comparison src/browser/sat_browser/plugin_sec_otr.py @ 556:3aef7c5c7d3a

browser_side (plugin OTR): popup a big warning if the correspondent's resource is unknown while trying to start/use an OTR session
author souliane <souliane@mailoo.org>
date Tue, 23 Sep 2014 09:32:10 +0200
parents ad18eb65b6db
children d0114855d6d4
comparison
equal deleted inserted replaced
555:db1b330c1eb1 556:3aef7c5c7d3a
35 35
36 NS_OTR = "otr_plugin" 36 NS_OTR = "otr_plugin"
37 PRIVATE_KEY = "PRIVATE KEY" 37 PRIVATE_KEY = "PRIVATE KEY"
38 MAIN_MENU = D_('OTR encryption') 38 MAIN_MENU = D_('OTR encryption')
39 DIALOG_EOL = "<br />" 39 DIALOG_EOL = "<br />"
40 DIALOG_USERS_ML = D_("<a href='mailto:users@salut-a-toi.org?subject={subject}&body=Please give us some hints about how to reproduce the bug (your browser name and version, what you did and what happened)'>users@salut-a-toi.org</a>")
40 41
41 AUTH_TRUSTED = D_("Verified") 42 AUTH_TRUSTED = D_("Verified")
42 AUTH_UNTRUSTED = D_("Unverified") 43 AUTH_UNTRUSTED = D_("Unverified")
43 AUTH_OTHER_TITLE = D_("Authentication of {jid}") 44 AUTH_OTHER_TITLE = D_("Authentication of {jid}")
44 AUTH_US_TITLE = D_("Authentication to {jid}") 45 AUTH_US_TITLE = D_("Authentication to {jid}")
87 QUERY_KEY = D_("You already have a private key, but to start the conversation will still require a couple of seconds.{eol}{eol}") 88 QUERY_KEY = D_("You already have a private key, but to start the conversation will still require a couple of seconds.{eol}{eol}")
88 QUERY_CONFIRM = D_("Press OK to start now the encryption.") 89 QUERY_CONFIRM = D_("Press OK to start now the encryption.")
89 90
90 ACTION_NA_TITLE = D_("Impossible action") 91 ACTION_NA_TITLE = D_("Impossible action")
91 ACTION_NA = D_("Your correspondent must be connected to start an OTR conversation with him.") 92 ACTION_NA = D_("Your correspondent must be connected to start an OTR conversation with him.")
93 RESOURCE_ISSUE_TITLE = D_("Security issue")
94 RESOURCE_ISSUE = D_("Your correspondent's resource is unknown!{eol}{eol}You should stop any OTR conversation with {jid} to avoid sending him unencrypted messages in an encrypted context.{eol}{eol}Please report the bug to the users mailing list: {users_ml}.")
92 95
93 DEFAULT_POLICY_FLAGS = { 96 DEFAULT_POLICY_FLAGS = {
94 'ALLOW_V2': True, 97 'ALLOW_V2': True,
95 'ALLOW_V3': True, 98 'ALLOW_V3': True,
96 'REQUIRE_ENCRYPTION': False, 99 'REQUIRE_ENCRYPTION': False,
337 @return: Context 340 @return: Context
338 """ 341 """
339 log.debug(u"getContextForUser [%s]" % other_jid) 342 log.debug(u"getContextForUser [%s]" % other_jid)
340 if not other_jid.resource: 343 if not other_jid.resource:
341 log.error("getContextForUser called with a bare jid") 344 log.error("getContextForUser called with a bare jid")
345 running_sessions = [jid.userhostJID() for jid in self.contexts.keys() if self.contexts[jid].state == otr.context.STATE_ENCRYPTED]
346 if start or (other_jid in running_sessions):
347 users_ml = DIALOG_USERS_ML.format(subject=D_("OTR issue in Libervia: getContextForUser called with a bare jid in an encrypted context"))
348 text = RESOURCE_ISSUE.format(eol=DIALOG_EOL, jid=other_jid.full(), users_ml=users_ml)
349 dialog.InfoDialog(RESOURCE_ISSUE_TITLE, text, AddStyleName="maxWidthLimit").show()
350 return None # never start an OTR session with a bare JID
342 if start: 351 if start:
343 return self.startContext(other_jid) 352 return self.startContext(other_jid)
344 else: 353 else:
345 return self.contexts.get(other_jid, None) 354 return self.contexts.get(other_jid, None)
346 355
486 495
487 @param menu_data: %(menu_data)s 496 @param menu_data: %(menu_data)s
488 """ 497 """
489 def query(other_jid): 498 def query(other_jid):
490 otrctx = self.context_manager.getContextForUser(other_jid) 499 otrctx = self.context_manager.getContextForUser(other_jid)
491 otrctx.sendQueryMessage() 500 if otrctx:
501 otrctx.sendQueryMessage()
492 502
493 def cb(jid): 503 def cb(jid):
494 key = self.context_manager.account.privkey 504 key = self.context_manager.account.privkey
495 if key is None: 505 if key is None:
496 def confirm(confirm): 506 def confirm(confirm):