plugin OTR: remove unnecessary attribute SatXMPPClient.otr_priv_key

This commit is contained in:
souliane 2014-09-01 16:05:28 +02:00
commit fbdca49737

View file

@ -129,7 +129,7 @@ class Account(potr.context.Account):
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 @@ class OTR(object):
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 @@ class OTR(object):
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 @@ class OTR(object):
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 {}