1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-23 06:37:59 +01:00

Make backend combobox tooltip display the active backend's description.

Reverse the order of the OK/Cancel button in the Ad-Hoc connection dialog.
Use a new set of icons.
Extend the update invervals for all backends by 1 second.
Try to use en_US.utf8 instead of C as the LANG in misc.Run if it is available.
Add ability to force a network state update.  (Currently not used).
This commit is contained in:
Dan O'Reilly
2008-12-27 18:23:15 -05:00
parent eb2959cdde
commit 9caae86049
58 changed files with 674 additions and 559 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/both-bad-signal-lock.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1022 B

BIN
images/both-bad-signal.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1022 B

BIN
images/both-good-signal-lock.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/both-good-signal.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/both-high-signal-lock.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 946 B

BIN
images/both-high-signal.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 946 B

BIN
images/both-low-signal-lock.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1014 B

BIN
images/both-low-signal.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1014 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 978 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 978 B

BIN
images/idle-bad-signal-lock.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/idle-bad-signal.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/idle-good-signal-lock.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/idle-good-signal.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/idle-high-signal-lock.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 978 B

BIN
images/idle-high-signal.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 978 B

BIN
images/idle-low-signal-lock.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/idle-low-signal.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/receiving-bad-signal-lock.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/receiving-bad-signal.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/receiving-good-signal-lock.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/receiving-good-signal.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/receiving-high-signal-lock.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 978 B

BIN
images/receiving-high-signal.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 978 B

BIN
images/receiving-low-signal-lock.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/receiving-low-signal.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 894 B

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 863 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 890 B

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 850 B

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
images/transmitting-bad-signal-lock.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1018 B

BIN
images/transmitting-bad-signal.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1018 B

BIN
images/transmitting-good-signal-lock.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/transmitting-good-signal.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/transmitting-high-signal-lock.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 941 B

BIN
images/transmitting-high-signal.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 941 B

BIN
images/transmitting-low-signal-lock.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/transmitting-low-signal.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -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

View File

@@ -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.

View File

@@ -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,

View File

@@ -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):

View File

@@ -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'])

View File

@@ -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.

View File

@@ -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()

View File

@@ -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

View File

@@ -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()]
)

View File

@@ -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..."

View File

@@ -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()

View File

@@ -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):