mirror of
https://github.com/gryf/wicd.git
synced 2025-12-20 21:08:06 +01:00
Merged with experimental-nacl, r292
This commit is contained in:
13
in/init=lunar=wicd.in
Executable file
13
in/init=lunar=wicd.in
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Startup script for wicd
|
||||
#
|
||||
# chkconfig: 345 99 01
|
||||
#
|
||||
# description: wicd wireless/wired internet connection daemon
|
||||
#
|
||||
# processname: wicd
|
||||
# pidfile: %PIDFILE%
|
||||
#
|
||||
|
||||
. /lib/lsb/init-functions $1
|
||||
@@ -3,6 +3,7 @@
|
||||
### BEGIN INIT INFO
|
||||
# Provides: wicd-daemon
|
||||
# Required-Start: dbus
|
||||
# Required-Stop:
|
||||
# Default-Start: 3 4 5
|
||||
# Default-Stop:
|
||||
# Description: wicd, a wired and wireless connection manager.
|
||||
|
||||
3
setup.py
3
setup.py
@@ -162,6 +162,9 @@ class configure(Command):
|
||||
self.initfile = 'init/pld/wicd'
|
||||
elif os.path.exists('/usr/bin/crux'):
|
||||
self.init = '/etc/rc.d/'
|
||||
elif os.path.exists('/etc/lunar.release'):
|
||||
self.init='/etc/init.d/'
|
||||
self.initfile = 'init/lunar/wicd'
|
||||
else:
|
||||
self.init = 'FAIL'
|
||||
self.no_install_init = True
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" ioctl Network interface control tools for wicd.
|
||||
|
||||
@@ -66,6 +67,7 @@ SIOCGIWESSID = 0x8B1B
|
||||
SIOCGIWRANGE = 0x8B0B
|
||||
SIOCGIWAP = 0x8B15
|
||||
SIOCGIWSTATS = 0x8B0F
|
||||
SIOCGIWRATE = 0x8B21
|
||||
|
||||
# Got these from /usr/include/sockios.h
|
||||
SIOCGIFADDR = 0x8915
|
||||
@@ -295,6 +297,7 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
|
||||
|
||||
ap["bssid"] = cell["bssid"]
|
||||
ap["mode"] = cell["mode"]
|
||||
ap["bitrates"] = cell["bitrate"]
|
||||
|
||||
if cell["enc"]:
|
||||
ap["encryption"] = True
|
||||
@@ -479,6 +482,31 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
|
||||
raw_addr = struct.unpack("xxBBBBBB", result[:8])
|
||||
return "%02X:%02X:%02X:%02X:%02X:%02X" % raw_addr
|
||||
|
||||
def GetCurrentBitrate(self, iwconfig=None):
|
||||
""" Get the current bitrate for the interface. """
|
||||
if not self.iface: return ""
|
||||
data = (self.iface + '\0' * 32)[:32]
|
||||
fmt = "ihbb"
|
||||
size = struct.calcsize(fmt)
|
||||
try:
|
||||
result = fcntl.ioctl(self.sock.fileno(), SIOCGIWRATE, data)[16:]
|
||||
except IOError, e:
|
||||
if self.verbose:
|
||||
print "SIOCGIWRATE failed: " + str(e)
|
||||
return ""
|
||||
f, e, x, x = struct.unpack(fmt, result[:size])
|
||||
return "%s %s" % ((f / 1000000), 'Mb/s')
|
||||
|
||||
#def GetOperationalMode(self, iwconfig=None):
|
||||
# """ Get the operational mode for the interface. """
|
||||
# TODO: implement me
|
||||
# return ''
|
||||
|
||||
#def GetAvailableAuthMethods(self, iwlistauth=None):
|
||||
# """ Get the authentication methods for the interface. """
|
||||
# TODO: Implement me
|
||||
# return ''
|
||||
|
||||
def GetSignalStrength(self, iwconfig=None):
|
||||
""" Get the signal strength of the current network.
|
||||
|
||||
@@ -544,3 +572,4 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
|
||||
return None
|
||||
|
||||
return buff.strip('\x00')
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" networking - Provides wrappers for common network operations
|
||||
|
||||
@@ -131,7 +132,7 @@ def expand_script_macros(script, msg, bssid, essid):
|
||||
print "Expanded '%s' to '%s'" % (script, expanded)
|
||||
return expanded
|
||||
|
||||
|
||||
|
||||
class Controller(object):
|
||||
""" Parent class for the different interface types. """
|
||||
def __init__(self, debug=False):
|
||||
@@ -335,7 +336,6 @@ class ConnectThread(threading.Thread):
|
||||
finally:
|
||||
self.lock.release()
|
||||
|
||||
|
||||
def GetStatus(self):
|
||||
""" Get the threads current status message in a thread-safe way.
|
||||
|
||||
@@ -630,6 +630,36 @@ class Wireless(Controller):
|
||||
"""
|
||||
return self.wiface.GetBSSID()
|
||||
|
||||
def GetCurrentBitrate(self, iwconfig):
|
||||
""" Get the current bitrate of the interface.
|
||||
|
||||
Returns:
|
||||
The bitrate of the active access point as a string, or
|
||||
None the bitrate can't be found.
|
||||
|
||||
"""
|
||||
return self.wiface.GetCurrentBitrate(iwconfig)
|
||||
|
||||
def GetOperationalMode(self, iwconfig):
|
||||
""" Get the current operational mode of the interface.
|
||||
|
||||
Returns:
|
||||
The operational mode of the interface as a string, or
|
||||
None if the operational mode can't be found.
|
||||
|
||||
"""
|
||||
return self.wiface.GetOperationalMode(iwconfig)
|
||||
|
||||
def GetAvailableAuthMethods(self, iwlistauth):
|
||||
""" Get the available authentication methods for the interface.
|
||||
|
||||
Returns:
|
||||
The available authentication methods of the interface as a string, or
|
||||
None if the auth methods can't be found.
|
||||
|
||||
"""
|
||||
return self.wiface.GetAvailableAuthMethods(iwlistauth)
|
||||
|
||||
def GetIwconfig(self):
|
||||
""" Get the out of iwconfig. """
|
||||
return self.wiface.GetIwconfig()
|
||||
|
||||
@@ -160,6 +160,7 @@ language['cannot_start_daemon'] = _('Unable to connect to wicd daemon DBus inter
|
||||
"This typically means there was a problem starting the daemon. " + \
|
||||
"Check the wicd log for more info')
|
||||
language['lost_dbus'] = _('The wicd daemon has shut down, the UI will not function properly until it is restarted.')
|
||||
language['access_denied'] = _("Unable to contact the wicd dameon due to an access denied error from DBus. Please check your DBus configuration.")
|
||||
language['configuring_wireless'] = _('Configuring preferences for wireless network "$A" ($B)')
|
||||
language['configuring_wired'] = _('Configuring preferences for wired profile "$A"')
|
||||
language['scan'] = _('Scan')
|
||||
|
||||
@@ -79,7 +79,11 @@ def catchdbus(func):
|
||||
try:
|
||||
return func(*args, **kwargs)
|
||||
except DBusException, e:
|
||||
print "warning: ignoring exception %s" % e
|
||||
if "DBus.Error.AccessDenied" in e:
|
||||
error(None, language['access_denied'])
|
||||
raise DBusException(e)
|
||||
else:
|
||||
print "warning: ignoring exception %s" % e
|
||||
return None
|
||||
wrapper.__name__ = func.__name__
|
||||
wrapper.__module__ = func.__module__
|
||||
@@ -693,6 +697,7 @@ def handle_no_dbus():
|
||||
block=False))
|
||||
return False
|
||||
|
||||
@catchdbus
|
||||
def main(argv):
|
||||
""" The main frontend program.
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" wicd - wireless connection daemon implementation.
|
||||
|
||||
@@ -993,8 +994,24 @@ class WirelessDaemon(dbus.service.Object):
|
||||
|
||||
@dbus.service.method('org.wicd.daemon.wireless')
|
||||
def GetApBssid(self):
|
||||
""" Gets the MAC address for the active network. """
|
||||
return self.wifi.GetBSSID()
|
||||
|
||||
@dbus.service.method('org.wicd.daemon.wireless')
|
||||
def GetCurrentBitrate(self, iwconfig):
|
||||
""" Returns the current bitrate for the active network. """
|
||||
return self.wifi.GetCurrentBitrate(iwconfig)
|
||||
|
||||
@dbus.service.method('org.wicd.daemon.wireless')
|
||||
def GetOperationalMode(self, iwconfig):
|
||||
""" Returns the operational mode for the iwconfig parameter """
|
||||
return misc.to_unicode(self.wifi.GetOperationalMode(iwconfig))
|
||||
|
||||
@dbus.service.method('org.wicd.daemon.wireless')
|
||||
def GetAvailableAuthMethods(self, iwlistauth):
|
||||
""" Returns the operational mode for the iwlistauth parameter """
|
||||
return misc.to_unicode(self.wifi.GetAvailableAuthMethods(iwlistauth))
|
||||
|
||||
@dbus.service.method('org.wicd.daemon.wireless')
|
||||
def CreateAdHocNetwork(self, essid, channel, ip, enctype, key, encused,
|
||||
ics):
|
||||
@@ -1125,6 +1142,12 @@ class WirelessDaemon(dbus.service.Object):
|
||||
ip = self.wifi.GetIP(ifconfig)
|
||||
return ip
|
||||
|
||||
@dbus.service.method('org.wicd.daemon.wireless')
|
||||
def GetOperationalMode(self, ifconfig=""):
|
||||
""" Returns the IP associated with the wireless interface. """
|
||||
ip = self.wifi.GetOperationalMode(ifconfig)
|
||||
return ip
|
||||
|
||||
@dbus.service.method('org.wicd.daemon.wireless')
|
||||
def CheckWirelessConnectingMessage(self):
|
||||
""" Returns the wireless interface's status message. """
|
||||
@@ -1677,3 +1700,4 @@ if __name__ == '__main__':
|
||||
sys.exit(1)
|
||||
gobject.threads_init()
|
||||
main(sys.argv)
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" Network interface control tools for wicd.
|
||||
|
||||
@@ -49,6 +50,7 @@ channel_pattern = re.compile('.*Channel:? ?(\d\d?)', __re_mode)
|
||||
strength_pattern = re.compile('.*Quality:?=? ?(\d+)\s*/?\s*(\d*)', __re_mode)
|
||||
altstrength_pattern = re.compile('.*Signal level:?=? ?(\d+)\s*/?\s*(\d*)', __re_mode)
|
||||
signaldbm_pattern = re.compile('.*Signal level:?=? ?(-\d\d*)', __re_mode)
|
||||
bitrates_pattern = re.compile('.*Bit Rates:(.*?)E', __re_mode)
|
||||
mode_pattern = re.compile('.*Mode:(.*?)\n', __re_mode)
|
||||
freq_pattern = re.compile('.*Frequency:(.*?)\n', __re_mode)
|
||||
wep_pattern = re.compile('.*Encryption key:(.*?)\n', __re_mode)
|
||||
@@ -59,6 +61,9 @@ wpa2_pattern = re.compile('(WPA2)', __re_mode)
|
||||
#iwconfig-only regular expressions.
|
||||
ip_pattern = re.compile(r'inet [Aa]d?dr[^.]*:([^.]*\.[^.]*\.[^.]*\.[0-9]*)',re.S)
|
||||
bssid_pattern = re.compile('.*Access Point: (([0-9A-Z]{2}:){5}[0-9A-Z]{2})', __re_mode)
|
||||
bitrate_pattern = re.compile('.*Bit Rate=(.*?/s)', __re_mode)
|
||||
opmode_pattern = re.compile('.*Mode:(.*?) ', __re_mode)
|
||||
authmethods_pattern = re.compile('.*Authentication capabilities :\n(.*?)Current', __re_mode)
|
||||
|
||||
# Regular expressions for wpa_cli output
|
||||
auth_pattern = re.compile('.*wpa_state=(.*?)\n', __re_mode)
|
||||
@@ -1035,7 +1040,6 @@ class BaseWirelessInterface(BaseInterface):
|
||||
A dictionary containing the cell networks properties.
|
||||
|
||||
"""
|
||||
|
||||
ap = {}
|
||||
ap['essid'] = misc.RunRegex(essid_pattern, cell)
|
||||
try:
|
||||
@@ -1056,6 +1060,10 @@ class BaseWirelessInterface(BaseInterface):
|
||||
freq = misc.RunRegex(freq_pattern, cell)
|
||||
ap['channel'] = self._FreqToChannel(freq)
|
||||
|
||||
# Bit Rate
|
||||
ap['bitrates'] = misc.RunRegex(bitrates_pattern, cell).split('\n')
|
||||
ap['bitrates'] = '; '.join(m.strip() for m in ap['bitrates']).rstrip('; ')
|
||||
|
||||
# BSSID
|
||||
ap['bssid'] = misc.RunRegex(ap_mac_pattern, cell)
|
||||
|
||||
@@ -1180,6 +1188,45 @@ class BaseWirelessInterface(BaseInterface):
|
||||
bssid = misc.RunRegex(bssid_pattern, output)
|
||||
return bssid
|
||||
|
||||
def GetCurrentBitrate(self, iwconfig=None):
|
||||
""" Get the current bitrate for the interface. """
|
||||
if not iwconfig:
|
||||
cmd = 'iwconfig ' + self.iface
|
||||
if self.verbose: print cmd
|
||||
output = misc.Run(cmd)
|
||||
else:
|
||||
output = iwconfig
|
||||
|
||||
bitrate = misc.RunRegex(bitrate_pattern, output)
|
||||
return bitrate
|
||||
|
||||
def GetOperationalMode(self, iwconfig=None):
|
||||
""" Get the operational mode for the interface. """
|
||||
if not iwconfig:
|
||||
cmd = 'iwconfig ' + self.iface
|
||||
if self.verbose: print cmd
|
||||
output = misc.Run(cmd)
|
||||
else:
|
||||
output = iwconfig
|
||||
|
||||
opmode = misc.RunRegex(opmode_pattern, output)
|
||||
if opmode:
|
||||
opmode = opmode.strip()
|
||||
return opmode
|
||||
|
||||
def GetAvailableAuthMethods(self, iwlistauth=None):
|
||||
""" Get the available authentication methods for the interface. """
|
||||
if not iwlistauth:
|
||||
cmd = 'iwlist ' + self.iface + ' auth'
|
||||
if self.verbose: print cmd
|
||||
output = misc.Run(cmd)
|
||||
else:
|
||||
output = iwlistauth
|
||||
|
||||
authm = misc.RunRegex(authmethods_pattern, output)
|
||||
authm_list = [m.strip() for m in authm.split('\n') if m.strip()]
|
||||
return ';'.join(authm_list)
|
||||
|
||||
def _get_link_quality(self, output):
|
||||
""" Parse out the link quality from iwlist scan or iwconfig output. """
|
||||
try:
|
||||
@@ -1247,3 +1294,4 @@ class BaseWirelessInterface(BaseInterface):
|
||||
if network:
|
||||
network = misc.to_unicode(network)
|
||||
return network
|
||||
|
||||
|
||||
Reference in New Issue
Block a user