# HG changeset patch # User souliane # Date 1409907674 -7200 # Node ID a3354063dfb6e313509c77a790498a8887704204 # Parent 39572f9d524955d078d28fe557786886accb96d6 plugin OTR: disconnect the active OTR sessions and delete the context on profile disconnection diff -r 39572f9d5249 -r a3354063dfb6 src/plugins/plugin_sec_otr.py --- a/src/plugins/plugin_sec_otr.py Fri Sep 05 10:39:06 2014 +0200 +++ b/src/plugins/plugin_sec_otr.py Fri Sep 05 11:01:14 2014 +0200 @@ -115,6 +115,11 @@ 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) @@ -240,6 +245,12 @@ 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: pass @@ -371,8 +382,7 @@ 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()}