allow to renamed the zeroconf account even if not enabled. Fixes #4238

This commit is contained in:
Yann Leboulanger 2008-08-26 10:48:24 +00:00
parent f63dcff5d3
commit b284b586da
1 changed files with 59 additions and 54 deletions

View File

@ -1419,7 +1419,7 @@ class AccountsWindow:
return
# Save config for previous account if needed cause focus_out event is
# called after the changed event
if self.current_account:
if self.current_account and self.window.get_focus():
focused_widget = self.window.get_focus()
focused_widget_name = focused_widget.get_name()
if focused_widget_name in ('jid_entry1', 'resource_entry1',
@ -1692,7 +1692,9 @@ class AccountsWindow:
remove(account)
def on_rename_button_clicked(self, widget):
if gajim.connections[self.current_account].connected != 0:
enable = gajim.config.get('enable_zeroconf')
if (self.current_account != gajim.ZEROCONF_ACC_NAME or enable) and \
gajim.connections[self.current_account].connected != 0:
dialogs.ErrorDialog(
_('You are currently connected to the server'),
_('To change the account name, you must be disconnected.'))
@ -1717,6 +1719,7 @@ class AccountsWindow:
dialogs.ErrorDialog(_('Invalid account name'),
_('Account name cannot contain spaces.'))
return
if self.current_account != gajim.ZEROCONF_ACC_NAME or enable:
# update variables
gajim.interface.instances[new_name] = gajim.interface.instances[
old_name]
@ -1732,7 +1735,8 @@ class AccountsWindow:
gajim.to_be_removed[new_name] = gajim.to_be_removed[old_name]
gajim.sleeper_state[new_name] = gajim.sleeper_state[old_name]
gajim.encrypted_chats[new_name] = gajim.encrypted_chats[old_name]
gajim.last_message_time[new_name] = gajim.last_message_time[old_name]
gajim.last_message_time[new_name] = \
gajim.last_message_time[old_name]
gajim.status_before_autoaway[new_name] = \
gajim.status_before_autoaway[old_name]
gajim.transport_avatar[new_name] = gajim.transport_avatar[old_name]
@ -1748,7 +1752,8 @@ class AccountsWindow:
# upgrade account variable in opened windows
for kind in ('infos', 'disco', 'gc_config', 'search'):
for j in gajim.interface.instances[new_name][kind]:
gajim.interface.instances[new_name][kind][j].account = new_name
gajim.interface.instances[new_name][kind][j].account = \
new_name
# ServiceCache object keep old property account
if hasattr(gajim.connections[old_name], 'services_cache'):