# HG changeset patch # User souliane # Date 1409908598 -7200 # Node ID 2df6427a5299791c0d63f43cc0fb5becfb8f4706 # Parent a3354063dfb6e313509c77a790498a8887704204 plugin OTR: forces FINISHED state if we are in ENCRYPTED state on contact disconnection diff -r a3354063dfb6 -r 2df6427a5299 src/core/xmpp.py --- a/src/core/xmpp.py Fri Sep 05 11:01:14 2014 +0200 +++ b/src/core/xmpp.py Fri Sep 05 11:16:38 2014 +0200 @@ -328,6 +328,10 @@ int(priority), statuses, self.parent.profile) + # uncomment these two lines if you need the trigger + #if not self.host.trigger.point("presenceReceived", entity, "unavailable", 0, statuses, self.parent.profile): + # return + # now it's time to notify frontends self.host.bridge.presenceUpdate(entity.full(), show or "", int(priority), statuses, @@ -344,6 +348,9 @@ del statuses[None] self.host.memory.setPresenceStatus(entity, "unavailable", 0, statuses, self.parent.profile) + if not self.host.trigger.point("presenceReceived", entity, "unavailable", 0, statuses, self.parent.profile): + return + # now it's time to notify frontends self.host.bridge.presenceUpdate(entity.full(), "unavailable", 0, statuses, self.parent.profile) diff -r a3354063dfb6 -r 2df6427a5299 src/plugins/plugin_sec_otr.py --- a/src/plugins/plugin_sec_otr.py Fri Sep 05 11:01:14 2014 +0200 +++ b/src/plugins/plugin_sec_otr.py Fri Sep 05 11:16:38 2014 +0200 @@ -120,6 +120,11 @@ if self.state != potr.context.STATE_PLAINTEXT: super(Context, self).disconnect() + def finish(self): + """Finish the session - avoid to send any message but the user still has to end the session himself.""" + if self.state == potr.context.STATE_ENCRYPTED: + self.processTLVs([potr.proto.DisconnectTLV()]) + 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) @@ -203,6 +208,7 @@ host.importMenu((MAIN_MENU, D_("End session")), self._endSession, security_limit=0, help_string=D_("Finish an OTR session"), type_=C.MENU_SINGLE) host.importMenu((MAIN_MENU, D_("Authenticate")), self._authenticate, security_limit=0, help_string=D_("Authenticate user/see your fingerprint"), type_=C.MENU_SINGLE) host.importMenu((MAIN_MENU, D_("Drop private key")), self._dropPrivKey, security_limit=0, type_=C.MENU_SINGLE) + host.trigger.add("presenceReceived", self.presenceReceivedTrigger) def _fixPotr(self): # FIXME: potr fix for bad unicode handling @@ -457,3 +463,11 @@ log.debug(u"sending message unencrypted") return True + def presenceReceivedTrigger(self, entity, show, priority, statuses, profile): + if show != "unavailable": + return + if not entity.resource: + entity.resource = self.host.memory.getLastResource(entity, profile) # FIXME: temporary and unsecure, must be changed when frontends are refactored + otrctx = self.context_managers[profile].getContextForUser(entity) + otrctx.disconnect() + return True