1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-23 22:52:33 +01:00

Merged with r294 of mainline 1.6.

This commit is contained in:
Andrew Psaltis
2009-02-12 00:38:24 -05:00
8 changed files with 37 additions and 10 deletions

0
in/init=default=wicd.in Normal file → Executable file
View File

View File

@@ -390,23 +390,29 @@ class appGui(object):
return True
def set_not_connected_state(self, info):
self.connecting = False
self._set_not_connecting_state()
if self.connecting:
self._set_not_connecting_state()
self.set_status(language['not_connected'])
return True
def _set_not_connecting_state(self):
self.connecting = False
if self.connecting:
gobject.source_remove(self.update_cb)
self.update_cb = misc.timeout_add(2, self.update_statusbar)
self.connecting = False
if self.pulse_active:
self.pulse_active = False
gobject.idle_add(self.network_list.set_sensitive, True)
gobject.idle_add(self.status_area.hide_all)
if self.statusID:
gobject.idle_add(self.status_bar.remove, 1, self.statusID)
def set_connecting_state(self, info):
self.connecting = True
if not self.connecting:
gobject.source_remove(self.update_cb)
self.update_cb = misc.timeout_add(500, self.update_statusbar,
milli=True)
self.connecting = True
if not self.pulse_active:
self.pulse_active = True
misc.timeout_add(100, self.pulse_progress_bar, milli=True)
@@ -710,6 +716,7 @@ class appGui(object):
daemon.SetGUIOpen(True)
self.wait_for_events(0.1)
gobject.idle_add(self.refresh_clicked)
self._do_statusbar_update(*daemon.GetConnectionStatus())
bus.add_signal_receiver(self._do_statusbar_update, 'StatusChanged',
'org.wicd.daemon')
self.update_cb = misc.timeout_add(2, self.update_statusbar)

View File

@@ -69,7 +69,7 @@ class WicdError(Exception):
__LANG = None
def Run(cmd, include_stderr=False, return_pipe=False):
def Run(cmd, include_stderr=False, return_pipe=False, return_obj=False):
""" Run a command.
Runs the given command, returning either the output
@@ -112,6 +112,8 @@ def Run(cmd, include_stderr=False, return_pipe=False):
return ""
if return_obj:
return f
if return_pipe:
return f.stdout
else:

View File

@@ -54,6 +54,8 @@ def diewithdbus(func):
self.__lost_dbus_count = 0
return ret
except dbusmanager.DBusException:
if not hasattr(self, "__lost_dbus_count"):
self.__lost_dbus_count = 0
if self.__lost_dbus_count > 3:
sys.exit(1)
self.__lost_dbus_count += 1

View File

@@ -44,7 +44,9 @@ class WiredConnectThread() -- Connection thread for wired
import re
import time
import threading
import os
import thread
from signal import SIGTERM
# wicd imports
import misc
@@ -202,7 +204,8 @@ class Controller(object):
iface = self.iface
if self.disconnect_script != None:
print 'Running disconnect script'
misc.ExecuteScript(expand_script_macros(self.disconnect_script, 'disconnection', *args))
misc.ExecuteScript(expand_script_macros(self.disconnect_script,
'disconnection', *args))
iface.ReleaseDHCP()
iface.SetAddress('0.0.0.0')
iface.FlushRoutes()
@@ -213,6 +216,14 @@ class Controller(object):
""" Release the DHCP lease for this interface. """
return self.iface.ReleaseDHCP()
def KillDHCP(self):
""" Kill the managed DHCP client if its in a connecting state. """
if (self.connecting_thread.is_connecting and
self.iface.dhcp_object):
if self.iface.dhcp_object.poll() is None:
os.kill(self.iface.dhcp_object.pid, SIGTERM)
self.iface.dhcp_object = None
def IsUp(self):
""" Calls the IsUp method for the wired interface.
@@ -404,7 +415,8 @@ class ConnectThread(threading.Thread):
print "Running DHCP"
dhcp_status = iface.StartDHCP()
if dhcp_status in ['no_dhcp_offers', 'dhcp_failed']:
self.abort_connection(dhcp_status)
if self.connect_result != "aborted":
self.abort_connection(dhcp_status)
return
@abortable

View File

@@ -80,7 +80,7 @@ def catchdbus(func):
try:
return func(*args, **kwargs)
except DBusException, e:
print "warning: ignoring exception %s" % egg
print "warning: ignoring exception %s" % e
return None
wrapper.__name__ = func.__name__
wrapper.__module__ = func.__module__

View File

@@ -380,6 +380,9 @@ class WicdDaemon(dbus.service.Object):
if self.wifi.connecting_thread:
self.wifi.connecting_thread.should_die = True
self.wifi.ReleaseDHCP()
# We have to actually kill dhcp if its still hanging
# around. It could still be trying to get a lease.
self.wifi.KillDHCP()
self.wifi.StopWPA()
self.wifi.connecting_thread.connect_result = 'aborted'
if self.wired.connecting_thread:

View File

@@ -453,7 +453,8 @@ class BaseInterface(object):
cmd = self._get_dhcp_command('connect')
#cmd = self.DHCP_CMD + " " + self.iface
if self.verbose: print cmd
pipe = misc.Run(cmd, include_stderr=True, return_pipe=True)
self.dhcp_object = misc.Run(cmd, include_stderr=True, return_obj=True)
pipe = self.dhcp_object.stdout
DHCP_CLIENT = self.DHCP_CLIENT
if DHCP_CLIENT == misc.DHCLIENT: