1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-20 04:48:00 +01:00

Autoconnect method will now fallback to wireless if a wired attempt fails for any reason.

This commit is contained in:
imdano
2008-03-01 19:45:45 +00:00
parent bcb46c1f12
commit 0386fc4ff4

View File

@@ -148,6 +148,7 @@ class ConnectionWizard(dbus.service.Object):
self.suspended = False self.suspended = False
self.connection_state = 0 self.connection_state = 0
self.connection_info = [""] self.connection_info = [""]
self.auto_connecting = False
# Load the config file # Load the config file
self.ReadConfig() self.ReadConfig()
@@ -357,11 +358,6 @@ class ConnectionWizard(dbus.service.Object):
def _wired_autoconnect(self): def _wired_autoconnect(self):
""" Attempts to autoconnect to a wired network. """ """ Attempts to autoconnect to a wired network. """
if self.GetWiredInterface() is None:
print 'no wired interface available'
return
if self.GetWiredAutoConnectMethod() == 2 and \ if self.GetWiredAutoConnectMethod() == 2 and \
not self.GetNeedWiredProfileChooser(): not self.GetNeedWiredProfileChooser():
self.LaunchChooser() self.LaunchChooser()
@@ -371,12 +367,16 @@ class ConnectionWizard(dbus.service.Object):
self.ReadWiredNetworkProfile(defaultNetwork) self.ReadWiredNetworkProfile(defaultNetwork)
self.ConnectWired() self.ConnectWired()
print "Attempting to autoconnect with wired interface..." print "Attempting to autoconnect with wired interface..."
self.auto_connecting = True
time.sleep(1.5)
gobject.timeout_add(3000, self._monitor_wired_autoconnect)
else: else:
print "Couldn't find a default wired connection, \ print "Couldn't find a default wired connection, \
wired autoconnect failed" wired autoconnect failed"
self._wireless_autoconnect() self._wireless_autoconnect()
def _wireless_autoconnect(self): def _wireless_autoconnect(self):
""" Attempts to autoconnect to a wireless network. """
print "No wired connection present, attempting to autoconnect \ print "No wired connection present, attempting to autoconnect \
to wireless network" to wireless network"
if self.GetWirelessInterface() is None: if self.GetWirelessInterface() is None:
@@ -393,7 +393,16 @@ class ConnectionWizard(dbus.service.Object):
return return
print "Unable to autoconnect, you'll have to manually connect" print "Unable to autoconnect, you'll have to manually connect"
def _monitor_wired_autoconnect(self):
if self.CheckIfWiredConnecting():
return True
elif self.GetWiredIP():
self.auto_connecting = False
return False
elif not self.CheckIfWirelessConnecting():
self._wireless_autoconnect()
self.auto_connecting = False
return False
@dbus.service.method('org.wicd.daemon') @dbus.service.method('org.wicd.daemon')
def GetAutoReconnect(self): def GetAutoReconnect(self):
@@ -1243,7 +1252,7 @@ class ConnectionWizard(dbus.service.Object):
print "using wireless interface...", self.GetWirelessInterface()[5:] print "using wireless interface...", self.GetWirelessInterface()[5:]
class ConnectionStatus(): class ConnectionStatus:
""" Class for monitoring the computer's connection status. """ """ Class for monitoring the computer's connection status. """
def __init__(self, connection): def __init__(self, connection):
""" Initialize variables needed for the connection status methods. """ """ Initialize variables needed for the connection status methods. """
@@ -1394,7 +1403,7 @@ class ConnectionStatus():
self.status_changed = True self.status_changed = True
if conn.GetAutoReconnect() and not conn.CheckIfConnecting() and \ if conn.GetAutoReconnect() and not conn.CheckIfConnecting() and \
not conn.GetForcedDisconnect(): not conn.GetForcedDisconnect() and not conn.auto_connecting:
print 'Starting automatic reconnect process' print 'Starting automatic reconnect process'
# First try connecting through ethernet # First try connecting through ethernet
if conn.CheckPluggedIn(): if conn.CheckPluggedIn():