comparison src/browser/sat_browser/plugin_sec_otr.py @ 535:331cb6ea0235

browser side (plugin otr): C.MESS_TYPE_INFO is used instead of "headline" for informational message
author Goffi <goffi@goffi.org>
date Fri, 05 Sep 2014 19:29:35 +0200
parents 19fc2ebc02dd
children 048ae7314156
comparison
equal deleted inserted replaced
534:d2bf317b2d28 535:331cb6ea0235
88 log.debug("message received (was %s): %s" % ('encrypted' if encrypted else 'plain', msg)) 88 log.debug("message received (was %s): %s" % ('encrypted' if encrypted else 'plain', msg))
89 if not encrypted: 89 if not encrypted:
90 if self.state == otr.context.STATE_ENCRYPTED: 90 if self.state == otr.context.STATE_ENCRYPTED:
91 log.warning(u"Received unencrypted message in an encrypted context (from %(jid)s)" % {'jid': self.peer.full()}) 91 log.warning(u"Received unencrypted message in an encrypted context (from %(jid)s)" % {'jid': self.peer.full()})
92 feedback = _(u"WARNING: received unencrypted data in a supposedly encrypted context"), 92 feedback = _(u"WARNING: received unencrypted data in a supposedly encrypted context"),
93 self.host.newMessageCb(self.peer, feedback, "headline", self.host.whoami, {}) 93 self.host.newMessageCb(self.peer, feedback, C.MESS_TYPE_INFO, self.host.whoami, {})
94 self.host.newMessageCb(self.peer, msg, "chat", self.host.whoami, {}) 94 self.host.newMessageCb(self.peer, msg, "chat", self.host.whoami, {})
95 95
96 def sendMessageCb(self, msg, meta=None): 96 def sendMessageCb(self, msg, meta=None):
97 assert isinstance(self.peer, jid.JID) 97 assert isinstance(self.peer, jid.JID)
98 log.debug("message to send%s: %s" % ((' (attached meta data: %s)' % meta) if meta else '', msg)) 98 log.debug("message to send%s: %s" % ((' (attached meta data: %s)' % meta) if meta else '', msg))
127 elif msg_state == otr.context.STATE_ENCRYPTED: 127 elif msg_state == otr.context.STATE_ENCRYPTED:
128 log.error(_("OTR session ended but the context's state is still 'encrypted'!")) 128 log.error(_("OTR session ended but the context's state is still 'encrypted'!"))
129 elif msg_state == otr.context.STATE_FINISHED: 129 elif msg_state == otr.context.STATE_FINISHED:
130 feedback = _("%s has ended his/her private conversation with you; you should do the same.") 130 feedback = _("%s has ended his/her private conversation with you; you should do the same.")
131 131
132 self.host.newMessageCb(self.peer, feedback % other_jid_s, "headline", self.host.whoami, {}) 132 self.host.newMessageCb(self.peer, feedback % other_jid_s, C.MESS_TYPE_INFO, self.host.whoami, {})
133 133
134 def setCurrentTrust(self, new_trust='', act='asked', type_='trust'): 134 def setCurrentTrust(self, new_trust='', act='asked', type_='trust'):
135 log.debug("setCurrentTrust: trust={trust}, act={act}, type={type}".format(type=type_, trust=new_trust, act=act)) 135 log.debug("setCurrentTrust: trust={trust}, act={act}, type={type}".format(type=type_, trust=new_trust, act=act))
136 title = (_("Authentication of {jid}") if act == "asked" else _("Authentication to {jid}")).format(jid=self.peer.full()) 136 title = (_("Authentication of {jid}") if act == "asked" else _("Authentication to {jid}")).format(jid=self.peer.full())
137 if type_ == 'abort': 137 if type_ == 'abort':
148 return 148 return
149 old_trust = self.getCurrentTrust() 149 old_trust = self.getCurrentTrust()
150 otr.context.Context.setCurrentTrust(self, new_trust) 150 otr.context.Context.setCurrentTrust(self, new_trust)
151 if old_trust != new_trust: 151 if old_trust != new_trust:
152 feedback = _("The privacy status of the current conversation is now: {state}").format(state='Private' if new_trust else 'Unverified') 152 feedback = _("The privacy status of the current conversation is now: {state}").format(state='Private' if new_trust else 'Unverified')
153 self.host.newMessageCb(self.peer, feedback, "headline", self.host.whoami, {}) 153 self.host.newMessageCb(self.peer, feedback, C.MESS_TYPE_INFO, self.host.whoami, {})
154 154
155 def fingerprintAuthCb(self): 155 def fingerprintAuthCb(self):
156 """OTR v2 authentication using manual fingerprint comparison""" 156 """OTR v2 authentication using manual fingerprint comparison"""
157 priv_key = self.user.privkey 157 priv_key = self.user.privkey
158 158
377 @return: True if the session has been finished or disconnected, False if there was nothing to do 377 @return: True if the session has been finished or disconnected, False if there was nothing to do
378 """ 378 """
379 def cb(other_jid): 379 def cb(other_jid):
380 def not_available(): 380 def not_available():
381 if not finish: 381 if not finish:
382 self.host.newMessageCb(other_jid, FEEDBACK_NOT_PRIVATE % other_jid.full(), "headline", self.host.whoami, {}) 382 self.host.newMessageCb(other_jid, FEEDBACK_NOT_PRIVATE % other_jid.full(), C.MESS_TYPE_INFO, self.host.whoami, {})
383 383
384 priv_key = self.context_manager.account.privkey 384 priv_key = self.context_manager.account.privkey
385 if priv_key is None: 385 if priv_key is None:
386 not_available() 386 not_available()
387 return 387 return