Commit 87ece239 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

[omemo] Refactor AxolotlStore

- Dont use cursor object
- Use namedtuple factory
parent 41cd8530
This diff is collapsed.
......@@ -17,8 +17,6 @@
import logging
import time
import binascii
import textwrap
from collections import defaultdict
from nbxmpp.structs import OMEMOBundle
......@@ -53,14 +51,15 @@ UNDECIDED = 2
class OmemoState:
def __init__(self, own_jid, db_con, account, xmpp_con):
def __init__(self, own_jid, db_path, account, xmpp_con):
self.account = account
self.xmpp_con = xmpp_con
self._session_ciphers = defaultdict(dict)
self.own_jid = own_jid
self.device_ids = {}
self.own_devices = []
self.store = LiteAxolotlStore(db_con)
self.store = LiteAxolotlStore(db_path)
for jid, device_id in self.store.getActiveDeviceTuples():
if jid != own_jid:
self.add_device(jid, device_id)
......
......@@ -19,7 +19,6 @@
import os
import time
import logging
import sqlite3
import nbxmpp
from nbxmpp.protocol import NodeProcessed
......@@ -30,7 +29,6 @@ from nbxmpp.structs import StanzaHandler
from nbxmpp.modules.omemo import create_omemo_message
from gajim.common import app
from gajim.common import ged
from gajim.common import helpers
from gajim.common import configpaths
from gajim.common.nec import NetworkEvent
......@@ -117,9 +115,7 @@ class OMEMO(BaseModule):
def __get_omemo(self):
data_dir = configpaths.get('MY_DATA')
db_path = os.path.join(data_dir, 'omemo_' + self.own_jid + '.db')
conn = sqlite3.connect(db_path, check_same_thread=False)
conn.execute("PRAGMA secure_delete=1")
return OmemoState(self.own_jid, conn, self._account, self)
return OmemoState(self.own_jid, db_path, self._account, self)
def on_signed_in(self):
log.info('%s => Announce Support after Sign In', self._account)
......
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