Merge branch 'master' into xmpp

Conflicts:
	Assistant/Threads/NetWatcher.hs
This commit is contained in:
Joey Hess 2012-10-26 19:42:24 -04:00
commit d1e5f2d596
13 changed files with 116 additions and 18 deletions

View file

@ -74,6 +74,11 @@ dbusThread st dstatus scanremotes pushnotifier =
)
onerr :: E.SomeException -> IO ()
onerr e = do
{- If the session dbus fails, the user probably
- logged out of their desktop. Even if they log
- back in, we won't have access to the dbus
- session key, so polling is the best that can be
- done in this situation. -}
runThreadState st $
warning $ "dbus failed; falling back to mtab polling (" ++ show e ++ ")"
pollinstead

View file

@ -25,7 +25,6 @@ import Utility.DBus
import DBus.Client
import DBus
import Data.Word (Word32)
import qualified Control.Exception as E
#else
#warning Building without dbus support; will poll for network connection changes
#endif
@ -59,22 +58,24 @@ netWatcherFallbackThread st dstatus scanremotes pushnotifier = thread $
dbusThread :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> PushNotifier -> IO ()
dbusThread st dstatus scanremotes pushnotifier =
E.catch (runClient getSystemAddress go) onerr
persistentClient getSystemAddress () onerr go
where
go client = ifM (checkNetMonitor client)
( do
listenNMConnections client handle
listenWicdConnections client handle
listenNMConnections client handleconn
listenWicdConnections client handleconn
, do
runThreadState st $
warning "No known network monitor available through dbus; falling back to polling"
)
onerr :: E.SomeException -> IO ()
onerr e = runThreadState st $
warning $ "dbus failed; falling back to polling (" ++ show e ++ ")"
handle = do
handleconn = do
debug thisThread ["detected network connection"]
handleConnection st dstatus scanremotes pushnotifier
onerr e _ = do
runThreadState st $
warning $ "lost dbus connection; falling back to polling (" ++ show e ++ ")"
{- Wait, in hope that dbus will come back -}
threadDelaySeconds (Seconds 60)
{- Examine the list of services connected to dbus, to see if there
- are any we can use to monitor network connections. -}