detect wicd network disconnection events
This commit is contained in:
parent
bb44df206d
commit
ff192ace2f
2 changed files with 23 additions and 8 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue