diff src/browser/sat_browser/plugin_sec_otr.py @ 624:9092e624bb27 frontends_multi_profiles

browser_side: fixes various issues
author souliane <souliane@mailoo.org>
date Sun, 22 Feb 2015 21:51:20 +0100
parents 1c0d5a87c554
children ebb602d8b3f2
line wrap: on
line diff
--- a/src/browser/sat_browser/plugin_sec_otr.py	Sun Feb 22 21:42:14 2015 +0100
+++ b/src/browser/sat_browser/plugin_sec_otr.py	Sun Feb 22 21:51:20 2015 +0100
@@ -264,20 +264,20 @@
         title = (AUTH_OTHER_TITLE if act == "asked" else AUTH_US_TITLE).format(jid=self.peer)
         if type_ == 'question':
             if act == 'asked':
-                def cb(question, answer=None):
-                    if question is False or not answer:  # dialog cancelled or the answer is empty
+                def cb(result, question, answer=None):
+                    if not result or not answer:  # dialog cancelled or the answer is empty
                         return
                     self.smpAuthSecret(answer, question)
                 text = (AUTH_INFO_TXT + "<i>" + AUTH_QUEST_DEFINE_TXT + "</i>" + AUTH_QUEST_DEFINE).format(eol=DIALOG_EOL)
                 dialog.PromptDialog(cb, [text, AUTH_SECRET_INPUT.format(eol=DIALOG_EOL)], title=title, AddStyleName="maxWidthLimit").show()
             else:
-                def cb(answer):
-                    if not answer:  # dialog cancelled or the answer is empty
+                def cb(result, answer):
+                    if not result or not answer:  # dialog cancelled or the answer is empty
                         self.smpAuthAbort('answered')
                         return
                     self.smpAuthSecret(answer)
                 text = (AUTH_INFO_TXT + "<i>" + AUTH_QUEST_ANSWER_TXT + "</i>" + AUTH_QUEST_ANSWER).format(eol=DIALOG_EOL, question=data)
-                dialog.PromptDialog(cb, text + AUTH_SECRET_INPUT.format(eol=DIALOG_EOL), title=title, AddStyleName="maxWidthLimit").show()
+                dialog.PromptDialog(cb, [text + AUTH_SECRET_INPUT.format(eol=DIALOG_EOL)], title=title, AddStyleName="maxWidthLimit").show()
         elif type_ == 'trust':
             self.setCurrentTrust('smp' if data else '', act)
         elif type_ == 'abort':
@@ -344,7 +344,7 @@
         log.debug(u"getContextForUser [%s]" % other_jid)
         if not other_jid.resource:
             log.error("getContextForUser called with a bare jid")
-            running_sessions = [jid_.bareJID() for jid_ in self.contexts.keys() if self.contexts[jid_].state == otr.context.STATE_ENCRYPTED]
+            running_sessions = [jid_.bare for jid_ in self.contexts.keys() if self.contexts[jid_].state == otr.context.STATE_ENCRYPTED]
             if start or (other_jid in running_sessions):
                 users_ml = DIALOG_USERS_ML.format(subject=D_("OTR issue in Libervia: getContextForUser called with a bare jid in an encrypted context"))
                 text = RESOURCE_ISSUE.format(eol=DIALOG_EOL, jid=other_jid, users_ml=users_ml)
@@ -485,7 +485,7 @@
         return False  # interrupt the main process
 
     def presenceReceivedTrigger(self, entity, show, priority, statuses):
-        if show == "unavailable":
+        if show == C.PRESENCE_UNAVAILABLE:
             self.endSession(entity, finish=True)
         return True
 
@@ -542,7 +542,8 @@
 
         try:
             other_jid = menu_data['jid']
-            if other_jid.bare not in self.host.contact_panel.connected:
+            contact_list = self.host.contact_list
+            if contact_list.getCache(other_jid.bare, C.PRESENCE_SHOW) is None:
                 dialog.InfoDialog(ACTION_NA_TITLE, ACTION_NA, AddStyleName="maxWidthLimit").show()
                 return
             self.fixResource(other_jid, cb)