diff options
author | Joey Hess <joey@kitenet.net> | 2014-04-09 15:51:00 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-04-09 15:51:00 -0400 |
commit | dd4916514507cc59a2fc59a87758ea50e43ae536 (patch) | |
tree | f2be5528e0b1bab07478f1c2d03513a0c0293b60 /Assistant | |
parent | b7feceff3dfd4ed7c8889036cd43f06642a449da (diff) |
also show signal icon next to connected xmpp remotes
Diffstat (limited to 'Assistant')
-rw-r--r-- | Assistant/Threads/XMPPClient.hs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/Assistant/Threads/XMPPClient.hs b/Assistant/Threads/XMPPClient.hs index d23f695f6..39b0459b7 100644 --- a/Assistant/Threads/XMPPClient.hs +++ b/Assistant/Threads/XMPPClient.hs @@ -42,17 +42,20 @@ xmppClientThread urlrenderer = namedThread "XMPPClient" $ restartableClient . xmppClient urlrenderer =<< getAssistant id {- Runs the client, handing restart events. -} -restartableClient :: (XMPPCreds -> IO ()) -> Assistant () +restartableClient :: (XMPPCreds -> UUID -> IO ()) -> Assistant () restartableClient a = forever $ go =<< liftAnnex getXMPPCreds where go Nothing = waitNetMessagerRestart go (Just creds) = do - tid <- liftIO $ forkIO $ a creds + xmppuuid <- maybe NoUUID Remote.uuid . headMaybe + . filter Remote.isXMPPRemote . syncRemotes + <$> getDaemonStatus + tid <- liftIO $ forkIO $ a creds xmppuuid waitNetMessagerRestart liftIO $ killThread tid -xmppClient :: UrlRenderer -> AssistantData -> XMPPCreds -> IO () -xmppClient urlrenderer d creds = +xmppClient :: UrlRenderer -> AssistantData -> XMPPCreds -> UUID -> IO () +xmppClient urlrenderer d creds xmppuuid = retry (runclient creds) =<< getCurrentTime where liftAssistant = runAssistant d @@ -67,10 +70,12 @@ xmppClient urlrenderer d creds = - is not retained. -} liftAssistant $ updateBuddyList (const noBuddies) <<~ buddyList - liftAssistant $ void client - liftAssistant $ modifyDaemonStatus_ $ \s -> s - { xmppClientID = Nothing } + liftAssistant $ do + modifyDaemonStatus_ $ \s -> s + { xmppClientID = Nothing } + changeCurrentlyConnected $ S.delete xmppuuid + now <- getCurrentTime if diffUTCTime now starttime > 300 then do @@ -88,6 +93,7 @@ xmppClient urlrenderer d creds = inAssistant $ do modifyDaemonStatus_ $ \s -> s { xmppClientID = Just $ xmppJID creds } + changeCurrentlyConnected $ S.insert xmppuuid debug ["connected", logJid selfjid] lasttraffic <- liftIO $ atomically . newTMVar =<< getCurrentTime |