diff --git a/configure.ac b/configure.ac index cc04ee34b..9e06da228 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_INIT([Gajim - A Jabber Instant Messager], - [0.12.5.2-dev],[http://trac.gajim.org/],[gajim]) + [0.12.5.3-dev],[http://trac.gajim.org/],[gajim]) AC_PREREQ([2.59]) AC_CONFIG_HEADER(config.h) diff --git a/data/glade/accounts_window.glade b/data/glade/accounts_window.glade index 55daa9acc..bb5f3cb9a 100644 --- a/data/glade/accounts_window.glade +++ b/data/glade/accounts_window.glade @@ -1,14 +1,14 @@ - + + + - - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 12 Accounts 800 - + True @@ -30,9 +30,9 @@ True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - automatic - automatic - in + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN True @@ -43,18 +43,16 @@ - - 0 - - gtk-add True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-add True + 0 @@ -64,12 +62,13 @@ - gtk-remove True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-remove True + 0 @@ -83,6 +82,7 @@ True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 @@ -96,7 +96,6 @@ False - 0 @@ -166,566 +165,535 @@ - + True - True - + True - 6 - 5 - 3 - 6 - 6 + True + _Enable + True + 0 + True + + + + False + False + + + + + True + True - + True - 0 - _Jabber ID: - True - jid_entry1 - - - GTK_FILL - - - - - - True - 0 - _Password: - True - password_entry1 - - - 1 - 2 - GTK_FILL - - - - - - True - False - True - False - True - - - - 1 - 2 - 1 - 2 - GTK_EXPAND | GTK_SHRINK | GTK_FILL - - - - - - Save pass_word - True - True - False - If checked, Gajim will remember the password for this account - True - False - True - - - - 2 - 3 - 1 - 2 - GTK_FILL - - - - - - True - 0 - Resour_ce: - True - resource_entry1 - - - 2 - 3 - GTK_FILL - - - - - - True - 0 - Priori_ty: - True - priority_spinbutton1 - - - 3 - 4 - GTK_FILL - - - - - - A_djust to status - True - True - False - Priority will change automatically according to your status. - True - True - - - - 1 - 2 - 3 - 4 - GTK_FILL - - - - - - True - True - Priority is used in Jabber to determine who gets the events from the jabber server when two or more clients are connected using the same account; The client with the highest priority gets the events - 5 0 127 1 5 0 - 1 - True - - - - 2 - 3 - 3 - 4 - GTK_FILL - - - - - - True - True + 6 + 5 + 3 + 6 + 6 - + True - 11 - True - - - Synchronise contacts - True - True - False - Click to request authorization to all contacts of another account - True - - - - False - 0 - - - - - Chan_ge Password - True - True - False - Click to change account's password - True - - - - False - 1 - - - - - - - True - Administration operations + True + Anonymous authentication + 0 + True + - label_item + 2 + 3 + GTK_FILL + + + + + + True + True + Resource is sent to the Jabber server in order to separate the same JID in two or more parts depending on the number of the clients connected in the same server with the same account. So you might be connected in the same account with resource 'Home' and 'Work' at the same time. The resource which has the highest priority will get the events. (see below) + Gajim + + + + 1 + 3 + 2 + 3 + GTK_EXPAND | GTK_SHRINK | GTK_FILL + + + + + + True + True + True + + + + 1 + 2 + + + + + + True + True + + + True + 11 + True + + + True + True + Click to request authorization to all contacts of another account + Synchronise contacts + True + 0 + + + + False + + + + + True + True + Click to change account's password + Chan_ge Password + True + 0 + + + + False + 1 + + + + + + + True + Administration operations + + + label_item + + + + + 3 + 4 + 5 + GTK_FILL + GTK_FILL + + + + + True + True + Priority is used in Jabber to determine who gets the events from the jabber server when two or more clients are connected using the same account; The client with the highest priority gets the events + 5 0 127 1 5 0 + 1 + True + + + + 2 + 3 + 3 + 4 + GTK_FILL + + + + + + True + True + Priority will change automatically according to your status. + A_djust to status + True + 0 + True + + + + 1 + 2 + 3 + 4 + GTK_FILL + + + + + + True + 0 + Priori_ty: + True + priority_spinbutton1 + + + 3 + 4 + GTK_FILL + + + + + + True + 0 + Resour_ce: + True + resource_entry1 + + + 2 + 3 + GTK_FILL + + + + + + True + True + If checked, Gajim will remember the password for this account + Save pass_word + True + False + 0 + True + + + + 2 + 3 + 1 + 2 + GTK_FILL + + + + + + True + False + True + False + True + + + + 1 + 2 + 1 + 2 + GTK_EXPAND | GTK_SHRINK | GTK_FILL + + + + + + True + 0 + _Password: + True + password_entry1 + + + 1 + 2 + GTK_FILL + + + + + + True + 0 + _Jabber ID: + True + jid_entry1 + + + GTK_FILL + + + + + + + + True + Account + + + tab + False + + + + + True + 6 + 6 + + + True + True + If checked, Gajim, when launched, will automatically connect to jabber using this account + C_onnect on Gajim startup + True + 0 + True + + + + False + False + + + + + True + True + Auto-reconnect when connection is lost + True + 0 + True + + + + False + False + 1 + + + + + True + True + Save conversation _logs for all contacts + True + 0 + True + True + + + + False + False + 2 + + + + + True + True + If checked, any change to the global status (handled by the combobox at the bottom of the roster window) will change the status of this account accordingly + Synch_ronize account status with global status + True + 0 + True + + + + False + False + 3 + + + + + True + True + If checked, Gajim will also broadcast some more IPs except from just your IP, so file transfer has higher chances of working. + Use file transfer proxies + True + 0 + True + + + + False + False + 4 - 3 - 4 - 5 - GTK_FILL - GTK_FILL - - - - - True - True - True - - - - 1 - 2 - - - - - - True - True - Resource is sent to the Jabber server in order to separate the same JID in two or more parts depending on the number of the clients connected in the same server with the same account. So you might be connected in the same account with resource 'Home' and 'Work' at the same time. The resource which has the highest priority will get the events. (see below) - Gajim - - - - 1 - 3 - 2 - 3 - GTK_EXPAND | GTK_SHRINK | GTK_FILL - - - - - - Anonymous authentication - True - True - False - True - - - - 2 - 3 - GTK_FILL - - - - - - - - True - Account - - - False - tab - - - - - True - 6 - 6 - - - C_onnect on Gajim startup - True - True - False - If checked, Gajim, when launched, will automatically connect to jabber using this account - True - True - - - - False - False - 0 - - - - - Auto-reconnect when connection is lost - True - True - False - True - True - - - - False - False 1 - - Save conversation _logs for all contacts + True - True - False - True - True - True - + General + True - False - False - 2 + tab + 1 + False - - Synch_ronize account status with global status + True - True - False - If checked, any change to the global status (handled by the combobox at the bottom of the roster window) will change the status of this account accordingly - True - True - - - - False - False - 3 - - - - - Use file transfer proxies - True - True - False - If checked, Gajim will also broadcast some more IPs except from just your IP, so file transfer has higher chances of working. - True - True - - - - False - False - 4 - - - - - 1 - - - - - True - General - True - - - 1 - False - tab - - - - - True - 6 - 12 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - none + 6 + 12 - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 12 + 0 + GTK_SHADOW_NONE - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 6 - 6 + 12 - - _use HTTP__PROXY environment variable + True - True - False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - True - True - - - - False - 0 - - - - - True + 6 6 - - True - None - - - - 0 - - - - - _Manage... + True True - False + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _use HTTP__PROXY environment variable True - + 0 + True + + + + False + + + + + True + 6 + + + True + None + + + + + + True + True + _Manage... + True + 0 + + + + False + False + 1 + + False - False 1 - - False - 1 - + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + <b>Proxy</b> + True + + + label_item + + - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - <b>Proxy</b> - True - - - label_item - - - - - 0 - - - - - True - 0 - none - - - True - 12 + 0 + GTK_SHADOW_NONE - + True - 6 - 6 + 12 - - _Warn before using an insecure connection + True - True - False - Check this so Gajim will ask you before sending your password over an insecure connection. - True - True - - - - False - False - 0 - - - - - Send _keep-alive packets - True - True - False - If checked, Gajim will send keep-alive packets to prevent connection timeout which results in disconnection - True - True - True - - - - False - False - 1 - - - - - Use cust_om hostname/port - True - True - False - True - True - - - - False - False - 2 - - - - - True - False + 6 6 - + True - _Hostname: + True + Check this so Gajim will ask you before sending your password over an insecure connection. + _Warn before using an insecure connection True + 0 + True + False False - 0 - + True True - + If checked, Gajim will send keep-alive packets to prevent connection timeout which results in disconnection + Send _keep-alive packets + True + 0 + True + True + + False + False 1 - + True - _Port: + True + Use cust_om hostname/port True + 0 + True + False @@ -734,217 +702,257 @@ - + True - True - 6 - 5222 - + False + 6 + + + True + _Hostname: + True + + + False + False + + + + + True + True + + + + 1 + + + + + True + _Port: + True + + + False + False + 2 + + + + + True + True + 6 + 5222 + + + + False + 3 + + - False 3 - - 3 - - - - - - True - <b>Miscellaneous</b> - True + + + True + <b>Miscellaneous</b> + True + + + label_item + + - label_item + False + 1 - False - 1 + 2 - - - 2 - - - - - True - Connection - - - 2 - False - tab - - - - - True - 5 - 6 - + True - 0 - none + Connection + + + tab + 2 + False + + + + + True + 5 + 6 - + True - 12 + 0 + GTK_SHADOW_NONE - + True - 6 - 6 + 12 - + True + 6 6 - + True + 6 + + + True + True + No key selected + True + + + False + False + + + + + True + True + True + + + 1 + + + + + True + True + Choose _Key... + True + 0 + + + + False + False + 2 + + + + + False + + + + + True + False True - No key selected - True + If checked, Gajim will get the password from a GPG agent like seahorse + Use G_PG Agent + True + 0 + True + False False - 0 - - - - - True - True - True - - 1 - - - Choose _Key... - True - True - False - True - - - - False - False - 2 - - - - False - 0 - - - - - Use G_PG Agent - True - False - True - False - If checked, Gajim will get the password from a GPG agent like seahorse - True - True - - - - False - False - 1 - - - - - - True - <b>OpenPGP</b> - True + + + True + <b>OpenPGP</b> + True + + + label_item + + - label_item + False + + + + + True + 0 + GTK_SHADOW_NONE + + + True + 6 + 12 + + + True + True + Information about you, as stored in the server + _Edit Personal Information... + True + 0 + + + + + + + + True + <b>Personal Information</b> + True + + + label_item + + + + + False + 1 - False - 0 + 3 - + True - 0 - none - - - True - 6 - 12 - - - _Edit Personal Information... - True - True - False - Information about you, as stored in the server - True - - - - - - - - True - <b>Personal Information</b> - True - - - label_item - - + Personal Information - False - 1 + tab + 3 + False - 3 - - - - - True - Personal Information - - - 3 - False - tab + 1 @@ -962,20 +970,20 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 1 - _Enable True True - False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _Enable True + 0 True False - 0 @@ -989,28 +997,27 @@ 6 - Co_nnect on Gajim startup True True - False If checked, Gajim, when launched, will automatically connect to jabber using this account + Co_nnect on Gajim startup True + 0 True False False - 0 - Save conversation _logs for all contacts True True - False + Save conversation _logs for all contacts True + 0 True @@ -1022,12 +1029,12 @@ - Synchroni_ze account status with global status True True - False If checked, any change to the global status (handled by the combobox at the bottom of the roster window) will change the status of this account accordingly + Synchroni_ze account status with global status True + 0 True @@ -1042,20 +1049,19 @@ True - Use cust_om port: True True - False If the default port that is used for incoming messages is unfitting for your setup you can select another one here. You might consider to change possible firewall settings. + Use cust_om port: True + 0 True False False - 0 @@ -1087,8 +1093,8 @@ You might consider to change possible firewall settings. True - False tab + False @@ -1113,7 +1119,6 @@ You might consider to change possible firewall settings. False False - 0 @@ -1128,7 +1133,6 @@ You might consider to change possible firewall settings. False False - 0 @@ -1141,11 +1145,11 @@ You might consider to change possible firewall settings. - Choose _Key... True True - False + Choose _Key... True + 0 @@ -1161,12 +1165,12 @@ You might consider to change possible firewall settings. - Use G_PG Agent True True - False If checked, Gajim will get the password from a GPG agent like seahorse + Use G_PG Agent True + 0 True @@ -1312,9 +1316,9 @@ You might consider to change possible firewall settings. Personal Information + tab 1 False - tab @@ -1340,18 +1344,15 @@ You might consider to change possible firewall settings. - - 0 - - Mer_ge accounts True True - False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Mer_ge accounts True + 0 True @@ -1364,21 +1365,21 @@ You might consider to change possible firewall settings. True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 6 - end + GTK_BUTTONBOX_END - gtk-close True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-close True + 0 False False - 0 diff --git a/src/common/config.py b/src/common/config.py index f2277f93e..5b1f887a4 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -100,7 +100,6 @@ class Config: 'mergeaccounts': [ opt_bool, False, '', True ], 'sort_by_show_in_roster': [ opt_bool, True, '', True ], 'sort_by_show_in_muc': [ opt_bool, False, '', True ], - 'enable_zeroconf': [opt_bool, False, _('Enable link-local/zeroconf messaging')], 'use_speller': [ opt_bool, False, ], 'ignore_incoming_xhtml': [ opt_bool, False, ], 'speller_language': [ opt_str, '', _('Language used by speller')], @@ -287,7 +286,7 @@ class Config: 'restore_last_status': [ opt_bool, False, _('If enabled, restore the last status that was used.') ], 'autoreconnect': [ opt_bool, True ], 'autoauth': [ opt_bool, False, _('If True, Contacts requesting authorization will be automatically accepted.')], - 'active': [ opt_bool, True], + 'active': [ opt_bool, True, _('If False, this account will be disabled and will not appear in roster window.'), True], 'proxy': [ opt_str, '', '', True ], 'keyid': [ opt_str, '', '', True ], 'gpg_sign_presence': [ opt_bool, True, _('If disabled, don\'t sign presences with GPG key, even if GPG is configured.') ], diff --git a/src/common/defs.py b/src/common/defs.py index 83ef075a3..3f73a6c9f 100644 --- a/src/common/defs.py +++ b/src/common/defs.py @@ -27,7 +27,7 @@ docdir = '../' datadir = '../' localedir = '../po' -version = '0.12.5.2-dev' +version = '0.12.5.3-dev' import sys, os.path for base in ('.', 'common'): diff --git a/src/common/optparser.py b/src/common/optparser.py index 5cedeeaca..f161ca053 100644 --- a/src/common/optparser.py +++ b/src/common/optparser.py @@ -204,6 +204,8 @@ class OptionsParser: self.update_config_to_01251() if old < [0, 12, 5, 2] and new >= [0, 12, 5, 2]: self.update_config_to_01252() + if old < [0, 12, 5, 3] and new >= [0, 12, 5, 3]: + self.update_config_to_01253() gajim.logger.init_vars() gajim.config.set('version', new_version) @@ -736,4 +738,14 @@ class OptionsParser: gajim.config.set_per('accounts', account, 'autoauth', val) gajim.config.set('version', '0.12.5.2') + def update_config_to_01253(self): + if 'enable_zeroconf' in self.old_values: + val = self.old_values['enable_zeroconf'] + for account in gajim.config.get_per('accounts'): + if gajim.config.get_per('accounts', account, 'is_zeroconf'): + gajim.config.set_per('accounts', account, 'active', val) + else: + gajim.config.set_per('accounts', account, 'active', True) + gajim.config.set('version', '0.12.5.3') + # vim: se ts=3: diff --git a/src/config.py b/src/config.py index 7aea772a7..d5be18655 100644 --- a/src/config.py +++ b/src/config.py @@ -1387,6 +1387,8 @@ class AccountsWindow: model.set(iter_, 0, account) def resend(self, account): + if not account in gajim.connections: + return show = gajim.SHOW_LIST[gajim.connections[account].connected] status = gajim.connections[account].status gajim.connections[account].change_status(show, status) @@ -1420,10 +1422,12 @@ class AccountsWindow: def on_no(account): if self.resend_presence: self.resend(account) - self.dialog = dialogs.YesNoDialog(_('Relogin now?'), - _('If you want all the changes to apply instantly, ' - 'you must relogin.'), on_response_yes=(on_yes, - self.current_account), on_response_no=(on_no, self.current_account)) + if self.current_account in gajim.connections: + self.dialog = dialogs.YesNoDialog(_('Relogin now?'), + _('If you want all the changes to apply instantly, ' + 'you must relogin.'), on_response_yes=(on_yes, + self.current_account), on_response_no=(on_no, + self.current_account)) elif self.resend_presence: self.resend(self.current_account) @@ -1507,12 +1511,13 @@ class AccountsWindow: self.notebook.set_current_page(1) def init_zeroconf_account(self): - enable = gajim.config.get('enable_zeroconf') and gajim.HAVE_ZEROCONF - self.xml.get_widget('enable_zeroconf_checkbutton2').set_active(enable) + active = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, + 'active') + self.xml.get_widget('enable_zeroconf_checkbutton2').set_active(active) if not gajim.HAVE_ZEROCONF: self.xml.get_widget('enable_zeroconf_checkbutton2').set_sensitive( False) - self.xml.get_widget('zeroconf_notebook').set_sensitive(enable) + self.xml.get_widget('zeroconf_notebook').set_sensitive(active) # General tab st = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'autoconnect') @@ -1573,7 +1578,7 @@ class AccountsWindow: use_gpg_agent_checkbutton = self.xml.get_widget( 'use_gpg_agent_checkbutton' + widget_name_add) - if not keyid or not gajim.connections[account].gpg: + if not keyid: use_gpg_agent_checkbutton.set_sensitive(False) gpg_key_label.set_text(_('No key selected')) gpg_name_label.set_text('') @@ -1587,6 +1592,9 @@ class AccountsWindow: def draw_normal_jid(self): account = self.current_account self.ignore_events = True + active = gajim.config.get_per('accounts', account, 'active') + self.xml.get_widget('enable_checkbutton1').set_active(active) + self.xml.get_widget('normal_notebook1').set_sensitive(active) if gajim.config.get_per('accounts', account, 'anonymous_auth'): self.xml.get_widget('anonymous_checkbutton1').set_active(True) self.xml.get_widget('jid_label1').set_text(_('Server:')) @@ -1667,7 +1675,7 @@ class AccountsWindow: # Personal tab gpg_key_label = self.xml.get_widget('gpg_key_label1') - if gajim.connections[account].gpg: + if gajim.HAVE_GPG: self.xml.get_widget('gpg_choose_button1').set_sensitive(True) self.init_account_gpg() else: @@ -1744,9 +1752,8 @@ class AccountsWindow: def on_rename_button_clicked(self, widget): if not self.current_account: return - enable = gajim.config.get('enable_zeroconf') - if (self.current_account != gajim.ZEROCONF_ACC_NAME or enable) and \ - gajim.connections[self.current_account].connected != 0: + active = gajim.config.get_per('accounts', self.current_account, 'active') + if active 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.')) @@ -1771,7 +1778,7 @@ class AccountsWindow: dialogs.ErrorDialog(_('Invalid account name'), _('Account name cannot contain spaces.')) return - if self.current_account != gajim.ZEROCONF_ACC_NAME or enable: + if active: # update variables gajim.interface.instances[new_name] = gajim.interface.instances[ old_name] @@ -2179,15 +2186,101 @@ class AccountsWindow: def on_merge_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'mergeaccounts') - if len(gajim.connections) >= 2: # Do not merge accounts if only one exists + if len(gajim.connections) >= 2: # Do not merge accounts if only one active gajim.interface.roster.regroup = gajim.config.get('mergeaccounts') else: gajim.interface.roster.regroup = False gajim.interface.roster.setup_and_draw_roster() + def _disable_account(self, account): + gajim.interface.roster.close_all(account) + if account == gajim.ZEROCONF_ACC_NAME: + gajim.connections[account].disable_account() + del gajim.connections[account] + gajim.interface.save_config() + del gajim.interface.instances[account] + del gajim.interface.minimized_controls[account] + del gajim.nicks[account] + del gajim.block_signed_in_notifications[account] + del gajim.groups[account] + gajim.contacts.remove_account(account) + del gajim.gc_connected[account] + del gajim.automatic_rooms[account] + del gajim.to_be_removed[account] + del gajim.newly_added[account] + del gajim.sleeper_state[account] + del gajim.encrypted_chats[account] + del gajim.last_message_time[account] + del gajim.status_before_autoaway[account] + del gajim.transport_avatar[account] + del gajim.gajim_optional_features[account] + del gajim.caps_hash[account] + if len(gajim.connections) >= 2: + # Do not merge accounts if only one exists + gajim.interface.roster.regroup = gajim.config.get('mergeaccounts') + else: + gajim.interface.roster.regroup = False + gajim.interface.roster.setup_and_draw_roster() + gajim.interface.roster.set_actions_menu_needs_rebuild() + + def _enable_account(self, account): + if account == gajim.ZEROCONF_ACC_NAME: + gajim.connections[account] = connection_zeroconf.ConnectionZeroconf( + account) + if gajim.connections[account].gpg: + self.xml.get_widget('gpg_choose_button2').set_sensitive(True) + else: + gajim.connections[account] = common.connection.Connection(account) + if gajim.connections[account].gpg: + self.xml.get_widget('gpg_choose_button1').set_sensitive(True) + self.init_account_gpg() + # update variables + gajim.interface.instances[account] = {'infos': {}, + 'disco': {}, 'gc_config': {}, 'search': {}, 'online_dialog': {}} + gajim.interface.minimized_controls[account] = {} + gajim.connections[account].connected = 0 + gajim.groups[account] = {} + gajim.contacts.add_account(account) + gajim.gc_connected[account] = {} + gajim.automatic_rooms[account] = {} + gajim.newly_added[account] = [] + gajim.to_be_removed[account] = [] + if account == gajim.ZEROCONF_ACC_NAME: + gajim.nicks[account] = gajim.ZEROCONF_ACC_NAME + else: + gajim.nicks[account] = gajim.config.get_per('accounts', account, + 'name') + gajim.block_signed_in_notifications[account] = True + gajim.sleeper_state[account] = 'off' + gajim.encrypted_chats[account] = [] + gajim.last_message_time[account] = {} + gajim.status_before_autoaway[account] = '' + gajim.transport_avatar[account] = {} + gajim.gajim_optional_features[account] = [] + gajim.caps_hash[account] = '' + # refresh roster + if len(gajim.connections) >= 2: + # Do not merge accounts if only one exists + gajim.interface.roster.regroup = gajim.config.get('mergeaccounts') + else: + gajim.interface.roster.regroup = False + gajim.interface.roster.setup_and_draw_roster() + gajim.interface.roster.set_actions_menu_needs_rebuild() + gajim.interface.save_config() + def on_enable_zeroconf_checkbutton2_toggled(self, widget): # don't do anything if there is an account with the local name but is a # normal account + if self.ignore_events: + return + if gajim.account_is_connected(self.current_account): + self.ignore_events = True + self.xml.get_widget('enable_zeroconf_checkbutton2').set_active(True) + self.ignore_events = False + dialogs.ErrorDialog( + _('You are currently connected to the server'), + _('To disable the account, you must be disconnected.')) + return if gajim.ZEROCONF_ACC_NAME in gajim.connections and not \ gajim.connections[gajim.ZEROCONF_ACC_NAME].is_zeroconf: gajim.connections[gajim.ZEROCONF_ACC_NAME].dispatch('ERROR', @@ -2196,77 +2289,42 @@ class AccountsWindow: '.'))) return - if gajim.config.get('enable_zeroconf') and not widget.get_active(): + if gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'active') \ + and not widget.get_active(): self.xml.get_widget('zeroconf_notebook').set_sensitive(False) # disable - gajim.interface.roster.close_all(gajim.ZEROCONF_ACC_NAME) - gajim.connections[gajim.ZEROCONF_ACC_NAME].disable_account() - del gajim.connections[gajim.ZEROCONF_ACC_NAME] - gajim.interface.save_config() - del gajim.interface.instances[gajim.ZEROCONF_ACC_NAME] - del gajim.interface.minimized_controls[gajim.ZEROCONF_ACC_NAME] - del gajim.nicks[gajim.ZEROCONF_ACC_NAME] - del gajim.block_signed_in_notifications[gajim.ZEROCONF_ACC_NAME] - del gajim.groups[gajim.ZEROCONF_ACC_NAME] - gajim.contacts.remove_account(gajim.ZEROCONF_ACC_NAME) - del gajim.gc_connected[gajim.ZEROCONF_ACC_NAME] - del gajim.automatic_rooms[gajim.ZEROCONF_ACC_NAME] - del gajim.to_be_removed[gajim.ZEROCONF_ACC_NAME] - del gajim.newly_added[gajim.ZEROCONF_ACC_NAME] - del gajim.sleeper_state[gajim.ZEROCONF_ACC_NAME] - del gajim.encrypted_chats[gajim.ZEROCONF_ACC_NAME] - del gajim.last_message_time[gajim.ZEROCONF_ACC_NAME] - del gajim.status_before_autoaway[gajim.ZEROCONF_ACC_NAME] - del gajim.transport_avatar[gajim.ZEROCONF_ACC_NAME] - del gajim.gajim_optional_features[gajim.ZEROCONF_ACC_NAME] - del gajim.caps_hash[gajim.ZEROCONF_ACC_NAME] - if len(gajim.connections) >= 2: - # Do not merge accounts if only one exists - gajim.interface.roster.regroup = gajim.config.get('mergeaccounts') - else: - gajim.interface.roster.regroup = False - gajim.interface.roster.setup_and_draw_roster() - gajim.interface.roster.set_actions_menu_needs_rebuild() + self._disable_account(gajim.ZEROCONF_ACC_NAME) - elif not gajim.config.get('enable_zeroconf') and widget.get_active(): + elif not gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, + 'active') and widget.get_active(): self.xml.get_widget('zeroconf_notebook').set_sensitive(True) # enable (will create new account if not present) - gajim.connections[gajim.ZEROCONF_ACC_NAME] = connection_zeroconf.\ - ConnectionZeroconf(gajim.ZEROCONF_ACC_NAME) - if gajim.connections[gajim.ZEROCONF_ACC_NAME].gpg: - self.xml.get_widget('gpg_choose_button2').set_sensitive(True) - self.init_account_gpg() - # update variables - gajim.interface.instances[gajim.ZEROCONF_ACC_NAME] = {'infos': {}, - 'disco': {}, 'gc_config': {}, 'search': {}, 'online_dialog': {}} - gajim.interface.minimized_controls[gajim.ZEROCONF_ACC_NAME] = {} - gajim.connections[gajim.ZEROCONF_ACC_NAME].connected = 0 - gajim.groups[gajim.ZEROCONF_ACC_NAME] = {} - gajim.contacts.add_account(gajim.ZEROCONF_ACC_NAME) - gajim.gc_connected[gajim.ZEROCONF_ACC_NAME] = {} - gajim.automatic_rooms[gajim.ZEROCONF_ACC_NAME] = {} - gajim.newly_added[gajim.ZEROCONF_ACC_NAME] = [] - gajim.to_be_removed[gajim.ZEROCONF_ACC_NAME] = [] - gajim.nicks[gajim.ZEROCONF_ACC_NAME] = gajim.ZEROCONF_ACC_NAME - gajim.block_signed_in_notifications[gajim.ZEROCONF_ACC_NAME] = True - gajim.sleeper_state[gajim.ZEROCONF_ACC_NAME] = 'off' - gajim.encrypted_chats[gajim.ZEROCONF_ACC_NAME] = [] - gajim.last_message_time[gajim.ZEROCONF_ACC_NAME] = {} - gajim.status_before_autoaway[gajim.ZEROCONF_ACC_NAME] = '' - gajim.transport_avatar[gajim.ZEROCONF_ACC_NAME] = {} - gajim.gajim_optional_features[gajim.ZEROCONF_ACC_NAME] = [] - gajim.caps_hash[gajim.ZEROCONF_ACC_NAME] = '' - # refresh roster - if len(gajim.connections) >= 2: - # Do not merge accounts if only one exists - gajim.interface.roster.regroup = gajim.config.get('mergeaccounts') - else: - gajim.interface.roster.regroup = False - gajim.interface.roster.setup_and_draw_roster() - gajim.interface.roster.set_actions_menu_needs_rebuild() - gajim.interface.save_config() + self._enable_account(gajim.ZEROCONF_ACC_NAME) - self.on_checkbutton_toggled(widget, 'enable_zeroconf') + self.on_checkbutton_toggled(widget, 'active', + account=gajim.ZEROCONF_ACC_NAME) + + def on_enable_checkbutton1_toggled(self, widget): + if self.ignore_events: + return + if gajim.account_is_connected(self.current_account): + self.ignore_events = True + self.xml.get_widget('enable_checkbutton1').set_active(True) + self.ignore_events = False + dialogs.ErrorDialog( + _('You are currently connected to the server'), + _('To disable the account, you must be disconnected.')) + return + # add/remove account in roster and all variables + if widget.get_active(): + # enable + self._enable_account(self.current_account) + else: + # disable + self._disable_account(self.current_account) + self.on_checkbutton_toggled(widget, 'active', + account=self.current_account, change_sensitivity_widgets=[ + self.xml.get_widget('normal_notebook1')]) def on_custom_port_checkbutton2_toggled(self, widget): self.xml.get_widget('custom_port_entry2').set_sensitive( diff --git a/src/gajim.py b/src/gajim.py index 82b95ad46..3c4bb4ebb 100644 --- a/src/gajim.py +++ b/src/gajim.py @@ -3486,11 +3486,13 @@ class Interface: gajim.proxy65_manager = proxy65_manager.Proxy65Manager(gajim.idlequeue) gajim.default_session_type = ChatControlSession self.register_handlers() - if gajim.config.get('enable_zeroconf') and gajim.HAVE_ZEROCONF: + if gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'active') \ + and gajim.HAVE_ZEROCONF: gajim.connections[gajim.ZEROCONF_ACC_NAME] = \ connection_zeroconf.ConnectionZeroconf(gajim.ZEROCONF_ACC_NAME) for account in gajim.config.get_per('accounts'): - if not gajim.config.get_per('accounts', account, 'is_zeroconf'): + if not gajim.config.get_per('accounts', account, 'is_zeroconf') and \ + gajim.config.get_per('accounts', account, 'active'): gajim.connections[account] = common.connection.Connection(account) # gtk hooks