diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py index 3fe5994..39b7544 100644 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -897,7 +897,7 @@ def main(): ('green','dark green','default'), ('blue','dark blue','default'), ('red','dark red','default'), - ('bold','white','default','bold')]) + ('bold','white','black','bold')]) # This is a wrapper around a function that calls another a function that is a # wrapper around a infinite loop. Fun. ui.run_wrapper(run) diff --git a/in/man=wicd-manager-settings.conf.5.in b/in/man=wicd-manager-settings.conf.5.in index 847e2f1..551824b 100644 --- a/in/man=wicd-manager-settings.conf.5.in +++ b/in/man=wicd-manager-settings.conf.5.in @@ -1,5 +1,5 @@ .\" Written by Robby Workman -.TH WICD-MANAGER-SETTINGS.CONF 5 "June 2008" "wicd-%VERSION%" +.TH WICD-MANAGER-SETTINGS.CONF 5 "wicd-%VERSION%" .SH NAME wicd-manager-settings.conf \- contains settings that control Wicd's behavior @@ -26,6 +26,9 @@ This file is located at %ETC%manager-settings.conf .br 2 = route .TP +.BI "backend = " +Default is ioctl backend. +.TP .BI "signal_display_type = " <0|1> 0 = Show signal strength as a percentage .br @@ -37,8 +40,18 @@ This file is located at %ETC%manager-settings.conf 1 = dhclient .br 2 = dhcpcd +.br 3 = pump .TP +.BI "sudo_app = " <0|1|2|3> +0 = autodetect +.br +1 = gksu +.br +2 = kdesu +.br +3 = ktsuss +.TP .BI "wired_interface = " .TP .BI "always_show_wired_interface = " @@ -48,6 +61,11 @@ This file is located at %ETC%manager-settings.conf .br 1 = do not connect to wired interface automatically .TP +.BI "prefer_wired = " +True = Switch to wired interface if a link is detected, even if already connected to wireless +.br +False = Do not switch to wired interface automatically +.TP .BI "wireless_interface = " .TP .BI "wpa_driver = " @@ -60,6 +78,9 @@ This settings determines whether Wicd will attempt to reconnect on connection lo If set to "True" and values are specified in the global DNS settings below, this will cause Wicd to use these DNS settings. .TP +.BI "global_dns_dom = " +This specifies the default search domain to be used by the resolver. +.TP .BI "global_dns_1 = " .TP .BI "global_dns_2 = " @@ -86,6 +107,7 @@ This determines the width of the "Preferences" window when launched from the cli .SH "SEE ALSO" .BR wicd (8), +.BR wicd-curses (8), .BR wicd-wired-settings.conf (5), .BR wicd-wireless-settings.conf (5). diff --git a/in/man=wicd-wired-settings.conf.5.in b/in/man=wicd-wired-settings.conf.5.in index 55a66cf..6d0b06c 100644 --- a/in/man=wicd-wired-settings.conf.5.in +++ b/in/man=wicd-wired-settings.conf.5.in @@ -1,5 +1,5 @@ .\" Written by Robby Workman -.TH WICD-WIRED-SETTINGS.CONF 5 "June 2008" "wicd-%VERSION%" +.TH WICD-WIRED-SETTINGS.CONF 5 "wicd-%VERSION%" .SH NAME wicd-wired-settings.conf \- controls Wicd's wired network settings @@ -70,6 +70,7 @@ Static DNS address if "use_static_dns = True" and "use_global_dns = False" .SH "SEE ALSO" .BR wicd (8), +.BR wicd-curses (8), .BR wicd-manager-settings.conf (5), .BR wicd-wireless-settings.conf (5). diff --git a/in/man=wicd-wireless-settings.conf.5.in b/in/man=wicd-wireless-settings.conf.5.in index cf1afd3..79ac751 100644 --- a/in/man=wicd-wireless-settings.conf.5.in +++ b/in/man=wicd-wireless-settings.conf.5.in @@ -1,5 +1,5 @@ .\" Written by Robby Workman -.TH WICD-WIRELESS-SETTINGS.CONF 5 "June 2008" "wicd-%VERSION%" +.TH WICD-WIRELESS-SETTINGS.CONF 5 "wicd-%VERSION%" .SH NAME wicd-wired-settings.conf \- controls Wicd's wireless network settings @@ -122,6 +122,7 @@ of the stanza will be in this format: .SH "SEE ALSO" .BR wicd (8), +.BR wicd-curses (8), .BR wicd-manager-settings.conf (5), .BR wicd-wired-settings.conf (5). diff --git a/in/man=wicd.8.in b/in/man=wicd.8.in index 9ca7591..55a5afb 100644 --- a/in/man=wicd.8.in +++ b/in/man=wicd.8.in @@ -1,5 +1,5 @@ .\" Written by Robby Workman -.TH WICD 8 "June 2008" "wicd-%VERSION%" +.TH WICD 8 "wicd-%VERSION%" .SH NAME .B Wicd \- Wired and Wireless Network Connection Manager @@ -139,6 +139,7 @@ log if you are having connection or other problems. .BR wicd-manager-settings.conf (5), .BR wicd-wired-settings.conf (5), .BR wicd-wireless-settings.conf (5), +.BR wicd-curses (8), .BR ifconfig (8), .BR iwconfig (8), .BR wpa_supplicant (8), @@ -155,6 +156,8 @@ log if you are having connection or other problems. Adam Blackburn .br Dan O'Reilly +.br +Andrew Psaltis (curses client) .SH MANPAGE AUTHOR Robby Workman diff --git a/in/other=postinst.in b/in/other=postinst.in deleted file mode 100755 index 0a1f0b2..0000000 --- a/in/other=postinst.in +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -# Stop daemon -if [ -f %INIT%%INITFILENAME% ]; then - %INIT%%INITFILENAME% stop -fi - -# Remove Wicd from the boot sequence -if which update-rc.d &>/dev/null ; then - update-rc.d -f wicd remove -fi - -# Remove pyc files -# They may exist if you are upgrading Wicd -rm -f /opt/wicd/*.pyc - -# Add Wicd to the startup sequence -# 80 to make sure that dbus is running when Wicd starts -if which update-rc.d &>/dev/null ; then - update-rc.d wicd start 80 2 3 4 5 . stop 20 0 1 6 . -fi - -# Start the daemon -if [ -f %INIT%%INITFILENAME% ]; then - %INIT%%INITFILENAME% start -fi diff --git a/wicd/gui.py b/wicd/gui.py index 72fbe75..7a40634 100644 --- a/wicd/gui.py +++ b/wicd/gui.py @@ -197,6 +197,7 @@ class appGui(object): self.connecting = False self.refreshing = False self.prev_state = None + self.update_cb = None self.network_list.set_sensitive(False) label = gtk.Label("%s..." % language['scanning']) self.network_list.pack_start(label) @@ -356,10 +357,11 @@ class appGui(object): if not self.is_visible: return True + daemon.UpdateState() if self.connecting: + # If we're connecting, don't wait for the monitor to send + # us a signal, since it won't until the connection is made. self._do_statusbar_update(*daemon.GetConnectionStatus()) - else: - daemon.UpdateState() return True def _do_statusbar_update(self, state, info): @@ -377,12 +379,16 @@ class appGui(object): return True def set_wired_state(self, info): - self._set_not_connecting_state() + if self.connecting: + # Adjust our state from connecting->connected. + self._set_not_connecting_state() self.set_status(language['connected_to_wired'].replace('$A', info[0])) return True def set_wireless_state(self, info): - self._set_not_connecting_state() + if self.connecting: + # Adjust our state from connecting->connected. + self._set_not_connecting_state() self.set_status(language['connected_to_wireless'].replace ('$A', info[1]).replace ('$B', daemon.FormatSignalForPrinting(info[2])).replace @@ -391,12 +397,13 @@ class appGui(object): def set_not_connected_state(self, info): if self.connecting: + # Adjust our state from connecting->not-connected. self._set_not_connecting_state() self.set_status(language['not_connected']) return True def _set_not_connecting_state(self): - if self.connecting: + if self.connecting and self.update_cb: gobject.source_remove(self.update_cb) self.update_cb = misc.timeout_add(2, self.update_statusbar) self.connecting = False @@ -408,7 +415,7 @@ class appGui(object): gobject.idle_add(self.status_bar.remove, 1, self.statusID) def set_connecting_state(self, info): - if not self.connecting: + if not self.connecting and self.update_cb: gobject.source_remove(self.update_cb) self.update_cb = misc.timeout_add(500, self.update_statusbar, milli=True) @@ -661,6 +668,7 @@ class appGui(object): """ widget.hide() networkentry.connect_button.show() + daemon.SetForcedDisconnect(True) if nettype == "wired": wired.DisconnectWired() else: diff --git a/wicd/monitor.py b/wicd/monitor.py index 592ec53..8ff56c1 100755 --- a/wicd/monitor.py +++ b/wicd/monitor.py @@ -53,7 +53,8 @@ def diewithdbus(func): ret = func(self, *__args, **__kargs) self.__lost_dbus_count = 0 return ret - except dbusmanager.DBusException: + except dbusmanager.DBusException, e: + print "Caught exception %e" % str(e) if not hasattr(self, "__lost_dbus_count"): self.__lost_dbus_count = 0 if self.__lost_dbus_count > 3: @@ -102,6 +103,7 @@ class ConnectionStatus(object): 2) A wired connection is currently active. """ + self.trigger_reconnect = False if not wired_ip and daemon.GetPreferWiredNetwork(): if not daemon.GetForcedDisconnect() and wired.CheckPluggedIn(): self.trigger_reconnect = True @@ -196,15 +198,6 @@ class ConnectionStatus(object): # Check for wired. wired_ip = wired.GetWiredIP("") wired_found = self.check_for_wired_connection(wired_ip) - # Trigger an AutoConnect if we're plugged in, not connected - # to a wired network, and the "autoswitch to wired" option - # is on. - if self.trigger_reconnect: - self.trigger_reconnect = False - wireless.DisconnectWireless() - daemon.AutoConnect(False, reply_handler=lambda:None, - error_handler=lambda:None) - return True if wired_found: self.update_state(misc.WIRED, wired_ip=wired_ip) return True @@ -214,6 +207,22 @@ class ConnectionStatus(object): self.signal_changed = False wireless_found = self.check_for_wireless_connection(wifi_ip) if wireless_found: + if self.trigger_reconnect: + # If we made it here, that means we want to switch + # to a wired network whenever possible, but a wireless + # connection is active. So we kill the wireless connection + # so the autoconnect logic will connect to the wired network. + self.trigger_reconnect = False + + # Don't trigger it if the gui is open, because autoconnect + # is disabled while it's open. + if not daemon.GetGUIOpen(): + print 'Killing wireless connection to switch to wired...' + wireless.DisconnectWireless() + daemon.AutoConnect(False, reply_handler=lambda:None, + error_handler=lambda:None) + self.update_state(misc.NOT_CONNECTED) + return True self.update_state(misc.WIRELESS, wifi_ip=wifi_ip) return True diff --git a/wicd/networking.py b/wicd/networking.py index aea3d04..b324663 100644 --- a/wicd/networking.py +++ b/wicd/networking.py @@ -218,6 +218,7 @@ class Controller(object): def KillDHCP(self): """ Kill the managed DHCP client if its in a connecting state. """ + print 'running kill dhcp.' if (self.connecting_thread.is_connecting and self.iface.dhcp_object): if self.iface.dhcp_object.poll() is None: diff --git a/wicd/wicd-daemon.py b/wicd/wicd-daemon.py index 26df66c..96ae287 100644 --- a/wicd/wicd-daemon.py +++ b/wicd/wicd-daemon.py @@ -323,12 +323,15 @@ class WicdDaemon(dbus.service.Object): """ print "Autoconnecting..." + if self.CheckIfConnecting(): + if self.debug_mode: + print 'Already connecting, doing nothing.' + return # We don't want to rescan/connect if the gui is open. if self.gui_open: if self.debug_mode: print "Skipping autoconnect because GUI is open." return - if self.wired_bus.CheckPluggedIn(): if self.debug_mode: print "Starting wired autoconnect..." @@ -388,6 +391,7 @@ class WicdDaemon(dbus.service.Object): if self.wired.connecting_thread: self.wired.connecting_thread.should_die = True self.wired.ReleaseDHCP() + self.wired.KillDHCP() self.wired.connecting_thread.connect_result = 'aborted' @dbus.service.method('org.wicd.daemon') @@ -425,9 +429,7 @@ class WicdDaemon(dbus.service.Object): @dbus.service.method('org.wicd.daemon') def GetForcedDisconnect(self): """ Returns the forced_disconnect status. See SetForcedDisconnect. """ - return (bool(self.forced_disconnect) or - bool(self.wireless_bus.GetForcedDisconnect()) or - bool(self.wired_bus.GetForcedDisconnect())) + return bool(self.forced_disconnect) @dbus.service.method('org.wicd.daemon') def SetForcedDisconnect(self, value): @@ -440,8 +442,6 @@ class WicdDaemon(dbus.service.Object): """ if self.debug_mode and value: print "Forced disconnect on" self.forced_disconnect = bool(value) - self.wireless_bus.SetForcedDisconnect(bool(value)) - self.wired_bus.SetForcedDisconnect(bool(value)) @dbus.service.method('org.wicd.daemon') def GetSignalDisplayType(self): @@ -923,7 +923,6 @@ class WirelessDaemon(dbus.service.Object): self.daemon = daemon self.wifi = wifi self._debug_mode = debug - self.forced_disconnect = False self._scanning = False self.LastScan = [] self.config = ConfigManager(os.path.join(wpath.etc, @@ -1041,26 +1040,9 @@ class WirelessDaemon(dbus.service.Object): @dbus.service.method('org.wicd.daemon.wireless') def DisconnectWireless(self): """ Disconnects the wireless network. """ - self.SetForcedDisconnect(True) self.wifi.Disconnect() self.daemon.UpdateState() - @dbus.service.method('org.wicd.daemon.wireless') - def GetForcedDisconnect(self): - """ Returns the forced_disconnect status. See SetForcedDisconnect. """ - return bool(self.forced_disconnect) - - @dbus.service.method('org.wicd.daemon.wireless') - def SetForcedDisconnect(self, value): - """ Sets the forced_disconnect status. - - Set to True when a user manually disconnects or cancels a connection. - It gets set to False as soon as the connection process is manually - started. - - """ - self.forced_disconnect = bool(value) - @dbus.service.method('org.wicd.daemon.wireless') def IsWirelessUp(self): """ Returns a boolean specifying if wireless is up or down. """ @@ -1119,13 +1101,13 @@ class WirelessDaemon(dbus.service.Object): # Will returned instantly, that way we don't hold up dbus. # CheckIfWirelessConnecting can be used to test if the connection # is done. - self.SetForcedDisconnect(False) self.wifi.before_script = self.GetWirelessProperty(id, 'beforescript') self.wifi.after_script = self.GetWirelessProperty(id, 'afterscript') self.wifi.disconnect_script = self.GetWirelessProperty(id, 'disconnectscript') print 'Connecting to wireless network ' + self.LastScan[id]['essid'] - self.daemon.wired_bus.DisconnectWired() + self.daemon.wired_bus.wired.Disconnect() + self.daemon.SetForcedDisconnect(False) conthread = self.wifi.Connect(self.LastScan[id], debug=self.debug_mode) self.daemon.UpdateState() @@ -1298,7 +1280,6 @@ class WiredDaemon(dbus.service.Object): self.daemon = daemon self.wired = wired self._debug_mode = debug - self.forced_disconnect = False self.WiredNetwork = {} self.config = ConfigManager(os.path.join(wpath.etc, "wired-settings.conf"), @@ -1378,7 +1359,6 @@ class WiredDaemon(dbus.service.Object): @dbus.service.method('org.wicd.daemon.wired') def DisconnectWired(self): """ Disconnects the wired network. """ - self.SetForcedDisconnect(True) self.wired.Disconnect() self.daemon.UpdateState() @@ -1405,30 +1385,14 @@ class WiredDaemon(dbus.service.Object): """ Calls a method to disable the wired interface. """ return self.wired.DisableInterface() - @dbus.service.method('org.wicd.daemon.wired') - def GetForcedDisconnect(self): - """ Returns the forced_disconnect status. See SetForcedDisconnect. """ - return bool(self.forced_disconnect) - - @dbus.service.method('org.wicd.daemon.wired') - def SetForcedDisconnect(self, value): - """ Sets the forced_disconnect status. - - Set to True when a user manually disconnects or cancels a connection. - It gets set to False as soon as the connection process is manually - started. - - """ - self.forced_disconnect = bool(value) - @dbus.service.method('org.wicd.daemon.wired') def ConnectWired(self): """ Connects to a wired network. """ - self.SetForcedDisconnect(False) self.wired.before_script = self.GetWiredProperty("beforescript") self.wired.after_script = self.GetWiredProperty("afterscript") self.wired.disconnect_script = self.GetWiredProperty("disconnectscript") - self.daemon.wireless_bus.DisconnectWireless() + self.daemon.wireless_bus.wifi.Disconnect() + self.daemon.SetForcedDisconnect(False) self.wired.Connect(self.WiredNetwork, debug=self.debug_mode) self.daemon.UpdateState() diff --git a/wicd/wnettools.py b/wicd/wnettools.py index c653237..1f462d4 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -217,15 +217,22 @@ class BaseInterface(object): cmd = "" return (client, cmd) - connect_dict = { - "dhclient" : r"%s %s", - "pump" : r"%s -i %s", - "dhcpcd" : r"%s %s", - } - release_dict = { - "dhclient" : r"%s -r %s", - "pump" : r"%s -r -i %s", - "dhcpcd" : r"%s -k %s", + client_dict = { + "dhclient" : + {'connect' : r"%s %s", + 'release' : r"%s -r %s", + 'id' : misc.DHCLIENT, + }, + "pump" : + { 'connect' : r"%s -i %s", + 'release' : r"%s -r -i %s", + 'id' : misc.PUMP, + }, + "dhcpcd" : + {'connect' : r"%s %s", + 'release' : r"%s -k %s", + 'id' : misc.DHCPCD, + }, } (client_name, cmd) = get_client_name(self.DHCP_CLIENT) if not client_name or not cmd: @@ -233,11 +240,11 @@ class BaseInterface(object): return "" if flavor == "connect": - return connect_dict[client_name] % (cmd, self.iface) + return client_dict[client_name]['connect'] % (cmd, self.iface) elif flavor == "release": - return release_dict[client_name] % (cmd, self.iface) + return client_dict[client_name]['release'] % (cmd, self.iface) else: - return str(cmd) + return client_dict[client_name]['id'] def AppAvailable(self, app): """ Return whether a given app is available. @@ -451,18 +458,19 @@ class BaseInterface(object): if not self.iface: return False cmd = self._get_dhcp_command('connect') - #cmd = self.DHCP_CMD + " " + self.iface if self.verbose: print cmd self.dhcp_object = misc.Run(cmd, include_stderr=True, return_obj=True) pipe = self.dhcp_object.stdout - DHCP_CLIENT = self.DHCP_CLIENT + DHCP_CLIENT = self._get_dhcp_command() if DHCP_CLIENT == misc.DHCLIENT: return self._parse_dhclient(pipe) elif DHCP_CLIENT == misc.PUMP: return self._parse_pump(pipe) elif DHCP_CLIENT == misc.DHCPCD: return self._parse_dhcpcd(pipe) + else: + print 'ERROR no dhclient found!' def ReleaseDHCP(self): """ Release the DHCP lease for this interface. """