summaryrefslogtreecommitdiff
path: root/xmppServer.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-03-06 23:04:03 -0500
committerjoe <joe@jerkface.net>2014-03-06 23:04:03 -0500
commitd80586526dee406e32340068434efe3e24f8143c (patch)
tree227903b5405f1851cd44111f5dacaa0de6e8fb91 /xmppServer.hs
parente0e39465f0e3816a46d3ee3f3ba8a02d597d39e8 (diff)
* Set "interested" flag when roster requested.
* Avoid sending presence status unless "available" flag set.
Diffstat (limited to 'xmppServer.hs')
-rw-r--r--xmppServer.hs19
1 files changed, 13 insertions, 6 deletions
diff --git a/xmppServer.hs b/xmppServer.hs
index 30ce774d..35d18e92 100644
--- a/xmppServer.hs
+++ b/xmppServer.hs
@@ -458,6 +458,16 @@ deliverMessage state fail msg =
458 sendModifiedStanzaToClient dup 458 sendModifiedStanzaToClient dup
459 chan 459 chan
460 460
461
462setClientFlag state k flag =
463 atomically $ modifyTVar' (clients state)
464 $ Map.adjust
465 (\c -> c { clientFlags = clientFlags c .|. flag })
466 k
467
468informSentRoster state k = setClientFlag state k cf_interested
469
470
461-- | Send presence notification to subscribed peers. 471-- | Send presence notification to subscribed peers.
462-- Note that a full JID from address will be added to the 472-- Note that a full JID from address will be added to the
463-- stanza if it is not present. 473-- stanza if it is not present.
@@ -469,10 +479,7 @@ informClientPresence state k stanza = do
469 writeTVar (clientStatus cstate) $ Just dup 479 writeTVar (clientStatus cstate) $ Just dup
470 forClient state k (return ()) $ \client -> do 480 forClient state k (return ()) $ \client -> do
471 when (not $ clientIsAvailable client) $ do 481 when (not $ clientIsAvailable client) $ do
472 atomically $ modifyTVar' (clients state) 482 setClientFlag state k cf_available
473 $ Map.adjust
474 (\c -> c { clientFlags = clientFlags c .|. cf_available })
475 k
476 sendCachedPresence state k 483 sendCachedPresence state k
477 jids <- configText ConfigFiles.getSubscribers (clientUser client) 484 jids <- configText ConfigFiles.getSubscribers (clientUser client)
478 let hosts = map ((\(_,h,_)->h) . splitJID) jids 485 let hosts = map ((\(_,h,_)->h) . splitJID) jids
@@ -526,6 +533,7 @@ informPeerPresence state k stanza = do
526 return (ck,con,client) 533 return (ck,con,client)
527 putStrLn $ "xmppInformPeerPresence (length clients="++show (length clients)++")" 534 putStrLn $ "xmppInformPeerPresence (length clients="++show (length clients)++")"
528 forM_ clients $ \(ck,con,client) -> do 535 forM_ clients $ \(ck,con,client) -> do
536 when (clientIsAvailable client) $ do
529 froms <- do 537 froms <- do
530 let ClientKey laddr = ck 538 let ClientKey laddr = ck
531 (_,trip) <- multiplyJIDForClient laddr from 539 (_,trip) <- multiplyJIDForClient laddr from
@@ -628,12 +636,11 @@ main = runResourceT $ do
628 , xmppRosterSubscribers = rosterGetSubscribers state 636 , xmppRosterSubscribers = rosterGetSubscribers state
629 , xmppRosterSolicited = rosterGetSolicited state 637 , xmppRosterSolicited = rosterGetSolicited state
630 , xmppRosterOthers = rosterGetOthers state 638 , xmppRosterOthers = rosterGetOthers state
631 , xmppSubscribeToRoster = \k -> return () 639 , xmppSubscribeToRoster = informSentRoster state
632 , xmppDeliverMessage = deliverMessage state 640 , xmppDeliverMessage = deliverMessage state
633 , xmppInformClientPresence = informClientPresence state 641 , xmppInformClientPresence = informClientPresence state
634 , xmppInformPeerPresence = informPeerPresence state 642 , xmppInformPeerPresence = informPeerPresence state
635 , xmppAnswerProbe = answerProbe state 643 , xmppAnswerProbe = answerProbe state
636 -- , xmppSendCachedPresenceToClient = sendCachedPresence state
637 } 644 }
638 liftIO $ do 645 liftIO $ do
639 atomically $ putTMVar (server state) sv 646 atomically $ putTMVar (server state) sv