Mercurial > libervia-backend
diff src/plugins/plugin_sec_otr.py @ 1146:1ac5ea74dbdf
plugin OTR: remove unnecessary attribute SatXMPPClient.otr_priv_key
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 01 Sep 2014 16:05:28 +0200 |
parents | 2481fa96ac1c |
children | 736f1dd6e142 |
line wrap: on
line diff
--- 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 {}