comparison src/browser/sat_browser/plugin_sec_otr.py @ 694:82123705474b

massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
author souliane <souliane@mailoo.org>
date Thu, 16 Apr 2015 14:57:02 +0200
parents 9877607c719a
children f8a7a046ff9c
comparison
equal deleted inserted replaced
693:1d60fa4d25a4 694:82123705474b
158 return False 158 return False
159 159
160 def receiveMessageCb(self, msg, encrypted): 160 def receiveMessageCb(self, msg, encrypted):
161 assert isinstance(self.peer, jid.JID) 161 assert isinstance(self.peer, jid.JID)
162 if not encrypted: 162 if not encrypted:
163 log.warning("A plain-text message has been handled by otr.js") 163 log.warning(u"A plain-text message has been handled by otr.js")
164 log.debug("message received (was %s): %s" % ('encrypted' if encrypted else 'plain', msg)) 164 log.debug(u"message received (was %s): %s" % ('encrypted' if encrypted else 'plain', msg))
165 if not encrypted: 165 if not encrypted:
166 if self.state == otr.context.STATE_ENCRYPTED: 166 if self.state == otr.context.STATE_ENCRYPTED:
167 log.warning(u"Received unencrypted message in an encrypted context (from %(jid)s)" % {'jid': self.peer}) 167 log.warning(u"Received unencrypted message in an encrypted context (from %(jid)s)" % {'jid': self.peer})
168 self.host.newMessageHandler(unicode(self.peer), RECEIVE_PLAIN_IN_ENCRYPTED_CONTEXT, C.MESS_TYPE_INFO, unicode(self.host.whoami), {}) 168 self.host.newMessageHandler(unicode(self.peer), RECEIVE_PLAIN_IN_ENCRYPTED_CONTEXT, C.MESS_TYPE_INFO, unicode(self.host.whoami), {})
169 self.host.newMessageHandler(unicode(self.peer), msg, C.MESS_TYPE_CHAT, unicode(self.host.whoami), {}) 169 self.host.newMessageHandler(unicode(self.peer), msg, C.MESS_TYPE_CHAT, unicode(self.host.whoami), {})
170 170
171 def sendMessageCb(self, msg, meta=None): 171 def sendMessageCb(self, msg, meta=None):
172 assert isinstance(self.peer, jid.JID) 172 assert isinstance(self.peer, jid.JID)
173 log.debug("message to send%s: %s" % ((' (attached meta data: %s)' % meta) if meta else '', msg)) 173 log.debug(u"message to send%s: %s" % ((' (attached meta data: %s)' % meta) if meta else '', msg))
174 self.host.bridge.call('sendMessage', (None, self.host.sendError), unicode(self.peer), msg, '', C.MESS_TYPE_CHAT, {'send_only': 'true'}) 174 self.host.bridge.call('sendMessage', (None, self.host.sendError), unicode(self.peer), msg, '', C.MESS_TYPE_CHAT, {'send_only': 'true'})
175 175
176 def messageErrorCb(self, error): 176 def messageErrorCb(self, error):
177 log.error('error occured: %s' % error) 177 log.error(u'error occured: %s' % error)
178 178
179 def setStateCb(self, msg_state, status): 179 def setStateCb(self, msg_state, status):
180 if status == otr.context.STATUS_AKE_INIT: 180 if status == otr.context.STATUS_AKE_INIT:
181 return 181 return
182 182
200 feedback = END_FINISHED 200 feedback = END_FINISHED
201 201
202 self.host.newMessageHandler(unicode(self.peer), feedback.format(jid=other_jid_s), C.MESS_TYPE_INFO, unicode(self.host.whoami), {'header_info': OTR.getInfoText(msg_state, trust)}) 202 self.host.newMessageHandler(unicode(self.peer), feedback.format(jid=other_jid_s), C.MESS_TYPE_INFO, unicode(self.host.whoami), {'header_info': OTR.getInfoText(msg_state, trust)})
203 203
204 def setCurrentTrust(self, new_trust='', act='asked', type_='trust'): 204 def setCurrentTrust(self, new_trust='', act='asked', type_='trust'):
205 log.debug("setCurrentTrust: trust={trust}, act={act}, type={type}".format(type=type_, trust=new_trust, act=act)) 205 log.debug(u"setCurrentTrust: trust={trust}, act={act}, type={type}".format(type=type_, trust=new_trust, act=act))
206 title = (AUTH_OTHER_TITLE if act == "asked" else AUTH_US_TITLE).format(jid=self.peer) 206 title = (AUTH_OTHER_TITLE if act == "asked" else AUTH_US_TITLE).format(jid=self.peer)
207 old_trust = self.getCurrentTrust() 207 old_trust = self.getCurrentTrust()
208 if type_ == 'abort': 208 if type_ == 'abort':
209 msg = AUTH_ABORTED_TXT 209 msg = AUTH_ABORTED_TXT
210 elif new_trust: 210 elif new_trust:
253 @param data (unicode, bool): this could be: 253 @param data (unicode, bool): this could be:
254 - a string containing the question if type_ is 'question' 254 - a string containing the question if type_ is 'question'
255 - a boolean value telling if the authentication succeed when type_ is 'trust' 255 - a boolean value telling if the authentication succeed when type_ is 'trust'
256 @param act (unicode): a value in ('asked', 'answered') 256 @param act (unicode): a value in ('asked', 'answered')
257 """ 257 """
258 log.debug("smpAuthCb: type={type}, data={data}, act={act}".format(type=type_, data=data, act=act)) 258 log.debug(u"smpAuthCb: type={type}, data={data}, act={act}".format(type=type_, data=data, act=act))
259 if act is None: 259 if act is None:
260 if type_ == 'question': 260 if type_ == 'question':
261 act = 'answered' # OTR._authenticate calls this method with act="asked" 261 act = 'answered' # OTR._authenticate calls this method with act="asked"
262 elif type_ == 'abort': 262 elif type_ == 'abort':
263 act = 'asked' # smpAuthAbort triggers this method with act='answered' when needed 263 act = 'asked' # smpAuthAbort triggers this method with act='answered' when needed