1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-29 01:42:33 +01:00

Implemented rfkill support (LP: #293727)

This commit is contained in:
David Paleino
2011-09-18 10:31:15 +02:00
parent bda00d0627
commit c86cffd67e
6 changed files with 76 additions and 2 deletions

View File

@@ -765,6 +765,37 @@ class Wireless(Controller):
"""
return self.wiface.GetKillSwitchStatus()
def SwitchRfKill(self):
""" Switches the rfkill on/off for wireless cards. """
types = ['wifi', 'wlan', 'wimax', 'wwan']
try:
if self.GetRfKillStatus():
action = 'unblock'
else:
action = 'block'
for t in types:
cmd = ['rfkill', action, t]
print "rfkill: %sing %s" % (action, t)
misc.Run(cmd)
return True
except Exception, e:
raise e
return False
def GetRfKillStatus(self):
""" Determines if rfkill switch is active or not.
Returns:
True if rfkill (soft-)switch is enabled.
"""
cmd = 'rfkill list'
rfkill_out = misc.Run(cmd)
soft_blocks = filter(lambda x: x.startswith('Soft'), rfkill_out.split('\t'))
for line in map(lambda x: x.strip(), soft_blocks):
if line.endswith('yes'):
return True
return False
def Disconnect(self):
""" Disconnect the given iface.

View File

@@ -242,3 +242,5 @@ language['conn_info_wired_labels'] = _('''Wired
IP:
RX:
TX:''')
language['switch_on_wifi'] = _('''Switch On Wi-Fi''')
language['switch_off_wifi'] = _('''Switch Off Wi-Fi''')

View File

@@ -1025,6 +1025,16 @@ class WirelessDaemon(dbus.service.Object):
status = self.wifi.GetKillSwitchStatus()
return status
@dbus.service.method('org.wicd.daemon.wireless')
def SwitchRfKill(self):
""" Switches the rfkill on/off for wireless cards. """
return self.wifi.SwitchRfKill()
@dbus.service.method('org.wicd.daemon.wireless')
def GetRfKillEnabled(self):
""" Returns true if rfkill switch is enabled. """
return self.wifi.GetRfKillStatus()
@dbus.service.method('org.wicd.daemon.wireless')
def GetWirelessProperty(self, networkid, property):
""" Retrieves wireless property from the network specified """