mirror of
https://github.com/gryf/wicd.git
synced 2026-03-07 18:15:48 +01:00
make sure that disconnect scripts are run when the connection is dropped
This commit is contained in:
@@ -294,6 +294,13 @@ class ConnectionStatus(object):
|
|||||||
if (state != self.last_state or (state == misc.WIRELESS and
|
if (state != self.last_state or (state == misc.WIRELESS and
|
||||||
self.signal_changed)):
|
self.signal_changed)):
|
||||||
daemon.EmitStatusChanged(state, info)
|
daemon.EmitStatusChanged(state, info)
|
||||||
|
|
||||||
|
if (state != self.last_state) and (state == misc.NOT_CONNECTED) and \
|
||||||
|
(not daemon.GetForcedDisconnect()):
|
||||||
|
daemon.Disconnect()
|
||||||
|
# Disconnect() sets forced disconnect = True
|
||||||
|
# so we'll revert that
|
||||||
|
daemon.SetForcedDisconnect(False)
|
||||||
self.last_state = state
|
self.last_state = state
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -345,6 +352,10 @@ class ConnectionStatus(object):
|
|||||||
# network again. Otherwise just call Autoconnect.
|
# network again. Otherwise just call Autoconnect.
|
||||||
cur_net_id = wireless.GetCurrentNetworkID(self.iwconfig)
|
cur_net_id = wireless.GetCurrentNetworkID(self.iwconfig)
|
||||||
if from_wireless and cur_net_id > -1:
|
if from_wireless and cur_net_id > -1:
|
||||||
|
# make sure disconnect scripts are run
|
||||||
|
# before we reconnect
|
||||||
|
print 'Disconnecting from network'
|
||||||
|
wireless.DisconnectWireless()
|
||||||
print 'Trying to reconnect to last used wireless ' + \
|
print 'Trying to reconnect to last used wireless ' + \
|
||||||
'network'
|
'network'
|
||||||
wireless.ConnectWireless(cur_net_id)
|
wireless.ConnectWireless(cur_net_id)
|
||||||
|
|||||||
@@ -1147,6 +1147,8 @@ class WirelessDaemon(dbus.service.Object):
|
|||||||
self.wifi.post_disconnect_script = self.GetWirelessProperty(id,
|
self.wifi.post_disconnect_script = self.GetWirelessProperty(id,
|
||||||
'postdisconnectscript')
|
'postdisconnectscript')
|
||||||
print 'Connecting to wireless network ' + str(self.LastScan[id]['essid'])
|
print 'Connecting to wireless network ' + str(self.LastScan[id]['essid'])
|
||||||
|
# disconnect to make sure that scripts are run
|
||||||
|
self.wifi.Disconnect()
|
||||||
self.daemon.wired_bus.wired.Disconnect()
|
self.daemon.wired_bus.wired.Disconnect()
|
||||||
self.daemon.SetForcedDisconnect(False)
|
self.daemon.SetForcedDisconnect(False)
|
||||||
conthread = self.wifi.Connect(self.LastScan[id], debug=self.debug_mode)
|
conthread = self.wifi.Connect(self.LastScan[id], debug=self.debug_mode)
|
||||||
@@ -1439,6 +1441,8 @@ class WiredDaemon(dbus.service.Object):
|
|||||||
self.wired.pre_disconnect_script = self.GetWiredProperty("predisconnectscript")
|
self.wired.pre_disconnect_script = self.GetWiredProperty("predisconnectscript")
|
||||||
self.wired.post_disconnect_script = self.GetWiredProperty("postdisconnectscript")
|
self.wired.post_disconnect_script = self.GetWiredProperty("postdisconnectscript")
|
||||||
self.daemon.wireless_bus.wifi.Disconnect()
|
self.daemon.wireless_bus.wifi.Disconnect()
|
||||||
|
# make sure disconnect scripts are run
|
||||||
|
self.wired.Disconnect()
|
||||||
self.daemon.SetForcedDisconnect(False)
|
self.daemon.SetForcedDisconnect(False)
|
||||||
self.UnsetWiredLastUsed()
|
self.UnsetWiredLastUsed()
|
||||||
self.config.set(self._cur_wired_prof_name, "lastused", True, write=True)
|
self.config.set(self._cur_wired_prof_name, "lastused", True, write=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user