From 414fb6e1dc03201cb237041be97670c12be90f9f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 3 Nov 2012 14:25:06 -0400 Subject: send a presence query when the buddy list is displayed This ensures that clients that have not sent presence in a while will show up in the list. --- Assistant/Threads/XMPPClient.hs | 4 ++-- Assistant/Types/NetMessager.hs | 6 +++++- Assistant/XMPP.hs | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Assistant/Threads/XMPPClient.hs b/Assistant/Threads/XMPPClient.hs index 7fb3cc874..9ecceabe5 100644 --- a/Assistant/Threads/XMPPClient.hs +++ b/Assistant/Threads/XMPPClient.hs @@ -88,8 +88,8 @@ xmppClientThread = NamedThread "XMPPClient" $ do relayNetMessage :: Assistant (XMPP ()) relayNetMessage = convert <$> waitNetMessage where - convert (NotifyPush us) = - putStanza $ gitAnnexPresence $ encodePushNotification us + convert (NotifyPush us) = putStanza $ pushNotification us + convert QueryPresence = putStanza presenceQuery data DecodedStanza = PresenceMessage Presence diff --git a/Assistant/Types/NetMessager.hs b/Assistant/Types/NetMessager.hs index fea88a53a..6bc9ec34a 100644 --- a/Assistant/Types/NetMessager.hs +++ b/Assistant/Types/NetMessager.hs @@ -13,7 +13,11 @@ import Control.Concurrent.STM import Control.Concurrent.MSampleVar {- Messages that can be sent out of band by a network messager. -} -data NetMessage = NotifyPush [UUID] +data NetMessage + -- indicate that pushes have been made to the repos with these uuids + = NotifyPush [UUID] + -- requests other clients to inform us of their presence + | QueryPresence {- Controls for the XMPP client. - diff --git a/Assistant/XMPP.hs b/Assistant/XMPP.hs index 05bc94fa3..834055fbc 100644 --- a/Assistant/XMPP.hs +++ b/Assistant/XMPP.hs @@ -84,6 +84,9 @@ decodePushNotification (Element name attrs _nodes) fromContent (ContentText t) = t fromContent (ContentEntity t) = t +pushNotification :: [UUID] -> Presence +pushNotification = gitAnnexPresence . encodePushNotification + {- A request for other git-annex clients to send presence. -} presenceQuery :: Presence presenceQuery = gitAnnexPresence $ Element gitAnnexTagName -- cgit v1.2.3