diff --git a/data/wicd.glade b/data/wicd.glade index 234fd4a..425bae3 100644 --- a/data/wicd.glade +++ b/data/wicd.glade @@ -1,6 +1,6 @@ - + 450 @@ -429,15 +429,14 @@ 4 4 - + True - 24 + 12 - + True True - If enabled, the wired network interface will always be displayed in the main window. This can be useful if your wired network card does not detect when the interface is connected to a cable. - Always show wired interface + Automatically reconnect on network connection loss 0 True @@ -445,278 +444,44 @@ 2 - 3 - 4 + 15 + 16 - - True - True - - - 1 - 2 - 6 - 7 - - - - - - True - True - - - 1 - 2 - 7 - 8 - - - - - - True - True - - - 1 - 2 - 8 - 9 - - - - - + True 0 - <b>Global DNS Servers</b> + <b>Wireless automatic connection</b> True 2 - 4 - 5 + 14 + 15 - + True 12 - + True True - Use global DNS servers - 0 - True - - - - - 2 - 5 - 6 - - - - - - True - 24 - - - True - 0 - Search domain: - - - - - 6 - 7 - - - - - - True - 24 - - - True - 0 - DNS server 1: - - - - - 7 - 8 - - - - - - True - 24 - - - True - 0 - DNS server 2: - - - - - 8 - 9 - - - - - - True - True - - - 1 - 2 - 9 - 10 - - - - - - True - 24 - - - True - 0 - DNS server 3: - - - - - 9 - 10 - - - - - - True - 0 - <b>Network Interfaces</b> - True - - - 2 - - - - - - True - True - - - 1 - 2 - 1 - 2 - - - - - - True - True - - - 1 - 2 - 2 - 3 - - - - - - True - 12 - - - True - 0 - Wireless interface: - - - - - 1 - 2 - - - - - - True - 12 - - - True - 0 - Wired interface: - - - - - 2 - 3 - - - - - - True - 0 - <b>Wired automatic connection</b> - True - - - 2 - 10 - 11 - - - - - - True - 12 - - - True - True - Use default wired network profile + Use last wired network profile 0 True True - pref_use_last_radio 2 - 11 - 12 + 13 + 14 @@ -744,50 +509,210 @@ - + True 12 - + True True - Use last wired network profile + Use default wired network profile 0 True True + pref_use_last_radio 2 - 13 - 14 + 11 + 12 - + True 0 - <b>Wireless automatic connection</b> + <b>Wired automatic connection</b> True 2 - 14 - 15 + 10 + 11 - + True 12 - + + True + 0 + Wired interface: + + + + + 2 + 3 + + + + + + True + 12 + + + True + 0 + Wireless interface: + + + + + 1 + 2 + + + + + + True + True + + + 1 + 2 + 2 + 3 + + + + + + True + True + + + 1 + 2 + 1 + 2 + + + + + + True + 0 + <b>Network Interfaces</b> + True + + + 2 + + + + + + True + 24 + + + True + 0 + DNS server 3: + + + + + 9 + 10 + + + + + + True + True + + + 1 + 2 + 9 + 10 + + + + + + True + 24 + + + True + 0 + DNS server 2: + + + + + 8 + 9 + + + + + + True + 24 + + + True + 0 + DNS server 1: + + + + + 7 + 8 + + + + + + True + 24 + + + True + 0 + Search domain: + + + + + 6 + 7 + + + + + + True + 12 + + True True - Automatically connect to on network connection loss + Use global DNS servers 0 True @@ -795,8 +720,83 @@ 2 - 15 - 16 + 5 + 6 + + + + + + True + 0 + <b>Global DNS Servers</b> + True + + + 2 + 4 + 5 + + + + + + True + True + + + 1 + 2 + 8 + 9 + + + + + + True + True + + + 1 + 2 + 7 + 8 + + + + + + True + True + + + 1 + 2 + 6 + 7 + + + + + + True + 24 + + + True + True + If enabled, the wired network interface will always be displayed in the main window. This can be useful if your wired network card does not detect when the interface is connected to a cable. + Always show wired interface + 0 + True + + + + + 2 + 3 + 4 @@ -841,13 +841,146 @@ True 6 - + True 0 - <b>DHCP Client</b> + <b>Route Table Flushing</b> True + 4 + 5 + + + + + + True + 0 + <b>Wired Link Detection</b> + True + + + 2 + 3 + + + + + + True + 12 + + + True + + + True + True + Automatic (recommended) + 0 + True + True + + + False + + + + + True + True + ip + 0 + True + True + flush_auto_radio + + + False + 1 + + + + + True + True + route + 0 + True + True + flush_auto_radio + + + False + 2 + + + + + + + 5 + 6 + + + + + + True + 12 + + + True + + + True + True + Automatic (recommended) + 0 + True + True + + + False + + + + + True + True + ethtool + 0 + True + True + link_auto_radio + + + False + 1 + + + + + True + True + mii-tool + 0 + True + True + link_auto_radio + + + False + 2 + + + + + + + 3 + 4 @@ -926,146 +1059,13 @@ - - True - 12 - - - True - - - True - True - Automatic (recommended) - 0 - True - True - - - False - - - - - True - True - ethtool - 0 - True - True - link_auto_radio - - - False - 1 - - - - - True - True - mii-tool - 0 - True - True - link_auto_radio - - - False - 2 - - - - - - - 3 - 4 - - - - - - True - 12 - - - True - - - True - True - Automatic (recommended) - 0 - True - True - - - False - - - - - True - True - ip - 0 - True - True - flush_auto_radio - - - False - 1 - - - - - True - True - route - 0 - True - True - flush_auto_radio - - - False - 2 - - - - - - - 5 - 6 - - - - - + True 0 - <b>Wired Link Detection</b> + <b>DHCP Client</b> True - 2 - 3 - - - - - - True - 0 - <b>Route Table Flushing</b> - True - - - 4 - 5 @@ -1101,30 +1101,21 @@ True - 9 + 10 2 - - True - - - 2 - 3 - - - - - + True 0 - You should almost always use wext as the WPA supplicant driver. + Hover your mouse over the selected backend +to read its description. True 1 2 - 2 - 3 + 5 + 6 @@ -1149,28 +1140,113 @@ - + True - 0 - <b>Backend</b> - True - 2 - 3 - 4 + 2 + 3 + GTK_FILL - + True + 12 + + + True + 0 + Driver: + + + + + 1 + 2 + + + + + + True + 12 + + + True + True + Use dBm to measure signal strength + 0 + True + + - 1 2 - 4 - 5 + 9 + 10 + + + + + + True + 12 + + + True + True + Enable debug mode + 0 + True + + + + + 2 + 7 + 8 + + + + + + True + 0 + <b>Wireless Interface</b> + True + + + 2 + 8 + 9 + + + + + + True + 0 + <b>WPA Supplicant</b> + True + + + 2 + + + + + + True + 0 + <b>Debugging</b> + True + + + 2 + 6 + 7 @@ -1193,102 +1269,56 @@ - + + True + True + + + 1 + 2 + 4 + 5 + + + + + True 0 - <b>Debugging</b> + <b>Backend</b> True 2 + 3 + 4 + + + + + + True + 0 + You should almost always use wext as the +WPA supplicant driver. + True + + + 1 + 2 + 2 + 3 + + + + + + True + + 5 6 - - - - - - True - 0 - <b>WPA Supplicant</b> - True - - - 2 - - - - - - True - 0 - <b>Wireless Interface</b> - True - - - 2 - 7 - 8 - - - - - - True - 12 - - - True - True - Enable debug mode - 0 - True - - - - - 2 - 6 - 7 - - - - - - True - 12 - - - True - True - Use dBm to measure signal strength - 0 - True - - - - - 2 - 8 - 9 - - - - - - True - 12 - - - True - 0 - Driver: - - - - - 1 - 2 + GTK_FILL diff --git a/images/bad-signal-lock.png b/images/bad-signal-lock.png index 83999b1..0b5ff2f 100644 Binary files a/images/bad-signal-lock.png and b/images/bad-signal-lock.png differ diff --git a/images/bad-signal.png b/images/bad-signal.png index 9896fb0..0b5ff2f 100644 Binary files a/images/bad-signal.png and b/images/bad-signal.png differ diff --git a/images/both-bad-signal-lock.png b/images/both-bad-signal-lock.png old mode 100755 new mode 100644 index fcdb8a5..38cb205 Binary files a/images/both-bad-signal-lock.png and b/images/both-bad-signal-lock.png differ diff --git a/images/both-bad-signal.png b/images/both-bad-signal.png old mode 100755 new mode 100644 index 999608b..38cb205 Binary files a/images/both-bad-signal.png and b/images/both-bad-signal.png differ diff --git a/images/both-good-signal-lock.png b/images/both-good-signal-lock.png old mode 100755 new mode 100644 index 66a326b..2bb8626 Binary files a/images/both-good-signal-lock.png and b/images/both-good-signal-lock.png differ diff --git a/images/both-good-signal.png b/images/both-good-signal.png old mode 100755 new mode 100644 index 5415126..2bb8626 Binary files a/images/both-good-signal.png and b/images/both-good-signal.png differ diff --git a/images/both-high-signal-lock.png b/images/both-high-signal-lock.png old mode 100755 new mode 100644 index d08aa99..5132836 Binary files a/images/both-high-signal-lock.png and b/images/both-high-signal-lock.png differ diff --git a/images/both-high-signal.png b/images/both-high-signal.png old mode 100755 new mode 100644 index 746f7d5..5132836 Binary files a/images/both-high-signal.png and b/images/both-high-signal.png differ diff --git a/images/both-low-signal-lock.png b/images/both-low-signal-lock.png old mode 100755 new mode 100644 index cc1bc35..7ab10fd Binary files a/images/both-low-signal-lock.png and b/images/both-low-signal-lock.png differ diff --git a/images/both-low-signal.png b/images/both-low-signal.png old mode 100755 new mode 100644 index 095b911..7ab10fd Binary files a/images/both-low-signal.png and b/images/both-low-signal.png differ diff --git a/images/good-signal-lock.png b/images/good-signal-lock.png index 5273ab3..9109295 100644 Binary files a/images/good-signal-lock.png and b/images/good-signal-lock.png differ diff --git a/images/good-signal.png b/images/good-signal.png index 3e09cdb..9109295 100644 Binary files a/images/good-signal.png and b/images/good-signal.png differ diff --git a/images/high-signal-lock.png b/images/high-signal-lock.png index 91a9bc5..6223add 100644 Binary files a/images/high-signal-lock.png and b/images/high-signal-lock.png differ diff --git a/images/high-signal.png b/images/high-signal.png index 4fb76f1..6223add 100644 Binary files a/images/high-signal.png and b/images/high-signal.png differ diff --git a/images/idle-bad-signal-lock.png b/images/idle-bad-signal-lock.png old mode 100755 new mode 100644 index 83999b1..0b5ff2f Binary files a/images/idle-bad-signal-lock.png and b/images/idle-bad-signal-lock.png differ diff --git a/images/idle-bad-signal.png b/images/idle-bad-signal.png old mode 100755 new mode 100644 index 9896fb0..0b5ff2f Binary files a/images/idle-bad-signal.png and b/images/idle-bad-signal.png differ diff --git a/images/idle-good-signal-lock.png b/images/idle-good-signal-lock.png old mode 100755 new mode 100644 index 5273ab3..9109295 Binary files a/images/idle-good-signal-lock.png and b/images/idle-good-signal-lock.png differ diff --git a/images/idle-good-signal.png b/images/idle-good-signal.png old mode 100755 new mode 100644 index 3e09cdb..9109295 Binary files a/images/idle-good-signal.png and b/images/idle-good-signal.png differ diff --git a/images/idle-high-signal-lock.png b/images/idle-high-signal-lock.png old mode 100755 new mode 100644 index 91a9bc5..6223add Binary files a/images/idle-high-signal-lock.png and b/images/idle-high-signal-lock.png differ diff --git a/images/idle-high-signal.png b/images/idle-high-signal.png old mode 100755 new mode 100644 index 4fb76f1..6223add Binary files a/images/idle-high-signal.png and b/images/idle-high-signal.png differ diff --git a/images/idle-low-signal-lock.png b/images/idle-low-signal-lock.png old mode 100755 new mode 100644 index 0a8b0fd..c569e5c Binary files a/images/idle-low-signal-lock.png and b/images/idle-low-signal-lock.png differ diff --git a/images/idle-low-signal.png b/images/idle-low-signal.png old mode 100755 new mode 100644 index 53325d4..c569e5c Binary files a/images/idle-low-signal.png and b/images/idle-low-signal.png differ diff --git a/images/low-signal-lock.png b/images/low-signal-lock.png index 0a8b0fd..c569e5c 100644 Binary files a/images/low-signal-lock.png and b/images/low-signal-lock.png differ diff --git a/images/low-signal.png b/images/low-signal.png index 53325d4..c569e5c 100644 Binary files a/images/low-signal.png and b/images/low-signal.png differ diff --git a/images/receiving-bad-signal-lock.png b/images/receiving-bad-signal-lock.png old mode 100755 new mode 100644 index 1403214..0d54c5d Binary files a/images/receiving-bad-signal-lock.png and b/images/receiving-bad-signal-lock.png differ diff --git a/images/receiving-bad-signal.png b/images/receiving-bad-signal.png old mode 100755 new mode 100644 index 1721559..0d54c5d Binary files a/images/receiving-bad-signal.png and b/images/receiving-bad-signal.png differ diff --git a/images/receiving-good-signal-lock.png b/images/receiving-good-signal-lock.png old mode 100755 new mode 100644 index 5d6b591..752c233 Binary files a/images/receiving-good-signal-lock.png and b/images/receiving-good-signal-lock.png differ diff --git a/images/receiving-good-signal.png b/images/receiving-good-signal.png old mode 100755 new mode 100644 index 241875f..752c233 Binary files a/images/receiving-good-signal.png and b/images/receiving-good-signal.png differ diff --git a/images/receiving-high-signal-lock.png b/images/receiving-high-signal-lock.png old mode 100755 new mode 100644 index edf3787..22393ce Binary files a/images/receiving-high-signal-lock.png and b/images/receiving-high-signal-lock.png differ diff --git a/images/receiving-high-signal.png b/images/receiving-high-signal.png old mode 100755 new mode 100644 index 96eeedc..22393ce Binary files a/images/receiving-high-signal.png and b/images/receiving-high-signal.png differ diff --git a/images/receiving-low-signal-lock.png b/images/receiving-low-signal-lock.png old mode 100755 new mode 100644 index 3bc8f4b..f0db613 Binary files a/images/receiving-low-signal-lock.png and b/images/receiving-low-signal-lock.png differ diff --git a/images/receiving-low-signal.png b/images/receiving-low-signal.png old mode 100755 new mode 100644 index 88e1b54..f0db613 Binary files a/images/receiving-low-signal.png and b/images/receiving-low-signal.png differ diff --git a/images/signal-100.png b/images/signal-100.png index da3aa0d..744a12b 100644 Binary files a/images/signal-100.png and b/images/signal-100.png differ diff --git a/images/signal-25.png b/images/signal-25.png index 19e5d29..d6ef732 100644 Binary files a/images/signal-25.png and b/images/signal-25.png differ diff --git a/images/signal-50.png b/images/signal-50.png index 10dde52..586213b 100644 Binary files a/images/signal-50.png and b/images/signal-50.png differ diff --git a/images/signal-75.png b/images/signal-75.png index ef9cd39..eaadde4 100644 Binary files a/images/signal-75.png and b/images/signal-75.png differ diff --git a/images/transmitting-bad-signal-lock.png b/images/transmitting-bad-signal-lock.png old mode 100755 new mode 100644 index 203e7da..41878ae Binary files a/images/transmitting-bad-signal-lock.png and b/images/transmitting-bad-signal-lock.png differ diff --git a/images/transmitting-bad-signal.png b/images/transmitting-bad-signal.png old mode 100755 new mode 100644 index 9d7ec0b..41878ae Binary files a/images/transmitting-bad-signal.png and b/images/transmitting-bad-signal.png differ diff --git a/images/transmitting-good-signal-lock.png b/images/transmitting-good-signal-lock.png old mode 100755 new mode 100644 index 7735f1b..baa6c1c Binary files a/images/transmitting-good-signal-lock.png and b/images/transmitting-good-signal-lock.png differ diff --git a/images/transmitting-good-signal.png b/images/transmitting-good-signal.png old mode 100755 new mode 100644 index 7538e36..baa6c1c Binary files a/images/transmitting-good-signal.png and b/images/transmitting-good-signal.png differ diff --git a/images/transmitting-high-signal-lock.png b/images/transmitting-high-signal-lock.png old mode 100755 new mode 100644 index 4c719fe..9907e5d Binary files a/images/transmitting-high-signal-lock.png and b/images/transmitting-high-signal-lock.png differ diff --git a/images/transmitting-high-signal.png b/images/transmitting-high-signal.png old mode 100755 new mode 100644 index b6749d6..9907e5d Binary files a/images/transmitting-high-signal.png and b/images/transmitting-high-signal.png differ diff --git a/images/transmitting-low-signal-lock.png b/images/transmitting-low-signal-lock.png old mode 100755 new mode 100644 index 0accd7d..a1a02ef Binary files a/images/transmitting-low-signal-lock.png and b/images/transmitting-low-signal-lock.png differ diff --git a/images/transmitting-low-signal.png b/images/transmitting-low-signal.png old mode 100755 new mode 100644 index a73b632..a1a02ef Binary files a/images/transmitting-low-signal.png and b/images/transmitting-low-signal.png differ diff --git a/images/wicd-client.png b/images/wicd-client.png index e69de29..1487bdb 100644 Binary files a/images/wicd-client.png and b/images/wicd-client.png differ diff --git a/wicd/backend.py b/wicd/backend.py index b9d0894..cb6ae49 100644 --- a/wicd/backend.py +++ b/wicd/backend.py @@ -29,6 +29,10 @@ import os import wicd.wpath as wpath +def fail(backend_name, reason): + print "Failed to load backend %s: %s" % (backend_name, reason) + return True + class BackendManager(object): """ Manages, validates, and loads wicd backends. """ @@ -39,7 +43,7 @@ class BackendManager(object): def _valid_backend_file(self, be_file): """ Make sure the backend file is valid. """ - return (os.access(be_file, os.F_OK) and + return (os.path.exists(be_file) and os.path.basename(be_file).startswith("be-") and be_file.endswith(".py")) @@ -65,30 +69,30 @@ class BackendManager(object): else: return None - def load_backend(self, backend_name): - """ Load and return a backend module. - - Given a backend name be-foo, attempt to load a python module - in the backends directory called be-foo.py. The module must - include a certain set of classes and variables to be considered - valid. - - """ - def fail(backend_name, reason): - print "Failed to load backend %s: %s" % (backend_name, reason) - return True - - failed = False + def get_backend_description(self, backend_name): + """ Loads a backend and returns its description. """ + backend = self._load_backend(backend_name) + if backend and backend.DESCRIPTION: + return backend.DESCRIPTION + else: + return "No backend data available" + + def _load_backend(self, backend_name): + """ Imports a backend and returns the loaded module. """ print 'trying to load backend %s' % backend_name backend_path = os.path.join(self.backend_dir, 'be-' + backend_name + '.py') if self._valid_backend_file(backend_path): sys.path.insert(0, self.backend_dir) backend = __import__('be-' + backend_name) + return backend else: fail(backend_name, 'Invalid backend file.') return None + def _validate_backend(self, backend): + """ Ensures that a backend module is valid. """ + failed = False if not backend.NAME: failed = fail(backend_name, 'Missing NAME attribute.') if not backend.UPDATE_INTERVAL: @@ -99,7 +103,21 @@ class BackendManager(object): failed = fail(backend_name, "Missing WiredInterface class.") if not backend.WirelessInterface: failed = fail(backend_name, "Missing WirelessInterface class.") + return failed + + def load_backend(self, backend_name): + """ Load and return a backend module. + Given a backend name be-foo, attempt to load a python module + in the backends directory called be-foo.py. The module must + include a certain set of classes and variables to be considered + valid. + + """ + backend = self._load_backend(backend_name) + if not backend : return None + + failed = self._validate_backend(backend) if failed: return None diff --git a/wicd/backends/be-external.py b/wicd/backends/be-external.py index 801574d..f801c33 100644 --- a/wicd/backends/be-external.py +++ b/wicd/backends/be-external.py @@ -41,13 +41,13 @@ import time NAME = "external" -UPDATE_INTERVAL = 4 -DESCRIPTION = """External app (slow) backend +UPDATE_INTERVAL = 5 +DESCRIPTION = """External app (original) backend This backend uses external program calls like ifconfig and iwconfig to query network information. This makes it a bit slower and more CPU intensive than the ioctl backend, but -it doesn't require any thirdy party libraries and may be +it doesn't require any third party libraries and may be more stable for some set ups. """ @@ -119,7 +119,7 @@ class Interface(wnettools.BaseInterface): """ wnettools.BaseInterface.__init__(self, iface, verbose) self.Check() - + def GetIP(self, ifconfig=""): """ Get the IP address of the interface. diff --git a/wicd/backends/be-ioctl.py b/wicd/backends/be-ioctl.py index b8d22ec..b100201 100644 --- a/wicd/backends/be-ioctl.py +++ b/wicd/backends/be-ioctl.py @@ -48,8 +48,8 @@ import array NAME = "ioctl" -UPDATE_INTERVAL = 3 -DESCRIPTION = """IOCTL (fast) backend +UPDATE_INTERVAL = 4 +DESCRIPTION = """IOCTL (new) backend This backend uses IOCTL calls and python libraries to query network information whenever possible. This makes it fast, diff --git a/wicd/dbusmanager.py b/wicd/dbusmanager.py index cc05e10..0063f64 100644 --- a/wicd/dbusmanager.py +++ b/wicd/dbusmanager.py @@ -42,7 +42,7 @@ def get_bus(): return DBUS_MANAGER.get_bus() def set_mainloop(): - return DBUS_MANAGER.connect_to_mainloop() + return DBUS_MANAGER.set_mainloop() def connect_to_dbus(): return DBUS_MANAGER.connect_to_dbus() @@ -50,6 +50,7 @@ def connect_to_dbus(): def threads_init(): dbus.mainloop.glib.threads_init() + class DBusManager(object): """ Manages the DBus objects used by wicd. """ def __init__(self): @@ -58,10 +59,12 @@ class DBusManager(object): def get_dbus_ifaces(self): """ Returns a dict of dbus interfaces. """ + if not self._dbus_ifaces: connect_to_dbus() return self._dbus_ifaces def get_interface(self, iface): """ Returns a DBus Interface. """ + if not self._dbus_ifaces: connect_to_dbus() return self._dbus_ifaces[iface] def get_bus(self): diff --git a/wicd/gui.py b/wicd/gui.py index 83d709a..8d9f935 100644 --- a/wicd/gui.py +++ b/wicd/gui.py @@ -318,7 +318,7 @@ class appGui(object): print "Starting the Ad-Hoc Network Creation Process..." dialog = gtk.Dialog(title = language['create_adhoc_network'], flags = gtk.DIALOG_MODAL, - buttons=(gtk.STOCK_OK, 1, gtk.STOCK_CANCEL, 2)) + buttons=(gtk.STOCK_CANCEL, 2, gtk.STOCK_OK, 1)) dialog.set_has_separator(False) dialog.set_size_request(400, -1) self.chkbox_use_encryption = gtk.CheckButton(language['use_wep_encryption']) diff --git a/wicd/misc.py b/wicd/misc.py index 476df90..dcb9ce9 100644 --- a/wicd/misc.py +++ b/wicd/misc.py @@ -53,6 +53,7 @@ class WicdError(Exception): pass +__LANG = None def Run(cmd, include_stderr=False, return_pipe=False): """ Run a command. @@ -69,6 +70,7 @@ def Run(cmd, include_stderr=False, return_pipe=False): one output string from the command. """ + global __LANG if not isinstance(cmd, list): cmd = to_unicode(str(cmd)) cmd = cmd.split() @@ -79,21 +81,35 @@ def Run(cmd, include_stderr=False, return_pipe=False): err = None fds = False + # We need to make sure that the results of the command we run + # are in English, so we set up a temporary environment. + if not __LANG: + __LANG = get_good_lang() tmpenv = os.environ.copy() - tmpenv["LC_ALL"] = "C" - tmpenv["LANG"] = "C" + tmpenv["LC_ALL"] = __LANG + tmpenv["LANG"] = __LANG + try: f = Popen(cmd, shell=False, stdout=PIPE, stderr=err, close_fds=fds, cwd='/', env=tmpenv) except OSError, e: print "Running command %s failed: %s" % (str(cmd), str(e)) return "" + if return_pipe: return f.stdout else: return f.communicate()[0] +def get_good_lang(): + """ Check if en_US.utf8 is an available locale, if not use C. """ + output = Popen(["locale", "-a"], shell=False, stdout=PIPE).communicate()[0] + if "en_US.utf8" in output: + return "en_US.utf8" + else: + return "C" + def LaunchAndWait(cmd): """ Launches the given program with the given arguments, then blocks. diff --git a/wicd/monitor.py b/wicd/monitor.py index 27b2f1a..0256932 100755 --- a/wicd/monitor.py +++ b/wicd/monitor.py @@ -45,6 +45,8 @@ wired = dbus_dict["wired"] wireless = dbus_dict["wireless"] bus = dbusmanager.get_bus() +monitor = to_time = update_callback = None + class ConnectionStatus(object): """ Class for monitoring the computer's connection status. """ def __init__(self): @@ -61,6 +63,10 @@ class ConnectionStatus(object): self.last_reconnect_time = time.time() self.signal_changed = False self.iwconfig = "" + + bus = dbusmanager.get_bus() + bus.add_signal_receiver(self._force_update_connection_status, + "UpdateState", "org.wicd.daemon") def check_for_wired_connection(self, wired_ip): """ Checks for an active wired connection. @@ -163,7 +169,7 @@ class ConnectionStatus(object): if wireless_found: self.update_state(misc.WIRELESS, wifi_ip=wifi_ip) return True - + state = misc.NOT_CONNECTED if self.last_state == misc.WIRELESS: from_wireless = True @@ -174,6 +180,12 @@ class ConnectionStatus(object): except DBusException, e: print 'Ignoring DBus Error: ' + str(e) return True + + def _force_update_connection_status(self): + global update_callback + gobject.source_remove(update_callback) + self.update_connection_status() + add_poll_callback() def update_state(self, state, wired_ip=None, wifi_ip=None): """ Set the current connection state. """ @@ -274,7 +286,17 @@ def reply_handle(): def err_handle(error): """ Just a dummy function needed for asynchronous dbus calls. """ pass - + +def add_poll_callback(): + global monitor, to_time, update_callback + + try: + update_callback = gobject.timeout_add_seconds(to_time, + monitor.update_connection_status) + except: + update_callback = gobject.timeout_add(to_time * 1000, + monitor.update_connection_status) + def main(): """ Starts the connection monitor. @@ -282,15 +304,14 @@ def main(): an amount of time determined by the active backend. """ + global monitor, to_time + monitor = ConnectionStatus() to_time = daemon.GetBackendUpdateInterval() - try: - gobject.timeout_add_seconds(to_time, monitor.update_connection_status) - except: - gobject.timeout_add(to_time * 1000, monitor.update_connection_status) - + add_poll_callback() mainloop = gobject.MainLoop() mainloop.run() + if __name__ == '__main__': main() diff --git a/wicd/networking.py b/wicd/networking.py index 47b7e53..ae9832a 100644 --- a/wicd/networking.py +++ b/wicd/networking.py @@ -74,6 +74,7 @@ def abortable(func): return wrapper def get_backend_list(): + """ Returns a list of available backends. """ if BACKEND_MGR: return BACKEND_MGR.get_available_backends() else: @@ -83,7 +84,7 @@ def get_backend_update_interval(): if BACKEND_MGR: return BACKEND_MGR.get_update_interval() else: - return 4 # seconds, this should never happen though. + return 5 # Seconds, this should never happen though. def get_current_backend(): if BACKEND_MGR: @@ -91,6 +92,16 @@ def get_current_backend(): else: return None +def get_backend_description(backend_name): + return BACKEND_MGR.get_backend_description(backend_name) + +def get_backend_description_dict(): + d = {} + for be in get_backend_list(): + if be: + d[be] = get_backend_description(be) + return d + class Controller(object): """ Parent class for the different interface types. """ def __init__(self): @@ -598,7 +609,6 @@ class Wireless(Controller): enctype -- unused key -- key of the ad-hoc network enc_used -- encrytion enabled on ad-hoc network - ics -- enable internet connection sharing """ wiface = self.wiface diff --git a/wicd/prefs.py b/wicd/prefs.py index c8ca2c0..75551bb 100644 --- a/wicd/prefs.py +++ b/wicd/prefs.py @@ -56,7 +56,6 @@ class PreferencesDialog(object): wireless = dbus['wireless'] wired = dbus['wired'] self.wTree = wTree - self.wpadrivers = None self.prep_settings_diag() self.load_preferences_diag() @@ -119,8 +118,6 @@ class PreferencesDialog(object): self.dns3Entry.set_sensitive(False) cur_backend = daemon.GetSavedBackend() - self.backendcombo.set_active(0) - try: self.backendcombo.set_active(self.backends.index(cur_backend)) except ValueError: @@ -313,8 +310,10 @@ class PreferencesDialog(object): self.dns3Entry = self.wTree.get_widget("pref_dns3_entry") self.backendcombo = build_combobox("pref_backend_combobox") + self.backendcombo.connect("changed", self.be_combo_changed) # Load backend combobox self.backends = daemon.GetBackendList() + self.be_descriptions = daemon.GetBackendDescriptionDict() # "" is included as a hack for DBus limitations, so we remove it. self.backends.remove("") @@ -322,3 +321,8 @@ class PreferencesDialog(object): for x in self.backends: self.backendcombo.append_text(x) + def be_combo_changed(self, combo): + """ Update the description label for the given backend. """ + self.backendcombo.set_tooltip_text( + self.be_descriptions[combo.get_active_text()] + ) diff --git a/wicd/wicd-client.py b/wicd/wicd-client.py index 743b9e8..dab3f39 100755 --- a/wicd/wicd-client.py +++ b/wicd/wicd-client.py @@ -107,7 +107,7 @@ class TrayIcon(object): raise NotImplementedError else: return self.tr.is_embedded() - + class TrayConnectionInfo(object): """ Class for updating the tray icon status. """ @@ -230,7 +230,7 @@ class TrayIcon(object): img_file = ''.join([wpath.images, prefix, signal_img, lock, ".png"]) self.tr.set_from_file(img_file) - + def get_bandwidth_state(self): """ Determines what network activity state we are in. """ transmitting = False @@ -640,7 +640,7 @@ Arguments: \t-h\t--help\t\tPrint this help information. \t-a\t--no-animate\tRun the tray without network traffic tray animations. """ - + def setup_dbus(force=True): global bus, daemon, wireless, wired, DBUS_AVAIL print "Connecting to daemon..." diff --git a/wicd/wicd-daemon.py b/wicd/wicd-daemon.py index 5129653..739e43c 100644 --- a/wicd/wicd-daemon.py +++ b/wicd/wicd-daemon.py @@ -210,6 +210,16 @@ class WicdDaemon(dbus.service.Object): """ Returns status update interval for the loaded backend. """ return networking.get_backend_update_interval() + @dbus.service.method('org.wicd.daemon') + def GetBackendDescription(self, backend_name): + """ Returns the description of the given backend. """ + return networking.get_backend_description(backend_name) + + @dbus.service.method('org.wicd.daemon') + def GetBackendDescriptionDict(self): + """ Returns a dict of all backend names mapped to their description. """ + return networking.get_backend_description_dict() + @dbus.service.method('org.wicd.daemon') def GetSavedBackend(self): """ Returns the backend saved to disk. """ @@ -720,6 +730,10 @@ class WicdDaemon(dbus.service.Object): def ConnectResultsSent(self, result): print "Sending connection attempt result %s" % result + @dbus.service.signal(dbus_interface="org.wicd.daemon", signature='') + def UpdateState(self): + pass + @dbus.service.signal(dbus_interface='org.wicd.daemon', signature='') def LaunchChooser(self): """ Emits the wired profile chooser dbus signal. """ @@ -1326,8 +1340,7 @@ class WiredDaemon(dbus.service.Object): return False for option in ["ip", "broadcast", "netmask","gateway", "dns1", "dns2", - "dns3", "beforescript", "afterscript", - "disconnectscript"]: + "dns3", "beforescript", "afterscript", "disconnectscript"]: self.config.set(profilename, option, None) self.config.set(profilename, "default", default) self.config.write() diff --git a/wicd/wnettools.py b/wicd/wnettools.py index 5c70c75..dad8037 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -402,7 +402,7 @@ class BaseInterface(object): pump_success = False pump_complete = True print line - + return self._check_dhcp_result(pump_success) def _parse_dhcpcd(self, pipe):