diff options
author | Joey Hess <joey@kitenet.net> | 2012-11-05 17:43:17 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-11-05 17:43:17 -0400 |
commit | a4667e3e8cb7fae50b0c2cb8bc1a46df0b289b6c (patch) | |
tree | 9f75d066b025e99f7015818ccbe143d70b5bbae7 /Assistant/XMPP/Buddies.hs | |
parent | dedc9790ef60b0965c0c34acd080ef8d4906e07a (diff) |
finished XMPP pairing!
This includes keeping track of which buddies we're pairing with, to know
which PairAck are legitimate.
Diffstat (limited to 'Assistant/XMPP/Buddies.hs')
-rw-r--r-- | Assistant/XMPP/Buddies.hs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Assistant/XMPP/Buddies.hs b/Assistant/XMPP/Buddies.hs index fe5d8c6a9..fdc307972 100644 --- a/Assistant/XMPP/Buddies.hs +++ b/Assistant/XMPP/Buddies.hs @@ -17,8 +17,8 @@ import qualified Data.Set as S import Data.Text (Text) import qualified Data.Text as T -genKey :: JID -> BuddyKey -genKey j = BuddyKey $ formatJID $ baseJID j +genBuddyKey :: JID -> BuddyKey +genBuddyKey j = BuddyKey $ formatJID $ baseJID j buddyName :: JID -> Text buddyName j = maybe (T.pack "") strNode (jidNode j) @@ -28,7 +28,7 @@ buddyName j = maybe (T.pack "") strNode (jidNode j) - If the buddy has no clients at all anymore, returns Nothing. -} buddySummary :: Buddy -> Maybe (Text, Bool, Bool, BuddyKey) buddySummary b = case clients of - ((Client j):_) -> Just (buddyName j, away, canpair, genKey j) + ((Client j):_) -> Just (buddyName j, away, canpair, genBuddyKey j) [] -> Nothing where away = S.null (buddyPresent b) && S.null (buddyAssistants b) @@ -39,7 +39,7 @@ buddySummary b = case clients of updateBuddies :: Presence -> Buddies -> Buddies updateBuddies p@(Presence { presenceFrom = Just jid }) = M.alter update key where - key = genKey jid + key = genBuddyKey jid update (Just b) = Just $ applyPresence p b update Nothing = newBuddy p updateBuddies _ = id @@ -56,6 +56,7 @@ newBuddy p { buddyPresent = S.empty , buddyAway = S.empty , buddyAssistants = S.empty + , buddyPairing = False } applyPresence :: Presence -> Buddy -> Buddy |