aboutsummaryrefslogtreecommitdiff
path: root/Assistant
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-01-22 16:50:08 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-01-22 16:50:08 -0400
commitbb64ea64d5e832cc5d044ad283d65ae3ef956d47 (patch)
treed47dfdc64439ef985d88e688875339811fdea44b /Assistant
parent2a756eabe28658eb5f35fe7bbac078c27c79be8b (diff)
assistant: Use udisks2 dbus events to detect when disks are mounted, instead of relying on gnome/kde stuff that is not stable.
Diffstat (limited to 'Assistant')
-rw-r--r--Assistant/Threads/MountWatcher.hs43
1 files changed, 13 insertions, 30 deletions
diff --git a/Assistant/Threads/MountWatcher.hs b/Assistant/Threads/MountWatcher.hs
index 0367c7b1a..dd45598f8 100644
--- a/Assistant/Threads/MountWatcher.hs
+++ b/Assistant/Threads/MountWatcher.hs
@@ -48,7 +48,7 @@ mountWatcherThread urlrenderer = namedThread "MountWatcher" $
dbusThread :: UrlRenderer -> Assistant ()
dbusThread urlrenderer = do
runclient <- asIO1 go
- r <- liftIO $ E.try $ runClient getSessionAddress runclient
+ r <- liftIO $ E.try $ runClient getSystemAddress runclient
either onerr (const noop) r
where
go client = ifM (checkMountMonitor client)
@@ -71,11 +71,6 @@ dbusThread urlrenderer = do
)
onerr :: E.SomeException -> Assistant ()
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. -}
liftAnnex $
warning $ "dbus failed; falling back to mtab polling (" ++ show e ++ ")"
pollingThread urlrenderer
@@ -95,12 +90,9 @@ checkMountMonitor client = do
]
return True
where
- startableservices = [gvfsnew, gvfs, gvfsgdu]
- usableservices = startableservices ++ [kde]
- gvfs = "org.gtk.Private.UDisks2VolumeMonitor"
- gvfsnew = "org.gtk.vfs.UDisks2VolumeMonitor"
- gvfsgdu = "org.gtk.Private.GduVolumeMonitor"
- kde = "org.kde.DeviceNotifications"
+ startableservices = [udisks2]
+ usableservices = startableservices
+ udisks2 = "org.freedesktop.UDisks2"
startOneService :: Client -> [ServiceName] -> Assistant Bool
startOneService _ [] = return False
@@ -119,27 +111,18 @@ startOneService client (x:xs) = do
{- Filter matching events recieved when drives are mounted and unmounted. -}
mountChanged :: [MatchRule]
-mountChanged = [gvfs True, gvfs False, kde, kdefallback]
+mountChanged = [udisks2mount, udisks2umount]
where
- {- gvfs reliably generates this event whenever a
- - drive is mounted/unmounted, whether automatically, or manually -}
- gvfs mount = matchAny
- { matchInterface = Just "org.gtk.Private.RemoteVolumeMonitor"
- , matchMember = Just $ if mount then "MountAdded" else "MountRemoved"
+ udisks2mount = matchAny
+ { matchPath = Just "/org/freedesktop/UDisks2"
+ , matchInterface = Just "org.freedesktop.DBus.ObjectManager"
+ , matchMember = Just "InterfacesAdded"
}
- {- This event fires when KDE prompts the user what to do with a drive,
- - but maybe not at other times. And it's not received -}
- kde = matchAny
- { matchInterface = Just "org.kde.Solid.Device"
- , matchMember = Just "setupDone"
+ udisks2umount = matchAny
+ { matchPath = Just "/org/freedesktop/UDisks2"
+ , matchInterface = Just "org.freedesktop.DBus.ObjectManager"
+ , matchMember = Just "InterfacesRemoved"
}
- {- This event may not be closely related to mounting a drive, but it's
- - observed reliably when a drive gets mounted or unmounted. -}
- kdefallback = matchAny
- { matchInterface = Just "org.kde.KDirNotify"
- , matchMember = Just "enteredDirectory"
- }
-
#endif
pollingThread :: UrlRenderer -> Assistant ()