# HG changeset patch # User souliane # Date 1409910100 -7200 # Node ID 9bfd71e2b35c71229bc1173cc902970c15f92f7d # Parent ac66b8b11ab8f8facae24ae17266529a61e08d74 plugin OTR: disconnect the active OTR sessions on profile disconnection diff -r ac66b8b11ab8 -r 9bfd71e2b35c src/browser/sat_browser/menu.py --- a/src/browser/sat_browser/menu.py Fri Sep 05 10:47:17 2014 +0200 +++ b/src/browser/sat_browser/menu.py Fri Sep 05 11:41:40 2014 +0200 @@ -104,6 +104,11 @@ def onDisconnect(self): def confirm_cb(answer): if answer: + # FIXME: are we sure the triggers finished their jobs when the backend disconnect? + # FIXME: disconnection on timeout is not handled yet... + for plugin in self.plugins.values(): + if hasattr(plugin, 'profileConnected'): + plugin.profileDisconnected() log.info("disconnection") self.host.bridge.call('disconnect', None) _dialog = dialog.ConfirmDialog(confirm_cb, text="Do you really want to disconnect ?") diff -r ac66b8b11ab8 -r 9bfd71e2b35c src/browser/sat_browser/plugin_sec_otr.py --- 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()