# HG changeset patch # User souliane # Date 1409580328 -7200 # Node ID 1ac5ea74dbdff9fa7de35061172dad08615052f7 # Parent 4e1a0a1523f184d548b57ec9ab1e1cc3a410ca8e plugin OTR: remove unnecessary attribute SatXMPPClient.otr_priv_key diff -r 4e1a0a1523f1 -r 1ac5ea74dbdf src/plugins/plugin_sec_otr.py --- a/src/plugins/plugin_sec_otr.py Mon Sep 01 11:05:27 2014 +0200 +++ b/src/plugins/plugin_sec_otr.py Mon Sep 01 16:05:28 2014 +0200 @@ -129,7 +129,7 @@ def loadPrivkey(self): log.debug(u"loadPrivkey") - return self.client.otr_priv_key + return self.privkey def savePrivkey(self): log.debug(u"savePrivkey") @@ -222,9 +222,9 @@ encrypted_priv_key = client.otr_data.get(PRIVATE_KEY, None) if encrypted_priv_key is not None: priv_key = yield self.host.memory.decryptValue(encrypted_priv_key, profile) - client.otr_priv_key = potr.crypt.PK.parsePrivateKey(priv_key.decode('hex'))[0] + ctxMng.account.privkey = potr.crypt.PK.parsePrivateKey(priv_key.decode('hex'))[0] else: - client.otr_priv_key = None + ctxMng.account.privkey = None ctxMng.account.loadTrusts() def _startRefresh(self, menu_data, profile): @@ -275,9 +275,9 @@ except KeyError: log.error(_("jid key is not present !")) return defer.fail(exceptions.DataError) - otrctx = self.context_managers[profile].getContextForUser(to_jid) - - priv_key = otrctx.user.client.otr_priv_key + ctxMng = self.context_managers[profile] + otrctx = ctxMng.getContextForUser(to_jid) + priv_key = ctxMng.account.privkey if priv_key is None: # we have no private key yet @@ -346,20 +346,18 @@ log.error(_("jid key is not present !")) return defer.fail(exceptions.DataError) - client = self.host.getClient(profile) - if client.otr_priv_key is None: + ctxMng = self.context_managers[profile] + if ctxMng.account.privkey is None: return {'xmlui': xml_tools.note(_("You don't have a private key yet !")).toXml()} def dropKey(data, profile): if C.bool(data['answer']): # we end all sessions - ctxMng = self.context_managers[profile] for context in ctxMng.contexts.values(): if context.state not in (potr.context.STATE_FINISHED, potr.context.STATE_PLAINTEXT): context.disconnect() - client.otr_priv_key = None ctxMng.account.privkey = None - ctxMng.account.getPrivkey() # as client.otr_priv_key and account.privkey are None, getPrivkey will generate a new key, and save it + ctxMng.account.getPrivkey() # as account.privkey is None, getPrivkey will generate a new key, and save it return {'xmlui': xml_tools.note(_("Your private key has been dropped")).toXml()} return {}