Commit 6634da0a authored by Philipp Hörist's avatar Philipp Hörist

[omemo] Adapt to Gajim changes

parent 5fc7a775
...@@ -171,7 +171,7 @@ class OMEMOConfigDialog(GajimPluginConfigDialog): ...@@ -171,7 +171,7 @@ class OMEMOConfigDialog(GajimPluginConfigDialog):
def cleardevice_button_clicked_cb(self, button, *args): def cleardevice_button_clicked_cb(self, button, *args):
active = self._ui.get_object('account_combobox').get_active() active = self._ui.get_object('account_combobox').get_active()
account = self.account_store[active][0] account = self.account_store[active][0]
self.plugin.connections[account].publish_own_devices_list(new=True) app.connections[account].get_module('OMEMO').publish_own_devices_list(new=True)
self.update_context_list() self.update_context_list()
def refresh_button_clicked_cb(self, button, *args): def refresh_button_clicked_cb(self, button, *args):
......
...@@ -60,7 +60,7 @@ class KeyDialog(Gtk.Dialog): ...@@ -60,7 +60,7 @@ class KeyDialog(Gtk.Dialog):
self._windowinstances = windowinstances self._windowinstances = windowinstances
self._account = self._contact.account.name self._account = self._contact.account.name
self._plugin = plugin self._plugin = plugin
self._con = plugin.connections[self._account] self._con = app.connections[self._account].get_module('OMEMO')
self.omemostate = self._plugin.get_omemo(self._account) self.omemostate = self._plugin.get_omemo(self._account)
self._own_jid = app.get_jid_from_account(self._account) self._own_jid = app.get_jid_from_account(self._account)
......
...@@ -71,7 +71,7 @@ except Exception as error: ...@@ -71,7 +71,7 @@ except Exception as error:
if not ERROR_MSG: if not ERROR_MSG:
try: try:
from omemo.omemo_connection import OMEMOConnection from omemo.modules import omemo
except Exception as error: except Exception as error:
log.error(error) log.error(error)
ERROR_MSG = 'Error: %s' % error ERROR_MSG = 'Error: %s' % error
...@@ -98,8 +98,12 @@ class OmemoPlugin(GajimPlugin): ...@@ -98,8 +98,12 @@ class OmemoPlugin(GajimPlugin):
self.allow_groupchat = True self.allow_groupchat = True
self.events_handlers = { self.events_handlers = {
'signed-in': (ged.PRECORE, self.signed_in), 'signed-in': (ged.PRECORE, self.signed_in),
} 'omemo-new-fingerprint': (ged.PRECORE, self._on_new_fingerprints),
}
self.modules = [
omemo,
# omemo_devicelist,
]
self.config_dialog = OMEMOConfigDialog(self) self.config_dialog = OMEMOConfigDialog(self)
self.gui_extension_points = { self.gui_extension_points = {
'hyperlink_handler': (self._file_decryption, None), 'hyperlink_handler': (self._file_decryption, None),
...@@ -118,7 +122,6 @@ class OmemoPlugin(GajimPlugin): ...@@ -118,7 +122,6 @@ class OmemoPlugin(GajimPlugin):
SUPPORTED_PERSONAL_USER_EVENTS.append(DevicelistPEP) SUPPORTED_PERSONAL_USER_EVENTS.append(DevicelistPEP)
self.disabled_accounts = [] self.disabled_accounts = []
self.windowinstances = {} self.windowinstances = {}
self.connections = {}
self.config_default_values = {'DISABLED_ACCOUNTS': ([], ''), } self.config_default_values = {'DISABLED_ACCOUNTS': ([], ''), }
...@@ -162,9 +165,6 @@ class OmemoPlugin(GajimPlugin): ...@@ -162,9 +165,6 @@ class OmemoPlugin(GajimPlugin):
return return
if account in self.disabled_accounts: if account in self.disabled_accounts:
return return
if account not in self.connections:
self.connections[account] = OMEMOConnection(account, self)
self.connections[account].signed_in(event)
def activate(self): def activate(self):
""" Method called when the Plugin is activated in the PluginManager """ Method called when the Plugin is activated in the PluginManager
...@@ -174,27 +174,24 @@ class OmemoPlugin(GajimPlugin): ...@@ -174,27 +174,24 @@ class OmemoPlugin(GajimPlugin):
continue continue
if account in self.disabled_accounts: if account in self.disabled_accounts:
continue continue
self.connections[account] = OMEMOConnection(account, self) app.connections[account].get_module('OMEMO').activate()
self.connections[account].activate()
def deactivate(self): def deactivate(self):
""" Method called when the Plugin is deactivated in the PluginManager """ Method called when the Plugin is deactivated in the PluginManager
""" """
for account in self.connections: for account in app.connections:
if account == 'Local': if account == 'Local':
continue continue
self.connections[account].deactivate() app.connections[account].get_module('OMEMO').deactivate()
def _update_caps(self, account): def _update_caps(self, account):
if account == 'Local': if account == 'Local':
return return
if account not in self.connections: app.connections[account].get_module('OMEMO').update_caps(account)
self.connections[account] = OMEMOConnection(account, self)
self.connections[account].update_caps(account)
def activate_encryption(self, chat_control): def activate_encryption(self, chat_control):
if isinstance(chat_control, GroupchatControl): if isinstance(chat_control, GroupchatControl):
omemo_con = self.connections[chat_control.account] omemo_con = app.connections[chat_control.account].get_module('OMEMO')
if chat_control.room_jid not in omemo_con.groupchat: if chat_control.room_jid not in omemo_con.groupchat:
dialogs.ErrorDialog( dialogs.ErrorDialog(
_('Bad Configuration'), _('Bad Configuration'),
...@@ -206,17 +203,17 @@ class OmemoPlugin(GajimPlugin): ...@@ -206,17 +203,17 @@ class OmemoPlugin(GajimPlugin):
def _message_received(self, conn, obj, callback): def _message_received(self, conn, obj, callback):
if conn.name == 'Local': if conn.name == 'Local':
return return
self.connections[conn.name].message_received(conn, obj, callback) app.connections[conn.name].get_module('OMEMO').message_received(conn, obj, callback)
def _gc_encrypt_message(self, conn, obj, callback): def _gc_encrypt_message(self, conn, obj, callback):
if conn.name == 'Local': if conn.name == 'Local':
return return
self.connections[conn.name].gc_encrypt_message(conn, obj, callback) app.connections[conn.name].get_module('OMEMO').gc_encrypt_message(conn, obj, callback)
def _encrypt_message(self, conn, obj, callback): def _encrypt_message(self, conn, obj, callback):
if conn.name == 'Local': if conn.name == 'Local':
return return
self.connections[conn.name].encrypt_message(conn, obj, callback) app.connections[conn.name].get_module('OMEMO').encrypt_message(conn, obj, callback)
def _file_decryption(self, url, kind, instance, window): def _file_decryption(self, url, kind, instance, window):
file_crypto.FileDecryption(self).hyperlink_handler( file_crypto.FileDecryption(self).hyperlink_handler(
...@@ -249,14 +246,14 @@ class OmemoPlugin(GajimPlugin): ...@@ -249,14 +246,14 @@ class OmemoPlugin(GajimPlugin):
self.show_fingerprint_window(chat_control) self.show_fingerprint_window(chat_control)
def get_omemo(self, account): def get_omemo(self, account):
return self.connections[account].omemo return app.connections[account].get_module('OMEMO').omemo
def before_sendmessage(self, chat_control): def before_sendmessage(self, chat_control):
account = chat_control.account account = chat_control.account
if account == 'Local': if account == 'Local':
return return
contact = chat_control.contact contact = chat_control.contact
con = self.connections[account] con = app.connections[account].get_module('OMEMO')
self.new_fingerprints_available(chat_control) self.new_fingerprints_available(chat_control)
if isinstance(chat_control, GroupchatControl): if isinstance(chat_control, GroupchatControl):
room = chat_control.room_jid room = chat_control.room_jid
...@@ -286,10 +283,13 @@ class OmemoPlugin(GajimPlugin): ...@@ -286,10 +283,13 @@ class OmemoPlugin(GajimPlugin):
log.debug('%s => Sending Message to %s', log.debug('%s => Sending Message to %s',
account, contact.jid) account, contact.jid)
def _on_new_fingerprints(self, event):
self.new_fingerprints_available(event.chat_control)
def new_fingerprints_available(self, chat_control): def new_fingerprints_available(self, chat_control):
jid = chat_control.contact.jid jid = chat_control.contact.jid
account = chat_control.account account = chat_control.account
con = self.connections[account] con = app.connections[account].get_module('OMEMO')
omemo = self.get_omemo(account) omemo = self.get_omemo(account)
if isinstance(chat_control, GroupchatControl): if isinstance(chat_control, GroupchatControl):
room_jid = chat_control.room_jid room_jid = chat_control.room_jid
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment