plugin OTR: forces FINISHED state if we are in ENCRYPTED state on contact disconnection
This commit is contained in:
parent
c1e71508c4
commit
af2554a508
1 changed files with 21 additions and 0 deletions
|
|
@ -120,6 +120,11 @@ class Context(potr.context.Context):
|
|||
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 @@ class OTR(object):
|
|||
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 @@ class OTR(object):
|
|||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue