Merge branch 'absolute_imports' into 'master'
Make gajim a python module See merge request !106
This commit is contained in:
commit
4ffc1cf8b6
|
@ -11,15 +11,17 @@ EXTRA_DIST = \
|
|||
intltool-merge.in \
|
||||
intltool-update.in \
|
||||
win \
|
||||
scripts/gajim.in
|
||||
|
||||
scripts/gajim.in \
|
||||
scripts/gajim-history-manager.in \
|
||||
scripts/gajim-remote.in
|
||||
|
||||
DISTCLEANFILES = \
|
||||
intltool-extract \
|
||||
intltool-merge \
|
||||
intltool-update \
|
||||
scripts/gajim \
|
||||
scripts/gajim-remote \
|
||||
scripts/gajim-histrory-manager
|
||||
scripts/gajim-history-manager
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
configure \
|
||||
|
|
17
configure.ac
17
configure.ac
|
@ -38,21 +38,10 @@ AC_SUBST(ACLOCAL_AMFLAGS)
|
|||
|
||||
AM_PATH_PYTHON([3.5])
|
||||
|
||||
dnl ****
|
||||
dnl enable installation in python-2.x/site-packages/gajim
|
||||
dnl ****
|
||||
AC_ARG_ENABLE(site-packages,
|
||||
[AS_HELP_STRING([--enable-site-packages],
|
||||
[install gajim sources in PYTHONDIR/site-packages/gajim
|
||||
instead of DATADIR/gajim/src.])]
|
||||
,
|
||||
AC_SUBST([gajim_srcdir], [\${pkgpythondir}])
|
||||
,
|
||||
AC_SUBST([gajim_srcdir], [\${datadir}/\${PACKAGE}/gajim])
|
||||
)
|
||||
|
||||
AC_SUBST([gajim_pluginsdir], [\${datadir}/\${PACKAGE}/plugins])
|
||||
|
||||
AS_AC_EXPAND(PY_SITEDIR, "${pythondir}")
|
||||
AS_AC_EXPAND(GAJIM_SRCDIR, "${gajim_srcdir}")
|
||||
AS_AC_EXPAND(PKGDATADIR, "${datadir}/${PACKAGE}")
|
||||
AS_AC_EXPAND(DOCDIR, "${docdir}")
|
||||
|
@ -78,8 +67,8 @@ AC_CONFIG_FILES([
|
|||
data/defs.py
|
||||
gajim/Makefile
|
||||
scripts/gajim
|
||||
scripts/gajim-remote:scripts/gajim.in
|
||||
scripts/gajim-history-manager:scripts/gajim.in
|
||||
scripts/gajim-history-manager
|
||||
scripts/gajim-remote
|
||||
po/Makefile.in
|
||||
plugins/Makefile
|
||||
])
|
||||
|
|
|
@ -29,12 +29,12 @@ from gi.repository import GLib
|
|||
from gi.repository import Gtk
|
||||
|
||||
import nbxmpp
|
||||
from common import gajim
|
||||
from common import dataforms
|
||||
from gajim.common import app
|
||||
from gajim.common import dataforms
|
||||
|
||||
import gtkgui_helpers
|
||||
import dialogs
|
||||
import dataforms_widget
|
||||
from gajim import gtkgui_helpers
|
||||
from gajim import dialogs
|
||||
from gajim import dataforms_widget
|
||||
|
||||
class CommandWindow:
|
||||
"""
|
||||
|
@ -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
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
from enum import IntEnum, unique
|
||||
|
||||
from gi.repository import Gtk
|
||||
import gtkgui_helpers
|
||||
from gajim import gtkgui_helpers
|
||||
from gi.repository import GLib
|
||||
from gi.repository import Pango
|
||||
|
||||
from 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
|
||||
|
|
|
@ -18,70 +18,64 @@
|
|||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
from common import helpers
|
||||
from common import gajim
|
||||
from common.exceptions import GajimGeneralException
|
||||
from gajim.common import app
|
||||
from gajim.common import helpers
|
||||
from gajim.common.app import interface
|
||||
from gajim.common.exceptions import GajimGeneralException
|
||||
from gi.repository import Gtk
|
||||
import sys
|
||||
import os
|
||||
import config
|
||||
import dialogs
|
||||
import features_window
|
||||
import shortcuts_window
|
||||
import plugins.gui
|
||||
import history_window
|
||||
import disco
|
||||
from history_sync import HistorySyncAssistant
|
||||
from server_info import ServerInfoDialog
|
||||
from gajim import config
|
||||
from gajim import dialogs
|
||||
from gajim import features_window
|
||||
from gajim import shortcuts_window
|
||||
import gajim.plugins.gui
|
||||
from gajim import history_window
|
||||
from gajim import disco
|
||||
from gajim.history_sync import HistorySyncAssistant
|
||||
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
|
||||
|
||||
def on_preferences(self, action, param):
|
||||
if 'preferences' in gajim.interface.instances:
|
||||
gajim.interface.instances['preferences'].window.present()
|
||||
if 'preferences' in interface.instances:
|
||||
interface.instances['preferences'].window.present()
|
||||
else:
|
||||
gajim.interface.instances['preferences'] = \
|
||||
interface.instances['preferences'] = \
|
||||
config.PreferencesWindow()
|
||||
|
||||
def on_plugins(self, action, param):
|
||||
if 'plugins' in gajim.interface.instances:
|
||||
gajim.interface.instances['plugins'].window.present()
|
||||
if 'plugins' in interface.instances:
|
||||
interface.instances['plugins'].window.present()
|
||||
else:
|
||||
gajim.interface.instances['plugins'] = plugins.gui.PluginsWindow()
|
||||
interface.instances['plugins'] = gajim.plugins.gui.PluginsWindow()
|
||||
|
||||
def on_accounts(self, action, param):
|
||||
if 'accounts' in gajim.interface.instances:
|
||||
gajim.interface.instances['accounts'].window.present()
|
||||
if 'accounts' in interface.instances:
|
||||
interface.instances['accounts'].window.present()
|
||||
else:
|
||||
gajim.interface.instances['accounts'] = config.AccountsWindow()
|
||||
interface.instances['accounts'] = config.AccountsWindow()
|
||||
|
||||
def on_history_manager(self, action, param):
|
||||
config_path = '-c %s' % gajim.gajimpaths.data_root
|
||||
posix = os.name != 'nt'
|
||||
if os.path.exists('history_manager.exe'): # Windows
|
||||
helpers.exec_command('history_manager.exe %s' % config_path,
|
||||
posix=posix)
|
||||
else: # Linux or running from Git
|
||||
helpers.exec_command(
|
||||
'%s history_manager.py %s' % (sys.executable, config_path),
|
||||
posix=posix)
|
||||
from gajim.history_manager import HistoryManager
|
||||
HistoryManager()
|
||||
|
||||
def on_manage_bookmarks(self, action, param):
|
||||
config.ManageBookmarksWindow()
|
||||
|
||||
def on_quit(self, action, param):
|
||||
gajim.interface.roster.on_quit_request()
|
||||
interface.roster.on_quit_request()
|
||||
|
||||
# Accounts Actions
|
||||
|
||||
def on_profile(self, action, param):
|
||||
gajim.interface.edit_own_details(param.get_string())
|
||||
interface.edit_own_details(param.get_string())
|
||||
|
||||
def on_activate_bookmark(self, action, param):
|
||||
dict_ = param.unpack()
|
||||
|
@ -91,19 +85,19 @@ class AppActions():
|
|||
nick = dict_['nick']
|
||||
if 'password' in dict_:
|
||||
password = dict_['password']
|
||||
gajim.interface.join_gc_room(account, jid, nick, password)
|
||||
interface.join_gc_room(account, jid, nick, password)
|
||||
|
||||
def on_send_server_message(self, action, param):
|
||||
account = param.get_string()
|
||||
server = 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 = 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 interface.instances[account]['disco']:
|
||||
interface.instances[account]['disco'][server_jid].\
|
||||
window.present()
|
||||
else:
|
||||
try:
|
||||
|
@ -114,16 +108,16 @@ class AppActions():
|
|||
|
||||
def on_join_gc(self, action, param):
|
||||
account = param.get_string()
|
||||
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 interface.instances[account]:
|
||||
interface.instances[account]['join_gc'].window.present()
|
||||
else:
|
||||
try:
|
||||
gajim.interface.instances[account]['join_gc'] = \
|
||||
interface.instances[account]['join_gc'] = \
|
||||
dialogs.JoinGroupchatWindow(account)
|
||||
except GajimGeneralException:
|
||||
pass
|
||||
|
@ -141,64 +135,64 @@ class AppActions():
|
|||
|
||||
def on_archiving_preferences(self, action, param):
|
||||
account = param.get_string()
|
||||
if 'archiving_preferences' in gajim.interface.instances[account]:
|
||||
gajim.interface.instances[account]['archiving_preferences'].window.\
|
||||
if 'archiving_preferences' in interface.instances[account]:
|
||||
interface.instances[account]['archiving_preferences'].window.\
|
||||
present()
|
||||
else:
|
||||
gajim.interface.instances[account]['archiving_preferences'] = \
|
||||
interface.instances[account]['archiving_preferences'] = \
|
||||
dialogs.Archiving313PreferencesWindow(account)
|
||||
|
||||
def on_history_sync(self, action, param):
|
||||
account = param.get_string()
|
||||
if 'history_sync' in gajim.interface.instances[account]:
|
||||
gajim.interface.instances[account]['history_sync'].present()
|
||||
if 'history_sync' in interface.instances[account]:
|
||||
interface.instances[account]['history_sync'].present()
|
||||
else:
|
||||
gajim.interface.instances[account]['history_sync'] = \
|
||||
HistorySyncAssistant(account, gajim.interface.roster.window)
|
||||
interface.instances[account]['history_sync'] = \
|
||||
HistorySyncAssistant(account, interface.roster.window)
|
||||
|
||||
def on_privacy_lists(self, action, param):
|
||||
account = param.get_string()
|
||||
if 'privacy_lists' in gajim.interface.instances[account]:
|
||||
gajim.interface.instances[account]['privacy_lists'].window.present()
|
||||
if 'privacy_lists' in interface.instances[account]:
|
||||
interface.instances[account]['privacy_lists'].window.present()
|
||||
else:
|
||||
gajim.interface.instances[account]['privacy_lists'] = \
|
||||
interface.instances[account]['privacy_lists'] = \
|
||||
dialogs.PrivacyListsWindow(account)
|
||||
|
||||
def on_server_info(self, action, param):
|
||||
account = param.get_string()
|
||||
if 'server_info' in gajim.interface.instances[account]:
|
||||
gajim.interface.instances[account]['server_info'].present()
|
||||
if 'server_info' in interface.instances[account]:
|
||||
interface.instances[account]['server_info'].present()
|
||||
else:
|
||||
gajim.interface.instances[account]['server_info'] = \
|
||||
interface.instances[account]['server_info'] = \
|
||||
ServerInfoDialog(account)
|
||||
|
||||
def on_xml_console(self, action, param):
|
||||
account = param.get_string()
|
||||
if 'xml_console' in gajim.interface.instances[account]:
|
||||
gajim.interface.instances[account]['xml_console'].present()
|
||||
if 'xml_console' in interface.instances[account]:
|
||||
interface.instances[account]['xml_console'].present()
|
||||
else:
|
||||
gajim.interface.instances[account]['xml_console'] = \
|
||||
interface.instances[account]['xml_console'] = \
|
||||
dialogs.XMLConsoleWindow(account)
|
||||
|
||||
# Admin Actions
|
||||
|
||||
def on_set_motd(self, action, param):
|
||||
account = param.get_string()
|
||||
server = 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 = 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 = gajim.config.get_per('accounts', account, 'hostname')
|
||||
server = app.config.get_per('accounts', account, 'hostname')
|
||||
server += '/announce/motd/delete'
|
||||
gajim.connections[account].send_motd(server)
|
||||
app.connections[account].send_motd(server)
|
||||
|
||||
# Help Actions
|
||||
|
||||
|
@ -222,15 +216,15 @@ class AppActions():
|
|||
# View Actions
|
||||
|
||||
def on_file_transfers(self, action, param):
|
||||
if gajim.interface.instances['file_transfers']. \
|
||||
if interface.instances['file_transfers']. \
|
||||
window.get_property('visible'):
|
||||
gajim.interface.instances['file_transfers'].window.present()
|
||||
interface.instances['file_transfers'].window.present()
|
||||
else:
|
||||
gajim.interface.instances['file_transfers'].window.show_all()
|
||||
interface.instances['file_transfers'].window.show_all()
|
||||
|
||||
def on_history(self, action, param):
|
||||
if 'logs' in gajim.interface.instances:
|
||||
gajim.interface.instances['logs'].window.present()
|
||||
if 'logs' in interface.instances:
|
||||
interface.instances['logs'].window.present()
|
||||
else:
|
||||
gajim.interface.instances['logs'] = history_window.\
|
||||
interface.instances['logs'] = history_window.\
|
||||
HistoryWindow()
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
from gi.repository import Gdk
|
||||
from gi.repository import GLib
|
||||
|
||||
import gtkgui_helpers
|
||||
from common import helpers
|
||||
from common import i18n
|
||||
from gajim import gtkgui_helpers
|
||||
from gajim.common import helpers
|
||||
from gajim.common import i18n
|
||||
|
||||
class AtomWindow:
|
||||
window = None
|
||||
|
|
|
@ -34,29 +34,29 @@ from gi.repository import Gdk
|
|||
from gi.repository import GdkPixbuf
|
||||
from gi.repository import Pango
|
||||
from gi.repository import GLib
|
||||
import gtkgui_helpers
|
||||
import gui_menu_builder
|
||||
import message_control
|
||||
import dialogs
|
||||
from gajim import gtkgui_helpers
|
||||
from gajim import gui_menu_builder
|
||||
from gajim import message_control
|
||||
from gajim import dialogs
|
||||
|
||||
from common import logger
|
||||
from common import gajim
|
||||
from common import helpers
|
||||
from common import exceptions
|
||||
from common import ged
|
||||
from common import i18n
|
||||
from common.stanza_session import EncryptedStanzaSession, ArchivingStanzaSession
|
||||
from common.contacts import GC_Contact
|
||||
from common.logger import KindConstant
|
||||
from gajim.common import logger
|
||||
from gajim.common import app
|
||||
from gajim.common import helpers
|
||||
from gajim.common import exceptions
|
||||
from gajim.common import ged
|
||||
from gajim.common import i18n
|
||||
from gajim.common.stanza_session import EncryptedStanzaSession, ArchivingStanzaSession
|
||||
from gajim.common.contacts import GC_Contact
|
||||
from gajim.common.logger import KindConstant
|
||||
from nbxmpp.protocol import NS_XHTML, NS_XHTML_IM, NS_FILE, NS_MUC
|
||||
from nbxmpp.protocol import NS_ESESSION
|
||||
from nbxmpp.protocol import NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO
|
||||
from nbxmpp.protocol import NS_JINGLE_ICE_UDP, NS_JINGLE_FILE_TRANSFER_5
|
||||
from nbxmpp.protocol import NS_CHATSTATES
|
||||
from common.connection_handlers_events import MessageOutgoingEvent
|
||||
from common.exceptions import GajimGeneralException
|
||||
from gajim.common.connection_handlers_events import MessageOutgoingEvent
|
||||
from gajim.common.exceptions import GajimGeneralException
|
||||
|
||||
from command_system.implementation.hosts import ChatCommands
|
||||
from gajim.command_system.implementation.hosts import ChatCommands
|
||||
|
||||
try:
|
||||
import gtkspell
|
||||
|
@ -64,7 +64,7 @@ try:
|
|||
except (ImportError, ValueError):
|
||||
HAS_GTK_SPELL = False
|
||||
|
||||
from chat_control_base import ChatControlBase
|
||||
from gajim.chat_control_base import ChatControlBase
|
||||
|
||||
################################################################################
|
||||
class ChatControl(ChatControlBase):
|
||||
|
@ -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,8 +1032,8 @@ class ChatControl(ChatControlBase):
|
|||
kind = 'outgoing'
|
||||
name = self.get_our_nick()
|
||||
if not xhtml and not encrypted and \
|
||||
gajim.config.get('rst_formatting_outgoing_messages'):
|
||||
from common.rst_xhtml_generator import create_xhtml
|
||||
app.config.get('rst_formatting_outgoing_messages'):
|
||||
from gajim.common.rst_xhtml_generator import create_xhtml
|
||||
xhtml = create_xhtml(text)
|
||||
if xhtml:
|
||||
xhtml = '<body xmlns="%s">%s</body>' % (NS_XHTML, 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 <active/> 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 = '<b>%s:</b> %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 = '<b>%s:</b> %s' % (_('Groupchat Invitation'), event.room_jid)
|
||||
|
|
|
@ -35,35 +35,35 @@ from gi.repository import Pango
|
|||
from gi.repository import GObject
|
||||
from gi.repository import GLib
|
||||
from gi.repository import Gio
|
||||
import gtkgui_helpers
|
||||
from gtkgui_helpers import Color
|
||||
import message_control
|
||||
import dialogs
|
||||
import history_window
|
||||
import notify
|
||||
from gajim import gtkgui_helpers
|
||||
from gajim.gtkgui_helpers import Color
|
||||
from gajim import message_control
|
||||
from gajim import dialogs
|
||||
from gajim import history_window
|
||||
from gajim import notify
|
||||
import re
|
||||
|
||||
import emoticons
|
||||
from scrolled_window import ScrolledWindow
|
||||
from common import events
|
||||
from common import gajim
|
||||
from common import helpers
|
||||
from common import ged
|
||||
from message_control import MessageControl
|
||||
from conversation_textview import ConversationTextview
|
||||
from message_textview import MessageTextView
|
||||
from common.contacts import GC_Contact
|
||||
from common.connection_handlers_events import MessageOutgoingEvent
|
||||
from gajim import emoticons
|
||||
from gajim.scrolled_window import ScrolledWindow
|
||||
from gajim.common import events
|
||||
from gajim.common import app
|
||||
from gajim.common import helpers
|
||||
from gajim.common import ged
|
||||
from gajim.message_control import MessageControl
|
||||
from gajim.conversation_textview import ConversationTextview
|
||||
from gajim.message_textview import MessageTextView
|
||||
from gajim.common.contacts import GC_Contact
|
||||
from gajim.common.connection_handlers_events import MessageOutgoingEvent
|
||||
|
||||
from command_system.implementation.middleware import ChatCommandProcessor
|
||||
from command_system.implementation.middleware import CommandTools
|
||||
from gajim.command_system.implementation.middleware import ChatCommandProcessor
|
||||
from gajim.command_system.implementation.middleware import CommandTools
|
||||
|
||||
# The members of these modules are not referenced directly anywhere in this
|
||||
# module, but still they need to be kept around. Importing them automatically
|
||||
# registers the contained CommandContainers with the command system, thereby
|
||||
# populating the list of available commands.
|
||||
import command_system.implementation.standard
|
||||
import command_system.implementation.execute
|
||||
from gajim.command_system.implementation import standard
|
||||
from gajim.command_system.implementation import execute
|
||||
|
||||
try:
|
||||
import gtkspell
|
||||
|
@ -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':
|
||||
|
|
|
@ -31,7 +31,7 @@ to automatic discovery and dispatching, also features manual control
|
|||
over the process.
|
||||
"""
|
||||
|
||||
from .tools import remove
|
||||
from gajim.command_system.tools import remove
|
||||
|
||||
COMMANDS = {}
|
||||
CONTAINERS = {}
|
||||
|
@ -66,7 +66,7 @@ def traverse_commands(container):
|
|||
yield attribute
|
||||
|
||||
def is_command(attribute):
|
||||
from .framework import Command
|
||||
from gajim.command_system.framework import Command
|
||||
return isinstance(attribute, Command)
|
||||
|
||||
def is_root(namespace):
|
||||
|
@ -115,4 +115,4 @@ class Container(Dispatchable):
|
|||
|
||||
def disable(self):
|
||||
remove_commands(self)
|
||||
remove_container(self)
|
||||
remove_container(self)
|
||||
|
|
|
@ -22,10 +22,10 @@ declarative way.
|
|||
from types import FunctionType
|
||||
from inspect import getargspec, getdoc
|
||||
|
||||
from .dispatcher import Host, Container
|
||||
from .dispatcher import get_command, list_commands
|
||||
from .mapping import parse_arguments, adapt_arguments
|
||||
from .errors import DefinitionError, CommandError, NoCommandError
|
||||
from gajim.command_system.dispatcher import Host, Container
|
||||
from gajim.command_system.dispatcher import get_command, list_commands
|
||||
from gajim.command_system.mapping import parse_arguments, adapt_arguments
|
||||
from gajim.command_system.errors import DefinitionError, CommandError, NoCommandError
|
||||
|
||||
class CommandHost(metaclass=Host):
|
||||
"""
|
||||
|
|
|
@ -34,8 +34,8 @@ code in here will not be executed and commands defined here will not be
|
|||
detected.
|
||||
"""
|
||||
|
||||
from ..framework import CommandContainer, command, doc
|
||||
from .hosts import ChatCommands, PrivateChatCommands, GroupChatCommands
|
||||
from gajim.command_system.framework import CommandContainer, command, doc
|
||||
from gajim.command_system.implementation.hosts import ChatCommands, PrivateChatCommands, GroupChatCommands
|
||||
|
||||
class CustomCommonCommands(CommandContainer):
|
||||
"""
|
||||
|
|
|
@ -37,8 +37,8 @@ from os.path import expanduser
|
|||
|
||||
from gi.repository import GLib
|
||||
|
||||
from ..framework import CommandContainer, command, doc
|
||||
from .hosts import ChatCommands, PrivateChatCommands, GroupChatCommands
|
||||
from gajim.command_system.framework import CommandContainer, command, doc
|
||||
from gajim.command_system.implementation.hosts import ChatCommands, PrivateChatCommands, GroupChatCommands
|
||||
|
||||
class Execute(CommandContainer):
|
||||
AUTOMATIC = True
|
||||
|
|
|
@ -18,7 +18,7 @@ The module defines a set of command hosts, which are bound to a
|
|||
different command processors, which are the source of commands.
|
||||
"""
|
||||
|
||||
from ..framework import CommandHost
|
||||
from gajim.command_system.framework import CommandHost
|
||||
|
||||
class ChatCommands(CommandHost):
|
||||
"""
|
||||
|
|
|
@ -34,10 +34,10 @@ don't need to dig up the code itself to write basic commands.
|
|||
from traceback import print_exc
|
||||
|
||||
from gi.repository import Pango
|
||||
from common import gajim
|
||||
from gajim.common import app
|
||||
|
||||
from ..framework import CommandProcessor
|
||||
from ..errors import CommandError, NoCommandError
|
||||
from gajim.command_system.framework import CommandProcessor
|
||||
from gajim.command_system.errors import CommandError, NoCommandError
|
||||
|
||||
class ChatCommandProcessor(CommandProcessor):
|
||||
"""
|
||||
|
@ -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):
|
||||
|
|
|
@ -20,17 +20,17 @@ Provides an actual implementation for the standard commands.
|
|||
from time import localtime, strftime
|
||||
from datetime import date
|
||||
|
||||
import dialogs
|
||||
from common import gajim
|
||||
from common import helpers
|
||||
from common.exceptions import GajimGeneralException
|
||||
from common.logger import KindConstant
|
||||
from gajim import dialogs
|
||||
from gajim.common import app
|
||||
from gajim.common import helpers
|
||||
from gajim.common.exceptions import GajimGeneralException
|
||||
from gajim.common.logger import KindConstant
|
||||
|
||||
from ..errors import CommandError
|
||||
from ..framework import CommandContainer, command, doc
|
||||
from ..mapping import generate_usage
|
||||
from gajim.command_system.errors import CommandError
|
||||
from gajim.command_system.framework import CommandContainer, command, doc
|
||||
from gajim.command_system.mapping import generate_usage
|
||||
|
||||
from .hosts import ChatCommands, PrivateChatCommands, GroupChatCommands
|
||||
from gajim.command_system.implementation.hosts import ChatCommands, PrivateChatCommands, GroupChatCommands
|
||||
|
||||
class StandardCommonCommands(CommandContainer):
|
||||
"""
|
||||
|
@ -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)
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ according to the command properties.
|
|||
import re
|
||||
from operator import itemgetter
|
||||
|
||||
from .errors import DefinitionError, CommandError
|
||||
from gajim.command_system.errors import DefinitionError, CommandError
|
||||
|
||||
# Quite complex piece of regular expression logic to parse options and
|
||||
# arguments. Might need some tweaking along the way.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding:utf-8 -*-
|
||||
## src/common/gajim.py
|
||||
## gajim/common/app.py
|
||||
##
|
||||
## Copyright (C) 2003-2014 Yann Leboulanger <asterix AT lagaule.org>
|
||||
## Copyright (C) 2005-2006 Dimitur Kirov <dkirov AT gmail.com>
|
||||
|
@ -34,9 +34,9 @@ import gi
|
|||
import uuid
|
||||
from distutils.version import LooseVersion as V
|
||||
|
||||
from common import config
|
||||
from gajim.common import config
|
||||
import nbxmpp
|
||||
from common import ged as ged_module
|
||||
from gajim.common import ged as ged_module
|
||||
|
||||
interface = None # The actual interface (the gtk one for the moment)
|
||||
thread_interface = None # Interface to run a thread and then a callback
|
||||
|
@ -54,7 +54,7 @@ log = logging.getLogger('gajim')
|
|||
|
||||
logger = None
|
||||
|
||||
from common import configpaths
|
||||
from gajim.common import configpaths
|
||||
gajimpaths = configpaths.gajimpaths
|
||||
|
||||
VCARD_PATH = gajimpaths['VCARD']
|
||||
|
@ -86,8 +86,8 @@ else:
|
|||
|
||||
os_info = None # used to cache os information
|
||||
|
||||
from common.contacts import LegacyContactsAPI
|
||||
from common.events import Events
|
||||
from gajim.common.contacts import LegacyContactsAPI
|
||||
from gajim.common.events import Events
|
||||
|
||||
gmail_domains = ['gmail.com', 'googlemail.com']
|
||||
|
||||
|
@ -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
|
||||
|
|
@ -9,7 +9,7 @@ try:
|
|||
raise ImportError
|
||||
from pyasn1.type import univ, constraint, char, namedtype, tag
|
||||
from pyasn1.codec.der.decoder import decode
|
||||
from common.helpers import prep, InvalidFormat
|
||||
from gajim.common.helpers import prep, InvalidFormat
|
||||
|
||||
MAX = 64
|
||||
oid_xmppaddr = '1.3.6.1.5.5.7.8.5'
|
||||
|
|
|
@ -27,8 +27,8 @@ import os
|
|||
import shutil
|
||||
import sys
|
||||
|
||||
from common import gajim
|
||||
from common import logger
|
||||
from gajim.common import app
|
||||
from gajim.common import logger
|
||||
|
||||
# DO NOT MOVE ABOVE OF import gajim
|
||||
import sqlite3 as sqlite
|
||||
|
@ -173,13 +173,13 @@ 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
|
||||
from common import configpaths
|
||||
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']
|
||||
MY_CACHE = configpaths.gajimpaths['MY_CACHE']
|
||||
|
@ -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,16 +262,16 @@ 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
|
||||
from common import configpaths
|
||||
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']
|
||||
MY_CACHE = configpaths.gajimpaths['MY_CACHE']
|
||||
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'))
|
||||
|
|
|
@ -23,10 +23,10 @@
|
|||
##
|
||||
|
||||
import nbxmpp
|
||||
from common import helpers
|
||||
from common import dataforms
|
||||
from common import gajim
|
||||
from common.connection_handlers_events import MessageOutgoingEvent
|
||||
from gajim.common import helpers
|
||||
from gajim.common import dataforms
|
||||
from gajim.common import app
|
||||
from gajim.common.connection_handlers_events import MessageOutgoingEvent
|
||||
|
||||
import logging
|
||||
log = logging.getLogger('gajim.c.commands')
|
||||
|
@ -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):
|
||||
"""
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
|
||||
import re
|
||||
from common import defs
|
||||
from gajim.common import defs
|
||||
from gi.repository import GLib
|
||||
from enum import IntEnum, unique
|
||||
|
||||
|
@ -795,9 +795,9 @@ class Config:
|
|||
self.__options[1][opt] = self.__options[0][opt][Option.VAL]
|
||||
|
||||
def _really_save(self):
|
||||
from 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
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
from common import defs
|
||||
from gajim.common import defs
|
||||
from enum import Enum, unique
|
||||
|
||||
@unique
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -32,21 +32,21 @@ from time import time as time_time
|
|||
|
||||
import nbxmpp
|
||||
from nbxmpp.protocol import NS_CHATSTATES
|
||||
from common import atom
|
||||
from common import nec
|
||||
from common import helpers
|
||||
from common import gajim
|
||||
from common import i18n
|
||||
from common import dataforms
|
||||
from common import exceptions
|
||||
from common.zeroconf.zeroconf import Constant
|
||||
from common.logger import LOG_DB_PATH, KindConstant
|
||||
from common.pep import SUPPORTED_PERSONAL_USER_EVENTS
|
||||
from common.jingle_transport import JingleTransportSocks5
|
||||
from common.file_props import FilesProp
|
||||
from common.nec import NetworkEvent
|
||||
from gajim.common import atom
|
||||
from gajim.common import nec
|
||||
from gajim.common import helpers
|
||||
from gajim.common import app
|
||||
from gajim.common import i18n
|
||||
from gajim.common import dataforms
|
||||
from gajim.common import exceptions
|
||||
from gajim.common.zeroconf.zeroconf import Constant
|
||||
from gajim.common.logger import LOG_DB_PATH, KindConstant
|
||||
from gajim.common.pep import SUPPORTED_PERSONAL_USER_EVENTS
|
||||
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
|
||||
|
||||
|
@ -1831,7 +1831,7 @@ class NewAccountConnectedEvent(nec.NetworkIncomingEvent):
|
|||
self.errnum = 0 # we don't have an errnum
|
||||
self.ssl_msg = ''
|
||||
if self.errnum > 0:
|
||||
from common.connection import ssl_error
|
||||
from gajim.common.connection import ssl_error
|
||||
self.ssl_msg = ssl_error.get(self.errnum,
|
||||
_('Unknown SSL error: %d') % self.errnum)
|
||||
self.ssl_cert = ''
|
||||
|
@ -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}
|
||||
|
|
|
@ -31,9 +31,9 @@
|
|||
from functools import cmp_to_key
|
||||
|
||||
try:
|
||||
from common import caps_cache
|
||||
from common.account import Account
|
||||
import common.gajim
|
||||
from gajim.common import caps_cache
|
||||
from gajim.common.account import Account
|
||||
from gajim import common
|
||||
except ImportError as e:
|
||||
if __name__ != "__main__":
|
||||
raise ImportError(str(e))
|
||||
|
@ -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:
|
||||
|
|
|
@ -27,7 +27,7 @@ information how to use them, read documentation
|
|||
"""
|
||||
|
||||
import nbxmpp
|
||||
from common import helpers
|
||||
from gajim.common import helpers
|
||||
|
||||
# exceptions used in this module
|
||||
# base class
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
|
||||
import os
|
||||
|
||||
from common import gajim
|
||||
from common import exceptions
|
||||
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
|
||||
|
||||
|
||||
|
|
|
@ -28,9 +28,9 @@ import sys
|
|||
import os.path
|
||||
|
||||
docdir = '../'
|
||||
basedir = '../'
|
||||
basedir = './'
|
||||
localedir = '../po'
|
||||
version = '0.16.10.5'
|
||||
version = '0.16.11'
|
||||
|
||||
try:
|
||||
node = subprocess.Popen('git rev-parse --short=12 HEAD', shell=True,
|
||||
|
|
|
@ -24,18 +24,17 @@
|
|||
|
||||
import os
|
||||
import logging
|
||||
from common import gajim
|
||||
from 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'
|
||||
|
|
|
@ -40,7 +40,7 @@ import select
|
|||
import base64
|
||||
import hashlib
|
||||
import shlex
|
||||
from common import caps_cache
|
||||
from gajim.common import caps_cache
|
||||
import socket
|
||||
import time
|
||||
from datetime import datetime, timedelta, timezone, tzinfo
|
||||
|
@ -50,8 +50,8 @@ from string import Template
|
|||
|
||||
import nbxmpp
|
||||
|
||||
from common.i18n import Q_
|
||||
from common.i18n import ngettext
|
||||
from gajim.common.i18n import Q_
|
||||
from gajim.common.i18n import ngettext
|
||||
|
||||
try:
|
||||
import precis_i18n.codec
|
||||
|
@ -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 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'])
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
import locale
|
||||
import gettext
|
||||
import os
|
||||
from common import defs
|
||||
from gajim.common import defs
|
||||
import unicodedata
|
||||
|
||||
# May be changed after GTK is imported
|
||||
|
|
|
@ -31,14 +31,14 @@ Handles the jingle signalling protocol
|
|||
import logging
|
||||
|
||||
import nbxmpp
|
||||
from common import helpers
|
||||
from common import gajim
|
||||
from gajim.common import helpers
|
||||
from gajim.common import app
|
||||
|
||||
from common.jingle_session import JingleSession, JingleStates
|
||||
from common.jingle_ft import JingleFileTransfer
|
||||
from common.jingle_transport import JingleTransportSocks5, JingleTransportIBB
|
||||
if gajim.HAVE_FARSTREAM:
|
||||
from common.jingle_rtp import JingleAudio, JingleVideo
|
||||
from gajim.common.jingle_session import JingleSession, JingleStates
|
||||
from gajim.common.jingle_ft import JingleFileTransfer
|
||||
from gajim.common.jingle_transport import JingleTransportSocks5, JingleTransportIBB
|
||||
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)
|
||||
|
|
|
@ -18,10 +18,10 @@ Handles Jingle contents (XEP 0166)
|
|||
"""
|
||||
|
||||
import os
|
||||
from common import gajim
|
||||
from gajim.common import app
|
||||
import nbxmpp
|
||||
from .jingle_xtls import SELF_SIGNED_CERTIFICATE
|
||||
from .jingle_xtls import load_cert_file
|
||||
from gajim.common.jingle_xtls import SELF_SIGNED_CERTIFICATE
|
||||
from gajim.common.jingle_xtls import load_cert_file
|
||||
|
||||
contents = {}
|
||||
|
||||
|
@ -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:
|
||||
|
|
|
@ -25,14 +25,14 @@ import os
|
|||
import threading
|
||||
from enum import IntEnum, unique
|
||||
import nbxmpp
|
||||
from common import gajim
|
||||
from common import configpaths
|
||||
from common import jingle_xtls
|
||||
from common.jingle_content import contents, JingleContent
|
||||
from common.jingle_transport import JingleTransportSocks5, TransportType
|
||||
from common import helpers
|
||||
from common.connection_handlers_events import FileRequestReceivedEvent
|
||||
from common.jingle_ftstates import (
|
||||
from gajim.common import app
|
||||
from gajim.common import configpaths
|
||||
from gajim.common import jingle_xtls
|
||||
from gajim.common.jingle_content import contents, JingleContent
|
||||
from gajim.common.jingle_transport import JingleTransportSocks5, TransportType
|
||||
from gajim.common import helpers
|
||||
from gajim.common.connection_handlers_events import FileRequestReceivedEvent
|
||||
from gajim.common.jingle_ftstates import (
|
||||
StateInitialized, StateCandSent, StateCandReceived, StateTransfering,
|
||||
StateCandSentAndRecv, StateTransportReplace)
|
||||
|
||||
|
@ -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,
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import nbxmpp
|
||||
from common import gajim
|
||||
from common.jingle_transport import TransportType
|
||||
from common.socks5 import Socks5ReceiverClient, Socks5SenderClient
|
||||
from gajim.common import app
|
||||
from gajim.common.jingle_transport import TransportType
|
||||
from gajim.common.socks5 import Socks5ReceiverClient, Socks5SenderClient
|
||||
|
||||
import logging
|
||||
log = logging.getLogger('gajim.c.jingle_ftstates')
|
||||
|
@ -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):
|
||||
|
|
|
@ -27,12 +27,12 @@ gi.require_version('Gst', '1.0')
|
|||
from gi.repository import Gst
|
||||
from gi.repository import GLib
|
||||
|
||||
from common import gajim
|
||||
from gajim.common import app
|
||||
|
||||
from common.jingle_transport import JingleTransportICEUDP
|
||||
from common.jingle_content import contents, JingleContent, JingleContentSetupException
|
||||
from common.connection_handlers_events import InformationEvent
|
||||
from common.jingle_session import FailedApplication
|
||||
from gajim.common.jingle_transport import JingleTransportICEUDP
|
||||
from gajim.common.jingle_content import contents, JingleContent, JingleContentSetupException
|
||||
from gajim.common.connection_handlers_events import InformationEvent
|
||||
from gajim.common.jingle_session import FailedApplication
|
||||
|
||||
from collections import deque
|
||||
|
||||
|
@ -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:
|
||||
|
|
|
@ -31,16 +31,16 @@ Handles Jingle sessions (XEP 0166)
|
|||
import logging
|
||||
from enum import Enum, unique
|
||||
import nbxmpp
|
||||
from common import gajim
|
||||
from common.jingle_transport import get_jingle_transport, JingleTransportIBB
|
||||
from common.jingle_content import get_jingle_content, JingleContentSetupException, JingleContent
|
||||
from common.jingle_ft import State
|
||||
from common.connection_handlers_events import (
|
||||
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
|
||||
from gajim.common.connection_handlers_events import (
|
||||
FilesProp, JingleRequestReceivedEvent, JingleDisconnectedReceivedEvent,
|
||||
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))
|
||||
|
|
|
@ -21,7 +21,7 @@ import logging
|
|||
import socket
|
||||
from enum import IntEnum, unique
|
||||
import nbxmpp
|
||||
from 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]
|
||||
|
|
|
@ -20,7 +20,7 @@ import logging
|
|||
import os
|
||||
|
||||
import nbxmpp
|
||||
from 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)
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
|
||||
from datetime import datetime
|
||||
|
||||
from common import gajim
|
||||
from common import dbus_support
|
||||
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):
|
||||
|
|
|
@ -40,15 +40,15 @@ from io import BytesIO
|
|||
from gi.repository import GLib
|
||||
from enum import IntEnum, unique
|
||||
|
||||
from common import exceptions
|
||||
from common import gajim
|
||||
from common import ged
|
||||
from gajim.common import exceptions
|
||||
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):
|
||||
|
|
|
@ -23,10 +23,10 @@ from datetime import datetime, timedelta
|
|||
|
||||
import nbxmpp
|
||||
|
||||
from common import gajim
|
||||
from common import ged
|
||||
from common.logger import KindConstant, JIDConstant
|
||||
import common.connection_handlers_events as ev
|
||||
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
|
||||
|
||||
log = logging.getLogger('gajim.c.message_archiving')
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -26,7 +26,7 @@ Network Events Controller.
|
|||
'''
|
||||
|
||||
#from plugins.helpers import log
|
||||
from 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)
|
||||
|
|
|
@ -30,12 +30,12 @@ import os
|
|||
import sys
|
||||
import re
|
||||
from time import time
|
||||
from common import gajim
|
||||
from common import helpers
|
||||
from common import caps_cache
|
||||
from gajim.common import app
|
||||
from gajim.common import helpers
|
||||
from gajim.common import caps_cache
|
||||
|
||||
import sqlite3 as sqlite
|
||||
from common import logger
|
||||
from gajim.common import logger
|
||||
|
||||
import logging
|
||||
log = logging.getLogger('gajim.c.optparser')
|
||||
|
@ -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<optname>[^.=]+)(?:(?:\.(?P<key>.+))?\.(?P<subname>[^.=]+))?\s=\s(?P<value>.*)")
|
||||
|
@ -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,11 +576,11 @@ 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
|
||||
from common.configpaths import gajimpaths
|
||||
from gajim.common.configpaths import gajimpaths
|
||||
|
||||
new_file = gajimpaths['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')
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
import os
|
||||
import logging
|
||||
import gi
|
||||
from 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)
|
||||
|
|
|
@ -221,7 +221,7 @@ import logging
|
|||
log = logging.getLogger('gajim.c.pep')
|
||||
|
||||
import nbxmpp
|
||||
from 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):
|
||||
|
|
|
@ -34,12 +34,12 @@ from gi.repository import GLib
|
|||
import time
|
||||
|
||||
import nbxmpp
|
||||
from common import gajim
|
||||
from common import helpers
|
||||
from common import ged
|
||||
from common import jingle_xtls
|
||||
from common.file_props import FilesProp
|
||||
from common.socks5 import Socks5SenderClient
|
||||
from gajim.common import app
|
||||
from gajim.common import helpers
|
||||
from gajim.common import ged
|
||||
from gajim.common import jingle_xtls
|
||||
from gajim.common.file_props import FilesProp
|
||||
from gajim.common.socks5 import Socks5SenderClient
|
||||
|
||||
import logging
|
||||
log = logging.getLogger('gajim.c.p.bytestream')
|
||||
|
@ -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)
|
||||
|
@ -256,8 +256,8 @@ class ConnectionBytestream:
|
|||
raise nbxmpp.NodeProcessed
|
||||
|
||||
def _siSetCB(self, con, iq_obj):
|
||||
from common.connection_handlers_events import FileRequestReceivedEvent
|
||||
gajim.nec.push_incoming_event(FileRequestReceivedEvent(None, conn=self,
|
||||
from gajim.common.connection_handlers_events import FileRequestReceivedEvent
|
||||
app.nec.push_incoming_event(FileRequestReceivedEvent(None, conn=self,
|
||||
stanza=iq_obj))
|
||||
raise nbxmpp.NodeProcessed
|
||||
|
||||
|
@ -274,8 +274,8 @@ class ConnectionBytestream:
|
|||
return
|
||||
jid = self._ft_get_from(iq_obj)
|
||||
file_props.error = -3
|
||||
from common.connection_handlers_events import FileRequestErrorEvent
|
||||
gajim.nec.push_incoming_event(FileRequestErrorEvent(None, conn=self,
|
||||
from gajim.common.connection_handlers_events import FileRequestErrorEvent
|
||||
app.nec.push_incoming_event(FileRequestErrorEvent(None, conn=self,
|
||||
jid=jid, file_props=file_props, error_msg=''))
|
||||
raise nbxmpp.NodeProcessed
|
||||
|
||||
|
@ -308,9 +308,9 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
|
|||
if contact.get_full_jid() == receiver_jid:
|
||||
file_props.error = -5
|
||||
self.remove_transfer(file_props)
|
||||
from common.connection_handlers_events import \
|
||||
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 common.connection_handlers_events import FileRequestErrorEvent
|
||||
gajim.nec.push_incoming_event(FileRequestErrorEvent(None, conn=self,
|
||||
from gajim.common.connection_handlers_events import FileRequestErrorEvent
|
||||
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 common.connection_handlers_events import InformationEvent
|
||||
gajim.nec.push_incoming_event(InformationEvent(None, conn=self,
|
||||
from gajim.common.connection_handlers_events import InformationEvent
|
||||
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 = {
|
||||
|
@ -582,9 +582,9 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
|
|||
if msg:
|
||||
self.disconnect_transfer(file_props)
|
||||
file_props.error = -3
|
||||
from common.connection_handlers_events import \
|
||||
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,15 +609,15 @@ 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_)
|
||||
if not file_props:
|
||||
return
|
||||
file_props.error = -4
|
||||
from common.connection_handlers_events import FileRequestErrorEvent
|
||||
gajim.nec.push_incoming_event(FileRequestErrorEvent(None, conn=self,
|
||||
from gajim.common.connection_handlers_events import FileRequestErrorEvent
|
||||
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
|
||||
|
|
|
@ -25,9 +25,9 @@ Module containing the network portion of XEP-115 (Entity Capabilities)
|
|||
import logging
|
||||
log = logging.getLogger('gajim.c.p.caps')
|
||||
|
||||
from common import gajim
|
||||
from common import ged
|
||||
from common.connection_handlers_events import CapsPresenceReceivedEvent, \
|
||||
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))
|
||||
|
|
|
@ -27,11 +27,11 @@ import logging
|
|||
log = logging.getLogger('gajim.c.proxy65_manager')
|
||||
|
||||
import nbxmpp
|
||||
from common import gajim
|
||||
from common import helpers
|
||||
from common.socks5 import Socks5
|
||||
from gajim.common import app
|
||||
from gajim.common import helpers
|
||||
from gajim.common.socks5 import Socks5
|
||||
from nbxmpp.idlequeue import IdleObject
|
||||
from common.file_props import FilesProp
|
||||
from gajim.common.file_props import FilesProp
|
||||
|
||||
S_INITIAL = 0
|
||||
S_STARTED = 1
|
||||
|
@ -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)
|
||||
|
|
|
@ -22,25 +22,25 @@
|
|||
##
|
||||
|
||||
import nbxmpp
|
||||
from common import gajim
|
||||
from gajim.common import app
|
||||
#TODO: Doesn't work
|
||||
#from common.connection_handlers import PEP_CONFIG
|
||||
PEP_CONFIG = 'pep_config'
|
||||
from common import ged
|
||||
from common.connection_handlers_events import PubsubReceivedEvent
|
||||
from common.connection_handlers_events import PubsubBookmarksReceivedEvent
|
||||
from gajim.common import ged
|
||||
from gajim.common.connection_handlers_events import PubsubReceivedEvent
|
||||
from gajim.common.connection_handlers_events import PubsubBookmarksReceivedEvent
|
||||
import logging
|
||||
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):
|
||||
|
|
|
@ -24,9 +24,9 @@ log = logging.getLogger('gajim.c.resolver')
|
|||
|
||||
if __name__ == '__main__':
|
||||
sys.path.append('..')
|
||||
from common import i18n
|
||||
import common.configpaths
|
||||
common.configpaths.gajimpaths.init(None)
|
||||
from gajim.common import i18n
|
||||
from gajim.common import configpaths
|
||||
configpaths.gajimpaths.init(None)
|
||||
|
||||
from gi.repository import Gio, GLib
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
from common import gajim
|
||||
from gajim.common import app
|
||||
import os
|
||||
|
||||
|
||||
|
@ -49,10 +49,10 @@ try:
|
|||
CloseDesktop = ctypes.windll.user32.CloseDesktop
|
||||
SystemParametersInfo = ctypes.windll.user32.SystemParametersInfoW
|
||||
else: # unix
|
||||
from common import idle
|
||||
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:
|
||||
|
|
|
@ -34,9 +34,9 @@ from errno import EISCONN
|
|||
from errno import EINPROGRESS
|
||||
from errno import EAFNOSUPPORT
|
||||
from nbxmpp.idlequeue import IdleObject
|
||||
from common.file_props import FilesProp
|
||||
from common import gajim
|
||||
from common import jingle_xtls
|
||||
from gajim.common.file_props import FilesProp
|
||||
from gajim.common import app
|
||||
from gajim.common import jingle_xtls
|
||||
if jingle_xtls.PYOPENSSL_PRESENT:
|
||||
import OpenSSL
|
||||
import logging
|
||||
|
@ -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',
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
from common import gajim
|
||||
from gajim.common import app
|
||||
import nbxmpp
|
||||
from common.exceptions import DecryptionError, NegotiationError
|
||||
from gajim.common.exceptions import DecryptionError, NegotiationError
|
||||
import nbxmpp.c14n
|
||||
|
||||
import itertools
|
||||
|
@ -35,17 +35,17 @@ import base64
|
|||
import os
|
||||
from hashlib import sha256
|
||||
from hmac import HMAC
|
||||
from common import crypto
|
||||
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
|
||||
|
||||
from common import dh
|
||||
import secrets
|
||||
from gajim.common import dh
|
||||
from gajim import secrets
|
||||
|
||||
XmlDsig = 'http://www.w3.org/2000/09/xmldsig#'
|
||||
|
||||
|
@ -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',
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
## You should have received a copy of the GNU General Public License
|
||||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
from common import gajim
|
||||
from gajim.common import app
|
||||
import nbxmpp
|
||||
from nbxmpp.idlequeue import IdleObject
|
||||
from nbxmpp import dispatcher_nb, simplexml
|
||||
from nbxmpp.plugin import *
|
||||
from nbxmpp.transports_nb import DATA_RECEIVED, DATA_SENT, DATA_ERROR
|
||||
from common.zeroconf import zeroconf
|
||||
from gajim.common.zeroconf import zeroconf
|
||||
|
||||
from nbxmpp.protocol import *
|
||||
import socket
|
||||
|
@ -37,7 +37,7 @@ from random import Random
|
|||
import logging
|
||||
log = logging.getLogger('gajim.c.z.client_zeroconf')
|
||||
|
||||
from common.zeroconf import roster_zeroconf
|
||||
from gajim.common.zeroconf import roster_zeroconf
|
||||
|
||||
MAX_BUFF_LEN = 65536
|
||||
TYPE_SERVER, TYPE_CLIENT = range(2)
|
||||
|
@ -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]
|
||||
|
|
|
@ -25,10 +25,10 @@
|
|||
|
||||
import nbxmpp
|
||||
|
||||
from common import gajim
|
||||
from common.commands import ConnectionCommands
|
||||
from common.protocol.bytestream import ConnectionSocks5BytestreamZeroconf
|
||||
from common.connection_handlers_events import ZeroconfMessageReceivedEvent
|
||||
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
|
||||
|
||||
import logging
|
||||
log = logging.getLogger('gajim.c.z.connection_handlers_zeroconf')
|
||||
|
@ -46,7 +46,7 @@ except Exception:
|
|||
log.debug(_('Unable to load idle module'))
|
||||
HAS_IDLE = False
|
||||
|
||||
from common import connection_handlers
|
||||
from gajim.common import connection_handlers
|
||||
|
||||
class ConnectionVcard(connection_handlers.ConnectionVcard):
|
||||
def add_sha(self, p, send_caps = True):
|
||||
|
@ -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
|
||||
|
||||
|
|
|
@ -42,13 +42,13 @@ if os.name != 'nt':
|
|||
import getpass
|
||||
from gi.repository import GLib
|
||||
|
||||
from common.connection import CommonConnection
|
||||
from common import gajim
|
||||
from common import ged
|
||||
from common.zeroconf import client_zeroconf
|
||||
from common.zeroconf import zeroconf
|
||||
from common.zeroconf.connection_handlers_zeroconf import *
|
||||
from common.connection_handlers_events import *
|
||||
from gajim.common.connection import CommonConnection
|
||||
from gajim.common import app
|
||||
from gajim.common import ged
|
||||
from gajim.common.zeroconf import client_zeroconf
|
||||
from gajim.common.zeroconf import zeroconf
|
||||
from gajim.common.zeroconf.connection_handlers_zeroconf import *
|
||||
from gajim.common.connection_handlers_events import *
|
||||
|
||||
class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf):
|
||||
def __init__(self, name):
|
||||
|
@ -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))
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
##
|
||||
|
||||
|
||||
from common.zeroconf import zeroconf
|
||||
from common.zeroconf.zeroconf import Constant, ConstantRI
|
||||
from gajim.common.zeroconf import zeroconf
|
||||
from gajim.common.zeroconf.zeroconf import Constant, ConstantRI
|
||||
|
||||
class Roster:
|
||||
def __init__(self, zeroconf):
|
||||
|
|
|
@ -56,8 +56,8 @@ def test_zeroconf():
|
|||
return test_avahi() or test_bonjour()
|
||||
|
||||
if test_avahi():
|
||||
from common.zeroconf import zeroconf_avahi
|
||||
from gajim.common.zeroconf import zeroconf_avahi
|
||||
Zeroconf = zeroconf_avahi.Zeroconf
|
||||
elif test_bonjour():
|
||||
from common.zeroconf import zeroconf_bonjour
|
||||
from gajim.common.zeroconf import zeroconf_bonjour
|
||||
Zeroconf = zeroconf_bonjour.Zeroconf
|
||||
|
|
|
@ -25,7 +25,7 @@ try:
|
|||
except ImportError:
|
||||
pass
|
||||
|
||||
from common.zeroconf.zeroconf import Constant, ConstantRI
|
||||
from gajim.common.zeroconf.zeroconf import Constant, ConstantRI
|
||||
|
||||
class Zeroconf:
|
||||
def __init__(self, new_serviceCB, remove_serviceCB, name_conflictCB,
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
from common import gajim
|
||||
from gajim.common import app
|
||||
import select
|
||||
import re
|
||||
from common.zeroconf.zeroconf import Constant
|
||||
from gajim.common.zeroconf.zeroconf import Constant
|
||||
|
||||
try:
|
||||
import pybonjour
|
||||
|
@ -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:
|
||||
|
|
1337
gajim/config.py
1337
gajim/config.py
File diff suppressed because it is too large
Load Diff
|
@ -37,21 +37,21 @@ from gi.repository import GObject
|
|||
from gi.repository import GLib
|
||||
import time
|
||||
import os
|
||||
import tooltips
|
||||
import dialogs
|
||||
from gajim import tooltips
|
||||
from gajim import dialogs
|
||||
import queue
|
||||
import urllib
|
||||
|
||||
import gtkgui_helpers
|
||||
from common import gajim
|
||||
from common import helpers
|
||||
from common import i18n
|
||||
from gajim import gtkgui_helpers
|
||||
from gajim.common import app
|
||||
from gajim.common import helpers
|
||||
from gajim.common import i18n
|
||||
from calendar import timegm
|
||||
from common.fuzzyclock import FuzzyClock
|
||||
import emoticons
|
||||
from gajim.common.fuzzyclock import FuzzyClock
|
||||
from gajim import emoticons
|
||||
|
||||
from htmltextview import HtmlTextView
|
||||
from common.exceptions import GajimGeneralException
|
||||
from gajim.htmltextview import HtmlTextView
|
||||
from gajim.common.exceptions import GajimGeneralException
|
||||
|
||||
NOT_SHOWN = 0
|
||||
ALREADY_RECEIVED = 1
|
||||
|
@ -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:
|
||||
|
|
|
@ -32,11 +32,11 @@ from gi.repository import GObject
|
|||
from gi.repository import GLib
|
||||
import base64
|
||||
|
||||
import gtkgui_helpers
|
||||
import dialogs
|
||||
from gajim import gtkgui_helpers
|
||||
from gajim import dialogs
|
||||
|
||||
import common.dataforms as dataforms
|
||||
from common import helpers
|
||||
from gajim.common import dataforms
|
||||
from gajim.common import helpers
|
||||
|
||||
import itertools
|
||||
|
||||
|
|
676
gajim/dialogs.py
676
gajim/dialogs.py
File diff suppressed because it is too large
Load Diff
120
gajim/disco.py
120
gajim/disco.py
|
@ -52,18 +52,18 @@ from gi.repository import Gdk
|
|||
from gi.repository import GdkPixbuf
|
||||
from gi.repository import Pango
|
||||
|
||||
import dialogs
|
||||
import gtkgui_helpers
|
||||
import groups
|
||||
import adhoc_commands
|
||||
import search_window
|
||||
import gui_menu_builder
|
||||
from gajim import dialogs
|
||||
from gajim import gtkgui_helpers
|
||||
from gajim import groups
|
||||
from gajim import adhoc_commands
|
||||
from gajim import search_window
|
||||
from gajim import gui_menu_builder
|
||||
|
||||
from common import gajim
|
||||
from gajim.common import app
|
||||
import nbxmpp
|
||||
from common.exceptions import GajimGeneralException
|
||||
from common import helpers
|
||||
from common import ged
|
||||
from gajim.common.exceptions import GajimGeneralException
|
||||
from gajim.common import helpers
|
||||
from gajim.common import ged
|
||||
|
||||
LABELS = {
|
||||
1: _('This service has not yet responded with detailed information'),
|
||||
|
@ -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 = "<b>%s</b>" % 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 = "<b>%s</b>" % 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):
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
import os
|
||||
import gi
|
||||
from gi.repository import Gtk, Gdk
|
||||
import gtkgui_helpers
|
||||
from gajim import gtkgui_helpers
|
||||
|
||||
from common import gajim
|
||||
from common.i18n import Q_
|
||||
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,17 +169,17 @@ class FeaturesWindow:
|
|||
return True
|
||||
|
||||
def zeroconf_available(self):
|
||||
return gajim.HAVE_ZEROCONF
|
||||
return app.HAVE_ZEROCONF
|
||||
|
||||
def dbus_available(self):
|
||||
from common import dbus_support
|
||||
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):
|
||||
import network_watcher
|
||||
from gajim import network_watcher
|
||||
return network_watcher.supported
|
||||
|
||||
def some_keyring_available(self):
|
||||
|
@ -194,7 +194,7 @@ class FeaturesWindow:
|
|||
|
||||
def speller_available(self):
|
||||
try:
|
||||
__import__('gtkspell')
|
||||
__import__('gajim.gtkspell')
|
||||
except ValueError:
|
||||
return False
|
||||
return True
|
||||
|
@ -202,7 +202,7 @@ class FeaturesWindow:
|
|||
def notification_available(self):
|
||||
if os.name == 'nt':
|
||||
return False
|
||||
from common import dbus_support
|
||||
from gajim.common import dbus_support
|
||||
if self.dbus_available() and dbus_support.get_notifications_interface():
|
||||
return True
|
||||
try:
|
||||
|
@ -212,11 +212,11 @@ class FeaturesWindow:
|
|||
return True
|
||||
|
||||
def idle_available(self):
|
||||
from common import sleepy
|
||||
from gajim.common import sleepy
|
||||
return sleepy.SUPPORTED
|
||||
|
||||
def pycrypto_available(self):
|
||||
return gajim.HAVE_PYCRYPTO
|
||||
return app.HAVE_PYCRYPTO
|
||||
|
||||
def docutils_available(self):
|
||||
try:
|
||||
|
@ -226,13 +226,13 @@ 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':
|
||||
return False
|
||||
import upower_listener
|
||||
from gajim import upower_listener
|
||||
return upower_listener.supported
|
||||
|
|
|
@ -32,14 +32,14 @@ import time
|
|||
from enum import IntEnum, unique
|
||||
from datetime import datetime
|
||||
|
||||
import gtkgui_helpers
|
||||
import tooltips
|
||||
import dialogs
|
||||
from gajim import gtkgui_helpers
|
||||
from gajim import tooltips
|
||||
from gajim import dialogs
|
||||
|
||||
from common import gajim
|
||||
from common import helpers
|
||||
from common.file_props import FilesProp
|
||||
from common.protocol.bytestream import (is_transfer_active, is_transfer_paused,
|
||||
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,
|
||||
is_transfer_stopped)
|
||||
from nbxmpp.protocol import NS_JINGLE_FILE_TRANSFER_5
|
||||
import logging
|
||||
|
@ -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
|
||||
|
@ -294,7 +294,7 @@ class FileTransfersWindow:
|
|||
win.set_shadow_type(Gtk.ShadowType.IN)
|
||||
win.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER)
|
||||
|
||||
from message_textview import MessageTextView
|
||||
from gajim.message_textview import MessageTextView
|
||||
desc_entry = MessageTextView()
|
||||
win.add(desc_entry)
|
||||
|
||||
|
@ -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):
|
||||
|
|
|
@ -50,9 +50,9 @@ gi.require_version('Gdk', '3.0')
|
|||
gi.require_version('GObject', '2.0')
|
||||
gi.require_version('Pango', '1.0')
|
||||
from gi.repository import GLib, Gio, Gtk
|
||||
from common import i18n
|
||||
from common import logging_helpers
|
||||
from common import crypto
|
||||
from gajim.common import i18n
|
||||
from gajim.common import logging_helpers
|
||||
from gajim.common import crypto
|
||||
try:
|
||||
PYOPENSSL_PRNG_PRESENT = True
|
||||
import OpenSSL.rand
|
||||
|
@ -114,7 +114,7 @@ class GajimApplication(Gtk.Application):
|
|||
def do_startup(self):
|
||||
Gtk.Application.do_startup(self)
|
||||
|
||||
import gtkexcepthook
|
||||
from gajim import gtkexcepthook
|
||||
gtkexcepthook.init()
|
||||
|
||||
try:
|
||||
|
@ -130,18 +130,18 @@ class GajimApplication(Gtk.Application):
|
|||
sys.exit(1)
|
||||
|
||||
# Create and initialize Application Paths & Databases
|
||||
from common import configpaths
|
||||
from gajim.common import configpaths
|
||||
configpaths.gajimpaths.init(
|
||||
self.config_path, self.profile, self.profile_separation)
|
||||
|
||||
from common import gajim
|
||||
from common import check_paths
|
||||
from common import exceptions
|
||||
from common import logger
|
||||
from common import caps_cache
|
||||
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)
|
||||
|
@ -242,13 +242,13 @@ class GajimApplication(Gtk.Application):
|
|||
|
||||
def do_activate(self):
|
||||
Gtk.Application.do_activate(self)
|
||||
from gui_interface import Interface
|
||||
import gtkgui_helpers
|
||||
from gajim.gui_interface import Interface
|
||||
from gajim import gtkgui_helpers
|
||||
self.interface = Interface()
|
||||
gtkgui_helpers.load_css()
|
||||
self.interface.run(self)
|
||||
self.add_actions()
|
||||
import gui_menu_builder
|
||||
from gajim import gui_menu_builder
|
||||
gui_menu_builder.build_accounts_menu()
|
||||
|
||||
def do_shutdown(self, *args):
|
||||
|
@ -264,8 +264,8 @@ class GajimApplication(Gtk.Application):
|
|||
self.interface.roster.prepare_quit()
|
||||
|
||||
# Commit any outstanding SQL transactions
|
||||
from common import gajim
|
||||
gajim.logger.commit()
|
||||
from gajim.common import app
|
||||
app.logger.commit()
|
||||
|
||||
def do_handle_local_options(self, options: GLib.VariantDict) -> int:
|
||||
|
||||
|
@ -283,7 +283,7 @@ class GajimApplication(Gtk.Application):
|
|||
if options.contains('config-path'):
|
||||
self.config_path = options.lookup_value('config-path').get_string()
|
||||
if options.contains('version'):
|
||||
from common.defs import version
|
||||
from gajim.common.defs import version
|
||||
print(version)
|
||||
return 0
|
||||
if options.contains('quiet'):
|
||||
|
@ -322,7 +322,7 @@ class GajimApplication(Gtk.Application):
|
|||
|
||||
def add_actions(self):
|
||||
''' Build Application Actions '''
|
||||
from app_actions import AppActions
|
||||
from gajim.app_actions import AppActions
|
||||
action = AppActions(self)
|
||||
|
||||
self.account_actions = [
|
||||
|
@ -368,8 +368,8 @@ class GajimApplication(Gtk.Application):
|
|||
act.connect("activate", func)
|
||||
self.add_action(act)
|
||||
|
||||
from 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:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*-
|
||||
## src/gajim-remote.py
|
||||
##
|
||||
|
@ -33,9 +34,9 @@ import signal
|
|||
signal.signal(signal.SIGINT, signal.SIG_DFL) # ^C exits the application
|
||||
|
||||
|
||||
from common import exceptions
|
||||
from common import i18n # This installs _() function
|
||||
from common.i18n import Q_
|
||||
from gajim.common import exceptions
|
||||
from gajim.common import i18n # This installs _() function
|
||||
from gajim.common.i18n import Q_
|
||||
|
||||
try:
|
||||
PREFERRED_ENCODING = locale.getpreferredencoding()
|
|
@ -25,17 +25,17 @@
|
|||
from gi.repository import Gtk
|
||||
from gi.repository import Gdk
|
||||
from gi.repository import Pango
|
||||
import dialogs
|
||||
import gtkgui_helpers
|
||||
from gajim import dialogs
|
||||
from gajim import gtkgui_helpers
|
||||
|
||||
from 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):
|
||||
"""
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -21,9 +21,9 @@
|
|||
|
||||
'''Window to create new post for discussion groups service.'''
|
||||
|
||||
from common import gajim
|
||||
from gajim.common import app
|
||||
from nbxmpp import Node
|
||||
import gtkgui_helpers
|
||||
from gajim import gtkgui_helpers
|
||||
|
||||
class GroupsPostWindow:
|
||||
def __init__(self, account, servicejid, groupid):
|
||||
|
@ -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()
|
||||
|
|
|
@ -31,7 +31,7 @@ import gi
|
|||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
from io import StringIO
|
||||
from common import configpaths
|
||||
from gajim.common import configpaths
|
||||
|
||||
glade_file = os.path.join(configpaths.get('GUI'), 'exception_dialog.ui')
|
||||
|
||||
|
|
|
@ -45,13 +45,13 @@ from io import BytesIO
|
|||
import logging
|
||||
log = logging.getLogger('gajim.gtkgui_helpers')
|
||||
|
||||
from common import i18n
|
||||
from common import gajim
|
||||
from common import pep
|
||||
from common import configpaths
|
||||
from gajim.common import i18n
|
||||
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)
|
||||
|
@ -82,8 +82,8 @@ def get_icon_path(icon_name, size=16):
|
|||
except GLib.GError as e:
|
||||
log.error("Unable to find icon %s: %s" % (icon_name, str(e)))
|
||||
|
||||
import vcard
|
||||
import dialogs
|
||||
from gajim import vcard
|
||||
from gajim import dialogs
|
||||
|
||||
|
||||
HAS_PYWIN32 = True
|
||||
|
@ -95,7 +95,7 @@ if os.name == 'nt':
|
|||
except ImportError:
|
||||
HAS_PYWIN32 = False
|
||||
|
||||
from common import helpers
|
||||
from gajim.common import helpers
|
||||
|
||||
screen_w = Gdk.Screen.width()
|
||||
screen_h = Gdk.Screen.height()
|
||||
|
@ -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)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -20,15 +20,15 @@
|
|||
|
||||
from gi.repository import Gtk, Gio, GLib
|
||||
import os
|
||||
import gtkgui_helpers
|
||||
import message_control
|
||||
from gajim import gtkgui_helpers
|
||||
from gajim import message_control
|
||||
|
||||
from common import gajim
|
||||
from common import helpers
|
||||
from common import i18n
|
||||
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
|
||||
from nbxmpp.protocol import NS_JINGLE_FILE_TRANSFER_5, NS_CONFERENCE
|
||||
from gtkgui_helpers import get_action
|
||||
from gajim.gtkgui_helpers import get_action
|
||||
|
||||
def build_resources_submenu(contacts, account, action, room_jid=None,
|
||||
room_account=None, cap=None):
|
||||
|
@ -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
|
||||
|
|
|
@ -39,7 +39,7 @@ from gi.repository import GLib
|
|||
import time
|
||||
|
||||
import getopt
|
||||
from common import i18n
|
||||
from gajim.common import i18n
|
||||
|
||||
def parseOpts():
|
||||
config_path = None
|
||||
|
@ -68,14 +68,14 @@ def parseOpts():
|
|||
config_path = parseOpts()
|
||||
del parseOpts
|
||||
|
||||
import common.configpaths
|
||||
common.configpaths.gajimpaths.init(config_path)
|
||||
import gajim.common.configpaths
|
||||
gajim.common.configpaths.gajimpaths.init(config_path)
|
||||
del config_path
|
||||
from common import gajim
|
||||
import gtkgui_helpers
|
||||
from common.logger import LOG_DB_PATH, JIDConstant, KindConstant
|
||||
from common import helpers
|
||||
import dialogs
|
||||
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
|
||||
from gajim import dialogs
|
||||
|
||||
from enum import IntEnum, unique
|
||||
|
||||
|
@ -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_ = '<span'
|
||||
|
@ -461,7 +461,7 @@ class HistoryManager:
|
|||
|
||||
dlg = xml.get_object('filechooserdialog')
|
||||
dlg.set_title(_('Exporting History Logs…'))
|
||||
dlg.set_current_folder(gajim.HOME_DIR)
|
||||
dlg.set_current_folder(app.HOME_DIR)
|
||||
dlg.props.do_overwrite_confirmation = True
|
||||
response = dlg.run()
|
||||
|
||||
|
|
|
@ -24,9 +24,9 @@ from datetime import datetime, timedelta, timezone
|
|||
import nbxmpp
|
||||
from gi.repository import Gtk, GLib
|
||||
|
||||
from common import gajim
|
||||
from common import ged
|
||||
from gtkgui_helpers import get_icon_pixmap
|
||||
from gajim.common import app
|
||||
from gajim.common import ged
|
||||
from gajim.gtkgui_helpers import get_icon_pixmap
|
||||
|
||||
log = logging.getLogger('gajim.c.message_archiving')
|
||||
|
||||
|
@ -48,7 +48,7 @@ class HistorySyncAssistant(Gtk.Assistant):
|
|||
self.set_name('HistorySyncAssistant')
|
||||
self.set_transient_for(parent)
|
||||
self.account = account
|
||||
self.con = gajim.connections[self.account]
|
||||
self.con = app.connections[self.account]
|
||||
self.timedelta = None
|
||||
self.now = datetime.utcnow()
|
||||
self.query_id = None
|
||||
|
@ -58,7 +58,7 @@ class HistorySyncAssistant(Gtk.Assistant):
|
|||
self.next = None
|
||||
self.hide_buttons()
|
||||
|
||||
mam_start = gajim.config.get_per('accounts', account, 'mam_start_date')
|
||||
mam_start = app.config.get_per('accounts', account, 'mam_start_date')
|
||||
if not mam_start or mam_start == ArchiveState.NEVER:
|
||||
self.current_start = self.now
|
||||
elif mam_start == ArchiveState.ALL:
|
||||
|
@ -80,10 +80,10 @@ class HistorySyncAssistant(Gtk.Assistant):
|
|||
self.set_page_type(self.summary, Gtk.AssistantPageType.SUMMARY)
|
||||
self.set_page_complete(self.summary, True)
|
||||
|
||||
gajim.ged.register_event_handler('archiving-finished',
|
||||
app.ged.register_event_handler('archiving-finished',
|
||||
ged.PRECORE,
|
||||
self._nec_archiving_finished)
|
||||
gajim.ged.register_event_handler('raw-mam-message-received',
|
||||
app.ged.register_event_handler('raw-mam-message-received',
|
||||
ged.PRECORE,
|
||||
self._nec_mam_message_received)
|
||||
|
||||
|
@ -164,13 +164,13 @@ class HistorySyncAssistant(Gtk.Assistant):
|
|||
self.prepare_query()
|
||||
|
||||
def on_destroy(self, *args):
|
||||
gajim.ged.remove_event_handler('archiving-finished',
|
||||
app.ged.remove_event_handler('archiving-finished',
|
||||
ged.PRECORE,
|
||||
self._nec_archiving_finished)
|
||||
gajim.ged.remove_event_handler('raw-mam-message-received',
|
||||
app.ged.remove_event_handler('raw-mam-message-received',
|
||||
ged.PRECORE,
|
||||
self._nec_mam_message_received)
|
||||
del gajim.interface.instances[self.account]['history_sync']
|
||||
del app.interface.instances[self.account]['history_sync']
|
||||
|
||||
def on_close_clicked(self, *args):
|
||||
self.destroy()
|
||||
|
@ -223,7 +223,7 @@ class HistorySyncAssistant(Gtk.Assistant):
|
|||
timestamp = self.start.timestamp()
|
||||
else:
|
||||
timestamp = ArchiveState.ALL
|
||||
gajim.config.set_per('accounts', self.account,
|
||||
app.config.set_per('accounts', self.account,
|
||||
'mam_start_date', timestamp)
|
||||
log.debug('config: set mam_start_date: %s', timestamp)
|
||||
self.set_current_page(Pages.SUMMARY)
|
||||
|
|
|
@ -34,15 +34,15 @@ import datetime
|
|||
|
||||
from enum import IntEnum, unique
|
||||
|
||||
import gtkgui_helpers
|
||||
import conversation_textview
|
||||
import dialogs
|
||||
from gajim import gtkgui_helpers
|
||||
from gajim import conversation_textview
|
||||
from gajim import dialogs
|
||||
|
||||
from common import gajim
|
||||
from common import helpers
|
||||
from common import exceptions
|
||||
from gajim.common import app
|
||||
from gajim.common import helpers
|
||||
from gajim.common import exceptions
|
||||
|
||||
from common.logger import ShowConstant, KindConstant
|
||||
from gajim.common.logger import ShowConstant, KindConstant
|
||||
|
||||
@unique
|
||||
class InfoColumn(IntEnum):
|
||||
|
@ -131,11 +131,11 @@ class HistoryWindow:
|
|||
self._load_history(None)
|
||||
|
||||
gtkgui_helpers.resize_window(self.window,
|
||||
gajim.config.get('history_window_width'),
|
||||
gajim.config.get('history_window_height'))
|
||||
app.config.get('history_window_width'),
|
||||
app.config.get('history_window_height'))
|
||||
gtkgui_helpers.move_window(self.window,
|
||||
gajim.config.get('history_window_x-position'),
|
||||
gajim.config.get('history_window_y-position'))
|
||||
app.config.get('history_window_x-position'),
|
||||
app.config.get('history_window_y-position'))
|
||||
|
||||
xml.connect_signals(self)
|
||||
self.window.show_all()
|
||||
|
@ -154,17 +154,17 @@ class HistoryWindow:
|
|||
liststore = gtkgui_helpers.get_completion_liststore(self.jid_entry)
|
||||
|
||||
# Add all jids in logs.db:
|
||||
db_jids = gajim.logger.get_jids_in_db()
|
||||
db_jids = app.logger.get_jids_in_db()
|
||||
completion_dict = dict.fromkeys(db_jids)
|
||||
|
||||
self.accounts_seen_online = list(gajim.contacts.get_accounts())
|
||||
self.accounts_seen_online = list(app.contacts.get_accounts())
|
||||
|
||||
# Enhance contacts of online accounts with contact. Needed for mapping below
|
||||
for account in self.accounts_seen_online:
|
||||
completion_dict.update(helpers.get_contact_dict_for_account(account))
|
||||
|
||||
muc_active_img = gtkgui_helpers.load_icon('muc_active')
|
||||
contact_img = gajim.interface.jabber_state_images['16']['online']
|
||||
contact_img = app.interface.jabber_state_images['16']['online']
|
||||
muc_active_pix = muc_active_img.get_pixbuf()
|
||||
contact_pix = contact_img.get_pixbuf()
|
||||
|
||||
|
@ -196,12 +196,12 @@ class HistoryWindow:
|
|||
|
||||
info_acc = self._get_account_for_jid(info_jid)
|
||||
|
||||
if gajim.logger.jid_is_room_jid(completed) or\
|
||||
gajim.logger.jid_is_from_pm(completed):
|
||||
if app.logger.jid_is_room_jid(completed) or\
|
||||
app.logger.jid_is_from_pm(completed):
|
||||
pix = muc_active_pix
|
||||
if gajim.logger.jid_is_from_pm(completed):
|
||||
if app.logger.jid_is_from_pm(completed):
|
||||
# It's PM. Make it easier to find
|
||||
room, nick = gajim.get_room_and_nick_from_fjid(completed)
|
||||
room, nick = app.get_room_and_nick_from_fjid(completed)
|
||||
info_completion = '%s from %s' % (nick, room)
|
||||
completed = info_completion
|
||||
info_completion2 = '%s/%s' % (room, nick)
|
||||
|
@ -234,11 +234,11 @@ class HistoryWindow:
|
|||
Return the corresponding account of the jid. May be None if an account
|
||||
could not be found
|
||||
"""
|
||||
accounts = gajim.contacts.get_accounts()
|
||||
accounts = app.contacts.get_accounts()
|
||||
account = None
|
||||
for acc in accounts:
|
||||
jid_list = gajim.contacts.get_jid_list(acc)
|
||||
gc_list = gajim.contacts.get_gc_list(acc)
|
||||
jid_list = app.contacts.get_jid_list(acc)
|
||||
gc_list = app.contacts.get_gc_list(acc)
|
||||
if jid in jid_list or jid in gc_list:
|
||||
account = acc
|
||||
break
|
||||
|
@ -246,7 +246,7 @@ class HistoryWindow:
|
|||
|
||||
def on_history_window_destroy(self, widget):
|
||||
self.history_textview.del_handlers()
|
||||
del gajim.interface.instances['logs']
|
||||
del app.interface.instances['logs']
|
||||
|
||||
def on_history_window_key_press_event(self, widget, event):
|
||||
if event.keyval == Gdk.KEY_Escape:
|
||||
|
@ -287,14 +287,14 @@ class HistoryWindow:
|
|||
self.checkbutton.set_sensitive(False)
|
||||
else:
|
||||
# Are log disabled for account ?
|
||||
if self.account in gajim.config.get_per('accounts', self.account,
|
||||
if self.account in app.config.get_per('accounts', self.account,
|
||||
'no_log_for').split(' '):
|
||||
self.checkbutton.set_active(False)
|
||||
self.checkbutton.set_sensitive(False)
|
||||
else:
|
||||
# Are log disabled for jid ?
|
||||
log = True
|
||||
if self.jid in gajim.config.get_per('accounts', self.account,
|
||||
if self.jid in app.config.get_per('accounts', self.account,
|
||||
'no_log_for').split(' '):
|
||||
log = False
|
||||
self.checkbutton.set_active(log)
|
||||
|
@ -305,7 +305,7 @@ class HistoryWindow:
|
|||
# select logs for last date we have logs with contact
|
||||
self.calendar.set_sensitive(True)
|
||||
last_log = \
|
||||
gajim.logger.get_last_date_that_has_logs(self.account, self.jid)
|
||||
app.logger.get_last_date_that_has_logs(self.account, self.jid)
|
||||
|
||||
date = time.localtime(last_log)
|
||||
|
||||
|
@ -361,7 +361,7 @@ class HistoryWindow:
|
|||
month = gtkgui_helpers.make_gtk_month_python_month(month)
|
||||
|
||||
try:
|
||||
log_days = gajim.logger.get_days_with_logs(
|
||||
log_days = app.logger.get_days_with_logs(
|
||||
self.account, self.jid, year, month)
|
||||
except exceptions.PysqliteOperationalError as e:
|
||||
dialogs.ErrorDialog(_('Disk Error'), str(e))
|
||||
|
@ -398,7 +398,7 @@ class HistoryWindow:
|
|||
|
||||
date = datetime.datetime(year, month, day)
|
||||
|
||||
conversation = gajim.logger.get_conversation_for_date(
|
||||
conversation = app.logger.get_conversation_for_date(
|
||||
self.account, self.jid, date)
|
||||
|
||||
for message in conversation:
|
||||
|
@ -427,13 +427,13 @@ class HistoryWindow:
|
|||
# Make the beginning of every message searchable by its log_line_id
|
||||
buf.create_mark(str(log_line_id), end_iter, left_gravity=True)
|
||||
|
||||
if gajim.config.get('print_time') == 'always':
|
||||
timestamp_str = gajim.config.get('time_stamp')
|
||||
if app.config.get('print_time') == 'always':
|
||||
timestamp_str = app.config.get('time_stamp')
|
||||
timestamp_str = helpers.from_one_line(timestamp_str)
|
||||
tim = time.strftime(timestamp_str, time.localtime(float(tim)))
|
||||
buf.insert(end_iter, tim)
|
||||
elif gajim.config.get('print_time') == 'sometimes':
|
||||
every_foo_seconds = 60 * gajim.config.get(
|
||||
elif app.config.get('print_time') == 'sometimes':
|
||||
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:
|
||||
|
@ -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)
|
||||
|
|
|
@ -48,17 +48,17 @@ from io import StringIO
|
|||
import urllib
|
||||
|
||||
if __name__ == '__main__':
|
||||
from common import i18n
|
||||
import common.configpaths
|
||||
common.configpaths.gajimpaths.init(None)
|
||||
from common import gajim
|
||||
import gtkgui_helpers
|
||||
from gtkgui_helpers import get_icon_pixmap
|
||||
from common import helpers
|
||||
from common.exceptions import GajimGeneralException
|
||||
import dialogs
|
||||
from gajim.common import i18n
|
||||
import gajim.common.configpaths
|
||||
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
|
||||
from gajim.common.exceptions import GajimGeneralException
|
||||
from gajim import dialogs
|
||||
|
||||
import tooltips
|
||||
from gajim import tooltips
|
||||
import logging
|
||||
log = logging.getLogger('gajim.htmlview')
|
||||
|
||||
|
@ -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:
|
||||
|
@ -924,7 +924,7 @@ class HtmlTextView(Gtk.TextView):
|
|||
dialogs.AddNewContactWindow(self.account, jid)
|
||||
|
||||
def make_link_menu(self, event, kind, text):
|
||||
from gtkgui_helpers import get_gtk_builder
|
||||
from gajim.gtkgui_helpers import get_gtk_builder
|
||||
xml = get_gtk_builder('chat_context_menu.ui')
|
||||
menu = xml.get_object('chat_context_menu')
|
||||
childs = menu.get_children()
|
||||
|
@ -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)
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ Documentation: http://www.freedesktop.org/wiki/Software/systemd/inhibit
|
|||
import os
|
||||
import logging
|
||||
|
||||
from common import dbus_support
|
||||
from common import gajim
|
||||
from gajim.common import dbus_support
|
||||
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
|
||||
|
@ -67,7 +67,7 @@ def on_suspend(active):
|
|||
def get_inhibitor():
|
||||
'''Ask for a suspend delay inhibitor'''
|
||||
|
||||
from common.dbus_support import system_bus, dbus
|
||||
from gajim.common.dbus_support import system_bus, dbus
|
||||
bus = system_bus.bus()
|
||||
global fd
|
||||
|
||||
|
@ -91,7 +91,7 @@ def set_listener():
|
|||
|
||||
@return bool whether it succeeded
|
||||
'''
|
||||
from common.dbus_support import system_bus
|
||||
from gajim.common.dbus_support import system_bus
|
||||
bus = system_bus.bus()
|
||||
|
||||
if not 'org.freedesktop.login1' in bus.list_names():
|
||||
|
|
|
@ -26,13 +26,13 @@
|
|||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
import gtkgui_helpers
|
||||
from gajim import gtkgui_helpers
|
||||
import uuid
|
||||
|
||||
from common import gajim
|
||||
from common import helpers
|
||||
from common import ged
|
||||
from common.stanza_session import EncryptedStanzaSession, ArchivingStanzaSession
|
||||
from gajim.common import app
|
||||
from gajim.common import helpers
|
||||
from gajim.common import ged
|
||||
from gajim.common.stanza_session import EncryptedStanzaSession, ArchivingStanzaSession
|
||||
|
||||
# Derived types MUST register their type IDs here if custom behavor is required
|
||||
TYPE_CHAT = 'chat'
|
||||
|
@ -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:
|
||||
|
|
|
@ -28,8 +28,8 @@ from gi.repository import GObject
|
|||
from gi.repository import GLib
|
||||
from gi.repository import Pango
|
||||
|
||||
from common import gajim
|
||||
import gtkgui_helpers
|
||||
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]
|
||||
|
|
|
@ -34,15 +34,15 @@ from gi.repository import GObject
|
|||
from gi.repository import GLib
|
||||
import time
|
||||
|
||||
import common
|
||||
import gtkgui_helpers
|
||||
import message_control
|
||||
import dialogs
|
||||
from chat_control_base import ChatControlBase
|
||||
from chat_control import ChatControl
|
||||
from gajim import common
|
||||
from gajim import gtkgui_helpers
|
||||
from gajim import message_control
|
||||
from gajim import dialogs
|
||||
from gajim.chat_control_base import ChatControlBase
|
||||
from gajim.chat_control import ChatControl
|
||||
|
||||
from common import gajim
|
||||
from gtkgui_helpers import get_action
|
||||
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]))
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
from gi.repository import GObject
|
||||
if __name__ == '__main__':
|
||||
# install _() func before importing dbus_support
|
||||
from common import i18n
|
||||
from gajim.common import i18n
|
||||
|
||||
from common import dbus_support
|
||||
from gajim.common import dbus_support
|
||||
if dbus_support.supported:
|
||||
import dbus
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
import gtkgui_helpers
|
||||
import dataforms_widget
|
||||
from gajim import gtkgui_helpers
|
||||
from gajim import dataforms_widget
|
||||
|
||||
from common import dataforms
|
||||
from common import gajim
|
||||
from gajim.common import dataforms
|
||||
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()
|
||||
|
|
|
@ -24,7 +24,7 @@ import logging
|
|||
|
||||
from gi.repository import Gio, GLib
|
||||
|
||||
from 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()
|
||||
|
|
|
@ -29,16 +29,16 @@
|
|||
|
||||
import os
|
||||
import time
|
||||
from dialogs import PopupNotificationWindow
|
||||
from gajim.dialogs import PopupNotificationWindow
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GLib
|
||||
import gtkgui_helpers
|
||||
from gajim import gtkgui_helpers
|
||||
|
||||
from common import gajim
|
||||
from common import helpers
|
||||
from common import ged
|
||||
from gajim.common import app
|
||||
from gajim.common import helpers
|
||||
from gajim.common import ged
|
||||
|
||||
from common import dbus_support
|
||||
from gajim.common import dbus_support
|
||||
if dbus_support.supported:
|
||||
import dbus
|
||||
|
||||
|
@ -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:
|
||||
|
|
|
@ -24,7 +24,7 @@ Main file of plugins package.
|
|||
:license: GPL
|
||||
'''
|
||||
|
||||
from .pluginmanager import PluginManager
|
||||
from .gajimplugin import GajimPlugin
|
||||
from gajim.plugins.pluginmanager import PluginManager
|
||||
from gajim.plugins.gajimplugin import GajimPlugin
|
||||
|
||||
__all__ = ['PluginManager', 'GajimPlugin']
|
||||
|
|
|
@ -27,10 +27,10 @@ Base class for implementing plugin.
|
|||
import os
|
||||
import locale
|
||||
|
||||
from common import gajim
|
||||
from gajim.common import app
|
||||
|
||||
from plugins.helpers import log_calls, log
|
||||
from plugins.gui import GajimPluginConfigDialog
|
||||
from gajim.plugins.helpers import log_calls, log
|
||||
from gajim.plugins.gui import GajimPluginConfigDialog
|
||||
|
||||
import logging
|
||||
log = logging.getLogger('gajim.p.plugin')
|
||||
|
@ -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')
|
||||
|
|
|
@ -34,14 +34,14 @@ import os
|
|||
|
||||
from enum import IntEnum, unique
|
||||
|
||||
import gtkgui_helpers
|
||||
from dialogs import WarningDialog, YesNoDialog, ArchiveChooserDialog
|
||||
from htmltextview import HtmlTextView
|
||||
from common import gajim
|
||||
from plugins.helpers import log_calls
|
||||
from plugins.helpers import GajimPluginActivateException
|
||||
from plugins.plugins_i18n import _
|
||||
from common.exceptions import PluginsystemError
|
||||
from gajim import gtkgui_helpers
|
||||
from gajim.dialogs import WarningDialog, YesNoDialog, ArchiveChooserDialog
|
||||
from gajim.htmltextview import HtmlTextView
|
||||
from gajim.common import app
|
||||
from gajim.plugins.helpers import log_calls
|
||||
from gajim.plugins.helpers import GajimPluginActivateException
|
||||
from gajim.plugins.plugins_i18n import _
|
||||
from gajim.common.exceptions import PluginsystemError
|
||||
|
||||
@unique
|
||||
class Column(IntEnum):
|
||||
|
@ -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'):
|
||||
|
|
|
@ -34,13 +34,13 @@ from shutil import rmtree
|
|||
import configparser
|
||||
from pkg_resources import parse_version
|
||||
|
||||
from common import gajim
|
||||
from common import nec
|
||||
from common.exceptions import PluginsystemError
|
||||
from gajim.common import app
|
||||
from gajim.common import nec
|
||||
from gajim.common.exceptions import PluginsystemError
|
||||
|
||||
from plugins.helpers import log, log_calls, Singleton
|
||||
from plugins.helpers import GajimPluginActivateException
|
||||
from plugins.gajimplugin import GajimPlugin, GajimPluginException
|
||||
from gajim.plugins.helpers import log, log_calls, Singleton
|
||||
from gajim.plugins.helpers import GajimPluginActivateException
|
||||
from gajim.plugins.gajimplugin import GajimPlugin, GajimPluginException
|
||||
|
||||
class PluginManager(metaclass=Singleton):
|
||||
'''
|
||||
|
@ -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')
|
||||
|
@ -460,7 +460,7 @@ class PluginManager(metaclass=Singleton):
|
|||
|
||||
:todo: add scanning zipped modules
|
||||
'''
|
||||
from plugins.plugins_i18n import _
|
||||
from gajim.plugins.plugins_i18n import _
|
||||
plugins_found = []
|
||||
conf = configparser.ConfigParser()
|
||||
fields = ('name', 'short_name', 'version', 'description', 'authors',
|
||||
|
@ -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):
|
||||
|
|
|
@ -22,10 +22,10 @@ import locale
|
|||
import gettext
|
||||
from os import path as os_path
|
||||
import os
|
||||
from 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, '')
|
||||
|
@ -36,5 +36,5 @@ try:
|
|||
t = gettext.translation(APP, plugins_locale_dir)
|
||||
_ = t.gettext
|
||||
except IOError:
|
||||
from common import i18n
|
||||
from gajim.common import i18n
|
||||
_ = gettext.gettext
|
||||
|
|
|
@ -32,12 +32,12 @@ import mimetypes
|
|||
import os
|
||||
import time
|
||||
|
||||
import gtkgui_helpers
|
||||
import dialogs
|
||||
import vcard
|
||||
from gajim import gtkgui_helpers
|
||||
from gajim import dialogs
|
||||
from gajim import vcard
|
||||
|
||||
from common import gajim
|
||||
from common import ged
|
||||
from gajim.common import app
|
||||
from gajim.common import ged
|
||||
|
||||
|
||||
class ProfileWindow:
|
||||
|
@ -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()
|
||||
|
|
|
@ -32,16 +32,16 @@ import os
|
|||
import base64
|
||||
import mimetypes
|
||||
|
||||
from common import gajim
|
||||
from common import helpers
|
||||
from gajim.common import app
|
||||
from gajim.common import helpers
|
||||
from time import time
|
||||
from dialogs import AddNewContactWindow, NewChatDialog, JoinGroupchatWindow
|
||||
from common import ged
|
||||
from common.connection_handlers_events import MessageOutgoingEvent
|
||||
from common.connection_handlers_events import GcMessageOutgoingEvent
|
||||
from gajim.dialogs import AddNewContactWindow, NewChatDialog, JoinGroupchatWindow
|
||||
from gajim.common import ged
|
||||
from gajim.common.connection_handlers_events import MessageOutgoingEvent
|
||||
from gajim.common.connection_handlers_events import GcMessageOutgoingEvent
|
||||
|
||||
|
||||
from common import dbus_support
|
||||
from gajim.common import dbus_support
|
||||
if dbus_support.supported:
|
||||
import dbus
|
||||
if dbus_support:
|
||||
|
@ -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)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -23,15 +23,15 @@ from gi.repository import GLib
|
|||
from gi.repository import Gtk
|
||||
from gi.repository import Gdk
|
||||
|
||||
from common import gajim
|
||||
from common import dataforms
|
||||
from common import ged
|
||||
from gajim.common import app
|
||||
from gajim.common import dataforms
|
||||
from gajim.common import ged
|
||||
|
||||
import gtkgui_helpers
|
||||
import dialogs
|
||||
import vcard
|
||||
import config
|
||||
import dataforms_widget
|
||||
from gajim import gtkgui_helpers
|
||||
from gajim import dialogs
|
||||
from gajim import vcard
|
||||
from gajim import config
|
||||
from gajim import dataforms_widget
|
||||
|
||||
class SearchWindow:
|
||||
def __init__(self, account, jid):
|
||||
|
@ -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):
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue