don't traceback when remove a disabled account. Fixes #5647

This commit is contained in:
Yann Leboulanger 2010-03-10 13:51:55 +01:00
parent 31d1d35b17
commit ccde9e4382
1 changed files with 41 additions and 28 deletions

View File

@ -1893,9 +1893,9 @@ class AccountsWindow:
return
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
else:
elif account in gajim.interface.instances:
for key in gajim.interface.instances[account]:
if gajim.interface.instances[account][key] and key != \
'remove_account':
@ -1903,10 +1903,13 @@ class AccountsWindow:
break
# Detect if we have opened windows for this 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.\
present()
else:
if not account in gajim.interface.instances:
gajim.interface.instances[account] = {}
gajim.interface.instances[account]['remove_account'] = \
RemoveAccountWindow(account)
if win_opened:
@ -2871,12 +2874,19 @@ class RemoveAccountWindow:
def on_remove_button_clicked(self, widget):
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():
# change status to offline only if we will not remove this JID from
# server
gajim.connections[self.account].change_status('offline', 'offline')
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:
def on_ok(passphrase, checked):
if passphrase == -1:
@ -2896,7 +2906,8 @@ class RemoveAccountWindow:
else:
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(
_('Account "%s" is connected to the server') % self.account,
_('If you remove it, the connection will be lost.'),
@ -2920,13 +2931,15 @@ class RemoveAccountWindow:
on_response_ok=self.on_remove_responce_ok, is_modal=False)
return
# Close all opened windows
gajim.interface.roster.close_all(self.account, force = True)
gajim.connections[self.account].disconnect(on_purpose = True)
gajim.interface.roster.close_all(self.account, force=True)
if self.account in gajim.connections:
gajim.connections[self.account].disconnect(on_purpose=True)
del gajim.connections[self.account]
gajim.logger.remove_roster(gajim.get_jid_from_account(self.account))
gajim.config.del_per('accounts', self.account)
gajim.interface.save_config()
del gajim.interface.instances[self.account]
if self.account in gajim.nicks:
del gajim.interface.minimized_controls[self.account]
del gajim.nicks[self.account]
del gajim.block_signed_in_notifications[self.account]