Mercurial > libervia-web
diff src/browser/sat_browser/plugin_sec_otr.py @ 559:77372641e05d
browser_side (plugin OTR): display the correct icons on opening the window + auto-open on accepted invitation
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 23 Sep 2014 13:57:36 +0200 |
parents | d0114855d6d4 |
children | b07f0fe2763a |
line wrap: on
line diff
--- a/src/browser/sat_browser/plugin_sec_otr.py Tue Sep 23 11:48:57 2014 +0200 +++ b/src/browser/sat_browser/plugin_sec_otr.py Tue Sep 23 13:57:36 2014 +0200 @@ -32,6 +32,8 @@ import jid import otrjs_wrapper as otr import dialog +import panels + NS_OTR = "otr_plugin" PRIVATE_KEY = "PRIVATE KEY" @@ -365,10 +367,31 @@ @classmethod def getInfoText(self, state=otr.context.STATE_PLAINTEXT, trust=''): + """Get the widget info text for a certain message state and trust. + + @param state (str): message state + @param trust (str): trust + @return: str + """ if not state: state = OTR_MSG_STATES.keys()[0] return OTR_MSG_STATES[state][1 if trust else 0] + def infoTextCallback(self, other_jid, cb): + """Get the current info text for a conversation and run a callback. + + @param other_jid (JID): JID of the correspondant + @paam cb (callable): method to be called with the computed info text + """ + def gotResource(other_jid): + otrctx = self.context_manager.getContextForUser(other_jid, start=False) + if otrctx is None: + cb(OTR.getInfoText()) + else: + cb(OTR.getInfoText(otrctx.state, otrctx.getCurrentTrust())) + + self.fixResource(other_jid, gotResource) + def inhibitMenus(self): """Tell the caller which dynamic menus should be inhibited""" return ["OTR"] # menu categories name to inhibit @@ -423,6 +446,7 @@ if otrctx is None: def confirm(confirm): if confirm: + self.host.getOrCreateLiberviaWidget(panels.ChatPanel, jid) decrypt(self.context_manager.startContext(jid)) else: # FIXME: plain text messages with whitespaces would be lost here when WHITESPACE_START_AKE is True