summaryrefslogtreecommitdiff
path: root/Presence
diff options
context:
space:
mode:
Diffstat (limited to 'Presence')
-rw-r--r--Presence/ConsoleWriter.hs2
-rw-r--r--Presence/Nesting.hs12
-rw-r--r--Presence/XMPPServer.hs11
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
16import Data.Monoid 16import Data.Monoid
17import Data.Char 17import Data.Char
18import Data.Maybe 18import Data.Maybe
19import System.Environment 19import System.Environment hiding (setEnv)
20import System.Process ( rawSystem ) 20import System.Process ( rawSystem )
21import System.Exit ( ExitCode(ExitSuccess) ) 21import System.Exit ( ExitCode(ExitSuccess) )
22import System.Posix.Env ( setEnv ) 22import 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
6import Data.Conduit.Lift 6import Data.Conduit.Lift
7import Data.XML.Types 7import Data.XML.Types
8import qualified Data.Text as S 8import qualified Data.Text as S
9import Control.Monad.State 9import Control.Monad.State.Strict
10import qualified Data.List as List 10import qualified Data.List as List
11 11
12type Lang = S.Text 12type Lang = S.Text
@@ -30,11 +30,10 @@ nesting = lift $ (return . nestingLevel) =<< get
30xmlLang :: Monad m => NestingXML o m (Maybe Lang) 30xmlLang :: Monad m => NestingXML o m (Maybe Lang)
31xmlLang = fmap (fmap snd . top . langStack) (lift get) 31xmlLang = 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 36trackNesting :: Monad m => Conduit Event (StateT XMLState m) Event
37trackNesting :: Monad m => ConduitM Event Event (StateT XMLState m) ()
38trackNesting = awaitForever doit 37trackNesting = awaitForever doit
39 where 38 where
40 doit xml = do 39 doit xml = do
@@ -61,7 +60,7 @@ lookupLang attrs =
61 60
62 61
63awaitCloser :: Monad m => Int -> NestingXML o m () 62awaitCloser :: Monad m => Int -> NestingXML o m ()
64awaitCloser lvl = do 63awaitCloser 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
51import qualified Data.Conduit.Binary as CB 51import qualified Data.Conduit.Binary as CB
52import Data.Conduit.Blaze (builderToByteStringFlush) 52import Data.Conduit.Blaze (builderToByteStringFlush)
53 53
54import qualified Text.XML.Stream.Render as XML 54import qualified Text.XML.Stream.Render as XML hiding (content)
55import qualified Text.XML.Stream.Parse as XML 55import qualified Text.XML.Stream.Parse as XML
56import Data.XML.Types as XML 56import Data.XML.Types as XML
57import Data.Maybe 57import Data.Maybe
@@ -77,6 +77,7 @@ import EventUtil
77import ControlMaybe 77import ControlMaybe
78import LockedChan 78import LockedChan
79import PeerResolve 79import PeerResolve
80import Blaze.ByteString.Builder (Builder)
80 81
81peerport :: PortNumber 82peerport :: PortNumber
82peerport = 5269 83peerport = 5269
@@ -247,13 +248,17 @@ wlog s = putStrLn s >> hFlush stdout
247wlogb :: ByteString -> IO () 248wlogb :: ByteString -> IO ()
248wlogb s = Strict8.putStrLn s >> hFlush stdout 249wlogb s = Strict8.putStrLn s >> hFlush stdout
249 250
251renderBuilderFlush :: Monad m => XML.RenderSettings -> Conduit (Flush Event) m (Flush Builder)
252renderBuilderFlush = undefined
253
250xmlStream :: ReadCommand -> WriteCommand -> ( Source IO XML.Event 254xmlStream :: ReadCommand -> WriteCommand -> ( Source IO XML.Event
251 , Sink (Flush XML.Event) IO () ) 255 , Sink (Flush XML.Event) IO () )
252xmlStream conread conwrite = (xsrc,xsnk) 256xmlStream 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
276type FlagCommand = STM Bool 281type FlagCommand = STM Bool
277type ReadCommand = IO (Maybe ByteString) 282type ReadCommand = IO (Maybe ByteString)