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

Fixed cancelling a connection not working.

Stopped the gui status bar from updating while the gui is closed, which reduces CPU usage and should hopefully fix problems with hibernation not working while wicd was running.
This commit is contained in:
imdano
2007-12-19 22:35:07 +00:00
parent da4d84b793
commit 8a0a471764
3 changed files with 70 additions and 7 deletions

View File

@@ -139,6 +139,17 @@ class ConnectThread(threading.Thread):
self.lock.release()
return message
def connect_aborted(self, reason):
""" Sets the thread status to aborted in a thread-safe way.
Sets the status to aborted, and also delays returning for
a few seconds to make sure the message is readable
"""
self.SetStatus(reason)
self.is_connecting = False
print 'exiting connection thread'
class Wireless(Controller):
@@ -378,10 +389,18 @@ class WirelessConnectThread(ConnectThread):
self.is_connecting = True
if self.should_die:
self.connect_aborted('aborted')
return
# Execute pre-connection script if necessary
if self.before_script != '' and self.before_script != None:
print 'Executing pre-connection script'
print misc.ExecuteScript(self.before_script)
misc.ExecuteScript(self.before_script)
if self.should_die:
self.connect_aborted('aborted')
return
# Put it down
print 'Interface down'
@@ -400,6 +419,11 @@ class WirelessConnectThread(ConnectThread):
wiface.StopWPA()
liface.StopDHCP()
if self.should_die:
wiface.Up()
self.connect_aborted('aborted')
return
# Check to see if we need to generate a PSK (only for non-ralink
# cards).
if self.wpa_driver != 'ralink legacy':
@@ -418,6 +442,11 @@ class WirelessConnectThread(ConnectThread):
print 'Attempting to authenticate...'
wiface.Authenticate(self.network)
if self.should_die:
wiface.Up()
self.connect_aborted('aborted')
return
self.SetStatus('flushing_routing_table')
print 'Flushing the routing table...'
wiface.FlushRoutes()
@@ -431,6 +460,10 @@ class WirelessConnectThread(ConnectThread):
self.SetStatus('interface_up')
wiface.Up()
if self.should_die:
self.connect_aborted('aborted')
return
wiface.SetMode(self.network['mode'])
wiface.Associate(self.network['essid'],
self.network['channel'], self.network['bssid'])
@@ -446,6 +479,10 @@ class WirelessConnectThread(ConnectThread):
print 'Setting the broadcast address...' + self.network['broadcast']
wiface.SetAddress(broadcast=self.network['broadcast'])
if self.should_die:
self.connect_aborted('aborted')
return
if not self.network.get('ip') == None:
self.SetStatus('setting_static_ip')
print 'Setting static IP : ' + self.network['ip']
@@ -470,11 +507,9 @@ class WirelessConnectThread(ConnectThread):
wnettools.SetDNS(self.network.get('dns1'),
self.network.get('dns2'), self.network.get('dns3'))
# Save as last used profile
print 'Saving last used profile'
config.UnsetLastUsedDefault() # Makes sure there is only one last used profile at a time
self.network.SetWiredProperty("lastused", True)
config.SaveWiredNetworkProfile(self.profilename)
if self.should_die:
self.connect_aborted('aborted')
return
# Execute post-connection script if necessary
if misc.Noneify(self.after_script):
@@ -594,11 +629,19 @@ class WiredConnectThread(ConnectThread):
self.is_connecting = True
if self.should_die:
self.connect_aborted('aborted')
return
# Execute pre-connection script if necessary
if self.before_script != '' and self.before_script != None:
print 'executing pre-connection script'
misc.ExecuteScript(self.before_script)
if self.should_die:
self.connect_aborted('aborted')
return
# Put it down
print 'Interface down'
self.SetStatus('interface_down')
@@ -616,6 +659,11 @@ class WiredConnectThread(ConnectThread):
wiface.StopWPA()
liface.StopDHCP()
if self.should_die:
liface.Up()
self.connect_aborted('aborted')
return
self.SetStatus('flushing_routing_table')
print 'Flushing the routing table...'
wiface.FlushRoutes()
@@ -626,11 +674,19 @@ class WiredConnectThread(ConnectThread):
self.SetStatus('interface_up')
liface.Up()
if self.should_die:
self.connect_aborted('aborted')
return
if not self.network.get('broadcast') == None:
self.SetStatus('setting_broadcast_address')
print 'Setting the broadcast address...' + self.network['broadcast']
liface.SetAddress(broadcast=self.network['broadcast'])
if self.should_die:
self.connect_aborted('aborted')
return
if self.network.get('ip'):
self.SetStatus('setting_static_ip')
print 'Setting static IP : ' + self.network['ip']
@@ -655,6 +711,10 @@ class WiredConnectThread(ConnectThread):
wnettools.SetDNS(self.network.get('dns1'),
self.network.get('dns2'), self.network.get('dns3'))
if self.should_die:
self.connect_aborted('aborted')
return
# Execute post-connection script if necessary
if misc.Noneify(self.after_script):
print 'executing post connection script'