comparison src/plugins/plugin_sec_otr.py @ 1168:39572f9d5249

plugin OTR: fixes handling of the FINISHED state
author souliane <souliane@mailoo.org>
date Fri, 05 Sep 2014 10:39:06 +0200
parents 652cd93dfdb4
children a3354063dfb6
comparison
equal deleted inserted replaced
1167:fe102b4cf275 1168:39572f9d5249
425 return True 425 return True
426 to_jid = mess_data['to'] 426 to_jid = mess_data['to']
427 if mess_data['type'] != 'groupchat' and not to_jid.resource: 427 if mess_data['type'] != 'groupchat' and not to_jid.resource:
428 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 428 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
429 otrctx = self.context_managers[profile].getContextForUser(to_jid) 429 otrctx = self.context_managers[profile].getContextForUser(to_jid)
430 if mess_data['type'] != 'groupchat' and otrctx.state == potr.context.STATE_ENCRYPTED: 430 if mess_data['type'] != 'groupchat' and otrctx.state != potr.context.STATE_PLAINTEXT:
431 log.debug(u"encrypting message") 431 if otrctx.state == potr.context.STATE_ENCRYPTED:
432 otrctx.sendMessage(0, mess_data['message'].encode('utf-8')) 432 log.debug(u"encrypting message")
433 client = self.host.getClient(profile) 433 otrctx.sendMessage(0, mess_data['message'].encode('utf-8'))
434 self.host.sendMessageToBridge(mess_data, client) 434 client = self.host.getClient(profile)
435 self.host.sendMessageToBridge(mess_data, client)
436 else:
437 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.")
438 client = self.host.getClient(profile)
439 self.host.bridge.newMessage(to_jid.full(),
440 feedback,
441 mess_type="headline",
442 to_jid=client.jid.full(),
443 extra={},
444 profile=client.profile)
435 return False 445 return False
436 else: 446 else:
437 log.debug(u"sending message unencrypted") 447 log.debug(u"sending message unencrypted")
438 return True 448 return True
439 449