diff options
Diffstat (limited to 'Presence')
-rw-r--r-- | Presence/ConsoleWriter.hs | 2 | ||||
-rw-r--r-- | Presence/Nesting.hs | 12 | ||||
-rw-r--r-- | Presence/XMPPServer.hs | 11 |
3 files changed, 14 insertions, 11 deletions
diff --git a/Presence/ConsoleWriter.hs b/Presence/ConsoleWriter.hs index b5040ba7..e755b27f 100644 --- a/Presence/ConsoleWriter.hs +++ b/Presence/ConsoleWriter.hs | |||
@@ -16,7 +16,7 @@ import Control.Concurrent.STM | |||
16 | import Data.Monoid | 16 | import Data.Monoid |
17 | import Data.Char | 17 | import Data.Char |
18 | import Data.Maybe | 18 | import Data.Maybe |
19 | import System.Environment | 19 | import System.Environment hiding (setEnv) |
20 | import System.Process ( rawSystem ) | 20 | import System.Process ( rawSystem ) |
21 | import System.Exit ( ExitCode(ExitSuccess) ) | 21 | import System.Exit ( ExitCode(ExitSuccess) ) |
22 | import System.Posix.Env ( setEnv ) | 22 | import System.Posix.Env ( setEnv ) |
diff --git a/Presence/Nesting.hs b/Presence/Nesting.hs index dd0e4113..720237fd 100644 --- a/Presence/Nesting.hs +++ b/Presence/Nesting.hs | |||
@@ -6,7 +6,7 @@ import Data.Conduit | |||
6 | import Data.Conduit.Lift | 6 | import Data.Conduit.Lift |
7 | import Data.XML.Types | 7 | import Data.XML.Types |
8 | import qualified Data.Text as S | 8 | import qualified Data.Text as S |
9 | import Control.Monad.State | 9 | import Control.Monad.State.Strict |
10 | import qualified Data.List as List | 10 | import qualified Data.List as List |
11 | 11 | ||
12 | type Lang = S.Text | 12 | type Lang = S.Text |
@@ -30,11 +30,10 @@ nesting = lift $ (return . nestingLevel) =<< get | |||
30 | xmlLang :: Monad m => NestingXML o m (Maybe Lang) | 30 | xmlLang :: Monad m => NestingXML o m (Maybe Lang) |
31 | xmlLang = fmap (fmap snd . top . langStack) (lift get) | 31 | xmlLang = fmap (fmap snd . top . langStack) (lift get) |
32 | where | 32 | where |
33 | top ( a :! as ) = Just a | 33 | top ( a :! _as ) = Just a |
34 | top _ = Nothing | 34 | top _ = Nothing |
35 | 35 | ||
36 | 36 | trackNesting :: Monad m => Conduit Event (StateT XMLState m) Event | |
37 | trackNesting :: Monad m => ConduitM Event Event (StateT XMLState m) () | ||
38 | trackNesting = awaitForever doit | 37 | trackNesting = awaitForever doit |
39 | where | 38 | where |
40 | doit xml = do | 39 | doit xml = do |
@@ -61,7 +60,7 @@ lookupLang attrs = | |||
61 | 60 | ||
62 | 61 | ||
63 | awaitCloser :: Monad m => Int -> NestingXML o m () | 62 | awaitCloser :: Monad m => Int -> NestingXML o m () |
64 | awaitCloser lvl = do | 63 | awaitCloser lvl = |
65 | fix $ \loop -> do | 64 | fix $ \loop -> do |
66 | lvl' <- nesting | 65 | lvl' <- nesting |
67 | when (lvl' >= lvl) $ do | 66 | when (lvl' >= lvl) $ do |
@@ -80,8 +79,7 @@ nextElement = do | |||
80 | xml <- await | 79 | xml <- await |
81 | case xml of | 80 | case xml of |
82 | Nothing -> return Nothing | 81 | Nothing -> return Nothing |
83 | Just (EventBeginElement _ _) -> do | 82 | Just (EventBeginElement _ _) -> return xml |
84 | return xml | ||
85 | Just _ -> do | 83 | Just _ -> do |
86 | lvl' <- nesting | 84 | lvl' <- nesting |
87 | if (lvl'>=lvl) then loop | 85 | if (lvl'>=lvl) then loop |
diff --git a/Presence/XMPPServer.hs b/Presence/XMPPServer.hs index 1f88fb9c..6176bbe6 100644 --- a/Presence/XMPPServer.hs +++ b/Presence/XMPPServer.hs | |||
@@ -51,7 +51,7 @@ import qualified Data.Conduit.List as CL | |||
51 | import qualified Data.Conduit.Binary as CB | 51 | import qualified Data.Conduit.Binary as CB |
52 | import Data.Conduit.Blaze (builderToByteStringFlush) | 52 | import Data.Conduit.Blaze (builderToByteStringFlush) |
53 | 53 | ||
54 | import qualified Text.XML.Stream.Render as XML | 54 | import qualified Text.XML.Stream.Render as XML hiding (content) |
55 | import qualified Text.XML.Stream.Parse as XML | 55 | import qualified Text.XML.Stream.Parse as XML |
56 | import Data.XML.Types as XML | 56 | import Data.XML.Types as XML |
57 | import Data.Maybe | 57 | import Data.Maybe |
@@ -77,6 +77,7 @@ import EventUtil | |||
77 | import ControlMaybe | 77 | import ControlMaybe |
78 | import LockedChan | 78 | import LockedChan |
79 | import PeerResolve | 79 | import PeerResolve |
80 | import Blaze.ByteString.Builder (Builder) | ||
80 | 81 | ||
81 | peerport :: PortNumber | 82 | peerport :: PortNumber |
82 | peerport = 5269 | 83 | peerport = 5269 |
@@ -247,13 +248,17 @@ wlog s = putStrLn s >> hFlush stdout | |||
247 | wlogb :: ByteString -> IO () | 248 | wlogb :: ByteString -> IO () |
248 | wlogb s = Strict8.putStrLn s >> hFlush stdout | 249 | wlogb s = Strict8.putStrLn s >> hFlush stdout |
249 | 250 | ||
251 | renderBuilderFlush :: Monad m => XML.RenderSettings -> Conduit (Flush Event) m (Flush Builder) | ||
252 | renderBuilderFlush = undefined | ||
253 | |||
250 | xmlStream :: ReadCommand -> WriteCommand -> ( Source IO XML.Event | 254 | xmlStream :: ReadCommand -> WriteCommand -> ( Source IO XML.Event |
251 | , Sink (Flush XML.Event) IO () ) | 255 | , Sink (Flush XML.Event) IO () ) |
252 | xmlStream conread conwrite = (xsrc,xsnk) | 256 | xmlStream conread conwrite = (xsrc,xsnk) |
253 | where | 257 | where |
254 | xsrc = src $= XML.parseBytes XML.def | 258 | xsrc = src $= XML.parseBytes XML.def |
259 | xsnk :: Sink (Flush Event) IO () | ||
255 | xsnk = -- XML.renderBytes XML.def =$ snk | 260 | xsnk = -- XML.renderBytes XML.def =$ snk |
256 | XML.renderBuilderFlush XML.def | 261 | renderBuilderFlush XML.def |
257 | =$= builderToByteStringFlush | 262 | =$= builderToByteStringFlush |
258 | =$= discardFlush | 263 | =$= discardFlush |
259 | =$ snk | 264 | =$ snk |
@@ -271,7 +276,7 @@ xmlStream conread conwrite = (xsrc,xsnk) | |||
271 | (\v -> yield v >> src) | 276 | (\v -> yield v >> src) |
272 | v | 277 | v |
273 | snk = awaitForever $ liftIO . conwrite | 278 | snk = awaitForever $ liftIO . conwrite |
274 | 279 | ||
275 | 280 | ||
276 | type FlagCommand = STM Bool | 281 | type FlagCommand = STM Bool |
277 | type ReadCommand = IO (Maybe ByteString) | 282 | type ReadCommand = IO (Maybe ByteString) |