Mercurial > libervia-web
diff src/browser/sat_browser/plugin_sec_otr.py @ 529:9bfd71e2b35c
plugin OTR: disconnect the active OTR sessions on profile disconnection
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 05 Sep 2014 11:41:40 +0200 |
parents | ac66b8b11ab8 |
children | 1735aaeac652 |
line wrap: on
line diff
--- a/src/browser/sat_browser/plugin_sec_otr.py Fri Sep 05 10:47:17 2014 +0200 +++ b/src/browser/sat_browser/plugin_sec_otr.py Fri Sep 05 11:41:40 2014 +0200 @@ -220,6 +220,11 @@ elif type_ == 'abort': self.setCurrentTrust('', act, 'abort') + def disconnect(self): + """Disconnect the session.""" + if self.state != otr.context.STATE_PLAINTEXT: + super(Context, self).disconnect() + class Account(otr.context.Account): @@ -298,6 +303,10 @@ # decrypt it, parse it with otr.crypt.PK.parsePrivateKey(privkey) and # assign it to self.context_manager.account.privkey + def profileDisconnected(self): + for context in self.context_manager.contexts.values(): + context.disconnect() + def fixResource(self, jid, cb): # FIXME: it's dirty, but libervia doesn't manage resources correctly now, refactoring is planed if jid.resource: @@ -437,8 +446,7 @@ if confirm: # we end all sessions for context in self.context_manager.contexts.values(): - if context.state not in (otr.context.STATE_FINISHED, otr.context.STATE_PLAINTEXT): - context.disconnect() + context.disconnect() self.context_manager.account.privkey = None self.context_manager.account.getPrivkey() # as account.privkey are None, getPrivkey will generate a new key, and save it dialog.InfoDialog(_('Private key'), _("Your private key has been dropped."), AddStyleName="maxWidthLimit").show()