don't traceback when remove a disabled account. Fixes #5647
This commit is contained in:
parent
31d1d35b17
commit
ccde9e4382
|
@ -1895,7 +1895,7 @@ class AccountsWindow:
|
||||||
win_opened = False
|
win_opened = False
|
||||||
if gajim.interface.msg_win_mgr.get_controls(acct=account):
|
if gajim.interface.msg_win_mgr.get_controls(acct=account):
|
||||||
win_opened = True
|
win_opened = True
|
||||||
else:
|
elif account in gajim.interface.instances:
|
||||||
for key in gajim.interface.instances[account]:
|
for key in gajim.interface.instances[account]:
|
||||||
if gajim.interface.instances[account][key] and key != \
|
if gajim.interface.instances[account][key] and key != \
|
||||||
'remove_account':
|
'remove_account':
|
||||||
|
@ -1903,10 +1903,13 @@ class AccountsWindow:
|
||||||
break
|
break
|
||||||
# Detect if we have opened windows for this account
|
# Detect if we have opened windows for this account
|
||||||
def remove(account):
|
def remove(account):
|
||||||
if 'remove_account' in gajim.interface.instances[account]:
|
if account in gajim.interface.instances and \
|
||||||
|
'remove_account' in gajim.interface.instances[account]:
|
||||||
gajim.interface.instances[account]['remove_account'].window.\
|
gajim.interface.instances[account]['remove_account'].window.\
|
||||||
present()
|
present()
|
||||||
else:
|
else:
|
||||||
|
if not account in gajim.interface.instances:
|
||||||
|
gajim.interface.instances[account] = {}
|
||||||
gajim.interface.instances[account]['remove_account'] = \
|
gajim.interface.instances[account]['remove_account'] = \
|
||||||
RemoveAccountWindow(account)
|
RemoveAccountWindow(account)
|
||||||
if win_opened:
|
if win_opened:
|
||||||
|
@ -2871,12 +2874,19 @@ class RemoveAccountWindow:
|
||||||
|
|
||||||
def on_remove_button_clicked(self, widget):
|
def on_remove_button_clicked(self, widget):
|
||||||
def remove():
|
def remove():
|
||||||
if gajim.connections[self.account].connected and \
|
if self.account in gajim.connections and \
|
||||||
|
gajim.connections[self.account].connected and \
|
||||||
not self.remove_and_unregister_radiobutton.get_active():
|
not self.remove_and_unregister_radiobutton.get_active():
|
||||||
# change status to offline only if we will not remove this JID from
|
# change status to offline only if we will not remove this JID from
|
||||||
# server
|
# server
|
||||||
gajim.connections[self.account].change_status('offline', 'offline')
|
gajim.connections[self.account].change_status('offline', 'offline')
|
||||||
if self.remove_and_unregister_radiobutton.get_active():
|
if self.remove_and_unregister_radiobutton.get_active():
|
||||||
|
if not self.account in gajim.connections:
|
||||||
|
dialogs.ErrorDialog(
|
||||||
|
_('Account is disabled'),
|
||||||
|
_('To unregister from a server, account must be '
|
||||||
|
'enabled.'))
|
||||||
|
return
|
||||||
if not gajim.connections[self.account].password:
|
if not gajim.connections[self.account].password:
|
||||||
def on_ok(passphrase, checked):
|
def on_ok(passphrase, checked):
|
||||||
if passphrase == -1:
|
if passphrase == -1:
|
||||||
|
@ -2896,7 +2906,8 @@ class RemoveAccountWindow:
|
||||||
else:
|
else:
|
||||||
self._on_remove_success(True)
|
self._on_remove_success(True)
|
||||||
|
|
||||||
if gajim.connections[self.account].connected:
|
if self.account in gajim.connections and \
|
||||||
|
gajim.connections[self.account].connected:
|
||||||
dialogs.ConfirmationDialog(
|
dialogs.ConfirmationDialog(
|
||||||
_('Account "%s" is connected to the server') % self.account,
|
_('Account "%s" is connected to the server') % self.account,
|
||||||
_('If you remove it, the connection will be lost.'),
|
_('If you remove it, the connection will be lost.'),
|
||||||
|
@ -2921,12 +2932,14 @@ class RemoveAccountWindow:
|
||||||
return
|
return
|
||||||
# Close all opened windows
|
# Close all opened windows
|
||||||
gajim.interface.roster.close_all(self.account, force=True)
|
gajim.interface.roster.close_all(self.account, force=True)
|
||||||
|
if self.account in gajim.connections:
|
||||||
gajim.connections[self.account].disconnect(on_purpose=True)
|
gajim.connections[self.account].disconnect(on_purpose=True)
|
||||||
del gajim.connections[self.account]
|
del gajim.connections[self.account]
|
||||||
gajim.logger.remove_roster(gajim.get_jid_from_account(self.account))
|
gajim.logger.remove_roster(gajim.get_jid_from_account(self.account))
|
||||||
gajim.config.del_per('accounts', self.account)
|
gajim.config.del_per('accounts', self.account)
|
||||||
gajim.interface.save_config()
|
gajim.interface.save_config()
|
||||||
del gajim.interface.instances[self.account]
|
del gajim.interface.instances[self.account]
|
||||||
|
if self.account in gajim.nicks:
|
||||||
del gajim.interface.minimized_controls[self.account]
|
del gajim.interface.minimized_controls[self.account]
|
||||||
del gajim.nicks[self.account]
|
del gajim.nicks[self.account]
|
||||||
del gajim.block_signed_in_notifications[self.account]
|
del gajim.block_signed_in_notifications[self.account]
|
||||||
|
|
Loading…
Reference in New Issue