plugin OTR: disconnect the active OTR sessions and delete the context on profile disconnection
This commit is contained in:
parent
f2d630fcad
commit
c1e71508c4
1 changed files with 12 additions and 2 deletions
|
|
@ -115,6 +115,11 @@ class Context(potr.context.Context):
|
|||
profile=client.profile)
|
||||
# TODO: send signal to frontends
|
||||
|
||||
def disconnect(self):
|
||||
"""Disconnect the session."""
|
||||
if self.state != potr.context.STATE_PLAINTEXT:
|
||||
super(Context, self).disconnect()
|
||||
|
||||
|
||||
class Account(potr.context.Account):
|
||||
#TODO: manage trusted keys: if a fingerprint is not used anymore, we have no way to remove it from database yet (same thing for a correspondent jid)
|
||||
|
|
@ -239,6 +244,12 @@ class OTR(object):
|
|||
ctxMng.account.loadTrusts()
|
||||
|
||||
def profileDisconnected(self, profile):
|
||||
try:
|
||||
for context in self.context_managers[profile].contexts.values():
|
||||
context.disconnect()
|
||||
del self.context_managers[profile]
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
self.skipped_profiles.remove(profile)
|
||||
except KeyError:
|
||||
|
|
@ -371,8 +382,7 @@ class OTR(object):
|
|||
if C.bool(data['answer']):
|
||||
# we end all sessions
|
||||
for context in ctxMng.contexts.values():
|
||||
if context.state not in (potr.context.STATE_FINISHED, potr.context.STATE_PLAINTEXT):
|
||||
context.disconnect()
|
||||
context.disconnect()
|
||||
ctxMng.account.privkey = None
|
||||
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()}
|
||||
|
|
|
|||
Loading…
Reference in a new issue