From bf4c327bacbcadfab484a9c5455fd41c7fc38eb9 Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Fri, 18 Jan 2008 21:02:25 +0100 Subject: [PATCH] Using setEnabledWireless to handle radio settings #1406 --- shell/controlpanel/control.py | 38 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 20 deletions(-) mode change 100644 => 100755 shell/controlpanel/control.py diff --git a/shell/controlpanel/control.py b/shell/controlpanel/control.py old mode 100644 new mode 100755 index c21d93a5..a26132e7 --- a/shell/controlpanel/control.py +++ b/shell/controlpanel/control.py @@ -307,33 +307,31 @@ def get_radio(): bus = dbus.SystemBus() proxy = bus.get_object(NM_SERVICE_NAME, NM_SERVICE_PATH) nm = dbus.Interface(proxy, NM_SERVICE_IFACE) - state = nm.state() - if state: - if state == NM_ASLEEP: - return _('off') - else: - return _('on') - return _('State is unknown.') - + state = nm.getWirelessEnabled() + if state == 0: + return _('off') + elif state == 1: + return _('on') + else: + return _('State is unknown.') + def print_radio(): print get_radio() def set_radio(state): """Turn Radio 'on' or 'off' state : 'on/off' - """ - - # TODO: NM 0.6.x does not return a reply yet - # so we ignore it for the moment - - if state == 'on': - dbus.SystemBus().call_async(NM_SERVICE_NAME, NM_SERVICE_PATH, - NM_SERVICE_IFACE, 'wake', '', (), - None, None) + """ + if state == 'on': + bus = dbus.SystemBus() + proxy = bus.get_object(NM_SERVICE_NAME, NM_SERVICE_PATH) + nm = dbus.Interface(proxy, NM_SERVICE_IFACE) + nm.setWirelessEnabled(True) elif state == 'off': - dbus.SystemBus().call_async(NM_SERVICE_NAME, NM_SERVICE_PATH, - NM_SERVICE_IFACE, 'sleep', '', (), - None, None) + bus = dbus.SystemBus() + proxy = bus.get_object(NM_SERVICE_NAME, NM_SERVICE_PATH) + nm = dbus.Interface(proxy, NM_SERVICE_IFACE) + nm.setWirelessEnabled(False) else: print (_("Error in specified radio argument use on/off."))