summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-04-12 18:36:48 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-04-12 18:36:48 -0400
commit5ede7f0368c1fab5dedd836f55a91cdc936816c6 (patch)
treebbce5ea15dbb521d42cdd652be0619255f726335
parent1434808d1379f3d941ab16868ef7bfabf5381770 (diff)
detect wicd network disconnection events
-rw-r--r--Assistant/Threads/NetWatcher.hs28
-rw-r--r--doc/design/git-remote-daemon.mdwn3
2 files changed, 23 insertions, 8 deletions
diff --git a/Assistant/Threads/NetWatcher.hs b/Assistant/Threads/NetWatcher.hs
index c1115f637..9dd617822 100644
--- a/Assistant/Threads/NetWatcher.hs
+++ b/Assistant/Threads/NetWatcher.hs
@@ -130,18 +130,36 @@ listenNMConnections client setconnected =
setconnected True
| otherwise = noop
-{- Listens for Wicd connections (not currently disconnections). -}
+{- Listens for Wicd connections and disconnections.
+ -
+ - Connection example:
+ - ConnectResultsSent:
+ - Variant "success"
+ -
+ - Diconnection example:
+ - StatusChanged
+ - [Variant 0, Variant [Varient ""]]
+ -}
listenWicdConnections :: Client -> (Bool -> IO ()) -> IO ()
-listenWicdConnections client callback =
- listen client matcher $ \event ->
+listenWicdConnections client setconnected = do
+ listen client connmatcher $ \event ->
when (any (== wicd_success) (signalBody event)) $
- callback False >> callback True
+ setconnected True
+ listen client statusmatcher $ \event -> handle (signalBody event)
where
- matcher = matchAny
+ connmatcher = matchAny
{ matchInterface = Just "org.wicd.daemon"
, matchMember = Just "ConnectResultsSent"
}
+ statusmatcher = matchAny
+ { matchInterface = Just "org.wicd.daemon"
+ , matchMember = Just "StatusChanged"
+ }
wicd_success = toVariant ("success" :: String)
+ wicd_disconnected = toVariant [toVariant ("" :: String)]
+ handle status
+ | any (== wicd_disconnected) status = setconnected False
+ | otherwise = noop
#endif
diff --git a/doc/design/git-remote-daemon.mdwn b/doc/design/git-remote-daemon.mdwn
index a0e24198c..7ab428ecc 100644
--- a/doc/design/git-remote-daemon.mdwn
+++ b/doc/design/git-remote-daemon.mdwn
@@ -164,9 +164,6 @@ No pushing is done for CHANGED, since git handles ssh natively.
TODO:
-* For wicd, the NetWatcher does not detect network loss, only network gain.
- So PAUSE is only sent when a new network is detected, followed
- immediately by RESUME. This was already fixed for networkmanager.
* Remote system might not be available. Find a smart way to detect it,
ideally w/o generating network traffic. One way might be to check
if the ssh connection caching control socket exists, for example.