def process_device_added(self): from vmc.common.plugin import PluginManager properties = self.get_devices_properties() for plugin in PluginManager.get_plugins(IDBusDevicePlugin): if plugin in properties: plugin.setup(properties) louie.send(notifications.SIG_DEVICE_ADDED, None, plugin) self.device = plugin
def device_removed(self, udi): """Called when a device has been removed""" if not self.device: return if IRemoteDevicePlugin.providedBy(self.device): log.msg("DEVICE %s REMOVED" % udi) return if self.device.udi == udi: louie.send(notifications.SIG_DEVICE_REMOVED, None) self.device = None
def _dev_removed_cb(self, udi): if self.mode == BUSY: # we're in the middle of a hotpluggin event and the udis that # we just added to self.added_udis are disappearing! # whats going on? Some devices such as the Huawei E870 will # add some child udis, and will remove them once libusual kicks # in, so we need to wait for at most ADD_THRESHOLD seconds # since the last removal/add to find out what really got added if udi in self.added_udis: self.added_udis.remove(udi) return if udi in self.devices: louie.send(notifications.SIG_DEVICE_REMOVED, None) del self.devices[udi]
def _register_devices(self, devices, to_idle=False): for device in devices: udi = device.udi if device.udi not in self.devices: self.devices[udi] = device louie.send(notifications.SIG_DEVICE_ADDED, None, device) if to_idle: self.mode = IDLE if self.get_devices_deferred is not None: self.get_devices_deferred.callback(self.devices.values()) self.get_devices_deferred = None return self.devices.values()