summaryrefslogtreecommitdiff
path: root/Presence/XMPP.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2013-07-20 20:08:12 -0400
committerjoe <joe@jerkface.net>2013-07-20 20:08:12 -0400
commit91f6d5730f0ceff2d640360e27be77101b425d3b (patch)
treeace67e37a5bec949ae4331aba695b06fd6d5bdfc /Presence/XMPP.hs
parentf48e0689821cb202c7b6c380ec5b75dd1b13ba93 (diff)
Progress toward respecting client's requeseted presence state.
Diffstat (limited to 'Presence/XMPP.hs')
-rw-r--r--Presence/XMPP.hs25
1 files changed, 25 insertions, 0 deletions
diff --git a/Presence/XMPP.hs b/Presence/XMPP.hs
index fb7d4204..756d300a 100644
--- a/Presence/XMPP.hs
+++ b/Presence/XMPP.hs
@@ -359,6 +359,28 @@ handleIQGet session cmdChan tag = do
359 req -> unhandledGet req 359 req -> unhandledGet req
360 360
361 361
362handleClientPresence session stanza = do
363 -- online (Available or Away)
364 let log = liftIO . debugL . ("(C) " <++>)
365 withJust (lookupAttrib "from" (tagAttrs stanza)) $ \jid -> do
366 -- cjid <- liftIO $ parseAddressJID (textToByteString jid)
367 let parseChildren stat = do
368 child <- nextElement
369 case child of
370 Just tag | tagName tag=="{jabber:server}show"
371 -> fmap toStat (lift content)
372 Just tag | otherwise -> parseChildren stat
373 Nothing -> return stat
374 toStat "away" = Away
375 toStat "xa" = ExtendedAway
376 toStat "dnd" = DoNotDisturb
377 toStat "chat" = Chatty
378
379 stat' <- parseChildren Available
380 liftIO $ setPresence session stat'
381 log $ "requesting presence: "<++>bshow stat'
382 return ()
383
362fromClient :: (MonadThrow m,MonadIO m, JabberClientSession session) => 384fromClient :: (MonadThrow m,MonadIO m, JabberClientSession session) =>
363 session -> TChan ClientCommands -> Sink XML.Event m () 385 session -> TChan ClientCommands -> Sink XML.Event m ()
364fromClient session cmdChan = doNestingXML $ do 386fromClient session cmdChan = doNestingXML $ do
@@ -395,6 +417,8 @@ fromClient session cmdChan = doNestingXML $ do
395 -> clientApprovesSubscription session stanza 417 -> clientApprovesSubscription session stanza
396 _ | stanza `isClientPresenceOf` presenceTypeUnsubscribed 418 _ | stanza `isClientPresenceOf` presenceTypeUnsubscribed
397 -> clientRejectsSubscription session stanza 419 -> clientRejectsSubscription session stanza
420 _ | stanza `isClientPresenceOf` presenceTypeOnline
421 -> handleClientPresence session stanza
398 _ | otherwise -> unhandledStanza 422 _ | otherwise -> unhandledStanza
399 423
400 awaitCloser stanza_lvl 424 awaitCloser stanza_lvl
@@ -672,6 +696,7 @@ isClientPresenceOf (EventBeginElement name attrs) testType
672 = True 696 = True
673isClientPresenceOf _ _ = False 697isClientPresenceOf _ _ = False
674 698
699
675handlePresenceProbe session stanza = do 700handlePresenceProbe session stanza = do
676 withJust (lookupAttrib "to" (tagAttrs stanza)) $ \to -> do 701 withJust (lookupAttrib "to" (tagAttrs stanza)) $ \to -> do
677 -- withJust (lookupAttrib "from" (tagAttrs stanza)) $ \from -> do 702 -- withJust (lookupAttrib "from" (tagAttrs stanza)) $ \from -> do