show when not connected to xmpp server

This commit is contained in:
Joey Hess 2013-03-06 22:02:47 -04:00
parent 15ef899b12
commit f8c2dc82d8
4 changed files with 14 additions and 6 deletions

View file

@ -47,8 +47,6 @@ restartableClient a = forever $ go =<< liftAnnex getXMPPCreds
where where
go Nothing = waitNetMessagerRestart go Nothing = waitNetMessagerRestart
go (Just creds) = do go (Just creds) = do
modifyDaemonStatus_ $ \s -> s
{ xmppClientID = Just $ xmppJID creds }
tid <- liftIO $ forkIO $ a creds tid <- liftIO $ forkIO $ a creds
waitNetMessagerRestart waitNetMessagerRestart
liftIO $ killThread tid liftIO $ killThread tid
@ -65,6 +63,8 @@ xmppClient urlrenderer d creds =
- trying it again. -} - trying it again. -}
retry client starttime = do retry client starttime = do
e <- client e <- client
liftAssistant $ modifyDaemonStatus_ $ \s -> s
{ xmppClientID = Nothing }
now <- getCurrentTime now <- getCurrentTime
if diffUTCTime now starttime > 300 if diffUTCTime now starttime > 300
then do then do
@ -79,7 +79,10 @@ xmppClient urlrenderer d creds =
selfjid <- bindJID jid selfjid <- bindJID jid
putStanza gitAnnexSignature putStanza gitAnnexSignature
inAssistant $ debug ["connected", show selfjid] inAssistant $ do
modifyDaemonStatus_ $ \s -> s
{ xmppClientID = Just $ xmppJID creds }
debug ["connected", show selfjid]
{- The buddy list starts empty each time {- The buddy list starts empty each time
- the client connects, so that stale info - the client connects, so that stale info
- is not retained. -} - is not retained. -}

View file

@ -58,7 +58,8 @@ data DaemonStatus = DaemonStatus
, alertNotifier :: NotificationBroadcaster , alertNotifier :: NotificationBroadcaster
-- Broadcasts notifications when the syncRemotes change -- Broadcasts notifications when the syncRemotes change
, syncRemotesNotifier :: NotificationBroadcaster , syncRemotesNotifier :: NotificationBroadcaster
-- When the XMPP client is in use, this will contain its JI. -- When the XMPP client is connected, this will contain the XMPP
-- address.
, xmppClientID :: Maybe ClientID , xmppClientID :: Maybe ClientID
} }

View file

@ -83,6 +83,7 @@ buddyListDisplay :: Widget
buddyListDisplay = do buddyListDisplay = do
autoUpdate ident NotifierBuddyListR (10 :: Int) (10 :: Int) autoUpdate ident NotifierBuddyListR (10 :: Int) (10 :: Int)
#ifdef WITH_XMPP #ifdef WITH_XMPP
myjid <- lift $ liftAssistant $ xmppClientID <$> getDaemonStatus
buddies <- lift $ liftAssistant $ do buddies <- lift $ liftAssistant $ do
rs <- filter isXMPPRemote . syncGitRemotes <$> getDaemonStatus rs <- filter isXMPPRemote . syncGitRemotes <$> getDaemonStatus
let pairedwith = catMaybes $ map (parseJID . getXMPPClientID) rs let pairedwith = catMaybes $ map (parseJID . getXMPPClientID) rs

View file

@ -3,8 +3,11 @@
<tbody> <tbody>
$if null buddies $if null buddies
<tr> <tr>
<td> <td>
Nobody is currently available. $if isNothing myjid
Not connected to the jabber server. Check your network connection ...
$else
Nobody is currently available.
$else $else
$forall (name, away, canpair, paired, buddyid) <- buddies $forall (name, away, canpair, paired, buddyid) <- buddies
<tr> <tr>