From 89c7eb6e6ab3f61a188c6cee063a000526df522c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= Date: Sun, 13 Aug 2017 13:18:56 +0200 Subject: [PATCH] Rename gajim.common.gajim to avoid name conflicts --- gajim/adhoc_commands.py | 4 +- gajim/advanced_configuration_window.py | 42 +- gajim/app_actions.py | 24 +- gajim/chat_control.py | 228 +-- gajim/chat_control_base.py | 132 +- .../implementation/middleware.py | 4 +- .../command_system/implementation/standard.py | 52 +- gajim/common/{gajim.py => app.py} | 4 +- gajim/common/check_paths.py | 28 +- gajim/common/commands.py | 36 +- gajim/common/config.py | 6 +- gajim/common/connection.py | 608 ++++---- gajim/common/connection_handlers.py | 480 +++--- gajim/common/connection_handlers_events.py | 198 +-- gajim/common/contacts.py | 34 +- gajim/common/dbus_support.py | 4 +- gajim/common/gpg.py | 11 +- gajim/common/helpers.py | 298 ++-- gajim/common/jingle.py | 12 +- gajim/common/jingle_content.py | 6 +- gajim/common/jingle_ft.py | 30 +- gajim/common/jingle_ftstates.py | 32 +- gajim/common/jingle_rtp.py | 24 +- gajim/common/jingle_session.py | 26 +- gajim/common/jingle_transport.py | 12 +- gajim/common/jingle_xtls.py | 18 +- gajim/common/location_listener.py | 10 +- gajim/common/logger.py | 20 +- gajim/common/message_archiving.py | 52 +- gajim/common/nec.py | 10 +- gajim/common/optparser.py | 304 ++-- gajim/common/passwords.py | 30 +- gajim/common/pep.py | 16 +- gajim/common/protocol/bytestream.py | 108 +- gajim/common/protocol/caps.py | 22 +- gajim/common/proxy65_manager.py | 18 +- gajim/common/pubsub.py | 14 +- gajim/common/sleepy.py | 4 +- gajim/common/socks5.py | 6 +- gajim/common/stanza_session.py | 24 +- gajim/common/zeroconf/client_zeroconf.py | 26 +- .../zeroconf/connection_handlers_zeroconf.py | 4 +- gajim/common/zeroconf/connection_zeroconf.py | 128 +- gajim/common/zeroconf/zeroconf_bonjour.py | 24 +- gajim/config.py | 1284 ++++++++-------- gajim/conversation_textview.py | 110 +- gajim/dialogs.py | 646 ++++---- gajim/disco.py | 102 +- gajim/features_window.py | 14 +- gajim/filetransfers_window.py | 60 +- gajim/gajim.py | 18 +- gajim/gajim_themes_window.py | 64 +- gajim/groupchat_control.py | 488 +++--- gajim/groups.py | 4 +- gajim/gtkgui_helpers.py | 94 +- gajim/gui_interface.py | 688 ++++----- gajim/gui_menu_builder.py | 104 +- gajim/history_manager.py | 12 +- gajim/history_sync.py | 18 +- gajim/history_window.py | 78 +- gajim/htmltextview.py | 26 +- gajim/logind_listener.py | 8 +- gajim/message_control.py | 14 +- gajim/message_textview.py | 4 +- gajim/message_window.py | 128 +- gajim/negotiation.py | 6 +- gajim/network_watcher.py | 6 +- gajim/notify.py | 42 +- gajim/plugins/gajimplugin.py | 4 +- gajim/plugins/gui.py | 24 +- gajim/plugins/pluginmanager.py | 32 +- gajim/plugins/plugins_i18n.py | 4 +- gajim/profile_window.py | 36 +- gajim/remote_control.py | 220 +-- gajim/roster_window.py | 1360 ++++++++--------- gajim/search_window.py | 26 +- gajim/server_info.py | 20 +- gajim/session.py | 94 +- gajim/statusicon.py | 142 +- gajim/tooltips.py | 76 +- gajim/upower_listener.py | 8 +- gajim/vcard.py | 58 +- plugins/dbus_plugin/plugin.py | 2 +- plugins/new_events_example/plugin.py | 6 +- plugins/roster_buttons/plugin.py | 6 +- test/integration/test_roster.py | 38 +- test/lib/__init__.py | 10 +- test/lib/gajim_mocks.py | 46 +- test/lib/notify.py | 6 +- test/test_pluginmanager.py | 6 +- test/unit/test_gui_interface.py | 6 +- test/unit/test_protocol_caps.py | 6 +- test/unit/test_sessions.py | 24 +- 93 files changed, 4725 insertions(+), 4726 deletions(-) rename gajim/common/{gajim.py => app.py} (99%) diff --git a/gajim/adhoc_commands.py b/gajim/adhoc_commands.py index 2aba302fa..a8ffd9bb2 100644 --- a/gajim/adhoc_commands.py +++ b/gajim/adhoc_commands.py @@ -29,7 +29,7 @@ from gi.repository import GLib from gi.repository import Gtk import nbxmpp -from gajim.common import gajim +from gajim.common import app from gajim.common import dataforms from gajim import gtkgui_helpers @@ -55,7 +55,7 @@ class CommandWindow: """ # an account object - self.account = gajim.connections[account] + self.account = app.connections[account] self.jid = jid self.commandnode = commandnode self.data_form_widget = None diff --git a/gajim/advanced_configuration_window.py b/gajim/advanced_configuration_window.py index 1a4a14c10..cc56b37db 100644 --- a/gajim/advanced_configuration_window.py +++ b/gajim/advanced_configuration_window.py @@ -30,7 +30,7 @@ from gajim import gtkgui_helpers from gi.repository import GLib from gi.repository import Pango -from gajim.common import gajim +from gajim.common import app @unique class Column(IntEnum): @@ -73,7 +73,7 @@ class AdvancedConfigurationWindow(object): self.xml = gtkgui_helpers.get_gtk_builder('advanced_configuration_window.ui') self.window = self.xml.get_object('advanced_configuration_window') self.window.set_transient_for( - gajim.interface.instances['preferences'].window) + app.interface.instances['preferences'].window) self.entry = self.xml.get_object('advanced_entry') self.desc_label = self.xml.get_object('advanced_desc_label') self.restart_box = self.xml.get_object('restart_box') @@ -130,7 +130,7 @@ class AdvancedConfigurationWindow(object): self.xml.connect_signals(self) self.restart_box.set_no_show_all(True) self.window.show_all() - gajim.interface.instances['advanced_config'] = self + app.interface.instances['advanced_config'] = self def cb_value_column_data(self, col, cell, model, iter_, data): """ @@ -166,9 +166,9 @@ class AdvancedConfigurationWindow(object): # Get text from first column in this row desc = None if len(opt_path) == 3: - desc = gajim.config.get_desc_per(opt_path[2], opt_path[0]) + desc = app.config.get_desc_per(opt_path[2], opt_path[0]) elif len(opt_path) == 1: - desc = gajim.config.get_desc(opt_path[0]) + desc = app.config.get_desc(opt_path[0]) if desc: self.desc_label.set_text(desc) else: @@ -205,10 +205,10 @@ class AdvancedConfigurationWindow(object): key = keyrow[0] self.remember_option(option + '\n' + key + '\n' + optname, modelrow[1], newval) - gajim.config.set_per(optname, key, option, newval) + app.config.set_per(optname, key, option, newval) else: self.remember_option(option, modelrow[1], newval) - gajim.config.set(option, newval) + app.config.set(option, newval) modelrow[1] = self.right_true_dict[newval] self.check_for_restart() @@ -217,10 +217,10 @@ class AdvancedConfigurationWindow(object): for opt in self.changed_opts: opt_path = opt.split('\n') if len(opt_path)==3: - restart = gajim.config.get_restart_per(opt_path[2], opt_path[1], + restart = app.config.get_restart_per(opt_path[2], opt_path[1], opt_path[0]) else: - restart = gajim.config.get_restart(opt_path[0]) + restart = app.config.get_restart(opt_path[0]) if restart: if self.changed_opts[opt][0] != self.changed_opts[opt][1]: self.restart_box.set_no_show_all(False) @@ -242,16 +242,16 @@ class AdvancedConfigurationWindow(object): optname = optnamerow[0] self.remember_option(option + '\n' + key + '\n' + optname, modelrow[1], text) - gajim.config.set_per(optname, key, option, text) + app.config.set_per(optname, key, option, text) else: self.remember_option(option, modelrow[1], text) - gajim.config.set(option, text) + app.config.set(option, text) modelrow[1] = text self.check_for_restart() @staticmethod def on_advanced_configuration_window_destroy(widget): - del gajim.interface.instances['advanced_config'] + del app.interface.instances['advanced_config'] def on_reset_button_clicked(self, widget): model, iter_ = self.treeview.get_selection().get_selected() @@ -260,9 +260,9 @@ class AdvancedConfigurationWindow(object): path = model.get_path(iter_) opt_path = self.get_option_path(model, iter_) if len(opt_path) == 1: - default = gajim.config.get_default(opt_path[0]) + default = app.config.get_default(opt_path[0]) elif len(opt_path) == 3: - default = gajim.config.get_default_per(opt_path[2], opt_path[0]) + default = app.config.get_default_per(opt_path[2], opt_path[0]) if model[iter_][Column.TYPE] == self.types['boolean']: if self.right_true_dict[default] == model[iter_][Column.VALUE]: @@ -277,10 +277,10 @@ class AdvancedConfigurationWindow(object): key = keyrow[0] self.remember_option(option + '\n' + key + '\n' + optname, modelrow[Column.VALUE], default) - gajim.config.set_per(optname, key, option, default) + app.config.set_per(optname, key, option, default) else: self.remember_option(option, modelrow[Column.VALUE], default) - gajim.config.set(option, default) + app.config.set(option, default) modelrow[Column.VALUE] = self.right_true_dict[default] self.check_for_restart() else: @@ -292,16 +292,16 @@ class AdvancedConfigurationWindow(object): self.window.destroy() def fill_model(self, node=None, parent=None): - for item, option in gajim.config.get_children(node): + for item, option in app.config.get_children(node): name = item[-1] if option is None: # Node newparent = self.model.append(parent, [name, '', '']) self.fill_model(item, newparent) else: # Leaf if len(item) == 1: - type_ = self.types[gajim.config.get_type(name)] + type_ = self.types[app.config.get_type(name)] elif len(item) == 3: - type_ = self.types[gajim.config.get_type_per(item[0], + type_ = self.types[app.config.get_type_per(item[0], item[2])] if name == 'password': value = _('Hidden') @@ -321,9 +321,9 @@ class AdvancedConfigurationWindow(object): if model[it][Column.TYPE] != '': opt_path = self.get_option_path(model, it) if len(opt_path) == 3: - desc = gajim.config.get_desc_per(opt_path[2], opt_path[0]) + desc = app.config.get_desc_per(opt_path[2], opt_path[0]) elif len(opt_path) == 1: - desc = gajim.config.get_desc(opt_path[0]) + desc = app.config.get_desc(opt_path[0]) if search_string in model[it][Column.PREFERENCE_NAME] or (desc and \ search_string in desc.lower()): return True diff --git a/gajim/app_actions.py b/gajim/app_actions.py index 6884f11e3..a88a75bb7 100644 --- a/gajim/app_actions.py +++ b/gajim/app_actions.py @@ -18,9 +18,9 @@ ## along with Gajim. If not, see . ## -from gajim.common import gajim as c_gajim +from gajim.common import app from gajim.common import helpers -from gajim.common.gajim import interface +from gajim.common.app import interface from gajim.common.exceptions import GajimGeneralException from gi.repository import Gtk import sys @@ -38,8 +38,8 @@ from gajim.server_info import ServerInfoDialog class AppActions(): ''' Action Callbacks ''' - def __init__(self, app: Gtk.Application): - self.application = app + def __init__(self, application: Gtk.Application): + self.application = application # Application Menu Actions @@ -89,13 +89,13 @@ class AppActions(): def on_send_server_message(self, action, param): account = param.get_string() - server = c_gajim.config.get_per('accounts', account, 'hostname') + server = app.config.get_per('accounts', account, 'hostname') server += '/announce/online' dialogs.SingleMessageWindow(account, server, 'send') def on_service_disco(self, action, param): account = param.get_string() - server_jid = c_gajim.config.get_per('accounts', account, 'hostname') + server_jid = app.config.get_per('accounts', account, 'hostname') if server_jid in interface.instances[account]['disco']: interface.instances[account]['disco'][server_jid].\ window.present() @@ -108,8 +108,8 @@ class AppActions(): def on_join_gc(self, action, param): account = param.get_string() - invisible_show = c_gajim.SHOW_LIST.index('invisible') - if c_gajim.connections[account].connected == invisible_show: + invisible_show = app.SHOW_LIST.index('invisible') + if app.connections[account].connected == invisible_show: dialogs.ErrorDialog(_( 'You cannot join a group chat while you are invisible')) return @@ -178,21 +178,21 @@ class AppActions(): def on_set_motd(self, action, param): account = param.get_string() - server = c_gajim.config.get_per('accounts', account, 'hostname') + server = app.config.get_per('accounts', account, 'hostname') server += '/announce/motd' dialogs.SingleMessageWindow(account, server, 'send') def on_update_motd(self, action, param): account = param.get_string() - server = c_gajim.config.get_per('accounts', account, 'hostname') + server = app.config.get_per('accounts', account, 'hostname') server += '/announce/motd/update' dialogs.SingleMessageWindow(account, server, 'send') def on_delete_motd(self, action, param): account = param.get_string() - server = c_gajim.config.get_per('accounts', account, 'hostname') + server = app.config.get_per('accounts', account, 'hostname') server += '/announce/motd/delete' - c_gajim.connections[account].send_motd(server) + app.connections[account].send_motd(server) # Help Actions diff --git a/gajim/chat_control.py b/gajim/chat_control.py index 05220adfd..d2bbb59d0 100644 --- a/gajim/chat_control.py +++ b/gajim/chat_control.py @@ -40,7 +40,7 @@ from gajim import message_control from gajim import dialogs from gajim.common import logger -from gajim.common import gajim +from gajim.common import app from gajim.common import helpers from gajim.common import exceptions from gajim.common import ged @@ -146,10 +146,10 @@ class ChatControl(ChatControlBase): self._on_contact_information_menuitem_activate) self.handlers[id_] = self._contact_information_button - compact_view = gajim.config.get('compact_view') + compact_view = app.config.get('compact_view') self.chat_buttons_set_visible(compact_view) self.widget_set_visible(self.xml.get_object('banner_eventbox'), - gajim.config.get('hide_chat_banner')) + app.config.get('hide_chat_banner')) self.authentication_button = self.xml.get_object( 'authentication_button') @@ -197,7 +197,7 @@ class ChatControl(ChatControlBase): self.handlers[id_] = message_tv_buffer widget = self.xml.get_object('avatar_eventbox') - widget.set_property('height-request', gajim.config.get( + widget.set_property('height-request', app.config.get( 'chat_avatar_height')) id_ = widget.connect('enter-notify-event', self.on_avatar_eventbox_enter_notify_event) @@ -269,7 +269,7 @@ class ChatControl(ChatControlBase): # and it's not the same if not resource: resource = contact.resource - session = gajim.connections[self.account].find_controlless_session( + session = app.connections[self.account].find_controlless_session( self.contact.jid, resource) self.setup_seclabel(self.xml.get_object('label_selector')) @@ -294,37 +294,37 @@ class ChatControl(ChatControlBase): self.restore_conversation() self.msg_textview.grab_focus() - gajim.ged.register_event_handler('pep-received', ged.GUI1, + app.ged.register_event_handler('pep-received', ged.GUI1, self._nec_pep_received) - gajim.ged.register_event_handler('vcard-received', ged.GUI1, + app.ged.register_event_handler('vcard-received', ged.GUI1, self._nec_vcard_received) - gajim.ged.register_event_handler('failed-decrypt', ged.GUI1, + app.ged.register_event_handler('failed-decrypt', ged.GUI1, self._nec_failed_decrypt) - gajim.ged.register_event_handler('chatstate-received', ged.GUI1, + app.ged.register_event_handler('chatstate-received', ged.GUI1, self._nec_chatstate_received) - gajim.ged.register_event_handler('caps-received', ged.GUI1, + app.ged.register_event_handler('caps-received', ged.GUI1, self._nec_caps_received) # PluginSystem: adding GUI extension point for this ChatControl # instance object - gajim.plugin_manager.gui_extension_point('chat_control', self) + app.plugin_manager.gui_extension_point('chat_control', self) def subscribe_events(self): """ Register listeners to the events class """ - gajim.events.event_added_subscribe(self.on_event_added) - gajim.events.event_removed_subscribe(self.on_event_removed) + app.events.event_added_subscribe(self.on_event_added) + app.events.event_removed_subscribe(self.on_event_removed) def unsubscribe_events(self): """ Unregister listeners to the events class """ - gajim.events.event_added_unsubscribe(self.on_event_added) - gajim.events.event_removed_unsubscribe(self.on_event_removed) + app.events.event_added_unsubscribe(self.on_event_added) + app.events.event_removed_unsubscribe(self.on_event_removed) def _update_toolbar(self): - if (gajim.connections[self.account].connected > 1 and not \ + if (app.connections[self.account].connected > 1 and not \ self.TYPE_ID == 'pm') or (self.contact.show != 'offline' and \ self.TYPE_ID == 'pm'): send_button = self.xml.get_object('send_button') @@ -347,14 +347,14 @@ class ChatControl(ChatControlBase): # Add to roster if not isinstance(self.contact, GC_Contact) \ and _('Not in Roster') in self.contact.groups and \ - gajim.connections[self.account].roster_supported: + app.connections[self.account].roster_supported: self._add_to_roster_button.show() else: self._add_to_roster_button.hide() # Jingle detection if self.contact.supports(NS_JINGLE_ICE_UDP) and \ - gajim.HAVE_FARSTREAM and self.contact.resource: + app.HAVE_FARSTREAM and self.contact.resource: self.audio_available = self.contact.supports(NS_JINGLE_RTP_AUDIO) self.video_available = self.contact.supports(NS_JINGLE_RTP_VIDEO) else: @@ -373,7 +373,7 @@ class ChatControl(ChatControlBase): # not installed audio_tooltip_text = _('Toggle audio session') + '\n' video_tooltip_text = _('Toggle video session') + '\n' - if not gajim.HAVE_FARSTREAM: + if not app.HAVE_FARSTREAM: ext_text = _('Feature not available, see Help->Features') self._audio_button.set_tooltip_text(audio_tooltip_text + ext_text) self._video_button.set_tooltip_text(video_tooltip_text + ext_text) @@ -404,7 +404,7 @@ class ChatControl(ChatControlBase): "them a file.")) # Convert to GC - if gajim.config.get_per('accounts', self.account, 'is_zeroconf'): + if app.config.get_per('accounts', self.account, 'is_zeroconf'): self._convert_to_gc_button.set_no_show_all(True) self._convert_to_gc_button.hide() else: @@ -414,7 +414,7 @@ class ChatControl(ChatControlBase): self._convert_to_gc_button.set_sensitive(False) # Information - if gajim.account_is_disconnected(self.account): + if app.account_is_disconnected(self.account): self._contact_information_button.set_sensitive(False) else: self._contact_information_button.set_sensitive(True) @@ -479,8 +479,8 @@ class ChatControl(ChatControlBase): hbox = self.xml.get_object('audio_buttons_hbox') if self.audio_state == self.JINGLE_STATE_CONNECTED: # Set volume from config - input_vol = gajim.config.get('audio_input_volume') - output_vol = gajim.config.get('audio_output_volume') + input_vol = app.config.get('audio_input_volume') + output_vol = app.config.get('audio_output_volume') input_vol = max(min(input_vol, 100), 0) output_vol = max(min(output_vol, 100), 0) self.xml.get_object('mic_hscale').set_value(input_vol) @@ -499,12 +499,12 @@ class ChatControl(ChatControlBase): old_full_jid = self.get_full_jid() self.resource = resource new_full_jid = self.get_full_jid() - # update gajim.last_message_time - if old_full_jid in gajim.last_message_time[self.account]: - gajim.last_message_time[self.account][new_full_jid] = \ - gajim.last_message_time[self.account][old_full_jid] + # update app.last_message_time + if old_full_jid in app.last_message_time[self.account]: + app.last_message_time[self.account][new_full_jid] = \ + app.last_message_time[self.account][old_full_jid] # update events - gajim.events.change_jid(self.account, old_full_jid, new_full_jid) + app.events.change_jid(self.account, old_full_jid, new_full_jid) # update MessageWindow._controls self.parent_win.change_jid(self.account, old_full_jid, new_full_jid) @@ -553,7 +553,7 @@ class ChatControl(ChatControlBase): self._set_jingle_state('video', state, sid=sid, reason=reason) def _get_audio_content(self): - session = gajim.connections[self.account].get_jingle_session( + session = app.connections[self.account].get_jingle_session( self.contact.get_full_jid(), self.audio_sid) return session.get_content('audio') @@ -572,12 +572,12 @@ class ChatControl(ChatControlBase): def on_mic_hscale_value_changed(self, widget, value): self._get_audio_content().set_mic_volume(value / 100) # Save volume to config - gajim.config.set('audio_input_volume', value) + app.config.set('audio_input_volume', value) def on_sound_hscale_value_changed(self, widget, value): self._get_audio_content().set_out_volume(value / 100) # Save volume to config - gajim.config.set('audio_output_volume', value) + app.config.set('audio_output_volume', value) def on_avatar_eventbox_enter_notify_event(self, widget, event): """ @@ -658,7 +658,7 @@ class ChatControl(ChatControlBase): self.update_toolbar() def _update_banner_state_image(self): - contact = gajim.contacts.get_contact_with_highest_priority(self.account, + contact = app.contacts.get_contact_with_highest_priority(self.account, self.contact.jid) if not contact or self.resource: # For transient contacts @@ -667,9 +667,9 @@ class ChatControl(ChatControlBase): jid = contact.jid # Set banner image - img_32 = gajim.interface.roster.get_appropriate_state_images(jid, + img_32 = app.interface.roster.get_appropriate_state_images(jid, size='32', icon_name=show) - img_16 = gajim.interface.roster.get_appropriate_state_images(jid, + img_16 = app.interface.roster.get_appropriate_state_images(jid, icon_name=show) if show in img_32 and img_32[show].get_pixbuf(): # we have 32x32! use it! @@ -715,14 +715,14 @@ class ChatControl(ChatControlBase): # in another account we need to also display the account. # except if we are talking to two different resources of the same contact acct_info = '' - for account in gajim.contacts.get_accounts(): + for account in app.contacts.get_accounts(): if account == self.account: continue if acct_info: # We already found a contact with same nick break - for jid in gajim.contacts.get_jid_list(account): + for jid in app.contacts.get_jid_list(account): other_contact_ = \ - gajim.contacts.get_first_contact_from_jid(account, jid) + app.contacts.get_first_contact_from_jid(account, jid) if other_contact_.get_shown_name() == \ self.contact.get_shown_name(): acct_info = i18n.direction_mark + ' (%s)' % \ @@ -739,7 +739,7 @@ class ChatControl(ChatControlBase): status_escaped = GLib.markup_escape_text(status_reduced) font_attrs, font_attrs_small = self.get_font_attrs() - st = gajim.config.get('displayed_chat_state_notifications') + st = app.config.get('displayed_chat_state_notifications') cs = contact.chatstate if cs and st in ('composing_only', 'all'): if contact.show == 'offline': @@ -784,7 +784,7 @@ class ChatControl(ChatControlBase): return setattr(self, jingle_type + '_sid', None) setattr(self, jingle_type + '_state', self.JINGLE_STATE_NULL) - session = gajim.connections[self.account].get_jingle_session( + session = app.connections[self.account].get_jingle_session( self.contact.get_full_jid(), sid) if session: content = session.get_content(jingle_type) @@ -804,7 +804,7 @@ class ChatControl(ChatControlBase): if jingle_type == 'video': video_hbox = self.xml.get_object('video_hbox') video_hbox.set_no_show_all(False) - if gajim.config.get('video_see_self'): + if app.config.get('video_see_self'): fixed = self.xml.get_object('outgoing_fixed') fixed.set_no_show_all(False) video_hbox.show_all() @@ -820,10 +820,10 @@ class ChatControl(ChatControlBase): in_da = self.xml.get_object('incoming_drawingarea') in_da.realize() in_xid = in_da.get_window().get_xid() - sid = gajim.connections[self.account].start_video( + sid = app.connections[self.account].start_video( self.contact.get_full_jid(), in_xid, out_xid) else: - sid = getattr(gajim.connections[self.account], + sid = getattr(app.connections[self.account], 'start_' + jingle_type)(self.contact.get_full_jid()) getattr(self, 'set_' + jingle_type + '_state')('connecting', sid) else: @@ -851,7 +851,7 @@ class ChatControl(ChatControlBase): 'authenticated': False} if self.encryption: - gajim.plugin_manager.extension_point( + app.plugin_manager.extension_point( 'encryption_state' + self.encryption, self, encryption_state) self._show_lock_image(**encryption_state) @@ -877,7 +877,7 @@ class ChatControl(ChatControlBase): def _on_authentication_button_clicked(self, widget): if self.encryption: - gajim.plugin_manager.extension_point( + app.plugin_manager.extension_point( 'encryption_dialog' + self.encryption, self) def send_message(self, message, keyID='', chatstate=None, xhtml=None, @@ -888,7 +888,7 @@ class ChatControl(ChatControlBase): if self.encryption: self.sendmessage = True - gajim.plugin_manager.extension_point( + app.plugin_manager.extension_point( 'send_message' + self.encryption, self) if not self.sendmessage: return @@ -900,7 +900,7 @@ class ChatControl(ChatControlBase): contact = self.contact keyID = contact.keyID - chatstates_on = gajim.config.get('outgoing_chat_state_notifications') != \ + chatstates_on = app.config.get('outgoing_chat_state_notifications') != \ 'disabled' chatstate_to_send = None @@ -915,8 +915,8 @@ class ChatControl(ChatControlBase): def _on_sent(obj, msg_stanza, message, encrypted, xhtml, label): id_ = msg_stanza.getID() xep0184_id = None - if self.contact.jid != gajim.get_jid_from_account(self.account): - if gajim.config.get_per('accounts', self.account, 'request_receipt'): + if self.contact.jid != app.get_jid_from_account(self.account): + if app.config.get_per('accounts', self.account, 'request_receipt'): xep0184_id = id_ if label: displaymarking = label.getTag('displaymarking') @@ -987,7 +987,7 @@ class ChatControl(ChatControlBase): self.print_archiving_session_details() def get_our_nick(self): - return gajim.nicks[self.account] + return app.nicks[self.account] def print_conversation(self, text, frm='', tim=None, encrypted=None, subject=None, xhtml=None, simple=False, xep0184_id=None, @@ -1011,7 +1011,7 @@ class ChatControl(ChatControlBase): additional_data = {} if frm == 'status': - if not gajim.config.get('print_status_in_chats'): + if not app.config.get('print_status_in_chats'): return kind = 'status' name = '' @@ -1032,7 +1032,7 @@ class ChatControl(ChatControlBase): kind = 'outgoing' name = self.get_our_nick() if not xhtml and not encrypted and \ - gajim.config.get('rst_formatting_outgoing_messages'): + app.config.get('rst_formatting_outgoing_messages'): from gajim.common.rst_xhtml_generator import create_xhtml xhtml = create_xhtml(text) if xhtml: @@ -1054,9 +1054,9 @@ class ChatControl(ChatControlBase): jid = self.contact.get_full_jid() else: jid = self.contact.jid - num_unread = len(gajim.events.get_events(self.account, jid, + num_unread = len(app.events.get_events(self.account, jid, ['printed_' + self.type_id, self.type_id])) - if num_unread == 1 and not gajim.config.get('show_unread_tab_icon'): + if num_unread == 1 and not app.config.get('show_unread_tab_icon'): unread = '*' elif num_unread > 1: unread = '[' + str(num_unread) + ']' @@ -1075,7 +1075,7 @@ class ChatControl(ChatControlBase): else: jid = self.contact.jid - if gajim.config.get('show_avatar_in_tabs'): + if app.config.get('show_avatar_in_tabs'): avatar_pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(jid) if avatar_pixbuf not in ('ask', None): avatar_pixbuf = gtkgui_helpers.get_scaled_pixbuf_by_size( @@ -1083,24 +1083,24 @@ class ChatControl(ChatControlBase): return avatar_pixbuf if count_unread: - num_unread = len(gajim.events.get_events(self.account, jid, + num_unread = len(app.events.get_events(self.account, jid, ['printed_' + self.type_id, self.type_id])) else: num_unread = 0 # Set tab image (always 16x16); unread messages show the 'event' image tab_img = None - if num_unread and gajim.config.get('show_unread_tab_icon'): - img_16 = gajim.interface.roster.get_appropriate_state_images( + if num_unread and app.config.get('show_unread_tab_icon'): + img_16 = app.interface.roster.get_appropriate_state_images( self.contact.jid, icon_name='event') tab_img = img_16['event'] else: - contact = gajim.contacts.get_contact_with_highest_priority( + contact = app.contacts.get_contact_with_highest_priority( self.account, self.contact.jid) if not contact or self.resource: # For transient contacts contact = self.contact - img_16 = gajim.interface.roster.get_appropriate_state_images( + img_16 = app.interface.roster.get_appropriate_state_images( self.contact.jid, icon_name=contact.show) tab_img = img_16[contact.show] @@ -1112,7 +1112,7 @@ class ChatControl(ChatControlBase): for history_menuitem (False for tranasports) and file_transfer_menuitem and hide()/show() for add_to_roster_menuitem """ - if gajim.jid_is_transport(self.contact.jid): + if app.jid_is_transport(self.contact.jid): menu = gui_menu_builder.get_transport_menu(self.contact, self.account) else: @@ -1139,7 +1139,7 @@ class ChatControl(ChatControlBase): # do not send if we have chat state notifications disabled # that means we won't reply to the from other peer # so we do not broadcast jep85 capabalities - chatstate_setting = gajim.config.get('outgoing_chat_state_notifications') + chatstate_setting = app.config.get('outgoing_chat_state_notifications') if chatstate_setting == 'disabled': return @@ -1148,7 +1148,7 @@ class ChatControl(ChatControlBase): if contact and contact.sub in ('to', 'none'): return - if self.contact.jid == gajim.get_jid_from_account(self.account): + if self.contact.jid == app.get_jid_from_account(self.account): return elif chatstate_setting == 'composing_only' and state != 'active' and\ @@ -1179,13 +1179,13 @@ class ChatControl(ChatControlBase): # if wel're inactive prevent composing (XEP violation) if contact.our_chatstate == 'inactive' and state == 'composing': # go active before - gajim.nec.push_outgoing_event(MessageOutgoingEvent(None, + app.nec.push_outgoing_event(MessageOutgoingEvent(None, account=self.account, jid=self.contact.jid, chatstate='active', control=self)) contact.our_chatstate = 'active' self.reset_kbd_mouse_timeout_vars() - gajim.nec.push_outgoing_event(MessageOutgoingEvent(None, + app.nec.push_outgoing_event(MessageOutgoingEvent(None, account=self.account, jid=self.contact.jid, chatstate=state, control=self)) @@ -1196,17 +1196,17 @@ class ChatControl(ChatControlBase): def shutdown(self): # PluginSystem: removing GUI extension points connected with ChatControl # instance object - gajim.plugin_manager.remove_gui_extension_point('chat_control', self) + app.plugin_manager.remove_gui_extension_point('chat_control', self) - gajim.ged.remove_event_handler('pep-received', ged.GUI1, + app.ged.remove_event_handler('pep-received', ged.GUI1, self._nec_pep_received) - gajim.ged.remove_event_handler('vcard-received', ged.GUI1, + app.ged.remove_event_handler('vcard-received', ged.GUI1, self._nec_vcard_received) - gajim.ged.remove_event_handler('failed-decrypt', ged.GUI1, + app.ged.remove_event_handler('failed-decrypt', ged.GUI1, self._nec_failed_decrypt) - gajim.ged.remove_event_handler('chatstate-received', ged.GUI1, + app.ged.remove_event_handler('chatstate-received', ged.GUI1, self._nec_chatstate_received) - gajim.ged.remove_event_handler('caps-received', ged.GUI1, + app.ged.remove_event_handler('caps-received', ged.GUI1, self._nec_caps_received) self.unsubscribe_events() @@ -1227,11 +1227,11 @@ class ChatControl(ChatControlBase): if self.bigger_avatar_window: self.bigger_avatar_window.destroy() # Clean events - gajim.events.remove_events(self.account, self.get_full_jid(), + app.events.remove_events(self.account, self.get_full_jid(), types=['printed_' + self.type_id, self.type_id]) # Remove contact instance if contact has been removed key = (self.contact.jid, self.account) - roster = gajim.interface.roster + roster = app.interface.roster if key in roster.contacts_to_be_removed.keys() and \ not roster.contact_has_pending_roster_events(self.contact, self.account): @@ -1246,7 +1246,7 @@ class ChatControl(ChatControlBase): self.handlers[i].disconnect(i) del self.handlers[i] self.conv_textview.del_handlers() - if gajim.config.get('use_speller') and HAS_GTK_SPELL: + if app.config.get('use_speller') and HAS_GTK_SPELL: spell_obj = gtkspell.get_from_text_view(self.msg_textview) if spell_obj: spell_obj.detach() @@ -1262,7 +1262,7 @@ class ChatControl(ChatControlBase): return False def allow_shutdown(self, method, on_yes, on_no, on_minimize): - if time.time() - gajim.last_message_time[self.account]\ + if time.time() - app.last_message_time[self.account]\ [self.get_full_jid()] < 2: # 2 seconds @@ -1319,7 +1319,7 @@ class ChatControl(ChatControlBase): self.show_avatar() def show_avatar(self): - if not gajim.config.get('show_avatar_in_chat'): + if not app.config.get('show_avatar_in_chat'): return jid_with_resource = self.contact.get_full_jid() @@ -1334,10 +1334,10 @@ class ChatControl(ChatControlBase): real_jid += '/' + self.gc_contact.resource else: real_jid = jid_with_resource - gajim.connections[self.account].request_vcard(real_jid, + app.connections[self.account].request_vcard(real_jid, jid_with_resource) else: - gajim.connections[self.account].request_vcard(jid_with_resource) + app.connections[self.account].request_vcard(jid_with_resource) return elif pixbuf: scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'chat') @@ -1351,7 +1351,7 @@ class ChatControl(ChatControlBase): def _nec_vcard_received(self, obj): if obj.conn.name != self.account: return - j = gajim.get_jid_without_resource(self.contact.jid) + j = app.get_jid_without_resource(self.contact.jid) if obj.jid != j: return self.show_avatar() @@ -1372,12 +1372,12 @@ class ChatControl(ChatControlBase): for uri in uri_splitted: path = helpers.get_file_path_from_dnd_dropped_uri(uri) if os.path.isfile(path): # is it file? - ft = gajim.interface.instances['file_transfers'] + ft = app.interface.instances['file_transfers'] ft.send_file(self.account, c, path) return # chat2muc - treeview = gajim.interface.roster.tree + treeview = app.interface.roster.tree model = treeview.get_model() data = selection.get_data() path = treeview.get_selection().get_selected_rows()[1][0] @@ -1387,8 +1387,8 @@ class ChatControl(ChatControlBase): return dropped_jid = data - dropped_transport = gajim.get_transport_name_from_jid(dropped_jid) - c_transport = gajim.get_transport_name_from_jid(c.jid) + dropped_transport = app.get_transport_name_from_jid(dropped_jid) + c_transport = app.get_transport_name_from_jid(c.jid) if dropped_transport or c_transport: return # transport contacts cannot be invited @@ -1397,24 +1397,24 @@ class ChatControl(ChatControlBase): def _on_message_tv_buffer_changed(self, textbuffer): super()._on_message_tv_buffer_changed(textbuffer) if textbuffer.get_char_count() and self.encryption: - gajim.plugin_manager.extension_point( + app.plugin_manager.extension_point( 'typing' + self.encryption, self) def restore_conversation(self): jid = self.contact.jid # don't restore lines if it's a transport - if gajim.jid_is_transport(jid): + if app.jid_is_transport(jid): return # number of messages that are in queue and are already logged, we want # to avoid duplication - pending = len(gajim.events.get_events(self.account, jid, + pending = len(app.events.get_events(self.account, jid, ['chat', 'pm'])) if self.resource: - pending += len(gajim.events.get_events(self.account, + pending += len(app.events.get_events(self.account, self.contact.get_full_jid(), ['chat', 'pm'])) - rows = gajim.logger.get_last_conversation_lines( + rows = app.logger.get_last_conversation_lines( self.account, jid, pending) local_old_kind = None @@ -1438,7 +1438,7 @@ class ChatControl(ChatControlBase): tim = float(row.time) - if gajim.config.get('restored_messages_small'): + if app.config.get('restored_messages_small'): small_attr = ['small'] else: small_attr = [] @@ -1467,7 +1467,7 @@ class ChatControl(ChatControlBase): jid_with_resource = jid if self.resource: jid_with_resource += '/' + self.resource - events = gajim.events.get_events(self.account, jid_with_resource) + events = app.events.get_events(self.account, jid_with_resource) # list of message ids which should be marked as read message_ids = [] @@ -1490,16 +1490,16 @@ class ChatControl(ChatControlBase): if event.session and not self.session: self.set_session(event.session) if message_ids: - gajim.logger.set_read_messages(message_ids) - gajim.events.remove_events(self.account, jid_with_resource, + app.logger.set_read_messages(message_ids) + app.events.remove_events(self.account, jid_with_resource, types=[self.type_id]) typ = 'chat' # Is it a normal chat or a pm ? # reset to status image in gc if it is a pm # Is it a pm ? - room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) - control = gajim.interface.msg_win_mgr.get_gc_control(room_jid, + room_jid, nick = app.get_room_and_nick_from_fjid(jid) + control = app.interface.msg_win_mgr.get_gc_control(room_jid, self.account) if control and control.type_id == message_control.TYPE_GC: control.update_ui() @@ -1508,12 +1508,12 @@ class ChatControl(ChatControlBase): self.redraw_after_event_removed(jid) if (self.contact.show in ('offline', 'error')): - show_offline = gajim.config.get('showoffline') - show_transports = gajim.config.get('show_transports_group') - if (not show_transports and gajim.jid_is_transport(jid)) or \ + show_offline = app.config.get('showoffline') + show_transports = app.config.get('show_transports_group') + if (not show_transports and app.jid_is_transport(jid)) or \ (not show_offline and typ == 'chat' and \ - len(gajim.contacts.get_contacts(self.account, jid)) < 2): - gajim.interface.roster.remove_to_be_removed(self.contact.jid, + len(app.contacts.get_contacts(self.account, jid)) < 2): + app.interface.roster.remove_to_be_removed(self.contact.jid, self.account) elif typ == 'pm': control.remove_contact(nick) @@ -1559,7 +1559,7 @@ class ChatControl(ChatControlBase): # make the bigger avatar window show up centered small_avatar_x, small_avatar_y = alloc.x, alloc.y translated_coordinates = small_avatar.translate_coordinates( - gajim.interface.roster.window, 0, 0) + app.interface.roster.window, 0, 0) if translated_coordinates: small_avatar_x, small_avatar_y = translated_coordinates roster_x, roster_y = self.parent_win.window.get_window().get_origin()[1:] @@ -1579,7 +1579,7 @@ class ChatControl(ChatControlBase): dialogs.AddNewContactWindow(self.account, self.contact.jid) def _on_contact_information_menuitem_activate(self, widget): - gajim.interface.roster.on_info(widget, self.contact, self.account) + app.interface.roster.on_info(widget, self.contact, self.account) def _on_convert_to_gc_menuitem_activate(self, widget): """ @@ -1600,7 +1600,7 @@ class ChatControl(ChatControlBase): self.session.terminate_e2e() - gajim.connections[self.account].delete_session(jid, thread_id) + app.connections[self.account].delete_session(jid, thread_id) # presumably the user had a good reason to shut it off, so # disable autonegotiation too @@ -1611,7 +1611,7 @@ class ChatControl(ChatControlBase): if not self.session: fjid = self.contact.get_full_jid() - new_sess = gajim.connections[self.account].make_new_session(fjid, type_=self.type_id) + new_sess = app.connections[self.account].make_new_session(fjid, type_=self.type_id) self.set_session(new_sess) def begin_e2e_negotiation(self): @@ -1641,7 +1641,7 @@ class ChatControl(ChatControlBase): def got_connected(self): ChatControlBase.got_connected(self) # Refreshing contact - contact = gajim.contacts.get_contact_with_highest_priority( + contact = app.contacts.get_contact_with_highest_priority( self.account, self.contact.jid) if isinstance(contact, GC_Contact): contact = contact.as_contact() @@ -1712,24 +1712,24 @@ class ChatControl(ChatControlBase): self._info_bar_show_message() def _get_file_props_event(self, file_props, type_): - evs = gajim.events.get_events(self.account, self.contact.jid, [type_]) + evs = app.events.get_events(self.account, self.contact.jid, [type_]) for ev in evs: if ev.file_props == file_props: return ev return None def _on_accept_file_request(self, widget, file_props): - gajim.interface.instances['file_transfers'].on_file_request_accepted( + app.interface.instances['file_transfers'].on_file_request_accepted( self.account, self.contact, file_props) ev = self._get_file_props_event(file_props, 'file-request') if ev: - gajim.events.remove_events(self.account, self.contact.jid, event=ev) + app.events.remove_events(self.account, self.contact.jid, event=ev) def _on_cancel_file_request(self, widget, file_props): - gajim.connections[self.account].send_file_rejection(file_props) + app.connections[self.account].send_file_rejection(file_props) ev = self._get_file_props_event(file_props, 'file-request') if ev: - gajim.events.remove_events(self.account, self.contact.jid, event=ev) + app.events.remove_events(self.account, self.contact.jid, event=ev) def _got_file_request(self, file_props): """ @@ -1753,12 +1753,12 @@ class ChatControl(ChatControlBase): helpers.launch_file_manager(path) ev = self._get_file_props_event(file_props, 'file-completed') if ev: - gajim.events.remove_events(self.account, self.contact.jid, event=ev) + app.events.remove_events(self.account, self.contact.jid, event=ev) def _on_ok(self, widget, file_props, type_): ev = self._get_file_props_event(file_props, type_) if ev: - gajim.events.remove_events(self.account, self.contact.jid, event=ev) + app.events.remove_events(self.account, self.contact.jid, event=ev) def _got_file_completed(self, file_props): markup = '%s: %s' % (_('File transfer completed'), @@ -1780,17 +1780,17 @@ class ChatControl(ChatControlBase): def _on_accept_gc_invitation(self, widget, event): try: if event.is_continued: - gajim.interface.join_gc_room(self.account, event.room_jid, - gajim.nicks[self.account], event.password, + app.interface.join_gc_room(self.account, event.room_jid, + app.nicks[self.account], event.password, is_continued=True) else: dialogs.JoinGroupchatWindow(self.account, event.room_jid) except GajimGeneralException: pass - gajim.events.remove_events(self.account, self.contact.jid, event=event) + app.events.remove_events(self.account, self.contact.jid, event=event) def _on_cancel_gc_invitation(self, widget, event): - gajim.events.remove_events(self.account, self.contact.jid, event=event) + app.events.remove_events(self.account, self.contact.jid, event=event) def _get_gc_invitation(self, event): markup = '%s: %s' % (_('Groupchat Invitation'), event.room_jid) diff --git a/gajim/chat_control_base.py b/gajim/chat_control_base.py index c38097a16..a5e05a16a 100644 --- a/gajim/chat_control_base.py +++ b/gajim/chat_control_base.py @@ -46,7 +46,7 @@ import re from gajim import emoticons from gajim.scrolled_window import ScrolledWindow from gajim.common import events -from gajim.common import gajim +from gajim.common import app from gajim.common import helpers from gajim.common import ged from gajim.message_control import MessageControl @@ -91,7 +91,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): keycode_ins = None def make_href(self, match): - url_color = gajim.config.get('urlmsgcolor') + url_color = app.config.get('urlmsgcolor') url = match.group() if not '://' in url: url = 'http://' + url @@ -102,9 +102,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): """ Get pango font attributes for banner from theme settings """ - theme = gajim.config.get('roster_theme') - bannerfont = gajim.config.get_per('themes', theme, 'bannerfont') - bannerfontattrs = gajim.config.get_per('themes', theme, 'bannerfontattrs') + theme = app.config.get('roster_theme') + bannerfont = app.config.get_per('themes', theme, 'bannerfont') + bannerfontattrs = app.config.get_per('themes', theme, 'bannerfontattrs') if bannerfont: font = Pango.FontDescription(bannerfont) @@ -131,7 +131,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): if self.resource: jid += '/' + self.resource type_ = self.type_id - return len(gajim.events.get_events(self.account, jid, ['printed_' + type_, + return len(app.events.get_events(self.account, jid, ['printed_' + type_, type_])) def draw_banner(self): @@ -142,7 +142,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): """ self.draw_banner_text() self._update_banner_state_image() - gajim.plugin_manager.gui_extension_point('chat_control_base_draw_banner', + app.plugin_manager.gui_extension_point('chat_control_base_draw_banner', self) def update_toolbar(self): @@ -150,7 +150,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): update state of buttons in toolbar """ self._update_toolbar() - gajim.plugin_manager.gui_extension_point( + app.plugin_manager.gui_extension_point( 'chat_control_base_update_toolbar', self) def draw_banner_text(self): @@ -220,15 +220,15 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): self.seclabel_combo.pack_start(cell, True) # text to show is in in first column of liststore self.seclabel_combo.add_attribute(cell, 'text', 0) - if gajim.connections[self.account].seclabel_supported: - gajim.connections[self.account].seclabel_catalogue(self.contact.jid, self.on_seclabels_ready) + if app.connections[self.account].seclabel_supported: + app.connections[self.account].seclabel_catalogue(self.contact.jid, self.on_seclabels_ready) def on_seclabels_ready(self): lb = self.seclabel_combo.get_model() lb.clear() i = 0 sel = 0 - catalogue = gajim.connections[self.account].seclabel_catalogues[ + catalogue = app.connections[self.account].seclabel_catalogues[ self.contact.jid] for label in catalogue[2]: lb.append([label]) @@ -248,7 +248,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): if resource is None: # We very likely got a contact with a random resource. # This is bad, we need the highest for caps etc. - c = gajim.contacts.get_contact_with_highest_priority(acct, + c = app.contacts.get_contact_with_highest_priority(acct, contact.jid) if c and not isinstance(c, GC_Contact): contact = c @@ -369,7 +369,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): self.set_emoticon_popover() # Attach speller - if gajim.config.get('use_speller') and HAS_GTK_SPELL: + if app.config.get('use_speller') and HAS_GTK_SPELL: self.set_speller() self.conv_textview.tv.show() @@ -399,15 +399,15 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): # PluginSystem: adding GUI extension point for ChatControlBase # instance object (also subclasses, eg. ChatControl or GroupchatControl) - gajim.plugin_manager.gui_extension_point('chat_control_base', self) + app.plugin_manager.gui_extension_point('chat_control_base', self) - gajim.ged.register_event_handler('our-show', ged.GUI1, + app.ged.register_event_handler('our-show', ged.GUI1, self._nec_our_status) - gajim.ged.register_event_handler('ping-sent', ged.GUI1, + app.ged.register_event_handler('ping-sent', ged.GUI1, self._nec_ping_sent) - gajim.ged.register_event_handler('ping-reply', ged.GUI1, + app.ged.register_event_handler('ping-reply', ged.GUI1, self._nec_ping_reply) - gajim.ged.register_event_handler('ping-error', ged.GUI1, + app.ged.register_event_handler('ping-error', ged.GUI1, self._nec_ping_error) # This is bascially a very nasty hack to surpass the inability @@ -431,7 +431,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): return if encryption: - plugin = gajim.plugin_manager.encryption_plugins[encryption] + plugin = app.plugin_manager.encryption_plugins[encryption] if not plugin.activate_encryption(self): return else: @@ -445,15 +445,15 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): def set_encryption_state(self, encryption): config_key = '%s-%s' % (self.account, self.contact.jid) self.encryption = encryption - gajim.config.set_per('encryption', config_key, + app.config.set_per('encryption', config_key, 'encryption', self.encryption or '') def get_encryption_state(self): config_key = '%s-%s' % (self.account, self.contact.jid) - state = gajim.config.get_per('encryption', config_key, 'encryption') + state = app.config.get_per('encryption', config_key, 'encryption') if not state: return None - if state not in gajim.plugin_manager.encryption_plugins: + if state not in app.plugin_manager.encryption_plugins: self.set_encryption_state(None) return None return state @@ -476,13 +476,13 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): per_type = 'contacts' if self.type_id == message_control.TYPE_GC: per_type = 'rooms' - lang = gajim.config.get_per(per_type, self.contact.jid, + lang = app.config.get_per(per_type, self.contact.jid, 'speller_language') if not lang: # use the default one - lang = gajim.config.get('speller_language') + lang = app.config.get('speller_language') if not lang: - lang = gajim.LANG + lang = app.LANG if lang: try: self.spell = gtkspell.Spell(self.msg_textview, lang) @@ -495,9 +495,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): per_type = 'contacts' if self.type_id == message_control.TYPE_GC: per_type = 'rooms' - if not gajim.config.get_per(per_type, self.contact.jid): - gajim.config.add_per(per_type, self.contact.jid) - gajim.config.set_per(per_type, self.contact.jid, 'speller_language', + if not app.config.get_per(per_type, self.contact.jid): + app.config.add_per(per_type, self.contact.jid) + app.config.set_per(per_type, self.contact.jid, 'speller_language', lang) self.msg_textview.lang = lang @@ -526,11 +526,11 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): GLib.source_remove(self.possible_inactive_timeout_id) # PluginSystem: removing GUI extension points connected with ChatControlBase # instance object - gajim.plugin_manager.remove_gui_extension_point('chat_control_base', + app.plugin_manager.remove_gui_extension_point('chat_control_base', self) - gajim.plugin_manager.remove_gui_extension_point( + app.plugin_manager.remove_gui_extension_point( 'chat_control_base_draw_banner', self) - gajim.ged.remove_event_handler('our-show', ged.GUI1, + app.ged.remove_event_handler('our-show', ged.GUI1, self._nec_our_status) def on_msg_textview_populate_popup(self, textview, menu): @@ -690,9 +690,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): send_message = False else: is_ctrl_enter = bool(event_state & Gdk.ModifierType.CONTROL_MASK) - send_message = is_ctrl_enter == gajim.config.get('send_on_ctrl_enter') + send_message = is_ctrl_enter == app.config.get('send_on_ctrl_enter') - if send_message and gajim.connections[self.account].connected < 2: + if send_message and app.connections[self.account].connected < 2: # we are not connected dialogs.ErrorDialog(_('A connection is not available'), _('Your message can not be sent until you are connected.')) @@ -737,7 +737,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): if self.seclabel_combo is not None: idx = self.seclabel_combo.get_active() if idx != -1: - cat = gajim.connections[self.account].seclabel_catalogues[self.contact.jid] + cat = app.connections[self.account].seclabel_catalogues[self.contact.jid] lname = cat[2][idx] label = cat[1][lname] return label @@ -760,8 +760,8 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): # refresh timers self.reset_kbd_mouse_timeout_vars() - notifications = gajim.config.get('outgoing_chat_state_notifications') - if (self.contact.jid == gajim.get_jid_from_account(self.account) or + notifications = app.config.get('outgoing_chat_state_notifications') + if (self.contact.jid == app.get_jid_from_account(self.account) or notifications == 'disabled'): chatstate = None @@ -777,7 +777,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): else: correct_id = None - gajim.nec.push_outgoing_event(MessageOutgoingEvent(None, + app.nec.push_outgoing_event(MessageOutgoingEvent(None, account=self.account, jid=self.contact.jid, message=message, keyID=keyID, type_=type_, chatstate=chatstate, resource=resource, user_nick=self.user_nick, xhtml=xhtml, @@ -897,7 +897,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): size = len(history) scroll = False if pos == size else True # are we scrolling? # we don't want size of the buffer to grow indefinately - max_size = gajim.config.get('key_up_lines') + max_size = app.config.get('key_up_lines') for i in range(size - max_size + 1): if pos == 0: break @@ -956,12 +956,12 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): self.last_received_id[name] = correct_id[0] if kind == 'incoming': if not self.type_id == message_control.TYPE_GC or \ - gajim.config.get('notify_on_all_muc_messages') or \ + app.config.get('notify_on_all_muc_messages') or \ 'marked' in other_tags_for_text: # it's a normal message, or a muc message with want to be # notified about if quitting just after # other_tags_for_text == ['marked'] --> highlighted gc message - gajim.last_message_time[self.account][full_jid] = time.time() + app.last_message_time[self.account][full_jid] = time.time() if kind in ('incoming', 'incoming_queue'): # Record the history of received messages @@ -976,7 +976,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): self != self.parent_win.get_active_control() or \ not self.parent_win.is_active() or not end)) or \ (gc_message and \ - jid in gajim.interface.minimized_controls[self.account])) and \ + jid in app.interface.minimized_controls[self.account])) and \ kind in ('incoming', 'incoming_queue', 'error'): # we want to have save this message in events list # other_tags_for_text == ['marked'] --> highlighted gc message @@ -1000,10 +1000,10 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): event = event_type(text, subject, self, msg_log_id, show_in_roster=show_in_roster, show_in_systray=show_in_systray) - gajim.events.add_event(self.account, full_jid, event) + app.events.add_event(self.account, full_jid, event) # We need to redraw contact if we show in roster if show_in_roster: - gajim.interface.roster.draw_contact(self.contact.jid, + app.interface.roster.draw_contact(self.contact.jid, self.account) if not self.parent_win: @@ -1023,7 +1023,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): """ Hide show emoticons_button """ - if gajim.config.get('emoticons_theme'): + if app.config.get('emoticons_theme'): self.emoticons_button.set_no_show_all(False) self.emoticons_button.show() else: @@ -1031,7 +1031,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): self.emoticons_button.hide() def set_emoticon_popover(self): - if not gajim.config.get('emoticons_theme'): + if not app.config.get('emoticons_theme'): return if not self.parent_win: @@ -1086,11 +1086,11 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): if not jid: jid = self.contact.jid - if 'logs' in gajim.interface.instances: - gajim.interface.instances['logs'].window.present() - gajim.interface.instances['logs'].open_history(jid, self.account) + if 'logs' in app.interface.instances: + app.interface.instances['logs'].window.present() + app.interface.instances['logs'].open_history(jid, self.account) else: - gajim.interface.instances['logs'] = \ + app.interface.instances['logs'] = \ history_window.HistoryWindow(jid, self.account) def _on_send_file(self, gc_contact=None): @@ -1098,19 +1098,19 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): gc_contact can be set when we are in a groupchat control """ def _on_ok(c): - gajim.interface.instances['file_transfers'].show_file_send_request( + app.interface.instances['file_transfers'].show_file_send_request( self.account, c) if self.TYPE_ID == message_control.TYPE_PM: gc_contact = self.gc_contact if gc_contact: # gc or pm - gc_control = gajim.interface.msg_win_mgr.get_gc_control( + gc_control = app.interface.msg_win_mgr.get_gc_control( gc_contact.room_jid, self.account) - self_contact = gajim.contacts.get_gc_contact(self.account, + self_contact = app.contacts.get_gc_contact(self.account, gc_control.room_jid, gc_control.nick) if gc_control.is_anonymous and gc_contact.affiliation not in ['admin', 'owner'] and self_contact.affiliation in ['admin', 'owner']: - contact = gajim.contacts.get_contact(self.account, gc_contact.jid) + contact = app.contacts.get_contact(self.account, gc_contact.jid) if not contact or contact.sub not in ('both', 'to'): prim_text = _('Really send file?') sec_text = _('If you send a file to %s, he/she will know your ' @@ -1128,7 +1128,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): When a grouchat is minimized, unparent the tab, put it in roster etc """ old_value = True - non_minimized_gc = gajim.config.get_per('accounts', self.account, + non_minimized_gc = app.config.get_per('accounts', self.account, 'non_minimized_gc').split() if self.contact.jid in non_minimized_gc: old_value = False @@ -1138,7 +1138,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): if minimize and self.contact.jid in non_minimized_gc: non_minimized_gc.remove(self.contact.jid) if old_value != minimize: - gajim.config.set_per('accounts', self.account, 'non_minimized_gc', + app.config.set_per('accounts', self.account, 'non_minimized_gc', ' '.join(non_minimized_gc)) def set_control_active(self, state): @@ -1150,7 +1150,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): type_ = ['printed_' + self.type_id] if self.type_id == message_control.TYPE_GC: type_ = ['printed_gc_msg', 'printed_marked_gc_msg'] - if not gajim.events.remove_events(self.account, self.get_full_jid(), + if not app.events.remove_events(self.account, self.get_full_jid(), types=type_): # There were events to remove self.redraw_after_event_removed(jid) @@ -1193,7 +1193,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): else: # Not a GC types_list = ['printed_' + type_, type_] - if not len(gajim.events.get_events(self.account, jid, types_list)): + if not len(app.events.get_events(self.account, jid, types_list)): return if not self.parent_win: return @@ -1202,7 +1202,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): self.parent_win.window.is_active(): # we are at the end if self.type_id == message_control.TYPE_GC: - if not gajim.events.remove_events(self.account, jid, + if not app.events.remove_events(self.account, jid, types=types_list): self.redraw_after_event_removed(jid) elif self.session and self.session.remove_events(types_list): @@ -1218,23 +1218,23 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): self.parent_win.show_title() # TODO : get the contact and check notify.get_show_in_roster() if self.type_id == message_control.TYPE_PM: - room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) - groupchat_control = gajim.interface.msg_win_mgr.get_gc_control( + room_jid, nick = app.get_room_and_nick_from_fjid(jid) + groupchat_control = app.interface.msg_win_mgr.get_gc_control( room_jid, self.account) - if room_jid in gajim.interface.minimized_controls[self.account]: + if room_jid in app.interface.minimized_controls[self.account]: groupchat_control = \ - gajim.interface.minimized_controls[self.account][room_jid] - contact = gajim.contacts.get_contact_with_highest_priority( + app.interface.minimized_controls[self.account][room_jid] + contact = app.contacts.get_contact_with_highest_priority( self.account, room_jid) if contact: - gajim.interface.roster.draw_contact(room_jid, self.account) + app.interface.roster.draw_contact(room_jid, self.account) if groupchat_control: groupchat_control.draw_contact(nick) if groupchat_control.parent_win: groupchat_control.parent_win.redraw_tab(groupchat_control) else: - gajim.interface.roster.draw_contact(jid, self.account) - gajim.interface.roster.show_title() + app.interface.roster.draw_contact(jid, self.account) + app.interface.roster.show_title() def scroll_messages(self, direction, msg_buf, msg_type): if msg_type == 'sent': diff --git a/gajim/command_system/implementation/middleware.py b/gajim/command_system/implementation/middleware.py index 51c119505..8efe527c8 100644 --- a/gajim/command_system/implementation/middleware.py +++ b/gajim/command_system/implementation/middleware.py @@ -34,7 +34,7 @@ don't need to dig up the code itself to write basic commands. from traceback import print_exc from gi.repository import Pango -from gajim.common import gajim +from gajim.common import app from gajim.command_system.framework import CommandProcessor from gajim.command_system.errors import CommandError, NoCommandError @@ -179,7 +179,7 @@ class CommandTools: """ Get the current connection object. """ - return gajim.connections[self.account] + return app.connections[self.account] @property def full_jid(self): diff --git a/gajim/command_system/implementation/standard.py b/gajim/command_system/implementation/standard.py index ed24163df..aeec4e7d5 100644 --- a/gajim/command_system/implementation/standard.py +++ b/gajim/command_system/implementation/standard.py @@ -21,7 +21,7 @@ from time import localtime, strftime from datetime import date from gajim import dialogs -from gajim.common import gajim +from gajim.common import app from gajim.common import helpers from gajim.common.exceptions import GajimGeneralException from gajim.common.logger import KindConstant @@ -87,7 +87,7 @@ class StandardCommonCommands(CommandContainer): @command('lastlog', overlap=True) @doc(_("Show logged messages which mention given text")) def grep(self, text, limit=None): - results = gajim.logger.search_log(self.account, self.contact.jid, text) + results = app.logger.search_log(self.account, self.contact.jid, text) if not results: raise CommandError(_("%s: Nothing found") % text) @@ -102,7 +102,7 @@ class StandardCommonCommands(CommandContainer): contact = row.contact_name if not contact: if row.kind == KindConstant.CHAT_MSG_SENT: - contact = gajim.nicks[self.account] + contact = app.nicks[self.account] else: contact = self.contact.name @@ -129,8 +129,8 @@ class StandardCommonCommands(CommandContainer): def status(self, status, message): if status not in ('online', 'away', 'chat', 'xa', 'dnd'): raise CommandError("Invalid status given") - for connection in gajim.connections.values(): - if not gajim.config.get_per('accounts', connection.name, + for connection in app.connections.values(): + if not app.config.get_per('accounts', connection.name, 'sync_with_global_status'): continue if connection.connected < 2: @@ -143,8 +143,8 @@ class StandardCommonCommands(CommandContainer): if not message: message = _("Away") - for connection in gajim.connections.values(): - if not gajim.config.get_per('accounts', connection.name, + for connection in app.connections.values(): + if not app.config.get_per('accounts', connection.name, 'sync_with_global_status'): continue if connection.connected < 2: @@ -157,8 +157,8 @@ class StandardCommonCommands(CommandContainer): if not message: message = _("Available") - for connection in gajim.connections.values(): - if not gajim.config.get_per('accounts', connection.name, + for connection in app.connections.values(): + if not app.config.get_per('accounts', connection.name, 'sync_with_global_status'): continue if connection.connected < 2: @@ -182,9 +182,9 @@ class StandardCommonChatCommands(CommandContainer): @command @doc(_("Send a ping to the contact")) def ping(self): - if self.account == gajim.ZEROCONF_ACC_NAME: + if self.account == app.ZEROCONF_ACC_NAME: raise CommandError(_('Command is not supported for zeroconf accounts')) - gajim.connections[self.account].sendPing(self.contact) + app.connections[self.account].sendPing(self.contact) @command @doc(_("Send DTMF sequence through an open audio session")) @@ -271,7 +271,7 @@ class StandardGroupChatCommands(CommandContainer): @command('query', raw=True) @doc(_("Open a private chat window with a specified occupant")) def chat(self, nick): - nicks = gajim.contacts.get_nick_list(self.account, self.room_jid) + nicks = app.contacts.get_nick_list(self.account, self.room_jid) if nick in nicks: self.on_send_pm(nick=nick) else: @@ -280,7 +280,7 @@ class StandardGroupChatCommands(CommandContainer): @command('msg', raw=True) @doc(_("Open a private chat window with a specified occupant and send him a message")) def message(self, nick, a_message): - nicks = gajim.contacts.get_nick_list(self.account, self.room_jid) + nicks = app.contacts.get_nick_list(self.account, self.room_jid) if nick in nicks: self.on_send_pm(nick=nick, msg=a_message) else: @@ -307,10 +307,10 @@ class StandardGroupChatCommands(CommandContainer): nick = self.nick if '@' not in jid: - jid = jid + '@' + gajim.get_server_from_jid(self.room_jid) + jid = jid + '@' + app.get_server_from_jid(self.room_jid) try: - gajim.interface.instances[self.account]['join_gc'].window.present() + app.interface.instances[self.account]['join_gc'].window.present() except KeyError: try: dialogs.JoinGroupchatWindow(account=self.account, room_jid=jid, nick=nick) @@ -329,15 +329,15 @@ class StandardGroupChatCommands(CommandContainer): If given nickname is not found it will be treated as a jid. """)) def ban(self, who, reason): - if who in gajim.contacts.get_nick_list(self.account, self.room_jid): - contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, who) + if who in app.contacts.get_nick_list(self.account, self.room_jid): + contact = app.contacts.get_gc_contact(self.account, self.room_jid, who) who = contact.jid self.connection.gc_set_affiliation(self.room_jid, who, 'outcast', reason or str()) @command(raw=True, empty=True) @doc(_("Kick user by a nick from a groupchat")) def kick(self, who, reason): - if not who in gajim.contacts.get_nick_list(self.account, self.room_jid): + if not who in app.contacts.get_nick_list(self.account, self.room_jid): raise CommandError(_("Nickname not found")) self.connection.gc_set_role(self.room_jid, who, 'none', reason or str()) @@ -349,7 +349,7 @@ class StandardGroupChatCommands(CommandContainer): def role(self, who, role): if role not in ('moderator', 'participant', 'visitor', 'none'): raise CommandError(_("Invalid role given")) - if not who in gajim.contacts.get_nick_list(self.account, self.room_jid): + if not who in app.contacts.get_nick_list(self.account, self.room_jid): raise CommandError(_("Nickname not found")) self.connection.gc_set_role(self.room_jid, who, role) @@ -361,17 +361,17 @@ class StandardGroupChatCommands(CommandContainer): def affiliate(self, who, affiliation): if affiliation not in ('owner', 'admin', 'member', 'outcast', 'none'): raise CommandError(_("Invalid affiliation given")) - if not who in gajim.contacts.get_nick_list(self.account, self.room_jid): + if not who in app.contacts.get_nick_list(self.account, self.room_jid): raise CommandError(_("Nickname not found")) - contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, who) + contact = app.contacts.get_gc_contact(self.account, self.room_jid, who) self.connection.gc_set_affiliation(self.room_jid, contact.jid, affiliation) @command @doc(_("Display names of all group chat occupants")) def names(self, verbose=False): - ggc = gajim.contacts.get_gc_contact - gnl = gajim.contacts.get_nick_list + ggc = app.contacts.get_gc_contact + gnl = app.contacts.get_nick_list get_contact = lambda nick: ggc(self.account, self.room_jid, nick) get_role = lambda nick: get_contact(nick).role @@ -402,8 +402,8 @@ class StandardGroupChatCommands(CommandContainer): @command @doc(_("Send a ping to the contact")) def ping(self, nick): - if self.account == gajim.ZEROCONF_ACC_NAME: + if self.account == app.ZEROCONF_ACC_NAME: raise CommandError(_('Command is not supported for zeroconf accounts')) - gc_c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick) - gajim.connections[self.account].sendPing(gc_c, self) + gc_c = app.contacts.get_gc_contact(self.account, self.room_jid, nick) + app.connections[self.account].sendPing(gc_c, self) diff --git a/gajim/common/gajim.py b/gajim/common/app.py similarity index 99% rename from gajim/common/gajim.py rename to gajim/common/app.py index 40e7877a7..6191cbfd0 100644 --- a/gajim/common/gajim.py +++ b/gajim/common/app.py @@ -1,5 +1,5 @@ # -*- coding:utf-8 -*- -## src/common/gajim.py +## gajim/common/app.py ## ## Copyright (C) 2003-2014 Yann Leboulanger ## Copyright (C) 2005-2006 Dimitur Kirov @@ -144,7 +144,7 @@ SHOW_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd', # zeroconf account name ZEROCONF_ACC_NAME = 'Local' -# These will be set in gajim.gui_interface. +# These will be set in app.gui_interface. idlequeue = None socks5queue = None diff --git a/gajim/common/check_paths.py b/gajim/common/check_paths.py index efd53fb21..d9f8f3311 100644 --- a/gajim/common/check_paths.py +++ b/gajim/common/check_paths.py @@ -27,7 +27,7 @@ import os import shutil import sys -from gajim.common import gajim +from gajim.common import app from gajim.common import logger # DO NOT MOVE ABOVE OF import gajim @@ -173,12 +173,12 @@ def check_and_possibly_move_config(): LOG_DB_PATH = logger.LOG_DB_PATH CACHE_DB_PATH = logger.CACHE_DB_PATH vars = {} - vars['VCARD_PATH'] = gajim.VCARD_PATH - vars['AVATAR_PATH'] = gajim.AVATAR_PATH - vars['MY_EMOTS_PATH'] = gajim.MY_EMOTS_PATH - vars['MY_ICONSETS_PATH'] = gajim.MY_ICONSETS_PATH - vars['MY_MOOD_ICONSETS_PATH'] = gajim.MY_MOOD_ICONSETS_PATH - vars['MY_ACTIVITY_ICONSETS_PATH'] = gajim.MY_ACTIVITY_ICONSETS_PATH + vars['VCARD_PATH'] = app.VCARD_PATH + vars['AVATAR_PATH'] = app.AVATAR_PATH + vars['MY_EMOTS_PATH'] = app.MY_EMOTS_PATH + vars['MY_ICONSETS_PATH'] = app.MY_ICONSETS_PATH + vars['MY_MOOD_ICONSETS_PATH'] = app.MY_MOOD_ICONSETS_PATH + vars['MY_ACTIVITY_ICONSETS_PATH'] = app.MY_ACTIVITY_ICONSETS_PATH from gajim.common import configpaths MY_DATA = configpaths.gajimpaths['MY_DATA'] MY_CONFIG = configpaths.gajimpaths['MY_CONFIG'] @@ -252,8 +252,8 @@ def check_and_possibly_move_config(): continue print(_('moving %s to %s') % (src, dst)) shutil.move(src, dst) - gajim.logger.init_vars() - gajim.logger.attach_cache_database() + app.logger.init_vars() + app.logger.attach_cache_database() def check_and_possibly_create_paths(): LOG_DB_PATH = logger.LOG_DB_PATH @@ -262,8 +262,8 @@ def check_and_possibly_create_paths(): CACHE_DB_PATH = logger.CACHE_DB_PATH CACHE_DB_FOLDER, CACHE_DB_FILE = os.path.split(CACHE_DB_PATH) - VCARD_PATH = gajim.VCARD_PATH - AVATAR_PATH = gajim.AVATAR_PATH + VCARD_PATH = app.VCARD_PATH + AVATAR_PATH = app.AVATAR_PATH from gajim.common import configpaths MY_DATA = configpaths.gajimpaths['MY_DATA'] MY_CONFIG = configpaths.gajimpaths['MY_CONFIG'] @@ -271,7 +271,7 @@ def check_and_possibly_create_paths(): XTLS_CERTS = configpaths.gajimpaths['MY_PEER_CERTS'] LOCAL_XTLS_CERTS = configpaths.gajimpaths['MY_CERT'] - PLUGINS_CONFIG_PATH = gajim.PLUGINS_CONFIG_DIR + PLUGINS_CONFIG_PATH = app.PLUGINS_CONFIG_DIR if not os.path.exists(MY_DATA): create_path(MY_DATA) @@ -335,7 +335,7 @@ def check_and_possibly_create_paths(): if os.path.exists(CACHE_DB_PATH): os.remove(CACHE_DB_PATH) create_log_db() - gajim.logger.init_vars() + app.logger.init_vars() elif os.path.isdir(LOG_DB_PATH): print(_('%s is a directory but should be a file') % LOG_DB_PATH) print(_('Gajim will now exit')) @@ -343,7 +343,7 @@ def check_and_possibly_create_paths(): if not os.path.exists(CACHE_DB_PATH): create_cache_db() - gajim.logger.attach_cache_database() + app.logger.attach_cache_database() elif os.path.isdir(CACHE_DB_PATH): print(_('%s is a directory but should be a file') % CACHE_DB_PATH) print(_('Gajim will now exit')) diff --git a/gajim/common/commands.py b/gajim/common/commands.py index 50a822fee..a02c8956f 100644 --- a/gajim/common/commands.py +++ b/gajim/common/commands.py @@ -25,7 +25,7 @@ import nbxmpp from gajim.common import helpers from gajim.common import dataforms -from gajim.common import gajim +from gajim.common import app from gajim.common.connection_handlers_events import MessageOutgoingEvent import logging @@ -157,7 +157,7 @@ class ChangeStatusCommand(AdHocCommand): self.connection.connection.send(response, now = presencetype == 'offline') # send new status - gajim.interface.roster.send_status(self.connection.name, presencetype, + app.interface.roster.send_status(self.connection.name, presencetype, presencedesc) return False # finish the session @@ -165,8 +165,8 @@ class ChangeStatusCommand(AdHocCommand): def find_current_groupchats(account): import message_control rooms = [] - for gc_control in gajim.interface.msg_win_mgr.get_controls( - message_control.TYPE_GC) + gajim.interface.minimized_controls[account].\ + for gc_control in app.interface.msg_win_mgr.get_controls( + message_control.TYPE_GC) + app.interface.minimized_controls[account].\ values(): acct = gc_control.account # check if account is the good one @@ -174,8 +174,8 @@ def find_current_groupchats(account): continue room_jid = gc_control.room_jid nick = gc_control.nick - if room_jid in gajim.gc_connected[acct] and \ - gajim.gc_connected[acct][room_jid]: + if room_jid in app.gc_connected[acct] and \ + app.gc_connected[acct][room_jid]: rooms.append((room_jid, nick,)) return rooms @@ -241,13 +241,13 @@ class LeaveGroupchatsCommand(AdHocCommand): account = self.connection.name try: for room_jid in gc: - gc_control = gajim.interface.msg_win_mgr.get_gc_control(room_jid, + gc_control = app.interface.msg_win_mgr.get_gc_control(room_jid, account) if not gc_control: - gc_control = gajim.interface.minimized_controls[account]\ + gc_control = app.interface.minimized_controls[account]\ [room_jid] gc_control.shutdown() - gajim.interface.roster.remove_groupchat(room_jid, account) + app.interface.roster.remove_groupchat(room_jid, account) continue gc_control.parent_win.remove_tab(gc_control, None, force = True) except Exception: # KeyError if there's no such room opened @@ -278,15 +278,15 @@ class ForwardMessagesCommand(AdHocCommand): def execute(self, request): account = self.connection.name # Forward messages - events = gajim.events.get_events(account, types=['chat', 'normal', + events = app.events.get_events(account, types=['chat', 'normal', 'printed_chat']) - j, resource = gajim.get_room_and_nick_from_fjid(self.jid) + j, resource = app.get_room_and_nick_from_fjid(self.jid) for jid in events: for event in events[jid]: ev_typ = event.type_ if ev_typ == 'printed_chat': ev_typ = 'chat' - gajim.nec.push_outgoing_event(MessageOutgoingEvent(None, + app.nec.push_outgoing_event(MessageOutgoingEvent(None, account=account, jid=j, message=event.message, type_=ev_typ, subject=event.subject, resource=resource, forward_from=jid, delayed=event.time_)) @@ -313,14 +313,14 @@ class FwdMsgThenDisconnectCommand(AdHocCommand): def execute(self, request): account = self.connection.name # Forward messages - events = gajim.events.get_events(account, types=['chat', 'normal']) - j, resource = gajim.get_room_and_nick_from_fjid(self.jid) + events = app.events.get_events(account, types=['chat', 'normal']) + j, resource = app.get_room_and_nick_from_fjid(self.jid) for jid in events: for event in events[jid]: ev_typ = event.type_ if ev_typ == 'printed_chat': ev_typ = 'chat' - gajim.nec.push_outgoing_event(MessageOutgoingEvent(None, + app.nec.push_outgoing_event(MessageOutgoingEvent(None, account=account, jid=j, message=event.message, type_=ev_typ, subject=event.subject, resource=resource, forward_from=jid, delayed=event.time_, now=True)) @@ -333,7 +333,7 @@ class FwdMsgThenDisconnectCommand(AdHocCommand): self.connection.connection.send(response, now = True) # send new status - gajim.interface.roster.send_status(self.connection.name, 'offline', '') + app.interface.roster.send_status(self.connection.name, 'offline', '') # finish the session return False @@ -345,7 +345,7 @@ class ConnectionCommands: def __init__(self): # a list of all commands exposed: node -> command class self.__commands = {} - if gajim.config.get('remote_commands'): + if app.config.get('remote_commands'): for cmdobj in (ChangeStatusCommand, ForwardMessagesCommand, LeaveGroupchatsCommand, FwdMsgThenDisconnectCommand): self.__commands[cmdobj.commandnode] = cmdobj @@ -354,7 +354,7 @@ class ConnectionCommands: self.__sessions = {} def getOurBareJID(self): - return gajim.get_jid_from_account(self.name) + return app.get_jid_from_account(self.name) def isSameJID(self, jid): """ diff --git a/gajim/common/config.py b/gajim/common/config.py index d7f6ee919..48047bc7c 100644 --- a/gajim/common/config.py +++ b/gajim/common/config.py @@ -795,9 +795,9 @@ class Config: self.__options[1][opt] = self.__options[0][opt][Option.VAL] def _really_save(self): - from gajim.common import gajim - if gajim.interface: - gajim.interface.save_config() + from gajim.common import app + if app.interface: + app.interface.save_config() self.save_timeout_id = None return False diff --git a/gajim/common/connection.py b/gajim/common/connection.py index b8ed3612a..e7880ff28 100644 --- a/gajim/common/connection.py +++ b/gajim/common/connection.py @@ -56,7 +56,7 @@ if os.name != 'nt': import nbxmpp from gajim import common from gajim.common import helpers -from gajim.common import gajim +from gajim.common import app from gajim.common import gpg from gajim.common import passwords from gajim.common import exceptions @@ -65,7 +65,7 @@ from gajim.common.connection_handlers import * from gajim.gtkgui_helpers import get_action -if gajim.HAVE_PYOPENSSL: +if app.HAVE_PYOPENSSL: import OpenSSL.crypto from nbxmpp import Smacks @@ -131,12 +131,12 @@ class CommonConnection: self.server_resource = self._compute_resource() self.gpg = None self.USE_GPG = False - if gajim.HAVE_GPG: + if app.HAVE_GPG: self.USE_GPG = True self.gpg = gpg.GnuPG() self.status = '' self.old_show = '' - self.priority = gajim.get_priority(name, 'offline') + self.priority = app.get_priority(name, 'offline') self.time_to_reconnect = None self.bookmarks = [] @@ -182,7 +182,7 @@ class CommonConnection: self.get_config_values_or_default() def _compute_resource(self): - resource = gajim.config.get_per('accounts', self.name, 'resource') + resource = app.config.get_per('accounts', self.name, 'resource') # All valid resource substitution strings should be added to this hash. if resource: rand = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(8)) @@ -196,7 +196,7 @@ class CommonConnection: """ Always passes account name as first param """ - gajim.ged.raise_event(event, self.name, data) + app.ged.raise_event(event, self.name, data) def reconnect(self): """ @@ -205,7 +205,7 @@ class CommonConnection: raise NotImplementedError def quit(self, kill_core): - if kill_core and gajim.account_is_connected(self.name): + if kill_core and app.account_is_connected(self.name): self.disconnect(on_purpose=True) def test_gpg_passphrase(self, password): @@ -215,7 +215,7 @@ class CommonConnection: if not self.gpg: return False self.gpg.passphrase = password - keyID = gajim.config.get_per('accounts', self.name, 'keyid') + keyID = app.config.get_per('accounts', self.name, 'keyid') signed = self.gpg.sign('test', keyID) self.gpg.password = None if signed == 'KEYEXPIRED': @@ -232,7 +232,7 @@ class CommonConnection: callback is the function to call when user give the passphrase """ signed = '' - keyID = gajim.config.get_per('accounts', self.name, 'keyid') + keyID = app.config.get_per('accounts', self.name, 'keyid') if keyID and self.USE_GPG: if self.gpg.passphrase is None and not self.gpg.use_agent: # We didn't set a passphrase @@ -241,7 +241,7 @@ class CommonConnection: if signed == 'BAD_PASSPHRASE': self.USE_GPG = False signed = '' - gajim.nec.push_incoming_event(BadGPGPassphraseEvent(None, + app.nec.push_incoming_event(BadGPGPassphraseEvent(None, conn=self)) return signed @@ -250,11 +250,11 @@ class CommonConnection: Called when a disconnect request has completed successfully """ self.disconnect(on_purpose=True) - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show='offline')) def get_status(self): - return gajim.SHOW_LIST[self.connected] + return app.SHOW_LIST[self.connected] def check_jid(self, jid): """ @@ -273,7 +273,7 @@ class CommonConnection: try: self.check_jid(jid) except helpers.InvalidFormat: - gajim.nec.push_incoming_event(InformationEvent(None, + app.nec.push_incoming_event(InformationEvent(None, conn=self, level='error', pri_txt=_('Invalid JID'), sec_txt=_('It is not possible to send a message ' 'to %s, this JID is not valid.') % jid)) @@ -282,13 +282,13 @@ class CommonConnection: try: self.check_jid(obj.jid) except helpers.InvalidFormat: - gajim.nec.push_incoming_event(InformationEvent(None, conn=self, + app.nec.push_incoming_event(InformationEvent(None, conn=self, level='error', pri_txt=_('Invalid JID'), sec_txt=_( 'It is not possible to send a message to %s, this JID is not ' 'valid.') % obj.jid)) return - if obj.message and not obj.xhtml and gajim.config.get( + if obj.message and not obj.xhtml and app.config.get( 'rst_formatting_outgoing_messages'): from gajim.common.rst_xhtml_generator import create_xhtml obj.xhtml = create_xhtml(obj.message) @@ -298,7 +298,7 @@ class CommonConnection: self._build_message_stanza(obj) def _build_message_stanza(self, obj): - if obj.jid == gajim.get_jid_from_account(self.name): + if obj.jid == app.get_jid_from_account(self.name): fjid = obj.jid else: fjid = obj.get_full_jid() @@ -336,7 +336,7 @@ class CommonConnection: # XEP-0203 if obj.delayed: - our_jid = gajim.get_jid_from_account(self.name) + '/' + \ + our_jid = app.get_jid_from_account(self.name) + '/' + \ self.server_resource timestamp = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(obj.delayed)) msg_iq.addChild('delay', namespace=nbxmpp.NS_DELAY2, @@ -348,7 +348,7 @@ class CommonConnection: if isinstance(obj.jid, list): if self.addressing_supported: - msg_iq.setTo(gajim.config.get_per('accounts', self.name, 'hostname')) + msg_iq.setTo(app.config.get_per('accounts', self.name, 'hostname')) addresses = msg_iq.addChild('addresses', namespace=nbxmpp.NS_ADDRESS) for j in obj.jid: @@ -365,11 +365,11 @@ class CommonConnection: msg_iq.setTo(fjid) r_ = obj.resource if not r_ and obj.jid != fjid: # Only if we're not in a pm - r_ = gajim.get_resource_from_jid(fjid) + r_ = app.get_resource_from_jid(fjid) if r_: - contact = gajim.contacts.get_contact(self.name, obj.jid, r_) + contact = app.contacts.get_contact(self.name, obj.jid, r_) else: - contact = gajim.contacts.get_contact_with_highest_priority( + contact = app.contacts.get_contact_with_highest_priority( self.name, obj.jid) # chatstates - if peer supports xep85, send chatstates @@ -385,8 +385,8 @@ class CommonConnection: namespace=nbxmpp.NS_MSG_HINTS) # XEP-0184 - if obj.jid != gajim.get_jid_from_account(self.name): - request = gajim.config.get_per('accounts', self.name, + if obj.jid != app.get_jid_from_account(self.name): + request = app.config.get_per('accounts', self.name, 'request_receipt') if obj.message and request: msg_iq.setTag('request', namespace=nbxmpp.NS_RECEIPTS) @@ -409,11 +409,11 @@ class CommonConnection: if isinstance(msg_iq, list): for iq in msg_iq: obj.msg_iq = iq - gajim.nec.push_incoming_event( + app.nec.push_incoming_event( StanzaMessageOutgoingEvent(None, **vars(obj))) else: obj.msg_iq = msg_iq - gajim.nec.push_incoming_event( + app.nec.push_incoming_event( StanzaMessageOutgoingEvent(None, **vars(obj))) def log_message(self, obj, jid): @@ -423,16 +423,16 @@ class CommonConnection: if obj.forward_from or not obj.session or not obj.session.is_loggable(): return - if not gajim.config.should_log(self.name, jid): + if not app.config.should_log(self.name, jid): return - if obj.xhtml and gajim.config.get('log_xhtml_messages'): + if obj.xhtml and app.config.get('log_xhtml_messages'): obj.message = '%s' % (nbxmpp.NS_XHTML, obj.xhtml) if obj.message is None: return - gajim.logger.insert_into_logs(jid, obj.timestamp, obj.kind, + app.logger.insert_into_logs(jid, obj.timestamp, obj.kind, message=obj.message, subject=obj.subject, additional_data=obj.additional_data, @@ -569,10 +569,10 @@ class CommonConnection: def _event_dispatcher(self, realm, event, data): if realm == '': if event == nbxmpp.transports_nb.DATA_RECEIVED: - gajim.nec.push_incoming_event(StanzaReceivedEvent(None, + app.nec.push_incoming_event(StanzaReceivedEvent(None, conn=self, stanza_str=data)) elif event == nbxmpp.transports_nb.DATA_SENT: - gajim.nec.push_incoming_event(StanzaSentEvent(None, conn=self, + app.nec.push_incoming_event(StanzaSentEvent(None, conn=self, stanza_str=data)) def change_status(self, show, msg, auto=False): @@ -590,10 +590,10 @@ class CommonConnection: self.old_show = show self.on_purpose = False self.server_resource = self._compute_resource() - if gajim.HAVE_GPG: + if app.HAVE_GPG: self.USE_GPG = True self.gpg = gpg.GnuPG() - gajim.nec.push_incoming_event(BeforeChangeShowEvent(None, + app.nec.push_incoming_event(BeforeChangeShowEvent(None, conn=self, show=show, message=msg)) self.connect_and_init(show, msg, sign_msg) return @@ -601,7 +601,7 @@ class CommonConnection: if show == 'offline': self.connected = 0 if self.connection: - gajim.nec.push_incoming_event(BeforeChangeShowEvent(None, + app.nec.push_incoming_event(BeforeChangeShowEvent(None, conn=self, show=show, message=msg)) p = nbxmpp.Presence(typ = 'unavailable') p = self.add_sha(p, False) @@ -620,22 +620,22 @@ class CommonConnection: if self.connected == 1: return if show == 'invisible': - gajim.nec.push_incoming_event(BeforeChangeShowEvent(None, + app.nec.push_incoming_event(BeforeChangeShowEvent(None, conn=self, show=show, message=msg)) self._change_to_invisible(msg) return if show not in ['offline', 'online', 'chat', 'away', 'xa', 'dnd']: return -1 - was_invisible = self.connected == gajim.SHOW_LIST.index('invisible') - self.connected = gajim.SHOW_LIST.index(show) + was_invisible = self.connected == app.SHOW_LIST.index('invisible') + self.connected = app.SHOW_LIST.index(show) idle_time = None if auto: global HAS_IDLE - if HAS_IDLE and gajim.config.get('autoaway'): + if HAS_IDLE and app.config.get('autoaway'): idle_sec = int(self.sleeper.getIdleSec()) idle_time = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(time.time() - idle_sec)) - gajim.nec.push_incoming_event(BeforeChangeShowEvent(None, + app.nec.push_incoming_event(BeforeChangeShowEvent(None, conn=self, show=show, message=msg)) if was_invisible: self._change_from_invisible() @@ -664,7 +664,7 @@ class Connection(CommonConnection, ConnectionHandlers): self.new_account_info = None self.new_account_form = None self.annotations = {} - self.last_io = gajim.idlequeue.current_time() + self.last_io = app.idlequeue.current_time() self.last_sent = [] self.last_history_time = {} self.password = passwords.get_password(name) @@ -691,51 +691,51 @@ class Connection(CommonConnection, ConnectionHandlers): self.sm = Smacks(self) # Stream Management - gajim.ged.register_event_handler('privacy-list-received', ged.CORE, + app.ged.register_event_handler('privacy-list-received', ged.CORE, self._nec_privacy_list_received) - gajim.ged.register_event_handler('agent-info-error-received', ged.CORE, + app.ged.register_event_handler('agent-info-error-received', ged.CORE, self._nec_agent_info_error_received) - gajim.ged.register_event_handler('agent-info-received', ged.CORE, + app.ged.register_event_handler('agent-info-received', ged.CORE, self._nec_agent_info_received) - gajim.ged.register_event_handler('message-outgoing', ged.OUT_CORE, + app.ged.register_event_handler('message-outgoing', ged.OUT_CORE, self._nec_message_outgoing) - gajim.ged.register_event_handler('gc-message-outgoing', ged.OUT_CORE, + app.ged.register_event_handler('gc-message-outgoing', ged.OUT_CORE, self._nec_gc_message_outgoing) - gajim.ged.register_event_handler('gc-stanza-message-outgoing', ged.OUT_CORE, + app.ged.register_event_handler('gc-stanza-message-outgoing', ged.OUT_CORE, self._nec_gc_stanza_message_outgoing) - gajim.ged.register_event_handler('stanza-message-outgoing', + app.ged.register_event_handler('stanza-message-outgoing', ged.OUT_CORE, self._nec_stanza_message_outgoing) # END __init__ def cleanup(self): ConnectionHandlers.cleanup(self) - gajim.ged.remove_event_handler('privacy-list-received', ged.CORE, + app.ged.remove_event_handler('privacy-list-received', ged.CORE, self._nec_privacy_list_received) - gajim.ged.remove_event_handler('agent-info-error-received', ged.CORE, + app.ged.remove_event_handler('agent-info-error-received', ged.CORE, self._nec_agent_info_error_received) - gajim.ged.remove_event_handler('agent-info-received', ged.CORE, + app.ged.remove_event_handler('agent-info-received', ged.CORE, self._nec_agent_info_received) - gajim.ged.remove_event_handler('message-outgoing', ged.OUT_CORE, + app.ged.remove_event_handler('message-outgoing', ged.OUT_CORE, self._nec_message_outgoing) - gajim.ged.remove_event_handler('gc-message-outgoing', ged.OUT_CORE, + app.ged.remove_event_handler('gc-message-outgoing', ged.OUT_CORE, self._nec_gc_message_outgoing) - gajim.ged.remove_event_handler('gc-stanza-message-outgoing', ged.OUT_CORE, + app.ged.remove_event_handler('gc-stanza-message-outgoing', ged.OUT_CORE, self._nec_gc_stanza_message_outgoing) - gajim.ged.remove_event_handler('stanza-message-outgoing', ged.OUT_CORE, + app.ged.remove_event_handler('stanza-message-outgoing', ged.OUT_CORE, self._nec_stanza_message_outgoing) def get_config_values_or_default(self): - if gajim.config.get_per('accounts', self.name, 'keep_alives_enabled'): - self.keepalives = gajim.config.get_per('accounts', self.name, + if app.config.get_per('accounts', self.name, 'keep_alives_enabled'): + self.keepalives = app.config.get_per('accounts', self.name, 'keep_alive_every_foo_secs') else: self.keepalives = 0 - if gajim.config.get_per('accounts', self.name, 'ping_alives_enabled'): - self.pingalives = gajim.config.get_per('accounts', self.name, + if app.config.get_per('accounts', self.name, 'ping_alives_enabled'): + self.pingalives = app.config.get_per('accounts', self.name, 'ping_alive_every_foo_secs') else: self.pingalives = 0 - self.client_cert = gajim.config.get_per('accounts', self.name, + self.client_cert = app.config.get_per('accounts', self.name, 'client_cert') self.client_cert_passphrase = '' @@ -752,7 +752,7 @@ class Connection(CommonConnection, ConnectionHandlers): return self.registered_name else: # This returns the bare jid - return nbxmpp.JID(gajim.get_jid_from_account(self.name)) + return nbxmpp.JID(app.get_jid_from_account(self.name)) def reconnect(self): # Do not try to reco while we are already trying @@ -760,7 +760,7 @@ class Connection(CommonConnection, ConnectionHandlers): if self.connected < 2: # connection failed log.debug('reconnect') self.connected = 1 - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show='connecting')) self.retrycount += 1 self.on_connect_auth = self._discover_server_at_connection @@ -772,7 +772,7 @@ class Connection(CommonConnection, ConnectionHandlers): # We are doing disconnect at so many places, better use one function in all def disconnect(self, on_purpose=False): - gajim.interface.music_track_changed(None, None, self.name) + app.interface.music_track_changed(None, None, self.name) self.reset_awaiting_pep() self.on_purpose = on_purpose self.connected = 0 @@ -782,7 +782,7 @@ class Connection(CommonConnection, ConnectionHandlers): self.sm = Smacks(self) if self.connection: # make sure previous connection is completely closed - gajim.proxy65_manager.disconnect(self.connection) + app.proxy65_manager.disconnect(self.connection) self.terminate_sessions() self.remove_all_transfers() self.connection.disconnect() @@ -791,44 +791,44 @@ class Connection(CommonConnection, ConnectionHandlers): def set_oldst(self): # Set old state if self.old_show: - self.connected = gajim.SHOW_LIST.index(self.old_show) - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + self.connected = app.SHOW_LIST.index(self.old_show) + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show=self.connected)) else: # we default to online self.connected = 2 - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, - show=gajim.SHOW_LIST[self.connected])) + app.nec.push_incoming_event(OurShowEvent(None, conn=self, + show=app.SHOW_LIST[self.connected])) def disconnectedReconnCB(self): """ Called when we are disconnected """ log.info('disconnectedReconnCB called') - if gajim.account_is_connected(self.name): + if app.account_is_connected(self.name): # we cannot change our status to offline or connecting # after we auth to server - self.old_show = gajim.SHOW_LIST[self.connected] + self.old_show = app.SHOW_LIST[self.connected] self.connected = 0 if not self.on_purpose: if not (self.sm and self.sm.resumption): - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show='offline')) else: self.sm.enabled = False - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show='error')) if self.connection: self.connection.UnregisterDisconnectHandler( self.disconnectedReconnCB) self.disconnect() - if gajim.config.get_per('accounts', self.name, 'autoreconnect'): + if app.config.get_per('accounts', self.name, 'autoreconnect'): self.connected = -1 - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show='error')) - if gajim.status_before_autoaway[self.name]: + if app.status_before_autoaway[self.name]: # We were auto away. So go back online - self.status = gajim.status_before_autoaway[self.name] - gajim.status_before_autoaway[self.name] = '' + self.status = app.status_before_autoaway[self.name] + app.status_before_autoaway[self.name] = '' self.old_show = 'online' # this check has moved from reconnect method # do exponential backoff until less than 5 minutes @@ -839,7 +839,7 @@ class Connection(CommonConnection, ConnectionHandlers): self.last_time_to_reconnect *= 1.5 self.time_to_reconnect = int(self.last_time_to_reconnect) log.info("Reconnect to %s in %ss", self.name, self.time_to_reconnect) - gajim.idlequeue.set_alarm(self._reconnect_alarm, + app.idlequeue.set_alarm(self._reconnect_alarm, self.time_to_reconnect) elif self.on_connect_failure: self.on_connect_failure() @@ -860,7 +860,7 @@ class Connection(CommonConnection, ConnectionHandlers): def _connection_lost(self): log.debug('_connection_lost') self.disconnect(on_purpose = False) - gajim.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, + app.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, title=_('Connection with account "%s" has been lost') % self.name, msg=_('Reconnect manually.'))) @@ -876,7 +876,7 @@ class Connection(CommonConnection, ConnectionHandlers): reason = _('Server %(name)s answered wrongly to ' 'register request: %(error)s') % {'name': data[0], 'error': data[3]} - gajim.nec.push_incoming_event(AccountNotCreatedEvent( + app.nec.push_incoming_event(AccountNotCreatedEvent( None, conn=self, reason=reason)) return is_form = data[2] @@ -886,13 +886,13 @@ class Connection(CommonConnection, ConnectionHandlers): if self.new_account_form: def _on_register_result(result): if not nbxmpp.isResultNode(result): - gajim.nec.push_incoming_event(AccountNotCreatedEvent( + app.nec.push_incoming_event(AccountNotCreatedEvent( None, conn=self, reason=result.getError())) return - if gajim.HAVE_GPG: + if app.HAVE_GPG: self.USE_GPG = True self.gpg = gpg.GnuPG() - gajim.nec.push_incoming_event( + app.nec.push_incoming_event( AccountCreatedEvent(None, conn=self, account_info = self.new_account_info)) self.new_account_info = None @@ -916,21 +916,21 @@ class Connection(CommonConnection, ConnectionHandlers): # requested config has changed since first connection reason = _('Server %s provided a different ' 'registration form') % data[0] - gajim.nec.push_incoming_event(AccountNotCreatedEvent( + app.nec.push_incoming_event(AccountNotCreatedEvent( None, conn=self, reason=reason)) return nbxmpp.features_nb.register(self.connection, self._hostname, self.new_account_form, _on_register_result) return - gajim.nec.push_incoming_event(NewAccountConnectedEvent(None, + app.nec.push_incoming_event(NewAccountConnectedEvent(None, conn=self, config=conf, is_form=is_form)) self.connection.UnregisterDisconnectHandler( self._on_new_account) self.disconnect(on_purpose=True) return if not data[1]: # wrong answer - gajim.nec.push_incoming_event(InformationEvent(None, + app.nec.push_incoming_event(InformationEvent(None, conn=self, level='error', pri_txt=_('Invalid answer'), sec_txt=_('Transport %(name)s answered wrongly to ' 'register request: %(error)s') % {'name': data[0], @@ -938,13 +938,13 @@ class Connection(CommonConnection, ConnectionHandlers): return is_form = data[2] conf = data[1] - gajim.nec.push_incoming_event(RegisterAgentInfoReceivedEvent( + app.nec.push_incoming_event(RegisterAgentInfoReceivedEvent( None, conn=self, agent=data[0], config=conf, is_form=is_form)) elif realm == nbxmpp.NS_PRIVACY: if event == nbxmpp.features_nb.PRIVACY_LISTS_RECEIVED: # data is (list) - gajim.nec.push_incoming_event(PrivacyListsReceivedEvent(None, + app.nec.push_incoming_event(PrivacyListsReceivedEvent(None, conn=self, lists_list=data)) elif event == nbxmpp.features_nb.PRIVACY_LIST_RECEIVED: # data is (resp) @@ -966,11 +966,11 @@ class Connection(CommonConnection, ConnectionHandlers): childs.append(scnd_child.getName()) rules.append({'action':dict_item['action'], 'order':dict_item['order'], 'child':childs}) - gajim.nec.push_incoming_event(PrivacyListReceivedEvent(None, + app.nec.push_incoming_event(PrivacyListReceivedEvent(None, conn=self, list_name=name, rules=rules)) elif event == nbxmpp.features_nb.PRIVACY_LISTS_ACTIVE_DEFAULT: # data is (dict) - gajim.nec.push_incoming_event(PrivacyListActiveDefaultEvent( + app.nec.push_incoming_event(PrivacyListActiveDefaultEvent( None, conn=self, active_list=data['active'], default_list=data['default'])) @@ -1014,7 +1014,7 @@ class Connection(CommonConnection, ConnectionHandlers): if self.sm.resuming and self.sm.location: # If resuming and server gave a location, connect from there hostname = self.sm.location - self.try_connecting_for_foo_secs = gajim.config.get_per('accounts', + self.try_connecting_for_foo_secs = app.config.get_per('accounts', self.name, 'try_connecting_for_foo_secs') use_custom = False proxy = helpers.get_proxy_info(self.name) @@ -1023,9 +1023,9 @@ class Connection(CommonConnection, ConnectionHandlers): hostname = data['hostname'] self.try_connecting_for_foo_secs = 45 p = data['proxy'] - if p and p in gajim.config.get_per('proxies'): + if p and p in app.config.get_per('proxies'): proxy = {} - proxyptr = gajim.config.get_per('proxies', p) + proxyptr = app.config.get_per('proxies', p) for key in proxyptr.keys(): proxy[key] = proxyptr[key] else: @@ -1036,27 +1036,27 @@ class Connection(CommonConnection, ConnectionHandlers): custom_h = data['custom_host'] custom_p = data['custom_port'] else: - hostname = gajim.config.get_per('accounts', self.name, 'hostname') - self.try_connecting_for_foo_secs = gajim.config.get_per('accounts', + hostname = app.config.get_per('accounts', self.name, 'hostname') + self.try_connecting_for_foo_secs = app.config.get_per('accounts', self.name, 'try_connecting_for_foo_secs') proxy = helpers.get_proxy_info(self.name) - use_srv = gajim.config.get_per('accounts', self.name, 'use_srv') + use_srv = app.config.get_per('accounts', self.name, 'use_srv') if self.redirected: use_custom = True custom_h = self.redirected['host'] custom_p = self.redirected['port'] else: - use_custom = gajim.config.get_per('accounts', self.name, + use_custom = app.config.get_per('accounts', self.name, 'use_custom_host') if use_custom: - custom_h = gajim.config.get_per('accounts', self.name, + custom_h = app.config.get_per('accounts', self.name, 'custom_host') - custom_p = gajim.config.get_per('accounts', self.name, + custom_p = app.config.get_per('accounts', self.name, 'custom_port') try: helpers.idn_to_ascii(custom_h) except Exception: - gajim.nec.push_incoming_event(InformationEvent(None, + app.nec.push_incoming_event(InformationEvent(None, conn=self, level='error', pri_txt=_('Wrong Custom Hostname'), sec_txt='Wrong custom hostname "%s". Ignoring it.' \ @@ -1085,7 +1085,7 @@ class Connection(CommonConnection, ConnectionHandlers): if use_srv: # add request for srv query to the resolve, on result '_on_resolve' # will be called - gajim.resolver.resolve('_xmpp-client._tcp.' + helpers.idn_to_ascii( + app.resolver.resolve('_xmpp-client._tcp.' + helpers.idn_to_ascii( h), self._on_resolve) else: self._on_resolve('', []) @@ -1096,8 +1096,8 @@ class Connection(CommonConnection, ConnectionHandlers): self._hosts = [i for i in result_array] # Add ssl port ssl_p = 5223 - if gajim.config.get_per('accounts', self.name, 'use_custom_host'): - ssl_p = gajim.config.get_per('accounts', self.name, + if app.config.get_per('accounts', self.name, 'use_custom_host'): + ssl_p = app.config.get_per('accounts', self.name, 'custom_port') for i in self._hosts: i['ssl_port'] = ssl_p @@ -1108,8 +1108,8 @@ class Connection(CommonConnection, ConnectionHandlers): log.debug('Connection to next host') if len(self._hosts): # No config option exist when creating a new account - if self.name in gajim.config.get_per('accounts'): - self._connection_types = gajim.config.get_per('accounts', self.name, + if self.name in app.config.get_per('accounts'): + self._connection_types = app.config.get_per('accounts', self.name, 'connection_types').split() else: self._connection_types = ['tls', 'ssl'] @@ -1174,20 +1174,20 @@ class Connection(CommonConnection, ConnectionHandlers): # plain connection on defined port port = self._current_host['port'] - cacerts = os.path.join(common.gajim.DATA_DIR, 'other', 'cacerts.pem') + cacerts = os.path.join(common.app.DATA_DIR, 'other', 'cacerts.pem') if not os.path.exists(cacerts): cacerts = '' - mycerts = common.gajim.MY_CACERTS - tls_version = gajim.config.get_per('accounts', self.name, + mycerts = common.app.MY_CACERTS + tls_version = app.config.get_per('accounts', self.name, 'tls_version') - cipher_list = gajim.config.get_per('accounts', self.name, + cipher_list = app.config.get_per('accounts', self.name, 'cipher_list') secure_tuple = (self._current_type, cacerts, mycerts, tls_version, cipher_list) con = nbxmpp.NonBlockingClient( domain=self._hostname, caller=self, - idlequeue=gajim.idlequeue) + idlequeue=app.idlequeue) self.last_connection = con # increase default timeout for server responses @@ -1197,9 +1197,9 @@ class Connection(CommonConnection, ConnectionHandlers): if self.on_connect_success == self._on_new_account: con.RegisterDisconnectHandler(self._on_new_account) - if self.client_cert and gajim.config.get_per('accounts', self.name, + if self.client_cert and app.config.get_per('accounts', self.name, 'client_cert_encrypted'): - gajim.nec.push_incoming_event(ClientCertPassphraseEvent( + app.nec.push_incoming_event(ClientCertPassphraseEvent( None, conn=self, con=con, port=port, secure_tuple=secure_tuple)) return @@ -1251,12 +1251,12 @@ class Connection(CommonConnection, ConnectionHandlers): key = nbxmpp.NS_XMPP_STREAMS + ' ' + self.streamError if key in nbxmpp.ERRORS: sectxt2 = _('Server replied: %s') % nbxmpp.ERRORS[key][2] - gajim.nec.push_incoming_event(InformationEvent(None, + app.nec.push_incoming_event(InformationEvent(None, conn=self, level='error', pri_txt=pritxt, sec_txt='%s\n%s' % (sectxt2, sectxt))) return # show popup - gajim.nec.push_incoming_event(ConnectionLostEvent(None, + app.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, title=pritxt, msg=sectxt)) def on_proxy_failure(self, reason): @@ -1264,7 +1264,7 @@ class Connection(CommonConnection, ConnectionHandlers): self.time_to_reconnect = None self.on_connect_failure = None self.disconnect(on_purpose = True) - gajim.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, + app.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, title=_('Connection to proxy failed'), msg=reason)) def _connect_success(self, con, con_type): @@ -1278,23 +1278,23 @@ class Connection(CommonConnection, ConnectionHandlers): self.connect_to_next_type() return con.RegisterDisconnectHandler(self._on_disconnected) - if _con_type == 'plain' and gajim.config.get_per('accounts', self.name, + if _con_type == 'plain' and app.config.get_per('accounts', self.name, 'action_when_plaintext_connection') == 'warn': - gajim.nec.push_incoming_event(PlainConnectionEvent(None, conn=self, + app.nec.push_incoming_event(PlainConnectionEvent(None, conn=self, xmpp_client=con)) return True - if _con_type == 'plain' and gajim.config.get_per('accounts', self.name, + if _con_type == 'plain' and app.config.get_per('accounts', self.name, 'action_when_plaintext_connection') == 'disconnect': self.disconnect(on_purpose=True) - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show='offline')) return False if _con_type in ('tls', 'ssl') and con.Connection.ssl_lib != 'PYOPENSSL' \ - and gajim.config.get_per('accounts', self.name, + and app.config.get_per('accounts', self.name, 'warn_when_insecure_ssl_connection') and \ not self.connection_auto_accepted: # Pyopenssl is not used - gajim.nec.push_incoming_event(InsecureSSLConnectionEvent(None, + app.nec.push_incoming_event(InsecureSSLConnectionEvent(None, conn=self, xmpp_client=con, conn_type=_con_type)) return True return self.connection_accepted(con, con_type) @@ -1302,7 +1302,7 @@ class Connection(CommonConnection, ConnectionHandlers): def connection_accepted(self, con, con_type): if not con or not con.Connection: self.disconnect(on_purpose=True) - gajim.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, + app.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, title=_('Could not connect to account %s') % self.name, msg=_('Connection with account %s has been lost. Retry ' 'connecting.') % self.name)) @@ -1320,23 +1320,23 @@ class Connection(CommonConnection, ConnectionHandlers): if con_type == 'tls' and 'ssl' in self._connection_types: # we were about to try ssl after tls, but tls succeed, so # definitively stop trying ssl - con_types = gajim.config.get_per('accounts', self.name, + con_types = app.config.get_per('accounts', self.name, 'connection_types').split() con_types.remove('ssl') - gajim.config.set_per('accounts', self.name, 'connection_types', + app.config.set_per('accounts', self.name, 'connection_types', ' '.join(con_types)) - if gajim.config.get_per('accounts', self.name, 'anonymous_auth'): + if app.config.get_per('accounts', self.name, 'anonymous_auth'): name = None else: - name = gajim.config.get_per('accounts', self.name, 'name') - hostname = gajim.config.get_per('accounts', self.name, 'hostname') + name = app.config.get_per('accounts', self.name, 'name') + hostname = app.config.get_per('accounts', self.name, 'hostname') self.connection = con try: errnum = con.Connection.ssl_errnum except AttributeError: errnum = 0 cert = con.Connection.ssl_certificate - if errnum > 0 and str(errnum) not in gajim.config.get_per('accounts', + if errnum > 0 and str(errnum) not in app.config.get_per('accounts', self.name, 'ignore_ssl_errors').split(): text = _('The authenticity of the %s certificate could be invalid' ) % hostname @@ -1348,7 +1348,7 @@ class Connection(CommonConnection, ConnectionHandlers): fingerprint_sha256 = cert.digest('sha256').decode('utf-8') pem = OpenSSL.crypto.dump_certificate(OpenSSL.crypto.FILETYPE_PEM, cert).decode('utf-8') - gajim.nec.push_incoming_event(SSLErrorEvent(None, conn=self, + app.nec.push_incoming_event(SSLErrorEvent(None, conn=self, error_text=text, error_num=errnum, cert=pem, fingerprint_sha1=fingerprint_sha1, fingerprint_sha256=fingerprint_sha256, certificate=cert)) @@ -1356,50 +1356,50 @@ class Connection(CommonConnection, ConnectionHandlers): if cert: fingerprint_sha1 = cert.digest('sha1').decode('utf-8') fingerprint_sha256 = cert.digest('sha256').decode('utf-8') - saved_fingerprint_sha1 = gajim.config.get_per('accounts', self.name, + saved_fingerprint_sha1 = app.config.get_per('accounts', self.name, 'ssl_fingerprint_sha1') if saved_fingerprint_sha1: # Check sha1 fingerprint if fingerprint_sha1 != saved_fingerprint_sha1: if not check_X509.check_certificate(cert, hostname): - gajim.nec.push_incoming_event(FingerprintErrorEvent( + app.nec.push_incoming_event(FingerprintErrorEvent( None, conn=self, certificate=cert, new_fingerprint_sha1=fingerprint_sha1, new_fingerprint_sha256=fingerprint_sha256)) return True - gajim.config.set_per('accounts', self.name, 'ssl_fingerprint_sha1', + app.config.set_per('accounts', self.name, 'ssl_fingerprint_sha1', fingerprint_sha1) - saved_fingerprint_sha256 = gajim.config.get_per('accounts', self.name, + saved_fingerprint_sha256 = app.config.get_per('accounts', self.name, 'ssl_fingerprint_sha256') if saved_fingerprint_sha256: # Check sha256 fingerprint if fingerprint_sha256 != saved_fingerprint_sha256: if not check_X509.check_certificate(cert, hostname): - gajim.nec.push_incoming_event(FingerprintErrorEvent( + app.nec.push_incoming_event(FingerprintErrorEvent( None, conn=self, certificate=cert, new_fingerprint_sha1=fingerprint_sha1, new_fingerprint_sha256=fingerprint_sha256)) return True - gajim.config.set_per('accounts', self.name, + app.config.set_per('accounts', self.name, 'ssl_fingerprint_sha256', fingerprint_sha256) if not check_X509.check_certificate(cert, hostname) and \ - '100' not in gajim.config.get_per('accounts', self.name, + '100' not in app.config.get_per('accounts', self.name, 'ignore_ssl_errors').split(): pem = OpenSSL.crypto.dump_certificate( OpenSSL.crypto.FILETYPE_PEM, cert).decode('utf-8') txt = _('The authenticity of the %s certificate could be ' 'invalid.\nThe certificate does not cover this domain.') %\ hostname - gajim.nec.push_incoming_event(SSLErrorEvent(None, conn=self, + app.nec.push_incoming_event(SSLErrorEvent(None, conn=self, error_text=txt, error_num=100, cert=pem, fingerprint_sha1=fingerprint_sha1, fingerprint_sha256=fingerprint_sha256, certificate=cert)) return True self._register_handlers(con, con_type) - auth_mechs = gajim.config.get_per('accounts', self.name, 'authentication_mechanisms') + auth_mechs = app.config.get_per('accounts', self.name, 'authentication_mechanisms') auth_mechs = auth_mechs.split() for mech in auth_mechs: if mech not in nbxmpp.auth_nb.SASL_AUTHENTICATION_MECHANISMS | set(['XEP-0078']): @@ -1412,31 +1412,31 @@ class Connection(CommonConnection, ConnectionHandlers): def ssl_certificate_accepted(self): if not self.connection: self.disconnect(on_purpose=True) - gajim.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, + app.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, title=_('Could not connect to account %s') % self.name, msg=_('Connection with account %s has been lost. Retry ' 'connecting.') % self.name)) return - if gajim.config.get_per('accounts', self.name, 'anonymous_auth'): + if app.config.get_per('accounts', self.name, 'anonymous_auth'): name = None else: - name = gajim.config.get_per('accounts', self.name, 'name') + name = app.config.get_per('accounts', self.name, 'name') self._register_handlers(self.connection, 'ssl') self.connection.auth(name, self.password, self.server_resource, 1, self.__on_auth) def _register_handlers(self, con, con_type): self.peerhost = con.get_peerhost() - gajim.con_types[self.name] = con_type + app.con_types[self.name] = con_type # notify the gui about con_type - gajim.nec.push_incoming_event(ConnectionTypeEvent(None, + app.nec.push_incoming_event(ConnectionTypeEvent(None, conn=self, connection_type=con_type)) ConnectionHandlers._register_handlers(self, con, con_type) def __on_auth(self, con, auth): if not con: self.disconnect(on_purpose=True) - gajim.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, + app.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, title=_('Could not connect to "%s"') % self._hostname, msg=_('Check your connection or try again later.'))) if self.on_connect_auth: @@ -1451,29 +1451,29 @@ class Connection(CommonConnection, ConnectionHandlers): if hasattr(con, 'Resource'): self.server_resource = con.Resource self.registered_name = con._registered_name - if gajim.config.get_per('accounts', self.name, 'anonymous_auth'): + if app.config.get_per('accounts', self.name, 'anonymous_auth'): # Get jid given by server - old_jid = gajim.get_jid_from_account(self.name) - gajim.config.set_per('accounts', self.name, 'name', con.User) - new_jid = gajim.get_jid_from_account(self.name) - gajim.nec.push_incoming_event(AnonymousAuthEvent(None, + old_jid = app.get_jid_from_account(self.name) + app.config.set_per('accounts', self.name, 'name', con.User) + new_jid = app.get_jid_from_account(self.name) + app.nec.push_incoming_event(AnonymousAuthEvent(None, conn=self, old_jid=old_jid, new_jid=new_jid)) if auth: - self.last_io = gajim.idlequeue.current_time() + self.last_io = app.idlequeue.current_time() self.connected = 2 self.retrycount = 0 if self.on_connect_auth: self.on_connect_auth(con) self.on_connect_auth = None else: - if not gajim.config.get_per('accounts', self.name, 'savepass'): + if not app.config.get_per('accounts', self.name, 'savepass'): # Forget password, it's wrong self.password = None - gajim.log.debug("Couldn't authenticate to %s" % self._hostname) + app.log.debug("Couldn't authenticate to %s" % self._hostname) self.disconnect(on_purpose = True) - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show='offline')) - gajim.nec.push_incoming_event(InformationEvent(None, conn=self, + app.nec.push_incoming_event(InformationEvent(None, conn=self, level='error', pri_txt=_('Authentication failed with "%s"') % \ self._hostname, sec_txt=_('Please check your login and password' ' for correctness.'))) @@ -1487,7 +1487,7 @@ class Connection(CommonConnection, ConnectionHandlers): stanza.setAttr('xml:lang', self.lang) def get_privacy_lists(self): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return nbxmpp.features_nb.getPrivacyLists(self.connection) @@ -1507,15 +1507,15 @@ class Connection(CommonConnection, ConnectionHandlers): server to detect connection failure at application level If control is set, display result there """ - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return id_ = self.connection.getAnID() if pingTo: to = pingTo.get_full_jid() - gajim.nec.push_incoming_event(PingSentEvent(None, conn=self, + app.nec.push_incoming_event(PingSentEvent(None, conn=self, contact=pingTo)) else: - to = gajim.config.get_per('accounts', self.name, 'hostname') + to = app.config.get_per('accounts', self.name, 'hostname') self.awaiting_xmpp_ping_id = id_ iq = nbxmpp.Iq('get', to=to) iq.addChild(name='ping', namespace=nbxmpp.NS_PING) @@ -1523,34 +1523,34 @@ class Connection(CommonConnection, ConnectionHandlers): def _on_response(resp): timePong = time.time() if not nbxmpp.isResultNode(resp): - gajim.nec.push_incoming_event(PingErrorEvent(None, conn=self, + app.nec.push_incoming_event(PingErrorEvent(None, conn=self, contact=pingTo)) return timeDiff = round(timePong - timePing, 2) - gajim.nec.push_incoming_event(PingReplyEvent(None, conn=self, + app.nec.push_incoming_event(PingReplyEvent(None, conn=self, contact=pingTo, seconds=timeDiff, control=control)) if pingTo: timePing = time.time() self.connection.SendAndCallForResponse(iq, _on_response) else: self.connection.SendAndCallForResponse(iq, self._on_xmpp_ping_answer) - gajim.idlequeue.set_alarm(self.check_pingalive, gajim.config.get_per( + app.idlequeue.set_alarm(self.check_pingalive, app.config.get_per( 'accounts', self.name, 'time_for_ping_alive_answer')) def get_active_default_lists(self): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return nbxmpp.features_nb.getActiveAndDefaultPrivacyLists(self.connection) def del_privacy_list(self, privacy_list): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return def _on_del_privacy_list_result(result): if result: - gajim.nec.push_incoming_event(PrivacyListRemovedEvent(None, + app.nec.push_incoming_event(PrivacyListRemovedEvent(None, conn=self, list_name=privacy_list)) else: - gajim.nec.push_incoming_event(InformationEvent(None, conn=self, + app.nec.push_incoming_event(InformationEvent(None, conn=self, level='error', pri_txt=_('Error while removing privacy ' 'list'), sec_txt=_('Privacy list %s has not been removed. ' 'It is maybe active in one of your connected resources. ' @@ -1559,23 +1559,23 @@ class Connection(CommonConnection, ConnectionHandlers): _on_del_privacy_list_result) def get_privacy_list(self, title): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return nbxmpp.features_nb.getPrivacyList(self.connection, title) def set_privacy_list(self, listname, tags): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return nbxmpp.features_nb.setPrivacyList(self.connection, listname, tags) def set_active_list(self, listname): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return nbxmpp.features_nb.setActivePrivacyList(self.connection, listname, 'active') def set_default_list(self, listname): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return nbxmpp.features_nb.setDefaultPrivacyList(self.connection, listname) @@ -1592,15 +1592,15 @@ class Connection(CommonConnection, ConnectionHandlers): def build_invisible_rule(self): iq = nbxmpp.Iq('set', nbxmpp.NS_PRIVACY, xmlns='') l = iq.setQuery().setTag('list', {'name': 'invisible'}) - if self.name in gajim.interface.status_sent_to_groups and \ - len(gajim.interface.status_sent_to_groups[self.name]) > 0: - for group in gajim.interface.status_sent_to_groups[self.name]: + if self.name in app.interface.status_sent_to_groups and \ + len(app.interface.status_sent_to_groups[self.name]) > 0: + for group in app.interface.status_sent_to_groups[self.name]: i = l.setTag('item', {'type': 'group', 'value': group, 'action': 'allow', 'order': '1'}) i.setTag('presence-out') - if self.name in gajim.interface.status_sent_to_users and \ - len(gajim.interface.status_sent_to_users[self.name]) > 0: - for jid in gajim.interface.status_sent_to_users[self.name]: + if self.name in app.interface.status_sent_to_users and \ + len(app.interface.status_sent_to_users[self.name]) > 0: + for jid in app.interface.status_sent_to_users[self.name]: i = l.setTag('item', {'type': 'jid', 'value': jid, 'action': 'allow', 'order': '2'}) i.setTag('presence-out') @@ -1609,7 +1609,7 @@ class Connection(CommonConnection, ConnectionHandlers): return iq def set_invisible_rule(self): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = self.build_invisible_rule() self.connection.send(iq) @@ -1675,8 +1675,8 @@ class Connection(CommonConnection, ConnectionHandlers): self.del_privacy_list(self.privacy_default_list) else: self.set_privacy_list(self.privacy_default_list, self.new_blocked_list) - if not gajim.interface.roster.regroup: - show = gajim.SHOW_LIST[self.connected] + if not app.interface.roster.regroup: + show = app.SHOW_LIST[self.connected] else: # accounts merged show = helpers.get_global_show() if show == 'invisible': @@ -1718,8 +1718,8 @@ class Connection(CommonConnection, ConnectionHandlers): self.del_privacy_list(self.privacy_default_list) else: self.set_privacy_list(self.privacy_default_list, self.new_blocked_list) - if not gajim.interface.roster.regroup: - show = gajim.SHOW_LIST[self.connected] + if not app.interface.roster.regroup: + show = app.SHOW_LIST[self.connected] else: # accounts merged show = helpers.get_global_show() if show == 'invisible': @@ -1728,12 +1728,12 @@ class Connection(CommonConnection, ConnectionHandlers): self.send_custom_status(show, self.status, contact.jid) def send_invisible_presence(self, msg, signed, initial = False): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return if not self.privacy_rules_supported: - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, - show=gajim.SHOW_LIST[self.connected])) - gajim.nec.push_incoming_event(InformationEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, + show=app.SHOW_LIST[self.connected])) + app.nec.push_incoming_event(InformationEvent(None, conn=self, level='error', pri_txt=_('Invisibility not supported'), sec_txt=_('Account %s doesn\'t support invisibility.') % \ self.name)) @@ -1759,9 +1759,9 @@ class Connection(CommonConnection, ConnectionHandlers): return # active the privacy rule self.set_active_list('invisible') - self.connected = gajim.SHOW_LIST.index('invisible') + self.connected = app.SHOW_LIST.index('invisible') self.status = msg - priority = gajim.get_priority(self.name, 'invisible') + priority = app.get_priority(self.name, 'invisible') p = nbxmpp.Presence(priority=priority) p = self.add_sha(p, True) if msg: @@ -1770,7 +1770,7 @@ class Connection(CommonConnection, ConnectionHandlers): p.setTag(nbxmpp.NS_SIGNED + ' x').setData(signed) self.connection.send(p) self.priority = priority - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show='invisible')) if initial: # ask our VCard @@ -1783,10 +1783,10 @@ class Connection(CommonConnection, ConnectionHandlers): self.get_annotations() # Inform GUI we just signed in - gajim.nec.push_incoming_event(SignedInEvent(None, conn=self)) + app.nec.push_incoming_event(SignedInEvent(None, conn=self)) def get_signed_presence(self, msg, callback = None): - if gajim.config.get_per('accounts', self.name, 'gpg_sign_presence'): + if app.config.get_per('accounts', self.name, 'gpg_sign_presence'): return self.get_signed_msg(msg, callback) return '' @@ -1802,7 +1802,7 @@ class Connection(CommonConnection, ConnectionHandlers): def _discover_server_at_connection(self, con): self.connection = con - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return self.connection.set_send_timeout(self.keepalives, self.send_keepalive) self.connection.set_send_timeout2(self.pingalives, self.sendPing) @@ -1813,15 +1813,15 @@ class Connection(CommonConnection, ConnectionHandlers): # If we are not resuming, we ask for discovery info # and archiving preferences if not self.sm.supports_sm or (not self.sm.resuming and self.sm.enabled): - our_jid = gajim.get_jid_from_account(self.name) - our_server = gajim.config.get_per('accounts', self.name, 'hostname') + our_jid = app.get_jid_from_account(self.name) + our_server = app.config.get_per('accounts', self.name, 'hostname') self.discoverInfo(our_jid, id_prefix='Gajim_') self.discoverInfo(our_server, id_prefix='Gajim_') self.sm.resuming = False # back to previous state # Discover Stun server(s) - hostname = gajim.config.get_per('accounts', self.name, 'hostname') - gajim.resolver.resolve('_stun._udp.' + helpers.idn_to_ascii(hostname), + hostname = app.config.get_per('accounts', self.name, 'hostname') + app.resolver.resolve('_stun._udp.' + helpers.idn_to_ascii(hostname), self._on_stun_resolved) def _on_stun_resolved(self, host, result_array): @@ -1829,7 +1829,7 @@ class Connection(CommonConnection, ConnectionHandlers): self._stun_servers = self._hosts = [i for i in result_array] def _request_privacy(self): - if not gajim.account_is_connected(self.name) or not self.connection: + if not app.account_is_connected(self.name) or not self.connection: return iq = nbxmpp.Iq('get', nbxmpp.NS_PRIVACY, xmlns='') id_ = self.connection.getAnID() @@ -1848,9 +1848,9 @@ class Connection(CommonConnection, ConnectionHandlers): # Trying to login as invisible but privacy list not # supported self.disconnect(on_purpose=True) - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show='offline')) - gajim.nec.push_incoming_event(InformationEvent(None, + app.nec.push_incoming_event(InformationEvent(None, conn=self, level='error', pri_txt=_('Invisibility not ' 'supported'), sec_txt=_('Account %s doesn\'t support ' 'invisibility.') % self.name)) @@ -1869,7 +1869,7 @@ class Connection(CommonConnection, ConnectionHandlers): def _nec_agent_info_error_received(self, obj): if obj.conn.name != self.name: return - hostname = gajim.config.get_per('accounts', self.name, 'hostname') + hostname = app.config.get_per('accounts', self.name, 'hostname') if obj.id_[:6] == 'Gajim_' and obj.fjid == hostname: self._continue_connection_request_privacy() @@ -1889,13 +1889,13 @@ class Connection(CommonConnection, ConnectionHandlers): and 'type' in identity and identity['type'] == 'text': is_muc = True - if transport_type != '' and obj.fjid not in gajim.transport_type: - gajim.transport_type[obj.fjid] = transport_type - gajim.logger.save_transport_type(obj.fjid, transport_type) + if transport_type != '' and obj.fjid not in app.transport_type: + app.transport_type[obj.fjid] = transport_type + app.logger.save_transport_type(obj.fjid, transport_type) if obj.id_[:6] == 'Gajim_': - hostname = gajim.config.get_per('accounts', self.name, 'hostname') - our_jid = gajim.get_jid_from_account(self.name) + hostname = app.config.get_per('accounts', self.name, 'hostname') + our_jid = app.get_jid_from_account(self.name) if obj.fjid == our_jid: if nbxmpp.NS_MAM_2 in obj.features: @@ -1911,7 +1911,7 @@ class Connection(CommonConnection, ConnectionHandlers): if obj.fjid == hostname: if nbxmpp.NS_GMAILNOTIFY in obj.features: - gajim.gmail_domains.append(obj.fjid) + app.gmail_domains.append(obj.fjid) self.request_gmail_notifications() if nbxmpp.NS_SECLABEL in obj.features: self.seclabel_supported = True @@ -1937,7 +1937,7 @@ class Connection(CommonConnection, ConnectionHandlers): self.blocking_supported = True if nbxmpp.NS_ADDRESS in obj.features: self.addressing_supported = True - if nbxmpp.NS_CARBONS in obj.features and gajim.config.get_per( + if nbxmpp.NS_CARBONS in obj.features and app.config.get_per( 'accounts', self.name, 'enable_message_carbons'): self.carbons_enabled = True # Server supports carbons, activate it @@ -1953,12 +1953,12 @@ class Connection(CommonConnection, ConnectionHandlers): if nbxmpp.NS_HTTPUPLOAD in obj.features: self.httpupload = True if nbxmpp.NS_BYTESTREAM in obj.features and \ - gajim.config.get_per('accounts', self.name, 'use_ft_proxies'): + app.config.get_per('accounts', self.name, 'use_ft_proxies'): our_fjid = helpers.parse_jid(our_jid + '/' + \ self.server_resource) - testit = gajim.config.get_per('accounts', self.name, + testit = app.config.get_per('accounts', self.name, 'test_ft_proxies_on_startup') - gajim.proxy65_manager.resolve(obj.fjid, self.connection, + app.proxy65_manager.resolve(obj.fjid, self.connection, our_fjid, default=self.name, testit=testit) if nbxmpp.NS_MUC in obj.features and is_muc: type_ = transport_type or 'jabber' @@ -1970,9 +1970,9 @@ class Connection(CommonConnection, ConnectionHandlers): self.available_transports[transport_type] = [obj.fjid] def send_custom_status(self, show, msg, jid): - if not show in gajim.SHOW_LIST: + if not show in app.SHOW_LIST: return -1 - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return sshow = helpers.get_xmpp_show(show) if not msg: @@ -1984,7 +1984,7 @@ class Connection(CommonConnection, ConnectionHandlers): p.setStatus(msg) else: signed = self.get_signed_presence(msg) - priority = gajim.get_priority(self.name, sshow) + priority = app.get_priority(self.name, sshow) p = nbxmpp.Presence(typ=None, priority=priority, show=sshow, to=jid) p = self.add_sha(p) if msg: @@ -2003,7 +2003,7 @@ class Connection(CommonConnection, ConnectionHandlers): def _update_status(self, show, msg, idle_time=None): xmpp_show = helpers.get_xmpp_show(show) - priority = gajim.get_priority(self.name, xmpp_show) + priority = app.get_priority(self.name, xmpp_show) p = nbxmpp.Presence(typ=None, priority=priority, show=xmpp_show) p = self.add_sha(p) if msg: @@ -2017,11 +2017,11 @@ class Connection(CommonConnection, ConnectionHandlers): if self.connection: self.connection.send(p) self.priority = priority - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show=show)) def send_motd(self, jid, subject='', msg='', xhtml=None): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return msg_iq = nbxmpp.Message(to=jid, body=msg, subject=subject, xhtml=xhtml) @@ -2039,9 +2039,9 @@ class Connection(CommonConnection, ConnectionHandlers): return config_key = '%s-%s' % (self.name, obj.jid) - encryption = gajim.config.get_per('encryption', config_key, 'encryption') + encryption = app.config.get_per('encryption', config_key, 'encryption') if encryption: - gajim.plugin_manager.extension_point( + app.plugin_manager.extension_point( 'encrypt' + encryption, self, obj, self.send_message) else: self.send_message(obj) @@ -2050,7 +2050,7 @@ class Connection(CommonConnection, ConnectionHandlers): obj.timestamp = time.time() obj.stanza_id = self.connection.send(obj.msg_iq, now=obj.now) - gajim.nec.push_incoming_event(MessageSentEvent( + app.nec.push_incoming_event(MessageSentEvent( None, conn=self, jid=obj.jid, message=obj.message, keyID=obj.keyID, chatstate=obj.chatstate, automatic_message=obj.automatic_message, stanza_id=obj.stanza_id, additional_data=obj.additional_data)) @@ -2069,7 +2069,7 @@ class Connection(CommonConnection, ConnectionHandlers): """ Send contacts with RosterX (Xep-0144) """ - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return if type_ == 'message': if len(contacts) == 1: @@ -2080,7 +2080,7 @@ class Connection(CommonConnection, ConnectionHandlers): for contact in contacts: msg += '\n "%s" (%s)' % (contact.get_full_jid(), contact.get_shown_name()) - stanza = nbxmpp.Message(to=gajim.get_jid_without_resource(fjid), + stanza = nbxmpp.Message(to=app.get_jid_without_resource(fjid), body=msg) elif type_ == 'iq': stanza = nbxmpp.Iq(to=fjid, typ='set') @@ -2099,14 +2099,14 @@ class Connection(CommonConnection, ConnectionHandlers): self.connection.send(stanza) def ack_subscribed(self, jid): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return log.debug('ack\'ing subscription complete for %s' % jid) p = nbxmpp.Presence(jid, 'subscribe') self.connection.send(p) def ack_unsubscribed(self, jid): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return log.debug('ack\'ing unsubscription complete for %s' % jid) p = nbxmpp.Presence(jid, 'unsubscribe') @@ -2114,7 +2114,7 @@ class Connection(CommonConnection, ConnectionHandlers): def request_subscription(self, jid, msg='', name='', groups=None, auto_auth=False, user_nick=''): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return if groups is None: groups = [] @@ -2141,34 +2141,34 @@ class Connection(CommonConnection, ConnectionHandlers): self.connection.send(p) def send_authorization(self, jid): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return p = nbxmpp.Presence(jid, 'subscribed') p = self.add_sha(p) self.connection.send(p) def refuse_authorization(self, jid): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return p = nbxmpp.Presence(jid, 'unsubscribed') p = self.add_sha(p) self.connection.send(p) def unsubscribe(self, jid, remove_auth = True): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return if remove_auth: self.connection.getRoster().delItem(jid) - jid_list = gajim.config.get_per('contacts') + jid_list = app.config.get_per('contacts') for j in jid_list: if j.startswith(jid): - gajim.config.del_per('contacts', j) + app.config.del_per('contacts', j) else: self.connection.getRoster().Unsubscribe(jid) self.update_contact(jid, '', []) def unsubscribe_agent(self, agent): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq('set', nbxmpp.NS_REGISTER, to=agent) iq.setQuery().setTag('remove') @@ -2212,7 +2212,7 @@ class Connection(CommonConnection, ConnectionHandlers): # There are still other way to try to connect return reason = _('Could not connect to "%s"') % self._hostname - gajim.nec.push_incoming_event(NewAccountNotConnectedEvent(None, + app.nec.push_incoming_event(NewAccountNotConnectedEvent(None, conn=self, reason=reason)) return self.on_connect_failure = None @@ -2224,10 +2224,10 @@ class Connection(CommonConnection, ConnectionHandlers): groupchat_jid is used when we want to send a request to a real jid and act as if the answer comes from the groupchat_jid """ - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return # If we are invisible, do not request - if self.connected == gajim.SHOW_LIST.index('invisible'): + if self.connected == app.SHOW_LIST.index('invisible'): self.dispatch('OS_INFO', (jid, resource, _('Not fetched because of invisible status'), _('Not fetched because of invisible status'))) return to_whom_jid = jid @@ -2246,10 +2246,10 @@ class Connection(CommonConnection, ConnectionHandlers): groupchat_jid is used when we want to send a request to a real jid and act as if the answer comes from the groupchat_jid """ - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return # If we are invisible, do not request - if self.connected == gajim.SHOW_LIST.index('invisible'): + if self.connected == app.SHOW_LIST.index('invisible'): self.dispatch('ENTITY_TIME', (jid, resource, _('Not fetched because of invisible status'))) return to_whom_jid = jid @@ -2266,7 +2266,7 @@ class Connection(CommonConnection, ConnectionHandlers): def request_gateway_prompt(self, jid, prompt=None): def _on_prompt_result(resp): - gajim.nec.push_incoming_event(GatewayPromptReceivedEvent(None, + app.nec.push_incoming_event(GatewayPromptReceivedEvent(None, conn=self, stanza=resp)) if prompt: typ_ = 'set' @@ -2282,7 +2282,7 @@ class Connection(CommonConnection, ConnectionHandlers): """ Get Gajim settings as described in XEP 0049 """ - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='get') iq2 = iq.addChild(name='query', namespace=nbxmpp.NS_PRIVATE) @@ -2290,17 +2290,17 @@ class Connection(CommonConnection, ConnectionHandlers): self.connection.send(iq) def seclabel_catalogue(self, to, callback): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return self.seclabel_catalogue_request(to, callback) - server = gajim.get_jid_from_account(self.name).split("@")[1] # Really, no better way? + server = app.get_jid_from_account(self.name).split("@")[1] # Really, no better way? iq = nbxmpp.Iq(typ='get', to=server) iq2 = iq.addChild(name='catalog', namespace=nbxmpp.NS_SECLABEL_CATALOG) iq2.setAttr('to', to) self.connection.send(iq) def _nec_privacy_list_received(self, obj): - roster = gajim.interface.roster + roster = app.interface.roster if obj.conn.name != self.name: return if obj.list_name != self.privacy_default_list: @@ -2337,7 +2337,7 @@ class Connection(CommonConnection, ConnectionHandlers): roster.draw_group(rule['value'], self.name) def _request_bookmarks_xml(self): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='get') iq2 = iq.addChild(name='query', namespace=nbxmpp.NS_PRIVATE) @@ -2355,14 +2355,14 @@ class Connection(CommonConnection, ConnectionHandlers): storage_type can be set to xml to force request to xml storage """ - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return if self.pubsub_supported and self.pubsub_publish_options_supported \ and storage_type != 'xml': self.send_pb_retrieve('', 'storage:bookmarks') # some server (ejabberd) are so slow to answer that we request via XML # if we don't get answer in the next 30 seconds - gajim.idlequeue.set_alarm(self._check_bookmarks_received, 30) + app.idlequeue.set_alarm(self._check_bookmarks_received, 30) else: self._request_bookmarks_xml() @@ -2374,7 +2374,7 @@ class Connection(CommonConnection, ConnectionHandlers): else it will be stored on both """ NS_GAJIM_BM = 'xmpp:gajim.org/bookmarks' - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Node(tag='storage', attrs={'xmlns': 'storage:bookmarks'}) for bm in self.bookmarks: @@ -2420,7 +2420,7 @@ class Connection(CommonConnection, ConnectionHandlers): Get Annonations from storage as described in XEP 0048, and XEP 0145 """ self.annotations = {} - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='get') iq2 = iq.addChild(name='query', namespace=nbxmpp.NS_PRIVATE) @@ -2431,7 +2431,7 @@ class Connection(CommonConnection, ConnectionHandlers): """ Set Annonations in private storage as described in XEP 0048, and XEP 0145 """ - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='set') iq2 = iq.addChild(name='query', namespace=nbxmpp.NS_PRIVATE) @@ -2447,7 +2447,7 @@ class Connection(CommonConnection, ConnectionHandlers): """ Get roster group delimiter from storage as described in XEP 0083 """ - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='get') iq2 = iq.addChild(name='query', namespace=nbxmpp.NS_PRIVATE) @@ -2461,7 +2461,7 @@ class Connection(CommonConnection, ConnectionHandlers): """ Set roster group delimiter to the storage namespace """ - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='set') iq2 = iq.addChild(name='query', namespace=nbxmpp.NS_PRIVATE) @@ -2474,7 +2474,7 @@ class Connection(CommonConnection, ConnectionHandlers): """ Get metacontacts list from storage as described in XEP 0049 """ - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='get') iq2 = iq.addChild(name='query', namespace=nbxmpp.NS_PRIVATE) @@ -2488,7 +2488,7 @@ class Connection(CommonConnection, ConnectionHandlers): """ Send meta contacts to the storage namespace """ - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='set') iq2 = iq.addChild(name='query', namespace=nbxmpp.NS_PRIVATE) @@ -2507,22 +2507,22 @@ class Connection(CommonConnection, ConnectionHandlers): features = self.connection.Dispatcher.Stream.features if features and features.getTag('ver', namespace=nbxmpp.NS_ROSTER_VER): - version = gajim.config.get_per('accounts', self.name, + version = app.config.get_per('accounts', self.name, 'roster_version') iq_id = self.connection.initRoster(version=version) self.awaiting_answers[iq_id] = (ROSTER_ARRIVED, ) def send_agent_status(self, agent, ptype): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return - show = helpers.get_xmpp_show(gajim.SHOW_LIST[self.connected]) + show = helpers.get_xmpp_show(app.SHOW_LIST[self.connected]) p = nbxmpp.Presence(to=agent, typ=ptype, show=show) p = self.add_sha(p, ptype != 'unavailable') self.connection.send(p) def send_captcha(self, jid, form_node): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='set', to=jid) captcha = iq.addChild(name='captcha', namespace=nbxmpp.NS_CAPTCHA) @@ -2530,17 +2530,17 @@ class Connection(CommonConnection, ConnectionHandlers): self.connection.send(iq) def check_unique_room_id_support(self, server, instance): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='get', to=server) iq.setAttr('id', 'unique1') iq.addChild('unique', namespace=nbxmpp.NS_MUC_UNIQUE) def _on_response(resp): if not nbxmpp.isResultNode(resp): - gajim.nec.push_incoming_event(UniqueRoomIdNotSupportedEvent( + app.nec.push_incoming_event(UniqueRoomIdNotSupportedEvent( None, conn=self, instance=instance, server=server)) return - gajim.nec.push_incoming_event(UniqueRoomIdSupportedEvent(None, + app.nec.push_incoming_event(UniqueRoomIdSupportedEvent(None, conn=self, instance=instance, server=server, room_id=resp.getTag('unique').getData())) self.connection.SendAndCallForResponse(iq, _on_response) @@ -2548,9 +2548,9 @@ class Connection(CommonConnection, ConnectionHandlers): def join_gc(self, nick, room_jid, password, change_nick=False, rejoin=False): # FIXME: This room JID needs to be normalized; see #1364 - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return - show = helpers.get_xmpp_show(gajim.SHOW_LIST[self.connected]) + show = helpers.get_xmpp_show(app.SHOW_LIST[self.connected]) if show == 'invisible': # Never join a room when invisible return @@ -2559,9 +2559,9 @@ class Connection(CommonConnection, ConnectionHandlers): if room_jid not in self.last_history_time: # Not in memory, get it from DB last_log = 0 - if gajim.config.should_log(self.name, room_jid): + if app.config.should_log(self.name, room_jid): # Check time first in the FAST table - last_log = gajim.logger.get_room_last_message_time( + last_log = app.logger.get_room_last_message_time( self.name, room_jid) if not last_log: last_log = 0 @@ -2577,16 +2577,16 @@ class Connection(CommonConnection, ConnectionHandlers): id_ = self.connection.getAnID() id_ = 'gajim_muc_' + id_ + '_' + h p.setID(id_) - if gajim.config.get('send_sha_in_gc_presence'): + if app.config.get('send_sha_in_gc_presence'): p = self.add_sha(p) self.add_lang(p) if not change_nick: t = p.setTag(nbxmpp.NS_MUC + ' x') tags = {} - timeout = gajim.config.get_per('rooms', room_jid, + timeout = app.config.get_per('rooms', room_jid, 'muc_restore_timeout') if timeout is None or timeout == -2: - timeout = gajim.config.get('muc_restore_timeout') + timeout = app.config.get('muc_restore_timeout') last_date = self.last_history_time[room_jid] if last_date == 0 and timeout >= 0: last_date = time.time() - timeout * 60 @@ -2596,9 +2596,9 @@ class Connection(CommonConnection, ConnectionHandlers): last_date)) tags['since'] = last_date - nb = gajim.config.get_per('rooms', room_jid, 'muc_restore_lines') + nb = app.config.get_per('rooms', room_jid, 'muc_restore_lines') if nb is None or nb == -2: - nb = gajim.config.get('muc_restore_lines') + nb = app.config.get('muc_restore_lines') if nb >= 0: tags['maxstanzas'] = nb if tags: @@ -2610,10 +2610,10 @@ class Connection(CommonConnection, ConnectionHandlers): def _nec_gc_message_outgoing(self, obj): if obj.account != self.name: return - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return - if not obj.xhtml and gajim.config.get('rst_formatting_outgoing_messages'): + if not obj.xhtml and app.config.get('rst_formatting_outgoing_messages'): from gajim.common.rst_xhtml_generator import create_xhtml obj.xhtml = create_xhtml(obj.message) @@ -2636,23 +2636,23 @@ class Connection(CommonConnection, ConnectionHandlers): obj.msg_iq = msg_iq obj.conn = self - gajim.nec.push_incoming_event(GcStanzaMessageOutgoingEvent(None, **vars(obj))) + app.nec.push_incoming_event(GcStanzaMessageOutgoingEvent(None, **vars(obj))) def _nec_gc_stanza_message_outgoing(self, obj): if obj.conn.name != self.name: return config_key = '%s-%s' % (self.name, obj.jid) - encryption = gajim.config.get_per('encryption', config_key, 'encryption') + encryption = app.config.get_per('encryption', config_key, 'encryption') if encryption: - gajim.plugin_manager.extension_point( + app.plugin_manager.extension_point( 'gc_encrypt' + encryption, self, obj, self.send_gc_message) else: self.send_gc_message(obj) def send_gc_message(self, obj): obj.stanza_id = self.connection.send(obj.msg_iq) - gajim.nec.push_incoming_event(MessageSentEvent( + app.nec.push_incoming_event(MessageSentEvent( None, conn=self, jid=obj.jid, message=obj.message, keyID=None, chatstate=None, automatic_message=obj.automatic_message, stanza_id=obj.stanza_id, additional_data=obj.additional_data)) @@ -2660,13 +2660,13 @@ class Connection(CommonConnection, ConnectionHandlers): obj.callback(obj) def send_gc_subject(self, jid, subject): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return msg_iq = nbxmpp.Message(jid, typ='groupchat', subject=subject) self.connection.send(msg_iq) def request_gc_config(self, room_jid): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='get', queryNS=nbxmpp.NS_MUC_OWNER, to=room_jid) @@ -2674,7 +2674,7 @@ class Connection(CommonConnection, ConnectionHandlers): self.connection.send(iq) def destroy_gc_room(self, room_jid, reason = '', jid = ''): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='set', queryNS=nbxmpp.NS_MUC_OWNER, to=room_jid) @@ -2686,7 +2686,7 @@ class Connection(CommonConnection, ConnectionHandlers): self.connection.send(iq) def send_gc_status(self, nick, jid, show, status, auto=False): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return if show == 'invisible': show = 'offline' @@ -2701,12 +2701,12 @@ class Connection(CommonConnection, ConnectionHandlers): id_ = self.connection.getAnID() id_ = 'gajim_muc_' + id_ + '_' + h p.setID(id_) - if gajim.config.get('send_sha_in_gc_presence') and show != 'offline': + if app.config.get('send_sha_in_gc_presence') and show != 'offline': p = self.add_sha(p, ptype != 'unavailable') self.add_lang(p) if auto: global HAS_IDLE - if HAS_IDLE and gajim.config.get('autoaway'): + if HAS_IDLE and app.config.get('autoaway'): idle_sec = int(self.sleeper.getIdleSec()) idle_time = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(time.time() - idle_sec)) @@ -2724,13 +2724,13 @@ class Connection(CommonConnection, ConnectionHandlers): than get that date from DB. Save time that we have in mem in a small table (with fast access) """ - gajim.logger.set_room_last_message_time(room_jid, self.last_history_time[room_jid]) + app.logger.set_room_last_message_time(room_jid, self.last_history_time[room_jid]) def gc_set_role(self, room_jid, nick, role, reason=''): """ Role is for all the life of the room so it's based on nick """ - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='set', to=room_jid, queryNS=nbxmpp.NS_MUC_ADMIN) item = iq.setQuery().setTag('item') @@ -2744,7 +2744,7 @@ class Connection(CommonConnection, ConnectionHandlers): """ Affiliation is for all the life of the room so it's based on jid """ - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='set', to=room_jid, queryNS=nbxmpp.NS_MUC_ADMIN) item = iq.setQuery().setTag('item') @@ -2755,7 +2755,7 @@ class Connection(CommonConnection, ConnectionHandlers): self.connection.send(iq) def send_gc_affiliation_list(self, room_jid, users_dict): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='set', to=room_jid, queryNS=nbxmpp.NS_MUC_ADMIN) item = iq.setQuery() @@ -2767,7 +2767,7 @@ class Connection(CommonConnection, ConnectionHandlers): self.connection.send(iq) def get_affiliation_list(self, room_jid, affiliation): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='get', to=room_jid, queryNS=nbxmpp.NS_MUC_ADMIN) item = iq.setQuery().setTag('item') @@ -2775,7 +2775,7 @@ class Connection(CommonConnection, ConnectionHandlers): self.connection.send(iq) def send_gc_config(self, room_jid, form): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='set', to=room_jid, queryNS=nbxmpp.NS_MUC_OWNER) query = iq.setQuery() @@ -2784,10 +2784,10 @@ class Connection(CommonConnection, ConnectionHandlers): self.connection.send(iq) def change_password(self, password): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return - hostname = gajim.config.get_per('accounts', self.name, 'hostname') - username = gajim.config.get_per('accounts', self.name, 'name') + hostname = app.config.get_per('accounts', self.name, 'hostname') + username = app.config.get_per('accounts', self.name, 'name') iq = nbxmpp.Iq(typ='set', to=hostname) q = iq.setTag(nbxmpp.NS_REGISTER + ' query') q.setTagData('username', username) @@ -2795,17 +2795,17 @@ class Connection(CommonConnection, ConnectionHandlers): self.connection.send(iq) def get_password(self, callback, type_): - if gajim.config.get_per('accounts', self.name, 'anonymous_auth') and \ + if app.config.get_per('accounts', self.name, 'anonymous_auth') and \ type_ != 'ANONYMOUS': - gajim.nec.push_incoming_event(NonAnonymousServerErrorEvent(None, + app.nec.push_incoming_event(NonAnonymousServerErrorEvent(None, conn=self)) self._on_disconnected() return self.pasword_callback = (callback, type_) if type_ == 'X-MESSENGER-OAUTH2': - client_id = gajim.config.get_per('accounts', self.name, + client_id = app.config.get_per('accounts', self.name, 'oauth2_client_id') - refresh_token = gajim.config.get_per('accounts', self.name, + refresh_token = app.config.get_per('accounts', self.name, 'oauth2_refresh_token') if refresh_token: renew_URL = 'https://oauth.live.com/token?client_id=' \ @@ -2818,29 +2818,29 @@ class Connection(CommonConnection, ConnectionHandlers): if 'access_token' in dict_: self.set_password(dict_['access_token']) return - script_url = gajim.config.get_per('accounts', self.name, + script_url = app.config.get_per('accounts', self.name, 'oauth2_redirect_url') token_URL = 'https://oauth.live.com/authorize?client_id=' \ '%(client_id)s&scope=wl.messenger%%20wl.offline_access&' \ 'response_type=code&redirect_uri=%(script_url)s' % locals() helpers.launch_browser_mailer('url', token_URL) self.disconnect(on_purpose=True) - gajim.nec.push_incoming_event(Oauth2CredentialsRequiredEvent(None, + app.nec.push_incoming_event(Oauth2CredentialsRequiredEvent(None, conn=self)) return if self.password: self.set_password(self.password) return - gajim.nec.push_incoming_event(PasswordRequiredEvent(None, conn=self)) + app.nec.push_incoming_event(PasswordRequiredEvent(None, conn=self)) def set_password(self, password): self.password = password if self.pasword_callback: callback, type_ = self.pasword_callback if self._current_type == 'plain' and type_ == 'PLAIN' and \ - gajim.config.get_per('accounts', self.name, + app.config.get_per('accounts', self.name, 'warn_when_insecure_password'): - gajim.nec.push_incoming_event(InsecurePasswordEvent(None, + app.nec.push_incoming_event(InsecurePasswordEvent(None, conn=self)) return callback(password) @@ -2857,8 +2857,8 @@ class Connection(CommonConnection, ConnectionHandlers): # on_remove_success as a class property as pass it as an argument def _on_unregister_account_connect(con): self.on_connect_auth = None - if gajim.account_is_connected(self.name): - hostname = gajim.config.get_per('accounts', self.name, 'hostname') + if app.account_is_connected(self.name): + hostname = app.config.get_per('accounts', self.name, 'hostname') iq = nbxmpp.Iq(typ='set', to=hostname) id_ = self.connection.getAnID() iq.setID(id_) @@ -2867,7 +2867,7 @@ class Connection(CommonConnection, ConnectionHandlers): if result.getID() == id_: on_remove_success(True) return - gajim.nec.push_incoming_event(InformationEvent(None, + app.nec.push_incoming_event(InformationEvent(None, conn=self, level='error', pri_txt=_('Unregister failed'), sec_txt=_('Unregistration with server %(server)s ' @@ -2888,9 +2888,9 @@ class Connection(CommonConnection, ConnectionHandlers): """ Send invitation """ - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return - contact = gajim.contacts.get_contact_from_full_jid(self.name, to) + contact = app.contacts.get_contact_from_full_jid(self.name, to) if contact and contact.supports(nbxmpp.NS_CONFERENCE): # send direct invite message=nbxmpp.Message(to=to) @@ -2899,7 +2899,7 @@ class Connection(CommonConnection, ConnectionHandlers): attrs['reason'] = reason if continue_tag: attrs['continue'] = 'true' - password = gajim.gc_passwords.get(room, '') + password = app.gc_passwords.get(room, '') if password: attrs['password'] = password c = message.addChild(name='x', attrs=attrs, @@ -2919,7 +2919,7 @@ class Connection(CommonConnection, ConnectionHandlers): """ decline a groupchat invitation """ - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return message=nbxmpp.Message(to=room) c = message.addChild(name='x', namespace=nbxmpp.NS_MUC_USER) @@ -2932,7 +2932,7 @@ class Connection(CommonConnection, ConnectionHandlers): """ Request voice in a moderated room """ - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return message = nbxmpp.Message(to=room) @@ -2947,7 +2947,7 @@ class Connection(CommonConnection, ConnectionHandlers): self.connection.send(message) def check_pingalive(self): - if not gajim.config.get_per('accounts', self.name, 'active'): + if not app.config.get_per('accounts', self.name, 'active'): # Account may have been disabled return if self.awaiting_xmpp_ping_id: @@ -2956,7 +2956,7 @@ class Connection(CommonConnection, ConnectionHandlers): self.disconnectedReconnCB() def _reconnect_alarm(self): - if not gajim.config.get_per('accounts', self.name, 'active'): + if not app.config.get_per('accounts', self.name, 'active'): # Account may have been disabled return if self.time_to_reconnect: @@ -2978,12 +2978,12 @@ class Connection(CommonConnection, ConnectionHandlers): for i in form.keys(): item.setTagData(i, form[i]) def _on_response(resp): - gajim.nec.push_incoming_event(SearchResultReceivedEvent(None, + app.nec.push_incoming_event(SearchResultReceivedEvent(None, conn=self, stanza=resp)) self.connection.SendAndCallForResponse(iq, _on_response) def load_roster_from_db(self): - gajim.nec.push_incoming_event(RosterReceivedEvent(None, conn=self)) + app.nec.push_incoming_event(RosterReceivedEvent(None, conn=self)) # END Connection diff --git a/gajim/common/connection_handlers.py b/gajim/common/connection_handlers.py index b54da9a94..3b1fe4b30 100644 --- a/gajim/common/connection_handlers.py +++ b/gajim/common/connection_handlers.py @@ -43,7 +43,7 @@ from gajim.common import caps_cache as capscache from gajim.common.pep import LOCATION_DATA from gajim.common import helpers -from gajim.common import gajim +from gajim.common import app from gajim.common import exceptions from gajim.common import dataforms from gajim.common import jingle_xtls @@ -113,7 +113,7 @@ class ConnectionDisco: id_ = self.connection.getAnID() iq.setID(id_) # Wait the answer during 30 secondes - self.awaiting_timeouts[gajim.idlequeue.current_time() + 30] = (id_, + self.awaiting_timeouts[app.idlequeue.current_time() + 30] = (id_, _('Registration information for transport %s has not arrived in ' 'time') % agent) self.connection.SendAndCallForResponse(iq, self._ReceivedRegInfo, @@ -121,7 +121,7 @@ class ConnectionDisco: def _agent_registered_cb(self, con, resp, agent): if resp.getType() == 'result': - gajim.nec.push_incoming_event(InformationEvent(None, conn=self, + app.nec.push_incoming_event(InformationEvent(None, conn=self, level='info', pri_txt=_('Registration succeeded'), sec_txt=_( 'Registration with agent %s succeeded') % agent)) self.request_subscription(agent, auto_auth=True) @@ -131,7 +131,7 @@ class ConnectionDisco: p = self.add_sha(p) self.connection.send(p) if resp.getType() == 'error': - gajim.nec.push_incoming_event(InformationEvent(None, conn=self, + app.nec.push_incoming_event(InformationEvent(None, conn=self, level='error', pri_txt=_('Registration failed'), sec_txt=_( 'Registration with agent %(agent)s failed with error %(error)s:' ' %(error_msg)s') % {'agent': agent, 'error': resp.getError(), @@ -183,7 +183,7 @@ class ConnectionDisco: iq = nbxmpp.Iq(to=frm, typ='result', queryNS=nbxmpp.NS_DISCO, frm=to) iq.setAttr('id', id_) query = iq.setTag('query') - query.setAttr('node', 'http://gajim.org#' + gajim.version.split('-', 1)[ + query.setAttr('node', 'http://gajim.org#' + app.version.split('-', 1)[ 0]) for f in (nbxmpp.NS_BYTESTREAM, nbxmpp.NS_SI, nbxmpp.NS_FILE, nbxmpp.NS_COMMANDS, nbxmpp.NS_JINGLE_FILE_TRANSFER_5, @@ -198,12 +198,12 @@ class ConnectionDisco: def _DiscoverItemsErrorCB(self, con, iq_obj): log.debug('DiscoverItemsErrorCB') - gajim.nec.push_incoming_event(AgentItemsErrorReceivedEvent(None, + app.nec.push_incoming_event(AgentItemsErrorReceivedEvent(None, conn=self, stanza=iq_obj)) def _DiscoverItemsCB(self, con, iq_obj): log.debug('DiscoverItemsCB') - gajim.nec.push_incoming_event(AgentItemsReceivedEvent(None, conn=self, + app.nec.push_incoming_event(AgentItemsReceivedEvent(None, conn=self, stanza=iq_obj)) def _DiscoverItemsGetCB(self, con, iq_obj): @@ -241,13 +241,13 @@ class ConnectionDisco: q = iq.setQuery() if node: q.setAttr('node', node) - q.addChild('identity', attrs=gajim.gajim_identity) - client_version = 'http://gajim.org#' + gajim.caps_hash[self.name] + q.addChild('identity', attrs=app.gajim_identity) + client_version = 'http://gajim.org#' + app.caps_hash[self.name] if node in (None, client_version): - for f in gajim.gajim_common_features: + for f in app.gajim_common_features: q.addChild('feature', attrs={'var': f}) - for f in gajim.gajim_optional_features[self.name]: + for f in app.gajim_optional_features[self.name]: q.addChild('feature', attrs={'var': f}) if q.getChildren(): @@ -256,14 +256,14 @@ class ConnectionDisco: def _DiscoverInfoErrorCB(self, con, iq_obj): log.debug('DiscoverInfoErrorCB') - gajim.nec.push_incoming_event(AgentInfoErrorReceivedEvent(None, + app.nec.push_incoming_event(AgentInfoErrorReceivedEvent(None, conn=self, stanza=iq_obj)) def _DiscoverInfoCB(self, con, iq_obj): log.debug('DiscoverInfoCB') if not self.connection or self.connected < 2: return - gajim.nec.push_incoming_event(AgentInfoReceivedEvent(None, conn=self, + app.nec.push_incoming_event(AgentInfoReceivedEvent(None, conn=self, stanza=iq_obj)) class ConnectionVcard: @@ -286,7 +286,7 @@ class ConnectionVcard: c = p.setTag('c', namespace=nbxmpp.NS_CAPS) c.setAttr('hash', 'sha-1') c.setAttr('node', 'http://gajim.org') - c.setAttr('ver', gajim.caps_hash[self.name]) + c.setAttr('ver', app.caps_hash[self.name]) return p def _node_to_dict(self, node): @@ -308,9 +308,9 @@ class ConnectionVcard: return dict_ def _save_vcard_to_hd(self, full_jid, card): - jid, nick = gajim.get_room_and_nick_from_fjid(full_jid) + jid, nick = app.get_room_and_nick_from_fjid(full_jid) puny_jid = helpers.sanitize_filename(jid) - path = os.path.join(gajim.VCARD_PATH, puny_jid) + path = os.path.join(app.VCARD_PATH, puny_jid) if jid in self.room_jids or os.path.isdir(path): if not nick: return @@ -321,7 +321,7 @@ class ConnectionVcard: if not os.path.isdir(path): os.mkdir(path, 0o700) puny_nick = helpers.sanitize_filename(nick) - path_to_file = os.path.join(gajim.VCARD_PATH, puny_jid, puny_nick) + path_to_file = os.path.join(app.VCARD_PATH, puny_jid, puny_nick) else: path_to_file = path try: @@ -329,7 +329,7 @@ class ConnectionVcard: fil.write(str(card)) fil.close() except IOError as e: - gajim.nec.push_incoming_event(InformationEvent(None, conn=self, + app.nec.push_incoming_event(InformationEvent(None, conn=self, level='error', pri_txt=_('Disk Write Error'), sec_txt=str(e))) def get_cached_vcard(self, fjid, is_fake_jid=False): @@ -338,13 +338,13 @@ class ConnectionVcard: Return {} if vcard was too old. Return None if we don't have cached vcard. """ - jid, nick = gajim.get_room_and_nick_from_fjid(fjid) + jid, nick = app.get_room_and_nick_from_fjid(fjid) puny_jid = helpers.sanitize_filename(jid) if is_fake_jid: puny_nick = helpers.sanitize_filename(nick) - path_to_file = os.path.join(gajim.VCARD_PATH, puny_jid, puny_nick) + path_to_file = os.path.join(app.VCARD_PATH, puny_jid, puny_nick) else: - path_to_file = os.path.join(gajim.VCARD_PATH, puny_jid) + path_to_file = os.path.join(app.VCARD_PATH, puny_jid) if not os.path.isfile(path_to_file): return None # We have the vcard cached @@ -368,7 +368,7 @@ class ConnectionVcard: # user change his vcard so don't use the cached one return {} vcard['jid'] = jid - vcard['resource'] = gajim.get_resource_from_jid(fjid) + vcard['resource'] = app.get_resource_from_jid(fjid) return vcard def request_vcard(self, jid=None, groupchat_jid=None): @@ -390,10 +390,10 @@ class ConnectionVcard: iq.setID(id_) j = jid if not j: - j = gajim.get_jid_from_account(self.name) + j = app.get_jid_from_account(self.name) self.awaiting_answers[id_] = (VCARD_ARRIVED, j, groupchat_jid) if groupchat_jid: - room_jid = gajim.get_room_and_nick_from_fjid(groupchat_jid)[0] + room_jid = app.get_room_and_nick_from_fjid(groupchat_jid)[0] if not room_jid in self.room_jids: self.room_jids.append(room_jid) self.groupchat_jids[id_] = groupchat_jid @@ -423,24 +423,24 @@ class ConnectionVcard: iq.setID(id_) self.connection.send(iq) - our_jid = gajim.get_jid_from_account(self.name) + our_jid = app.get_jid_from_account(self.name) # Add the sha of the avatar if 'PHOTO' in vcard and isinstance(vcard['PHOTO'], dict) and \ 'BINVAL' in vcard['PHOTO']: photo = vcard['PHOTO']['BINVAL'] photo_decoded = base64.b64decode(photo.encode('utf-8')) - gajim.interface.save_avatar_files(our_jid, photo_decoded) + app.interface.save_avatar_files(our_jid, photo_decoded) avatar_sha = hashlib.sha1(photo_decoded).hexdigest() iq2.getTag('PHOTO').setTagData('SHA', avatar_sha) else: - gajim.interface.remove_avatar_files(our_jid) + app.interface.remove_avatar_files(our_jid) self.awaiting_answers[id_] = (VCARD_PUBLISHED, iq2) def _IqCB(self, con, iq_obj): id_ = iq_obj.getID() - gajim.nec.push_incoming_event(NetworkEvent('raw-iq-received', + app.nec.push_incoming_event(NetworkEvent('raw-iq-received', conn=self, stanza=iq_obj)) # Check if we were waiting a timeout for this id @@ -466,26 +466,26 @@ class ConnectionVcard: new_sha = '' # Save it to file - our_jid = gajim.get_jid_from_account(self.name) + our_jid = app.get_jid_from_account(self.name) self._save_vcard_to_hd(our_jid, vcard_iq) # Send new presence if sha changed and we are not invisible - if self.vcard_sha != new_sha and gajim.SHOW_LIST[ + if self.vcard_sha != new_sha and app.SHOW_LIST[ self.connected] != 'invisible': if not self.connection or self.connected < 2: del self.awaiting_answers[id_] return self.vcard_sha = new_sha - sshow = helpers.get_xmpp_show(gajim.SHOW_LIST[ + sshow = helpers.get_xmpp_show(app.SHOW_LIST[ self.connected]) p = nbxmpp.Presence(typ=None, priority=self.priority, show=sshow, status=self.status) p = self.add_sha(p) self.connection.send(p) - gajim.nec.push_incoming_event(VcardPublishedEvent(None, + app.nec.push_incoming_event(VcardPublishedEvent(None, conn=self)) elif iq_obj.getType() == 'error': - gajim.nec.push_incoming_event(VcardNotPublishedEvent(None, + app.nec.push_incoming_event(VcardNotPublishedEvent(None, conn=self)) del self.awaiting_answers[id_] elif self.awaiting_answers[id_][0] == VCARD_ARRIVED: @@ -497,7 +497,7 @@ class ConnectionVcard: if groupchat_jid: # We do as if it comes from the fake_jid frm = groupchat_jid - our_jid = gajim.get_jid_from_account(self.name) + our_jid = app.get_jid_from_account(self.name) if (not iq_obj.getTag('vCard') and iq_obj.getType() == 'result') or\ iq_obj.getType() == 'error': if id_ in self.groupchat_jids: @@ -506,21 +506,21 @@ class ConnectionVcard: if frm: # Write an empty file self._save_vcard_to_hd(frm, '') - jid, resource = gajim.get_room_and_nick_from_fjid(frm) + jid, resource = app.get_room_and_nick_from_fjid(frm) vcard = {'jid': jid, 'resource': resource} - gajim.nec.push_incoming_event(VcardReceivedEvent(None, + app.nec.push_incoming_event(VcardReceivedEvent(None, conn=self, vcard_dict=vcard)) del self.awaiting_answers[id_] elif self.awaiting_answers[id_][0] == AGENT_REMOVED: jid = self.awaiting_answers[id_][1] - gajim.nec.push_incoming_event(AgentRemovedEvent(None, conn=self, + app.nec.push_incoming_event(AgentRemovedEvent(None, conn=self, agent=jid)) del self.awaiting_answers[id_] elif self.awaiting_answers[id_][0] == METACONTACTS_ARRIVED: if not self.connection: return if iq_obj.getType() == 'result': - gajim.nec.push_incoming_event(MetacontactsReceivedEvent(None, + app.nec.push_incoming_event(MetacontactsReceivedEvent(None, conn=self, stanza=iq_obj)) else: if iq_obj.getErrorCode() not in ('403', '406', '404'): @@ -548,19 +548,19 @@ class ConnectionVcard: elif self.awaiting_answers[id_][0] == ROSTER_ARRIVED: if iq_obj.getType() == 'result': if not iq_obj.getTag('query'): - account_jid = gajim.get_jid_from_account(self.name) - roster_data = gajim.logger.get_roster(account_jid) + account_jid = app.get_jid_from_account(self.name) + roster_data = app.logger.get_roster(account_jid) roster = self.connection.getRoster(force=True) roster.setRaw(roster_data) self._getRoster() elif iq_obj.getType() == 'error': self.roster_supported = False - self.discoverItems(gajim.config.get_per('accounts', self.name, + self.discoverItems(app.config.get_per('accounts', self.name, 'hostname'), id_prefix='Gajim_') - if gajim.config.get_per('accounts', self.name, + if app.config.get_per('accounts', self.name, 'use_ft_proxies'): self.discover_ft_proxies() - gajim.nec.push_incoming_event(RosterReceivedEvent(None, + app.nec.push_incoming_event(RosterReceivedEvent(None, conn=self)) GLib.timeout_add_seconds(10, self.discover_servers) del self.awaiting_answers[id_] @@ -601,7 +601,7 @@ class ConnectionVcard: form_tag = conf.getTag('x', namespace=nbxmpp.NS_DATA) if form_tag: form = dataforms.ExtendForm(node=form_tag) - gajim.nec.push_incoming_event(PEPConfigReceivedEvent(None, + app.nec.push_incoming_event(PEPConfigReceivedEvent(None, conn=self, node=node, form=form)) def _vCardCB(self, con, vc): @@ -614,15 +614,15 @@ class ConnectionVcard: return id_ = vc.getID() frm_iq = vc.getFrom() - our_jid = gajim.get_jid_from_account(self.name) + our_jid = app.get_jid_from_account(self.name) resource = '' if id_ in self.groupchat_jids: who = self.groupchat_jids[id_] - frm, resource = gajim.get_room_and_nick_from_fjid(who) + frm, resource = app.get_room_and_nick_from_fjid(who) del self.groupchat_jids[id_] elif frm_iq: who = helpers.get_full_jid_from_iq(vc) - frm, resource = gajim.get_room_and_nick_from_fjid(who) + frm, resource = app.get_room_and_nick_from_fjid(who) else: who = frm = our_jid card = vc.getChildren()[0] @@ -648,7 +648,7 @@ class ConnectionVcard: # for dbus notifications puny_jid = helpers.sanitize_filename(frm) puny_nick = None - begin_path = os.path.join(gajim.AVATAR_PATH, puny_jid) + begin_path = os.path.join(app.AVATAR_PATH, puny_jid) frm_jid = frm if frm in self.room_jids: puny_nick = helpers.sanitize_filename(resource) @@ -660,11 +660,11 @@ class ConnectionVcard: if photo_decoded: avatar_file = begin_path + '_notif_size_colored.png' if frm_jid == our_jid and avatar_sha != self.vcard_sha: - gajim.interface.save_avatar_files(frm, photo_decoded, puny_nick) + app.interface.save_avatar_files(frm, photo_decoded, puny_nick) elif frm_jid != our_jid and (not os.path.exists(avatar_file) or \ frm_jid not in self.vcard_shas or \ avatar_sha != self.vcard_shas[frm_jid]): - gajim.interface.save_avatar_files(frm, photo_decoded, puny_nick) + app.interface.save_avatar_files(frm, photo_decoded, puny_nick) if avatar_sha: self.vcard_shas[frm_jid] = avatar_sha elif frm in self.vcard_shas: @@ -678,7 +678,7 @@ class ConnectionVcard: vcard['jid'] = frm vcard['resource'] = resource - gajim.nec.push_incoming_event(VcardReceivedEvent(None, conn=self, + app.nec.push_incoming_event(VcardReceivedEvent(None, conn=self, vcard_dict=vcard)) if frm_jid == our_jid: # we re-send our presence with sha if has changed and if we are @@ -686,11 +686,11 @@ class ConnectionVcard: if self.vcard_sha == avatar_sha: return self.vcard_sha = avatar_sha - if gajim.SHOW_LIST[self.connected] == 'invisible': + if app.SHOW_LIST[self.connected] == 'invisible': return if not self.connection: return - sshow = helpers.get_xmpp_show(gajim.SHOW_LIST[self.connected]) + sshow = helpers.get_xmpp_show(app.SHOW_LIST[self.connected]) p = nbxmpp.Presence(typ=None, priority=self.priority, show=sshow, status=self.status) p = self.add_sha(p) @@ -733,7 +733,7 @@ class ConnectionPEP(object): def _pubsubEventCB(self, xmpp_dispatcher, msg): ''' Called when we receive with pubsub event. ''' - gajim.nec.push_incoming_event(PEPReceivedEvent(None, conn=self, + app.nec.push_incoming_event(PEPReceivedEvent(None, conn=self, stanza=msg)) def send_activity(self, activity, subactivity=None, message=None): @@ -884,35 +884,35 @@ class ConnectionHandlersBase: # We decrypt GPG messages one after the other. Keep queue in mem self.gpg_messages_to_decrypt = [] - gajim.ged.register_event_handler('iq-error-received', ged.CORE, + app.ged.register_event_handler('iq-error-received', ged.CORE, self._nec_iq_error_received) - gajim.ged.register_event_handler('presence-received', ged.CORE, + app.ged.register_event_handler('presence-received', ged.CORE, self._nec_presence_received) - gajim.ged.register_event_handler('gc-presence-received', ged.CORE, + app.ged.register_event_handler('gc-presence-received', ged.CORE, self._nec_gc_presence_received) - gajim.ged.register_event_handler('message-received', ged.CORE, + app.ged.register_event_handler('message-received', ged.CORE, self._nec_message_received) - gajim.ged.register_event_handler('mam-message-received', ged.CORE, + app.ged.register_event_handler('mam-message-received', ged.CORE, self._nec_message_received) - gajim.ged.register_event_handler('decrypted-message-received', ged.CORE, + app.ged.register_event_handler('decrypted-message-received', ged.CORE, self._nec_decrypted_message_received) - gajim.ged.register_event_handler('gc-message-received', ged.CORE, + app.ged.register_event_handler('gc-message-received', ged.CORE, self._nec_gc_message_received) def cleanup(self): - gajim.ged.remove_event_handler('iq-error-received', ged.CORE, + app.ged.remove_event_handler('iq-error-received', ged.CORE, self._nec_iq_error_received) - gajim.ged.remove_event_handler('presence-received', ged.CORE, + app.ged.remove_event_handler('presence-received', ged.CORE, self._nec_presence_received) - gajim.ged.remove_event_handler('gc-presence-received', ged.CORE, + app.ged.remove_event_handler('gc-presence-received', ged.CORE, self._nec_gc_presence_received) - gajim.ged.remove_event_handler('message-received', ged.CORE, + app.ged.remove_event_handler('message-received', ged.CORE, self._nec_message_received) - gajim.ged.remove_event_handler('mam-message-received', ged.CORE, + app.ged.remove_event_handler('mam-message-received', ged.CORE, self._nec_message_received) - gajim.ged.remove_event_handler('decrypted-message-received', ged.CORE, + app.ged.remove_event_handler('decrypted-message-received', ged.CORE, self._nec_decrypted_message_received) - gajim.ged.remove_event_handler('gc-message-received', ged.CORE, + app.ged.remove_event_handler('gc-message-received', ged.CORE, self._nec_gc_message_received) def _nec_iq_error_received(self, obj): @@ -933,11 +933,11 @@ class ConnectionHandlersBase: obj.contact_list = [] - highest = gajim.contacts.get_contact_with_highest_priority(account, jid) + highest = app.contacts.get_contact_with_highest_priority(account, jid) obj.was_highest = (highest and highest.resource == resource) # Update contact - obj.contact_list = gajim.contacts.get_contacts(account, jid) + obj.contact_list = app.contacts.get_contacts(account, jid) obj.contact = None resources = [] for c in obj.contact_list: @@ -972,7 +972,7 @@ class ConnectionHandlersBase: obj.contact.idle_time == obj.idle_time: # no change return True else: - obj.contact = gajim.contacts.get_first_contact_from_jid(account, + obj.contact = app.contacts.get_first_contact_from_jid(account, jid) if not obj.contact: # Presence of another resource of our jid @@ -982,44 +982,44 @@ class ConnectionHandlersBase: # Ignore offline presence of unknown self resource if obj.new_show < 2: return - obj.contact = gajim.contacts.create_self_contact(jid=jid, + obj.contact = app.contacts.create_self_contact(jid=jid, account=account, show=obj.show, status=obj.status, priority=obj.prio, keyID=obj.keyID, resource=obj.resource) - gajim.contacts.add_contact(account, obj.contact) + app.contacts.add_contact(account, obj.contact) obj.contact_list.append(obj.contact) elif obj.contact.show in statuss: obj.old_show = statuss.index(obj.contact.show) if (resources != [''] and (len(obj.contact_list) != 1 or \ obj.contact_list[0].show not in ('not in roster', 'offline'))) and \ - not gajim.jid_is_transport(jid): + not app.jid_is_transport(jid): # Another resource of an existing contact connected obj.old_show = 0 - obj.contact = gajim.contacts.copy_contact(obj.contact) + obj.contact = app.contacts.copy_contact(obj.contact) obj.contact_list.append(obj.contact) obj.contact.resource = resource obj.need_add_in_roster = True - if not gajim.jid_is_transport(jid) and len(obj.contact_list) == 1: + if not app.jid_is_transport(jid) and len(obj.contact_list) == 1: # It's not an agent if obj.old_show == 0 and obj.new_show > 1: - if not jid in gajim.newly_added[account]: - gajim.newly_added[account].append(jid) - if jid in gajim.to_be_removed[account]: - gajim.to_be_removed[account].remove(jid) + if not jid in app.newly_added[account]: + app.newly_added[account].append(jid) + if jid in app.to_be_removed[account]: + app.to_be_removed[account].remove(jid) elif obj.old_show > 1 and obj.new_show == 0 and \ obj.conn.connected > 1: - if not jid in gajim.to_be_removed[account]: - gajim.to_be_removed[account].append(jid) - if jid in gajim.newly_added[account]: - gajim.newly_added[account].remove(jid) + if not jid in app.to_be_removed[account]: + app.to_be_removed[account].append(jid) + if jid in app.newly_added[account]: + app.newly_added[account].remove(jid) obj.need_redraw = True obj.contact.show = obj.show obj.contact.status = obj.status obj.contact.priority = obj.prio - attached_keys = gajim.config.get_per('accounts', account, + attached_keys = app.config.get_per('accounts', account, 'attached_gpg_keys').split() if jid in attached_keys: obj.contact.keyID = attached_keys[attached_keys.index(jid) + 1] @@ -1029,7 +1029,7 @@ class ConnectionHandlersBase: obj.contact.contact_nickname = obj.contact_nickname obj.contact.idle_time = obj.idle_time - if gajim.jid_is_transport(jid): + if app.jid_is_transport(jid): return # It isn't an agent @@ -1060,11 +1060,11 @@ class ConnectionHandlersBase: if sess.enable_encryption: sess.terminate_e2e() - if gajim.config.get('log_contact_status_changes') and \ - gajim.config.should_log(self.name, obj.jid): - show = gajim.logger.convert_show_values_to_db_api_values(obj.show) + if app.config.get('log_contact_status_changes') and \ + app.config.should_log(self.name, obj.jid): + show = app.logger.convert_show_values_to_db_api_values(obj.show) if show is not None: - gajim.logger.insert_into_logs(nbxmpp.JID(obj.jid).getStripped(), + app.logger.insert_into_logs(nbxmpp.JID(obj.jid).getStripped(), time_time(), KindConstant.STATUS, message=obj.status, @@ -1083,17 +1083,17 @@ class ConnectionHandlersBase: if obj.conn.name != self.name: return - gajim.plugin_manager.extension_point( + app.plugin_manager.extension_point( 'decrypt', self, obj, self._on_message_received) if not obj.encrypted: self._on_message_received(obj) def _on_message_received(self, obj): if isinstance(obj, MessageReceivedEvent): - gajim.nec.push_incoming_event( + app.nec.push_incoming_event( DecryptedMessageReceivedEvent(None, conn=self, msg_obj=obj)) else: - gajim.nec.push_incoming_event( + app.nec.push_incoming_event( MamDecryptedMessageReceivedEvent(None, **vars(obj))) def _nec_decrypted_message_received(self, obj): @@ -1102,9 +1102,9 @@ class ConnectionHandlersBase: # Receipt requested # TODO: We shouldn't answer if we're invisible! - contact = gajim.contacts.get_contact(self.name, obj.jid) + contact = app.contacts.get_contact(self.name, obj.jid) nick = obj.resource - gc_contact = gajim.contacts.get_gc_contact(self.name, obj.jid, nick) + gc_contact = app.contacts.get_gc_contact(self.name, obj.jid, nick) if obj.sent: jid_to = obj.stanza.getFrom() else: @@ -1114,12 +1114,12 @@ class ConnectionHandlersBase: reply = True else: fjid_to = helpers.parse_jid(str(jid_to)) - jid_to = gajim.get_jid_without_resource(fjid_to) - if jid_to == gajim.get_jid_from_account(self.name): + jid_to = app.get_jid_without_resource(fjid_to) + if jid_to == app.get_jid_from_account(self.name): reply = True - if obj.jid != gajim.get_jid_from_account(self.name): - if obj.receipt_request_tag and gajim.config.get_per('accounts', + if obj.jid != app.get_jid_from_account(self.name): + if obj.receipt_request_tag and app.config.get_per('accounts', self.name, 'answer_receipts') and ((contact and contact.sub \ not in ('to', 'none')) or gc_contact) and obj.mtype != 'error' and \ reply: @@ -1132,14 +1132,14 @@ class ConnectionHandlersBase: self.connection.send(receipt) # We got our message's receipt - if obj.receipt_received_tag and gajim.config.get_per('accounts', + if obj.receipt_received_tag and app.config.get_per('accounts', self.name, 'request_receipt'): ctrl = obj.session.control if not ctrl: # Received doesn't have the element # or control is not bound to session? # --> search for it - ctrl = gajim.interface.msg_win_mgr.search_control(obj.jid, + ctrl = app.interface.msg_win_mgr.search_control(obj.jid, obj.conn.name, obj.resource) if ctrl: @@ -1156,18 +1156,18 @@ class ConnectionHandlersBase: obj.session, obj.fjid, obj.timestamp) return True elif obj.mtype == 'groupchat': - gajim.nec.push_incoming_event(GcMessageReceivedEvent(None, + app.nec.push_incoming_event(GcMessageReceivedEvent(None, conn=self, msg_obj=obj)) return True def _nec_gc_message_received(self, obj): - if gajim.config.should_log(obj.conn.name, obj.jid) and not \ + if app.config.should_log(obj.conn.name, obj.jid) and not \ obj.timestamp < obj.conn.last_history_time[obj.jid] and obj.msgtxt and \ obj.nick: # if not obj.nick, it means message comes from room itself # usually it hold description and can be send at each connection # so don't store it in logs - gajim.logger.insert_into_logs(obj.jid, + app.logger.insert_into_logs(obj.jid, obj.timestamp, KindConstant.GC_MSG, message=obj.msgtxt, @@ -1189,13 +1189,13 @@ class ConnectionHandlersBase: subject = msg.getSubject() if session.is_loggable(): - gajim.logger.insert_into_logs(nbxmpp.JID(frm).getStripped(), + app.logger.insert_into_logs(nbxmpp.JID(frm).getStripped(), tim, KindConstant.ERROR, message=error_msg, subject=subject) - gajim.nec.push_incoming_event(MessageErrorEvent(None, conn=self, + app.nec.push_incoming_event(MessageErrorEvent(None, conn=self, fjid=frm, error_code=msg.getErrorCode(), error_msg=error_msg, msg=msgtxt, time_=tim, session=session, stanza=msg)) @@ -1203,8 +1203,8 @@ class ConnectionHandlersBase: """ Get all sessions for the given full jid """ - if not gajim.interface.is_pm_contact(jid, self.name): - jid = gajim.get_jid_without_resource(jid) + if not app.interface.is_pm_contact(jid, self.name): + jid = app.get_jid_without_resource(jid) try: return list(self.sessions[jid].values()) @@ -1219,9 +1219,9 @@ class ConnectionHandlersBase: pm = True jid = fjid - if not gajim.interface.is_pm_contact(fjid, self.name): + if not app.interface.is_pm_contact(fjid, self.name): pm = False - jid = gajim.get_jid_without_resource(fjid) + jid = app.get_jid_without_resource(fjid) session = self.find_session(jid, thread_id) @@ -1254,7 +1254,7 @@ class ConnectionHandlersBase: def delete_session(self, jid, thread_id): if not jid in self.sessions: - jid = gajim.get_jid_without_resource(jid) + jid = app.get_jid_without_resource(jid) if not jid in self.sessions: return @@ -1276,7 +1276,7 @@ class ConnectionHandlersBase: # filter out everything except the default session type chat_sessions = [s for s in idless if isinstance(s, - gajim.default_session_type)] + app.default_session_type)] if chat_sessions: # return the session that we last sent a message in @@ -1305,7 +1305,7 @@ class ConnectionHandlersBase: # filter out everything except the default session type chat_sessions = [s for s in sessions if isinstance(s, - gajim.default_session_type)] + app.default_session_type)] orphaned = [s for s in chat_sessions if not s.control] @@ -1324,14 +1324,14 @@ class ConnectionHandlersBase: type_ should be 'chat' or 'pm'. """ if not cls: - cls = gajim.default_session_type + cls = app.default_session_type sess = cls(self, nbxmpp.JID(jid), thread_id, type_) # determine if this session is a pm session # if not, discard the resource so that all sessions are stored bare if not type_ == 'pm': - jid = gajim.get_jid_without_resource(jid) + jid = app.get_jid_without_resource(jid) if not jid in self.sessions: self.sessions[jid] = {} @@ -1356,7 +1356,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): pubsub_connection=self) # Handle presences BEFORE caps - gajim.nec.register_incoming_event(PresenceReceivedEvent) + app.nec.register_incoming_event(PresenceReceivedEvent) ConnectionCaps.__init__(self, account=self.name, capscache=capscache.capscache, @@ -1391,62 +1391,62 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): self.gmail_last_tid = None self.gmail_last_time = None - gajim.nec.register_incoming_event(PrivateStorageBookmarksReceivedEvent) - gajim.nec.register_incoming_event(BookmarksReceivedEvent) - gajim.nec.register_incoming_event( + app.nec.register_incoming_event(PrivateStorageBookmarksReceivedEvent) + app.nec.register_incoming_event(BookmarksReceivedEvent) + app.nec.register_incoming_event( PrivateStorageRosternotesReceivedEvent) - gajim.nec.register_incoming_event(RosternotesReceivedEvent) - gajim.nec.register_incoming_event(StreamConflictReceivedEvent) - gajim.nec.register_incoming_event(StreamOtherHostReceivedEvent) - gajim.nec.register_incoming_event(MessageReceivedEvent) - gajim.nec.register_incoming_event(ArchivingErrorReceivedEvent) - gajim.nec.register_incoming_event( + app.nec.register_incoming_event(RosternotesReceivedEvent) + app.nec.register_incoming_event(StreamConflictReceivedEvent) + app.nec.register_incoming_event(StreamOtherHostReceivedEvent) + app.nec.register_incoming_event(MessageReceivedEvent) + app.nec.register_incoming_event(ArchivingErrorReceivedEvent) + app.nec.register_incoming_event( Archiving313PreferencesChangedReceivedEvent) - gajim.nec.register_incoming_event( + app.nec.register_incoming_event( ArchivingFinishedLegacyReceivedEvent) - gajim.nec.register_incoming_event( + app.nec.register_incoming_event( ArchivingFinishedReceivedEvent) - gajim.nec.register_incoming_event(NotificationEvent) + app.nec.register_incoming_event(NotificationEvent) - gajim.ged.register_event_handler('http-auth-received', ged.CORE, + app.ged.register_event_handler('http-auth-received', ged.CORE, self._nec_http_auth_received) - gajim.ged.register_event_handler('version-request-received', ged.CORE, + app.ged.register_event_handler('version-request-received', ged.CORE, self._nec_version_request_received) - gajim.ged.register_event_handler('last-request-received', ged.CORE, + app.ged.register_event_handler('last-request-received', ged.CORE, self._nec_last_request_received) - gajim.ged.register_event_handler('time-request-received', ged.CORE, + app.ged.register_event_handler('time-request-received', ged.CORE, self._nec_time_request_received) - gajim.ged.register_event_handler('time-revised-request-received', + app.ged.register_event_handler('time-revised-request-received', ged.CORE, self._nec_time_revised_request_received) - gajim.ged.register_event_handler('roster-set-received', + app.ged.register_event_handler('roster-set-received', ged.CORE, self._nec_roster_set_received) - gajim.ged.register_event_handler('private-storage-bookmarks-received', + app.ged.register_event_handler('private-storage-bookmarks-received', ged.CORE, self._nec_private_storate_bookmarks_received) - gajim.ged.register_event_handler('private-storage-rosternotes-received', + app.ged.register_event_handler('private-storage-rosternotes-received', ged.CORE, self._nec_private_storate_rosternotes_received) - gajim.ged.register_event_handler('roster-received', ged.CORE, + app.ged.register_event_handler('roster-received', ged.CORE, self._nec_roster_received) - gajim.ged.register_event_handler('iq-error-received', ged.CORE, + app.ged.register_event_handler('iq-error-received', ged.CORE, self._nec_iq_error_received) - gajim.ged.register_event_handler('gmail-new-mail-received', ged.CORE, + app.ged.register_event_handler('gmail-new-mail-received', ged.CORE, self._nec_gmail_new_mail_received) - gajim.ged.register_event_handler('ping-received', ged.CORE, + app.ged.register_event_handler('ping-received', ged.CORE, self._nec_ping_received) - gajim.ged.register_event_handler('subscribe-presence-received', + app.ged.register_event_handler('subscribe-presence-received', ged.CORE, self._nec_subscribe_presence_received) - gajim.ged.register_event_handler('subscribed-presence-received', + app.ged.register_event_handler('subscribed-presence-received', ged.CORE, self._nec_subscribed_presence_received) - gajim.ged.register_event_handler('subscribed-presence-received', + app.ged.register_event_handler('subscribed-presence-received', ged.POSTGUI, self._nec_subscribed_presence_received_end) - gajim.ged.register_event_handler('unsubscribed-presence-received', + app.ged.register_event_handler('unsubscribed-presence-received', ged.CORE, self._nec_unsubscribed_presence_received) - gajim.ged.register_event_handler('unsubscribed-presence-received', + app.ged.register_event_handler('unsubscribed-presence-received', ged.POSTGUI, self._nec_unsubscribed_presence_received_end) - gajim.ged.register_event_handler('agent-removed', ged.CORE, + app.ged.register_event_handler('agent-removed', ged.CORE, self._nec_agent_removed) - gajim.ged.register_event_handler('stream-other-host-received', ged.CORE, + app.ged.register_event_handler('stream-other-host-received', ged.CORE, self._nec_stream_other_host_received) - gajim.ged.register_event_handler('blocking', ged.CORE, + app.ged.register_event_handler('blocking', ged.CORE, self._nec_blocking) def cleanup(self): @@ -1454,45 +1454,45 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): ConnectionCaps.cleanup(self) ConnectionArchive313.cleanup(self) ConnectionPubSub.cleanup(self) - gajim.ged.remove_event_handler('http-auth-received', ged.CORE, + app.ged.remove_event_handler('http-auth-received', ged.CORE, self._nec_http_auth_received) - gajim.ged.remove_event_handler('version-request-received', ged.CORE, + app.ged.remove_event_handler('version-request-received', ged.CORE, self._nec_version_request_received) - gajim.ged.remove_event_handler('last-request-received', ged.CORE, + app.ged.remove_event_handler('last-request-received', ged.CORE, self._nec_last_request_received) - gajim.ged.remove_event_handler('time-request-received', ged.CORE, + app.ged.remove_event_handler('time-request-received', ged.CORE, self._nec_time_request_received) - gajim.ged.remove_event_handler('time-revised-request-received', + app.ged.remove_event_handler('time-revised-request-received', ged.CORE, self._nec_time_revised_request_received) - gajim.ged.remove_event_handler('roster-set-received', + app.ged.remove_event_handler('roster-set-received', ged.CORE, self._nec_roster_set_received) - gajim.ged.remove_event_handler('private-storage-bookmarks-received', + app.ged.remove_event_handler('private-storage-bookmarks-received', ged.CORE, self._nec_private_storate_bookmarks_received) - gajim.ged.remove_event_handler('private-storage-rosternotes-received', + app.ged.remove_event_handler('private-storage-rosternotes-received', ged.CORE, self._nec_private_storate_rosternotes_received) - gajim.ged.remove_event_handler('roster-received', ged.CORE, + app.ged.remove_event_handler('roster-received', ged.CORE, self._nec_roster_received) - gajim.ged.remove_event_handler('iq-error-received', ged.CORE, + app.ged.remove_event_handler('iq-error-received', ged.CORE, self._nec_iq_error_received) - gajim.ged.remove_event_handler('gmail-new-mail-received', ged.CORE, + app.ged.remove_event_handler('gmail-new-mail-received', ged.CORE, self._nec_gmail_new_mail_received) - gajim.ged.remove_event_handler('ping-received', ged.CORE, + app.ged.remove_event_handler('ping-received', ged.CORE, self._nec_ping_received) - gajim.ged.remove_event_handler('subscribe-presence-received', + app.ged.remove_event_handler('subscribe-presence-received', ged.CORE, self._nec_subscribe_presence_received) - gajim.ged.remove_event_handler('subscribed-presence-received', + app.ged.remove_event_handler('subscribed-presence-received', ged.CORE, self._nec_subscribed_presence_received) - gajim.ged.remove_event_handler('subscribed-presence-received', + app.ged.remove_event_handler('subscribed-presence-received', ged.POSTGUI, self._nec_subscribed_presence_received_end) - gajim.ged.remove_event_handler('unsubscribed-presence-received', + app.ged.remove_event_handler('unsubscribed-presence-received', ged.CORE, self._nec_unsubscribed_presence_received) - gajim.ged.remove_event_handler('unsubscribed-presence-received', + app.ged.remove_event_handler('unsubscribed-presence-received', ged.POSTGUI, self._nec_unsubscribed_presence_received_end) - gajim.ged.remove_event_handler('agent-removed', ged.CORE, + app.ged.remove_event_handler('agent-removed', ged.CORE, self._nec_agent_removed) - gajim.ged.remove_event_handler('stream-other-host-received', ged.CORE, + app.ged.remove_event_handler('stream-other-host-received', ged.CORE, self._nec_stream_other_host_received) - gajim.ged.remove_event_handler('blocking', ged.CORE, self._nec_blocking) + app.ged.remove_event_handler('blocking', ged.CORE, self._nec_blocking) def build_http_auth_answer(self, iq_obj, answer): if not self.connection or self.connected < 2: @@ -1516,32 +1516,32 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): def _HttpAuthCB(self, con, iq_obj): log.debug('HttpAuthCB') - gajim.nec.push_incoming_event(HttpAuthReceivedEvent(None, conn=self, + app.nec.push_incoming_event(HttpAuthReceivedEvent(None, conn=self, stanza=iq_obj)) raise nbxmpp.NodeProcessed def _ErrorCB(self, con, iq_obj): log.debug('ErrorCB') - gajim.nec.push_incoming_event(IqErrorReceivedEvent(None, conn=self, + app.nec.push_incoming_event(IqErrorReceivedEvent(None, conn=self, stanza=iq_obj)) def _nec_iq_error_received(self, obj): if obj.conn.name != self.name: return if obj.id_ in self.version_ids: - gajim.nec.push_incoming_event(VersionResultReceivedEvent(None, + app.nec.push_incoming_event(VersionResultReceivedEvent(None, conn=self, stanza=obj.stanza)) return True if obj.id_ in self.entity_time_ids: - gajim.nec.push_incoming_event(TimeResultReceivedEvent(None, + app.nec.push_incoming_event(TimeResultReceivedEvent(None, conn=self, stanza=obj.stanza)) return True if obj.id_ in self.disco_items_ids: - gajim.nec.push_incoming_event(AgentItemsErrorReceivedEvent(None, + app.nec.push_incoming_event(AgentItemsErrorReceivedEvent(None, conn=self, stanza=obj.stanza)) return True if obj.id_ in self.disco_info_ids: - gajim.nec.push_incoming_event(AgentInfoErrorReceivedEvent(None, + app.nec.push_incoming_event(AgentInfoErrorReceivedEvent(None, conn=self, stanza=obj.stanza)) return True @@ -1569,7 +1569,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): Private Data (XEP 048 and 049) """ log.debug('PrivateCB') - gajim.nec.push_incoming_event(PrivateStorageReceivedEvent(None, + app.nec.push_incoming_event(PrivateStorageReceivedEvent(None, conn=self, stanza=iq_obj)) def _SecLabelCB(self, con, iq_obj): @@ -1605,7 +1605,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): def _rosterSetCB(self, con, iq_obj): log.debug('rosterSetCB') - gajim.nec.push_incoming_event(RosterSetReceivedEvent(None, conn=self, + app.nec.push_incoming_event(RosterSetReceivedEvent(None, conn=self, stanza=iq_obj)) raise nbxmpp.NodeProcessed @@ -1614,33 +1614,33 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): return for jid in obj.items: item = obj.items[jid] - gajim.nec.push_incoming_event(RosterInfoEvent(None, conn=self, + app.nec.push_incoming_event(RosterInfoEvent(None, conn=self, jid=jid, nickname=item['name'], sub=item['sub'], ask=item['ask'], groups=item['groups'])) - account_jid = gajim.get_jid_from_account(self.name) - gajim.logger.add_or_update_contact(account_jid, jid, item['name'], + account_jid = app.get_jid_from_account(self.name) + app.logger.add_or_update_contact(account_jid, jid, item['name'], item['sub'], item['ask'], item['groups']) if obj.version: - gajim.config.set_per('accounts', self.name, 'roster_version', + app.config.set_per('accounts', self.name, 'roster_version', obj.version) def _VersionCB(self, con, iq_obj): log.debug('VersionCB') if not self.connection or self.connected < 2: return - gajim.nec.push_incoming_event(VersionRequestEvent(None, conn=self, + app.nec.push_incoming_event(VersionRequestEvent(None, conn=self, stanza=iq_obj)) raise nbxmpp.NodeProcessed def _nec_version_request_received(self, obj): if obj.conn.name != self.name: return - send_os = gajim.config.get_per('accounts', self.name, 'send_os_info') + send_os = app.config.get_per('accounts', self.name, 'send_os_info') if send_os: iq_obj = obj.stanza.buildReply('result') qp = iq_obj.getQuery() qp.setTagData('name', 'Gajim') - qp.setTagData('version', gajim.version) + qp.setTagData('version', app.version) qp.setTagData('os', helpers.get_os_info()) else: iq_obj = obj.stanza.buildReply('error') @@ -1653,7 +1653,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): log.debug('LastCB') if not self.connection or self.connected < 2: return - gajim.nec.push_incoming_event(LastRequestEvent(None, conn=self, + app.nec.push_incoming_event(LastRequestEvent(None, conn=self, stanza=iq_obj)) raise nbxmpp.NodeProcessed @@ -1661,7 +1661,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): global HAS_IDLE if obj.conn.name != self.name: return - if HAS_IDLE and gajim.config.get_per('accounts', self.name, + if HAS_IDLE and app.config.get_per('accounts', self.name, 'send_idle_time'): iq_obj = obj.stanza.buildReply('result') qp = iq_obj.setQuery() @@ -1675,21 +1675,21 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): def _VersionResultCB(self, con, iq_obj): log.debug('VersionResultCB') - gajim.nec.push_incoming_event(VersionResultReceivedEvent(None, + app.nec.push_incoming_event(VersionResultReceivedEvent(None, conn=self, stanza=iq_obj)) def _TimeCB(self, con, iq_obj): log.debug('TimeCB') if not self.connection or self.connected < 2: return - gajim.nec.push_incoming_event(TimeRequestEvent(None, conn=self, + app.nec.push_incoming_event(TimeRequestEvent(None, conn=self, stanza=iq_obj)) raise nbxmpp.NodeProcessed def _nec_time_request_received(self, obj): if obj.conn.name != self.name: return - if gajim.config.get_per('accounts', self.name, 'send_time_info'): + if app.config.get_per('accounts', self.name, 'send_time_info'): iq_obj = obj.stanza.buildReply('result') qp = iq_obj.setQuery() qp.setTagData('utc', strftime('%Y%m%dT%H:%M:%S', gmtime())) @@ -1706,14 +1706,14 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): log.debug('TimeRevisedCB') if not self.connection or self.connected < 2: return - gajim.nec.push_incoming_event(TimeRevisedRequestEvent(None, conn=self, + app.nec.push_incoming_event(TimeRevisedRequestEvent(None, conn=self, stanza=iq_obj)) raise nbxmpp.NodeProcessed def _nec_time_revised_request_received(self, obj): if obj.conn.name != self.name: return - if gajim.config.get_per('accounts', self.name, 'send_time_info'): + if app.config.get_per('accounts', self.name, 'send_time_info'): iq_obj = obj.stanza.buildReply('result') qp = iq_obj.setTag('time', namespace=nbxmpp.NS_TIME_REVISED) qp.setTagData('utc', strftime('%Y-%m-%dT%H:%M:%SZ', gmtime())) @@ -1730,7 +1730,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): def _TimeRevisedResultCB(self, con, iq_obj): log.debug('TimeRevisedResultCB') - gajim.nec.push_incoming_event(TimeResultReceivedEvent(None, conn=self, + app.nec.push_incoming_event(TimeResultReceivedEvent(None, conn=self, stanza=iq_obj)) def _gMailNewMailCB(self, con, iq_obj): @@ -1738,7 +1738,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): Called when we get notified of new mail messages in gmail account """ log.debug('gMailNewMailCB') - gajim.nec.push_incoming_event(GmailNewMailReceivedEvent(None, conn=self, + app.nec.push_incoming_event(GmailNewMailReceivedEvent(None, conn=self, stanza=iq_obj)) raise nbxmpp.NodeProcessed @@ -1748,7 +1748,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): if not self.connection or self.connected < 2: return # we'll now ask the server for the exact number of new messages - jid = gajim.get_jid_from_account(self.name) + jid = app.get_jid_from_account(self.name) log.debug('Got notification of new gmail e-mail on %s. Asking the ' 'server for more info.' % jid) iq = nbxmpp.Iq(typ='get') @@ -1767,7 +1767,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): in gmail account """ log.debug('gMailQueryCB') - gajim.nec.push_incoming_event(GMailQueryReceivedEvent(None, conn=self, + app.nec.push_incoming_event(GMailQueryReceivedEvent(None, conn=self, stanza=iq_obj)) raise nbxmpp.NodeProcessed @@ -1776,7 +1776,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): XEP-0144 Roster Item Echange """ log.debug('rosterItemExchangeCB') - gajim.nec.push_incoming_event(RosterItemExchangeEvent(None, conn=self, + app.nec.push_incoming_event(RosterItemExchangeEvent(None, conn=self, stanza=msg)) raise nbxmpp.NodeProcessed @@ -1786,12 +1786,12 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): """ log.debug('MessageCB') - gajim.nec.push_incoming_event(NetworkEvent('raw-message-received', + app.nec.push_incoming_event(NetworkEvent('raw-message-received', conn=self, stanza=msg, account=self.name)) def _dispatch_gc_msg_with_captcha(self, stanza, msg_obj): msg_obj.stanza = stanza - gajim.nec.push_incoming_event(GcMessageReceivedEvent(None, + app.nec.push_incoming_event(GcMessageReceivedEvent(None, conn=self, msg_obj=msg_obj)) def _on_bob_received(self, conn, result, cid): @@ -1848,27 +1848,27 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): Called when we receive a presence """ log.debug('PresenceCB') - gajim.nec.push_incoming_event(NetworkEvent('raw-pres-received', + app.nec.push_incoming_event(NetworkEvent('raw-pres-received', conn=self, stanza=prs)) def _nec_subscribe_presence_received(self, obj): account = obj.conn.name if account != self.name: return - if gajim.jid_is_transport(obj.fjid) and obj.fjid in \ + if app.jid_is_transport(obj.fjid) and obj.fjid in \ self.agent_registrations: self.agent_registrations[obj.fjid]['sub_received'] = True if not self.agent_registrations[obj.fjid]['roster_push']: # We'll reply after roster push result return True - if gajim.config.get_per('accounts', self.name, 'autoauth') or \ - gajim.jid_is_transport(obj.fjid) or obj.jid in self.jids_for_auto_auth \ + if app.config.get_per('accounts', self.name, 'autoauth') or \ + app.jid_is_transport(obj.fjid) or obj.jid in self.jids_for_auto_auth \ or obj.transport_auto_auth: if self.connection: p = nbxmpp.Presence(obj.fjid, 'subscribed') p = self.add_sha(p) self.connection.send(p) - if gajim.jid_is_transport(obj.fjid) or obj.transport_auto_auth: + if app.jid_is_transport(obj.fjid) or obj.transport_auto_auth: #TODO!?!? #self.show = 'offline' #self.status = 'offline' @@ -1900,7 +1900,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): self.subscribed_events[obj.jid] = \ self.subscribed_events[obj.jid][1:] if block: - gajim.config.set_per('account', self.name, 'dont_ack_subscription', + app.config.set_per('account', self.name, 'dont_ack_subscription', True) return True @@ -1908,7 +1908,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): account = obj.conn.name if account != self.name: return - if not gajim.config.get_per('accounts', account, + if not app.config.get_per('accounts', account, 'dont_ack_subscription'): self.ack_subscribed(obj.jid) @@ -1927,7 +1927,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): self.subscribed_events[obj.jid] = \ self.subscribed_events[obj.jid][1:] if block: - gajim.config.set_per('account', self.name, 'dont_ack_subscription', + app.config.set_per('account', self.name, 'dont_ack_subscription', True) return True @@ -1935,7 +1935,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): account = obj.conn.name if account != self.name: return - if not gajim.config.get_per('accounts', account, + if not app.config.get_per('accounts', account, 'dont_ack_subscription'): self.ack_unsubscribed(obj.jid) @@ -1947,26 +1947,26 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): (jid, obj.agent)) self.unsubscribe(jid) # Transport contacts can't have 2 resources - if jid in gajim.to_be_removed[self.name]: + if jid in app.to_be_removed[self.name]: # This way we'll really remove it - gajim.to_be_removed[self.name].remove(jid) + app.to_be_removed[self.name].remove(jid) def _StanzaArrivedCB(self, con, obj): - self.last_io = gajim.idlequeue.current_time() + self.last_io = app.idlequeue.current_time() def _MucOwnerCB(self, con, iq_obj): log.debug('MucOwnerCB') - gajim.nec.push_incoming_event(MucOwnerReceivedEvent(None, conn=self, + app.nec.push_incoming_event(MucOwnerReceivedEvent(None, conn=self, stanza=iq_obj)) def _MucAdminCB(self, con, iq_obj): log.debug('MucAdminCB') - gajim.nec.push_incoming_event(MucAdminReceivedEvent(None, conn=self, + app.nec.push_incoming_event(MucAdminReceivedEvent(None, conn=self, stanza=iq_obj)) def _IqPingCB(self, con, iq_obj): log.debug('IqPingCB') - gajim.nec.push_incoming_event(PingReceivedEvent(None, conn=self, + app.nec.push_incoming_event(PingReceivedEvent(None, conn=self, stanza=iq_obj)) raise nbxmpp.NodeProcessed @@ -2007,43 +2007,43 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): if not self.connection: return self.connection.getRoster(self._on_roster_set) - self.discoverItems(gajim.config.get_per('accounts', self.name, + self.discoverItems(app.config.get_per('accounts', self.name, 'hostname'), id_prefix='Gajim_') - if gajim.config.get_per('accounts', self.name, 'use_ft_proxies'): + if app.config.get_per('accounts', self.name, 'use_ft_proxies'): self.discover_ft_proxies() def discover_ft_proxies(self): - cfg_proxies = gajim.config.get_per('accounts', self.name, + cfg_proxies = app.config.get_per('accounts', self.name, 'file_transfer_proxies') - our_jid = helpers.parse_jid(gajim.get_jid_from_account(self.name) + \ + our_jid = helpers.parse_jid(app.get_jid_from_account(self.name) + \ '/' + self.server_resource) - testit = gajim.config.get_per('accounts', self.name, + testit = app.config.get_per('accounts', self.name, 'test_ft_proxies_on_startup') if cfg_proxies: proxies = [e.strip() for e in cfg_proxies.split(',')] for proxy in proxies: - gajim.proxy65_manager.resolve(proxy, self.connection, our_jid, + app.proxy65_manager.resolve(proxy, self.connection, our_jid, testit=testit) def discover_servers(self): if not self.connection: return servers = [] - for c in gajim.contacts.iter_contacts(self.name): - s = gajim.get_server_from_jid(c.jid) - if s not in servers and s not in gajim.transport_type: + for c in app.contacts.iter_contacts(self.name): + s = app.get_server_from_jid(c.jid) + if s not in servers and s not in app.transport_type: servers.append(s) for s in servers: self.discoverInfo(s) def _on_roster_set(self, roster): - gajim.nec.push_incoming_event(RosterReceivedEvent(None, conn=self, + app.nec.push_incoming_event(RosterReceivedEvent(None, conn=self, xmpp_roster=roster)) def _nec_roster_received(self, obj): if obj.conn.name != self.name: return - our_jid = gajim.get_jid_from_account(self.name) + our_jid = app.get_jid_from_account(self.name) if self.connected > 1 and self.continue_connect_info: msg = self.continue_connect_info[1] sign_msg = self.continue_connect_info[2] @@ -2053,7 +2053,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): signed = self.get_signed_presence(msg, self._send_first_presence) if signed is None: - gajim.nec.push_incoming_event(GPGPasswordRequiredEvent(None, + app.nec.push_incoming_event(GPGPasswordRequiredEvent(None, conn=self, callback=self._send_first_presence)) # _send_first_presence will be called when user enter # passphrase @@ -2063,21 +2063,21 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): if obj.received_from_server: for jid in obj.roster: - if jid != our_jid and gajim.jid_is_transport(jid) and \ - not gajim.get_transport_name_from_jid(jid): + if jid != our_jid and app.jid_is_transport(jid) and \ + not app.get_transport_name_from_jid(jid): # we can't determine which iconset to use self.discoverInfo(jid) - gajim.logger.replace_roster(self.name, obj.version, obj.roster) + app.logger.replace_roster(self.name, obj.version, obj.roster) - for contact in gajim.contacts.iter_contacts(self.name): + for contact in app.contacts.iter_contacts(self.name): if not contact.is_groupchat() and contact.jid not in obj.roster\ and contact.jid != our_jid: - gajim.nec.push_incoming_event(RosterInfoEvent(None, + app.nec.push_incoming_event(RosterInfoEvent(None, conn=self, jid=contact.jid, nickname=None, sub=None, ask=None, groups=())) for jid, info in obj.roster.items(): - gajim.nec.push_incoming_event(RosterInfoEvent(None, + app.nec.push_incoming_event(RosterInfoEvent(None, conn=self, jid=jid, nickname=info['name'], sub=info['subscription'], ask=info['ask'], groups=info['groups'])) @@ -2089,11 +2089,11 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): if sign_msg and not signed: signed = self.get_signed_presence(msg) if signed is None: - gajim.nec.push_incoming_event(BadGPGPassphraseEvent(None, + app.nec.push_incoming_event(BadGPGPassphraseEvent(None, conn=self)) self.USE_GPG = False signed = '' - self.connected = gajim.SHOW_LIST.index(show) + self.connected = app.SHOW_LIST.index(show) sshow = helpers.get_xmpp_show(show) # send our presence if show == 'invisible': @@ -2101,8 +2101,8 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): return if show not in ['offline', 'online', 'chat', 'away', 'xa', 'dnd']: return - priority = gajim.get_priority(self.name, sshow) - our_jid = helpers.parse_jid(gajim.get_jid_from_account(self.name)) + priority = app.get_priority(self.name, sshow) + our_jid = helpers.parse_jid(app.get_jid_from_account(self.name)) vcard = self.get_cached_vcard(our_jid) if vcard and 'PHOTO' in vcard and 'SHA' in vcard['PHOTO']: self.vcard_sha = vcard['PHOTO']['SHA'] @@ -2116,7 +2116,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): if self.connection: self.connection.send(p) self.priority = priority - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show=show)) if self.vcard_supported: # ask our VCard @@ -2129,7 +2129,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): self.get_annotations() # Inform GUI we just signed in - gajim.nec.push_incoming_event(SignedInEvent(None, conn=self)) + app.nec.push_incoming_event(SignedInEvent(None, conn=self)) self.send_awaiting_pep() self.continue_connect_info = None # hashes of already received messages @@ -2140,7 +2140,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): return # It's a gmail account, # inform the server that we want e-mail notifications - our_jid = helpers.parse_jid(gajim.get_jid_from_account(self.name)) + our_jid = helpers.parse_jid(app.get_jid_from_account(self.name)) log.debug(('%s is a gmail account. Setting option ' 'to get e-mail notifications on the server.') % (our_jid)) iq = nbxmpp.Iq(typ='set', to=our_jid) @@ -2159,7 +2159,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): def _SearchCB(self, con, iq_obj): log.debug('SearchCB') - gajim.nec.push_incoming_event(SearchFormReceivedEvent(None, + app.nec.push_incoming_event(SearchFormReceivedEvent(None, conn=self, stanza=iq_obj)) def _search_fields_received(self, con, iq_obj): @@ -2191,7 +2191,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): def _BlockingSetCB(self, con, iq_obj): log.debug('_BlockingSetCB') - gajim.nec.push_incoming_event(BlockingEvent(None, conn=self, + app.nec.push_incoming_event(BlockingEvent(None, conn=self, stanza=iq_obj)) raise nbxmpp.NodeProcessed @@ -2215,7 +2215,7 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): def _StreamCB(self, con, obj): log.debug('StreamCB') - gajim.nec.push_incoming_event(StreamReceivedEvent(None, + app.nec.push_incoming_event(StreamReceivedEvent(None, conn=self, stanza=obj)) def _register_handlers(self, con, con_type): diff --git a/gajim/common/connection_handlers_events.py b/gajim/common/connection_handlers_events.py index 88bf70520..58284f0c3 100644 --- a/gajim/common/connection_handlers_events.py +++ b/gajim/common/connection_handlers_events.py @@ -35,7 +35,7 @@ from nbxmpp.protocol import NS_CHATSTATES from gajim.common import atom from gajim.common import nec from gajim.common import helpers -from gajim.common import gajim +from gajim.common import app from gajim.common import i18n from gajim.common import dataforms from gajim.common import exceptions @@ -46,7 +46,7 @@ from gajim.common.jingle_transport import JingleTransportSocks5 from gajim.common.file_props import FilesProp from gajim.common.nec import NetworkEvent -if gajim.HAVE_PYOPENSSL: +if app.HAVE_PYOPENSSL: import OpenSSL.crypto log = logging.getLogger('gajim.c.connection_handlers_events') @@ -81,20 +81,20 @@ class HelperEvent: del self.conn.groupchat_jids[self.id_] else: self.fjid = helpers.get_full_jid_from_iq(self.stanza) - self.jid, self.resource = gajim.get_room_and_nick_from_fjid(self.fjid) + self.jid, self.resource = app.get_room_and_nick_from_fjid(self.fjid) def get_id(self): self.id_ = self.stanza.getID() def get_gc_control(self): - self.gc_control = gajim.interface.msg_win_mgr.get_gc_control(self.jid, + self.gc_control = app.interface.msg_win_mgr.get_gc_control(self.jid, self.conn.name) # If gc_control is missing - it may be minimized. Try to get it # from there. If it's not there - then it's missing anyway and # will remain set to None. if not self.gc_control: - minimized = gajim.interface.minimized_controls[self.conn.name] + minimized = app.interface.minimized_controls[self.conn.name] self.gc_control = minimized.get(self.jid) def _generate_timestamp(self, tag): @@ -130,7 +130,7 @@ class HttpAuthReceivedEvent(nec.NetworkIncomingEvent): base_network_events = [] def generate(self): - self.opt = gajim.config.get_per('accounts', self.conn.name, 'http_auth') + self.opt = app.config.get_per('accounts', self.conn.name, 'http_auth') self.iq_id = self.stanza.getTagAttr('confirm', 'id') self.method = self.stanza.getTagAttr('confirm', 'method') self.url = self.stanza.getTagAttr('confirm', 'url') @@ -283,7 +283,7 @@ class GMailQueryReceivedEvent(nec.NetworkIncomingEvent): 'date': gmessage.getAttr('date')}) self.conn.gmail_last_time = int(mb.getAttr('result-time')) - self.jid = gajim.get_jid_from_account(self.name) + self.jid = app.get_jid_from_account(self.name) log.debug('You have %s new gmail e-mails on %s.', self.newmsgs, self.jid) return True @@ -309,7 +309,7 @@ class RosterItemExchangeEvent(nec.NetworkIncomingEvent, HelperEvent): log.warning('Invalid JID: %s, ignoring it' % item.getAttr('jid')) continue name = item.getAttr('name') - contact = gajim.contacts.get_contact(self.conn.name, jid) + contact = app.contacts.get_contact(self.conn.name, jid) groups = [] same_groups = True for group in item.getTags('group'): @@ -358,7 +358,7 @@ class RosterReceivedEvent(nec.NetworkIncomingEvent): self.received_from_server = self.xmpp_roster.received_from_server self.roster = {} raw_roster = self.xmpp_roster.getRaw() - our_jid = gajim.get_jid_from_account(self.conn.name) + our_jid = app.get_jid_from_account(self.conn.name) for jid in raw_roster: try: @@ -382,12 +382,12 @@ class RosterReceivedEvent(nec.NetworkIncomingEvent): else: # Roster comes from DB self.received_from_server = False - self.version = gajim.config.get_per('accounts', self.conn.name, + self.version = app.config.get_per('accounts', self.conn.name, 'roster_version') - self.roster = gajim.logger.get_roster(gajim.get_jid_from_account( + self.roster = app.logger.get_roster(app.get_jid_from_account( self.conn.name)) if not self.roster: - gajim.config.set_per( + app.config.set_per( 'accounts', self.conn.name, 'roster_version', '') return True @@ -397,8 +397,8 @@ class RosterSetReceivedEvent(nec.NetworkIncomingEvent): def generate(self): frm = helpers.get_jid_from_iq(self.stanza) - our_jid = gajim.get_jid_from_account(self.conn.name) - if frm and frm != our_jid and frm != gajim.get_server_from_jid(our_jid): + our_jid = app.get_jid_from_account(self.conn.name) + if frm and frm != our_jid and frm != app.get_server_from_jid(our_jid): return self.version = self.stanza.getTagAttr('query', 'ver') self.items = {} @@ -783,7 +783,7 @@ PresenceHelperEvent): except Exception: log.warning('Invalid JID: %s, ignoring it' % self.stanza.getFrom()) return - jid_list = gajim.contacts.get_jid_list(self.conn.name) + jid_list = app.contacts.get_jid_list(self.conn.name) self.timestamp = None self.get_id() self.is_gc = False # is it a GC presence ? @@ -819,7 +819,7 @@ PresenceHelperEvent): self._generate_timestamp(self.stanza.getTimestamp()) elif namespace == 'http://delx.cjb.net/protocol/roster-subsync': # see http://trac.gajim.org/ticket/326 - agent = gajim.get_server_from_jid(self.jid) + agent = app.get_server_from_jid(self.jid) if self.conn.connection.getRoster().getItem(agent): # to be sure it's a transport contact self.transport_auto_auth = True @@ -841,32 +841,32 @@ PresenceHelperEvent): self.errmsg = self.stanza.getErrorMsg() if self.is_gc: - gajim.nec.push_incoming_event( + app.nec.push_incoming_event( GcPresenceReceivedEvent( None, conn=self.conn, stanza=self.stanza, presence_obj=self)) return if self.ptype == 'subscribe': - gajim.nec.push_incoming_event(SubscribePresenceReceivedEvent(None, + app.nec.push_incoming_event(SubscribePresenceReceivedEvent(None, conn=self.conn, stanza=self.stanza, presence_obj=self)) elif self.ptype == 'subscribed': # BE CAREFUL: no con.updateRosterItem() in a callback - gajim.nec.push_incoming_event(SubscribedPresenceReceivedEvent(None, + app.nec.push_incoming_event(SubscribedPresenceReceivedEvent(None, conn=self.conn, stanza=self.stanza, presence_obj=self)) elif self.ptype == 'unsubscribe': log.debug(_('unsubscribe request from %s') % self.jid) elif self.ptype == 'unsubscribed': - gajim.nec.push_incoming_event(UnsubscribedPresenceReceivedEvent( + app.nec.push_incoming_event(UnsubscribedPresenceReceivedEvent( None, conn=self.conn, stanza=self.stanza, presence_obj=self)) elif self.ptype == 'error': return if not self.ptype or self.ptype == 'unavailable': - our_jid = gajim.get_jid_from_account(self.conn.name) + our_jid = app.get_jid_from_account(self.conn.name) if self.jid == our_jid and self.resource == self.conn.server_resource: # We got our own presence - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self.conn, + app.nec.push_incoming_event(OurShowEvent(None, conn=self.conn, show=self.show)) elif self.jid in jid_list or self.jid == our_jid: return True @@ -876,7 +876,7 @@ class ZeroconfPresenceReceivedEvent(nec.NetworkIncomingEvent): base_network_events = [] def generate(self): - self.jid, self.resource = gajim.get_room_and_nick_from_fjid(self.fjid) + self.jid, self.resource = app.get_room_and_nick_from_fjid(self.fjid) self.resource = 'local' self.prio = 0 self.keyID = None @@ -914,7 +914,7 @@ class GcPresenceReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): self.errmsg = self.presence_obj.errmsg self.errcon = self.stanza.getError() self.get_gc_control() - self.gc_contact = gajim.contacts.get_gc_contact(self.conn.name, + self.gc_contact = app.contacts.get_gc_contact(self.conn.name, self.room_jid, self.nick) if self.ptype == 'error': @@ -922,8 +922,8 @@ class GcPresenceReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): if self.ptype and self.ptype != 'unavailable': return - if gajim.config.get('log_contact_status_changes') and \ - gajim.config.should_log(self.conn.name, self.room_jid): + if app.config.get('log_contact_status_changes') and \ + app.config.should_log(self.conn.name, self.room_jid): if self.gc_contact: jid = self.gc_contact.jid else: @@ -932,10 +932,10 @@ class GcPresenceReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): if jid: # we know real jid, save it in db st += ' (%s)' % jid - show = gajim.logger.convert_show_values_to_db_api_values(self.show) + show = app.logger.convert_show_values_to_db_api_values(self.show) if show is not None: fjid = nbxmpp.JID(self.fjid) - gajim.logger.insert_into_logs(fjid.getStripped(), + app.logger.insert_into_logs(fjid.getStripped(), time_time(), KindConstant.GCSTATUS, contact_name=fjid.getResource(), @@ -944,7 +944,7 @@ class GcPresenceReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): if self.avatar_sha == '': # contact has no avatar puny_nick = helpers.sanitize_filename(self.nick) - gajim.interface.remove_avatar_files(self.room_jid, puny_nick) + app.interface.remove_avatar_files(self.room_jid, puny_nick) # NOTE: if it's a gc presence, don't ask vcard here. # We may ask it to real jid in gui part. self.status_code = [] @@ -1118,7 +1118,7 @@ class MamDecryptedMessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): # For example Chatstates, Receipts, Chatmarkers log.debug('Received MAM message without text') return - self.is_pm = gajim.logger.jid_is_room_jid(self.with_.getStripped()) + self.is_pm = app.logger.jid_is_room_jid(self.with_.getStripped()) if self.is_pm is None: # Check if this event is triggered after a disco, so we dont # run into an endless loop @@ -1166,13 +1166,13 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): # check if the message is a roster item exchange (XEP-0144) if self.stanza.getTag('x', namespace=nbxmpp.NS_ROSTERX): - gajim.nec.push_incoming_event(RosterItemExchangeEvent(None, + app.nec.push_incoming_event(RosterItemExchangeEvent(None, conn=self.conn, stanza=self.stanza)) return # check if the message is a XEP-0070 confirmation request if self.stanza.getTag('confirm', namespace=nbxmpp.NS_HTTP_AUTH): - gajim.nec.push_incoming_event(HttpAuthReceivedEvent(None, + app.nec.push_incoming_event(HttpAuthReceivedEvent(None, conn=self.conn, stanza=self.stanza)) return @@ -1186,7 +1186,7 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): address_tag = self.stanza.getTag('addresses', namespace=nbxmpp.NS_ADDRESS) # Be sure it comes from one of our resource, else ignore address element - if address_tag and self.jid == gajim.get_jid_from_account(account): + if address_tag and self.jid == app.get_jid_from_account(account): address = address_tag.getTag('address', attrs={'type': 'ofrom'}) if address: try: @@ -1195,14 +1195,14 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): log.warning('Invalid JID: %s, ignoring it', address.getAttr('jid')) return - self.jid = gajim.get_jid_without_resource(self.fjid) + self.jid = app.get_jid_without_resource(self.fjid) carbon_marker = self.stanza.getTag('sent', namespace=nbxmpp.NS_CARBONS) if not carbon_marker: carbon_marker = self.stanza.getTag('received', namespace=nbxmpp.NS_CARBONS) # Be sure it comes from one of our resource, else ignore forward element - if carbon_marker and self.jid == gajim.get_jid_from_account(account): + if carbon_marker and self.jid == app.get_jid_from_account(account): forward_tag = carbon_marker.getTag('forwarded', namespace=nbxmpp.NS_FORWARD) if forward_tag: @@ -1213,16 +1213,16 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): to = self.stanza.getTo() frm = self.stanza.getFrom() if not frm: - frm = gajim.get_jid_from_account(account) + frm = app.get_jid_from_account(account) self.stanza.setTo(frm) if not to: - to = gajim.get_jid_from_account(account) + to = app.get_jid_from_account(account) self.stanza.setFrom(to) self.sent = True elif carbon_marker.getName() == 'received': full_frm = str(self.stanza.getFrom()) - frm = gajim.get_jid_without_resource(full_frm) - if frm == gajim.get_jid_from_account(account): + frm = app.get_jid_without_resource(full_frm) + if frm == app.get_jid_from_account(account): # Drop 'received' Carbons from ourself, we already # got the message with the 'sent' Carbon or via the # message itself @@ -1249,7 +1249,7 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): log.warning('Invalid MAM Message: no forwarded child') return - gajim.nec.push_incoming_event( + app.nec.push_incoming_event( NetworkEvent('raw-mam-message-received', conn=self.conn, stanza=self.stanza, @@ -1261,13 +1261,13 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): muc_user = self.stanza.getTag('x', namespace=nbxmpp.NS_MUC_USER) if muc_user: if muc_user.getTag('decline'): - gajim.nec.push_incoming_event( + app.nec.push_incoming_event( GcDeclineReceivedEvent( None, conn=self.conn, room_jid=self.fjid, stanza=muc_user)) return if muc_user.getTag('invite'): - gajim.nec.push_incoming_event( + app.nec.push_incoming_event( GcInvitationReceivedEvent( None, conn=self.conn, jid_from=self.fjid, mediated=True, stanza=muc_user)) @@ -1277,7 +1277,7 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): direct = self.stanza.getTag( 'x', namespace=nbxmpp.NS_CONFERENCE) if direct: - gajim.nec.push_incoming_event( + app.nec.push_incoming_event( GcInvitationReceivedEvent( None, conn=self.conn, jid_from=self.fjid, mediated=False, stanza=direct)) @@ -1304,7 +1304,7 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): self.session = None if self.mtype != 'groupchat': - if gajim.interface.is_pm_contact(self.fjid, account) and \ + if app.interface.is_pm_contact(self.fjid, account) and \ self.mtype == 'error': self.session = self.conn.find_session(self.fjid, self.thread_id) if not self.session: @@ -1340,7 +1340,7 @@ class ZeroconfMessageReceivedEvent(MessageReceivedEvent): self.fjid = key break - self.jid, self.resource = gajim.get_room_and_nick_from_fjid(self.fjid) + self.jid, self.resource = app.get_room_and_nick_from_fjid(self.fjid) def generate(self): self.base_event = nec.NetworkIncomingEvent(None, conn=self.conn, @@ -1379,15 +1379,15 @@ class GcInvitationReceivedEvent(nec.NetworkIncomingEvent): self.password = self.stanza.getTagData('password') self.is_continued = self.stanza.getTag('continue') is not None - if self.room_jid in gajim.gc_connected[account] and \ - gajim.gc_connected[account][self.room_jid]: + if self.room_jid in app.gc_connected[account] and \ + app.gc_connected[account][self.room_jid]: # We are already in groupchat. Ignore invitation return - jid = gajim.get_jid_without_resource(self.jid_from) + jid = app.get_jid_without_resource(self.jid_from) - ignore = gajim.config.get_per( + ignore = app.config.get_per( 'accounts', account, 'ignore_unknown_contacts') - if ignore and not gajim.contacts.get_contacts(account, jid): + if ignore and not app.contacts.get_contacts(account, jid): return return True @@ -1405,10 +1405,10 @@ class GcDeclineReceivedEvent(nec.NetworkIncomingEvent): log.warning('Invalid JID: %s, ignoring it', decline.getAttr('from')) return - jid = gajim.get_jid_without_resource(self.jid_from) - ignore = gajim.config.get_per( + jid = app.get_jid_without_resource(self.jid_from) + ignore = app.config.get_per( 'accounts', account, 'ignore_unknown_contacts') - if ignore and not gajim.contacts.get_contacts(account, jid): + if ignore and not app.contacts.get_contacts(account, jid): return self.reason = decline.getTagData('reason') @@ -1463,7 +1463,7 @@ class DecryptedMessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): self.form_node = self.stanza.getTag('x', namespace=nbxmpp.NS_DATA) - if gajim.config.get('ignore_incoming_xhtml'): + if app.config.get('ignore_incoming_xhtml'): self.xhtml = None else: self.xhtml = self.stanza.getXHTML() @@ -1540,7 +1540,7 @@ class GcMessageReceivedEvent(nec.NetworkIncomingEvent): self.encrypted = self.msg_obj.encrypted self.correct_id = None # XEP-0308 - if gajim.config.get('ignore_incoming_xhtml'): + if app.config.get('ignore_incoming_xhtml'): self.xhtml_msgtxt = None if self.msg_obj.resource: @@ -1555,7 +1555,7 @@ class GcMessageReceivedEvent(nec.NetworkIncomingEvent): self.subject = self.stanza.getSubject() if self.subject is not None: - gajim.nec.push_incoming_event(GcSubjectReceivedEvent(None, + app.nec.push_incoming_event(GcSubjectReceivedEvent(None, conn=self.conn, msg_event=self)) return @@ -1573,7 +1573,7 @@ class GcMessageReceivedEvent(nec.NetworkIncomingEvent): # http://www.xmpp.org/extensions/xep-0045.html#roomconfig-notify if self.stanza.getTag('x'): if self.status_code != []: - gajim.nec.push_incoming_event(GcConfigChangedReceivedEvent( + app.nec.push_incoming_event(GcConfigChangedReceivedEvent( None, conn=self.conn, msg_event=self)) if self.msg_obj.form_node: return True @@ -1681,7 +1681,7 @@ class JingleRequestReceivedEvent(nec.NetworkIncomingEvent): def generate(self): self.fjid = self.jingle_session.peerjid - self.jid, self.resource = gajim.get_room_and_nick_from_fjid(self.fjid) + self.jid, self.resource = app.get_room_and_nick_from_fjid(self.fjid) self.sid = self.jingle_session.sid return True @@ -1691,7 +1691,7 @@ class JingleConnectedReceivedEvent(nec.NetworkIncomingEvent): def generate(self): self.fjid = self.jingle_session.peerjid - self.jid, self.resource = gajim.get_room_and_nick_from_fjid(self.fjid) + self.jid, self.resource = app.get_room_and_nick_from_fjid(self.fjid) self.sid = self.jingle_session.sid return True @@ -1701,7 +1701,7 @@ class JingleDisconnectedReceivedEvent(nec.NetworkIncomingEvent): def generate(self): self.fjid = self.jingle_session.peerjid - self.jid, self.resource = gajim.get_room_and_nick_from_fjid(self.fjid) + self.jid, self.resource = app.get_room_and_nick_from_fjid(self.fjid) self.sid = self.jingle_session.sid return True @@ -1711,7 +1711,7 @@ class JingleTransferCancelledEvent(nec.NetworkIncomingEvent): def generate(self): self.fjid = self.jingle_session.peerjid - self.jid, self.resource = gajim.get_room_and_nick_from_fjid(self.fjid) + self.jid, self.resource = app.get_room_and_nick_from_fjid(self.fjid) self.sid = self.jingle_session.sid return True @@ -1721,7 +1721,7 @@ class JingleErrorReceivedEvent(nec.NetworkIncomingEvent): def generate(self): self.fjid = self.jingle_session.peerjid - self.jid, self.resource = gajim.get_room_and_nick_from_fjid(self.fjid) + self.jid, self.resource = app.get_room_and_nick_from_fjid(self.fjid) self.sid = self.jingle_session.sid return True @@ -1884,7 +1884,7 @@ class AgentRemovedEvent(nec.NetworkIncomingEvent): def generate(self): self.jid_list = [] - for jid in gajim.contacts.get_jid_list(self.conn.name): + for jid in app.contacts.get_jid_list(self.conn.name): if jid.endswith('@' + self.agent): self.jid_list.append(jid) return True @@ -1895,8 +1895,8 @@ class BadGPGPassphraseEvent(nec.NetworkIncomingEvent): def generate(self): self.account = self.conn.name - self.use_gpg_agent = gajim.config.get('use_gpg_agent') - self.keyID = gajim.config.get_per('accounts', self.conn.name, 'keyid') + self.use_gpg_agent = app.config.get('use_gpg_agent') + self.keyID = app.config.get_per('accounts', self.conn.name, 'keyid') return True class ConnectionLostEvent(nec.NetworkIncomingEvent): @@ -1904,7 +1904,7 @@ class ConnectionLostEvent(nec.NetworkIncomingEvent): base_network_events = [] def generate(self): - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self.conn, + app.nec.push_incoming_event(OurShowEvent(None, conn=self.conn, show='offline')) return True @@ -1971,7 +1971,7 @@ class GPGPasswordRequiredEvent(nec.NetworkIncomingEvent): base_network_events = [] def generate(self): - self.keyid = gajim.config.get_per('accounts', self.conn.name, 'keyid') + self.keyid = app.config.get_per('accounts', self.conn.name, 'keyid') return True class PEPReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): @@ -2006,7 +2006,7 @@ class PEPReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): for item in items.getTags('item'): entry = item.getTag('entry', namespace=nbxmpp.NS_ATOM) if entry: - gajim.nec.push_incoming_event(AtomEntryReceived(None, + app.nec.push_incoming_event(AtomEntryReceived(None, conn=self.conn, node=entry)) raise nbxmpp.NodeProcessed @@ -2178,7 +2178,7 @@ class AgentItemsReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): continue self.items.append(attr) self.get_jid_resource() - hostname = gajim.config.get_per('accounts', self.conn.name, 'hostname') + hostname = app.config.get_per('accounts', self.conn.name, 'hostname') self.get_id() if self.id_ in self.conn.disco_items_ids: self.conn.disco_items_ids.remove(self.id_) @@ -2266,7 +2266,7 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): def generate(self): self.get_id() self.fjid = self.conn._ft_get_from(self.stanza) - self.jid = gajim.get_jid_without_resource(self.fjid) + self.jid = app.get_jid_without_resource(self.fjid) if self.jingle_content: secu = self.jingle_content.getTag('security') self.FT_content.use_security = bool(secu) @@ -2303,7 +2303,7 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): h = h.getData() if h else None n = file_tag.getTag('name') n = n.getData() if n else None - pjid = gajim.get_jid_without_resource(self.fjid) + pjid = app.get_jid_without_resource(self.fjid) file_info = self.conn.get_file_info(pjid, hash_=h, name=n,account=self.conn.name) self.file_props.file_name = file_info['file-name'] @@ -2377,7 +2377,7 @@ class FileRequestErrorEvent(nec.NetworkIncomingEvent): base_network_events = [] def generate(self): - self.jid = gajim.get_jid_without_resource(self.jid) + self.jid = app.get_jid_without_resource(self.jid) return True class FileTransferCompletedEvent(nec.NetworkIncomingEvent): @@ -2386,7 +2386,7 @@ class FileTransferCompletedEvent(nec.NetworkIncomingEvent): def generate(self): jid = str(self.file_props.receiver) - self.jid = gajim.get_jid_without_resource(jid) + self.jid = app.get_jid_without_resource(jid) return True class GatewayPromptReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): @@ -2440,14 +2440,14 @@ class NotificationEvent(nec.NetworkIncomingEvent): self.control = None self.get_focused() # This event has already been added to event list - if not self.control and len(gajim.events.get_events(self.conn.name, \ + if not self.control and len(app.events.get_events(self.conn.name, \ self.jid, [msg_obj.mtype])) <= 1: self.first_unread = True if msg_obj.mtype == 'pm': nick = msg_obj.resource else: - nick = gajim.get_name_from_jid(self.conn.name, self.jid) + nick = app.get_name_from_jid(self.conn.name, self.jid) if self.first_unread: self.sound_event = 'first_message_received' @@ -2456,7 +2456,7 @@ class NotificationEvent(nec.NetworkIncomingEvent): else: self.sound_event = 'next_message_received_unfocused' - if gajim.config.get('notification_preview_message'): + if app.config.get('notification_preview_message'): self.popup_text = msg_obj.msgtxt if self.popup_text and (self.popup_text.startswith('/me ') or \ self.popup_text.startswith('/me\n')): @@ -2490,25 +2490,25 @@ class NotificationEvent(nec.NetworkIncomingEvent): {'nickname': nick} - if gajim.config.get('notify_on_new_message'): - if self.first_unread or (gajim.config.get('autopopup_chat_opened') \ + if app.config.get('notify_on_new_message'): + if self.first_unread or (app.config.get('autopopup_chat_opened') \ and not self.control_focused): - if gajim.config.get('autopopupaway'): + if app.config.get('autopopupaway'): # always show notification self.do_popup = True - if gajim.connections[self.conn.name].connected in (2, 3): + if app.connections[self.conn.name].connected in (2, 3): # we're online or chat self.do_popup = True - if msg_obj.attention and not gajim.config.get( + if msg_obj.attention and not app.config.get( 'ignore_incoming_attention'): self.popup_timeout = 0 self.do_popup = True else: - self.popup_timeout = gajim.config.get('notification_timeout') + self.popup_timeout = app.config.get('notification_timeout') - if msg_obj.attention and not gajim.config.get( - 'ignore_incoming_attention') and gajim.config.get_per('soundevents', + if msg_obj.attention and not app.config.get( + 'ignore_incoming_attention') and app.config.get_per('soundevents', 'attention_received', 'enabled'): self.sound_event = 'attention_received' self.do_sound = True @@ -2555,7 +2555,7 @@ class NotificationEvent(nec.NetworkIncomingEvent): if jid: # we want an avatar puny_jid = helpers.sanitize_filename(jid) - path_to_file = os.path.join(gajim.AVATAR_PATH, puny_jid) + suffix + path_to_file = os.path.join(app.AVATAR_PATH, puny_jid) + suffix path_to_local_file = path_to_file + '_local' for extension in ('.png', '.jpeg'): path_to_local_file_full = path_to_local_file + extension @@ -2568,7 +2568,7 @@ class NotificationEvent(nec.NetworkIncomingEvent): return os.path.abspath(generic) def handle_incoming_pres_event(self, pres_obj): - if gajim.jid_is_transport(pres_obj.jid): + if app.jid_is_transport(pres_obj.jid): return True account = pres_obj.conn.name self.jid = pres_obj.jid @@ -2583,11 +2583,11 @@ class NotificationEvent(nec.NetworkIncomingEvent): # no other resource is connected, let's look in metacontacts - family = gajim.contacts.get_metacontacts_family(account, self.jid) + family = app.contacts.get_metacontacts_family(account, self.jid) for info in family: acct_ = info['account'] jid_ = info['jid'] - c_ = gajim.contacts.get_contact_with_highest_priority(acct_, jid_) + c_ = app.contacts.get_contact_with_highest_priority(acct_, jid_) if not c_: continue if c_.jid == self.jid: @@ -2599,18 +2599,18 @@ class NotificationEvent(nec.NetworkIncomingEvent): event = 'contact_connected' show_image = 'online.png' suffix = '_notif_size_colored' - server = gajim.get_server_from_jid(self.jid) + server = app.get_server_from_jid(self.jid) account_server = account + '/' + server block_transport = False - if account_server in gajim.block_signed_in_notifications and \ - gajim.block_signed_in_notifications[account_server]: + if account_server in app.block_signed_in_notifications and \ + app.block_signed_in_notifications[account_server]: block_transport = True if helpers.allow_showing_notification(account, 'notify_on_signin') \ - and not gajim.block_signed_in_notifications[account] and \ + and not app.block_signed_in_notifications[account] and \ not block_transport: self.do_popup = True - if gajim.config.get_per('soundevents', 'contact_connected', - 'enabled') and not gajim.block_signed_in_notifications[account] and\ + if app.config.get_per('soundevents', 'contact_connected', + 'enabled') and not app.block_signed_in_notifications[account] and\ not block_transport and helpers.allow_sound_notification(account, 'contact_connected'): self.sound_event = event @@ -2622,7 +2622,7 @@ class NotificationEvent(nec.NetworkIncomingEvent): suffix = '_notif_size_bw' if helpers.allow_showing_notification(account, 'notify_on_signout'): self.do_popup = True - if gajim.config.get_per('soundevents', 'contact_disconnected', + if app.config.get_per('soundevents', 'contact_disconnected', 'enabled') and helpers.allow_sound_notification(account, event): self.sound_event = event self.do_sound = True @@ -2636,21 +2636,21 @@ class NotificationEvent(nec.NetworkIncomingEvent): else: return True - transport_name = gajim.get_transport_name_from_jid(self.jid) + transport_name = app.get_transport_name_from_jid(self.jid) img_path = None if transport_name: img_path = os.path.join(helpers.get_transport_path( transport_name), '48x48', show_image) if not img_path or not os.path.isfile(img_path): - iconset = gajim.config.get('iconset') + iconset = app.config.get('iconset') img_path = os.path.join(helpers.get_iconset_path(iconset), '48x48', show_image) self.popup_image_path = self.get_path_to_generic_or_avatar(img_path, jid=self.jid, suffix=suffix) - self.popup_timeout = gajim.config.get('notification_timeout') + self.popup_timeout = app.config.get('notification_timeout') - nick = i18n.direction_mark + gajim.get_name_from_jid(account, self.jid) + nick = i18n.direction_mark + app.get_name_from_jid(account, self.jid) if event == 'status_change': self.popup_title = _('%(nick)s Changed Status') % \ {'nick': nick} diff --git a/gajim/common/contacts.py b/gajim/common/contacts.py index dc36c151b..e4a84315b 100644 --- a/gajim/common/contacts.py +++ b/gajim/common/contacts.py @@ -165,8 +165,8 @@ class Contact(CommonContact): return is_observer def is_groupchat(self): - for account in common.gajim.gc_connected: - if self.jid in common.gajim.gc_connected[account]: + for account in common.app.gc_connected: + if self.jid in common.app.gc_connected[account]: return True return False @@ -258,8 +258,8 @@ class LegacyContactsAPI: def create_self_contact(self, jid, account, resource, show, status, priority, name='', keyID=''): - conn = common.gajim.connections[account] - nick = name or common.gajim.nicks[account] + conn = common.app.connections[account] + nick = name or common.app.nicks[account] account = self._accounts.get(account, account) # Use Account object if available self_contact = self.create_contact(jid=jid, account=account, name=nick, groups=['self_contact'], show=show, status=status, @@ -357,11 +357,11 @@ class LegacyContactsAPI: nbr_online = 0 nbr_total = 0 for account in accounts: - our_jid = common.gajim.get_jid_from_account(account) + our_jid = common.app.get_jid_from_account(account) for jid in self.get_jid_list(account): if jid == our_jid: continue - if common.gajim.jid_is_transport(jid) and not \ + if common.app.jid_is_transport(jid) and not \ _('Transports') in groups: # do not count transports continue @@ -506,7 +506,7 @@ class Contacts(): """ Get Contact object for specific resource of given jid """ - barejid, resource = common.gajim.get_room_and_nick_from_fjid(fjid) + barejid, resource = common.app.get_room_and_nick_from_fjid(fjid) return self.get_contact(barejid, resource) def get_first_contact_from_jid(self, jid): @@ -655,7 +655,7 @@ class MetacontactManager(): self._metacontacts_tags[brother_account][tag] = [{'jid': brother_jid, 'tag': tag}] if brother_account != account: - common.gajim.connections[brother_account].store_metacontacts( + common.app.connections[brother_account].store_metacontacts( self._metacontacts_tags[brother_account]) # be sure jid has no other tag old_tag = self._get_metacontacts_tag(account, jid) @@ -671,7 +671,7 @@ class MetacontactManager(): else: self._metacontacts_tags[account][tag].append({'jid': jid, 'tag': tag}) - common.gajim.connections[account].store_metacontacts( + common.app.connections[account].store_metacontacts( self._metacontacts_tags[account]) def remove_metacontact(self, account, jid): @@ -686,7 +686,7 @@ class MetacontactManager(): break if found: self._metacontacts_tags[account][tag].remove(found) - common.gajim.connections[account].store_metacontacts( + common.app.connections[account].store_metacontacts( self._metacontacts_tags[account]) break @@ -789,8 +789,8 @@ class MetacontactManager(): return 1 if 'order' in data2: return -1 - transport1 = common.gajim.get_transport_name_from_jid(jid1) - transport2 = common.gajim.get_transport_name_from_jid(jid2) + transport1 = common.app.get_transport_name_from_jid(jid1) + transport2 = common.app.get_transport_name_from_jid(jid2) if transport2 and not transport1: return 1 if transport1 and not transport2: @@ -803,10 +803,10 @@ class MetacontactManager(): return 1 if priority2 > priority1: return -1 - server1 = common.gajim.get_server_from_jid(jid1) - server2 = common.gajim.get_server_from_jid(jid2) - myserver1 = common.gajim.config.get_per('accounts', account1, 'hostname') - myserver2 = common.gajim.config.get_per('accounts', account2, 'hostname') + server1 = common.app.get_server_from_jid(jid1) + server2 = common.app.get_server_from_jid(jid2) + myserver1 = common.app.config.get_per('accounts', account1, 'hostname') + myserver2 = common.app.config.get_per('accounts', account2, 'hostname') if server1 == myserver1: if server2 != myserver2: return 1 @@ -833,7 +833,7 @@ class MetacontactManager(): (nearby_family, big_brother_jid, big_brother_account) """ - if common.gajim.config.get('mergeaccounts'): + if common.app.config.get('mergeaccounts'): # group all together nearby_family = family else: diff --git a/gajim/common/dbus_support.py b/gajim/common/dbus_support.py index e87944236..c8476551b 100644 --- a/gajim/common/dbus_support.py +++ b/gajim/common/dbus_support.py @@ -26,7 +26,7 @@ import os -from gajim.common import gajim +from gajim.common import app from gajim.common import exceptions _GAJIM_ERROR_IFACE = 'org.gajim.dbus.Error' @@ -155,7 +155,7 @@ def get_interface(interface, path, start_service=True): obj = bus.get_object(interface, path) return dbus.Interface(obj, interface) except Exception as e: - gajim.log.debug(str(e)) + app.log.debug(str(e)) return None diff --git a/gajim/common/gpg.py b/gajim/common/gpg.py index 0013de3c1..c271d2766 100644 --- a/gajim/common/gpg.py +++ b/gajim/common/gpg.py @@ -24,18 +24,17 @@ import os import logging -from gajim.common import gajim -from gajim.common.gajim import HAVE_GPG, GPG_BINARY +from gajim.common import app -if HAVE_GPG: +if app.HAVE_GPG: import gnupg gnupg.logger = logging.getLogger('gajim.c.gnupg') class GnuPG(gnupg.GPG): def __init__(self): - use_agent = gajim.config.get('use_gpg_agent') - gnupg.GPG.__init__(self, gpgbinary=GPG_BINARY, use_agent=use_agent) - encoding = gajim.config.get('pgp_encoding') + use_agent = app.config.get('use_gpg_agent') + gnupg.GPG.__init__(self, gpgbinary=app.GPG_BINARY, use_agent=use_agent) + encoding = app.config.get('pgp_encoding') if encoding: self.encoding = encoding self.decode_errors = 'replace' diff --git a/gajim/common/helpers.py b/gajim/common/helpers.py index 6f99efb1a..26496d859 100644 --- a/gajim/common/helpers.py +++ b/gajim/common/helpers.py @@ -545,7 +545,7 @@ def exec_command(command, use_shell=False, posix=True): else: args = shlex.split(command, posix=posix) p = subprocess.Popen(args) - gajim.thread_interface(p.wait) + app.thread_interface(p.wait) def build_command(executable, parameter): # we add to the parameter (can hold path with spaces) @@ -750,8 +750,8 @@ def parse_datetime(timestring, check_utc=False, convert='utc', epoch=False): return date_time return None -from gajim.common import gajim -if gajim.HAVE_PYCURL: +from gajim.common import app +if app.HAVE_PYCURL: import pycurl from io import StringIO @@ -759,7 +759,7 @@ def convert_bytes(string): suffix = '' # IEC standard says KiB = 1024 bytes KB = 1000 bytes # but do we use the standard? - use_kib_mib = gajim.config.get('use_kib_mib') + use_kib_mib = app.config.get('use_kib_mib') align = 1024. bytes_ = float(string) if bytes_ >= align: @@ -800,8 +800,8 @@ def get_contact_dict_for_account(account): Can be used for completion lists """ contacts_dict = {} - for jid in gajim.contacts.get_jid_list(account): - contact = gajim.contacts.get_contact_with_highest_priority(account, + for jid in app.contacts.get_jid_list(account): + contact = app.contacts.get_contact_with_highest_priority(account, jid) contacts_dict[jid] = contact name = contact.name @@ -811,7 +811,7 @@ def get_contact_dict_for_account(account): contacts_dict['%s (%s)' % (name, contact1.jid)] = contact1 contacts_dict['%s (%s)' % (name, jid)] = contact elif contact.name: - if contact.name == gajim.get_nick_from_jid(jid): + if contact.name == app.get_nick_from_jid(jid): del contacts_dict[jid] contacts_dict[name] = contact return contacts_dict @@ -827,11 +827,11 @@ def launch_browser_mailer(kind, uri): if kind == 'url' and uri.startswith('www.'): uri = 'http://' + uri - if not gajim.config.get('autodetect_browser_mailer'): + if not app.config.get('autodetect_browser_mailer'): if kind == 'url': - command = gajim.config.get('custombrowser') + command = app.config.get('custombrowser') elif kind in ('mail', 'sth_at_sth'): - command = gajim.config.get('custommailapp') + command = app.config.get('custommailapp') if command == '': # if no app is configured return @@ -854,8 +854,8 @@ def launch_file_manager(path_to_open): except Exception: pass else: - if not gajim.config.get('autodetect_browser_mailer'): - command = gajim.config.get('custom_file_manager') + if not app.config.get('autodetect_browser_mailer'): + command = app.config.get('custom_file_manager') if command == '': # if no app is configured return else: @@ -867,13 +867,13 @@ def launch_file_manager(path_to_open): pass def play_sound(event): - if not gajim.config.get('sounds_on'): + if not app.config.get('sounds_on'): return - path_to_soundfile = gajim.config.get_per('soundevents', event, 'path') + path_to_soundfile = app.config.get_per('soundevents', event, 'path') play_sound_file(path_to_soundfile) -def check_soundfile_path(file_, dirs=(gajim.gajimpaths.data_root, -gajim.DATA_DIR)): +def check_soundfile_path(file_, dirs=(app.gajimpaths.data_root, +app.DATA_DIR)): """ Check if the sound file exists @@ -893,8 +893,8 @@ gajim.DATA_DIR)): return d return None -def strip_soundfile_path(file_, dirs=(gajim.gajimpaths.data_root, -gajim.DATA_DIR), abs=True): +def strip_soundfile_path(file_, dirs=(app.gajimpaths.data_root, +app.DATA_DIR), abs=True): """ Remove knowns paths from a sound file @@ -930,7 +930,7 @@ def play_sound_file(path_to_soundfile): except Exception: log.exception('Sound Playback Error') elif sys.platform == 'linux': - if gajim.config.get('soundplayer') == '': + if app.config.get('soundplayer') == '': def _oss_play(): sndfile = wave.open(path_to_soundfile, 'rb') (nc, sw, fr, nf, comptype, compname) = sndfile.getparams() @@ -939,9 +939,9 @@ def play_sound_file(path_to_soundfile): dev.write(sndfile.readframes(nf)) sndfile.close() dev.close() - gajim.thread_interface(_oss_play) + app.thread_interface(_oss_play) return - player = gajim.config.get('soundplayer') + player = app.config.get('soundplayer') command = build_command(player, path_to_soundfile) exec_command(command) elif sys.platform == 'darwin' and HAS_SOUND: @@ -951,25 +951,25 @@ def play_sound_file(path_to_soundfile): def get_global_show(): maxi = 0 - for account in gajim.connections: - if not gajim.config.get_per('accounts', account, + for account in app.connections: + if not app.config.get_per('accounts', account, 'sync_with_global_status'): continue - connected = gajim.connections[account].connected + connected = app.connections[account].connected if connected > maxi: maxi = connected - return gajim.SHOW_LIST[maxi] + return app.SHOW_LIST[maxi] def get_global_status(): maxi = 0 - for account in gajim.connections: - if not gajim.config.get_per('accounts', account, + for account in app.connections: + if not app.config.get_per('accounts', account, 'sync_with_global_status'): continue - connected = gajim.connections[account].connected + connected = app.connections[account].connected if connected > maxi: maxi = connected - status = gajim.connections[account].status + status = app.connections[account].status return status @@ -978,13 +978,13 @@ def statuses_unified(): Test if all statuses are the same """ reference = None - for account in gajim.connections: - if not gajim.config.get_per('accounts', account, + for account in app.connections: + if not app.config.get_per('accounts', account, 'sync_with_global_status'): continue if reference is None: - reference = gajim.connections[account].connected - elif reference != gajim.connections[account].connected: + reference = app.connections[account].connected + elif reference != app.connections[account].connected: return False return True @@ -992,17 +992,17 @@ def get_icon_name_to_show(contact, account = None): """ Get the icon name to show in online, away, requested, etc """ - if account and gajim.events.get_nb_roster_events(account, contact.jid): + if account and app.events.get_nb_roster_events(account, contact.jid): return 'event' - if account and gajim.events.get_nb_roster_events(account, + if account and app.events.get_nb_roster_events(account, contact.get_full_jid()): return 'event' - if account and account in gajim.interface.minimized_controls and \ - contact.jid in gajim.interface.minimized_controls[account] and gajim.interface.\ + if account and account in app.interface.minimized_controls and \ + contact.jid in app.interface.minimized_controls[account] and app.interface.\ minimized_controls[account][contact.jid].get_nb_unread_pm() > 0: return 'event' - if account and contact.jid in gajim.gc_connected[account]: - if gajim.gc_connected[account][contact.jid]: + if account and contact.jid in app.gc_connected[account]: + if app.gc_connected[account][contact.jid]: return 'muc_active' else: return 'muc_inactive' @@ -1012,10 +1012,10 @@ def get_icon_name_to_show(contact, account = None): return contact.show if contact.ask == 'subscribe': return 'requested' - transport = gajim.get_transport_name_from_jid(contact.jid) + transport = app.get_transport_name_from_jid(contact.jid) if transport: return contact.show - if contact.show in gajim.SHOW_LIST: + if contact.show in app.SHOW_LIST: return contact.show return 'not in roster' @@ -1030,7 +1030,7 @@ def get_jid_from_iq(iq_obj): Return the jid (without resource) from an iq """ jid = get_full_jid_from_iq(iq_obj) - return gajim.get_jid_without_resource(jid) + return app.get_jid_without_resource(jid) def get_auth_sha(sid, initiator, target): """ @@ -1041,7 +1041,7 @@ def get_auth_sha(sid, initiator, target): def remove_invalid_xml_chars(string): if string: - string = re.sub(gajim.interface.invalid_XML_chars_re, '', string) + string = re.sub(app.interface.invalid_XML_chars_re, '', string) return string distro_info = { @@ -1078,8 +1078,8 @@ def get_random_string_16(): return ''.join(sample(char_sequence, 16)) def get_os_info(): - if gajim.os_info: - return gajim.os_info + if app.os_info: + return app.os_info if os.name == 'nt': # platform.release() seems to return the name of the windows ver = sys.getwindowsversion() @@ -1099,7 +1099,7 @@ def get_os_info(): os_info = 'Windows' + ' ' + win_version[ver_format] else: os_info = 'Windows' - gajim.os_info = os_info + app.os_info = os_info return os_info elif os.name == 'posix': executable = 'lsb_release' @@ -1113,7 +1113,7 @@ def get_os_info(): output = temp_failure_retry(p.stdout.readline).strip() # some distros put n/a in places, so remove those output = output.decode('utf-8').replace('n/a', '').replace('N/A', '') - gajim.os_info = output + app.os_info = output p.stdout.close() p.stdin.close() return output @@ -1145,17 +1145,17 @@ def get_os_info(): # file just has version text = distro_name + ' ' + text os_info = text.replace('\n', '') - gajim.os_info = os_info + app.os_info = os_info return os_info # our last chance, ask uname and strip it uname_output = get_output_of_command('uname -sr') if uname_output is not None: os_info = uname_output[0] # only first line - gajim.os_info = os_info + app.os_info = os_info return os_info os_info = 'N/A' - gajim.os_info = os_info + app.os_info = os_info return os_info @@ -1168,11 +1168,11 @@ is_first_message=True): option that need to be True e.g.: notify_on_signing is_first_message: set it to false when it's not the first message """ - if type_ and (not gajim.config.get(type_) or not is_first_message): + if type_ and (not app.config.get(type_) or not is_first_message): return False - if gajim.config.get('autopopupaway'): # always show notification + if app.config.get('autopopupaway'): # always show notification return True - if gajim.connections[account].connected in (2, 3): # we're online or chat + if app.connections[account].connected in (2, 3): # we're online or chat return True return False @@ -1180,16 +1180,16 @@ def allow_popup_window(account): """ Is it allowed to popup windows? """ - autopopup = gajim.config.get('autopopup') - autopopupaway = gajim.config.get('autopopupaway') + autopopup = app.config.get('autopopup') + autopopupaway = app.config.get('autopopupaway') if autopopup and (autopopupaway or \ - gajim.connections[account].connected in (2, 3)): # we're online or chat + app.connections[account].connected in (2, 3)): # we're online or chat return True return False def allow_sound_notification(account, sound_event): - if gajim.config.get('sounddnd') or gajim.connections[account].connected != \ - gajim.SHOW_LIST.index('dnd') and gajim.config.get_per('soundevents', + if app.config.get('sounddnd') or app.connections[account].connected != \ + app.SHOW_LIST.index('dnd') and app.config.get_per('soundevents', sound_event, 'enabled'): return True return False @@ -1198,12 +1198,12 @@ def get_chat_control(account, contact): full_jid_with_resource = contact.jid if contact.resource: full_jid_with_resource += '/' + contact.resource - highest_contact = gajim.contacts.get_contact_with_highest_priority( + highest_contact = app.contacts.get_contact_with_highest_priority( account, contact.jid) # Look for a chat control that has the given resource, or default to # one without resource - ctrl = gajim.interface.msg_win_mgr.get_control(full_jid_with_resource, + ctrl = app.interface.msg_win_mgr.get_control(full_jid_with_resource, account) if ctrl: @@ -1213,7 +1213,7 @@ def get_chat_control(account, contact): return None else: # unknown contact or offline message - return gajim.interface.msg_win_mgr.get_control(contact.jid, account) + return app.interface.msg_win_mgr.get_control(contact.jid, account) def get_notification_icon_tooltip_dict(): """ @@ -1230,7 +1230,7 @@ def get_notification_icon_tooltip_dict(): account_name = account['name'] account['event_lines'] = [] # Gather events per-account - pending_events = gajim.events.get_events(account = account_name) + pending_events = app.events.get_events(account = account_name) messages, non_messages, total_messages, total_non_messages = {}, {}, 0, 0 for jid in pending_events: for event in pending_events[jid]: @@ -1256,10 +1256,10 @@ def get_notification_icon_tooltip_dict(): '%d message pending', '%d messages pending', messages[jid], messages[jid], messages[jid]) - contact = gajim.contacts.get_first_contact_from_jid( + contact = app.contacts.get_first_contact_from_jid( account['name'], jid) text += ' ' - if jid in gajim.gc_connected[account['name']]: + if jid in app.gc_connected[account['name']]: text += _('from room %s') % (jid) elif contact: name = contact.get_shown_name() @@ -1334,13 +1334,13 @@ def get_accounts_info(): Helper for notification icon tooltip """ accounts = [] - accounts_list = sorted(gajim.contacts.get_accounts()) + accounts_list = sorted(app.contacts.get_accounts()) for account in accounts_list: - status_idx = gajim.connections[account].connected + status_idx = app.connections[account].connected # uncomment the following to hide offline accounts # if status_idx == 0: continue - status = gajim.SHOW_LIST[status_idx] - message = gajim.connections[account].status + status = app.SHOW_LIST[status_idx] + message = app.connections[account].status single_line = get_uf_show(status) if message is None: message = '' @@ -1354,33 +1354,33 @@ def get_accounts_info(): def get_iconset_path(iconset): - if os.path.isdir(os.path.join(gajim.DATA_DIR, 'iconsets', iconset)): - return os.path.join(gajim.DATA_DIR, 'iconsets', iconset) - elif os.path.isdir(os.path.join(gajim.MY_ICONSETS_PATH, iconset)): - return os.path.join(gajim.MY_ICONSETS_PATH, iconset) + if os.path.isdir(os.path.join(app.DATA_DIR, 'iconsets', iconset)): + return os.path.join(app.DATA_DIR, 'iconsets', iconset) + elif os.path.isdir(os.path.join(app.MY_ICONSETS_PATH, iconset)): + return os.path.join(app.MY_ICONSETS_PATH, iconset) def get_mood_iconset_path(iconset): - if os.path.isdir(os.path.join(gajim.DATA_DIR, 'moods', iconset)): - return os.path.join(gajim.DATA_DIR, 'moods', iconset) - elif os.path.isdir(os.path.join(gajim.MY_MOOD_ICONSETS_PATH, iconset)): - return os.path.join(gajim.MY_MOOD_ICONSETS_PATH, iconset) + if os.path.isdir(os.path.join(app.DATA_DIR, 'moods', iconset)): + return os.path.join(app.DATA_DIR, 'moods', iconset) + elif os.path.isdir(os.path.join(app.MY_MOOD_ICONSETS_PATH, iconset)): + return os.path.join(app.MY_MOOD_ICONSETS_PATH, iconset) def get_activity_iconset_path(iconset): - if os.path.isdir(os.path.join(gajim.DATA_DIR, 'activities', iconset)): - return os.path.join(gajim.DATA_DIR, 'activities', iconset) - elif os.path.isdir(os.path.join(gajim.MY_ACTIVITY_ICONSETS_PATH, + if os.path.isdir(os.path.join(app.DATA_DIR, 'activities', iconset)): + return os.path.join(app.DATA_DIR, 'activities', iconset) + elif os.path.isdir(os.path.join(app.MY_ACTIVITY_ICONSETS_PATH, iconset)): - return os.path.join(gajim.MY_ACTIVITY_ICONSETS_PATH, iconset) + return os.path.join(app.MY_ACTIVITY_ICONSETS_PATH, iconset) def get_transport_path(transport): - if os.path.isdir(os.path.join(gajim.DATA_DIR, 'iconsets', 'transports', + if os.path.isdir(os.path.join(app.DATA_DIR, 'iconsets', 'transports', transport)): - return os.path.join(gajim.DATA_DIR, 'iconsets', 'transports', transport) - elif os.path.isdir(os.path.join(gajim.MY_ICONSETS_PATH, 'transports', + return os.path.join(app.DATA_DIR, 'iconsets', 'transports', transport) + elif os.path.isdir(os.path.join(app.MY_ICONSETS_PATH, 'transports', transport)): - return os.path.join(gajim.MY_ICONSETS_PATH, 'transports', transport) + return os.path.join(app.MY_ICONSETS_PATH, 'transports', transport) # No transport folder found, use default jabber one - return get_iconset_path(gajim.config.get('iconset')) + return get_iconset_path(app.config.get('iconset')) def prepare_and_validate_gpg_keyID(account, jid, keyID): """ @@ -1391,11 +1391,11 @@ def prepare_and_validate_gpg_keyID(account, jid, keyID): assigned key XXXXXXXXMISMATCH is returned. If the key is trusted and not yet assigned, assign it. """ - if gajim.connections[account].USE_GPG: + if app.connections[account].USE_GPG: if keyID and len(keyID) == 16: keyID = keyID[8:] - attached_keys = gajim.config.get_per('accounts', account, + attached_keys = app.config.get_per('accounts', account, 'attached_gpg_keys').split() if jid in attached_keys and keyID: @@ -1403,7 +1403,7 @@ def prepare_and_validate_gpg_keyID(account, jid, keyID): if attachedkeyID != keyID: # Get signing subkeys for the attached key subkeys = [] - for key in gajim.connections[account].gpg.list_keys(): + for key in app.connections[account].gpg.list_keys(): if key['keyid'][8:] == attachedkeyID: subkeys = [subkey[0][8:] for subkey in key['subkeys'] \ if subkey[1] == 's'] @@ -1416,15 +1416,15 @@ def prepare_and_validate_gpg_keyID(account, jid, keyID): # An unsigned presence, just use the assigned key keyID = attached_keys[attached_keys.index(jid) + 1] elif keyID: - full_key = gajim.connections[account].ask_gpg_keys(keyID=keyID) + full_key = app.connections[account].ask_gpg_keys(keyID=keyID) # Assign the corresponding key, if we have it in our keyring if full_key: - for u in gajim.contacts.get_contacts(account, jid): + for u in app.contacts.get_contacts(account, jid): u.keyID = keyID - keys_str = gajim.config.get_per('accounts', account, + keys_str = app.config.get_per('accounts', account, 'attached_gpg_keys') keys_str += jid + ' ' + keyID + ' ' - gajim.config.set_per('accounts', account, 'attached_gpg_keys', + app.config.set_per('accounts', account, 'attached_gpg_keys', keys_str) elif keyID is None: keyID = 'UNKNOWN' @@ -1434,70 +1434,70 @@ def update_optional_features(account = None): if account: accounts = [account] else: - accounts = [a for a in gajim.connections] + accounts = [a for a in app.connections] for a in accounts: - gajim.gajim_optional_features[a] = [] - if gajim.config.get_per('accounts', a, 'subscribe_mood'): - gajim.gajim_optional_features[a].append(nbxmpp.NS_MOOD + '+notify') - if gajim.config.get_per('accounts', a, 'subscribe_activity'): - gajim.gajim_optional_features[a].append(nbxmpp.NS_ACTIVITY + \ + app.gajim_optional_features[a] = [] + if app.config.get_per('accounts', a, 'subscribe_mood'): + app.gajim_optional_features[a].append(nbxmpp.NS_MOOD + '+notify') + if app.config.get_per('accounts', a, 'subscribe_activity'): + app.gajim_optional_features[a].append(nbxmpp.NS_ACTIVITY + \ '+notify') - if gajim.config.get_per('accounts', a, 'publish_tune'): - gajim.gajim_optional_features[a].append(nbxmpp.NS_TUNE) - if gajim.config.get_per('accounts', a, 'publish_location'): - gajim.gajim_optional_features[a].append(nbxmpp.NS_LOCATION) - if gajim.config.get_per('accounts', a, 'subscribe_tune'): - gajim.gajim_optional_features[a].append(nbxmpp.NS_TUNE + '+notify') - if gajim.config.get_per('accounts', a, 'subscribe_nick'): - gajim.gajim_optional_features[a].append(nbxmpp.NS_NICK + '+notify') - if gajim.config.get_per('accounts', a, 'subscribe_location'): - gajim.gajim_optional_features[a].append(nbxmpp.NS_LOCATION + \ + if app.config.get_per('accounts', a, 'publish_tune'): + app.gajim_optional_features[a].append(nbxmpp.NS_TUNE) + if app.config.get_per('accounts', a, 'publish_location'): + app.gajim_optional_features[a].append(nbxmpp.NS_LOCATION) + if app.config.get_per('accounts', a, 'subscribe_tune'): + app.gajim_optional_features[a].append(nbxmpp.NS_TUNE + '+notify') + if app.config.get_per('accounts', a, 'subscribe_nick'): + app.gajim_optional_features[a].append(nbxmpp.NS_NICK + '+notify') + if app.config.get_per('accounts', a, 'subscribe_location'): + app.gajim_optional_features[a].append(nbxmpp.NS_LOCATION + \ '+notify') - if gajim.config.get('outgoing_chat_state_notifactions') != 'disabled': - gajim.gajim_optional_features[a].append(nbxmpp.NS_CHATSTATES) - if not gajim.config.get('ignore_incoming_xhtml'): - gajim.gajim_optional_features[a].append(nbxmpp.NS_XHTML_IM) - if gajim.HAVE_PYCRYPTO \ - and gajim.config.get_per('accounts', a, 'enable_esessions'): - gajim.gajim_optional_features[a].append(nbxmpp.NS_ESESSION) - if gajim.config.get_per('accounts', a, 'answer_receipts'): - gajim.gajim_optional_features[a].append(nbxmpp.NS_RECEIPTS) - gajim.gajim_optional_features[a].append(nbxmpp.NS_JINGLE) - if gajim.HAVE_FARSTREAM: - gajim.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_RTP) - gajim.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_RTP_AUDIO) - gajim.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_RTP_VIDEO) - gajim.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_ICE_UDP) - gajim.gajim_optional_features[a].append( + if app.config.get('outgoing_chat_state_notifactions') != 'disabled': + app.gajim_optional_features[a].append(nbxmpp.NS_CHATSTATES) + if not app.config.get('ignore_incoming_xhtml'): + app.gajim_optional_features[a].append(nbxmpp.NS_XHTML_IM) + if app.HAVE_PYCRYPTO \ + and app.config.get_per('accounts', a, 'enable_esessions'): + app.gajim_optional_features[a].append(nbxmpp.NS_ESESSION) + if app.config.get_per('accounts', a, 'answer_receipts'): + app.gajim_optional_features[a].append(nbxmpp.NS_RECEIPTS) + app.gajim_optional_features[a].append(nbxmpp.NS_JINGLE) + if app.HAVE_FARSTREAM: + app.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_RTP) + app.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_RTP_AUDIO) + app.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_RTP_VIDEO) + app.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_ICE_UDP) + app.gajim_optional_features[a].append( nbxmpp.NS_JINGLE_FILE_TRANSFER_5) - gajim.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_XTLS) - gajim.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_BYTESTREAM) - gajim.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_IBB) - gajim.caps_hash[a] = caps_cache.compute_caps_hash([gajim.gajim_identity], - gajim.gajim_common_features + gajim.gajim_optional_features[a]) + app.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_XTLS) + app.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_BYTESTREAM) + app.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_IBB) + app.caps_hash[a] = caps_cache.compute_caps_hash([app.gajim_identity], + app.gajim_common_features + app.gajim_optional_features[a]) # re-send presence with new hash - connected = gajim.connections[a].connected - if connected > 1 and gajim.SHOW_LIST[connected] != 'invisible': - gajim.connections[a].change_status(gajim.SHOW_LIST[connected], - gajim.connections[a].status) + connected = app.connections[a].connected + if connected > 1 and app.SHOW_LIST[connected] != 'invisible': + app.connections[a].change_status(app.SHOW_LIST[connected], + app.connections[a].status) def jid_is_blocked(account, jid): - return ((jid in gajim.connections[account].blocked_contacts) or \ - gajim.connections[account].blocked_all) + return ((jid in app.connections[account].blocked_contacts) or \ + app.connections[account].blocked_all) def group_is_blocked(account, group): - return ((group in gajim.connections[account].blocked_groups) or \ - gajim.connections[account].blocked_all) + return ((group in app.connections[account].blocked_groups) or \ + app.connections[account].blocked_all) def get_subscription_request_msg(account=None): - s = gajim.config.get_per('accounts', account, 'subscription_request_msg') + s = app.config.get_per('accounts', account, 'subscription_request_msg') if s: return s s = _('I would like to add you to my contact list.') if account: s = _('Hello, I am $name.') + ' ' + s - our_jid = gajim.get_jid_from_account(account) - vcard = gajim.connections[account].get_cached_vcard(our_jid) + our_jid = app.get_jid_from_account(account) + vcard = app.connections[account].get_cached_vcard(our_jid) name = '' if vcard: if 'N' in vcard: @@ -1505,7 +1505,7 @@ def get_subscription_request_msg(account=None): name = vcard['N']['GIVEN'] + ' ' + vcard['N']['FAMILY'] if not name and 'FN' in vcard: name = vcard['FN'] - nick = gajim.nicks[account] + nick = app.nicks[account] if name and nick: name += ' (%s)' % nick elif nick: @@ -1529,9 +1529,9 @@ def replace_dataform_media(form, stanza): return found def get_proxy_info(account): - p = gajim.config.get_per('accounts', account, 'proxy') + p = app.config.get_per('accounts', account, 'proxy') if not p: - if gajim.config.get_per('accounts', account, 'use_env_http_proxy'): + if app.config.get_per('accounts', account, 'use_env_http_proxy'): try: try: env_http_proxy = os.environ['HTTP_PROXY'] @@ -1565,10 +1565,10 @@ def get_proxy_info(account): except Exception: proxy = None - p = gajim.config.get('global_proxy') - if p and p in gajim.config.get_per('proxies'): + p = app.config.get('global_proxy') + if p and p in app.config.get_per('proxies'): proxy = {} - proxyptr = gajim.config.get_per('proxies', p) + proxyptr = app.config.get_per('proxies', p) if not proxyptr: return proxy for key in proxyptr.keys(): @@ -1588,7 +1588,7 @@ def _get_img_direct(attrs): socket.setdefaulttimeout(10) try: req = urllib.request.Request(attrs['src']) - req.add_header('User-Agent', 'Gajim ' + gajim.version) + req.add_header('User-Agent', 'Gajim ' + app.version) f = urllib.request.urlopen(req) except Exception as ex: log.debug('Error loading image %s ' % attrs['src'] + str(ex)) @@ -1638,7 +1638,7 @@ def _get_img_proxy(attrs, proxy): Download an image through a proxy. This function should be launched in a separated thread. """ - if not gajim.HAVE_PYCURL: + if not app.HAVE_PYCURL: return '', _('PyCURL is not installed') mem, alt, max_size = '', '', 2*1024*1024 if 'max_size' in attrs: @@ -1654,7 +1654,7 @@ def _get_img_proxy(attrs, proxy): c.setopt(pycurl.TIMEOUT, 10 * (max_size / 1048576)) c.setopt(pycurl.MAXFILESIZE, max_size) c.setopt(pycurl.WRITEFUNCTION, b.write) - c.setopt(pycurl.USERAGENT, 'Gajim ' + gajim.version) + c.setopt(pycurl.USERAGENT, 'Gajim ' + app.version) # set proxy c.setopt(pycurl.PROXY, proxy['host'].encode('utf-8')) c.setopt(pycurl.PROXYPORT, proxy['port']) diff --git a/gajim/common/jingle.py b/gajim/common/jingle.py index ff137a65d..469dfe555 100644 --- a/gajim/common/jingle.py +++ b/gajim/common/jingle.py @@ -32,12 +32,12 @@ import logging import nbxmpp from gajim.common import helpers -from gajim.common import gajim +from gajim.common import app from gajim.common.jingle_session import JingleSession, JingleStates from gajim.common.jingle_ft import JingleFileTransfer from gajim.common.jingle_transport import JingleTransportSocks5, JingleTransportIBB -if gajim.HAVE_FARSTREAM: +if app.HAVE_FARSTREAM: from gajim.common.jingle_rtp import JingleAudio, JingleVideo logger = logging.getLogger('gajim.c.jingle') @@ -145,12 +145,12 @@ class ConnectionJingle(object): def start_file_transfer(self, jid, file_props, request=False): logger.info("start file transfer with file: %s", file_props) - contact = gajim.contacts.get_contact_with_highest_priority(self.name, - gajim.get_jid_without_resource(jid)) - if gajim.contacts.is_gc_contact(self.name, jid): + contact = app.contacts.get_contact_with_highest_priority(self.name, + app.get_jid_without_resource(jid)) + if app.contacts.is_gc_contact(self.name, jid): gcc = jid.split('/') if len(gcc) == 2: - contact = gajim.contacts.get_gc_contact(self.name, gcc[0], gcc[1]) + contact = app.contacts.get_gc_contact(self.name, gcc[0], gcc[1]) if contact is None: return use_security = contact.supports(nbxmpp.NS_JINGLE_XTLS) diff --git a/gajim/common/jingle_content.py b/gajim/common/jingle_content.py index ab0629265..0d4835606 100644 --- a/gajim/common/jingle_content.py +++ b/gajim/common/jingle_content.py @@ -18,7 +18,7 @@ Handles Jingle contents (XEP 0166) """ import os -from gajim.common import gajim +from gajim.common import app import nbxmpp from gajim.common.jingle_xtls import SELF_SIGNED_CERTIFICATE from gajim.common.jingle_xtls import load_cert_file @@ -206,7 +206,7 @@ class JingleContent: hash_data = self._compute_hash() if hash_data: file_tag.addChild(node=hash_data) - pjid = gajim.get_jid_without_resource(self.session.peerjid) + pjid = app.get_jid_without_resource(self.session.peerjid) file_info = {'name' : self.file_props.name, 'file-name' : self.file_props.file_name, 'hash' : self.file_props.hash_, @@ -221,7 +221,7 @@ class JingleContent: if self.use_security: security = nbxmpp.simplexml.Node( tag=nbxmpp.NS_JINGLE_XTLS + ' security') - certpath = os.path.join(gajim.MY_CERT_DIR, SELF_SIGNED_CERTIFICATE)\ + certpath = os.path.join(app.MY_CERT_DIR, SELF_SIGNED_CERTIFICATE)\ + '.cert' cert = load_cert_file(certpath) if cert: diff --git a/gajim/common/jingle_ft.py b/gajim/common/jingle_ft.py index e462d1969..f0033702f 100644 --- a/gajim/common/jingle_ft.py +++ b/gajim/common/jingle_ft.py @@ -25,7 +25,7 @@ import os import threading from enum import IntEnum, unique import nbxmpp -from gajim.common import gajim +from gajim.common import app from gajim.common import configpaths from gajim.common import jingle_xtls from gajim.common.jingle_content import contents, JingleContent @@ -102,7 +102,7 @@ class JingleFileTransfer(JingleContent): self.session = session self.media = 'file' self.nominated_cand = {} - if gajim.contacts.is_gc_contact(session.connection.name, + if app.contacts.is_gc_contact(session.connection.name, session.peerjid): roomjid = session.peerjid.split('/')[0] dstaddr = hashlib.sha1(('%s%s%s' % (self.file_props.sid, @@ -137,7 +137,7 @@ class JingleFileTransfer(JingleContent): def __on_session_initiate(self, stanza, content, error, action): log.debug("Jingle FT request received") - gajim.nec.push_incoming_event(FileRequestReceivedEvent(None, + app.nec.push_incoming_event(FileRequestReceivedEvent(None, conn=self.session.connection, stanza=stanza, jingle_content=content, @@ -157,7 +157,7 @@ class JingleFileTransfer(JingleContent): payload=[self._compute_hash()])]) checksum.setNamespace(nbxmpp.NS_JINGLE_FILE_TRANSFER_5) self.session.__session_info(checksum) - pjid = gajim.get_jid_without_resource(self.session.peerjid) + pjid = app.get_jid_without_resource(self.session.peerjid) file_info = {'name' : self.file_props.name, 'file-name' : self.file_props.file_name, 'hash' : self.file_props.hash_, @@ -203,7 +203,7 @@ class JingleFileTransfer(JingleContent): if fingerprint: fingerprint = fingerprint.getData() self.x509_fingerprint = fingerprint - if not jingle_xtls.check_cert(gajim.get_jid_without_resource( + if not jingle_xtls.check_cert(app.get_jid_without_resource( self.session.responder), fingerprint): id_ = jingle_xtls.send_cert_request(con, self.session.responder) @@ -238,7 +238,7 @@ class JingleFileTransfer(JingleContent): fingerprint = 'client' if self.transport.type_ == TransportType.SOCKS5: sid = self.file_props.transport_sid - gajim.socks5queue.connect_to_hosts(self.session.connection.name, + app.socks5queue.connect_to_hosts(self.session.connection.name, sid, self.on_connect, self._on_connect_error, @@ -271,8 +271,8 @@ class JingleFileTransfer(JingleContent): self.state >= State.CAND_SENT_AND_RECEIVED: raise nbxmpp.NodeProcessed if cand_error: - if not gajim.socks5queue.listener.connections: - gajim.socks5queue.listener.disconnect() + if not app.socks5queue.listener.connections: + app.socks5queue.listener.disconnect() self.nominated_cand['peer-cand'] = False if self.state == State.CAND_SENT: if not self.nominated_cand['our-cand'] and \ @@ -298,13 +298,13 @@ class JingleFileTransfer(JingleContent): streamhost_used = cand break if streamhost_used is None or streamhost_used['type'] == 'proxy': - if gajim.socks5queue.listener and \ - not gajim.socks5queue.listener.connections: - gajim.socks5queue.listener.disconnect() + if app.socks5queue.listener and \ + not app.socks5queue.listener.connections: + app.socks5queue.listener.disconnect() if content.getTag('transport').getTag('activated'): self.state = State.TRANSFERING - jid = gajim.get_jid_without_resource(self.session.ourjid) - gajim.socks5queue.send_file(self.file_props, + jid = app.get_jid_without_resource(self.session.ourjid) + app.socks5queue.send_file(self.file_props, self.session.connection.name, 'client') return args = {'content': content, @@ -374,11 +374,11 @@ class JingleFileTransfer(JingleContent): sha_str = helpers.get_auth_sha(self.file_props.sid, sender, receiver) self.file_props.sha_str = sha_str - port = gajim.config.get('file_transfers_port') + port = app.config.get('file_transfers_port') fingerprint = None if self.use_security: fingerprint = 'server' - listener = gajim.socks5queue.start_listener(port, sha_str, + listener = app.socks5queue.start_listener(port, sha_str, self._store_socks5_sid, self.file_props, fingerprint=fingerprint, diff --git a/gajim/common/jingle_ftstates.py b/gajim/common/jingle_ftstates.py index d387128df..157613e46 100644 --- a/gajim/common/jingle_ftstates.py +++ b/gajim/common/jingle_ftstates.py @@ -14,7 +14,7 @@ ## along with Gajim. If not, see . import nbxmpp -from gajim.common import gajim +from gajim.common import app from gajim.common.jingle_transport import TransportType from gajim.common.socks5 import Socks5ReceiverClient, Socks5SenderClient @@ -52,7 +52,7 @@ class StateInitialized(JingleFileTransferStates): if self.jft.use_security: fingerprint = 'client' # Connect to the candidate host, on success call on_connect method - gajim.socks5queue.connect_to_hosts(self.jft.session.connection.name, + app.socks5queue.connect_to_hosts(self.jft.session.connection.name, self.jft.file_props.transport_sid, self.jft.on_connect, self.jft._on_connect_error, fingerprint=fingerprint) @@ -154,12 +154,12 @@ class StateTransfering(JingleFileTransferStates): if self.jft.is_our_candidate_used(): mode = 'client' streamhost_used = self.jft.nominated_cand['our-cand'] - gajim.socks5queue.remove_server(self.jft.file_props.transport_sid) + app.socks5queue.remove_server(self.jft.file_props.transport_sid) else: mode = 'server' streamhost_used = self.jft.nominated_cand['peer-cand'] - gajim.socks5queue.remove_client(self.jft.file_props.transport_sid) - gajim.socks5queue.remove_other_servers(streamhost_used['host']) + app.socks5queue.remove_client(self.jft.file_props.transport_sid) + app.socks5queue.remove_other_servers(streamhost_used['host']) if streamhost_used['type'] == 'proxy': self.jft.file_props.is_a_proxy = True if self.jft.file_props.type_ == 's' and self.jft.weinitiate: @@ -170,13 +170,13 @@ class StateTransfering(JingleFileTransferStates): self.jft.file_props.proxy_receiver = streamhost_used[ 'initiator'] if self.jft.file_props.type_ == 's': - s = gajim.socks5queue.senders + s = app.socks5queue.senders for sender in s: if s[sender].host == streamhost_used['host'] and \ s[sender].connected: return elif self.jft.file_props.type_ == 'r': - r = gajim.socks5queue.readers + r = app.socks5queue.readers for reader in r: if r[reader].host == streamhost_used['host'] and \ r[reader].connected: @@ -190,32 +190,32 @@ class StateTransfering(JingleFileTransferStates): self.jft.file_props.proxyhosts = [] self.jft.file_props.proxyhosts.append(streamhost_used) if self.jft.file_props.type_ == 's': - gajim.socks5queue.idx += 1 - idx = gajim.socks5queue.idx - sockobj = Socks5SenderClient(gajim.idlequeue, idx, - gajim.socks5queue, _sock=None, + app.socks5queue.idx += 1 + idx = app.socks5queue.idx + sockobj = Socks5SenderClient(app.idlequeue, idx, + app.socks5queue, _sock=None, host=str(streamhost_used['host']), port=int(streamhost_used['port']), fingerprint=None, connected=False, file_props=self.jft.file_props) else: - sockobj = Socks5ReceiverClient(gajim.idlequeue, streamhost_used, + sockobj = Socks5ReceiverClient(app.idlequeue, streamhost_used, transport_sid=self.jft.file_props.transport_sid, file_props=self.jft.file_props, fingerprint=None) sockobj.proxy = True sockobj.streamhost = streamhost_used - gajim.socks5queue.add_sockobj(self.jft.session.connection.name, + app.socks5queue.add_sockobj(self.jft.session.connection.name, sockobj) streamhost_used['idx'] = sockobj.queue_idx # If we offered the nominated candidate used, we activate # the proxy if not self.jft.is_our_candidate_used(): - gajim.socks5queue.on_success[self.jft.file_props.transport_sid]\ + app.socks5queue.on_success[self.jft.file_props.transport_sid]\ = self.jft.transport._on_proxy_auth_ok # TODO: add on failure else: - jid = gajim.get_jid_without_resource(self.jft.session.ourjid) - gajim.socks5queue.send_file(self.jft.file_props, + jid = app.get_jid_without_resource(self.jft.session.ourjid) + app.socks5queue.send_file(self.jft.file_props, self.jft.session.connection.name, mode) def action(self, args=None): diff --git a/gajim/common/jingle_rtp.py b/gajim/common/jingle_rtp.py index ae9669031..b6ead263e 100644 --- a/gajim/common/jingle_rtp.py +++ b/gajim/common/jingle_rtp.py @@ -27,7 +27,7 @@ gi.require_version('Gst', '1.0') from gi.repository import Gst from gi.repository import GLib -from gajim.common import gajim +from gajim.common import app from gajim.common.jingle_transport import JingleTransportICEUDP from gajim.common.jingle_content import contents, JingleContent, JingleContentSetupException @@ -90,8 +90,8 @@ class JingleRTPContent(JingleContent): # due to bad controlling-mode params = {'controlling-mode': self.session.weinitiate, 'debug': False} - if gajim.config.get('use_stun_server'): - stun_server = gajim.config.get('stun_server') + if app.config.get('use_stun_server'): + stun_server = app.config.get('stun_server') if not stun_server and self.session.connection._stun_servers: stun_server = self.session.connection._stun_servers[0]['host'] if stun_server: @@ -112,12 +112,12 @@ class JingleRTPContent(JingleContent): return JingleContent.is_ready(self) and self.candidates_ready def make_bin_from_config(self, config_key, pipeline, text): - pipeline = pipeline % gajim.config.get(config_key) + pipeline = pipeline % app.config.get(config_key) try: gst_bin = Gst.parse_bin_from_description(pipeline, True) return gst_bin except GLib.GError as e: - gajim.nec.push_incoming_event( + app.nec.push_incoming_event( InformationEvent( None, conn=self.session.connection, level='error', pri_txt=_('%s configuration error') % text.capitalize(), @@ -224,7 +224,7 @@ class JingleRTPContent(JingleContent): # or raise an error, Jingle way # or maybe one-sided stream? if not self.stream_failed_once: - gajim.nec.push_incoming_event( + app.nec.push_incoming_event( InformationEvent( None, conn=self.session.connection, level='error', pri_txt=_('GStreamer error'), @@ -406,23 +406,23 @@ class JingleVideo(JingleRTPContent): bus.connect('sync-message::element', self._on_sync_message) # the local parts - if gajim.config.get('video_framerate'): + if app.config.get('video_framerate'): framerate = 'videorate ! video/x-raw,framerate=%s ! ' % \ - gajim.config.get('video_framerate') + app.config.get('video_framerate') else: framerate = '' try: - w, h = gajim.config.get('video_size').split('x') + w, h = app.config.get('video_size').split('x') except: w = h = None if w and h: video_size = 'video/x-raw,width=%s,height=%s ! ' % (w, h) else: video_size = '' - if gajim.config.get('video_see_self'): + if app.config.get('video_see_self'): tee = '! tee name=t ! queue ! videoscale ! ' + \ 'video/x-raw,width=160,height=120 ! videoconvert ! ' + \ - '%s t. ! queue ' % gajim.config.get( + '%s t. ! queue ' % app.config.get( 'video_output_device') else: tee = '' @@ -453,7 +453,7 @@ class JingleVideo(JingleRTPContent): if message.get_structure().get_name() == 'prepare-window-handle': message.src.set_property('force-aspect-ratio', True) imagesink = message.src - if gajim.config.get('video_see_self') and not self.out_xid_set: + if app.config.get('video_see_self') and not self.out_xid_set: imagesink.set_window_handle(self.out_xid) self.out_xid_set = True else: diff --git a/gajim/common/jingle_session.py b/gajim/common/jingle_session.py index 3e10ea726..e075e67cf 100644 --- a/gajim/common/jingle_session.py +++ b/gajim/common/jingle_session.py @@ -31,7 +31,7 @@ Handles Jingle sessions (XEP 0166) import logging from enum import Enum, unique import nbxmpp -from gajim.common import gajim +from gajim.common import app from gajim.common.jingle_transport import get_jingle_transport, JingleTransportIBB from gajim.common.jingle_content import get_jingle_content, JingleContentSetupException, JingleContent from gajim.common.jingle_ft import State @@ -40,7 +40,7 @@ from gajim.common.connection_handlers_events import ( JingleTransferCancelledEvent, JingleConnectedReceivedEvent, JingleErrorReceivedEvent) -log = logging.getLogger("gajim.c.jingle_session") +log = logging.getLogger("app.c.jingle_session") # FIXME: Move it to JingleSession.States? @unique @@ -86,7 +86,7 @@ class JingleSession: self.contents = {} # negotiated contents self.connection = con # connection to use # our full jid - self.ourjid = gajim.get_jid_from_account(self.connection.name) + self.ourjid = app.get_jid_from_account(self.connection.name) if con.server_resource: self.ourjid = self.ourjid + '/' + con.server_resource self.peerjid = jid # jid we connect to @@ -462,7 +462,7 @@ class JingleSession: if (creator, name) in self.contents: content = self.contents[(creator, name)] # TODO: this will fail if content is not an RTP content - gajim.nec.push_incoming_event(JingleDisconnectedReceivedEvent( + app.nec.push_incoming_event(JingleDisconnectedReceivedEvent( None, conn=self.connection, jingle_session=self, media=content.media, reason='removed')) content.destroy() @@ -501,7 +501,7 @@ class JingleSession: self.add_content(name, content, creator) self.__content_reject(content) self.contents[(content.creator, content.name)].destroy() - gajim.nec.push_incoming_event(JingleRequestReceivedEvent(None, + app.nec.push_incoming_event(JingleRequestReceivedEvent(None, conn=self.connection, jingle_session=self, contents=contents)) @@ -544,7 +544,7 @@ class JingleSession: hash_data = hash_tag.getData() if hash_tag else None n = request.getTag('file').getTag('name') n = n.getData() if n else None - pjid = gajim.get_jid_without_resource(self.peerjid) + pjid = app.get_jid_without_resource(self.peerjid) file_info = self.connection.get_file_info(pjid, hash_data, n, self.connection.name) if not file_info: @@ -563,7 +563,7 @@ class JingleSession: raise nbxmpp.NodeProcessed self.state = JingleStates.PENDING # Send event about starting a session - gajim.nec.push_incoming_event(JingleRequestReceivedEvent(None, + app.nec.push_incoming_event(JingleRequestReceivedEvent(None, conn=self.connection, jingle_session=self, contents=contents[0])) @@ -603,7 +603,7 @@ class JingleSession: # TODO text = reason if reason == 'cancel' and self.session_type_ft: - gajim.nec.push_incoming_event(JingleTransferCancelledEvent(None, + app.nec.push_incoming_event(JingleTransferCancelledEvent(None, conn=self.connection, jingle_session=self, media=None, @@ -656,7 +656,7 @@ class JingleSession: if text: text = '%s (%s)' % (error, text) if type_ != 'modify': - gajim.nec.push_incoming_event(JingleErrorReceivedEvent(None, + app.nec.push_incoming_event(JingleErrorReceivedEvent(None, conn=self.connection, jingle_session=self, reason=text or error)) @@ -774,7 +774,7 @@ class JingleSession: else: text = reason self.connection.delete_jingle_session(self.sid) - gajim.nec.push_incoming_event(JingleDisconnectedReceivedEvent(None, + app.nec.push_incoming_event(JingleDisconnectedReceivedEvent(None, conn=self.connection, jingle_session=self, media=None, @@ -804,7 +804,7 @@ class JingleSession: self.__append_content(jingle, content) self.connection.connection.send(stanza) # TODO: this will fail if content is not an RTP content - gajim.nec.push_incoming_event(JingleDisconnectedReceivedEvent(None, + app.nec.push_incoming_event(JingleDisconnectedReceivedEvent(None, conn=self.connection, jingle_session=self, media=content.media, @@ -820,14 +820,14 @@ class JingleSession: self.__append_content(jingle, content) self.connection.connection.send(stanza) # TODO: this will fail if content is not an RTP content - gajim.nec.push_incoming_event(JingleDisconnectedReceivedEvent(None, + app.nec.push_incoming_event(JingleDisconnectedReceivedEvent(None, conn=self.connection, jingle_session=self, media=content.media, reason='removed')) def content_negotiated(self, media): - gajim.nec.push_incoming_event(JingleConnectedReceivedEvent(None, + app.nec.push_incoming_event(JingleConnectedReceivedEvent(None, conn=self.connection, jingle_session=self, media=media)) diff --git a/gajim/common/jingle_transport.py b/gajim/common/jingle_transport.py index 701a2a040..51ab5550b 100644 --- a/gajim/common/jingle_transport.py +++ b/gajim/common/jingle_transport.py @@ -21,7 +21,7 @@ import logging import socket from enum import IntEnum, unique import nbxmpp -from gajim.common import gajim +from gajim.common import app log = logging.getLogger('gajim.c.jingle_transport') @@ -180,12 +180,12 @@ class JingleTransportSocks5(JingleTransport): self.candidates.append(cand) def _add_local_ips_as_candidates(self): - if not gajim.config.get_per('accounts', self.connection.name, + if not app.config.get_per('accounts', self.connection.name, 'ft_send_local_ips'): return if not self.connection: return - port = int(gajim.config.get('file_transfers_port')) + port = int(app.config.get('file_transfers_port')) #type preference of connection type. XEP-0260 section 2.2 type_preference = 126 priority = (2**16) * type_preference @@ -275,8 +275,8 @@ class JingleTransportSocks5(JingleTransport): type_preference = 126 priority = (2**16) * type_preference additional_ip_cand = [] - port = int(gajim.config.get('file_transfers_port')) - ft_add_hosts = gajim.config.get('ft_add_hosts_to_send') + port = int(app.config.get('file_transfers_port')) + ft_add_hosts = app.config.get('ft_add_hosts_to_send') if ft_add_hosts: hosts = [e.strip() for e in ft_add_hosts.split(',')] @@ -426,7 +426,7 @@ class JingleTransportICEUDP(JingleTransport): 'network': '0', 'port': candidate.port, 'priority': int(candidate.priority), # hack - 'id': gajim.get_an_id() + 'id': app.get_an_id() } if candidate.type in types: attrs['type'] = types[candidate.type] diff --git a/gajim/common/jingle_xtls.py b/gajim/common/jingle_xtls.py index 3ae94a710..7744df133 100644 --- a/gajim/common/jingle_xtls.py +++ b/gajim/common/jingle_xtls.py @@ -20,7 +20,7 @@ import logging import os import nbxmpp -from gajim.common import gajim +from gajim.common import app log = logging.getLogger('gajim.c.jingle_xtls') @@ -111,18 +111,18 @@ def get_context(fingerprint, verify_cb=None, remote_jid=None): elif fingerprint == 'client': ctx.set_verify(SSL.VERIFY_PEER, verify_cb or default_callback) - cert_name = os.path.join(gajim.MY_CERT_DIR, SELF_SIGNED_CERTIFICATE) + cert_name = os.path.join(app.MY_CERT_DIR, SELF_SIGNED_CERTIFICATE) ctx.use_privatekey_file((cert_name + '.pkey').encode('utf-8')) ctx.use_certificate_file((cert_name + '.cert').encode('utf-8')) # Try to load Diffie-Hellman parameters. # First try user DH parameters, if this fails load the default DH parameters - dh_params_name = os.path.join(gajim.MY_CERT_DIR, DH_PARAMS) + dh_params_name = os.path.join(app.MY_CERT_DIR, DH_PARAMS) try: with open(dh_params_name, "r") as dh_params_file: ctx.load_tmp_dh(dh_params_name.encode('utf-8')) except FileNotFoundError as err: - default_dh_params_name = os.path.join(gajim.DATA_DIR, + default_dh_params_name = os.path.join(app.DATA_DIR, 'other', DEFAULT_DH_PARAMS) try: with open(default_dh_params_name, "r") as default_dh_params_file: @@ -134,7 +134,7 @@ def get_context(fingerprint, verify_cb=None, remote_jid=None): if remote_jid: store = ctx.get_cert_store() - path = os.path.join(os.path.expanduser(gajim.MY_PEER_CERTS_PATH), + path = os.path.join(os.path.expanduser(app.MY_PEER_CERTS_PATH), remote_jid) + '.cert' if os.path.exists(path): load_cert_file(path, cert_store=store) @@ -151,7 +151,7 @@ def read_cert(certpath): return certificate def send_cert(con, jid_from, sid): - certpath = os.path.join(gajim.MY_CERT_DIR, SELF_SIGNED_CERTIFICATE) + \ + certpath = os.path.join(app.MY_CERT_DIR, SELF_SIGNED_CERTIFICATE) + \ '.cert' certificate = read_cert(certpath) iq = nbxmpp.Iq('result', to=jid_from) @@ -169,8 +169,8 @@ def send_cert(con, jid_from, sid): con.send(iq) def handle_new_cert(con, obj, jid_from): - jid = gajim.get_jid_without_resource(jid_from) - certpath = os.path.join(os.path.expanduser(gajim.MY_PEER_CERTS_PATH), jid) + jid = app.get_jid_without_resource(jid_from) + certpath = os.path.join(os.path.expanduser(app.MY_PEER_CERTS_PATH), jid) certpath += '.cert' id_ = obj.getAttr('id') @@ -188,7 +188,7 @@ def handle_new_cert(con, obj, jid_from): approve_pending_content(id_) def check_cert(jid, fingerprint): - certpath = os.path.join(os.path.expanduser(gajim.MY_PEER_CERTS_PATH), jid) + certpath = os.path.join(os.path.expanduser(app.MY_PEER_CERTS_PATH), jid) certpath += '.cert' if os.path.exists(certpath): cert = load_cert_file(certpath) diff --git a/gajim/common/location_listener.py b/gajim/common/location_listener.py index 0fcffc996..10afafa4d 100644 --- a/gajim/common/location_listener.py +++ b/gajim/common/location_listener.py @@ -20,7 +20,7 @@ from datetime import datetime -from gajim.common import gajim +from gajim.common import app from gajim.common import dbus_support if dbus_support.supported: import dbus @@ -121,11 +121,11 @@ class LocationListener: self._send_location() def _send_location(self): - accounts = gajim.connections.keys() + accounts = app.connections.keys() for acct in accounts: - if not gajim.account_is_connected(acct): + if not app.account_is_connected(acct): continue - if not gajim.config.get_per('accounts', acct, 'publish_location'): + if not app.config.get_per('accounts', acct, 'publish_location'): continue if self.location_info == self._data: continue @@ -136,7 +136,7 @@ class LocationListener: del new_data['timestamp'] if last_data == new_data: continue - gajim.connections[acct].send_location(self._data) + app.connections[acct].send_location(self._data) self.location_info = self._data.copy() def _timestamp_to_utc(self, timestamp): diff --git a/gajim/common/logger.py b/gajim/common/logger.py index d5765c3ba..a1f5873bd 100644 --- a/gajim/common/logger.py +++ b/gajim/common/logger.py @@ -41,14 +41,14 @@ from gi.repository import GLib from enum import IntEnum, unique from gajim.common import exceptions -from gajim.common import gajim +from gajim.common import app from gajim.common import ged import sqlite3 as sqlite -LOG_DB_PATH = gajim.gajimpaths['LOG_DB'] +LOG_DB_PATH = app.gajimpaths['LOG_DB'] LOG_DB_FOLDER, LOG_DB_FILE = os.path.split(LOG_DB_PATH) -CACHE_DB_PATH = gajim.gajimpaths['CACHE_DB'] +CACHE_DB_PATH = app.gajimpaths['CACHE_DB'] import logging log = logging.getLogger('gajim.c.logger') @@ -139,7 +139,7 @@ class Logger: return named_row def dispatch(self, event, error): - gajim.ged.raise_event(event, None, str(error)) + app.ged.raise_event(event, None, str(error)) def close_db(self): if self.con: @@ -196,7 +196,7 @@ class Logger: """ returns the timeout in epoch """ - timeout = gajim.config.get('restore_timeout') + timeout = app.config.get('restore_timeout') now = int(time.time()) if timeout > 0: @@ -284,7 +284,7 @@ class Logger: returns a list of JIDs' """ - family = gajim.contacts.get_metacontacts_family(account, jid) + family = app.contacts.get_metacontacts_family(account, jid) if family: return [user['jid'] for user in family] return [jid] @@ -553,7 +553,7 @@ class Logger: returns a list of namedtuples """ - restore = gajim.config.get('restore_lines') + restore = app.config.get('restore_lines') if restore <= 0: return [] @@ -914,9 +914,9 @@ class Logger: # First we must reset roster_version value to ensure that the server # sends back all the roster at the next connexion if the replacement # didn't work properly. - gajim.config.set_per('accounts', account_name, 'roster_version', '') + app.config.set_per('accounts', account_name, 'roster_version', '') - account_jid = gajim.get_jid_from_account(account_name) + account_jid = app.get_jid_from_account(account_name) account_jid_id = self.get_jid_id(account_jid) # Delete old roster @@ -931,7 +931,7 @@ class Logger: # At this point, we are sure the replacement works properly so we can # set the new roster_version value. - gajim.config.set_per('accounts', account_name, 'roster_version', + app.config.set_per('accounts', account_name, 'roster_version', roster_version) def del_contact(self, account_jid, jid): diff --git a/gajim/common/message_archiving.py b/gajim/common/message_archiving.py index 95281465c..2ac6843e2 100644 --- a/gajim/common/message_archiving.py +++ b/gajim/common/message_archiving.py @@ -23,7 +23,7 @@ from datetime import datetime, timedelta import nbxmpp -from gajim.common import gajim +from gajim.common import app from gajim.common import ged from gajim.common.logger import KindConstant, JIDConstant import gajim.common.connection_handlers_events as ev @@ -38,33 +38,33 @@ class ConnectionArchive313: self.iq_answer = [] self.mam_query_date = None self.mam_query_id = None - gajim.nec.register_incoming_event(ev.MamMessageReceivedEvent) - gajim.ged.register_event_handler('archiving-finished-legacy', ged.CORE, + app.nec.register_incoming_event(ev.MamMessageReceivedEvent) + app.ged.register_event_handler('archiving-finished-legacy', ged.CORE, self._nec_result_finished) - gajim.ged.register_event_handler('archiving-finished', ged.CORE, + app.ged.register_event_handler('archiving-finished', ged.CORE, self._nec_result_finished) - gajim.ged.register_event_handler('agent-info-error-received', ged.CORE, + app.ged.register_event_handler('agent-info-error-received', ged.CORE, self._nec_agent_info_error) - gajim.ged.register_event_handler('agent-info-received', ged.CORE, + app.ged.register_event_handler('agent-info-received', ged.CORE, self._nec_agent_info) - gajim.ged.register_event_handler('mam-decrypted-message-received', + app.ged.register_event_handler('mam-decrypted-message-received', ged.CORE, self._nec_mam_decrypted_message_received) - gajim.ged.register_event_handler( + app.ged.register_event_handler( 'archiving-313-preferences-changed-received', ged.CORE, self._nec_archiving_313_preferences_changed_received) def cleanup(self): - gajim.ged.remove_event_handler('archiving-finished-legacy', ged.CORE, + app.ged.remove_event_handler('archiving-finished-legacy', ged.CORE, self._nec_result_finished) - gajim.ged.remove_event_handler('archiving-finished', ged.CORE, + app.ged.remove_event_handler('archiving-finished', ged.CORE, self._nec_result_finished) - gajim.ged.remove_event_handler('agent-info-error-received', ged.CORE, + app.ged.remove_event_handler('agent-info-error-received', ged.CORE, self._nec_agent_info_error) - gajim.ged.remove_event_handler('agent-info-received', ged.CORE, + app.ged.remove_event_handler('agent-info-received', ged.CORE, self._nec_agent_info) - gajim.ged.remove_event_handler('mam-decrypted-message-received', + app.ged.remove_event_handler('mam-decrypted-message-received', ged.CORE, self._nec_mam_decrypted_message_received) - gajim.ged.remove_event_handler( + app.ged.remove_event_handler( 'archiving-313-preferences-changed-received', ged.CORE, self._nec_archiving_313_preferences_changed_received) @@ -86,17 +86,17 @@ class ConnectionArchive313: continue # it's a groupchat for msg_obj in self.mam_awaiting_disco_result[obj.jid]: - gajim.logger.insert_jid(msg_obj.with_.getStripped(), + app.logger.insert_jid(msg_obj.with_.getStripped(), type_=JIDConstant.ROOM_TYPE) - gajim.nec.push_incoming_event( + app.nec.push_incoming_event( ev.MamDecryptedMessageReceivedEvent( None, disco=True, **vars(msg_obj))) del self.mam_awaiting_disco_result[obj.jid] return # it's not a groupchat for msg_obj in self.mam_awaiting_disco_result[obj.jid]: - gajim.logger.insert_jid(msg_obj.with_.getStripped()) - gajim.nec.push_incoming_event( + app.logger.insert_jid(msg_obj.with_.getStripped()) + app.nec.push_incoming_event( ev.MamDecryptedMessageReceivedEvent( None, disco=True, **vars(msg_obj))) del self.mam_awaiting_disco_result[obj.jid] @@ -113,13 +113,13 @@ class ConnectionArchive313: last = set_.getTagData('last') complete = obj.fin.getAttr('complete') if last: - gajim.config.set_per('accounts', self.name, 'last_mam_id', last) + app.config.set_per('accounts', self.name, 'last_mam_id', last) if complete != 'true': self.request_archive(self.get_query_id(), after=last) if complete == 'true': self.mam_query_id = None if self.mam_query_date: - gajim.config.set_per( + app.config.set_per( 'accounts', self.name, 'mam_start_date', self.mam_query_date.timestamp()) self.mam_query_date = None @@ -127,10 +127,10 @@ class ConnectionArchive313: def _nec_mam_decrypted_message_received(self, obj): if obj.conn.name != self.name: return - duplicate = gajim.logger.search_for_duplicate( + duplicate = app.logger.search_for_duplicate( obj.with_, obj.timestamp, obj.msgtxt) if not duplicate: - gajim.logger.insert_into_logs( + app.logger.insert_into_logs( obj.with_, obj.timestamp, obj.kind, unread=False, message=obj.msgtxt) @@ -140,7 +140,7 @@ class ConnectionArchive313: return self.mam_query_id def request_archive_on_signin(self): - mam_id = gajim.config.get_per('accounts', self.name, 'last_mam_id') + mam_id = app.config.get_per('accounts', self.name, 'last_mam_id') query_id = self.get_query_id() if mam_id: self.request_archive(query_id, after=mam_id) @@ -184,7 +184,7 @@ class ConnectionArchive313: self.connection.send(iq) def request_archive_preferences(self): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='get') id_ = self.connection.getAnID() @@ -193,7 +193,7 @@ class ConnectionArchive313: self.connection.send(iq) def set_archive_preferences(self, items, default): - if not gajim.account_is_connected(self.name): + if not app.account_is_connected(self.name): return iq = nbxmpp.Iq(typ='set') id_ = self.connection.getAnID() @@ -211,6 +211,6 @@ class ConnectionArchive313: self.connection.send(iq) def _ArchiveCB(self, con, iq_obj): - gajim.nec.push_incoming_event(ev.ArchivingReceivedEvent(None, conn=self, + app.nec.push_incoming_event(ev.ArchivingReceivedEvent(None, conn=self, stanza=iq_obj)) raise nbxmpp.NodeProcessed diff --git a/gajim/common/nec.py b/gajim/common/nec.py index 037f09edb..d59842843 100644 --- a/gajim/common/nec.py +++ b/gajim/common/nec.py @@ -26,7 +26,7 @@ Network Events Controller. ''' #from plugins.helpers import log -from gajim.common import gajim +from gajim.common import app class NetworkEventsController(object): @@ -72,12 +72,12 @@ class NetworkEventsController(object): def push_incoming_event(self, event_object): if event_object.generate(): - if not gajim.ged.raise_event(event_object.name, event_object): + if not app.ged.raise_event(event_object.name, event_object): self._generate_events_based_on_incoming_event(event_object) def push_outgoing_event(self, event_object): if event_object.generate(): - if not gajim.ged.raise_event(event_object.name, event_object): + if not app.ged.raise_event(event_object.name, event_object): self._generate_events_based_on_outgoing_event(event_object) def _generate_events_based_on_incoming_event(self, event_object): @@ -96,7 +96,7 @@ class NetworkEventsController(object): new_event_object = new_event_class(None, base_event=event_object) if new_event_object.generate(): - if not gajim.ged.raise_event(new_event_object.name, + if not app.ged.raise_event(new_event_object.name, new_event_object): self._generate_events_based_on_incoming_event( new_event_object) @@ -117,7 +117,7 @@ class NetworkEventsController(object): new_event_object = new_event_class(None, base_event=event_object) if new_event_object.generate(): - if not gajim.ged.raise_event(new_event_object.name, + if not app.ged.raise_event(new_event_object.name, new_event_object): self._generate_events_based_on_outgoing_event( new_event_object) diff --git a/gajim/common/optparser.py b/gajim/common/optparser.py index 65d733eb0..273558b70 100644 --- a/gajim/common/optparser.py +++ b/gajim/common/optparser.py @@ -30,7 +30,7 @@ import os import sys import re from time import time -from gajim.common import gajim +from gajim.common import app from gajim.common import helpers from gajim.common import caps_cache @@ -56,7 +56,7 @@ class OptionsParser: file=sys.stderr) return False - new_version = gajim.config.get('version') + new_version = app.config.get('version') new_version = new_version.split('-', 1)[0] seen = set() regex = re.compile(r"(?P[^.=]+)(?:(?:\.(?P.+))?\.(?P[^.=]+))?\s=\s(?P.*)") @@ -69,19 +69,19 @@ class OptionsParser: optname, key, subname, value = match.groups() if key is None: self.old_values[optname] = value - gajim.config.set(optname, value) + app.config.set(optname, value) else: if (optname, key) not in seen: if optname in self.old_values: self.old_values[optname][key] = {} else: self.old_values[optname] = {key: {}} - gajim.config.add_per(optname, key) + app.config.add_per(optname, key) seen.add((optname, key)) self.old_values[optname][key][subname] = value - gajim.config.set_per(optname, key, subname, value) + app.config.set_per(optname, key, subname, value) - old_version = gajim.config.get('version') + old_version = app.config.get('version') old_version = old_version.split('-', 1)[0] self.update_config(old_version, new_version) @@ -113,7 +113,7 @@ class OptionsParser: except IOError as e: return str(e) try: - gajim.config.foreach(self.write_line, f) + app.config.foreach(self.write_line, f) except IOError as e: return str(e) f.flush() @@ -241,9 +241,9 @@ class OptionsParser: if old < [0, 16, 10, 5] and new >= [0, 16, 10, 5]: self.update_config_to_016105() - gajim.logger.init_vars() - gajim.logger.attach_cache_database() - gajim.config.set('version', new_version) + app.logger.init_vars() + app.logger.attach_cache_database() + app.config.set('version', new_version) caps_cache.capscache.initialize_from_db() @@ -267,7 +267,7 @@ class OptionsParser: ''' ) con.commit() - gajim.logger.init_vars() + app.logger.init_vars() except sqlite.OperationalError: pass con.close() @@ -278,8 +278,8 @@ class OptionsParser: to_remove = [] if to_add is None: to_add = [] - for account in gajim.config.get_per('accounts'): - proxies_str = gajim.config.get_per('accounts', account, + for account in app.config.get_per('accounts'): + proxies_str = app.config.get_per('accounts', account, 'file_transfer_proxies') proxies = [p.strip() for p in proxies_str.split(',')] for wrong_proxy in to_remove: @@ -289,23 +289,23 @@ class OptionsParser: if new_proxy not in proxies: proxies.append(new_proxy) proxies_str = ', '.join(proxies) - gajim.config.set_per('accounts', account, 'file_transfer_proxies', + app.config.set_per('accounts', account, 'file_transfer_proxies', proxies_str) def update_config_x_to_09(self): # Var name that changed: # avatar_width /height -> chat_avatar_width / height if 'avatar_width' in self.old_values: - gajim.config.set('chat_avatar_width', self.old_values['avatar_width']) + app.config.set('chat_avatar_width', self.old_values['avatar_width']) if 'avatar_height' in self.old_values: - gajim.config.set('chat_avatar_height', self.old_values['avatar_height']) + app.config.set('chat_avatar_height', self.old_values['avatar_height']) if 'use_dbus' in self.old_values: - gajim.config.set('remote_control', self.old_values['use_dbus']) + app.config.set('remote_control', self.old_values['use_dbus']) # always_compact_view -> always_compact_view_chat / _gc if 'always_compact_view' in self.old_values: - gajim.config.set('always_compact_view_chat', + app.config.set('always_compact_view_chat', self.old_values['always_compact_view']) - gajim.config.set('always_compact_view_gc', + app.config.set('always_compact_view_gc', self.old_values['always_compact_view']) # new theme: grocery, plain d = ['accounttextcolor', 'accountbgcolor', 'accountfont', @@ -314,64 +314,64 @@ class OptionsParser: 'contactfontattrs', 'bannertextcolor', 'bannerbgcolor', 'bannerfont', 'bannerfontattrs'] for theme_name in (_('grocery'), _('default')): - if theme_name not in gajim.config.get_per('themes'): - gajim.config.add_per('themes', theme_name) - theme = gajim.config.themes_default[theme_name] + if theme_name not in app.config.get_per('themes'): + app.config.add_per('themes', theme_name) + theme = app.config.themes_default[theme_name] for o in d: - gajim.config.set_per('themes', theme_name, o, theme[d.index(o)]) + app.config.set_per('themes', theme_name, o, theme[d.index(o)]) # Remove cyan theme if it's not the current theme - if 'cyan' in gajim.config.get_per('themes'): - gajim.config.del_per('themes', 'cyan') - if _('cyan') in gajim.config.get_per('themes'): - gajim.config.del_per('themes', _('cyan')) + if 'cyan' in app.config.get_per('themes'): + app.config.del_per('themes', 'cyan') + if _('cyan') in app.config.get_per('themes'): + app.config.del_per('themes', _('cyan')) # If we removed our roster_theme, choose the default green one or another # one if doesn't exists in config - if gajim.config.get('roster_theme') not in gajim.config.get_per('themes'): + if app.config.get('roster_theme') not in app.config.get_per('themes'): theme = _('green') - if theme not in gajim.config.get_per('themes'): - theme = gajim.config.get_per('themes')[0] - gajim.config.set('roster_theme', theme) + if theme not in app.config.get_per('themes'): + theme = app.config.get_per('themes')[0] + app.config.set('roster_theme', theme) # new proxies in accounts.name.file_transfer_proxies self.update_ft_proxies(to_add=['proxy.netlab.cz']) - gajim.config.set('version', '0.9') + app.config.set('version', '0.9') def update_config_09_to_010(self): if 'usetabbedchat' in self.old_values and not \ self.old_values['usetabbedchat']: - gajim.config.set('one_message_window', 'never') + app.config.set('one_message_window', 'never') if 'autodetect_browser_mailer' in self.old_values and \ self.old_values['autodetect_browser_mailer'] is True: - gajim.config.set('autodetect_browser_mailer', False) + app.config.set('autodetect_browser_mailer', False) if 'useemoticons' in self.old_values and \ not self.old_values['useemoticons']: - gajim.config.set('emoticons_theme', '') + app.config.set('emoticons_theme', '') if 'always_compact_view_chat' in self.old_values and \ self.old_values['always_compact_view_chat'] != 'False': - gajim.config.set('always_hide_chat_buttons', True) + app.config.set('always_hide_chat_buttons', True) if 'always_compact_view_gc' in self.old_values and \ self.old_values['always_compact_view_gc'] != 'False': - gajim.config.set('always_hide_groupchat_buttons', True) + app.config.set('always_hide_groupchat_buttons', True) self.update_ft_proxies(to_remove=['proxy65.jabber.autocom.pl', 'proxy65.jabber.ccc.de'], to_add=['transfer.jabber.freenet.de']) # create unread_messages table if needed self.assert_unread_msgs_table_exists() - gajim.config.set('version', '0.10') + app.config.set('version', '0.10') def update_config_to_01011(self): if 'print_status_in_muc' in self.old_values and \ self.old_values['print_status_in_muc'] in (True, False): - gajim.config.set('print_status_in_muc', 'in_and_out') - gajim.config.set('version', '0.10.1.1') + app.config.set('print_status_in_muc', 'in_and_out') + app.config.set('version', '0.10.1.1') def update_config_to_01012(self): # See [6456] if 'emoticons_theme' in self.old_values and \ self.old_values['emoticons_theme'] == 'Disabled': - gajim.config.set('emoticons_theme', '') - gajim.config.set('version', '0.10.1.2') + app.config.set('emoticons_theme', '') + app.config.set('version', '0.10.1.2') def update_config_to_01013(self): """ @@ -396,7 +396,7 @@ class OptionsParser: except sqlite.OperationalError: pass con.close() - gajim.config.set('version', '0.10.1.3') + app.config.set('version', '0.10.1.3') def update_config_to_01014(self): """ @@ -422,7 +422,7 @@ class OptionsParser: except Exception: pass con.close() - gajim.config.set('version', '0.10.1.4') + app.config.set('version', '0.10.1.4') def update_config_to_01015(self): """ @@ -443,7 +443,7 @@ class OptionsParser: con.commit() cur.close() # remove this in 2007 [pysqlite old versions need this] con.close() - gajim.config.set('version', '0.10.1.5') + app.config.set('version', '0.10.1.5') def update_config_to_01016(self): """ @@ -452,46 +452,46 @@ class OptionsParser: """ if 'notify_on_all_muc_messages' in self.old_values and \ self.old_values['notify_on_all_muc_messages'] == 'False' and \ - gajim.config.get_per('soundevents', 'muc_message_received', 'enabled'): - gajim.config.set_per('soundevents',\ + app.config.get_per('soundevents', 'muc_message_received', 'enabled'): + app.config.set_per('soundevents',\ 'muc_message_received', 'enabled', False) - gajim.config.set('version', '0.10.1.6') + app.config.set('version', '0.10.1.6') def update_config_to_01017(self): """ trayicon_notification_on_new_messages -> trayicon_notification_on_events """ if 'trayicon_notification_on_new_messages' in self.old_values: - gajim.config.set('trayicon_notification_on_events', + app.config.set('trayicon_notification_on_events', self.old_values['trayicon_notification_on_new_messages']) - gajim.config.set('version', '0.10.1.7') + app.config.set('version', '0.10.1.7') def update_config_to_01018(self): """ chat_state_notifications -> outgoing_chat_state_notifications """ if 'chat_state_notifications' in self.old_values: - gajim.config.set('outgoing_chat_state_notifications', + app.config.set('outgoing_chat_state_notifications', self.old_values['chat_state_notifications']) - gajim.config.set('version', '0.10.1.8') + app.config.set('version', '0.10.1.8') def update_config_to_01101(self): """ Fill time_stamp from before_time and after_time """ if 'before_time' in self.old_values: - gajim.config.set('time_stamp', '%s%%X%s ' % ( + app.config.set('time_stamp', '%s%%X%s ' % ( self.old_values['before_time'], self.old_values['after_time'])) - gajim.config.set('version', '0.11.0.1') + app.config.set('version', '0.11.0.1') def update_config_to_01102(self): """ Fill time_stamp from before_time and after_time """ if 'ft_override_host_to_send' in self.old_values: - gajim.config.set('ft_add_hosts_to_send', + app.config.set('ft_add_hosts_to_send', self.old_values['ft_override_host_to_send']) - gajim.config.set('version', '0.11.0.2') + app.config.set('version', '0.11.0.2') def update_config_to_01111(self): """ @@ -499,9 +499,9 @@ class OptionsParser: """ if 'always_hide_groupchat_buttons' in self.old_values and \ 'always_hide_chat_buttons' in self.old_values: - gajim.config.set('compact_view', self.old_values['always_hide_groupchat_buttons'] and \ + app.config.set('compact_view', self.old_values['always_hide_groupchat_buttons'] and \ self.old_values['always_hide_chat_buttons']) - gajim.config.set('version', '0.11.1.1') + app.config.set('version', '0.11.1.1') def update_config_to_01112(self): """ @@ -509,8 +509,8 @@ class OptionsParser: """ if 'roster_theme' in self.old_values and \ self.old_values['roster_theme'] == 'gtk+': - gajim.config.set('roster_theme', _('default')) - gajim.config.set('version', '0.11.1.2') + app.config.set('roster_theme', _('default')) + app.config.set('version', '0.11.1.2') def update_config_to_01113(self): # copy&pasted from update_config_to_01013, possibly 'FIXME see #2812' applies too @@ -534,7 +534,7 @@ class OptionsParser: except sqlite.OperationalError: pass con.close() - gajim.config.set('version', '0.11.1.3') + app.config.set('version', '0.11.1.3') def update_config_to_01114(self): # add default theme if it doesn't exist @@ -544,20 +544,20 @@ class OptionsParser: 'contactfontattrs', 'bannertextcolor', 'bannerbgcolor', 'bannerfont', 'bannerfontattrs'] theme_name = _('default') - if theme_name not in gajim.config.get_per('themes'): - gajim.config.add_per('themes', theme_name) - if gajim.config.get_per('themes', 'gtk+'): + if theme_name not in app.config.get_per('themes'): + app.config.add_per('themes', theme_name) + if app.config.get_per('themes', 'gtk+'): # copy from old gtk+ theme for o in d: - val = gajim.config.get_per('themes', 'gtk+', o) - gajim.config.set_per('themes', theme_name, o, val) - gajim.config.del_per('themes', 'gtk+') + val = app.config.get_per('themes', 'gtk+', o) + app.config.set_per('themes', theme_name, o, val) + app.config.del_per('themes', 'gtk+') else: # copy from default theme - theme = gajim.config.themes_default[theme_name] + theme = app.config.themes_default[theme_name] for o in d: - gajim.config.set_per('themes', theme_name, o, theme[d.index(o)]) - gajim.config.set('version', '0.11.1.4') + app.config.set_per('themes', theme_name, o, theme[d.index(o)]) + app.config.set('version', '0.11.1.4') def update_config_to_01115(self): # copy&pasted from update_config_to_01013, possibly 'FIXME see #2812' applies too @@ -576,7 +576,7 @@ class OptionsParser: except sqlite.OperationalError: pass con.close() - gajim.config.set('version', '0.11.1.5') + app.config.set('version', '0.11.1.5') def update_config_to_01121(self): # remove old unencrypted secrets file @@ -589,7 +589,7 @@ class OptionsParser: if os.path.exists(old_file): os.remove(old_file) - gajim.config.set('version', '0.11.2.1') + app.config.set('version', '0.11.2.1') def update_config_to_01141(self): back = os.getcwd() @@ -612,25 +612,25 @@ class OptionsParser: except sqlite.OperationalError: pass con.close() - gajim.config.set('version', '0.11.4.1') + app.config.set('version', '0.11.4.1') def update_config_to_01142(self): """ next_message_received sound event is splittedin 2 events """ - gajim.config.add_per('soundevents', 'next_message_received_focused') - gajim.config.add_per('soundevents', 'next_message_received_unfocused') - if gajim.config.get_per('soundevents', 'next_message_received'): - enabled = gajim.config.get_per('soundevents', 'next_message_received', + app.config.add_per('soundevents', 'next_message_received_focused') + app.config.add_per('soundevents', 'next_message_received_unfocused') + if app.config.get_per('soundevents', 'next_message_received'): + enabled = app.config.get_per('soundevents', 'next_message_received', 'enabled') - path = gajim.config.get_per('soundevents', 'next_message_received', + path = app.config.get_per('soundevents', 'next_message_received', 'path') - gajim.config.del_per('soundevents', 'next_message_received') - gajim.config.set_per('soundevents', 'next_message_received_focused', + app.config.del_per('soundevents', 'next_message_received') + app.config.set_per('soundevents', 'next_message_received_focused', 'enabled', enabled) - gajim.config.set_per('soundevents', 'next_message_received_focused', + app.config.set_per('soundevents', 'next_message_received_focused', 'path', path) - gajim.config.set('version', '0.11.1.2') + app.config.set('version', '0.11.1.2') def update_config_to_01143(self): back = os.getcwd() @@ -651,7 +651,7 @@ class OptionsParser: except sqlite.OperationalError: pass con.close() - gajim.config.set('version', '0.11.4.3') + app.config.set('version', '0.11.4.3') def update_config_to_01144(self): back = os.getcwd() @@ -678,71 +678,71 @@ class OptionsParser: except sqlite.OperationalError: pass con.close() - gajim.config.set('version', '0.11.4.4') + app.config.set('version', '0.11.4.4') def update_config_to_01201(self): if 'uri_schemes' in self.old_values: new_values = self.old_values['uri_schemes'].replace(' mailto', '').\ replace(' xmpp', '') - gajim.config.set('uri_schemes', new_values) - gajim.config.set('version', '0.12.0.1') + app.config.set('uri_schemes', new_values) + app.config.set('version', '0.12.0.1') def update_config_to_01211(self): if 'trayicon' in self.old_values: if self.old_values['trayicon'] == 'False': - gajim.config.set('trayicon', 'never') + app.config.set('trayicon', 'never') else: - gajim.config.set('trayicon', 'always') - gajim.config.set('version', '0.12.1.1') + app.config.set('trayicon', 'always') + app.config.set('version', '0.12.1.1') def update_config_to_01212(self): for opt in ('ignore_unknown_contacts', 'send_os_info', 'log_encrypted_sessions'): if opt in self.old_values: val = self.old_values[opt] - for account in gajim.config.get_per('accounts'): - gajim.config.set_per('accounts', account, opt, val) - gajim.config.set('version', '0.12.1.2') + for account in app.config.get_per('accounts'): + app.config.set_per('accounts', account, opt, val) + app.config.set('version', '0.12.1.2') def update_config_to_01213(self): - msgs = gajim.config.statusmsg_default - for msg_name in gajim.config.get_per('statusmsg'): + msgs = app.config.statusmsg_default + for msg_name in app.config.get_per('statusmsg'): if msg_name in msgs: - gajim.config.set_per('statusmsg', msg_name, 'activity', + app.config.set_per('statusmsg', msg_name, 'activity', msgs[msg_name][1]) - gajim.config.set_per('statusmsg', msg_name, 'subactivity', + app.config.set_per('statusmsg', msg_name, 'subactivity', msgs[msg_name][2]) - gajim.config.set_per('statusmsg', msg_name, 'activity_text', + app.config.set_per('statusmsg', msg_name, 'activity_text', msgs[msg_name][3]) - gajim.config.set_per('statusmsg', msg_name, 'mood', + app.config.set_per('statusmsg', msg_name, 'mood', msgs[msg_name][4]) - gajim.config.set_per('statusmsg', msg_name, 'mood_text', + app.config.set_per('statusmsg', msg_name, 'mood_text', msgs[msg_name][5]) - gajim.config.set('version', '0.12.1.3') + app.config.set('version', '0.12.1.3') def update_config_to_01214(self): for status in ['online', 'chat', 'away', 'xa', 'dnd', 'invisible', 'offline']: if 'last_status_msg_' + status in self.old_values: - gajim.config.add_per('statusmsg', '_last_' + status) - gajim.config.set_per('statusmsg', '_last_' + status, 'message', + app.config.add_per('statusmsg', '_last_' + status) + app.config.set_per('statusmsg', '_last_' + status, 'message', self.old_values['last_status_msg_' + status]) - gajim.config.set('version', '0.12.1.4') + app.config.set('version', '0.12.1.4') def update_config_to_01215(self): """ Remove hardcoded ../data/sounds from config """ - dirs = ['../data', gajim.gajimpaths.data_root, gajim.DATA_DIR] + dirs = ['../data', app.gajimpaths.data_root, app.DATA_DIR] if os.name != 'nt': dirs.append(os.path.expanduser('~/.gajim')) - for evt in gajim.config.get_per('soundevents'): - path = gajim.config.get_per('soundevents', evt, 'path') + for evt in app.config.get_per('soundevents'): + path = app.config.get_per('soundevents', evt, 'path') # absolute and relative passes are necessary path = helpers.strip_soundfile_path(path, dirs, abs=False) path = helpers.strip_soundfile_path(path, dirs, abs=True) - gajim.config.set_per('soundevents', evt, 'path', path) - gajim.config.set('version', '0.12.1.5') + app.config.set_per('soundevents', evt, 'path', path) + app.config.set('version', '0.12.1.5') def update_config_to_01231(self): back = os.getcwd() @@ -774,7 +774,7 @@ class OptionsParser: except sqlite.OperationalError: pass con.close() - gajim.config.set('version', '0.12.3.1') + app.config.set('version', '0.12.3.1') def update_config_from_0125(self): # All those functions need to be called for 0.12.5 to 0.13 transition @@ -801,24 +801,24 @@ class OptionsParser: except sqlite.OperationalError: pass con.close() - gajim.config.set('version', '0.12.5.1') + app.config.set('version', '0.12.5.1') def update_config_to_01252(self): if 'alwaysauth' in self.old_values: val = self.old_values['alwaysauth'] - for account in gajim.config.get_per('accounts'): - gajim.config.set_per('accounts', account, 'autoauth', val) - gajim.config.set('version', '0.12.5.2') + for account in app.config.get_per('accounts'): + app.config.set_per('accounts', account, 'autoauth', val) + app.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) + for account in app.config.get_per('accounts'): + if app.config.get_per('accounts', account, 'is_zeroconf'): + app.config.set_per('accounts', account, 'active', val) else: - gajim.config.set_per('accounts', account, 'active', True) - gajim.config.set('version', '0.12.5.3') + app.config.set_per('accounts', account, 'active', True) + app.config.set('version', '0.12.5.3') def update_config_to_01254(self): vals = {'inmsgcolor': ['#a34526', '#a40000'], @@ -833,8 +833,8 @@ class OptionsParser: val = self.old_values[c] if val == vals[c][0]: # We didn't change default value, so update it with new default - gajim.config.set(c, vals[c][1]) - gajim.config.set('version', '0.12.5.4') + app.config.set(c, vals[c][1]) + app.config.set('version', '0.12.5.4') def update_config_to_01255(self): vals = {'statusmsgcolor': ['#73d216', '#4e9a06'], @@ -845,8 +845,8 @@ class OptionsParser: val = self.old_values[c] if val == vals[c][0]: # We didn't change default value, so update it with new default - gajim.config.set(c, vals[c][1]) - gajim.config.set('version', '0.12.5.5') + app.config.set(c, vals[c][1]) + app.config.set('version', '0.12.5.5') def update_config_to_01256(self): vals = {'gc_nicknames_colors': ['#4e9a06:#f57900:#ce5c00:#3465a4:#204a87:#75507b:#5c3566:#c17d11:#8f5902:#ef2929:#cc0000:#a40000', '#f57900:#ce5c00:#204a87:#75507b:#5c3566:#c17d11:#8f5902:#ef2929:#cc0000:#a40000']} @@ -856,22 +856,22 @@ class OptionsParser: val = self.old_values[c] if val == vals[c][0]: # We didn't change default value, so update it with new default - gajim.config.set(c, vals[c][1]) - gajim.config.set('version', '0.12.5.6') + app.config.set(c, vals[c][1]) + app.config.set('version', '0.12.5.6') def update_config_to_01257(self): if 'iconset' in self.old_values: if self.old_values['iconset'] in ('nuvola', 'crystal', 'gossip', 'simplebulb', 'stellar'): - gajim.config.set('iconset', gajim.config.DEFAULT_ICONSET) - gajim.config.set('version', '0.12.5.7') + app.config.set('iconset', app.config.DEFAULT_ICONSET) + app.config.set('version', '0.12.5.7') def update_config_to_01258(self): self.update_ft_proxies(to_remove=['proxy65.talkonaut.com', 'proxy.jabber.org', 'proxy.netlab.cz', 'transfer.jabber.freenet.de', 'proxy.jabber.cd.chalmers.se'], to_add=['proxy.eu.jabber.org', 'proxy.jabber.ru', 'proxy.jabbim.cz']) - gajim.config.set('version', '0.12.5.8') + app.config.set('version', '0.12.5.8') def update_config_to_013100(self): back = os.getcwd() @@ -890,7 +890,7 @@ class OptionsParser: except sqlite.OperationalError: pass con.close() - gajim.config.set('version', '0.13.10.0') + app.config.set('version', '0.13.10.0') def update_config_to_013101(self): back = os.getcwd() @@ -911,36 +911,36 @@ class OptionsParser: except sqlite.OperationalError: pass con.close() - gajim.config.set('version', '0.13.10.1') + app.config.set('version', '0.13.10.1') def update_config_to_013901(self): schemes = 'aaa:// aaas:// acap:// cap:// cid: crid:// data: dav: dict:// dns: fax: file:/ ftp:// geo: go: gopher:// h323: http:// https:// iax: icap:// im: imap:// info: ipp:// iris: iris.beep: iris.xpc: iris.xpcs: iris.lwz: ldap:// mid: modem: msrp:// msrps:// mtqp:// mupdate:// news: nfs:// nntp:// opaquelocktoken: pop:// pres: prospero:// rtsp:// service: shttp:// sip: sips: sms: snmp:// soap.beep:// soap.beeps:// tag: tel: telnet:// tftp:// thismessage:/ tip:// tv: urn:// vemmi:// xmlrpc.beep:// xmlrpc.beeps:// z39.50r:// z39.50s:// about: apt: cvs:// daap:// ed2k:// feed: fish:// git:// iax2: irc:// ircs:// ldaps:// magnet: mms:// rsync:// ssh:// svn:// sftp:// smb:// webcal://' - gajim.config.set('uri_schemes', schemes) - gajim.config.set('version', '0.13.90.1') + app.config.set('uri_schemes', schemes) + app.config.set('version', '0.13.90.1') def update_config_to_01401(self): if 'autodetect_browser_mailer' not in self.old_values or 'openwith' \ not in self.old_values or \ (self.old_values['autodetect_browser_mailer'] == False and \ self.old_values['openwith'] != 'custom'): - gajim.config.set('autodetect_browser_mailer', True) - gajim.config.set('openwith', gajim.config.DEFAULT_OPENWITH) - gajim.config.set('version', '0.14.0.1') + app.config.set('autodetect_browser_mailer', True) + app.config.set('openwith', app.config.DEFAULT_OPENWITH) + app.config.set('version', '0.14.0.1') def update_config_to_014900(self): if 'use_stun_server' in self.old_values and self.old_values[ 'use_stun_server'] and not self.old_values['stun_server']: - gajim.config.set('use_stun_server', False) + app.config.set('use_stun_server', False) if os.name == 'nt': - gajim.config.set('autodetect_browser_mailer', True) + app.config.set('autodetect_browser_mailer', True) def update_config_to_01601(self): if 'last_mam_id' in self.old_values: last_mam_id = self.old_values['last_mam_id'] - for account in gajim.config.get_per('accounts'): - gajim.config.set_per('accounts', account, 'last_mam_id', + for account in app.config.get_per('accounts'): + app.config.set_per('accounts', account, 'last_mam_id', last_mam_id) - gajim.config.set('version', '0.16.0.1') + app.config.set('version', '0.16.0.1') def update_config_to_01641(self): for account in self.old_values['accounts'].keys(): @@ -948,21 +948,21 @@ class OptionsParser: 'connection_types'].split() if 'plain' in connection_types and len(connection_types) > 1: connection_types.remove('plain') - gajim.config.set_per('accounts', account, 'connection_types', + app.config.set_per('accounts', account, 'connection_types', ' '.join(connection_types)) - gajim.config.set('version', '0.16.4.1') + app.config.set('version', '0.16.4.1') def update_config_to_016101(self): if 'video_input_device' in self.old_values: if self.old_values['video_input_device'] == 'autovideosrc ! videoscale ! ffmpegcolorspace': - gajim.config.set('video_input_device', 'autovideosrc') + app.config.set('video_input_device', 'autovideosrc') if self.old_values['video_input_device'] == 'videotestsrc is-live=true ! video/x-raw-yuv,framerate=10/1': - gajim.config.set('video_input_device', 'videotestsrc is-live=true ! video/x-raw,framerate=10/1') - gajim.config.set('version', '0.16.10.1') + app.config.set('video_input_device', 'videotestsrc is-live=true ! video/x-raw,framerate=10/1') + app.config.set('version', '0.16.10.1') def update_config_to_016102(self): for account in self.old_values['accounts'].keys(): - gajim.config.del_per('accounts', account, 'minimized_gc') + app.config.del_per('accounts', account, 'minimized_gc') back = os.getcwd() os.chdir(logger.LOG_DB_FOLDER) @@ -980,7 +980,7 @@ class OptionsParser: pass con.close() - gajim.config.set('version', '0.16.10.2') + app.config.set('version', '0.16.10.2') def update_config_to_016103(self): back = os.getcwd() @@ -1002,13 +1002,13 @@ class OptionsParser: except sqlite.OperationalError: pass con.close() - gajim.config.set('version', '0.16.10.3') + app.config.set('version', '0.16.10.3') def update_config_to_016104(self): - gajim.config.set('emoticons_theme', 'noto-emoticons') - gajim.config.set('version', '0.16.10.4') + app.config.set('emoticons_theme', 'noto-emoticons') + app.config.set('version', '0.16.10.4') def update_config_to_016105(self): - gajim.config.set('muc_restore_timeout', -1) - gajim.config.set('restore_timeout', -1) - gajim.config.set('version', '0.16.10.5') + app.config.set('muc_restore_timeout', -1) + app.config.set('restore_timeout', -1) + app.config.set('version', '0.16.10.5') diff --git a/gajim/common/passwords.py b/gajim/common/passwords.py index 3d10290e8..c97996e0f 100644 --- a/gajim/common/passwords.py +++ b/gajim/common/passwords.py @@ -27,7 +27,7 @@ import os import logging import gi -from gajim.common import gajim +from gajim.common import app __all__ = ['get_password', 'save_password'] @@ -69,15 +69,15 @@ class LibSecretPasswordStorage(PasswordStorage): ) def get_password(self, account_name): - server = gajim.config.get_per('accounts', account_name, 'hostname') - user = gajim.config.get_per('accounts', account_name, 'name') + server = app.config.get_per('accounts', account_name, 'hostname') + user = app.config.get_per('accounts', account_name, 'name') password = self.Secret.password_lookup_sync(self.GAJIM_SCHEMA, {'user': user, 'server': server, 'protocol': 'xmpp'}, None) return password def save_password(self, account_name, password, update=True): - server = gajim.config.get_per('accounts', account_name, 'hostname') - user = gajim.config.get_per('accounts', account_name, 'name') + server = app.config.get_per('accounts', account_name, 'hostname') + user = app.config.get_per('accounts', account_name, 'name') display_name = _('XMPP account %s@%s') % (user, server) attributes = {'user': user, 'server': server, 'protocol': 'xmpp'} return self.Secret.password_store_sync(self.GAJIM_SCHEMA, attributes, @@ -123,7 +123,7 @@ class PasswordStorageManager(PasswordStorage): """ # TODO: handle disappearing backends - if gajim.config.get('use_keyring'): + if app.config.get('use_keyring'): if os.name == 'nt' and keyring: self.winsecret = SecretWindowsPasswordStorage() else: @@ -133,7 +133,7 @@ class PasswordStorageManager(PasswordStorage): log.debug("Could not connect to libsecret: %s" % e) def get_password(self, account_name): - pw = gajim.config.get_per('accounts', account_name, 'password') + pw = app.config.get_per('accounts', account_name, 'password') if not pw: return pw if pw.startswith(LibSecretPasswordStorage.identifier) and \ @@ -156,15 +156,15 @@ class PasswordStorageManager(PasswordStorage): def save_password(self, account_name, password): if self.preferred_backend: if self.preferred_backend.save_password(account_name, password): - gajim.config.set_per('accounts', account_name, 'password', + app.config.set_per('accounts', account_name, 'password', self.preferred_backend.identifier) - if account_name in gajim.connections: - gajim.connections[account_name].password = password + if account_name in app.connections: + app.connections[account_name].password = password return True - gajim.config.set_per('accounts', account_name, 'password', password) - if account_name in gajim.connections: - gajim.connections[account_name].password = password + app.config.set_per('accounts', account_name, 'password', password) + if account_name in app.connections: + app.connections[account_name].password = password return True def set_preferred_backend(self): @@ -192,6 +192,6 @@ def get_password(account_name): return get_storage().get_password(account_name) def save_password(account_name, password): - if account_name in gajim.connections: - gajim.connections[account_name].set_password(password) + if account_name in app.connections: + app.connections[account_name].set_password(password) return get_storage().save_password(account_name, password) diff --git a/gajim/common/pep.py b/gajim/common/pep.py index 9343e1649..004296c12 100644 --- a/gajim/common/pep.py +++ b/gajim/common/pep.py @@ -221,7 +221,7 @@ import logging log = logging.getLogger('gajim.c.pep') import nbxmpp -from gajim.common import gajim +from gajim.common import app class AbstractPEP(object): @@ -242,7 +242,7 @@ class AbstractPEP(object): self._pep_specific_data, self._retracted = self._extract_info(items) self._update_contacts(jid, account) - if jid == gajim.get_jid_from_account(account): + if jid == app.get_jid_from_account(account): self._update_account(account) def _extract_info(self, items): @@ -250,7 +250,7 @@ class AbstractPEP(object): raise NotImplementedError def _update_contacts(self, jid, account): - for contact in gajim.contacts.get_contacts(account, jid): + for contact in app.contacts.get_contacts(account, jid): if self._retracted: if self.type_ in contact.pep: del contact.pep[self.type_] @@ -258,7 +258,7 @@ class AbstractPEP(object): contact.pep[self.type_] = self def _update_account(self, account): - acc = gajim.connections[account] + acc = app.connections[account] if self._retracted: if self.type_ in acc.pep: del acc.pep[self.type_] @@ -417,14 +417,14 @@ class UserNicknamePEP(AbstractPEP): def _update_contacts(self, jid, account): nick = '' if self._retracted else self._pep_specific_data - for contact in gajim.contacts.get_contacts(account, jid): + for contact in app.contacts.get_contacts(account, jid): contact.contact_name = nick def _update_account(self, account): if self._retracted: - gajim.nicks[account] = gajim.config.get_per('accounts', account, 'name') + app.nicks[account] = app.config.get_per('accounts', account, 'name') else: - gajim.nicks[account] = self._pep_specific_data + app.nicks[account] = self._pep_specific_data class UserLocationPEP(AbstractPEP): @@ -450,7 +450,7 @@ class UserLocationPEP(AbstractPEP): def _update_account(self, account): AbstractPEP._update_account(self, account) - con = gajim.connections[account].location_info = \ + con = app.connections[account].location_info = \ self._pep_specific_data def asMarkupText(self): diff --git a/gajim/common/protocol/bytestream.py b/gajim/common/protocol/bytestream.py index 33a5d094c..606dc432b 100644 --- a/gajim/common/protocol/bytestream.py +++ b/gajim/common/protocol/bytestream.py @@ -34,7 +34,7 @@ from gi.repository import GLib import time import nbxmpp -from gajim.common import gajim +from gajim.common import app from gajim.common import helpers from gajim.common import ged from gajim.common import jingle_xtls @@ -79,15 +79,15 @@ def is_transfer_stopped(file_props): class ConnectionBytestream: def __init__(self): - gajim.ged.register_event_handler('file-request-received', ged.GUI1, + app.ged.register_event_handler('file-request-received', ged.GUI1, self._nec_file_request_received) def cleanup(self): - gajim.ged.remove_event_handler('file-request-received', ged.GUI1, + app.ged.remove_event_handler('file-request-received', ged.GUI1, self._nec_file_request_received) def _ft_get_our_jid(self): - our_jid = gajim.get_jid_from_account(self.name) + our_jid = app.get_jid_from_account(self.name) resource = self.server_resource return our_jid + '/' + resource @@ -156,7 +156,7 @@ class ConnectionBytestream: if content.use_security: fingerprint = content.x509_fingerprint if not jingle_xtls.check_cert( - gajim.get_jid_without_resource(file_props.sender), + app.get_jid_without_resource(file_props.sender), fingerprint): id_ = jingle_xtls.send_cert_request(self, file_props.sender) @@ -257,7 +257,7 @@ class ConnectionBytestream: def _siSetCB(self, con, iq_obj): from gajim.common.connection_handlers_events import FileRequestReceivedEvent - gajim.nec.push_incoming_event(FileRequestReceivedEvent(None, conn=self, + app.nec.push_incoming_event(FileRequestReceivedEvent(None, conn=self, stanza=iq_obj)) raise nbxmpp.NodeProcessed @@ -275,7 +275,7 @@ class ConnectionBytestream: jid = self._ft_get_from(iq_obj) file_props.error = -3 from gajim.common.connection_handlers_events import FileRequestErrorEvent - gajim.nec.push_incoming_event(FileRequestErrorEvent(None, conn=self, + app.nec.push_incoming_event(FileRequestErrorEvent(None, conn=self, jid=jid, file_props=file_props, error_msg='')) raise nbxmpp.NodeProcessed @@ -310,7 +310,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): self.remove_transfer(file_props) from gajim.common.connection_handlers_events import \ FileRequestErrorEvent - gajim.nec.push_incoming_event(FileRequestErrorEvent(None, + app.nec.push_incoming_event(FileRequestErrorEvent(None, conn=self, jid=contact.jid, file_props=file_props, error_msg='')) sender_jid = file_props.sender @@ -335,13 +335,13 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): if file_props is None: return if file_props.hash_: - gajim.socks5queue.remove_sender(file_props.hash_) + app.socks5queue.remove_sender(file_props.hash_) if file_props.streamhosts: for host in file_props.streamhosts: if 'idx' in host and host['idx'] > 0: - gajim.socks5queue.remove_receiver(host['idx']) - gajim.socks5queue.remove_sender(host['idx']) + app.socks5queue.remove_receiver(host['idx']) + app.socks5queue.remove_sender(host['idx']) def _send_socks5_info(self, file_props): """ @@ -355,13 +355,13 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): sha_str = helpers.get_auth_sha(file_props.sid, sender, receiver) file_props.sha_str = sha_str - port = gajim.config.get('file_transfers_port') - listener = gajim.socks5queue.start_listener(port, sha_str, + port = app.config.get('file_transfers_port') + listener = app.socks5queue.start_listener(port, sha_str, self._result_socks5_sid, file_props) if not listener: file_props.error = -5 from gajim.common.connection_handlers_events import FileRequestErrorEvent - gajim.nec.push_incoming_event(FileRequestErrorEvent(None, conn=self, + app.nec.push_incoming_event(FileRequestErrorEvent(None, conn=self, jid=receiver, file_props=file_props, error_msg='')) self._connect_error(file_props.sid, error='not-acceptable', error_type='modify') @@ -387,7 +387,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): streamhost.setAttr('jid', sender) def _add_local_ips_as_streamhosts_to_query(self, query, file_props): - if not gajim.config.get_per('accounts', self.name, 'ft_send_local_ips'): + if not app.config.get_per('accounts', self.name, 'ft_send_local_ips'): return try: my_ips = [self.peerhost[0]] # The ip we're connected to server with @@ -397,18 +397,18 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): my_ips.append(addr[4][0]) sender = file_props.sender - port = gajim.config.get('file_transfers_port') + port = app.config.get('file_transfers_port') self._add_streamhosts_to_query(query, sender, port, my_ips) except socket.gaierror: from gajim.common.connection_handlers_events import InformationEvent - gajim.nec.push_incoming_event(InformationEvent(None, conn=self, + app.nec.push_incoming_event(InformationEvent(None, conn=self, level='error', pri_txt=_('Wrong host'), sec_txt=_('Invalid local address? :-O'))) def _add_addiditional_streamhosts_to_query(self, query, file_props): sender = file_props.sender - port = gajim.config.get('file_transfers_port') - ft_add_hosts_to_send = gajim.config.get('ft_add_hosts_to_send') + port = app.config.get('file_transfers_port') + ft_add_hosts_to_send = app.config.get('ft_add_hosts_to_send') additional_hosts = [] if ft_add_hosts_to_send: additional_hosts = [e.strip() for e in ft_add_hosts_to_send.split(',')] @@ -417,7 +417,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): self._add_streamhosts_to_query(query, sender, port, additional_hosts) def _add_upnp_igd_as_streamhost_to_query(self, query, file_props, iq): - if not gajim.HAVE_UPNP_IGD: + if not app.HAVE_UPNP_IGD: self.connection.send(iq) return @@ -458,18 +458,18 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): if self.no_gupnp_reply_id: GLib.source_remove(self.no_gupnp_reply_id) self.no_gupnp_reply_id = 0 - gajim.gupnp_igd.disconnect(self.ok_id) - gajim.gupnp_igd.disconnect(self.fail_id) + app.gupnp_igd.disconnect(self.ok_id) + app.gupnp_igd.disconnect(self.fail_id) def ok(s, proto, ext_ip, re, ext_port, local_ip, local_port, desc): log.debug('Got GUPnP-IGD answer: external: %s:%s, internal: %s:%s', ext_ip, ext_port, local_ip, local_port) - if local_port != gajim.config.get('file_transfers_port'): + if local_port != app.config.get('file_transfers_port'): sender = file_props.sender receiver = file_props.receiver sha_str = helpers.get_auth_sha(file_props.sid, sender, receiver) - listener = gajim.socks5queue.start_listener(local_port, sha_str, + listener = app.socks5queue.start_listener(local_port, sha_str, self._result_socks5_sid, file_props.sid) if listener: self._add_streamhosts_to_query(query, sender, ext_port, @@ -488,19 +488,19 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): def no_upnp_reply(): log.debug('Got not GUPnP-IGD answer') # stop trying to use it - gajim.HAVE_UPNP_IGD = False + app.HAVE_UPNP_IGD = False self.no_gupnp_reply_id = 0 self.connection.send(iq) cleanup_gupnp() return False - self.ok_id = gajim.gupnp_igd.connect('mapped-external-port', ok) - self.fail_id = gajim.gupnp_igd.connect('error-mapping-port', fail) + self.ok_id = app.gupnp_igd.connect('mapped-external-port', ok) + self.fail_id = app.gupnp_igd.connect('error-mapping-port', fail) - port = gajim.config.get('file_transfers_port') + port = app.config.get('file_transfers_port') self.no_gupnp_reply_id = GLib.timeout_add_seconds(10, no_upnp_reply) - gajim.gupnp_igd.add_port('TCP', 0, my_ip, port, 3600, + app.gupnp_igd.add_port('TCP', 0, my_ip, port, 3600, 'Gajim file transfer') def _add_proxy_streamhosts_to_query(self, query, file_props): @@ -515,16 +515,16 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): proxyhost['port'], [proxyhost['host']]) def _get_file_transfer_proxies_from_config(self, file_props): - configured_proxies = gajim.config.get_per('accounts', self.name, + configured_proxies = app.config.get_per('accounts', self.name, 'file_transfer_proxies') - shall_use_proxies = gajim.config.get_per('accounts', self.name, + shall_use_proxies = app.config.get_per('accounts', self.name, 'use_ft_proxies') if shall_use_proxies: proxyhost_dicts = [] proxies = [] if configured_proxies: proxies = [item.strip() for item in configured_proxies.split(',')] - default_proxy = gajim.proxy65_manager.get_default_for_name(self.name) + default_proxy = app.proxy65_manager.get_default_for_name(self.name) if default_proxy: # add/move default proxy at top of the others if default_proxy in proxies: @@ -532,7 +532,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): proxies.insert(0, default_proxy) for proxy in proxies: - (host, _port, jid) = gajim.proxy65_manager.get_proxy(proxy, self.name) + (host, _port, jid) = app.proxy65_manager.get_proxy(proxy, self.name) if not host: continue host_dict = { @@ -584,7 +584,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): file_props.error = -3 from gajim.common.connection_handlers_events import \ FileRequestErrorEvent - gajim.nec.push_incoming_event(FileRequestErrorEvent(None, + app.nec.push_incoming_event(FileRequestErrorEvent(None, conn=self, jid=to, file_props=file_props, error_msg=msg)) def _proxy_auth_ok(self, proxy): @@ -609,7 +609,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): id_ = iq_obj.getAttr('id') frm = helpers.get_full_jid_from_iq(iq_obj) query = iq_obj.getTag('query') - gajim.proxy65_manager.error_cb(frm, query) + app.proxy65_manager.error_cb(frm, query) jid = helpers.get_jid_from_iq(iq_obj) id_ = id_[3:] file_props = FilesProp.getFilePropBySid(id_) @@ -617,7 +617,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): return file_props.error = -4 from gajim.common.connection_handlers_events import FileRequestErrorEvent - gajim.nec.push_incoming_event(FileRequestErrorEvent(None, conn=self, + app.nec.push_incoming_event(FileRequestErrorEvent(None, conn=self, jid=jid, file_props=file_props, error_msg='')) raise nbxmpp.NodeProcessed @@ -654,7 +654,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): file_props.streamhosts.extend(streamhosts) else: file_props.streamhosts = streamhosts - gajim.socks5queue.connect_to_hosts(self.name, sid, + app.socks5queue.connect_to_hosts(self.name, sid, self.send_success_connect_reply, None) raise nbxmpp.NodeProcessed else: @@ -666,7 +666,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): self._connect_error(sid, 'item-not-found', 'cancel', msg='Could not connect to given hosts') if file_props.type_ == 'r': - gajim.socks5queue.connect_to_hosts(self.name, sid, + app.socks5queue.connect_to_hosts(self.name, sid, self.send_success_connect_reply, _connection_error) raise nbxmpp.NodeProcessed @@ -682,14 +682,14 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): if file_props.streamhost_used: for host in file_props.proxyhosts: if host['initiator'] == frm and 'idx' in host: - gajim.socks5queue.activate_proxy(host['idx']) + app.socks5queue.activate_proxy(host['idx']) raise nbxmpp.NodeProcessed def _bytestreamResultCB(self, con, iq_obj): frm = self._ft_get_from(iq_obj) real_id = iq_obj.getAttr('id') query = iq_obj.getTag('query') - gajim.proxy65_manager.resolve_result(frm, query) + app.proxy65_manager.resolve_result(frm, query) try: streamhost = query.getTag('streamhost-used') @@ -709,7 +709,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): for host in file_props.proxyhosts: if host['initiator'] == frm and \ query.getAttr('sid') == file_props.sid: - gajim.socks5queue.activate_proxy(host['idx']) + app.socks5queue.activate_proxy(host['idx']) break raise nbxmpp.NodeProcessed jid = self._ft_get_streamhost_jid_attr(streamhost) @@ -720,7 +720,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): if file_props.stopped: self.remove_transfer(file_props) else: - gajim.socks5queue.send_file(file_props, self.name) + app.socks5queue.send_file(file_props, self.name) raise nbxmpp.NodeProcessed proxy = None @@ -736,22 +736,22 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): file_props.streamhost_used = True file_props.streamhosts.append(proxy) file_props.is_a_proxy = True - idx = gajim.socks5queue.idx - sender = Socks5SenderClient(gajim.idlequeue, idx, - gajim.socks5queue, _sock=None, host=str(proxy['host']), + idx = app.socks5queue.idx + sender = Socks5SenderClient(app.idlequeue, idx, + app.socks5queue, _sock=None, host=str(proxy['host']), port=int(proxy['port']), fingerprint=None, connected=False, file_props=file_props) sender.streamhost = proxy - gajim.socks5queue.add_sockobj(self.name, sender) + app.socks5queue.add_sockobj(self.name, sender) proxy['idx'] = sender.queue_idx - gajim.socks5queue.on_success[file_props.sid] = self._proxy_auth_ok + app.socks5queue.on_success[file_props.sid] = self._proxy_auth_ok raise nbxmpp.NodeProcessed else: if file_props.stopped: self.remove_transfer(file_props) else: - gajim.socks5queue.send_file(file_props, self.name, 'server') + app.socks5queue.send_file(file_props, self.name, 'server') raise nbxmpp.NodeProcessed @@ -785,7 +785,7 @@ class ConnectionIBBytestream(ConnectionBytestream): elif not file_props.connected: log.debug('Received IQ for closed filetransfer, IQ dropped') elif typ == 'error': - gajim.socks5queue.error_cb() + app.socks5queue.error_cb() else: conn.send(nbxmpp.Error(stanza, nbxmpp.ERR_BAD_REQUEST)) raise nbxmpp.NodeProcessed @@ -841,7 +841,7 @@ class ConnectionIBBytestream(ConnectionBytestream): payload=[nbxmpp.Node(nbxmpp.NS_IBB + ' close', {'sid':file_props.transport_sid})])) if file_props.completed: - gajim.socks5queue.complete_transfer_cb(self.name, file_props) + app.socks5queue.complete_transfer_cb(self.name, file_props) elif file_props.session_type == 'jingle': peerjid = \ file_props.receiver if file_props.type_ == 's' else file_props.sender @@ -910,7 +910,7 @@ class ConnectionIBBytestream(ConnectionBytestream): file_props.received_len += len(chunk) if file_props.size == file_props.received_len: file_props.completed = True - gajim.socks5queue.progress_transfer_cb(self.name, + app.socks5queue.progress_transfer_cb(self.name, file_props) else: log.debug('Nothing to read, but file not completed') @@ -949,7 +949,7 @@ class ConnectionIBBytestream(ConnectionBytestream): file_props.elapsed_time += current_time - file_props.last_time file_props.last_time = current_time file_props.received_len += len(data) - gajim.socks5queue.progress_transfer_cb(self.name, file_props) + app.socks5queue.progress_transfer_cb(self.name, file_props) if file_props.received_len >= file_props.size: file_props.completed = True if err: @@ -978,7 +978,7 @@ class ConnectionIBBytestream(ConnectionBytestream): file_props.completed = file_props.received_len >= file_props.size if not file_props.completed: file_props.error = -1 - gajim.socks5queue.complete_transfer_cb(self.name, file_props) + app.socks5queue.complete_transfer_cb(self.name, file_props) else: conn.send(nbxmpp.Error(stanza, nbxmpp.ERR_ITEM_NOT_FOUND)) @@ -1014,7 +1014,7 @@ class ConnectionSocks5BytestreamZeroconf(ConnectionSocks5Bytestream): return iq_obj.getFrom() def _ft_get_our_jid(self): - return gajim.get_jid_from_account(self.name) + return app.get_jid_from_account(self.name) def _ft_get_receiver_jid(self, file_props): return file_props.receiver.jid diff --git a/gajim/common/protocol/caps.py b/gajim/common/protocol/caps.py index d941e8d87..12a2d2d4c 100644 --- a/gajim/common/protocol/caps.py +++ b/gajim/common/protocol/caps.py @@ -25,7 +25,7 @@ Module containing the network portion of XEP-115 (Entity Capabilities) import logging log = logging.getLogger('gajim.c.p.caps') -from gajim.common import gajim +from gajim.common import app from gajim.common import ged from gajim.common.connection_handlers_events import CapsPresenceReceivedEvent, \ CapsDiscoReceivedEvent, CapsReceivedEvent @@ -37,17 +37,17 @@ class ConnectionCaps(object): self._account = account self._capscache = capscache self._create_suitable_client_caps = client_caps_factory - gajim.nec.register_incoming_event(CapsPresenceReceivedEvent) - gajim.nec.register_incoming_event(CapsReceivedEvent) - gajim.ged.register_event_handler('caps-presence-received', ged.GUI1, + app.nec.register_incoming_event(CapsPresenceReceivedEvent) + app.nec.register_incoming_event(CapsReceivedEvent) + app.ged.register_event_handler('caps-presence-received', ged.GUI1, self._nec_caps_presence_received) - gajim.ged.register_event_handler('agent-info-received', ged.GUI1, + app.ged.register_event_handler('agent-info-received', ged.GUI1, self._nec_agent_info_received_caps) def cleanup(self): - gajim.ged.remove_event_handler('caps-presence-received', ged.GUI1, + app.ged.remove_event_handler('caps-presence-received', ged.GUI1, self._nec_caps_presence_received) - gajim.ged.remove_event_handler('agent-info-received', ged.GUI1, + app.ged.remove_event_handler('agent-info-received', ged.GUI1, self._nec_agent_info_received_caps) def caps_change_account_name(self, new_name): @@ -75,10 +75,10 @@ class ConnectionCaps(object): log.info('Received Caps from unknown contact %s' % obj.fjid) def _get_contact_or_gc_contact_for_jid(self, jid): - contact = gajim.contacts.get_contact_from_full_jid(self._account, jid) + contact = app.contacts.get_contact_from_full_jid(self._account, jid) if contact is None: - room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) - contact = gajim.contacts.get_gc_contact(self._account, room_jid, nick) + room_jid, nick = app.get_room_and_nick_from_fjid(jid) + contact = app.contacts.get_gc_contact(self._account, room_jid, nick) return contact def _nec_agent_info_received_caps(self, obj): @@ -113,6 +113,6 @@ class ConnectionCaps(object): log.info('Computed and retrieved caps hash differ.' + 'Ignoring caps of contact %s' % contact.get_full_jid()) - gajim.nec.push_incoming_event(CapsDiscoReceivedEvent(None, + app.nec.push_incoming_event(CapsDiscoReceivedEvent(None, conn=self, fjid=obj.fjid, jid=obj.jid, resource=obj.resource, client_caps=contact.client_caps)) diff --git a/gajim/common/proxy65_manager.py b/gajim/common/proxy65_manager.py index 243a0806b..b7f75f222 100644 --- a/gajim/common/proxy65_manager.py +++ b/gajim/common/proxy65_manager.py @@ -27,7 +27,7 @@ import logging log = logging.getLogger('gajim.c.proxy65_manager') import nbxmpp -from gajim.common import gajim +from gajim.common import app from gajim.common import helpers from gajim.common.socks5 import Socks5 from nbxmpp.idlequeue import IdleObject @@ -260,7 +260,7 @@ class HostTester(Socks5, IdleObject): self.file_props.is_a_proxy = True self.file_props.proxy_sender = sender_jid self.file_props.proxy_receiver = 'test@gajim.org/test2' - Socks5.__init__(self, gajim.idlequeue, host, port, None, None, None) + Socks5.__init__(self, app.idlequeue, host, port, None, None, None) self.sid = sid def connect(self): @@ -274,7 +274,7 @@ class HostTester(Socks5, IdleObject): self._sock.setblocking(False) self.fd = self._sock.fileno() self.state = 0 # about to be connected - gajim.idlequeue.plug_idle(self, True, False) + app.idlequeue.plug_idle(self, True, False) self.do_connect() self.idlequeue.set_read_timeout(self.fd, CONNECT_TIMEOUT) return None @@ -299,8 +299,8 @@ class HostTester(Socks5, IdleObject): return self.state += 1 # unplug and plug for reading - gajim.idlequeue.plug_idle(self, False, True) - gajim.idlequeue.set_read_timeout(self.fd, CONNECT_TIMEOUT) + app.idlequeue.plug_idle(self, False, True) + app.idlequeue.set_read_timeout(self.fd, CONNECT_TIMEOUT) def pollin(self): self.idlequeue.remove_timeout(self.fd) @@ -380,7 +380,7 @@ class ReceiverTester(Socks5, IdleObject): self.file_props.is_a_proxy = True self.file_props.proxy_sender = sender_jid self.file_props.proxy_receiver = 'test@gajim.org/test2' - Socks5.__init__(self, gajim.idlequeue, host, port, None, None, None) + Socks5.__init__(self, app.idlequeue, host, port, None, None, None) self.sid = sid def connect(self): @@ -394,7 +394,7 @@ class ReceiverTester(Socks5, IdleObject): self._sock.setblocking(False) self.fd = self._sock.fileno() self.state = 0 # about to be connected - gajim.idlequeue.plug_idle(self, True, False) + app.idlequeue.plug_idle(self, True, False) self.do_connect() self.idlequeue.set_read_timeout(self.fd, CONNECT_TIMEOUT) return None @@ -419,8 +419,8 @@ class ReceiverTester(Socks5, IdleObject): return self.state += 1 # unplug and plug for reading - gajim.idlequeue.plug_idle(self, False, True) - gajim.idlequeue.set_read_timeout(self.fd, CONNECT_TIMEOUT) + app.idlequeue.plug_idle(self, False, True) + app.idlequeue.set_read_timeout(self.fd, CONNECT_TIMEOUT) def pollin(self): self.idlequeue.remove_timeout(self.fd) diff --git a/gajim/common/pubsub.py b/gajim/common/pubsub.py index 465eff025..4718b62ff 100644 --- a/gajim/common/pubsub.py +++ b/gajim/common/pubsub.py @@ -22,7 +22,7 @@ ## import nbxmpp -from gajim.common import gajim +from gajim.common import app #TODO: Doesn't work #from common.connection_handlers import PEP_CONFIG PEP_CONFIG = 'pep_config' @@ -35,12 +35,12 @@ log = logging.getLogger('gajim.c.pubsub') class ConnectionPubSub: def __init__(self): self.__callbacks = {} - gajim.nec.register_incoming_event(PubsubBookmarksReceivedEvent) - gajim.ged.register_event_handler('pubsub-bookmarks-received', + app.nec.register_incoming_event(PubsubBookmarksReceivedEvent) + app.ged.register_event_handler('pubsub-bookmarks-received', ged.CORE, self._nec_pubsub_bookmarks_received) def cleanup(self): - gajim.ged.remove_event_handler('pubsub-bookmarks-received', + app.ged.remove_event_handler('pubsub-bookmarks-received', ged.CORE, self._nec_pubsub_bookmarks_received) def send_pb_subscription_query(self, jid, cb, *args, **kwargs): @@ -57,7 +57,7 @@ class ConnectionPubSub: def send_pb_subscribe(self, jid, node, cb, *args, **kwargs): if not self.connection or self.connected < 2: return - our_jid = gajim.get_jid_from_account(self.name) + our_jid = app.get_jid_from_account(self.name) query = nbxmpp.Iq('set', to=jid) pb = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB) pb.addChild('subscribe', {'node': node, 'jid': our_jid}) @@ -69,7 +69,7 @@ class ConnectionPubSub: def send_pb_unsubscribe(self, jid, node, cb, *args, **kwargs): if not self.connection or self.connected < 2: return - our_jid = gajim.get_jid_from_account(self.name) + our_jid = app.get_jid_from_account(self.name) query = nbxmpp.Iq('set', to=jid) pb = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB) pb.addChild('unsubscribe', {'node': node, 'jid': our_jid}) @@ -189,7 +189,7 @@ class ConnectionPubSub: cb(conn, stanza, *args, **kwargs) except Exception: pass - gajim.nec.push_incoming_event(PubsubReceivedEvent(None, + app.nec.push_incoming_event(PubsubReceivedEvent(None, conn=self, stanza=stanza)) def _nec_pubsub_bookmarks_received(self, obj): diff --git a/gajim/common/sleepy.py b/gajim/common/sleepy.py index 28363e1b8..57904a40b 100644 --- a/gajim/common/sleepy.py +++ b/gajim/common/sleepy.py @@ -21,7 +21,7 @@ ## along with Gajim. If not, see . ## -from gajim.common import gajim +from gajim.common import app import os @@ -52,7 +52,7 @@ try: from gajim.common import idle idle.xss_available except Exception: - gajim.log.debug('Unable to load idle module') + app.log.debug('Unable to load idle module') SUPPORTED = False class SleepyWindows: diff --git a/gajim/common/socks5.py b/gajim/common/socks5.py index 9cb9ada24..90013683b 100644 --- a/gajim/common/socks5.py +++ b/gajim/common/socks5.py @@ -35,7 +35,7 @@ from errno import EINPROGRESS from errno import EAFNOSUPPORT from nbxmpp.idlequeue import IdleObject from gajim.common.file_props import FilesProp -from gajim.common import gajim +from gajim.common import app from gajim.common import jingle_xtls if jingle_xtls.PYOPENSSL_PRESENT: import OpenSSL @@ -501,10 +501,10 @@ class Socks5(object): self._sock = socket.socket(*ai[:3]) if self.fingerprint is not None: if self.file_props.type_ == 's': - remote_jid = gajim.get_jid_without_resource( + remote_jid = app.get_jid_without_resource( self.file_props.receiver) else: - remote_jid = gajim.get_jid_without_resource( + remote_jid = app.get_jid_without_resource( self.file_props.sender) self._sock = OpenSSL.SSL.Connection( jingle_xtls.get_context('client', diff --git a/gajim/common/stanza_session.py b/gajim/common/stanza_session.py index 678384739..ebf897b49 100644 --- a/gajim/common/stanza_session.py +++ b/gajim/common/stanza_session.py @@ -22,7 +22,7 @@ ## along with Gajim. If not, see . ## -from gajim.common import gajim +from gajim.common import app import nbxmpp from gajim.common.exceptions import DecryptionError, NegotiationError import nbxmpp.c14n @@ -40,7 +40,7 @@ from gajim.common import crypto import logging log = logging.getLogger('gajim.c.stanza_session') -if gajim.HAVE_PYCRYPTO: +if app.HAVE_PYCRYPTO: from Crypto.Cipher import AES from Crypto.PublicKey import RSA @@ -78,12 +78,12 @@ class StanzaSession(object): self.negotiated = {} def is_loggable(self): - return self.loggable and gajim.config.should_log(self.conn.name, + return self.loggable and app.config.should_log(self.conn.name, self.jid.getStripped()) def get_to(self): to = str(self.jid) - return gajim.get_jid_without_resource(to) + '/' + self.resource + return app.get_jid_without_resource(to) + '/' + self.resource def remove_events(self, types): """ @@ -94,7 +94,7 @@ class StanzaSession(object): any_removed = False for j in (self.jid, self.jid.getStripped()): - for event in gajim.events.get_events(self.conn.name, j, types=types): + for event in app.events.get_events(self.conn.name, j, types=types): # the event wasn't in this session if (event.type_ == 'chat' and event.session != self) or \ (event.type_ == 'printed_chat' and event.control.session != \ @@ -103,7 +103,7 @@ class StanzaSession(object): # events.remove_events returns True when there were no events # for some reason - r = gajim.events.remove_events(self.conn.name, j, event) + r = app.events.remove_events(self.conn.name, j, event) if not r: any_removed = True @@ -315,7 +315,7 @@ class EncryptedStanzaSession(ArchivingStanzaSession): of any of the types listed in 'encryptable_stanzas' should be encrypted before they're sent. - The transition between these states is handled in gajim.py's + The transition between these states is handled in app.py's handle_session_negotiation method. """ @@ -337,9 +337,9 @@ class EncryptedStanzaSession(ArchivingStanzaSession): self.verified_identity = False def _get_contact(self): - c = gajim.contacts.get_contact(self.conn.name, self.jid, self.resource) + c = app.contacts.get_contact(self.conn.name, self.jid, self.resource) if not c: - c = gajim.contacts.get_contact(self.conn.name, self.jid) + c = app.contacts.get_contact(self.conn.name, self.jid) return c def _is_buggy_gajim(self): @@ -384,7 +384,7 @@ class EncryptedStanzaSession(ArchivingStanzaSession): def sign(self, string): if self.negotiated['sign_algs'] == (XmlDsig + 'rsa-sha256'): hash_ = crypto.sha256(string) - return crypto.encode_mpi(gajim.pubkey.sign(hash_, '')[0]) + return crypto.encode_mpi(app.pubkey.sign(hash_, '')[0]) def encrypt_stanza(self, stanza): encryptable = [x for x in stanza.getChildren() if x.getName() not in @@ -503,7 +503,7 @@ class EncryptedStanzaSession(ArchivingStanzaSession): return self.decrypter.decrypt(ciphertext) def logging_preference(self): - if gajim.config.get_per('accounts', self.conn.name, + if app.config.get_per('accounts', self.conn.name, 'log_encrypted_sessions'): return ['may', 'mustnot'] else: @@ -697,7 +697,7 @@ class EncryptedStanzaSession(ArchivingStanzaSession): x.addChild(node=nbxmpp.DataField(name='my_nonce', value=base64.b64encode(self.n_s).decode('utf-8'), typ='hidden')) - modp_options = [ int(g) for g in gajim.config.get('esession_modp').split( + modp_options = [ int(g) for g in app.config.get('esession_modp').split( ',') ] x.addChild(node=nbxmpp.DataField(name='modp', typ='list-single', diff --git a/gajim/common/zeroconf/client_zeroconf.py b/gajim/common/zeroconf/client_zeroconf.py index e664bef96..67cd2e4a4 100644 --- a/gajim/common/zeroconf/client_zeroconf.py +++ b/gajim/common/zeroconf/client_zeroconf.py @@ -17,7 +17,7 @@ ## You should have received a copy of the GNU General Public License ## along with Gajim. If not, see . ## -from gajim.common import gajim +from gajim.common import app import nbxmpp from nbxmpp.idlequeue import IdleObject from nbxmpp import dispatcher_nb, simplexml @@ -87,7 +87,7 @@ class ZeroconfListener(IdleObject): self._serv.listen(socket.SOMAXCONN) self._serv.setblocking(False) self.fd = self._serv.fileno() - gajim.idlequeue.plug_idle(self, False, True) + app.idlequeue.plug_idle(self, False, True) self.started = True def pollend(self): @@ -117,8 +117,8 @@ class ZeroconfListener(IdleObject): Free all resources, we are not listening anymore """ log.info('Disconnecting ZeroconfListener: %s' % message) - gajim.idlequeue.remove_timeout(self.fd) - gajim.idlequeue.unplug_idle(self.fd) + app.idlequeue.remove_timeout(self.fd) + app.idlequeue.unplug_idle(self.fd) self.fd = -1 self.started = False try: @@ -400,14 +400,14 @@ class P2PConnection(IdleObject, PlugIn): self.connect_to_next_ip() return self.fd = self._sock.fileno() - gajim.idlequeue.plug_idle(self, True, False) + app.idlequeue.plug_idle(self, True, False) self.set_timeout(CONNECT_TIMEOUT_SECONDS) self.do_connect() def set_timeout(self, timeout): - gajim.idlequeue.remove_timeout(self.fd) + app.idlequeue.remove_timeout(self.fd) if self.state >= 0: - gajim.idlequeue.set_read_timeout(self.fd, timeout) + app.idlequeue.set_read_timeout(self.fd, timeout) def plugin(self, owner): self.onreceive(owner._on_receive_document_attrs) @@ -492,7 +492,7 @@ class P2PConnection(IdleObject, PlugIn): if self.state == 0: self.do_connect() return - gajim.idlequeue.remove_timeout(self.fd) + app.idlequeue.remove_timeout(self.fd) self._do_send() def pollend(self): @@ -550,8 +550,8 @@ class P2PConnection(IdleObject, PlugIn): """ Close the socket """ - gajim.idlequeue.remove_timeout(self.fd) - gajim.idlequeue.unplug_idle(self.fd) + app.idlequeue.remove_timeout(self.fd) + app.idlequeue.unplug_idle(self.fd) try: self._sock.shutdown(socket.SHUT_RDWR) self._sock.close() @@ -575,7 +575,7 @@ class P2PConnection(IdleObject, PlugIn): self.sendbuff = self.sendbuff[send_count:] if not self.sendbuff and not self.sendqueue: if self.state < 0: - gajim.idlequeue.unplug_idle(self.fd) + app.idlequeue.unplug_idle(self.fd) self._on_send() self.disconnect() return @@ -602,7 +602,7 @@ class P2PConnection(IdleObject, PlugIn): else: writable = False if self.writable != writable or self.readable != readable: - gajim.idlequeue.plug_idle(self, writable, readable) + app.idlequeue.plug_idle(self, writable, readable) def _on_send(self): @@ -830,7 +830,7 @@ class ClientZeroconf: # if timeout: # self._owner.set_timeout(timeout) to = stanza.getTo() - to = gajim.get_jid_without_resource(to) + to = app.get_jid_without_resource(to) try: item = self.roster[to] diff --git a/gajim/common/zeroconf/connection_handlers_zeroconf.py b/gajim/common/zeroconf/connection_handlers_zeroconf.py index 237704b42..584c6fbfc 100644 --- a/gajim/common/zeroconf/connection_handlers_zeroconf.py +++ b/gajim/common/zeroconf/connection_handlers_zeroconf.py @@ -25,7 +25,7 @@ import nbxmpp -from gajim.common import gajim +from gajim.common import app from gajim.common.commands import ConnectionCommands from gajim.common.protocol.bytestream import ConnectionSocks5BytestreamZeroconf from gajim.common.connection_handlers_events import ZeroconfMessageReceivedEvent @@ -84,7 +84,7 @@ connection_handlers.ConnectionJingle): Called when we receive a message """ log.debug('Zeroconf MessageCB') - gajim.nec.push_incoming_event(ZeroconfMessageReceivedEvent(None, + app.nec.push_incoming_event(ZeroconfMessageReceivedEvent(None, conn=self, stanza=msg, ip=ip)) return diff --git a/gajim/common/zeroconf/connection_zeroconf.py b/gajim/common/zeroconf/connection_zeroconf.py index 50185bfeb..10220a6e1 100644 --- a/gajim/common/zeroconf/connection_zeroconf.py +++ b/gajim/common/zeroconf/connection_zeroconf.py @@ -43,7 +43,7 @@ import getpass from gi.repository import GLib from gajim.common.connection import CommonConnection -from gajim.common import gajim +from gajim.common import app from gajim.common import ged from gajim.common.zeroconf import client_zeroconf from gajim.common.zeroconf import zeroconf @@ -64,7 +64,7 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): CommonConnection.__init__(self, name) self.is_zeroconf = True - gajim.ged.register_event_handler('stanza-message-outgoing', ged.OUT_CORE, + app.ged.register_event_handler('stanza-message-outgoing', ged.OUT_CORE, self._nec_stanza_message_outgoing) def get_config_values_or_default(self): @@ -72,49 +72,49 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): Get name, host, port from config, or create zeroconf account with default values """ - if not gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'name'): - gajim.log.debug('Creating zeroconf account') - gajim.config.add_per('accounts', gajim.ZEROCONF_ACC_NAME) - gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, + if not app.config.get_per('accounts', app.ZEROCONF_ACC_NAME, 'name'): + app.log.debug('Creating zeroconf account') + app.config.add_per('accounts', app.ZEROCONF_ACC_NAME) + app.config.set_per('accounts', app.ZEROCONF_ACC_NAME, 'autoconnect', True) - gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'no_log_for', + app.config.set_per('accounts', app.ZEROCONF_ACC_NAME, 'no_log_for', '') - gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'password', + app.config.set_per('accounts', app.ZEROCONF_ACC_NAME, 'password', 'zeroconf') - gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, + app.config.set_per('accounts', app.ZEROCONF_ACC_NAME, 'sync_with_global_status', True) - gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, + app.config.set_per('accounts', app.ZEROCONF_ACC_NAME, 'custom_port', 5298) - gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, + app.config.set_per('accounts', app.ZEROCONF_ACC_NAME, 'is_zeroconf', True) - gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, + app.config.set_per('accounts', app.ZEROCONF_ACC_NAME, 'use_ft_proxies', False) self.host = socket.gethostname() - gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'hostname', + app.config.set_per('accounts', app.ZEROCONF_ACC_NAME, 'hostname', self.host) - self.port = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, + self.port = app.config.get_per('accounts', app.ZEROCONF_ACC_NAME, 'custom_port') - self.autoconnect = gajim.config.get_per('accounts', - gajim.ZEROCONF_ACC_NAME, 'autoconnect') - self.sync_with_global_status = gajim.config.get_per('accounts', - gajim.ZEROCONF_ACC_NAME, 'sync_with_global_status') - self.first = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, + self.autoconnect = app.config.get_per('accounts', + app.ZEROCONF_ACC_NAME, 'autoconnect') + self.sync_with_global_status = app.config.get_per('accounts', + app.ZEROCONF_ACC_NAME, 'sync_with_global_status') + self.first = app.config.get_per('accounts', app.ZEROCONF_ACC_NAME, 'zeroconf_first_name') - self.last = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, + self.last = app.config.get_per('accounts', app.ZEROCONF_ACC_NAME, 'zeroconf_last_name') - self.jabber_id = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, + self.jabber_id = app.config.get_per('accounts', app.ZEROCONF_ACC_NAME, 'zeroconf_jabber_id') - self.email = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, + self.email = app.config.get_per('accounts', app.ZEROCONF_ACC_NAME, 'zeroconf_email') if not self.username: self.username = getpass.getuser() - gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'name', + app.config.set_per('accounts', app.ZEROCONF_ACC_NAME, 'name', self.username) else: - self.username = gajim.config.get_per('accounts', - gajim.ZEROCONF_ACC_NAME, 'name') + self.username = app.config.get_per('accounts', + app.ZEROCONF_ACC_NAME, 'name') # END __init__ def check_jid(self, jid): @@ -123,7 +123,7 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): def reconnect(self): # Do not try to reco while we are already trying self.time_to_reconnect = None - gajim.log.debug('reconnect') + app.log.debug('reconnect') self.disconnect() self.change_status(self.old_show, self.status) @@ -137,10 +137,10 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): diffs = self.roster.getDiffs() for key in diffs: self.roster.setItem(key) - gajim.nec.push_incoming_event(RosterInfoEvent(None, conn=self, + app.nec.push_incoming_event(RosterInfoEvent(None, conn=self, jid=key, nickname=self.roster.getName(key), sub='both', ask='no', groups=self.roster.getGroups(key))) - gajim.nec.push_incoming_event(ZeroconfPresenceReceivedEvent( + app.nec.push_incoming_event(ZeroconfPresenceReceivedEvent( None, conn=self, fjid=key, show=self.roster.getStatus(key), status=self.roster.getMessage(key))) #XXX open chat windows don't get refreshed (full name), add that @@ -149,10 +149,10 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): # callbacks called from zeroconf def _on_new_service(self, jid): self.roster.setItem(jid) - gajim.nec.push_incoming_event(RosterInfoEvent(None, conn=self, + app.nec.push_incoming_event(RosterInfoEvent(None, conn=self, jid=jid, nickname=self.roster.getName(jid), sub='both', ask='no', groups=self.roster.getGroups(jid))) - gajim.nec.push_incoming_event(ZeroconfPresenceReceivedEvent( + app.nec.push_incoming_event(ZeroconfPresenceReceivedEvent( None, conn=self, fjid=jid, show=self.roster.getStatus(jid), status=self.roster.getMessage(jid))) @@ -160,7 +160,7 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): self.roster.delItem(jid) # 'NOTIFY' (account, (jid, status, status message, resource, priority, # keyID, timestamp, contact_nickname)) - gajim.nec.push_incoming_event(ZeroconfPresenceReceivedEvent( + app.nec.push_incoming_event(ZeroconfPresenceReceivedEvent( None, conn=self, fjid=jid, show='offline', status='')) def disconnectedReconnCB(self): @@ -168,12 +168,12 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): Called when we are disconnected. Comes from network manager for example we don't try to reconnect, network manager will tell us when we can """ - if gajim.account_is_connected(self.name): + if app.account_is_connected(self.name): # we cannot change our status to offline or connecting # after we auth to server self.old_show = STATUS_LIST[self.connected] self.connected = 0 - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show='offline')) # random number to show we wait network manager to send us a reconenct self.time_to_reconnect = 5 @@ -181,13 +181,13 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): def _on_name_conflictCB(self, alt_name): self.disconnect() - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show='offline')) - gajim.nec.push_incoming_event(ZeroconfNameConflictEvent(None, conn=self, + app.nec.push_incoming_event(ZeroconfNameConflictEvent(None, conn=self, alt_name=alt_name)) def _on_error(self, message): - gajim.nec.push_incoming_event(InformationEvent(None, conn=self, + app.nec.push_incoming_event(InformationEvent(None, conn=self, level='error', pri_txt=_('Avahi error'), sec_txt=_('%s\nLink-local ' 'messaging might not work properly.') % message)) @@ -196,25 +196,25 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): if not self.connection: self.connection = client_zeroconf.ClientZeroconf(self) if not zeroconf.test_zeroconf(): - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show='offline')) self.status = 'offline' - gajim.nec.push_incoming_event(ConnectionLostEvent(None, + app.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, title=_('Could not connect to "%s"') % self.name, msg=_('Please check if Avahi or Bonjour is installed.'))) self.disconnect() return result = self.connection.connect(show, msg) if not result: - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show='offline')) self.status = 'offline' if result is False: - gajim.nec.push_incoming_event(ConnectionLostEvent(None, + app.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, title=_('Could not start local service'), msg=_('Unable to bind to port %d.' % self.port))) else: # result is None - gajim.nec.push_incoming_event(ConnectionLostEvent(None, + app.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, title=_('Could not start local service'), msg=_('Please check if avahi-daemon is running.'))) self.disconnect() @@ -222,15 +222,15 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): else: self.connection.announce() self.roster = self.connection.getRoster() - gajim.nec.push_incoming_event(RosterReceivedEvent(None, conn=self, + app.nec.push_incoming_event(RosterReceivedEvent(None, conn=self, xmpp_roster=self.roster)) # display contacts already detected and resolved for jid in self.roster.keys(): - gajim.nec.push_incoming_event(RosterInfoEvent(None, conn=self, + app.nec.push_incoming_event(RosterInfoEvent(None, conn=self, jid=jid, nickname=self.roster.getName(jid), sub='both', ask='no', groups=self.roster.getGroups(jid))) - gajim.nec.push_incoming_event(ZeroconfPresenceReceivedEvent( + app.nec.push_incoming_event(ZeroconfPresenceReceivedEvent( None, conn=self, fjid=jid, show=self.roster.getStatus(jid), status=self.roster.getMessage(jid))) @@ -253,19 +253,19 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): def reannounce(self): if self.connected: txt = {} - txt['1st'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, + txt['1st'] = app.config.get_per('accounts', app.ZEROCONF_ACC_NAME, 'zeroconf_first_name') - txt['last'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, + txt['last'] = app.config.get_per('accounts', app.ZEROCONF_ACC_NAME, 'zeroconf_last_name') - txt['jid'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, + txt['jid'] = app.config.get_per('accounts', app.ZEROCONF_ACC_NAME, 'zeroconf_jabber_id') - txt['email'] = gajim.config.get_per('accounts', - gajim.ZEROCONF_ACC_NAME, 'zeroconf_email') + txt['email'] = app.config.get_per('accounts', + app.ZEROCONF_ACC_NAME, 'zeroconf_email') self.connection.reannounce(txt) def update_details(self): if self.connection: - port = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, + port = app.config.get_per('accounts', app.ZEROCONF_ACC_NAME, 'custom_port') if port != self.port: self.port = port @@ -287,32 +287,32 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): check = self.connection.announce() else: self.connected = STATUS_LIST.index(show) - gajim.nec.push_incoming_event(SignedInEvent(None, conn=self)) + app.nec.push_incoming_event(SignedInEvent(None, conn=self)) # stay offline when zeroconf does something wrong if check: - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show=show)) else: # show notification that avahi or system bus is down self.connected = 0 - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show='offline')) self.status = 'offline' - gajim.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, + app.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, title=_('Could not change status of account "%s"') % self.name, msg=_('Please check if avahi-daemon is running.'))) def _change_to_invisible(self, msg): if self.connection.remove_announce(): - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show='invisible')) else: # show notification that avahi or system bus is down - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show='offline')) self.status = 'offline' - gajim.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, + app.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, title=_('Could not change status of account "%s"') % self.name, msg=_('Please check if avahi-daemon is running.'))) @@ -321,14 +321,14 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): def _update_status(self, show, msg): if self.connection.set_show_msg(show, msg): - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show=show)) else: # show notification that avahi or system bus is down - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + app.nec.push_incoming_event(OurShowEvent(None, conn=self, show='offline')) self.status = 'offline' - gajim.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, + app.nec.push_incoming_event(ConnectionLostEvent(None, conn=self, title=_('Could not change status of account "%s"') % self.name, msg=_('Please check if avahi-daemon is running.'))) @@ -337,7 +337,7 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): return def on_send_ok(stanza_id): - gajim.nec.push_incoming_event(MessageSentEvent(None, conn=self, + app.nec.push_incoming_event(MessageSentEvent(None, conn=self, jid=obj.jid, message=obj.message, keyID=obj.keyID, automatic_message=obj.automatic_message, chatstate=None, stanza_id=stanza_id)) @@ -348,7 +348,7 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): def on_send_not_ok(reason): reason += ' ' + _('Your message could not be sent.') - gajim.nec.push_incoming_event(MessageErrorEvent(None, conn=self, + app.nec.push_incoming_event(MessageErrorEvent(None, conn=self, fjid=obj.jid, error_code=-1, error_msg=reason, msg=None, time_=None, session=obj.session)) @@ -358,7 +358,7 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): if ret == -1: # Contact Offline - gajim.nec.push_incoming_event(MessageErrorEvent(None, conn=self, + app.nec.push_incoming_event(MessageErrorEvent(None, conn=self, fjid=obj.jid, error_code=-1, error_msg=_( 'Contact is offline. Your message could not be sent.'), msg=None, time_=None, session=obj.session)) @@ -378,7 +378,7 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): thread_id = data[1] frm = data[0] session = self.get_or_create_session(frm, thread_id) - gajim.nec.push_incoming_event(MessageErrorEvent( + app.nec.push_incoming_event(MessageErrorEvent( None, conn=self, fjid=frm, error_code=-1, error_msg=_( 'Connection to host could not be established: Timeout while ' 'sending data.'), msg=None, time_=None, session=session)) diff --git a/gajim/common/zeroconf/zeroconf_bonjour.py b/gajim/common/zeroconf/zeroconf_bonjour.py index f6ffd19b2..9c2257e2b 100644 --- a/gajim/common/zeroconf/zeroconf_bonjour.py +++ b/gajim/common/zeroconf/zeroconf_bonjour.py @@ -17,7 +17,7 @@ ## along with Gajim. If not, see . ## -from gajim.common import gajim +from gajim.common import app import select import re from gajim.common.zeroconf.zeroconf import Constant @@ -56,7 +56,7 @@ class Zeroconf: def browse_callback(self, sdRef, flags, interfaceIndex, errorCode, serviceName, regtype, replyDomain): - gajim.log.debug('Found service %s in domain %s on %i(type: %s).' % (serviceName, replyDomain, interfaceIndex, regtype)) + app.log.debug('Found service %s in domain %s on %i(type: %s).' % (serviceName, replyDomain, interfaceIndex, regtype)) if not self.connected: return if errorCode != pybonjour.kDNSServiceErr_NoError: @@ -72,7 +72,7 @@ class Zeroconf: while not self.resolved: ready = select.select([resolve_sdRef], [], [], resolve_timeout) if resolve_sdRef not in ready[0]: - gajim.log.debug('Resolve timed out') + app.log.debug('Resolve timed out') break pybonjour.DNSServiceProcessResult(resolve_sdRef) else: @@ -81,7 +81,7 @@ class Zeroconf: resolve_sdRef.close() def remove_service_callback(self, name): - gajim.log.debug('Service %s disappeared.' % name) + app.log.debug('Service %s disappeared.' % name) if not self.connected: return if name != self.name: @@ -121,8 +121,8 @@ class Zeroconf: txt = pybonjour.TXTRecord.parse(txtRecord) - gajim.log.debug('Service data for service %s on %i:' % (fullname, interfaceIndex)) - gajim.log.debug('Host %s, port %i, TXT data: %s' % (hosttarget, port, txt._items)) + app.log.debug('Service data for service %s on %i:' % (fullname, interfaceIndex)) + app.log.debug('Host %s, port %i, TXT data: %s' % (hosttarget, port, txt._items)) if not self.connected: return @@ -176,11 +176,11 @@ class Zeroconf: def service_added_callback(self, sdRef, flags, errorCode, name, regtype, domain): if errorCode == pybonjour.kDNSServiceErr_NoError: - gajim.log.debug('Service successfully added') + app.log.debug('Service successfully added') def service_add_fail_callback(self, err): if err[0][0] == pybonjour.kDNSServiceErr_NameConflict: - gajim.log.debug('Error while adding service. %s' % str(err)) + app.log.debug('Error while adding service. %s' % str(err)) parts = self.username.split(' ') #check if last part is a number and if, increment it @@ -230,7 +230,7 @@ class Zeroconf: except pybonjour.BonjourError as e: self.service_add_fail_callback(e) else: - gajim.log.debug('Publishing service %s of type %s' % (self.name, self.stype)) + app.log.debug('Publishing service %s of type %s' % (self.name, self.stype)) ready = select.select([sdRef], [], [], resolve_timeout) if sdRef in ready[0]: @@ -252,7 +252,7 @@ class Zeroconf: self.announced = False return True except pybonjour.BonjourError as e: - gajim.log.debug(e) + app.log.debug(e) return False @@ -282,7 +282,7 @@ class Zeroconf: self.remove_announce() def browse_domain(self, domain=None): - gajim.log.debug('starting to browse') + app.log.debug('starting to browse') try: self.browse_sdRef = pybonjour.DNSServiceBrowse(regtype=self.stype, domain=domain, callBack=self.browse_callback) except pybonjour.BonjourError as e: @@ -310,7 +310,7 @@ class Zeroconf: try: ready = select.select([resolve_sdRef], [], [], resolve_timeout) if resolve_sdRef not in ready[0]: - gajim.log.debug('Resolve timed out (in resolve_all)') + app.log.debug('Resolve timed out (in resolve_all)') break pybonjour.DNSServiceProcessResult(resolve_sdRef) finally: diff --git a/gajim/config.py b/gajim/config.py index b27248177..8f2120fd6 100644 --- a/gajim/config.py +++ b/gajim/config.py @@ -57,7 +57,7 @@ except (ImportError, ValueError): HAS_GTK_SPELL = False from gajim.common import helpers -from gajim.common import gajim +from gajim.common import app from gajim.common import connection from gajim.common import passwords from gajim.common.zeroconf import connection_zeroconf @@ -85,7 +85,7 @@ class PreferencesWindow: """ Close window """ - del gajim.interface.instances['preferences'] + del app.interface.instances['preferences'] def on_close_button_clicked(self, widget): self.window.destroy() @@ -96,7 +96,7 @@ class PreferencesWindow: """ self.xml = gtkgui_helpers.get_gtk_builder('preferences_window.ui') self.window = self.xml.get_object('preferences_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.window.set_transient_for(app.interface.roster.window) self.notebook = self.xml.get_object('preferences_notebook') self.one_window_type_combobox = self.xml.get_object( 'one_window_type_combobox') @@ -122,20 +122,20 @@ class PreferencesWindow: ### General tab ### # Display avatars in roster - st = gajim.config.get('show_avatars_in_roster') + st = app.config.get('show_avatars_in_roster') self.xml.get_object('show_avatars_in_roster_checkbutton'). \ set_active(st) # Display status msg under contact name in roster - st = gajim.config.get('show_status_msgs_in_roster') + st = app.config.get('show_status_msgs_in_roster') self.xml.get_object('show_status_msgs_in_roster_checkbutton'). \ set_active( st) # Display PEP in roster - st1 = gajim.config.get('show_mood_in_roster') - st2 = gajim.config.get('show_activity_in_roster') - st3 = gajim.config.get('show_tunes_in_roster') - st4 = gajim.config.get('show_location_in_roster') + st1 = app.config.get('show_mood_in_roster') + st2 = app.config.get('show_activity_in_roster') + st3 = app.config.get('show_tunes_in_roster') + st4 = app.config.get('show_location_in_roster') w = self.xml.get_object('show_pep_in_roster_checkbutton') if st1 == st2 == st3 == st4: w.set_active(st1) @@ -143,17 +143,17 @@ class PreferencesWindow: w.set_inconsistent(True) # Sort contacts by show - st = gajim.config.get('sort_by_show_in_roster') + st = app.config.get('sort_by_show_in_roster') self.xml.get_object('sort_by_show_in_roster_checkbutton').set_active(st) - st = gajim.config.get('sort_by_show_in_muc') + st = app.config.get('sort_by_show_in_muc') self.xml.get_object('sort_by_show_in_muc_checkbutton').set_active(st) # emoticons emoticons_combobox = self.xml.get_object('emoticons_combobox') - emoticons_list = os.listdir(os.path.join(gajim.DATA_DIR, 'emoticons')) + emoticons_list = os.listdir(os.path.join(app.DATA_DIR, 'emoticons')) # user themes - if os.path.isdir(gajim.MY_EMOTS_PATH): - emoticons_list += os.listdir(gajim.MY_EMOTS_PATH) + if os.path.isdir(app.MY_EMOTS_PATH): + emoticons_list += os.listdir(app.MY_EMOTS_PATH) emoticons_list.sort() renderer_text = Gtk.CellRendererText() emoticons_combobox.pack_start(renderer_text, True) @@ -162,21 +162,21 @@ class PreferencesWindow: emoticons_combobox.set_model(model) l = [_('Disabled')] for dir_ in emoticons_list: - if not os.path.isdir(os.path.join(gajim.DATA_DIR, 'emoticons', dir_)) \ - and not os.path.isdir(os.path.join(gajim.MY_EMOTS_PATH, dir_)) : + if not os.path.isdir(os.path.join(app.DATA_DIR, 'emoticons', dir_)) \ + and not os.path.isdir(os.path.join(app.MY_EMOTS_PATH, dir_)) : continue if dir_ != '.svn': l.append(dir_) for i in range(len(l)): model.append([l[i]]) - if gajim.config.get('emoticons_theme') == l[i]: + if app.config.get('emoticons_theme') == l[i]: emoticons_combobox.set_active(i) - if not gajim.config.get('emoticons_theme'): + if not app.config.get('emoticons_theme'): emoticons_combobox.set_active(0) # Set default for single window type choices = c_config.opt_one_window_types - type_ = gajim.config.get('one_message_window') + type_ = app.config.get('one_message_window') if type_ in choices: self.one_window_type_combobox.set_active(choices.index(type_)) else: @@ -185,33 +185,33 @@ class PreferencesWindow: # Show roster on startup show_roster_combobox = self.xml.get_object('show_roster_on_startup') choices = c_config.opt_show_roster_on_startup - type_ = gajim.config.get('show_roster_on_startup') + type_ = app.config.get('show_roster_on_startup') if type_ in choices: show_roster_combobox.set_active(choices.index(type_)) else: show_roster_combobox.set_active(0) # Compact View - st = gajim.config.get('compact_view') + st = app.config.get('compact_view') self.xml.get_object('compact_view_checkbutton').set_active(st) # Ignore XHTML - st = gajim.config.get('ignore_incoming_xhtml') + st = app.config.get('ignore_incoming_xhtml') self.xml.get_object('xhtml_checkbutton').set_active(st) # use speller if HAS_GTK_SPELL: - st = gajim.config.get('use_speller') + st = app.config.get('use_speller') self.xml.get_object('speller_checkbutton').set_active(st) else: self.xml.get_object('speller_checkbutton').set_sensitive(False) # XEP-0184 positive ack - st = gajim.config.get('positive_184_ack') + st = app.config.get('positive_184_ack') self.xml.get_object('positive_184_ack_checkbutton').set_active(st) # Show avatar in tabs - st = gajim.config.get('show_avatar_in_tabs') + st = app.config.get('show_avatar_in_tabs') self.xml.get_object('show_avatar_in_tabs_checkbutton').set_active(st) ### Style tab ### @@ -223,9 +223,9 @@ class PreferencesWindow: self.update_theme_list() # iconset - iconsets_list = os.listdir(os.path.join(gajim.DATA_DIR, 'iconsets')) - if os.path.isdir(gajim.MY_ICONSETS_PATH): - iconsets_list += os.listdir(gajim.MY_ICONSETS_PATH) + iconsets_list = os.listdir(os.path.join(app.DATA_DIR, 'iconsets')) + if os.path.isdir(app.MY_ICONSETS_PATH): + iconsets_list += os.listdir(app.MY_ICONSETS_PATH) # new model, image in 0, string in 1 model = Gtk.ListStore(Gtk.Image, str) renderer_image = cell_renderer_image.CellRendererImage(0, 0) @@ -238,8 +238,8 @@ class PreferencesWindow: self.iconset_combobox.set_model(model) l = [] for dir in iconsets_list: - if not os.path.isdir(os.path.join(gajim.DATA_DIR, 'iconsets', dir)) \ - and not os.path.isdir(os.path.join(gajim.MY_ICONSETS_PATH, dir)): + if not os.path.isdir(os.path.join(app.DATA_DIR, 'iconsets', dir)) \ + and not os.path.isdir(os.path.join(app.MY_ICONSETS_PATH, dir)): continue if dir != '.svn' and dir != 'transports': l.append(dir) @@ -256,18 +256,18 @@ class PreferencesWindow: if os.path.exists(file_): preview.set_from_file(file_) model.append([preview, l[i]]) - if gajim.config.get('iconset') == l[i]: + if app.config.get('iconset') == l[i]: self.iconset_combobox.set_active(i) # Use transports iconsets - st = gajim.config.get('use_transports_iconsets') + st = app.config.get('use_transports_iconsets') self.xml.get_object('transports_iconsets_checkbutton').set_active(st) # Color widgets self.draw_color_widgets() # Font for messages - font = gajim.config.get('conversation_font') + font = app.config.get('conversation_font') # try to set default font for the current desktop env fontbutton = self.xml.get_object('conversation_fontbutton') if font == '': @@ -278,7 +278,7 @@ class PreferencesWindow: ### Personal Events tab ### # outgoing send chat state notifications - st = gajim.config.get('outgoing_chat_state_notifications') + st = app.config.get('outgoing_chat_state_notifications') combo = self.xml.get_object('outgoing_chat_states_combobox') if st == 'all': combo.set_active(0) @@ -288,7 +288,7 @@ class PreferencesWindow: combo.set_active(2) # displayed send chat state notifications - st = gajim.config.get('displayed_chat_state_notifications') + st = app.config.get('displayed_chat_state_notifications') combo = self.xml.get_object('displayed_chat_states_combobox') if st == 'all': combo.set_active(0) @@ -301,44 +301,44 @@ class PreferencesWindow: ### Notifications tab ### # On new event on_event_combobox = self.xml.get_object('on_event_combobox') - if gajim.config.get('autopopup'): + if app.config.get('autopopup'): on_event_combobox.set_active(0) - elif gajim.config.get('notify_on_new_message'): + elif app.config.get('notify_on_new_message'): on_event_combobox.set_active(1) else: on_event_combobox.set_active(2) # notify on online statuses - st = gajim.config.get('notify_on_signin') + st = app.config.get('notify_on_signin') self.notify_on_signin_checkbutton.set_active(st) # notify on offline statuses - st = gajim.config.get('notify_on_signout') + st = app.config.get('notify_on_signout') self.notify_on_signout_checkbutton.set_active(st) # autopopupaway - st = gajim.config.get('autopopupaway') + st = app.config.get('autopopupaway') self.auto_popup_away_checkbutton.set_active(st) # autopopup_chat_opened - st = gajim.config.get('autopopup_chat_opened') + st = app.config.get('autopopup_chat_opened') self.auto_popup_chat_opened_checkbutton.set_active(st) # sounddnd - st = gajim.config.get('sounddnd') + st = app.config.get('sounddnd') self.sound_dnd_checkbutton.set_active(st) # Systray systray_combobox = self.xml.get_object('systray_combobox') - if gajim.config.get('trayicon') == 'never': + if app.config.get('trayicon') == 'never': systray_combobox.set_active(0) - elif gajim.config.get('trayicon') == 'on_event': + elif app.config.get('trayicon') == 'on_event': systray_combobox.set_active(1) else: systray_combobox.set_active(2) # sounds - if gajim.config.get('sounds_on'): + if app.config.get('sounds_on'): self.xml.get_object('play_sounds_checkbutton').set_active(True) else: self.xml.get_object('manage_sounds_button').set_sensitive(False) @@ -350,53 +350,53 @@ class PreferencesWindow: notify_gmail_extra_checkbutton = self.xml.get_object( 'notify_gmail_extra_checkbutton') - for account in gajim.config.get_per('accounts'): - jid = gajim.get_jid_from_account(account) - if gajim.get_server_from_jid(jid) in gajim.gmail_domains: + for account in app.config.get_per('accounts'): + jid = app.get_jid_from_account(account) + if app.get_server_from_jid(jid) in app.gmail_domains: frame_gmail.set_sensitive(True) - st = gajim.config.get('notify_on_new_gmail_email') + st = app.config.get('notify_on_new_gmail_email') notify_gmail_checkbutton.set_active(st) - st = gajim.config.get('notify_on_new_gmail_email_extra') + st = app.config.get('notify_on_new_gmail_email_extra') notify_gmail_extra_checkbutton.set_active(st) break #### Status tab ### # Autoaway - st = gajim.config.get('autoaway') + st = app.config.get('autoaway') self.auto_away_checkbutton.set_active(st) # Autoawaytime - st = gajim.config.get('autoawaytime') + st = app.config.get('autoawaytime') self.auto_away_time_spinbutton.set_value(st) - self.auto_away_time_spinbutton.set_sensitive(gajim.config.get('autoaway')) + self.auto_away_time_spinbutton.set_sensitive(app.config.get('autoaway')) # autoaway message - st = gajim.config.get('autoaway_message') + st = app.config.get('autoaway_message') self.auto_away_message_entry.set_text(st) - self.auto_away_message_entry.set_sensitive(gajim.config.get('autoaway')) + self.auto_away_message_entry.set_sensitive(app.config.get('autoaway')) # Autoxa - st = gajim.config.get('autoxa') + st = app.config.get('autoxa') self.auto_xa_checkbutton.set_active(st) # Autoxatime - st = gajim.config.get('autoxatime') + st = app.config.get('autoxatime') self.auto_xa_time_spinbutton.set_value(st) - self.auto_xa_time_spinbutton.set_sensitive(gajim.config.get('autoxa')) + self.auto_xa_time_spinbutton.set_sensitive(app.config.get('autoxa')) # autoxa message - st = gajim.config.get('autoxa_message') + st = app.config.get('autoxa_message') self.auto_xa_message_entry.set_text(st) - self.auto_xa_message_entry.set_sensitive(gajim.config.get('autoxa')) + self.auto_xa_message_entry.set_sensitive(app.config.get('autoxa')) if not sleepy.SUPPORTED: self.xml.get_object('autoaway_table').set_sensitive(False) # ask_status when online / offline - st = gajim.config.get('ask_online_status') + st = app.config.get('ask_online_status') self.xml.get_object('prompt_online_status_message_checkbutton').\ set_active(st) - st = gajim.config.get('ask_offline_status') + st = app.config.get('ask_offline_status') self.xml.get_object('prompt_offline_status_message_checkbutton').\ set_active(st) @@ -428,9 +428,9 @@ class PreferencesWindow: model = Gtk.ListStore(str, str) combobox.set_model(model) if config_name: - config = gajim.config.get(config_name) + config = app.config.get(config_name) else: - config = gajim.config.get(opt_name + '_device') + config = app.config.get(opt_name + '_device') for index, (name, value) in enumerate(sorted(device_dict.items(), key=key)): @@ -438,7 +438,7 @@ class PreferencesWindow: if config == value: combobox.set_active(index) - if HAS_GST and gajim.HAVE_FARSTREAM: + if HAS_GST and app.HAVE_FARSTREAM: create_av_combobox('audio_input', AudioInputManager().get_devices()) create_av_combobox('audio_output', AudioOutputManager().get_devices( )) @@ -454,7 +454,7 @@ class PreferencesWindow: '800x600': '800x600', '640x480': '640x480', '320x240': '320x240'}, 'video_size', key=lambda x: -1 if \ not x[1] else int(x[0][:3])) - st = gajim.config.get('video_see_self') + st = app.config.get('video_see_self') self.xml.get_object('video_see_self_checkbutton').set_active(st) else: @@ -465,11 +465,11 @@ class PreferencesWindow: # STUN cb = self.xml.get_object('stun_checkbutton') - st = gajim.config.get('use_stun_server') + st = app.config.get('use_stun_server') cb.set_active(st) entry = self.xml.get_object('stun_server_entry') - entry.set_text(gajim.config.get('stun_server')) + entry.set_text(app.config.get('stun_server')) if not st: entry.set_sensitive(False) @@ -485,21 +485,21 @@ class PreferencesWindow: self.xml.get_object('custom_apps_frame').hide() self.xml.get_object('custom_apps_frame').set_no_show_all(True) - if gajim.config.get('autodetect_browser_mailer'): + if app.config.get('autodetect_browser_mailer'): self.applications_combobox.set_active(0) else: self.applications_combobox.set_active(1) self.xml.get_object('custom_apps_frame').show() self.xml.get_object('custom_browser_entry').set_text( - gajim.config.get('custombrowser')) + app.config.get('custombrowser')) self.xml.get_object('custom_mail_client_entry').set_text( - gajim.config.get('custommailapp')) + app.config.get('custommailapp')) self.xml.get_object('custom_file_manager_entry').set_text( - gajim.config.get('custom_file_manager')) + app.config.get('custom_file_manager')) # log status changes of contacts - st = gajim.config.get('log_contact_status_changes') + st = app.config.get('log_contact_status_changes') self.xml.get_object('log_show_changes_checkbutton').set_active(st) # log encrypted chat sessions @@ -574,12 +574,12 @@ class PreferencesWindow: Return the value of the option opt if it's the same in all accounts else returns "mixed" """ - if len(gajim.connections) == 0: + if len(app.connections) == 0: # a non existant key return default value - return gajim.config.get_per('accounts', '__default__', opt) + return app.config.get_per('accounts', '__default__', opt) val = None - for account in gajim.connections: - v = gajim.config.get_per('accounts', account, opt) + for account in app.connections: + v = app.config.get_per('accounts', account, opt) if val is None: val = v elif val != v: @@ -588,38 +588,38 @@ class PreferencesWindow: def on_checkbutton_toggled(self, widget, config_name, change_sensitivity_widgets=None): - gajim.config.set(config_name, widget.get_active()) + 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_per_account_checkbutton_toggled(self, widget, config_name, change_sensitivity_widgets=None): - for account in gajim.connections: - gajim.config.set_per('accounts', account, config_name, + for account in app.connections: + app.config.set_per('accounts', account, config_name, widget.get_active()) if change_sensitivity_widgets: for w in change_sensitivity_widgets: w.set_sensitive(widget.get_active()) def _get_all_controls(self): - for ctrl in gajim.interface.msg_win_mgr.get_controls(): + for ctrl in app.interface.msg_win_mgr.get_controls(): yield ctrl - for account in gajim.connections: - for ctrl in gajim.interface.minimized_controls[account].values(): + for account in app.connections: + for ctrl in app.interface.minimized_controls[account].values(): yield ctrl def _get_all_muc_controls(self): - for ctrl in gajim.interface.msg_win_mgr.get_controls( + for ctrl in app.interface.msg_win_mgr.get_controls( message_control.TYPE_GC): yield ctrl - for account in gajim.connections: - for ctrl in gajim.interface.minimized_controls[account].values(): + for account in app.connections: + for ctrl in app.interface.minimized_controls[account].values(): yield ctrl def on_sort_by_show_in_roster_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'sort_by_show_in_roster') - gajim.interface.roster.setup_and_draw_roster() + app.interface.roster.setup_and_draw_roster() def on_sort_by_show_in_muc_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'sort_by_show_in_muc') @@ -629,14 +629,14 @@ class PreferencesWindow: def on_show_avatars_in_roster_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'show_avatars_in_roster') - gajim.interface.roster.setup_and_draw_roster() + app.interface.roster.setup_and_draw_roster() # Redraw groupchats (in an ugly way) for ctrl in self._get_all_muc_controls(): ctrl.draw_roster() def on_show_status_msgs_in_roster_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'show_status_msgs_in_roster') - gajim.interface.roster.setup_and_draw_roster() + app.interface.roster.setup_and_draw_roster() for ctrl in self._get_all_muc_controls(): ctrl.update_ui() @@ -645,19 +645,19 @@ class PreferencesWindow: self.on_checkbutton_toggled(widget, 'show_activity_in_roster') self.on_checkbutton_toggled(widget, 'show_tunes_in_roster') self.on_checkbutton_toggled(widget, 'show_location_in_roster') - gajim.interface.roster.setup_and_draw_roster() + app.interface.roster.setup_and_draw_roster() def on_emoticons_combobox_changed(self, widget): active = widget.get_active() model = widget.get_model() emot_theme = model[active][0] if emot_theme == _('Disabled'): - gajim.config.set('emoticons_theme', '') + app.config.set('emoticons_theme', '') else: - gajim.config.set('emoticons_theme', emot_theme) + app.config.set('emoticons_theme', emot_theme) - gajim.interface.init_emoticons() - gajim.interface.make_regexps() + app.interface.init_emoticons() + app.interface.make_regexps() self.toggle_emoticons() def toggle_emoticons(self): @@ -670,19 +670,19 @@ class PreferencesWindow: def on_one_window_type_combo_changed(self, widget): active = widget.get_active() config_type = c_config.opt_one_window_types[active] - gajim.config.set('one_message_window', config_type) - gajim.interface.msg_win_mgr.reconfig() + app.config.set('one_message_window', config_type) + app.interface.msg_win_mgr.reconfig() def on_show_roster_on_startup_changed(self, widget): active = widget.get_active() config_type = c_config.opt_show_roster_on_startup[active] - gajim.config.set('show_roster_on_startup', config_type) + app.config.set('show_roster_on_startup', config_type) def on_compact_view_checkbutton_toggled(self, widget): active = widget.get_active() for ctrl in self._get_all_controls(): ctrl.chat_buttons_set_visible(active) - gajim.config.set('compact_view', active) + app.config.set('compact_view', active) def on_xhtml_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'ignore_incoming_xhtml') @@ -711,11 +711,11 @@ class PreferencesWindow: def on_speller_checkbutton_toggled(self, widget): active = widget.get_active() - gajim.config.set('use_speller', active) + app.config.set('use_speller', active) if active: - lang = gajim.config.get('speller_language') + lang = app.config.get('speller_language') if not lang: - lang = gajim.LANG + lang = app.LANG tv = Gtk.TextView() try: gtkspell.Spell(tv, lang) @@ -725,10 +725,10 @@ class PreferencesWindow: _('You have to install %s dictionary to use spellchecking, or ' 'choose another language by setting the speller_language option.' ) % lang) - gajim.config.set('use_speller', False) + app.config.set('use_speller', False) widget.set_active(False) else: - gajim.config.set('speller_language', lang) + app.config.set('speller_language', lang) self.apply_speller() else: self.remove_speller() @@ -744,11 +744,11 @@ class PreferencesWindow: active = widget.get_active() config_theme = model[active][0].replace(' ', '_') - gajim.config.set('roster_theme', config_theme) + app.config.set('roster_theme', config_theme) # begin repainting themed widgets throughout - gajim.interface.roster.repaint_themed_widgets() - gajim.interface.roster.change_roster_style(None) + app.interface.roster.repaint_themed_widgets() + app.interface.roster.change_roster_style(None) gtkgui_helpers.load_css() def update_theme_list(self): @@ -756,10 +756,10 @@ class PreferencesWindow: model = Gtk.ListStore(str) theme_combobox.set_model(model) i = 0 - for config_theme in gajim.config.get_per('themes'): + for config_theme in app.config.get_per('themes'): theme = config_theme.replace('_', ' ') model.append([theme]) - if gajim.config.get('roster_theme') == config_theme: + if app.config.get('roster_theme') == config_theme: theme_combobox.set_active(i) i += 1 @@ -774,7 +774,7 @@ class PreferencesWindow: model = widget.get_model() active = widget.get_active() icon_string = model[active][1] - gajim.config.set('iconset', icon_string) + app.config.set('iconset', icon_string) gtkgui_helpers.reload_jabber_state_images() def on_transports_iconsets_checkbutton_toggled(self, widget): @@ -783,14 +783,14 @@ class PreferencesWindow: def on_outgoing_chat_states_combobox_changed(self, widget): active = widget.get_active() - old_value = gajim.config.get('outgoing_chat_state_notifications') + old_value = app.config.get('outgoing_chat_state_notifications') if active == 0: # all - gajim.config.set('outgoing_chat_state_notifications', 'all') + app.config.set('outgoing_chat_state_notifications', 'all') elif active == 1: # only composing - gajim.config.set('outgoing_chat_state_notifications', 'composing_only') + app.config.set('outgoing_chat_state_notifications', 'composing_only') else: # disabled - gajim.config.set('outgoing_chat_state_notifications', 'disabled') - new_value = gajim.config.get('outgoing_chat_state_notifications') + app.config.set('outgoing_chat_state_notifications', 'disabled') + new_value = app.config.get('outgoing_chat_state_notifications') if 'disabled' in (old_value, new_value): # we changed from disabled to sth else or vice versa helpers.update_optional_features() @@ -798,12 +798,12 @@ class PreferencesWindow: def on_displayed_chat_states_combobox_changed(self, widget): active = widget.get_active() if active == 0: # all - gajim.config.set('displayed_chat_state_notifications', 'all') + app.config.set('displayed_chat_state_notifications', 'all') elif active == 1: # only composing - gajim.config.set('displayed_chat_state_notifications', + app.config.set('displayed_chat_state_notifications', 'composing_only') else: # disabled - gajim.config.set('displayed_chat_state_notifications', 'disabled') + app.config.set('displayed_chat_state_notifications', 'disabled') def on_ignore_events_from_unknown_contacts_checkbutton_toggled(self, widget): widget.set_inconsistent(False) @@ -812,14 +812,14 @@ class PreferencesWindow: def on_on_event_combobox_changed(self, widget): active = widget.get_active() if active == 0: - gajim.config.set('autopopup', True) - gajim.config.set('notify_on_new_message', False) + app.config.set('autopopup', True) + app.config.set('notify_on_new_message', False) elif active == 1: - gajim.config.set('autopopup', False) - gajim.config.set('notify_on_new_message', True) + app.config.set('autopopup', False) + app.config.set('notify_on_new_message', True) else: - gajim.config.set('autopopup', False) - gajim.config.set('notify_on_new_message', False) + app.config.set('autopopup', False) + app.config.set('notify_on_new_message', False) def on_notify_on_signin_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'notify_on_signin') @@ -839,17 +839,17 @@ class PreferencesWindow: def on_systray_combobox_changed(self, widget): active = widget.get_active() if active == 0: - gajim.config.set('trayicon', 'never') - gajim.interface.systray_enabled = False - gajim.interface.systray.hide_icon() + app.config.set('trayicon', 'never') + app.interface.systray_enabled = False + app.interface.systray.hide_icon() elif active == 1: - gajim.config.set('trayicon', 'on_event') - gajim.interface.systray_enabled = True - gajim.interface.systray.show_icon() + app.config.set('trayicon', 'on_event') + app.interface.systray_enabled = True + app.interface.systray.show_icon() else: - gajim.config.set('trayicon', 'always') - gajim.interface.systray_enabled = True - gajim.interface.systray.show_icon() + app.config.set('trayicon', 'always') + app.interface.systray_enabled = True + app.interface.systray.show_icon() def on_play_sounds_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'sounds_on', @@ -871,7 +871,7 @@ class PreferencesWindow: def on_preference_widget_color_set(self, widget, text): color = widget.get_color() color_string = gtkgui_helpers.make_color_string(color) - gajim.config.set(text, color_string) + app.config.set(text, color_string) self.update_text_tags() def on_preference_widget_font_set(self, widget, text): @@ -879,7 +879,7 @@ class PreferencesWindow: font = widget.get_font_name() else: font = '' - gajim.config.set(text, font) + app.config.set(text, font) gtkgui_helpers.load_css() def on_incoming_nick_colorbutton_color_set(self, widget): @@ -926,7 +926,7 @@ class PreferencesWindow: 'urlmsgcolor': 'url_msg_colorbutton', 'markedmsgcolor': 'muc_highlight_colorbutton'} for c in col_to_widget: - col = gajim.config.get(c) + col = app.config.get(c) if col: if isinstance(col_to_widget[c], list): rgba = Gdk.RGBA() @@ -957,7 +957,7 @@ class PreferencesWindow: 'urlmsgcolor': 'url_msg_colorbutton', 'markedmsgcolor': 'muc_highlight_colorbutton'} for c in col_to_widget: - gajim.config.set(c, gajim.interface.default_colors[c]) + app.config.set(c, app.interface.default_colors[c]) self.draw_color_widgets() self.update_text_tags() @@ -971,7 +971,7 @@ class PreferencesWindow: color_string = gtkgui_helpers.make_color_string(color) else: color_string = '' - gajim.config.set(option, color_string) + app.config.set(option, color_string) def on_incoming_msg_checkbutton_toggled(self, widget): state = widget.get_active() @@ -989,13 +989,13 @@ class PreferencesWindow: def on_auto_away_time_spinbutton_value_changed(self, widget): aat = widget.get_value_as_int() - gajim.config.set('autoawaytime', aat) - gajim.interface.sleeper = sleepy.Sleepy( - gajim.config.get('autoawaytime') * 60, - gajim.config.get('autoxatime') * 60) + app.config.set('autoawaytime', aat) + app.interface.sleeper = sleepy.Sleepy( + app.config.get('autoawaytime') * 60, + app.config.get('autoxatime') * 60) def on_auto_away_message_entry_changed(self, widget): - gajim.config.set('autoaway_message', widget.get_text()) + app.config.set('autoaway_message', widget.get_text()) def on_auto_xa_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'autoxa', @@ -1003,13 +1003,13 @@ class PreferencesWindow: def on_auto_xa_time_spinbutton_value_changed(self, widget): axt = widget.get_value_as_int() - gajim.config.set('autoxatime', axt) - gajim.interface.sleeper = sleepy.Sleepy( - gajim.config.get('autoawaytime') * 60, - gajim.config.get('autoxatime') * 60) + app.config.set('autoxatime', axt) + app.interface.sleeper = sleepy.Sleepy( + app.config.get('autoawaytime') * 60, + app.config.get('autoxatime') * 60) def on_auto_xa_message_entry_changed(self, widget): - gajim.config.set('autoxa_message', widget.get_text()) + app.config.set('autoxa_message', widget.get_text()) def on_prompt_online_status_message_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'ask_online_status') @@ -1021,13 +1021,13 @@ class PreferencesWindow: model = self.default_msg_tree.get_model() model.clear() status = [] - for status_ in gajim.config.get_per('defaultstatusmsg'): + for status_ in app.config.get_per('defaultstatusmsg'): status.append(status_) status.sort() for status_ in status: - msg = gajim.config.get_per('defaultstatusmsg', status_, 'message') + msg = app.config.get_per('defaultstatusmsg', status_, 'message') msg = helpers.from_one_line(msg) - enabled = gajim.config.get_per('defaultstatusmsg', status_, 'enabled') + enabled = app.config.get_per('defaultstatusmsg', status_, 'enabled') iter_ = model.append() uf_show = helpers.get_uf_show(status_) model.set(iter_, 0, status_, 1, uf_show, 2, msg, 3, enabled) @@ -1045,9 +1045,9 @@ class PreferencesWindow: status = model[iter_][0] message = model[iter_][2] message = helpers.to_one_line(message) - gajim.config.set_per('defaultstatusmsg', status, 'enabled', + app.config.set_per('defaultstatusmsg', status, 'enabled', model[iter_][3]) - gajim.config.set_per('defaultstatusmsg', status, 'message', message) + app.config.set_per('defaultstatusmsg', status, 'message', message) def on_default_status_expander_activate(self, expander): eventbox = self.xml.get_object('default_status_eventbox') @@ -1056,17 +1056,17 @@ class PreferencesWindow: Gtk.PACK_START) def save_status_messages(self, model): - for msg in gajim.config.get_per('statusmsg'): - gajim.config.del_per('statusmsg', msg) + for msg in app.config.get_per('statusmsg'): + app.config.del_per('statusmsg', msg) iter_ = model.get_iter_first() while iter_: val = model[iter_][0] if model[iter_][1]: # we have a preset message if not val: # no title, use message text for title val = model[iter_][1] - gajim.config.add_per('statusmsg', val) + app.config.add_per('statusmsg', val) msg = helpers.to_one_line(model[iter_][1]) - gajim.config.set_per('statusmsg', val, 'message', msg) + app.config.set_per('statusmsg', val, 'message', msg) i = 2 # store mood / activity for subname in ('activity', 'subactivity', 'activity_text', @@ -1074,7 +1074,7 @@ class PreferencesWindow: val2 = model[iter_][i] if not val2: val2 = '' - gajim.config.set_per('statusmsg', val, subname, val2) + app.config.set_per('statusmsg', val, subname, val2) i += 1 iter_ = model.iter_next(iter_) @@ -1088,7 +1088,7 @@ class PreferencesWindow: model = combobox.get_model() active = combobox.get_active() device = model[active][1] - gajim.config.set(config_name, device) + app.config.set(config_name, device) def on_audio_input_combobox_changed(self, widget): self.on_av_combobox_changed(widget, 'audio_input_device') @@ -1116,24 +1116,24 @@ class PreferencesWindow: [self.xml.get_object('stun_server_entry')]) def stun_server_entry_changed(self, widget): - gajim.config.set('stun_server', widget.get_text()) + app.config.set('stun_server', widget.get_text()) def on_applications_combobox_changed(self, widget): if widget.get_active() == 0: - gajim.config.set('autodetect_browser_mailer', True) + app.config.set('autodetect_browser_mailer', True) self.xml.get_object('custom_apps_frame').hide() elif widget.get_active() == 1: - gajim.config.set('autodetect_browser_mailer', False) + app.config.set('autodetect_browser_mailer', False) self.xml.get_object('custom_apps_frame').show() def on_custom_browser_entry_changed(self, widget): - gajim.config.set('custombrowser', widget.get_text()) + app.config.set('custombrowser', widget.get_text()) def on_custom_mail_client_entry_changed(self, widget): - gajim.config.set('custommailapp', widget.get_text()) + app.config.set('custommailapp', widget.get_text()) def on_custom_file_manager_entry_changed(self, widget): - gajim.config.set('custom_file_manager', widget.get_text()) + app.config.set('custom_file_manager', widget.get_text()) def on_log_show_changes_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'log_contact_status_changes') @@ -1165,21 +1165,21 @@ class PreferencesWindow: model = self.msg_tree.get_model() model.clear() preset_status = [] - for msg_name in gajim.config.get_per('statusmsg'): + for msg_name in app.config.get_per('statusmsg'): if msg_name.startswith('_last_'): continue preset_status.append(msg_name) preset_status.sort() for msg_name in preset_status: - msg_text = gajim.config.get_per('statusmsg', msg_name, 'message') + msg_text = app.config.get_per('statusmsg', msg_name, 'message') msg_text = helpers.from_one_line(msg_text) - activity = gajim.config.get_per('statusmsg', msg_name, 'activity') - subactivity = gajim.config.get_per('statusmsg', msg_name, + activity = app.config.get_per('statusmsg', msg_name, 'activity') + subactivity = app.config.get_per('statusmsg', msg_name, 'subactivity') - activity_text = gajim.config.get_per('statusmsg', msg_name, + activity_text = app.config.get_per('statusmsg', msg_name, 'activity_text') - mood = gajim.config.get_per('statusmsg', msg_name, 'mood') - mood_text = gajim.config.get_per('statusmsg', msg_name, 'mood_text') + mood = app.config.get_per('statusmsg', msg_name, 'mood') + mood_text = app.config.get_per('statusmsg', msg_name, 'mood_text') iter_ = model.append() model.set(iter_, 0, msg_name, 1, msg_text, 2, activity, 3, subactivity, 4, activity_text, 5, mood, 6, mood_text) @@ -1241,23 +1241,23 @@ class PreferencesWindow: if proxy == _('None'): proxy = '' - gajim.config.set('global_proxy', proxy) + app.config.set('global_proxy', proxy) def on_manage_proxies_button_clicked(self, widget): - if 'manage_proxies' in gajim.interface.instances: - gajim.interface.instances['manage_proxies'].window.present() + if 'manage_proxies' in app.interface.instances: + app.interface.instances['manage_proxies'].window.present() else: - gajim.interface.instances['manage_proxies'] = ManageProxiesWindow( + app.interface.instances['manage_proxies'] = ManageProxiesWindow( self.window) def update_proxy_list(self): - our_proxy = gajim.config.get('global_proxy') + our_proxy = app.config.get('global_proxy') if not our_proxy: our_proxy = _('None') proxy_combobox = self.xml.get_object('proxies_combobox') model = proxy_combobox.get_model() model.clear() - l = gajim.config.get_per('proxies') + l = app.config.get_per('proxies') l.insert(0, _('None')) for i in range(len(l)): model.append([l[i]]) @@ -1265,10 +1265,10 @@ class PreferencesWindow: proxy_combobox.set_active(i) def on_open_advanced_editor_button_clicked(self, widget, data = None): - if 'advanced_config' in gajim.interface.instances: - gajim.interface.instances['advanced_config'].window.present() + if 'advanced_config' in app.interface.instances: + app.interface.instances['advanced_config'].window.present() else: - gajim.interface.instances['advanced_config'] = \ + app.interface.instances['advanced_config'] = \ dialogs.AdvancedConfigurationWindow() #---------- ManageProxiesWindow class -------------# @@ -1307,7 +1307,7 @@ class ManageProxiesWindow: model.clear() iter_ = model.append() model.set(iter_, 0, _('None')) - for p in gajim.config.get_per('proxies'): + for p in app.config.get_per('proxies'): iter_ = model.append() model.set(iter_, 0, p) @@ -1326,20 +1326,20 @@ class ManageProxiesWindow: self.xml.get_object('proxytype_combobox').set_active(0) def on_manage_proxies_window_destroy(self, widget): - if 'accounts' in gajim.interface.instances: - gajim.interface.instances['accounts'].\ + if 'accounts' in app.interface.instances: + app.interface.instances['accounts'].\ update_proxy_list() - del gajim.interface.instances['manage_proxies'] + del app.interface.instances['manage_proxies'] def on_add_proxy_button_clicked(self, widget): model = self.proxies_treeview.get_model() - proxies = gajim.config.get_per('proxies') + proxies = app.config.get_per('proxies') i = 1 while ('proxy' + str(i)) in proxies: i += 1 iter_ = model.append() model.set(iter_, 0, 'proxy' + str(i)) - gajim.config.add_per('proxies', 'proxy' + str(i)) + app.config.add_per('proxies', 'proxy' + str(i)) self.proxies_treeview.set_cursor(model.get_path(iter_)) def on_remove_proxy_button_clicked(self, widget): @@ -1351,7 +1351,7 @@ class ManageProxiesWindow: return proxy = model[iter_][0] model.remove(iter_) - gajim.config.del_per('proxies', proxy) + app.config.del_per('proxies', proxy) self.xml.get_object('remove_proxy_button').set_sensitive(False) self.block_signal = True self.on_proxies_treeview_cursor_changed(self.proxies_treeview) @@ -1365,7 +1365,7 @@ class ManageProxiesWindow: return act = widget.get_active() proxy = self.proxyname_entry.get_text() - gajim.config.set_per('proxies', proxy, 'useauth', act) + app.config.set_per('proxies', proxy, 'useauth', act) self.xml.get_object('proxyuser_entry').set_sensitive(act) self.xml.get_object('proxypass_entry').set_sensitive(act) @@ -1374,7 +1374,7 @@ class ManageProxiesWindow: return act = widget.get_active() proxy = self.proxyname_entry.get_text() - gajim.config.set_per('proxies', proxy, 'bosh_useproxy', act) + app.config.set_per('proxies', proxy, 'bosh_useproxy', act) self.xml.get_object('proxyhost_entry').set_sensitive(act) self.xml.get_object('proxyport_entry').set_sensitive(act) @@ -1423,7 +1423,7 @@ class ManageProxiesWindow: self.xml.get_object('proxytype_combobox').set_sensitive(False) self.xml.get_object('proxy_table').set_sensitive(False) else: - proxytype = gajim.config.get_per('proxies', proxy, 'type') + proxytype = app.config.get_per('proxies', proxy, 'type') self.show_bosh_fields(proxytype=='bosh') @@ -1431,22 +1431,22 @@ class ManageProxiesWindow: self.xml.get_object('remove_proxy_button').set_sensitive(True) self.xml.get_object('proxytype_combobox').set_sensitive(True) self.xml.get_object('proxy_table').set_sensitive(True) - proxyhost_entry.set_text(gajim.config.get_per('proxies', proxy, + proxyhost_entry.set_text(app.config.get_per('proxies', proxy, 'host')) - proxyport_entry.set_text(str(gajim.config.get_per('proxies', + proxyport_entry.set_text(str(app.config.get_per('proxies', proxy, 'port'))) - proxyuser_entry.set_text(gajim.config.get_per('proxies', proxy, + proxyuser_entry.set_text(app.config.get_per('proxies', proxy, 'user')) - proxypass_entry.set_text(gajim.config.get_per('proxies', proxy, + proxypass_entry.set_text(app.config.get_per('proxies', proxy, 'pass')) - boshuri_entry.set_text(gajim.config.get_per('proxies', proxy, + boshuri_entry.set_text(app.config.get_per('proxies', proxy, 'bosh_uri')) types = ['http', 'socks5', 'bosh'] self.proxytype_combobox.set_active(types.index(proxytype)) boshuseproxy_checkbutton.set_active( - gajim.config.get_per('proxies', proxy, 'bosh_useproxy')) + app.config.get_per('proxies', proxy, 'bosh_useproxy')) useauth_checkbutton.set_active( - gajim.config.get_per('proxies', proxy, 'useauth')) + app.config.get_per('proxies', proxy, 'useauth')) self.block_signal = False def on_proxies_treeview_key_press_event(self, widget, event): @@ -1468,11 +1468,11 @@ class ManageProxiesWindow: return if new_name == old_name: return - config = gajim.config.get_per('proxies', old_name) - gajim.config.del_per('proxies', old_name) - gajim.config.add_per('proxies', new_name) + config = app.config.get_per('proxies', old_name) + app.config.del_per('proxies', old_name) + app.config.add_per('proxies', new_name) for option in config: - gajim.config.set_per('proxies', new_name, option, config[option]) + app.config.set_per('proxies', new_name, option, config[option]) model.set_value(iter_, 0, new_name) def on_proxytype_combobox_changed(self, widget): @@ -1482,42 +1482,42 @@ class ManageProxiesWindow: type_ = self.proxytype_combobox.get_active() self.show_bosh_fields(types[type_]=='bosh') proxy = self.proxyname_entry.get_text() - gajim.config.set_per('proxies', proxy, 'type', types[type_]) + app.config.set_per('proxies', proxy, 'type', types[type_]) def on_proxyhost_entry_changed(self, widget): if self.block_signal: return value = widget.get_text() proxy = self.proxyname_entry.get_text() - gajim.config.set_per('proxies', proxy, 'host', value) + app.config.set_per('proxies', proxy, 'host', value) def on_proxyport_entry_changed(self, widget): if self.block_signal: return value = widget.get_text() proxy = self.proxyname_entry.get_text() - gajim.config.set_per('proxies', proxy, 'port', value) + app.config.set_per('proxies', proxy, 'port', value) def on_proxyuser_entry_changed(self, widget): if self.block_signal: return value = widget.get_text() proxy = self.proxyname_entry.get_text() - gajim.config.set_per('proxies', proxy, 'user', value) + app.config.set_per('proxies', proxy, 'user', value) def on_boshuri_entry_changed(self, widget): if self.block_signal: return value = widget.get_text() proxy = self.proxyname_entry.get_text() - gajim.config.set_per('proxies', proxy, 'bosh_uri', value) + app.config.set_per('proxies', proxy, 'bosh_uri', value) def on_proxypass_entry_changed(self, widget): if self.block_signal: return value = widget.get_text() proxy = self.proxyname_entry.get_text() - gajim.config.set_per('proxies', proxy, 'pass', value) + app.config.set_per('proxies', proxy, 'pass', value) #---------- AccountsWindow class -------------# @@ -1527,7 +1527,7 @@ class AccountsWindow: """ def on_accounts_window_destroy(self, widget): - del gajim.interface.instances['accounts'] + del app.interface.instances['accounts'] def on_close_button_clicked(self, widget): self.check_resend_relog() @@ -1536,7 +1536,7 @@ class AccountsWindow: 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(gajim.interface.roster.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') @@ -1568,7 +1568,7 @@ class AccountsWindow: self.window.show_all() # Merge accounts - st = gajim.config.get('mergeaccounts') + 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 @@ -1608,7 +1608,7 @@ class AccountsWindow: self.current_account = None model = self.accounts_treeview.get_model() model.clear() - list_ = gajim.config.get_per('accounts') + list_ = app.config.get_per('accounts') list_.sort() for account in list_: iter_ = model.append() @@ -1618,37 +1618,37 @@ class AccountsWindow: self.selection.select_iter(model.get_iter_first()) def resend(self, account): - if not account in gajim.connections: + if not account in app.connections: return - show = gajim.SHOW_LIST[gajim.connections[account].connected] - status = gajim.connections[account].status - gajim.connections[account].change_status(show, status) + 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 == \ - gajim.ZEROCONF_ACC_NAME: - if gajim.ZEROCONF_ACC_NAME in gajim.connections: - gajim.connections[gajim.ZEROCONF_ACC_NAME].update_details() + 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 \ - gajim.connections[self.current_account].connected > 0: + 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 - gajim.connections[account].disconnect(True) - gajim.interface.roster.send_status(account, show_before, + app.connections[account].disconnect(True) + app.interface.roster.send_status(account, show_before, status_before) def relog(account): self.dialog.destroy() - show_before = gajim.SHOW_LIST[gajim.connections[account].\ + show_before = app.SHOW_LIST[app.connections[account].\ connected] - status_before = gajim.connections[account].status - gajim.interface.roster.send_status(account, 'offline', + 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) @@ -1658,7 +1658,7 @@ class AccountsWindow: def on_no(account): if self.resend_presence: self.resend(account) - if self.current_account in gajim.connections: + 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, @@ -1715,10 +1715,10 @@ class AccountsWindow: self.remove_button.set_sensitive(True) self.rename_button.set_sensitive(True) - if (account != gajim.ZEROCONF_ACC_NAME and - account in gajim.connections): + if (account != app.ZEROCONF_ACC_NAME and + account in app.connections): self.change_password_button.set_sensitive( - gajim.connections[account].register_supported) + app.connections[account].register_supported) else: self.remove_button.set_sensitive(False) @@ -1726,7 +1726,7 @@ class AccountsWindow: self.change_password_button.set_sensitive(False) if iter_: self.current_account = account - if account == gajim.ZEROCONF_ACC_NAME: + if account == app.ZEROCONF_ACC_NAME: self.remove_button.set_sensitive(False) self.init_account() self.update_proxy_list() @@ -1737,7 +1737,7 @@ class AccountsWindow: if not path_to_clientcert_file: return self.xml.get_object('cert_entry1').set_text(path_to_clientcert_file) - gajim.config.set_per('accounts', self.current_account, + app.config.set_per('accounts', self.current_account, 'client_cert', path_to_clientcert_file) def on_cancel(widget): @@ -1749,7 +1749,7 @@ class AccountsWindow: def update_proxy_list(self): if self.current_account: - our_proxy = gajim.config.get_per('accounts', self.current_account, + our_proxy = app.config.get_per('accounts', self.current_account, 'proxy') else: our_proxy = '' @@ -1759,7 +1759,7 @@ class AccountsWindow: proxy_combobox = self.xml.get_object('proxies_combobox1') model = Gtk.ListStore(str) proxy_combobox.set_model(model) - l = gajim.config.get_per('proxies') + l = app.config.get_per('proxies') l.insert(0, _('None')) for i in range(len(l)): model.append([l[i]]) @@ -1770,7 +1770,7 @@ class AccountsWindow: if not self.current_account: self.notebook.set_current_page(0) return - if gajim.config.get_per('accounts', self.current_account, + if app.config.get_per('accounts', self.current_account, 'is_zeroconf'): self.ignore_events = True self.init_zeroconf_account() @@ -1783,47 +1783,47 @@ class AccountsWindow: self.notebook.set_current_page(1) def init_zeroconf_account(self): - active = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, + active = app.config.get_per('accounts', app.ZEROCONF_ACC_NAME, 'active') self.xml.get_object('enable_zeroconf_checkbutton2').set_active(active) - if not gajim.HAVE_ZEROCONF: + 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 = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, + st = app.config.get_per('accounts', app.ZEROCONF_ACC_NAME, 'autoconnect') self.xml.get_object('autoconnect_checkbutton2').set_active(st) - list_no_log_for = gajim.config.get_per('accounts', - gajim.ZEROCONF_ACC_NAME, 'no_log_for').split() - if gajim.ZEROCONF_ACC_NAME in list_no_log_for: + 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 = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, + 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 = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, + 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 = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, + st = app.config.get_per('accounts', app.ZEROCONF_ACC_NAME, 'custom_port') if not st: - gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, + 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 gajim.ZEROCONF_ACC_NAME in gajim.connections and \ - gajim.connections[gajim.ZEROCONF_ACC_NAME].gpg: + 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: @@ -1831,17 +1831,17 @@ class AccountsWindow: self.xml.get_object('gpg_choose_button2').set_sensitive(False) for opt in ('first_name', 'last_name', 'jabber_id', 'email'): - st = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, + 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 = gajim.config.get_per('accounts', account, 'keyid') - keyname = gajim.config.get_per('accounts', account, 'keyname') - use_gpg_agent = gajim.config.get('use_gpg_agent') + 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 == gajim.ZEROCONF_ACC_NAME: + if account == app.ZEROCONF_ACC_NAME: widget_name_add = '2' else: widget_name_add = '1' @@ -1865,10 +1865,10 @@ class AccountsWindow: def draw_normal_jid(self): account = self.current_account self.ignore_events = True - active = gajim.config.get_per('accounts', account, 'active') + 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 gajim.config.get_per('accounts', account, 'anonymous_auth'): + 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') @@ -1877,11 +1877,11 @@ class AccountsWindow: password_entry = self.xml.get_object('password_entry1') password_entry.set_text('') password_entry.set_sensitive(False) - jid = gajim.config.get_per('accounts', account, 'hostname') + 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 = gajim.config.get_per('accounts', account, 'savepass') + 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) @@ -1894,8 +1894,8 @@ class AccountsWindow: password_entry.set_sensitive(False) password_entry.set_text(passstr) - jid = gajim.config.get_per('accounts', account, 'name') \ - + '@' + gajim.config.get_per('accounts', account, 'hostname') + 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 @@ -1903,62 +1903,62 @@ class AccountsWindow: account = self.current_account # Account tab self.draw_normal_jid() - self.xml.get_object('resource_entry1').set_text(gajim.config.get_per( + self.xml.get_object('resource_entry1').set_text(app.config.get_per( 'accounts', account, 'resource')) - client_cert = gajim.config.get_per('accounts', account, 'client_cert') + client_cert = app.config.get_per('accounts', account, 'client_cert') self.xml.get_object('cert_entry1').set_text(client_cert) - client_cert_encrypted = gajim.config.get_per('accounts', account, + 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(gajim.config.get_per('accounts', account, + set_active(app.config.get_per('accounts', account, 'adjust_priority_with_status')) spinbutton = self.xml.get_object('priority_spinbutton1') - if gajim.config.get('enable_negative_priority'): + if app.config.get('enable_negative_priority'): spinbutton.set_range(-128, 127) else: spinbutton.set_range(0, 127) - spinbutton.set_value(gajim.config.get_per('accounts', account, + spinbutton.set_value(app.config.get_per('accounts', account, 'priority')) # Connection tab - use_env_http_proxy = gajim.config.get_per('accounts', account, + 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 = gajim.config.get_per('accounts', account, + 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( - gajim.config.get_per('accounts', account, 'keep_alives_enabled')) + app.config.get_per('accounts', account, 'keep_alives_enabled')) - use_custom_host = gajim.config.get_per('accounts', account, + 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 = gajim.config.get_per('accounts', account, 'custom_host') + custom_host = app.config.get_per('accounts', account, 'custom_host') if not custom_host: - custom_host = gajim.config.get_per('accounts', account, 'hostname') - gajim.config.set_per('accounts', account, '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 = gajim.config.get_per('accounts', account, 'custom_port') + custom_port = app.config.get_per('accounts', account, 'custom_port') if not custom_port: custom_port = 5222 - gajim.config.set_per('accounts', account, 'custom_port', + 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 gajim.HAVE_GPG: + if app.HAVE_GPG: self.xml.get_object('gpg_choose_button1').set_sensitive(True) self.init_account_gpg() else: @@ -1967,11 +1967,11 @@ class AccountsWindow: # General tab self.xml.get_object('autoconnect_checkbutton1').set_active( - gajim.config.get_per('accounts', account, 'autoconnect')) - self.xml.get_object('autoreconnect_checkbutton1').set_active(gajim. + 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 = gajim.config.get_per('accounts', account, + 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) @@ -1979,23 +1979,23 @@ class AccountsWindow: self.xml.get_object('log_history_checkbutton1').set_active(True) self.xml.get_object('sync_logs_with_server_checkbutton1').set_active( - gajim.config.get_per('accounts', account, 'sync_logs_with_server')) + app.config.get_per('accounts', account, 'sync_logs_with_server')) self.xml.get_object('sync_with_global_status_checkbutton1').set_active( - gajim.config.get_per('accounts', account, + app.config.get_per('accounts', account, 'sync_with_global_status')) self.xml.get_object('carbons_checkbutton1').set_active( - gajim.config.get_per('accounts', account, 'enable_message_carbons')) + app.config.get_per('accounts', account, 'enable_message_carbons')) self.xml.get_object('use_ft_proxies_checkbutton1').set_active( - gajim.config.get_per('accounts', account, 'use_ft_proxies')) + 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 gajim.interface.instances: - gajim.interface.instances['account_creation_wizard'].window.present() + if 'account_creation_wizard' in app.interface.instances: + app.interface.instances['account_creation_wizard'].window.present() else: - gajim.interface.instances['account_creation_wizard'] = \ + app.interface.instances['account_creation_wizard'] = \ AccountCreationWizardWindow() def on_remove_button_clicked(self, widget): @@ -2006,35 +2006,35 @@ class AccountsWindow: if not self.current_account: return account = self.current_account - if len(gajim.events.get_events(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 gajim.config.get_per('accounts', account, 'is_zeroconf'): + if app.config.get_per('accounts', account, 'is_zeroconf'): # Should never happen as button is insensitive return win_opened = False - if gajim.interface.msg_win_mgr.get_controls(acct=account): + if app.interface.msg_win_mgr.get_controls(acct=account): win_opened = True - elif account in gajim.interface.instances: - for key in gajim.interface.instances[account]: - if gajim.interface.instances[account][key] and key != \ + 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 gajim.interface.instances and \ - 'remove_account' in gajim.interface.instances[account]: - gajim.interface.instances[account]['remove_account'].window.\ + 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 gajim.interface.instances: - gajim.interface.instances[account] = {} - gajim.interface.instances[account]['remove_account'] = \ + if not account in app.interface.instances: + app.interface.instances[account] = {} + app.interface.instances[account]['remove_account'] = \ RemoveAccountWindow(account) if win_opened: dialogs.ConfirmationDialog( @@ -2048,22 +2048,22 @@ class AccountsWindow: def on_rename_button_clicked(self, widget): if not self.current_account: return - active = gajim.config.get_per('accounts', self.current_account, - 'active') and self.current_account in gajim.connections - if active and gajim.connections[self.current_account].connected != 0: + 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(gajim.events.get_events(self.current_account)): + 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 gajim.connections: + 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) @@ -2080,79 +2080,79 @@ class AccountsWindow: return if active: # update variables - gajim.interface.instances[new_name] = gajim.interface.instances[ + app.interface.instances[new_name] = app.interface.instances[ old_name] - gajim.interface.minimized_controls[new_name] = \ - gajim.interface.minimized_controls[old_name] - gajim.nicks[new_name] = gajim.nicks[old_name] - gajim.block_signed_in_notifications[new_name] = \ - gajim.block_signed_in_notifications[old_name] - gajim.groups[new_name] = gajim.groups[old_name] - gajim.gc_connected[new_name] = gajim.gc_connected[old_name] - gajim.automatic_rooms[new_name] = gajim.automatic_rooms[ + 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] - gajim.newly_added[new_name] = gajim.newly_added[old_name] - 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[ + 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] - 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] - gajim.gajim_optional_features[new_name] = \ - gajim.gajim_optional_features[old_name] - gajim.caps_hash[new_name] = gajim.caps_hash[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] - gajim.contacts.change_account_name(old_name, new_name) - gajim.events.change_account_name(old_name, new_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 - gajim.interface.msg_win_mgr.change_account_name(old_name, new_name) + 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 gajim.interface.instances[new_name][kind]: - gajim.interface.instances[new_name][kind][j].account = \ + 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(gajim.connections[old_name], 'services_cache'): - gajim.connections[old_name].services_cache.account = \ + if hasattr(app.connections[old_name], 'services_cache'): + app.connections[old_name].services_cache.account = \ new_name - del gajim.interface.instances[old_name] - del gajim.interface.minimized_controls[old_name] - del gajim.nicks[old_name] - del gajim.block_signed_in_notifications[old_name] - del gajim.groups[old_name] - del gajim.gc_connected[old_name] - del gajim.automatic_rooms[old_name] - del gajim.newly_added[old_name] - del gajim.to_be_removed[old_name] - del gajim.sleeper_state[old_name] - del gajim.encrypted_chats[old_name] - del gajim.last_message_time[old_name] - del gajim.status_before_autoaway[old_name] - del gajim.transport_avatar[old_name] - del gajim.gajim_optional_features[old_name] - del gajim.caps_hash[old_name] - gajim.connections[old_name].name = new_name - gajim.connections[old_name].pep_change_account_name(new_name) - gajim.connections[old_name].caps_change_account_name(new_name) - gajim.connections[new_name] = gajim.connections[old_name] - del gajim.connections[old_name] - gajim.config.add_per('accounts', new_name) - old_config = gajim.config.get_per('accounts', old_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: - gajim.config.set_per('accounts', new_name, opt, old_config[opt]) - gajim.config.del_per('accounts', old_name) + 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 == gajim.ZEROCONF_ACC_NAME: - gajim.ZEROCONF_ACC_NAME = new_name + if old_name == app.ZEROCONF_ACC_NAME: + app.ZEROCONF_ACC_NAME = new_name # refresh roster - gajim.interface.roster.setup_and_draw_roster() + app.interface.roster.setup_and_draw_roster() self.init_accounts() self.select_account(new_name) gajim.app.remove_account_actions(old_name) @@ -2167,7 +2167,7 @@ class AccountsWindow: transient_for=self.window) def option_changed(self, option, value): - return gajim.config.get_per('accounts', self.current_account, option) \ + return app.config.get_per('accounts', self.current_account, option) \ != value def on_jid_entry1_focus_out_event(self, widget, event): @@ -2185,7 +2185,7 @@ class AccountsWindow: return True jid_splited = jid.split('@', 1) - if len(jid_splited) != 2 and not gajim.config.get_per('accounts', + 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') @@ -2196,9 +2196,9 @@ class AccountsWindow: return True - if gajim.config.get_per('accounts', self.current_account, + if app.config.get_per('accounts', self.current_account, 'anonymous_auth'): - gajim.config.set_per('accounts', self.current_account, 'hostname', + app.config.set_per('accounts', self.current_account, 'hostname', jid_splited[0]) if self.option_changed('hostname', jid_splited[0]): self.need_relogin = True @@ -2207,9 +2207,9 @@ class AccountsWindow: self.option_changed('hostname', jid_splited[1]): self.need_relogin = True - gajim.config.set_per('accounts', self.current_account, 'name', + app.config.set_per('accounts', self.current_account, 'name', jid_splited[0]) - gajim.config.set_per('accounts', self.current_account, 'hostname', + app.config.set_per('accounts', self.current_account, 'hostname', jid_splited[1]) def on_cert_entry1_focus_out_event(self, widget, event): @@ -2218,14 +2218,14 @@ class AccountsWindow: client_cert = widget.get_text() if self.option_changed('client_cert', client_cert): self.need_relogin = True - gajim.config.set_per('accounts', self.current_account, 'client_cert', + 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() - gajim.config.set_per('accounts', self.current_account, 'anonymous_auth', + app.config.set_per('accounts', self.current_account, 'anonymous_auth', active) self.draw_normal_jid() @@ -2240,7 +2240,7 @@ class AccountsWindow: active = widget.get_active() password_entry = self.xml.get_object('password_entry1') password_entry.set_sensitive(active) - gajim.config.set_per('accounts', self.current_account, 'savepass', + app.config.set_per('accounts', self.current_account, 'savepass', active) if active: password = password_entry.get_text() @@ -2264,7 +2264,7 @@ class AccountsWindow: if self.option_changed('resource', resource): self.need_relogin = True - gajim.config.set_per('accounts', self.current_account, 'resource', + app.config.set_per('accounts', self.current_account, 'resource', resource) def on_adjust_priority_with_status_checkbutton1_toggled(self, widget): @@ -2279,7 +2279,7 @@ class AccountsWindow: if self.option_changed('priority', prio): self.resend_presence = True - gajim.config.set_per('accounts', self.current_account, 'priority', prio) + app.config.set_per('accounts', self.current_account, 'priority', prio) def on_synchronise_contacts_button1_clicked(self, widget): try: @@ -2291,7 +2291,7 @@ class AccountsWindow: def on_change_password_button1_clicked(self, widget): def on_changed(new_password): if new_password is not None: - gajim.connections[self.current_account].change_password( + app.connections[self.current_account].change_password( new_password) if self.xml.get_object('save_password_checkbutton1').\ get_active(): @@ -2326,14 +2326,14 @@ class AccountsWindow: def on_log_history_checkbutton_toggled(self, widget): if self.ignore_events: return - list_no_log_for = gajim.config.get_per('accounts', self.current_account, + 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) - gajim.config.set_per('accounts', self.current_account, 'no_log_for', + 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): @@ -2347,7 +2347,7 @@ class AccountsWindow: return self.on_checkbutton_toggled(widget, 'sync_with_global_status', account=self.current_account) - gajim.interface.roster.update_status_combobox() + app.interface.roster.update_status_combobox() def on_carbons_checkbutton_toggled(self, widget): if self.ignore_events: @@ -2378,13 +2378,13 @@ class AccountsWindow: if self.option_changed('proxy', proxy): self.need_relogin = True - gajim.config.set_per('accounts', self.current_account, 'proxy', proxy) + app.config.set_per('accounts', self.current_account, 'proxy', proxy) def on_manage_proxies_button1_clicked(self, widget): - if 'manage_proxies' in gajim.interface.instances: - gajim.interface.instances['manage_proxies'].window.present() + if 'manage_proxies' in app.interface.instances: + app.interface.instances['manage_proxies'].window.present() else: - gajim.interface.instances['manage_proxies'] = ManageProxiesWindow( + app.interface.instances['manage_proxies'] = ManageProxiesWindow( self.window) def on_warn_when_insecure_connection_checkbutton1_toggled(self, widget): @@ -2399,7 +2399,7 @@ class AccountsWindow: return self.on_checkbutton_toggled(widget, 'keep_alives_enabled', account=self.current_account) - gajim.config.set_per('accounts', 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): @@ -2417,7 +2417,7 @@ class AccountsWindow: host = widget.get_text() if self.option_changed('custom_host', host): self.need_relogin = True - gajim.config.set_per('accounts', self.current_account, 'custom_host', + app.config.set_per('accounts', self.current_account, 'custom_host', host) def on_custom_port_entry_focus_out_event(self, widget, event): @@ -2435,18 +2435,18 @@ class AccountsWindow: return True if self.option_changed('custom_port', custom_port): self.need_relogin = True - gajim.config.set_per('accounts', self.current_account, 'custom_port', + 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 gajim.connections and \ - gajim.connections[self.current_account].gpg: - secret_keys = gajim.connections[self.current_account].\ + 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 gajim.connections is {} + # self.current_account is None and/or app.connections is {} else: - if gajim.HAVE_GPG: + if app.HAVE_GPG: secret_keys = gpg.GnuPG().get_secret_keys() else: secret_keys = [] @@ -2459,7 +2459,7 @@ class AccountsWindow: def on_key_selected(keyID): if keyID is None: return - if self.current_account == gajim.ZEROCONF_ACC_NAME: + if self.current_account == app.ZEROCONF_ACC_NAME: wiget_name_ext = '2' else: wiget_name_ext = '1' @@ -2475,9 +2475,9 @@ class AccountsWindow: use_gpg_agent_checkbutton.set_sensitive(False) if self.option_changed('keyid', ''): self.need_relogin = True - gajim.config.set_per('accounts', self.current_account, + app.config.set_per('accounts', self.current_account, 'keyname', '') - gajim.config.set_per('accounts', self.current_account, 'keyid', + app.config.set_per('accounts', self.current_account, 'keyid', '') else: gpg_key_label.set_text(keyID[0]) @@ -2485,9 +2485,9 @@ class AccountsWindow: use_gpg_agent_checkbutton.set_sensitive(True) if self.option_changed('keyid', keyID[0]): self.need_relogin = True - gajim.config.set_per('accounts', self.current_account, + app.config.set_per('accounts', self.current_account, 'keyname', keyID[1]) - gajim.config.set_per('accounts', self.current_account, 'keyid', + app.config.set_per('accounts', self.current_account, 'keyid', keyID[0]) dialogs.ChooseGPGKeyDialog(_('OpenPGP Key Selection'), @@ -2498,128 +2498,128 @@ class AccountsWindow: self.on_checkbutton_toggled(widget, 'use_gpg_agent') def on_edit_details_button1_clicked(self, widget): - if self.current_account not in gajim.interface.instances: + 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 gajim.connections) - if self.current_account not in gajim.connections or \ - gajim.connections[self.current_account].connected < 2: + # 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 gajim.connections[self.current_account].vcard_supported: + 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 = gajim.get_jid_from_account(self.current_account) - if 'profile' not in gajim.interface.instances[self.current_account]: - gajim.interface.instances[self.current_account]['profile'] = \ + 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) - gajim.connections[self.current_account].request_vcard(jid) + app.connections[self.current_account].request_vcard(jid) def on_checkbutton_toggled(self, widget, config_name, change_sensitivity_widgets = None, account = None): if account: - gajim.config.set_per('accounts', account, config_name, + app.config.set_per('accounts', account, config_name, widget.get_active()) else: - gajim.config.set(config_name, widget.get_active()) + 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(gajim.connections) >= 2: # Do not merge accounts if only one active - gajim.interface.roster.regroup = gajim.config.get('mergeaccounts') + if len(app.connections) >= 2: # Do not merge accounts if only one active + app.interface.roster.regroup = app.config.get('mergeaccounts') else: - gajim.interface.roster.regroup = False - gajim.interface.roster.setup_and_draw_roster() + app.interface.roster.regroup = False + app.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() - gajim.connections[account].cleanup() - del gajim.connections[account] - 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: + 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 - gajim.interface.roster.regroup = gajim.config.get('mergeaccounts') + app.interface.roster.regroup = app.config.get('mergeaccounts') else: - gajim.interface.roster.regroup = False - gajim.interface.roster.setup_and_draw_roster() - gajim.app.remove_account_actions(account) + 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 == gajim.ZEROCONF_ACC_NAME: - gajim.connections[account] = connection_zeroconf.ConnectionZeroconf( + if account == app.ZEROCONF_ACC_NAME: + app.connections[account] = connection_zeroconf.ConnectionZeroconf( account) - if gajim.connections[account].gpg: + if app.connections[account].gpg: self.xml.get_object('gpg_choose_button2').set_sensitive(True) else: - gajim.connections[account] = common.connection.Connection(account) - if gajim.connections[account].gpg: + app.connections[account] = common.connection.Connection(account) + if app.connections[account].gpg: self.xml.get_object('gpg_choose_button1').set_sensitive(True) self.init_account_gpg() # update variables - gajim.interface.instances[account] = {'infos': {}, + app.interface.instances[account] = {'infos': {}, 'disco': {}, 'gc_config': {}, 'search': {}, 'online_dialog': {}, 'sub_request': {}} - 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 + 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: - gajim.nicks[account] = gajim.config.get_per('accounts', account, + app.nicks[account] = app.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] = '' + 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(gajim.connections) >= 2: + if len(app.connections) >= 2: # Do not merge accounts if only one exists - gajim.interface.roster.regroup = gajim.config.get('mergeaccounts') + app.interface.roster.regroup = app.config.get('mergeaccounts') else: - gajim.interface.roster.regroup = False - gajim.interface.roster.setup_and_draw_roster() - gajim.app.add_account_actions(account) + 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): @@ -2627,8 +2627,8 @@ class AccountsWindow: # normal account if self.ignore_events: return - if self.current_account in gajim.connections and \ - gajim.connections[self.current_account].connected > 0: + 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 @@ -2637,35 +2637,35 @@ class AccountsWindow: _('To disable the account, you must be disconnected.'), transient_for=self.window) return - if gajim.ZEROCONF_ACC_NAME in gajim.connections and not \ - gajim.connections[gajim.ZEROCONF_ACC_NAME].is_zeroconf: - gajim.nec.push_incoming_event(InformationEvent(None, - conn=gajim.connections[gajim.ZEROCONF_ACC_NAME], + 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 gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'active') \ + 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(gajim.ZEROCONF_ACC_NAME) + self._disable_account(app.ZEROCONF_ACC_NAME) - elif not gajim.config.get_per('accounts', gajim.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(gajim.ZEROCONF_ACC_NAME) + self._enable_account(app.ZEROCONF_ACC_NAME) self.on_checkbutton_toggled(widget, 'active', - account=gajim.ZEROCONF_ACC_NAME) + account=app.ZEROCONF_ACC_NAME) def on_enable_checkbutton1_toggled(self, widget): if self.ignore_events: return - if self.current_account in gajim.connections and \ - gajim.connections[self.current_account].connected > 0: + 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) @@ -2700,7 +2700,7 @@ class AccountsWindow: name = widget.get_text() if self.option_changed('zeroconf_first_name', name): self.need_relogin = True - gajim.config.set_per('accounts', self.current_account, + app.config.set_per('accounts', self.current_account, 'zeroconf_first_name', name) def on_last_name_entry2_changed(self, widget): @@ -2709,7 +2709,7 @@ class AccountsWindow: name = widget.get_text() if self.option_changed('zeroconf_last_name', name): self.need_relogin = True - gajim.config.set_per('accounts', self.current_account, + app.config.set_per('accounts', self.current_account, 'zeroconf_last_name', name) def on_jabber_id_entry2_changed(self, widget): @@ -2718,7 +2718,7 @@ class AccountsWindow: id_ = widget.get_text() if self.option_changed('zeroconf_jabber_id', id_): self.need_relogin = True - gajim.config.set_per('accounts', self.current_account, + app.config.set_per('accounts', self.current_account, 'zeroconf_jabber_id', id_) def on_email_entry2_changed(self, widget): @@ -2727,7 +2727,7 @@ class AccountsWindow: email = widget.get_text() if self.option_changed('zeroconf_email', email): self.need_relogin = True - gajim.config.set_per('accounts', self.current_account, + app.config.set_per('accounts', self.current_account, 'zeroconf_email', email) class FakeDataForm(Gtk.Table, object): @@ -2793,7 +2793,7 @@ class ServiceRegistrationWindow: self.is_form = is_form self.xml = gtkgui_helpers.get_gtk_builder('service_registration_window.ui') self.window = self.xml.get_object('service_registration_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.window.set_transient_for(app.interface.roster.window) if self.is_form: dataform = dataforms.ExtendForm(node = infos) self.data_form_widget = dataforms_widget.DataFormWidget(dataform) @@ -2820,7 +2820,7 @@ class ServiceRegistrationWindow: # send registration info to the core if self.is_form: form = self.data_form_widget.data_form - gajim.connections[self.account].register_agent(self.service, + app.connections[self.account].register_agent(self.service, form, True) # True is for is_form else: infos = self.data_form_widget.get_infos() @@ -2828,7 +2828,7 @@ class ServiceRegistrationWindow: del infos['instructions'] if 'registered' in infos: del infos['registered'] - gajim.connections[self.account].register_agent(self.service, infos) + app.connections[self.account].register_agent(self.service, infos) self.window.destroy() @@ -2848,7 +2848,7 @@ class GroupchatConfigWindow: self.xml = gtkgui_helpers.get_gtk_builder('data_form_window.ui', 'data_form_window') self.window = self.xml.get_object('data_form_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.window.set_transient_for(app.interface.roster.window) if self.form: config_vbox = self.xml.get_object('config_vbox') @@ -2939,7 +2939,7 @@ class GroupchatConfigWindow: sw = Gtk.ScrolledWindow() sw.add(self.affiliation_treeview[affiliation]) add_on_vbox.pack_start(sw, True, True, 0) - gajim.connections[self.account].get_affiliation_list(self.room_jid, + app.connections[self.account].get_affiliation_list(self.room_jid, affiliation) self.xml.connect_signals(self) @@ -3015,12 +3015,12 @@ class GroupchatConfigWindow: model.append((jid, reason, nick, role)) def on_data_form_window_destroy(self, widget): - del gajim.interface.instances[self.account]['gc_config'][self.room_jid] + del app.interface.instances[self.account]['gc_config'][self.room_jid] def on_ok_button_clicked(self, widget): if self.form: form = self.data_form_widget.data_form - gajim.connections[self.account].send_gc_config(self.room_jid, form) + app.connections[self.account].send_gc_config(self.room_jid, form) for affiliation in self.affiliation_labels.keys(): users_dict = {} actual_jid_list = [] @@ -3043,7 +3043,7 @@ class GroupchatConfigWindow: if jid not in actual_jid_list: users_dict[jid] = {'affiliation': 'none'} if users_dict: - gajim.connections[self.account].send_gc_affiliation_list( + app.connections[self.account].send_gc_affiliation_list( self.room_jid, users_dict) self.window.destroy() @@ -3055,8 +3055,8 @@ class RemoveAccountWindow: """ def on_remove_account_window_destroy(self, widget): - if self.account in gajim.interface.instances: - del gajim.interface.instances[self.account]['remove_account'] + if self.account in app.interface.instances: + del app.interface.instances[self.account]['remove_account'] def on_cancel_button_clicked(self, widget): self.window.destroy() @@ -3065,7 +3065,7 @@ class RemoveAccountWindow: self.account = account xml = gtkgui_helpers.get_gtk_builder('remove_account_window.ui') self.window = xml.get_object('remove_account_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.window.set_transient_for(app.interface.roster.window) self.remove_and_unregister_radiobutton = xml.get_object( 'remove_and_unregister_radiobutton') self.window.set_title(_('Removing %s account') % self.account) @@ -3074,26 +3074,26 @@ class RemoveAccountWindow: def on_remove_button_clicked(self, widget): def remove(): - if self.account in gajim.connections and \ - gajim.connections[self.account].connected and \ + if self.account in app.connections and \ + app.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') + app.connections[self.account].change_status('offline', 'offline') if self.remove_and_unregister_radiobutton.get_active(): - if not self.account in gajim.connections: + if not self.account in app.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 app.connections[self.account].password: def on_ok(passphrase, checked): if passphrase == -1: # We don't remove account cause we canceled pw window return - gajim.connections[self.account].password = passphrase - gajim.connections[self.account].unregister_account( + app.connections[self.account].password = passphrase + app.connections[self.account].unregister_account( self._on_remove_success) dialogs.PassphraseDialog( @@ -3101,13 +3101,13 @@ class RemoveAccountWindow: _('Enter your password for account %s') % self.account, _('Save password'), ok_handler=on_ok) return - gajim.connections[self.account].unregister_account( + app.connections[self.account].unregister_account( self._on_remove_success) else: self._on_remove_success(True) - if self.account in gajim.connections and \ - gajim.connections[self.account].connected: + if self.account in app.connections and \ + app.connections[self.account].connected: dialogs.ConfirmationDialog( _('Account "%s" is connected to the server') % self.account, _('If you remove it, the connection will be lost.'), @@ -3131,41 +3131,41 @@ 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) - if self.account in gajim.connections: - gajim.connections[self.account].disconnect(on_purpose=True) - gajim.connections[self.account].cleanup() - del gajim.connections[self.account] - gajim.logger.remove_roster(gajim.get_jid_from_account(self.account)) - gajim.config.del_per('accounts', self.account) - 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] - del gajim.groups[self.account] - gajim.contacts.remove_account(self.account) - del gajim.gc_connected[self.account] - del gajim.automatic_rooms[self.account] - del gajim.to_be_removed[self.account] - del gajim.newly_added[self.account] - del gajim.sleeper_state[self.account] - del gajim.encrypted_chats[self.account] - del gajim.last_message_time[self.account] - del gajim.status_before_autoaway[self.account] - del gajim.transport_avatar[self.account] - del gajim.gajim_optional_features[self.account] - del gajim.caps_hash[self.account] - if len(gajim.connections) >= 2: # Do not merge accounts if only one exists - gajim.interface.roster.regroup = gajim.config.get('mergeaccounts') + app.interface.roster.close_all(self.account, force=True) + if self.account in app.connections: + app.connections[self.account].disconnect(on_purpose=True) + app.connections[self.account].cleanup() + del app.connections[self.account] + app.logger.remove_roster(app.get_jid_from_account(self.account)) + app.config.del_per('accounts', self.account) + del app.interface.instances[self.account] + if self.account in app.nicks: + del app.interface.minimized_controls[self.account] + del app.nicks[self.account] + del app.block_signed_in_notifications[self.account] + del app.groups[self.account] + app.contacts.remove_account(self.account) + del app.gc_connected[self.account] + del app.automatic_rooms[self.account] + del app.to_be_removed[self.account] + del app.newly_added[self.account] + del app.sleeper_state[self.account] + del app.encrypted_chats[self.account] + del app.last_message_time[self.account] + del app.status_before_autoaway[self.account] + del app.transport_avatar[self.account] + del app.gajim_optional_features[self.account] + del app.caps_hash[self.account] + if len(app.connections) >= 2: # Do not merge accounts if only one exists + app.interface.roster.regroup = app.config.get('mergeaccounts') else: - gajim.interface.roster.regroup = False - gajim.interface.roster.setup_and_draw_roster() - gajim.app.remove_account_actions(self.account) + app.interface.roster.regroup = False + app.interface.roster.setup_and_draw_roster() + app.app.remove_account_actions(self.account) gui_menu_builder.build_accounts_menu() - if 'accounts' in gajim.interface.instances: - gajim.interface.instances['accounts'].init_accounts() - gajim.interface.instances['accounts'].init_account() + if 'accounts' in app.interface.instances: + app.interface.instances['accounts'].init_accounts() + app.interface.instances['accounts'].init_account() self.window.destroy() #---------- ManageBookmarksWindow class -------------# @@ -3173,7 +3173,7 @@ class ManageBookmarksWindow: def __init__(self): self.xml = gtkgui_helpers.get_gtk_builder('manage_bookmarks_window.ui') self.window = self.xml.get_object('manage_bookmarks_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.window.set_transient_for(app.interface.roster.window) self.ignore_events = False @@ -3183,17 +3183,17 @@ class ManageBookmarksWindow: self.treestore.set_sort_column_id(1, Gtk.SortType.ASCENDING) # Store bookmarks in treeview. - for account in gajim.connections: - if gajim.connections[account].connected <= 1: + for account in app.connections: + if app.connections[account].connected <= 1: continue - if gajim.connections[account].is_zeroconf: + if app.connections[account].is_zeroconf: continue - if not gajim.connections[account].private_storage_supported: + if not app.connections[account].private_storage_supported: continue iter_ = self.treestore.append(None, [None, account, None, None, None, None, None, None]) - for bookmark in gajim.connections[account].bookmarks: + for bookmark in app.connections[account].bookmarks: if not bookmark['name']: # No name was given for this bookmark. # Use the first part of JID instead... @@ -3290,7 +3290,7 @@ class ManageBookmarksWindow: add_to = iter_ account = model[add_to][1] - nick = gajim.nicks[account] + nick = app.nicks[account] iter_ = self.treestore.append(add_to, [account, _('New Group Chat'), '@', False, False, '', nick, 'in_and_out']) @@ -3347,7 +3347,7 @@ class ManageBookmarksWindow: for account in self.treestore: acct = account[1] - gajim.connections[acct].bookmarks = [] + app.connections[acct].bookmarks = [] for bm in account.iterchildren(): # Convert True/False/None to '1' or '0' @@ -3363,9 +3363,9 @@ class ManageBookmarksWindow: 'minimize': minimize, 'password': pw, 'nick': nick, 'print_status': bm[7]} - gajim.connections[acct].bookmarks.append(bmdict) + app.connections[acct].bookmarks.append(bmdict) - gajim.connections[acct].store_bookmarks() + app.connections[acct].store_bookmarks() gui_menu_builder.build_bookmark_menu(acct) self.window.destroy() @@ -3556,7 +3556,7 @@ class AccountCreationWizardWindow: self.xml = gtkgui_helpers.get_gtk_builder( 'account_creation_wizard_window.ui') self.window = self.xml.get_object('account_creation_wizard_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.window.set_transient_for(app.interface.roster.window) # Connect events from comboboxtext_entry server_comboboxtext = self.xml.get_object('server_comboboxtext') @@ -3569,7 +3569,7 @@ class AccountCreationWizardWindow: self.update_proxy_list() # parse servers.xml - servers_xml = os.path.join(gajim.DATA_DIR, 'other', 'servers.xml') + servers_xml = os.path.join(app.DATA_DIR, 'other', 'servers.xml') servers = gtkgui_helpers.parse_server_xml(servers_xml) servers_model = self.xml.get_object('server_liststore') for server in servers: @@ -3598,32 +3598,32 @@ class AccountCreationWizardWindow: self.notebook.set_current_page(0) self.xml.connect_signals(self) self.window.show_all() - gajim.ged.register_event_handler('new-account-connected', ged.GUI1, + app.ged.register_event_handler('new-account-connected', ged.GUI1, self._nec_new_acc_connected) - gajim.ged.register_event_handler('new-account-not-connected', ged.GUI1, + app.ged.register_event_handler('new-account-not-connected', ged.GUI1, self._nec_new_acc_not_connected) - gajim.ged.register_event_handler('account-created', ged.GUI1, + app.ged.register_event_handler('account-created', ged.GUI1, self._nec_acc_is_ok) - gajim.ged.register_event_handler('account-not-created', ged.GUI1, + app.ged.register_event_handler('account-not-created', ged.GUI1, self._nec_acc_is_not_ok) def on_wizard_window_destroy(self, widget): page = self.notebook.get_current_page() - if page in (4, 5) and self.account in gajim.connections: - # connection instance is saved in gajim.connections and we canceled + if page in (4, 5) and self.account in app.connections: + # connection instance is saved in app.connections and we canceled # the addition of the account - del gajim.connections[self.account] - if self.account in gajim.config.get_per('accounts'): - gajim.config.del_per('accounts', self.account) - gajim.ged.remove_event_handler('new-account-connected', ged.GUI1, + del app.connections[self.account] + if self.account in app.config.get_per('accounts'): + app.config.del_per('accounts', self.account) + app.ged.remove_event_handler('new-account-connected', ged.GUI1, self._nec_new_acc_connected) - gajim.ged.remove_event_handler('new-account-not-connected', ged.GUI1, + app.ged.remove_event_handler('new-account-not-connected', ged.GUI1, self._nec_new_acc_not_connected) - gajim.ged.remove_event_handler('account-created', ged.GUI1, + app.ged.remove_event_handler('account-created', ged.GUI1, self._nec_acc_is_ok) - gajim.ged.remove_event_handler('account-not-created', ged.GUI1, + app.ged.remove_event_handler('account-not-created', ged.GUI1, self._nec_acc_is_not_ok) - del gajim.interface.instances['account_creation_wizard'] + del app.interface.instances['account_creation_wizard'] def on_register_server_features_button_clicked(self, widget): helpers.launch_browser_mailer('url', @@ -3645,8 +3645,8 @@ class AccountCreationWizardWindow: self.xml.get_object('form_vbox').remove(self.data_form_widget) self.notebook.set_current_page(2) # show server page elif cur_page == 4: - if self.account in gajim.connections: - del gajim.connections[self.account] + if self.account in app.connections: + del app.connections[self.account] self.notebook.set_current_page(2) self.xml.get_object('form_vbox').remove(self.data_form_widget) elif cur_page == 6: # finish page @@ -3739,11 +3739,11 @@ class AccountCreationWizardWindow: self.account = server i = 1 - while self.account in gajim.connections: + while self.account in app.connections: self.account = server + str(i) i += 1 - username, server = gajim.get_name_and_server_from_jid(jid) + username, server = app.get_name_and_server_from_jid(jid) if self.xml.get_object('anonymous_checkbutton1').get_active(): self.save_account('', server, False, '', anonymous=True) else: @@ -3760,7 +3760,7 @@ class AccountCreationWizardWindow: return self.account = server i = 1 - while self.account in gajim.connections: + while self.account in app.connections: self.account = server + str(i) i += 1 @@ -3798,31 +3798,31 @@ class AccountCreationWizardWindow: self.update_progressbar) # Get form from serveur con = connection.Connection(self.account) - gajim.connections[self.account] = con + app.connections[self.account] = con con.new_account(self.account, config) elif cur_page == 3: checked = self.xml.get_object('ssl_checkbutton').get_active() if checked: - hostname = gajim.connections[self.account].new_account_info[ + hostname = app.connections[self.account].new_account_info[ 'hostname'] # Check if cert is already in file certs = '' - if os.path.isfile(gajim.MY_CACERTS): - f = open(gajim.MY_CACERTS) + if os.path.isfile(app.MY_CACERTS): + f = open(app.MY_CACERTS) certs = f.read() f.close() if self.ssl_cert in certs: dialogs.ErrorDialog(_('Certificate Already in File'), _('This certificate is already in file %s, so it\'s ' - 'not added again.') % gajim.MY_CACERTS) + 'not added again.') % app.MY_CACERTS) else: - f = open(gajim.MY_CACERTS, 'a') + f = open(app.MY_CACERTS, 'a') f.write(hostname + '\n') f.write(self.ssl_cert + '\n\n') f.close() - gajim.connections[self.account].new_account_info[ + app.connections[self.account].new_account_info[ 'ssl_fingerprint_sha1'] = self.ssl_fingerprint_sha1 - gajim.connections[self.account].new_account_info[ + app.connections[self.account].new_account_info[ 'ssl_fingerprint_sha256'] = self.ssl_fingerprint_sha256 self.notebook.set_current_page(4) # show fom page elif cur_page == 4: @@ -3830,7 +3830,7 @@ class AccountCreationWizardWindow: form = self.data_form_widget.data_form else: form = self.data_form_widget.get_infos() - gajim.connections[self.account].send_new_account_infos(form, + app.connections[self.account].send_new_account_infos(form, self.is_form) self.xml.get_object('form_vbox').remove(self.data_form_widget) self.xml.get_object('progressbar_label').set_markup( @@ -3845,17 +3845,17 @@ class AccountCreationWizardWindow: proxies_combobox = self.xml.get_object('proxies_combobox') model = Gtk.ListStore(str) proxies_combobox.set_model(model) - l = gajim.config.get_per('proxies') + l = app.config.get_per('proxies') l.insert(0, _('None')) for i in range(len(l)): model.append([l[i]]) proxies_combobox.set_active(0) def on_manage_proxies_button_clicked(self, widget): - if 'manage_proxies' in gajim.interface.instances: - gajim.interface.instances['manage_proxies'].window.present() + if 'manage_proxies' in app.interface.instances: + app.interface.instances['manage_proxies'].window.present() else: - gajim.interface.instances['manage_proxies'] = \ + app.interface.instances['manage_proxies'] = \ ManageProxiesWindow() def on_custom_host_port_checkbutton_toggled(self, widget): @@ -3903,7 +3903,7 @@ class AccountCreationWizardWindow: self.ssl_cert = obj.ssl_cert if obj.ssl_msg: # An SSL warning occured, show it - hostname = gajim.connections[self.account].new_account_info[ + hostname = app.connections[self.account].new_account_info[ 'hostname'] self.xml.get_object('ssl_label').set_markup(_( 'Security Warning' @@ -3931,13 +3931,13 @@ class AccountCreationWizardWindow: # We receive events from all accounts from GED if obj.conn.name != self.account: return - if self.account not in gajim.connections: + if self.account not in app.connections: return if self.update_progressbar_timeout_id is not None: GLib.source_remove(self.update_progressbar_timeout_id) - del gajim.connections[self.account] - if self.account in gajim.config.get_per('accounts'): - gajim.config.del_per('accounts', self.account) + del app.connections[self.account] + if self.account in app.config.get_per('accounts'): + app.config.del_per('accounts', self.account) self.back_button.show() self.cancel_button.show() self.go_online_checkbutton.hide() @@ -3973,9 +3973,9 @@ class AccountCreationWizardWindow: self.cancel_button.show() self.go_online_checkbutton.hide() self.show_vcard_checkbutton.hide() - del gajim.connections[self.account] - if self.account in gajim.config.get_per('accounts'): - gajim.config.del_per('accounts', self.account) + del app.connections[self.account] + if self.account in app.config.get_per('accounts'): + app.config.del_per('accounts', self.account) img = self.xml.get_object('finish_image') img.set_from_stock(Gtk.STOCK_DIALOG_ERROR, Gtk.IconSize.DIALOG) finish_text = '%s\n\n%s' % (_( @@ -3987,11 +3987,11 @@ class AccountCreationWizardWindow: GLib.source_remove(self.update_progressbar_timeout_id) def on_advanced_button_clicked(self, widget): - if 'accounts' in gajim.interface.instances: - gajim.interface.instances['accounts'].window.present() + if 'accounts' in app.interface.instances: + app.interface.instances['accounts'].window.present() else: - gajim.interface.instances['accounts'] = AccountsWindow() - gajim.interface.instances['accounts'].select_account(self.account) + app.interface.instances['accounts'] = AccountsWindow() + app.interface.instances['accounts'].select_account(self.account) self.window.destroy() def on_finish_button_clicked(self, widget): @@ -3999,9 +3999,9 @@ class AccountCreationWizardWindow: show_vcard = self.xml.get_object('show_vcard_checkbutton').get_active() self.window.destroy() if show_vcard: - gajim.interface.show_vcard_when_connect.append(self.account) + app.interface.show_vcard_when_connect.append(self.account) if go_online: - gajim.interface.roster.send_status(self.account, 'online', '') + app.interface.roster.send_status(self.account, 'online', '') def on_username_entry_key_press_event(self, widget, event): # Check for pressed @ and jump to combobox if found @@ -4041,7 +4041,7 @@ class AccountCreationWizardWindow: return config def save_account(self, login, server, savepass, password, anonymous=False): - if self.account in gajim.connections: + if self.account in app.connections: dialogs.ErrorDialog(_('Account name is in use'), _('You already have an account using this name.')) return @@ -4053,60 +4053,60 @@ class AccountCreationWizardWindow: if not self.modify: con.new_account(self.account, config) return - gajim.connections[self.account] = con + app.connections[self.account] = con self.create_vars(config) def create_vars(self, config): - gajim.config.add_per('accounts', self.account) + app.config.add_per('accounts', self.account) if not config['savepass']: config['password'] = '' for opt in config: - gajim.config.set_per('accounts', self.account, opt, config[opt]) + app.config.set_per('accounts', self.account, opt, config[opt]) # update variables - gajim.interface.instances[self.account] = {'infos': {}, 'disco': {}, + app.interface.instances[self.account] = {'infos': {}, 'disco': {}, 'gc_config': {}, 'search': {}, 'online_dialog': {}, 'sub_request': {}} - gajim.interface.minimized_controls[self.account] = {} - gajim.connections[self.account].connected = 0 - gajim.connections[self.account].keepalives = gajim.config.get_per( + app.interface.minimized_controls[self.account] = {} + app.connections[self.account].connected = 0 + app.connections[self.account].keepalives = app.config.get_per( 'accounts', self.account, 'keep_alive_every_foo_secs') - gajim.groups[self.account] = {} - gajim.contacts.add_account(self.account) - gajim.gc_connected[self.account] = {} - gajim.automatic_rooms[self.account] = {} - gajim.newly_added[self.account] = [] - gajim.to_be_removed[self.account] = [] - gajim.nicks[self.account] = config['name'] - gajim.block_signed_in_notifications[self.account] = True - gajim.sleeper_state[self.account] = 'off' - gajim.encrypted_chats[self.account] = [] - gajim.last_message_time[self.account] = {} - gajim.status_before_autoaway[self.account] = '' - gajim.transport_avatar[self.account] = {} - gajim.gajim_optional_features[self.account] = [] - gajim.caps_hash[self.account] = '' + app.groups[self.account] = {} + app.contacts.add_account(self.account) + app.gc_connected[self.account] = {} + app.automatic_rooms[self.account] = {} + app.newly_added[self.account] = [] + app.to_be_removed[self.account] = [] + app.nicks[self.account] = config['name'] + app.block_signed_in_notifications[self.account] = True + app.sleeper_state[self.account] = 'off' + app.encrypted_chats[self.account] = [] + app.last_message_time[self.account] = {} + app.status_before_autoaway[self.account] = '' + app.transport_avatar[self.account] = {} + app.gajim_optional_features[self.account] = [] + app.caps_hash[self.account] = '' helpers.update_optional_features(self.account) # refresh accounts window - if 'accounts' in gajim.interface.instances: - gajim.interface.instances['accounts'].init_accounts() + if 'accounts' in app.interface.instances: + app.interface.instances['accounts'].init_accounts() # refresh roster - if len(gajim.connections) >= 2: + if len(app.connections) >= 2: # Do not merge accounts if only one exists - gajim.interface.roster.regroup = gajim.config.get('mergeaccounts') + app.interface.roster.regroup = app.config.get('mergeaccounts') else: - gajim.interface.roster.regroup = False - gajim.interface.roster.setup_and_draw_roster() - gajim.app.add_account_actions(self.account) + app.interface.roster.regroup = False + app.interface.roster.setup_and_draw_roster() + app.app.add_account_actions(self.account) gui_menu_builder.build_accounts_menu() class ManagePEPServicesWindow: def __init__(self, account): self.xml = gtkgui_helpers.get_gtk_builder('manage_pep_services_window.ui') self.window = self.xml.get_object('manage_pep_services_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.window.set_transient_for(app.interface.roster.window) self.xml.get_object('configure_button').set_sensitive(False) self.xml.get_object('delete_button').set_sensitive(False) self.xml.connect_signals(self) @@ -4116,19 +4116,19 @@ class ManagePEPServicesWindow: self.xml.get_object('services_treeview').get_selection().connect( 'changed', self.on_services_selection_changed) - gajim.ged.register_event_handler('pep-config-received', ged.GUI1, + app.ged.register_event_handler('pep-config-received', ged.GUI1, self._nec_pep_config_received) - gajim.ged.register_event_handler('agent-items-received', ged.GUI1, + app.ged.register_event_handler('agent-items-received', ged.GUI1, self._nec_agent_items_received) self.window.show_all() def on_manage_pep_services_window_destroy(self, widget): '''close window''' - del gajim.interface.instances[self.account]['pep_services'] - gajim.ged.remove_event_handler('pep-config-received', ged.GUI1, + del app.interface.instances[self.account]['pep_services'] + app.ged.remove_event_handler('pep-config-received', ged.GUI1, self._nec_pep_config_received) - gajim.ged.remove_event_handler('agent-items-received', ged.GUI1, + app.ged.remove_event_handler('agent-items-received', ged.GUI1, self._nec_agent_items_received) def on_close_button_clicked(self, widget): @@ -4151,17 +4151,17 @@ class ManagePEPServicesWindow: col.pack_start(cellrenderer_text, True) col.add_attribute(cellrenderer_text, 'text', 0) - our_jid = gajim.get_jid_from_account(self.account) - gajim.connections[self.account].discoverItems(our_jid) + our_jid = app.get_jid_from_account(self.account) + app.connections[self.account].discoverItems(our_jid) def _nec_agent_items_received(self, obj): - our_jid = gajim.get_jid_from_account(self.account) + our_jid = app.get_jid_from_account(self.account) for item in obj.items: if 'jid' in item and item['jid'] == our_jid and 'node' in item: self.treestore.append([item['node']]) def node_removed(self, jid, node): - if jid != gajim.get_jid_from_account(self.account): + if jid != app.get_jid_from_account(self.account): return model = self.treeview.get_model() iter_ = model.get_iter_first() @@ -4172,7 +4172,7 @@ class ManagePEPServicesWindow: iter_ = model.iter_next(iter_) def node_not_removed(self, jid, node, msg): - if jid != gajim.get_jid_from_account(self.account): + if jid != app.get_jid_from_account(self.account): return dialogs.WarningDialog(_('PEP node was not removed'), _('PEP node %(node)s was not removed: %(message)s') % {'node': node, @@ -4184,8 +4184,8 @@ class ManagePEPServicesWindow: return model, iter_ = selection.get_selected() node = model[iter_][0] - our_jid = gajim.get_jid_from_account(self.account) - gajim.connections[self.account].send_pb_delete(our_jid, node, + our_jid = app.get_jid_from_account(self.account) + app.connections[self.account].send_pb_delete(our_jid, node, on_ok=self.node_removed, on_fail=self.node_not_removed) def on_configure_button_clicked(self, widget): @@ -4194,14 +4194,14 @@ class ManagePEPServicesWindow: return model, iter_ = selection.get_selected() node = model[iter_][0] - our_jid = gajim.get_jid_from_account(self.account) - gajim.connections[self.account].request_pb_configuration(our_jid, node) + our_jid = app.get_jid_from_account(self.account) + app.connections[self.account].request_pb_configuration(our_jid, node) def _nec_pep_config_received(self, obj): def on_ok(form, node): form.type_ = 'submit' - our_jid = gajim.get_jid_from_account(self.account) - gajim.connections[self.account].send_pb_configure(our_jid, node, form) + our_jid = app.get_jid_from_account(self.account) + app.connections[self.account].send_pb_configure(our_jid, node, form) window = dialogs.DataFormWindow(obj.form, (on_ok, obj.node)) title = _('Configure %s') % obj.node window.set_title(title) @@ -4212,7 +4212,7 @@ class ManageSoundsWindow: self.xml = gtkgui_helpers.get_gtk_builder('manage_sounds_window.ui') self.window = self.xml.get_object('manage_sounds_window') self.window.set_transient_for( - gajim.interface.instances['preferences'].window) + app.interface.instances['preferences'].window) # sounds treeview self.sound_tree = self.xml.get_object('sounds_treeview') @@ -4245,9 +4245,9 @@ class ManageSoundsWindow: def on_sounds_treemodel_row_changed(self, model, path, iter_): sound_event = model[iter_][3] - gajim.config.set_per('soundevents', sound_event, 'enabled', + app.config.set_per('soundevents', sound_event, 'enabled', bool(model[path][0])) - gajim.config.set_per('soundevents', sound_event, 'path', + app.config.set_per('soundevents', sound_event, 'path', model[iter_][2]) def sound_toggled_cb(self, cell, path): @@ -4260,7 +4260,7 @@ class ManageSoundsWindow: model.set_sort_column_id(1, Gtk.SortType.ASCENDING) # NOTE: sounds_ui_names MUST have all items of - # sounds = gajim.config.get_per('soundevents') as keys + # sounds = app.config.get_per('soundevents') as keys sounds_dict = { 'attention_received': _('Attention Message Received'), 'first_message_received': _('First Message Received'), @@ -4276,9 +4276,9 @@ class ManageSoundsWindow: } for sound_event_config_name, sound_ui_name in sounds_dict.items(): - enabled = gajim.config.get_per('soundevents', + enabled = app.config.get_per('soundevents', sound_event_config_name, 'enabled') - path = gajim.config.get_per('soundevents', + path = app.config.get_per('soundevents', sound_event_config_name, 'path') model.append((enabled, sound_ui_name, path, sound_event_config_name)) @@ -4311,7 +4311,7 @@ class ManageSoundsWindow: model[iter_][0] = False return directory = os.path.dirname(path_to_snd_file) - gajim.config.set('last_sounds_dir', directory) + app.config.set('last_sounds_dir', directory) path_to_snd_file = helpers.strip_soundfile_path(path_to_snd_file) self.xml.get_object('sounds_entry').set_text(path_to_snd_file) diff --git a/gajim/conversation_textview.py b/gajim/conversation_textview.py index 43ff798f4..1b98d2cdd 100644 --- a/gajim/conversation_textview.py +++ b/gajim/conversation_textview.py @@ -43,7 +43,7 @@ import queue import urllib from gajim import gtkgui_helpers -from gajim.common import gajim +from gajim.common import app from gajim.common import helpers from gajim.common import i18n from calendar import timegm @@ -234,38 +234,38 @@ class ConversationTextview(GObject.GObject): buffer_.create_mark('end', end_iter, False) self.tagIn = buffer_.create_tag('incoming') - color = gajim.config.get('inmsgcolor') - font = Pango.FontDescription(gajim.config.get('inmsgfont')) + color = app.config.get('inmsgcolor') + font = Pango.FontDescription(app.config.get('inmsgfont')) self.tagIn.set_property('foreground', color) self.tagIn.set_property('font-desc', font) self.tagOut = buffer_.create_tag('outgoing') - color = gajim.config.get('outmsgcolor') - font = Pango.FontDescription(gajim.config.get('outmsgfont')) + color = app.config.get('outmsgcolor') + font = Pango.FontDescription(app.config.get('outmsgfont')) self.tagOut.set_property('foreground', color) self.tagOut.set_property('font-desc', font) self.tagStatus = buffer_.create_tag('status') - color = gajim.config.get('statusmsgcolor') - font = Pango.FontDescription(gajim.config.get('satusmsgfont')) + color = app.config.get('statusmsgcolor') + font = Pango.FontDescription(app.config.get('satusmsgfont')) self.tagStatus.set_property('foreground', color) self.tagStatus.set_property('font-desc', font) self.tagInText = buffer_.create_tag('incomingtxt') - color = gajim.config.get('inmsgtxtcolor') - font = Pango.FontDescription(gajim.config.get('inmsgtxtfont')) + color = app.config.get('inmsgtxtcolor') + font = Pango.FontDescription(app.config.get('inmsgtxtfont')) if color: self.tagInText.set_property('foreground', color) self.tagInText.set_property('font-desc', font) self.tagOutText = buffer_.create_tag('outgoingtxt') - color = gajim.config.get('outmsgtxtcolor') + color = app.config.get('outmsgtxtcolor') if color: - font = Pango.FontDescription(gajim.config.get('outmsgtxtfont')) + font = Pango.FontDescription(app.config.get('outmsgtxtfont')) self.tagOutText.set_property('foreground', color) self.tagOutText.set_property('font-desc', font) - colors = gajim.config.get('gc_nicknames_colors') + colors = app.config.get('gc_nicknames_colors') colors = colors.split(':') for i, color in enumerate(colors): tagname = 'gc_nickname_color_' + str(i) @@ -273,7 +273,7 @@ class ConversationTextview(GObject.GObject): tag.set_property('foreground', color) self.tagMarked = buffer_.create_tag('marked') - color = gajim.config.get('markedmsgcolor') + color = app.config.get('markedmsgcolor') self.tagMarked.set_property('foreground', color) self.tagMarked.set_property('weight', Pango.Weight.BOLD) @@ -288,7 +288,7 @@ class ConversationTextview(GObject.GObject): tag.set_property('scale', 0.8333333333333) tag = buffer_.create_tag('restored_message') - color = gajim.config.get('restored_messages_color') + color = app.config.get('restored_messages_color') tag.set_property('foreground', color) self.tv.create_tags() @@ -309,7 +309,7 @@ class ConversationTextview(GObject.GObject): tag.set_property('foreground', '#73d216') # One mark at the begining then 2 marks between each lines - size = gajim.config.get('max_conversation_lines') + size = app.config.get('max_conversation_lines') size = 2 * size - 1 self.marks_queue = queue.Queue(size) @@ -367,13 +367,13 @@ class ConversationTextview(GObject.GObject): self.tv.destroy() def update_tags(self): - self.tagIn.set_property('foreground', gajim.config.get('inmsgcolor')) - self.tagOut.set_property('foreground', gajim.config.get('outmsgcolor')) + self.tagIn.set_property('foreground', app.config.get('inmsgcolor')) + self.tagOut.set_property('foreground', app.config.get('outmsgcolor')) self.tagStatus.set_property('foreground', - gajim.config.get('statusmsgcolor')) + app.config.get('statusmsgcolor')) self.tagMarked.set_property('foreground', - gajim.config.get('markedmsgcolor')) - color = gajim.config.get('urlmsgcolor') + app.config.get('markedmsgcolor')) + color = app.config.get('urlmsgcolor') self.tv.tagURL.set_property('foreground', color) self.tv.tagMail.set_property('foreground', color) self.tv.tagXMPP.set_property('foreground', color) @@ -450,7 +450,7 @@ class ConversationTextview(GObject.GObject): buffer_ = self.tv.get_buffer() buffer_.begin_user_action() - if gajim.config.get('positive_184_ack'): + if app.config.get('positive_184_ack'): begin_iter = buffer_.get_iter_at_mark(self.xep0184_marks[id_]) buffer_.insert_with_tags_by_name(begin_iter, ' ✓', 'xep0184-received') @@ -555,7 +555,7 @@ class ConversationTextview(GObject.GObject): buffer_ = self.tv.get_buffer() start, end = buffer_.get_bounds() buffer_.delete(start, end) - size = gajim.config.get('max_conversation_lines') + size = app.config.get('max_conversation_lines') size = 2 * size - 1 self.marks_queue = queue.Queue(size) self.focus_out_end_mark = None @@ -606,29 +606,29 @@ class ConversationTextview(GObject.GObject): phrase_for_url = urllib.parse.quote(self.selected_phrase.encode( 'utf-8')) - always_use_en = gajim.config.get('always_english_wikipedia') + always_use_en = app.config.get('always_english_wikipedia') if always_use_en: link = 'http://en.wikipedia.org/wiki/Special:Search?search=%s'\ % phrase_for_url else: link = 'http://%s.wikipedia.org/wiki/Special:Search?search=%s'\ - % (gajim.LANG, phrase_for_url) + % (app.LANG, phrase_for_url) item = Gtk.MenuItem.new_with_mnemonic(_('Read _Wikipedia Article')) id_ = item.connect('activate', self.visit_url_from_menuitem, link) self.handlers[id_] = item submenu.append(item) item = Gtk.MenuItem.new_with_mnemonic(_('Look it up in _Dictionary')) - dict_link = gajim.config.get('dictionary_url') + dict_link = app.config.get('dictionary_url') if dict_link == 'WIKTIONARY': # special link (yeah undocumented but default) - always_use_en = gajim.config.get('always_english_wiktionary') + always_use_en = app.config.get('always_english_wiktionary') if always_use_en: link = 'http://en.wiktionary.org/wiki/Special:Search?search=%s'\ % phrase_for_url else: link = 'http://%s.wiktionary.org/wiki/Special:Search?search=%s'\ - % (gajim.LANG, phrase_for_url) + % (app.LANG, phrase_for_url) id_ = item.connect('activate', self.visit_url_from_menuitem, link) self.handlers[id_] = item else: @@ -645,7 +645,7 @@ class ConversationTextview(GObject.GObject): submenu.append(item) - search_link = gajim.config.get('search_engine') + search_link = app.config.get('search_engine') if search_link.find('%s') == -1: # we must have %s in the url item = Gtk.MenuItem.new_with_label( @@ -716,13 +716,13 @@ class ConversationTextview(GObject.GObject): clip.set_text(text, -1) def on_start_chat_activate(self, widget, jid): - gajim.interface.new_chat_from_jid(self.account, jid) + app.interface.new_chat_from_jid(self.account, jid) def on_join_group_chat_menuitem_activate(self, widget, room_jid): - if 'join_gc' in gajim.interface.instances[self.account]: - instance = gajim.interface.instances[self.account]['join_gc'] + if 'join_gc' in app.interface.instances[self.account]: + instance = app.interface.instances[self.account]['join_gc'] instance.xml.get_object('room_jid_entry').set_text(room_jid) - gajim.interface.instances[self.account]['join_gc'].window.present() + app.interface.instances[self.account]['join_gc'].window.present() else: try: dialogs.JoinGroupchatWindow(account=self.account, room_jid=room_jid) @@ -766,7 +766,7 @@ class ConversationTextview(GObject.GObject): self.on_join_group_chat_menuitem_activate, text) self.handlers[id_] = childs[6] - if self.account and gajim.connections[self.account].\ + if self.account and app.connections[self.account].\ roster_supported: id_ = childs[7].connect('activate', self.on_add_to_roster_activate, text) @@ -813,7 +813,7 @@ class ConversationTextview(GObject.GObject): kind = 'xmpp' elif word.startswith('mailto:'): kind = 'mail' - elif gajim.interface.sth_at_sth_dot_sth_re.match(word): + elif app.interface.sth_at_sth_dot_sth_re.match(word): # it's a JID or mail kind = 'sth_at_sth' else: @@ -823,7 +823,7 @@ class ConversationTextview(GObject.GObject): return True else: self.plugin_modified = False - gajim.plugin_manager.extension_point( + app.plugin_manager.extension_point( 'hyperlink_handler', word, kind, self, self.tv.get_toplevel()) if self.plugin_modified: @@ -875,11 +875,11 @@ class ConversationTextview(GObject.GObject): specials_limit = 100 # basic: links + mail + formatting is always checked (we like that) - if gajim.config.get('emoticons_theme') and graphics: + if app.config.get('emoticons_theme') and graphics: # search for emoticons & urls - iterator = gajim.interface.emot_and_basic_re.finditer(otext) + iterator = app.interface.emot_and_basic_re.finditer(otext) else: # search for just urls + mail + formatting - iterator = gajim.interface.basic_pattern_re.finditer(otext) + iterator = app.interface.basic_pattern_re.finditer(otext) if iter_: end_iter = iter_ else: @@ -921,7 +921,7 @@ class ConversationTextview(GObject.GObject): # PluginSystem: adding GUI extension point for ConversationTextview self.plugin_modified = False - gajim.plugin_manager.extension_point('print_special_text', self, + app.plugin_manager.extension_point('print_special_text', self, special_text, other_tags, graphics, additional_data) if self.plugin_modified: return @@ -931,7 +931,7 @@ class ConversationTextview(GObject.GObject): text_is_valid_uri = False is_xhtml_link = None show_ascii_formatting_chars = \ - gajim.config.get('show_ascii_formatting_chars') + app.config.get('show_ascii_formatting_chars') buffer_ = self.tv.get_buffer() # Detect XHTML-IM link @@ -943,7 +943,7 @@ class ConversationTextview(GObject.GObject): break # Check if we accept this as an uri - schemes = gajim.config.get('uri_schemes').split() + schemes = app.config.get('uri_schemes').split() for scheme in schemes: if special_text.startswith(scheme): text_is_valid_uri = True @@ -955,7 +955,7 @@ class ConversationTextview(GObject.GObject): end_iter = buffer_.get_end_iter() pixbuf = emoticons.get_pixbuf(possible_emot_ascii_caps) - if gajim.config.get('emoticons_theme') and pixbuf and graphics: + if app.config.get('emoticons_theme') and pixbuf and graphics: # it's an emoticon anchor = buffer_.create_child_anchor(end_iter) img = TextViewImage(anchor, @@ -972,7 +972,7 @@ class ConversationTextview(GObject.GObject): tags.append('mail') elif special_text.startswith('xmpp:') and not is_xhtml_link: tags.append('xmpp') - elif gajim.interface.sth_at_sth_dot_sth_re.match(special_text) and\ + elif app.interface.sth_at_sth_dot_sth_re.match(special_text) and\ not is_xhtml_link: # it's a JID or mail tags.append('sth_at_sth') @@ -1191,12 +1191,12 @@ class ConversationTextview(GObject.GObject): text_tags.append(other_text_tag) else: # not status nor /me - if gajim.config.get('chat_merge_consecutive_nickname'): + if app.config.get('chat_merge_consecutive_nickname'): if kind != old_kind or self.just_cleared: self.print_name(name, kind, other_tags_for_name, direction_mark=direction_mark, iter_=iter_) else: - self.print_real_text(gajim.config.get( + self.print_real_text(app.config.get( 'chat_merge_consecutive_nickname_indent'), mark=insert_mark, additional_data=additional_data) else: @@ -1283,7 +1283,7 @@ class ConversationTextview(GObject.GObject): format_ += i18n.direction_mark + day_str + direction_mark + ' ' else: format_ += day_str + ' ' - timestamp_str = gajim.config.get('time_stamp') + timestamp_str = app.config.get('time_stamp') timestamp_str = helpers.from_one_line(timestamp_str) format_ += timestamp_str tim_format = time.strftime(format_, tim) @@ -1298,7 +1298,7 @@ class ConversationTextview(GObject.GObject): def print_time(self, text, kind, tim, simple, direction_mark, other_tags_for_time, iter_): local_tim = time.localtime(tim) buffer_ = self.tv.get_buffer() - current_print_time = gajim.config.get('print_time') + current_print_time = app.config.get('print_time') if current_print_time == 'always' and kind != 'info' and not simple: timestamp_str = self.get_time_to_show(local_tim, direction_mark) @@ -1310,14 +1310,14 @@ class ConversationTextview(GObject.GObject): else: buffer_.insert(iter_, timestamp) elif current_print_time == 'sometimes' and kind != 'info' and not simple: - every_foo_seconds = 60 * gajim.config.get( + every_foo_seconds = 60 * app.config.get( 'print_ichat_every_foo_minutes') seconds_passed = tim - self.last_time_printout if seconds_passed > every_foo_seconds: self.last_time_printout = tim - if gajim.config.get('print_time_fuzzy') > 0: + if app.config.get('print_time_fuzzy') > 0: tim_format = self.fc.fuzzy_time( - gajim.config.get('print_time_fuzzy'), tim) + app.config.get('print_time_fuzzy'), tim) else: tim_format = self.get_time_to_show(local_tim, direction_mark) buffer_.insert_with_tags_by_name(iter_, tim_format + '\n', @@ -1352,9 +1352,9 @@ class ConversationTextview(GObject.GObject): if other_tags_for_name: name_tags = other_tags_for_name[:] # create a new list name_tags.append(kind) - before_str = gajim.config.get('before_nickname') + before_str = app.config.get('before_nickname') before_str = helpers.from_one_line(before_str) - after_str = gajim.config.get('after_nickname') + after_str = app.config.get('after_nickname') after_str = helpers.from_one_line(after_str) format_ = before_str + name + direction_mark + after_str + ' ' buffer_.insert_with_tags_by_name(end_iter, format_, *name_tags) @@ -1389,8 +1389,8 @@ class ConversationTextview(GObject.GObject): self.tv.display_html(xhtml, self.tv, self, iter_=iter_) return except Exception as e: - gajim.log.debug('Error processing xhtml: ' + str(e)) - gajim.log.debug('with |' + xhtml + '|') + app.log.debug('Error processing xhtml: ' + str(e)) + app.log.debug('with |' + xhtml + '|') # /me is replaced by name if name is given if name and (text.startswith('/me ') or text.startswith('/me\n')): @@ -1399,7 +1399,7 @@ class ConversationTextview(GObject.GObject): # PluginSystem: adding GUI extension point for ConversationTextview self.plugin_modified = False - gajim.plugin_manager.extension_point('print_real_text', self, + app.plugin_manager.extension_point('print_real_text', self, text, text_tags, graphics, iter_, additional_data) if self.plugin_modified: diff --git a/gajim/dialogs.py b/gajim/dialogs.py index 958de0332..a2a7d9a56 100644 --- a/gajim/dialogs.py +++ b/gajim/dialogs.py @@ -60,7 +60,7 @@ from gajim.filetransfers_window import FileTransfersWindow from gajim.gajim_themes_window import GajimThemesWindow from gajim.advanced_configuration_window import AdvancedConfigurationWindow -from gajim.common import gajim +from gajim.common import app from gajim.common import helpers from gajim.common import i18n from gajim.common import dataforms @@ -82,7 +82,7 @@ class EditGroupsDialog: """ self.xml = gtkgui_helpers.get_gtk_builder('edit_groups_dialog.ui') self.dialog = self.xml.get_object('edit_groups_dialog') - self.dialog.set_transient_for(gajim.interface.roster.window) + self.dialog.set_transient_for(app.interface.roster.window) self.list_ = list_ self.changes_made = False self.treeview = self.xml.get_object('groups_treeview') @@ -104,7 +104,7 @@ class EditGroupsDialog: self.dialog.show_all() if self.changes_made: for (contact, account) in self.list_: - gajim.connections[account].update_contact(contact.jid, + app.connections[account].update_contact(contact.jid, contact.name, contact.groups) def on_edit_groups_dialog_response(self, widget, response_id): @@ -116,23 +116,23 @@ class EditGroupsDialog: Remove group group from all contacts and all their brothers """ for (contact, account) in self.list_: - gajim.interface.roster.remove_contact_from_groups(contact.jid, + app.interface.roster.remove_contact_from_groups(contact.jid, account, [group]) # FIXME: Ugly workaround. - gajim.interface.roster.draw_group(_('General'), account) + app.interface.roster.draw_group(_('General'), account) def add_group(self, group): """ Add group group to all contacts and all their brothers """ for (contact, account) in self.list_: - gajim.interface.roster.add_contact_to_groups(contact.jid, account, + app.interface.roster.add_contact_to_groups(contact.jid, account, [group]) # FIXME: Ugly workaround. # Maybe we haven't been in any group (defaults to General) - gajim.interface.roster.draw_group(_('General'), account) + app.interface.roster.draw_group(_('General'), account) def on_add_button_clicked(self, widget): group = self.xml.get_object('group_entry').get_text() @@ -180,7 +180,7 @@ class EditGroupsDialog: for (contact, account) in self.list_: if account not in accounts: accounts.append(account) - for g in gajim.groups[account].keys(): + for g in app.groups[account].keys(): if g in groups: continue groups[g] = 0 @@ -245,7 +245,7 @@ class PassphraseDialog: cancelbutton.connect('clicked', self.on_cancelbutton_clicked) self.xml.connect_signals(self) - self.window.set_transient_for(gajim.interface.roster.window) + self.window.set_transient_for(app.interface.roster.window) self.window.show_all() self.check = bool(checkbuttontext) @@ -362,7 +362,7 @@ class ChangeActivityDialog: self.text = text self.xml = gtkgui_helpers.get_gtk_builder('change_activity_dialog.ui') self.window = self.xml.get_object('change_activity_dialog') - self.window.set_transient_for(gajim.interface.roster.window) + self.window.set_transient_for(app.interface.roster.window) self.checkbutton = self.xml.get_object('enable_checkbutton') self.notebook = self.xml.get_object('notebook') @@ -487,7 +487,7 @@ class ChangeMoodDialog: self.xml = gtkgui_helpers.get_gtk_builder('change_mood_dialog.ui') self.window = self.xml.get_object('change_mood_dialog') - self.window.set_transient_for(gajim.interface.roster.window) + self.window.set_transient_for(app.interface.roster.window) self.window.set_title(_('Set Mood')) table = self.xml.get_object('mood_icons_table') @@ -597,7 +597,7 @@ class TimeoutDialog: class ChangeStatusMessageDialog(TimeoutDialog): def __init__(self, on_response, show=None, show_pep=True): - countdown_time = gajim.config.get('change_status_window_timeout') + countdown_time = app.config.get('change_status_window_timeout') TimeoutDialog.__init__(self, countdown_time, self.on_timeout) self.show = show self.pep_dict = {} @@ -605,22 +605,22 @@ class ChangeStatusMessageDialog(TimeoutDialog): self.on_response = on_response self.xml = gtkgui_helpers.get_gtk_builder('change_status_message_dialog.ui') self.dialog = self.xml.get_object('change_status_message_dialog') - self.dialog.set_transient_for(gajim.interface.roster.window) + self.dialog.set_transient_for(app.interface.roster.window) msg = None if show: uf_show = helpers.get_uf_show(show) self.title_text = _('%s Status Message') % uf_show - msg = gajim.config.get_per('statusmsg', '_last_' + self.show, + msg = app.config.get_per('statusmsg', '_last_' + self.show, 'message') - self.pep_dict['activity'] = gajim.config.get_per('statusmsg', + self.pep_dict['activity'] = app.config.get_per('statusmsg', '_last_' + self.show, 'activity') - self.pep_dict['subactivity'] = gajim.config.get_per('statusmsg', + self.pep_dict['subactivity'] = app.config.get_per('statusmsg', '_last_' + self.show, 'subactivity') - self.pep_dict['activity_text'] = gajim.config.get_per('statusmsg', + self.pep_dict['activity_text'] = app.config.get_per('statusmsg', '_last_' + self.show, 'activity_text') - self.pep_dict['mood'] = gajim.config.get_per('statusmsg', + self.pep_dict['mood'] = app.config.get_per('statusmsg', '_last_' + self.show, 'mood') - self.pep_dict['mood_text'] = gajim.config.get_per('statusmsg', + self.pep_dict['mood_text'] = app.config.get_per('statusmsg', '_last_' + self.show, 'mood_text') else: self.title_text = _('Status Message') @@ -636,13 +636,13 @@ class ChangeStatusMessageDialog(TimeoutDialog): # have an empty string selectable, so user can clear msg self.preset_messages_dict = {'': ['', '', '', '', '', '']} - for msg_name in gajim.config.get_per('statusmsg'): + for msg_name in app.config.get_per('statusmsg'): if msg_name.startswith('_last_'): continue opts = [] for opt in ['message', 'activity', 'subactivity', 'activity_text', 'mood', 'mood_text']: - opts.append(gajim.config.get_per('statusmsg', msg_name, opt)) + opts.append(app.config.get_per('statusmsg', msg_name, opt)) opts[0] = helpers.from_one_line(opts[0]) self.preset_messages_dict[msg_name] = opts sorted_keys_list = helpers.get_sorted_keys(self.preset_messages_dict) @@ -729,18 +729,18 @@ class ChangeStatusMessageDialog(TimeoutDialog): message = helpers.remove_invalid_xml_chars(message) msg = helpers.to_one_line(message) if self.show: - gajim.config.set_per('statusmsg', '_last_' + self.show, + app.config.set_per('statusmsg', '_last_' + self.show, 'message', msg) if self.show_pep: - gajim.config.set_per('statusmsg', '_last_' + self.show, + app.config.set_per('statusmsg', '_last_' + self.show, 'activity', self.pep_dict['activity']) - gajim.config.set_per('statusmsg', '_last_' + self.show, + app.config.set_per('statusmsg', '_last_' + self.show, 'subactivity', self.pep_dict['subactivity']) - gajim.config.set_per('statusmsg', '_last_' + self.show, + app.config.set_per('statusmsg', '_last_' + self.show, 'activity_text', self.pep_dict['activity_text']) - gajim.config.set_per('statusmsg', '_last_' + self.show, + app.config.set_per('statusmsg', '_last_' + self.show, 'mood', self.pep_dict['mood']) - gajim.config.set_per('statusmsg', '_last_' + self.show, + app.config.set_per('statusmsg', '_last_' + self.show, 'mood_text', self.pep_dict['mood_text']) else: message = None # user pressed Cancel button or X wm button @@ -800,24 +800,24 @@ class ChangeStatusMessageDialog(TimeoutDialog): self.pep_dict.get('subactivity'), self.pep_dict.get('activity_text'), self.pep_dict.get('mood'), self.pep_dict.get('mood_text')] - gajim.config.set_per('statusmsg', msg_name, 'message', + app.config.set_per('statusmsg', msg_name, 'message', msg_text_1l) - gajim.config.set_per('statusmsg', msg_name, 'activity', + app.config.set_per('statusmsg', msg_name, 'activity', self.pep_dict.get('activity')) - gajim.config.set_per('statusmsg', msg_name, 'subactivity', + app.config.set_per('statusmsg', msg_name, 'subactivity', self.pep_dict.get('subactivity')) - gajim.config.set_per('statusmsg', msg_name, 'activity_text', + app.config.set_per('statusmsg', msg_name, 'activity_text', self.pep_dict.get('activity_text')) - gajim.config.set_per('statusmsg', msg_name, 'mood', + app.config.set_per('statusmsg', msg_name, 'mood', self.pep_dict.get('mood')) - gajim.config.set_per('statusmsg', msg_name, 'mood_text', + app.config.set_per('statusmsg', msg_name, 'mood_text', self.pep_dict.get('mood_text')) if msg_name in self.preset_messages_dict: ConfirmationDialog(_('Overwrite Status Message?'), _('This name is already used. Do you want to overwrite this ' 'status message?'), on_response_ok=on_ok2, transient_for=self.dialog) return - gajim.config.add_per('statusmsg', msg_name) + app.config.add_per('statusmsg', msg_name) on_ok2() iter_ = self.message_liststore.append((msg_name,)) # select in combobox the one we just saved @@ -863,8 +863,8 @@ class AddNewContactWindow: if account is None: # fill accounts with active accounts accounts = [] - for account in gajim.connections.keys(): - if gajim.connections[account].connected > 1: + for account in app.connections.keys(): + if app.connections[account].connected > 1: accounts.append(account) if not accounts: return @@ -873,9 +873,9 @@ class AddNewContactWindow: else: accounts = [self.account] if self.account: - location = gajim.interface.instances[self.account] + location = app.interface.instances[self.account] else: - location = gajim.interface.instances + location = app.interface.instances if 'add_contact' in location: location['add_contact'].window.present() # An instance is already opened @@ -891,7 +891,7 @@ class AddNewContactWindow: 'add_button', 'message_textview', 'connected_label', 'group_comboboxentry', 'auto_authorize_checkbutton'): self.__dict__[w] = self.xml.get_object(w) - if account and len(gajim.connections) >= 2: + if account and len(app.connections) >= 2: self.default_desc = _('Please fill in the data of the contact you want\n' 'to add to your account %s') % account else: @@ -903,9 +903,9 @@ class AddNewContactWindow: # types to which we are not subscribed but account has an agent for it self.available_types = [] for acct in accounts: - for j in gajim.contacts.get_jid_list(acct): - if gajim.jid_is_transport(j): - type_ = gajim.get_transport_name_from_jid(j, False) + for j in app.contacts.get_jid_list(acct): + if app.jid_is_transport(j): + type_ = app.get_transport_name_from_jid(j, False) if not type_: continue if type_ in self.agents: @@ -915,11 +915,11 @@ class AddNewContactWindow: self.gateway_prompt[j] = {'desc': None, 'prompt': None} # Now add the one to which we can register for acct in accounts: - for type_ in gajim.connections[acct].available_transports: + for type_ in app.connections[acct].available_transports: if type_ in self.agents: continue self.agents[type_] = [] - for jid_ in gajim.connections[acct].available_transports[type_]: + for jid_ in app.connections[acct].available_transports[type_]: if not jid_ in self.agents[type_]: self.agents[type_].append(jid_) self.gateway_prompt[jid_] = {'desc': None, @@ -938,12 +938,12 @@ class AddNewContactWindow: uf_type = {'jabber': 'XMPP', 'aim': 'AIM', 'gadu-gadu': 'Gadu Gadu', 'icq': 'ICQ', 'msn': 'MSN', 'yahoo': 'Yahoo'} # Jabber as first - img = gajim.interface.jabber_state_images['16']['online'] + img = app.interface.jabber_state_images['16']['online'] liststore.append(['XMPP', img.get_pixbuf(), 'jabber']) for type_ in self.agents: if type_ == 'jabber': continue - imgs = gajim.interface.roster.transports_state_images + imgs = app.interface.roster.transports_state_images img = None if type_ in imgs['16'] and 'online' in imgs['16'][type_]: img = imgs['16'][type_]['online'] @@ -955,20 +955,20 @@ class AddNewContactWindow: liststore.append([type_, img, type_]) if account: for service in self.agents[type_]: - gajim.connections[account].request_gateway_prompt(service) + app.connections[account].request_gateway_prompt(service) self.protocol_combobox.set_active(0) self.auto_authorize_checkbutton.show() liststore = Gtk.ListStore(str) self.protocol_jid_combobox.set_model(liststore) if jid: self.jid_escaped = True - type_ = gajim.get_transport_name_from_jid(jid) + type_ = app.get_transport_name_from_jid(jid) if not type_: type_ = 'jabber' if type_ == 'jabber': self.uid_entry.set_text(jid) else: - uid, transport = gajim.get_name_and_server_from_jid(jid) + uid, transport = app.get_name_and_server_from_jid(jid) self.uid_entry.set_text(uid.replace('%', '@', 1)) # set protocol_combobox model = self.protocol_combobox.get_model() @@ -1000,7 +1000,7 @@ class AddNewContactWindow: self.uid_entry.grab_focus() group_names = [] for acct in accounts: - for g in gajim.groups[acct].keys(): + for g in app.groups[acct].keys(): if g not in helpers.special_groups and g not in group_names: group_names.append(g) group_names.sort() @@ -1011,7 +1011,7 @@ class AddNewContactWindow: self.group_comboboxentry.set_active(i) i += 1 - self.window.set_transient_for(gajim.interface.roster.window) + self.window.set_transient_for(app.interface.roster.window) self.window.show_all() if self.account: @@ -1030,27 +1030,27 @@ class AddNewContactWindow: self.account)) message_buffer.set_text(msg) - gajim.ged.register_event_handler('gateway-prompt-received', ged.GUI1, + app.ged.register_event_handler('gateway-prompt-received', ged.GUI1, self._nec_gateway_prompt_received) - gajim.ged.register_event_handler('presence-received', ged.GUI1, + app.ged.register_event_handler('presence-received', ged.GUI1, self._nec_presence_received) def on_add_new_contact_window_destroy(self, widget): if self.account: - location = gajim.interface.instances[self.account] + location = app.interface.instances[self.account] else: - location = gajim.interface.instances + location = app.interface.instances del location['add_contact'] - gajim.ged.remove_event_handler('presence-received', ged.GUI1, + app.ged.remove_event_handler('presence-received', ged.GUI1, self._nec_presence_received) - gajim.ged.remove_event_handler('gateway-prompt-received', ged.GUI1, + app.ged.remove_event_handler('gateway-prompt-received', ged.GUI1, self._nec_gateway_prompt_received) def on_register_button_clicked(self, widget): model = self.protocol_jid_combobox.get_model() row = self.protocol_jid_combobox.get_active() jid = model[row][0] - gajim.connections[self.account].request_register_agent_info(jid) + app.connections[self.account].request_register_agent_info(jid) def on_add_new_contact_window_key_press_event(self, widget, event): if event.keyval == Gdk.KEY_Escape: # ESCAPE @@ -1079,7 +1079,7 @@ class AddNewContactWindow: transport = model[row][0] if self.account and not self.jid_escaped: self.adding_jid = (jid, transport, type_) - gajim.connections[self.account].request_gateway_prompt( + app.connections[self.account].request_gateway_prompt( transport, jid) else: jid = jid.replace('@', '%') + '@' + transport @@ -1102,7 +1102,7 @@ class AddNewContactWindow: ErrorDialog(pritext, _('The user ID must not contain a resource.')) return - if jid == gajim.get_jid_from_account(self.account): + if jid == app.get_jid_from_account(self.account): pritext = _('Invalid User ID') ErrorDialog(pritext, _('You cannot add yourself to your roster.')) return @@ -1115,8 +1115,8 @@ class AddNewContactWindow: self.account = model[index][1] # Check if jid is already in roster - if jid in gajim.contacts.get_jid_list(self.account): - c = gajim.contacts.get_first_contact_from_jid(self.account, jid) + if jid in app.contacts.get_jid_list(self.account): + c = app.contacts.get_first_contact_from_jid(self.account, jid) if _('Not in Roster') not in c.groups and c.sub in ('both', 'to'): ErrorDialog(_('Contact already in roster'), _('This contact is already listed in your roster.')) @@ -1129,7 +1129,7 @@ class AddNewContactWindow: message = message_buffer.get_text(start_iter, end_iter, True) if self.save_message_checkbutton.get_active(): msg = helpers.to_one_line(message) - gajim.config.set_per('accounts', self.account, + app.config.set_per('accounts', self.account, 'subscription_request_msg', msg) else: message= '' @@ -1138,7 +1138,7 @@ class AddNewContactWindow: if group: groups = [group] auto_auth = self.auto_authorize_checkbutton.get_active() - gajim.interface.roster.req_sub(self, jid, message, self.account, + app.interface.roster.req_sub(self, jid, message, self.account, groups=groups, nickname=nickname, auto_auth=auto_auth) self.window.destroy() @@ -1227,7 +1227,7 @@ class AddNewContactWindow: model = self.protocol_jid_combobox.get_model() row = self.protocol_jid_combobox.get_active() jid = model[row][0] - contact = gajim.contacts.get_first_contact_from_jid( + contact = app.contacts.get_first_contact_from_jid( self.account, jid) if contact.show in ('offline', 'error'): self.subscription_table.hide() @@ -1262,7 +1262,7 @@ class AddNewContactWindow: self.add_button.set_sensitive(False) def _nec_presence_received(self, obj): - if gajim.jid_is_transport(obj.jid): + if app.jid_is_transport(obj.jid): if obj.old_show == 0 and obj.new_show > 1: self.transport_signed_in(obj.jid) elif obj.old_show > 1 and obj.new_show == 0: @@ -1294,9 +1294,9 @@ class AboutDialog(Gtk.AboutDialog): def __init__(self): Gtk.AboutDialog.__init__(self) - self.set_transient_for(gajim.interface.roster.window) + self.set_transient_for(app.interface.roster.window) self.set_name('Gajim') - self.set_version(gajim.version) + self.set_version(app.version) s = 'Copyright © 2003-2017 Gajim Team' self.set_copyright(s) copying_file_path = self.get_path('COPYING') @@ -1535,7 +1535,7 @@ class AspellDictError: _('You have to install %s dictionary to use spellchecking, or ' 'choose another language by setting the speller_language option.' '\n\nHighlighting misspelled words feature will not be used') % lang) - gajim.config.set('use_speller', False) + app.config.set('use_speller', False) class ConfirmationDialog(HigDialog): """ @@ -1578,8 +1578,8 @@ class NonModalConfirmationDialog(HigDialog): on_response_cancel=None): self.user_response_ok = on_response_ok self.user_response_cancel = on_response_cancel - if hasattr(gajim.interface, 'roster') and gajim.interface.roster: - parent = gajim.interface.roster.window + if hasattr(app.interface, 'roster') and app.interface.roster: + parent = app.interface.roster.window else: parent = None HigDialog.__init__(self, parent, Gtk.MessageType.QUESTION, @@ -1611,9 +1611,9 @@ class WarningDialog(HigDialog): """ def __init__(self, pritext, sectext='', transient_for=None): - if not transient_for and hasattr(gajim.interface, 'roster') and \ - gajim.interface.roster: - transient_for = gajim.interface.roster.window + if not transient_for and hasattr(app.interface, 'roster') and \ + app.interface.roster: + transient_for = app.interface.roster.window HigDialog.__init__(self, transient_for, Gtk.MessageType.WARNING, Gtk.ButtonsType.OK, pritext, sectext) self.set_modal(False) @@ -1627,8 +1627,8 @@ class InformationDialog(HigDialog): def __init__(self, pritext, sectext='', transient_for=None): if transient_for: parent = transient_for - elif hasattr(gajim.interface, 'roster') and gajim.interface.roster: - parent = gajim.interface.roster.window + elif hasattr(app.interface, 'roster') and app.interface.roster: + parent = app.interface.roster.window else: parent = None HigDialog.__init__(self, parent, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, @@ -1645,8 +1645,8 @@ class ErrorDialog(HigDialog): on_response_cancel=None, transient_for=None): if transient_for: parent = transient_for - elif hasattr(gajim.interface, 'roster') and gajim.interface.roster: - parent = gajim.interface.roster.window + elif hasattr(app.interface, 'roster') and app.interface.roster: + parent = app.interface.roster.window else: parent = None HigDialog.__init__(self, parent, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, @@ -1666,8 +1666,8 @@ class YesNoDialog(HigDialog): self.user_response_no = on_response_no if transient_for: parent = transient_for - elif hasattr(gajim.interface, 'roster') and gajim.interface.roster: - parent = gajim.interface.roster.window + elif hasattr(app.interface, 'roster') and app.interface.roster: + parent = app.interface.roster.window else: parent = None HigDialog.__init__(self, parent, type_, Gtk.ButtonsType.YES_NO, pritext, @@ -1755,8 +1755,8 @@ class ConfirmationDialogCheck(ConfirmationDialog): if transient_for: parent = transient_for - elif hasattr(gajim.interface, 'roster') and gajim.interface.roster: - parent = gajim.interface.roster.window + elif hasattr(app.interface, 'roster') and app.interface.roster: + parent = app.interface.roster.window else: parent = None HigDialog.__init__(self, parent, Gtk.MessageType.QUESTION, @@ -1810,8 +1810,8 @@ class ConfirmationDialogDoubleCheck(ConfirmationDialog): self.user_response_ok = on_response_ok self.user_response_cancel = on_response_cancel - if hasattr(gajim.interface, 'roster') and gajim.interface.roster: - parent = gajim.interface.roster.window + if hasattr(app.interface, 'roster') and app.interface.roster: + parent = app.interface.roster.window else: parent = None HigDialog.__init__(self, parent, Gtk.MessageType.QUESTION, @@ -1882,7 +1882,7 @@ class PlainConnectionDialog(ConfirmationDialogDoubleCheck): '(%(server)s) insecurely. This means conversations will not be ' 'encrypted, and is strongly discouraged.\nAre you sure you want ' 'to do that?') % {'account': account, - 'server': gajim.get_hostname_from_account(account)} + 'server': app.get_hostname_from_account(account)} checktext1 = _('Yes, I really want to connect insecurely') tooltip1 = _('Gajim will NOT connect unless you check this box') checktext2 = _('_Do not ask me again') @@ -1907,8 +1907,8 @@ class ConfirmationDialogDoubleRadio(ConfirmationDialog): self.user_response_ok = on_response_ok self.user_response_cancel = on_response_cancel - if hasattr(gajim.interface, 'roster') and gajim.interface.roster: - parent = gajim.interface.roster.window + if hasattr(app.interface, 'roster') and app.interface.roster: + parent = app.interface.roster.window else: parent = None HigDialog.__init__(self, parent, Gtk.MessageType.QUESTION, @@ -1970,8 +1970,8 @@ class FTOverwriteConfirmationDialog(ConfirmationDialog): on_response=None, transient_for=None): if transient_for: parent = transient_for - elif hasattr(gajim.interface, 'roster') and gajim.interface.roster: - parent = gajim.interface.roster.window + elif hasattr(app.interface, 'roster') and app.interface.roster: + parent = app.interface.roster.window else: parent = None HigDialog.__init__(self, parent, Gtk.MessageType.QUESTION, @@ -2024,7 +2024,7 @@ class CommonInputDialog: if transient_for: self.dialog.set_transient_for(transient_for) else: - self.dialog.set_transient_for(gajim.interface.roster.window) + self.dialog.set_transient_for(app.interface.roster.window) self.ok_handler = ok_handler okbutton = self.xml.get_object('okbutton') @@ -2153,36 +2153,36 @@ class ChangeNickDialog(InputDialogCheck): return True def setup_dialog(self): - self.gc_control = gajim.interface.msg_win_mgr.get_gc_control( + self.gc_control = app.interface.msg_win_mgr.get_gc_control( self.room_jid, self.account) if not self.gc_control and \ - self.room_jid in gajim.interface.minimized_controls[self.account]: + self.room_jid in app.interface.minimized_controls[self.account]: self.gc_control = \ - gajim.interface.minimized_controls[self.account][self.room_jid] + app.interface.minimized_controls[self.account][self.room_jid] if not self.gc_control: self.check_next() return label = self.xml.get_object('label') label.set_markup(self.prompt) self.set_entry(self.gc_control.nick + \ - gajim.config.get('gc_proposed_nick_char')) + app.config.get('gc_proposed_nick_char')) def check_next(self): if len(self.room_queue) == 0: self.cancel_handler = None self.dialog.destroy() - if 'change_nick_dialog' in gajim.interface.instances: - del gajim.interface.instances['change_nick_dialog'] + if 'change_nick_dialog' in app.interface.instances: + del app.interface.instances['change_nick_dialog'] return self.account, self.room_jid, self.prompt, self.change_nick = \ self.room_queue.pop(0) self.setup_dialog() - if gajim.new_room_nick is not None and not gajim.gc_connected[ + if app.new_room_nick is not None and not app.gc_connected[ self.account][self.room_jid] and self.gc_control.nick != \ - gajim.new_room_nick: + app.new_room_nick: self.dialog.hide() - self.on_ok(gajim.new_room_nick, True) + self.on_ok(app.new_room_nick, True) else: self.dialog.show() @@ -2202,10 +2202,10 @@ class ChangeNickDialog(InputDialogCheck): def on_ok(self, nick, is_checked): if is_checked: - gajim.new_room_nick = nick - gajim.connections[self.account].join_gc(nick, self.room_jid, None, + app.new_room_nick = nick + app.connections[self.account].join_gc(nick, self.room_jid, None, change_nick=self.change_nick) - if gajim.gc_connected[self.account][self.room_jid]: + if app.gc_connected[self.account][self.room_jid]: # We are changing nick, we will change self.nick when we receive # presence that inform that it works self.gc_control.new_nick = nick @@ -2317,7 +2317,7 @@ class SubscriptionRequestWindow: self.jid = jid self.account = account self.user_nick = user_nick - if len(gajim.connections) >= 2: + if len(app.connections) >= 2: prompt_text = \ _('Subscription request for account %(account)s from %(jid)s')\ % {'account': account, 'jid': self.jid} @@ -2332,9 +2332,9 @@ class SubscriptionRequestWindow: """ Close window """ - if self.jid in gajim.interface.instances[self.account]['sub_request']: + if self.jid in app.interface.instances[self.account]['sub_request']: # remove us from open windows - del gajim.interface.instances[self.account]['sub_request'][self.jid] + del app.interface.instances[self.account]['sub_request'][self.jid] def prepare_popup_menu(self): xml = gtkgui_helpers.get_gtk_builder('subscription_request_popup_menu.ui') @@ -2349,9 +2349,9 @@ class SubscriptionRequestWindow: """ Accept the request """ - gajim.connections[self.account].send_authorization(self.jid) + app.connections[self.account].send_authorization(self.jid) self.window.destroy() - contact = gajim.contacts.get_contact(self.account, self.jid) + contact = app.contacts.get_contact(self.account, self.jid) if not contact or _('Not in Roster') in contact.groups: AddNewContactWindow(self.account, self.jid, self.user_nick) @@ -2359,30 +2359,30 @@ class SubscriptionRequestWindow: """ Ask vcard """ - if self.jid in gajim.interface.instances[self.account]['infos']: - gajim.interface.instances[self.account]['infos'][self.jid].window.present() + if self.jid in app.interface.instances[self.account]['infos']: + app.interface.instances[self.account]['infos'][self.jid].window.present() else: - contact = gajim.contacts.create_contact(jid=self.jid, account=self.account) - gajim.interface.instances[self.account]['infos'][self.jid] = \ + contact = app.contacts.create_contact(jid=self.jid, account=self.account) + app.interface.instances[self.account]['infos'][self.jid] = \ vcard.VcardWindow(contact, self.account) # Remove jabber page - gajim.interface.instances[self.account]['infos'][self.jid].xml.\ + app.interface.instances[self.account]['infos'][self.jid].xml.\ get_object('information_notebook').remove_page(0) def on_start_chat_activate(self, widget): """ Open chat """ - gajim.interface.new_chat_from_jid(self.account, self.jid) + app.interface.new_chat_from_jid(self.account, self.jid) def on_deny_button_clicked(self, widget): """ Refuse the request """ - gajim.connections[self.account].refuse_authorization(self.jid) - contact = gajim.contacts.get_contact(self.account, self.jid) + app.connections[self.account].refuse_authorization(self.jid) + contact = app.contacts.get_contact(self.account, self.jid) if contact and _('Not in Roster') in contact.get_shown_groups(): - gajim.interface.roster.remove_contact(self.jid, self.account) + app.interface.roster.remove_contact(self.jid, self.account) self.window.destroy() def on_actions_button_clicked(self, widget): @@ -2405,13 +2405,13 @@ class JoinGroupchatWindow: """ self.window_account = None if account: - if room_jid != '' and room_jid in gajim.gc_connected[account] and \ - gajim.gc_connected[account][room_jid]: + if room_jid != '' and room_jid in app.gc_connected[account] and \ + app.gc_connected[account][room_jid]: ErrorDialog(_('You are already in group chat %s') % room_jid) raise GajimGeneralException('You are already in this group chat') if nick == '': - nick = gajim.nicks[account] - if gajim.connections[account].connected < 2: + nick = app.nicks[account] + if app.connections[account].connected < 2: ErrorDialog(_('You are not connected to the server'), _('You can not join a group chat unless you are connected.')) raise GajimGeneralException('You must be connected to join a groupchat') @@ -2431,9 +2431,9 @@ class JoinGroupchatWindow: account_combobox.set_active(-1) # Add accounts, set current as active if it matches 'account' - for acct in [a for a in gajim.connections if \ - gajim.account_is_connected(a)]: - if gajim.connections[acct].is_zeroconf: + for acct in [a for a in app.connections if \ + app.account_is_connected(a)]: + if app.connections[acct].is_zeroconf: continue liststore.append([acct]) if account and account == acct: @@ -2444,7 +2444,7 @@ class JoinGroupchatWindow: self._empty_required_widgets = [] self.window = self.xml.get_object('join_groupchat_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.window.set_transient_for(app.interface.roster.window) self._room_jid_entry = self.xml.get_object('room_jid_entry') self._nickname_entry = self.xml.get_object('nickname_entry') self._password_entry = self.xml.get_object('password_entry') @@ -2457,8 +2457,8 @@ class JoinGroupchatWindow: title = None if account: # now add us to open windows - gajim.interface.instances[account]['join_gc'] = self - if len(gajim.connections) > 1: + app.interface.instances[account]['join_gc'] = self + if len(app.connections) > 1: title = _('Join Group Chat with account %s') % account if title is None: title = _('Join Group Chat') @@ -2473,22 +2473,22 @@ class JoinGroupchatWindow: cell = Gtk.CellRendererText() self.recently_combobox.pack_start(cell, True) self.recently_combobox.add_attribute(cell, 'text', 0) - self.recently_groupchat = gajim.config.get('recently_groupchat').split() + self.recently_groupchat = app.config.get('recently_groupchat').split() server_list = [] # get the muc server of our server - if 'jabber' in gajim.connections[account].muc_jid: - server_list.append(gajim.connections[account].muc_jid['jabber']) + if 'jabber' in app.connections[account].muc_jid: + server_list.append(app.connections[account].muc_jid['jabber']) for g in self.recently_groupchat: - r_jid = gajim.get_jid_without_resource(g) - nick = gajim.get_resource_from_jid(g) + r_jid = app.get_jid_without_resource(g) + nick = app.get_resource_from_jid(g) if nick: show = '%(nick)s on %(room_jid)s' % {'nick': nick, 'room_jid': r_jid} else: show = r_jid liststore.append([show, g]) - server = gajim.get_server_from_jid(r_jid) + server = app.get_server_from_jid(r_jid) if server not in server_list and not server.startswith('irc'): server_list.append(server) @@ -2513,13 +2513,13 @@ class JoinGroupchatWindow: if len(self._empty_required_widgets): self.xml.get_object('join_button').set_sensitive(False) - if account and not gajim.connections[account].private_storage_supported: + if account and not app.connections[account].private_storage_supported: self.xml.get_object('bookmark_checkbutton').set_sensitive(False) self.requested_jid = None - gajim.ged.register_event_handler('agent-info-received', ged.GUI1, + app.ged.register_event_handler('agent-info-received', ged.GUI1, self._nec_agent_info_received) - gajim.ged.register_event_handler('agent-info-error-received', ged.GUI1, + app.ged.register_event_handler('agent-info-error-received', ged.GUI1, self._nec_agent_info_error_received) self.window.show_all() @@ -2528,14 +2528,14 @@ class JoinGroupchatWindow: """ Close window """ - gajim.ged.remove_event_handler('agent-info-received', ged.GUI1, + app.ged.remove_event_handler('agent-info-received', ged.GUI1, self._nec_agent_info_received) - gajim.ged.register_event_handler('agent-info-error-received', ged.GUI1, + app.ged.register_event_handler('agent-info-error-received', ged.GUI1, self._nec_agent_info_error_received) - if self.window_account and 'join_gc' in gajim.interface.instances[ + if self.window_account and 'join_gc' in app.interface.instances[ self.window_account]: # remove us from open windows - del gajim.interface.instances[self.window_account]['join_gc'] + del app.interface.instances[self.window_account]['join_gc'] def on_join_groupchat_window_key_press_event(self, widget, event): if event.keyval == Gdk.KEY_Escape: # ESCAPE @@ -2571,8 +2571,8 @@ class JoinGroupchatWindow: self.on_required_entry_changed(self._nickname_entry) def _set_room_jid(self, full_jid): - room_jid, nick = gajim.get_room_and_nick_from_fjid(full_jid) - room, server = gajim.get_name_and_server_from_jid(room_jid) + room_jid, nick = app.get_room_and_nick_from_fjid(full_jid) + room, server = app.get_name_and_server_from_jid(room_jid) self._room_jid_entry.set_text(room) model = self.server_comboboxtext.get_model() self.server_comboboxtext.get_child().set_text(server) @@ -2588,7 +2588,7 @@ class JoinGroupchatWindow: def on_browse_rooms_button_clicked(self, widget): server = self.server_comboboxtext.get_child().get_text() self.requested_jid = server - gajim.connections[self.account].discoverInfo(server) + app.connections[self.account].discoverInfo(server) def _nec_agent_info_error_received(self, obj): if obj.conn.name != self.account: @@ -2596,7 +2596,7 @@ class JoinGroupchatWindow: if obj.jid != self.requested_jid: return self.requested_jid = None - window = gajim.interface.instances[self.account]['join_gc'].window + window = app.interface.instances[self.account]['join_gc'].window ErrorDialog(_('Wrong server'), _('%s is not a groupchat server') % \ obj.jid, transient_for=window) @@ -2607,12 +2607,12 @@ class JoinGroupchatWindow: return self.requested_jid = None if nbxmpp.NS_MUC not in obj.features: - window = gajim.interface.instances[self.account]['join_gc'].window + window = app.interface.instances[self.account]['join_gc'].window ErrorDialog(_('Wrong server'), _('%s is not a groupchat server') % \ obj.jid, transient_for=window) return - if obj.jid in gajim.interface.instances[self.account]['disco']: - gajim.interface.instances[self.account]['disco'][obj.jid].window.\ + if obj.jid in app.interface.instances[self.account]['disco']: + app.interface.instances[self.account]['disco'][obj.jid].window.\ present() else: try: @@ -2675,8 +2675,8 @@ class JoinGroupchatWindow: _('The group chat JID contains invalid characters.')) return - if gajim.contacts.get_contact(self.account, room_jid) and \ - not gajim.contacts.get_contact(self.account, room_jid).is_groupchat(): + if app.contacts.get_contact(self.account, room_jid) and \ + not app.contacts.get_contact(self.account, room_jid).is_groupchat(): ErrorDialog(_('This is not a group chat'), _('%s is already in your roster. Please check if %s is a ' 'correct group chat name. If it is, delete it from your roster ' @@ -2689,7 +2689,7 @@ class JoinGroupchatWindow: self.recently_groupchat.insert(0, full_jid) if len(self.recently_groupchat) > 10: self.recently_groupchat = self.recently_groupchat[0:10] - gajim.config.set('recently_groupchat', + app.config.set('recently_groupchat', ' '.join(self.recently_groupchat)) if self.xml.get_object('bookmark_checkbutton').get_active(): @@ -2698,28 +2698,28 @@ class JoinGroupchatWindow: else: autojoin = '0' # Add as bookmark, with autojoin and not minimized - name = gajim.get_nick_from_jid(room_jid) - gajim.interface.add_gc_bookmark(self.account, name, room_jid, + name = app.get_nick_from_jid(room_jid) + app.interface.add_gc_bookmark(self.account, name, room_jid, autojoin, autojoin, password, nickname) if self.automatic: - gajim.automatic_rooms[self.account][room_jid] = self.automatic + app.automatic_rooms[self.account][room_jid] = self.automatic - gajim.interface.join_gc_room(self.account, room_jid, nickname, password) + app.interface.join_gc_room(self.account, room_jid, nickname, password) self.window.destroy() class SynchroniseSelectAccountDialog: def __init__(self, account): # 'account' can be None if we are about to create our first one - if not account or gajim.connections[account].connected < 2: + if not account or app.connections[account].connected < 2: ErrorDialog(_('You are not connected to the server'), _('Without a connection, you can not synchronise your contacts.')) raise GajimGeneralException('You are not connected to the server') self.account = account self.xml = gtkgui_helpers.get_gtk_builder('synchronise_select_account_dialog.ui') self.dialog = self.xml.get_object('synchronise_select_account_dialog') - self.dialog.set_transient_for(gajim.interface.instances['accounts'].window) + self.dialog.set_transient_for(app.interface.instances['accounts'].window) self.accounts_treeview = self.xml.get_object('accounts_treeview') model = Gtk.ListStore(str, str, bool) self.accounts_treeview.set_model(model) @@ -2745,13 +2745,13 @@ class SynchroniseSelectAccountDialog: """ model = self.accounts_treeview.get_model() model.clear() - for remote_account in gajim.connections: + for remote_account in app.connections: if remote_account == self.account: # Do not show the account we're sync'ing continue iter_ = model.append() model.set(iter_, 0, remote_account, 1, - gajim.get_hostname_from_account(remote_account)) + app.get_hostname_from_account(remote_account)) def on_cancel_button_clicked(self, widget): self.dialog.destroy() @@ -2763,7 +2763,7 @@ class SynchroniseSelectAccountDialog: return remote_account = model.get_value(iter_, 0) - if gajim.connections[remote_account].connected < 2: + if app.connections[remote_account].connected < 2: ErrorDialog(_('This account is not connected to the server'), _('You cannot synchronize with an account unless it is connected.')) return @@ -2816,9 +2816,9 @@ class SynchroniseSelectContactsDialog: model.clear() # recover local contacts - local_jid_list = gajim.contacts.get_contacts_jid_list(self.local_account) + local_jid_list = app.contacts.get_contacts_jid_list(self.local_account) - remote_jid_list = gajim.contacts.get_contacts_jid_list( + remote_jid_list = app.contacts.get_contacts_jid_list( self.remote_account) for remote_jid in remote_jid_list: if remote_jid not in local_jid_list: @@ -2836,11 +2836,11 @@ class SynchroniseSelectContactsDialog: # it is selected remote_jid = model[iter_][1] message = 'I\'m synchronizing my contacts from my %s account, could you please add this address to your contact list?' % \ - gajim.get_hostname_from_account(self.remote_account) - remote_contact = gajim.contacts.get_first_contact_from_jid( + app.get_hostname_from_account(self.remote_account) + remote_contact = app.contacts.get_first_contact_from_jid( self.remote_account, remote_jid) # keep same groups and same nickname - gajim.interface.roster.req_sub(self, remote_jid, message, + app.interface.roster.req_sub(self, remote_jid, message, self.local_account, groups = remote_contact.groups, nickname = remote_contact.name, auto_auth = True) iter_ = model.iter_next(iter_) @@ -2850,7 +2850,7 @@ class NewChatDialog(InputDialog): def __init__(self, account): self.account = account - if len(gajim.connections) > 1: + if len(app.connections) > 1: title = _('Start Chat with account %s') % account else: title = _('Start Chat') @@ -2866,7 +2866,7 @@ class NewChatDialog(InputDialog): keys = sorted(self.completion_dict.keys()) for jid in keys: contact = self.completion_dict[jid] - img = gajim.interface.jabber_state_images['16'][contact.show] + img = app.interface.jabber_state_images['16'][contact.show] liststore.append((img.get_pixbuf(), jid)) self.ok_handler = self.new_chat_response @@ -2874,14 +2874,14 @@ class NewChatDialog(InputDialog): okbutton.connect('clicked', self.on_okbutton_clicked) cancelbutton = self.xml.get_object('cancelbutton') cancelbutton.connect('clicked', self.on_cancelbutton_clicked) - self.dialog.set_transient_for(gajim.interface.roster.window) + self.dialog.set_transient_for(app.interface.roster.window) self.dialog.show_all() def new_chat_response(self, jid): """ Called when ok button is clicked """ - if gajim.connections[self.account].connected <= 1: + if app.connections[self.account].connected <= 1: #if offline or connecting ErrorDialog(_('Connection not available'), _('Please make sure you are connected with "%s".') % self.account) @@ -2898,12 +2898,12 @@ class NewChatDialog(InputDialog): except: ErrorDialog(_('Invalid JID'), _('Unable to parse "%s".') % jid) return - gajim.interface.new_chat_from_jid(self.account, jid) + app.interface.new_chat_from_jid(self.account, jid) class ChangePasswordDialog: def __init__(self, account, on_response, transient_for=None): # 'account' can be None if we are about to create our first one - if not account or gajim.connections[account].connected < 2: + if not account or app.connections[account].connected < 2: ErrorDialog(_('You are not connected to the server'), _('Without a connection, you can not change your password.')) raise GajimGeneralException('You are not connected to the server') @@ -2941,7 +2941,7 @@ class PopupNotificationWindow: self.account = account self.jid = jid self.msg_type = msg_type - self.index = len(gajim.interface.roster.popup_notification_windows) + self.index = len(app.interface.roster.popup_notification_windows) xml = gtkgui_helpers.get_gtk_builder('popup_notification_window.ui') self.window = xml.get_object('popup_notification_window') @@ -2953,7 +2953,7 @@ class PopupNotificationWindow: image = xml.get_object('notification_image') if not text: - text = gajim.get_name_from_jid(account, jid) # default value of text + text = app.get_name_from_jid(account, jid) # default value of text if not title: title = '' @@ -2971,25 +2971,25 @@ class PopupNotificationWindow: path_to_image = gtkgui_helpers.get_icon_path('gajim-chat_msg_recv', 48) if event_type == _('Contact Signed In'): - bg_color = gajim.config.get('notif_signin_color') + bg_color = app.config.get('notif_signin_color') elif event_type == _('Contact Signed Out'): - bg_color = gajim.config.get('notif_signout_color') + bg_color = app.config.get('notif_signout_color') elif event_type in (_('New Message'), _('New Single Message'), _('New Private Message'), _('New E-mail')): - bg_color = gajim.config.get('notif_message_color') + bg_color = app.config.get('notif_message_color') elif event_type == _('File Transfer Request'): - bg_color = gajim.config.get('notif_ftrequest_color') + bg_color = app.config.get('notif_ftrequest_color') elif event_type == _('File Transfer Error'): - bg_color = gajim.config.get('notif_fterror_color') + bg_color = app.config.get('notif_fterror_color') elif event_type in (_('File Transfer Completed'), _('File Transfer Stopped')): - bg_color = gajim.config.get('notif_ftcomplete_color') + bg_color = app.config.get('notif_ftcomplete_color') elif event_type == _('Groupchat Invitation'): - bg_color = gajim.config.get('notif_invite_color') + bg_color = app.config.get('notif_invite_color') elif event_type == _('Contact Changed Status'): - bg_color = gajim.config.get('notif_status_color') + bg_color = app.config.get('notif_status_color') else: # Unknown event! Shouldn't happen but deal with it - bg_color = gajim.config.get('notif_other_color') + bg_color = app.config.get('notif_other_color') popup_bg_color = Gdk.RGBA() Gdk.RGBA.parse(popup_bg_color, bg_color) close_button.override_background_color(Gtk.StateType.NORMAL, @@ -3003,14 +3003,14 @@ class PopupNotificationWindow: # position the window to bottom-right of screen window_width, self.window_height = self.window.get_size() - gajim.interface.roster.popups_notification_height += self.window_height - pos_x = gajim.config.get('notification_position_x') + app.interface.roster.popups_notification_height += self.window_height + pos_x = app.config.get('notification_position_x') if pos_x < 0: pos_x = Gdk.Screen.width() - window_width + pos_x + 1 - pos_y = gajim.config.get('notification_position_y') + pos_y = app.config.get('notification_position_y') if pos_y < 0: pos_y = Gdk.Screen.height() - \ - gajim.interface.roster.popups_notification_height + pos_y + 1 + app.interface.roster.popups_notification_height + pos_y + 1 self.window.move(pos_x, pos_y) xml.connect_signals(self) @@ -3026,30 +3026,30 @@ class PopupNotificationWindow: def adjust_height_and_move_popup_notification_windows(self): #remove - gajim.interface.roster.popups_notification_height -= self.window_height + app.interface.roster.popups_notification_height -= self.window_height self.window.destroy() - if len(gajim.interface.roster.popup_notification_windows) > self.index: + if len(app.interface.roster.popup_notification_windows) > self.index: # we want to remove the destroyed window from the list - gajim.interface.roster.popup_notification_windows.pop(self.index) + app.interface.roster.popup_notification_windows.pop(self.index) # move the rest of popup windows - gajim.interface.roster.popups_notification_height = 0 + app.interface.roster.popups_notification_height = 0 current_index = 0 - for window_instance in gajim.interface.roster.popup_notification_windows: + for window_instance in app.interface.roster.popup_notification_windows: window_instance.index = current_index current_index += 1 window_width, window_height = window_instance.window.get_size() - gajim.interface.roster.popups_notification_height += window_height + app.interface.roster.popups_notification_height += window_height window_instance.window.move(Gdk.Screen.width() - window_width, Gdk.Screen.height() - \ - gajim.interface.roster.popups_notification_height) + app.interface.roster.popups_notification_height) def on_popup_notification_window_button_press_event(self, widget, event): if event.button != 1: self.window.destroy() return - gajim.interface.handle_event(self.account, self.jid, self.msg_type) + app.interface.handle_event(self.account, self.jid, self.msg_type) self.adjust_height_and_move_popup_notification_windows() class SingleMessageWindow: @@ -3119,11 +3119,11 @@ class SingleMessageWindow: else: self.to_entry.set_text(to) - if gajim.config.get('use_speller') and HAS_GTK_SPELL and action == 'send': + if app.config.get('use_speller') and HAS_GTK_SPELL and action == 'send': try: - lang = gajim.config.get('speller_language') + lang = app.config.get('speller_language') if not lang: - lang = gajim.LANG + lang = app.LANG gtkspell.Spell(self.conversation_textview.tv, lang) gtkspell.Spell(self.message_textview, lang) except (GObject.GError, TypeError, RuntimeError, OSError): @@ -3143,7 +3143,7 @@ class SingleMessageWindow: keys = sorted(self.completion_dict.keys()) for jid in keys: contact = self.completion_dict[jid] - img = gajim.interface.jabber_state_images['16'][contact.show] + img = app.interface.jabber_state_images['16'][contact.show] liststore.append((img.get_pixbuf(), jid)) else: self.completion_dict = {} @@ -3151,26 +3151,26 @@ class SingleMessageWindow: # get window position and size from config gtkgui_helpers.resize_window(self.window, - gajim.config.get('single-msg-width'), - gajim.config.get('single-msg-height')) + app.config.get('single-msg-width'), + app.config.get('single-msg-height')) gtkgui_helpers.move_window(self.window, - gajim.config.get('single-msg-x-position'), - gajim.config.get('single-msg-y-position')) + app.config.get('single-msg-x-position'), + app.config.get('single-msg-y-position')) self.window.show_all() def on_single_message_window_destroy(self, widget): self.instances.remove(self) - c = gajim.contacts.get_contact_with_highest_priority(self.account, + c = app.contacts.get_contact_with_highest_priority(self.account, self.from_whom) if not c: # Groupchat is maybe already destroyed return if c.is_groupchat() and not self.from_whom in \ - gajim.interface.minimized_controls[self.account] and self.action == \ - 'receive' and gajim.events.get_nb_roster_events(self.account, + app.interface.minimized_controls[self.account] and self.action == \ + 'receive' and app.events.get_nb_roster_events(self.account, self.from_whom, types=['chat', 'normal']) == 0: - gajim.interface.roster.remove_groupchat(self.from_whom, self.account) + app.interface.roster.remove_groupchat(self.from_whom, self.account) def set_cursor_to_end(self): end_iter = self.message_tv_buffer.get_end_iter() @@ -3179,17 +3179,17 @@ class SingleMessageWindow: def save_pos(self): # save the window size and position x, y = self.window.get_position() - gajim.config.set('single-msg-x-position', x) - gajim.config.set('single-msg-y-position', y) + app.config.set('single-msg-x-position', x) + app.config.set('single-msg-y-position', y) width, height = self.window.get_size() - gajim.config.set('single-msg-width', width) - gajim.config.set('single-msg-height', height) + app.config.set('single-msg-width', width) + app.config.set('single-msg-height', height) def on_single_message_window_delete_event(self, window, ev): self.save_pos() def prepare_widgets_for(self, action): - if len(gajim.connections) > 1: + if len(app.connections) > 1: if action == 'send': title = _('Single Message using account %s') % self.account else: @@ -3270,7 +3270,7 @@ class SingleMessageWindow: self.count_chars_label.set_text(str(characters_no)) def send_single_message(self): - if gajim.connections[self.account].connected <= 1: + if app.connections[self.account].connected <= 1: # if offline or connecting ErrorDialog(_('Connection not available'), _('Please make sure you are connected with "%s".') % self.account) @@ -3309,13 +3309,13 @@ class SingleMessageWindow: return True if '/announce/' in to_whom_jid: - gajim.connections[self.account].send_motd(to_whom_jid, subject, + app.connections[self.account].send_motd(to_whom_jid, subject, message) continue recipient_list.append(to_whom_jid) - gajim.nec.push_outgoing_event(MessageOutgoingEvent(None, + app.nec.push_outgoing_event(MessageOutgoingEvent(None, account=self.account, jid=recipient_list, message=message, type_='normal', subject=subject, form_node=form_node)) @@ -3403,15 +3403,15 @@ class XMLConsoleWindow(Gtk.Window): self.connect('key_press_event', self.on_key_press_event) self.builder.connect_signals(self) - gajim.ged.register_event_handler('stanza-received', ged.GUI1, + app.ged.register_event_handler('stanza-received', ged.GUI1, self._nec_stanza_received) - gajim.ged.register_event_handler('stanza-sent', ged.GUI1, + app.ged.register_event_handler('stanza-sent', ged.GUI1, self._nec_stanza_sent) def create_tags(self): buffer_ = self.textview.get_buffer() - in_color = gajim.config.get('inmsgcolor') - out_color = gajim.config.get('outmsgcolor') + in_color = app.config.get('inmsgcolor') + out_color = app.config.get('outmsgcolor') tags = ['presence', 'message', 'stream', 'iq'] @@ -3454,7 +3454,7 @@ class XMLConsoleWindow(Gtk.Window): self.input.grab_focus() def on_send(self, *args): - if gajim.connections[self.account].connected <= 1: + if app.connections[self.account].connected <= 1: # if offline or connecting ErrorDialog(_('Connection not available'), _('Please make sure you are connected with "%s".') % \ @@ -3464,7 +3464,7 @@ class XMLConsoleWindow(Gtk.Window): begin_iter, end_iter = buffer_.get_bounds() stanza = buffer_.get_text(begin_iter, end_iter, True) if stanza: - gajim.connections[self.account].send_stanza(stanza) + app.connections[self.account].send_stanza(stanza) buffer_.set_text('') def on_input(self, button, *args): @@ -3503,10 +3503,10 @@ class XMLConsoleWindow(Gtk.Window): buffer_ = self.textview.get_buffer().set_text('') def on_destroy(self, *args): - del gajim.interface.instances[self.account]['xml_console'] - gajim.ged.remove_event_handler('stanza-received', ged.GUI1, + del app.interface.instances[self.account]['xml_console'] + app.ged.remove_event_handler('stanza-received', ged.GUI1, self._nec_stanza_received) - gajim.ged.remove_event_handler('stanza-sent', ged.GUI1, + app.ged.remove_event_handler('stanza-sent', ged.GUI1, self._nec_stanza_sent) def on_enable(self, switch, param): @@ -3690,7 +3690,7 @@ class RosterItemExchangeWindow: for jid in self.exchange_list: groups = '' is_in_roster = True - contact = gajim.contacts.get_contact_with_highest_priority( + contact = app.contacts.get_contact_with_highest_priority( self.account, jid) if not contact or _('Not in Roster') in contact.groups: is_in_roster = False @@ -3717,7 +3717,7 @@ class RosterItemExchangeWindow: groups = '' is_in_roster = True is_right = True - contact = gajim.contacts.get_contact_with_highest_priority( + contact = app.contacts.get_contact_with_highest_priority( self.account, jid) name = self.exchange_list[jid][0] if not contact: @@ -3747,7 +3747,7 @@ class RosterItemExchangeWindow: for jid in self.exchange_list: groups = '' is_in_roster = True - contact = gajim.contacts.get_contact_with_highest_priority( + contact = app.contacts.get_contact_with_highest_priority( self.account, jid) name = self.exchange_list[jid][0] if not contact: @@ -3794,10 +3794,10 @@ class RosterItemExchangeWindow: if groups == ['']: groups = [] jid = model[iter_][1] - if gajim.jid_is_transport(self.jid_from): - gajim.connections[self.account].automatically_added.append( + if app.jid_is_transport(self.jid_from): + app.connections[self.account].automatically_added.append( jid) - gajim.interface.roster.req_sub(self, jid, message, + app.interface.roster.req_sub(self, jid, message, self.account, groups=groups, nickname=model[iter_][2], auto_auth=True) iter_ = model.iter_next(iter_) @@ -3814,16 +3814,16 @@ class RosterItemExchangeWindow: groups = model[iter_][3].split(', ') if groups == ['']: groups = [] - for u in gajim.contacts.get_contact(self.account, jid): + for u in app.contacts.get_contact(self.account, jid): u.name = model[iter_][2] - gajim.connections[self.account].update_contact(jid, + app.connections[self.account].update_contact(jid, model[iter_][2], groups) self.draw_contact(jid, self.account) # Update opened chat - ctrl = gajim.interface.msg_win_mgr.get_control(jid, self.account) + ctrl = app.interface.msg_win_mgr.get_control(jid, self.account) if ctrl: ctrl.update_ui() - win = gajim.interface.msg_win_mgr.get_window(jid, + win = app.interface.msg_win_mgr.get_window(jid, self.account) win.redraw_tab(ctrl) win.show_title() @@ -3835,9 +3835,9 @@ class RosterItemExchangeWindow: a+=1 # it is selected jid = model[iter_][1] - gajim.connections[self.account].unsubscribe(jid) - gajim.interface.roster.remove_contact(jid, self.account) - gajim.contacts.remove_jid(self.account, jid) + app.connections[self.account].unsubscribe(jid) + app.interface.roster.remove_contact(jid, self.account) + app.contacts.remove_jid(self.account, jid) iter_ = model.iter_next(iter_) InformationDialog(i18n.ngettext('Removed %d contact', 'Removed %d contacts', a, a, a)) @@ -3867,10 +3867,10 @@ class Archiving313PreferencesWindow: self.window.set_title(_('Archiving Preferences for %s') % self.account) - gajim.ged.register_event_handler( + app.ged.register_event_handler( 'archiving-313-preferences-changed-received', ged.GUI1, self._nec_archiving_313_changed_received) - gajim.ged.register_event_handler( + app.ged.register_event_handler( 'archiving-error-received', ged.GUI1, self._nec_archiving_error) self.default_cb.set_active(0) @@ -3879,7 +3879,7 @@ class Archiving313PreferencesWindow: self.xml.connect_signals(self) self.idle_id = GLib.timeout_add_seconds(3, self._nec_archiving_error) - gajim.connections[self.account].request_archive_preferences() + app.connections[self.account].request_archive_preferences() def on_key_press_event(self, widget, event): if event.keyval == Gdk.KEY_Escape: @@ -3932,10 +3932,10 @@ class Archiving313PreferencesWindow: def on_add_item_button_clicked(self, widget): key_name = 'item_archiving_preferences' - if key_name in gajim.interface.instances[self.account]: - gajim.interface.instances[self.account][key_name].window.present() + if key_name in app.interface.instances[self.account]: + app.interface.instances[self.account][key_name].window.present() else: - gajim.interface.instances[self.account][key_name] = \ + app.interface.instances[self.account][key_name] = \ ItemArchiving313PreferencesWindow( self.account, self, self.window) @@ -3953,20 +3953,20 @@ class Archiving313PreferencesWindow: for item in self.archive_items_liststore: items.append((item[0].lower(), item[1].lower())) self.idle_id = GLib.timeout_add_seconds(3, self._nec_archiving_error) - gajim.connections[self.account]. \ + app.connections[self.account]. \ set_archive_preferences(items, default) def on_close_button_clicked(self, widget): self.window.destroy() def on_archiving_preferences_window_destroy(self, widget): - gajim.ged.remove_event_handler( + app.ged.remove_event_handler( 'archiving-313-preferences-changed-received', ged.GUI1, self._nec_archiving_313_changed_received) - gajim.ged.remove_event_handler( + app.ged.remove_event_handler( 'archiving-error-received', ged.GUI1, self._nec_archiving_error) - if 'archiving_preferences' in gajim.interface.instances[self.account]: - del gajim.interface.instances[self.account]['archiving_preferences'] + if 'archiving_preferences' in app.interface.instances[self.account]: + del app.interface.instances[self.account]['archiving_preferences'] class ItemArchiving313PreferencesWindow: @@ -4007,8 +4007,8 @@ class ItemArchiving313PreferencesWindow: def on_item_archiving_preferences_window_destroy(self, widget): key_name = 'item_archiving_preferences' - if key_name in gajim.interface.instances[self.account]: - del gajim.interface.instances[self.account][key_name] + if key_name in app.interface.instances[self.account]: + del app.interface.instances[self.account][key_name] class PrivacyListWindow: @@ -4060,7 +4060,7 @@ class PrivacyListWindow: _('Privacy List %s') % \ GLib.markup_escape_text(self.privacy_list_name)) - if len(gajim.connections) > 1: + if len(app.connections) > 1: title = _('Privacy List for %s') % self.account else: title = _('Privacy List') @@ -4073,7 +4073,7 @@ class PrivacyListWindow: # set jabber id completion jids_list_store = Gtk.ListStore(GObject.TYPE_STRING) - for jid in gajim.contacts.get_jid_list(self.account): + for jid in app.contacts.get_jid_list(self.account): jids_list_store.append([jid]) jid_entry_completion = Gtk.EntryCompletion() jid_entry_completion.set_text_column(0) @@ -4085,7 +4085,7 @@ class PrivacyListWindow: model = self.edit_type_group_combobox.get_model() count = 0 - for group in gajim.groups[self.account]: + for group in app.groups[self.account]: self.list_of_groups[group] = count count += 1 model.append([group]) @@ -4093,9 +4093,9 @@ class PrivacyListWindow: self.window.set_title(title) - gajim.ged.register_event_handler('privacy-list-received', ged.GUI1, + app.ged.register_event_handler('privacy-list-received', ged.GUI1, self._nec_privacy_list_received) - gajim.ged.register_event_handler('privacy-list-active-default', + app.ged.register_event_handler('privacy-list-active-default', ged.GUI1, self._nec_privacy_list_active_default) self.window.show_all() @@ -4109,11 +4109,11 @@ class PrivacyListWindow: def on_privacy_list_edit_window_destroy(self, widget): key_name = 'privacy_list_%s' % self.privacy_list_name - if key_name in gajim.interface.instances[self.account]: - del gajim.interface.instances[self.account][key_name] - gajim.ged.remove_event_handler('privacy-list-received', ged.GUI1, + if key_name in app.interface.instances[self.account]: + del app.interface.instances[self.account][key_name] + app.ged.remove_event_handler('privacy-list-received', ged.GUI1, self._nec_privacy_list_received) - gajim.ged.remove_event_handler('privacy-list-active-default', + app.ged.remove_event_handler('privacy-list-active-default', ged.GUI1, self._nec_privacy_list_active_default) def _nec_privacy_list_active_default(self, obj): @@ -4161,7 +4161,7 @@ class PrivacyListWindow: self.privacy_list_active_checkbutton.set_sensitive(True) self.privacy_list_default_checkbutton.set_sensitive(True) self.reset_fields() - gajim.connections[self.account].get_active_default_lists() + app.connections[self.account].get_active_default_lists() def _nec_privacy_list_received(self, obj): if obj.conn.name != self.account: @@ -4171,7 +4171,7 @@ class PrivacyListWindow: self.privacy_list_received(obj.rules) def refresh_rules(self): - gajim.connections[self.account].get_privacy_list(self.privacy_list_name) + app.connections[self.account].get_privacy_list(self.privacy_list_name) def on_delete_rule_button_clicked(self, widget): model = self.list_of_rules_combobox.get_model() @@ -4181,13 +4181,13 @@ class PrivacyListWindow: for rule in self.global_rules: if rule != _rule: tags.append(self.global_rules[rule]) - gajim.connections[self.account].set_privacy_list( + app.connections[self.account].set_privacy_list( self.privacy_list_name, tags) self.privacy_list_received(tags) self.add_edit_vbox.hide() if not tags: # we removed latest rule - if 'privacy_lists' in gajim.interface.instances[self.account]: - win = gajim.interface.instances[self.account]['privacy_lists'] + if 'privacy_lists' in app.interface.instances[self.account]: + win = app.interface.instances[self.account]['privacy_lists'] win.remove_privacy_list_from_combobox(self.privacy_list_name) win.draw_widgets() @@ -4275,17 +4275,17 @@ class PrivacyListWindow: def on_privacy_list_active_checkbutton_toggled(self, widget): if widget.get_active(): - gajim.connections[self.account].set_active_list( + app.connections[self.account].set_active_list( self.privacy_list_name) else: - gajim.connections[self.account].set_active_list(None) + app.connections[self.account].set_active_list(None) def on_privacy_list_default_checkbutton_toggled(self, widget): if widget.get_active(): - gajim.connections[self.account].set_default_list( + app.connections[self.account].set_default_list( self.privacy_list_name) else: - gajim.connections[self.account].set_default_list(None) + app.connections[self.account].set_default_list(None) def on_new_rule_button_clicked(self, widget): self.reset_fields() @@ -4357,12 +4357,12 @@ class PrivacyListWindow: else: tags.append(current_tags) - gajim.connections[self.account].set_privacy_list( + app.connections[self.account].set_privacy_list( self.privacy_list_name, tags) self.refresh_rules() self.add_edit_vbox.hide() - if 'privacy_lists' in gajim.interface.instances[self.account]: - win = gajim.interface.instances[self.account]['privacy_lists'] + if 'privacy_lists' in app.interface.instances[self.account]: + win = app.interface.instances[self.account]['privacy_lists'] win.add_privacy_list_to_combobox(self.privacy_list_name) win.draw_widgets() @@ -4405,16 +4405,16 @@ class PrivacyListsWindow: self.enabled = True - if len(gajim.connections) > 1: + if len(app.connections) > 1: title = _('Privacy Lists for %s') % self.account else: title = _('Privacy Lists') self.window.set_title(title) - gajim.ged.register_event_handler('privacy-lists-received', ged.GUI1, + app.ged.register_event_handler('privacy-lists-received', ged.GUI1, self._nec_privacy_lists_received) - gajim.ged.register_event_handler('privacy-lists-removed', ged.GUI1, + app.ged.register_event_handler('privacy-lists-removed', ged.GUI1, self._nec_privacy_lists_removed) self.window.show_all() @@ -4426,11 +4426,11 @@ class PrivacyListsWindow: self.window.destroy() def on_privacy_lists_first_window_destroy(self, widget): - if 'privacy_lists' in gajim.interface.instances[self.account]: - del gajim.interface.instances[self.account]['privacy_lists'] - gajim.ged.remove_event_handler('privacy-lists-received', ged.GUI1, + if 'privacy_lists' in app.interface.instances[self.account]: + del app.interface.instances[self.account]['privacy_lists'] + app.ged.remove_event_handler('privacy-lists-received', ged.GUI1, self._nec_privacy_lists_received) - gajim.ged.remove_event_handler('privacy-lists-removed', ged.GUI1, + app.ged.remove_event_handler('privacy-lists-removed', ged.GUI1, self._nec_privacy_lists_removed) def remove_privacy_list_from_combobox(self, privacy_list): @@ -4472,7 +4472,7 @@ class PrivacyListsWindow: def on_delete_privacy_list_button_clicked(self, widget): active_list = self.privacy_lists_save[ self.list_of_privacy_lists_combobox.get_active()] - gajim.connections[self.account].del_privacy_list(active_list) + app.connections[self.account].del_privacy_list(active_list) def privacy_list_removed(self, active_list): self.privacy_lists_save.remove(active_list) @@ -4497,7 +4497,7 @@ class PrivacyListsWindow: self.privacy_lists_received(obj.lists_list) def privacy_lists_refresh(self): - gajim.connections[self.account].get_privacy_lists() + app.connections[self.account].get_privacy_lists() def on_new_privacy_list_button_clicked(self, widget): name = self.new_privacy_list_entry.get_text() @@ -4507,10 +4507,10 @@ class PrivacyListsWindow: transient_for=self.window) return key_name = 'privacy_list_%s' % name - if key_name in gajim.interface.instances[self.account]: - gajim.interface.instances[self.account][key_name].window.present() + if key_name in app.interface.instances[self.account]: + app.interface.instances[self.account][key_name].window.present() else: - gajim.interface.instances[self.account][key_name] = \ + app.interface.instances[self.account][key_name] = \ PrivacyListWindow(self.account, name, 'NEW') self.new_privacy_list_entry.set_text('') @@ -4521,10 +4521,10 @@ class PrivacyListsWindow: name = self.privacy_lists_save[ self.list_of_privacy_lists_combobox.get_active()] key_name = 'privacy_list_%s' % name - if key_name in gajim.interface.instances[self.account]: - gajim.interface.instances[self.account][key_name].window.present() + if key_name in app.interface.instances[self.account]: + app.interface.instances[self.account][key_name].window.present() else: - gajim.interface.instances[self.account][key_name] = \ + app.interface.instances[self.account][key_name] = \ PrivacyListWindow(self.account, name, 'EDIT') class InvitationReceivedDialog: @@ -4537,7 +4537,7 @@ class InvitationReceivedDialog: self.is_continued = is_continued self.contact_fjid = contact_fjid - jid = gajim.get_jid_without_resource(contact_fjid) + jid = app.get_jid_without_resource(contact_fjid) pritext = _('''You are invited to a groupchat''') #Don't translate $Contact @@ -4546,7 +4546,7 @@ class InvitationReceivedDialog: else: sectext = _('$Contact has invited you to group chat %(room_jid)s')\ % {'room_jid': room_jid} - contact = gajim.contacts.get_first_contact_from_jid(account, jid) + contact = app.contacts.get_first_contact_from_jid(account, jid) contact_text = contact and contact.name or jid sectext = i18n.direction_mark + sectext.replace('$Contact', contact_text) @@ -4560,8 +4560,8 @@ class InvitationReceivedDialog: def on_yes(checked, text): try: if self.is_continued: - gajim.interface.join_gc_room(self.account, self.room_jid, - gajim.nicks[self.account], self.password, + app.interface.join_gc_room(self.account, self.room_jid, + app.nicks[self.account], self.password, is_continued=True) else: JoinGroupchatWindow(self.account, self.room_jid, @@ -4570,7 +4570,7 @@ class InvitationReceivedDialog: pass def on_no(text): - gajim.connections[account].decline_invitation(self.room_jid, + app.connections[account].decline_invitation(self.room_jid, self.contact_fjid, text) dlg = YesNoDialog(pritext, sectext, @@ -4624,7 +4624,7 @@ class ClientCertChooserDialog(FileChooserDialog): FileChooserDialog.__init__(self, title_text=_('Choose Client Cert #PCKS12'), - transient_for=gajim.interface.instances['accounts'].window, + transient_for=app.interface.instances['accounts'].window, action=Gtk.FileChooserAction.OPEN, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK), @@ -4670,7 +4670,7 @@ class SoundChooserDialog(FileChooserDialog): buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK), default_response=Gtk.ResponseType.OK, - current_folder=gajim.config.get('last_sounds_dir'), + current_folder=app.config.get('last_sounds_dir'), on_response_ok=(on_ok, on_response_ok), on_response_cancel=on_response_cancel, transient_for=transient_for) @@ -4906,12 +4906,12 @@ class TransformChatToMUC: self.server_list_comboboxentry.add_attribute(cell, 'text', 0) # get the muc server of our server - if 'jabber' in gajim.connections[account].muc_jid: - server_list.append(gajim.connections[account].muc_jid['jabber']) + if 'jabber' in app.connections[account].muc_jid: + server_list.append(app.connections[account].muc_jid['jabber']) # add servers or recently joined groupchats - recently_groupchat = gajim.config.get('recently_groupchat').split() + recently_groupchat = app.config.get('recently_groupchat').split() for g in recently_groupchat: - server = gajim.get_server_from_jid(g) + server = app.get_server_from_jid(g) if server not in server_list and not server.startswith('irc'): server_list.append(server) # add a default server @@ -4942,23 +4942,23 @@ class TransformChatToMUC: # transports, zeroconf contacts, minimized groupchats def invitable(contact, contact_transport=None): return (contact.jid not in self.auto_jids and - contact.jid != gajim.get_jid_from_account(self.account) and - contact.jid not in gajim.interface.minimized_controls[account] and + contact.jid != app.get_jid_from_account(self.account) and + contact.jid not in app.interface.minimized_controls[account] and not contact.is_transport() and contact_transport in ('jabber', None)) # set jabber id and pseudos - for account in gajim.contacts.get_accounts(): - if gajim.connections[account].is_zeroconf: + for account in app.contacts.get_accounts(): + if app.connections[account].is_zeroconf: continue - for jid in gajim.contacts.get_jid_list(account): - contact = gajim.contacts.get_contact_with_highest_priority( + for jid in app.contacts.get_jid_list(account): + contact = app.contacts.get_contact_with_highest_priority( account, jid) - contact_transport = gajim.get_transport_name_from_jid(jid) + contact_transport = app.get_transport_name_from_jid(jid) # Add contact if it can be invited if invitable(contact, contact_transport) and \ contact.show not in ('offline', 'error'): - img = gajim.interface.jabber_state_images['16'][contact.show] + img = app.interface.jabber_state_images['16'][contact.show] name = contact.name if name == '': name = jid.split('@')[0] @@ -4968,9 +4968,9 @@ class TransformChatToMUC: path = self.store.get_path(iter_) self.guests_treeview.get_selection().select_path(path) - gajim.ged.register_event_handler('unique-room-id-supported', ged.GUI1, + app.ged.register_event_handler('unique-room-id-supported', ged.GUI1, self._nec_unique_room_id_supported) - gajim.ged.register_event_handler('unique-room-id-not-supported', + app.ged.register_event_handler('unique-room-id-not-supported', ged.GUI1, self._nec_unique_room_id_not_supported) # show all @@ -4979,9 +4979,9 @@ class TransformChatToMUC: self.xml.connect_signals(self) def on_chat_to_muc_window_destroy(self, widget): - gajim.ged.remove_event_handler('unique-room-id-supported', ged.GUI1, + app.ged.remove_event_handler('unique-room-id-supported', ged.GUI1, self._nec_unique_room_id_supported) - gajim.ged.remove_event_handler('unique-room-id-not-supported', ged.GUI1, + app.ged.remove_event_handler('unique-room-id-not-supported', ged.GUI1, self._nec_unique_room_id_not_supported) self.instances.remove(self) @@ -4995,7 +4995,7 @@ class TransformChatToMUC: server = model[row][0].strip() if server == '': return - gajim.connections[self.account].check_unique_room_id_support(server, self) + app.connections[self.account].check_unique_room_id_support(server, self) def _nec_unique_room_id_supported(self, obj): if obj.instance != self: @@ -5008,11 +5008,11 @@ class TransformChatToMUC: for guest in self.auto_jids: guest_list.append(guest) room_jid = obj.room_id + '@' + obj.server - gajim.automatic_rooms[self.account][room_jid] = {} - gajim.automatic_rooms[self.account][room_jid]['invities'] = guest_list - gajim.automatic_rooms[self.account][room_jid]['continue_tag'] = True - gajim.interface.join_gc_room(self.account, room_jid, - gajim.nicks[self.account], None, is_continued=True) + app.automatic_rooms[self.account][room_jid] = {} + app.automatic_rooms[self.account][room_jid]['invities'] = guest_list + app.automatic_rooms[self.account][room_jid]['continue_tag'] = True + app.interface.join_gc_room(self.account, room_jid, + app.nicks[self.account], None, is_continued=True) self.window.destroy() def on_cancel_button_clicked(self, widget): @@ -5021,7 +5021,7 @@ class TransformChatToMUC: def _nec_unique_room_id_not_supported(self, obj): if obj.instance != self: return - obj.room_id = gajim.nicks[self.account].lower().replace(' ', '') + \ + obj.room_id = app.nicks[self.account].lower().replace(' ', '') + \ str(randrange(9999999)) self._nec_unique_room_id_supported(obj) @@ -5074,8 +5074,8 @@ class VoIPCallReceivedDialog(object): xml = gtkgui_helpers.get_gtk_builder('voip_call_received_dialog.ui') xml.connect_signals(self) - jid = gajim.get_jid_without_resource(self.fjid) - contact = gajim.contacts.get_first_contact_from_jid(account, jid) + jid = app.get_jid_without_resource(self.fjid) + contact = app.contacts.get_first_contact_from_jid(account, jid) if contact and contact.name: self.contact_text = '%s (%s)' % (contact.name, jid) else: @@ -5132,18 +5132,18 @@ class VoIPCallReceivedDialog(object): def on_voip_call_received_messagedialog_response(self, dialog, response): # we've got response from user, either stop connecting or accept the call - session = gajim.connections[self.account].get_jingle_session(self.fjid, + session = app.connections[self.account].get_jingle_session(self.fjid, self.sid) if not session: dialog.destroy() return if response == Gtk.ResponseType.YES: #TODO: Ensure that ctrl.contact.resource == resource - jid = gajim.get_jid_without_resource(self.fjid) - resource = gajim.get_resource_from_jid(self.fjid) - ctrl = (gajim.interface.msg_win_mgr.get_control(self.fjid, self.account) - or gajim.interface.msg_win_mgr.get_control(jid, self.account) - or gajim.interface.new_chat_from_jid(self.account, jid)) + jid = app.get_jid_without_resource(self.fjid) + resource = app.get_resource_from_jid(self.fjid) + ctrl = (app.interface.msg_win_mgr.get_control(self.fjid, self.account) + or app.interface.msg_win_mgr.get_control(jid, self.account) + or app.interface.new_chat_from_jid(self.account, jid)) # Chat control opened, update content's status audio = session.get_content('audio') @@ -5153,7 +5153,7 @@ class VoIPCallReceivedDialog(object): if video and not video.negotiated: video_hbox = ctrl.xml.get_object('video_hbox') video_hbox.set_no_show_all(False) - if gajim.config.get('video_see_self'): + if app.config.get('video_see_self'): fixed = ctrl.xml.get_object('outgoing_fixed') fixed.set_no_show_all(False) video_hbox.show_all() @@ -5166,7 +5166,7 @@ class VoIPCallReceivedDialog(object): get_property('window').get_xid() content = session.get_content('video') # move outgoing stream to chat window - if gajim.config.get('video_see_self'): + if app.config.get('video_see_self'): ctrl.xml.get_object('outgoing_drawingarea').realize() if os.name == 'nt': out_xid = ctrl.xml.get_object('outgoing_drawingarea').\ diff --git a/gajim/disco.py b/gajim/disco.py index 940ba19f2..43f8c29ad 100644 --- a/gajim/disco.py +++ b/gajim/disco.py @@ -59,7 +59,7 @@ from gajim import adhoc_commands from gajim import search_window from gajim import gui_menu_builder -from gajim.common import gajim +from gajim.common import app import nbxmpp from gajim.common.exceptions import GajimGeneralException from gajim.common import helpers @@ -264,23 +264,23 @@ class ServicesCache: self._info = CacheDictionary(0, getrefresh = False) self._subscriptions = CacheDictionary(5, getrefresh=False) self._cbs = {} - gajim.ged.register_event_handler('agent-items-received', ged.GUI1, + app.ged.register_event_handler('agent-items-received', ged.GUI1, self._nec_agent_items_received) - gajim.ged.register_event_handler('agent-items-error-received', ged.GUI1, + app.ged.register_event_handler('agent-items-error-received', ged.GUI1, self._nec_agent_items_error_received) - gajim.ged.register_event_handler('agent-info-received', ged.GUI1, + app.ged.register_event_handler('agent-info-received', ged.GUI1, self._nec_agent_info_received) - gajim.ged.register_event_handler('agent-info-error-received', ged.GUI1, + app.ged.register_event_handler('agent-info-error-received', ged.GUI1, self._nec_agent_info_error_received) def __del__(self): - gajim.ged.remove_event_handler('agent-items-received', ged.GUI1, + app.ged.remove_event_handler('agent-items-received', ged.GUI1, self._nec_agent_items_received) - gajim.ged.remove_event_handler('agent-items-error-received', ged.GUI1, + app.ged.remove_event_handler('agent-items-error-received', ged.GUI1, self._nec_agent_items_error_received) - gajim.ged.remove_event_handler('agent-info-received', ged.GUI1, + app.ged.remove_event_handler('agent-info-received', ged.GUI1, self._nec_agent_info_received) - gajim.ged.remove_event_handler('agent-info-error-received', ged.GUI1, + app.ged.remove_event_handler('agent-info-error-received', ged.GUI1, self._nec_agent_info_error_received) def cleanup(self): @@ -397,7 +397,7 @@ class ServicesCache: self._cbs[cbkey].append(cb) else: self._cbs[cbkey] = [cb] - gajim.connections[self.account].discoverInfo(jid, node) + app.connections[self.account].discoverInfo(jid, node) def get_items(self, jid, node, cb, force=False, nofetch=False, args=()): """ @@ -421,7 +421,7 @@ class ServicesCache: self._cbs[cbkey].append(cb) else: self._cbs[cbkey] = [cb] - gajim.connections[self.account].discoverItems(jid, node) + app.connections[self.account].discoverItems(jid, node) def _nec_agent_info_received(self, obj): """ @@ -521,7 +521,7 @@ class ServiceDiscoveryWindow(object): self._account = account self.parent = parent if not jid: - jid = gajim.config.get_per('accounts', account, 'hostname') + jid = app.config.get_per('accounts', account, 'hostname') node = '' self.jid = None @@ -532,17 +532,17 @@ class ServiceDiscoveryWindow(object): self.reloading = False # Check connection - if gajim.connections[account].connected < 2: + if app.connections[account].connected < 2: dialogs.ErrorDialog(_('You are not connected to the server'), _('Without a connection, you can not browse available services')) raise RuntimeError('You must be connected to browse services') # Get a ServicesCache object. try: - self.cache = gajim.connections[account].services_cache + self.cache = app.connections[account].services_cache except AttributeError: self.cache = ServicesCache(account) - gajim.connections[account].services_cache = self.cache + app.connections[account].services_cache = self.cache if initial_identities: self.cache._on_agent_info(jid, node, initial_identities, [], None) @@ -572,7 +572,7 @@ _('Without a connection, you can not browse available services')) self.address_comboboxtext_entry = self.xml.get_object( 'address_entry') - self.latest_addresses = gajim.config.get( + self.latest_addresses = app.config.get( 'latest_disco_addresses').split() if jid in self.latest_addresses: self.latest_addresses.remove(jid) @@ -630,9 +630,9 @@ _('Without a connection, you can not browse available services')) self.banner_icon.hide() # Just clearing it doesn't work def _set_window_banner_text(self, text, text_after = None): - theme = gajim.config.get('roster_theme') - bannerfont = gajim.config.get_per('themes', theme, 'bannerfont') - bannerfontattrs = gajim.config.get_per('themes', theme, + theme = app.config.get('roster_theme') + bannerfont = app.config.get_per('themes', theme, 'bannerfont') + bannerfontattrs = app.config.get_per('themes', theme, 'bannerfontattrs') if bannerfont: @@ -671,8 +671,8 @@ _('Without a connection, you can not browse available services')) # self.browser._get_agent_address() would break when no browser. addr = get_agent_address(self.jid, self.node) - if addr in gajim.interface.instances[self.account]['disco']: - del gajim.interface.instances[self.account]['disco'][addr] + if addr in app.interface.instances[self.account]['disco']: + del app.interface.instances[self.account]['disco'][addr] if self.browser: self.window.hide() @@ -710,10 +710,10 @@ _('Without a connection, you can not browse available services')) # Update the window list if self.jid: old_addr = get_agent_address(self.jid, self.node) - if old_addr in gajim.interface.instances[self.account]['disco']: - del gajim.interface.instances[self.account]['disco'][old_addr] + if old_addr in app.interface.instances[self.account]['disco']: + del app.interface.instances[self.account]['disco'][old_addr] addr = get_agent_address(jid, node) - gajim.interface.instances[self.account]['disco'][addr] = self + app.interface.instances[self.account]['disco'][addr] = self # We need to store these, self.browser is not always available. self.jid = jid self.node = node @@ -752,7 +752,7 @@ _('Without a connection, you can not browse available services')) Open an agent. By default, this happens in a new window """ try: - win = gajim.interface.instances[self.account]['disco']\ + win = app.interface.instances[self.account]['disco']\ [get_agent_address(jid, node)] win.window.present() return @@ -802,7 +802,7 @@ _('Without a connection, you can not browse available services')) self.address_comboboxtext.get_model().clear() for j in self.latest_addresses: self.address_comboboxtext.append_text(j) - gajim.config.set('latest_disco_addresses', + app.config.set('latest_disco_addresses', ' '.join(self.latest_addresses)) self.travel(jid, '') @@ -1187,7 +1187,7 @@ class ToplevelAgentBrowser(AgentBrowser): descr = "%s" % addr # Guess which kind of service this is identities = [] - type_ = gajim.get_transport_name_from_jid(self.jid, + type_ = app.get_transport_name_from_jid(self.jid, use_config_setting=False) if type_: identity = {'category': '_jid', 'type': type_} @@ -1227,8 +1227,8 @@ class ToplevelAgentBrowser(AgentBrowser): # Normal/succes cell.set_property('foreground_set', False) else: - theme = gajim.config.get('roster_theme') - bgcolor = gajim.config.get_per('themes', theme, 'groupbgcolor') + theme = app.config.get('roster_theme') + bgcolor = app.config.get_per('themes', theme, 'groupbgcolor') if bgcolor: cell.set_property('cell_background_set', True) cell.set_property('foreground_set', False) @@ -1352,19 +1352,19 @@ class ToplevelAgentBrowser(AgentBrowser): if not iter_: return service = model[iter_][0] - if service in gajim.interface.instances[self.account]['search']: - gajim.interface.instances[self.account]['search'][service].window.\ + if service in app.interface.instances[self.account]['search']: + app.interface.instances[self.account]['search'][service].window.\ present() else: - gajim.interface.instances[self.account]['search'][service] = \ + app.interface.instances[self.account]['search'][service] = \ search_window.SearchWindow(self.account, service) def cleanup(self): AgentBrowser.cleanup(self) def update_theme(self): - theme = gajim.config.get('roster_theme') - bgcolor = gajim.config.get_per('themes', theme, 'groupbgcolor') + theme = app.config.get('roster_theme') + bgcolor = app.config.get_per('themes', theme, 'groupbgcolor') if bgcolor: self._renderer.set_property('cell-background', bgcolor) self.window.services_treeview.queue_draw() @@ -1390,7 +1390,7 @@ class ToplevelAgentBrowser(AgentBrowser): return jid = model[iter_][0] if jid: - gajim.connections[self.account].request_register_agent_info(jid) + app.connections[self.account].request_register_agent_info(jid) self.window.destroy(chain = True) def on_join_button_clicked(self, widget): @@ -1402,13 +1402,13 @@ class ToplevelAgentBrowser(AgentBrowser): if not iter_: return service = model[iter_][0] - if 'join_gc' not in gajim.interface.instances[self.account]: + if 'join_gc' not in app.interface.instances[self.account]: try: dialogs.JoinGroupchatWindow(self.account, service) except GajimGeneralException: pass else: - gajim.interface.instances[self.account]['join_gc'].window.present() + app.interface.instances[self.account]['join_gc'].window.present() def update_actions(self): if self.execute_button: @@ -1435,7 +1435,7 @@ class ToplevelAgentBrowser(AgentBrowser): # Guess what kind of service we're dealing with if self.browse_button: jid = model[iter_][0] - type_ = gajim.get_transport_name_from_jid(jid, + type_ = app.get_transport_name_from_jid(jid, use_config_setting = False) if type_: identity = {'category': '_jid', 'type': type_} @@ -1460,9 +1460,9 @@ class ToplevelAgentBrowser(AgentBrowser): jid != self.jid: # We can register this agent registered_transports = [] - jid_list = gajim.contacts.get_jid_list(self.account) + jid_list = app.contacts.get_jid_list(self.account) for jid_ in jid_list: - contact = gajim.contacts.get_first_contact_from_jid( + contact = app.contacts.get_first_contact_from_jid( self.account, jid_) if _('Transports') in contact.groups: registered_transports.append(jid_) @@ -1602,7 +1602,7 @@ class ToplevelAgentBrowser(AgentBrowser): descr = "%s" % addr # Guess which kind of service this is identities = [] - type_ = gajim.get_transport_name_from_jid(jid, + type_ = app.get_transport_name_from_jid(jid, use_config_setting = False) if type_: identity = {'category': '_jid', 'type': type_} @@ -1774,7 +1774,7 @@ class MucBrowser(AgentBrowser): model, iter = self.window.services_treeview.get_selection().get_selected() if not iter: return - name = gajim.config.get_per('accounts', self.account, 'name') + name = app.config.get_per('accounts', self.account, 'name') room_jid = model[iter][0] bm = { 'name': room_jid.split('@')[0], @@ -1785,15 +1785,15 @@ class MucBrowser(AgentBrowser): 'nick': name } - for bookmark in gajim.connections[self.account].bookmarks: + for bookmark in app.connections[self.account].bookmarks: if bookmark['jid'] == bm['jid']: dialogs.ErrorDialog( _('Bookmark already set'), _('Group Chat "%s" is already in your bookmarks.') % bm['jid'], transient_for=self.window.window) return - gajim.connections[self.account].bookmarks.append(bm) - gajim.connections[self.account].store_bookmarks() + app.connections[self.account].bookmarks.append(bm) + app.connections[self.account].store_bookmarks() gui_menu_builder.build_bookmark_menu(self.account) @@ -1811,15 +1811,15 @@ class MucBrowser(AgentBrowser): if not iter_: return service = model[iter_][0] - if 'join_gc' not in gajim.interface.instances[self.account]: + if 'join_gc' not in app.interface.instances[self.account]: try: dialogs.JoinGroupchatWindow(self.account, service) except GajimGeneralException: pass else: - gajim.interface.instances[self.account]['join_gc']._set_room_jid( + app.interface.instances[self.account]['join_gc']._set_room_jid( service) - gajim.interface.instances[self.account]['join_gc'].window.present() + app.interface.instances[self.account]['join_gc'].window.present() def update_actions(self): sens = self.window.services_treeview.get_selection().count_selected_rows() @@ -1968,7 +1968,7 @@ class DiscussionGroupsBrowser(AgentBrowser): self.subscribe_button = None self.unsubscribe_button = None - gajim.connections[account].send_pb_subscription_query(jid, + app.connections[account].send_pb_subscription_query(jid, self._on_pep_subscriptions) def _create_treemodel(self): @@ -2141,7 +2141,7 @@ class DiscussionGroupsBrowser(AgentBrowser): groupnode = model.get_value(iter_, 1) # 1 = groupnode - gajim.connections[self.account].send_pb_subscribe(self.jid, groupnode, + app.connections[self.account].send_pb_subscribe(self.jid, groupnode, self._on_pep_subscribe, groupnode) def on_unsubscribe_button_clicked(self, widget): @@ -2153,7 +2153,7 @@ class DiscussionGroupsBrowser(AgentBrowser): groupnode = model.get_value(iter_, 1) # 1 = groupnode - gajim.connections[self.account].send_pb_unsubscribe(self.jid, groupnode, + app.connections[self.account].send_pb_unsubscribe(self.jid, groupnode, self._on_pep_unsubscribe, groupnode) def _on_pep_subscriptions(self, conn, request): diff --git a/gajim/features_window.py b/gajim/features_window.py index 4f790a93a..50ce25bdb 100644 --- a/gajim/features_window.py +++ b/gajim/features_window.py @@ -28,7 +28,7 @@ import gi from gi.repository import Gtk, Gdk from gajim import gtkgui_helpers -from gajim.common import gajim +from gajim.common import app from gajim.common.i18n import Q_ class FeaturesWindow: @@ -39,7 +39,7 @@ class FeaturesWindow: def __init__(self): self.xml = gtkgui_helpers.get_gtk_builder('features_window.ui') self.window = self.xml.get_object('features_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.window.set_transient_for(app.interface.roster.window) treeview = self.xml.get_object('features_treeview') self.desc_label = self.xml.get_object('feature_desc_label') @@ -169,14 +169,14 @@ class FeaturesWindow: return True def zeroconf_available(self): - return gajim.HAVE_ZEROCONF + return app.HAVE_ZEROCONF def dbus_available(self): from gajim.common import dbus_support return dbus_support.supported def gpg_available(self): - return gajim.HAVE_GPG + return app.HAVE_GPG def network_watcher_available(self): from gajim import network_watcher @@ -216,7 +216,7 @@ class FeaturesWindow: return sleepy.SUPPORTED def pycrypto_available(self): - return gajim.HAVE_PYCRYPTO + return app.HAVE_PYCRYPTO def docutils_available(self): try: @@ -226,10 +226,10 @@ class FeaturesWindow: return True def farstream_available(self): - return gajim.HAVE_FARSTREAM + return app.HAVE_FARSTREAM def gupnp_igd_available(self): - return gajim.HAVE_UPNP_IGD + return app.HAVE_UPNP_IGD def upower_available(self): if os.name == 'nt': diff --git a/gajim/filetransfers_window.py b/gajim/filetransfers_window.py index 860f7d1c7..0f3325158 100644 --- a/gajim/filetransfers_window.py +++ b/gajim/filetransfers_window.py @@ -36,7 +36,7 @@ from gajim import gtkgui_helpers from gajim import tooltips from gajim import dialogs -from gajim.common import gajim +from gajim.common import app from gajim.common import helpers from gajim.common.file_props import FilesProp from gajim.common.protocol.bytestream import (is_transfer_active, is_transfer_paused, @@ -70,7 +70,7 @@ class FileTransfersWindow: self.notify_ft_checkbox = self.xml.get_object( 'notify_ft_complete_checkbox') - shall_notify = gajim.config.get('notify_on_file_complete') + shall_notify = app.config.get('notify_on_file_complete') self.notify_ft_checkbox.set_active(shall_notify) self.model = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str, str, str, int, int, str) @@ -193,7 +193,7 @@ class FileTransfersWindow: helpers.convert_bytes(file_props.size) if file_props.type_ == 'r': jid = file_props.sender.split('/')[0] - sender_name = gajim.contacts.get_first_contact_from_jid( + sender_name = app.contacts.get_first_contact_from_jid( file_props.tt_account, jid).get_shown_name() sender = sender_name else: @@ -203,7 +203,7 @@ class FileTransfersWindow: sectext += '\n\t' + _('Recipient: ') if file_props.type_ == 's': jid = file_props.receiver.split('/')[0] - receiver_name = gajim.contacts.get_first_contact_from_jid( + receiver_name = app.contacts.get_first_contact_from_jid( file_props.tt_account, jid).get_shown_name() recipient = receiver_name else: @@ -212,7 +212,7 @@ class FileTransfersWindow: sectext += recipient if file_props.type_ == 'r': sectext += '\n\t' + _('Saved in: %s') % file_path - dialog = dialogs.HigDialog(gajim.interface.roster.window, Gtk.MessageType.INFO, + dialog = dialogs.HigDialog(app.interface.roster.window, Gtk.MessageType.INFO, Gtk.ButtonsType.NONE, _('File transfer completed'), sectext) if file_props.type_ == 'r': button = Gtk.Button.new_with_mnemonic(_('Open _Containing Folder')) @@ -256,11 +256,11 @@ class FileTransfersWindow: def on_yes(dummy, fjid, file_props, account): # Delete old file os.remove(file_props.file_name) - jid, resource = gajim.get_room_and_nick_from_fjid(fjid) + jid, resource = app.get_room_and_nick_from_fjid(fjid) if resource: - contact = gajim.contacts.get_contact(account, jid, resource) + contact = app.contacts.get_contact(account, jid, resource) else: - contact = gajim.contacts.get_contact_with_highest_priority( + contact = app.contacts.get_contact_with_highest_priority( account, jid) fjid = contact.get_full_jid() # Request the file to the sender @@ -273,7 +273,7 @@ class FileTransfersWindow: new_file_props.date = file_props.date new_file_props.hash_ = file_props.hash_ new_file_props.type_ = 'r' - tsid = gajim.connections[account].start_file_transfer(fjid, + tsid = app.connections[account].start_file_transfer(fjid, new_file_props, True) new_file_props.transport_sid = tsid @@ -309,17 +309,17 @@ class FileTransfersWindow: and file_dir is None: file_dir = os.path.dirname(file_path) if file_dir: - gajim.config.set('last_send_dir', file_dir) + app.config.set('last_send_dir', file_dir) dialog.destroy() dialog = dialogs.FileChooserDialog(_('Choose File to Send…'), Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL), Gtk.ResponseType.OK, True, # select multiple true as we can select many files to send - gajim.config.get('last_send_dir'), + app.config.get('last_send_dir'), on_response_ok=on_ok, on_response_cancel=lambda e:dialog.destroy(), - transient_for=gajim.interface.roster.window + transient_for=app.interface.roster.window ) btn = Gtk.Button.new_with_mnemonic(_('_Send')) @@ -351,7 +351,7 @@ class FileTransfersWindow: if contact.find('/') == -1: return (jid, resource) = contact.split('/', 1) - contact = gajim.contacts.create_contact(jid=jid, account=account, + contact = app.contacts.create_contact(jid=jid, account=account, resource=resource) file_name = os.path.split(file_path)[1] file_props = self.get_send_file_props(account, contact, @@ -360,24 +360,24 @@ class FileTransfersWindow: return False if contact.supports(NS_JINGLE_FILE_TRANSFER_5): log.info("contact %s supports jingle file transfer"%(contact.get_full_jid())) - gajim.connections[account].start_file_transfer(contact.get_full_jid(), + app.connections[account].start_file_transfer(contact.get_full_jid(), file_props) self.add_transfer(account, contact, file_props) else: log.info("contact does not support jingle file transfer") file_props.transport_sid = file_props.sid - gajim.connections[account].send_file_request(file_props) + app.connections[account].send_file_request(file_props) self.add_transfer(account, contact, file_props) return True def _start_receive(self, file_path, account, contact, file_props): file_dir = os.path.dirname(file_path) if file_dir: - gajim.config.set('last_save_dir', file_dir) + app.config.set('last_save_dir', file_dir) file_props.file_name = file_path file_props.type_ = 'r' self.add_transfer(account, contact, file_props) - gajim.connections[account].send_file_approval(file_props) + app.connections[account].send_file_approval(file_props) def on_file_request_accepted(self, account, contact, file_props): def on_ok(widget, account, contact, file_props): @@ -426,7 +426,7 @@ class FileTransfersWindow: def on_cancel(widget, account, contact, file_props): dialog2.destroy() - gajim.connections[account].send_file_rejection(file_props) + app.connections[account].send_file_rejection(file_props) dialog2 = dialogs.FileChooserDialog( title_text=_('Save File as…'), @@ -434,7 +434,7 @@ class FileTransfersWindow: buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_SAVE, Gtk.ResponseType.OK), default_response=Gtk.ResponseType.OK, - current_folder=gajim.config.get('last_save_dir'), + current_folder=app.config.get('last_save_dir'), on_response_ok=(on_ok, account, contact, file_props), on_response_cancel=(on_cancel, account, contact, file_props)) @@ -465,7 +465,7 @@ class FileTransfersWindow: self.on_file_request_accepted(account, contact, file_props) def on_response_cancel(account, file_props): - gajim.connections[account].send_file_rejection(file_props) + app.connections[account].send_file_rejection(file_props) dialog = dialogs.NonModalConfirmationDialog(prim_text, sec_text, on_response_ok=(on_response_ok, account, contact, file_props), @@ -579,24 +579,24 @@ class FileTransfersWindow: if file_props.tt_account: # file transfer is set account = file_props.tt_account - if account in gajim.connections: + if account in app.connections: # there is a connection to the account - gajim.connections[account].remove_transfer(file_props) + app.connections[account].remove_transfer(file_props) if file_props.type_ == 'r': # we receive a file other = file_props.sender else: # we send a file other = file_props.receiver if isinstance(other, str): - jid = gajim.get_jid_without_resource(other) + jid = app.get_jid_without_resource(other) else: # It's a Contact instance jid = other.jid for ev_type in ('file-error', 'file-completed', 'file-request-error', 'file-send-error', 'file-stopped'): - for event in gajim.events.get_events(account, jid, [ev_type]): + for event in app.events.get_events(account, jid, [ev_type]): if event.file_props.sid == file_props.sid: - gajim.events.remove_events(account, jid, event) - gajim.interface.roster.draw_contact(jid, account) - gajim.interface.roster.show_title() + app.events.remove_events(account, jid, event) + app.interface.roster.draw_contact(jid, account) + app.interface.roster.show_title() FilesProp.deleteFileProp(file_props) del(file_props) @@ -945,9 +945,9 @@ class FileTransfersWindow: sid = self.model[s_iter][Column.SID] file_props = FilesProp.getFilePropByType(sid[0], sid[1:]) account = file_props.tt_account - if account not in gajim.connections: + if account not in app.connections: return - con = gajim.connections[account] + con = app.connections[account] # Check if we are in a IBB transfer if file_props.direction: con.CloseIBBStream(file_props) @@ -980,7 +980,7 @@ class FileTransfersWindow: self.tooltip.hide_tooltip() def on_notify_ft_complete_checkbox_toggled(self, widget): - gajim.config.set('notify_on_file_complete', + app.config.set('notify_on_file_complete', widget.get_active()) def on_file_transfers_dialog_delete_event(self, widget, event): diff --git a/gajim/gajim.py b/gajim/gajim.py index f8f8749f4..99c44faec 100644 --- a/gajim/gajim.py +++ b/gajim/gajim.py @@ -134,14 +134,14 @@ class GajimApplication(Gtk.Application): configpaths.gajimpaths.init( self.config_path, self.profile, self.profile_separation) - from gajim.common import gajim + from gajim.common import app from gajim.common import check_paths from gajim.common import exceptions from gajim.common import logger from gajim.common import caps_cache try: - gajim.logger = logger.Logger() - caps_cache.initialize(gajim.logger) + app.logger = logger.Logger() + caps_cache.initialize(app.logger) check_paths.check_and_possibly_create_paths() except exceptions.DatabaseMalformed as error: dlg = Gtk.MessageDialog( @@ -209,7 +209,7 @@ class GajimApplication(Gtk.Application): # Seed the OpenSSL pseudo random number generator from file and initialize if PYOPENSSL_PRNG_PRESENT: - self.rng_seed = gajim.gajimpaths['RNG_SEED'] + self.rng_seed = app.gajimpaths['RNG_SEED'] # Seed from file try: OpenSSL.rand.load_file(self.rng_seed) @@ -232,7 +232,7 @@ class GajimApplication(Gtk.Application): sys.getfilesystemencoding(), locale.getpreferredencoding())) # Set Application Menu - gajim.app = self + app.app = self path = os.path.join(configpaths.get('GUI'), 'application_menu.ui') builder = Gtk.Builder() builder.set_translation_domain(i18n.APP) @@ -264,8 +264,8 @@ class GajimApplication(Gtk.Application): self.interface.roster.prepare_quit() # Commit any outstanding SQL transactions - from gajim.common import gajim - gajim.logger.commit() + from gajim.common import app + app.logger.commit() def do_handle_local_options(self, options: GLib.VariantDict) -> int: @@ -368,8 +368,8 @@ class GajimApplication(Gtk.Application): act.connect("activate", func) self.add_action(act) - from gajim.common import gajim - accounts_list = sorted(gajim.contacts.get_accounts()) + from gajim.common import app + accounts_list = sorted(app.contacts.get_accounts()) if not accounts_list: return if len(accounts_list) > 1: diff --git a/gajim/gajim_themes_window.py b/gajim/gajim_themes_window.py index 8490a29f7..040edaf2c 100644 --- a/gajim/gajim_themes_window.py +++ b/gajim/gajim_themes_window.py @@ -28,14 +28,14 @@ from gi.repository import Pango from gajim import dialogs from gajim import gtkgui_helpers -from gajim.common import gajim +from gajim.common import app class GajimThemesWindow: def __init__(self): self.xml = gtkgui_helpers.get_gtk_builder('gajim_themes_window.ui') self.window = self.xml.get_object('gajim_themes_window') - self.window.set_transient_for(gajim.interface.instances[ + self.window.set_transient_for(app.interface.instances[ 'preferences'].window) self.options = ['account', 'group', 'contact', 'banner'] @@ -65,7 +65,7 @@ class GajimThemesWindow: col.add_attribute(renderer, 'text', 0) renderer.connect('edited', self.on_theme_cell_edited) renderer.set_property('editable', True) - self.current_theme = gajim.config.get('roster_theme') + self.current_theme = app.config.get('roster_theme') self.no_update = False self.fill_themes_treeview() self.select_active_theme() @@ -83,8 +83,8 @@ class GajimThemesWindow: return True # do NOT destroy the window def on_close_button_clicked(self, widget): - if 'preferences' in gajim.interface.instances: - gajim.interface.instances['preferences'].update_theme_list() + if 'preferences' in app.interface.instances: + app.interface.instances['preferences'].update_theme_list() self.window.hide() def on_theme_cell_edited(self, cell, row, new_name): @@ -99,35 +99,35 @@ class GajimThemesWindow: _('Please create a new clean theme.')) return new_config_name = new_name.replace(' ', '_') - if new_config_name in gajim.config.get_per('themes'): + if new_config_name in app.config.get_per('themes'): return - gajim.config.add_per('themes', new_config_name) + app.config.add_per('themes', new_config_name) # Copy old theme values old_config_name = old_name.replace(' ', '_') properties = ['textcolor', 'bgcolor', 'font', 'fontattrs'] - gajim.config.add_per('themes', new_config_name) + app.config.add_per('themes', new_config_name) for option in self.options: for property_ in properties: option_name = option + property_ - gajim.config.set_per('themes', new_config_name, option_name, - gajim.config.get_per('themes', old_config_name, option_name)) - gajim.config.del_per('themes', old_config_name) - if old_config_name == gajim.config.get('roster_theme'): - gajim.config.set('roster_theme', new_config_name) + app.config.set_per('themes', new_config_name, option_name, + app.config.get_per('themes', old_config_name, option_name)) + app.config.del_per('themes', old_config_name) + if old_config_name == app.config.get('roster_theme'): + app.config.set('roster_theme', new_config_name) model.set_value(iter_, 0, new_name) self.current_theme = new_name def fill_themes_treeview(self): model = self.themes_tree.get_model() model.clear() - for config_theme in gajim.config.get_per('themes'): + for config_theme in app.config.get_per('themes'): theme = config_theme.replace('_', ' ') model.append([theme]) def select_active_theme(self): model = self.themes_tree.get_model() iter_ = model.get_iter_first() - active_theme = gajim.config.get('roster_theme').replace('_', ' ') + active_theme = app.config.get('roster_theme').replace('_', ' ') while iter_: theme = model[iter_][0] if theme == active_theme: @@ -169,10 +169,10 @@ class GajimThemesWindow: # don't confuse translators theme_name = _('theme name') theme_name_ns = theme_name.replace(' ', '_') - while theme_name_ns + str(i) in gajim.config.get_per('themes'): + while theme_name_ns + str(i) in app.config.get_per('themes'): i += 1 model.set_value(iter_, 0, theme_name + str(i)) - gajim.config.add_per('themes', theme_name_ns + str(i)) + app.config.add_per('themes', theme_name_ns + str(i)) self.themes_tree.get_selection().select_iter(iter_) col = self.themes_tree.get_column(0) path = model.get_path(iter_) @@ -182,7 +182,7 @@ class GajimThemesWindow: (model, iter_) = self.themes_tree.get_selection().get_selected() if not iter_: return - if self.current_theme == gajim.config.get('roster_theme'): + if self.current_theme == app.config.get('roster_theme'): dialogs.ErrorDialog( _('You cannot delete your current theme'), _('Pick another theme to use first.')) @@ -190,13 +190,13 @@ class GajimThemesWindow: self.theme_options_vbox.set_sensitive(False) self.theme_options_table.set_sensitive(False) self.xml.get_object('remove_button').set_sensitive(False) - gajim.config.del_per('themes', self.current_theme) + app.config.del_per('themes', self.current_theme) model.remove(iter_) def set_theme_options(self, theme, option = 'account'): self.no_update = True self.options_combobox.set_active(self.options.index(option)) - textcolor = gajim.config.get_per('themes', theme, option + 'textcolor') + textcolor = app.config.get_per('themes', theme, option + 'textcolor') if textcolor: state = True rgba = Gdk.RGBA() @@ -206,7 +206,7 @@ class GajimThemesWindow: state = False self.textcolor_checkbutton.set_active(state) self.text_colorbutton.set_sensitive(state) - bgcolor = gajim.config.get_per('themes', theme, option + 'bgcolor') + bgcolor = app.config.get_per('themes', theme, option + 'bgcolor') if bgcolor: state = True rgba = Gdk.RGBA() @@ -218,8 +218,8 @@ class GajimThemesWindow: self.background_colorbutton.set_sensitive(state) # get the font name before we set widgets and it will not be overriden - font_name = gajim.config.get_per('themes', theme, option + 'font') - font_attrs = gajim.config.get_per('themes', theme, option + 'fontattrs') + font_name = app.config.get_per('themes', theme, option + 'font') + font_attrs = app.config.get_per('themes', theme, option + 'fontattrs') self._set_font_widgets(font_attrs) if font_name: state = True @@ -229,11 +229,11 @@ class GajimThemesWindow: self.textfont_checkbutton.set_active(state) self.text_fontbutton.set_sensitive(state) self.no_update = False - gajim.interface.roster.change_roster_style(None) + app.interface.roster.change_roster_style(None) for chatstate in ('inactive', 'composing', 'paused', 'gone', 'muc_msg', 'muc_directed_msg'): - color = gajim.config.get_per('themes', theme, 'state_' + chatstate + \ + color = app.config.get_per('themes', theme, 'state_' + chatstate + \ '_color') rgba = Gdk.RGBA() rgba.parse(color) @@ -292,15 +292,15 @@ class GajimThemesWindow: begin_option = '' if not option.startswith('state'): begin_option = self.current_option - gajim.config.set_per('themes', self.current_theme, + app.config.set_per('themes', self.current_theme, begin_option + option, color_string) # use faster functions for this if self.current_option == 'banner': - gajim.interface.roster.repaint_themed_widgets() + app.interface.roster.repaint_themed_widgets() return if self.no_update: return - gajim.interface.roster.change_roster_style(self.current_option) + app.interface.roster.change_roster_style(self.current_option) def _set_font(self): """ @@ -311,17 +311,17 @@ class GajimThemesWindow: font_string = self.text_fontbutton.get_font_name() else: font_string = '' - gajim.config.set_per('themes', self.current_theme, + app.config.set_per('themes', self.current_theme, self.current_option + 'font', font_string) font_attrs = self._get_font_attrs() - gajim.config.set_per('themes', self.current_theme, + app.config.set_per('themes', self.current_theme, self.current_option + 'fontattrs', font_attrs) # use faster functions for this if self.current_option == 'banner': - gajim.interface.roster.repaint_themed_widgets() + app.interface.roster.repaint_themed_widgets() if self.no_update: return - gajim.interface.roster.change_roster_style(self.current_option) + app.interface.roster.change_roster_style(self.current_option) def _toggle_font_widgets(self, font_props): """ diff --git a/gajim/groupchat_control.py b/gajim/groupchat_control.py index 21d40de6d..9c1dffd9d 100644 --- a/gajim/groupchat_control.py +++ b/gajim/groupchat_control.py @@ -49,7 +49,7 @@ import nbxmpp from enum import IntEnum, unique from gajim.common import events -from gajim.common import gajim +from gajim.common import app from gajim.common import helpers from gajim.common import dataforms from gajim.common import ged @@ -79,11 +79,11 @@ empty_pixbuf.fill(0xffffff00) def tree_cell_data_func(column, renderer, model, iter_, tv=None): # cell data func is global, because we don't want it to keep # reference to GroupchatControl instance (self) - theme = gajim.config.get('roster_theme') + theme = app.config.get('roster_theme') # allocate space for avatar only if needed parent_iter = model.iter_parent(iter_) if isinstance(renderer, Gtk.CellRendererPixbuf): - avatar_position = gajim.config.get('avatar_position_in_roster') + avatar_position = app.config.get('avatar_position_in_roster') if avatar_position == 'right': renderer.set_property('xalign', 1) # align pixbuf to the right else: @@ -91,19 +91,19 @@ def tree_cell_data_func(column, renderer, model, iter_, tv=None): if parent_iter and (model[iter_][Column.AVATAR] or avatar_position == \ 'left'): renderer.set_property('visible', True) - renderer.set_property('width', gajim.config.get( + renderer.set_property('width', app.config.get( 'roster_avatar_width')) else: renderer.set_property('visible', False) if parent_iter: - bgcolor = gajim.config.get_per('themes', theme, 'contactbgcolor') + bgcolor = app.config.get_per('themes', theme, 'contactbgcolor') if bgcolor: renderer.set_property('cell-background', bgcolor) else: renderer.set_property('cell-background', None) if isinstance(renderer, Gtk.CellRendererText): # foreground property is only with CellRendererText - color = gajim.config.get_per('themes', theme, 'contacttextcolor') + color = app.config.get_per('themes', theme, 'contacttextcolor') if color: renderer.set_property('foreground', color) else: @@ -111,11 +111,11 @@ def tree_cell_data_func(column, renderer, model, iter_, tv=None): renderer.set_property('font', gtkgui_helpers.get_theme_font_for_option(theme, 'contactfont')) else: # it is root (eg. group) - bgcolor = gajim.config.get_per('themes', theme, 'groupbgcolor') + bgcolor = app.config.get_per('themes', theme, 'groupbgcolor') renderer.set_property('cell-background', bgcolor or None) if isinstance(renderer, Gtk.CellRendererText): # foreground property is only with CellRendererText - color = gajim.config.get_per('themes', theme, 'grouptextcolor') + color = app.config.get_per('themes', theme, 'grouptextcolor') renderer.set_property('foreground', color or None) renderer.set_property('font', gtkgui_helpers.get_theme_font_for_option(theme, 'groupfont')) @@ -130,10 +130,10 @@ class PrivateChatControl(ChatControl): def __init__(self, parent_win, gc_contact, contact, account, session): room_jid = gc_contact.room_jid - self.room_ctrl = gajim.interface.msg_win_mgr.get_gc_control(room_jid, + self.room_ctrl = app.interface.msg_win_mgr.get_gc_control(room_jid, account) - if room_jid in gajim.interface.minimized_controls[account]: - self.room_ctrl = gajim.interface.minimized_controls[account][room_jid] + if room_jid in app.interface.minimized_controls[account]: + self.room_ctrl = app.interface.minimized_controls[account][room_jid] if self.room_ctrl: self.room_name = self.room_ctrl.name else: @@ -141,9 +141,9 @@ class PrivateChatControl(ChatControl): self.gc_contact = gc_contact ChatControl.__init__(self, parent_win, contact, account, session) self.TYPE_ID = 'pm' - gajim.ged.register_event_handler('caps-received', ged.GUI1, + app.ged.register_event_handler('caps-received', ged.GUI1, self._nec_caps_received_pm) - gajim.ged.register_event_handler('gc-presence-received', ged.GUI1, + app.ged.register_event_handler('gc-presence-received', ged.GUI1, self._nec_gc_presence_received) def get_our_nick(self): @@ -151,9 +151,9 @@ class PrivateChatControl(ChatControl): def shutdown(self): super(PrivateChatControl, self).shutdown() - gajim.ged.remove_event_handler('caps-received', ged.GUI1, + app.ged.remove_event_handler('caps-received', ged.GUI1, self._nec_caps_received_pm) - gajim.ged.remove_event_handler('gc-presence-received', ged.GUI1, + app.ged.remove_event_handler('gc-presence-received', ged.GUI1, self._nec_gc_presence_received) def _nec_caps_received_pm(self, obj): @@ -171,7 +171,7 @@ class PrivateChatControl(ChatControl): self.print_conversation(_('%(nick)s is now known as ' '%(new_nick)s') % {'nick': obj.nick, 'new_nick': obj.new_nick}, 'status') - gc_c = gajim.contacts.get_gc_contact(obj.conn.name, obj.room_jid, + gc_c = app.contacts.get_gc_contact(obj.conn.name, obj.room_jid, obj.new_nick) c = gc_c.as_contact() self.gc_contact = gc_c @@ -186,7 +186,7 @@ class PrivateChatControl(ChatControl): self.draw_banner() old_jid = obj.room_jid + '/' + obj.nick new_jid = obj.room_jid + '/' + obj.new_nick - gajim.interface.msg_win_mgr.change_key(old_jid, new_jid, + app.interface.msg_win_mgr.change_key(old_jid, new_jid, obj.conn.name) else: self.contact.show = obj.show @@ -215,12 +215,12 @@ class PrivateChatControl(ChatControl): # We need to make sure that we can still send through the room and that # the recipient did not go away - contact = gajim.contacts.get_first_contact_from_jid(self.account, + contact = app.contacts.get_first_contact_from_jid(self.account, self.contact.jid) if not contact: # contact was from pm in MUC - room, nick = gajim.get_room_and_nick_from_fjid(self.contact.jid) - gc_contact = gajim.contacts.get_gc_contact(self.account, room, nick) + room, nick = app.get_room_and_nick_from_fjid(self.contact.jid) + gc_contact = app.contacts.get_gc_contact(self.account, room, nick) if not gc_contact: dialogs.ErrorDialog( _('Sending private message failed'), @@ -248,7 +248,7 @@ class PrivateChatControl(ChatControl): if not self.session: fjid = self.gc_contact.get_full_jid() - new_sess = gajim.connections[self.account].make_new_session(fjid, + new_sess = app.connections[self.account].make_new_session(fjid, type_=self.type_id) self.set_session(new_sess) @@ -322,7 +322,7 @@ class GroupchatControl(ChatControlBase): formattings_button.set_sensitive(False) widget = self.xml.get_object('bookmark_button') - for bm in gajim.connections[self.account].bookmarks: + for bm in app.connections[self.account].bookmarks: if bm['jid'] == self.contact.jid: widget.hide() break @@ -335,9 +335,9 @@ class GroupchatControl(ChatControlBase): img = self.xml.get_object('image7') img.set_from_icon_name('bookmark-new', Gtk.IconSize.MENU) widget.set_sensitive( - gajim.connections[self.account].private_storage_supported or \ - (gajim.connections[self.account].pubsub_supported and \ - gajim.connections[self.account].pubsub_publish_options_supported)) + app.connections[self.account].private_storage_supported or \ + (app.connections[self.account].pubsub_supported and \ + app.connections[self.account].pubsub_publish_options_supported)) widget.show() if gtkgui_helpers.gtk_icon_theme.has_icon('document-open-recent'): @@ -374,19 +374,19 @@ class GroupchatControl(ChatControlBase): self.nick = contact.name self.new_nick = '' self.name = '' - for bm in gajim.connections[self.account].bookmarks: + for bm in app.connections[self.account].bookmarks: if bm['jid'] == self.room_jid: self.name = bm['name'] break if not self.name: self.name = self.room_jid.split('@')[0] - compact_view = gajim.config.get('compact_view') + compact_view = app.config.get('compact_view') self.chat_buttons_set_visible(compact_view) self.widget_set_visible(self.xml.get_object('banner_eventbox'), - gajim.config.get('hide_groupchat_banner')) + app.config.get('hide_groupchat_banner')) self.widget_set_visible(self.xml.get_object('list_scrolledwindow'), - gajim.config.get('hide_groupchat_occupants_list')) + app.config.get('hide_groupchat_occupants_list')) self._last_selected_contact = None # None or holds jid, account tuple @@ -405,7 +405,7 @@ class GroupchatControl(ChatControlBase): # nickname coloring self.gc_count_nicknames_colors = -1 self.gc_custom_colors = {} - self.number_of_colors = len(gajim.config.get('gc_nicknames_colors').\ + self.number_of_colors = len(app.config.get('gc_nicknames_colors').\ split(':')) self.name_label = self.xml.get_object('banner_name_label') @@ -427,7 +427,7 @@ class GroupchatControl(ChatControlBase): self.handlers[id_] = self.hpaned # set the position of the current hpaned - hpaned_position = gajim.config.get('gc-hpaned-position') + hpaned_position = app.config.get('gc-hpaned-position') self.hpaned.set_position(hpaned_position) #status_image, shown_nick, type, nickname, avatar @@ -464,7 +464,7 @@ class GroupchatControl(ChatControlBase): False, 'pixbuf', Column.AVATAR, tree_cell_data_func, self.list_treeview) - if gajim.config.get('avatar_position_in_roster') == 'right': + if app.config.get('avatar_position_in_roster') == 'right': self.renderers_list.append(avater_renderer) else: self.renderers_list.insert(0, avater_renderer) @@ -498,23 +498,23 @@ class GroupchatControl(ChatControlBase): gui_menu_builder.get_encryption_menu(self.control_id, self.type_id)) self.set_encryption_menu_icon() - gajim.ged.register_event_handler('gc-presence-received', ged.GUI1, + app.ged.register_event_handler('gc-presence-received', ged.GUI1, self._nec_gc_presence_received) - gajim.ged.register_event_handler('gc-message-received', ged.GUI1, + app.ged.register_event_handler('gc-message-received', ged.GUI1, self._nec_gc_message_received) - gajim.ged.register_event_handler('vcard-published', ged.GUI1, + app.ged.register_event_handler('vcard-published', ged.GUI1, self._nec_vcard_published) - gajim.ged.register_event_handler('vcard-received', ged.GUI1, + app.ged.register_event_handler('vcard-received', ged.GUI1, self._nec_vcard_received) - gajim.ged.register_event_handler('gc-subject-received', ged.GUI1, + app.ged.register_event_handler('gc-subject-received', ged.GUI1, self._nec_gc_subject_received) - gajim.ged.register_event_handler('gc-config-changed-received', ged.GUI1, + app.ged.register_event_handler('gc-config-changed-received', ged.GUI1, self._nec_gc_config_changed_received) - gajim.ged.register_event_handler('signed-in', ged.GUI1, + app.ged.register_event_handler('signed-in', ged.GUI1, self._nec_signed_in) - gajim.ged.register_event_handler('decrypted-message-received', ged.GUI2, + app.ged.register_event_handler('decrypted-message-received', ged.GUI2, self._nec_decrypted_message_received) - gajim.gc_connected[self.account][self.room_jid] = False + app.gc_connected[self.account][self.room_jid] = False # disable win, we are not connected yet ChatControlBase.got_disconnected(self) @@ -523,7 +523,7 @@ class GroupchatControl(ChatControlBase): # PluginSystem: adding GUI extension point for this GroupchatControl # instance object - gajim.plugin_manager.gui_extension_point('groupchat_control', self) + app.plugin_manager.gui_extension_point('groupchat_control', self) def on_groupchat_maximize(self): self.set_tooltip() @@ -572,7 +572,7 @@ class GroupchatControl(ChatControlBase): return True tooltip.row = row - contact = gajim.contacts.get_gc_contact( + contact = app.contacts.get_gc_contact( self.account, self.room_jid, nick) if not contact: return False @@ -605,17 +605,17 @@ class GroupchatControl(ChatControlBase): if type1 == 'role': return locale.strcoll(nick1, nick2) if type1 == 'contact': - gc_contact1 = gajim.contacts.get_gc_contact(self.account, + gc_contact1 = app.contacts.get_gc_contact(self.account, self.room_jid, nick1) if not gc_contact1: return 0 if type2 == 'contact': - gc_contact2 = gajim.contacts.get_gc_contact(self.account, + gc_contact2 = app.contacts.get_gc_contact(self.account, self.room_jid, nick2) if not gc_contact2: return 0 if type1 == 'contact' and type2 == 'contact' and \ - gajim.config.get('sort_by_show_in_muc'): + app.config.get('sort_by_show_in_muc'): cshow = {'chat':0, 'online': 1, 'away': 2, 'xa': 3, 'dnd': 4, 'invisible': 5, 'offline': 6, 'error': 7} show1 = cshow[gc_contact1.show] @@ -643,7 +643,7 @@ class GroupchatControl(ChatControlBase): submenu = Gtk.Menu() item.set_submenu(submenu) - for nick in sorted(gajim.contacts.get_nick_list(self.account, + for nick in sorted(app.contacts.get_nick_list(self.account, self.room_jid)): item = Gtk.MenuItem.new_with_label(nick) item.set_use_underline(False) @@ -675,16 +675,16 @@ class GroupchatControl(ChatControlBase): return hpaned_position = self.hpaned.get_position() - gajim.config.set('gc-hpaned-position', hpaned_position) - for account in gajim.gc_connected: - for room_jid in [i for i in gajim.gc_connected[account] if \ - gajim.gc_connected[account][i] and i != self.room_jid]: - ctrl = gajim.interface.msg_win_mgr.get_gc_control(room_jid, + app.config.set('gc-hpaned-position', hpaned_position) + for account in app.gc_connected: + for room_jid in [i for i in app.gc_connected[account] if \ + app.gc_connected[account][i] and i != self.room_jid]: + ctrl = app.interface.msg_win_mgr.get_gc_control(room_jid, account) if not ctrl and room_jid in \ - gajim.interface.minimized_controls[account]: - ctrl = gajim.interface.minimized_controls[account][room_jid] - if ctrl and gajim.config.get('one_message_window') != 'never': + app.interface.minimized_controls[account]: + ctrl = app.interface.minimized_controls[account][room_jid] + if ctrl and app.config.get('one_message_window') != 'never': ctrl.resize_occupant_treeview(hpaned_position) def iter_contact_rows(self): @@ -763,7 +763,7 @@ class GroupchatControl(ChatControlBase): def get_tab_image(self, count_unread=True): # Set tab image (always 16x16) tab_image = None - if gajim.gc_connected[self.account][self.room_jid]: + if app.gc_connected[self.account][self.room_jid]: tab_image = gtkgui_helpers.load_icon('muc_active') else: tab_image = gtkgui_helpers.load_icon('muc_inactive') @@ -771,7 +771,7 @@ class GroupchatControl(ChatControlBase): def update_ui(self): ChatControlBase.update_ui(self) - for nick in gajim.contacts.get_nick_list(self.account, self.room_jid): + for nick in app.contacts.get_nick_list(self.account, self.room_jid): self.draw_contact(nick) def set_lock_image(self): @@ -780,7 +780,7 @@ class GroupchatControl(ChatControlBase): 'authenticated': False} if self.encryption: - gajim.plugin_manager.extension_point( + app.plugin_manager.extension_point( 'encryption_state' + self.encryption, self, encryption_state) self._show_lock_image(**encryption_state) @@ -806,7 +806,7 @@ class GroupchatControl(ChatControlBase): self.lock_image.set_sensitive(visible) def _on_authentication_button_clicked(self, widget): - gajim.plugin_manager.extension_point( + app.plugin_manager.extension_point( 'encryption_dialog' + self.encryption, self) def _change_style(self, model, path, iter_, option): @@ -821,9 +821,9 @@ class GroupchatControl(ChatControlBase): def _update_banner_state_image(self): banner_status_img = self.xml.get_object('gc_banner_status_image') - images = gajim.interface.jabber_state_images - if self.room_jid in gajim.gc_connected[self.account] and \ - gajim.gc_connected[self.account][self.room_jid]: + images = app.interface.jabber_state_images + if self.room_jid in app.gc_connected[self.account] and \ + app.gc_connected[self.account][self.room_jid]: image = 'muc_active' else: image = 'muc_inactive' @@ -845,7 +845,7 @@ class GroupchatControl(ChatControlBase): Conversation if there isn't any other contact in the room """ nicks = [] - for nick in gajim.contacts.get_nick_list(self.account, + for nick in app.contacts.get_nick_list(self.account, self.room_jid): if nick != self.nick: nicks.append(nick) @@ -924,7 +924,7 @@ class GroupchatControl(ChatControlBase): history_menuitem.show() bookmark_separator.show() separatormenuitem2.show() - for bm in gajim.connections[self.account].bookmarks: + for bm in app.connections[self.account].bookmarks: if bm['jid'] == self.room_jid: bookmark_room_menuitem.hide() bookmark_separator.hide() @@ -940,15 +940,15 @@ class GroupchatControl(ChatControlBase): history_menuitem.add_accelerator('activate', ag, Gdk.KEY_h, Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE) - if self.contact.jid not in gajim.config.get_per('accounts', self.account, + if self.contact.jid not in app.config.get_per('accounts', self.account, 'non_minimized_gc').split(' '): minimize_menuitem.set_active(True) - conn = gajim.connections[self.account] + conn = app.connections[self.account] if not conn.private_storage_supported and (not conn.pubsub_supported or \ not conn.pubsub_publish_options_supported): bookmark_room_menuitem.set_sensitive(False) - if gajim.gc_connected[self.account][self.room_jid]: - c = gajim.contacts.get_gc_contact(self.account, self.room_jid, + if app.gc_connected[self.account][self.room_jid]: + c = app.contacts.get_gc_contact(self.account, self.room_jid, self.nick) if c.affiliation not in ('owner', 'admin'): configure_room_menuitem.set_sensitive(False) @@ -1032,7 +1032,7 @@ class GroupchatControl(ChatControlBase): def _nec_vcard_published(self, obj): if obj.conn.name != self.account: return - show = gajim.SHOW_LIST[obj.conn.connected] + show = app.SHOW_LIST[obj.conn.connected] status = obj.conn.status obj.conn.send_gc_status(self.nick, self.room_jid, show, status) @@ -1110,22 +1110,22 @@ class GroupchatControl(ChatControlBase): encrypted=False, displaymarking=None): # Do we have a queue? fjid = self.room_jid + '/' + nick - no_queue = len(gajim.events.get_events(self.account, fjid)) == 0 + no_queue = len(app.events.get_events(self.account, fjid)) == 0 event = events.PmEvent(msg, '', 'incoming', tim, encrypted, '', msg_log_id, xhtml=xhtml, session=session, form_node=None, displaymarking=displaymarking, sent_forwarded=False) - gajim.events.add_event(self.account, fjid, event) + app.events.add_event(self.account, fjid, event) - autopopup = gajim.config.get('autopopup') - autopopupaway = gajim.config.get('autopopupaway') + autopopup = app.config.get('autopopup') + autopopupaway = app.config.get('autopopupaway') iter_ = self.get_contact_iter(nick) path = self.model.get_path(iter_) if not autopopup or (not autopopupaway and \ - gajim.connections[self.account].connected > 2): + app.connections[self.account].connected > 2): if no_queue: # We didn't have a queue: we change icons state_images = \ - gajim.interface.roster.get_appropriate_state_images( + app.interface.roster.get_appropriate_state_images( self.room_jid, icon_name='event') image = state_images['event'] self.model[iter_][Column.IMG] = image @@ -1140,10 +1140,10 @@ class GroupchatControl(ChatControlBase): self.list_treeview.expand_row(path_, False) self.list_treeview.scroll_to_cell(path) self.list_treeview.set_cursor(path) - contact = gajim.contacts.get_contact_with_highest_priority( + contact = app.contacts.get_contact_with_highest_priority( self.account, self.room_jid) if contact: - gajim.interface.roster.draw_contact(self.room_jid, self.account) + app.interface.roster.draw_contact(self.room_jid, self.account) def get_contact_iter(self, nick): role_iter = self.model.get_iter_first() @@ -1166,7 +1166,7 @@ class GroupchatControl(ChatControlBase): kind = 'incoming' else: kind = 'status' - if gajim.config.get('restored_messages_small'): + if app.config.get('restored_messages_small'): small_attr = ['small'] else: small_attr = [] @@ -1245,17 +1245,17 @@ class GroupchatControl(ChatControlBase): def get_nb_unread(self): type_events = ['printed_marked_gc_msg'] - if gajim.config.get('notify_on_all_muc_messages'): + if app.config.get('notify_on_all_muc_messages'): type_events.append('printed_gc_msg') - nb = len(gajim.events.get_events(self.account, self.room_jid, + nb = len(app.events.get_events(self.account, self.room_jid, type_events)) nb += self.get_nb_unread_pm() return nb def get_nb_unread_pm(self): nb = 0 - for nick in gajim.contacts.get_nick_list(self.account, self.room_jid): - nb += len(gajim.events.get_events(self.account, self.room_jid + \ + for nick in app.contacts.get_nick_list(self.account, self.room_jid): + nb += len(app.events.get_events(self.account, self.room_jid + \ '/' + nick, ['pm'])) return nb @@ -1269,12 +1269,12 @@ class GroupchatControl(ChatControlBase): # Are any of the defined highlighting words in the text? if self.needs_visual_notification(text): highlight = True - if gajim.config.get_per('soundevents', 'muc_message_highlight', + if app.config.get_per('soundevents', 'muc_message_highlight', 'enabled'): sound = 'highlight' # Do we play a sound on every muc message? - elif gajim.config.get_per('soundevents', 'muc_message_received', \ + elif app.config.get_per('soundevents', 'muc_message_received', \ 'enabled'): sound = 'received' @@ -1290,7 +1290,7 @@ class GroupchatControl(ChatControlBase): does not already have it as last event. If it goes to add this line - remove previous line first """ - win = gajim.interface.msg_win_mgr.get_window(self.room_jid, + win = app.interface.msg_win_mgr.get_window(self.room_jid, self.account) if win and self.room_jid == win.get_active_jid() and\ win.window.get_property('has-toplevel-focus') and\ @@ -1307,7 +1307,7 @@ class GroupchatControl(ChatControlBase): Check text to see whether any of the words in (muc_highlight_words and nick) appear """ - special_words = gajim.config.get('muc_highlight_words').split(';') + special_words = app.config.get('muc_highlight_words').split(';') special_words.append(self.nick) # Strip empties: ''.split(';') == [''] and would highlight everything. # Also lowercase everything for case insensitive compare. @@ -1386,7 +1386,7 @@ class GroupchatControl(ChatControlBase): def _nec_signed_in(self, obj): if obj.conn.name != self.account: return - password = gajim.gc_passwords.get(self.room_jid, '') + password = app.gc_passwords.get(self.room_jid, '') obj.conn.join_gc(self.nick, self.room_jid, password, rejoin=True) def _nec_decrypted_message_received(self, obj): @@ -1422,7 +1422,7 @@ class GroupchatControl(ChatControlBase): GLib.source_remove(self.autorejoin) self.autorejoin = None - gajim.gc_connected[self.account][self.room_jid] = True + app.gc_connected[self.account][self.room_jid] = True ChatControlBase.got_connected(self) self.list_treeview.set_model(self.model) self.list_treeview.expand_all() @@ -1451,14 +1451,14 @@ class GroupchatControl(ChatControlBase): change_subject_button.set_sensitive(False) self.list_treeview.set_model(None) self.model.clear() - nick_list = gajim.contacts.get_nick_list(self.account, self.room_jid) + nick_list = app.contacts.get_nick_list(self.account, self.room_jid) for nick in nick_list: # Update pm chat window fjid = self.room_jid + '/' + nick - gc_contact = gajim.contacts.get_gc_contact(self.account, + gc_contact = app.contacts.get_gc_contact(self.account, self.room_jid, nick) - ctrl = gajim.interface.msg_win_mgr.get_control(fjid, self.account) + ctrl = app.interface.msg_win_mgr.get_control(fjid, self.account) if ctrl: gc_contact.show = 'offline' gc_contact.status = '' @@ -1466,11 +1466,11 @@ class GroupchatControl(ChatControlBase): if ctrl.parent_win: ctrl.parent_win.redraw_tab(ctrl) - gajim.contacts.remove_gc_contact(self.account, gc_contact) - gajim.gc_connected[self.account][self.room_jid] = False + app.contacts.remove_gc_contact(self.account, gc_contact) + app.gc_connected[self.account][self.room_jid] = False ChatControlBase.got_disconnected(self) # Tell connection to note the date we disconnect to avoid duplicate logs - gajim.connections[self.account].gc_got_disconnected(self.room_jid) + app.connections[self.account].gc_got_disconnected(self.room_jid) # We don't redraw the whole banner here, because only icon change self._update_banner_state_image() if self.parent_win: @@ -1479,23 +1479,23 @@ class GroupchatControl(ChatControlBase): # Autorejoin stuff goes here. # Notice that we don't need to activate autorejoin if connection is lost # or in progress. - if self.autorejoin is None and gajim.account_is_connected(self.account): - ar_to = gajim.config.get('muc_autorejoin_timeout') + if self.autorejoin is None and app.account_is_connected(self.account): + ar_to = app.config.get('muc_autorejoin_timeout') if ar_to: self.autorejoin = GLib.timeout_add_seconds(ar_to, self.rejoin) def rejoin(self): if not self.autorejoin: return False - password = gajim.gc_passwords.get(self.room_jid, '') - gajim.connections[self.account].join_gc(self.nick, self.room_jid, + password = app.gc_passwords.get(self.room_jid, '') + app.connections[self.account].join_gc(self.nick, self.room_jid, password, rejoin=True) return True def draw_roster(self): self.model.clear() - for nick in gajim.contacts.get_nick_list(self.account, self.room_jid): - gc_contact = gajim.contacts.get_gc_contact(self.account, + for nick in app.contacts.get_nick_list(self.account, self.room_jid): + gc_contact = app.contacts.get_gc_contact(self.account, self.room_jid, nick) self.add_contact_to_roster(nick, gc_contact.show, gc_contact.role, gc_contact.affiliation, gc_contact.status, gc_contact.jid) @@ -1526,10 +1526,10 @@ class GroupchatControl(ChatControlBase): iter_ = self.get_contact_iter(nick) if not iter_: return - gc_contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, + gc_contact = app.contacts.get_gc_contact(self.account, self.room_jid, nick) - state_images = gajim.interface.jabber_state_images['16'] - if len(gajim.events.get_events(self.account, self.room_jid + '/' + \ + state_images = app.interface.jabber_state_images['16'] + if len(app.events.get_events(self.account, self.room_jid + '/' + \ nick)): image = state_images['event'] else: @@ -1544,7 +1544,7 @@ class GroupchatControl(ChatControlBase): status = gc_contact.status # add status msg, if not empty, under contact name in the treeview - if status and gajim.config.get('show_status_msgs_in_roster'): + if status and app.config.get('show_status_msgs_in_roster'): status = status.strip() if status != '': status = helpers.reduce_chars_newlines(status, max_lines=1) @@ -1558,7 +1558,7 @@ class GroupchatControl(ChatControlBase): status)) if image.get_storage_type() == Gtk.ImageType.PIXBUF and \ - gc_contact.affiliation != 'none' and gajim.config.get( + gc_contact.affiliation != 'none' and app.config.get( 'show_affiliation_in_groupchat'): pixbuf1 = image.get_pixbuf().copy() pixbuf2 = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 4, 4) @@ -1576,7 +1576,7 @@ class GroupchatControl(ChatControlBase): self.model[iter_][Column.TEXT] = name def draw_avatar(self, nick): - if not gajim.config.get('show_avatars_in_roster'): + if not app.config.get('show_avatars_in_roster'): return iter_ = self.get_contact_iter(nick) if not iter_: @@ -1596,8 +1596,8 @@ class GroupchatControl(ChatControlBase): if not role_iter: return role_name = helpers.get_uf_role(role, plural=True) - if gajim.config.get('show_contacts_number'): - nbr_role, nbr_total = gajim.contacts.get_nb_role_total_gc_contacts( + if app.config.get('show_contacts_number'): + nbr_role, nbr_total = app.contacts.get_nb_role_total_gc_contacts( self.account, self.room_jid, role) role_name += ' (%s/%s)' % (repr(nbr_role), repr(nbr_total)) self.model[role_iter][Column.TEXT] = role_name @@ -1629,7 +1629,7 @@ class GroupchatControl(ChatControlBase): if obj.real_jid: # delete ressource - simple_jid = gajim.get_jid_without_resource(obj.real_jid) + simple_jid = app.get_jid_without_resource(obj.real_jid) nick_jid += ' (%s)' % simple_jid # status_code @@ -1638,20 +1638,20 @@ class GroupchatControl(ChatControlBase): if obj.status_code: if '110' in obj.status_code: # We just join the room - if self.room_jid in gajim.automatic_rooms[self.account] and \ - gajim.automatic_rooms[self.account][self.room_jid]['invities']: - if self.room_jid not in gajim.interface.instances[ + if self.room_jid in app.automatic_rooms[self.account] and \ + app.automatic_rooms[self.account][self.room_jid]['invities']: + if self.room_jid not in app.interface.instances[ self.account]['gc_config']: if obj.affiliation == 'owner': # We need to configure the room if it's a new one. # We cannot know it's a new one. Status 201 is not # sent by all servers. - gajim.connections[self.account].request_gc_config( + app.connections[self.account].request_gc_config( self.room_jid) - elif 'continue_tag' in gajim.automatic_rooms[ + elif 'continue_tag' in app.automatic_rooms[ self.account][self.room_jid]: # We just need to invite contacts - for jid in gajim.automatic_rooms[self.account][ + for jid in app.automatic_rooms[self.account][ self.room_jid]['invities']: obj.conn.send_invite(self.room_jid, jid) self.print_conversation(_('%(jid)s has been ' @@ -1659,13 +1659,13 @@ class GroupchatControl(ChatControlBase): graphics=False) if '100' in obj.status_code: # Can be a message (see handle_event_gc_config_change in - # gajim.py) + # app.py) self.print_conversation( _('Any occupant is allowed to see your full JID')) self.is_anonymous = False if '170' in obj.status_code: # Can be a message (see handle_event_gc_config_change in - # gajim.py) + # app.py) self.print_conversation(_('Room logging is enabled')) if '201' in obj.status_code: self.print_conversation(_('A new room has been created')) @@ -1684,7 +1684,7 @@ class GroupchatControl(ChatControlBase): '%(reason)s') % {'nick': nick, 'who': obj.actor, 'reason': obj.reason} self.print_conversation(s, 'info', graphics=False) - if obj.nick == self.nick and not gajim.config.get( + if obj.nick == self.nick and not app.config.get( 'muc_autorejoin_on_kick'): self.autorejoin = False elif '301' in obj.status_code: @@ -1705,17 +1705,17 @@ class GroupchatControl(ChatControlBase): self.new_nick = '' s = _('You are now known as %s') % self.nick # Stop all E2E sessions - nick_list = gajim.contacts.get_nick_list(self.account, + nick_list = app.contacts.get_nick_list(self.account, self.room_jid) for nick_ in nick_list: fjid_ = self.room_jid + '/' + nick_ - ctrl = gajim.interface.msg_win_mgr.get_control( + ctrl = app.interface.msg_win_mgr.get_control( fjid_, self.account) if ctrl and ctrl.session and \ ctrl.session.enable_encryption: thread_id = ctrl.session.thread_id ctrl.session.terminate_e2e() - gajim.connections[self.account].delete_session( + app.connections[self.account].delete_session( fjid_, thread_id) ctrl.no_autonegotiation = False else: @@ -1750,12 +1750,12 @@ class GroupchatControl(ChatControlBase): puny_jid = helpers.sanitize_filename(self.room_jid) puny_nick = helpers.sanitize_filename(obj.nick) puny_new_nick = helpers.sanitize_filename(obj.new_nick) - old_path = os.path.join(gajim.VCARD_PATH, puny_jid, + old_path = os.path.join(app.VCARD_PATH, puny_jid, puny_nick) - new_path = os.path.join(gajim.VCARD_PATH, puny_jid, + new_path = os.path.join(app.VCARD_PATH, puny_jid, puny_new_nick) files = {old_path: new_path} - path = os.path.join(gajim.AVATAR_PATH, puny_jid) + path = os.path.join(app.AVATAR_PATH, puny_jid) # possible extensions for ext in ('.png', '.jpeg', '_notif_size_bw.png', '_notif_size_colored.png'): @@ -1793,23 +1793,23 @@ class GroupchatControl(ChatControlBase): self.autorejoin = False self.print_conversation(obj.reason, 'info', graphics=False) - if len(gajim.events.get_events(self.account, jid=obj.fjid, + if len(app.events.get_events(self.account, jid=obj.fjid, types=['pm'])) == 0: self.remove_contact(obj.nick) self.draw_all_roles() else: - c = gajim.contacts.get_gc_contact(self.account, self.room_jid, + c = app.contacts.get_gc_contact(self.account, self.room_jid, obj.nick) c.show = obj.show c.status = obj.status if obj.nick == self.nick and (not obj.status_code or \ '303' not in obj.status_code): # We became offline self.got_disconnected() - contact = gajim.contacts.\ + contact = app.contacts.\ get_contact_with_highest_priority(self.account, self.room_jid) if contact: - gajim.interface.roster.draw_contact(self.room_jid, + app.interface.roster.draw_contact(self.room_jid, self.account) if self.parent_win: self.parent_win.redraw_tab(self) @@ -1827,10 +1827,10 @@ class GroupchatControl(ChatControlBase): self.draw_all_roles() if obj.status_code and '201' in obj.status_code: # We just created the room - gajim.connections[self.account].request_gc_config( + app.connections[self.account].request_gc_config( self.room_jid) else: - gc_c = gajim.contacts.get_gc_contact(self.account, + gc_c = app.contacts.get_gc_contact(self.account, self.room_jid, obj.nick) if not gc_c: log.error('%s has an iter, but no gc_contact instance' % \ @@ -1839,14 +1839,14 @@ class GroupchatControl(ChatControlBase): # Re-get vcard if avatar has changed # We do that here because we may request it to the real JID if # we knows it. connections.py doesn't know it. - con = gajim.connections[self.account] + con = app.connections[self.account] if gc_c and gc_c.jid: real_jid = gc_c.jid else: real_jid = obj.fjid if obj.fjid in obj.conn.vcard_shas: if obj.avatar_sha != obj.conn.vcard_shas[obj.fjid]: - server = gajim.get_server_from_jid(self.room_jid) + server = app.get_server_from_jid(self.room_jid) if not server.startswith('irc'): obj.conn.request_vcard(real_jid, obj.fjid) else: @@ -1859,7 +1859,7 @@ class GroupchatControl(ChatControlBase): if cached_sha != obj.avatar_sha: # avatar has been updated # sha in mem will be updated later - server = gajim.get_server_from_jid(self.room_jid) + server = app.get_server_from_jid(self.room_jid) if not server.startswith('irc'): obj.conn.request_vcard(real_jid, obj.fjid) else: @@ -1911,12 +1911,12 @@ class GroupchatControl(ChatControlBase): right_changed: st = '' print_status = None - for bookmark in gajim.connections[self.account].bookmarks: + for bookmark in app.connections[self.account].bookmarks: if bookmark['jid'] == self.room_jid: print_status = bookmark.get('print_status', None) break if not print_status: - print_status = gajim.config.get('print_status_in_muc') + print_status = app.config.get('print_status_in_muc') if obj.show == 'offline': if obj.nick in self.attention_list: self.attention_list.remove(obj.nick) @@ -1954,31 +1954,31 @@ class GroupchatControl(ChatControlBase): role_iter = self.get_role_iter(role) if not role_iter: role_iter = self.model.append(None, - [gajim.interface.jabber_state_images['16']['closed'], role, + [app.interface.jabber_state_images['16']['closed'], role, 'role', role_name, None] + [None] * self.nb_ext_renderers) self.draw_all_roles() iter_ = self.model.append(role_iter, [None, nick, 'contact', name, None] + \ [None] * self.nb_ext_renderers) - if not nick in gajim.contacts.get_nick_list(self.account, + if not nick in app.contacts.get_nick_list(self.account, self.room_jid): - gc_contact = gajim.contacts.create_gc_contact( + gc_contact = app.contacts.create_gc_contact( room_jid=self.room_jid, account=self.account, name=nick, show=show, status=status, role=role, affiliation=affiliation, jid=j, resource=resource) - gajim.contacts.add_gc_contact(self.account, gc_contact) + app.contacts.add_gc_contact(self.account, gc_contact) self.draw_contact(nick) self.draw_avatar(nick) # Do not ask avatar to irc rooms as irc transports reply with messages - server = gajim.get_server_from_jid(self.room_jid) - if gajim.config.get('ask_avatars_on_startup') and \ + server = app.get_server_from_jid(self.room_jid) + if app.config.get('ask_avatars_on_startup') and \ not server.startswith('irc'): fake_jid = self.room_jid + '/' + nick pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(fake_jid) if pixbuf == 'ask': if j and not self.is_anonymous: - gajim.connections[self.account].request_vcard(j, fake_jid) + app.connections[self.account].request_vcard(j, fake_jid) else: - gajim.connections[self.account].request_vcard(fake_jid, + app.connections[self.account].request_vcard(fake_jid, fake_jid) if nick == self.nick: # we became online self.got_connected() @@ -2004,10 +2004,10 @@ class GroupchatControl(ChatControlBase): iter_ = self.get_contact_iter(nick) if not iter_: return - gc_contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, + gc_contact = app.contacts.get_gc_contact(self.account, self.room_jid, nick) if gc_contact: - gajim.contacts.remove_gc_contact(self.account, gc_contact) + app.contacts.remove_gc_contact(self.account, gc_contact) parent_iter = self.model.iter_parent(iter_) self.model.remove(iter_) if self.model.iter_n_children(parent_iter) == 0: @@ -2022,7 +2022,7 @@ class GroupchatControl(ChatControlBase): if self.encryption: self.sendmessage = True - gajim.plugin_manager.extension_point( + app.plugin_manager.extension_point( 'send_message' + self.encryption, self) if not self.sendmessage: return @@ -2053,7 +2053,7 @@ class GroupchatControl(ChatControlBase): else: correct_id = None # Send the message - gajim.nec.push_outgoing_event(GcMessageOutgoingEvent(None, + app.nec.push_outgoing_event(GcMessageOutgoingEvent(None, account=self.account, jid=self.room_jid, message=message, xhtml=xhtml, label=label, callback=_cb, correct_id=correct_id, automatic_message=False)) @@ -2061,7 +2061,7 @@ class GroupchatControl(ChatControlBase): self.msg_textview.grab_focus() def get_role(self, nick): - gc_contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, + gc_contact = app.contacts.get_gc_contact(self.account, self.room_jid, nick) if gc_contact: return gc_contact.role @@ -2071,14 +2071,14 @@ class GroupchatControl(ChatControlBase): def minimizable(self): if self.force_non_minimizable: return False - if self.contact.jid not in gajim.config.get_per('accounts', self.account, + if self.contact.jid not in app.config.get_per('accounts', self.account, 'non_minimized_gc').split(' '): return True return False def minimize(self, status='offline'): # Minimize it - win = gajim.interface.msg_win_mgr.get_window(self.contact.jid, + win = app.interface.msg_win_mgr.get_window(self.contact.jid, self.account) ctrl = win.get_control(self.contact.jid, self.account) @@ -2096,7 +2096,7 @@ class GroupchatControl(ChatControlBase): ctrl.parent_win = None self.send_chatstate('inactive', self.contact) - gajim.interface.roster.add_groupchat(self.contact.jid, self.account, + app.interface.roster.add_groupchat(self.contact.jid, self.account, status = self.subject) del win._controls[self.account][self.contact.jid] @@ -2118,7 +2118,7 @@ class GroupchatControl(ChatControlBase): # do not send if we have chat state notifications disabled # that means we won't reply to the from other peer # so we do not broadcast jep85 capabalities - chatstate_setting = gajim.config.get('outgoing_chat_state_notifications') + chatstate_setting = app.config.get('outgoing_chat_state_notifications') if chatstate_setting == 'disabled': return @@ -2134,13 +2134,13 @@ class GroupchatControl(ChatControlBase): # if wel're inactive prevent composing (XEP violation) if contact.our_chatstate == 'inactive' and state == 'composing': # go active before - gajim.nec.push_outgoing_event(GcMessageOutgoingEvent(None, + app.nec.push_outgoing_event(GcMessageOutgoingEvent(None, account=self.account, jid=self.contact.jid, chatstate='active', control=self)) contact.our_chatstate = 'active' self.reset_kbd_mouse_timeout_vars() - gajim.nec.push_outgoing_event(GcMessageOutgoingEvent(None, + app.nec.push_outgoing_event(GcMessageOutgoingEvent(None, account=self.account, jid=self.contact.jid, chatstate=state, control=self)) @@ -2154,63 +2154,63 @@ class GroupchatControl(ChatControlBase): super(GroupchatControl, self).shutdown() # PluginSystem: removing GUI extension points connected with # GrouphatControl instance object - gajim.plugin_manager.remove_gui_extension_point('groupchat_control', + app.plugin_manager.remove_gui_extension_point('groupchat_control', self) # Preventing autorejoin from being activated self.autorejoin = False - gajim.ged.remove_event_handler('gc-presence-received', ged.GUI1, + app.ged.remove_event_handler('gc-presence-received', ged.GUI1, self._nec_gc_presence_received) - gajim.ged.remove_event_handler('gc-message-received', ged.GUI1, + app.ged.remove_event_handler('gc-message-received', ged.GUI1, self._nec_gc_message_received) - gajim.ged.remove_event_handler('vcard-published', ged.GUI1, + app.ged.remove_event_handler('vcard-published', ged.GUI1, self._nec_vcard_published) - gajim.ged.remove_event_handler('vcard-received', ged.GUI1, + app.ged.remove_event_handler('vcard-received', ged.GUI1, self._nec_vcard_received) - gajim.ged.remove_event_handler('gc-subject-received', ged.GUI1, + app.ged.remove_event_handler('gc-subject-received', ged.GUI1, self._nec_gc_subject_received) - gajim.ged.remove_event_handler('gc-config-changed-received', ged.GUI1, + app.ged.remove_event_handler('gc-config-changed-received', ged.GUI1, self._nec_gc_config_changed_received) - gajim.ged.remove_event_handler('signed-in', ged.GUI1, + app.ged.remove_event_handler('signed-in', ged.GUI1, self._nec_signed_in) - gajim.ged.remove_event_handler('decrypted-message-received', ged.GUI2, + app.ged.remove_event_handler('decrypted-message-received', ged.GUI2, self._nec_decrypted_message_received) - if self.room_jid in gajim.gc_connected[self.account] and \ - gajim.gc_connected[self.account][self.room_jid]: + if self.room_jid in app.gc_connected[self.account] and \ + app.gc_connected[self.account][self.room_jid]: # Tell connection to note the date we disconnect to avoid duplicate # logs. We do it only when connected because if connection was lost # there may be new messages since disconnection. - gajim.connections[self.account].gc_got_disconnected(self.room_jid) - gajim.connections[self.account].send_gc_status(self.nick, + app.connections[self.account].gc_got_disconnected(self.room_jid) + app.connections[self.account].send_gc_status(self.nick, self.room_jid, show='offline', status=status) - nick_list = gajim.contacts.get_nick_list(self.account, self.room_jid) + nick_list = app.contacts.get_nick_list(self.account, self.room_jid) for nick in nick_list: # Update pm chat window fjid = self.room_jid + '/' + nick - ctrl = gajim.interface.msg_win_mgr.get_gc_control(fjid, + ctrl = app.interface.msg_win_mgr.get_gc_control(fjid, self.account) if ctrl: - contact = gajim.contacts.get_gc_contact(self.account, + contact = app.contacts.get_gc_contact(self.account, self.room_jid, nick) contact.show = 'offline' contact.status = '' ctrl.update_ui() ctrl.parent_win.redraw_tab(ctrl) - for sess in gajim.connections[self.account].get_sessions(fjid): + for sess in app.connections[self.account].get_sessions(fjid): if sess.control: sess.control.no_autonegotiation = False if sess.enable_encryption: sess.terminate_e2e() - gajim.connections[self.account].delete_session(fjid, + app.connections[self.account].delete_session(fjid, sess.thread_id) # They can already be removed by the destroy function - if self.room_jid in gajim.contacts.get_gc_list(self.account): - gajim.contacts.remove_room(self.account, self.room_jid) - del gajim.gc_connected[self.account][self.room_jid] + if self.room_jid in app.contacts.get_gc_list(self.account): + app.contacts.remove_room(self.account, self.room_jid) + del app.gc_connected[self.account][self.room_jid] # Save hpaned position - gajim.config.set('gc-hpaned-position', self.hpaned.get_position()) + app.config.set('gc-hpaned-position', self.hpaned.get_position()) # remove all register handlers on wigets, created by self.xml # to prevent circular references among objects for i in list(self.handlers.keys()): @@ -2218,16 +2218,16 @@ class GroupchatControl(ChatControlBase): self.handlers[i].disconnect(i) del self.handlers[i] # Remove unread events from systray - gajim.events.remove_events(self.account, self.room_jid) + app.events.remove_events(self.account, self.room_jid) def safe_shutdown(self): if self.minimizable(): return True - includes = gajim.config.get('confirm_close_muc_rooms').split(' ') - excludes = gajim.config.get('noconfirm_close_muc_rooms').split(' ') + includes = app.config.get('confirm_close_muc_rooms').split(' ') + excludes = app.config.get('noconfirm_close_muc_rooms').split(' ') # whether to ask for comfirmation before closing muc - if (gajim.config.get('confirm_close_muc') or self.room_jid in includes)\ - and gajim.gc_connected[self.account][self.room_jid] and self.room_jid \ + if (app.config.get('confirm_close_muc') or self.room_jid in includes)\ + and app.gc_connected[self.account][self.room_jid] and self.room_jid \ not in excludes: return False return True @@ -2242,23 +2242,23 @@ class GroupchatControl(ChatControlBase): self.list_treeview.get_selection().unselect_all() on_no(self) return - includes = gajim.config.get('confirm_close_muc_rooms').split(' ') - excludes = gajim.config.get('noconfirm_close_muc_rooms').split(' ') + includes = app.config.get('confirm_close_muc_rooms').split(' ') + excludes = app.config.get('noconfirm_close_muc_rooms').split(' ') # whether to ask for comfirmation before closing muc - if (gajim.config.get('confirm_close_muc') or self.room_jid in includes)\ - and gajim.gc_connected[self.account][self.room_jid] and self.room_jid \ + if (app.config.get('confirm_close_muc') or self.room_jid in includes)\ + and app.gc_connected[self.account][self.room_jid] and self.room_jid \ not in excludes: def on_ok(clicked): if clicked: # user does not want to be asked again - gajim.config.set('confirm_close_muc', False) + app.config.set('confirm_close_muc', False) on_yes(self) def on_cancel(clicked): if clicked: # user does not want to be asked again - gajim.config.set('confirm_close_muc', False) + app.config.set('confirm_close_muc', False) on_no(self) pritext = _('Are you sure you want to leave group chat "%s"?')\ @@ -2289,9 +2289,9 @@ class GroupchatControl(ChatControlBase): # for room_jid & number of unread private msgs with each contact # that we have nb = 0 - for nick in gajim.contacts.get_nick_list(self.account, self.room_jid): + for nick in app.contacts.get_nick_list(self.account, self.room_jid): fjid = self.room_jid + '/' + nick - nb += len(gajim.events.get_events(self.account, fjid)) + nb += len(app.events.get_events(self.account, fjid)) # gc can only have messages as event return nb @@ -2299,7 +2299,7 @@ class GroupchatControl(ChatControlBase): def on_ok(subject): # Note, we don't update self.subject since we don't know whether it # will work yet - gajim.connections[self.account].send_gc_subject(self.room_jid, + app.connections[self.account].send_gc_subject(self.room_jid, subject) dialogs.InputTextDialog(_('Changing Subject'), @@ -2312,24 +2312,24 @@ class GroupchatControl(ChatControlBase): self.force_non_minimizable = False def _on_change_nick_menuitem_activate(self, widget): - if 'change_nick_dialog' in gajim.interface.instances: - gajim.interface.instances['change_nick_dialog'].dialog.present() + if 'change_nick_dialog' in app.interface.instances: + app.interface.instances['change_nick_dialog'].dialog.present() else: title = _('Changing Nickname') prompt = _('Please specify the new nickname you want to use:') - gajim.interface.instances['change_nick_dialog'] = \ + app.interface.instances['change_nick_dialog'] = \ dialogs.ChangeNickDialog(self.account, self.room_jid, title, prompt, change_nick=True, transient_for=self.parent_win.window) def _on_configure_room_menuitem_activate(self, widget): - c = gajim.contacts.get_gc_contact(self.account, self.room_jid, + c = app.contacts.get_gc_contact(self.account, self.room_jid, self.nick) if c.affiliation == 'owner': - gajim.connections[self.account].request_gc_config(self.room_jid) + app.connections[self.account].request_gc_config(self.room_jid) elif c.affiliation == 'admin': - if self.room_jid not in gajim.interface.instances[self.account][ + if self.room_jid not in app.interface.instances[self.account][ 'gc_config']: - gajim.interface.instances[self.account]['gc_config'][ + app.interface.instances[self.account]['gc_config'][ self.room_jid] = config.GroupchatConfigWindow(self.account, self.room_jid) @@ -2343,7 +2343,7 @@ class GroupchatControl(ChatControlBase): dialogs.ErrorDialog(_('Invalid group chat JID'), _('The group chat JID has not allowed characters.')) return - gajim.connections[self.account].destroy_gc_room(self.room_jid, + app.connections[self.account].destroy_gc_room(self.room_jid, reason, jid) # Ask for a reason @@ -2357,20 +2357,20 @@ class GroupchatControl(ChatControlBase): """ Bookmark the room, without autojoin and not minimized """ - password = gajim.gc_passwords.get(self.room_jid, '') - gajim.interface.add_gc_bookmark(self.account, self.name, self.room_jid,\ + password = app.gc_passwords.get(self.room_jid, '') + app.interface.add_gc_bookmark(self.account, self.name, self.room_jid,\ '0', '0', password, self.nick) def _on_request_voice_menuitem_activate(self, widget): """ Request voice in the current room """ - gajim.connections[self.account].request_voice(self.room_jid) + app.connections[self.account].request_voice(self.room_jid) def _on_drag_data_received(self, widget, context, x, y, selection, target_type, timestamp): # Invite contact to groupchat - treeview = gajim.interface.roster.tree + treeview = app.interface.roster.tree model = treeview.get_model() if not selection.get_data() or target_type == 80: # target_type = 80 means a file is dropped @@ -2382,7 +2382,7 @@ class GroupchatControl(ChatControlBase): if type_ != 'contact': # source is not a contact return contact_jid = data - gajim.connections[self.account].send_invite(self.room_jid, contact_jid) + app.connections[self.account].send_invite(self.room_jid, contact_jid) self.print_conversation(_('%(jid)s has been invited in this room') % { 'jid': contact_jid}, graphics=False) @@ -2408,7 +2408,7 @@ class GroupchatControl(ChatControlBase): else: begin = '' - gc_refer_to_nick_char = gajim.config.get('gc_refer_to_nick_char') + gc_refer_to_nick_char = app.config.get('gc_refer_to_nick_char') with_refer_to_nick_char = False after_nick_len = 1 # the space that is printed after we type [Tab] @@ -2426,7 +2426,7 @@ class GroupchatControl(ChatControlBase): begin = self.nick_hits.pop(0) else: self.nick_hits = [] # clear the hit list - list_nick = gajim.contacts.get_nick_list(self.account, + list_nick = app.contacts.get_nick_list(self.account, self.room_jid) list_nick.sort(key=str.lower) # case-insensitive sort if begin == '': @@ -2457,7 +2457,7 @@ class GroupchatControl(ChatControlBase): # completion # gc_refer_to_nick_char may be more than one char! start_iter.backward_chars(len(begin) + len(add)) - elif self.last_key_tabs and not gajim.config.get( + elif self.last_key_tabs and not app.config.get( 'shell_like_completion'): # have to accomodate for the added space from last # completion @@ -2470,7 +2470,7 @@ class GroupchatControl(ChatControlBase): # get a shell-like completion # if there's more than one nick for this completion, complete # only the part that all these nicks have in common - if gajim.config.get('shell_like_completion') and \ + if app.config.get('shell_like_completion') and \ len(self.nick_hits) > 1: end = False completion = '' @@ -2512,7 +2512,7 @@ class GroupchatControl(ChatControlBase): When a row is expanded: change the icon of the arrow """ model = widget.get_model() - image = gajim.interface.jabber_state_images['16']['opened'] + image = app.interface.jabber_state_images['16']['opened'] model[iter_][Column.IMG] = image def on_list_treeview_row_collapsed(self, widget, iter_, path): @@ -2520,7 +2520,7 @@ class GroupchatControl(ChatControlBase): When a row is collapsed: change the icon of the arrow """ model = widget.get_model() - image = gajim.interface.jabber_state_images['16']['closed'] + image = app.interface.jabber_state_images['16']['closed'] model[iter_][Column.IMG] = image def kick(self, widget, nick): @@ -2528,7 +2528,7 @@ class GroupchatControl(ChatControlBase): Kick a user """ def on_ok(reason): - gajim.connections[self.account].gc_set_role(self.room_jid, nick, + app.connections[self.account].gc_set_role(self.room_jid, nick, 'none', reason) # ask for reason @@ -2541,7 +2541,7 @@ class GroupchatControl(ChatControlBase): Make contact's popup menu """ nick = self.model[iter_][Column.NICK] - c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick) + c = app.contacts.get_gc_contact(self.account, self.room_jid, nick) fjid = self.room_jid + '/' + nick jid = c.jid target_affiliation = c.affiliation @@ -2549,7 +2549,7 @@ class GroupchatControl(ChatControlBase): # looking for user's affiliation and role user_nick = self.nick - user_affiliation = gajim.contacts.get_gc_contact(self.account, + user_affiliation = app.contacts.get_gc_contact(self.account, self.room_jid, user_nick).affiliation user_role = self.get_role(user_nick) @@ -2624,7 +2624,7 @@ class GroupchatControl(ChatControlBase): item = xml.get_object('invite_menuitem') if jid and c.name != self.nick: bookmarked = False - contact = gajim.contacts.get_contact(self.account, jid, c.resource) + contact = app.contacts.get_contact(self.account, jid, c.resource) if contact and contact.supports(nbxmpp.NS_CONFERENCE): bookmarked=True gui_menu_builder.build_invite_submenu(item, ((c, self.account),), @@ -2641,8 +2641,8 @@ class GroupchatControl(ChatControlBase): self.handlers[id_] = item item = xml.get_object('add_to_roster_menuitem') - our_jid = gajim.get_jid_from_account(self.account) - if not jid or jid == our_jid or not gajim.connections[self.account].\ + our_jid = app.get_jid_from_account(self.account) + if not jid or jid == our_jid or not app.connections[self.account].\ roster_supported: item.set_sensitive(False) else: @@ -2676,16 +2676,16 @@ class GroupchatControl(ChatControlBase): # show the popup now! menu = xml.get_object('gc_occupants_menu') menu.show_all() - menu.attach_to_widget(gajim.interface.roster.window, None) + menu.attach_to_widget(app.interface.roster.window, None) menu.popup(None, None, None, None, event.button, event.time) def _start_private_message(self, nick): - gc_c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick) + gc_c = app.contacts.get_gc_contact(self.account, self.room_jid, nick) nick_jid = gc_c.get_full_jid() - ctrl = gajim.interface.msg_win_mgr.get_control(nick_jid, self.account) + ctrl = app.interface.msg_win_mgr.get_control(nick_jid, self.account) if not ctrl: - ctrl = gajim.interface.new_private_chat(gc_c, self.account) + ctrl = app.interface.new_private_chat(gc_c, self.account) if ctrl: ctrl.parent_win.set_active_tab(ctrl) @@ -2710,7 +2710,7 @@ class GroupchatControl(ChatControlBase): """ When an iter is double clicked: open the chat window """ - if not gajim.single_click: + if not app.single_click: self.on_row_activated(widget, path) def on_list_treeview_button_press_event(self, widget, event): @@ -2739,13 +2739,13 @@ class GroupchatControl(ChatControlBase): return True elif event.button == 1: # left click - if gajim.single_click and not event.get_state() & Gdk.ModifierType.SHIFT_MASK: + if app.single_click and not event.get_state() & Gdk.ModifierType.SHIFT_MASK: self.on_row_activated(widget, path) return True else: iter_ = self.model.get_iter(path) nick = self.model[iter_][Column.NICK] - if not nick in gajim.contacts.get_nick_list(self.account, + if not nick in app.contacts.get_nick_list(self.account, self.room_jid): # it's a group if x < 27: @@ -2770,7 +2770,7 @@ class GroupchatControl(ChatControlBase): start = ' ' add = ' ' else: - gc_refer_to_nick_char = gajim.config.get('gc_refer_to_nick_char') + gc_refer_to_nick_char = app.config.get('gc_refer_to_nick_char') add = gc_refer_to_nick_char + ' ' message_buffer.insert_at_cursor(start + nick + add) @@ -2778,28 +2778,28 @@ class GroupchatControl(ChatControlBase): """ Grant voice privilege to a user """ - gajim.connections[self.account].gc_set_role(self.room_jid, nick, + app.connections[self.account].gc_set_role(self.room_jid, nick, 'participant') def revoke_voice(self, widget, nick): """ Revoke voice privilege to a user """ - gajim.connections[self.account].gc_set_role(self.room_jid, nick, + app.connections[self.account].gc_set_role(self.room_jid, nick, 'visitor') def grant_moderator(self, widget, nick): """ Grant moderator privilege to a user """ - gajim.connections[self.account].gc_set_role(self.room_jid, nick, + app.connections[self.account].gc_set_role(self.room_jid, nick, 'moderator') def revoke_moderator(self, widget, nick): """ Revoke moderator privilege to a user """ - gajim.connections[self.account].gc_set_role(self.room_jid, nick, + app.connections[self.account].gc_set_role(self.room_jid, nick, 'participant') def ban(self, widget, jid): @@ -2807,11 +2807,11 @@ class GroupchatControl(ChatControlBase): Ban a user """ def on_ok(reason): - gajim.connections[self.account].gc_set_affiliation(self.room_jid, + app.connections[self.account].gc_set_affiliation(self.room_jid, jid, 'outcast', reason) # to ban we know the real jid. so jid is not fakejid - nick = gajim.get_nick_from_jid(jid) + nick = app.get_nick_from_jid(jid) # ask for reason dialogs.InputDialog(_('Banning %s') % nick, _('You may specify a reason below:'), ok_handler=on_ok, @@ -2821,60 +2821,60 @@ class GroupchatControl(ChatControlBase): """ Grant membership privilege to a user """ - gajim.connections[self.account].gc_set_affiliation(self.room_jid, jid, + app.connections[self.account].gc_set_affiliation(self.room_jid, jid, 'member') def revoke_membership(self, widget, jid): """ Revoke membership privilege to a user """ - gajim.connections[self.account].gc_set_affiliation(self.room_jid, jid, + app.connections[self.account].gc_set_affiliation(self.room_jid, jid, 'none') def grant_admin(self, widget, jid): """ Grant administrative privilege to a user """ - gajim.connections[self.account].gc_set_affiliation(self.room_jid, jid, + app.connections[self.account].gc_set_affiliation(self.room_jid, jid, 'admin') def revoke_admin(self, widget, jid): """ Revoke administrative privilege to a user """ - gajim.connections[self.account].gc_set_affiliation(self.room_jid, jid, + app.connections[self.account].gc_set_affiliation(self.room_jid, jid, 'member') def grant_owner(self, widget, jid): """ Grant owner privilege to a user """ - gajim.connections[self.account].gc_set_affiliation(self.room_jid, jid, + app.connections[self.account].gc_set_affiliation(self.room_jid, jid, 'owner') def revoke_owner(self, widget, jid): """ Revoke owner privilege to a user """ - gajim.connections[self.account].gc_set_affiliation(self.room_jid, jid, + app.connections[self.account].gc_set_affiliation(self.room_jid, jid, 'admin') def on_info(self, widget, nick): """ Call vcard_information_window class to display user's information """ - gc_contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, + gc_contact = app.contacts.get_gc_contact(self.account, self.room_jid, nick) contact = gc_contact.as_contact() - if contact.jid in gajim.interface.instances[self.account]['infos']: - gajim.interface.instances[self.account]['infos'][contact.jid].\ + if contact.jid in app.interface.instances[self.account]['infos']: + app.interface.instances[self.account]['infos'][contact.jid].\ window.present() else: - gajim.interface.instances[self.account]['infos'][contact.jid] = \ + app.interface.instances[self.account]['infos'][contact.jid] = \ vcard.VcardWindow(contact, self.account, gc_contact) def on_history(self, widget, nick): - jid = gajim.construct_fjid(self.room_jid, nick) + jid = app.construct_fjid(self.room_jid, nick) self._on_history_menuitem_activate(widget=widget, jid=jid) def on_add_to_roster(self, widget, jid): @@ -2882,7 +2882,7 @@ class GroupchatControl(ChatControlBase): def on_block(self, widget, nick): fjid = self.room_jid + '/' + nick - connection = gajim.connections[self.account] + connection = app.connections[self.account] default = connection.privacy_default_list if fjid in connection.blocked_contacts: return @@ -2899,7 +2899,7 @@ class GroupchatControl(ChatControlBase): def on_unblock(self, widget, nick): fjid = self.room_jid + '/' + nick - connection = gajim.connections[self.account] + connection = app.connections[self.account] default = connection.privacy_default_list connection.new_blocked_list = [] # needed for draw_contact: @@ -2917,8 +2917,8 @@ class GroupchatControl(ChatControlBase): connection.blocked_groups = [] connection.set_default_list('') connection.del_privacy_list(default) - if 'privay_list_block' in gajim.interface.instances[self.account]: - del gajim.interface.instances[self.account]\ + if 'privay_list_block' in app.interface.instances[self.account]: + del app.interface.instances[self.account]\ ['privay_list_block'] else: connection.set_privacy_list(default, connection.new_blocked_list) diff --git a/gajim/groups.py b/gajim/groups.py index cd0fc9809..a2e418ee4 100644 --- a/gajim/groups.py +++ b/gajim/groups.py @@ -21,7 +21,7 @@ '''Window to create new post for discussion groups service.''' -from gajim.common import gajim +from gajim.common import app from nbxmpp import Node from gajim import gtkgui_helpers @@ -67,7 +67,7 @@ class GroupsPostWindow: item.addChild('content', {}, [buf.get_text(buf.get_start_iter(), buf.get_end_iter(), True)]) # publish it to node - gajim.connections[self.account].send_pb_publish(self.servicejid, self.groupid, item, '0') + app.connections[self.account].send_pb_publish(self.servicejid, self.groupid, item, '0') # close the window self.window.destroy() diff --git a/gajim/gtkgui_helpers.py b/gajim/gtkgui_helpers.py index dca845356..5aca86ac2 100644 --- a/gajim/gtkgui_helpers.py +++ b/gajim/gtkgui_helpers.py @@ -46,12 +46,12 @@ import logging log = logging.getLogger('gajim.gtkgui_helpers') from gajim.common import i18n -from gajim.common import gajim +from gajim.common import app from gajim.common import pep from gajim.common import configpaths gtk_icon_theme = Gtk.IconTheme.get_default() -gtk_icon_theme.append_search_path(gajim.ICONS_DIR) +gtk_icon_theme.append_search_path(app.ICONS_DIR) class Color: BLACK = Gdk.RGBA(red=0, green=0, blue=0, alpha=1) @@ -118,7 +118,7 @@ def get_image_button(icon_name, tooltip, toggle=False): button.set_image(image) return button -GUI_DIR = os.path.join(gajim.DATA_DIR, 'gui') +GUI_DIR = os.path.join(app.DATA_DIR, 'gui') def get_gtk_builder(file_name, widget=None): file_path = os.path.join(GUI_DIR, file_name) builder = Gtk.Builder() @@ -161,7 +161,7 @@ def popup_emoticons_under_button(menu, button, parent_win): alloc = button.get_allocation() button_x, button_y = alloc.x, alloc.y translated_coordinates = button.translate_coordinates( - gajim.interface.roster.window, 0, 0) + app.interface.roster.window, 0, 0) if translated_coordinates: button_x, button_y = translated_coordinates @@ -190,9 +190,9 @@ def get_theme_font_for_option(theme, option): """ Return string description of the font, stored in theme preferences """ - font_name = gajim.config.get_per('themes', theme, option) + font_name = app.config.get_per('themes', theme, option) font_desc = Pango.FontDescription() - font_prop_str = gajim.config.get_per('themes', theme, option + 'attrs') + font_prop_str = app.config.get_per('themes', theme, option + 'attrs') if font_prop_str: if font_prop_str.find('B') != -1: font_desc.set_weight(Pango.Weight.BOLD) @@ -427,7 +427,7 @@ def set_unset_urgency_hint(window, unread_messages_no): Sets/unset urgency hint in window argument depending if we have unread messages or not """ - if gajim.config.get('use_urgency_hint'): + if app.config.get('use_urgency_hint'): if unread_messages_no > 0: window.props.urgency_hint = True else: @@ -645,8 +645,8 @@ def get_scaled_pixbuf(pixbuf, kind): """ # resize to a width / height for the avatar not to have distortion # (keep aspect ratio) - width = gajim.config.get(kind + '_avatar_width') - height = gajim.config.get(kind + '_avatar_height') + width = app.config.get(kind + '_avatar_width') + height = app.config.get(kind + '_avatar_height') if width < 1 or height < 1: return None @@ -661,14 +661,14 @@ def get_avatar_pixbuf_from_cache(fjid, use_local=True): Returns 'ask' if cached vcard should not be used (user changed his vcard, so we have new sha) or if we don't have the vcard """ - jid, nick = gajim.get_room_and_nick_from_fjid(fjid) - if gajim.config.get('hide_avatar_of_transport') and\ - gajim.jid_is_transport(jid): + jid, nick = app.get_room_and_nick_from_fjid(fjid) + if app.config.get('hide_avatar_of_transport') and\ + app.jid_is_transport(jid): # don't show avatar for the transport itself return None - if any(jid in gajim.contacts.get_gc_list(acc) for acc in \ - gajim.contacts.get_accounts()): + if any(jid in app.contacts.get_gc_list(acc) for acc in \ + app.contacts.get_accounts()): is_groupchat_contact = True else: is_groupchat_contact = False @@ -676,12 +676,12 @@ def get_avatar_pixbuf_from_cache(fjid, use_local=True): puny_jid = helpers.sanitize_filename(jid) if is_groupchat_contact: puny_nick = helpers.sanitize_filename(nick) - path = os.path.join(gajim.VCARD_PATH, puny_jid, puny_nick) - local_avatar_basepath = os.path.join(gajim.AVATAR_PATH, puny_jid, + path = os.path.join(app.VCARD_PATH, puny_jid, puny_nick) + local_avatar_basepath = os.path.join(app.AVATAR_PATH, puny_jid, puny_nick) + '_local' else: - path = os.path.join(gajim.VCARD_PATH, puny_jid) - local_avatar_basepath = os.path.join(gajim.AVATAR_PATH, puny_jid) + \ + path = os.path.join(app.VCARD_PATH, puny_jid) + local_avatar_basepath = os.path.join(app.AVATAR_PATH, puny_jid) + \ '_local' if use_local: for extension in ('.png', '.jpeg'): @@ -695,7 +695,7 @@ def get_avatar_pixbuf_from_cache(fjid, use_local=True): if not os.path.isfile(path): return 'ask' - vcard_dict = list(gajim.connections.values())[0].get_cached_vcard(fjid, + vcard_dict = list(app.connections.values())[0].get_cached_vcard(fjid, is_groupchat_contact) if not vcard_dict: # This can happen if cached vcard is too old return 'ask' @@ -832,7 +832,7 @@ def on_avatar_save_as_menuitem_activate(widget, jid, default_name=''): action=Gtk.FileChooserAction.SAVE, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_SAVE, Gtk.ResponseType.OK), default_response=Gtk.ResponseType.OK, - current_folder=gajim.config.get('last_save_dir'), on_response_ok=on_ok, + current_folder=app.config.get('last_save_dir'), on_response_ok=on_ok, on_response_cancel=on_cancel) dialog.set_current_name(default_name + '.jpeg') @@ -903,7 +903,7 @@ def load_icon(icon_name): """ Load an icon from the iconset in 16x16 """ - iconset = gajim.config.get('iconset') + iconset = app.config.get('iconset') path = os.path.join(helpers.get_iconset_path(iconset), '16x16', '') icon_list = _load_icon_list([icon_name], path) return icon_list[icon_name] @@ -912,7 +912,7 @@ def load_mood_icon(icon_name): """ Load an icon from the mood iconset in 16x16 """ - iconset = gajim.config.get('mood_iconset') + iconset = app.config.get('mood_iconset') path = os.path.join(helpers.get_mood_iconset_path(iconset), '') icon_list = _load_icon_list([icon_name], path) return icon_list[icon_name] @@ -921,7 +921,7 @@ def load_activity_icon(category, activity = None): """ Load an icon from the activity iconset in 16x16 """ - iconset = gajim.config.get('activity_iconset') + iconset = app.config.get('activity_iconset') path = os.path.join(helpers.get_activity_iconset_path(iconset), category, '') if activity is None: @@ -939,7 +939,7 @@ def get_pep_as_pixbuf(pep_class): elif isinstance(pep_class, pep.UserTunePEP): icon = get_icon_pixmap('audio-x-generic', quiet=True) if not icon: - path = os.path.join(gajim.DATA_DIR, 'emoticons', 'static', + path = os.path.join(app.DATA_DIR, 'emoticons', 'static', 'music.png') return GdkPixbuf.Pixbuf.new_from_file(path) return icon @@ -972,7 +972,7 @@ def load_icons_meta(): Load and return - AND + small icons to put on top left of an icon for meta contacts """ - iconset = gajim.config.get('iconset') + iconset = app.config.get('iconset') path = os.path.join(helpers.get_iconset_path(iconset), '16x16') # try to find opened_meta.png file, else opened.png else nopixbuf merge path_opened = os.path.join(path, 'opened_meta.png') @@ -1025,44 +1025,44 @@ def make_jabber_state_images(): """ Initialize jabber_state_images dictionary """ - iconset = gajim.config.get('iconset') + iconset = app.config.get('iconset') if iconset: if helpers.get_iconset_path(iconset): path = os.path.join(helpers.get_iconset_path(iconset), '16x16') if not os.path.exists(path): - iconset = gajim.config.DEFAULT_ICONSET - gajim.config.set('iconset', iconset) + iconset = app.config.DEFAULT_ICONSET + app.config.set('iconset', iconset) else: - iconset = gajim.config.DEFAULT_ICONSET - gajim.config.set('iconset', iconset) + iconset = app.config.DEFAULT_ICONSET + app.config.set('iconset', iconset) else: - iconset = gajim.config.DEFAULT_ICONSET - gajim.config.set('iconset', iconset) + iconset = app.config.DEFAULT_ICONSET + app.config.set('iconset', iconset) path = os.path.join(helpers.get_iconset_path(iconset), '16x16') - gajim.interface.jabber_state_images['16'] = load_iconset(path) + app.interface.jabber_state_images['16'] = load_iconset(path) pixo, pixc = load_icons_meta() - gajim.interface.jabber_state_images['opened'] = load_iconset(path, pixo) - gajim.interface.jabber_state_images['closed'] = load_iconset(path, pixc) + app.interface.jabber_state_images['opened'] = load_iconset(path, pixo) + app.interface.jabber_state_images['closed'] = load_iconset(path, pixc) path = os.path.join(helpers.get_iconset_path(iconset), '32x32') - gajim.interface.jabber_state_images['32'] = load_iconset(path) + app.interface.jabber_state_images['32'] = load_iconset(path) path = os.path.join(helpers.get_iconset_path(iconset), '24x24') if (os.path.exists(path)): - gajim.interface.jabber_state_images['24'] = load_iconset(path) + app.interface.jabber_state_images['24'] = load_iconset(path) else: # Resize 32x32 icons to 24x24 - for each in gajim.interface.jabber_state_images['32']: + for each in app.interface.jabber_state_images['32']: img = Gtk.Image() - pix = gajim.interface.jabber_state_images['32'][each] + pix = app.interface.jabber_state_images['32'][each] pix_type = pix.get_storage_type() if pix_type == Gtk.ImageType.ANIMATION: animation = pix.get_animation() pixbuf = animation.get_static_image() elif pix_type == Gtk.ImageType.EMPTY: - pix = gajim.interface.jabber_state_images['16'][each] + pix = app.interface.jabber_state_images['16'][each] pix_16_type = pix.get_storage_type() if pix_16_type == Gtk.ImageType.ANIMATION: animation = pix.get_animation() @@ -1073,11 +1073,11 @@ def make_jabber_state_images(): pixbuf = pix.get_pixbuf() scaled_pix = pixbuf.scale_simple(24, 24, GdkPixbuf.InterpType.BILINEAR) img.set_from_pixbuf(scaled_pix) - gajim.interface.jabber_state_images['24'][each] = img + app.interface.jabber_state_images['24'][each] = img def reload_jabber_state_images(): make_jabber_state_images() - gajim.interface.roster.update_jabber_state_images() + app.interface.roster.update_jabber_state_images() def label_set_autowrap(widget): """ @@ -1112,7 +1112,7 @@ def __label_size_allocate(widget, allocation): widget.set_size_request (-1, lh / Pango.SCALE) def get_action(action): - return gajim.app.lookup_action(action) + return app.app.lookup_action(action) def load_css(): path = os.path.join(configpaths.get('DATA'), 'style', 'gajim.css') @@ -1152,18 +1152,18 @@ def convert_config_to_css(): 'state_muc_msg_color': ('', 'color')} - theme = gajim.config.get('roster_theme') + theme = app.config.get('roster_theme') for key, values in themed_widgets.items(): config, attr = values css += '#{} {{'.format(key) - value = gajim.config.get_per('themes', theme, config) + value = app.config.get_per('themes', theme, config) if value: css += '{attr}: {color};\n'.format(attr=attr, color=value) css += '}\n' for key, values in classes.items(): node, attr = values - value = gajim.config.get_per('themes', theme, key) + value = app.config.get_per('themes', theme, key) if value: css += '.theme_{cls} {node} {{ {attr}: {color}; }}\n'.format( cls=key, node=node, attr=attr, color=value) @@ -1185,7 +1185,7 @@ def remove_css_class(widget, class_name): style.remove_class('theme_' + class_name) def add_css_font(): - conversation_font = gajim.config.get('conversation_font') + conversation_font = app.config.get('conversation_font') if not conversation_font: return '' font = Pango.FontDescription(conversation_font) diff --git a/gajim/gui_interface.py b/gajim/gui_interface.py index 011ad37f8..3b0eb71de 100644 --- a/gajim/gui_interface.py +++ b/gajim/gui_interface.py @@ -46,7 +46,7 @@ from gi.repository import GdkPixbuf from gi.repository import GLib from gajim.common import i18n -from gajim.common import gajim +from gajim.common import app from gajim.common import events from gajim.common import dbus_support @@ -158,7 +158,7 @@ class Interface: account = obj.conn.name sec_msg = _('Do you accept this request?') - if gajim.get_number_of_connected_accounts() > 1: + if app.get_number_of_connected_accounts() > 1: sec_msg = _('Do you accept this request on account %s?') % account if obj.msg: sec_msg = obj.msg + '\n' + sec_msg @@ -181,7 +181,7 @@ class Interface: file_props.error = -3 else: file_props.error = -4 - gajim.nec.push_incoming_event(FileRequestErrorEvent(None, + app.nec.push_incoming_event(FileRequestErrorEvent(None, conn=obj.conn, jid=obj.jid, file_props=file_props, error_msg=obj.errmsg)) obj.conn.disconnect_transfer(file_props) @@ -211,7 +211,7 @@ class Interface: @staticmethod def unblock_signed_in_notifications(account): - gajim.block_signed_in_notifications[account] = False + app.block_signed_in_notifications[account] = False def handle_event_status(self, obj): # OUR status #('STATUS', account, show) @@ -230,7 +230,7 @@ class Interface: if account in self.pass_dialog: self.pass_dialog[account].window.destroy() if obj.show == 'offline': - gajim.block_signed_in_notifications[account] = True + app.block_signed_in_notifications[account] = True else: # 30 seconds after we change our status to sth else than offline # we stop blocking notifications of any kind @@ -244,11 +244,11 @@ class Interface: self.edit_own_details(account) def edit_own_details(self, account): - jid = gajim.get_jid_from_account(account) + jid = app.get_jid_from_account(account) if 'profile' not in self.instances[account]: self.instances[account]['profile'] = \ - profile_window.ProfileWindow(account, gajim.interface.roster.window) - gajim.connections[account].request_vcard(jid) + profile_window.ProfileWindow(account, app.interface.roster.window) + app.connections[account].request_vcard(jid) @staticmethod def handle_gc_error(gc_control, pritext, sectext): @@ -272,13 +272,13 @@ class Interface: def handle_gc_password_required(self, account, room_jid, nick): def on_ok(text): - gajim.connections[account].join_gc(nick, room_jid, text) - gajim.gc_passwords[room_jid] = text + app.connections[account].join_gc(nick, room_jid, text) + app.gc_passwords[room_jid] = text gc_control.error_dialog = None def on_cancel(): # get and destroy window - if room_jid in gajim.interface.minimized_controls[account]: + if room_jid in app.interface.minimized_controls[account]: self.roster.on_disconnect(None, room_jid, account) else: win = self.msg_win_mgr.get_window(room_jid, account) @@ -366,7 +366,7 @@ class Interface: status = obj.status resource = obj.resource or '' - jid_list = gajim.contacts.get_jid_list(account) + jid_list = app.contacts.get_jid_list(account) # unset custom status if (obj.old_show == 0 and obj.new_show > 1) or \ @@ -375,17 +375,17 @@ class Interface: jid in self.status_sent_to_users[account]: del self.status_sent_to_users[account][jid] - if gajim.jid_is_transport(jid): + if app.jid_is_transport(jid): # It must be an agent # transport just signed in/out, don't show # popup notifications for 30s account_jid = account + '/' + jid - gajim.block_signed_in_notifications[account_jid] = True + app.block_signed_in_notifications[account_jid] = True GLib.timeout_add_seconds(30, self.unblock_signed_in_notifications, account_jid) - highest = gajim.contacts.get_contact_with_highest_priority(account, jid) + highest = app.contacts.get_contact_with_highest_priority(account, jid) is_highest = (highest and highest.resource == resource) ctrl = self.msg_win_mgr.get_control(jid, account) @@ -423,7 +423,7 @@ class Interface: show = model[iter_][3] else: show = 'offline' - gc_c = gajim.contacts.create_gc_contact(room_jid=jid, + gc_c = app.contacts.create_gc_contact(room_jid=jid, account=account, name=nick, show=show) ctrl = self.new_private_chat(gc_c, account, session) @@ -439,7 +439,7 @@ class Interface: gc_control.set_subject(gc_control.subject) return - if gajim.jid_is_transport(jid): + if app.jid_is_transport(jid): jid = jid.replace('@', '') msg = obj.error_msg if obj.msg: @@ -452,7 +452,7 @@ class Interface: def handle_event_msgsent(obj): #('MSGSENT', account, (jid, msg, keyID)) # do not play sound when standalone chatstate message (eg no msg) - if obj.message and gajim.config.get_per('soundevents', 'message_sent', + if obj.message and app.config.get_per('soundevents', 'message_sent', 'enabled'): helpers.play_sound('message_sent') @@ -493,23 +493,23 @@ class Interface: def handle_event_subscribed_presence(self, obj): #('SUBSCRIBED', account, (jid, resource)) account = obj.conn.name - if obj.jid in gajim.contacts.get_jid_list(account): - c = gajim.contacts.get_first_contact_from_jid(account, obj.jid) + if obj.jid in app.contacts.get_jid_list(account): + c = app.contacts.get_first_contact_from_jid(account, obj.jid) c.resource = obj.resource self.roster.remove_contact_from_groups(c.jid, account, [_('Not in Roster'), _('Observers')], update=False) else: keyID = '' - attached_keys = gajim.config.get_per('accounts', account, + attached_keys = app.config.get_per('accounts', account, 'attached_gpg_keys').split() if obj.jid in attached_keys: keyID = attached_keys[attached_keys.index(obj.jid) + 1] name = obj.jid.split('@', 1)[0] name = name.split('%', 1)[0] - contact1 = gajim.contacts.create_contact(jid=obj.jid, + contact1 = app.contacts.create_contact(jid=obj.jid, account=account, name=name, groups=[], show='online', status='online', ask='to', resource=obj.resource, keyID=keyID) - gajim.contacts.add_contact(account, contact1) + app.contacts.add_contact(account, contact1) self.roster.add_contact(obj.jid, account) dialogs.InformationDialog(_('Authorization accepted'), _('The contact "%s" has authorized you to see his or her status.') @@ -530,7 +530,7 @@ class Interface: def handle_event_unsubscribed_presence(self, obj): #('UNSUBSCRIBED', account, jid) account = obj.conn.name - contact = gajim.contacts.get_first_contact_from_jid(account, obj.jid) + contact = app.contacts.get_first_contact_from_jid(account, obj.jid) if not contact: return @@ -561,18 +561,18 @@ class Interface: def handle_event_vcard(self, obj): # ('VCARD', account, data) '''vcard holds the vcard data''' - our_jid = gajim.get_jid_from_account(obj.conn.name) + our_jid = app.get_jid_from_account(obj.conn.name) if obj.jid == our_jid: if obj.nickname: - gajim.nicks[obj.conn.name] = obj.nickname + app.nicks[obj.conn.name] = obj.nickname if obj.conn.name in self.show_vcard_when_connect: self.show_vcard_when_connect.remove(obj.conn.name) def handle_event_gc_config(self, obj): #('GC_CONFIG', account, (jid, form_node)) config is a dict account = obj.conn.name - if obj.jid in gajim.automatic_rooms[account]: - if 'continue_tag' in gajim.automatic_rooms[account][obj.jid]: + if obj.jid in app.automatic_rooms[account]: + if 'continue_tag' in app.automatic_rooms[account][obj.jid]: # We're converting chat to muc. allow participants to invite for f in obj.dataform.iter_fields(): if f.var == 'muc#roomconfig_allowinvites': @@ -585,7 +585,7 @@ class Interface: f.value = False obj.conn.send_gc_config(obj.jid, obj.dataform.get_purged()) user_list = {} - for jid in gajim.automatic_rooms[account][obj.jid]['invities']: + for jid in app.automatic_rooms[account][obj.jid]['invities']: user_list[jid] = {'affiliation': 'member'} obj.conn.send_gc_affiliation_list(obj.jid, user_list) else: @@ -594,10 +594,10 @@ class Interface: # invite contacts # check if it is necessary to add continue_tag = False - if 'continue_tag' in gajim.automatic_rooms[account][obj.jid]: + if 'continue_tag' in app.automatic_rooms[account][obj.jid]: continue_tag = True - if 'invities' in gajim.automatic_rooms[account][obj.jid]: - for jid in gajim.automatic_rooms[account][obj.jid]['invities']: + if 'invities' in app.automatic_rooms[account][obj.jid]: + for jid in app.automatic_rooms[account][obj.jid]['invities']: obj.conn.send_invite(obj.jid, jid, continue_tag=continue_tag) gc_control = self.msg_win_mgr.get_gc_control(obj.jid, @@ -606,7 +606,7 @@ class Interface: gc_control.print_conversation( _('%(jid)s has been invited in this room') % { 'jid': jid}, graphics=False) - del gajim.automatic_rooms[account][obj.jid] + del app.automatic_rooms[account][obj.jid] elif obj.jid not in self.instances[account]['gc_config']: self.instances[account]['gc_config'][obj.jid] = \ config.GroupchatConfigWindow(account, obj.jid, obj.dataform) @@ -720,7 +720,7 @@ class Interface: def on_ok(passphrase, save): if save: - gajim.config.set_per('accounts', account, 'savepass', True) + app.config.set_per('accounts', account, 'savepass', True) passwords.save_password(account, passphrase) obj.conn.set_password(passphrase) del self.pass_dialog[account] @@ -737,16 +737,16 @@ class Interface: def handle_oauth2_credentials(self, obj): account = obj.conn.name def on_ok(refresh): - gajim.config.set_per('accounts', account, 'oauth2_refresh_token', + app.config.set_per('accounts', account, 'oauth2_refresh_token', refresh) - st = gajim.config.get_per('accounts', account, 'last_status') - msg = helpers.from_one_line(gajim.config.get_per('accounts', + st = app.config.get_per('accounts', account, 'last_status') + msg = helpers.from_one_line(app.config.get_per('accounts', account, 'last_status_msg')) - gajim.interface.roster.send_status(account, st, msg) + app.interface.roster.send_status(account, st, msg) del self.pass_dialog[account] def on_cancel(): - gajim.config.set_per('accounts', account, 'oauth2_refresh_token', + app.config.set_per('accounts', account, 'oauth2_refresh_token', '') self.roster.set_state(account, 'offline') self.roster.update_status_combobox() @@ -761,7 +761,7 @@ class Interface: def handle_event_roster_info(self, obj): #('ROSTER_INFO', account, (jid, name, sub, ask, groups)) account = obj.conn.name - contacts = gajim.contacts.get_contacts(account, obj.jid) + contacts = app.contacts.get_contacts(account, obj.jid) if (not obj.sub or obj.sub == 'none') and \ (not obj.ask or obj.ask == 'none') and not obj.nickname and \ not obj.groups: @@ -774,14 +774,14 @@ class Interface: return # Add new contact to roster keyID = '' - attached_keys = gajim.config.get_per('accounts', account, + attached_keys = app.config.get_per('accounts', account, 'attached_gpg_keys').split() if obj.jid in attached_keys: keyID = attached_keys[attached_keys.index(obj.jid) + 1] - contact = gajim.contacts.create_contact(jid=obj.jid, + contact = app.contacts.create_contact(jid=obj.jid, account=account, name=obj.nickname, groups=obj.groups, show='offline', sub=obj.sub, ask=obj.ask, keyID=keyID) - gajim.contacts.add_contact(account, contact) + app.contacts.add_contact(account, contact) self.roster.add_contact(obj.jid, account) else: # If contact has changed (sub, ask or group) update roster @@ -821,7 +821,7 @@ class Interface: # Auto join GC windows if neccessary gui_menu_builder.build_bookmark_menu(obj.conn.name) - invisible_show = gajim.SHOW_LIST.index('invisible') + invisible_show = app.SHOW_LIST.index('invisible') # do not autojoin if we are invisible if obj.conn.connected == invisible_show: return @@ -852,7 +852,7 @@ class Interface: jid = obj.jid gmail_new_messages = int(obj.newmsgs) gmail_messages_list = obj.gmail_messages_list - if not gajim.config.get('notify_on_new_gmail_email'): + if not app.config.get('notify_on_new_gmail_email'): return path = gtkgui_helpers.get_icon_path('gajim-new_email_recv', 48) title = _('New e-mail on %(gmail_mail_address)s') % \ @@ -861,7 +861,7 @@ class Interface: 'You have %d new e-mail conversations', gmail_new_messages, gmail_new_messages, gmail_new_messages) - if gajim.config.get('notify_on_new_gmail_email_extra'): + if app.config.get('notify_on_new_gmail_email_extra'): cnt = 0 for gmessage in gmail_messages_list: # FIXME: emulate Gtalk client popups. find out what they @@ -876,11 +876,11 @@ class Interface: 'snippet': gmessage['Snippet']} cnt += 1 - command = gajim.config.get('notify_on_new_gmail_email_command') + command = app.config.get('notify_on_new_gmail_email_command') if command: Popen(command, shell=True) - if gajim.config.get_per('soundevents', 'gmail_received', 'enabled'): + if app.config.get_per('soundevents', 'gmail_received', 'enabled'): helpers.play_sound('gmail_received') notify.popup(_('New E-mail'), jid, obj.conn.name, 'gmail', path_to_image=path, title=title, text=text) @@ -917,17 +917,17 @@ class Interface: def handle_event_file_request(self, obj): account = obj.conn.name - if obj.jid not in gajim.contacts.get_jid_list(account): + if obj.jid not in app.contacts.get_jid_list(account): keyID = '' - attached_keys = gajim.config.get_per('accounts', account, + attached_keys = app.config.get_per('accounts', account, 'attached_gpg_keys').split() if obj.jid in attached_keys: keyID = attached_keys[attached_keys.index(obj.jid) + 1] - contact = gajim.contacts.create_not_in_roster_contact(jid=obj.jid, + contact = app.contacts.create_not_in_roster_contact(jid=obj.jid, account=account, keyID=keyID) - gajim.contacts.add_contact(account, contact) + app.contacts.add_contact(account, contact) self.roster.add_contact(obj.jid, account) - contact = gajim.contacts.get_first_contact_from_jid(account, obj.jid) + contact = app.contacts.get_first_contact_from_jid(account, obj.jid) if obj.file_props.session_type == 'jingle': request = obj.stanza.getTag('jingle').getTag('content')\ .getTag('description').getTag('request') @@ -944,7 +944,7 @@ class Interface: self.add_event(account, obj.jid, event) if helpers.allow_showing_notification(account): path = gtkgui_helpers.get_icon_path('gajim-ft_request', 48) - txt = _('%s wants to send you a file.') % gajim.get_name_from_jid( + txt = _('%s wants to send you a file.') % app.get_name_from_jid( account, obj.jid) event_type = _('File Transfer Request') notify.popup(event_type, obj.jid, account, 'file-request', @@ -962,7 +962,7 @@ class Interface: file_props.sid, file_props.received_len) def __compare_hashes(self, account, file_props): - session = gajim.connections[account].get_jingle_session(jid=None, + session = app.connections[account].get_jingle_session(jid=None, sid=file_props.sid) ft_win = self.instances['file_transfers'] h = Hashes2() @@ -992,7 +992,7 @@ class Interface: if file_props.error == 0: ft.set_progress(file_props.type_, file_props.sid, file_props.received_len) - gajim.nec.push_incoming_event(FileTransferCompletedEvent(None, + app.nec.push_incoming_event(FileTransferCompletedEvent(None, file_props=file_props)) else: ft.set_status(file_props, 'stop') @@ -1001,7 +1001,7 @@ class Interface: return if file_props.type_ == 'r': # we receive a file - gajim.socks5queue.remove_receiver(file_props.sid, True, True) + app.socks5queue.remove_receiver(file_props.sid, True, True) if file_props.session_type == 'jingle': if file_props.hash_ and file_props.error == 0: # We compare hashes in a new thread @@ -1014,7 +1014,7 @@ class Interface: self.popup_ft_result(account, jid, file_props) if file_props.error == 0: ft.set_status(file_props, 'ok') - session = gajim.connections[account].get_jingle_session(jid=None, + session = app.connections[account].get_jingle_session(jid=None, sid=file_props.sid) # End jingle session # TODO: only if there are no other parallel downloads in this session @@ -1022,14 +1022,14 @@ class Interface: session.end_session() else: # we send a file jid = file_props.receiver - gajim.socks5queue.remove_sender(file_props.sid, True, True) + app.socks5queue.remove_sender(file_props.sid, True, True) self.popup_ft_result(account, jid, file_props) def popup_ft_result(self, account, jid, file_props): ft = self.instances['file_transfers'] if helpers.allow_popup_window(account): if file_props.error == 0: - if gajim.config.get('notify_on_file_complete'): + if app.config.get('notify_on_file_complete'): ft.show_completed(jid, file_props) elif file_props.error == -1: ft.show_stopped(jid, file_props, @@ -1046,7 +1046,7 @@ class Interface: msg_type = '' event_type = '' - if file_props.error == 0 and gajim.config.get( + if file_props.error == 0 and app.config.get( 'notify_on_file_complete'): event_class = events.FileCompletedEvent msg_type = 'file-completed' @@ -1076,7 +1076,7 @@ class Interface: if file_props.type_ == 'r': # get the name of the sender, as it is in the roster sender = file_props.sender.split('/')[0] - name = gajim.contacts.get_first_contact_from_jid(account, + name = app.contacts.get_first_contact_from_jid(account, sender).get_shown_name() filename = os.path.basename(file_props.file_name) if event_type == _('File Transfer Completed'): @@ -1097,7 +1097,7 @@ class Interface: receiver = receiver.jid receiver = receiver.split('/')[0] # get the name of the contact, as it is in the roster - name = gajim.contacts.get_first_contact_from_jid(account, + name = app.contacts.get_first_contact_from_jid(account, receiver).get_shown_name() filename = os.path.basename(file_props.file_name) if event_type == _('File Transfer Completed'): @@ -1117,9 +1117,9 @@ class Interface: txt = '' path = '' - if gajim.config.get('notify_on_file_complete') and \ - (gajim.config.get('autopopupaway') or \ - gajim.connections[account].connected in (2, 3)): + if app.config.get('notify_on_file_complete') and \ + (app.config.get('autopopupaway') or \ + app.connections[account].connected in (2, 3)): # we want to be notified and we are online/chat or we don't mind # bugged when away/na/busy notify.popup(event_type, jid, account, msg_type, path_to_image=path, @@ -1132,40 +1132,40 @@ class Interface: # ('SIGNED_IN', account, ()) # block signed in notifications for 30 seconds account = obj.conn.name - gajim.block_signed_in_notifications[account] = True + app.block_signed_in_notifications[account] = True state = self.sleeper.getState() connected = obj.conn.connected if state != sleepy.STATE_UNKNOWN and connected in (2, 3): # we go online or free for chat, so we activate auto status - gajim.sleeper_state[account] = 'online' + app.sleeper_state[account] = 'online' elif not ((state == sleepy.STATE_AWAY and connected == 4) or \ (state == sleepy.STATE_XA and connected == 5)): # If we are autoaway/xa and come back after a disconnection, do # nothing # Else disable autoaway - gajim.sleeper_state[account] = 'off' + app.sleeper_state[account] = 'off' - if obj.conn.archiving_313_supported and gajim.config.get_per('accounts', + if obj.conn.archiving_313_supported and app.config.get_per('accounts', account, 'sync_logs_with_server'): obj.conn.request_archive_on_signin() - invisible_show = gajim.SHOW_LIST.index('invisible') + invisible_show = app.SHOW_LIST.index('invisible') # We cannot join rooms if we are invisible if connected == invisible_show: return # send currently played music if obj.conn.pep_supported and dbus_support.supported and \ - gajim.config.get_per('accounts', account, 'publish_tune'): + app.config.get_per('accounts', account, 'publish_tune'): self.enable_music_listener() # enable location listener if obj.conn.pep_supported and dbus_support.supported and \ - gajim.config.get_per('accounts', account, 'publish_location'): + app.config.get_per('accounts', account, 'publish_location'): location_listener.enable() @staticmethod def handle_event_metacontacts(obj): - gajim.contacts.define_metacontacts(obj.conn.name, obj.meta_list) + app.contacts.define_metacontacts(obj.conn.name, obj.meta_list) @staticmethod def handle_atom_entry(obj): @@ -1179,7 +1179,7 @@ class Interface: def handle_event_zc_name_conflict(self, obj): def on_ok(new_name): - gajim.config.set_per('accounts', obj.conn.name, 'name', new_name) + app.config.set_per('accounts', obj.conn.name, 'name', new_name) show = obj.conn.old_show status = obj.conn.status obj.conn.username = new_name @@ -1199,10 +1199,10 @@ class Interface: conn = obj.conn self.roster.send_status(account, 'offline', conn.status) def on_ok(new_resource): - gajim.config.set_per('accounts', account, 'resource', new_resource) + app.config.set_per('accounts', account, 'resource', new_resource) self.roster.send_status(account, conn.old_show, conn.status) proposed_resource = conn.server_resource - proposed_resource += gajim.config.get('gc_proposed_nick_char') + proposed_resource += app.config.get('gc_proposed_nick_char') dlg = dialogs.ResourceConflictDialog(_('Resource Conflict'), _('You are already connected to this account with the same ' 'resource. Please type a new one'), resource=proposed_resource, @@ -1262,7 +1262,7 @@ class Interface: if helpers.allow_showing_notification(account): # TODO: we should use another pixmap ;-) txt = _('%s wants to start a voice chat.') % \ - gajim.get_name_from_jid(account, obj.fjid) + app.get_name_from_jid(account, obj.fjid) path = gtkgui_helpers.get_icon_path('gajim-mic_active', 48) event_type = _('Voice Chat Request') notify.popup(event_type, obj.fjid, account, 'jingle-incoming', @@ -1316,42 +1316,42 @@ class Interface: def handle_event_ssl_error(self, obj): # ('SSL_ERROR', account, (text, errnum, cert, sha1_fingerprint, sha256_fingerprint)) account = obj.conn.name - server = gajim.config.get_per('accounts', account, 'hostname') + server = app.config.get_per('accounts', account, 'hostname') def on_ok(is_checked): del self.instances[account]['online_dialog']['ssl_error'] if is_checked[0]: # Check if cert is already in file certs = '' - if os.path.isfile(gajim.MY_CACERTS): - f = open(gajim.MY_CACERTS) + if os.path.isfile(app.MY_CACERTS): + f = open(app.MY_CACERTS) certs = f.read() f.close() if obj.cert in certs: dialogs.ErrorDialog(_('Certificate Already in File'), _('This certificate is already in file %s, so it\'s ' - 'not added again.') % gajim.MY_CACERTS) + 'not added again.') % app.MY_CACERTS) else: - f = open(gajim.MY_CACERTS, 'a') + f = open(app.MY_CACERTS, 'a') f.write(server + '\n') f.write(obj.cert + '\n\n') f.close() - gajim.config.set_per('accounts', account, 'ssl_fingerprint_sha1', + app.config.set_per('accounts', account, 'ssl_fingerprint_sha1', obj.fingerprint_sha1) - gajim.config.set_per('accounts', account, 'ssl_fingerprint_sha256', + app.config.set_per('accounts', account, 'ssl_fingerprint_sha256', obj.fingerprint_sha256) if is_checked[1]: - ignore_ssl_errors = gajim.config.get_per('accounts', account, + ignore_ssl_errors = app.config.get_per('accounts', account, 'ignore_ssl_errors').split() ignore_ssl_errors.append(str(obj.error_num)) - gajim.config.set_per('accounts', account, 'ignore_ssl_errors', + app.config.set_per('accounts', account, 'ignore_ssl_errors', ' '.join(ignore_ssl_errors)) obj.conn.ssl_certificate_accepted() def on_cancel(): del self.instances[account]['online_dialog']['ssl_error'] obj.conn.disconnect(on_purpose=True) - gajim.nec.push_incoming_event(OurShowEvent(None, conn=obj.conn, + app.nec.push_incoming_event(OurShowEvent(None, conn=obj.conn, show='offline')) pritext = _('Error verifying SSL certificate') @@ -1377,7 +1377,7 @@ class Interface: def handle_event_non_anonymous_server(self, obj): account = obj.conn.name - server = gajim.config.get_per('accounts', account, 'hostname') + server = app.config.get_per('accounts', account, 'hostname') dialogs.ErrorDialog(_('Non Anonymous Server'), sectext='Server "%s"' 'does not support anonymous connection' % server, transient_for=self.roster.window) @@ -1387,18 +1387,18 @@ class Interface: account = obj.conn.name def on_yes(is_checked): del self.instances[account]['online_dialog']['fingerprint_error'] - gajim.config.set_per('accounts', account, 'ssl_fingerprint_sha1', + app.config.set_per('accounts', account, 'ssl_fingerprint_sha1', obj.new_fingerprint_sha1) - gajim.config.set_per('accounts', account, 'ssl_fingerprint_sha256', + app.config.set_per('accounts', account, 'ssl_fingerprint_sha256', obj.new_fingerprint_sha256) # Reset the ignored ssl errors - gajim.config.set_per('accounts', account, 'ignore_ssl_errors', '') + app.config.set_per('accounts', account, 'ignore_ssl_errors', '') obj.conn.ssl_certificate_accepted() def on_no(): del self.instances[account]['online_dialog']['fingerprint_error'] obj.conn.disconnect(on_purpose=True) - gajim.nec.push_incoming_event(OurShowEvent(None, conn=obj.conn, + app.nec.push_incoming_event(OurShowEvent(None, conn=obj.conn, show='offline')) pritext = _('SSL certificate error') @@ -1410,8 +1410,8 @@ class Interface: '%(new_sha256)s\n\nDo you still want to connect ' 'and update the fingerprint of the certificate?') % \ {'account': account, - 'old_sha1': gajim.config.get_per('accounts', account, 'ssl_fingerprint_sha1'), - 'old_sha256': gajim.config.get_per('accounts', account, 'ssl_fingerprint_sha256'), + 'old_sha1': app.config.get_per('accounts', account, 'ssl_fingerprint_sha1'), + 'old_sha256': app.config.get_per('accounts', account, 'ssl_fingerprint_sha256'), 'new_sha1': obj.new_fingerprint_sha1, 'new_sha256': obj.new_fingerprint_sha256} if 'fingerprint_error' in self.instances[account]['online_dialog']: @@ -1427,7 +1427,7 @@ class Interface: def on_ok(is_checked): if not is_checked[0]: if is_checked[1]: - gajim.config.set_per('accounts', obj.conn.name, + app.config.set_per('accounts', obj.conn.name, 'action_when_plaintext_connection', 'disconnect') on_cancel() return @@ -1436,7 +1436,7 @@ class Interface: del self.instances[obj.conn.name]['online_dialog']\ ['plain_connection'] if is_checked[1]: - gajim.config.set_per('accounts', obj.conn.name, + app.config.set_per('accounts', obj.conn.name, 'action_when_plaintext_connection', 'connect') obj.conn.connection_accepted(obj.xmpp_client, 'plain') @@ -1444,7 +1444,7 @@ class Interface: del self.instances[obj.conn.name]['online_dialog']\ ['plain_connection'] obj.conn.disconnect(on_purpose=True) - gajim.nec.push_incoming_event(OurShowEvent(None, conn=obj.conn, + app.nec.push_incoming_event(OurShowEvent(None, conn=obj.conn, show='offline')) if 'plain_connection' in self.instances[obj.conn.name]['online_dialog']: @@ -1461,7 +1461,7 @@ class Interface: return del self.instances[obj.conn.name]['online_dialog']['insecure_ssl'] if is_checked[1]: - gajim.config.set_per('accounts', obj.conn.name, + app.config.set_per('accounts', obj.conn.name, 'warn_when_insecure_ssl_connection', False) if obj.conn.connected == 0: # We have been disconnecting (too long time since window is @@ -1476,7 +1476,7 @@ class Interface: def on_cancel(): del self.instances[obj.conn.name]['online_dialog']['insecure_ssl'] obj.conn.disconnect(on_purpose=True) - gajim.nec.push_incoming_event(OurShowEvent(None, conn=obj.conn, + app.nec.push_incoming_event(OurShowEvent(None, conn=obj.conn, show='offline')) pritext = _('Insecure connection') @@ -1502,7 +1502,7 @@ class Interface: del self.instances[obj.conn.name]['online_dialog']\ ['insecure_password'] if is_checked[1]: - gajim.config.set_per('accounts', obj.conn.name, + app.config.set_per('accounts', obj.conn.name, 'warn_when_insecure_password', False) if obj.conn.connected == 0: # We have been disconnecting (too long time since window is @@ -1518,7 +1518,7 @@ class Interface: del self.instances[obj.conn.name]['online_dialog']\ ['insecure_password'] obj.conn.disconnect(on_purpose=True) - gajim.nec.push_incoming_event(OurShowEvent(None, conn=obj.conn, + app.nec.push_incoming_event(OurShowEvent(None, conn=obj.conn, show='offline')) pritext = _('Insecure connection') @@ -1609,21 +1609,21 @@ class Interface: if type(event_handler) == tuple: prio = event_handler[1] event_handler = event_handler[0] - gajim.ged.register_event_handler(event_name, prio, + app.ged.register_event_handler(event_name, prio, event_handler) ################################################################################ -### Methods dealing with gajim.events +### Methods dealing with app.events ################################################################################ def add_event(self, account, jid, event): """ - Add an event to the gajim.events var + Add an event to the app.events var """ - # We add it to the gajim.events queue + # We add it to the app.events queue # Do we have a queue? - jid = gajim.get_jid_without_resource(jid) - no_queue = len(gajim.events.get_events(account, jid)) == 0 + jid = app.get_jid_without_resource(jid) + no_queue = len(app.events.get_events(account, jid)) == 0 # event can be in common.events.* # event_type can be in advancedNotificationWindow.events_list event_types = {'file-request': 'ft_request', @@ -1633,21 +1633,21 @@ class Interface: show_in_systray = notify.get_show_in_systray(event_type, account, jid) event.show_in_roster = show_in_roster event.show_in_systray = show_in_systray - gajim.events.add_event(account, jid, event) + app.events.add_event(account, jid, event) self.roster.show_title() if no_queue: # We didn't have a queue: we change icons - if gajim.contacts.get_contact_with_highest_priority(account, jid): + if app.contacts.get_contact_with_highest_priority(account, jid): self.roster.draw_contact(jid, account) else: self.roster.add_to_not_in_the_roster(account, jid) # Select the big brother contact in roster, it's visible because it has # events. - family = gajim.contacts.get_metacontacts_family(account, jid) + family = app.contacts.get_metacontacts_family(account, jid) if family: nearby_family, bb_jid, bb_account = \ - gajim.contacts.get_nearby_family_and_big_brother(family, + app.contacts.get_nearby_family_and_big_brother(family, account) else: bb_jid, bb_account = jid, account @@ -1658,8 +1658,8 @@ class Interface: ctrl = None session = None - resource = gajim.get_resource_from_jid(fjid) - jid = gajim.get_jid_without_resource(fjid) + resource = app.get_resource_from_jid(fjid) + jid = app.get_jid_without_resource(fjid) if type_ in ('printed_gc_msg', 'printed_marked_gc_msg', 'gc_msg'): w = self.msg_win_mgr.get_window(jid, account) @@ -1673,9 +1673,9 @@ class Interface: # '' is for log in/out notifications if type_ != '': - event = gajim.events.get_first_event(account, fjid, type_) + event = app.events.get_first_event(account, fjid, type_) if not event: - event = gajim.events.get_first_event(account, jid, type_) + event = app.events.get_first_event(account, jid, type_) if not event: return @@ -1688,34 +1688,34 @@ class Interface: ctrl = self.msg_win_mgr.get_control(fjid, account) if not ctrl: - highest_contact = gajim.contacts.\ + highest_contact = app.contacts.\ get_contact_with_highest_priority(account, jid) # jid can have a window if this resource was lower when he sent # message and is now higher because the other one is offline if resource and highest_contact.resource == resource and \ not self.msg_win_mgr.has_window(jid, account): # remove resource of events too - gajim.events.change_jid(account, fjid, jid) + app.events.change_jid(account, fjid, jid) resource = None fjid = jid contact = None if resource: - contact = gajim.contacts.get_contact(account, jid, resource) + contact = app.contacts.get_contact(account, jid, resource) if not contact: contact = highest_contact ctrl = self.new_chat(contact, account, resource=resource, session=session) - gajim.last_message_time[account][jid] = 0 # long time ago + app.last_message_time[account][jid] = 0 # long time ago w = ctrl.parent_win elif type_ in ('printed_pm', 'pm'): # assume that the most recently updated control we have for this # party is the one that this event was in - event = gajim.events.get_first_event(account, fjid, type_) + event = app.events.get_first_event(account, fjid, type_) if not event: - event = gajim.events.get_first_event(account, jid, type_) + event = app.events.get_first_event(account, jid, type_) if not event: return @@ -1729,18 +1729,18 @@ class Interface: elif not ctrl: room_jid = jid nick = resource - gc_contact = gajim.contacts.get_gc_contact(account, room_jid, + gc_contact = app.contacts.get_gc_contact(account, room_jid, nick) if gc_contact: show = gc_contact.show else: show = 'offline' - gc_contact = gajim.contacts.create_gc_contact( + gc_contact = app.contacts.create_gc_contact( room_jid=room_jid, account=account, name=nick, show=show) if not session: - session = gajim.connections[account].make_new_session( + session = app.connections[account].make_new_session( fjid, None, type_='pm') self.new_private_chat(gc_contact, account, session=session) @@ -1751,10 +1751,10 @@ class Interface: 'file-send-error', 'file-error', 'file-stopped', 'file-completed', 'file-hash-error', 'jingle-incoming'): # Get the first single message event - event = gajim.events.get_first_event(account, fjid, type_) + event = app.events.get_first_event(account, fjid, type_) if not event: # default to jid without resource - event = gajim.events.get_first_event(account, jid, type_) + event = app.events.get_first_event(account, jid, type_) if not event: return # Open the window @@ -1763,25 +1763,25 @@ class Interface: # Open the window self.roster.open_event(account, fjid, event) elif type_ == 'gmail': - url = gajim.connections[account].gmail_url + url = app.connections[account].gmail_url if url: helpers.launch_browser_mailer('url', url) elif type_ == 'gc-invitation': - event = gajim.events.get_first_event(account, jid, type_) + event = app.events.get_first_event(account, jid, type_) dialogs.InvitationReceivedDialog(account, event.room_jid, jid, event.password, event.reason, event.is_continued) - gajim.events.remove_events(account, jid, event) + app.events.remove_events(account, jid, event) self.roster.draw_contact(jid, account) elif type_ == 'subscription_request': - event = gajim.events.get_first_event(account, jid, type_) + event = app.events.get_first_event(account, jid, type_) dialogs.SubscriptionRequestWindow(jid, event.text, account, event.nick) - gajim.events.remove_events(account, jid, event) + app.events.remove_events(account, jid, event) self.roster.draw_contact(jid, account) elif type_ == 'unsubscribed': - event = gajim.events.get_first_event(account, jid, type_) + event = app.events.get_first_event(account, jid, type_) self.show_unsubscribed_dialog(account, event.contact) - gajim.events.remove_events(account, jid, event) + app.events.remove_events(account, jid, event) self.roster.draw_contact(jid, account) if w: w.set_active_tab(ctrl) @@ -1874,12 +1874,12 @@ class Interface: link_pattern = basic_pattern self.link_pattern_re = re.compile(link_pattern, re.I | re.U) - if gajim.config.get('ascii_formatting'): + if app.config.get('ascii_formatting'): basic_pattern += formatting self.basic_pattern = basic_pattern emoticons_pattern = '' - if gajim.config.get('emoticons_theme'): + if app.config.get('emoticons_theme'): # When an emoticon is bordered by an alpha-numeric character it is # NOT expanded. e.g., foo:) NO, foo :) YES, (brb) NO, (:)) YES, etc # We still allow multiple emoticons side-by-side like :P:P:P @@ -1924,25 +1924,25 @@ class Interface: '[\ud800-\udfff]|[\ufffe-\uffff]' def init_emoticons(self): - emot_theme = gajim.config.get('emoticons_theme') + emot_theme = app.config.get('emoticons_theme') if not emot_theme: return transient_for = None - if 'preferences' in gajim.interface.instances: - transient_for = gajim.interface.instances['preferences'].window + if 'preferences' in app.interface.instances: + transient_for = app.interface.instances['preferences'].window - path = os.path.join(gajim.DATA_DIR, 'emoticons', emot_theme) + path = os.path.join(app.DATA_DIR, 'emoticons', emot_theme) if not os.path.exists(path): # It's maybe a user theme - path = os.path.join(gajim.MY_EMOTS_PATH, emot_theme) + path = os.path.join(app.MY_EMOTS_PATH, emot_theme) if not os.path.exists(path): # theme doesn't exist, disable emoticons dialogs.WarningDialog(_('Emoticons disabled'), _('Your configured emoticons theme has not been found, so ' 'emoticons have been disabled.'), transient_for=transient_for) - gajim.config.set('emoticons_theme', '') + app.config.set('emoticons_theme', '') return if not emoticons.load(path): dialogs.WarningDialog( @@ -1950,7 +1950,7 @@ class Interface: _('Your configured emoticons theme could not be loaded.' ' See the log for more details.'), transient_for=transient_for) - gajim.config.set('emoticons_theme', '') + app.config.set('emoticons_theme', '') return ################################################################################ @@ -1963,8 +1963,8 @@ class Interface: Join the room immediately """ - if gajim.contacts.get_contact(account, room_jid) and \ - not gajim.contacts.get_contact(account, room_jid).is_groupchat(): + if app.contacts.get_contact(account, room_jid) and \ + not app.contacts.get_contact(account, room_jid).is_groupchat(): dialogs.ErrorDialog(_('This is not a group chat'), _('%s is already in your roster. Please check if %s is a ' 'correct group chat name. If it is, delete it from your roster ' @@ -1972,13 +1972,13 @@ class Interface: return if not nick: - nick = gajim.nicks[account] + nick = app.nicks[account] - minimized_control = gajim.interface.minimized_controls[account].get( + minimized_control = app.interface.minimized_controls[account].get( room_jid, None) if (self.msg_win_mgr.has_window(room_jid, account) or \ - minimized_control) and gajim.gc_connected[account][room_jid]: + minimized_control) and app.gc_connected[account][room_jid]: if self.msg_win_mgr.has_window(room_jid, account): gc_ctrl = self.msg_win_mgr.get_gc_control(room_jid, account) win = gc_ctrl.parent_win @@ -1989,8 +1989,8 @@ class Interface: room_jid) return - invisible_show = gajim.SHOW_LIST.index('invisible') - if gajim.connections[account].connected == invisible_show: + invisible_show = app.SHOW_LIST.index('invisible') + if app.connections[account].connected == invisible_show: dialogs.ErrorDialog( _('You cannot join a group chat while you are invisible')) return @@ -2000,10 +2000,10 @@ class Interface: # Join new groupchat if minimize: # GCMIN - contact = gajim.contacts.create_contact(jid=room_jid, + contact = app.contacts.create_contact(jid=room_jid, account=account, name=nick) gc_control = GroupchatControl(None, contact, account) - gajim.interface.minimized_controls[account][room_jid] = \ + app.interface.minimized_controls[account][room_jid] = \ gc_control self.roster.add_groupchat(room_jid, account) else: @@ -2016,14 +2016,14 @@ class Interface: gc_control.parent_win.set_active_tab(gc_control) # Connect - gajim.connections[account].join_gc(nick, room_jid, password) + app.connections[account].join_gc(nick, room_jid, password) if password: - gajim.gc_passwords[room_jid] = password + app.gc_passwords[room_jid] = password def new_room(self, room_jid, nick, account, is_continued=False): # Get target window, create a control, and associate it with the window # GCMIN - contact = gajim.contacts.create_contact(jid=room_jid, account=account, + contact = app.contacts.create_contact(jid=room_jid, account=account, name=nick) mw = self.msg_win_mgr.get_window(contact.jid, account) if not mw: @@ -2035,7 +2035,7 @@ class Interface: mw.set_active_tab(gc_control) def new_private_chat(self, gc_contact, account, session=None): - conn = gajim.connections[account] + conn = app.connections[account] if not session and gc_contact.get_full_jid() in conn.sessions: sessions = [s for s in conn.sessions[gc_contact.get_full_jid()].\ values() if isinstance(s, ChatControlSession)] @@ -2066,7 +2066,7 @@ class Interface: contact, account, session) message_window.new_tab(session.control) - if gajim.events.get_events(account, gc_contact.get_full_jid()): + if app.events.get_events(account, gc_contact.get_full_jid()): # We call this here to avoid race conditions with widget validation session.control.read_queue() @@ -2089,15 +2089,15 @@ class Interface: mw.new_tab(chat_control) - if len(gajim.events.get_events(account, fjid)): + if len(app.events.get_events(account, fjid)): # We call this here to avoid race conditions with widget validation chat_control.read_queue() return chat_control def new_chat_from_jid(self, account, fjid, message=None): - jid, resource = gajim.get_room_and_nick_from_fjid(fjid) - contact = gajim.contacts.get_contact(account, jid, resource) + jid, resource = app.get_room_and_nick_from_fjid(fjid) + contact = app.contacts.get_contact(account, jid, resource) added_to_roster = False if not contact: added_to_roster = True @@ -2109,7 +2109,7 @@ class Interface: if not ctrl: ctrl = self.new_chat(contact, account, resource=resource) - if len(gajim.events.get_events(account, fjid)): + if len(app.events.get_events(account, fjid)): ctrl.read_queue() if message: @@ -2119,7 +2119,7 @@ class Interface: mw.set_active_tab(ctrl) # For JEP-0172 if added_to_roster: - ctrl.user_nick = gajim.nicks[account] + ctrl.user_nick = app.nicks[account] GLib.idle_add(mw.window.grab_focus) return ctrl @@ -2146,14 +2146,14 @@ class Interface: ctrl = self.new_chat(contact, account, resource=resource, session=session) # last message is long time ago - gajim.last_message_time[account][ctrl.get_full_jid()] = 0 + app.last_message_time[account][ctrl.get_full_jid()] = 0 win = ctrl.parent_win win.set_active_tab(ctrl) - if gajim.connections[account].is_zeroconf and \ - gajim.connections[account].status in ('offline', 'invisible'): + if app.connections[account].is_zeroconf and \ + app.connections[account].status in ('offline', 'invisible'): ctrl = win.get_control(fjid, account) if ctrl: ctrl.got_disconnected() @@ -2174,7 +2174,7 @@ class Interface: return except Exception: return - iconset = gajim.config.get('iconset') + iconset = app.config.get('iconset') prefix = os.path.join(helpers.get_iconset_path(iconset), '32x32') if status in ('chat', 'away', 'xa', 'dnd', 'invisible', 'offline'): status = status + '.png' @@ -2205,7 +2205,7 @@ class Interface: @staticmethod def music_track_changed(unused_listener, music_track_info, account=None): if not account: - accounts = gajim.connections.keys() + accounts = app.connections.keys() else: accounts = [account] @@ -2218,16 +2218,16 @@ class Interface: title = music_track_info.title source = music_track_info.album for acct in accounts: - if not gajim.account_is_connected(acct): + if not app.account_is_connected(acct): continue - if not gajim.connections[acct].pep_supported: + if not app.connections[acct].pep_supported: continue - if not gajim.config.get_per('accounts', acct, 'publish_tune'): + if not app.config.get_per('accounts', acct, 'publish_tune'): continue - if gajim.connections[acct].music_track_info == music_track_info: + if app.connections[acct].music_track_info == music_track_info: continue - gajim.connections[acct].send_tune(artist, title, source) - gajim.connections[acct].music_track_info = music_track_info + app.connections[acct].send_tune(artist, title, source) + app.connections[acct].music_track_info = music_track_info def read_sleepy(self): """ @@ -2237,67 +2237,67 @@ class Interface: # idle detection is not supported in that OS return False # stop looping in vain state = self.sleeper.getState() - for account in gajim.connections: - if account not in gajim.sleeper_state or \ - not gajim.sleeper_state[account]: + for account in app.connections: + if account not in app.sleeper_state or \ + not app.sleeper_state[account]: continue if state == sleepy.STATE_AWAKE: - if gajim.sleeper_state[account] in ('autoaway', 'autoxa'): + if app.sleeper_state[account] in ('autoaway', 'autoxa'): # we go online self.roster.send_status(account, 'online', - gajim.status_before_autoaway[account]) - gajim.status_before_autoaway[account] = '' - gajim.sleeper_state[account] = 'online' - if gajim.sleeper_state[account] == 'idle': + app.status_before_autoaway[account]) + app.status_before_autoaway[account] = '' + app.sleeper_state[account] = 'online' + if app.sleeper_state[account] == 'idle': # we go to the previous state - connected = gajim.connections[account].connected - self.roster.send_status(account, gajim.SHOW_LIST[connected], - gajim.status_before_autoaway[account]) - gajim.status_before_autoaway[account] = '' - gajim.sleeper_state[account] = 'off' - elif state == sleepy.STATE_AWAY and gajim.config.get('autoaway'): - if gajim.sleeper_state[account] == 'online': + connected = app.connections[account].connected + self.roster.send_status(account, app.SHOW_LIST[connected], + app.status_before_autoaway[account]) + app.status_before_autoaway[account] = '' + app.sleeper_state[account] = 'off' + elif state == sleepy.STATE_AWAY and app.config.get('autoaway'): + if app.sleeper_state[account] == 'online': # we save out online status - gajim.status_before_autoaway[account] = \ - gajim.connections[account].status + app.status_before_autoaway[account] = \ + app.connections[account].status # we go away (no auto status) [we pass True to auto param] - auto_message = gajim.config.get('autoaway_message') + auto_message = app.config.get('autoaway_message') if not auto_message: - auto_message = gajim.connections[account].status + auto_message = app.connections[account].status else: auto_message = auto_message.replace('$S', '%(status)s') auto_message = auto_message.replace('$T', '%(time)s') auto_message = auto_message % { - 'status': gajim.status_before_autoaway[account], - 'time': gajim.config.get('autoawaytime') + 'status': app.status_before_autoaway[account], + 'time': app.config.get('autoawaytime') } self.roster.send_status(account, 'away', auto_message, auto=True) - gajim.sleeper_state[account] = 'autoaway' - elif gajim.sleeper_state[account] == 'off': + app.sleeper_state[account] = 'autoaway' + elif app.sleeper_state[account] == 'off': # we save out online status - gajim.status_before_autoaway[account] = \ - gajim.connections[account].status - connected = gajim.connections[account].connected - self.roster.send_status(account, gajim.SHOW_LIST[connected], - gajim.status_before_autoaway[account], auto=True) - gajim.sleeper_state[account] = 'idle' + app.status_before_autoaway[account] = \ + app.connections[account].status + connected = app.connections[account].connected + self.roster.send_status(account, app.SHOW_LIST[connected], + app.status_before_autoaway[account], auto=True) + app.sleeper_state[account] = 'idle' elif state == sleepy.STATE_XA and \ - gajim.sleeper_state[account] in ('online', 'autoaway', - 'autoaway-forced') and gajim.config.get('autoxa'): + app.sleeper_state[account] in ('online', 'autoaway', + 'autoaway-forced') and app.config.get('autoxa'): # we go extended away [we pass True to auto param] - auto_message = gajim.config.get('autoxa_message') + auto_message = app.config.get('autoxa_message') if not auto_message: - auto_message = gajim.connections[account].status + auto_message = app.connections[account].status else: auto_message = auto_message.replace('$S', '%(status)s') auto_message = auto_message.replace('$T', '%(time)s') auto_message = auto_message % { - 'status': gajim.status_before_autoaway[account], - 'time': gajim.config.get('autoxatime') + 'status': app.status_before_autoaway[account], + 'time': app.config.get('autoxatime') } self.roster.send_status(account, 'xa', auto_message, auto=True) - gajim.sleeper_state[account] = 'autoxa' + app.sleeper_state[account] = 'autoxa' return True # renew timeout (loop for ever) def autoconnect(self): @@ -2306,15 +2306,15 @@ class Interface: """ # dict of account that want to connect sorted by status shows = {} - for a in gajim.connections: - if gajim.config.get_per('accounts', a, 'autoconnect'): - if gajim.config.get_per('accounts', a, 'restore_last_status'): - self.roster.send_status(a, gajim.config.get_per('accounts', + for a in app.connections: + if app.config.get_per('accounts', a, 'autoconnect'): + if app.config.get_per('accounts', a, 'restore_last_status'): + self.roster.send_status(a, app.config.get_per('accounts', a, 'last_status'), helpers.from_one_line( - gajim.config.get_per('accounts', a, 'last_status_msg'))) + app.config.get_per('accounts', a, 'last_status_msg'))) continue - show = gajim.config.get_per('accounts', a, 'autoconnect_as') - if not show in gajim.SHOW_LIST: + show = app.config.get_per('accounts', a, 'autoconnect_as') + if not show in app.SHOW_LIST: continue if not show in shows: shows[show] = [a] @@ -2347,10 +2347,10 @@ class Interface: Called each foo (200) miliseconds. Check for idlequeue timeouts """ try: - gajim.idlequeue.process() + app.idlequeue.process() except Exception: # Otherwise, an exception will stop our loop - timeout, in_seconds = gajim.idlequeue.PROCESS_TIMEOUT + timeout, in_seconds = app.idlequeue.PROCESS_TIMEOUT if in_seconds: GLib.timeout_add_seconds(timeout, self.process_connections) else: @@ -2377,7 +2377,7 @@ class Interface: decoded image """ puny_jid = helpers.sanitize_filename(jid) - path_to_file = os.path.join(gajim.AVATAR_PATH, puny_jid) + path_to_file = os.path.join(app.AVATAR_PATH, puny_jid) if puny_nick: path_to_file = os.path.join(path_to_file, puny_nick) # remove old avatars @@ -2398,7 +2398,7 @@ class Interface: if pixbuf is None: return if typ not in ('jpeg', 'png'): - gajim.log.info('gtkpixbuf cannot save other than jpeg and '\ + app.log.info('gtkpixbuf cannot save other than jpeg and '\ 'png formats. saving \'%s\' avatar as png file (originaly: %s)'\ % (jid, typ)) typ = 'png' @@ -2436,7 +2436,7 @@ class Interface: Remove avatar files of a jid """ puny_jid = helpers.sanitize_filename(jid) - path_to_file = os.path.join(gajim.AVATAR_PATH, puny_jid) + path_to_file = os.path.join(app.AVATAR_PATH, puny_jid) if puny_nick: path_to_file = os.path.join(path_to_file, puny_nick) for ext in ('.jpeg', '.png'): @@ -2454,12 +2454,12 @@ class Interface: """ Autojoin bookmarked GCs that have 'auto join' on for this account """ - for bm in gajim.connections[account].bookmarks: + for bm in app.connections[account].bookmarks: if bm['autojoin'] in ('1', 'true'): jid = bm['jid'] # Only join non-opened groupchats. Opened one are already # auto-joined on re-connection - if not jid in gajim.gc_connected[account]: + if not jid in app.gc_connected[account]: # we are not already connected minimize = bm['minimize'] in ('1', 'true') self.join_gc_room(account, jid, bm['nick'], @@ -2487,7 +2487,7 @@ class Interface: place_found = False index = 0 # check for duplicate entry and respect alpha order - for bookmark in gajim.connections[account].bookmarks: + for bookmark in app.connections[account].bookmarks: if bookmark['jid'] == bm['jid']: dialogs.ErrorDialog( _('Bookmark already set'), @@ -2499,10 +2499,10 @@ class Interface: break index += 1 if place_found: - gajim.connections[account].bookmarks.insert(index, bm) + app.connections[account].bookmarks.insert(index, bm) else: - gajim.connections[account].bookmarks.append(bm) - gajim.connections[account].store_bookmarks() + app.connections[account].bookmarks.append(bm) + app.connections[account].store_bookmarks() gui_menu_builder.build_bookmark_menu(account) dialogs.InformationDialog( _('Bookmark has been added successfully'), @@ -2511,7 +2511,7 @@ class Interface: # does JID exist only within a groupchat? def is_pm_contact(self, fjid, account): - bare_jid = gajim.get_jid_without_resource(fjid) + bare_jid = app.get_jid_without_resource(fjid) gc_ctrl = self.msg_win_mgr.get_gc_control(bare_jid, account) @@ -2528,7 +2528,7 @@ class Interface: mood = received_mood if received_mood in pep.MOODS else 'unknown' return gtkgui_helpers.load_mood_icon(mood).get_pixbuf() elif isinstance(pep_obj, pep.UserTunePEP): - path = os.path.join(gajim.DATA_DIR, 'emoticons', 'static', 'music.png') + path = os.path.join(app.DATA_DIR, 'emoticons', 'static', 'music.png') return GdkPixbuf.Pixbuf.new_from_file(path) elif isinstance(pep_obj, pep.UserActivityPEP): pep_ = pep_obj._pep_specific_data @@ -2583,40 +2583,40 @@ class Interface: return True window.connect('delete_event', on_delete) view.updateNamespace({'gajim': gajim}) - gajim.ipython_window = window + app.ipython_window = window - def run(self, app): - if gajim.config.get('trayicon') != 'never': + def run(self, application): + if app.config.get('trayicon') != 'never': self.show_systray() - self.roster = roster_window.RosterWindow(app) + self.roster = roster_window.RosterWindow(application) if self.msg_win_mgr.mode == \ MessageWindowMgr.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER: self.msg_win_mgr.create_window(None, None, None) # Creating plugin manager from gajim import plugins - gajim.plugin_manager = plugins.PluginManager() + app.plugin_manager = plugins.PluginManager() self.roster._before_fill() - for account in gajim.connections: - gajim.connections[account].load_roster_from_db() + for account in app.connections: + app.connections[account].load_roster_from_db() self.roster._after_fill() # get instances for windows/dialogs that will show_all()/hide() self.instances['file_transfers'] = dialogs.FileTransfersWindow() GLib.timeout_add(100, self.autoconnect) - timeout, in_seconds = gajim.idlequeue.PROCESS_TIMEOUT + timeout, in_seconds = app.idlequeue.PROCESS_TIMEOUT if in_seconds: GLib.timeout_add_seconds(timeout, self.process_connections) else: GLib.timeout_add(timeout, self.process_connections) - GLib.timeout_add_seconds(gajim.config.get( + GLib.timeout_add_seconds(app.config.get( 'check_idle_every_foo_seconds'), self.read_sleepy) def remote_init(): - if gajim.config.get('remote_control'): + if app.config.get('remote_control'): try: from gajim import remote_control self.remote_ctrl = remote_control.Remote() @@ -2625,8 +2625,8 @@ class Interface: GLib.timeout_add_seconds(5, remote_init) def __init__(self): - gajim.interface = self - gajim.thread_interface = ThreadInterface + app.interface = self + app.thread_interface = ThreadInterface # This is the manager and factory of message windows set by the module self.msg_win_mgr = None self.jabber_state_images = {'16': {}, '24': {}, '32': {}, 'opened': {}, @@ -2638,13 +2638,13 @@ class Interface: self.pass_dialog = {} self.db_error_dialog = None self.default_colors = { - 'inmsgcolor': gajim.config.get('inmsgcolor'), - 'outmsgcolor': gajim.config.get('outmsgcolor'), - 'inmsgtxtcolor': gajim.config.get('inmsgtxtcolor'), - 'outmsgtxtcolor': gajim.config.get('outmsgtxtcolor'), - 'statusmsgcolor': gajim.config.get('statusmsgcolor'), - 'urlmsgcolor': gajim.config.get('urlmsgcolor'), - 'markedmsgcolor': gajim.config.get('markedmsgcolor'), + 'inmsgcolor': app.config.get('inmsgcolor'), + 'outmsgcolor': app.config.get('outmsgcolor'), + 'inmsgtxtcolor': app.config.get('inmsgtxtcolor'), + 'outmsgtxtcolor': app.config.get('outmsgtxtcolor'), + 'statusmsgcolor': app.config.get('statusmsgcolor'), + 'urlmsgcolor': app.config.get('urlmsgcolor'), + 'markedmsgcolor': app.config.get('markedmsgcolor'), } self.handlers = {} @@ -2664,16 +2664,16 @@ class Interface: if not cfg_was_read: # enable plugin_installer by default when creating config file - gajim.config.set_per('plugins', 'plugin_installer', 'active', True) + app.config.set_per('plugins', 'plugin_installer', 'active', True) - gajim.logger.reset_shown_unread_messages() + app.logger.reset_shown_unread_messages() # override logging settings from config (don't take care of '-q' option) - if gajim.config.get('verbose'): + if app.config.get('verbose'): logging_helpers.set_verbose() - for account in gajim.config.get_per('accounts'): - if gajim.config.get_per('accounts', account, 'is_zeroconf'): - gajim.ZEROCONF_ACC_NAME = account + for account in app.config.get_per('accounts'): + if app.config.get_per('accounts', account, 'is_zeroconf'): + app.ZEROCONF_ACC_NAME = account break # Is gnome configured to activate row on single click ? # try: @@ -2683,83 +2683,83 @@ class Interface: # click_policy = client.get_string( # '/apps/nautilus/preferences/click_policy') # if click_policy == 'single': -# gajim.single_click = True +# app.single_click = True # except Exception: # pass # add default status messages if there is not in the config file - if len(gajim.config.get_per('statusmsg')) == 0: - default = gajim.config.statusmsg_default + if len(app.config.get_per('statusmsg')) == 0: + default = app.config.statusmsg_default for msg in default: - gajim.config.add_per('statusmsg', msg) - gajim.config.set_per('statusmsg', msg, 'message', + app.config.add_per('statusmsg', msg) + app.config.set_per('statusmsg', msg, 'message', default[msg][0]) - gajim.config.set_per('statusmsg', msg, 'activity', + app.config.set_per('statusmsg', msg, 'activity', default[msg][1]) - gajim.config.set_per('statusmsg', msg, 'subactivity', + app.config.set_per('statusmsg', msg, 'subactivity', default[msg][2]) - gajim.config.set_per('statusmsg', msg, 'activity_text', + app.config.set_per('statusmsg', msg, 'activity_text', default[msg][3]) - gajim.config.set_per('statusmsg', msg, 'mood', + app.config.set_per('statusmsg', msg, 'mood', default[msg][4]) - gajim.config.set_per('statusmsg', msg, 'mood_text', + app.config.set_per('statusmsg', msg, 'mood_text', default[msg][5]) #add default themes if there is not in the config file - theme = gajim.config.get('roster_theme') - if not theme in gajim.config.get_per('themes'): - gajim.config.set('roster_theme', _('default')) - if len(gajim.config.get_per('themes')) == 0: + theme = app.config.get('roster_theme') + if not theme in app.config.get_per('themes'): + app.config.set('roster_theme', _('default')) + if len(app.config.get_per('themes')) == 0: d = ['accounttextcolor', 'accountbgcolor', 'accountfont', 'accountfontattrs', 'grouptextcolor', 'groupbgcolor', 'groupfont', 'groupfontattrs', 'contacttextcolor', 'contactbgcolor', 'contactfont', 'contactfontattrs', 'bannertextcolor', 'bannerbgcolor'] - default = gajim.config.themes_default + default = app.config.themes_default for theme_name in default: - gajim.config.add_per('themes', theme_name) + app.config.add_per('themes', theme_name) theme = default[theme_name] for o in d: - gajim.config.set_per('themes', theme_name, o, + app.config.set_per('themes', theme_name, o, theme[d.index(o)]) # Add Tor proxy if there is not in the config - if len(gajim.config.get_per('proxies')) == 0: - default = gajim.config.proxies_default + if len(app.config.get_per('proxies')) == 0: + default = app.config.proxies_default for proxy in default: - gajim.config.add_per('proxies', proxy) - gajim.config.set_per('proxies', proxy, 'type', + app.config.add_per('proxies', proxy) + app.config.set_per('proxies', proxy, 'type', default[proxy][0]) - gajim.config.set_per('proxies', proxy, 'host', + app.config.set_per('proxies', proxy, 'host', default[proxy][1]) - gajim.config.set_per('proxies', proxy, 'port', + app.config.set_per('proxies', proxy, 'port', default[proxy][2]) - gajim.idlequeue = idlequeue.get_idlequeue() + app.idlequeue = idlequeue.get_idlequeue() # resolve and keep current record of resolved hosts - gajim.resolver = resolver.get_resolver(gajim.idlequeue) - gajim.socks5queue = socks5.SocksQueue(gajim.idlequeue, + app.resolver = resolver.get_resolver(app.idlequeue) + app.socks5queue = socks5.SocksQueue(app.idlequeue, self.handle_event_file_rcv_completed, self.handle_event_file_progress, self.handle_event_file_error) - gajim.proxy65_manager = proxy65_manager.Proxy65Manager(gajim.idlequeue) - gajim.default_session_type = ChatControlSession + app.proxy65_manager = proxy65_manager.Proxy65Manager(app.idlequeue) + app.default_session_type = ChatControlSession # Creating Network Events Controller from gajim.common import nec - gajim.nec = nec.NetworkEventsController() - gajim.notification = notify.Notification() + app.nec = nec.NetworkEventsController() + app.notification = notify.Notification() self.create_core_handlers_list() self.register_core_handlers() - 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') and\ - gajim.config.get_per('accounts', account, 'active'): - gajim.connections[account] = Connection(account) + if app.config.get_per('accounts', app.ZEROCONF_ACC_NAME, 'active') \ + and app.HAVE_ZEROCONF: + app.connections[app.ZEROCONF_ACC_NAME] = \ + connection_zeroconf.ConnectionZeroconf(app.ZEROCONF_ACC_NAME) + for account in app.config.get_per('accounts'): + if not app.config.get_per('accounts', account, 'is_zeroconf') and\ + app.config.get_per('accounts', account, 'active'): + app.connections[account] = Connection(account) # gtk hooks # Gtk.about_dialog_set_email_hook(self.on_launch_browser_mailer, 'mail') @@ -2768,36 +2768,36 @@ class Interface: self.instances = {} - for a in gajim.connections: + for a in app.connections: self.instances[a] = {'infos': {}, 'disco': {}, 'gc_config': {}, 'search': {}, 'online_dialog': {}, 'sub_request': {}} # online_dialog contains all dialogs that have a meaning only when # we are not disconnected self.minimized_controls[a] = {} - gajim.contacts.add_account(a) - gajim.groups[a] = {} - gajim.gc_connected[a] = {} - gajim.automatic_rooms[a] = {} - gajim.newly_added[a] = [] - gajim.to_be_removed[a] = [] - gajim.nicks[a] = gajim.config.get_per('accounts', a, 'name') - gajim.block_signed_in_notifications[a] = True - gajim.sleeper_state[a] = 0 - gajim.encrypted_chats[a] = [] - gajim.last_message_time[a] = {} - gajim.status_before_autoaway[a] = '' - gajim.transport_avatar[a] = {} - gajim.gajim_optional_features[a] = [] - gajim.caps_hash[a] = '' + app.contacts.add_account(a) + app.groups[a] = {} + app.gc_connected[a] = {} + app.automatic_rooms[a] = {} + app.newly_added[a] = [] + app.to_be_removed[a] = [] + app.nicks[a] = app.config.get_per('accounts', a, 'name') + app.block_signed_in_notifications[a] = True + app.sleeper_state[a] = 0 + app.encrypted_chats[a] = [] + app.last_message_time[a] = {} + app.status_before_autoaway[a] = '' + app.transport_avatar[a] = {} + app.gajim_optional_features[a] = [] + app.caps_hash[a] = '' helpers.update_optional_features() # prepopulate data which we are sure of; note: we do not log these info - for account in gajim.connections: + for account in app.connections: gajimcaps = caps_cache.capscache[('sha-1', - gajim.caps_hash[account])] - gajimcaps.identities = [gajim.gajim_identity] - gajimcaps.features = gajim.gajim_common_features + \ - gajim.gajim_optional_features[account] + app.caps_hash[account])] + gajimcaps.identities = [app.gajim_identity] + gajimcaps.features = app.gajim_common_features + \ + app.gajim_optional_features[account] self.remote_ctrl = None @@ -2811,45 +2811,45 @@ class Interface: if dbus_support.supported: def gnome_screensaver_ActiveChanged_cb(active): if not active: - for account in gajim.connections: - if gajim.account_is_connected(account) and \ - gajim.sleeper_state[account] == 'autoaway-forced': + for account in app.connections: + if app.account_is_connected(account) and \ + app.sleeper_state[account] == 'autoaway-forced': # We came back online ofter gnome-screensaver # autoaway self.roster.send_status(account, 'online', - gajim.status_before_autoaway[account]) - gajim.status_before_autoaway[account] = '' - gajim.sleeper_state[account] = 'online' + app.status_before_autoaway[account]) + app.status_before_autoaway[account] = '' + app.sleeper_state[account] = 'online' return - if not gajim.config.get('autoaway'): + if not app.config.get('autoaway'): # Don't go auto away if user disabled the option return - for account in gajim.connections: - if account not in gajim.sleeper_state or \ - not gajim.sleeper_state[account]: + for account in app.connections: + if account not in app.sleeper_state or \ + not app.sleeper_state[account]: continue - if gajim.sleeper_state[account] == 'online': - if not gajim.account_is_connected(account): + if app.sleeper_state[account] == 'online': + if not app.account_is_connected(account): continue # we save out online status - gajim.status_before_autoaway[account] = \ - gajim.connections[account].status + app.status_before_autoaway[account] = \ + app.connections[account].status # we go away (no auto status) [we pass True to auto # param] - auto_message = gajim.config.get('autoaway_message') + auto_message = app.config.get('autoaway_message') if not auto_message: - auto_message = gajim.connections[account].status + auto_message = app.connections[account].status else: auto_message = auto_message.replace('$S', '%(status)s') auto_message = auto_message.replace('$T', '%(time)s') auto_message = auto_message % { - 'status': gajim.status_before_autoaway[account], - 'time': gajim.config.get('autoxatime')} + 'status': app.status_before_autoaway[account], + 'time': app.config.get('autoxatime')} self.roster.send_status(account, 'away', auto_message, auto=True) - gajim.sleeper_state[account] = 'autoaway-forced' + app.sleeper_state[account] = 'autoaway-forced' try: bus = dbus.SessionBus() @@ -2861,8 +2861,8 @@ class Interface: self.show_vcard_when_connect = [] self.sleeper = sleepy.Sleepy( - gajim.config.get('autoawaytime') * 60, # make minutes to seconds - gajim.config.get('autoxatime') * 60) + app.config.get('autoawaytime') * 60, # make minutes to seconds + app.config.get('autoxatime') * 60) gtkgui_helpers.make_jabber_state_images() @@ -2884,13 +2884,13 @@ class Interface: self.make_regexps() # get transports type from DB - gajim.transport_type = gajim.logger.get_transports_type() + app.transport_type = app.logger.get_transports_type() # test is dictionnary is present for speller - if gajim.config.get('use_speller'): - lang = gajim.config.get('speller_language') + if app.config.get('use_speller'): + lang = app.config.get('speller_language') if not lang: - lang = gajim.LANG + lang = app.LANG tv = Gtk.TextView() try: from gajim import gtkspell @@ -2898,7 +2898,7 @@ class Interface: except (ImportError, TypeError, RuntimeError, OSError, ValueError): dialogs.AspellDictError(lang) - if gajim.config.get('soundplayer') == '': + if app.config.get('soundplayer') == '': # only on first time Gajim starts commands = ('paplay', 'aplay', 'play', 'ossplay') for command in commands: @@ -2909,7 +2909,7 @@ class Interface: command += ' -q' elif command == 'ossplay': command += ' -qq' - gajim.config.set('soundplayer', command) + app.config.set('soundplayer', command) break self.last_ftwindow_update = 0 @@ -2937,7 +2937,7 @@ class PassphraseRequest: self.dialog.window.destroy() def run_callback(self, account, callback): - gajim.connections[account].gpg_passphrase(self.passphrase) + app.connections[account].gpg_passphrase(self.passphrase) callback() def add_callback(self, account, cb): @@ -2952,7 +2952,7 @@ class PassphraseRequest: self.passphrase = passphrase self.completed = True if passphrase is not None: - GLib.timeout_add_seconds(30, gajim.interface.forget_gpg_passphrase, + GLib.timeout_add_seconds(30, app.interface.forget_gpg_passphrase, self.keyid) for (account, cb) in self.callbacks: self.run_callback(account, cb) @@ -2968,7 +2968,7 @@ class PassphraseRequest: self.complete(None) def _ok(passphrase, checked, count): - result = gajim.connections[account].test_gpg_passphrase(passphrase) + result = app.connections[account].test_gpg_passphrase(passphrase) if result == 'ok': # passphrase is good self.complete(passphrase) @@ -2978,7 +2978,7 @@ class PassphraseRequest: _('Your OpenPGP key has expired, you will be connected to ' '%s without OpenPGP.') % account) # Don't try to connect with GPG - gajim.connections[account].continue_connect_info[2] = False + app.connections[account].continue_connect_info[2] = False self.complete(None) return diff --git a/gajim/gui_menu_builder.py b/gajim/gui_menu_builder.py index 1ea8cf931..ed44619c9 100644 --- a/gajim/gui_menu_builder.py +++ b/gajim/gui_menu_builder.py @@ -23,7 +23,7 @@ import os from gajim import gtkgui_helpers from gajim import message_control -from gajim.common import gajim +from gajim.common import app from gajim.common import helpers from gajim.common import i18n from nbxmpp.protocol import NS_COMMANDS, NS_FILE, NS_MUC, NS_ESESSION @@ -36,12 +36,12 @@ def build_resources_submenu(contacts, account, action, room_jid=None, Build a submenu with contact's resources. room_jid and room_account are for action self.on_invite_to_room """ - roster = gajim.interface.roster + roster = app.interface.roster sub_menu = Gtk.Menu() - iconset = gajim.config.get('iconset') + iconset = app.config.get('iconset') if not iconset: - iconset = gajim.config.DEFAULT_ICONSET + iconset = app.config.DEFAULT_ICONSET path = os.path.join(helpers.get_iconset_path(iconset), '16x16') for c in contacts: item = Gtk.MenuItem.new_with_label( @@ -70,19 +70,19 @@ show_bookmarked=False, force_resource=False): """ if ignore_rooms is None: ignore_rooms = [] - roster = gajim.interface.roster + roster = app.interface.roster # used if we invite only one contact with several resources contact_list = [] if len(list_) == 1: contact, account = list_[0] - contact_list = gajim.contacts.get_contacts(account, contact.jid) + contact_list = app.contacts.get_contacts(account, contact.jid) contacts_transport = -1 connected_accounts = [] # -1 is at start, False when not from the same, None when jabber for (contact, account) in list_: if not account in connected_accounts: connected_accounts.append(account) - transport = gajim.get_transport_name_from_jid(contact.jid) + transport = app.get_transport_name_from_jid(contact.jid) if transport == 'jabber': transport = None if contacts_transport == -1: @@ -104,7 +104,7 @@ show_bookmarked=False, force_resource=False): elif len(list_) == 1 and contact.supports(NS_MUC): invite_menuitem.set_sensitive(True) # use resource if it's self contact - if contact.jid == gajim.get_jid_from_account(account) or force_resource: + if contact.jid == app.get_jid_from_account(account) or force_resource: resource = contact.resource else: resource = None @@ -126,8 +126,8 @@ show_bookmarked=False, force_resource=False): c_t = contacts_transport or 'jabber' muc_jid = {} for account in connected_accounts: - for t in gajim.connections[account].muc_jid: - muc_jid[t] = gajim.connections[account].muc_jid[t] + for t in app.connections[account].muc_jid: + muc_jid[t] = app.connections[account].muc_jid[t] if c_t not in muc_jid: invite_to_new_room_menuitem.set_sensitive(False) rooms = [] # a list of (room_jid, account) tuple @@ -135,8 +135,8 @@ show_bookmarked=False, force_resource=False): minimized_controls = [] for account in connected_accounts: minimized_controls += \ - list(gajim.interface.minimized_controls[account].values()) - for gc_control in gajim.interface.msg_win_mgr.get_controls( + list(app.interface.minimized_controls[account].values()) + for gc_control in app.interface.msg_win_mgr.get_controls( message_control.TYPE_GC) + minimized_controls: acct = gc_control.account if acct not in connected_accounts: @@ -144,8 +144,8 @@ show_bookmarked=False, force_resource=False): room_jid = gc_control.room_jid if room_jid in ignore_rooms: continue - if room_jid in gajim.gc_connected[acct] and \ - gajim.gc_connected[acct][room_jid] and \ + if room_jid in app.gc_connected[acct] and \ + app.gc_connected[acct][room_jid] and \ contacts_transport in ['jabber', None]: rooms.append((room_jid, acct)) if len(rooms): @@ -159,7 +159,7 @@ show_bookmarked=False, force_resource=False): account)) else: # use resource if it's self contact - if contact.jid == gajim.get_jid_from_account(account): + if contact.jid == app.get_jid_from_account(account): resource = contact.resource else: resource = None @@ -172,12 +172,12 @@ show_bookmarked=False, force_resource=False): rooms2 = [] # a list of (room_jid, account) tuple r_jids = [] # list of room jids for account in connected_accounts: - for room in gajim.connections[account].bookmarks: + for room in app.connections[account].bookmarks: r_jid = room['jid'] if r_jid in r_jids: continue - if r_jid not in gajim.gc_connected[account] or not \ - gajim.gc_connected[account][r_jid]: + if r_jid not in app.gc_connected[account] or not \ + app.gc_connected[account][r_jid]: rooms2.append((r_jid, account)) r_jids.append(r_jid) @@ -193,7 +193,7 @@ show_bookmarked=False, force_resource=False): account)) else: # use resource if it's self contact - if contact.jid == gajim.get_jid_from_account(account): + if contact.jid == app.get_jid_from_account(account): resource = contact.resource else: resource = None @@ -212,8 +212,8 @@ control=None, gc_contact=None, is_anonymous=True): return jid = contact.jid - our_jid = jid == gajim.get_jid_from_account(account) - roster = gajim.interface.roster + our_jid = jid == app.get_jid_from_account(account) + roster = app.interface.roster xml = gtkgui_helpers.get_gtk_builder('contact_context_menu.ui') contact_context_menu = xml.get_object('contact_context_menu') @@ -249,17 +249,17 @@ control=None, gc_contact=None, is_anonymous=True): items_to_hide = [] - contacts = gajim.contacts.get_contacts(account, jid) + contacts = app.contacts.get_contacts(account, jid) if len(contacts) > 1 and use_multiple_contacts: # several resources start_chat_menuitem.set_submenu(build_resources_submenu(contacts, - account, gajim.interface.on_open_chat_window)) + account, app.interface.on_open_chat_window)) send_file_menuitem.set_submenu(build_resources_submenu(contacts, account, roster.on_send_file_menuitem_activate, cap=NS_FILE)) execute_command_menuitem.set_submenu(build_resources_submenu( contacts, account, roster.on_execute_command, cap=NS_COMMANDS)) else: start_chat_menuitem.connect('activate', - gajim.interface.on_open_chat_window, contact, account) + app.interface.on_open_chat_window, contact, account) if contact.supports(NS_FILE) or contact.supports(NS_JINGLE_FILE_TRANSFER_5): send_file_menuitem.set_sensitive(True) send_file_menuitem.connect('activate', @@ -295,7 +295,7 @@ control=None, gc_contact=None, is_anonymous=True): edit_groups_menuitem.connect('activate', roster.on_edit_groups, [(contact, account)]) - if gajim.connections[account].gpg: + if app.connections[account].gpg: assign_openpgp_key_menuitem.connect('activate', roster.on_assign_pgp_key, contact, account) else: @@ -310,7 +310,7 @@ control=None, gc_contact=None, is_anonymous=True): items_to_hide += [rename_menuitem, edit_groups_menuitem] # Unsensitive many items when account is offline - if gajim.account_is_disconnected(account): + if app.account_is_disconnected(account): for widget in (start_chat_menuitem, rename_menuitem, edit_groups_menuitem, send_file_menuitem, convert_to_gc_menuitem, information_menuitem): @@ -336,7 +336,7 @@ control=None, gc_contact=None, is_anonymous=True): item.hide() # Zeroconf Account - if gajim.config.get_per('accounts', account, 'is_zeroconf'): + if app.config.get_per('accounts', account, 'is_zeroconf'): for item in (send_custom_status_menuitem, send_single_message_menuitem, invite_menuitem, block_menuitem, unblock_menuitem, ignore_menuitem, unignore_menuitem, set_custom_avatar_menuitem, subscription_menuitem, @@ -367,7 +367,7 @@ control=None, gc_contact=None, is_anonymous=True): if helpers.group_is_blocked(account, group): blocked = True break - transport = gajim.get_transport_name_from_jid(jid, use_config_setting=False) + transport = app.get_transport_name_from_jid(jid, use_config_setting=False) if transport and transport != 'jabber': # Transport contact, send custom status unavailable send_custom_status_menuitem.set_sensitive(False) @@ -380,7 +380,7 @@ control=None, gc_contact=None, is_anonymous=True): invite_menuitem.set_sensitive(False) else: bookmarked = False - c_ = gajim.contacts.get_contact(account, gc_contact.jid, + c_ = app.contacts.get_contact(account, gc_contact.jid, gc_contact.resource) if c_ and c_.supports(NS_CONFERENCE): bookmarked=True @@ -394,7 +394,7 @@ control=None, gc_contact=None, is_anonymous=True): show_bookmarked=contact.supports(NS_CONFERENCE), force_resource=force_resource) - if gajim.account_is_disconnected(account): + if app.account_is_disconnected(account): invite_menuitem.set_sensitive(False) # One or several resource, we do the same for send_custom_status @@ -431,7 +431,7 @@ control=None, gc_contact=None, is_anonymous=True): ask_auth_menuitem.connect('activate', roster.req_sub, jid, _('I would like to add you to my roster'), account, contact.groups, contact.name) - transport = gajim.get_transport_name_from_jid(jid, + transport = app.get_transport_name_from_jid(jid, use_config_setting=False) if contact.sub in ('to', 'none') or transport not in ['jabber', None]: revoke_auth_menuitem.set_sensitive(False) @@ -439,7 +439,7 @@ control=None, gc_contact=None, is_anonymous=True): revoke_auth_menuitem.connect('activate', roster.revoke_auth, jid, account) - elif gajim.connections[account].roster_supported: + elif app.connections[account].roster_supported: # contact is in group 'Not in Roster' add_to_roster_menuitem.set_no_show_all(False) subscription_menuitem.set_sensitive(False) @@ -459,18 +459,18 @@ control=None, gc_contact=None, is_anonymous=True): manage_contact_menuitem.set_sensitive(False) # Unsensitive items when account is offline - if gajim.account_is_disconnected(account): + if app.account_is_disconnected(account): for widget in (send_single_message_menuitem, subscription_menuitem, add_to_roster_menuitem, remove_from_roster_menuitem, execute_command_menuitem, send_custom_status_menuitem): widget.set_sensitive(False) - if gajim.connections[account] and (gajim.connections[account].\ - privacy_rules_supported or gajim.connections[account].blocking_supported): + if app.connections[account] and (app.connections[account].\ + privacy_rules_supported or app.connections[account].blocking_supported): if helpers.jid_is_blocked(account, jid): block_menuitem.set_no_show_all(True) block_menuitem.hide() - if gajim.get_transport_name_from_jid(jid, use_config_setting=False)\ + if app.get_transport_name_from_jid(jid, use_config_setting=False)\ and transport != 'jabber': unblock_menuitem.set_no_show_all(True) unblock_menuitem.hide() @@ -483,7 +483,7 @@ control=None, gc_contact=None, is_anonymous=True): else: unblock_menuitem.set_no_show_all(True) unblock_menuitem.hide() - if gajim.get_transport_name_from_jid(jid, use_config_setting=False)\ + if app.get_transport_name_from_jid(jid, use_config_setting=False)\ and transport != 'jabber': block_menuitem.set_no_show_all(True) block_menuitem.hide() @@ -503,7 +503,7 @@ control=None, gc_contact=None, is_anonymous=True): return contact_context_menu def get_transport_menu(contact, account): - roster = gajim.interface.roster + roster = app.interface.roster jid = contact.jid menu = Gtk.Menu() @@ -513,7 +513,7 @@ def get_transport_menu(contact, account): item.connect('activate', roster.on_send_single_message_menuitem_activate, account, contact) menu.append(item) - if gajim.account_is_disconnected(account): + if app.account_is_disconnected(account): item.set_sensitive(False) blocked = False @@ -535,7 +535,7 @@ def get_transport_menu(contact, account): [(contact, account)], s) status_menuitems.append(status_menuitem) menu.append(send_custom_status_menuitem) - if gajim.account_is_disconnected(account): + if app.account_is_disconnected(account): send_custom_status_menuitem.set_sensitive(False) item = Gtk.SeparatorMenuItem.new() # separator @@ -546,7 +546,7 @@ def get_transport_menu(contact, account): menu.append(item) item.connect('activate', roster.on_execute_command, contact, account, contact.resource) - if gajim.account_is_disconnected(account): + if app.account_is_disconnected(account): item.set_sensitive(False) # Manage Transport submenu @@ -559,14 +559,14 @@ def get_transport_menu(contact, account): item = Gtk.MenuItem.new_with_mnemonic(_('_Modify Transport')) manage_transport_submenu.append(item) item.connect('activate', roster.on_edit_agent, contact, account) - if gajim.account_is_disconnected(account): + if app.account_is_disconnected(account): item.set_sensitive(False) # Rename item = Gtk.MenuItem.new_with_mnemonic(_('_Rename…')) manage_transport_submenu.append(item) item.connect('activate', roster.on_rename, 'agent', jid, account) - if gajim.account_is_disconnected(account): + if app.account_is_disconnected(account): item.set_sensitive(False) item = Gtk.SeparatorMenuItem.new() # separator @@ -581,14 +581,14 @@ def get_transport_menu(contact, account): item.connect('activate', roster.on_block, [(contact, account)]) manage_transport_submenu.append(item) - if gajim.account_is_disconnected(account): + if app.account_is_disconnected(account): item.set_sensitive(False) # Remove item = Gtk.MenuItem.new_with_mnemonic(_('Remo_ve')) manage_transport_submenu.append(item) item.connect('activate', roster.on_remove_agent, [(contact, account)]) - if gajim.account_is_disconnected(account): + if app.account_is_disconnected(account): item.set_sensitive(False) item = Gtk.SeparatorMenuItem.new() # separator @@ -598,7 +598,7 @@ def get_transport_menu(contact, account): information_menuitem = Gtk.MenuItem.new_with_mnemonic(_('_Information')) menu.append(information_menuitem) information_menuitem.connect('activate', roster.on_info, contact, account) - if gajim.account_is_disconnected(account): + if app.account_is_disconnected(account): information_menuitem.set_sensitive(False) menu.connect('selection-done', gtkgui_helpers.destroy_widget) @@ -611,7 +611,7 @@ Build dynamic Application Menus def get_bookmarks_menu(account, rebuild=False): - if not gajim.connections[account].bookmarks: + if not app.connections[account].bookmarks: return None menu = Gio.Menu() @@ -624,7 +624,7 @@ def get_bookmarks_menu(account, rebuild=False): # Build Bookmarks section = Gio.Menu() - for bookmark in gajim.connections[account].bookmarks: + for bookmark in app.connections[account].bookmarks: name = bookmark['name'] if not name: # No name was given for this bookmark. @@ -710,11 +710,11 @@ def get_account_menu(account): def build_accounts_menu(): - menubar = gajim.app.get_menubar() + menubar = app.app.get_menubar() # Accounts Submenu acc_menu = menubar.get_item_link(0, 'submenu') acc_menu.remove_all() - accounts_list = sorted(gajim.contacts.get_accounts()) + accounts_list = sorted(app.contacts.get_accounts()) if not accounts_list: no_accounts = _('No Accounts available') acc_menu.append_item(Gio.MenuItem.new(no_accounts, None)) @@ -730,7 +730,7 @@ def build_accounts_menu(): def build_bookmark_menu(account): - menubar = gajim.app.get_menubar() + menubar = app.app.get_menubar() bookmark_menu = get_bookmarks_menu(account) if not bookmark_menu: return @@ -756,7 +756,7 @@ def get_encryption_menu(control_id, type_id): menu = Gio.Menu() menu.append( 'Disabled', 'win.set-encryption-{}::{}'.format(control_id, 'disabled')) - for name, plugin in gajim.plugin_manager.encryption_plugins.items(): + for name, plugin in app.plugin_manager.encryption_plugins.items(): if type_id == 'gc': if not hasattr(plugin, 'allow_groupchat'): continue diff --git a/gajim/history_manager.py b/gajim/history_manager.py index fc03cfcb2..72f1bc08b 100644 --- a/gajim/history_manager.py +++ b/gajim/history_manager.py @@ -71,7 +71,7 @@ del parseOpts import gajim.common.configpaths gajim.common.configpaths.gajimpaths.init(config_path) del config_path -from gajim.common import gajim +from gajim.common import app from gajim import gtkgui_helpers from gajim.common.logger import LOG_DB_PATH, JIDConstant, KindConstant from gajim.common import helpers @@ -381,20 +381,20 @@ class HistoryManager: if kind in (KindConstant.SINGLE_MSG_RECV, KindConstant.CHAT_MSG_RECV, KindConstant.GC_MSG): # it is the other side - color = gajim.config.get('inmsgcolor') # so incoming color + color = app.config.get('inmsgcolor') # so incoming color elif kind in (KindConstant.SINGLE_MSG_SENT, KindConstant.CHAT_MSG_SENT): # it is us - color = gajim.config.get('outmsgcolor') # so outgoing color + color = app.config.get('outmsgcolor') # so outgoing color elif kind in (KindConstant.STATUS, KindConstant.GCSTATUS): # is is statuses # so status color - color = gajim.config.get('statusmsgcolor') + color = app.config.get('statusmsgcolor') # include status into (status) message if message is None: message = '' else: message = ' : ' + message - message = helpers.get_uf_show(gajim.SHOW_LIST[show]) + \ + message = helpers.get_uf_show(app.SHOW_LIST[show]) + \ message message_ = ' every_foo_seconds: @@ -455,12 +455,12 @@ class HistoryWindow: tag_msg = 'incomingtxt' elif kind in (KindConstant.SINGLE_MSG_SENT, KindConstant.CHAT_MSG_SENT): if self.account: - contact_name = gajim.nicks[self.account] + contact_name = app.nicks[self.account] else: # we don't have roster, we don't know our own nick, use first # account one (urk!) - account = list(gajim.contacts.get_accounts())[0] - contact_name = gajim.nicks[account] + account = list(app.contacts.get_accounts())[0] + contact_name = app.nicks[account] tag_name = 'outgoing' tag_msg = 'outgoingtxt' elif kind == KindConstant.GCSTATUS: @@ -495,9 +495,9 @@ class HistoryWindow: # eg. nkour: nkour is now Offline if contact_name and kind != KindConstant.GCSTATUS: # add stuff before and after contact name - before_str = gajim.config.get('before_nickname') + before_str = app.config.get('before_nickname') before_str = helpers.from_one_line(before_str) - after_str = gajim.config.get('after_nickname') + after_str = app.config.get('after_nickname') after_str = helpers.from_one_line(after_str) format = before_str + contact_name + after_str + ' ' if tag_name: @@ -537,7 +537,7 @@ class HistoryWindow: # or if we browse a groupchat history. The account is not needed, a dummy can # be set. # This may leed to wrong self nick in the displayed history (Uggh!) - account = list(gajim.contacts.get_accounts())[0] + account = list(app.contacts.get_accounts())[0] date = None if self.search_in_date.get_active(): @@ -547,7 +547,7 @@ class HistoryWindow: show_status = self.show_status_checkbutton.get_active() - results = gajim.logger.search_log(account, jid, text, date) + results = app.logger.search_log(account, jid, text, date) #FIXME: # add "subject: | message: " in message column if kind is single # also do we need show at all? (we do not search on subject) @@ -559,7 +559,7 @@ class HistoryWindow: contact_name = row.contact_name if not contact_name: if row.kind == KindConstant.CHAT_MSG_SENT: # it's us! :) - contact_name = gajim.nicks[account] + contact_name = app.nicks[account] else: contact_name = self.completion_dict[jid][InfoColumn.NAME] @@ -633,7 +633,7 @@ class HistoryWindow: def on_log_history_checkbutton_toggled(self, widget): # log conversation history? oldlog = True - no_log_for = gajim.config.get_per('accounts', self.account, + no_log_for = app.config.get_per('accounts', self.account, 'no_log_for').split() if self.jid in no_log_for: oldlog = False @@ -643,7 +643,7 @@ class HistoryWindow: if log and self.jid in no_log_for: no_log_for.remove(self.jid) if oldlog != log: - gajim.config.set_per('accounts', self.account, 'no_log_for', + app.config.set_per('accounts', self.account, 'no_log_for', ' '.join(no_log_for)) def on_show_status_checkbutton_toggled(self, widget): @@ -668,7 +668,7 @@ class HistoryWindow: x, y = self.window.get_window().get_root_origin() width, height = self.window.get_size() - gajim.config.set('history_window_x-position', x) - gajim.config.set('history_window_y-position', y) - gajim.config.set('history_window_width', width) - gajim.config.set('history_window_height', height) + app.config.set('history_window_x-position', x) + app.config.set('history_window_y-position', y) + app.config.set('history_window_width', width) + app.config.set('history_window_height', height) diff --git a/gajim/htmltextview.py b/gajim/htmltextview.py index 48451a386..a5eeb2ff4 100644 --- a/gajim/htmltextview.py +++ b/gajim/htmltextview.py @@ -50,8 +50,8 @@ import urllib if __name__ == '__main__': from gajim.common import i18n import gajim.common.configpaths - gajim.common.configpaths.gajimpaths.init(None) -from gajim.common import gajim + app.common.configpaths.gajimpaths.init(None) +from gajim.common import app from gajim import gtkgui_helpers from gajim.gtkgui_helpers import get_icon_pixmap from gajim.common import helpers @@ -515,7 +515,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler): tag.href = href tag.type_ = type_ # to be used by the URL handler tag.connect('event', self.textview.hyperlink_handler, 'url') - tag.set_property('foreground', gajim.config.get('urlmsgcolor')) + tag.set_property('foreground', app.config.get('urlmsgcolor')) tag.set_property('underline', Pango.Underline.SINGLE) tag.is_anchor = True if title: @@ -550,7 +550,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler): else: if self.conv_textview: img_mark = self.textbuf.create_mark(None, self.iter, True) - gajim.thread_interface(helpers.download_image, [ + app.thread_interface(helpers.download_image, [ self.conv_textview.account, attrs], self._update_img, [attrs, img_mark, self._get_style_tags()]) alt = attrs.get('alt', '') @@ -849,8 +849,8 @@ class HtmlTextView(Gtk.TextView): self.id_ = self.connect('button-release-event', self.on_left_mouse_button_release) self.get_buffer().eol_tag = self.get_buffer().create_tag('eol') - self.config = gajim.config - self.interface = gajim.interface + self.config = app.config + self.interface = app.interface # end big hack def connect_tooltip(self, func=None): @@ -860,7 +860,7 @@ class HtmlTextView(Gtk.TextView): buffer_ = self.get_buffer() self.tagURL = buffer_.create_tag('url') - color = gajim.config.get('urlmsgcolor') + color = app.config.get('urlmsgcolor') self.tagURL.set_property('foreground', color) self.tagURL.set_property('underline', Pango.Underline.SINGLE) self.tagURL.connect('event', self.hyperlink_handler, 'url') @@ -912,7 +912,7 @@ class HtmlTextView(Gtk.TextView): clip.set_text(text, -1) # def on_start_chat_activate(self, widget, jid): -# gajim.interface.new_chat_from_jid(self.account, jid) +# app.interface.new_chat_from_jid(self.account, jid) def on_join_group_chat_menuitem_activate(self, widget, room_jid): try: @@ -952,7 +952,7 @@ class HtmlTextView(Gtk.TextView): childs[6].connect('activate', self.on_join_group_chat_menuitem_activate, text) -# if self.account and gajim.connections[self.account].\ +# if self.account and app.connections[self.account].\ # roster_supported: # childs[7].connect('activate', # self.on_add_to_roster_activate, text) @@ -995,7 +995,7 @@ class HtmlTextView(Gtk.TextView): kind = 'xmpp' elif word.startswith('mailto:'): kind = 'mail' - elif gajim.interface.sth_at_sth_dot_sth_re.match(word): + elif app.interface.sth_at_sth_dot_sth_re.match(word): # it's a JID or mail kind = 'sth_at_sth' else: @@ -1097,11 +1097,11 @@ if __name__ == '__main__': log = logging.getLogger() gaj.Interface() - # create fake gajim.plugin_manager.gui_extension_point method for tests + # create fake app.plugin_manager.gui_extension_point method for tests def gui_extension_point(*args): pass - gajim.plugin_manager = gaj.Interface() - gajim.plugin_manager.gui_extension_point = gui_extension_point + app.plugin_manager = gaj.Interface() + app.plugin_manager.gui_extension_point = gui_extension_point htmlview = ConversationTextview(None) diff --git a/gajim/logind_listener.py b/gajim/logind_listener.py index 1b89d4346..33cd53bf6 100644 --- a/gajim/logind_listener.py +++ b/gajim/logind_listener.py @@ -26,7 +26,7 @@ import os import logging from gajim.common import dbus_support -from gajim.common import gajim +from gajim.common import app log = logging.getLogger('gajim.logind_listener') supported = False @@ -46,9 +46,9 @@ def on_suspend(active): # we're going for suspend, let's disconnect log.debug('System suspend detected, disconnecting from network…') - for name, conn in gajim.connections.items(): - if gajim.account_is_connected(name): - conn.old_show = gajim.SHOW_LIST[conn.connected] + for name, conn in app.connections.items(): + if app.account_is_connected(name): + conn.old_show = app.SHOW_LIST[conn.connected] st = conn.status conn.change_status('offline', _('Machine going to sleep')) conn.status = st diff --git a/gajim/message_control.py b/gajim/message_control.py index fd4029120..86ac1c5e4 100644 --- a/gajim/message_control.py +++ b/gajim/message_control.py @@ -29,7 +29,7 @@ from gajim import gtkgui_helpers import uuid -from gajim.common import gajim +from gajim.common import app from gajim.common import helpers from gajim.common import ged from gajim.common.stanza_session import EncryptedStanzaSession, ArchivingStanzaSession @@ -64,13 +64,13 @@ class MessageControl(object): self.control_id = str(uuid.uuid4()) self.session = None - gajim.last_message_time[self.account][self.get_full_jid()] = 0 + app.last_message_time[self.account][self.get_full_jid()] = 0 self.xml = gtkgui_helpers.get_gtk_builder('%s.ui' % widget_name) self.xml.connect_signals(self) self.widget = self.xml.get_object('%s_hbox' % widget_name) - gajim.ged.register_event_handler('message-outgoing', ged.OUT_GUI1, + app.ged.register_event_handler('message-outgoing', ged.OUT_GUI1, self._nec_message_outgoing) def get_full_jid(self): @@ -119,7 +119,7 @@ class MessageControl(object): """ Derived classes MUST implement this """ - gajim.ged.remove_event_handler('message-outgoing', ged.OUT_GUI1, + app.ged.remove_event_handler('message-outgoing', ged.OUT_GUI1, self._nec_message_outgoing) def repaint_themed_widgets(self): @@ -188,7 +188,7 @@ class MessageControl(object): pass def get_specific_unread(self): - return len(gajim.events.get_events(self.account, + return len(app.events.get_events(self.account, self.contact.jid)) def set_session(self, session): @@ -234,11 +234,11 @@ class MessageControl(object): obj.message = helpers.remove_invalid_xml_chars(obj.message) - conn = gajim.connections[self.account] + conn = app.connections[self.account] if not self.session: if (not obj.resource and - obj.jid != gajim.get_jid_from_account(self.account)): + obj.jid != app.get_jid_from_account(self.account)): if self.resource: obj.resource = self.resource else: diff --git a/gajim/message_textview.py b/gajim/message_textview.py index 440f6f8ac..fb02a3c27 100644 --- a/gajim/message_textview.py +++ b/gajim/message_textview.py @@ -28,7 +28,7 @@ from gi.repository import GObject from gi.repository import GLib from gi.repository import Pango -from gajim.common import gajim +from gajim.common import app from gajim import gtkgui_helpers class MessageTextView(Gtk.TextView): @@ -97,7 +97,7 @@ class MessageTextView(Gtk.TextView): index = 0 new_text = '' - iterator = gajim.interface.link_pattern_re.finditer(text) + iterator = app.interface.link_pattern_re.finditer(text) for match in iterator: start, end = match.span() url = text[start:end] diff --git a/gajim/message_window.py b/gajim/message_window.py index 060d920f2..d245b1beb 100644 --- a/gajim/message_window.py +++ b/gajim/message_window.py @@ -41,7 +41,7 @@ from gajim import dialogs from gajim.chat_control_base import ChatControlBase from gajim.chat_control import ChatControl -from gajim.common import gajim +from gajim.common import app from gajim.gtkgui_helpers import get_action #################### @@ -89,7 +89,7 @@ class MessageWindow(object): self.parent_paned = parent_paned old_parent = self.notebook.get_parent() old_parent.remove(self.notebook) - if gajim.config.get('roster_on_the_right'): + if app.config.get('roster_on_the_right'): child1 = self.parent_paned.get_child1() self.parent_paned.remove(child1) self.parent_paned.add(self.notebook) @@ -141,7 +141,7 @@ class MessageWindow(object): self.handlers[id_] = self.notebook # Tab customizations - pref_pos = gajim.config.get('tabs_position') + pref_pos = app.config.get('tabs_position') if pref_pos == 'bottom': nb_pos = Gtk.PositionType.BOTTOM elif pref_pos == 'left': @@ -151,13 +151,13 @@ class MessageWindow(object): else: nb_pos = Gtk.PositionType.TOP self.notebook.set_tab_pos(nb_pos) - window_mode = gajim.interface.msg_win_mgr.mode - if gajim.config.get('tabs_always_visible') or \ + window_mode = app.interface.msg_win_mgr.mode + if app.config.get('tabs_always_visible') or \ window_mode == MessageWindowMgr.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER: self.notebook.set_show_tabs(True) else: self.notebook.set_show_tabs(False) - self.notebook.set_show_border(gajim.config.get('tabs_border')) + self.notebook.set_show_border(app.config.get('tabs_border')) self.show_icon() def change_account_name(self, old_name, new_name): @@ -222,14 +222,14 @@ class MessageWindow(object): if number_of_closed_control > 1: def on_yes1(checked): if checked: - gajim.config.set('confirm_close_multiple_tabs', False) + app.config.set('confirm_close_multiple_tabs', False) self.dont_warn_on_delete = True for ctrl in self.controls(): if ctrl.minimizable(): ctrl.minimize() win.destroy() - if not gajim.config.get('confirm_close_multiple_tabs'): + if not app.config.get('confirm_close_multiple_tabs'): for ctrl in self.controls(): if ctrl.minimizable(): ctrl.minimize() @@ -360,9 +360,9 @@ class MessageWindow(object): # theme if not Gtk.Settings.get_default().get_property( 'gtk-key-theme-name') == 'Emacs': - if gajim.interface.msg_win_mgr.mode == \ - gajim.interface.msg_win_mgr.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER: - gajim.interface.roster.tree.grab_focus() + if app.interface.msg_win_mgr.mode == \ + app.interface.msg_win_mgr.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER: + app.interface.roster.tree.grab_focus() return False control._on_send_file_menuitem_activate(None) return True @@ -451,7 +451,7 @@ class MessageWindow(object): return True # Close tab bindings elif keyval == Gdk.KEY_Escape and \ - gajim.config.get('escape_key_closes'): # Escape + app.config.get('escape_key_closes'): # Escape self.remove_tab(control, self.CLOSE_ESC) return True @@ -462,7 +462,7 @@ class MessageWindow(object): self.remove_tab(control, self.CLOSE_CLOSE_BUTTON) def show_icon(self): - window_mode = gajim.interface.msg_win_mgr.mode + window_mode = app.interface.msg_win_mgr.mode icon = None if window_mode == MessageWindowMgr.ONE_MSG_WINDOW_NEVER: ctrl = self.get_active_control() @@ -499,7 +499,7 @@ class MessageWindow(object): unread = 0 for ctrl in self.controls(): if ctrl.type_id == message_control.TYPE_GC and not \ - gajim.config.get('notify_on_all_muc_messages') and not \ + app.config.get('notify_on_all_muc_messages') and not \ ctrl.attention_flag: # count only pm messages unread += ctrl.get_nb_unread_pm() @@ -517,13 +517,13 @@ class MessageWindow(object): if control.type_id == message_control.TYPE_GC: name = control.room_jid.split('@')[0] urgent = control.attention_flag or \ - gajim.config.get('notify_on_all_muc_messages') + app.config.get('notify_on_all_muc_messages') else: name = control.contact.get_shown_name() if control.resource: name += '/' + control.resource - window_mode = gajim.interface.msg_win_mgr.mode + window_mode = app.interface.msg_win_mgr.mode if window_mode == MessageWindowMgr.ONE_MSG_WINDOW_PERTYPE: # Show the plural form since number of tabs > 1 if self.type_ == 'chat': @@ -570,19 +570,19 @@ class MessageWindow(object): else: # We are leaving gc without status message or it's a chat ctrl.shutdown() # Update external state - gajim.events.remove_events(ctrl.account, ctrl.get_full_jid, + app.events.remove_events(ctrl.account, ctrl.get_full_jid, types = ['printed_msg', 'chat', 'gc_msg']) fjid = ctrl.get_full_jid() - jid = gajim.get_jid_without_resource(fjid) + jid = app.get_jid_without_resource(fjid) fctrl = self.get_control(fjid, ctrl.account) bctrl = self.get_control(jid, ctrl.account) # keep last_message_time around unless this was our last control with # that jid if not fctrl and not bctrl and \ - fjid in gajim.last_message_time[ctrl.account]: - del gajim.last_message_time[ctrl.account][fjid] + fjid in app.last_message_time[ctrl.account]: + del app.last_message_time[ctrl.account][fjid] self.notebook.remove_page(self.notebook.page_num(ctrl.widget)) @@ -619,8 +619,8 @@ class MessageWindow(object): pass elif self.get_num_controls() == 0: # These are not called when the window is destroyed like this, fake it - gajim.interface.msg_win_mgr._on_window_delete(self.window, None) - gajim.interface.msg_win_mgr._on_window_destroy(self.window) + app.interface.msg_win_mgr._on_window_delete(self.window, None) + app.interface.msg_win_mgr._on_window_destroy(self.window) # dnd clean up self.notebook.drag_dest_unset() if self.parent_paned: @@ -632,8 +632,8 @@ class MessageWindow(object): self.window.destroy() return # don't show_title, we are dead elif self.get_num_controls() == 1: # we are going from two tabs to one - window_mode = gajim.interface.msg_win_mgr.mode - show_tabs_if_one_tab = gajim.config.get('tabs_always_visible') or \ + window_mode = app.interface.msg_win_mgr.mode + show_tabs_if_one_tab = app.config.get('tabs_always_visible') or \ window_mode == MessageWindowMgr.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER self.notebook.set_show_tabs(show_tabs_if_one_tab) @@ -647,7 +647,7 @@ class MessageWindow(object): # Optionally hide close button close_button = hbox.get_children()[2] - if gajim.config.get('tabs_close_button'): + if app.config.get('tabs_close_button'): close_button.show() else: close_button.hide() @@ -757,10 +757,10 @@ class MessageWindow(object): self._controls[acct][new_jid] = ctrl del self._controls[acct][old_jid] - if old_jid in gajim.last_message_time[acct]: - gajim.last_message_time[acct][new_jid] = \ - gajim.last_message_time[acct][old_jid] - del gajim.last_message_time[acct][old_jid] + if old_jid in app.last_message_time[acct]: + app.last_message_time[acct][new_jid] = \ + app.last_message_time[acct][old_jid] + del app.last_message_time[acct][old_jid] def controls(self): for jid_dict in list(self._controls.values()): @@ -790,7 +790,7 @@ class MessageWindow(object): if ctrl.get_nb_unread() > 0: found = True break # found - elif gajim.config.get('ctrl_tab_go_to_next_composing') : + elif app.config.get('ctrl_tab_go_to_next_composing') : # Search for a composing contact contact = ctrl.contact if first_composing_ind == -1 and contact.chatstate == 'composing': @@ -818,7 +818,7 @@ class MessageWindow(object): def popup_menu(self, event): menu = self.get_active_control().prepare_context_menu() # show the menu - menu.attach_to_widget(gajim.interface.roster.window, None) + menu.attach_to_widget(app.interface.roster.window, None) menu.show_all() menu.popup(None, None, None, None, event.button, event.time) @@ -956,7 +956,7 @@ class MessageWindowMgr(GObject.GObject): self._windows = {} # Map the mode to a int constant for frequent compares - mode = gajim.config.get('one_message_window') + mode = app.config.get('one_message_window') self.mode = common.config.opt_one_window_types.index(mode) self.parent_win = parent_window @@ -1005,23 +1005,23 @@ class MessageWindowMgr(GObject.GObject): """ Resizes window according to config settings """ - hpaned = gajim.config.get('roster_hpaned_position') + hpaned = app.config.get('roster_hpaned_position') if self.mode in (self.ONE_MSG_WINDOW_ALWAYS, self.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER): - size = (gajim.config.get('msgwin-width'), - gajim.config.get('msgwin-height')) + size = (app.config.get('msgwin-width'), + app.config.get('msgwin-height')) if self.mode == self.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER: # Need to add the size of the now visible paned handle, otherwise # the saved width of the message window decreases by this amount handle_size = win.parent_paned.style_get_property('handle-size') size = (hpaned + size[0] + handle_size, size[1]) elif self.mode == self.ONE_MSG_WINDOW_PERACCT: - size = (gajim.config.get_per('accounts', acct, 'msgwin-width'), - gajim.config.get_per('accounts', acct, 'msgwin-height')) + size = (app.config.get_per('accounts', acct, 'msgwin-width'), + app.config.get_per('accounts', acct, 'msgwin-height')) elif self.mode in (self.ONE_MSG_WINDOW_NEVER, self.ONE_MSG_WINDOW_PERTYPE): opt_width = type_ + '-msgwin-width' opt_height = type_ + '-msgwin-height' - size = (gajim.config.get(opt_width), gajim.config.get(opt_height)) + size = (app.config.get(opt_width), app.config.get(opt_height)) else: return win.resize(size[0], size[1]) @@ -1037,14 +1037,14 @@ class MessageWindowMgr(GObject.GObject): return if self.mode == self.ONE_MSG_WINDOW_ALWAYS: - pos = (gajim.config.get('msgwin-x-position'), - gajim.config.get('msgwin-y-position')) + pos = (app.config.get('msgwin-x-position'), + app.config.get('msgwin-y-position')) elif self.mode == self.ONE_MSG_WINDOW_PERACCT: - pos = (gajim.config.get_per('accounts', acct, 'msgwin-x-position'), - gajim.config.get_per('accounts', acct, 'msgwin-y-position')) + pos = (app.config.get_per('accounts', acct, 'msgwin-x-position'), + app.config.get_per('accounts', acct, 'msgwin-y-position')) elif self.mode == self.ONE_MSG_WINDOW_PERTYPE: - pos = (gajim.config.get(type_ + '-msgwin-x-position'), - gajim.config.get(type_ + '-msgwin-y-position')) + pos = (app.config.get(type_ + '-msgwin-x-position'), + app.config.get(type_ + '-msgwin-y-position')) else: return @@ -1094,7 +1094,7 @@ class MessageWindowMgr(GObject.GObject): # Position and size window based on saved state and window mode if not self.one_window_opened(contact, acct, type_): - if gajim.config.get('msgwin-max-state'): + if app.config.get('msgwin-max-state'): win.window.maximize() else: self._resize_window(win, acct, type_) @@ -1116,7 +1116,7 @@ class MessageWindowMgr(GObject.GObject): def _on_window_delete(self, win, event): self.save_state(self._gtk_win_to_msg_win(win)) - gajim.interface.save_config() + app.interface.save_config() return False def _on_window_destroy(self, win): @@ -1190,7 +1190,7 @@ class MessageWindowMgr(GObject.GObject): w.window.hide() w.window.destroy() - gajim.interface.save_config() + app.interface.save_config() def save_state(self, msg_win, width_adjust=0): # Save window size and position @@ -1225,29 +1225,29 @@ class MessageWindowMgr(GObject.GObject): width = msg_win.notebook.get_allocation().width if acct: - gajim.config.set_per('accounts', acct, size_width_key, width) - gajim.config.set_per('accounts', acct, size_height_key, height) + app.config.set_per('accounts', acct, size_width_key, width) + app.config.set_per('accounts', acct, size_height_key, height) if self.mode != self.ONE_MSG_WINDOW_NEVER: - gajim.config.set_per('accounts', acct, pos_x_key, x) - gajim.config.set_per('accounts', acct, pos_y_key, y) + app.config.set_per('accounts', acct, pos_x_key, x) + app.config.set_per('accounts', acct, pos_y_key, y) else: win_maximized = msg_win.window.get_window().get_state() == \ Gdk.WindowState.MAXIMIZED - gajim.config.set(max_win_key, win_maximized) + app.config.set(max_win_key, win_maximized) width += width_adjust - gajim.config.set(size_width_key, width) - gajim.config.set(size_height_key, height) + app.config.set(size_width_key, width) + app.config.set(size_height_key, height) if self.mode != self.ONE_MSG_WINDOW_NEVER: - gajim.config.set(pos_x_key, x) - gajim.config.set(pos_y_key, y) + app.config.set(pos_x_key, x) + app.config.set(pos_y_key, y) def reconfig(self): for w in self.windows(): self.save_state(w) - mode = gajim.config.get('one_message_window') + mode = app.config.get('one_message_window') if self.mode == common.config.opt_one_window_types.index(mode): # No change return @@ -1263,7 +1263,7 @@ class MessageWindowMgr(GObject.GObject): # Stash current size so it can be restored if the MessageWindow # is not longer embedded roster_width = w.parent_paned.get_position() - gajim.config.set('roster_width', roster_width) + app.config.set('roster_width', roster_width) while w.notebook.get_n_pages(): page = w.notebook.get_nth_page(0) @@ -1282,8 +1282,8 @@ class MessageWindowMgr(GObject.GObject): w.parent_paned.remove(child) self.parent_win.lookup_action('show-roster').set_enabled(False) gtkgui_helpers.resize_window(w.window, - gajim.config.get('roster_width'), - gajim.config.get('roster_height')) + app.config.get('roster_width'), + app.config.get('roster_height')) self._windows = {} @@ -1296,15 +1296,15 @@ class MessageWindowMgr(GObject.GObject): mw.new_tab(ctrl) def save_opened_controls(self): - if not gajim.config.get('remember_opened_chat_controls'): + if not app.config.get('remember_opened_chat_controls'): return chat_controls = {} - for acct in gajim.connections: + for acct in app.connections: chat_controls[acct] = [] for ctrl in self.get_controls(type_=message_control.TYPE_CHAT): acct = ctrl.account if ctrl.contact.jid not in chat_controls[acct]: chat_controls[acct].append(ctrl.contact.jid) - for acct in gajim.connections: - gajim.config.set_per('accounts', acct, 'opened_chat_controls', + for acct in app.connections: + app.config.set_per('accounts', acct, 'opened_chat_controls', ','.join(chat_controls[acct])) diff --git a/gajim/negotiation.py b/gajim/negotiation.py index b6fc9505e..250512e08 100644 --- a/gajim/negotiation.py +++ b/gajim/negotiation.py @@ -23,7 +23,7 @@ from gajim import gtkgui_helpers from gajim import dataforms_widget from gajim.common import dataforms -from gajim.common import gajim +from gajim.common import app import nbxmpp def describe_features(features): @@ -65,7 +65,7 @@ class FeatureNegotiationWindow: feature.addChild(node=form) - gajim.connections[self.account].send_stanza(acceptance) + app.connections[self.account].send_stanza(acceptance) self.window.destroy() @@ -81,6 +81,6 @@ class FeatureNegotiationWindow: feature.addChild(node=x) - gajim.connections[self.account].send_stanza(rejection) + app.connections[self.account].send_stanza(rejection) self.window.destroy() diff --git a/gajim/network_watcher.py b/gajim/network_watcher.py index a35e0e882..f1ef629fc 100644 --- a/gajim/network_watcher.py +++ b/gajim/network_watcher.py @@ -24,7 +24,7 @@ import logging from gi.repository import Gio, GLib -from gajim.common import gajim +from gajim.common import app log = logging.getLogger('gajim.network_watcher') @@ -87,11 +87,11 @@ def appeared(connection, name, name_owner, *user_data): def update_connection_state(connected): if connected: - for connection in gajim.connections.values(): + for connection in app.connections.values(): log.info('Connect %s', connection.name) connection.reconnect() else: - for connection in gajim.connections.values(): + for connection in app.connections.values(): if connection.connected > 1: log.info('Disconnect %s', connection.name) connection.disconnectedReconnCB() diff --git a/gajim/notify.py b/gajim/notify.py index 501d61271..d2a80f08e 100644 --- a/gajim/notify.py +++ b/gajim/notify.py @@ -34,7 +34,7 @@ from gi.repository import GObject from gi.repository import GLib from gajim import gtkgui_helpers -from gajim.common import gajim +from gajim.common import app from gajim.common import helpers from gajim.common import ged @@ -67,11 +67,11 @@ def get_show_in_systray(event, account, contact, type_=None): """ Return True if this event must be shown in systray, else False """ - if type_ == 'printed_gc_msg' and not gajim.config.get( + if type_ == 'printed_gc_msg' and not app.config.get( 'notify_on_all_muc_messages'): # it's not an highlighted message, don't show in systray return False - return gajim.config.get('trayicon_notification_on_events') + return app.config.get('trayicon_notification_on_events') def popup(event_type, jid, account, msg_type='', path_to_image=None, title=None, text=None, timeout=-1): @@ -85,27 +85,27 @@ text=None, timeout=-1): path_to_image = gtkgui_helpers.get_icon_path('gajim-chat_msg_recv', 48) if timeout < 0: - timeout = gajim.config.get('notification_timeout') + timeout = app.config.get('notification_timeout') # Try to show our popup via D-Bus and notification daemon - if gajim.config.get('use_notif_daemon') and dbus_support.supported: + if app.config.get('use_notif_daemon') and dbus_support.supported: try: DesktopNotification(event_type, jid, account, msg_type, path_to_image, title, GLib.markup_escape_text(text), timeout) return # sucessfully did D-Bus Notification procedure! except dbus.DBusException as e: # Connection to D-Bus failed - gajim.log.debug(str(e)) + app.log.debug(str(e)) except TypeError as e: # This means that we sent the message incorrectly - gajim.log.debug(str(e)) + app.log.debug(str(e)) # Ok, that failed. Let's try pynotify, which also uses notification daemon - if gajim.config.get('use_notif_daemon') and USER_HAS_PYNOTIFY: + if app.config.get('use_notif_daemon') and USER_HAS_PYNOTIFY: if not text and event_type == 'new_message': # empty text for new_message means do_preview = False # -> default value for text - _text = GLib.markup_escape_text(gajim.get_name_from_jid(account, + _text = GLib.markup_escape_text(app.get_name_from_jid(account, jid)) else: _text = GLib.markup_escape_text(text) @@ -134,12 +134,12 @@ text=None, timeout=-1): return except GObject.GError as e: # Connection to notification-daemon failed, see #2893 - gajim.log.debug(str(e)) + app.log.debug(str(e)) # Either nothing succeeded or the user wants old-style notifications instance = PopupNotificationWindow(event_type, jid, account, msg_type, path_to_image, title, text, timeout) - gajim.interface.roster.popup_notification_windows.append(instance) + app.interface.roster.popup_notification_windows.append(instance) def on_pynotify_notification_clicked(notification, action): jid = notification._data.jid @@ -147,14 +147,14 @@ def on_pynotify_notification_clicked(notification, action): msg_type = notification._data.msg_type notification.close() - gajim.interface.handle_event(account, jid, msg_type) + app.interface.handle_event(account, jid, msg_type) class Notification: """ Handle notifications """ def __init__(self): - gajim.ged.register_event_handler('notification', ged.GUI2, + app.ged.register_event_handler('notification', ged.GUI2, self._nec_notification) def _nec_notification(self, obj): @@ -237,7 +237,7 @@ class NotificationResponseManager: self.pending[id_] = object_ else: # We've triggered an event that has a duplicate ID! - gajim.log.debug('Duplicate ID of notification. Can\'t handle this.') + app.log.debug('Duplicate ID of notification. Can\'t handle this.') notification_response_manager = NotificationResponseManager() @@ -265,7 +265,7 @@ class DesktopNotification: # default value of text if not text and event_type == 'new_message': # empty text for new_message means do_preview = False - self.text = gajim.get_name_from_jid(account, jid) + self.text = app.get_name_from_jid(account, jid) if not title: self.title = event_type # default value @@ -365,9 +365,9 @@ class DesktopNotification: # we're actually dealing with the newer version version = [0, 3, 1] if version > [0, 3]: - if gajim.interface.systray_enabled and \ - gajim.config.get('attach_notifications_to_systray'): - status_icon = gajim.interface.systray.status_icon + if app.interface.systray_enabled and \ + app.config.get('attach_notifications_to_systray'): + status_icon = app.interface.systray.status_icon rect = status_icon.get_geometry()[2] x, y, width, height = rect.x, rect.y, rect.width, rect.height pos_x = x + (width / 2) @@ -432,12 +432,12 @@ class DesktopNotification: notification_response_manager.add_pending(id_, self) def notify_another_way(self, e): - gajim.log.debug('Error when trying to use notification daemon: %s' % \ + app.log.debug('Error when trying to use notification daemon: %s' % \ str(e)) instance = PopupNotificationWindow(self.event_type, self.jid, self.account, self.msg_type, self.path_to_image, self.title, self.text, self.timeout) - gajim.interface.roster.popup_notification_windows.append(instance) + app.interface.roster.popup_notification_windows.append(instance) def on_action_invoked(self, id_, reason): if self.notif is None: @@ -448,7 +448,7 @@ class DesktopNotification: if reason == 'ignore': return - gajim.interface.handle_event(self.account, self.jid, self.msg_type) + app.interface.handle_event(self.account, self.jid, self.msg_type) def version_reply_handler(self, name, vendor, version, spec_version=None): if spec_version: diff --git a/gajim/plugins/gajimplugin.py b/gajim/plugins/gajimplugin.py index 0f89e5fd1..c9fd28229 100644 --- a/gajim/plugins/gajimplugin.py +++ b/gajim/plugins/gajimplugin.py @@ -27,7 +27,7 @@ Base class for implementing plugin. import os import locale -from gajim.common import gajim +from gajim.common import app from gajim.plugins.helpers import log_calls, log from gajim.plugins.gui import GajimPluginConfigDialog @@ -213,7 +213,7 @@ class GajimPluginConfig(): def __init__(self, plugin): self.plugin = plugin self.FILE_PATH = os.path.join( - gajim.PLUGINS_CONFIG_DIR, self.plugin.short_name) + app.PLUGINS_CONFIG_DIR, self.plugin.short_name) self.data = {} @log_calls('GajimPluginConfig') diff --git a/gajim/plugins/gui.py b/gajim/plugins/gui.py index 7c4bed707..086294a39 100644 --- a/gajim/plugins/gui.py +++ b/gajim/plugins/gui.py @@ -37,7 +37,7 @@ from enum import IntEnum, unique from gajim import gtkgui_helpers from gajim.dialogs import WarningDialog, YesNoDialog, ArchiveChooserDialog from gajim.htmltextview import HtmlTextView -from gajim.common import gajim +from gajim.common import app from gajim.plugins.helpers import log_calls from gajim.plugins.helpers import GajimPluginActivateException from gajim.plugins.plugins_i18n import _ @@ -60,7 +60,7 @@ class PluginsWindow(object): '''Initialize Plugins window''' builder = gtkgui_helpers.get_gtk_builder('plugins_window.ui') self.window = builder.get_object('plugins_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.window.set_transient_for(app.interface.roster.window) widgets_to_extract = ('plugins_notebook', 'plugin_name_label', 'plugin_version_label', 'plugin_authors_label', @@ -118,7 +118,7 @@ class PluginsWindow(object): self.close_button.grab_focus() # Adding GUI extension point for Plugins that want to hook the Plugin Window - gajim.plugin_manager.gui_extension_point('plugin_window', self) + app.plugin_manager.gui_extension_point('plugin_window', self) self.window.show_all() gtkgui_helpers.possibly_move_window_in_current_desktop(self.window) @@ -166,7 +166,7 @@ class PluginsWindow(object): self.plugin_description_textview.set_property('sensitive', True) self.uninstall_plugin_button.set_property('sensitive', - gajim.PLUGINS_DIRS[1] in plugin.__path__) + app.PLUGINS_DIRS[1] in plugin.__path__) self.configure_plugin_button.set_property( 'sensitive', plugin.config_dialog is not None) @@ -186,7 +186,7 @@ class PluginsWindow(object): @log_calls('PluginsWindow') def fill_installed_plugins_model(self): - pm = gajim.plugin_manager + pm = app.plugin_manager self.installed_plugins_model.clear() self.installed_plugins_model.set_sort_column_id(1, Gtk.SortType.ASCENDING) @@ -209,10 +209,10 @@ class PluginsWindow(object): plugin = self.installed_plugins_model[path][Column.PLUGIN] if is_active: - gajim.plugin_manager.deactivate_plugin(plugin) + app.plugin_manager.deactivate_plugin(plugin) else: try: - gajim.plugin_manager.activate_plugin(plugin) + app.plugin_manager.activate_plugin(plugin) except GajimPluginActivateException as e: WarningDialog(_('Plugin failed'), str(e), transient_for=self.window) @@ -223,8 +223,8 @@ class PluginsWindow(object): @log_calls('PluginsWindow') def on_plugins_window_destroy(self, widget): '''Close window''' - gajim.plugin_manager.remove_gui_extension_point('plugin_window', self) - del gajim.interface.instances['plugins'] + app.plugin_manager.remove_gui_extension_point('plugin_window', self) + del app.interface.instances['plugins'] @log_calls('PluginsWindow') def on_close_button_clicked(self, widget): @@ -257,7 +257,7 @@ class PluginsWindow(object): plugin_name = model.get_value(iter, Column.NAME) is_active = model.get_value(iter, Column.ACTIVE) try: - gajim.plugin_manager.remove_plugin(plugin) + app.plugin_manager.remove_plugin(plugin) except PluginsystemError as e: WarningDialog(_('Unable to properly remove the plugin'), str(e), self.window) @@ -274,7 +274,7 @@ class PluginsWindow(object): def _on_plugin_exists(zip_filename): def on_yes(is_checked): - plugin = gajim.plugin_manager.install_from_zip(zip_filename, + plugin = app.plugin_manager.install_from_zip(zip_filename, True) if not plugin: show_warn_dialog() @@ -296,7 +296,7 @@ class PluginsWindow(object): def _try_install(zip_filename): try: - plugin = gajim.plugin_manager.install_from_zip(zip_filename) + plugin = app.plugin_manager.install_from_zip(zip_filename) except PluginsystemError as er_type: error_text = str(er_type) if error_text == _('Plugin already exists'): diff --git a/gajim/plugins/pluginmanager.py b/gajim/plugins/pluginmanager.py index 59bea980c..b08837824 100644 --- a/gajim/plugins/pluginmanager.py +++ b/gajim/plugins/pluginmanager.py @@ -34,7 +34,7 @@ from shutil import rmtree import configparser from pkg_resources import parse_version -from gajim.common import gajim +from gajim.common import app from gajim.common import nec from gajim.common.exceptions import PluginsystemError @@ -107,24 +107,24 @@ class PluginManager(metaclass=Singleton): Registered names with instances of encryption Plugins. ''' - for path in [gajim.PLUGINS_DIRS[1], gajim.PLUGINS_DIRS[0]]: + for path in [app.PLUGINS_DIRS[1], app.PLUGINS_DIRS[0]]: pc = PluginManager.scan_dir_for_plugins(path) self.add_plugins(pc) self._activate_all_plugins_from_global_config() @log_calls('PluginManager') def _plugin_has_entry_in_global_config(self, plugin): - if gajim.config.get_per('plugins', plugin.short_name) is None: + if app.config.get_per('plugins', plugin.short_name) is None: return False else: return True @log_calls('PluginManager') def _create_plugin_entry_in_global_config(self, plugin): - gajim.config.add_per('plugins', plugin.short_name) + app.config.add_per('plugins', plugin.short_name) def _remove_plugin_entry_in_global_config(self, plugin): - gajim.config.del_per('plugins', plugin.short_name) + app.config.del_per('plugins', plugin.short_name) @log_calls('PluginManager') def add_plugin(self, plugin_class): @@ -292,30 +292,30 @@ class PluginManager(metaclass=Singleton): for event_name, handler in plugin.events_handlers.items(): priority = handler[0] handler_function = handler[1] - gajim.ged.register_event_handler(event_name, priority, + app.ged.register_event_handler(event_name, priority, handler_function) def _remove_events_handler_from_ged(self, plugin): for event_name, handler in plugin.events_handlers.items(): priority = handler[0] handler_function = handler[1] - gajim.ged.remove_event_handler(event_name, priority, + app.ged.remove_event_handler(event_name, priority, handler_function) def _register_network_events_in_nec(self, plugin): for event_class in plugin.events: setattr(event_class, 'plugin', plugin) if issubclass(event_class, nec.NetworkIncomingEvent): - gajim.nec.register_incoming_event(event_class) + app.nec.register_incoming_event(event_class) elif issubclass(event_class, nec.NetworkOutgoingEvent): - gajim.nec.register_outgoing_event(event_class) + app.nec.register_outgoing_event(event_class) def _remove_network_events_from_nec(self, plugin): for event_class in plugin.events: if issubclass(event_class, nec.NetworkIncomingEvent): - gajim.nec.unregister_incoming_event(event_class) + app.nec.unregister_incoming_event(event_class) elif issubclass(event_class, nec.NetworkOutgoingEvent): - gajim.nec.unregister_outgoing_event(event_class) + app.nec.unregister_outgoing_event(event_class) def _remove_name_from_encryption_plugins(self, plugin): if plugin.encryption_name: @@ -432,10 +432,10 @@ class PluginManager(metaclass=Singleton): pass def _plugin_is_active_in_global_config(self, plugin): - return gajim.config.get_per('plugins', plugin.short_name, 'active') + return app.config.get_per('plugins', plugin.short_name, 'active') def _set_plugin_active_in_global_config(self, plugin, active=True): - gajim.config.set_per('plugins', plugin.short_name, 'active', active) + app.config.set_per('plugins', plugin.short_name, 'active', active) @staticmethod @log_calls('PluginManager') @@ -506,7 +506,7 @@ class PluginManager(metaclass=Singleton): min_v = conf.get('info', 'min_gajim_version', fallback=None) max_v = conf.get('info', 'max_gajim_version', fallback=None) - gajim_v = gajim.config.get('version').split('-', 1)[0] + gajim_v = app.config.get('version').split('-', 1)[0] gajim_v_cmp = parse_version(gajim_v) if min_v and gajim_v_cmp < parse_version(min_v): @@ -531,7 +531,7 @@ class PluginManager(metaclass=Singleton): try: if module_name in sys.modules: - if path == gajim.PLUGINS_DIRS[0]: + if path == app.PLUGINS_DIRS[0]: # Only reload plugins from Gajim base dir when they # dont exist. This means plugins in the user path are # always preferred. @@ -629,7 +629,7 @@ class PluginManager(metaclass=Singleton): if len(dirs) > 1: raise PluginsystemError(_('Archive is malformed')) - base_dir, user_dir = gajim.PLUGINS_DIRS + base_dir, user_dir = app.PLUGINS_DIRS plugin_dir = os.path.join(user_dir, dirs[0]) if os.path.isdir(plugin_dir): diff --git a/gajim/plugins/plugins_i18n.py b/gajim/plugins/plugins_i18n.py index b525b835b..e33050f7f 100644 --- a/gajim/plugins/plugins_i18n.py +++ b/gajim/plugins/plugins_i18n.py @@ -22,10 +22,10 @@ import locale import gettext from os import path as os_path import os -from gajim.common import gajim +from gajim.common import app APP = 'gajim_plugins' -plugins_locale_dir = os_path.join(gajim.PLUGINS_DIRS[1], 'locale') +plugins_locale_dir = os_path.join(app.PLUGINS_DIRS[1], 'locale') if os.name != 'nt': locale.setlocale(locale.LC_ALL, '') diff --git a/gajim/profile_window.py b/gajim/profile_window.py index eacab65c1..c16247ed3 100644 --- a/gajim/profile_window.py +++ b/gajim/profile_window.py @@ -36,7 +36,7 @@ from gajim import gtkgui_helpers from gajim import dialogs from gajim import vcard -from gajim.common import gajim +from gajim.common import app from gajim.common import ged @@ -54,7 +54,7 @@ class ProfileWindow: self.context_id = self.statusbar.get_context_id('profile') self.account = account - self.jid = gajim.get_jid_from_account(account) + self.jid = app.get_jid_from_account(account) self.dialog = None self.avatar_mime_type = None @@ -69,11 +69,11 @@ class ProfileWindow: image = Gtk.Image() self.xml.get_object('PHOTO_button').set_image(image) self.xml.connect_signals(self) - gajim.ged.register_event_handler('vcard-published', ged.GUI1, + app.ged.register_event_handler('vcard-published', ged.GUI1, self._nec_vcard_published) - gajim.ged.register_event_handler('vcard-not-published', ged.GUI1, + app.ged.register_event_handler('vcard-not-published', ged.GUI1, self._nec_vcard_not_published) - gajim.ged.register_event_handler('vcard-received', ged.GUI1, + app.ged.register_event_handler('vcard-received', ged.GUI1, self._nec_vcard_received) self.window.show_all() self.xml.get_object('ok_button').grab_focus() @@ -94,13 +94,13 @@ class ProfileWindow: GLib.source_remove(self.update_progressbar_timeout_id) if self.remove_statusbar_timeout_id is not None: GLib.source_remove(self.remove_statusbar_timeout_id) - gajim.ged.remove_event_handler('vcard-published', ged.GUI1, + app.ged.remove_event_handler('vcard-published', ged.GUI1, self._nec_vcard_published) - gajim.ged.remove_event_handler('vcard-not-published', ged.GUI1, + app.ged.remove_event_handler('vcard-not-published', ged.GUI1, self._nec_vcard_not_published) - gajim.ged.remove_event_handler('vcard-received', ged.GUI1, + app.ged.remove_event_handler('vcard-received', ged.GUI1, self._nec_vcard_received) - del gajim.interface.instances[self.account]['profile'] + del app.interface.instances[self.account]['profile'] if self.dialog: # Image chooser dialog self.dialog.destroy() @@ -151,7 +151,7 @@ class ProfileWindow: return if filesize > 16384: if scaled_pixbuf: - path_to_file = os.path.join(gajim.TMP, + path_to_file = os.path.join(app.TMP, 'avatar_scaled.png') scaled_pixbuf.savev(path_to_file, 'png', [], []) must_delete = True @@ -181,7 +181,7 @@ class ProfileWindow: try: os.remove(path_to_file) except OSError: - gajim.log.debug('Cannot remove %s' % path_to_file) + app.log.debug('Cannot remove %s' % path_to_file) def on_clear(widget): self.dialog.destroy() @@ -210,7 +210,7 @@ class ProfileWindow: use_local=False) if pixbuf not in (None, 'ask'): - nick = gajim.config.get_per('accounts', self.account, 'name') + nick = app.config.get_per('accounts', self.account, 'name') menuitem = Gtk.MenuItem.new_with_mnemonic(_('Save _As')) menuitem.connect('activate', gtkgui_helpers.on_avatar_save_as_menuitem_activate, @@ -371,7 +371,7 @@ class ProfileWindow: if self.update_progressbar_timeout_id: # Operation in progress return - if gajim.connections[self.account].connected < 2: + if app.connections[self.account].connected < 2: dialogs.ErrorDialog(_('You are not connected to the server'), _('Without a connection, you can not publish your contact ' 'information.'), transient_for=self.window) @@ -380,12 +380,12 @@ class ProfileWindow: nick = '' if 'NICKNAME' in vcard_: nick = vcard_['NICKNAME'] - gajim.connections[self.account].send_nickname(nick) + app.connections[self.account].send_nickname(nick) if nick == '': - gajim.connections[self.account].retract_nickname() - nick = gajim.config.get_per('accounts', self.account, 'name') - gajim.nicks[self.account] = nick - gajim.connections[self.account].send_vcard(vcard_) + app.connections[self.account].retract_nickname() + nick = app.config.get_per('accounts', self.account, 'name') + app.nicks[self.account] = nick + app.connections[self.account].send_vcard(vcard_) self.message_id = self.statusbar.push(self.context_id, _('Sending profile…')) self.progressbar.show() diff --git a/gajim/remote_control.py b/gajim/remote_control.py index 8f20f09b3..60c9a96a0 100644 --- a/gajim/remote_control.py +++ b/gajim/remote_control.py @@ -32,7 +32,7 @@ import os import base64 import mimetypes -from gajim.common import gajim +from gajim.common import app from gajim.common import helpers from time import time from gajim.dialogs import AddNewContactWindow, NewChatDialog, JoinGroupchatWindow @@ -107,33 +107,33 @@ class Remote: bus_name = dbus.service.BusName(SERVICE, bus=session_bus) self.signal_object = SignalObject(bus_name) - gajim.ged.register_event_handler('version-result-received', ged.POSTGUI, + app.ged.register_event_handler('version-result-received', ged.POSTGUI, self.on_os_info) - gajim.ged.register_event_handler('time-result-received', ged.POSTGUI, + app.ged.register_event_handler('time-result-received', ged.POSTGUI, self.on_time) - gajim.ged.register_event_handler('gmail-nofify', ged.POSTGUI, + app.ged.register_event_handler('gmail-nofify', ged.POSTGUI, self.on_gmail_notify) - gajim.ged.register_event_handler('roster-info', ged.POSTGUI, + app.ged.register_event_handler('roster-info', ged.POSTGUI, self.on_roster_info) - gajim.ged.register_event_handler('presence-received', ged.POSTGUI, + app.ged.register_event_handler('presence-received', ged.POSTGUI, self.on_presence_received) - gajim.ged.register_event_handler('subscribe-presence-received', + app.ged.register_event_handler('subscribe-presence-received', ged.POSTGUI, self.on_subscribe_presence_received) - gajim.ged.register_event_handler('subscribed-presence-received', + app.ged.register_event_handler('subscribed-presence-received', ged.POSTGUI, self.on_subscribed_presence_received) - gajim.ged.register_event_handler('unsubscribed-presence-received', + app.ged.register_event_handler('unsubscribed-presence-received', ged.POSTGUI, self.on_unsubscribed_presence_received) - gajim.ged.register_event_handler('gc-message-received', + app.ged.register_event_handler('gc-message-received', ged.POSTGUI, self.on_gc_message_received) - gajim.ged.register_event_handler('our-show', ged.POSTGUI, + app.ged.register_event_handler('our-show', ged.POSTGUI, self.on_our_status) - gajim.ged.register_event_handler('account-created', ged.POSTGUI, + app.ged.register_event_handler('account-created', ged.POSTGUI, self.on_account_created) - gajim.ged.register_event_handler('vcard-received', ged.POSTGUI, + app.ged.register_event_handler('vcard-received', ged.POSTGUI, self.on_vcard_received) - gajim.ged.register_event_handler('chatstate-received', ged.POSTGUI, + app.ged.register_event_handler('chatstate-received', ged.POSTGUI, self.on_chatstate_received) - gajim.ged.register_event_handler('message-sent', ged.POSTGUI, + app.ged.register_event_handler('message-sent', ged.POSTGUI, self.on_message_sent) def on_chatstate_received(self, obj): @@ -321,8 +321,8 @@ class SignalObject(dbus.service.Object): # If user did not ask for account, returns the global status return DBUS_STRING(helpers.get_global_show()) # return show for the given account - index = gajim.connections[account].connected - return DBUS_STRING(gajim.SHOW_LIST[index]) + index = app.connections[account].connected + return DBUS_STRING(app.SHOW_LIST[index]) @dbus.service.method(INTERFACE, in_signature='s', out_signature='s') def get_status_message(self, account): @@ -333,7 +333,7 @@ class SignalObject(dbus.service.Object): # If user did not ask for account, returns the global status return DBUS_STRING(str(helpers.get_global_status())) # return show for the given account - status = gajim.connections[account].status + status = app.connections[account].status return DBUS_STRING(status) def _get_account_and_contact(self, account, jid): @@ -342,21 +342,21 @@ class SignalObject(dbus.service.Object): """ connected_account = None contact = None - accounts = gajim.contacts.get_accounts() + accounts = app.contacts.get_accounts() # if there is only one account in roster, take it as default # if user did not ask for account if not account and len(accounts) == 1: account = accounts[0] if account: - if gajim.connections[account].connected > 1: # account is connected + if app.connections[account].connected > 1: # account is connected connected_account = account - contact = gajim.contacts.get_contact_with_highest_priority(account, + contact = app.contacts.get_contact_with_highest_priority(account, jid) else: for account in accounts: - contact = gajim.contacts.get_contact_with_highest_priority(account, + contact = app.contacts.get_contact_with_highest_priority(account, jid) - if contact and gajim.connections[account].connected > 1: + if contact and app.connections[account].connected > 1: # account is connected connected_account = account break @@ -371,22 +371,22 @@ class SignalObject(dbus.service.Object): or check if the given account is connected to the groupchat """ connected_account = None - accounts = gajim.contacts.get_accounts() + accounts = app.contacts.get_accounts() # if there is only one account in roster, take it as default # if user did not ask for account if not account and len(accounts) == 1: account = accounts[0] if account: - if gajim.connections[account].connected > 1 and \ - room_jid in gajim.gc_connected[account] and \ - gajim.gc_connected[account][room_jid]: + if app.connections[account].connected > 1 and \ + room_jid in app.gc_connected[account] and \ + app.gc_connected[account][room_jid]: # account and groupchat are connected connected_account = account else: for account in accounts: - if gajim.connections[account].connected > 1 and \ - room_jid in gajim.gc_connected[account] and \ - gajim.gc_connected[account][room_jid]: + if app.connections[account].connected > 1 and \ + room_jid in app.gc_connected[account] and \ + app.gc_connected[account][room_jid]: # account and groupchat are connected connected_account = account break @@ -405,7 +405,7 @@ class SignalObject(dbus.service.Object): if file_path.startswith('file://'): file_path=file_path[7:] if os.path.isfile(file_path): # is it file? - gajim.interface.instances['file_transfers'].send_file( + app.interface.instances['file_transfers'].send_file( connected_account, contact, file_path) return DBUS_BOOLEAN(True) return DBUS_BOOLEAN(False) @@ -423,18 +423,18 @@ class SignalObject(dbus.service.Object): connected_account, contact = self._get_account_and_contact(account, jid) if connected_account: - connection = gajim.connections[connected_account] + connection = app.connections[connected_account] sessions = connection.get_sessions(jid) if sessions: session = sessions[0] else: session = connection.make_new_session(jid) - ctrl = gajim.interface.msg_win_mgr.search_control(jid, + ctrl = app.interface.msg_win_mgr.search_control(jid, connected_account) if ctrl: ctrl.send_message(message) else: - gajim.nec.push_outgoing_event(MessageOutgoingEvent(None, account=connected_account, jid=jid, message=message, keyID=keyID, type_=type_, control=ctrl)) + app.nec.push_outgoing_event(MessageOutgoingEvent(None, account=connected_account, jid=jid, message=message, keyID=keyID, type_=type_, control=ctrl)) return DBUS_BOOLEAN(True) return DBUS_BOOLEAN(False) @@ -466,8 +466,8 @@ class SignalObject(dbus.service.Object): return DBUS_BOOLEAN(False) connected_account = self._get_account_for_groupchat(account, room_jid) if connected_account: - connection = gajim.connections[connected_account] - gajim.nec.push_outgoing_event(GcMessageOutgoingEvent(None, + connection = app.connections[connected_account] + app.nec.push_outgoing_event(GcMessageOutgoingEvent(None, account=connected_account, jid=room_jid, message=message)) return DBUS_BOOLEAN(True) return DBUS_BOOLEAN(False) @@ -491,21 +491,21 @@ class SignalObject(dbus.service.Object): if account: accounts = [account] else: - accounts = gajim.connections.keys() + accounts = app.connections.keys() if len(accounts) == 1: account = accounts[0] connected_account = None first_connected_acct = None for acct in accounts: - if gajim.connections[acct].connected > 1: # account is online - contact = gajim.contacts.get_first_contact_from_jid(acct, jid) - if gajim.interface.msg_win_mgr.has_window(jid, acct): + if app.connections[acct].connected > 1: # account is online + contact = app.contacts.get_first_contact_from_jid(acct, jid) + if app.interface.msg_win_mgr.has_window(jid, acct): connected_account = acct break # jid is in roster elif contact: minimized_control = \ - jid in gajim.interface.minimized_controls[acct] + jid in app.interface.minimized_controls[acct] connected_account = acct break # we send the message to jid not in roster, because account is @@ -520,13 +520,13 @@ class SignalObject(dbus.service.Object): connected_account = first_connected_acct if minimized_control: - gajim.interface.roster.on_groupchat_maximized(None, jid, + app.interface.roster.on_groupchat_maximized(None, jid, connected_account) if connected_account: - gajim.interface.new_chat_from_jid(connected_account, jid, message) + app.interface.new_chat_from_jid(connected_account, jid, message) # preserve the 'steal focus preservation' - win = gajim.interface.msg_win_mgr.get_window(jid, + win = app.interface.msg_win_mgr.get_window(jid, connected_account).window if win.get_property('visible'): win.window.focus(Gtk.get_current_event_time()) @@ -544,24 +544,24 @@ class SignalObject(dbus.service.Object): status = '' if account: if not status: - if account not in gajim.connections: + if account not in app.connections: return DBUS_BOOLEAN(False) - status = gajim.SHOW_LIST[gajim.connections[account].connected] - GLib.idle_add(gajim.interface.roster.send_status, account, status, + status = app.SHOW_LIST[app.connections[account].connected] + GLib.idle_add(app.interface.roster.send_status, account, status, message) else: # account not specified, so change the status of all accounts - for acc in gajim.contacts.get_accounts(): - if not gajim.config.get_per('accounts', acc, + for acc in app.contacts.get_accounts(): + if not app.config.get_per('accounts', acc, 'sync_with_global_status'): continue if status: status_ = status else: - if acc not in gajim.connections: + if acc not in app.connections: continue - status_ = gajim.SHOW_LIST[gajim.connections[acc].connected] - GLib.idle_add(gajim.interface.roster.send_status, acc, status_, + status_ = app.SHOW_LIST[app.connections[acc].connected] + GLib.idle_add(app.interface.roster.send_status, acc, status_, message) return DBUS_BOOLEAN(False) @@ -572,23 +572,23 @@ class SignalObject(dbus.service.Object): priority is changed for all accounts. That are synced with global status """ if account: - gajim.config.set_per('accounts', account, 'priority', prio) - show = gajim.SHOW_LIST[gajim.connections[account].connected] - status = gajim.connections[account].status - GLib.idle_add(gajim.connections[account].change_status, show, + app.config.set_per('accounts', account, 'priority', prio) + show = app.SHOW_LIST[app.connections[account].connected] + status = app.connections[account].status + GLib.idle_add(app.connections[account].change_status, show, status) else: # account not specified, so change prio of all accounts - for acc in gajim.contacts.get_accounts(): - if not gajim.account_is_connected(acc): + for acc in app.contacts.get_accounts(): + if not app.account_is_connected(acc): continue - if not gajim.config.get_per('accounts', acc, + if not app.config.get_per('accounts', acc, 'sync_with_global_status'): continue - gajim.config.set_per('accounts', acc, 'priority', prio) - show = gajim.SHOW_LIST[gajim.connections[acc].connected] - status = gajim.connections[acc].status - GLib.idle_add(gajim.connections[acc].change_status, show, + app.config.set_per('accounts', acc, 'priority', prio) + show = app.SHOW_LIST[app.connections[acc].connected] + status = app.connections[acc].status + GLib.idle_add(app.connections[acc].change_status, show, status) @dbus.service.method(INTERFACE, in_signature='', out_signature='') @@ -596,11 +596,11 @@ class SignalObject(dbus.service.Object): """ Show the window(s) with next pending event in tabbed/group chats """ - if gajim.events.get_nb_events(): - account, jid, event = gajim.events.get_first_systray_event() + if app.events.get_nb_events(): + account, jid, event = app.events.get_first_systray_event() if not event: return - gajim.interface.handle_event(account, jid, event.type_) + app.interface.handle_event(account, jid, event.type_) @dbus.service.method(INTERFACE, in_signature='s', out_signature='a{sv}') def contact_info(self, jid): @@ -613,7 +613,7 @@ class SignalObject(dbus.service.Object): raise dbus_support.MissingArgument() jid = self._get_real_jid(jid) - cached_vcard = list(gajim.connections.values())[0].get_cached_vcard(jid) + cached_vcard = list(app.connections.values())[0].get_cached_vcard(jid) if cached_vcard: return get_dbus_struct(cached_vcard) @@ -625,7 +625,7 @@ class SignalObject(dbus.service.Object): """ List register accounts """ - result = gajim.contacts.get_accounts() + result = app.contacts.get_accounts() result_array = dbus.Array([], signature='s') if result and len(result) > 0: for account in result: @@ -638,16 +638,16 @@ class SignalObject(dbus.service.Object): Show info on account: resource, jid, nick, prio, message """ result = DBUS_DICT_SS() - if account in gajim.connections: + if account in app.connections: # account is valid - con = gajim.connections[account] + con = app.connections[account] index = con.connected - result['status'] = DBUS_STRING(gajim.SHOW_LIST[index]) + result['status'] = DBUS_STRING(app.SHOW_LIST[index]) result['name'] = DBUS_STRING(con.name) - result['jid'] = DBUS_STRING(gajim.get_jid_from_account(con.name)) + result['jid'] = DBUS_STRING(app.get_jid_from_account(con.name)) result['message'] = DBUS_STRING(con.status) result['priority'] = DBUS_STRING(str(con.priority)) - result['resource'] = DBUS_STRING(gajim.config.get_per('accounts', + result['resource'] = DBUS_STRING(app.config.get_per('accounts', con.name, 'resource')) return result @@ -658,7 +658,7 @@ class SignalObject(dbus.service.Object): return the contacts for the specified account """ result = dbus.Array([], signature='aa{sv}') - accounts = gajim.contacts.get_accounts() + accounts = app.contacts.get_accounts() if len(accounts) == 0: return result if account: @@ -667,9 +667,9 @@ class SignalObject(dbus.service.Object): accounts_to_search = accounts for acct in accounts_to_search: if acct in accounts: - for jid in gajim.contacts.get_jid_list(acct): + for jid in app.contacts.get_jid_list(acct): item = self._contacts_as_dbus_structure( - gajim.contacts.get_contacts(acct, jid)) + app.contacts.get_contacts(acct, jid)) if item: result.append(item) return result @@ -679,7 +679,7 @@ class SignalObject(dbus.service.Object): """ Show/hide the roster window """ - win = gajim.interface.roster.window + win = app.interface.roster.window if win.get_property('visible'): GLib.idle_add(win.hide) else: @@ -695,7 +695,7 @@ class SignalObject(dbus.service.Object): """ Show the roster window """ - win = gajim.interface.roster.window + win = app.interface.roster.window win.present() # preserve the 'steal focus preservation' if self._is_first(): @@ -708,7 +708,7 @@ class SignalObject(dbus.service.Object): """ Show/hide the ipython window """ - win = gajim.ipython_window + win = app.ipython_window if win: if win.window.is_visible(): GLib.idle_add(win.hide) @@ -716,7 +716,7 @@ class SignalObject(dbus.service.Object): win.show_all() win.present() else: - gajim.interface.create_ipython_window() + app.interface.create_ipython_window() @dbus.service.method(INTERFACE, in_signature='', out_signature='a{ss}') def prefs_list(self): @@ -730,13 +730,13 @@ class SignalObject(dbus.service.Object): key += node + '#' key += name prefs_dict[DBUS_STRING(key)] = DBUS_STRING(value) - gajim.config.foreach(get_prefs) + app.config.foreach(get_prefs) return prefs_dict @dbus.service.method(INTERFACE, in_signature='', out_signature='b') def prefs_store(self): try: - gajim.interface.save_config() + app.interface.save_config() except Exception: return DBUS_BOOLEAN(False) return DBUS_BOOLEAN(True) @@ -749,9 +749,9 @@ class SignalObject(dbus.service.Object): if len(key_path) != 3: return DBUS_BOOLEAN(False) if key_path[2] == '*': - gajim.config.del_per(key_path[0], key_path[1]) + app.config.del_per(key_path[0], key_path[1]) else: - gajim.config.del_per(key_path[0], key_path[1], key_path[2]) + app.config.del_per(key_path[0], key_path[1], key_path[2]) return DBUS_BOOLEAN(True) @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') @@ -761,17 +761,17 @@ class SignalObject(dbus.service.Object): key_path = key.split('#', 2) if len(key_path) < 3: subname, value = key.split('=', 1) - gajim.config.set(subname, value) + app.config.set(subname, value) return DBUS_BOOLEAN(True) subname, value = key_path[2].split('=', 1) - gajim.config.set_per(key_path[0], key_path[1], subname, value) + app.config.set_per(key_path[0], key_path[1], subname, value) return DBUS_BOOLEAN(True) @dbus.service.method(INTERFACE, in_signature='ss', out_signature='b') def add_contact(self, jid, account): if account: - if account in gajim.connections and \ - gajim.connections[account].connected > 1: + if account in app.connections and \ + app.connections[account].connected > 1: # if given account is active, use it AddNewContactWindow(account = account, jid = jid) else: @@ -785,19 +785,19 @@ class SignalObject(dbus.service.Object): @dbus.service.method(INTERFACE, in_signature='ss', out_signature='b') def remove_contact(self, jid, account): jid = self._get_real_jid(jid, account) - accounts = gajim.contacts.get_accounts() + accounts = app.contacts.get_accounts() # if there is only one account in roster, take it as default if account: accounts = [account] contact_exists = False for account in accounts: - contacts = gajim.contacts.get_contacts(account, jid) + contacts = app.contacts.get_contacts(account, jid) if contacts: - gajim.connections[account].unsubscribe(jid) + app.connections[account].unsubscribe(jid) for contact in contacts: - gajim.interface.roster.remove_contact(contact, account) - gajim.contacts.remove_jid(account, jid) + app.interface.roster.remove_contact(contact, account) + app.contacts.remove_jid(account, jid) contact_exists = True return DBUS_BOOLEAN(contact_exists) @@ -815,18 +815,18 @@ class SignalObject(dbus.service.Object): if account: accounts = [account] else: - accounts = gajim.connections.keys() + accounts = app.connections.keys() if jid.startswith('xmpp:'): return jid[5:] # len('xmpp:') = 5 nick_in_roster = None # Is jid a nick ? for account in accounts: # Does jid exists in roster of one account ? - if gajim.contacts.get_contacts(account, jid): + if app.contacts.get_contacts(account, jid): return jid if not nick_in_roster: # look in all contact if one has jid as nick - for jid_ in gajim.contacts.get_jid_list(account): - c = gajim.contacts.get_contacts(account, jid_) + for jid_ in app.contacts.get_jid_list(account): + c = app.contacts.get_contacts(account, jid_) if c[0].name == jid: nick_in_roster = jid_ break @@ -870,7 +870,7 @@ class SignalObject(dbus.service.Object): @dbus.service.method(INTERFACE, in_signature='', out_signature='s') def get_unread_msgs_number(self): - return DBUS_STRING(str(gajim.events.get_nb_events())) + return DBUS_STRING(str(app.events.get_nb_events())) @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') def start_chat(self, account): @@ -883,10 +883,10 @@ class SignalObject(dbus.service.Object): @dbus.service.method(INTERFACE, in_signature='ss', out_signature='') def send_xml(self, xml, account): if account: - gajim.connections[account].send_stanza(str(xml)) + app.connections[account].send_stanza(str(xml)) else: - for acc in gajim.contacts.get_accounts(): - gajim.connections[acc].send_stanza(str(xml)) + for acc in app.contacts.get_accounts(): + app.connections[acc].send_stanza(str(xml)) @dbus.service.method(INTERFACE, in_signature='ss', out_signature='') def change_avatar(self, picture, account): @@ -908,31 +908,31 @@ class SignalObject(dbus.service.Object): if avatar_mime_type: vcard['PHOTO']['TYPE'] = avatar_mime_type if account: - gajim.connections[account].send_vcard(vcard) + app.connections[account].send_vcard(vcard) else: - for acc in gajim.connections: - gajim.connections[acc].send_vcard(vcard) + for acc in app.connections: + app.connections[acc].send_vcard(vcard) @dbus.service.method(INTERFACE, in_signature='ssss', out_signature='') def join_room(self, room_jid, nick, password, account): if not account: # get the first connected account - accounts = gajim.connections.keys() + accounts = app.connections.keys() for acct in accounts: - if gajim.account_is_connected(acct): - if not gajim.connections[acct].is_zeroconf: + if app.account_is_connected(acct): + if not app.connections[acct].is_zeroconf: account = acct break if not account: return - if gajim.connections[account].is_zeroconf: + if app.connections[account].is_zeroconf: # zeroconf not support groupchats return if not nick: nick = '' - gajim.interface.instances[account]['join_gc'] = \ + app.interface.instances[account]['join_gc'] = \ JoinGroupchatWindow(account, room_jid, nick) else: - gajim.interface.join_gc_room(account, room_jid, nick, password) + app.interface.join_gc_room(account, room_jid, nick, password) diff --git a/gajim/roster_window.py b/gajim/roster_window.py index c6c43ad94..47de3df4a 100644 --- a/gajim/roster_window.py +++ b/gajim/roster_window.py @@ -58,7 +58,7 @@ from gajim import tooltips from gajim import message_control from gajim import adhoc_commands -from gajim.common import gajim +from gajim.common import app from gajim.common import helpers from gajim.common.exceptions import GajimGeneralException from gajim.common import i18n @@ -164,7 +164,7 @@ class RosterWindow: account -- the account of SelfContact model -- the data model (default TreeFilterModel) """ - jid = gajim.get_jid_from_account(account) + jid = app.get_jid_from_account(account) its = self._get_contact_iter(jid, account, model=model) if its: return its[0] @@ -188,7 +188,7 @@ class RosterWindow: return [] if not contact: - contact = gajim.contacts.get_first_contact_from_jid(account, jid) + contact = app.contacts.get_first_contact_from_jid(account, jid) if not contact: # We don't know this contact return [] @@ -247,23 +247,23 @@ class RosterWindow: # Merged accounts view show = helpers.get_global_show() it = self.model.append(None, [ - gajim.interface.jabber_state_images['16'][show], + app.interface.jabber_state_images['16'][show], _('Merged accounts'), 'account', '', 'all', None, None, None, None, None, None] + [None] * self.nb_ext_renderers) self._iters['MERGED']['account'] = it else: - show = gajim.SHOW_LIST[gajim.connections[account].connected] - our_jid = gajim.get_jid_from_account(account) + show = app.SHOW_LIST[app.connections[account].connected] + our_jid = app.get_jid_from_account(account) tls_pixbuf = None - if gajim.account_is_securely_connected(account): + if app.account_is_securely_connected(account): tls_pixbuf = gtkgui_helpers.get_icon_pixmap('changes-prevent', 16) # the only way to create a pixbuf from stock # tls_pixbuf = self.window.render_icon_pixbuf( # Gtk.STOCK_DIALOG_AUTHENTICATION, Gtk.IconSize.MENU) it = self.model.append(None, [ - gajim.interface.jabber_state_images['16'][show], + app.interface.jabber_state_images['16'][show], GLib.markup_escape_text(account), 'account', our_jid, account, None, None, None, None, None, tls_pixbuf] + [None] * self.nb_ext_renderers) @@ -280,7 +280,7 @@ class RosterWindow: """ if improve_speed: self._before_fill() - jids = gajim.contacts.get_jid_list(account) + jids = app.contacts.get_jid_list(account) for jid in jids: self.add_contact(jid, account) @@ -292,7 +292,7 @@ class RosterWindow: self._idle_draw_jids_of_account(jids, account) # Draw all known groups - for group in gajim.groups[account]: + for group in app.groups[account]: self.draw_group(group, account) self.draw_account(account) @@ -307,23 +307,23 @@ class RosterWindow: account_group = 'MERGED' else: account_group = account - delimiter = gajim.connections[account].nested_group_delimiter + delimiter = app.connections[account].nested_group_delimiter group_splited = group.split(delimiter) parent_group = delimiter.join(group_splited[:-1]) if len(group_splited) > 1 and parent_group in self._iters[account_group]['groups']: iter_parent = self._iters[account_group]['groups'][parent_group] elif parent_group: iter_parent = self._add_group_iter(account, parent_group) - if parent_group not in gajim.groups[account]: + if parent_group not in app.groups[account]: if account + parent_group in self.collapsed_rows: is_expanded = False else: is_expanded = True - gajim.groups[account][parent_group] = {'expand': is_expanded} + app.groups[account][parent_group] = {'expand': is_expanded} else: iter_parent = self._get_account_iter(account, self.model) iter_group = self.model.append(iter_parent, - [gajim.interface.jabber_state_images['16']['closed'], + [app.interface.jabber_state_images['16']['closed'], GLib.markup_escape_text(group), 'group', group, account, None, None, None, None, None, None] + [None] * self.nb_ext_renderers) self.draw_group(group, account) @@ -404,8 +404,8 @@ class RosterWindow: is_expanded = False else: is_expanded = True - if group not in gajim.groups[account]: - gajim.groups[account][group] = {'expand': is_expanded} + if group not in app.groups[account]: + app.groups[account][group] = {'expand': is_expanded} assert len(added_iters), '%s has not been added to roster!' % \ contact.jid @@ -462,8 +462,8 @@ class RosterWindow: else: account_group = account group = self.model[parent_i][Column.JID] - if group in gajim.groups[account]: - del gajim.groups[account][group] + if group in app.groups[account]: + del app.groups[account][group] to_be_removed = parent_i del self._iters[account_group]['groups'][group] parent_i = self.model.iter_parent(parent_i) @@ -489,7 +489,7 @@ class RosterWindow: self._get_nearby_family_and_big_brother(family, account) if not big_brother_jid: return [] - big_brother_contact = gajim.contacts.get_first_contact_from_jid( + big_brother_contact = app.contacts.get_first_contact_from_jid( big_brother_account, big_brother_jid) assert len(self._get_contact_iter(big_brother_jid, @@ -503,7 +503,7 @@ class RosterWindow: for data in nearby_family: _account = data['account'] _jid = data['jid'] - _contact = gajim.contacts.get_first_contact_from_jid( + _contact = app.contacts.get_first_contact_from_jid( _account, _jid) if not _contact or _contact == big_brother_contact: @@ -538,7 +538,7 @@ class RosterWindow: for data in nearby_family: _account = data['account'] _jid = data['jid'] - _contact = gajim.contacts.get_first_contact_from_jid(_account, _jid) + _contact = app.contacts.get_first_contact_from_jid(_account, _jid) iters = self._get_contact_iter(_jid, _account, _contact, self.model) if not iters or not _contact: @@ -593,7 +593,7 @@ class RosterWindow: brothers = [] nearby_family, big_brother_jid, big_brother_account = \ self._get_nearby_family_and_big_brother(family, account) - big_brother_contact = gajim.contacts.get_contact(big_brother_account, + big_brother_contact = app.contacts.get_contact(big_brother_account, big_brother_jid) child_iters = self._get_contact_iter(big_brother_jid, big_brother_account, model=self.model) @@ -605,7 +605,7 @@ class RosterWindow: if parent_type == 'contact': for data in nearby_family: # recalibrate after remove to keep highlight - if data['jid'] in gajim.to_be_removed[data['account']]: + if data['jid'] in app.to_be_removed[data['account']]: return self._remove_metacontact_family(family, account) @@ -627,14 +627,14 @@ class RosterWindow: parent_iter = self.model.iter_parent(child_iters[0]) parent_type = self.model[parent_iter][Column.TYPE] if parent_type != 'contact': - _contact = gajim.contacts.get_contact(_account, _jid) + _contact = app.contacts.get_contact(_account, _jid) self._remove_entity(_contact, _account) self._add_entity(_contact, _account, groups=None, big_brother_contact=big_brother_contact, big_brother_account=big_brother_account) def _get_nearby_family_and_big_brother(self, family, account): - return gajim.contacts.get_nearby_family_and_big_brother(family, account) + return app.contacts.get_nearby_family_and_big_brother(family, account) def _add_self_contact(self, account): """ @@ -642,15 +642,15 @@ class RosterWindow: Return the SelfContact contact instance """ - jid = gajim.get_jid_from_account(account) - contact = gajim.contacts.get_first_contact_from_jid(account, jid) + jid = app.get_jid_from_account(account) + contact = app.contacts.get_first_contact_from_jid(account, jid) assert len(self._get_contact_iter(jid, account, contact, self.model)) == 0, 'Self contact %s already in roster' % jid child_iterA = self._get_account_iter(account, self.model) self._iters[account]['contacts'][jid] = [self.model.append(child_iterA, - [None, gajim.nicks[account], 'self_contact', jid, account, None, + [None, app.nicks[account], 'self_contact', jid, account, None, None, None, None, None, None] + [None] * self.nb_ext_renderers)] self.draw_completely(jid, account) @@ -659,7 +659,7 @@ class RosterWindow: return contact def redraw_metacontacts(self, account): - for family in gajim.contacts.iter_metacontacts_families(account): + for family in app.contacts.iter_metacontacts_families(account): self._recalibrate_metacontact_family(family, account) def add_contact(self, jid, account): @@ -677,16 +677,16 @@ class RosterWindow: jid -- the contact's jid or SelfJid to add SelfContact account -- the corresponding account. """ - contact = gajim.contacts.get_contact_with_highest_priority(account, jid) + contact = app.contacts.get_contact_with_highest_priority(account, jid) if len(self._get_contact_iter(jid, account, contact, self.model)): # If contact already in roster, do nothing return - if jid == gajim.get_jid_from_account(account): - show_self_contact = gajim.config.get('show_self_contact') + if jid == app.get_jid_from_account(account): + show_self_contact = app.config.get('show_self_contact') if show_self_contact == 'never': return - if (contact.resource != gajim.connections[account].server_resource \ + if (contact.resource != app.connections[account].server_resource \ and show_self_contact == 'when_other_resource') or \ show_self_contact == 'always': return self._add_self_contact(account) @@ -695,10 +695,10 @@ class RosterWindow: is_observer = contact.is_observer() if is_observer: # if he has a tag, remove it - gajim.contacts.remove_metacontact(account, jid) + app.contacts.remove_metacontact(account, jid) # Add contact to roster - family = gajim.contacts.get_metacontacts_family(account, jid) + family = app.contacts.get_metacontacts_family(account, jid) contacts = [] if family: # We have a family. So we are a metacontact. @@ -739,7 +739,7 @@ class RosterWindow: force -- remove contact even it has pending evens (Default False) backend -- also remove contact instance (Default False) """ - contact = gajim.contacts.get_contact_with_highest_priority(account, jid) + contact = app.contacts.get_contact_with_highest_priority(account, jid) if not contact: return @@ -751,7 +751,7 @@ class RosterWindow: if iters: # no more pending events # Remove contact from roster directly - family = gajim.contacts.get_metacontacts_family(account, jid) + family = app.contacts.get_metacontacts_family(account, jid) if family: # We have a family. So we are a metacontact. self._remove_metacontact_family(family, account) @@ -760,12 +760,12 @@ class RosterWindow: old_grps = [] if backend: - if not gajim.interface.msg_win_mgr.get_control(jid, account) or \ + if not app.interface.msg_win_mgr.get_control(jid, account) or \ force: # If a window is still opened: don't remove contact instance # Remove contact before redrawing, otherwise the old # numbers will still be show - gajim.contacts.remove_jid(account, jid, remove_meta=True) + app.contacts.remove_jid(account, jid, remove_meta=True) if iters: rest_of_family = [data for data in family if account != data['account'] or jid != data['jid']] @@ -776,7 +776,7 @@ class RosterWindow: for c, acc in brothers: self.draw_completely(c.jid, acc) else: - for c in gajim.contacts.get_contacts(account, jid): + for c in app.contacts.get_contacts(account, jid): c.sub = 'none' c.show = 'not in roster' c.status = '' @@ -802,7 +802,7 @@ class RosterWindow: new_jid -- our new jid account -- the corresponding account. """ - gajim.contacts.change_contact_jid(old_jid, new_jid, account) + app.contacts.change_contact_jid(old_jid, new_jid, account) self_iter = self._get_self_contact_iter(account, model=self.model) if not self_iter: return @@ -813,37 +813,37 @@ class RosterWindow: """ Add groupchat to roster and draw it. Return the added contact instance """ - contact = gajim.contacts.get_contact_with_highest_priority(account, jid) + contact = app.contacts.get_contact_with_highest_priority(account, jid) # Do not show gc if we are disconnected and minimize it - if gajim.account_is_connected(account): + if app.account_is_connected(account): show = 'online' else: show = 'offline' status = '' if contact is None: - gc_control = gajim.interface.msg_win_mgr.get_gc_control(jid, + gc_control = app.interface.msg_win_mgr.get_gc_control(jid, account) if gc_control: # there is a window that we can minimize - gajim.interface.minimized_controls[account][jid] = gc_control + app.interface.minimized_controls[account][jid] = gc_control name = gc_control.name - elif jid in gajim.interface.minimized_controls[account]: - name = gajim.interface.minimized_controls[account][jid].name + elif jid in app.interface.minimized_controls[account]: + name = app.interface.minimized_controls[account][jid].name else: name = jid.split('@')[0] # New groupchat - contact = gajim.contacts.create_contact(jid=jid, account=account, + contact = app.contacts.create_contact(jid=jid, account=account, name=name, groups=[_('Groupchats')], show=show, status=status, sub='none') - gajim.contacts.add_contact(account, contact) + app.contacts.add_contact(account, contact) self.add_contact(jid, account) else: - if jid not in gajim.interface.minimized_controls[account]: + if jid not in app.interface.minimized_controls[account]: # there is a window that we can minimize - gc_control = gajim.interface.msg_win_mgr.get_gc_control(jid, + gc_control = app.interface.msg_win_mgr.get_gc_control(jid, account) - gajim.interface.minimized_controls[account][jid] = gc_control + app.interface.minimized_controls[account][jid] = gc_control contact.show = show contact.status = status self.adjust_and_draw_contact_context(jid, account) @@ -855,10 +855,10 @@ class RosterWindow: """ Remove groupchat from roster and redraw account and group """ - contact = gajim.contacts.get_contact_with_highest_priority(account, jid) + contact = app.contacts.get_contact_with_highest_priority(account, jid) if contact.is_groupchat(): - if jid in gajim.interface.minimized_controls[account]: - del gajim.interface.minimized_controls[account][jid] + if jid in app.interface.minimized_controls[account]: + del app.interface.minimized_controls[account][jid] self.remove_contact(jid, account, force=True, backend=True) return True else: @@ -870,12 +870,12 @@ class RosterWindow: """ Add transport to roster and draw it. Return the added contact instance """ - contact = gajim.contacts.get_contact_with_highest_priority(account, jid) + contact = app.contacts.get_contact_with_highest_priority(account, jid) if contact is None: - contact = gajim.contacts.create_contact(jid=jid, account=account, + contact = app.contacts.create_contact(jid=jid, account=account, name=jid, groups=[_('Transports')], show='offline', status='offline', sub='from') - gajim.contacts.add_contact(account, contact) + app.contacts.add_contact(account, contact) self.add_contact(jid, account) return contact @@ -900,14 +900,14 @@ class RosterWindow: # update all contacts in the given group if self.regroup: - accounts = gajim.connections.keys() + accounts = app.connections.keys() else: accounts = [account, ] for acc in accounts: changed_contacts = [] - for jid in gajim.contacts.get_jid_list(acc): - contact = gajim.contacts.get_first_contact_from_jid(acc, jid) + for jid in app.contacts.get_jid_list(acc): + contact = app.contacts.get_first_contact_from_jid(acc, jid) if old_name not in contact.groups: continue @@ -920,7 +920,7 @@ class RosterWindow: changed_contacts.append({'jid': jid, 'name': contact.name, 'groups':contact.groups}) - gajim.connections[acc].update_contacts(changed_contacts) + app.connections[acc].update_contacts(changed_contacts) for c in changed_contacts: self.add_contact(c['jid'], acc) @@ -945,13 +945,13 @@ class RosterWindow: update -- update contact on the server """ self.remove_contact(jid, account, force=True) - for contact in gajim.contacts.get_contacts(account, jid): + for contact in app.contacts.get_contacts(account, jid): for group in groups: if group not in contact.groups: # we might be dropped from meta to group contact.groups.append(group) if update: - gajim.connections[account].update_contact(jid, contact.name, + app.connections[account].update_contact(jid, contact.name, contact.groups) self.add_contact(jid, account) @@ -973,13 +973,13 @@ class RosterWindow: update -- update contact on the server """ self.remove_contact(jid, account, force=True) - for contact in gajim.contacts.get_contacts(account, jid): + for contact in app.contacts.get_contacts(account, jid): for group in groups: if group in contact.groups: # Needed when we remove from "General" or "Observers" contact.groups.remove(group) if update: - gajim.connections[account].update_contact(jid, contact.name, + app.connections[account].update_contact(jid, contact.name, contact.groups) self.add_contact(jid, account) @@ -987,25 +987,25 @@ class RosterWindow: for group in groups: self.draw_group(group, account) - # FIXME: maybe move to gajim.py + # FIXME: maybe move to app.py def remove_newly_added(self, jid, account): - if account not in gajim.newly_added: + if account not in app.newly_added: # Account has been deleted during the timeout that called us return - if jid in gajim.newly_added[account]: - gajim.newly_added[account].remove(jid) + if jid in app.newly_added[account]: + app.newly_added[account].remove(jid) self.draw_contact(jid, account) - # FIXME: maybe move to gajim.py + # FIXME: maybe move to app.py def remove_to_be_removed(self, jid, account): - if account not in gajim.interface.instances: + if account not in app.interface.instances: # Account has been deleted during the timeout that called us return - if jid in gajim.newly_added[account]: + if jid in app.newly_added[account]: return - if jid in gajim.to_be_removed[account]: - gajim.to_be_removed[account].remove(jid) - family = gajim.contacts.get_metacontacts_family(account, jid) + if jid in app.to_be_removed[account]: + app.to_be_removed[account].remove(jid) + family = app.contacts.get_metacontacts_family(account, jid) if family: # Peform delayed recalibration self._recalibrate_metacontact_family(family, account) @@ -1014,13 +1014,13 @@ class RosterWindow: # FIXME: integrate into add_contact() def add_to_not_in_the_roster(self, account, jid, nick='', resource=''): keyID = '' - attached_keys = gajim.config.get_per('accounts', account, + attached_keys = app.config.get_per('accounts', account, 'attached_gpg_keys').split() if jid in attached_keys: keyID = attached_keys[attached_keys.index(jid) + 1] - contact = gajim.contacts.create_not_in_roster_contact(jid=jid, + contact = app.contacts.create_not_in_roster_contact(jid=jid, account=account, resource=resource, name=nick, keyID=keyID) - gajim.contacts.add_contact(account, contact) + app.contacts.add_contact(account, contact) self.add_contact(contact.jid, account) return contact @@ -1035,10 +1035,10 @@ class RosterWindow: assert False, 'Account iter of %s could not be found.' % account return - num_of_accounts = gajim.get_number_of_connected_accounts() - num_of_secured = gajim.get_number_of_securely_connected_accounts() + num_of_accounts = app.get_number_of_connected_accounts() + num_of_secured = app.get_number_of_securely_connected_accounts() - if gajim.account_is_securely_connected(account) and not self.regroup or\ + if app.account_is_securely_connected(account) and not self.regroup or\ self.regroup and num_of_secured and num_of_secured == num_of_accounts: tls_pixbuf = gtkgui_helpers.get_icon_pixmap('changes-prevent', 16) # the only way to create a pixbuf from stock @@ -1059,36 +1059,36 @@ class RosterWindow: self.model.iter_has_child(child_iter): account_name = '[%s]' % account_name - if (gajim.account_is_connected(account) or (self.regroup and \ - gajim.get_number_of_connected_accounts())) and gajim.config.get( + if (app.account_is_connected(account) or (self.regroup and \ + app.get_number_of_connected_accounts())) and app.config.get( 'show_contacts_number'): - nbr_on, nbr_total = gajim.contacts.get_nb_online_total_contacts( + nbr_on, nbr_total = app.contacts.get_nb_online_total_contacts( accounts = accounts) account_name += ' (%s/%s)' % (repr(nbr_on), repr(nbr_total)) self.model[child_iter][Column.NAME] = account_name - pep_dict = gajim.connections[account].pep - if gajim.config.get('show_mood_in_roster') and 'mood' in pep_dict: + pep_dict = app.connections[account].pep + if app.config.get('show_mood_in_roster') and 'mood' in pep_dict: self.model[child_iter][Column.MOOD_PIXBUF] = \ gtkgui_helpers.get_pep_as_pixbuf(pep_dict['mood']) else: self.model[child_iter][Column.MOOD_PIXBUF] = empty_pixbuf - if gajim.config.get('show_activity_in_roster') and 'activity' in \ + if app.config.get('show_activity_in_roster') and 'activity' in \ pep_dict: self.model[child_iter][Column.ACTIVITY_PIXBUF] = \ gtkgui_helpers.get_pep_as_pixbuf(pep_dict['activity']) else: self.model[child_iter][Column.ACTIVITY_PIXBUF] = empty_pixbuf - if gajim.config.get('show_tunes_in_roster') and 'tune' in pep_dict: + if app.config.get('show_tunes_in_roster') and 'tune' in pep_dict: self.model[child_iter][Column.TUNE_PIXBUF] = \ gtkgui_helpers.get_pep_as_pixbuf(pep_dict['tune']) else: self.model[child_iter][Column.TUNE_PIXBUF] = empty_pixbuf - if gajim.config.get('show_location_in_roster') and 'location' in \ + if app.config.get('show_location_in_roster') and 'location' in \ pep_dict: self.model[child_iter][Column.LOCATION_PIXBUF] = \ gtkgui_helpers.get_pep_as_pixbuf(pep_dict['location']) @@ -1121,8 +1121,8 @@ class RosterWindow: text = GLib.markup_escape_text(group) if helpers.group_is_blocked(account, group): text = '%s' % text - if gajim.config.get('show_contacts_number'): - nbr_on, nbr_total = gajim.contacts.get_nb_online_total_contacts( + if app.config.get('show_contacts_number'): + nbr_on, nbr_total = app.contacts.get_nb_online_total_contacts( accounts = accounts, groups = [group]) text += ' (%s/%s)' % (repr(nbr_on), repr(nbr_total)) @@ -1166,9 +1166,9 @@ class RosterWindow: # FIXME: We really need a custom cell_renderer if not contact_instances: - contact_instances = gajim.contacts.get_contacts(account, jid) + contact_instances = app.contacts.get_contacts(account, jid) if not contact: - contact = gajim.contacts.get_highest_prio_contact_from_contacts( + contact = app.contacts.get_highest_prio_contact_from_contacts( contact_instances) if not contact: return False @@ -1180,11 +1180,11 @@ class RosterWindow: name = GLib.markup_escape_text(contact.get_shown_name()) # gets number of unread gc marked messages - if jid in gajim.interface.minimized_controls[account] and \ - gajim.interface.minimized_controls[account][jid]: - nb_unread = len(gajim.events.get_events(account, jid, + if jid in app.interface.minimized_controls[account] and \ + app.interface.minimized_controls[account][jid]: + nb_unread = len(app.events.get_events(account, jid, ['printed_marked_gc_msg'])) - nb_unread += gajim.interface.minimized_controls \ + nb_unread += app.interface.minimized_controls \ [account][jid].get_nb_unread_pm() if nb_unread == 1: @@ -1216,7 +1216,7 @@ class RosterWindow: # add status msg, if not empty, under contact name in # the treeview - if contact.status and gajim.config.get('show_status_msgs_in_roster'): + if contact.status and app.config.get('show_status_msgs_in_roster'): status = contact.status.strip() if status != '': status = helpers.reduce_chars_newlines(status, @@ -1241,7 +1241,7 @@ class RosterWindow: break # Check for events of collapsed (hidden) brothers - family = gajim.contacts.get_metacontacts_family(account, jid) + family = app.contacts.get_metacontacts_family(account, jid) is_big_brother = False have_visible_children = False if family: @@ -1267,7 +1267,7 @@ class RosterWindow: # a child has awaiting messages? jidC = self.model[iterC][Column.JID] accountC = self.model[iterC][Column.ACCOUNT] - if len(gajim.events.get_events(accountC, jidC)): + if len(app.events.get_events(accountC, jidC)): icon_name = 'event' break iterC = self.model.iter_next(iterC) @@ -1301,7 +1301,7 @@ class RosterWindow: if family and not is_big_brother and not self.starting: self.draw_parent_contact(jid, account) - delimiter = gajim.connections[account].nested_group_delimiter + delimiter = app.connections[account].nested_group_delimiter for group in contact.get_shown_groups(): # We need to make sure that _visible_func is called for # our groups otherwise we might not be shown @@ -1315,20 +1315,20 @@ class RosterWindow: self.model[iterG][Column.JID] = self.model[iterG][Column.JID] i += 1 - gajim.plugin_manager.gui_extension_point('roster_draw_contact', self, + app.plugin_manager.gui_extension_point('roster_draw_contact', self, jid, account, contact) return False def _is_pep_shown_in_roster(self, pep_type): if pep_type == 'mood': - return gajim.config.get('show_mood_in_roster') + return app.config.get('show_mood_in_roster') elif pep_type == 'activity': - return gajim.config.get('show_activity_in_roster') + return app.config.get('show_activity_in_roster') elif pep_type == 'tune': - return gajim.config.get('show_tunes_in_roster') + return app.config.get('show_tunes_in_roster') elif pep_type == 'location': - return gajim.config.get('show_location_in_roster') + return app.config.get('show_location_in_roster') else: return False @@ -1347,7 +1347,7 @@ class RosterWindow: if not iters: return if not contact: - contact = gajim.contacts.get_contact(account, jid) + contact = app.contacts.get_contact(account, jid) if pep_type in contact.pep: pixbuf = gtkgui_helpers.get_pep_as_pixbuf(contact.pep[pep_type]) else: @@ -1357,7 +1357,7 @@ class RosterWindow: def draw_avatar(self, jid, account): iters = self._get_contact_iter(jid, account, model=self.model) - if not iters or not gajim.config.get('show_avatars_in_roster'): + if not iters or not app.config.get('show_avatars_in_roster'): return jid = self.model[iters[0]][Column.JID] pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(jid) @@ -1370,8 +1370,8 @@ class RosterWindow: return False def draw_completely(self, jid, account): - contact_instances = gajim.contacts.get_contacts(account, jid) - contact = gajim.contacts.get_highest_prio_contact_from_contacts( + contact_instances = app.contacts.get_contacts(account, jid) + contact = app.contacts.get_highest_prio_contact_from_contacts( contact_instances) self.draw_contact(jid, account, contact_instances=contact_instances, contact=contact) @@ -1383,12 +1383,12 @@ class RosterWindow: Draw contact, account and groups of given jid Show contact if it has pending events """ - contact = gajim.contacts.get_first_contact_from_jid(account, jid) + contact = app.contacts.get_first_contact_from_jid(account, jid) if not contact: # idle draw or just removed SelfContact return - family = gajim.contacts.get_metacontacts_family(account, jid) + family = app.contacts.get_metacontacts_family(account, jid) if family: # There might be a new big brother self._recalibrate_metacontact_family(family, account) @@ -1409,7 +1409,7 @@ class RosterWindow: """ def _draw_all_contacts(jids, account): for jid in jids: - family = gajim.contacts.get_metacontacts_family(account, jid) + family = app.contacts.get_metacontacts_family(account, jid) if family: # For metacontacts over several accounts: # When we connect a new account existing brothers @@ -1435,17 +1435,17 @@ class RosterWindow: def _after_fill(self): self.starting = False - accounts_list = gajim.contacts.get_accounts() - for account in gajim.connections: + accounts_list = app.contacts.get_accounts() + for account in app.connections: if account not in accounts_list: continue - jids = gajim.contacts.get_jid_list(account) + jids = app.contacts.get_jid_list(account) for jid in jids: self.draw_completely(jid, account) # Draw all known groups - for group in gajim.groups[account]: + for group in app.groups[account]: self.draw_group(group, account) self.draw_account(account) @@ -1473,10 +1473,10 @@ class RosterWindow: self._iters = {} # for merged mode self._iters['MERGED'] = {'account': None, 'groups': {}} - for acct in gajim.contacts.get_accounts(): + for acct in app.contacts.get_accounts(): self._iters[acct] = {'account': None, 'groups': {}, 'contacts': {}} - for acct in gajim.contacts.get_accounts(): + for acct in app.contacts.get_accounts(): self.add_account(acct) self.add_account_contacts(acct, improve_speed=True, draw_contacts=False) @@ -1497,7 +1497,7 @@ class RosterWindow: # Not visible in roster return path = self.modelfilter.get_path(iters[0]) - if self.dragging or not gajim.config.get( + if self.dragging or not app.config.get( 'scroll_roster_to_last_message'): # do not change selection while DND'ing return @@ -1554,9 +1554,9 @@ class RosterWindow: """ if not self.tree.get_model(): return - if account not in gajim.connections: + if account not in app.connections: return - delimiter = gajim.connections[account].nested_group_delimiter + delimiter = app.connections[account].nested_group_delimiter group_splited = group.split(delimiter) i = 1 while i < len(group_splited) + 1: @@ -1588,11 +1588,11 @@ class RosterWindow: Return True if the contact or one if it resources has pending events """ # jid has pending events - if gajim.events.get_nb_roster_events(account, contact.jid) > 0: + if app.events.get_nb_roster_events(account, contact.jid) > 0: return True # check events of all resources - for contact_ in gajim.contacts.get_contacts(account, contact.jid): - if contact_.resource and gajim.events.get_nb_roster_events(account, + for contact_ in app.contacts.get_contacts(account, contact.jid): + if contact_.resource and app.events.get_nb_roster_events(account, contact_.get_full_jid()) > 0: return True return False @@ -1604,10 +1604,10 @@ class RosterWindow: return True if contact.show in ('offline', 'error'): - if contact.jid in gajim.to_be_removed[account]: + if contact.jid in app.to_be_removed[account]: return True return False - if gajim.config.get('show_only_chat_and_online') and contact.show in ( + if app.config.get('show_only_chat_and_online') and contact.show in ( 'away', 'xa', 'busy'): return False return True @@ -1637,11 +1637,11 @@ class RosterWindow: group = jid if group == _('Transports'): if self.regroup: - accounts = gajim.contacts.get_accounts() + accounts = app.contacts.get_accounts() else: accounts = [account] for _acc in accounts: - for contact in gajim.contacts.iter_contacts(_acc): + for contact in app.contacts.iter_contacts(_acc): if group in contact.get_shown_groups(): if self.rfilter_enabled: if self.rfilter_string in \ @@ -1653,22 +1653,22 @@ class RosterWindow: if self.rfilter_enabled: # No transport has been found return False - return gajim.config.get('show_transports_group') and \ - (gajim.account_is_connected(account) or \ - gajim.config.get('showoffline')) - if gajim.config.get('showoffline'): + return app.config.get('show_transports_group') and \ + (app.account_is_connected(account) or \ + app.config.get('showoffline')) + if app.config.get('showoffline'): return True if self.regroup: # Column.ACCOUNT for groups depends on the order # accounts were connected # Check all accounts for online group contacts - accounts = gajim.contacts.get_accounts() + accounts = app.contacts.get_accounts() else: accounts = [account] for _acc in accounts: - delimiter = gajim.connections[_acc].nested_group_delimiter - for contact in gajim.contacts.iter_contacts(_acc): + delimiter = app.connections[_acc].nested_group_delimiter + for contact in app.contacts.iter_contacts(_acc): if not self.contact_is_visible(contact, _acc): continue # Is this contact in this group? @@ -1687,11 +1687,11 @@ class RosterWindow: return True iter_c = model.iter_next(iter_c) return self.rfilter_string in model[titer][Column.NAME].lower() - if gajim.config.get('showoffline'): + if app.config.get('showoffline'): return True bb_jid = None bb_account = None - family = gajim.contacts.get_metacontacts_family(account, jid) + family = app.contacts.get_metacontacts_family(account, jid) if family: nearby_family, bb_jid, bb_account = \ self._get_nearby_family_and_big_brother(family, account) @@ -1700,24 +1700,24 @@ class RosterWindow: for data in nearby_family: jid = data['jid'] account = data['account'] - contact = gajim.contacts.get_contact_with_highest_priority( + contact = app.contacts.get_contact_with_highest_priority( account, jid) if contact and self.contact_is_visible(contact, account): return True return False else: - contact = gajim.contacts.get_contact_with_highest_priority( + contact = app.contacts.get_contact_with_highest_priority( account, jid) return self.contact_is_visible(contact, account) if type_ == 'agent': if self.rfilter_enabled: return self.rfilter_string in model[titer][Column.NAME].lower() - contact = gajim.contacts.get_contact_with_highest_priority(account, + contact = app.contacts.get_contact_with_highest_priority(account, jid) return self.contact_has_pending_roster_events(contact, account) or \ - (gajim.config.get('show_transports_group') and \ - (gajim.account_is_connected(account) or \ - gajim.config.get('showoffline'))) + (app.config.get('show_transports_group') and \ + (app.account_is_connected(account) or \ + app.config.get('showoffline'))) if type_ == 'groupchat' and self.rfilter_enabled: return self.rfilter_string in model[titer][Column.NAME].lower() return True @@ -1768,21 +1768,21 @@ class RosterWindow: jid1 = model[iter1][Column.JID] jid2 = model[iter2][Column.JID] if type1 == 'contact': - lcontact1 = gajim.contacts.get_contacts(account1, jid1) - contact1 = gajim.contacts.get_first_contact_from_jid(account1, jid1) + lcontact1 = app.contacts.get_contacts(account1, jid1) + contact1 = app.contacts.get_first_contact_from_jid(account1, jid1) if not contact1: return 0 name1 = contact1.get_shown_name() if type2 == 'contact': - lcontact2 = gajim.contacts.get_contacts(account2, jid2) - contact2 = gajim.contacts.get_first_contact_from_jid(account2, jid2) + lcontact2 = app.contacts.get_contacts(account2, jid2) + contact2 = app.contacts.get_first_contact_from_jid(account2, jid2) if not contact2: return 0 name2 = contact2.get_shown_name() # We first compare by show if sort_by_show_in_roster is True or if it's # a child contact if type1 == 'contact' and type2 == 'contact' and \ - gajim.config.get('sort_by_show_in_roster'): + app.config.get('sort_by_show_in_roster'): cshow = {'chat':0, 'online': 1, 'away': 2, 'xa': 3, 'dnd': 4, 'invisible': 5, 'offline': 6, 'not in roster': 7, 'error': 8} s = self.get_show(lcontact1) @@ -1791,9 +1791,9 @@ class RosterWindow: show2 = cshow.get(s, 9) removing1 = False removing2 = False - if show1 == 6 and jid1 in gajim.to_be_removed[account1]: + if show1 == 6 and jid1 in app.to_be_removed[account1]: removing1 = True - if show2 == 6 and jid2 in gajim.to_be_removed[account2]: + if show2 == 6 and jid2 in app.to_be_removed[account2]: removing2 = True if removing1 and not removing2: return 1 @@ -1841,47 +1841,47 @@ class RosterWindow: Read from db the unread messages, and fire them up, and if we find very old unread messages, delete them from unread table """ - results = gajim.logger.get_unread_msgs() + results = app.logger.get_unread_msgs() for result, shown in results: jid = result.jid additional_data = result.additional_data - if gajim.contacts.get_first_contact_from_jid(account, jid) and not \ + if app.contacts.get_first_contact_from_jid(account, jid) and not \ shown: # We have this jid in our contacts list # XXX unread messages should probably have their session saved # with them - session = gajim.connections[account].make_new_session(jid) + session = app.connections[account].make_new_session(jid) tim = float(result.time) session.roster_message(jid, result.message, tim, msg_type='chat', msg_log_id=result.log_line_id, additional_data=additional_data) - gajim.logger.set_shown_unread_msgs(result.log_line_id) + app.logger.set_shown_unread_msgs(result.log_line_id) elif (time.time() - result.time) > 2592000: # ok, here we see that we have a message in unread messages # table that is older than a month. It is probably from someone # not in our roster for accounts we usually launch, so we will # delete this id from unread message tables. - gajim.logger.set_read_messages([result.log_line_id]) + app.logger.set_read_messages([result.log_line_id]) def fill_contacts_and_groups_dicts(self, array, account): """ - Fill gajim.contacts and gajim.groups + Fill app.contacts and app.groups """ # FIXME: This function needs to be splitted # Most of the logic SHOULD NOT be done at GUI level - if account not in gajim.contacts.get_accounts(): - gajim.contacts.add_account(account) + if account not in app.contacts.get_accounts(): + app.contacts.add_account(account) if not account in self._iters: self._iters[account] = {'account': None, 'groups': {}, 'contacts': {}} - if account not in gajim.groups: - gajim.groups[account] = {} - if gajim.config.get('show_self_contact') == 'always': - self_jid = gajim.get_jid_from_account(account) - if gajim.connections[account].server_resource: - self_jid += '/' + gajim.connections[account].server_resource - array[self_jid] = {'name': gajim.nicks[account], + if account not in app.groups: + app.groups[account] = {} + if app.config.get('show_self_contact') == 'always': + self_jid = app.get_jid_from_account(account) + if app.connections[account].server_resource: + self_jid += '/' + app.connections[account].server_resource + array[self_jid] = {'name': app.nicks[account], 'groups': ['self_contact'], 'subscription': 'both', 'ask': 'none'} # .keys() is needed @@ -1889,7 +1889,7 @@ class RosterWindow: # Remove the contact in roster. It might has changed self.remove_contact(jid, account, force=True) # Remove old Contact instances - gajim.contacts.remove_jid(account, jid, remove_meta=False) + app.contacts.remove_jid(account, jid, remove_meta=False) jids = jid.split('/') # get jid ji = jids[0] @@ -1903,47 +1903,47 @@ class RosterWindow: status = '' # no status message by default keyID = '' - attached_keys = gajim.config.get_per('accounts', account, + attached_keys = app.config.get_per('accounts', account, 'attached_gpg_keys').split() if jid in attached_keys: keyID = attached_keys[attached_keys.index(jid) + 1] - if gajim.jid_is_transport(jid): + if app.jid_is_transport(jid): array[jid]['groups'] = [_('Transports')] #TRANSP - potential - contact1 = gajim.contacts.create_contact(jid=ji, account=account, + contact1 = app.contacts.create_contact(jid=ji, account=account, name=name, groups=array[jid]['groups'], show=show, status=status, sub=array[jid]['subscription'], ask=array[jid]['ask'], resource=resource, keyID=keyID) - gajim.contacts.add_contact(account, contact1) + app.contacts.add_contact(account, contact1) - if gajim.config.get('ask_avatars_on_startup'): + if app.config.get('ask_avatars_on_startup'): pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(ji) if pixbuf == 'ask': - transport = gajim.get_transport_name_from_jid(contact1.jid) - if not transport or gajim.jid_is_transport(contact1.jid): + transport = app.get_transport_name_from_jid(contact1.jid) + if not transport or app.jid_is_transport(contact1.jid): jid_with_resource = contact1.jid if contact1.resource: jid_with_resource += '/' + contact1.resource - gajim.connections[account].request_vcard( + app.connections[account].request_vcard( jid_with_resource) else: - host = gajim.get_server_from_jid(contact1.jid) - if host not in gajim.transport_avatar[account]: - gajim.transport_avatar[account][host] = \ + host = app.get_server_from_jid(contact1.jid) + if host not in app.transport_avatar[account]: + app.transport_avatar[account][host] = \ [contact1.jid] else: - gajim.transport_avatar[account][host].append( + app.transport_avatar[account][host].append( contact1.jid) # If we already have chat windows opened, update them with new # contact instance - chat_control = gajim.interface.msg_win_mgr.get_control(ji, account) + chat_control = app.interface.msg_win_mgr.get_control(ji, account) if chat_control: chat_control.contact = contact1 def connected_rooms(self, account): - if account in list(gajim.gc_connected[account].values()): + if account in list(app.gc_connected[account].values()): return True return False @@ -1964,7 +1964,7 @@ class RosterWindow: msg_log_ids.append(ev.msg_log_id) if msg_log_ids: - gajim.logger.set_read_messages(msg_log_ids) + app.logger.set_read_messages(msg_log_ids) contact_list = ((event.jid.split('/')[0], event.account) for event in \ event_list) @@ -1985,24 +1985,24 @@ class RosterWindow: """ If an event was handled, return True, else return False """ - ft = gajim.interface.instances['file_transfers'] - event = gajim.events.get_first_event(account, jid, event.type_) + ft = app.interface.instances['file_transfers'] + event = app.events.get_first_event(account, jid, event.type_) if event.type_ == 'normal': dialogs.SingleMessageWindow(account, jid, action='receive', from_whom=jid, subject=event.subject, message=event.message, resource=event.resource, session=event.session, form_node=event.form_node) - gajim.events.remove_events(account, jid, event) + app.events.remove_events(account, jid, event) return True elif event.type_ == 'file-request': - contact = gajim.contacts.get_contact_with_highest_priority(account, + contact = app.contacts.get_contact_with_highest_priority(account, jid) ft.show_file_request(account, contact, event.file_props) - gajim.events.remove_events(account, jid, event) + app.events.remove_events(account, jid, event) return True elif event.type_ in ('file-request-error', 'file-send-error'): ft.show_send_error(event.file_props) - gajim.events.remove_events(account, jid, event) + app.events.remove_events(account, jid, event) return True elif event.type_ in ('file-error', 'file-stopped'): msg_err = '' @@ -2011,35 +2011,35 @@ class RosterWindow: elif event.file_props.error == -6: msg_err = _('Error opening file') ft.show_stopped(jid, event.file_props, error_msg=msg_err) - gajim.events.remove_events(account, jid, event) + app.events.remove_events(account, jid, event) return True elif event.type_ == 'file-hash-error': ft.show_hash_error(jid, event.file_props, account) - gajim.events.remove_events(account, jid, event) + app.events.remove_events(account, jid, event) return True elif event.type_ == 'file-completed': ft.show_completed(jid, event.file_props) - gajim.events.remove_events(account, jid, event) + app.events.remove_events(account, jid, event) return True elif event.type_ == 'gc-invitation': dialogs.InvitationReceivedDialog(account, event.room_jid, event.jid_from, event.password, event.reason, is_continued=event.is_continued) - gajim.events.remove_events(account, jid, event) + app.events.remove_events(account, jid, event) return True elif event.type_ == 'subscription_request': dialogs.SubscriptionRequestWindow(jid, event.text, account, event.nick) - gajim.events.remove_events(account, jid, event) + app.events.remove_events(account, jid, event) return True elif event.type_ == 'unsubscribed': - gajim.interface.show_unsubscribed_dialog(account, event.contact) - gajim.events.remove_events(account, jid, event) + app.interface.show_unsubscribed_dialog(account, event.contact) + app.events.remove_events(account, jid, event) return True elif event.type_ == 'jingle-incoming': dialogs.VoIPCallReceivedDialog(account, event.peerjid, event.sid, event.content_types) - gajim.events.remove_events(account, jid, event) + app.events.remove_events(account, jid, event) return True return False @@ -2060,7 +2060,7 @@ class RosterWindow: """ Authorize a contact (by re-sending auth menuitem) """ - gajim.connections[account].send_authorization(jid) + app.connections[account].send_authorization(jid) dialogs.InformationDialog(_('Authorization sent'), _('"%s" will now see your status.') %jid) @@ -2070,19 +2070,19 @@ class RosterWindow: Request subscription to a contact """ groups_list = groups or [] - gajim.connections[account].request_subscription(jid, txt, nickname, - groups_list, auto_auth, gajim.nicks[account]) - contact = gajim.contacts.get_contact_with_highest_priority(account, jid) + app.connections[account].request_subscription(jid, txt, nickname, + groups_list, auto_auth, app.nicks[account]) + contact = app.contacts.get_contact_with_highest_priority(account, jid) if not contact: keyID = '' - attached_keys = gajim.config.get_per('accounts', account, + attached_keys = app.config.get_per('accounts', account, 'attached_gpg_keys').split() if jid in attached_keys: keyID = attached_keys[attached_keys.index(jid) + 1] - contact = gajim.contacts.create_contact(jid=jid, account=account, + contact = app.contacts.create_contact(jid=jid, account=account, name=nickname, groups=groups_list, show='requested', status='', ask='none', sub='subscribe', keyID=keyID) - gajim.contacts.add_contact(account, contact) + app.contacts.add_contact(account, contact) else: if not _('Not in Roster') in contact.get_shown_groups(): dialogs.InformationDialog(_('Subscription request has been ' @@ -2099,7 +2099,7 @@ class RosterWindow: """ Revoke a contact's authorization """ - gajim.connections[account].refuse_authorization(jid) + app.connections[account].refuse_authorization(jid) dialogs.InformationDialog(_('Authorization removed'), _('Now "%s" will always see you as offline.') %jid) @@ -2107,9 +2107,9 @@ class RosterWindow: child_iterA = self._get_account_iter(account, self.model) if child_iterA: self.model[child_iterA][0] = \ - gajim.interface.jabber_state_images['16'][state] - if gajim.interface.systray_enabled: - gajim.interface.systray.change_status(state) + app.interface.jabber_state_images['16'][state] + if app.interface.systray_enabled: + app.interface.systray.change_status(state) def set_connecting_state(self, account): self.set_state(account, 'connecting') @@ -2117,14 +2117,14 @@ class RosterWindow: def send_status(self, account, status, txt, auto=False, to=None): if status != 'offline': if to is None: - gajim.config.set_per('accounts', account, 'last_status', status) - gajim.config.set_per('accounts', account, 'last_status_msg', + app.config.set_per('accounts', account, 'last_status', status) + app.config.set_per('accounts', account, 'last_status_msg', helpers.to_one_line(txt)) - if gajim.connections[account].connected < 2: + if app.connections[account].connected < 2: self.set_connecting_state(account) - keyid = gajim.config.get_per('accounts', account, 'keyid') - if keyid and not gajim.connections[account].gpg: + keyid = app.config.get_per('accounts', account, 'keyid') + if keyid and not app.connections[account].gpg: dialogs.WarningDialog(_('OpenPGP is not usable'), _('Gajim needs python-gnupg >= 0.3.8\n' 'Beware there is an incompatible python package called gnupg.\n' @@ -2133,7 +2133,7 @@ class RosterWindow: self.send_status_continue(account, status, txt, auto, to) def send_pep(self, account, pep_dict): - connection = gajim.connections[account] + connection = app.connections[account] if 'activity' in pep_dict: activity = pep_dict['activity'] @@ -2151,58 +2151,58 @@ class RosterWindow: connection.retract_mood() def delete_pep(self, jid, account): - if jid == gajim.get_jid_from_account(account): - gajim.connections[account].pep = {} + if jid == app.get_jid_from_account(account): + app.connections[account].pep = {} self.draw_account(account) - for contact in gajim.contacts.get_contacts(account, jid): + for contact in app.contacts.get_contacts(account, jid): contact.pep = {} self.draw_all_pep_types(jid, account) - ctrl = gajim.interface.msg_win_mgr.get_control(jid, account) + ctrl = app.interface.msg_win_mgr.get_control(jid, account) if ctrl: ctrl.update_all_pep_types() def send_status_continue(self, account, status, txt, auto, to): - if gajim.account_is_connected(account) and not to: - if status == 'online' and gajim.interface.sleeper.getState() != \ + if app.account_is_connected(account) and not to: + if status == 'online' and app.interface.sleeper.getState() != \ sleepy.STATE_UNKNOWN: - gajim.sleeper_state[account] = 'online' - elif gajim.sleeper_state[account] not in ('autoaway', 'autoxa') or \ + app.sleeper_state[account] = 'online' + elif app.sleeper_state[account] not in ('autoaway', 'autoxa') or \ status == 'offline': - gajim.sleeper_state[account] = 'off' + app.sleeper_state[account] = 'off' if to: - gajim.connections[account].send_custom_status(status, txt, to) + app.connections[account].send_custom_status(status, txt, to) else: if status in ('invisible', 'offline'): - self.delete_pep(gajim.get_jid_from_account(account), account) - was_invisible = gajim.connections[account].connected == \ - gajim.SHOW_LIST.index('invisible') - gajim.connections[account].change_status(status, txt, auto) + self.delete_pep(app.get_jid_from_account(account), account) + was_invisible = app.connections[account].connected == \ + app.SHOW_LIST.index('invisible') + app.connections[account].change_status(status, txt, auto) - if account in gajim.interface.status_sent_to_users: - gajim.interface.status_sent_to_users[account] = {} - if account in gajim.interface.status_sent_to_groups: - gajim.interface.status_sent_to_groups[account] = {} - for gc_control in gajim.interface.msg_win_mgr.get_controls( + if account in app.interface.status_sent_to_users: + app.interface.status_sent_to_users[account] = {} + if account in app.interface.status_sent_to_groups: + app.interface.status_sent_to_groups[account] = {} + for gc_control in app.interface.msg_win_mgr.get_controls( message_control.TYPE_GC) + \ - list(gajim.interface.minimized_controls[account].values()): + list(app.interface.minimized_controls[account].values()): if gc_control.account == account: - if gajim.gc_connected[account][gc_control.room_jid]: - gajim.connections[account].send_gc_status( + if app.gc_connected[account][gc_control.room_jid]: + app.connections[account].send_gc_status( gc_control.nick, gc_control.room_jid, status, txt, auto=auto) if was_invisible and status != 'offline': # We come back from invisible, join bookmarks - gajim.interface.auto_join_bookmarks(account) + app.interface.auto_join_bookmarks(account) def chg_contact_status(self, contact, show, status, account): """ When a contact changes his or her status """ - contact_instances = gajim.contacts.get_contacts(account, contact.jid) + contact_instances = app.contacts.get_contacts(account, contact.jid) contact.show = show contact.status = status # name is to show in conversation window @@ -2217,18 +2217,18 @@ class RosterWindow: # Remove resource when going offline if show in ('offline', 'error') and \ not self.contact_has_pending_roster_events(contact, account): - ctrl = gajim.interface.msg_win_mgr.get_control(fjid, account) + ctrl = app.interface.msg_win_mgr.get_control(fjid, account) if ctrl: ctrl.update_ui() ctrl.parent_win.redraw_tab(ctrl) # keep the contact around, since it's # already attached to the control else: - gajim.contacts.remove_contact(account, contact) + app.contacts.remove_contact(account, contact) - elif contact.jid == gajim.get_jid_from_account(account) and \ + elif contact.jid == app.get_jid_from_account(account) and \ show in ('offline', 'error'): - if gajim.config.get('show_self_contact') != 'never': + if app.config.get('show_self_contact') != 'never': # SelfContact went offline. Remove him when last pending # message was read self.remove_contact(contact.jid, account, backend=True) @@ -2236,21 +2236,21 @@ class RosterWindow: uf_show = helpers.get_uf_show(show) # print status in chat window and update status/GPG image - ctrl = gajim.interface.msg_win_mgr.get_control(contact.jid, account) + ctrl = app.interface.msg_win_mgr.get_control(contact.jid, account) if ctrl and ctrl.type_id != message_control.TYPE_GC: - ctrl.contact = gajim.contacts.get_contact_with_highest_priority( + ctrl.contact = app.contacts.get_contact_with_highest_priority( account, contact.jid) ctrl.update_status_display(name, uf_show, status) if contact.resource: - ctrl = gajim.interface.msg_win_mgr.get_control(fjid, account) + ctrl = app.interface.msg_win_mgr.get_control(fjid, account) if ctrl: ctrl.update_status_display(name, uf_show, status) # Delete pep if needed keep_pep = any(c.show not in ('error', 'offline') for c in contact_instances) - if not keep_pep and contact.jid != gajim.get_jid_from_account(account) \ + if not keep_pep and contact.jid != app.get_jid_from_account(account) \ and not contact.is_groupchat(): self.delete_pep(contact.jid, account) @@ -2262,15 +2262,15 @@ class RosterWindow: """ The core tells us that our status has changed """ - if account not in gajim.contacts.get_accounts(): + if account not in app.contacts.get_accounts(): return child_iterA = self._get_account_iter(account, self.model) - if gajim.config.get('show_self_contact') == 'always': - self_resource = gajim.connections[account].server_resource - self_contact = gajim.contacts.get_contact(account, - gajim.get_jid_from_account(account), resource=self_resource) + if app.config.get('show_self_contact') == 'always': + self_resource = app.connections[account].server_resource + self_contact = app.contacts.get_contact(account, + app.get_jid_from_account(account), resource=self_resource) if self_contact: - status = gajim.connections[account].status + status = app.connections[account].status self.chg_contact_status(self_contact, show, status, account) self.set_account_status_icon(account) if show == 'offline': @@ -2284,11 +2284,11 @@ class RosterWindow: # No need to redraw contacts if we're quitting if child_iterA: self.model[child_iterA][Column.AVATAR_PIXBUF] = empty_pixbuf - if account in gajim.con_types: - gajim.con_types[account] = None - for jid in list(gajim.contacts.get_jid_list(account)): - lcontact = gajim.contacts.get_contacts(account, jid) - ctrl = gajim.interface.msg_win_mgr.get_gc_control(jid, + if account in app.con_types: + app.con_types[account] = None + for jid in list(app.contacts.get_jid_list(account)): + lcontact = app.contacts.get_contacts(account, jid) + ctrl = app.interface.msg_win_mgr.get_gc_control(jid, account) for contact in [c for c in lcontact if ( (c.show != 'offline' or c.is_transport()) and not ctrl)]: @@ -2307,15 +2307,15 @@ class RosterWindow: """ empty_pep = {'activity': '', 'subactivity': '', 'activity_text': '', 'mood': '', 'mood_text': ''} - if show in gajim.config.get_per('defaultstatusmsg'): - if gajim.config.get_per('defaultstatusmsg', show, 'enabled'): - msg = gajim.config.get_per('defaultstatusmsg', show, 'message') + if show in app.config.get_per('defaultstatusmsg'): + if app.config.get_per('defaultstatusmsg', show, 'enabled'): + msg = app.config.get_per('defaultstatusmsg', show, 'message') msg = helpers.from_one_line(msg) on_response(msg, empty_pep) return - if not always_ask and ((show == 'online' and not gajim.config.get( + if not always_ask and ((show == 'online' and not app.config.get( 'ask_online_status')) or (show in ('offline', 'invisible') and not \ - gajim.config.get('ask_offline_status'))): + app.config.get('ask_offline_status'))): on_response('', empty_pep) return @@ -2364,12 +2364,12 @@ class RosterWindow: liststore.prepend(['SEPARATOR', None, '', True]) status_combobox_text = uf_show + ' (' + _("desync'ed") +')' liststore.prepend([status_combobox_text, - gajim.interface.jabber_state_images['16'][show], show, False]) + app.interface.jabber_state_images['16'][show], show, False]) self.status_combobox.set_active(0) - gajim.interface.change_awn_icon_status(show) + app.interface.change_awn_icon_status(show) self.combobox_callback_active = True - if gajim.interface.systray_enabled: - gajim.interface.systray.change_status(show) + if app.interface.systray_enabled: + app.interface.systray.change_status(show) def get_show(self, lcontact): prio = lcontact[0].priority @@ -2381,11 +2381,11 @@ class RosterWindow: return show def on_message_window_delete(self, win_mgr, msg_win): - if gajim.config.get('one_message_window') == 'always_with_roster': + if app.config.get('one_message_window') == 'always_with_roster': self.show_roster_vbox(True) gtkgui_helpers.resize_window(self.window, - gajim.config.get('roster_width'), - gajim.config.get('roster_height')) + app.config.get('roster_width'), + app.config.get('roster_height')) def close_all_from_dict(self, dic): """ @@ -2405,9 +2405,9 @@ class RosterWindow: Close all the windows from an account. If force is True, do not ask confirmation before closing chat/gc windows """ - if account in gajim.interface.instances: - self.close_all_from_dict(gajim.interface.instances[account]) - for ctrl in gajim.interface.msg_win_mgr.get_controls(acct=account): + if account in app.interface.instances: + self.close_all_from_dict(app.interface.instances[account]) + for ctrl in app.interface.msg_win_mgr.get_controls(acct=account): ctrl.parent_win.remove_tab(ctrl, ctrl.parent_win.CLOSE_CLOSE_BUTTON, force=force) @@ -2415,20 +2415,20 @@ class RosterWindow: """ Main window X button was clicked """ - if not gajim.config.get('quit_on_roster_x_button') and ( - (gajim.interface.systray_enabled and gajim.config.get('trayicon') != \ - 'on_event') or gajim.config.get('allow_hide_roster')): - if gajim.config.get('save-roster-position'): + if not app.config.get('quit_on_roster_x_button') and ( + (app.interface.systray_enabled and app.config.get('trayicon') != \ + 'on_event') or app.config.get('allow_hide_roster')): + if app.config.get('save-roster-position'): x, y = self.window.get_position() - gajim.config.set('roster_x-position', x) - gajim.config.set('roster_y-position', y) + app.config.set('roster_x-position', x) + app.config.set('roster_y-position', y) self.window.iconify() - elif gajim.config.get('quit_on_roster_x_button'): + elif app.config.get('quit_on_roster_x_button'): self.on_quit_request() else: def on_ok(checked): if checked: - gajim.config.set('quit_on_roster_x_button', True) + app.config.set('quit_on_roster_x_button', True) self.on_quit_request() dialogs.ConfirmationDialogCheck(_('Really quit Gajim?'), _('Are you sure you want to quit Gajim?'), @@ -2443,30 +2443,30 @@ class RosterWindow: # in case show_roster_on_start is False and roster is never shown # window.window is None if self.window.get_window() is not None: - if gajim.config.get('save-roster-position'): + if app.config.get('save-roster-position'): x, y = self.window.get_window().get_root_origin() - gajim.config.set('roster_x-position', x) - gajim.config.set('roster_y-position', y) + app.config.set('roster_x-position', x) + app.config.set('roster_y-position', y) width, height = self.window.get_size() - gajim.config.set('roster_width', width) - gajim.config.set('roster_height', height) + app.config.set('roster_width', width) + app.config.set('roster_height', height) if not self.xml.get_object('roster_vbox2').get_property('visible'): # The roster vbox is hidden, so the message window is larger # then we want to save (i.e. the window will grow every startup) # so adjust. msgwin_width_adjust = -1 * width - gajim.config.set('last_roster_visible', + app.config.set('last_roster_visible', self.window.get_property('visible')) - gajim.interface.msg_win_mgr.save_opened_controls() - gajim.interface.msg_win_mgr.shutdown(msgwin_width_adjust) + app.interface.msg_win_mgr.save_opened_controls() + app.interface.msg_win_mgr.shutdown(msgwin_width_adjust) - gajim.config.set('collapsed_rows', '\t'.join(self.collapsed_rows)) - gajim.interface.save_config() - for account in gajim.connections: - gajim.connections[account].quit(True) + app.config.set('collapsed_rows', '\t'.join(self.collapsed_rows)) + app.interface.save_config() + for account in app.connections: + app.connections[account].quit(True) self.close_all(account) - if gajim.interface.systray_enabled: - gajim.interface.hide_systray() + if app.interface.systray_enabled: + app.interface.hide_systray() self.save_done = True def quit_gtkgui_interface(self): @@ -2482,10 +2482,10 @@ class RosterWindow: Terminate all sessions and send offline to all connected account. We do NOT really quit gajim here """ - accounts = list(gajim.connections.keys()) + accounts = list(app.connections.keys()) get_msg = False for acct in accounts: - if gajim.connections[acct].connected: + if app.connections[acct].connected: get_msg = True break @@ -2493,7 +2493,7 @@ class RosterWindow: self.quit_on_next_offline = 0 accounts_to_disconnect = [] for acct in accounts: - if gajim.connections[acct].connected > 1: + if app.connections[acct].connected > 1: self.quit_on_next_offline += 1 accounts_to_disconnect.append(acct) @@ -2509,7 +2509,7 @@ class RosterWindow: def on_continue2(message, pep_dict): # check if there is an active file transfer from gajim.common.protocol.bytestream import (is_transfer_active) - files_props = gajim.interface.instances['file_transfers'].\ + files_props = app.interface.instances['file_transfers'].\ files_props transfer_active = False for x in files_props: @@ -2531,19 +2531,19 @@ class RosterWindow: # user pressed Cancel to change status message dialog return # check if we have unread messages - unread = gajim.events.get_nb_events() - if not gajim.config.get('notify_on_all_muc_messages'): - unread_not_to_notify = gajim.events.get_nb_events( + unread = app.events.get_nb_events() + if not app.config.get('notify_on_all_muc_messages'): + unread_not_to_notify = app.events.get_nb_events( ['printed_gc_msg']) unread -= unread_not_to_notify # check if we have recent messages recent = False - for win in gajim.interface.msg_win_mgr.windows(): + for win in app.interface.msg_win_mgr.windows(): for ctrl in win.controls(): fjid = ctrl.get_full_jid() - if fjid in gajim.last_message_time[ctrl.account]: - if time.time() - gajim.last_message_time[ctrl.account][ + if fjid in app.last_message_time[ctrl.account]: + if time.time() - app.last_message_time[ctrl.account][ fjid] < 2: recent = True break @@ -2571,9 +2571,9 @@ class RosterWindow: if obj.need_add_in_roster: self.add_contact(jid, account) - jid_list = gajim.contacts.get_jid_list(account) - if jid in jid_list or jid == gajim.get_jid_from_account(account): - if not gajim.jid_is_transport(jid) and len(obj.contact_list) == 1: + jid_list = app.contacts.get_jid_list(account) + if jid in jid_list or jid == app.get_jid_from_account(account): + if not app.jid_is_transport(jid) and len(obj.contact_list) == 1: if obj.old_show == 0 and obj.new_show > 1: GLib.timeout_add_seconds(5, self.remove_newly_added, jid, account) @@ -2585,38 +2585,38 @@ class RosterWindow: if obj.need_redraw: self.draw_contact(jid, account) - if gajim.jid_is_transport(jid) and jid in jid_list: + if app.jid_is_transport(jid) and jid in jid_list: # It must be an agent # Update existing iter and group counting self.draw_contact(jid, account) self.draw_group(_('Transports'), account) - if obj.new_show > 1 and jid in gajim.transport_avatar[account]: + if obj.new_show > 1 and jid in app.transport_avatar[account]: # transport just signed in. # request avatars - for jid_ in gajim.transport_avatar[account][jid]: + for jid_ in app.transport_avatar[account][jid]: obj.conn.request_vcard(jid_) if obj.contact: self.chg_contact_status(obj.contact, obj.show, obj.status, account) if obj.popup: - ctrl = gajim.interface.msg_win_mgr.search_control(jid, account) + ctrl = app.interface.msg_win_mgr.search_control(jid, account) if ctrl: GLib.idle_add(ctrl.parent_win.set_active_tab, ctrl) else: - ctrl = gajim.interface.new_chat(obj.contact, account) - if len(gajim.events.get_events(account, obj.jid)): + ctrl = app.interface.new_chat(obj.contact, account) + if len(app.events.get_events(account, obj.jid)): ctrl.read_queue() def _nec_gc_presence_received(self, obj): account = obj.conn.name - if obj.room_jid in gajim.interface.minimized_controls[account]: - gc_ctrl = gajim.interface.minimized_controls[account][obj.room_jid] + if obj.room_jid in app.interface.minimized_controls[account]: + gc_ctrl = app.interface.minimized_controls[account][obj.room_jid] else: return if obj.nick == gc_ctrl.nick: - contact = gajim.contacts.get_contact_with_highest_priority(account, + contact = app.contacts.get_contact_with_highest_priority(account, obj.room_jid) if contact: contact.show = obj.show @@ -2630,34 +2630,34 @@ class RosterWindow: self.fire_up_unread_messages_events(obj.conn.name) else: # add self contact - if gajim.config.get('show_self_contact') == 'always': + if app.config.get('show_self_contact') == 'always': account = obj.conn.name - self_jid = gajim.get_jid_from_account(account) - if self_jid not in gajim.contacts.get_jid_list(account): + self_jid = app.get_jid_from_account(account) + if self_jid not in app.contacts.get_jid_list(account): resource = '' - if gajim.connections[account].server_resource: - resource = gajim.connections[account].server_resource - contact = gajim.contacts.create_contact(jid=self_jid, - account=account, name=gajim.nicks[account], + if app.connections[account].server_resource: + resource = app.connections[account].server_resource + contact = app.contacts.create_contact(jid=self_jid, + account=account, name=app.nicks[account], groups=['self_contact'], show='offline', sub='both', ask='none', resource=resource) - gajim.contacts.add_contact(account, contact) + app.contacts.add_contact(account, contact) self.add_contact(self_jid, account) - if gajim.config.get('remember_opened_chat_controls'): + if app.config.get('remember_opened_chat_controls'): account = obj.conn.name - controls = gajim.config.get_per('accounts', account, + controls = app.config.get_per('accounts', account, 'opened_chat_controls') if controls: for jid in controls.split(','): contact = \ - gajim.contacts.get_contact_with_highest_priority( + app.contacts.get_contact_with_highest_priority( account, jid) if not contact: contact = self.add_to_not_in_the_roster(account, jid) - gajim.interface.on_open_chat_window(None, contact, + app.interface.on_open_chat_window(None, contact, account) - gajim.config.set_per('accounts', account, + app.config.set_per('accounts', account, 'opened_chat_controls', '') GLib.idle_add(self.refilter_shown_roster_items) @@ -2672,7 +2672,7 @@ class RosterWindow: model = self.status_combobox.get_model() if obj.show == 'offline': # sensitivity for this menuitem - if gajim.get_number_of_connected_accounts() == 0: + if app.get_number_of_connected_accounts() == 0: model[self.status_message_menuitem_iter][3] = False self.application.set_account_actions_state(obj.conn.name) else: @@ -2688,7 +2688,7 @@ class RosterWindow: self.remove_contact(jid, obj.conn.name, backend=True) def _nec_pep_received(self, obj): - if obj.jid == gajim.get_jid_from_account(obj.conn.name): + if obj.jid == app.get_jid_from_account(obj.conn.name): self.draw_account(obj.conn.name) if obj.pep_type == 'nickname': @@ -2703,7 +2703,7 @@ class RosterWindow: self.draw_avatar(obj.jid, obj.conn.name) def _nec_gc_subject_received(self, obj): - contact = gajim.contacts.get_contact_with_highest_priority( + contact = app.contacts.get_contact_with_highest_priority( obj.conn.name, obj.room_jid) if contact: contact.status = obj.subject @@ -2735,7 +2735,7 @@ class RosterWindow: typ = 'error' if obj.forwarded and obj.sent: typ = 'out' - if obj.jid != gajim.get_jid_from_account(obj.conn.name): + if obj.jid != app.get_jid_from_account(obj.conn.name): xep0184_id = obj.id_ obj.session.control.print_conversation(obj.msgtxt, typ, @@ -2748,12 +2748,12 @@ class RosterWindow: end = obj.session.control.was_at_the_end if not pw or (pw.get_active_control() and obj.session.control \ == pw.get_active_control() and pw.is_active() and end): - gajim.logger.set_read_messages([obj.msg_log_id]) + app.logger.set_read_messages([obj.msg_log_id]) elif obj.popup and obj.mtype == 'chat': - contact = gajim.contacts.get_contact(obj.conn.name, obj.jid) - obj.session.control = gajim.interface.new_chat(contact, + contact = app.contacts.get_contact(obj.conn.name, obj.jid) + obj.session.control = app.interface.new_chat(contact, obj.conn.name, session=obj.session) - if len(gajim.events.get_events(obj.conn.name, obj.fjid)): + if len(app.events.get_events(obj.conn.name, obj.fjid)): obj.session.control.read_queue() if obj.show_in_roster: @@ -2761,11 +2761,11 @@ class RosterWindow: self.show_title() # we show the * or [n] # Select the big brother contact in roster, it's visible because it # has events. - family = gajim.contacts.get_metacontacts_family(obj.conn.name, + family = app.contacts.get_metacontacts_family(obj.conn.name, obj.jid) if family: nearby_family, bb_jid, bb_account = \ - gajim.contacts.get_nearby_family_and_big_brother(family, + app.contacts.get_nearby_family_and_big_brother(family, obj.conn.name) else: bb_jid, bb_account = obj.jid, obj.conn.name @@ -2777,29 +2777,29 @@ class RosterWindow: ################################################################################ def on_bookmark_menuitem_activate(self, widget, account, bookmark): - gajim.interface.join_gc_room(account, bookmark['jid'], bookmark['nick'], + app.interface.join_gc_room(account, bookmark['jid'], bookmark['nick'], bookmark['password']) def on_info(self, widget, contact, account): """ Call vcard_information_window class to display contact's information """ - if gajim.connections[account].is_zeroconf: + if app.connections[account].is_zeroconf: self.on_info_zeroconf(widget, contact, account) return - info = gajim.interface.instances[account]['infos'] + info = app.interface.instances[account]['infos'] if contact.jid in info: info[contact.jid].window.present() else: info[contact.jid] = vcard.VcardWindow(contact, account) def on_info_zeroconf(self, widget, contact, account): - info = gajim.interface.instances[account]['infos'] + info = app.interface.instances[account]['infos'] if contact.jid in info: info[contact.jid].window.present() else: - contact = gajim.contacts.get_first_contact_from_jid(account, + contact = app.contacts.get_first_contact_from_jid(account, contact.jid) if contact.show in ('offline', 'error'): # don't show info on offline contacts @@ -2810,13 +2810,13 @@ class RosterWindow: """ When an agent is requested to log in or off """ - gajim.connections[account].send_agent_status(jid, state) + app.connections[account].send_agent_status(jid, state) def on_edit_agent(self, widget, contact, account): """ When we want to modify the agent registration """ - gajim.connections[account].request_register_agent_info(contact.jid) + app.connections[account].request_register_agent_info(contact.jid) def on_remove_agent(self, widget, list_): """ @@ -2824,25 +2824,25 @@ class RosterWindow: account) tuple """ for (contact, account) in list_: - if gajim.config.get_per('accounts', account, 'hostname') == \ + if app.config.get_per('accounts', account, 'hostname') == \ contact.jid: # We remove the server contact # remove it from treeview - gajim.connections[account].unsubscribe(contact.jid) + app.connections[account].unsubscribe(contact.jid) self.remove_contact(contact.jid, account, backend=True) return def remove(list_): for (contact, account) in list_: full_jid = contact.get_full_jid() - gajim.connections[account].unsubscribe_agent(full_jid) + app.connections[account].unsubscribe_agent(full_jid) # remove transport from treeview self.remove_contact(contact.jid, account, backend=True) # Check if there are unread events from some contacts has_unread_events = False for (contact, account) in list_: - for jid in gajim.events.get_events(account): + for jid in app.events.get_events(account): if jid.endswith(contact.jid): has_unread_events = True break @@ -2867,7 +2867,7 @@ class RosterWindow: def _nec_blocking(self, obj): if obj.unblock_all: - jids = gajim.contacts.get_jid_list(obj.conn.name) + jids = app.contacts.get_jid_list(obj.conn.name) self._idle_draw_jids_of_account(jids, obj.conn.name) else: for jid in obj.blocked_jids + obj.unblocked_jids: @@ -2882,19 +2882,19 @@ class RosterWindow: if msg is None: # user pressed Cancel to change status message dialog return - accounts = set(i[1] for i in list_ if (gajim.connections[i[1]].\ - privacy_rules_supported or (group is None and gajim.\ + accounts = set(i[1] for i in list_ if (app.connections[i[1]].\ + privacy_rules_supported or (group is None and app.\ connections[i[1]].blocking_supported))) if group is None: for acct in accounts: l_ = [i[0] for i in list_ if i[1] == acct] - gajim.connections[acct].block_contacts(l_, msg) + app.connections[acct].block_contacts(l_, msg) for contact in l_: self.draw_contact(contact.jid, acct) else: for acct in accounts: l_ = [i[0] for i in list_ if i[1] == acct] - gajim.connections[acct].block_group(group, l_, msg) + app.connections[acct].block_group(group, l_, msg) self.draw_group(group, acct) for contact in l_: self.draw_contact(contact.jid, acct) @@ -2902,12 +2902,12 @@ class RosterWindow: def _block_it(is_checked=None): if is_checked is not None: # dialog has been shown if is_checked: # user does not want to be asked again - gajim.config.set('confirm_block', 'no') + app.config.set('confirm_block', 'no') else: - gajim.config.set('confirm_block', 'yes') + app.config.set('confirm_block', 'yes') self.get_status_message('offline', on_continue, show_pep=False) - confirm_block = gajim.config.get('confirm_block') + confirm_block = app.config.get('confirm_block') if confirm_block == 'no': _block_it() return @@ -2922,40 +2922,40 @@ class RosterWindow: """ When clicked on the 'unblock' button in context menu. """ - accounts = set(i[1] for i in list_ if (gajim.connections[i[1]].\ - privacy_rules_supported or (group is None and gajim.\ + accounts = set(i[1] for i in list_ if (app.connections[i[1]].\ + privacy_rules_supported or (group is None and app.\ connections[i[1]].blocking_supported))) if group is None: for acct in accounts: l_ = [i[0] for i in list_ if i[1] == acct] - gajim.connections[acct].unblock_contacts(l_) + app.connections[acct].unblock_contacts(l_) for contact in l_: self.draw_contact(contact.jid, acct) else: for acct in accounts: l_ = [i[0] for i in list_ if i[1] == acct] - gajim.connections[acct].unblock_group(group, l_) + app.connections[acct].unblock_group(group, l_) self.draw_group(group, acct) for contact in l_: self.draw_contact(contact.jid, acct) for acct in accounts: - if 'privacy_list_block' in gajim.interface.instances[acct]: - del gajim.interface.instances[acct]['privacy_list_block'] + if 'privacy_list_block' in app.interface.instances[acct]: + del app.interface.instances[acct]['privacy_list_block'] def on_rename(self, widget, row_type, jid, account): # this function is called either by F2 or by Rename menuitem - if 'rename' in gajim.interface.instances: - gajim.interface.instances['rename'].dialog.present() + if 'rename' in app.interface.instances: + app.interface.instances['rename'].dialog.present() return # account is offline, don't allow to rename - if gajim.connections[account].connected < 2: + if app.connections[account].connected < 2: return if row_type in ('contact', 'agent'): # it's jid title = _('Rename Contact') message = _('Enter a new nickname for contact %s') % jid - old_text = gajim.contacts.get_contact_with_highest_priority(account, + old_text = app.contacts.get_contact_with_highest_priority(account, jid).name elif row_type == 'group': if jid in helpers.special_groups + (_('General'),): @@ -2966,22 +2966,22 @@ class RosterWindow: GLib.markup_escape_text(jid) def on_renamed(new_text, account, row_type, jid, old_text): - if 'rename' in gajim.interface.instances: - del gajim.interface.instances['rename'] + if 'rename' in app.interface.instances: + del app.interface.instances['rename'] if row_type in ('contact', 'agent'): if old_text == new_text: return - contacts = gajim.contacts.get_contacts(account, jid) + contacts = app.contacts.get_contacts(account, jid) for contact in contacts: contact.name = new_text - gajim.connections[account].update_contact(jid, new_text, \ + app.connections[account].update_contact(jid, new_text, \ contacts[0].groups) self.draw_contact(jid, account) # Update opened chats - for ctrl in gajim.interface.msg_win_mgr.get_controls(jid, + for ctrl in app.interface.msg_win_mgr.get_controls(jid, account): ctrl.update_ui() - win = gajim.interface.msg_win_mgr.get_window(jid, account) + win = app.interface.msg_win_mgr.get_window(jid, account) win.redraw_tab(ctrl) win.show_title() elif row_type == 'group': @@ -2989,22 +2989,22 @@ class RosterWindow: self.rename_group(old_text, new_text, account) def on_canceled(): - if 'rename' in gajim.interface.instances: - del gajim.interface.instances['rename'] + if 'rename' in app.interface.instances: + del app.interface.instances['rename'] - gajim.interface.instances['rename'] = dialogs.InputDialog(title, + app.interface.instances['rename'] = dialogs.InputDialog(title, message, old_text, False, (on_renamed, account, row_type, jid, old_text), on_canceled, transient_for=self.window) def on_remove_group_item_activated(self, widget, group, account): def on_ok(checked): - for contact in gajim.contacts.get_contacts_from_group(account, + for contact in app.contacts.get_contacts_from_group(account, group): if not checked: self.remove_contact_from_groups(contact.jid, account, [group]) else: - gajim.connections[account].unsubscribe(contact.jid) + app.connections[account].unsubscribe(contact.jid) self.remove_contact(contact.jid, account, backend=True) dialogs.ConfirmationDialogCheck(_('Remove Group'), @@ -3013,7 +3013,7 @@ class RosterWindow: on_response_ok=on_ok) def on_assign_pgp_key(self, widget, contact, account): - attached_keys = gajim.config.get_per('accounts', account, + attached_keys = app.config.get_per('accounts', account, 'attached_gpg_keys').split() keys = {} keyID = _('None') @@ -3021,7 +3021,7 @@ class RosterWindow: keys[attached_keys[2*i]] = attached_keys[2*i+1] if attached_keys[2*i] == contact.jid: keyID = attached_keys[2*i+1] - public_keys = gajim.connections[account].ask_gpg_keys() + public_keys = app.connections[account].ask_gpg_keys() public_keys[_('None')] = _('None') def on_key_selected(keyID): @@ -3035,16 +3035,16 @@ class RosterWindow: keyID = keyID[0] keys[contact.jid] = keyID - ctrl = gajim.interface.msg_win_mgr.get_control(contact.jid, account) + ctrl = app.interface.msg_win_mgr.get_control(contact.jid, account) if ctrl: ctrl.update_ui() keys_str = '' for jid in keys: keys_str += jid + ' ' + keys[jid] + ' ' - gajim.config.set_per('accounts', account, 'attached_gpg_keys', + app.config.set_per('accounts', account, 'attached_gpg_keys', keys_str) - for u in gajim.contacts.get_contacts(account, contact.jid): + for u in app.contacts.get_contacts(account, contact.jid): u.keyID = helpers.prepare_and_validate_gpg_keyID(account, contact.jid, keyID) @@ -3079,14 +3079,14 @@ class RosterWindow: msg = str(msg) dialogs.ErrorDialog(_('Could not load image'), msg) return - gajim.interface.save_avatar_files(contact.jid, pixbuf, local=True) + app.interface.save_avatar_files(contact.jid, pixbuf, local=True) dlg.destroy() self.update_avatar_in_gui(contact.jid, account) def on_clear(widget): dlg.destroy() # Delete file: - gajim.interface.remove_avatar_files(contact.jid, local=True) + app.interface.remove_avatar_files(contact.jid, local=True) self.update_avatar_in_gui(contact.jid, account) dlg = dialogs.AvatarChooserDialog(on_response_ok=on_ok, @@ -3099,19 +3099,19 @@ class RosterWindow: """ When history menuitem is activated: call log window """ - if 'logs' in gajim.interface.instances: - gajim.interface.instances['logs'].window.present() - gajim.interface.instances['logs'].open_history(contact.jid, account) + if 'logs' in app.interface.instances: + app.interface.instances['logs'].window.present() + app.interface.instances['logs'].open_history(contact.jid, account) else: - gajim.interface.instances['logs'] = history_window.\ + app.interface.instances['logs'] = history_window.\ HistoryWindow(contact.jid, account) def on_disconnect(self, widget, jid, account): """ When disconnect menuitem is activated: disconect from room """ - if jid in gajim.interface.minimized_controls[account]: - ctrl = gajim.interface.minimized_controls[account][jid] + if jid in app.interface.minimized_controls[account]: + ctrl = app.interface.minimized_controls[account][jid] ctrl.shutdown() ctrl.got_disconnected() self.remove_groupchat(jid, account) @@ -3120,10 +3120,10 @@ class RosterWindow: """ When reconnect menuitem is activated: join the room """ - if jid in gajim.interface.minimized_controls[account]: - ctrl = gajim.interface.minimized_controls[account][jid] - gajim.interface.join_gc_room(account, jid, ctrl.nick, - gajim.gc_passwords.get(jid, '')) + if jid in app.interface.minimized_controls[account]: + ctrl = app.interface.minimized_controls[account][jid] + app.interface.join_gc_room(account, jid, ctrl.nick, + app.gc_passwords.get(jid, '')) def on_send_single_message_menuitem_activate(self, widget, account, contact=None): @@ -3133,13 +3133,13 @@ class RosterWindow: dialogs.SingleMessageWindow(account, contact, 'send') else: jid = contact.jid - if contact.jid == gajim.get_jid_from_account(account): + if contact.jid == app.get_jid_from_account(account): jid += '/' + contact.resource dialogs.SingleMessageWindow(account, jid, 'send') def on_send_file_menuitem_activate(self, widget, contact, account, resource=None): - gajim.interface.instances['file_transfers'].show_file_send_request( + app.interface.instances['file_transfers'].show_file_send_request( account, contact) def on_add_special_notification_menuitem_activate(self, widget, jid): @@ -3161,17 +3161,17 @@ class RosterWindow: if account not in account_list: account_list.append(account) # transform None in 'jabber' - type_ = gajim.get_transport_name_from_jid(jid_list[0]) or 'jabber' + type_ = app.get_transport_name_from_jid(jid_list[0]) or 'jabber' for account in account_list: - if gajim.connections[account].muc_jid[type_]: + if app.connections[account].muc_jid[type_]: # create the room on this muc server - if 'join_gc' in gajim.interface.instances[account]: - gajim.interface.instances[account]['join_gc'].window.\ + if 'join_gc' in app.interface.instances[account]: + app.interface.instances[account]['join_gc'].window.\ destroy() try: - gajim.interface.instances[account]['join_gc'] = \ + app.interface.instances[account]['join_gc'] = \ dialogs.JoinGroupchatWindow(account, - gajim.connections[account].muc_jid[type_], + app.connections[account].muc_jid[type_], automatic = {'invities': jid_list}) except GajimGeneralException: continue @@ -3187,8 +3187,8 @@ class RosterWindow: contact_jid = contact.jid if resource: # we MUST have one contact only in list_ contact_jid += '/' + resource - gajim.connections[room_account].send_invite(room_jid, contact_jid) - gc_control = gajim.interface.msg_win_mgr.get_gc_control(room_jid, + app.connections[room_account].send_invite(room_jid, contact_jid) + gc_control = app.interface.msg_win_mgr.get_gc_control(room_jid, room_account) if gc_control: gc_control.print_conversation( @@ -3203,19 +3203,19 @@ class RosterWindow: """ When a groupchat is maximized """ - if not jid in gajim.interface.minimized_controls[account]: + if not jid in app.interface.minimized_controls[account]: # Already opened? - gc_control = gajim.interface.msg_win_mgr.get_gc_control(jid, + gc_control = app.interface.msg_win_mgr.get_gc_control(jid, account) if gc_control: - mw = gajim.interface.msg_win_mgr.get_window(jid, account) + mw = app.interface.msg_win_mgr.get_window(jid, account) mw.set_active_tab(gc_control) mw.window.get_window().focus(Gtk.get_current_event_time()) return - ctrl = gajim.interface.minimized_controls[account][jid] - mw = gajim.interface.msg_win_mgr.get_window(jid, account) + ctrl = app.interface.minimized_controls[account][jid] + mw = app.interface.msg_win_mgr.get_window(jid, account) if not mw: - mw = gajim.interface.msg_win_mgr.create_window(ctrl.contact, + mw = app.interface.msg_win_mgr.create_window(ctrl.contact, ctrl.account, ctrl.type_id) id_ = mw.window.connect('motion-notify-event', ctrl._on_window_motion_notify) @@ -3228,19 +3228,19 @@ class RosterWindow: self.remove_groupchat(jid, account) def on_edit_account(self, widget, account): - if 'accounts' in gajim.interface.instances: - gajim.interface.instances['accounts'].window.present() + if 'accounts' in app.interface.instances: + app.interface.instances['accounts'].window.present() else: - gajim.interface.instances['accounts'] = config.AccountsWindow() - gajim.interface.instances['accounts'].select_account(account) + app.interface.instances['accounts'] = config.AccountsWindow() + app.interface.instances['accounts'].select_account(account) def on_open_gmail_inbox(self, widget, account): - url = gajim.connections[account].gmail_url + url = app.connections[account].gmail_url if url: helpers.launch_browser_mailer('url', url) def on_change_status_message_activate(self, widget, account): - show = gajim.SHOW_LIST[gajim.connections[account].connected] + show = app.SHOW_LIST[app.connections[account].connected] def on_response(message, pep_dict): if message is None: # None is if user pressed Cancel return @@ -3280,7 +3280,7 @@ class RosterWindow: type_ = model[list_of_paths[0]][Column.TYPE] account = model[list_of_paths[0]][Column.ACCOUNT] if type_ in ('account', 'group', 'self_contact') or \ - account == gajim.ZEROCONF_ACC_NAME: + account == app.ZEROCONF_ACC_NAME: return list_ = [] for path in list_of_paths: @@ -3288,9 +3288,9 @@ class RosterWindow: return jid = model[path][Column.JID] account = model[path][Column.ACCOUNT] - if not gajim.account_is_connected(account): + if not app.account_is_connected(account): continue - contact = gajim.contacts.get_contact_with_highest_priority( + contact = app.contacts.get_contact_with_highest_priority( account, jid) list_.append((contact, account)) if not list_: @@ -3344,7 +3344,7 @@ class RosterWindow: return False if event.button == 1: # Left click - if gajim.single_click and not event.get_state() & Gdk.ModifierType.SHIFT_MASK and \ + if app.single_click and not event.get_state() & Gdk.ModifierType.SHIFT_MASK and \ not event.get_state() & Gdk.ModifierType.CONTROL_MASK: # Check if button has been pressed on the same row if self.clicked_path == path: @@ -3356,16 +3356,16 @@ class RosterWindow: if modifier & Gdk.ModifierType.CONTROL_MASK: if keyval == Gdk.KEY_s: # CTRL + s model = self.status_combobox.get_model() - accounts = list(gajim.connections.keys()) + accounts = list(app.connections.keys()) status = model[self.previous_status_combobox_active][2] def on_response(message, pep_dict): if message is not None: # None if user pressed Cancel for account in accounts: - if not gajim.config.get_per('accounts', account, + if not app.config.get_per('accounts', account, 'sync_with_global_status'): continue - current_show = gajim.SHOW_LIST[ - gajim.connections[account].connected] + current_show = app.SHOW_LIST[ + app.connections[account].connected] self.send_status(account, current_show, message) self.send_pep(account, pep_dict) dialogs.ChangeStatusMessageDialog(on_response, status) @@ -3407,7 +3407,7 @@ class RosterWindow: elif type_ == 'account': account = model[path][Column.ACCOUNT] if account != 'all': - show = gajim.connections[account].connected + show = app.connections[account].connected if show > 1: # We are connected self.on_change_status_message_activate(widget, account) return True @@ -3417,11 +3417,11 @@ class RosterWindow: def on_response(message, pep_dict): if message is None: return True - for acct in gajim.connections: - if not gajim.config.get_per('accounts', acct, + for acct in app.connections: + if not app.config.get_per('accounts', acct, 'sync_with_global_status'): continue - current_show = gajim.SHOW_LIST[gajim.connections[acct].\ + current_show = app.SHOW_LIST[app.connections[acct].\ connected] self.send_status(acct, current_show, message) self.send_pep(acct, pep_dict) @@ -3432,11 +3432,11 @@ class RosterWindow: model = self.modelfilter type_ = model[path][Column.TYPE] # x_min is the x start position of status icon column - if gajim.config.get('avatar_position_in_roster') == 'left': - x_min = gajim.config.get('roster_avatar_width') + if app.config.get('avatar_position_in_roster') == 'left': + x_min = app.config.get('roster_avatar_width') else: x_min = 0 - if gajim.single_click and not event.get_state() & Gdk.ModifierType.SHIFT_MASK and \ + if app.single_click and not event.get_state() & Gdk.ModifierType.SHIFT_MASK and \ not event.get_state() & Gdk.ModifierType.CONTROL_MASK: # Don't handle double click if we press icon of a metacontact titer = model.get_iter(path) @@ -3490,7 +3490,7 @@ class RosterWindow: remove_auth = False for (contact, account) in list_: if _('Not in Roster') not in contact.get_shown_groups(): - gajim.connections[account].unsubscribe(contact.jid, + app.connections[account].unsubscribe(contact.jid, remove_auth) self.remove_contact(contact.jid, account, backend=True) if not remove_auth and contact.sub == 'both': @@ -3499,7 +3499,7 @@ class RosterWindow: contact.sub = 'from' # we can't see him, but have to set it manually in contact contact.show = 'offline' - gajim.contacts.add_contact(account, contact) + app.contacts.add_contact(account, contact) self.add_contact(contact.jid, account) def on_ok2(list_): on_ok(False, list_) @@ -3556,25 +3556,25 @@ class RosterWindow: # 1. update status_sent_to_[groups|users] list if group: for account in account_list: - if account not in gajim.interface.status_sent_to_groups: - gajim.interface.status_sent_to_groups[account] = {} - gajim.interface.status_sent_to_groups[account][group] = show + if account not in app.interface.status_sent_to_groups: + app.interface.status_sent_to_groups[account] = {} + app.interface.status_sent_to_groups[account][group] = show else: for (contact, account) in contact_list: - if account not in gajim.interface.status_sent_to_users: - gajim.interface.status_sent_to_users[account] = {} - gajim.interface.status_sent_to_users[account][contact.jid] \ + if account not in app.interface.status_sent_to_users: + app.interface.status_sent_to_users[account] = {} + app.interface.status_sent_to_users[account][contact.jid] \ = show # 2. update privacy lists if main status is invisible for account in account_list: - if gajim.SHOW_LIST[gajim.connections[account].connected] == \ + if app.SHOW_LIST[app.connections[account].connected] == \ 'invisible': - gajim.connections[account].set_invisible_rule() + app.connections[account].set_invisible_rule() # 3. send directed presence for (contact, account) in contact_list: - our_jid = gajim.get_jid_from_account(account) + our_jid = app.get_jid_from_account(account) jid = contact.jid if jid == our_jid: jid += '/' + contact.resource @@ -3583,13 +3583,13 @@ class RosterWindow: def send_it(is_checked=None): if is_checked is not None: # dialog has been shown if is_checked: # user does not want to be asked again - gajim.config.set('confirm_custom_status', 'no') + app.config.set('confirm_custom_status', 'no') else: - gajim.config.set('confirm_custom_status', 'yes') + app.config.set('confirm_custom_status', 'yes') self.get_status_message(show, on_response, show_pep=False, always_ask=True) - confirm_custom_status = gajim.config.get('confirm_custom_status') + confirm_custom_status = app.config.get('confirm_custom_status') if confirm_custom_status == 'no': send_it() return @@ -3612,7 +3612,7 @@ class RosterWindow: if not self.combobox_callback_active: self.previous_status_combobox_active = active return - accounts = list(gajim.connections.keys()) + accounts = list(app.connections.keys()) if len(accounts) == 0: dialogs.ErrorDialog(_('No account available'), _('You must create an account before you can chat with other ' @@ -3630,11 +3630,11 @@ class RosterWindow: def on_response(message, pep_dict): if message is not None: # None if user pressed Cancel for account in accounts: - if not gajim.config.get_per('accounts', account, + if not app.config.get_per('accounts', account, 'sync_with_global_status'): continue - current_show = gajim.SHOW_LIST[ - gajim.connections[account].connected] + current_show = app.SHOW_LIST[ + app.connections[account].connected] self.send_status(account, current_show, message) self.send_pep(account, pep_dict) self.combobox_callback_active = False @@ -3647,7 +3647,7 @@ class RosterWindow: # after user chooses "Change status message" menuitem # we can return to this show self.previous_status_combobox_active = active - connected_accounts = gajim.get_number_of_connected_accounts() + connected_accounts = app.get_number_of_connected_accounts() def on_continue(message, pep_dict): if message is None: @@ -3656,13 +3656,13 @@ class RosterWindow: return global_sync_accounts = [] for acct in accounts: - if gajim.config.get_per('accounts', acct, + if app.config.get_per('accounts', acct, 'sync_with_global_status'): global_sync_accounts.append(acct) global_sync_connected_accounts = \ - gajim.get_number_of_connected_accounts(global_sync_accounts) + app.get_number_of_connected_accounts(global_sync_accounts) for account in accounts: - if not gajim.config.get_per('accounts', account, + if not app.config.get_per('accounts', account, 'sync_with_global_status'): continue # we are connected (so we wanna change show and status) @@ -3670,7 +3670,7 @@ class RosterWindow: # show and status if not global_sync_connected_accounts > 0 or \ - gajim.connections[account].connected > 0: + app.connections[account].connected > 0: self.send_status(account, status, message) self.send_pep(account, pep_dict) self.update_status_combobox() @@ -3678,9 +3678,9 @@ class RosterWindow: if status == 'invisible': bug_user = False for account in accounts: - if connected_accounts < 1 or gajim.account_is_connected( + if connected_accounts < 1 or app.account_is_connected( account): - if not gajim.config.get_per('accounts', account, + if not app.config.get_per('accounts', account, 'sync_with_global_status'): continue # We're going to change our status to invisible @@ -3706,30 +3706,30 @@ class RosterWindow: def on_publish_tune_toggled(self, widget, account): active = widget.get_active() - gajim.config.set_per('accounts', account, 'publish_tune', active) + app.config.set_per('accounts', account, 'publish_tune', active) if active: - gajim.interface.enable_music_listener() + app.interface.enable_music_listener() else: - gajim.connections[account].retract_tune() + app.connections[account].retract_tune() # disable music listener only if no other account uses it - for acc in gajim.connections: - if gajim.config.get_per('accounts', acc, 'publish_tune'): + for acc in app.connections: + if app.config.get_per('accounts', acc, 'publish_tune'): break else: - gajim.interface.disable_music_listener() + app.interface.disable_music_listener() helpers.update_optional_features(account) def on_publish_location_toggled(self, widget, account): active = widget.get_active() - gajim.config.set_per('accounts', account, 'publish_location', active) + app.config.set_per('accounts', account, 'publish_location', active) if active: location_listener.enable() else: - gajim.connections[account].retract_location() + app.connections[account].retract_location() # disable music listener only if no other account uses it - for acc in gajim.connections: - if gajim.config.get_per('accounts', acc, 'publish_location'): + for acc in app.connections: + if app.config.get_per('accounts', acc, 'publish_location'): break else: location_listener.disable() @@ -3737,10 +3737,10 @@ class RosterWindow: helpers.update_optional_features(account) def on_pep_services_menuitem_activate(self, widget, account): - if 'pep_services' in gajim.interface.instances[account]: - gajim.interface.instances[account]['pep_services'].window.present() + if 'pep_services' in app.interface.instances[account]: + app.interface.instances[account]['pep_services'].window.present() else: - gajim.interface.instances[account]['pep_services'] = \ + app.interface.instances[account]['pep_services'] = \ config.ManagePEPServicesWindow(account) def on_add_new_contact(self, widget, account): @@ -3750,16 +3750,16 @@ class RosterWindow: """ When the join gc menuitem is clicked, show the join gc window """ - invisible_show = gajim.SHOW_LIST.index('invisible') - if gajim.connections[account].connected == invisible_show: + invisible_show = app.SHOW_LIST.index('invisible') + if app.connections[account].connected == invisible_show: dialogs.ErrorDialog(_('You cannot join a group chat while you are ' 'invisible')) return - if 'join_gc' in gajim.interface.instances[account]: - gajim.interface.instances[account]['join_gc'].window.present() + if 'join_gc' in app.interface.instances[account]: + app.interface.instances[account]['join_gc'].window.present() else: try: - gajim.interface.instances[account]['join_gc'] = \ + app.interface.instances[account]['join_gc'] = \ dialogs.JoinGroupchatWindow(account) except GajimGeneralException: pass @@ -3768,7 +3768,7 @@ class RosterWindow: dialogs.NewChatDialog(account) def on_show_transports_action(self, action, param): - gajim.config.set('show_transports_group', param.get_boolean()) + app.config.set('show_transports_group', param.get_boolean()) action.set_state(param) self.refilter_shown_roster_items() @@ -3812,15 +3812,15 @@ class RosterWindow: if self.rfilter_enabled: self.disable_rfilter() return True - if gajim.interface.msg_win_mgr.mode == \ + if app.interface.msg_win_mgr.mode == \ MessageWindowMgr.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER and \ - gajim.interface.msg_win_mgr.one_window_opened(): + app.interface.msg_win_mgr.one_window_opened(): # let message window close the tab return list_of_paths = self.tree.get_selection().get_selected_rows()[1] - if not len(list_of_paths) and not gajim.config.get( - 'quit_on_roster_x_button') and ((gajim.interface.systray_enabled and\ - gajim.config.get('trayicon') == 'always') or gajim.config.get( + if not len(list_of_paths) and not app.config.get( + 'quit_on_roster_x_button') and ((app.interface.systray_enabled and\ + app.config.get('trayicon') == 'always') or app.config.get( 'allow_hide_roster')): self.window.hide() elif event.get_state() & Gdk.ModifierType.CONTROL_MASK and event.keyval == \ @@ -3832,7 +3832,7 @@ class RosterWindow: if type_ in ('contact', 'agent'): jid = model[path][Column.JID] account = model[path][Column.ACCOUNT] - contact = gajim.contacts.get_first_contact_from_jid(account, + contact = app.contacts.get_first_contact_from_jid(account, jid) self.on_info(widget, contact, account) elif event.get_state() & Gdk.ModifierType.CONTROL_MASK and event.keyval == \ @@ -3846,7 +3846,7 @@ class RosterWindow: if type_ in ('contact', 'agent'): jid = model[path][Column.JID] account = model[path][Column.ACCOUNT] - contact = gajim.contacts.get_first_contact_from_jid(account, + contact = app.contacts.get_first_contact_from_jid(account, jid) self.on_history(widget, contact, account) @@ -3872,10 +3872,10 @@ class RosterWindow: GObject.idle_add(self.disable_rfilter) jid = model[path][Column.JID] resource = None - contact = gajim.contacts.get_contact_with_highest_priority(account, jid) + contact = app.contacts.get_contact_with_highest_priority(account, jid) titer = model.get_iter(path) if contact.is_groupchat(): - first_ev = gajim.events.get_first_event(account, jid) + first_ev = app.events.get_first_event(account, jid) if first_ev and self.open_event(account, jid, first_ev): # We are invited to a GC # open event cares about connecting to it @@ -3885,12 +3885,12 @@ class RosterWindow: return # else - first_ev = gajim.events.get_first_event(account, jid) + first_ev = app.events.get_first_event(account, jid) if not first_ev: # look in other resources - for c in gajim.contacts.get_contacts(account, jid): + for c in app.contacts.get_contacts(account, jid): fjid = c.get_full_jid() - first_ev = gajim.events.get_first_event(account, fjid) + first_ev = app.events.get_first_event(account, fjid) if first_ev: resource = c.resource break @@ -3898,7 +3898,7 @@ class RosterWindow: child_iter = model.iter_children(titer) while not first_ev and child_iter: child_jid = model[child_iter][Column.JID] - first_ev = gajim.events.get_first_event(account, child_jid) + first_ev = app.events.get_first_event(account, child_jid) if first_ev: jid = child_jid else: @@ -3913,21 +3913,21 @@ class RosterWindow: if self.open_event(account, fjid, first_ev): return # else - contact = gajim.contacts.get_contact(account, jid, resource) + contact = app.contacts.get_contact(account, jid, resource) if not contact or isinstance(contact, list): - contact = gajim.contacts.get_contact_with_highest_priority(account, + contact = app.contacts.get_contact_with_highest_priority(account, jid) - if jid == gajim.get_jid_from_account(account): + if jid == app.get_jid_from_account(account): resource = None - gajim.interface.on_open_chat_window(None, contact, account, \ + app.interface.on_open_chat_window(None, contact, account, \ resource=resource, session=session) def on_roster_treeview_row_activated(self, widget, path, col=0): """ When an iter is double clicked: open the first event window """ - if not gajim.single_click: + if not app.single_click: self.on_row_activated(widget, path) def on_roster_treeview_row_expanded(self, widget, titer, path): @@ -3940,7 +3940,7 @@ class RosterWindow: child_iter = model.convert_iter_to_child_iter(titer) if self.regroup: # merged accounts - accounts = list(gajim.connections.keys()) + accounts = list(app.connections.keys()) else: accounts = [model[titer][Column.ACCOUNT]] @@ -3948,18 +3948,18 @@ class RosterWindow: if type_ == 'group': group = model[titer][Column.JID] child_model[child_iter][Column.IMG] = \ - gajim.interface.jabber_state_images['16']['opened'] + app.interface.jabber_state_images['16']['opened'] if self.rfilter_enabled: return for account in accounts: - if group in gajim.groups[account]: # This account has this group - gajim.groups[account][group]['expand'] = True + if group in app.groups[account]: # This account has this group + app.groups[account][group]['expand'] = True if account + group in self.collapsed_rows: self.collapsed_rows.remove(account + group) - for contact in gajim.contacts.iter_contacts(account): + for contact in app.contacts.iter_contacts(account): jid = contact.jid if group in contact.groups and \ - gajim.contacts.is_big_brother(account, jid, accounts) and \ + app.contacts.is_big_brother(account, jid, accounts) and \ account + group + jid not in self.collapsed_rows: titers = self._get_contact_iter(jid, account) for titer in titers: @@ -3971,8 +3971,8 @@ class RosterWindow: self.collapsed_rows.remove(account) self.draw_account(account) # When we expand, groups are collapsed. Restore expand state - for group in gajim.groups[account]: - if gajim.groups[account][group]['expand']: + for group in app.groups[account]: + if app.groups[account][group]['expand']: titer = self._get_group_iter(group, account) if titer: path = model.get_path(titer) @@ -3981,11 +3981,11 @@ class RosterWindow: # Metacontact got toggled, update icon jid = model[titer][Column.JID] account = model[titer][Column.ACCOUNT] - contact = gajim.contacts.get_contact(account, jid) + contact = app.contacts.get_contact(account, jid) for group in contact.groups: if account + group + jid in self.collapsed_rows: self.collapsed_rows.remove(account + group + jid) - family = gajim.contacts.get_metacontacts_family(account, jid) + family = app.contacts.get_metacontacts_family(account, jid) nearby_family = \ self._get_nearby_family_and_big_brother(family, account)[0] # Redraw all brothers to show pending events @@ -4004,20 +4004,20 @@ class RosterWindow: child_iter = model.convert_iter_to_child_iter(titer) if self.regroup: # merged accounts - accounts = list(gajim.connections.keys()) + accounts = list(app.connections.keys()) else: accounts = [model[titer][Column.ACCOUNT]] type_ = model[titer][Column.TYPE] if type_ == 'group': - child_model[child_iter][Column.IMG] = gajim.interface.\ + child_model[child_iter][Column.IMG] = app.interface.\ jabber_state_images['16']['closed'] if self.rfilter_enabled: return group = model[titer][Column.JID] for account in accounts: - if group in gajim.groups[account]: # This account has this group - gajim.groups[account][group]['expand'] = False + if group in app.groups[account]: # This account has this group + app.groups[account][group]['expand'] = False if account + group not in self.collapsed_rows: self.collapsed_rows.append(account + group) elif type_ == 'account': @@ -4029,14 +4029,14 @@ class RosterWindow: # Metacontact got toggled, update icon jid = model[titer][Column.JID] account = model[titer][Column.ACCOUNT] - contact = gajim.contacts.get_contact(account, jid) + contact = app.contacts.get_contact(account, jid) groups = contact.groups if not groups: groups = [_('General')] for group in groups: if account + group + jid not in self.collapsed_rows: self.collapsed_rows.append(account + group + jid) - family = gajim.contacts.get_metacontacts_family(account, jid) + family = app.contacts.get_metacontacts_family(account, jid) nearby_family = \ self._get_nearby_family_and_big_brother(family, account)[0] # Redraw all brothers to show pending events @@ -4107,9 +4107,9 @@ class RosterWindow: def on_service_disco_menuitem_activate(self, widget, account): - server_jid = gajim.config.get_per('accounts', account, 'hostname') - if server_jid in gajim.interface.instances[account]['disco']: - gajim.interface.instances[account]['disco'][server_jid].\ + server_jid = app.config.get_per('accounts', account, 'hostname') + if server_jid in app.interface.instances[account]['disco']: + app.interface.instances[account]['disco'][server_jid].\ window.present() else: try: @@ -4123,7 +4123,7 @@ class RosterWindow: When show offline option is changed: redraw the treeview """ action.set_state(param) - gajim.config.set('showoffline', param.get_boolean()) + app.config.set('showoffline', param.get_boolean()) self.refilter_shown_roster_items() if param.get_boolean(): # We need to filter twice to show groups with no contacts inside @@ -4138,7 +4138,7 @@ class RosterWindow: When show only active contact option is changed: redraw the treeview """ action.set_state(param) - gajim.config.set('show_only_chat_and_online', param.get_boolean()) + app.config.set('show_only_chat_and_online', param.get_boolean()) self.refilter_shown_roster_items() if param.get_boolean(): @@ -4230,8 +4230,8 @@ class RosterWindow: """ if gparamspec and gparamspec.name == 'position': roster_width = pane.get_child1().get_allocation().width - gajim.config.set('roster_width', roster_width) - gajim.config.set('roster_hpaned_position', pane.get_position()) + app.config.set('roster_width', roster_width) + app.config.set('roster_hpaned_position', pane.get_position()) ################################################################################ ### Drag and Drop handling @@ -4260,14 +4260,14 @@ class RosterWindow: if c_dest.show not in ('offline', 'error') and c_dest.supports( NS_ROSTERX): type_ = 'iq' - gajim.connections[account_dest].send_contacts([c_source], + app.connections[account_dest].send_contacts([c_source], c_dest.get_full_jid(), type_=type_) def on_drop_in_contact(self, widget, account_source, c_source, account_dest, c_dest, was_big_brother, context, etime): - if not gajim.connections[account_source].private_storage_supported or \ - not gajim.connections[account_dest].private_storage_supported: + if not app.connections[account_source].private_storage_supported or \ + not app.connections[account_dest].private_storage_supported: dialogs.WarningDialog(_('Metacontacts storage not supported by ' 'your server'), _('Your server does not support storing metacontacts ' @@ -4278,17 +4278,17 @@ class RosterWindow: contacts = 0 if is_checked is not None: # dialog has been shown if is_checked: # user does not want to be asked again - gajim.config.set('confirm_metacontacts', 'no') + app.config.set('confirm_metacontacts', 'no') else: - gajim.config.set('confirm_metacontacts', 'yes') + app.config.set('confirm_metacontacts', 'yes') # We might have dropped on a metacontact. # Remove it and readd later with updated family info - dest_family = gajim.contacts.get_metacontacts_family(account_dest, + dest_family = app.contacts.get_metacontacts_family(account_dest, c_dest.jid) if dest_family: self._remove_metacontact_family(dest_family, account_dest) - source_family = gajim.contacts.get_metacontacts_family( + source_family = app.contacts.get_metacontacts_family( account_source, c_source.jid) if dest_family == source_family: n = contacts = len(dest_family) @@ -4302,7 +4302,7 @@ class RosterWindow: else: self._remove_entity(c_dest, account_dest) - old_family = gajim.contacts.get_metacontacts_family(account_source, + old_family = app.contacts.get_metacontacts_family(account_source, c_source.jid) old_groups = c_source.groups @@ -4331,20 +4331,20 @@ class RosterWindow: _account = data['account'] _jid = data['jid'] - _contact = gajim.contacts.get_first_contact_from_jid(_account, + _contact = app.contacts.get_first_contact_from_jid(_account, _jid) if not _contact: # One of the metacontacts may be not connected. continue _contact.groups = c_dest.groups[:] - gajim.contacts.add_metacontact(account_dest, c_dest.jid, + app.contacts.add_metacontact(account_dest, c_dest.jid, _account, _contact.jid, contacts) - gajim.connections[account_source].update_contact(_contact.jid, + app.connections[account_source].update_contact(_contact.jid, _contact.name, _contact.groups) # Re-add all and update GUI - new_family = gajim.contacts.get_metacontacts_family(account_source, + new_family = app.contacts.get_metacontacts_family(account_source, c_source.jid) brothers = self._add_metacontact_family(new_family, account_source) @@ -4358,11 +4358,11 @@ class RosterWindow: self.draw_account(account_source) context.finish(True, True, etime) - dest_family = gajim.contacts.get_metacontacts_family(account_dest, + dest_family = app.contacts.get_metacontacts_family(account_dest, c_dest.jid) - source_family = gajim.contacts.get_metacontacts_family(account_source, + source_family = app.contacts.get_metacontacts_family(account_source, c_source.jid) - confirm_metacontacts = gajim.config.get('confirm_metacontacts') + confirm_metacontacts = app.config.get('confirm_metacontacts') if confirm_metacontacts == 'no' or dest_family == source_family: merge_contacts() return @@ -4388,14 +4388,14 @@ class RosterWindow: [grp_source]) else: # Normal contact or little brother - family = gajim.contacts.get_metacontacts_family(account, + family = app.contacts.get_metacontacts_family(account, c_source.jid) if family: # Little brother # Remove whole family. Remove us from the family. # Then re-add other family members. self._remove_metacontact_family(family, account) - gajim.contacts.remove_metacontact(account, c_source.jid) + app.contacts.remove_metacontact(account, c_source.jid) for data in family: if account != data['account'] and not self.regroup: continue @@ -4427,7 +4427,7 @@ class RosterWindow: return True def move_group(self, old_name, new_name, account): - for group in list(gajim.groups[account].keys()): + for group in list(app.groups[account].keys()): if group.startswith(old_name): self.rename_group(group, group.replace(old_name, new_name), account) @@ -4462,7 +4462,7 @@ class RosterWindow: if account_dest == 'all': return # nothing can be done, if destination account is offline - if gajim.connections[account_dest].connected < 2: + if app.connections[account_dest].connected < 2: return # A file got dropped on the roster @@ -4471,7 +4471,7 @@ class RosterWindow: return if type_dest != 'contact': return - c_dest = gajim.contacts.get_contact_with_highest_priority( + c_dest = app.contacts.get_contact_with_highest_priority( account_dest, jid_dest) if not c_dest.supports(NS_FILE): return @@ -4493,12 +4493,12 @@ class RosterWindow: dialogs.ErrorDialog(_('Invalid file URI:'), '\n'.join(bad_uris)) return def _on_send_files(account, jid, uris): - c = gajim.contacts.get_contact_with_highest_priority(account, + c = app.contacts.get_contact_with_highest_priority(account, jid) for uri in uris: path = helpers.get_file_path_from_dnd_dropped_uri(uri) if os.path.isfile(path): # is it file? - gajim.interface.instances['file_transfers'].send_file( + app.interface.instances['file_transfers'].send_file( account, c, path) # Popup dialog to confirm sending prim_text = 'Send file?' @@ -4522,7 +4522,7 @@ class RosterWindow: type_source = model[iter_source][Column.TYPE] account_source = model[iter_source][Column.ACCOUNT] - if gajim.config.get_per('accounts', account_source, 'is_zeroconf'): + if app.config.get_per('accounts', account_source, 'is_zeroconf'): return if type_dest == 'self_contact': @@ -4539,7 +4539,7 @@ class RosterWindow: # drop on another account return grp_source = model[iter_source][Column.JID] - delimiter = gajim.connections[account_source].nested_group_delimiter + delimiter = app.connections[account_source].nested_group_delimiter grp_source_list = grp_source.split(delimiter) new_grp = None if type_dest == 'account': @@ -4559,7 +4559,7 @@ class RosterWindow: return # A contact was dropped - if gajim.config.get_per('accounts', account_dest, 'is_zeroconf'): + if app.config.get_per('accounts', account_dest, 'is_zeroconf'): # drop on zeroconf account, adding not possible return @@ -4579,7 +4579,7 @@ class RosterWindow: # see below return jid_source = data - c_source = gajim.contacts.get_contact_with_highest_priority( + c_source = app.contacts.get_contact_with_highest_priority( account_source, jid_source) # Get destination group @@ -4612,9 +4612,9 @@ class RosterWindow: return # Is the contact we drag a meta contact? - accounts = (self.regroup and gajim.contacts.get_accounts()) or \ + accounts = (self.regroup and app.contacts.get_accounts()) or \ account_source - is_big_brother = gajim.contacts.is_big_brother(account_source, + is_big_brother = app.contacts.is_big_brother(account_source, jid_source, accounts) drop_in_middle_of_meta = False @@ -4635,7 +4635,7 @@ class RosterWindow: # Contact drop on another contact, make meta contacts if position == Gtk.TreeViewDropPosition.INTO_OR_AFTER or \ position == Gtk.TreeViewDropPosition.INTO_OR_BEFORE or drop_in_middle_of_meta: - c_dest = gajim.contacts.get_contact_with_highest_priority( + c_dest = app.contacts.get_contact_with_highest_priority( account_dest, jid_dest) if not c_dest: # c_dest is None if jid_dest doesn't belong to account @@ -4648,9 +4648,9 @@ class RosterWindow: c_source, account_dest, c_dest, is_big_brother, context, etime) menu.append(item) - dest_family = gajim.contacts.get_metacontacts_family(account_dest, + dest_family = app.contacts.get_metacontacts_family(account_dest, c_dest.jid) - source_family = gajim.contacts.get_metacontacts_family( + source_family = app.contacts.get_metacontacts_family( account_source, c_source.jid) if dest_family == source_family and dest_family: item = Gtk.MenuItem.new_with_label( @@ -4685,7 +4685,7 @@ class RosterWindow: transport iconset doesn't contain all icons, so we fall back to jabber one """ - transport = gajim.get_transport_name_from_jid(jid) + transport = app.get_transport_name_from_jid(jid) if transport and size in self.transports_state_images: if transport not in self.transports_state_images[size]: # we don't have iconset for this transport loaded yet. Let's do @@ -4694,13 +4694,13 @@ class RosterWindow: if transport in self.transports_state_images[size] and \ icon_name in self.transports_state_images[size][transport]: return self.transports_state_images[size][transport] - return gajim.interface.jabber_state_images[size] + return app.interface.jabber_state_images[size] def make_transport_state_images(self, transport): """ Initialize opened and closed 'transport' iconset dict """ - if not gajim.config.get('use_transports_iconsets'): + if not app.config.get('use_transports_iconsets'): return folder = os.path.join(helpers.get_transport_path(transport), '32x32') @@ -4726,14 +4726,14 @@ class RosterWindow: if model[titer][2] != '': # If it's not change status message iter # eg. if it has show parameter not '' - model[titer][1] = gajim.interface.jabber_state_images['16'][ + model[titer][1] = app.interface.jabber_state_images['16'][ model[titer][2]] titer = model.iter_next(titer) # Update the systray - if gajim.interface.systray_enabled: - gajim.interface.systray.set_img() + if app.interface.systray_enabled: + app.interface.systray.set_img() - for win in gajim.interface.msg_win_mgr.windows(): + for win in app.interface.msg_win_mgr.windows(): for ctrl in win.controls(): ctrl.update_ui() win.redraw_tab(ctrl) @@ -4741,15 +4741,15 @@ class RosterWindow: self.update_status_combobox() def set_account_status_icon(self, account): - status = gajim.connections[account].connected + status = app.connections[account].connected child_iterA = self._get_account_iter(account, self.model) if not child_iterA: return if not self.regroup: - show = gajim.SHOW_LIST[status] + show = app.SHOW_LIST[status] else: # accounts merged show = helpers.get_global_show() - self.model[child_iterA][Column.IMG] = gajim.interface.jabber_state_images[ + self.model[child_iterA][Column.IMG] = app.interface.jabber_state_images[ '16'][show] ################################################################################ @@ -4757,23 +4757,23 @@ class RosterWindow: ################################################################################ def show_title(self): - change_title_allowed = gajim.config.get('change_roster_title') + change_title_allowed = app.config.get('change_roster_title') if not change_title_allowed: return nb_unread = 0 - for account in gajim.connections: + for account in app.connections: # Count events in roster title only if we don't auto open them if not helpers.allow_popup_window(account): - nb_unread += gajim.events.get_nb_events(['chat', 'normal', + nb_unread += app.events.get_nb_events(['chat', 'normal', 'file-request', 'file-error', 'file-completed', 'file-request-error', 'file-send-error', 'file-stopped', 'printed_chat'], account) - if gajim.config.get('one_message_window') == 'always_with_roster': + if app.config.get('one_message_window') == 'always_with_roster': # always_with_roster mode defers to the MessageWindow - if not gajim.interface.msg_win_mgr.one_window_opened(): + if not app.interface.msg_win_mgr.one_window_opened(): # No MessageWindow to defer to self.window.set_title('Gajim') gtkgui_helpers.set_unset_urgency_hint(self.window, nb_unread) @@ -4796,17 +4796,17 @@ class RosterWindow: def change_roster_style(self, option): self.model.foreach(self._change_style, option) - for win in gajim.interface.msg_win_mgr.windows(): + for win in app.interface.msg_win_mgr.windows(): win.repaint_themed_widgets() def repaint_themed_widgets(self): """ Notify windows that contain themed widgets to repaint them """ - for win in gajim.interface.msg_win_mgr.windows(): + for win in app.interface.msg_win_mgr.windows(): win.repaint_themed_widgets() - for account in gajim.connections: - for ctrl in list(gajim.interface.minimized_controls[account].values()): + for account in app.connections: + for ctrl in list(app.interface.minimized_controls[account].values()): ctrl.repaint_themed_widgets() def update_avatar_in_gui(self, jid, account): @@ -4814,7 +4814,7 @@ class RosterWindow: self.draw_avatar(jid, account) # Update chat window - ctrl = gajim.interface.msg_win_mgr.get_control(jid, account) + ctrl = app.interface.msg_win_mgr.get_control(jid, account) if ctrl: ctrl.show_avatar() @@ -4859,9 +4859,9 @@ class RosterWindow: type_ = model[titer][Column.TYPE] except TypeError: return - theme = gajim.config.get('roster_theme') + theme = app.config.get('roster_theme') if type_ == 'account': - color = gajim.config.get_per('themes', theme, 'accounttextcolor') + color = app.config.get_per('themes', theme, 'accounttextcolor') renderer.set_property('foreground', color or None) renderer.set_property('font', gtkgui_helpers.get_theme_font_for_option(theme, 'accountfont')) @@ -4869,7 +4869,7 @@ class RosterWindow: renderer.set_property('width', 3) self._set_account_row_background_color(renderer) elif type_ == 'group': - color = gajim.config.get_per('themes', theme, 'grouptextcolor') + color = app.config.get_per('themes', theme, 'grouptextcolor') renderer.set_property('foreground', color or None) renderer.set_property('font', gtkgui_helpers.get_theme_font_for_option(theme, 'groupfont')) @@ -4888,14 +4888,14 @@ class RosterWindow: account = model[titer][Column.ACCOUNT] color = None if type_ == 'groupchat': - ctrl = gajim.interface.minimized_controls[account].get(jid, + ctrl = app.interface.minimized_controls[account].get(jid, None) if ctrl and ctrl.attention_flag: - color = gajim.config.get_per('themes', theme, + color = app.config.get_per('themes', theme, 'state_muc_directed_msg_color') renderer.set_property('foreground', 'red') if not color: - color = gajim.config.get_per('themes', theme, + color = app.config.get_per('themes', theme, 'contacttextcolor') if color: renderer.set_property('foreground', color) @@ -4953,7 +4953,7 @@ class RosterWindow: # allocate space for the icon only if needed if model[titer][Column.AVATAR_PIXBUF] or \ - gajim.config.get('avatar_position_in_roster') == 'left': + app.config.get('avatar_position_in_roster') == 'left': renderer.set_property('visible', True) if type_: # prevent type_ = None, see http://trac.gajim.org/ticket/2534 @@ -4966,11 +4966,11 @@ class RosterWindow: else: renderer.set_property('visible', False) if model[titer][Column.AVATAR_PIXBUF] == empty_pixbuf and \ - gajim.config.get('avatar_position_in_roster') != 'left': + app.config.get('avatar_position_in_roster') != 'left': renderer.set_property('visible', False) - if gajim.config.get('avatar_position_in_roster') == 'left': - renderer.set_property('width', gajim.config.get( + if app.config.get('avatar_position_in_roster') == 'left': + renderer.set_property('width', app.config.get( 'roster_avatar_width')) renderer.set_property('xalign', 0.5) else: @@ -4995,25 +4995,25 @@ class RosterWindow: renderer.set_property('visible', False) def _set_account_row_background_color(self, renderer): - theme = gajim.config.get('roster_theme') - color = gajim.config.get_per('themes', theme, 'accountbgcolor') + theme = app.config.get('roster_theme') + color = app.config.get_per('themes', theme, 'accountbgcolor') renderer.set_property('cell-background', color or None) def _set_contact_row_background_color(self, renderer, jid, account): - theme = gajim.config.get('roster_theme') - if jid in gajim.newly_added[account]: - renderer.set_property('cell-background', gajim.config.get( + theme = app.config.get('roster_theme') + if jid in app.newly_added[account]: + renderer.set_property('cell-background', app.config.get( 'just_connected_bg_color')) - elif jid in gajim.to_be_removed[account]: - renderer.set_property('cell-background', gajim.config.get( + elif jid in app.to_be_removed[account]: + renderer.set_property('cell-background', app.config.get( 'just_disconnected_bg_color')) else: - color = gajim.config.get_per('themes', theme, 'contactbgcolor') + color = app.config.get_per('themes', theme, 'contactbgcolor') renderer.set_property('cell-background', color or None) def _set_group_row_background_color(self, renderer): - theme = gajim.config.get('roster_theme') - color = gajim.config.get_per('themes', theme, 'groupbgcolor') + theme = app.config.get('roster_theme') + color = app.config.get_per('themes', theme, 'groupbgcolor') renderer.set_property('cell-background', color or None) ################################################################################ @@ -5024,10 +5024,10 @@ class RosterWindow: def build_account_menu(self, account): # we have to create our own set of icons for the menu # using self.jabber_status_images is poopoo - iconset = gajim.config.get('iconset') + iconset = app.config.get('iconset') path = os.path.join(helpers.get_iconset_path(iconset), '16x16') - if not gajim.config.get_per('accounts', account, 'is_zeroconf'): + if not app.config.get_per('accounts', account, 'is_zeroconf'): xml = gtkgui_helpers.get_gtk_builder('account_context_menu.ui') account_context_menu = xml.get_object('account_context_menu') @@ -5050,7 +5050,7 @@ class RosterWindow: uf_show = helpers.get_uf_show(show, use_mnemonic=True) item = Gtk.MenuItem.new_with_mnemonic(uf_show) sub_menu.append(item) - con = gajim.connections[account] + con = app.connections[account] if show == 'invisible' and con.connected > 1 and \ not con.privacy_rules_supported: item.set_sensitive(False) @@ -5064,7 +5064,7 @@ class RosterWindow: sub_menu.append(item) item.connect('activate', self.on_change_status_message_activate, account) - if gajim.connections[account].connected < 2: + if app.connections[account].connected < 2: item.set_sensitive(False) item = Gtk.SeparatorMenuItem.new() @@ -5076,7 +5076,7 @@ class RosterWindow: item.connect('activate', self.change_status, account, 'offline') pep_menuitem = xml.get_object('pep_menuitem') - if gajim.connections[account].pep_supported: + if app.connections[account].pep_supported: pep_submenu = Gtk.Menu() pep_menuitem.set_submenu(pep_submenu) def add_item(label, opt_name, func): @@ -5085,7 +5085,7 @@ class RosterWindow: if not dbus_support.supported: item.set_sensitive(False) else: - activ = gajim.config.get_per('accounts', account, + activ = app.config.get_per('accounts', account, opt_name) item.set_active(activ) item.connect('toggled', func, account) @@ -5107,7 +5107,7 @@ class RosterWindow: else: pep_menuitem.set_sensitive(False) - if not gajim.connections[account].gmail_url: + if not app.connections[account].gmail_url: open_gmail_inbox_menuitem.set_no_show_all(True) open_gmail_inbox_menuitem.hide() else: @@ -5116,15 +5116,15 @@ class RosterWindow: edit_account_menuitem.connect('activate', self.on_edit_account, account) - if gajim.connections[account].roster_supported: + if app.connections[account].roster_supported: add_contact_menuitem.connect('activate', self.on_add_new_contact, account) else: add_contact_menuitem.set_sensitive(False) service_discovery_menuitem.connect('activate', self.on_service_disco_menuitem_activate, account) - hostname = gajim.config.get_per('accounts', account, 'hostname') - contact = gajim.contacts.create_contact(jid=hostname, + hostname = app.config.get_per('accounts', account, 'hostname') + contact = app.contacts.create_contact(jid=hostname, account=account) # Fake contact execute_command_menuitem.connect('activate', self.on_execute_command, contact, account) @@ -5137,7 +5137,7 @@ class RosterWindow: self.add_bookmarks_list(gc_sub_menu, account) # make some items insensitive if account is offline - if gajim.connections[account].connected < 2: + if app.connections[account].connected < 2: for widget in (add_contact_menuitem, service_discovery_menuitem, join_group_chat_menuitem, execute_command_menuitem, pep_menuitem, start_chat_menuitem): @@ -5165,7 +5165,7 @@ class RosterWindow: sub_menu.append(item) item.connect('activate', self.on_change_status_message_activate, account) - if gajim.connections[account].connected < 2: + if app.connections[account].connected < 2: item.set_sensitive(False) uf_show = helpers.get_uf_show('offline', use_mnemonic=True) @@ -5189,10 +5189,10 @@ class RosterWindow: menu = self.build_account_menu(account) else: menu = Gtk.Menu() - iconset = gajim.config.get('iconset') + iconset = app.config.get('iconset') path = os.path.join(helpers.get_iconset_path(iconset), '16x16') accounts = [] # Put accounts in a list to sort them - for account in gajim.connections: + for account in app.connections: accounts.append(account) accounts.sort() for account in accounts: @@ -5222,8 +5222,8 @@ class RosterWindow: show_bookmarked = True group = model[titer][Column.JID] - for jid in gajim.contacts.get_jid_list(account): - contact = gajim.contacts.get_contact_with_highest_priority(account, + for jid in app.contacts.get_jid_list(account): + contact = app.contacts.get_contact_with_highest_priority(account, jid) if group in contact.get_shown_groups(): if contact.show not in ('offline', 'error'): @@ -5280,7 +5280,7 @@ class RosterWindow: send_custom_status_menuitem.set_sensitive(False) status_menuitems = Gtk.Menu() send_custom_status_menuitem.set_submenu(status_menuitems) - iconset = gajim.config.get('iconset') + iconset = app.config.get('iconset') path = os.path.join(helpers.get_iconset_path(iconset), '16x16') for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'): status_menuitem = Gtk.MenuItem.new_with_label( @@ -5291,11 +5291,11 @@ class RosterWindow: menu.append(send_custom_status_menuitem) # there is no singlemessage and custom status for zeroconf - if gajim.config.get_per('accounts', account, 'is_zeroconf'): + if app.config.get_per('accounts', account, 'is_zeroconf'): send_custom_status_menuitem.set_sensitive(False) send_group_message_item.set_sensitive(False) - if gajim.connections[account].connected < 2: + if app.connections[account].connected < 2: send_group_message_item.set_sensitive(False) invite_menuitem.set_sensitive(False) send_custom_status_menuitem.set_sensitive(False) @@ -5313,14 +5313,14 @@ class RosterWindow: # Block group is_blocked = False if self.regroup: - for g_account in gajim.connections: + for g_account in app.connections: if helpers.group_is_blocked(g_account, group): is_blocked = True else: if helpers.group_is_blocked(account, group): is_blocked = True - if is_blocked and gajim.connections[account].\ + if is_blocked and app.connections[account].\ privacy_rules_supported: unblock_menuitem = Gtk.MenuItem.new_with_mnemonic(_('_Unblock')) unblock_menuitem.connect('activate', self.on_unblock, list_, @@ -5330,7 +5330,7 @@ class RosterWindow: block_menuitem = Gtk.MenuItem.new_with_mnemonic(_('_Block')) block_menuitem.connect('activate', self.on_block, list_, group) menu.append(block_menuitem) - if not gajim.connections[account].privacy_rules_supported: + if not app.connections[account].privacy_rules_supported: block_menuitem.set_sensitive(False) # Remove group @@ -5340,7 +5340,7 @@ class RosterWindow: group, account) # unsensitive if account is not connected - if gajim.connections[account].connected < 2: + if app.connections[account].connected < 2: rename_item.set_sensitive(False) # General group cannot be changed @@ -5362,7 +5362,7 @@ class RosterWindow: model = self.modelfilter jid = model[titer][Column.JID] account = model[titer][Column.ACCOUNT] - contact = gajim.contacts.get_contact_with_highest_priority(account, jid) + contact = app.contacts.get_contact_with_highest_priority(account, jid) menu = gui_menu_builder.get_contact_menu(contact, account) event_button = gtkgui_helpers.get_possible_button_event(event) menu.attach_to_widget(self.tree, None) @@ -5380,11 +5380,11 @@ class RosterWindow: for titer in iters: jid = model[titer][Column.JID] account = model[titer][Column.ACCOUNT] - if gajim.connections[account].connected < 2: + if app.connections[account].connected < 2: one_account_offline = True - if not gajim.connections[account].privacy_rules_supported: + if not app.connections[account].privacy_rules_supported: privacy_rules_supported = False - contact = gajim.contacts.get_contact_with_highest_priority(account, + contact = app.contacts.get_contact_with_highest_priority(account, jid) if not helpers.jid_is_blocked(account, jid): is_blocked = False @@ -5471,7 +5471,7 @@ class RosterWindow: jid = model[titer][Column.JID] path = model.get_path(titer) account = model[titer][Column.ACCOUNT] - contact = gajim.contacts.get_contact_with_highest_priority(account, jid) + contact = app.contacts.get_contact_with_highest_priority(account, jid) menu = gui_menu_builder.get_transport_menu(contact, account) event_button = gtkgui_helpers.get_possible_button_event(event) menu.attach_to_widget(self.tree, None) @@ -5482,17 +5482,17 @@ class RosterWindow: jid = model[titer][Column.JID] account = model[titer][Column.ACCOUNT] - contact = gajim.contacts.get_contact_with_highest_priority(account, jid) + contact = app.contacts.get_contact_with_highest_priority(account, jid) menu = Gtk.Menu() - if jid in gajim.interface.minimized_controls[account]: + if jid in app.interface.minimized_controls[account]: maximize_menuitem = Gtk.MenuItem.new_with_mnemonic(_( '_Maximize')) maximize_menuitem.connect('activate', self.on_groupchat_maximized, \ jid, account) menu.append(maximize_menuitem) - if not gajim.gc_connected[account].get(jid, False): + if not app.gc_connected[account].get(jid, False): connect_menuitem = Gtk.MenuItem.new_with_mnemonic(_( '_Reconnect')) connect_menuitem.connect('activate', self.on_reconnect, jid, @@ -5539,20 +5539,20 @@ class RosterWindow: xml_console_menuitem.connect('activate', self.on_xml_console_menuitem_activate, account) - if gajim.connections[account]: - if gajim.connections[account].privacy_rules_supported: + if app.connections[account]: + if app.connections[account].privacy_rules_supported: privacy_lists_menuitem.connect('activate', self.on_privacy_lists_menuitem_activate, account) else: privacy_lists_menuitem.set_sensitive(False) - if gajim.connections[account].archiving_313_supported: + if app.connections[account].archiving_313_supported: archiving_preferences_menuitem.connect( 'activate', self.on_archiving_preferences_menuitem_activate, account) else: archiving_preferences_menuitem.set_sensitive(False) - if gajim.connections[account].is_zeroconf: + if app.connections[account].is_zeroconf: administrator_menuitem.set_sensitive(False) send_server_message_menuitem.set_sensitive(False) set_motd_menuitem.set_sensitive(False) @@ -5597,11 +5597,11 @@ class RosterWindow: gc_sub_menu.append(item) # User has at least one bookmark. - if gajim.connections[account].bookmarks: + if app.connections[account].bookmarks: item = Gtk.SeparatorMenuItem.new() gc_sub_menu.append(item) - for bookmark in gajim.connections[account].bookmarks: + for bookmark in app.connections[account].bookmarks: name = bookmark['name'] if not name: # No name was given for this bookmark. @@ -5664,8 +5664,8 @@ class RosterWindow: activated """ # find a connected account: - for account in gajim.connections: - if gajim.account_is_connected(account): + for account in app.connections: + if app.account_is_connected(account): break self.on_join_gc_activate(None, account) return True @@ -5701,7 +5701,7 @@ class RosterWindow: connected_contacts = [] if typ in ('contact', 'self_contact'): - contacts = gajim.contacts.get_contacts(account, jid) + contacts = app.contacts.get_contacts(account, jid) for c in contacts: if c.show not in ('offline', 'error'): @@ -5710,7 +5710,7 @@ class RosterWindow: # no connected contacts, show the offline one connected_contacts = contacts elif typ == 'groupchat': - connected_contacts = gajim.contacts.get_contacts(account, jid) + connected_contacts = app.contacts.get_contacts(account, jid) elif typ != 'account': return False @@ -5739,7 +5739,7 @@ class RosterWindow: action = Gio.SimpleAction.new_stateful( "show-offline", None, - GLib.Variant.new_boolean(gajim.config.get('showoffline'))) + GLib.Variant.new_boolean(app.config.get('showoffline'))) action.connect("change-state", self.on_show_offline_contacts_action) self.window.add_action(action) @@ -5747,14 +5747,14 @@ class RosterWindow: action = Gio.SimpleAction.new_stateful( "show-active", None, GLib.Variant.new_boolean( - gajim.config.get('show_only_chat_and_online'))) + app.config.get('show_only_chat_and_online'))) action.connect("change-state", self.on_show_active_contacts_action) self.window.add_action(action) action = Gio.SimpleAction.new_stateful( "show-transports", None, - GLib.Variant.new_boolean(gajim.config.get('show_transports_group'))) + GLib.Variant.new_boolean(app.config.get('show_transports_group'))) action.connect("change-state", self.on_show_transports_action) self.window.add_action(action) @@ -5762,8 +5762,8 @@ class RosterWindow: ### ################################################################################ - def __init__(self, app: Gtk.Application): - self.application = app + def __init__(self, application: Gtk.Application): + self.application = application self.filtering = False self.starting = False self.starting_filtering = False @@ -5779,14 +5779,14 @@ class RosterWindow: GdkPixbuf.Pixbuf, GdkPixbuf.Pixbuf] self.xml = gtkgui_helpers.get_gtk_builder('roster_window.ui') self.window = self.xml.get_object('roster_window') - app.add_window(self.window) + application.add_window(self.window) self.add_actions() self.hpaned = self.xml.get_object('roster_hpaned') - gajim.interface.msg_win_mgr = MessageWindowMgr(self.window, self.hpaned) - gajim.interface.msg_win_mgr.connect('window-delete', + app.interface.msg_win_mgr = MessageWindowMgr(self.window, self.hpaned) + app.interface.msg_win_mgr.connect('window-delete', self.on_message_window_delete) self.advanced_menus = [] # We keep them to destroy them - if gajim.config.get('roster_window_skip_taskbar'): + if app.config.get('roster_window_skip_taskbar'): self.window.set_property('skip-taskbar-hint', True) self.tree = self.xml.get_object('roster_treeview') sel = self.tree.get_selection() @@ -5812,18 +5812,18 @@ class RosterWindow: #FIXME: When list_accel_closures will be wrapped in pygtk # no need of this variable self.have_new_chat_accel = False # Is the "Ctrl+N" shown ? - self.regroup = gajim.config.get('mergeaccounts') + self.regroup = app.config.get('mergeaccounts') self.clicked_path = None # Used remember on wich row we clicked - if len(gajim.connections) < 2: + if len(app.connections) < 2: # Do not merge accounts if only one exists self.regroup = False gtkgui_helpers.resize_window(self.window, - gajim.config.get('roster_width'), - gajim.config.get('roster_height')) - if gajim.config.get('save-roster-position'): + app.config.get('roster_width'), + app.config.get('roster_height')) + if app.config.get('save-roster-position'): gtkgui_helpers.move_window(self.window, - gajim.config.get('roster_x-position'), - gajim.config.get('roster_y-position')) + app.config.get('roster_x-position'), + app.config.get('roster_y-position')) self.popups_notification_height = 0 self.popup_notification_windows = [] @@ -5831,7 +5831,7 @@ class RosterWindow: # Remove contact from roster when last event opened # { (contact, account): { backend: boolean } self.contacts_to_be_removed = {} - gajim.events.event_removed_subscribe(self.on_event_removed) + app.events.event_removed_subscribe(self.on_event_removed) # when this value become 0 we quit main application. If it's more than 0 # it means we are waiting for this number of accounts to disconnect @@ -5871,7 +5871,7 @@ class RosterWindow: for show in ('online', 'chat', 'away', 'xa', 'dnd', 'invisible'): uf_show = helpers.get_uf_show(show) liststore.append([uf_show, - gajim.interface.jabber_state_images['16'][show], show, True]) + app.interface.jabber_state_images['16'][show], show, True]) # Add a Separator (self._iter_is_separator() checks on string SEPARATOR) liststore.append(['SEPARATOR', None, '', True]) @@ -5885,7 +5885,7 @@ class RosterWindow: liststore.append(['SEPARATOR', None, '', True]) uf_show = helpers.get_uf_show('offline') - liststore.append([uf_show, gajim.interface.jabber_state_images['16'][ + liststore.append([uf_show, app.interface.jabber_state_images['16'][ 'offline'], 'offline', True]) status_combobox_items = ['online', 'chat', 'away', 'xa', 'dnd', @@ -5903,10 +5903,10 @@ class RosterWindow: self.previous_status_combobox_active = number_of_menuitem # Enable/Disable checkboxes at start - if gajim.config.get('showoffline'): + if app.config.get('showoffline'): self.window.lookup_action('show-active').set_enabled(False) - if gajim.config.get('show_only_chat_and_online'): + if app.config.get('show_only_chat_and_online'): self.window.lookup_action('show-offline').set_enabled(False) if self.hpaned.get_child2() is None: @@ -5932,7 +5932,7 @@ class RosterWindow: False, 'pixbuf', Column.AVATAR_PIXBUF, self._fill_avatar_pixbuf_renderer, None)) - if gajim.config.get('avatar_position_in_roster') == 'left': + if app.config.get('avatar_position_in_roster') == 'left': add_avatar_renderer() self.renderers_list += ( @@ -5958,7 +5958,7 @@ class RosterWindow: 'pixbuf', Column.LOCATION_PIXBUF, self._fill_pep_pixbuf_renderer, Column.LOCATION_PIXBUF)) - if gajim.config.get('avatar_position_in_roster') == 'right': + if app.config.get('avatar_position_in_roster') == 'right': add_avatar_renderer() self.renderers_list.append(('padlock', Gtk.CellRendererPixbuf(), False, @@ -5997,7 +5997,7 @@ class RosterWindow: self.xml.connect_signals(self) self.combobox_callback_active = True - self.collapsed_rows = gajim.config.get('collapsed_rows').split('\t') + self.collapsed_rows = app.config.get('collapsed_rows').split('\t') self.tree.set_has_tooltip(True) self.tree.set_tooltip_window(tooltips.RosterTooltip(self.window)) self.current_tooltip = None @@ -6006,32 +6006,32 @@ class RosterWindow: self._toggeling_row = False self.setup_and_draw_roster() - if gajim.config.get('show_roster_on_startup') == 'always': + if app.config.get('show_roster_on_startup') == 'always': self.window.show_all() - elif gajim.config.get('show_roster_on_startup') == 'never': - if gajim.config.get('trayicon') != 'always': + elif app.config.get('show_roster_on_startup') == 'never': + if app.config.get('trayicon') != 'always': # Without trayicon, user should see the roster! self.window.show_all() - gajim.config.set('last_roster_visible', True) + app.config.set('last_roster_visible', True) else: - if gajim.config.get('last_roster_visible') or \ - gajim.config.get('trayicon') != 'always': + if app.config.get('last_roster_visible') or \ + app.config.get('trayicon') != 'always': self.window.show_all() - if not gajim.config.get_per('accounts') or \ - gajim.config.get_per('accounts') == ['Local'] and not \ - gajim.config.get_per('accounts', 'Local', 'active'): + if not app.config.get_per('accounts') or \ + app.config.get_per('accounts') == ['Local'] and not \ + app.config.get_per('accounts', 'Local', 'active'): # if we have no account configured or only Local account but not enabled def _open_wizard(): - gajim.interface.instances['account_creation_wizard'] = \ + app.interface.instances['account_creation_wizard'] = \ config.AccountCreationWizardWindow() # Open wizard only after roster is created, so we can make it # transient for the roster window GLib.idle_add(_open_wizard) - if not gajim.ZEROCONF_ACC_NAME in gajim.config.get_per('accounts'): + if not app.ZEROCONF_ACC_NAME in app.config.get_per('accounts'): # Create zeroconf in config file from gajim.common.zeroconf import connection_zeroconf - connection_zeroconf.ConnectionZeroconf(gajim.ZEROCONF_ACC_NAME) + connection_zeroconf.ConnectionZeroconf(app.ZEROCONF_ACC_NAME) # Setting CTRL+J to be the shortcut for bringing up the dialog to join a # conference. @@ -6058,33 +6058,33 @@ class RosterWindow: self.rfilter_entry.connect('key-press-event', self.on_rfilter_entry_key_press_event) - gajim.ged.register_event_handler('presence-received', ged.GUI1, + app.ged.register_event_handler('presence-received', ged.GUI1, self._nec_presence_received) # presence has to be fully handled so that contact is added to occupant # list before roster can be correctly updated - gajim.ged.register_event_handler('gc-presence-received', ged.GUI2, + app.ged.register_event_handler('gc-presence-received', ged.GUI2, self._nec_gc_presence_received) - gajim.ged.register_event_handler('roster-received', ged.GUI1, + app.ged.register_event_handler('roster-received', ged.GUI1, self._nec_roster_received) - gajim.ged.register_event_handler('anonymous-auth', ged.GUI1, + app.ged.register_event_handler('anonymous-auth', ged.GUI1, self._nec_anonymous_auth) - gajim.ged.register_event_handler('our-show', ged.GUI1, + app.ged.register_event_handler('our-show', ged.GUI1, self._nec_our_show) - gajim.ged.register_event_handler('connection-type', ged.GUI1, + app.ged.register_event_handler('connection-type', ged.GUI1, self._nec_connection_type) - gajim.ged.register_event_handler('agent-removed', ged.GUI1, + app.ged.register_event_handler('agent-removed', ged.GUI1, self._nec_agent_removed) - gajim.ged.register_event_handler('pep-received', ged.GUI1, + app.ged.register_event_handler('pep-received', ged.GUI1, self._nec_pep_received) - gajim.ged.register_event_handler('vcard-received', ged.GUI1, + app.ged.register_event_handler('vcard-received', ged.GUI1, self._nec_vcard_received) - gajim.ged.register_event_handler('gc-subject-received', ged.GUI1, + app.ged.register_event_handler('gc-subject-received', ged.GUI1, self._nec_gc_subject_received) - gajim.ged.register_event_handler('metacontacts-received', ged.GUI2, + app.ged.register_event_handler('metacontacts-received', ged.GUI2, self._nec_metacontacts_received) - gajim.ged.register_event_handler('signed-in', ged.GUI1, + app.ged.register_event_handler('signed-in', ged.GUI1, self._nec_signed_in) - gajim.ged.register_event_handler('decrypted-message-received', ged.GUI2, + app.ged.register_event_handler('decrypted-message-received', ged.GUI2, self._nec_decrypted_message_received) - gajim.ged.register_event_handler('blocking', ged.GUI1, + app.ged.register_event_handler('blocking', ged.GUI1, self._nec_blocking) diff --git a/gajim/search_window.py b/gajim/search_window.py index df8551ea4..cfdd79b8e 100644 --- a/gajim/search_window.py +++ b/gajim/search_window.py @@ -23,7 +23,7 @@ from gi.repository import GLib from gi.repository import Gtk from gi.repository import Gdk -from gajim.common import gajim +from gajim.common import app from gajim.common import dataforms from gajim.common import ged @@ -62,13 +62,13 @@ class SearchWindow: # Is there a jid column in results ? if -1: no, else column number self.jid_column = -1 - gajim.ged.register_event_handler('search-form-received', ged.GUI1, + app.ged.register_event_handler('search-form-received', ged.GUI1, self._nec_search_form_received) - gajim.ged.register_event_handler('search-result-received', ged.GUI1, + app.ged.register_event_handler('search-result-received', ged.GUI1, self._nec_search_result_received) def request_form(self): - gajim.connections[self.account].request_search_fields(self.jid) + app.connections[self.account].request_search_fields(self.jid) def pulse_callback(self): self.progressbar.pulse() @@ -81,10 +81,10 @@ class SearchWindow: def on_search_window_destroy(self, widget): if self.pulse_id: GLib.source_remove(self.pulse_id) - del gajim.interface.instances[self.account]['search'][self.jid] - gajim.ged.remove_event_handler('search-form-received', ged.GUI1, + del app.interface.instances[self.account]['search'][self.jid] + app.ged.remove_event_handler('search-form-received', ged.GUI1, self._nec_search_form_received) - gajim.ged.remove_event_handler('search-result-received', ged.GUI1, + app.ged.remove_event_handler('search-result-received', ged.GUI1, self._nec_search_result_received) def on_close_button_clicked(self, button): @@ -93,13 +93,13 @@ class SearchWindow: def on_search_button_clicked(self, button): if self.is_form: self.data_form_widget.data_form.type_ = 'submit' - gajim.connections[self.account].send_search_form(self.jid, + app.connections[self.account].send_search_form(self.jid, self.data_form_widget.data_form.get_purged(), True) else: infos = self.data_form_widget.get_infos() if 'instructions' in infos: del infos['instructions'] - gajim.connections[self.account].send_search_form(self.jid, infos, + app.connections[self.account].send_search_form(self.jid, infos, False) self.search_vbox.remove(self.data_form_widget) @@ -122,11 +122,11 @@ class SearchWindow: if not iter_: return jid = model[iter_][self.jid_column] - if jid in gajim.interface.instances[self.account]['infos']: - gajim.interface.instances[self.account]['infos'][jid].window.present() + if jid in app.interface.instances[self.account]['infos']: + app.interface.instances[self.account]['infos'][jid].window.present() else: - contact = gajim.contacts.create_contact(jid=jid, account=self.account) - gajim.interface.instances[self.account]['infos'][jid] = \ + contact = app.contacts.create_contact(jid=jid, account=self.account) + app.interface.instances[self.account]['infos'][jid] = \ vcard.VcardWindow(contact, self.account) def _nec_search_form_received(self, obj): diff --git a/gajim/server_info.py b/gajim/server_info.py index 7facde671..48cc8c9a3 100644 --- a/gajim/server_info.py +++ b/gajim/server_info.py @@ -22,7 +22,7 @@ from collections import namedtuple import nbxmpp from gi.repository import Gtk -from gajim.common import gajim +from gajim.common import app from gajim.common import ged from gajim.gtkgui_helpers import get_icon_pixmap, Color @@ -32,7 +32,7 @@ class ServerInfoDialog(Gtk.Dialog): super().__init__(_('Server Info'), None, flags) self.account = account - self.set_transient_for(gajim.interface.roster.window) + self.set_transient_for(app.interface.roster.window) self.set_resizable(False) grid = Gtk.Grid() @@ -58,17 +58,17 @@ class ServerInfoDialog(Gtk.Dialog): self.connect('response', self.on_response) self.connect('destroy', self.on_destroy) - gajim.ged.register_event_handler('version-result-received', + app.ged.register_event_handler('version-result-received', ged.CORE, self._nec_version_result_received) - gajim.ged.register_event_handler('agent-info-received', + app.ged.register_event_handler('agent-info-received', ged.GUI1, self._nec_agent_info_received) self.version = '' - self.hostname = gajim.get_hostname_from_account(account) - gajim.connections[account].request_os_info(self.hostname, None) + self.hostname = app.get_hostname_from_account(account) + app.connections[account].request_os_info(self.hostname, None) for feature in self.get_features(): self.add_feature(feature) @@ -111,7 +111,7 @@ class ServerInfoDialog(Gtk.Dialog): item.get_parent().set_tooltip_text(feature.tooltip) def get_features(self): - con = gajim.connections[self.account] + con = app.connections[self.account] Feature = namedtuple('Feature', ['name', 'enabled', 'tooltip']) return [ @@ -139,12 +139,12 @@ class ServerInfoDialog(Gtk.Dialog): self.destroy() def on_destroy(self, *args): - del gajim.interface.instances[self.account]['server_info'] - gajim.ged.remove_event_handler('version-result-received', + del app.interface.instances[self.account]['server_info'] + app.ged.remove_event_handler('version-result-received', ged.CORE, self._nec_version_result_received) - gajim.ged.remove_event_handler('agent-info-received', + app.ged.remove_event_handler('agent-info-received', ged.GUI1, self._nec_agent_info_received) diff --git a/gajim/session.py b/gajim/session.py index 42ac5c705..5a44fc260 100644 --- a/gajim/session.py +++ b/gajim/session.py @@ -27,7 +27,7 @@ from gajim.common import helpers from gajim.common import events from gajim.common import exceptions -from gajim.common import gajim +from gajim.common import app from gajim.common import stanza_session from gajim.common import contacts from gajim.common import ged @@ -46,7 +46,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): def __init__(self, conn, jid, thread_id, type_='chat'): stanza_session.EncryptedStanzaSession.__init__(self, conn, jid, thread_id, type_='chat') - gajim.ged.register_event_handler('decrypted-message-received', ged.GUI1, + app.ged.register_event_handler('decrypted-message-received', ged.GUI1, self._nec_decrypted_message_received) self.control = None @@ -69,10 +69,10 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): """ if obj.session != self: return - contact = gajim.contacts.get_contact(self.conn.name, obj.jid, + contact = app.contacts.get_contact(self.conn.name, obj.jid, obj.resource) if not contact: - contact = gajim.contacts.get_gc_contact(self.conn.name, obj.jid, + contact = app.contacts.get_gc_contact(self.conn.name, obj.jid, obj.resource) if self.resource != obj.resource: self.resource = obj.resource @@ -97,7 +97,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): if obj.forwarded and obj.sent: log_type = KindConstant.SINGLE_MSG_SENT - treat_as = gajim.config.get('treat_incoming_messages') + treat_as = app.config.get('treat_incoming_messages') if treat_as: obj.mtype = treat_as pm = False @@ -107,7 +107,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): obj.mtype = 'pm' if self.is_loggable() and obj.msgtxt: - if obj.xhtml and gajim.config.get('log_xhtml_messages'): + if obj.xhtml and app.config.get('log_xhtml_messages'): msg_to_log = obj.xhtml else: msg_to_log = obj.msgtxt @@ -116,7 +116,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): if not pm: jid = obj.jid - obj.msg_log_id = gajim.logger.insert_into_logs( + obj.msg_log_id = app.logger.insert_into_logs( jid, obj.timestamp, log_type, message=msg_to_log, subject=obj.subject, @@ -131,7 +131,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): contact.chatstate = obj.chatstate if contact.our_chatstate == 'ask': # we were jep85 disco? contact.our_chatstate = 'active' # no more - gajim.nec.push_incoming_event(ChatstateReceivedEvent(None, + app.nec.push_incoming_event(ChatstateReceivedEvent(None, conn=obj.conn, msg_obj=obj)) elif contact.chatstate != 'active': # got no valid jep85 answer, peer does not support it @@ -146,12 +146,12 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): if not obj.msgtxt: # empty message text return True - if gajim.config.get_per('accounts', self.conn.name, - 'ignore_unknown_contacts') and not gajim.contacts.get_contacts( + if app.config.get_per('accounts', self.conn.name, + 'ignore_unknown_contacts') and not app.contacts.get_contacts( self.conn.name, obj.jid) and not pm: return True - highest_contact = gajim.contacts.get_contact_with_highest_priority( + highest_contact = app.contacts.get_contact_with_highest_priority( self.conn.name, obj.jid) # does this resource have the highest priority of any available? @@ -160,7 +160,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): 'offline' if not self.control: - ctrl = gajim.interface.msg_win_mgr.search_control(obj.jid, + ctrl = app.interface.msg_win_mgr.search_control(obj.jid, obj.conn.name, obj.resource) if ctrl: self.control = ctrl @@ -174,8 +174,8 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): if not pm: self.roster_message2(obj) - if gajim.interface.remote_ctrl: - gajim.interface.remote_ctrl.raise_signal('NewMessage', ( + if app.interface.remote_ctrl: + app.interface.remote_ctrl.raise_signal('NewMessage', ( self.conn.name, [obj.fjid, obj.msgtxt, obj.timestamp, obj.encrypted, obj.mtype, obj.subject, obj.chatstate, obj.msg_log_id, obj.user_nick, obj.xhtml, obj.form_node])) @@ -193,22 +193,22 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): # Try to catch the contact with correct resource if resource: fjid = jid + '/' + resource - contact = gajim.contacts.get_contact(obj.conn.name, jid, resource) + contact = app.contacts.get_contact(obj.conn.name, jid, resource) - highest_contact = gajim.contacts.get_contact_with_highest_priority( + highest_contact = app.contacts.get_contact_with_highest_priority( obj.conn.name, jid) if not contact: # If there is another resource, it may be a message from an # invisible resource - lcontact = gajim.contacts.get_contacts(obj.conn.name, jid) + lcontact = app.contacts.get_contacts(obj.conn.name, jid) if (len(lcontact) > 1 or (lcontact and lcontact[0].resource and \ lcontact[0].show != 'offline')) and jid.find('@') > 0: - contact = gajim.contacts.copy_contact(highest_contact) + contact = app.contacts.copy_contact(highest_contact) contact.resource = resource contact.priority = 0 contact.show = 'offline' contact.status = '' - gajim.contacts.add_contact(obj.conn.name, contact) + app.contacts.add_contact(obj.conn.name, contact) else: # Default to highest prio @@ -217,11 +217,11 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): if not contact: # contact is not in roster - contact = gajim.interface.roster.add_to_not_in_the_roster( + contact = app.interface.roster.add_to_not_in_the_roster( obj.conn.name, jid, obj.user_nick) if not self.control: - ctrl = gajim.interface.msg_win_mgr.search_control(obj.jid, + ctrl = app.interface.msg_win_mgr.search_control(obj.jid, obj.conn.name, obj.resource) if ctrl: self.control = ctrl @@ -247,7 +247,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): # Its a Carbon Copied Message we sent obj.show_in_roster = False obj.show_in_systray = False - gajim.events.remove_events(self.conn.name, fjid, types=['chat']) + app.events.remove_events(self.conn.name, fjid, types=['chat']) do_event = False else: # Everything else @@ -269,7 +269,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): show_in_roster=obj.show_in_roster, show_in_systray=obj.show_in_systray) - gajim.events.add_event(self.conn.name, fjid, event) + app.events.add_event(self.conn.name, fjid, event) def roster_message(self, jid, msg, tim, encrypted=False, msg_type='', subject=None, resource='', msg_log_id=None, user_nick='', xhtml=None, @@ -286,24 +286,24 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): # Try to catch the contact with correct resource if resource: fjid = jid + '/' + resource - contact = gajim.contacts.get_contact(self.conn.name, jid, resource) + contact = app.contacts.get_contact(self.conn.name, jid, resource) - highest_contact = gajim.contacts.get_contact_with_highest_priority( + highest_contact = app.contacts.get_contact_with_highest_priority( self.conn.name, jid) if not contact: # If there is another resource, it may be a message from an invisible # resource - lcontact = gajim.contacts.get_contacts(self.conn.name, jid) + lcontact = app.contacts.get_contacts(self.conn.name, jid) if (len(lcontact) > 1 or (lcontact and lcontact[0].resource and \ lcontact[0].show != 'offline')) and jid.find('@') > 0: - contact = gajim.contacts.copy_contact(highest_contact) + contact = app.contacts.copy_contact(highest_contact) contact.resource = resource if resource: fjid = jid + '/' + resource contact.priority = 0 contact.show = 'offline' contact.status = '' - gajim.contacts.add_contact(self.conn.name, contact) + app.contacts.add_contact(self.conn.name, contact) else: # Default to highest prio @@ -312,11 +312,11 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): if not contact: # contact is not in roster - contact = gajim.interface.roster.add_to_not_in_the_roster( + contact = app.interface.roster.add_to_not_in_the_roster( self.conn.name, jid, user_nick) if not self.control: - ctrl = gajim.interface.msg_win_mgr.get_control(fjid, self.conn.name) + ctrl = app.interface.msg_win_mgr.get_control(fjid, self.conn.name) if ctrl: self.control = ctrl self.control.set_session(self) @@ -324,7 +324,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): fjid = jid # Do we have a queue? - no_queue = len(gajim.events.get_events(self.conn.name, fjid)) == 0 + no_queue = len(app.events.get_events(self.conn.name, fjid)) == 0 popup = helpers.allow_popup_window(self.conn.name) @@ -346,7 +346,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): additional_data=additional_data) if msg_log_id: - gajim.logger.set_read_messages([msg_log_id]) + app.logger.set_read_messages([msg_log_id]) return @@ -369,30 +369,30 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): show_in_roster=show_in_roster, show_in_systray=show_in_systray, additional_data=additional_data) - gajim.events.add_event(self.conn.name, fjid, event) + app.events.add_event(self.conn.name, fjid, event) if popup: if not self.control: - self.control = gajim.interface.new_chat(contact, + self.control = app.interface.new_chat(contact, self.conn.name, session=self) - if len(gajim.events.get_events(self.conn.name, fjid)): + if len(app.events.get_events(self.conn.name, fjid)): self.control.read_queue() else: if no_queue: # We didn't have a queue: we change icons - gajim.interface.roster.draw_contact(jid, self.conn.name) + app.interface.roster.draw_contact(jid, self.conn.name) - gajim.interface.roster.show_title() # we show the * or [n] + app.interface.roster.show_title() # we show the * or [n] # Select the big brother contact in roster, it's visible because it has # events. - family = gajim.contacts.get_metacontacts_family(self.conn.name, jid) + family = app.contacts.get_metacontacts_family(self.conn.name, jid) if family: nearby_family, bb_jid, bb_account = \ - gajim.contacts.get_nearby_family_and_big_brother(family, + app.contacts.get_nearby_family_and_big_brother(family, self.conn.name) else: bb_jid, bb_account = jid, self.conn.name - gajim.interface.roster.select_contact(bb_jid, bb_account) + app.interface.roster.select_contact(bb_jid, bb_account) # ---- ESessions stuff --- @@ -469,13 +469,13 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): dialog.destroy() if is_checked: - allow_no_log_for = gajim.config.get_per( + allow_no_log_for = app.config.get_per( 'accounts', self.conn.name, 'allow_no_log_for').split() jid = str(self.jid) if jid not in allow_no_log_for: allow_no_log_for.append(jid) - gajim.config.set_per('accounts', self.conn.name, + app.config.set_per('accounts', self.conn.name, 'allow_no_log_for', ' '.join(allow_no_log_for)) negotiated.update(ask_user) @@ -489,7 +489,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): self.reject_negotiation() dialog.destroy() - allow_no_log_for = gajim.config.get_per('accounts', + allow_no_log_for = app.config.get_per('accounts', self.conn.name, 'allow_no_log_for').split() if str(self.jid) in allow_no_log_for: dialog = None @@ -552,17 +552,17 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): # around to test my test suite. if form.getType() == 'form': if not self.control: - jid, resource = gajim.get_room_and_nick_from_fjid(str(self.jid)) + jid, resource = app.get_room_and_nick_from_fjid(str(self.jid)) account = self.conn.name - contact = gajim.contacts.get_contact(account, str(self.jid), + contact = app.contacts.get_contact(account, str(self.jid), resource) if not contact: - contact = gajim.contacts.create_contact(jid=jid, account=account, + contact = app.contacts.create_contact(jid=jid, account=account, resource=resource, show=self.conn.get_status()) - gajim.interface.new_chat(contact, account, resource=resource, + app.interface.new_chat(contact, account, resource=resource, session=self) negotiation.FeatureNegotiationWindow(account, str(self.jid), self, diff --git a/gajim/statusicon.py b/gajim/statusicon.py index ea48ad2fc..50a745d95 100644 --- a/gajim/statusicon.py +++ b/gajim/statusicon.py @@ -32,7 +32,7 @@ from gajim import config from gajim import tooltips from gajim import gtkgui_helpers -from gajim.common import gajim +from gajim.common import app from gajim.common import helpers class StatusIcon: @@ -58,15 +58,15 @@ class StatusIcon: """ Register listeners to the events class """ - gajim.events.event_added_subscribe(self.on_event_added) - gajim.events.event_removed_subscribe(self.on_event_removed) + app.events.event_added_subscribe(self.on_event_added) + app.events.event_removed_subscribe(self.on_event_removed) def unsubscribe_events(self): """ Unregister listeners to the events class """ - gajim.events.event_added_unsubscribe(self.on_event_added) - gajim.events.event_removed_unsubscribe(self.on_event_removed) + app.events.event_added_unsubscribe(self.on_event_added) + app.events.event_removed_unsubscribe(self.on_event_removed) def on_event_added(self, event): """ @@ -141,24 +141,24 @@ class StatusIcon: image.get_animation().get_static_image()) # self.status_icon.set_from_animation(image.get_animation()) - if not gajim.interface.systray_enabled: + if not app.interface.systray_enabled: return - if gajim.config.get('trayicon') == 'always': + if app.config.get('trayicon') == 'always': self.status_icon.set_visible(True) - if gajim.events.get_nb_systray_events(): + if app.events.get_nb_systray_events(): self.status_icon.set_visible(True) -# if gajim.config.get('trayicon_blink'): +# if app.config.get('trayicon_blink'): # self.status_icon.set_blinking(True) # else: image = gtkgui_helpers.load_icon('event') really_set_img() return else: - if gajim.config.get('trayicon') == 'on_event': + if app.config.get('trayicon') == 'on_event': self.status_icon.set_visible(False) # self.status_icon.set_blinking(False) - image = gajim.interface.jabber_state_images[self.statusicon_size][ + image = app.interface.jabber_state_images[self.statusicon_size][ self.status] really_set_img() @@ -172,13 +172,13 @@ class StatusIcon: self.set_img() def start_chat(self, widget, account, jid): - contact = gajim.contacts.get_first_contact_from_jid(account, jid) - if gajim.interface.msg_win_mgr.has_window(jid, account): - gajim.interface.msg_win_mgr.get_window(jid, account).set_active_tab( + contact = app.contacts.get_first_contact_from_jid(account, jid) + if app.interface.msg_win_mgr.has_window(jid, account): + app.interface.msg_win_mgr.get_window(jid, account).set_active_tab( jid, account) elif contact: - gajim.interface.new_chat(contact, account) - gajim.interface.msg_win_mgr.get_window(jid, account).set_active_tab( + app.interface.new_chat(contact, account) + app.interface.msg_win_mgr.get_window(jid, account).set_active_tab( jid, account) def on_single_message_menuitem_activate(self, widget, account): @@ -218,7 +218,7 @@ class StatusIcon: join_gc_menuitem.set_submenu(gc_sub_menu) # We need our own set of status icons, let's make 'em! - iconset = gajim.config.get('iconset') + iconset = app.config.get('iconset') path = os.path.join(helpers.get_iconset_path(iconset), '16x16') for show in ('online', 'chat', 'away', 'xa', 'dnd', 'invisible'): @@ -234,7 +234,7 @@ class StatusIcon: sub_menu.append(item) item.connect('activate', self.on_change_status_message_activate) - connected_accounts = gajim.get_number_of_connected_accounts() + connected_accounts = app.get_number_of_connected_accounts() if connected_accounts < 1: item.set_sensitive(False) @@ -249,12 +249,12 @@ class StatusIcon: item.connect('activate', self.on_show_menuitem_activate, 'offline') iskey = connected_accounts > 0 and not (connected_accounts == 1 and - gajim.zeroconf_is_connected()) + app.zeroconf_is_connected()) chat_with_menuitem.set_sensitive(iskey) single_message_menuitem.set_sensitive(iskey) join_gc_menuitem.set_sensitive(iskey) - accounts_list = sorted(gajim.contacts.get_accounts()) + accounts_list = sorted(app.contacts.get_accounts()) # items that get shown whether an account is zeroconf or not if connected_accounts > 1: # 2 or more connections? make submenus account_menu_for_chat_with = Gtk.Menu() @@ -262,7 +262,7 @@ class StatusIcon: self.popup_menus.append(account_menu_for_chat_with) for account in accounts_list: - if gajim.account_is_connected(account): + if app.account_is_connected(account): # for chat_with item = Gtk.MenuItem.new_with_label( _('using account %s') % account) @@ -271,8 +271,8 @@ class StatusIcon: elif connected_accounts == 1: # one account # one account connected, no need to show 'as jid' - for account in gajim.connections: - if gajim.connections[account].connected > 1: + for account in app.connections: + if app.connections[account].connected > 1: # for start chat self.new_chat_handler_id = chat_with_menuitem.connect( 'activate', self.on_new_chat, account) @@ -280,13 +280,13 @@ class StatusIcon: # menu items that don't apply to zeroconf connections if connected_accounts == 1 or (connected_accounts == 2 and \ - gajim.zeroconf_is_connected()): + app.zeroconf_is_connected()): # only one 'real' (non-zeroconf) account is connected, don't need # submenus - for account in gajim.connections: - if gajim.account_is_connected(account) and \ - not gajim.config.get_per('accounts', account, 'is_zeroconf'): - if gajim.connections[account].private_storage_supported: + for account in app.connections: + if app.account_is_connected(account) and \ + not app.config.get_per('accounts', account, 'is_zeroconf'): + if app.connections[account].private_storage_supported: connected_accounts_with_private_storage += 1 # for single message @@ -295,7 +295,7 @@ class StatusIcon: connect('activate', self.on_single_message_menuitem_activate, account) # join gc - gajim.interface.roster.add_bookmarks_list(gc_sub_menu, + app.interface.roster.add_bookmarks_list(gc_sub_menu, account) break # No other account connected else: @@ -306,10 +306,10 @@ class StatusIcon: self.popup_menus.append(account_menu_for_single_message) for account in accounts_list: - if gajim.connections[account].is_zeroconf or \ - not gajim.account_is_connected(account): + if app.connections[account].is_zeroconf or \ + not app.account_is_connected(account): continue - if gajim.connections[account].private_storage_supported: + if app.connections[account].private_storage_supported: connected_accounts_with_private_storage += 1 # for single message item = Gtk.MenuItem.new_with_label( @@ -323,7 +323,7 @@ class StatusIcon: _('using account %s') % account) gc_sub_menu.append(gc_item) gc_menuitem_menu = Gtk.Menu() - gajim.interface.roster.add_bookmarks_list(gc_menuitem_menu, + app.interface.roster.add_bookmarks_list(gc_menuitem_menu, account) gc_item.set_submenu(gc_menuitem_menu) gc_sub_menu.show_all() @@ -332,14 +332,14 @@ class StatusIcon: gc_sub_menu.append(newitem) newitem = Gtk.MenuItem.new_with_mnemonic(_('_Manage Bookmarks…')) newitem.connect('activate', - gajim.interface.roster.on_manage_bookmarks_menuitem_activate) + app.interface.roster.on_manage_bookmarks_menuitem_activate) gc_sub_menu.append(newitem) if connected_accounts_with_private_storage == 0: newitem.set_sensitive(False) - sounds_mute_menuitem.set_active(not gajim.config.get('sounds_on')) + sounds_mute_menuitem.set_active(not app.config.get('sounds_on')) - win = gajim.interface.roster.window + win = app.interface.roster.window if self.show_roster_handler_id: show_roster_menuitem.handler_disconnect(self.show_roster_handler_id) if win.get_property('has-toplevel-focus'): @@ -363,35 +363,35 @@ class StatusIcon: self.systray_context_menu.popup(None, None, None, None, 0, event_time) def on_show_all_events_menuitem_activate(self, widget): - events = gajim.events.get_systray_events() + events = app.events.get_systray_events() for account in events: for jid in events[account]: for event in events[account][jid]: - gajim.interface.handle_event(account, jid, event.type_) + app.interface.handle_event(account, jid, event.type_) def on_sounds_mute_menuitem_activate(self, widget): - gajim.config.set('sounds_on', not widget.get_active()) + app.config.set('sounds_on', not widget.get_active()) def on_show_roster_menuitem_activate(self, widget): - win = gajim.interface.roster.window + win = app.interface.roster.window win.present() def on_hide_roster_menuitem_activate(self, widget): - win = gajim.interface.roster.window + win = app.interface.roster.window win.hide() def on_preferences_menuitem_activate(self, widget): - if 'preferences' in gajim.interface.instances: - gajim.interface.instances['preferences'].window.present() + if 'preferences' in app.interface.instances: + app.interface.instances['preferences'].window.present() else: - gajim.interface.instances['preferences'] = config.PreferencesWindow() + app.interface.instances['preferences'] = config.PreferencesWindow() def on_quit_menuitem_activate(self, widget): - gajim.interface.roster.on_quit_request() + app.interface.roster.on_quit_request() def on_left_click(self): - win = gajim.interface.roster.window - if len(gajim.events.get_systray_events()) == 0: + win = app.interface.roster.window + if len(app.events.get_systray_events()) == 0: # No pending events, so toggle visible/hidden for roster window if win.get_property('visible') and (win.get_property( 'has-toplevel-focus') or os.name == 'nt'): @@ -400,42 +400,42 @@ class StatusIcon: # we could be in another VD right now. eg vd2 # and we want to show it in vd2 if not gtkgui_helpers.possibly_move_window_in_current_desktop( - win) and gajim.config.get('save-roster-position'): + win) and app.config.get('save-roster-position'): x, y = win.get_position() - gajim.config.set('roster_x-position', x) - gajim.config.set('roster_y-position', y) + app.config.set('roster_x-position', x) + app.config.set('roster_y-position', y) win.hide() # else we hide it from VD that was visible in else: if not win.get_property('visible'): win.show_all() - if gajim.config.get('save-roster-position'): + if app.config.get('save-roster-position'): gtkgui_helpers.move_window(win, - gajim.config.get('roster_x-position'), - gajim.config.get('roster_y-position')) - if not gajim.config.get('roster_window_skip_taskbar'): + app.config.get('roster_x-position'), + app.config.get('roster_y-position')) + if not app.config.get('roster_window_skip_taskbar'): win.set_property('skip-taskbar-hint', False) win.present_with_time(Gtk.get_current_event_time()) else: self.handle_first_event() def handle_first_event(self): - account, jid, event = gajim.events.get_first_systray_event() + account, jid, event = app.events.get_first_systray_event() if not event: return - win = gajim.interface.roster.window - if not win.get_property('visible') and gajim.config.get( + win = app.interface.roster.window + if not win.get_property('visible') and app.config.get( 'save-roster-position'): gtkgui_helpers.move_window(win, - gajim.config.get('roster_x-position'), - gajim.config.get('roster_y-position')) - gajim.interface.handle_event(account, jid, event.type_) + app.config.get('roster_x-position'), + app.config.get('roster_y-position')) + app.interface.handle_event(account, jid, event.type_) def on_middle_click(self): """ Middle click raises window to have complete focus (fe. get kbd events) but if already raised, it hides it """ - win = gajim.interface.roster.window + win = app.interface.roster.window if win.is_active(): # is it fully raised? (eg does it receive kbd events?) win.hide() else: @@ -459,26 +459,26 @@ class StatusIcon: 'CHANGE_STATUS_MSG_MENUITEM', 'SEPARATOR', 'offline'] index = l.index(show) if not helpers.statuses_unified(): - gajim.interface.roster.status_combobox.set_active(index + 2) + app.interface.roster.status_combobox.set_active(index + 2) return - current = gajim.interface.roster.status_combobox.get_active() + current = app.interface.roster.status_combobox.get_active() if index != current: - gajim.interface.roster.status_combobox.set_active(index) + app.interface.roster.status_combobox.set_active(index) def on_change_status_message_activate(self, widget): - model = gajim.interface.roster.status_combobox.get_model() - active = gajim.interface.roster.status_combobox.get_active() + model = app.interface.roster.status_combobox.get_model() + active = app.interface.roster.status_combobox.get_active() status = model[active][2] def on_response(message, pep_dict): if message is None: # None if user press Cancel return - accounts = gajim.connections.keys() + accounts = app.connections.keys() for acct in accounts: - if not gajim.config.get_per('accounts', acct, + if not app.config.get_per('accounts', acct, 'sync_with_global_status'): continue - show = gajim.SHOW_LIST[gajim.connections[acct].connected] - gajim.interface.roster.send_status(acct, show, message) - gajim.interface.roster.send_pep(acct, pep_dict) + show = app.SHOW_LIST[app.connections[acct].connected] + app.interface.roster.send_status(acct, show, message) + app.interface.roster.send_pep(acct, pep_dict) dlg = dialogs.ChangeStatusMessageDialog(on_response, status) dlg.dialog.present() diff --git a/gajim/tooltips.py b/gajim/tooltips.py index b83aa02c0..17da32219 100644 --- a/gajim/tooltips.py +++ b/gajim/tooltips.py @@ -39,7 +39,7 @@ from datetime import timedelta from gajim import gtkgui_helpers -from gajim.common import gajim +from gajim.common import app from gajim.common import helpers from gajim.common.i18n import Q_ @@ -273,7 +273,7 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable): StatusTable.__init__(self) def fill_table_with_accounts(self, accounts): - iconset = gajim.config.get('iconset') + iconset = app.config.get('iconset') if not iconset: iconset = 'dcraven' file_path = os.path.join(helpers.get_iconset_path(iconset), '16x16') @@ -281,8 +281,8 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable): message = acct['message'] message = helpers.reduce_chars_newlines(message, 100, 1) message = GLib.markup_escape_text(message) - if acct['name'] in gajim.con_types and \ - gajim.con_types[acct['name']] in ('tls', 'ssl'): + if acct['name'] in app.con_types and \ + app.con_types[acct['name']] in ('tls', 'ssl'): show_lock = True else: show_lock = False @@ -381,7 +381,7 @@ class GCTooltip(Gtk.Window): # Avatar puny_name = helpers.sanitize_filename(contact.name) puny_room = helpers.sanitize_filename(contact.room_jid) - file_ = helpers.get_avatar_path(os.path.join(gajim.AVATAR_PATH, + file_ = helpers.get_avatar_path(os.path.join(app.AVATAR_PATH, puny_room, puny_name)) if file_: with open(file_, 'rb') as file_data: @@ -400,13 +400,13 @@ class GCTooltip(Gtk.Window): formatted = "%s" color = None if affiliation.startswith(Q_("?Group Chat Contact Affiliation:None")): - color = gajim.config.get('tooltip_affiliation_none_color') + color = app.config.get('tooltip_affiliation_none_color') elif affiliation.startswith(_("Member")): - color = gajim.config.get('tooltip_affiliation_member_color') + color = app.config.get('tooltip_affiliation_member_color') elif affiliation.startswith(_("Administrator")): - color = gajim.config.get('tooltip_affiliation_administrator_color') + color = app.config.get('tooltip_affiliation_administrator_color') elif affiliation.startswith(_("Owner")): - color = gajim.config.get('tooltip_affiliation_owner_color') + color = app.config.get('tooltip_affiliation_owner_color') if color: affiliation = formatted % (color, affiliation) return affiliation @@ -451,7 +451,7 @@ class RosterTooltip(Gtk.Window, StatusTable): self.create_table() def fill_table_with_accounts(self, accounts): - iconset = gajim.config.get('iconset') + iconset = app.config.get('iconset') if not iconset: iconset = 'dcraven' file_path = os.path.join(helpers.get_iconset_path(iconset), '16x16') @@ -459,8 +459,8 @@ class RosterTooltip(Gtk.Window, StatusTable): message = acct['message'] message = helpers.reduce_chars_newlines(message, 100, 1) message = GLib.markup_escape_text(message) - if acct['name'] in gajim.con_types and \ - gajim.con_types[acct['name']] in ('tls', 'ssl'): + if acct['name'] in app.con_types and \ + app.con_types[acct['name']] in ('tls', 'ssl'): show_lock = True else: show_lock = False @@ -496,25 +496,25 @@ class RosterTooltip(Gtk.Window, StatusTable): return if typ == 'account': - jid = gajim.get_jid_from_account(account) + jid = app.get_jid_from_account(account) contacts = [] - connection = gajim.connections[account] + connection = app.connections[account] # get our current contact info - nbr_on, nbr_total = gajim.\ + nbr_on, nbr_total = app.\ contacts.get_nb_online_total_contacts( accounts=[account]) account_name = account - if gajim.account_is_connected(account): + if app.account_is_connected(account): account_name += ' (%s/%s)' % (repr(nbr_on), repr(nbr_total)) - contact = gajim.contacts.create_self_contact(jid=jid, + contact = app.contacts.create_self_contact(jid=jid, account=account, name=account_name, show=connection.get_status(), status=connection.status, resource=connection.server_resource, priority=connection.priority) - if gajim.connections[account].gpg: - contact.keyID = gajim.config.get_per('accounts', + if app.connections[account].gpg: + contact.keyID = app.config.get_per('accounts', connection.name, 'keyid') contacts.append(contact) # if we're online ... @@ -538,7 +538,7 @@ class RosterTooltip(Gtk.Window, StatusTable): show = roster.getShow(jid + '/' + resource) if not show: show = 'online' - contact = gajim.contacts.create_self_contact( + contact = app.contacts.create_self_contact( jid=jid, account=account, show=show, status=roster.getStatus( jid + '/' + resource), @@ -547,13 +547,13 @@ class RosterTooltip(Gtk.Window, StatusTable): contacts.append(contact) # Username/Account/Groupchat - self.prim_contact = gajim.contacts.get_highest_prio_contact_from_contacts( + self.prim_contact = app.contacts.get_highest_prio_contact_from_contacts( contacts) self.contact_jid = self.prim_contact.jid name = GLib.markup_escape_text(self.prim_contact.get_shown_name()) name_markup = '{}'.format(name) - if gajim.config.get('mergeaccounts'): - color = gajim.config.get('tooltip_account_name_color') + if app.config.get('mergeaccounts'): + color = app.config.get('tooltip_account_name_color') account_name = GLib.markup_escape_text(self.prim_contact.account.name) name_markup += " ({})".format( color, account_name) @@ -562,7 +562,7 @@ class RosterTooltip(Gtk.Window, StatusTable): name_markup += _(' [blocked]') try: - if self.prim_contact.jid in gajim.interface.minimized_controls[account]: + if self.prim_contact.jid in app.interface.minimized_controls[account]: name_markup += _(' [minimized]') except KeyError: pass @@ -583,12 +583,12 @@ class RosterTooltip(Gtk.Window, StatusTable): contacts_dict[priority] = [contact] if self.num_resources > 1: self.status_label.show() - transport = gajim.get_transport_name_from_jid(self.prim_contact.jid) + transport = app.get_transport_name_from_jid(self.prim_contact.jid) if transport: file_path = os.path.join(helpers.get_transport_path(transport), '16x16') else: - iconset = gajim.config.get('iconset') + iconset = app.config.get('iconset') if not iconset: iconset = 'dcraven' file_path = os.path.join(helpers.get_iconset_path(iconset), @@ -639,7 +639,7 @@ class RosterTooltip(Gtk.Window, StatusTable): self.resource.show() self.resource_label.show() - if self.prim_contact.jid not in gajim.gc_connected[account]: + if self.prim_contact.jid not in app.gc_connected[account]: if (account and self.prim_contact.sub and self.prim_contact.sub != 'both'): @@ -663,7 +663,7 @@ class RosterTooltip(Gtk.Window, StatusTable): # Avatar puny_jid = helpers.sanitize_filename(self.prim_contact.jid) - file_ = helpers.get_avatar_path(os.path.join(gajim.AVATAR_PATH, + file_ = helpers.get_avatar_path(os.path.join(app.AVATAR_PATH, puny_jid)) if file_: with open(file_, 'rb') as file_data: @@ -713,7 +713,7 @@ class RosterTooltip(Gtk.Window, StatusTable): def _set_idle_time(self, contact): if contact.idle_time: - idle_color = gajim.config.get('tooltip_idle_color') + idle_color = app.config.get('tooltip_idle_color') idle_time = contact.idle_time idle_time = time.localtime(contact.idle_time) idle_time = datetime(*(idle_time[:6])) @@ -732,8 +732,8 @@ class RosterTooltip(Gtk.Window, StatusTable): show = helpers.get_uf_show(contact.show) # Contact is Groupchat if (self.account and - self.prim_contact.jid in gajim.gc_connected[self.account]): - if gajim.gc_connected[self.account][self.prim_contact.jid]: + self.prim_contact.jid in app.gc_connected[self.account]): + if app.gc_connected[self.account][self.prim_contact.jid]: show = _('Connected') else: show = _('Disconnected') @@ -779,7 +779,7 @@ class FileTransfersTooltip(BaseTooltip): type_ = _('?Noun:Download') actor = _('Sender: ') sender = file_props.sender.split('/')[0] - name = gajim.contacts.get_first_contact_from_jid( + name = app.contacts.get_first_contact_from_jid( file_props.tt_account, sender).get_shown_name() else: type_ = _('?Noun:Upload') @@ -848,17 +848,17 @@ def colorize_status(status): formatted = "%s" color = None if status.startswith(Q_("?user status:Available")): - color = gajim.config.get('tooltip_status_online_color') + color = app.config.get('tooltip_status_online_color') elif status.startswith(_("Free for Chat")): - color = gajim.config.get('tooltip_status_free_for_chat_color') + color = app.config.get('tooltip_status_free_for_chat_color') elif status.startswith(_("Away")): - color = gajim.config.get('tooltip_status_away_color') + color = app.config.get('tooltip_status_away_color') elif status.startswith(_("Busy")): - color = gajim.config.get('tooltip_status_busy_color') + color = app.config.get('tooltip_status_busy_color') elif status.startswith(_("Not Available")): - color = gajim.config.get('tooltip_status_na_color') + color = app.config.get('tooltip_status_na_color') elif status.startswith(_("Offline")): - color = gajim.config.get('tooltip_status_offline_color') + color = app.config.get('tooltip_status_offline_color') if color: status = formatted % (color, status) return status diff --git a/gajim/upower_listener.py b/gajim/upower_listener.py index 89adfc5ef..544dca535 100644 --- a/gajim/upower_listener.py +++ b/gajim/upower_listener.py @@ -21,12 +21,12 @@ supported = False from gajim.common import dbus_support -from gajim.common import gajim +from gajim.common import app def on_suspend(*args, **kwargs): - for name, conn in gajim.connections.items(): - if gajim.account_is_connected(name): - conn.old_show = gajim.SHOW_LIST[conn.connected] + for name, conn in app.connections.items(): + if app.account_is_connected(name): + conn.old_show = app.SHOW_LIST[conn.connected] st = conn.status conn.change_status('offline', _('Machine going to sleep')) conn.status = st diff --git a/gajim/vcard.py b/gajim/vcard.py index 0a2b1e839..3791f2d86 100644 --- a/gajim/vcard.py +++ b/gajim/vcard.py @@ -43,7 +43,7 @@ import os from gajim import gtkgui_helpers from gajim.common import helpers -from gajim.common import gajim +from gajim.common import app from gajim.common import ged from gajim.common.i18n import Q_ @@ -96,7 +96,7 @@ class VcardWindow: # Get real jid if gc_contact: # Don't use real jid if room is (semi-)anonymous - gc_control = gajim.interface.msg_win_mgr.get_gc_control( + gc_control = app.interface.msg_win_mgr.get_gc_control( gc_contact.room_jid, account) if gc_contact.jid and not gc_control.is_anonymous: self.real_jid = gc_contact.jid @@ -112,7 +112,7 @@ class VcardWindow: self.real_resource = contact.resource puny_jid = helpers.sanitize_filename(contact.jid) - local_avatar_basepath = os.path.join(gajim.AVATAR_PATH, puny_jid) + \ + local_avatar_basepath = os.path.join(app.AVATAR_PATH, puny_jid) + \ '_local' for extension in ('.png', '.jpeg'): local_avatar_path = local_avatar_basepath + extension @@ -132,15 +132,15 @@ class VcardWindow: self.update_progressbar_timeout_id = GLib.timeout_add(self.update_intervall, self.update_progressbar) - gajim.ged.register_event_handler('version-result-received', ged.GUI1, + app.ged.register_event_handler('version-result-received', ged.GUI1, self.set_os_info) - gajim.ged.register_event_handler('time-result-received', ged.GUI1, + app.ged.register_event_handler('time-result-received', ged.GUI1, self.set_entity_time) - gajim.ged.register_event_handler('vcard-received', ged.GUI1, + app.ged.register_event_handler('vcard-received', ged.GUI1, self._nec_vcard_received) self.fill_jabber_page() - annotations = gajim.connections[self.account].annotations + annotations = app.connections[self.account].annotations if self.contact.jid in annotations: buffer_ = self.xml.get_object('textview_annotation').get_buffer() buffer_.set_text(annotations[self.contact.jid]) @@ -169,19 +169,19 @@ class VcardWindow: def on_vcard_information_window_destroy(self, widget): if self.update_progressbar_timeout_id is not None: GLib.source_remove(self.update_progressbar_timeout_id) - del gajim.interface.instances[self.account]['infos'][self.contact.jid] + del app.interface.instances[self.account]['infos'][self.contact.jid] buffer_ = self.xml.get_object('textview_annotation').get_buffer() annotation = buffer_.get_text(buffer_.get_start_iter(), buffer_.get_end_iter(), True) - connection = gajim.connections[self.account] + connection = app.connections[self.account] if annotation != connection.annotations.get(self.contact.jid, ''): connection.annotations[self.contact.jid] = annotation connection.store_annotations() - gajim.ged.remove_event_handler('version-result-received', ged.GUI1, + app.ged.remove_event_handler('version-result-received', ged.GUI1, self.set_os_info) - gajim.ged.remove_event_handler('time-result-received', ged.GUI1, + app.ged.remove_event_handler('time-result-received', ged.GUI1, self.set_entity_time) - gajim.ged.remove_event_handler('vcard-received', ged.GUI1, + app.ged.remove_event_handler('vcard-received', ged.GUI1, self._nec_vcard_received) def on_vcard_information_window_key_press_event(self, widget, event): @@ -298,7 +298,7 @@ class VcardWindow: if self.gc_contact: if obj.fjid != self.contact.jid: return - elif gajim.get_jid_without_resource(obj.fjid) != self.contact.jid: + elif app.get_jid_without_resource(obj.fjid) != self.contact.jid: return i = 0 client = '' @@ -337,7 +337,7 @@ class VcardWindow: if self.gc_contact: if obj.fjid != self.contact.jid: return - elif gajim.get_jid_without_resource(obj.fjid) != self.contact.jid: + elif app.get_jid_without_resource(obj.fjid) != self.contact.jid: return i = 0 time_s = '' @@ -361,7 +361,7 @@ class VcardWindow: def fill_status_label(self): if self.xml.get_object('information_notebook').get_n_pages() < 5: return - contact_list = gajim.contacts.get_contacts(self.account, self.contact.jid) + contact_list = app.contacts.get_contacts(self.account, self.contact.jid) connected_contact_list = [] for c in contact_list: if c.show not in ('offline', 'error'): @@ -442,11 +442,11 @@ class VcardWindow: self.os_info_arrived = True else: # Request os info if contact is connected if self.gc_contact: - j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) - GLib.idle_add(gajim.connections[self.account].request_os_info, + j, r = app.get_room_and_nick_from_fjid(self.real_jid) + GLib.idle_add(app.connections[self.account].request_os_info, j, r, self.contact.jid) else: - GLib.idle_add(gajim.connections[self.account].request_os_info, + GLib.idle_add(app.connections[self.account].request_os_info, self.contact.jid, self.contact.resource) # do not wait for entity_time if contact is not connected or has error @@ -456,18 +456,18 @@ class VcardWindow: self.entity_time_arrived = True else: # Request entity time if contact is connected if self.gc_contact: - j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) - GLib.idle_add(gajim.connections[self.account].\ + j, r = app.get_room_and_nick_from_fjid(self.real_jid) + GLib.idle_add(app.connections[self.account].\ request_entity_time, j, r, self.contact.jid) else: - GLib.idle_add(gajim.connections[self.account].\ + GLib.idle_add(app.connections[self.account].\ request_entity_time, self.contact.jid, self.contact.resource) self.os_info = {0: {'resource': self.real_resource, 'client': '', 'os': ''}} self.time_info = {0: {'resource': self.real_resource, 'time': ''}} i = 1 - contact_list = gajim.contacts.get_contacts(self.account, self.contact.jid) + contact_list = app.contacts.get_contacts(self.account, self.contact.jid) if contact_list: for c in contact_list: if c.resource != self.contact.resource: @@ -476,9 +476,9 @@ class VcardWindow: uf_resources += '\n' + c.resource + \ _(' resource with priority ') + str(c.priority) if c.show not in ('offline', 'error'): - GLib.idle_add(gajim.connections[self.account].\ + GLib.idle_add(app.connections[self.account].\ request_os_info, c.jid, c.resource) - GLib.idle_add(gajim.connections[self.account].\ + GLib.idle_add(app.connections[self.account].\ request_entity_time, c.jid, c.resource) self.os_info[i] = {'resource': c.resource, 'client': '', 'os': ''} @@ -494,10 +494,10 @@ class VcardWindow: if self.gc_contact: # If we know the real jid, remove the resource from vcard request - gajim.connections[self.account].request_vcard(self.real_jid_for_vcard, + app.connections[self.account].request_vcard(self.real_jid_for_vcard, self.gc_contact.get_full_jid()) else: - gajim.connections[self.account].request_vcard(self.contact.jid) + app.connections[self.account].request_vcard(self.contact.jid) def on_close_button_clicked(self, widget): self.window.destroy() @@ -523,7 +523,7 @@ class ZeroconfVcardWindow: self.window.show_all() def on_zeroconf_information_window_destroy(self, widget): - del gajim.interface.instances[self.account]['infos'][self.contact.jid] + del app.interface.instances[self.account]['infos'][self.contact.jid] def on_zeroconf_information_window_key_press_event(self, widget, event): if event.keyval == Gdk.KEY_Escape: @@ -561,7 +561,7 @@ class ZeroconfVcardWindow: def fill_status_label(self): if self.xml.get_object('information_notebook').get_n_pages() < 2: return - contact_list = gajim.contacts.get_contacts(self.account, self.contact.jid) + contact_list = app.contacts.get_contacts(self.account, self.contact.jid) # stats holds show and status message stats = '' one = True # Are we adding the first line ? @@ -603,7 +603,7 @@ class ZeroconfVcardWindow: self.fill_status_label() def fill_personal_page(self): - contact = gajim.connections[gajim.ZEROCONF_ACC_NAME].roster.getItem(self.contact.jid) + contact = app.connections[app.ZEROCONF_ACC_NAME].roster.getItem(self.contact.jid) for key in ('1st', 'last', 'jid', 'email'): if key not in contact['txt_dict']: contact['txt_dict'][key] = '' diff --git a/plugins/dbus_plugin/plugin.py b/plugins/dbus_plugin/plugin.py index f1b5bfeea..22d8a853f 100644 --- a/plugins/dbus_plugin/plugin.py +++ b/plugins/dbus_plugin/plugin.py @@ -675,7 +675,7 @@ if dbus_support.supported: else: gajim.interface.join_gc_room(account, room_jid, nick, password) -from gajim.common import gajim +from gajim.common import app from gajim.common import helpers from time import time from gajim.dialogs import AddNewContactWindow, NewChatDialog, JoinGroupchatWindow diff --git a/plugins/new_events_example/plugin.py b/plugins/new_events_example/plugin.py index 297e5884e..bff72cd9c 100644 --- a/plugins/new_events_example/plugin.py +++ b/plugins/new_events_example/plugin.py @@ -30,7 +30,7 @@ based on existing one. from pprint import pformat from gajim.common import helpers -from gajim.common import gajim +from gajim.common import app from gajim.plugins import GajimPlugin from gajim.plugins.helpers import log_calls, log @@ -128,10 +128,10 @@ class EnrichedChatMessageReceivedEvent(nec.NetworkIncomingEvent): self.stanza = self.base_event.stanza self.conn = self.base_event.conn self.from_jid = helpers.get_full_jid_from_iq(self.stanza) - self.from_jid_without_resource = gajim.get_jid_without_resource( + self.from_jid_without_resource = app.get_jid_without_resource( self.from_jid) self.account = self.conn.name - self.from_nickname = gajim.get_contact_name_from_jid( self.account, + self.from_nickname = app.get_contact_name_from_jid( self.account, self.from_jid_without_resource) self.msg_text = ''.join(self.stanza.kids[0].data) diff --git a/plugins/roster_buttons/plugin.py b/plugins/roster_buttons/plugin.py index e59bda6d9..2a62a1595 100644 --- a/plugins/roster_buttons/plugin.py +++ b/plugins/roster_buttons/plugin.py @@ -27,7 +27,7 @@ Roster buttons plug-in. import sys import gtk -from gajim.common import gajim +from gajim.common import app from gajim.plugins import GajimPlugin from gajim.plugins.helpers import log, log_calls @@ -38,8 +38,8 @@ class RosterButtonsPlugin(GajimPlugin): def init(self): self.description = _('Adds quick action buttons to roster window.') self.GTK_BUILDER_FILE_PATH = self.local_file_path('roster_buttons.ui') - self.roster_vbox = gajim.interface.roster.xml.get_object('roster_vbox2') - self.show_offline_contacts_menuitem = gajim.interface.roster.xml.get_object('show_offline_contacts_menuitem') + self.roster_vbox = app.interface.roster.xml.get_object('roster_vbox2') + self.show_offline_contacts_menuitem = app.interface.roster.xml.get_object('show_offline_contacts_menuitem') self.config_dialog = None diff --git a/test/integration/test_roster.py b/test/integration/test_roster.py index 380ed7f07..8c0e322de 100644 --- a/test/integration/test_roster.py +++ b/test/integration/test_roster.py @@ -8,17 +8,17 @@ from data import * from mock import Mock, expectParams from gajim_mocks import * -from gajim.common import gajim +from gajim.common import app from gajim.common import contacts as contacts_module from gajim import roster_window -gajim.get_jid_from_account = lambda acc: 'myjid@' + acc +app.get_jid_from_account = lambda acc: 'myjid@' + acc class TestRosterWindow(unittest.TestCase): def setUp(self): - gajim.interface = MockInterface() + app.interface = MockInterface() self.C_NAME = roster_window.Column.NAME self.C_TYPE = roster_window.Column.TYPE @@ -27,13 +27,13 @@ class TestRosterWindow(unittest.TestCase): # Add after creating RosterWindow # We want to test the filling explicitly - gajim.contacts = contacts_module.LegacyContactsAPI() - gajim.connections = {} - self.roster = roster_window.RosterWindow(gajim.app) + app.contacts = contacts_module.LegacyContactsAPI() + app.connections = {} + self.roster = roster_window.RosterWindow(app.app) for acc in contacts: - gajim.connections[acc] = MockConnection(acc) - gajim.contacts.add_account(acc) + app.connections[acc] = MockConnection(acc) + app.contacts.add_account(acc) ### Custom assertions def assert_all_contacts_are_in_roster(self, acc): @@ -41,13 +41,13 @@ class TestRosterWindow(unittest.TestCase): self.assert_contact_is_in_roster(jid, acc) def assert_contact_is_in_roster(self, jid, account): - contacts = gajim.contacts.get_contacts(account, jid) + contacts = app.contacts.get_contacts(account, jid) # check for all resources for contact in contacts: iters = self.roster._get_contact_iter(jid, account, model=self.roster.model) - if jid != gajim.get_jid_from_account(account): + if jid != app.get_jid_from_account(account): # We don't care for groups of SelfContact self.assertTrue(len(iters) == len(contact.get_shown_groups()), msg='Contact is not in all his groups') @@ -55,7 +55,7 @@ class TestRosterWindow(unittest.TestCase): # Are we big brother? bb_jid = None bb_account = None - family = gajim.contacts.get_metacontacts_family(account, jid) + family = app.contacts.get_metacontacts_family(account, jid) if family: nearby_family, bb_jid, bb_account = \ self.roster._get_nearby_family_and_big_brother(family, account) @@ -94,7 +94,7 @@ class TestRosterWindow(unittest.TestCase): self.assertTrue(p_model[self.C_TYPE] == 'contact', msg='Little Brother brother has no BigB') else: - if jid == gajim.get_jid_from_account(account): + if jid == app.get_jid_from_account(account): self.assertTrue(p_model[self.C_TYPE] == 'account', msg='SelfContact is not on top') else: @@ -118,7 +118,7 @@ class TestRosterWindow(unittest.TestCase): self.assertEquals(acc_model[self.C_ACCOUNT], acc, msg='Account not found') - self_jid = gajim.get_jid_from_account(acc) + self_jid = app.get_jid_from_account(acc) self.assertEquals(acc_model[self.C_JID], self_jid, msg='Account JID not found in account row') @@ -132,7 +132,7 @@ class TestRosterWindow(unittest.TestCase): self.roster.fill_contacts_and_groups_dicts(contacts[acc], acc) for jid in contacts[acc]: - instances = gajim.contacts.get_contacts(acc, jid) + instances = app.contacts.get_contacts(acc, jid) # Created a contact for each single jid? self.assertTrue(len(instances) == 1) @@ -160,7 +160,7 @@ class TestRosterWindow(unittest.TestCase): class TestRosterWindowRegrouped(TestRosterWindow): def setUp(self): - gajim.config.set('mergeaccounts', True) + app.config.set('mergeaccounts', True) TestRosterWindow.setUp(self) def test_toggle_regroup(self): @@ -180,19 +180,19 @@ class TestRosterWindowMetaContacts(TestRosterWindowRegrouped): for brother in data: acc = brother['account'] jid = brother['jid'] - gajim.contacts.add_metacontact(t_acc, t_jid, acc, jid) + app.contacts.add_metacontact(t_acc, t_jid, acc, jid) self.roster.setup_and_draw_roster() def test_connect_new_metacontact(self): self.test_fill_roster_model() jid = 'coolstuff@gajim.org' - contact = gajim.contacts.create_contact(jid, account1) - gajim.contacts.add_contact(account1, contact) + contact = app.contacts.create_contact(jid, account1) + app.contacts.add_contact(account1, contact) self.roster.add_contact(jid, account1) self.roster.chg_contact_status(contact, 'offline', '', account1) - gajim.contacts.add_metacontact(account1, 'samejid@gajim.org', + app.contacts.add_metacontact(account1, 'samejid@gajim.org', account1, jid) self.roster.chg_contact_status(contact, 'online', '', account1) diff --git a/test/lib/__init__.py b/test/lib/__init__.py index 192b31844..9c10673c6 100644 --- a/test/lib/__init__.py +++ b/test/lib/__init__.py @@ -38,17 +38,17 @@ def setup_env(): import gajim.common.configpaths gajim.common.configpaths.gajimpaths.init(configdir) - # for some reason gajim.common.gajim needs to be imported before xmpppy? - from gajim.common import gajim + # for some reason gajim.common.app needs to be imported before xmpppy? + from gajim.common import app import logging logging.basicConfig() - gajim.DATA_DIR = gajim_root + '/data' - gajim.use_x = use_x + app.DATA_DIR = gajim_root + '/data' + app.use_x = use_x if use_x: from gajim import gtkgui_helpers gtkgui_helpers.GUI_DIR = gajim_root + '/data/gui' from gajim.gajim import GajimApplication - gajim.app = GajimApplication() + app.app = GajimApplication() diff --git a/test/lib/gajim_mocks.py b/test/lib/gajim_mocks.py index cea618347..dd528cfc7 100644 --- a/test/lib/gajim_mocks.py +++ b/test/lib/gajim_mocks.py @@ -3,7 +3,7 @@ Module with dummy classes for Gajim specific unit testing ''' from mock import Mock -from gajim.common import gajim +from gajim.common import app from gajim.common import ged from gajim.common.connection_handlers import ConnectionHandlers @@ -26,26 +26,26 @@ class MockConnection(Mock, ConnectionHandlers): self.nested_group_delimiter = '::' self.server_resource = 'Gajim' - gajim.interface.instances[account] = {'infos': {}, 'disco': {}, + app.interface.instances[account] = {'infos': {}, 'disco': {}, 'gc_config': {}, 'search': {}, 'sub_request': {}} - gajim.interface.minimized_controls[account] = {} - gajim.contacts.add_account(account) - gajim.groups[account] = {} - gajim.gc_connected[account] = {} - gajim.automatic_rooms[account] = {} - gajim.newly_added[account] = [] - gajim.to_be_removed[account] = [] - gajim.nicks[account] = gajim.config.get_per('accounts', account, 'name') - gajim.block_signed_in_notifications[account] = True - gajim.sleeper_state[account] = 0 - 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] = '' + app.interface.minimized_controls[account] = {} + app.contacts.add_account(account) + app.groups[account] = {} + app.gc_connected[account] = {} + app.automatic_rooms[account] = {} + app.newly_added[account] = [] + app.to_be_removed[account] = [] + app.nicks[account] = app.config.get_per('accounts', account, 'name') + app.block_signed_in_notifications[account] = True + app.sleeper_state[account] = 0 + 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] = '' - gajim.connections[account] = self + app.connections[account] = self def request_vcard(self, jid): pass @@ -103,19 +103,19 @@ class MockChatControl(Mock): class MockInterface(Mock): def __init__(self, *args): Mock.__init__(self, *args) - gajim.interface = self + app.interface = self self.msg_win_mgr = Mock() self.roster = Mock() - gajim.ged = ged.GlobalEventsDispatcher() + app.ged = ged.GlobalEventsDispatcher() import plugins - gajim.plugin_manager = plugins.PluginManager() + app.plugin_manager = plugins.PluginManager() self.remote_ctrl = None self.instances = {} self.minimized_controls = {} self.status_sent_to_users = Mock() - if gajim.use_x: + if app.use_x: self.jabber_state_images = {'16': {}, '24': {}, '32': {}, 'opened': {}, 'closed': {}} diff --git a/test/lib/notify.py b/test/lib/notify.py index e903691c2..9bf59ea83 100644 --- a/test/lib/notify.py +++ b/test/lib/notify.py @@ -1,6 +1,6 @@ # mock notify module -from gajim.common import gajim +from gajim.common import app from gajim.common import ged notifications = [] @@ -13,11 +13,11 @@ class Notification: def clean(self): global notifications notifications = [] - gajim.ged.remove_event_handler('notification', ged.GUI2, + app.ged.remove_event_handler('notification', ged.GUI2, self._nec_notification) def __init__(self): - gajim.ged.register_event_handler('notification', ged.GUI2, + app.ged.register_event_handler('notification', ged.GUI2, self._nec_notification) diff --git a/test/test_pluginmanager.py b/test/test_pluginmanager.py index 1682f8a5b..fa990b64d 100644 --- a/test/test_pluginmanager.py +++ b/test/test_pluginmanager.py @@ -52,11 +52,11 @@ os.mkdir(configdir) import gajim.common.configpaths gajim.common.configpaths.gajimpaths.init(configdir) -# for some reason common.gajim needs to be imported before xmpppy? -from gajim.common import gajim +# for some reason common.app needs to be imported before xmpppy? +from gajim.common import app from gajim.common import xmpp -gajim.DATA_DIR = gajim_root + '/data' +app.DATA_DIR = gajim_root + '/data' from common.stanza_session import StanzaSession diff --git a/test/unit/test_gui_interface.py b/test/unit/test_gui_interface.py index 604299855..4f7d97ffc 100644 --- a/test/unit/test_gui_interface.py +++ b/test/unit/test_gui_interface.py @@ -9,10 +9,10 @@ lib.setup_env() from gajim.common import logging_helpers logging_helpers.set_quiet() -from gajim.common import gajim +from gajim.common import app from gajim_mocks import MockLogger -gajim.logger = MockLogger() +app.logger = MockLogger() from gajim.gui_interface import Interface @@ -20,7 +20,7 @@ class TestInterface(unittest.TestCase): def test_instantiation(self): ''' Test that we can proper initialize and do not fail on globals ''' - gajim.app.run() + app.app.run() def test_links_regexp_entire(self): sut = Interface() diff --git a/test/unit/test_protocol_caps.py b/test/unit/test_protocol_caps.py index c7e7c675e..55ec1e579 100644 --- a/test/unit/test_protocol_caps.py +++ b/test/unit/test_protocol_caps.py @@ -6,7 +6,7 @@ import unittest import lib lib.setup_env() -from gajim.common import gajim +from gajim.common import app from gajim.common import nec from gajim.common import ged from gajim.common import caps_cache @@ -45,8 +45,8 @@ class TestableConnectionCaps(ConnectionHandlers, caps.ConnectionCaps): class TestConnectionCaps(unittest.TestCase): def setUp(self): - gajim.nec = nec.NetworkEventsController() - gajim.ged.register_event_handler('caps-presence-received', ged.GUI2, + app.nec = nec.NetworkEventsController() + app.ged.register_event_handler('caps-presence-received', ged.GUI2, self._nec_caps_presence_received) def _nec_caps_presence_received(self, obj): diff --git a/test/unit/test_sessions.py b/test/unit/test_sessions.py index 9cda7800f..d7ea32b7a 100644 --- a/test/unit/test_sessions.py +++ b/test/unit/test_sessions.py @@ -8,7 +8,7 @@ lib.setup_env() import notify -from gajim.common import gajim +from gajim.common import app from gajim.common import nec from gajim.common import ged from gajim.common.nec import NetworkEvent @@ -23,7 +23,7 @@ from gajim.roster_window import RosterWindow from mock import Mock, expectParams from gajim_mocks import * -gajim.interface = MockInterface() +app.interface = MockInterface() # name to use for the test account @@ -88,19 +88,19 @@ class TestChatControlSession(unittest.TestCase): @classmethod def setUpClass(cls): - gajim.nec = nec.NetworkEventsController() + app.nec = nec.NetworkEventsController() cls.conn = MockConnection(account_name, {'send_stanza': None}) - gajim.logger = MockLogger() - gajim.default_session_type = ChatControlSession + app.logger = MockLogger() + app.default_session_type = ChatControlSession def setUp(self): - gajim.notification = notify.Notification() + app.notification = notify.Notification() # no notifications have been sent self.assertEqual(0, len(notify.notifications)) def tearDown(self): - gajim.notification.clean() + app.notification.clean() def receive_chat_msg(self, jid, msgtxt): '''simulate receiving a chat message from jid''' @@ -153,12 +153,12 @@ class TestChatControlSession(unittest.TestCase): sess = self.conn.sessions[jid]['123'] # message was logged - calls = gajim.logger.mockGetNamedCalls('insert_into_logs') + calls = app.logger.mockGetNamedCalls('insert_into_logs') self.assertEqual(1, len(calls)) # no ChatControl was open and autopopup was off # so the message goes into the event queue - self.assertEqual(1, len(gajim.events.get_events(account_name))) + self.assertEqual(1, len(app.events.get_events(account_name))) self.assert_first_message_notification() @@ -171,7 +171,7 @@ class TestChatControlSession(unittest.TestCase): jid = 'bct@necronomicorp.com' fjid = 'bct@necronomicorp.com/Gajim' msgtxt = 'testing two' - roster = RosterWindow(gajim.app) + roster = RosterWindow(app.app) sess = self.conn.sessions[jid]['123'] sess.control = MockChatControl(fjid, account_name) @@ -179,11 +179,11 @@ class TestChatControlSession(unittest.TestCase): self.receive_chat_msg(fjid, msgtxt) # message was logged - calls = gajim.logger.mockGetNamedCalls('insert_into_logs') + calls = app.logger.mockGetNamedCalls('insert_into_logs') self.assertEqual(2, len(calls)) # the message does not go into the event queue - self.assertEqual(1, len(gajim.events.get_events(account_name))) + self.assertEqual(1, len(app.events.get_events(account_name))) self.assert_not_first_message_notification()