[Sugar-devel] [PATCH sugar 1/4] use dbus.PROPERTIES_IFACE instead of literal value

Sascha Silbe sascha-pgp at silbe.org
Fri Jan 21 08:10:32 EST 2011


From: James Cameron <quozl at laptop.org>

[split out from larger "fix network disconnect and discard history" patch;
fixed up all remaining occurences as well]
Signed-Off-By: Sascha Silbe <sascha-pgp at silbe.org>
Reviewed-By: Sascha Silbe <sascha-pgp at silbe.org>

diff --git a/extensions/cpsection/network/model.py b/extensions/cpsection/network/model.py
index 667e476..8426b7f 100644
--- a/extensions/cpsection/network/model.py
+++ b/extensions/cpsection/network/model.py
@@ -57,7 +57,7 @@ def get_radio():
     try:
         bus = dbus.SystemBus()
         obj = bus.get_object(_NM_SERVICE, _NM_PATH)
-        nm_props = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')
+        nm_props = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
     except dbus.DBusException:
         raise ReadError('%s service not available' % _NM_SERVICE)
 
@@ -80,7 +80,7 @@ def set_radio(state):
         try:
             bus = dbus.SystemBus()
             obj = bus.get_object(_NM_SERVICE, _NM_PATH)
-            nm_props = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')
+            nm_props = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
         except dbus.DBusException:
             raise ReadError('%s service not available' % _NM_SERVICE)
         nm_props.Set(_NM_IFACE, 'WirelessEnabled', True)
@@ -88,7 +88,7 @@ def set_radio(state):
         try:
             bus = dbus.SystemBus()
             obj = bus.get_object(_NM_SERVICE, _NM_PATH)
-            nm_props = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')
+            nm_props = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
         except dbus.DBusException:
             raise ReadError('%s service not available' % _NM_SERVICE)
         nm_props.Set(_NM_IFACE, 'WirelessEnabled', False)
diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
index 887c1c2..bc2492d 100644
--- a/extensions/deviceicon/network.py
+++ b/extensions/deviceicon/network.py
@@ -405,7 +405,7 @@ class WirelessDeviceView(ToolButton):
         self._palette.set_group_id('frame')
 
         self._device_props = dbus.Interface(self._device,
-                                            'org.freedesktop.DBus.Properties')
+                                            dbus.PROPERTIES_IFACE)
         self._device_props.GetAll(_NM_DEVICE_IFACE, byte_arrays=True,
                               reply_handler=self.__get_device_props_reply_cb,
                               error_handler=self.__get_device_props_error_cb)
@@ -446,8 +446,7 @@ class WirelessDeviceView(ToolButton):
                 return
             self._active_ap_op = active_ap_op
             active_ap = self._bus.get_object(_NM_SERVICE, active_ap_op)
-            props = dbus.Interface(active_ap,
-                                   'org.freedesktop.DBus.Properties')
+            props = dbus.Interface(active_ap, dbus.PROPERTIES_IFACE)
 
             props.GetAll(_NM_ACCESSPOINT_IFACE, byte_arrays=True,
                          reply_handler=self.__get_all_ap_props_reply_cb,
@@ -568,14 +567,13 @@ class WirelessDeviceView(ToolButton):
         if self._active_ap_op is not None:
             obj = self._bus.get_object(_NM_SERVICE, _NM_PATH)
             netmgr = dbus.Interface(obj, _NM_IFACE)
-            netmgr_props = dbus.Interface(
-                netmgr, 'org.freedesktop.DBus.Properties')
+            netmgr_props = dbus.Interface(netmgr, dbus.PROPERTIES_IFACE)
             active_connections_o = netmgr_props.Get(_NM_IFACE,
                                                     'ActiveConnections')
 
             for conn_o in active_connections_o:
                 obj = self._bus.get_object(_NM_IFACE, conn_o)
-                props = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')
+                props = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
                 ap_op = props.Get(_NM_ACTIVE_CONN_IFACE, 'SpecificObject')
                 if ap_op == self._active_ap_op:
                     netmgr.DeactivateConnection(conn_o)
@@ -621,7 +619,7 @@ class OlpcMeshDeviceView(ToolButton):
         self.update_state(state)
 
         self._device_props = dbus.Interface(self._device,
-                                            'org.freedesktop.DBus.Properties')
+                                            dbus.PROPERTIES_IFACE)
         self._device_props.Get(_NM_OLPC_MESH_IFACE, 'ActiveChannel',
                             reply_handler=self.__get_active_channel_reply_cb,
                             error_handler=self.__get_active_channel_error_cb)
@@ -683,20 +681,19 @@ class OlpcMeshDeviceView(ToolButton):
     def __deactivate_connection(self, palette, data=None):
         obj = self._bus.get_object(_NM_SERVICE, _NM_PATH)
         netmgr = dbus.Interface(obj, _NM_IFACE)
-        netmgr_props = dbus.Interface(netmgr,
-                                      'org.freedesktop.DBus.Properties')
+        netmgr_props = dbus.Interface(netmgr, dbus.PROPERTIES_IFACE)
         active_connections_o = netmgr_props.Get(_NM_IFACE,
                                                 'ActiveConnections')
 
         for conn_o in active_connections_o:
             # The connection path for a mesh connection is the device itself.
             obj = self._bus.get_object(_NM_IFACE, conn_o)
-            props = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')
+            props = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
             ap_op = props.Get(_NM_ACTIVE_CONN_IFACE, 'SpecificObject')
 
             try:
                 obj = self._bus.get_object(_NM_IFACE, ap_op)
-                props = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')
+                props = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
                 device_type = props.Get(_NM_DEVICE_IFACE, 'DeviceType')
                 if device_type == network.DEVICE_TYPE_802_11_OLPC_MESH:
                     netmgr.DeactivateConnection(conn_o)
@@ -760,7 +757,7 @@ class GsmDeviceView(TrayIcon):
 
         self._palette = palette
 
-        props = dbus.Interface(self._device, 'org.freedesktop.DBus.Properties')
+        props = dbus.Interface(self._device, dbus.PROPERTIES_IFACE)
         props.GetAll(_NM_DEVICE_IFACE, byte_arrays=True,
                      reply_handler=self.__current_state_check_cb,
                      error_handler=self.__current_state_check_error_cb)
@@ -793,13 +790,12 @@ class GsmDeviceView(TrayIcon):
     def __gsm_disconnect_cb(self, palette, data=None):
         obj = self._bus.get_object(_NM_SERVICE, _NM_PATH)
         netmgr = dbus.Interface(obj, _NM_IFACE)
-        netmgr_props = dbus.Interface(netmgr,
-                                      'org.freedesktop.DBus.Properties')
+        netmgr_props = dbus.Interface(netmgr, dbus.PROPERTIES_IFACE)
         active_connections_o = netmgr_props.Get(_NM_IFACE, 'ActiveConnections')
 
         for conn_o in active_connections_o:
             obj = self._bus.get_object(_NM_IFACE, conn_o)
-            props = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')
+            props = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
             devices = props.Get(_NM_ACTIVE_CONN_IFACE, 'Devices')
             if self._device.object_path in devices:
                 netmgr.DeactivateConnection(
@@ -964,7 +960,7 @@ class WiredDeviceObserver(object):
         self._device_view = None
         self._tray = tray
 
-        props = dbus.Interface(self._device, 'org.freedesktop.DBus.Properties')
+        props = dbus.Interface(self._device, dbus.PROPERTIES_IFACE)
         props.GetAll(_NM_DEVICE_IFACE, byte_arrays=True,
                      reply_handler=self.__get_device_props_reply_cb,
                      error_handler=self.__get_device_props_error_cb)
@@ -992,8 +988,7 @@ class WiredDeviceObserver(object):
 
     def _update_state(self, state):
         if state == network.DEVICE_STATE_ACTIVATED:
-            props = dbus.Interface(self._device,
-                                   'org.freedesktop.DBus.Properties')
+            props = dbus.Interface(self._device, dbus.PROPERTIES_IFACE)
             address = props.Get(_NM_DEVICE_IFACE, 'Ip4Address')
             speed = props.Get(_NM_WIRED_IFACE, 'Speed')
             self._device_view = WiredDeviceView(speed, address)
@@ -1053,7 +1048,7 @@ class NetworkManagerObserver(object):
 
     def _check_device(self, device_op):
         nm_device = self._bus.get_object(_NM_SERVICE, device_op)
-        props = dbus.Interface(nm_device, 'org.freedesktop.DBus.Properties')
+        props = dbus.Interface(nm_device, dbus.PROPERTIES_IFACE)
 
         device_type = props.Get(_NM_DEVICE_IFACE, 'DeviceType')
         if device_type == network.DEVICE_TYPE_802_3_ETHERNET:
diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py
index 063a20c..ad4b873 100644
--- a/src/jarabe/desktop/meshbox.py
+++ b/src/jarabe/desktop/meshbox.py
@@ -318,13 +318,12 @@ class NetworkManagerObserver(object):
         # FIXME It would be better to do all of this async, but I cannot think
         # of a good way to. NM could really use some love here.
 
-        netmgr_props = dbus.Interface(
-                            self._netmgr, 'org.freedesktop.DBus.Properties')
+        netmgr_props = dbus.Interface(self._netmgr, dbus.PROPERTIES_IFACE)
         active_connections_o = netmgr_props.Get(_NM_IFACE, 'ActiveConnections')
 
         for conn_o in active_connections_o:
             obj = self._bus.get_object(_NM_IFACE, conn_o)
-            props = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')
+            props = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
             state = props.Get(_NM_ACTIVE_CONN_IFACE, 'State')
             if state == network.NM_ACTIVE_CONNECTION_STATE_ACTIVATING:
                 ap_o = props.Get(_NM_ACTIVE_CONN_IFACE, 'SpecificObject')
@@ -348,7 +347,7 @@ class NetworkManagerObserver(object):
 
     def _check_device(self, device_o):
         device = self._bus.get_object(_NM_SERVICE, device_o)
-        props = dbus.Interface(device, 'org.freedesktop.DBus.Properties')
+        props = dbus.Interface(device, dbus.PROPERTIES_IFACE)
 
         device_type = props.Get(_NM_DEVICE_IFACE, 'DeviceType')
         if device_type == network.DEVICE_TYPE_802_11_WIRELESS:
diff --git a/src/jarabe/desktop/networkviews.py b/src/jarabe/desktop/networkviews.py
index e1cfc13..23eb4a8 100644
--- a/src/jarabe/desktop/networkviews.py
+++ b/src/jarabe/desktop/networkviews.py
@@ -116,8 +116,7 @@ class WirelessNetworkView(CanvasPulsingIcon):
             self.props.badge_name = None
             self._palette_icon.props.badge_name = None
 
-        interface_props = dbus.Interface(self._device,
-                                         'org.freedesktop.DBus.Properties')
+        interface_props = dbus.Interface(self._device, dbus.PROPERTIES_IFACE)
         interface_props.Get(_NM_DEVICE_IFACE, 'State',
                             reply_handler=self.__get_device_state_reply_cb,
                             error_handler=self.__get_device_state_error_cb)
@@ -593,8 +592,7 @@ class OlpcMeshView(CanvasPulsingIcon):
 
         self.connect('button-release-event', self.__button_release_event_cb)
 
-        interface_props = dbus.Interface(device,
-                                         'org.freedesktop.DBus.Properties')
+        interface_props = dbus.Interface(device, dbus.PROPERTIES_IFACE)
         interface_props.Get(_NM_DEVICE_IFACE, 'State',
                             reply_handler=self.__get_device_state_reply_cb,
                             error_handler=self.__get_device_state_error_cb)
diff --git a/src/jarabe/model/adhoc.py b/src/jarabe/model/adhoc.py
index 62090f7..8842a5c 100644
--- a/src/jarabe/model/adhoc.py
+++ b/src/jarabe/model/adhoc.py
@@ -84,7 +84,7 @@ class AdHocManager(gobject.GObject):
                                    ' only be called once.')
 
         self._device = device
-        props = dbus.Interface(device, 'org.freedesktop.DBus.Properties')
+        props = dbus.Interface(device, dbus.PROPERTIES_IFACE)
         self._device_state = props.Get(_NM_DEVICE_IFACE, 'State')
 
         self._bus.add_signal_receiver(self.__device_state_changed_cb,
diff --git a/src/jarabe/model/neighborhood.py b/src/jarabe/model/neighborhood.py
index 11c96dd..ca4c5bf 100644
--- a/src/jarabe/model/neighborhood.py
+++ b/src/jarabe/model/neighborhood.py
@@ -617,7 +617,7 @@ class _Account(gobject.GObject):
                 reply_handler=self.__set_enabled_cb,
                 error_handler=partial(self.__error_handler_cb,
                                       'Account.SetEnabled'),
-                dbus_interface='org.freedesktop.DBus.Properties')
+                dbus_interface=dbus.PROPERTIES_IFACE)
 
     def __set_enabled_cb(self):
         logging.debug('_Account.__set_enabled_cb success')
diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
index db69bc5..1eb34ab 100644
--- a/src/jarabe/model/network.py
+++ b/src/jarabe/model/network.py
@@ -692,8 +692,7 @@ class AccessPoint(gobject.GObject):
         self.channel = 0
 
     def initialize(self):
-        model_props = dbus.Interface(self.model,
-            'org.freedesktop.DBus.Properties')
+        model_props = dbus.Interface(self.model, dbus.PROPERTIES_IFACE)
         model_props.GetAll(NM_ACCESSPOINT_IFACE, byte_arrays=True,
                            reply_handler=self._ap_properties_changed_cb,
                            error_handler=self._get_all_props_error_cb)
diff --git a/src/jarabe/model/olpcmesh.py b/src/jarabe/model/olpcmesh.py
index 4cf837b..f070100 100644
--- a/src/jarabe/model/olpcmesh.py
+++ b/src/jarabe/model/olpcmesh.py
@@ -58,14 +58,12 @@ class OlpcMeshManager(object):
 
         """
 
-        props = dbus.Interface(self.mesh_device,
-                               'org.freedesktop.DBus.Properties')
+        props = dbus.Interface(self.mesh_device, dbus.PROPERTIES_IFACE)
         props.Get(_NM_DEVICE_IFACE, 'State',
                   reply_handler=self.__get_mesh_state_reply_cb,
                   error_handler=self.__get_state_error_cb)
 
-        props = dbus.Interface(self.eth_device,
-                               'org.freedesktop.DBus.Properties')
+        props = dbus.Interface(self.eth_device, dbus.PROPERTIES_IFACE)
         props.Get(_NM_DEVICE_IFACE, 'State',
                   reply_handler=self.__get_eth_state_reply_cb,
                   error_handler=self.__get_state_error_cb)
@@ -90,8 +88,7 @@ class OlpcMeshManager(object):
             self._start_automesh()
 
     def _get_companion_device(self):
-        props = dbus.Interface(self.mesh_device,
-                               'org.freedesktop.DBus.Properties')
+        props = dbus.Interface(self.mesh_device, dbus.PROPERTIES_IFACE)
         eth_device_o = props.Get(_NM_OLPC_MESH_IFACE, 'Companion')
         return self._bus.get_object(_NM_SERVICE, eth_device_o)
 
-- 
1.7.2.3



More information about the Sugar-devel mailing list