diff options
-rw-r--r-- | Connection/Tcp.hs | 10 | ||||
-rw-r--r-- | Presence/Nesting.hs | 26 | ||||
-rw-r--r-- | Presence/XMPPServer.hs | 74 |
3 files changed, 54 insertions, 56 deletions
diff --git a/Connection/Tcp.hs b/Connection/Tcp.hs index 35083198..97b78eda 100644 --- a/Connection/Tcp.hs +++ b/Connection/Tcp.hs | |||
@@ -26,7 +26,7 @@ module Connection.Tcp | |||
26 | 26 | ||
27 | import Data.ByteString (ByteString,hGetNonBlocking) | 27 | import Data.ByteString (ByteString,hGetNonBlocking) |
28 | import qualified Data.ByteString.Char8 as S -- ( hPutStrLn, hPutStr, pack) | 28 | import qualified Data.ByteString.Char8 as S -- ( hPutStrLn, hPutStr, pack) |
29 | import Data.Conduit ( Source, Sink, Flush ) | 29 | import Data.Conduit ( ConduitT, Void, Flush ) |
30 | #if MIN_VERSION_containers(0,5,0) | 30 | #if MIN_VERSION_containers(0,5,0) |
31 | import qualified Data.Map.Strict as Map | 31 | import qualified Data.Map.Strict as Map |
32 | import Data.Map.Strict (Map) | 32 | import Data.Map.Strict (Map) |
@@ -168,7 +168,7 @@ data InOrOut = In | Out | |||
168 | -- | These events may be read from 'serverEvent' TChannel. | 168 | -- | These events may be read from 'serverEvent' TChannel. |
169 | -- | 169 | -- |
170 | data ConnectionEvent b | 170 | data ConnectionEvent b |
171 | = Connection (STM Bool) (Source IO b) (Sink (Flush b) IO ()) | 171 | = Connection (STM Bool) (ConduitT () b IO ()) (ConduitT (Flush b) Void IO ()) |
172 | -- ^ A new connection was established | 172 | -- ^ A new connection was established |
173 | | ConnectFailure SockAddr | 173 | | ConnectFailure SockAddr |
174 | -- ^ A 'Connect' command failed. | 174 | -- ^ A 'Connect' command failed. |
@@ -249,7 +249,7 @@ server :: | |||
249 | -- forall (m :: * -> *) a u conkey releaseKey. | 249 | -- forall (m :: * -> *) a u conkey releaseKey. |
250 | (Show conkey, MonadIO m, Ord conkey) => | 250 | (Show conkey, MonadIO m, Ord conkey) => |
251 | Allocate releaseKey m | 251 | Allocate releaseKey m |
252 | -> ( IO (Maybe ByteString) -> (ByteString -> IO Bool) -> ( Source IO x, Sink (Flush x) IO () ) ) | 252 | -> ( IO (Maybe ByteString) -> (ByteString -> IO Bool) -> ( ConduitT () x IO (), ConduitT (Flush x) Void IO () ) ) |
253 | -> m (Server conkey u releaseKey x) | 253 | -> m (Server conkey u releaseKey x) |
254 | server allocate sessionConduits = do | 254 | server allocate sessionConduits = do |
255 | (key,cmds) <- allocate (atomically newEmptyTMVar) | 255 | (key,cmds) <- allocate (atomically newEmptyTMVar) |
@@ -438,7 +438,7 @@ socketFamily (SockAddrInet6 _ _ _ _) = AF_INET6 | |||
438 | socketFamily (SockAddrUnix _) = AF_UNIX | 438 | socketFamily (SockAddrUnix _) = AF_UNIX |
439 | 439 | ||
440 | 440 | ||
441 | conevent :: ( IO (Maybe ByteString) -> (ByteString -> IO Bool) -> ( Source IO x, Sink (Flush x) IO () ) ) | 441 | conevent :: ( IO (Maybe ByteString) -> (ByteString -> IO Bool) -> ( ConduitT () x IO (), ConduitT (Flush x) Void IO () ) ) |
442 | -> ConnectionState | 442 | -> ConnectionState |
443 | -> ConnectionEvent x | 443 | -> ConnectionEvent x |
444 | conevent sessionConduits con = Connection pingflag read write | 444 | conevent sessionConduits con = Connection pingflag read write |
@@ -448,7 +448,7 @@ conevent sessionConduits con = Connection pingflag read write | |||
448 | 448 | ||
449 | newConnection :: Ord a | 449 | newConnection :: Ord a |
450 | => Server a u1 releaseKey x | 450 | => Server a u1 releaseKey x |
451 | -> ( IO (Maybe ByteString) -> (ByteString -> IO Bool) -> ( Source IO x, Sink (Flush x) IO () ) ) | 451 | -> ( IO (Maybe ByteString) -> (ByteString -> IO Bool) -> ( ConduitT () x IO (), ConduitT (Flush x) Void IO () ) ) |
452 | -> ConnectionParameters conkey u | 452 | -> ConnectionParameters conkey u |
453 | -> a | 453 | -> a |
454 | -> u1 | 454 | -> u1 |
diff --git a/Presence/Nesting.hs b/Presence/Nesting.hs index 720237fd..cf47c9fc 100644 --- a/Presence/Nesting.hs +++ b/Presence/Nesting.hs | |||
@@ -1,19 +1,19 @@ | |||
1 | {-# LANGUAGE FlexibleContexts #-} | ||
1 | {-# LANGUAGE OverloadedStrings #-} | 2 | {-# LANGUAGE OverloadedStrings #-} |
2 | {-# LANGUAGE FlexibleContexts #-} | ||
3 | module Nesting where | 3 | module Nesting where |
4 | 4 | ||
5 | import Control.Monad.State.Strict | ||
5 | import Data.Conduit | 6 | import Data.Conduit |
6 | import Data.Conduit.Lift | 7 | import Data.Conduit.Lift |
7 | import Data.XML.Types | ||
8 | import qualified Data.Text as S | ||
9 | import Control.Monad.State.Strict | ||
10 | import qualified Data.List as List | 8 | import qualified Data.List as List |
9 | import qualified Data.Text as S | ||
10 | import Data.XML.Types | ||
11 | 11 | ||
12 | type Lang = S.Text | 12 | type Lang = S.Text |
13 | 13 | ||
14 | data StrictList a = a :! !(StrictList a) | StrictNil | 14 | data StrictList a = a :! !(StrictList a) | StrictNil |
15 | 15 | ||
16 | data XMLState = XMLState { | 16 | data XMLState = XMLState { |
17 | nestingLevel :: Int, | 17 | nestingLevel :: Int, |
18 | langStack :: StrictList (Int,Lang) | 18 | langStack :: StrictList (Int,Lang) |
19 | } | 19 | } |
@@ -21,8 +21,8 @@ data XMLState = XMLState { | |||
21 | type NestingXML o m a = ConduitM Event o (StateT XMLState m) a | 21 | type NestingXML o m a = ConduitM Event o (StateT XMLState m) a |
22 | 22 | ||
23 | doNestingXML :: Monad m => NestingXML o m r -> ConduitM Event o m r | 23 | doNestingXML :: Monad m => NestingXML o m r -> ConduitM Event o m r |
24 | doNestingXML m = | 24 | doNestingXML m = |
25 | evalStateC (XMLState 0 StrictNil) (trackNesting =$= m) | 25 | evalStateC (XMLState 0 StrictNil) (trackNesting .| m) |
26 | 26 | ||
27 | nesting :: Monad m => NestingXML o m Int | 27 | nesting :: Monad m => NestingXML o m Int |
28 | nesting = lift $ (return . nestingLevel) =<< get | 28 | nesting = lift $ (return . nestingLevel) =<< get |
@@ -33,18 +33,18 @@ xmlLang = fmap (fmap snd . top . langStack) (lift get) | |||
33 | top ( a :! _as ) = Just a | 33 | top ( a :! _as ) = Just a |
34 | top _ = Nothing | 34 | top _ = Nothing |
35 | 35 | ||
36 | trackNesting :: Monad m => Conduit Event (StateT XMLState m) Event | 36 | trackNesting :: Monad m => ConduitM Event Event (StateT XMLState m) () |
37 | trackNesting = awaitForever doit | 37 | trackNesting = awaitForever doit |
38 | where | 38 | where |
39 | doit xml = do | 39 | doit xml = do |
40 | XMLState lvl langs <- lift get | 40 | XMLState lvl langs <- lift get |
41 | lift . put $ case xml of | 41 | lift . put $ case xml of |
42 | EventBeginElement _ attrs -> | 42 | EventBeginElement _ attrs -> |
43 | case lookupLang attrs of | 43 | case lookupLang attrs of |
44 | Nothing -> XMLState (lvl+1) langs | 44 | Nothing -> XMLState (lvl+1) langs |
45 | Just lang -> XMLState (lvl+1) ( (lvl+1,lang) :! langs) | 45 | Just lang -> XMLState (lvl+1) ( (lvl+1,lang) :! langs) |
46 | EventEndElement _ -> | 46 | EventEndElement _ -> |
47 | case langs of | 47 | case langs of |
48 | (llvl,_) :! ls | llvl==lvl -> XMLState (lvl-1) ls | 48 | (llvl,_) :! ls | llvl==lvl -> XMLState (lvl-1) ls |
49 | _ | otherwise -> XMLState (lvl-1) langs | 49 | _ | otherwise -> XMLState (lvl-1) langs |
50 | _ -> XMLState lvl langs | 50 | _ -> XMLState lvl langs |
@@ -82,7 +82,5 @@ nextElement = do | |||
82 | Just (EventBeginElement _ _) -> return xml | 82 | Just (EventBeginElement _ _) -> return xml |
83 | Just _ -> do | 83 | Just _ -> do |
84 | lvl' <- nesting | 84 | lvl' <- nesting |
85 | if (lvl'>=lvl) then loop | 85 | if (lvl'>=lvl) then loop |
86 | else return Nothing | 86 | else return Nothing |
87 | |||
88 | |||
diff --git a/Presence/XMPPServer.hs b/Presence/XMPPServer.hs index 24cfd055..2345cb67 100644 --- a/Presence/XMPPServer.hs +++ b/Presence/XMPPServer.hs | |||
@@ -297,11 +297,11 @@ wlog = dput XJabber | |||
297 | wlogb :: ByteString -> IO () | 297 | wlogb :: ByteString -> IO () |
298 | wlogb = wlog . Strict8.unpack | 298 | wlogb = wlog . Strict8.unpack |
299 | 299 | ||
300 | flushPassThrough :: Monad m => Conduit a m b -> Conduit (Flush a) m (Flush b) | 300 | flushPassThrough :: Monad m => ConduitT a b m () -> ConduitT (Flush a) (Flush b) m () |
301 | flushPassThrough c = getZipConduit $ ZipConduit (onlyChunks =$= mapOutput Chunk c) <* ZipConduit onlyFlushes | 301 | flushPassThrough c = getZipConduit $ ZipConduit (onlyChunks .| mapOutput Chunk c) <* ZipConduit onlyFlushes |
302 | where | 302 | where |
303 | onlyChunks :: Monad m => Conduit (Flush a) m a | 303 | onlyChunks :: Monad m => ConduitT (Flush a) a m () |
304 | onlyFlushes :: Monad m => Conduit (Flush a) m (Flush b) | 304 | onlyFlushes :: Monad m => ConduitT (Flush a) (Flush b) m () |
305 | onlyChunks = awaitForever yieldChunk | 305 | onlyChunks = awaitForever yieldChunk |
306 | onlyFlushes = awaitForever yieldFlush | 306 | onlyFlushes = awaitForever yieldFlush |
307 | yieldFlush Flush = yield Flush | 307 | yieldFlush Flush = yield Flush |
@@ -309,17 +309,17 @@ flushPassThrough c = getZipConduit $ ZipConduit (onlyChunks =$= mapOutput Chunk | |||
309 | yieldChunk (Chunk x) = yield x | 309 | yieldChunk (Chunk x) = yield x |
310 | yieldChunk _ = return () | 310 | yieldChunk _ = return () |
311 | 311 | ||
312 | xmlStream :: ReadCommand -> WriteCommand -> ( Source IO XML.Event | 312 | xmlStream :: ReadCommand -> WriteCommand -> ( ConduitT () XML.Event IO () |
313 | , Sink (Flush XML.Event) IO () ) | 313 | , ConduitT (Flush XML.Event) Void IO () ) |
314 | xmlStream conread conwrite = (xsrc,xsnk) | 314 | xmlStream conread conwrite = (xsrc,xsnk) |
315 | where | 315 | where |
316 | xsrc = src $= XML.parseBytes XML.def | 316 | xsrc = src .| XML.parseBytes XML.def |
317 | xsnk :: Sink (Flush Event) IO () | 317 | xsnk :: ConduitT (Flush Event) Void IO () |
318 | xsnk = -- XML.renderBytes XML.def =$ snk | 318 | xsnk = -- XML.renderBytes XML.def =$ snk |
319 | flushPassThrough (XML.renderBuilder XML.def) | 319 | flushPassThrough (XML.renderBuilder XML.def) |
320 | =$= builderToByteStringFlush | 320 | .| builderToByteStringFlush |
321 | =$= discardFlush | 321 | .| discardFlush |
322 | =$ snk | 322 | .| snk |
323 | where | 323 | where |
324 | discardFlush :: Monad m => ConduitM (Flush a) a m () | 324 | discardFlush :: Monad m => ConduitM (Flush a) a m () |
325 | discardFlush = awaitForever yieldChunk | 325 | discardFlush = awaitForever yieldChunk |
@@ -365,8 +365,8 @@ copyToChannel f chan closer_stack = awaitForever copy | |||
365 | prettyPrint :: ByteString -> ConduitM Event Void IO () | 365 | prettyPrint :: ByteString -> ConduitM Event Void IO () |
366 | prettyPrint prefix = | 366 | prettyPrint prefix = |
367 | XML.renderBytes (XML.def { XML.rsPretty=True }) | 367 | XML.renderBytes (XML.def { XML.rsPretty=True }) |
368 | =$= CB.lines | 368 | .| CB.lines |
369 | =$ CL.mapM_ (wlogb . (prefix <>)) | 369 | .| CL.mapM_ (wlogb . (prefix <>)) |
370 | 370 | ||
371 | swapNamespace :: Monad m => Text -> Text -> ConduitM Event Event m () | 371 | swapNamespace :: Monad m => Text -> Text -> ConduitM Event Event m () |
372 | swapNamespace old new = awaitForever (yield . swapit old new) | 372 | swapNamespace old new = awaitForever (yield . swapit old new) |
@@ -403,14 +403,14 @@ fixHeaders Stanza { stanzaType=typ, stanzaTo=mto, stanzaFrom=mfrom } = do | |||
403 | delAttrib akey as = filter ((/=akey) . fst) as | 403 | delAttrib akey as = filter ((/=akey) . fst) as |
404 | 404 | ||
405 | conduitToChan | 405 | conduitToChan |
406 | :: Conduit () IO Event | 406 | :: ConduitT () Event IO () |
407 | -> IO (LockedChan Event, TVar (Maybe [Event]), TMVar a) | 407 | -> IO (LockedChan Event, TVar (Maybe [Event]), TMVar a) |
408 | conduitToChan c = do | 408 | conduitToChan c = do |
409 | chan <- atomically newLockedChan | 409 | chan <- atomically newLockedChan |
410 | clsrs <- atomically $ newTVar (Just []) | 410 | clsrs <- atomically $ newTVar (Just []) |
411 | quitvar <- atomically $ newEmptyTMVar | 411 | quitvar <- atomically $ newEmptyTMVar |
412 | forkIO $ do | 412 | forkIO $ do |
413 | c =$= copyToChannel id chan clsrs $$ awaitForever (const $ return ()) | 413 | runConduit $ c .| copyToChannel id chan clsrs .| awaitForever (const $ return ()) |
414 | atomically $ writeTVar clsrs Nothing | 414 | atomically $ writeTVar clsrs Nothing |
415 | return (chan,clsrs,quitvar) | 415 | return (chan,clsrs,quitvar) |
416 | 416 | ||
@@ -419,7 +419,7 @@ conduitToStanza | |||
419 | -> Maybe Text -- ^ id | 419 | -> Maybe Text -- ^ id |
420 | -> Maybe Text -- ^ from | 420 | -> Maybe Text -- ^ from |
421 | -> Maybe Text -- ^ to | 421 | -> Maybe Text -- ^ to |
422 | -> Conduit () IO Event | 422 | -> ConduitT () Event IO () |
423 | -> IO Stanza | 423 | -> IO Stanza |
424 | conduitToStanza stype mid from to c = do | 424 | conduitToStanza stype mid from to c = do |
425 | (chan,clsrs,quitvar) <- conduitToChan c | 425 | (chan,clsrs,quitvar) <- conduitToChan c |
@@ -476,7 +476,7 @@ sendModifiedStanzaToPeer stanza chan = do | |||
476 | where | 476 | where |
477 | old = "jabber:client" | 477 | old = "jabber:client" |
478 | new = "jabber:server" | 478 | new = "jabber:server" |
479 | c = stanzaToConduit stanza =$= swapNamespace old new =$= fixHeaders stanza | 479 | c = stanzaToConduit stanza .| swapNamespace old new .| fixHeaders stanza |
480 | processedType (Error cond tag) = Error cond (swapit old new tag) | 480 | processedType (Error cond tag) = Error cond (swapit old new tag) |
481 | processedType x = x | 481 | processedType x = x |
482 | 482 | ||
@@ -498,7 +498,7 @@ sendModifiedStanzaToClient stanza chan = do | |||
498 | where | 498 | where |
499 | old = "jabber:server" | 499 | old = "jabber:server" |
500 | new = "jabber:client" | 500 | new = "jabber:client" |
501 | c = stanzaToConduit stanza =$= swapNamespace old new =$= fixHeaders stanza | 501 | c = stanzaToConduit stanza .| swapNamespace old new .| fixHeaders stanza |
502 | processedType (Error cond tag) = Error cond (swapit old new tag) | 502 | processedType (Error cond tag) = Error cond (swapit old new tag) |
503 | processedType x = x | 503 | processedType x = x |
504 | 504 | ||
@@ -939,7 +939,7 @@ xmppInbound cdta xmpp (namespace,tellmyname,tellyourname,mkorigin) pingflag stan | |||
939 | liftIO . atomically $ do | 939 | liftIO . atomically $ do |
940 | writeLChan chan stanzaTag | 940 | writeLChan chan stanzaTag |
941 | modifyTVar' clsrs (fmap (closerFor stanzaTag:)) | 941 | modifyTVar' clsrs (fmap (closerFor stanzaTag:)) |
942 | copyToChannel id chan clsrs =$= do | 942 | copyToChannel id chan clsrs .| do |
943 | let mid = lookupAttrib "id" $ tagAttrs stanzaTag | 943 | let mid = lookupAttrib "id" $ tagAttrs stanzaTag |
944 | mfrom = lookupAttrib "from" $ tagAttrs stanzaTag | 944 | mfrom = lookupAttrib "from" $ tagAttrs stanzaTag |
945 | mto = lookupAttrib "to" $ tagAttrs stanzaTag | 945 | mto = lookupAttrib "to" $ tagAttrs stanzaTag |
@@ -1218,7 +1218,7 @@ slotsToSource :: | |||
1218 | -> TVar (Maybe (StanzaWrap XML.Event)) | 1218 | -> TVar (Maybe (StanzaWrap XML.Event)) |
1219 | -> TVar Bool | 1219 | -> TVar Bool |
1220 | -> TMVar () | 1220 | -> TMVar () |
1221 | -> Source IO (Flush XML.Event) | 1221 | -> ConduitT () (Flush XML.Event) IO () |
1222 | slotsToSource slots nesting lastStanza needsFlush rdone = | 1222 | slotsToSource slots nesting lastStanza needsFlush rdone = |
1223 | fix $ \slot_src -> join . lift . atomically $ foldr1 orElse | 1223 | fix $ \slot_src -> join . lift . atomically $ foldr1 orElse |
1224 | [Slotted.pull slots >>= \x -> do | 1224 | [Slotted.pull slots >>= \x -> do |
@@ -1255,11 +1255,11 @@ forkConnection :: Server PeerAddress ConnectionData releaseKey XML.Event | |||
1255 | -> PeerAddress -- SockAddr (XXX(what?): remote for peer, local for client) | 1255 | -> PeerAddress -- SockAddr (XXX(what?): remote for peer, local for client) |
1256 | -> ConnectionData | 1256 | -> ConnectionData |
1257 | -> FlagCommand | 1257 | -> FlagCommand |
1258 | -> Source IO XML.Event | 1258 | -> ConduitT () XML.Event IO () |
1259 | -> Sink (Flush XML.Event) IO () | 1259 | -> ConduitT (Flush XML.Event) Void IO () |
1260 | -> TChan Stanza | 1260 | -> TChan Stanza |
1261 | -> MVar () | 1261 | -> MVar () |
1262 | -> IO (TChan Stanza) | 1262 | -> IO (TChan Stanza) |
1263 | forkConnection sv xmpp saddr cdta pingflag src snk stanzas pp_mvar = do | 1263 | forkConnection sv xmpp saddr cdta pingflag src snk stanzas pp_mvar = do |
1264 | let auxAddr = cdAddr cdta | 1264 | let auxAddr = cdAddr cdta |
1265 | clientOrServer@(namespace,tellmyname,telltheirname,_) = case auxAddr of | 1265 | clientOrServer@(namespace,tellmyname,telltheirname,_) = case auxAddr of |
@@ -1283,7 +1283,7 @@ forkConnection sv xmpp saddr cdta pingflag src snk stanzas pp_mvar = do | |||
1283 | nesting <- atomically $ newTVar 0 | 1283 | nesting <- atomically $ newTVar 0 |
1284 | let _ = slots :: Slotted.UpdateStream XMPPState (Either (StanzaWrap XML.Event) XML.Event) | 1284 | let _ = slots :: Slotted.UpdateStream XMPPState (Either (StanzaWrap XML.Event) XML.Event) |
1285 | let greet_src = do | 1285 | let greet_src = do |
1286 | CL.sourceList (greet' namespace me) =$= CL.map Chunk | 1286 | CL.sourceList (greet' namespace me) .| CL.map Chunk |
1287 | yield Flush | 1287 | yield Flush |
1288 | slot_src = slotsToSource slots nesting lastStanza needsFlush rdone | 1288 | slot_src = slotsToSource slots nesting lastStanza needsFlush rdone |
1289 | -- client.PeerAddress {peerAddress = [::1]:5222} | 1289 | -- client.PeerAddress {peerAddress = [::1]:5222} |
@@ -1302,7 +1302,7 @@ forkConnection sv xmpp saddr cdta pingflag src snk stanzas pp_mvar = do | |||
1302 | -- Read all slots-queued XML events or stanzas and yield them | 1302 | -- Read all slots-queued XML events or stanzas and yield them |
1303 | -- upstream. This should continue until the connection is | 1303 | -- upstream. This should continue until the connection is |
1304 | -- closed. | 1304 | -- closed. |
1305 | (greet_src >> slot_src) $$ snk | 1305 | runConduit $ (greet_src >> slot_src) .| snk |
1306 | 1306 | ||
1307 | -- Connection is now closed. Here we handle any unsent stanzas. | 1307 | -- Connection is now closed. Here we handle any unsent stanzas. |
1308 | last <- atomically $ readTVar lastStanza | 1308 | last <- atomically $ readTVar lastStanza |
@@ -1360,7 +1360,7 @@ forkConnection sv xmpp saddr cdta pingflag src snk stanzas pp_mvar = do | |||
1360 | Left _ -> "P" | 1360 | Left _ -> "P" |
1361 | wlog "" | 1361 | wlog "" |
1362 | liftIO $ takeMVar pp_mvar | 1362 | liftIO $ takeMVar pp_mvar |
1363 | stanzaToConduit dup $$ prettyPrint typ | 1363 | runConduit $ stanzaToConduit dup .| prettyPrint typ |
1364 | liftIO $ putMVar pp_mvar () | 1364 | liftIO $ putMVar pp_mvar () |
1365 | -- wlog $ "hacks: "++show (stanzaId stanza) | 1365 | -- wlog $ "hacks: "++show (stanzaId stanza) |
1366 | case stanzaType stanza of | 1366 | case stanzaType stanza of |
@@ -1371,10 +1371,10 @@ forkConnection sv xmpp saddr cdta pingflag src snk stanzas pp_mvar = do | |||
1371 | -- wlog $ "cache id thread: " ++ show x | 1371 | -- wlog $ "cache id thread: " ++ show x |
1372 | atomically $ modifyTVar' msgids (take 3 . (x:)) | 1372 | atomically $ modifyTVar' msgids (take 3 . (x:)) |
1373 | _ -> return () | 1373 | _ -> return () |
1374 | stanzaToConduit stanza =$= wrapStanzaConduit stanza | 1374 | runConduit $ stanzaToConduit stanza .| wrapStanzaConduit stanza |
1375 | $$ awaitForever | 1375 | .| awaitForever |
1376 | -- TODO: PresenceStatus stanzas should be pushed to appropriate slots | 1376 | -- TODO: PresenceStatus stanzas should be pushed to appropriate slots |
1377 | $ liftIO . atomically . Slotted.push slots Nothing | 1377 | (liftIO . atomically . Slotted.push slots Nothing) |
1378 | case stanzaType stanza of | 1378 | case stanzaType stanza of |
1379 | Error err tag | tagName tag=="{jabber:client}message" -> do | 1379 | Error err tag | tagName tag=="{jabber:client}message" -> do |
1380 | wlog $ "handling Error hacks" | 1380 | wlog $ "handling Error hacks" |
@@ -1388,9 +1388,9 @@ forkConnection sv xmpp saddr cdta pingflag src snk stanzas pp_mvar = do | |||
1388 | when b $ do | 1388 | when b $ do |
1389 | let sim = simulateChatError err (stanzaFrom stanza) | 1389 | let sim = simulateChatError err (stanzaFrom stanza) |
1390 | wlog $ "sending simulated chat for error message." | 1390 | wlog $ "sending simulated chat for error message." |
1391 | CL.sourceList sim =$= wrapStanzaConduit stanza -- not quite right, but whatever | 1391 | runConduit $ CL.sourceList sim .| wrapStanzaConduit stanza -- not quite right, but whatever |
1392 | $$ awaitForever | 1392 | .| awaitForever |
1393 | $ liftIO . atomically . Slotted.push slots Nothing | 1393 | (liftIO . atomically . Slotted.push slots Nothing) |
1394 | Error e _ -> do | 1394 | Error e _ -> do |
1395 | wlog $ "no hacks for error: " ++ show e | 1395 | wlog $ "no hacks for error: " ++ show e |
1396 | _ -> return () | 1396 | _ -> return () |
@@ -1406,9 +1406,9 @@ forkConnection sv xmpp saddr cdta pingflag src snk stanzas pp_mvar = do | |||
1406 | mapM_ (atomically . Slotted.push slots (Just $ PingSlot)) | 1406 | mapM_ (atomically . Slotted.push slots (Just $ PingSlot)) |
1407 | ping | 1407 | ping |
1408 | wlog "" | 1408 | wlog "" |
1409 | CL.sourceList ping0 $$ prettyPrint $ case auxAddr of | 1409 | runConduit $ CL.sourceList ping0 .| prettyPrint (case auxAddr of |
1410 | Right _ -> "C<-Ping" | 1410 | Right _ -> "C<-Ping" |
1411 | Left _ -> "P<-Ping " | 1411 | Left _ -> "P<-Ping ") |
1412 | loop | 1412 | loop |
1413 | ,readTMVar rdone >> return (return ()) | 1413 | ,readTMVar rdone >> return (return ()) |
1414 | ] | 1414 | ] |
@@ -1417,7 +1417,7 @@ forkConnection sv xmpp saddr cdta pingflag src snk stanzas pp_mvar = do | |||
1417 | forkIO $ do | 1417 | forkIO $ do |
1418 | myThreadId >>= flip labelThread (lbl "xmpp-reader.") | 1418 | myThreadId >>= flip labelThread (lbl "xmpp-reader.") |
1419 | -- src $$ awaitForever (lift . putStrLn . takeWhile (/=' ') . show) | 1419 | -- src $$ awaitForever (lift . putStrLn . takeWhile (/=' ') . show) |
1420 | src $$ xmppInbound cdta xmpp clientOrServer pingflag stanzas output rdone | 1420 | runConduit $ src .| xmppInbound cdta xmpp clientOrServer pingflag stanzas output rdone |
1421 | atomically $ putTMVar rdone () | 1421 | atomically $ putTMVar rdone () |
1422 | wlog $ "end reader fork: " ++ lbl "" | 1422 | wlog $ "end reader fork: " ++ lbl "" |
1423 | return output | 1423 | return output |
@@ -1764,7 +1764,7 @@ monitor sv params xmpp = do | |||
1764 | let rsc = unsplitJID (n,hostname,r) where (n,_,r) = splitJID rsc0 | 1764 | let rsc = unsplitJID (n,hostname,r) where (n,_,r) = splitJID rsc0 |
1765 | let reply = iq_bind_reply (stanzaId stanza) rsc | 1765 | let reply = iq_bind_reply (stanzaId stanza) rsc |
1766 | -- sendReply quitVar SetResource reply replyto | 1766 | -- sendReply quitVar SetResource reply replyto |
1767 | let requestVersion :: Producer IO XML.Event | 1767 | let requestVersion :: ConduitT i XML.Event IO () |
1768 | requestVersion = do | 1768 | requestVersion = do |
1769 | yield $ EventBeginElement "{jabber:client}iq" | 1769 | yield $ EventBeginElement "{jabber:client}iq" |
1770 | [ attr "to" rsc | 1770 | [ attr "to" rsc |
@@ -1872,7 +1872,7 @@ monitor sv params xmpp = do | |||
1872 | PeerOrigin {} -> "P" | 1872 | PeerOrigin {} -> "P" |
1873 | wlog "" | 1873 | wlog "" |
1874 | liftIO $ takeMVar pp_mvar | 1874 | liftIO $ takeMVar pp_mvar |
1875 | stanzaToConduit dup $$ prettyPrint typ | 1875 | runConduit $ stanzaToConduit dup .| prettyPrint typ |
1876 | liftIO $ putMVar pp_mvar () | 1876 | liftIO $ putMVar pp_mvar () |
1877 | ] | 1877 | ] |
1878 | action | 1878 | action |