From f1076d654b9100b0e528b201b0aeb468edbd7a26 Mon Sep 17 00:00:00 2001 From: Martin Abente Date: Wed, 09 Jun 2010 20:31:29 +0000 Subject: Fix duplication of OLPC mesh icons Three or more mesh icons were being added after every suspend/resume. There was already code present to detect when the device goes away and remove the icons, but it was not working. NetworkManagerObserver was attempting to look at the properties of the gone-away device in order to see if it is a mesh device, but this was failing because the device has already been destroyed at this point. Solve this by recording the device path of the mesh device when it is detected, so that we can later determine if the gone-away device is the mesh device. Signed-off-by: Martin Abente --- diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py index a04922b..eabc737 100644 --- a/src/jarabe/desktop/meshbox.py +++ b/src/jarabe/desktop/meshbox.py @@ -574,13 +574,15 @@ class OlpcMeshView(CanvasPulsingIcon): self._update_color() def disconnect(self): + device_object_path = self._mesh_mgr.mesh_device.object_path + self._bus.remove_signal_receiver(self.__device_state_changed_cb, signal_name='StateChanged', - path=self._device.object_path, + path=device_object_path, dbus_interface=_NM_DEVICE_IFACE) self._bus.remove_signal_receiver(self.__wireless_properties_changed_cb, signal_name='PropertiesChanged', - path=self._device.object_path, + path=device_object_path, dbus_interface=_NM_OLPC_MESH_IFACE) @@ -821,6 +823,7 @@ class NetworkManagerObserver(object): self._bus = None self._devices = {} self._netmgr = None + self._olpc_mesh_device_o = None def listen(self): try: @@ -885,6 +888,7 @@ class NetworkManagerObserver(object): if device_type == network.DEVICE_TYPE_802_11_WIRELESS: self._devices[device_o] = DeviceObserver(self._box, device) elif device_type == network.DEVICE_TYPE_802_11_OLPC_MESH: + self._olpc_mesh_device_o = device_o self._box.enable_olpc_mesh(device) def _get_device_path_error_cb(self, err): @@ -899,12 +903,9 @@ class NetworkManagerObserver(object): observer.disconnect() del self._devices[device_o] return - - device = self._bus.get_object(_NM_SERVICE, device_o) - props = dbus.Interface(device, 'org.freedesktop.DBus.Properties') - device_type = props.Get(_NM_DEVICE_IFACE, 'DeviceType') - if device_type == network.DEVICE_TYPE_802_11_OLPC_MESH: - self._box.disable_olpc_mesh(device) + + if self._olpc_mesh_device_o == device_o: + self._box.disable_olpc_mesh(device_o) class MeshBox(gtk.VBox): __gtype_name__ = 'SugarMeshBox' -- cgit v0.9.1