comparison frontends/src/quick_frontend/quick_app.py @ 1172:e15d8a01cf6a

frontends: use of new "info" type in newMessage
author Goffi <goffi@goffi.org>
date Fri, 05 Sep 2014 19:29:30 +0200
parents 75025461141f
children 802b7e6bf098
comparison
equal deleted inserted replaced
1171:0abce7f17782 1172:e15d8a01cf6a
269 def newContactHandler(self, JabberId, attributes, groups, profile): 269 def newContactHandler(self, JabberId, attributes, groups, profile):
270 entity = JID(JabberId) 270 entity = JID(JabberId)
271 _groups = list(groups) 271 _groups = list(groups)
272 self.contact_list.replace(entity, _groups, attributes) 272 self.contact_list.replace(entity, _groups, attributes)
273 273
274 def _newMessage(self, from_jid_s, msg, _type, to_jid_s, extra, profile): 274 def _newMessage(self, from_jid_s, msg, type_, to_jid_s, extra, profile):
275 """newMessage premanagement: a dirty hack to manage private messages 275 """newMessage premanagement: a dirty hack to manage private messages
276 if a private MUC message is detected, from_jid or to_jid is prefixed and resource is escaped""" 276
277 if a private MUC message is detected, from_jid or to_jid is prefixed and resource is escaped
278 """
279 # FIXME: must be refactored for 0.6
277 from_jid = JID(from_jid_s) 280 from_jid = JID(from_jid_s)
278 to_jid = JID(to_jid_s) 281 to_jid = JID(to_jid_s)
279 282
280 from_me = from_jid.bare == self.profiles[profile]['whoami'].bare 283 from_me = from_jid.bare == self.profiles[profile]['whoami'].bare
281 win = to_jid if from_me else from_jid 284 win = to_jid if from_me else from_jid
282 285
283 if _type != "groupchat" and self.contact_list.getSpecial(win) == "MUC": 286 if ((type_ != "groupchat" and self.contact_list.getSpecial(win) == "MUC") and
287 (type_ != C.MESS_TYPE_INFO or (type_ == C.MESS_TYPE_INFO and win.resource))):
284 #we have a private message in a MUC room 288 #we have a private message in a MUC room
285 #XXX: normaly we use bare jid as key, here we need the full jid 289 #XXX: normaly we use bare jid as key, here we need the full jid
286 # so we cheat by replacing the "/" before the resource by 290 # so we cheat by replacing the "/" before the resource by
287 # a "@", so the jid is invalid, 291 # a "@", so the jid is invalid,
288 new_jid = escapePrivate(win) 292 new_jid = escapePrivate(win)
291 else: 295 else:
292 from_jid = new_jid 296 from_jid = new_jid
293 if new_jid not in self.contact_list: 297 if new_jid not in self.contact_list:
294 self.contact_list.add(new_jid, [C.GROUP_NOT_IN_ROSTER]) 298 self.contact_list.add(new_jid, [C.GROUP_NOT_IN_ROSTER])
295 299
296 self.newMessageHandler(from_jid, to_jid, msg, _type, extra, profile) 300 self.newMessageHandler(from_jid, to_jid, msg, type_, extra, profile)
297 301
298 def newMessageHandler(self, from_jid, to_jid, msg, _type, extra, profile): 302 def newMessageHandler(self, from_jid, to_jid, msg, type_, extra, profile):
299 from_me = from_jid.bare == self.profiles[profile]['whoami'].bare 303 from_me = from_jid.bare == self.profiles[profile]['whoami'].bare
300 win = to_jid if from_me else from_jid 304 win = to_jid if from_me else from_jid
301 305
302 self.current_action_ids = set() 306 self.current_action_ids = set()
303 self.current_action_ids_cb = {} 307 self.current_action_ids_cb = {}
304 308
305 timestamp = extra.get('archive') 309 timestamp = extra.get('archive')
306 self.chat_wins[win.bare].printMessage(from_jid, msg, profile, float(timestamp) if timestamp else '') 310 if type_ == C.MESS_TYPE_INFO:
311 self.chat_wins[win.bare].printInfo( msg, timestamp = float(timestamp) if timestamp else '')
312 else:
313 self.chat_wins[win.bare].printMessage(from_jid, msg, profile, float(timestamp) if timestamp else '')
307 314
308 def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, callback=None, errback=None, profile_key="@NONE@"): 315 def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, callback=None, errback=None, profile_key="@NONE@"):
309 if to_jid.startswith(C.PRIVATE_PREFIX): 316 if to_jid.startswith(C.PRIVATE_PREFIX):
310 to_jid = unescapePrivate(to_jid) 317 to_jid = unescapePrivate(to_jid)
311 mess_type = "chat" 318 mess_type = "chat"