Commit ce480aa5 authored by Philipp Hörist's avatar Philipp Hörist

[omemo] Refactor whole plugin

- create a OMEMOConnection class to mimic more how Gajim does things
parent 18598abf
......@@ -52,18 +52,18 @@ UNDECIDED = 2
class OmemoState:
def __init__(self, own_jid, connection, account, plugin):
def __init__(self, own_jid, db_con, account, xmpp_con):
""" Instantiates an OmemoState object.
:param connection: an :py:class:`sqlite3.Connection`
"""
self.account = account
self.plugin = plugin
self.xmpp_con = xmpp_con
self.session_ciphers = {}
self.own_jid = own_jid
self.device_ids = {}
self.own_devices = []
self.store = LiteAxolotlStore(connection)
self.store = LiteAxolotlStore(db_con)
self.encryption = self.store.encryptionStore
for jid, device_id in self.store.getActiveDeviceTuples():
if jid != own_jid:
......@@ -302,8 +302,8 @@ class OmemoState:
self.get_session_cipher(tup[0], tup[1])
# Encrypt the message key with for each of receivers devices
for nick in self.plugin.groupchat[room]:
jid_to = self.plugin.groupchat[room][nick]
for nick in self.xmpp_con.groupchat[room]:
jid_to = self.xmpp_con.groupchat[room][nick]
if jid_to == self.own_jid:
continue
if jid_to in encrypted_jids: # We already encrypted to this JID
......@@ -366,8 +366,8 @@ class OmemoState:
if gc:
room = jid
devicelist = []
for nick in self.plugin.groupchat[room]:
jid_to = self.plugin.groupchat[room][nick]
for nick in self.xmpp_con.groupchat[room]:
jid_to = self.xmpp_con.groupchat[room][nick]
if jid_to == self.own_jid:
continue
try:
......@@ -449,7 +449,7 @@ class OmemoState:
key = sessionCipher.decryptPkmsg(preKeyWhisperMessage)
# Publish new bundle after PreKey has been used
# for building a new Session
self.plugin.publish_bundle(self.account)
self.xmpp_con.publish_bundle()
self.add_device(recipient_id, device_id)
return key
except UntrustedIdentityException as e:
......
This diff is collapsed.
This diff is collapsed.
......@@ -174,7 +174,7 @@ class OMEMOConfigDialog(GajimPluginConfigDialog):
active = self.B.get_object('account_combobox').get_active()
account = self.account_store[active][0]
state = self.plugin.get_omemo_state(account)
state = self.plugin.get_omemo(account)
mod, paths = self.fpr_view.get_selection().get_selected_rows()
......@@ -202,7 +202,7 @@ class OMEMOConfigDialog(GajimPluginConfigDialog):
active = self.B.get_object('account_combobox').get_active()
account = self.account_store[active][0]
state = self.plugin.get_omemo_state(account)
state = self.plugin.get_omemo(account)
mod, paths = self.fpr_view.get_selection().get_selected_rows()
......@@ -311,7 +311,7 @@ class OMEMOConfigDialog(GajimPluginConfigDialog):
self.B.get_object('cleardevice_button').set_sensitive(True)
# Set FPR Label and DeviceID
state = self.plugin.get_omemo_state(account)
state = self.plugin.get_omemo(account)
deviceid = state.own_device_id
self.B.get_object('ID').set_markup('<tt>%s</tt>' % deviceid)
......@@ -373,7 +373,7 @@ class FingerprintWindow(Gtk.Dialog):
self.windowinstances = windowinstances
self.account = self.contact.account.name
self.plugin = plugin
self.omemostate = self.plugin.get_omemo_state(self.account)
self.omemostate = self.plugin.get_omemo(self.account)
self.own_jid = app.get_jid_from_account(self.account)
Gtk.Dialog.__init__(self,
title=('Fingerprints for %s') % contact.jid,
......
......@@ -39,6 +39,7 @@ NS_OMEMO = 'eu.siacs.conversations.axolotl'
NS_DEVICE_LIST = NS_OMEMO + '.devicelist'
NS_NOTIFY = NS_DEVICE_LIST + '+notify'
NS_BUNDLES = NS_OMEMO + '.bundles:'
NS_HINTS = 'urn:xmpp:hints'
log = logging.getLogger('gajim.plugin_system.omemo')
......@@ -149,7 +150,7 @@ class DevicelistQuery(Iq):
class DevicelistPEP(AbstractPEP):
type_ = 'headline'
type_ = 'omemo-devicelist'
namespace = NS_DEVICE_LIST
def _extract_info(self, items):
......
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