1
0
mirror of https://github.com/gryf/wicd.git synced 2026-01-07 22:34:18 +01:00

experimental:

- Use the full path to wpa_passphrase.
- Fix some crashing bugs in the daemon and configscript.py
- Port a few changes/fixes from trunk.
- Some minor refactoring.
This commit is contained in:
imdano
2008-09-18 21:18:40 +00:00
parent 55e292b3c1
commit 890b5ee16a
9 changed files with 56 additions and 49 deletions

View File

@@ -12,8 +12,8 @@ network={
group=CCMP TKIP
key-mgmt=WPA-EAP
eap=FAST
identity=$_USERNAME
password=$_PASSWORD
identity="$_USERNAME"
password="$_PASSWORD"
phase1="fast_provisioning=1"
pac-file="$_PAC_FILE"
}

View File

@@ -55,6 +55,12 @@ class BackendManager(object):
if self._valid_backend_file(os.path.join(self.backend_dir, f)):
be_list.append(f[3:-3])
return be_list
def get_update_interval(self):
if self.__loaded_backend:
return self.__loaded_backend.UPDATE_INTERVAL
else:
return None
def load_backend(self, backend_name):
""" Load and return a backend module.

View File

@@ -30,11 +30,11 @@ import sys
import os
import gtk
import ConfigParser
import dbus
import gtk.glade
import wicd.wpath as wpath
import wicd.misc as misc
from wicd import wpath
from wicd import misc
from wicd import dbusmanager
_ = misc.get_gettext()
@@ -44,20 +44,11 @@ language['before_script'] = _("Pre-connection Script")
language['after_script'] = _("Post-connection Script")
language['disconnect_script'] = _("Disconnection Script")
bus = dbus.SystemBus()
dbus = dbusmanager.DBusManager()
dbus.connect_to_dbus()
# Connect to the daemon
try:
print 'Attempting to connect tray to daemon...'
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
print 'Success.'
except Exception:
print 'Daemon not running...'
misc.PromptToStartDaemon()
sys.exit(1)
wireless = dbus.Interface(proxy_obj, 'org.wicd.daemon.wireless')
wired = dbus.Interface(proxy_obj, 'org.wicd.daemon.wired')
wireless = dbus.get_interface("wireless")
wired = dbus.get_interface("wired")
wireless_conf = wpath.etc + 'wireless-settings.conf'
wired_conf = wpath.etc + 'wired-settings.conf'

View File

@@ -34,6 +34,9 @@ class DBusManager(object):
""" Returns a dict of dbus interfaces. """
return self._dbus_ifaces
def get_interface(self, iface):
return self._dbus_ifaces[iface]
def get_bus(self):
""" Returns the loaded SystemBus. """
return self._bus

View File

@@ -1,8 +1,8 @@
""" Misc - miscellaneous functions for wicd """
#
# Copyright (C) 2007 Adam Blackburn
# Copyright (C) 2007 Dan O'Reilly
# Copyright (C) 2007 - 2008 Adam Blackburn
# Copyright (C) 2007 - 2008 Dan O'Reilly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License Version 2 as
@@ -109,7 +109,7 @@ def IsValidIP(ip):
def PromptToStartDaemon():
""" Prompt the user to start the daemon """
daemonloc = wpath.bin + 'launchdaemon.sh'
daemonloc = wpath.sbin + 'wicd'
sudo_prog = choose_sudo_prog()
if sudo_prog.endswith("gksu") or sudo_prog.endswith("ktsuss"):
msg = '--message'
@@ -275,8 +275,7 @@ def get_gettext():
""" Set up gettext for translations. """
# Borrowed from an excellent post on how to do this at
# http://www.learningpython.com/2006/12/03/translating-your-pythonpygtk-application/
local_path = os.path.realpath(os.path.dirname(sys.argv[0])) + \
'/translations'
local_path = wpath.translations
langs = []
lc, encoding = locale.getdefaultlocale()
if (lc):
@@ -350,6 +349,13 @@ def choose_sudo_prog():
raise WicdError("Couldn't find graphical sudo program.")
def find_path(cmd):
paths = os.getenv("PATH", default=["/usr/bin", "/usr/local/bin"]).split(':')
for path in paths:
if os.access(os.path.join(path, cmd), os.F_OK):
return os.path.join(path, cmd)
return None
def get_language_list_gui():
""" Returns a dict of translatable strings used by the GUI.

View File

@@ -284,8 +284,7 @@ def main():
""" Starts the connection monitor.
Starts a ConnectionStatus instance, sets the status to update
every two seconds, and sets a wireless scan to be called every
two minutes.
an amount of time determined by the active backend.
"""
monitor = ConnectionStatus()

View File

@@ -18,9 +18,9 @@ class WiredConnectThread() -- Connection thread for wired
"""
#
# Copyright (C) 2007 Adam Blackburn
# Copyright (C) 2007 Dan O'Reilly
# Copyright (C) 2007 Byron Hillis
# Copyright (C) 2007 - 2008 Adam Blackburn
# Copyright (C) 2007 - 2008 Dan O'Reilly
# Copyright (C) 2007 - 2008 Byron Hillis
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License Version 2 as
@@ -58,22 +58,22 @@ BACKEND = None
BACKEND_MGR = BackendManager()
def get_backend_list():
if not BACKEND_MGR:
return [""]
else:
if BACKEND_MGR:
return BACKEND_MGR.get_available_backends()
else:
return [""]
def get_backend_update_interval():
if not BACKEND_MGR:
return 4
if BACKEND_MGR:
return BACKEND_MGR.get_update_interval()
else:
return BACKEND_MGR.UPDATE_INTERVAL
return 4 # seconds, this should never happen though.
def get_current_backend():
if not BACKEND_MGR:
return None
else:
if BACKEND_MGR:
return BACKEND_MGR.get_current_backend()
else:
return None
class Controller(object):
""" Parent class for the different interface types. """
@@ -776,14 +776,15 @@ class WirelessConnectThread(ConnectThread):
self.SetStatus('generating_psk')
print 'Generating psk...'
key_pattern = re.compile('network={.*?\spsk=(.*?)\n}.*',
re.I | re.M | re.S)
self.network['psk'] = misc.RunRegex(key_pattern,
misc.Run(''.join(['wpa_passphrase "',
self.network['essid'], '" "',
_sanitize(self.network['key']), '"'])))
wpa_pass_path = misc.find_path('wpa_passphrase')
if wpa_pass_path:
key_pattern = re.compile('network={.*?\spsk=(.*?)\n}.*',
re.I | re.M | re.S)
cmd = ''.join([wpa_pass_path, ' "', self.network['essid'],
'" "', _sanitize(self.network['key']), '"'])
self.network['psk'] = misc.RunRegex(key_pattern, misc.Run(cmd))
if not self.network['psk']:
if not self.network.get('psk'):
self.network['psk'] = self.network['key']
print 'WARNING: PSK generation failed! Falling back to ' + \
'wireless key.\nPlease report this error to the wicd ' + \

View File

@@ -227,7 +227,7 @@ class PreferencesDialog(object):
daemon.SetAlwaysShowWiredInterface(self.wiredcheckbox.get_active())
daemon.SetAutoReconnect(self.reconnectcheckbox.get_active())
daemon.SetDebugMode(self.debugmodecheckbox.get_active())
wireless.SetSignalDisplayType(self.displaytypecheckbox.get_active())
daemon.SetSignalDisplayType(self.displaytypecheckbox.get_active())
if self.showlistradiobutton.get_active():
wired.SetWiredAutoConnectMethod(2)
elif self.lastusedradiobutton.get_active():

View File

@@ -55,6 +55,7 @@ else:
from wicd import wpath
from wicd import networking
from wicd import misc
from wicd.misc import noneToBlankString
from wicd.logfile import ManagedStdio
from wicd.configmanager import ConfigManager
@@ -131,8 +132,8 @@ class WicdDaemon(dbus.service.Object):
def SetWiredInterface(self, interface):
""" Sets the wired interface for the daemon to use. """
print "setting wired interface %s" % (str(interface))
self.wired.wired_interface = interface
self.wifi.wired_interface = interface
self.wired.wired_interface = noneToBlankString(interface)
self.wifi.wired_interface = noneToBlankString(interface)
self.config.set("Settings", "wired_interface", interface, True)
@dbus.service.method('org.wicd.daemon')
@@ -193,8 +194,8 @@ class WicdDaemon(dbus.service.Object):
""" Returns the currently loaded backend. """
return networking.get_current_backend()
@dbus.server.method('org.wicd.daemon')
def GetBackendUpdateInterval('org.wicd.daemon'):
@dbus.service.method('org.wicd.daemon')
def GetBackendUpdateInterval(self):
""" Returns status update interval for the loaded backend. """
return networking.get_backend_update_interval()