From 247602d0f7f0b5447607a5c08fc5e11956b7116c Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Sat, 15 Oct 2022 20:50:34 +0300 Subject: [PATCH] Gajim 1.3 compatibility fixes [WIP] --- otr.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/otr.py b/otr.py index f7c2d4a..1a8e9cf 100644 --- a/otr.py +++ b/otr.py @@ -1,5 +1,6 @@ ## Copyright (C) 2008-2012 Kjell Braden ## Copyright (C) 2019 Pavel R. +## Copyright (C) 2022 Bohdan Horbeshko # # This file is part of Gajim OTR Plugin. @@ -21,6 +22,7 @@ import itertools import logging from inspect import signature from gajim.common import const, app, helpers, configpaths +from gajim.common.const import EncryptionData from nbxmpp.protocol import Message, JID import pathlib @@ -91,7 +93,7 @@ class OTR(context.Account): self.account = account self.stream = app.connections[account] self.jid = self.stream.get_own_jid() - self.keystore = Keystore(os.path.join(configpaths.get('MY_DATA'), 'otr_' + self.jid.getStripped() + '.db')) + self.keystore = Keystore(os.path.join(configpaths.get('MY_DATA'), 'otr_' + self.jid.bare + '.db')) self.loadTrusts() # get chat control @@ -107,12 +109,12 @@ class OTR(context.Account): # load my private key def loadPrivkey(self): - my = self.keystore.load(jid=self.jid) + my = self.keystore.load(jid=str(self.jid)) return (my and my.privatekey) and crypt.PK.parsePrivateKey(bytes.fromhex(my.privatekey))[0] or None # save my privatekey def savePrivkey(self): - self.keystore.save(jid=self.jid,privatekey=self.getPrivkey().serializePrivateKey().hex()) + self.keystore.save(jid=str(self.jid),privatekey=self.getPrivkey().serializePrivateKey().hex()) # load known fingerprints def loadTrusts(self): @@ -121,7 +123,7 @@ class OTR(context.Account): # save known fingerprints def saveTrusts(self): for peer,fingerprints in self.trusts.items(): - for fingerprint,trust in fingerprints.items(): self.keystore.save(jid=peer,fingerprint=fingerprint,trust=trust) + for fingerprint,trust in fingerprints.items(): self.keystore.save(jid=str(peer),fingerprint=fingerprint,trust=trust) # decrypt message def decrypt(self,stanza,properties): @@ -134,8 +136,8 @@ class OTR(context.Account): self.log.error("** got exception while decrypting message: %s" % e) channel.printl(OTR.STATUS[e].format(msg=msgtxt,err=e.args[0].error)) else: - event.setBody(text and text.decode() or "") - properties.encrypted = OTR.ENCRYPTION_NAME + stanza.setBody(text and text.decode() or "") + properties.encrypted = EncryptionData({'name': OTR.ENCRYPTION_NAME}) finally: if channel.mayRetransmit and channel.state and ctl: channel.mayRetransmit = ctl.send_message(channel.lastMessage.decode())