Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <forenjunkie@chello.at>2017-09-16 16:27:31 +0300
committerPhilipp Hörist <forenjunkie@chello.at>2017-09-16 17:09:19 +0300
commit539c1969db63a284916d8005f42ef881d58967d3 (patch)
tree7ac03a982b17dfce390d2303984626f6fec5f4bf
parentdfdeb65e8fdb43f586cc0a04143705e682eead51 (diff)
Remove old AccountsWindow
-rw-r--r--gajim/config.py1222
1 files changed, 4 insertions, 1218 deletions
diff --git a/gajim/config.py b/gajim/config.py
index 1245deabf..f1d743dd1 100644
--- a/gajim/config.py
+++ b/gajim/config.py
@@ -31,12 +31,14 @@
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
##
+import os
+
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import Pango
from gi.repository import GObject
from gi.repository import GLib
-import os
+
from gajim.common import config as c_config
from gajim.common import sleepy
from gajim.common.i18n import Q_
@@ -47,7 +49,6 @@ from gajim import cell_renderer_image
from gajim import message_control
from gajim.chat_control_base import ChatControlBase
from gajim import dataforms_widget
-from gajim import profile_window
from gajim import gui_menu_builder
try:
@@ -59,11 +60,9 @@ except (ImportError, ValueError):
from gajim.common import helpers
from gajim.common import app
from gajim.common import connection
-from gajim.common import passwords
-from gajim.common.zeroconf import connection_zeroconf
from gajim.common import dataforms
-from gajim.common import gpg
from gajim.common import ged
+from gajim.accounts_window import AccountsWindow
try:
from gajim.common.multimedia_helpers import AudioInputManager, AudioOutputManager
@@ -72,9 +71,6 @@ try:
except (ImportError, ValueError):
HAS_GST = False
-from gajim.common.exceptions import GajimGeneralException
-from gajim.common.connection_handlers_events import InformationEvent
-
#---------- PreferencesWindow class -------------#
class PreferencesWindow:
"""
@@ -1514,1216 +1510,6 @@ class ManageProxiesWindow:
app.config.set_per('proxies', proxy, 'pass', value)
-#---------- AccountsWindow class -------------#
-class AccountsWindow:
- """
- Class for accounts window: list of accounts
- """
-
- def on_accounts_window_destroy(self, widget):
- del app.interface.instances['accounts']
-
- def on_close_button_clicked(self, widget):
- self.check_resend_relog()
- self.window.destroy()
-
- def __init__(self):
- self.xml = gtkgui_helpers.get_gtk_builder('accounts_window.ui')
- self.window = self.xml.get_object('accounts_window')
- self.window.set_transient_for(app.interface.roster.window)
- self.accounts_treeview = self.xml.get_object('accounts_treeview')
- self.remove_button = self.xml.get_object('remove_button')
- self.rename_button = self.xml.get_object('rename_button')
- self.change_password_button = self.xml.get_object('change_password_button1')
- path_to_kbd_input_img = gtkgui_helpers.get_icon_path('gajim-kbd_input')
- img = self.xml.get_object('rename_image')
- img.set_from_file(path_to_kbd_input_img)
- self.notebook = self.xml.get_object('notebook')
- # Name
- model = Gtk.ListStore(str)
- self.accounts_treeview.set_model(model)
- # column
- renderer = Gtk.CellRendererText()
- col = Gtk.TreeViewColumn()
- col.set_title(_('Name'))
- col.pack_start(renderer, False)
- col.add_attribute(renderer, 'text', 0)
- self.accounts_treeview.insert_column(col, -1)
-
- self.current_account = None
- # When we fill info, we don't want to handle the changed signals
- self.ignore_events = False
- self.need_relogin = False
- self.resend_presence = False
-
- self.update_proxy_list()
- self.xml.connect_signals(self)
- self.init_accounts()
- self.window.show_all()
-
- # Merge accounts
- st = app.config.get('mergeaccounts')
- checkbutton = self.xml.get_object('merge_checkbutton')
- checkbutton.set_active(st)
- # prevent roster redraws by connecting the signal after button state is
- # set
- checkbutton.connect('toggled', self.on_merge_checkbutton_toggled)
-
- self.avahi_available = True
- try:
- import avahi
- except ImportError:
- self.avahi_available = False
-
- self.xml.get_object('close_button').grab_focus()
-
- def on_accounts_window_key_press_event(self, widget, event):
- if event.keyval == Gdk.KEY_Escape:
- self.check_resend_relog()
- self.window.destroy()
-
- def select_account(self, account):
- model = self.accounts_treeview.get_model()
- iter_ = model.get_iter_first()
- while iter_:
- acct = model[iter_][0]
- if account == acct:
- self.accounts_treeview.set_cursor(model.get_path(iter_))
- return
- iter_ = model.iter_next(iter_)
-
- def init_accounts(self):
- """
- Initialize listStore with existing accounts
- """
- self.remove_button.set_sensitive(False)
- self.rename_button.set_sensitive(False)
- self.change_password_button.set_sensitive(False)
- self.current_account = None
- model = self.accounts_treeview.get_model()
- model.clear()
- list_ = app.config.get_per('accounts')
- list_.sort()
- for account in list_:
- iter_ = model.append()
- model.set(iter_, 0, account)
-
- self.selection = self.accounts_treeview.get_selection()
- self.selection.select_iter(model.get_iter_first())
-
- def resend(self, account):
- if not account in app.connections:
- return
- show = app.SHOW_LIST[app.connections[account].connected]
- status = app.connections[account].status
- app.connections[account].change_status(show, status)
-
- def check_resend_relog(self):
- if self.need_relogin and self.current_account == \
- app.ZEROCONF_ACC_NAME:
- if app.ZEROCONF_ACC_NAME in app.connections:
- app.connections[app.ZEROCONF_ACC_NAME].update_details()
- return
-
- elif self.need_relogin and self.current_account and \
- app.connections[self.current_account].connected > 0:
- def login(account, show_before, status_before):
- """
- Login with previous status
- """
- # first make sure connection is really closed,
- # 0.5 may not be enough
- app.connections[account].disconnect(True)
- app.interface.roster.send_status(account, show_before,
- status_before)
-
- def relog(account):
- self.dialog.destroy()
- show_before = app.SHOW_LIST[app.connections[account].\
- connected]
- status_before = app.connections[account].status
- app.interface.roster.send_status(account, 'offline',
- _('Be right back.'))
- GLib.timeout_add(500, login, account, show_before,
- status_before)
-
- def on_yes(checked, account):
- relog(account)
- def on_no(account):
- if self.resend_presence:
- self.resend(account)
- if self.current_account in app.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)
-
- self.need_relogin = False
- self.resend_presence = False
-
- def on_accounts_treeview_cursor_changed(self, widget):
- """
- Activate modify buttons when a row is selected, update accounts info
- """
- sel = self.accounts_treeview.get_selection()
- if sel:
- (model, iter_) = sel.get_selected()
- if iter_:
- account = model[iter_][0]
- else:
- account = None
- else:
- iter_ = account = None
- if self.current_account and self.current_account == account:
- # We're comming back to our current account, no need to update
- # widgets
- return
- # Save config for previous account if needed cause focus_out event is
- # called after the changed event
- 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',
- 'custom_port_entry', 'cert_entry1'):
- if focused_widget_name == 'jid_entry1':
- func = self.on_jid_entry1_focus_out_event
- elif focused_widget_name == 'resource_entry1':
- func = self.on_resource_entry1_focus_out_event
- elif focused_widget_name == 'custom_port_entry':
- func = self.on_custom_port_entry_focus_out_event
- elif focused_widget_name == 'cert_entry1':
- func = self.on_cert_entry1_focus_out_event
- if func(focused_widget, None):
- # Error detected in entry, don't change account,
- # re-put cursor on previous row
- self.select_account(self.current_account)
- return True
- self.window.set_focus(widget)
-
- self.check_resend_relog()
-
- if account:
- self.remove_button.set_sensitive(True)
- self.rename_button.set_sensitive(True)
-
- if (account != app.ZEROCONF_ACC_NAME and
- account in app.connections):
- self.change_password_button.set_sensitive(
- app.connections[account].register_supported)
-
- else:
- self.remove_button.set_sensitive(False)
- self.rename_button.set_sensitive(False)
- self.change_password_button.set_sensitive(False)
- if iter_:
- self.current_account = account
- if account == app.ZEROCONF_ACC_NAME:
- self.remove_button.set_sensitive(False)
- self.init_account()
- self.update_proxy_list()
-
- def on_browse_for_client_cert_button_clicked(self, widget, data=None):
- def on_ok(widget, path_to_clientcert_file):
- self.dialog.destroy()
- if not path_to_clientcert_file:
- return
- self.xml.get_object('cert_entry1').set_text(path_to_clientcert_file)
- app.config.set_per('accounts', self.current_account,
- 'client_cert', path_to_clientcert_file)
-
- def on_cancel(widget):
- self.dialog.destroy()
-
- path_to_clientcert_file = self.xml.get_object('cert_entry1').get_text()
- self.dialog = dialogs.ClientCertChooserDialog(path_to_clientcert_file,
- on_ok, on_cancel)
-
- def update_proxy_list(self):
- if self.current_account:
- our_proxy = app.config.get_per('accounts', self.current_account,
- 'proxy')
- else:
- our_proxy = ''
-
- if not our_proxy:
- our_proxy = _('None')
- proxy_combobox = self.xml.get_object('proxies_combobox1')
- model = Gtk.ListStore(str)
- proxy_combobox.set_model(model)
- l = app.config.get_per('proxies')
- l.insert(0, _('None'))
- for i in range(len(l)):
- model.append([l[i]])
- if our_proxy == l[i]:
- proxy_combobox.set_active(i)
-
- def init_account(self):
- if not self.current_account:
- self.notebook.set_current_page(0)
- return
- if app.config.get_per('accounts', self.current_account,
- 'is_zeroconf'):
- self.ignore_events = True
- self.init_zeroconf_account()
- self.ignore_events = False
- self.notebook.set_current_page(2)
- return
- self.ignore_events = True
- self.init_normal_account()
- self.ignore_events = False
- self.notebook.set_current_page(1)
-
- def init_zeroconf_account(self):
- active = app.config.get_per('accounts', app.ZEROCONF_ACC_NAME,
- 'active')
- self.xml.get_object('enable_zeroconf_checkbutton2').set_active(active)
- if not app.HAVE_ZEROCONF:
- self.xml.get_object('enable_zeroconf_checkbutton2').set_sensitive(
- False)
- self.xml.get_object('zeroconf_notebook').set_sensitive(active)
- # General tab
- st = app.config.get_per('accounts', app.ZEROCONF_ACC_NAME,
- 'autoconnect')
- self.xml.get_object('autoconnect_checkbutton2').set_active(st)
-
- list_no_log_for = app.config.get_per('accounts',
- app.ZEROCONF_ACC_NAME, 'no_log_for').split()
- if app.ZEROCONF_ACC_NAME in list_no_log_for:
- self.xml.get_object('log_history_checkbutton2').set_active(0)
- else:
- self.xml.get_object('log_history_checkbutton2').set_active(1)
-
- st = app.config.get_per('accounts', app.ZEROCONF_ACC_NAME,
- 'sync_with_global_status')
- self.xml.get_object('sync_with_global_status_checkbutton2').set_active(
- st)
-
- st = app.config.get_per('accounts', app.ZEROCONF_ACC_NAME,
- 'use_custom_host')
- self.xml.get_object('custom_port_checkbutton2').set_active(st)
- self.xml.get_object('custom_port_entry2').set_sensitive(st)
-
- st = app.config.get_per('accounts', app.ZEROCONF_ACC_NAME,
- 'custom_port')
- if not st:
- app.config.set_per('accounts', app.ZEROCONF_ACC_NAME,
- 'custom_port', '5298')
- st = '5298'
- self.xml.get_object('custom_port_entry2').set_text(str(st))
-
- # Personal tab
- gpg_key_label = self.xml.get_object('gpg_key_label2')
- if app.ZEROCONF_ACC_NAME in app.connections and \
- app.connections[app.ZEROCONF_ACC_NAME].gpg:
- self.xml.get_object('gpg_choose_button2').set_sensitive(True)
- self.init_account_gpg()
- else:
- gpg_key_label.set_text(_('OpenPGP is not usable on this computer'))
- self.xml.get_object('gpg_choose_button2').set_sensitive(False)
-
- for opt in ('first_name', 'last_name', 'jabber_id', 'email'):
- st = app.config.get_per('accounts', app.ZEROCONF_ACC_NAME,
- 'zeroconf_' + opt)
- self.xml.get_object(opt + '_entry2').set_text(st)
-
- def init_account_gpg(self):
- account = self.current_account
- keyid = app.config.get_per('accounts', account, 'keyid')
- keyname = app.config.get_per('accounts', account, 'keyname')
- use_gpg_agent = app.config.get('use_gpg_agent')
-
- if account == app.ZEROCONF_ACC_NAME:
- widget_name_add = '2'
- else:
- widget_name_add = '1'
-
- gpg_key_label = self.xml.get_object('gpg_key_label' + widget_name_add)
- gpg_name_label = self.xml.get_object('gpg_name_label' + widget_name_add)
- use_gpg_agent_checkbutton = self.xml.get_object(
- 'use_gpg_agent_checkbutton' + widget_name_add)
-
- if not keyid:
- use_gpg_agent_checkbutton.set_sensitive(False)
- gpg_key_label.set_text(_('No key selected'))
- gpg_name_label.set_text('')
- return
-
- gpg_key_label.set_text(keyid)
- gpg_name_label.set_text(keyname)
- use_gpg_agent_checkbutton.set_sensitive(True)
- use_gpg_agent_checkbutton.set_active(use_gpg_agent)
-
- def draw_normal_jid(self):
- account = self.current_account
- self.ignore_events = True
- active = app.config.get_per('accounts', account, 'active')
- self.xml.get_object('enable_checkbutton1').set_active(active)
- self.xml.get_object('normal_notebook1').set_sensitive(active)
- if app.config.get_per('accounts', account, 'anonymous_auth'):
- self.xml.get_object('anonymous_checkbutton1').set_active(True)
- self.xml.get_object('jid_label1').set_text(_('Server:'))
- save_password = self.xml.get_object('save_password_checkbutton1')
- save_password.set_active(False)
- save_password.set_sensitive(False)
- password_entry = self.xml.get_object('password_entry1')
- password_entry.set_text('')
- password_entry.set_sensitive(False)
- jid = app.config.get_per('accounts', account, 'hostname')
- else:
- self.xml.get_object('anonymous_checkbutton1').set_active(False)
- self.xml.get_object('jid_label1').set_text(_('JID:'))
- savepass = app.config.get_per('accounts', account, 'savepass')
- save_password = self.xml.get_object('save_password_checkbutton1')
- save_password.set_sensitive(True)
- save_password.set_active(savepass)
- password_entry = self.xml.get_object('password_entry1')
- if savepass:
- passstr = passwords.get_password(account) or ''
- password_entry.set_sensitive(True)
- else:
- passstr = ''
- password_entry.set_sensitive(False)
- password_entry.set_text(passstr)
-
- jid = app.config.get_per('accounts', account, 'name') \
- + '@' + app.config.get_per('accounts', account, 'hostname')
- self.xml.get_object('jid_entry1').set_text(jid)
- self.ignore_events = False
-
- def init_normal_account(self):
- account = self.current_account
- # Account tab
- self.draw_normal_jid()
- self.xml.get_object('resource_entry1').set_text(app.config.get_per(
- 'accounts', account, 'resource'))
-
- client_cert = app.config.get_per('accounts', account, 'client_cert')
- self.xml.get_object('cert_entry1').set_text(client_cert)
- client_cert_encrypted = app.config.get_per('accounts', account,
- 'client_cert_encrypted')
- self.xml.get_object('client_cert_encrypted_checkbutton1').\
- set_active(client_cert_encrypted)
-
- self.xml.get_object('adjust_priority_with_status_checkbutton1').\
- set_active(app.config.get_per('accounts', account,
- 'adjust_priority_with_status'))
- spinbutton = self.xml.get_object('priority_spinbutton1')
- if app.config.get('enable_negative_priority'):
- spinbutton.set_range(-128, 127)
- else:
- spinbutton.set_range(0, 127)
- spinbutton.set_value(app.config.get_per('accounts', account,
- 'priority'))
-
- # Connection tab
- use_env_http_proxy = app.config.get_per('accounts', account,
- 'use_env_http_proxy')
- self.xml.get_object('use_env_http_proxy_checkbutton1').set_active(
- use_env_http_proxy)
- self.xml.get_object('proxy_hbox1').set_sensitive(not use_env_http_proxy)
-
- warn_when_insecure_ssl = app.config.get_per('accounts', account,
- 'warn_when_insecure_ssl_connection')
- self.xml.get_object('warn_when_insecure_connection_checkbutton1').\
- set_active(warn_when_insecure_ssl)
-
- self.xml.get_object('send_keepalive_checkbutton1').set_active(
- app.config.get_per('accounts', account, 'keep_alives_enabled'))
-
- use_custom_host = app.config.get_per('accounts', account,
- 'use_custom_host')
- self.xml.get_object('custom_host_port_checkbutton1').set_active(
- use_custom_host)
- custom_host = app.config.get_per('accounts', account, 'custom_host')
- if not custom_host:
- custom_host = app.config.get_per('accounts', account, 'hostname')
- app.config.set_per('accounts', account, 'custom_host',
- custom_host)
- self.xml.get_object('custom_host_entry1').set_text(custom_host)
- custom_port = app.config.get_per('accounts', account, 'custom_port')
- if not custom_port:
- custom_port = 5222
- app.config.set_per('accounts', account, 'custom_port',
- custom_port)
- self.xml.get_object('custom_port_entry1').set_text(str(custom_port))
-
- # Personal tab
- gpg_key_label = self.xml.get_object('gpg_key_label1')
- if app.HAVE_GPG:
- self.xml.get_object('gpg_choose_button1').set_sensitive(True)
- self.init_account_gpg()
- else:
- gpg_key_label.set_text(_('OpenPGP is not usable on this computer'))
- self.xml.get_object('gpg_choose_button1').set_sensitive(False)
-
- # General tab
- self.xml.get_object('autoconnect_checkbutton1').set_active(
- app.config.get_per('accounts', account, 'autoconnect'))
- self.xml.get_object('autoreconnect_checkbutton1').set_active(app.
- config.get_per('accounts', account, 'autoreconnect'))
-
- list_no_log_for = app.config.get_per('accounts', account,
- 'no_log_for').split()
- if account in list_no_log_for:
- self.xml.get_object('log_history_checkbutton1').set_active(False)
- else:
- self.xml.get_object('log_history_checkbutton1').set_active(True)
-
- self.xml.get_object('sync_logs_with_server_checkbutton1').set_active(
- app.config.get_per('accounts', account, 'sync_logs_with_server'))
- self.xml.get_object('sync_with_global_status_checkbutton1').set_active(
- app.config.get_per('accounts', account,
- 'sync_with_global_status'))
- self.xml.get_object('carbons_checkbutton1').set_active(
- app.config.get_per('accounts', account, 'enable_message_carbons'))
- self.xml.get_object('use_ft_proxies_checkbutton1').set_active(
- app.config.get_per('accounts', account, 'use_ft_proxies'))
-
- def on_add_button_clicked(self, widget):
- """
- When add button is clicked: open an account information window
- """
- if 'account_creation_wizard' in app.interface.instances:
- app.interface.instances['account_creation_wizard'].window.present()
- else:
- app.interface.instances['account_creation_wizard'] = \
- AccountCreationWizardWindow()
-
- def on_remove_button_clicked(self, widget):
- """
- When delete button is clicked: Remove an account from the listStore and
- from the config file
- """
- if not self.current_account:
- return
- account = self.current_account
- if len(app.events.get_events(account)):
- dialogs.ErrorDialog(_('Unread events'),
- _('Read all pending events before removing this account.'),
- transient_for=self.window)
- return
-
- if app.config.get_per('accounts', account, 'is_zeroconf'):
- # Should never happen as button is insensitive
- return
-
- win_opened = False
- if app.interface.msg_win_mgr.get_controls(acct=account):
- win_opened = True
- elif account in app.interface.instances:
- for key in app.interface.instances[account]:
- if app.interface.instances[account][key] and key != \
- 'remove_account':
- win_opened = True
- break
- # Detect if we have opened windows for this account
- def remove(account):
- if account in app.interface.instances and \
- 'remove_account' in app.interface.instances[account]:
- app.interface.instances[account]['remove_account'].window.\
- present()
- else:
- if not account in app.interface.instances:
- app.interface.instances[account] = {}
- app.interface.instances[account]['remove_account'] = \
- RemoveAccountWindow(account)
- if win_opened:
- dialogs.ConfirmationDialog(
- _('You have opened chat in account %s') % account,
- _('All chat and groupchat windows will be closed. Do you want to '
- 'continue?'),
- on_response_ok = (remove, account))
- else:
- remove(account)
-
- def on_rename_button_clicked(self, widget):
- if not self.current_account:
- return
- active = app.config.get_per('accounts', self.current_account,
- 'active') and self.current_account in app.connections
- if active and app.connections[self.current_account].connected != 0:
- dialogs.ErrorDialog(
- _('You are currently connected to the server'),
- _('To change the account name, you must be disconnected.'),
- transient_for=self.window)
- return
- if len(app.events.get_events(self.current_account)):
- dialogs.ErrorDialog(_('Unread events'),
- _('To change the account name, you must read all pending '
- 'events.'), transient_for=self.window)
- return
- # Get the new name
- def on_renamed(new_name, old_name):
- if new_name in app.connections:
- dialogs.ErrorDialog(_('Account Name Already Used'),
- _('This name is already used by another of your accounts. '
- 'Please choose another name.'), transient_for=self.window)
- return
- if (new_name == ''):
- dialogs.ErrorDialog(_('Invalid account name'),
- _('Account name cannot be empty.'),
- transient_for=self.window)
- return
- if new_name.find(' ') != -1:
- dialogs.ErrorDialog(_('Invalid account name'),
- _('Account name cannot contain spaces.'),
- transient_for=self.window)
- return
- if active:
- # update variables
- app.interface.instances[new_name] = app.interface.instances[
- old_name]
- app.interface.minimized_controls[new_name] = \
- app.interface.minimized_controls[old_name]
- app.nicks[new_name] = app.nicks[old_name]
- app.block_signed_in_notifications[new_name] = \
- app.block_signed_in_notifications[old_name]
- app.groups[new_name] = app.groups[old_name]
- app.gc_connected[new_name] = app.gc_connected[old_name]
- app.automatic_rooms[new_name] = app.automatic_rooms[
- old_name]
- app.newly_added[new_name] = app.newly_added[old_name]
- app.to_be_removed[new_name] = app.to_be_removed[old_name]
- app.sleeper_state[new_name] = app.sleeper_state[old_name]
- app.encrypted_chats[new_name] = app.encrypted_chats[
- old_name]
- app.last_message_time[new_name] = \
- app.last_message_time[old_name]
- app.status_before_autoaway[new_name] = \
- app.status_before_autoaway[old_name]
- app.transport_avatar[new_name] = app.transport_avatar[old_name]
- app.gajim_optional_features[new_name] = \
- app.gajim_optional_features[old_name]
- app.caps_hash[new_name] = app.caps_hash[old_name]
-
- app.contacts.change_account_name(old_name, new_name)
- app.events.change_account_name(old_name, new_name)
-
- # change account variable for chat / gc controls
- app.interface.msg_win_mgr.change_account_name(old_name, new_name)
- # upgrade account variable in opened windows
- for kind in ('infos', 'disco', 'gc_config', 'search',
- 'online_dialog', 'sub_request'):
- for j in app.interface.instances[new_name][kind]:
- app.interface.instances[new_name][kind][j].account = \
- new_name
-
- # ServiceCache object keep old property account
- if hasattr(app.connections[old_name], 'services_cache'):
- app.connections[old_name].services_cache.account = \
- new_name
- del app.interface.instances[old_name]
- del app.interface.minimized_controls[old_name]
- del app.nicks[old_name]
- del app.block_signed_in_notifications[old_name]
- del app.groups[old_name]
- del app.gc_connected[old_name]
- del app.automatic_rooms[old_name]
- del app.newly_added[old_name]
- del app.to_be_removed[old_name]
- del app.sleeper_state[old_name]
- del app.encrypted_chats[old_name]
- del app.last_message_time[old_name]
- del app.status_before_autoaway[old_name]
- del app.transport_avatar[old_name]
- del app.gajim_optional_features[old_name]
- del app.caps_hash[old_name]
- app.connections[old_name].name = new_name
- app.connections[old_name].pep_change_account_name(new_name)
- app.connections[old_name].caps_change_account_name(new_name)
- app.connections[new_name] = app.connections[old_name]
- del app.connections[old_name]
- app.config.add_per('accounts', new_name)
- old_config = app.config.get_per('accounts', old_name)
- for opt in old_config:
- app.config.set_per('accounts', new_name, opt, old_config[opt])
- app.config.del_per('accounts', old_name)
- if self.current_account == old_name:
- self.current_account = new_name
- if old_name == app.ZEROCONF_ACC_NAME:
- app.ZEROCONF_ACC_NAME = new_name
- # refresh roster
- app.interface.roster.setup_and_draw_roster()
- self.init_accounts()
- self.select_account(new_name)
- app.app.remove_account_actions(old_name)
- app.app.add_account_actions(new_name)
- gui_menu_builder.build_accounts_menu()
-
- title = _('Rename Account')
- message = _('Enter a new name for account %s') % self.current_account
- old_text = self.current_account
- dialogs.InputDialog(title, message, old_text, is_modal=False,
- ok_handler=(on_renamed, self.current_account),
- transient_for=self.window)
-
- def option_changed(self, option, value):
- return app.config.get_per('accounts', self.current_account, option) \
- != value
-
- def on_jid_entry1_focus_out_event(self, widget, event):
- if self.ignore_events:
- return
- jid = widget.get_text()
- # check if jid is conform to RFC and stringprep it
- try:
- jid = helpers.parse_jid(jid)
- except helpers.InvalidFormat as s:
- if not widget.is_focus():
- pritext = _('Invalid JID')
- dialogs.ErrorDialog(pritext, str(s), transient_for=self.window)
- GLib.idle_add(lambda: widget.grab_focus())
- return True
-
- jid_splited = jid.split('@', 1)
- if len(jid_splited) != 2 and not app.config.get_per('accounts',
- self.current_account, 'anonymous_auth'):
- if not widget.is_focus():
- pritext = _('Invalid JID')
- sectext = \
- _('A JID must be in the form "user@servername".')
- dialogs.ErrorDialog(pritext, sectext, transient_for=self.window)
- GLib.idle_add(lambda: widget.grab_focus())
- return True
-
-
- if app.config.get_per('accounts', self.current_account,
- 'anonymous_auth'):
- app.config.set_per('accounts', self.current_account, 'hostname',
- jid_splited[0])
- if self.option_changed('hostname', jid_splited[0]):
- self.need_relogin = True
- else:
- if self.option_changed('name', jid_splited[0]) or \
- self.option_changed('hostname', jid_splited[1]):
- self.need_relogin = True
-
- app.config.set_per('accounts', self.current_account, 'name',
- jid_splited[0])
- app.config.set_per('accounts', self.current_account, 'hostname',
- jid_splited[1])
-
- def on_cert_entry1_focus_out_event(self, widget, event):
- if self.ignore_events:
- return
- client_cert = widget.get_text()
- if self.option_changed('client_cert', client_cert):
- self.need_relogin = True
- app.config.set_per('accounts', self.current_account, 'client_cert',
- client_cert)
-
- def on_anonymous_checkbutton1_toggled(self, widget):
- if self.ignore_events:
- return
- active = widget.get_active()
- app.config.set_per('accounts', self.current_account, 'anonymous_auth',
- active)
- self.draw_normal_jid()
-
- def on_password_entry1_changed(self, widget):
- if self.ignore_events:
- return
- passwords.save_password(self.current_account, widget.get_text())
-
- def on_save_password_checkbutton1_toggled(self, widget):
- if self.ignore_events:
- return
- active = widget.get_active()
- password_entry = self.xml.get_object('password_entry1')
- password_entry.set_sensitive(active)
- app.config.set_per('accounts', self.current_account, 'savepass',
- active)
- if active:
- password = password_entry.get_text()
- passwords.save_password(self.current_account, password)
- else:
- passwords.save_password(self.current_account, '')
-
- def on_resource_entry1_focus_out_event(self, widget, event):
- if self.ignore_events:
- return
- resource = self.xml.get_object('resource_entry1').get_text()
- try:
- resource = helpers.parse_resource(resource)
- except helpers.InvalidFormat as s:
- if not widget.is_focus():
- pritext = _('Invalid JID')
- dialogs.ErrorDialog(pritext, str(s), transient_for=self.window)
- GLib.idle_add(lambda: widget.grab_focus())
- return True
-
- if self.option_changed('resource', resource):
- self.need_relogin = True
-
- app.config.set_per('accounts', self.current_account, 'resource',
- resource)
-
- def on_adjust_priority_with_status_checkbutton1_toggled(self, widget):
- self.xml.get_object('priority_spinbutton1').set_sensitive(
- not widget.get_active())
- self.on_checkbutton_toggled(widget, 'adjust_priority_with_status',
- account = self.current_account)
-
- def on_priority_spinbutton1_value_changed(self, widget):
- prio = widget.get_value_as_int()
-
- if self.option_changed('priority', prio):
- self.resend_presence = True
-
- app.config.set_per('accounts', self.current_account, 'priority', prio)
-
- def on_synchronise_contacts_button1_clicked(self, widget):
- try:
- dialogs.SynchroniseSelectAccountDialog(self.current_account)
- except GajimGeneralException:
- # If we showed ErrorDialog, there will not be dialog instance
- return
-
- def on_change_password_button1_clicked(self, widget):
- def on_changed(new_password):
- if new_password is not None:
- app.connections[self.current_account].change_password(
- new_password)
- if self.xml.get_object('save_password_checkbutton1').\
- get_active():
- self.xml.get_object('password_entry1').set_text(
- new_password)
-
- try:
- dialogs.ChangePasswordDialog(self.current_account, on_changed,
- self.window)
- except GajimGeneralException:
- # if we showed ErrorDialog, there will not be dialog instance
- return
-
- def on_client_cert_encrypted_checkbutton1_toggled(self, widget):
- if self.ignore_events:
- return
- self.on_checkbutton_toggled(widget, 'client_cert_encrypted',
- account=self.current_account)
-
- def on_autoconnect_checkbutton_toggled(self, widget):
- if self.ignore_events:
- return
- self.on_checkbutton_toggled(widget, 'autoconnect',
- account=self.current_account)
-
- def on_autoreconnect_checkbutton_toggled(self, widget):
- if self.ignore_events:
- return
- self.on_checkbutton_toggled(widget, 'autoreconnect',
- account=self.current_account)
-
- def on_log_history_checkbutton_toggled(self, widget):
- if self.ignore_events:
- return
- list_no_log_for = app.config.get_per('accounts', self.current_account,
- 'no_log_for').split()
- if self.current_account in list_no_log_for:
- list_no_log_for.remove(self.current_account)
-
- if not widget.get_active():
- list_no_log_for.append(self.current_account)
- app.config.set_per('accounts', self.current_account, 'no_log_for',
- ' '.join(list_no_log_for))
-
- def on_sync_logs_with_server_checkbutton_toggled(self, widget):
- if self.ignore_events:
- return
- self.on_checkbutton_toggled(widget, 'sync_logs_with_server',
- account=self.current_account)
-
- def on_sync_with_global_status_checkbutton_toggled(self, widget):
- if self.ignore_events:
- return
- self.on_checkbutton_toggled(widget, 'sync_with_global_status',
- account=self.current_account)
- app.interface.roster.update_status_combobox()
-
- def on_carbons_checkbutton_toggled(self, widget):
- if self.ignore_events:
- return
- self.on_checkbutton_toggled(widget, 'enable_message_carbons',
- account=self.current_account)
-
- def on_use_ft_proxies_checkbutton1_toggled(self, widget):
- if self.ignore_events:
- return
- self.on_checkbutton_toggled(widget, 'use_ft_proxies',
- account=self.current_account)
-
- def on_use_env_http_proxy_checkbutton1_toggled(self, widget):
- if self.ignore_events:
- return
- self.on_checkbutton_toggled(widget, 'use_env_http_proxy',
- account=self.current_account)
- hbox = self.xml.get_object('proxy_hbox1')
- hbox.set_sensitive(not widget.get_active())
-
- def on_proxies_combobox1_changed(self, widget):
- active = widget.get_active()
- proxy = widget.get_model()[active][0]
- if proxy == _('None'):
- proxy = ''
-
- if self.option_changed('proxy', proxy):
- self.need_relogin = True
-
- app.config.set_per('accounts', self.current_account, 'proxy', proxy)
-
- def on_manage_proxies_button1_clicked(self, widget):
- if 'manage_proxies' in app.interface.instances:
- app.interface.instances['manage_proxies'].window.present()
- else:
- app.interface.instances['manage_proxies'] = ManageProxiesWindow(
- self.window)
-
- def on_warn_when_insecure_connection_checkbutton1_toggled(self, widget):
- if self.ignore_events:
- return
-
- self.on_checkbutton_toggled(widget, 'warn_when_insecure_ssl_connection',
- account=self.current_account)
-
- def on_send_keepalive_checkbutton1_toggled(self, widget):
- if self.ignore_events:
- return
- self.on_checkbutton_toggled(widget, 'keep_alives_enabled',
- account=self.current_account)
- app.config.set_per('accounts', self.current_account,
- 'ping_alives_enabled', widget.get_active())
-
- def on_custom_host_port_checkbutton1_toggled(self, widget):
- if self.option_changed('use_custom_host', widget.get_active()):
- self.need_relogin = True
-
- self.on_checkbutton_toggled(widget, 'use_custom_host',
- account=self.current_account)
- active = widget.get_active()
- self.xml.get_object('custom_host_port_hbox1').set_sensitive(active)
-
- def on_custom_host_entry1_changed(self, widget):
- if self.ignore_events:
- return
- host = widget.get_text()
- if self.option_changed('custom_host', host):
- self.need_relogin = True
- app.config.set_per('accounts', self.current_account, 'custom_host',
- host)
-
- def on_custom_port_entry_focus_out_event(self, widget, event):
- if self.ignore_events:
- return
- custom_port = widget.get_text()
- try:
- custom_port = int(custom_port)
- except Exception:
- if not widget.is_focus():
- dialogs.ErrorDialog(_('Invalid entry'),
- _('Custom port must be a port number.'),
- transient_for=self.window)
- GLib.idle_add(lambda: widget.grab_focus())
- return True
- if self.option_changed('custom_port', custom_port):
- self.need_relogin = True
- app.config.set_per('accounts', self.current_account, 'custom_port',
- custom_port)
-
- def on_gpg_choose_button_clicked(self, widget, data = None):
- if self.current_account in app.connections and \
- app.connections[self.current_account].gpg:
- secret_keys = app.connections[self.current_account].\
- ask_gpg_secrete_keys()
-
- # self.current_account is None and/or app.connections is {}
- else:
- if app.HAVE_GPG:
- secret_keys = gpg.GnuPG().get_secret_keys()
- else:
- secret_keys = []
- if not secret_keys:
- dialogs.ErrorDialog(_('Failed to get secret keys'),
- _('There is no OpenPGP secret key available.'),
- transient_for=self.window)
- secret_keys[_('None')] = _('None')
-
- def on_key_selected(keyID):
- if keyID is None:
- return
- if self.current_account == app.ZEROCONF_ACC_NAME:
- wiget_name_ext = '2'
- else:
- wiget_name_ext = '1'
- gpg_key_label = self.xml.get_object('gpg_key_label' + \
- wiget_name_ext)
- gpg_name_label = self.xml.get_object('gpg_name_label' + \
- wiget_name_ext)
- use_gpg_agent_checkbutton = self.xml.get_object(
- 'use_gpg_agent_checkbutton' + wiget_name_ext)
- if keyID[0] == _('None'):
- gpg_key_label.set_text(_('No key selected'))
- gpg_name_label.set_text('')
- use_gpg_agent_checkbutton.set_sensitive(False)
- if self.option_changed('keyid', ''):
- self.need_relogin = True
- app.config.set_per('accounts', self.current_account,
- 'keyname', '')
- app.config.set_per('accounts', self.current_account, 'keyid',
- '')
- else:
- gpg_key_label.set_text(keyID[0])
- gpg_name_label.set_text(keyID[1])
- use_gpg_agent_checkbutton.set_sensitive(True)
- if self.option_changed('keyid', keyID[0]):
- self.need_relogin = True
- app.config.set_per('accounts', self.current_account,
- 'keyname', keyID[1])
- app.config.set_per('accounts', self.current_account, 'keyid',
- keyID[0])
-
- dialogs.ChooseGPGKeyDialog(_('OpenPGP Key Selection'),
- _('Choose your OpenPGP key'), secret_keys, on_key_selected,
- transient_for=self.window)
-
- def on_use_gpg_agent_checkbutton_toggled(self, widget):
- self.on_checkbutton_toggled(widget, 'use_gpg_agent')
-
- def on_edit_details_button1_clicked(self, widget):
- if self.current_account not in app.interface.instances:
- dlg = dialogs.ErrorDialog(_('No such account available'),
- _('You must create your account before editing your personal '
- 'information.'), transient_for=self.window)
- return
-
- # show error dialog if account is newly created (not in app.connections)
- if self.current_account not in app.connections or \
- app.connections[self.current_account].connected < 2:
- dialogs.ErrorDialog(_('You are not connected to the server'),
- _('Without a connection, you can not edit your personal '
- 'information.'), transient_for=self.window)
- return
-
- if not app.connections[self.current_account].vcard_supported:
- dialogs.ErrorDialog(_("Your server does not have vCard support"),
- _("Your server can't save your personal information."),
- transient_for=self.window)
- return
-
- jid = app.get_jid_from_account(self.current_account)
- if 'profile' not in app.interface.instances[self.current_account]:
- app.interface.instances[self.current_account]['profile'] = \
- profile_window.ProfileWindow(self.current_account, transient_for=self.window)
- app.connections[self.current_account].request_vcard(jid)
-
- def on_checkbutton_toggled(self, widget, config_name,
- change_sensitivity_widgets = None, account = None):
- if account:
- app.config.set_per('accounts', account, config_name,
- widget.get_active())
- else:
- app.config.set(config_name, widget.get_active())
- if change_sensitivity_widgets:
- for w in change_sensitivity_widgets:
- w.set_sensitive(widget.get_active())
-
- def on_merge_checkbutton_toggled(self, widget):
- self.on_checkbutton_toggled(widget, 'mergeaccounts')
- if len(app.connections) >= 2: # Do not merge accounts if only one active
- app.interface.roster.regroup = app.config.get('mergeaccounts')
- else:
- app.interface.roster.regroup = False
- app.interface.roster.setup_and_draw_roster()
-
- def _disable_account(self, account):
- app.interface.roster.close_all(account)
- if account == app.ZEROCONF_ACC_NAME:
- app.connections[account].disable_account()
- app.connections[account].cleanup()
- del app.connections[account]
- del app.interface.instances[account]
- del app.interface.minimized_controls[account]
- del app.nicks[account]
- del app.block_signed_in_notifications[account]
- del app.groups[account]
- app.contacts.remove_account(account)
- del app.gc_connected[account]
- del app.automatic_rooms[account]
- del app.to_be_removed[account]
- del app.newly_added[account]
- del app.sleeper_state[account]
- del app.encrypted_chats[account]
- del app.last_message_time[account]
- del app.status_before_autoaway[account]
- del app.transport_avatar[account]
- del app.gajim_optional_features[account]
- del app.caps_hash[account]
- if len(app.connections) >= 2:
- # Do not merge accounts if only one exists
- app.interface.roster.regroup = app.config.get('mergeaccounts')
- else:
- app.interface.roster.regroup = False
- app.interface.roster.setup_and_draw_roster()
- app.app.remove_account_actions(account)
- gui_menu_builder.build_accounts_menu()
-
- def _enable_account(self, account):
- if account == app.ZEROCONF_ACC_NAME:
- app.connections[account] = connection_zeroconf.ConnectionZeroconf(
- account)
- if app.connections[account].gpg:
- self.xml.get_object('gpg_choose_button2').set_sensitive(True)
- else:
- app.connections[account] = connection.Connection(account)
- if app.connections[account].gpg:
- self.xml.get_object('gpg_choose_button1').set_sensitive(True)
- self.init_account_gpg()
- # update variables
- app.interface.instances[account] = {'infos': {},
- 'disco': {}, 'gc_config': {}, 'search': {}, 'online_dialog': {},
- 'sub_request': {}}
- app.interface.minimized_controls[account] = {}
- app.connections[account].connected = 0
- app.groups[account] = {}
- app.contacts.add_account(account)
- app.gc_connected[account] = {}
- app.automatic_rooms[account] = {}
- app.newly_added[account] = []
- app.to_be_removed[account] = []
- if account == app.ZEROCONF_ACC_NAME:
- app.nicks[account] = app.ZEROCONF_ACC_NAME
- else:
- app.nicks[account] = app.config.get_per('accounts', account,
- 'name')
- app.block_signed_in_notifications[account] = True
- app.sleeper_state[account] = 'off'
- app.encrypted_chats[account] = []
- app.last_message_time[account] = {}
- app.status_before_autoaway[account] = ''
- app.transport_avatar[account] = {}
- app.gajim_optional_features[account] = []
- app.caps_hash[account] = ''
- helpers.update_optional_features(account)
- # refresh roster
- if len(app.connections) >= 2:
- # Do not merge accounts if only one exists
- app.interface.roster.regroup = app.config.get('mergeaccounts')
- else:
- app.interface.roster.regroup = False
- app.interface.roster.setup_and_draw_roster()
- app.app.add_account_actions(account)
- gui_menu_builder.build_accounts_menu()
-
- 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 self.current_account in app.connections and \
- app.connections[self.current_account].connected > 0:
- self.ignore_events = True
- self.xml.get_object('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.'),
- transient_for=self.window)
- return
- if app.ZEROCONF_ACC_NAME in app.connections and not \
- app.connections[app.ZEROCONF_ACC_NAME].is_zeroconf:
- app.nec.push_incoming_event(InformationEvent(None,
- conn=app.connections[app.ZEROCONF_ACC_NAME],
- level='error', pri_txt=_('Account Local already exists.'),
- sec_txt=_('Please rename or remove it before enabling '
- 'link-local messaging.')))
- return
-
- if app.config.get_per('accounts', app.ZEROCONF_ACC_NAME, 'active') \
- and not widget.get_active():
- self.xml.get_object('zeroconf_notebook').set_sensitive(False)
- # disable
- self._disable_account(app.ZEROCONF_ACC_NAME)
-
- elif not app.config.get_per('accounts', app.ZEROCONF_ACC_NAME,
- 'active') and widget.get_active():
- self.xml.get_object('zeroconf_notebook').set_sensitive(True)
- # enable (will create new account if not present)
- self._enable_account(app.ZEROCONF_ACC_NAME)
-
- self.on_checkbutton_toggled(widget, 'active',
- account=app.ZEROCONF_ACC_NAME)
-
- def on_enable_checkbutton1_toggled(self, widget):
- if self.ignore_events:
- return
- if self.current_account in app.connections and \
- app.connections[self.current_account].connected > 0:
- # connecting or connected
- self.ignore_events = True
- self.xml.get_object('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.'),
- transient_for=self.window)
- 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_object('normal_notebook1')])
-
- def on_custom_port_checkbutton2_toggled(self, widget):
- self.xml.get_object('custom_port_entry2').set_sensitive(
- widget.get_active())
- self.on_checkbutton_toggled(widget, 'use_custom_host',
- account=self.current_account)
- if not widget.get_active():
- self.xml.get_object('custom_port_entry2').set_text('5298')
-
- def on_first_name_entry2_changed(self, widget):
- if self.ignore_events:
- return
- name = widget.get_text()
- if self.option_changed('zeroconf_first_name', name):
- self.need_relogin = True
- app.config.set_per('accounts', self.current_account,
- 'zeroconf_first_name', name)
-
- def on_last_name_entry2_changed(self, widget):
- if self.ignore_events:
- return
- name = widget.get_text()
- if self.option_changed('zeroconf_last_name', name):
- self.need_relogin = True
- app.config.set_per('accounts', self.current_account,
- 'zeroconf_last_name', name)
-
- def on_jabber_id_entry2_changed(self, widget):
- if self.ignore_events:
- return
- id_ = widget.get_text()
- if self.option_changed('zeroconf_jabber_id', id_):
- self.need_relogin = True
- app.config.set_per('accounts', self.current_account,
- 'zeroconf_jabber_id', id_)
-
- def on_email_entry2_changed(self, widget):
- if self.ignore_events:
- return
- email = widget.get_text()
- if self.option_changed('zeroconf_email', email):
- self.need_relogin = True
- app.config.set_per('accounts', self.current_account,
- 'zeroconf_email', email)
-
class FakeDataForm(Gtk.Table, object):
"""
Class for forms that are in XML format <entry1>value1</entry1> infos in a