diff --git a/curses/prefs_curses.py b/curses/prefs_curses.py index 43da851..bf1eb74 100644 --- a/curses/prefs_curses.py +++ b/curses/prefs_curses.py @@ -93,6 +93,7 @@ class PrefsDialog(urwid.WidgetWrap): dhcp1_t = 'dhclient' dhcp2_t = 'dhcpcd' dhcp3_t = 'pump' + dhcp4_t = 'udhcpc' wired_detect_header_t = ('header',language["wired_detect"]) wired1_t = 'ethtool' @@ -185,7 +186,8 @@ class PrefsDialog(urwid.WidgetWrap): self.dhcp1 = DynRadioButton(self.dhcp_l,dhcp1_t) self.dhcp2 = DynRadioButton(self.dhcp_l,dhcp2_t) self.dhcp3 = DynRadioButton(self.dhcp_l,dhcp3_t) - self.dhcp_l = [self.dhcp0,self.dhcp1,self.dhcp2,self.dhcp3] + self.dhcp4 = DynRadioButton(self.dhcp_l,dhcp4_t) + self.dhcp_l = [self.dhcp0,self.dhcp1,self.dhcp2,self.dhcp3,self.dhcp4] self.wired_l = [] self.wired_detect_header = urwid.Text(wired_detect_header_t) @@ -202,7 +204,7 @@ class PrefsDialog(urwid.WidgetWrap): self.flush_l = [self.flush0,self.flush1,self.flush2] externalLB = urwid.ListBox([self.dhcp_header, - self.dhcp0,self.dhcp2,self.dhcp3,self.dhcp1, + self.dhcp0,self.dhcp2,self.dhcp3,self.dhcp1,self.dhcp4, _blank, self.wired_detect_header, self.wired0,self.wired1,self.wired2, @@ -351,8 +353,10 @@ class PrefsDialog(urwid.WidgetWrap): dhcp_client = misc.DHCLIENT elif self.dhcp2.get_state(): dhcp_client = misc.DHCPCD - else: + elif self.dhcp3.get_state(): dhcp_client = misc.PUMP + else: + dhcp_client = misc.UDHCPC daemon.SetDHCPClient(dhcp_client) if self.wired0.get_state(): diff --git a/data/wicd.glade b/data/wicd.glade index 258f6b8..f37be7e 100644 --- a/data/wicd.glade +++ b/data/wicd.glade @@ -1171,6 +1171,21 @@ is already active. 2 + + + udhcpc + True + True + False + True + True + dhclient_radio + + + False + 4 + + diff --git a/man/wicd-client.1 b/man/wicd-client.1 index 6d86469..a2e71ad 100644 --- a/man/wicd-client.1 +++ b/man/wicd-client.1 @@ -1,6 +1,6 @@ -.TH WICD-CLIENT "1" "February 2009" "wicd-client " "User Commands" +.TH WICD-CLIENT "1" "June 2009" "wicd-client " "User Commands" .SH NAME -wicd-client \- manual page for wicd-client +wicd-client \- frontend to the WICD daemon .SH DESCRIPTION wireless (and wired) connection daemon front\-end. diff --git a/other/wicd.desktop b/other/wicd.desktop index 7221c15..a0f334f 100644 --- a/other/wicd.desktop +++ b/other/wicd.desktop @@ -1,6 +1,5 @@ [Desktop Entry] Categories=Application;Network; -Encoding=UTF-8 Exec=wicd-client --no-tray GenericName=Network Manager Icon=wicd-client diff --git a/wicd/misc.py b/wicd/misc.py index 2dde1d4..1ed4e33 100644 --- a/wicd/misc.py +++ b/wicd/misc.py @@ -49,6 +49,7 @@ AUTO = 0 DHCLIENT = 1 DHCPCD = 2 PUMP = 3 +UDHCPC = 4 # Link detection tools ETHTOOL = 1 diff --git a/wicd/monitor.py b/wicd/monitor.py index 2937360..6dcb0a0 100755 --- a/wicd/monitor.py +++ b/wicd/monitor.py @@ -185,7 +185,7 @@ class ConnectionStatus(object): # try to reconnect. self.connection_lost_counter += 1 print self.connection_lost_counter - if self.connection_lost_counter >= 4: + if self.connection_lost_counter >= 4 and daemon.GetAutoReconnect(): wireless.DisconnectWireless() self.connection_lost_counter = 0 return False diff --git a/wicd/networking.py b/wicd/networking.py index 8eaa454..937f323 100644 --- a/wicd/networking.py +++ b/wicd/networking.py @@ -315,6 +315,13 @@ class ConnectThread(threading.Thread): self.SetStatus('interface_down') + def run(self): + self.connect_result = "Failed" + try: + self._connect() + finally: + self.is_connecting = False + def set_should_die(self, val): self.lock.acquire() try: @@ -794,7 +801,7 @@ class WirelessConnectThread(ConnectThread): self.wpa_driver = wpa_driver - def run(self): + def _connect(self): """ The main function of the connection thread. This function performs the necessary calls to connect to the @@ -1006,7 +1013,7 @@ class WiredConnectThread(ConnectThread): after_script, disconnect_script, gdns1, gdns2, gdns3, gdns_dom, gsearch_dom, liface, debug) - def run(self): + def _connect(self): """ The main function of the connection thread. This function performs the necessary calls to connect to the diff --git a/wicd/prefs.py b/wicd/prefs.py index a8da776..6072f8d 100644 --- a/wicd/prefs.py +++ b/wicd/prefs.py @@ -82,7 +82,7 @@ class PreferencesDialog(object): self.preferwiredcheckbox.set_active(daemon.GetPreferWiredNetwork()) dhcp_list = [self.dhcpautoradio, self.dhclientradio, self.dhcpcdradio, - self.pumpradio] + self.pumpradio, self.udhcpcradio] self._setup_external_app_radios(dhcp_list, daemon.GetDHCPClient, daemon.SetDHCPClient) @@ -210,8 +210,10 @@ class PreferencesDialog(object): dhcp_client = misc.DHCLIENT elif self.dhcpcdradio.get_active(): dhcp_client = misc.DHCPCD - else: + elif self.pumpradio.get_active(): dhcp_client = misc.PUMP + else: + dhcp_client = misc.UDHCPC daemon.SetDHCPClient(dhcp_client) if self.linkautoradio.get_active(): @@ -347,6 +349,7 @@ class PreferencesDialog(object): self.dhclientradio = self.wTree.get_widget("dhclient_radio") self.pumpradio = self.wTree.get_widget("pump_radio") self.dhcpcdradio = self.wTree.get_widget("dhcpcd_radio") + self.udhcpcradio = self.wTree.get_widget("udhcpc_radio") # Wired Link Detection Apps self.linkautoradio = setup_label("link_auto_radio", 'wicd_auto_config') diff --git a/wicd/wnettools.py b/wicd/wnettools.py index 113015f..65a2018 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -250,6 +250,9 @@ class BaseInterface(object): cmd = self.dhclient_cmd if self.dhclient_needs_verbose: cmd += ' -v' + elif self.udhcpc_cmd and cl in [misc.UDHCPC, misc.AUTO]: + client = "udhcpc" + cmd = self.udhcpc_cmd else: client = None cmd = "" @@ -257,20 +260,25 @@ class BaseInterface(object): client_dict = { "dhclient" : - {'connect' : r"%s %s", - 'release' : r"%s -r %s", + {'connect' : r"%(cmd)s %(iface)s", + 'release' : r"%(cmd)s -r %(iface)s", 'id' : misc.DHCLIENT, }, "pump" : - { 'connect' : r"%s -i %s", - 'release' : r"%s -r -i %s", + { 'connect' : r"%(cmd)s -i %(iface)s", + 'release' : r"%(cmd)s -r -i %(iface)s", 'id' : misc.PUMP, }, "dhcpcd" : - {'connect' : r"%s %s", - 'release' : r"%s -k %s", + {'connect' : r"%(cmd)s %(iface)s", + 'release' : r"%(cmd)s -k %(iface)s", 'id' : misc.DHCPCD, }, + "udhcpc": + {'connect' : r"%(cmd)s -n -i %(iface)s", + 'release' : r"killall -SIGUSR2 %(cmd)s", + 'id' : misc.UDHCPC, + }, } (client_name, cmd) = get_client_name(self.DHCP_CLIENT) if not client_name or not cmd: @@ -278,9 +286,9 @@ class BaseInterface(object): return "" if flavor == "connect": - return client_dict[client_name]['connect'] % (cmd, self.iface) + return client_dict[client_name]['connect'] % {"cmd":cmd, "iface":self.iface} elif flavor == "release": - return client_dict[client_name]['release'] % (cmd, self.iface) + return client_dict[client_name]['release'] % {"cmd":cmd, "iface":self.iface} else: return client_dict[client_name]['id'] @@ -327,6 +335,7 @@ class BaseInterface(object): self.dhclient_needs_verbose = False self.dhcpcd_cmd = self._find_program_path("dhcpcd") self.pump_cmd = self._find_program_path("pump") + self.udhcpc_cmd = self._find_program_path("udhcpc") def CheckWiredTools(self): """ Check for the existence of ethtool and mii-tool. """ @@ -431,7 +440,7 @@ class BaseInterface(object): if line == '': # Empty string means dhclient is done. dhclient_complete = True else: - print line.strip('\n') + print misc.to_unicode(line.strip('\n')) if line.startswith('bound'): dhclient_success = True dhclient_complete = True @@ -458,7 +467,7 @@ class BaseInterface(object): elif line.strip().lower().startswith('Operation failed.'): pump_success = False pump_complete = True - print line + print misc.to_unicode(line) return self._check_dhcp_result(pump_success) @@ -482,10 +491,34 @@ class BaseInterface(object): dhcpcd_complete = True elif line == '': dhcpcd_complete = True - print line + print misc.to_unicode(line) return self._check_dhcp_result(dhcpcd_success) - + + def _parse_udhcpc(self, pipe): + """ Determines if obtaining an IP using udhcpc succeeded. + + Keyword arguments: + pipe -- stdout pipe to the dhcpcd process. + + Returns: + 'success' if successful, an error code string otherwise. + + """ + udhcpc_complete = False + udhcpc_success = True + + while not udhcpc_complete: + line = pipe.readline() + if line.endswith("failing"): + udhcpc_success = False + udhcpc_complete = True + elif line == '': + udhcpc_complete = True + print line + + return self._check_dhcp_result(udhcpc_success) + def _check_dhcp_result(self, success): """ Print and return the correct DHCP connection result. @@ -524,6 +557,8 @@ class BaseInterface(object): return self._parse_pump(pipe) elif DHCP_CLIENT == misc.DHCPCD: return self._parse_dhcpcd(pipe) + elif DHCP_CLIENT == misc.UDHCPC: + return self._parse_udhcpc(pipe) else: print 'ERROR no dhclient found!' @@ -1106,15 +1141,21 @@ class BaseWirelessInterface(BaseInterface): # An array for the access points access_points = [] + access_points = {} for cell in networks: # Only use sections where there is an ESSID. if 'ESSID:' in cell: # Add this network to the list of networks entry = self._ParseAccessPoint(cell, ralink_info) if entry is not None: - access_points.append(entry) + # Normally we only get duplicate bssids with hidden + # networks. If we hit this, we only want the entry + # with the real essid to be in the network list. + if (entry['bssid'] not in access_points + or not entry['hidden']): + access_points[entry['bssid']] = entry - return access_points + return access_points.values() def _ParseAccessPoint(self, cell, ralink_info): """ Parse a single cell from the output of iwlist.