# HG changeset patch # User souliane # Date 1409906346 -7200 # Node ID 39572f9d524955d078d28fe557786886accb96d6 # Parent fe102b4cf275b66093ace6916d6d858cf86c1f27 plugin OTR: fixes handling of the FINISHED state diff -r fe102b4cf275 -r 39572f9d5249 src/plugins/plugin_sec_otr.py --- a/src/plugins/plugin_sec_otr.py Thu Sep 04 11:26:22 2014 +0200 +++ b/src/plugins/plugin_sec_otr.py Fri Sep 05 10:39:06 2014 +0200 @@ -427,11 +427,21 @@ if mess_data['type'] != 'groupchat' and not to_jid.resource: to_jid.resource = self.host.memory.getLastResource(to_jid, profile) # FIXME: it's dirty, but frontends don't manage resources correctly now, refactoring is planed otrctx = self.context_managers[profile].getContextForUser(to_jid) - if mess_data['type'] != 'groupchat' and otrctx.state == potr.context.STATE_ENCRYPTED: - log.debug(u"encrypting message") - otrctx.sendMessage(0, mess_data['message'].encode('utf-8')) - client = self.host.getClient(profile) - self.host.sendMessageToBridge(mess_data, client) + if mess_data['type'] != 'groupchat' and otrctx.state != potr.context.STATE_PLAINTEXT: + if otrctx.state == potr.context.STATE_ENCRYPTED: + log.debug(u"encrypting message") + otrctx.sendMessage(0, mess_data['message'].encode('utf-8')) + client = self.host.getClient(profile) + self.host.sendMessageToBridge(mess_data, client) + else: + feedback = D_("Your message was not sent because your correspondent closed the encrypted conversation on his/her side. Either close your own side, or refresh the session.") + client = self.host.getClient(profile) + self.host.bridge.newMessage(to_jid.full(), + feedback, + mess_type="headline", + to_jid=client.jid.full(), + extra={}, + profile=client.profile) return False else: log.debug(u"sending message unencrypted")