disconnect account on unregister from server
This commit is contained in:
parent
37252b0c21
commit
f1f385f7c3
|
@ -115,6 +115,17 @@ class Connection(ConnectionHandlers):
|
||||||
self.time_to_reconnect = None
|
self.time_to_reconnect = None
|
||||||
self.retrycount = 0
|
self.retrycount = 0
|
||||||
|
|
||||||
|
# We are doing disconnect at so many places, better use one function in all
|
||||||
|
def disconnect(self, on_purpose = False):
|
||||||
|
self.on_purpose = on_purpose
|
||||||
|
self.connected = 0
|
||||||
|
self.time_to_reconnect = None
|
||||||
|
if self.connection:
|
||||||
|
# make sure previous connection is completely closed
|
||||||
|
gajim.proxy65_manager.disconnect(self.connection)
|
||||||
|
self.connection.disconnect()
|
||||||
|
self.connection = None
|
||||||
|
|
||||||
def _disconnectedReconnCB(self):
|
def _disconnectedReconnCB(self):
|
||||||
'''Called when we are disconnected'''
|
'''Called when we are disconnected'''
|
||||||
gajim.log.debug('disconnectedReconnCB')
|
gajim.log.debug('disconnectedReconnCB')
|
||||||
|
@ -124,12 +135,8 @@ class Connection(ConnectionHandlers):
|
||||||
self.old_show = STATUS_LIST[self.connected]
|
self.old_show = STATUS_LIST[self.connected]
|
||||||
self.connected = 0
|
self.connected = 0
|
||||||
self.dispatch('STATUS', 'offline')
|
self.dispatch('STATUS', 'offline')
|
||||||
if self.connection:
|
|
||||||
# make sure previous connection is completely closed
|
|
||||||
gajim.proxy65_manager.disconnect(self.connection)
|
|
||||||
self.connection.disconnect()
|
|
||||||
self.connection = None
|
|
||||||
if not self.on_purpose:
|
if not self.on_purpose:
|
||||||
|
self.disconnect()
|
||||||
if gajim.config.get_per('accounts', self.name, 'autoreconnect'):
|
if gajim.config.get_per('accounts', self.name, 'autoreconnect'):
|
||||||
self.connected = 1
|
self.connected = 1
|
||||||
self.dispatch('STATUS', 'connecting')
|
self.dispatch('STATUS', 'connecting')
|
||||||
|
@ -147,6 +154,8 @@ class Connection(ConnectionHandlers):
|
||||||
self.dispatch('ERROR',
|
self.dispatch('ERROR',
|
||||||
(_('Connection with account "%s" has been lost') % self.name,
|
(_('Connection with account "%s" has been lost') % self.name,
|
||||||
_('To continue sending and receiving messages, you will need to reconnect.')))
|
_('To continue sending and receiving messages, you will need to reconnect.')))
|
||||||
|
else:
|
||||||
|
self.disconnect()
|
||||||
self.on_purpose = False
|
self.on_purpose = False
|
||||||
# END disconenctedReconnCB
|
# END disconenctedReconnCB
|
||||||
|
|
||||||
|
@ -409,13 +418,8 @@ class Connection(ConnectionHandlers):
|
||||||
# END connect
|
# END connect
|
||||||
|
|
||||||
def quit(self, kill_core):
|
def quit(self, kill_core):
|
||||||
if kill_core:
|
if kill_core and self.connected > 1:
|
||||||
if self.connected > 1:
|
self.disconnect()
|
||||||
self.connected = 0
|
|
||||||
gajim.proxy65_manager.disconnect(self.connection)
|
|
||||||
self.connection.disconnect()
|
|
||||||
self.time_to_reconnect = None
|
|
||||||
return
|
|
||||||
|
|
||||||
def build_privacy_rule(self, name, action):
|
def build_privacy_rule(self, name, action):
|
||||||
'''Build a Privacy rule stanza for invisibility'''
|
'''Build a Privacy rule stanza for invisibility'''
|
||||||
|
@ -578,8 +582,7 @@ class Connection(ConnectionHandlers):
|
||||||
def _on_disconnected(self):
|
def _on_disconnected(self):
|
||||||
''' called when a disconnect request has completed successfully'''
|
''' called when a disconnect request has completed successfully'''
|
||||||
self.dispatch('STATUS', 'offline')
|
self.dispatch('STATUS', 'offline')
|
||||||
gajim.proxy65_manager.disconnect(self.connection)
|
self.disconnect()
|
||||||
self.connection = None
|
|
||||||
|
|
||||||
def get_status(self):
|
def get_status(self):
|
||||||
return STATUS_LIST[self.connected]
|
return STATUS_LIST[self.connected]
|
||||||
|
|
|
@ -2150,6 +2150,7 @@ class RemoveAccountWindow:
|
||||||
return
|
return
|
||||||
# Close all opened windows
|
# Close all opened windows
|
||||||
gajim.interface.roster.close_all(gajim.interface.instances[self.account])
|
gajim.interface.roster.close_all(gajim.interface.instances[self.account])
|
||||||
|
gajim.connections[self.account].disconnect(on_purpose = True)
|
||||||
del gajim.connections[self.account]
|
del gajim.connections[self.account]
|
||||||
gajim.config.del_per('accounts', self.account)
|
gajim.config.del_per('accounts', self.account)
|
||||||
gajim.interface.save_config()
|
gajim.interface.save_config()
|
||||||
|
|
Loading…
Reference in New Issue