From 749c030d61018383fbe7f68ff4c994ff2ca847d0 Mon Sep 17 00:00:00 2001 From: aluzzardi Date: Thu, 21 Apr 2011 01:15:37 +0200 Subject: [PATCH] pamusb-agent UDisks migration --- tools/pamusb-agent | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/tools/pamusb-agent b/tools/pamusb-agent index 942bbd6..2a29d75 100755 --- a/tools/pamusb-agent +++ b/tools/pamusb-agent @@ -53,31 +53,27 @@ class HotPlugDevice: self.__callbacks.append(callback) def __scanDevices(self): - halService = self.__bus.get_object('org.freedesktop.Hal', - '/org/freedesktop/Hal/Manager') - halManager = dbus.Interface(halService, 'org.freedesktop.Hal.Manager') - for udi in halManager.FindDeviceByCapability('storage'): + halService = self.__bus.get_object('org.freedesktop.UDisks', + '/org/freedesktop/UDisks') + halManager = dbus.Interface(halService, 'org.freedesktop.UDisks') + for udi in halManager.EnumerateDevices(): self.__deviceAdded(udi) def __registerSignals(self): + halService = self.__bus.get_object('org.freedesktop.UDisks', + '/org/freedesktop/UDisks') + halManager = dbus.Interface(halService, 'org.freedesktop.UDisks') for signal, callback in (('DeviceAdded', self.__deviceAdded), ('DeviceRemoved', self.__deviceRemoved)): - self.__bus.add_signal_receiver(callback, - signal, - 'org.freedesktop.Hal.Manager', - 'org.freedesktop.Hal', - '/org/freedesktop/Hal/Manager') + halManager.connect_to_signal(signal, callback) def __deviceAdded(self, udi): if self.__udi is not None: return - deviceObj = self.__bus.get_object('org.freedesktop.Hal', + deviceObj = self.__bus.get_object('org.freedesktop.UDisks', udi) - deviceProperties = deviceObj.GetAllProperties( - dbus_interface = 'org.freedesktop.Hal.Device') - if not deviceProperties.has_key('storage.serial'): - return - if deviceProperties['storage.serial'] != self.__serial: + deviceProperties = dbus.Interface(deviceObj, dbus.PROPERTIES_IFACE) + if deviceProperties.Get('org.freedesktop.UDisks.Device', 'DriveSerial') != self.__serial: return self.__udi = udi if self.__running: