comparison frontends/src/quick_frontend/quick_app.py @ 688:f7878ad3c846

tools: renamed tools.jid.JID attribute "short" to "bare"
author souliane <souliane@mailoo.org>
date Tue, 29 Oct 2013 16:26:55 +0100
parents 0b9bd47dffcd
children d731ae066158
comparison
equal deleted inserted replaced
687:af0d08a84cc6 688:f7878ad3c846
252 if not self.check_profile(profile): 252 if not self.check_profile(profile):
253 return 253 return
254 from_jid = JID(from_jid_s) 254 from_jid = JID(from_jid_s)
255 to_jid = JID(to_jid_s) 255 to_jid = JID(to_jid_s)
256 256
257 from_me = from_jid.short == self.profiles[profile]['whoami'].short 257 from_me = from_jid.bare == self.profiles[profile]['whoami'].bare
258 win = to_jid if from_me else from_jid 258 win = to_jid if from_me else from_jid
259 259
260 if _type != "groupchat" and self.contact_list.getSpecial(win) == "MUC": 260 if _type != "groupchat" and self.contact_list.getSpecial(win) == "MUC":
261 #we have a private message in a MUC room 261 #we have a private message in a MUC room
262 #XXX: normaly we use bare jid as key, here we need the full jid 262 #XXX: normaly we use bare jid as key, here we need the full jid
271 self.contact_list.add(new_jid) 271 self.contact_list.add(new_jid)
272 272
273 self.newMessage(from_jid, to_jid, msg, _type, extra, profile) 273 self.newMessage(from_jid, to_jid, msg, _type, extra, profile)
274 274
275 def newMessage(self, from_jid, to_jid, msg, _type, extra, profile): 275 def newMessage(self, from_jid, to_jid, msg, _type, extra, profile):
276 from_me = from_jid.short == self.profiles[profile]['whoami'].short 276 from_me = from_jid.bare == self.profiles[profile]['whoami'].bare
277 win = to_jid if from_me else from_jid 277 win = to_jid if from_me else from_jid
278 278
279 self.current_action_ids = set() 279 self.current_action_ids = set()
280 self.current_action_ids_cb = {} 280 self.current_action_ids_cb = {}
281 281
282 timestamp = extra.get('archive') 282 timestamp = extra.get('archive')
283 self.chat_wins[win.short].printMessage(from_jid, msg, profile, float(timestamp) if timestamp else '') 283 self.chat_wins[win.bare].printMessage(from_jid, msg, profile, float(timestamp) if timestamp else '')
284 284
285 def sendMessage(self, to_jid, message, subject='', mess_type="auto", options={}, profile_key="@NONE@"): 285 def sendMessage(self, to_jid, message, subject='', mess_type="auto", options={}, profile_key="@NONE@"):
286 if to_jid.startswith(const_PRIVATE_PREFIX): 286 if to_jid.startswith(const_PRIVATE_PREFIX):
287 to_jid = unescapePrivate(to_jid) 287 to_jid = unescapePrivate(to_jid)
288 mess_type = "chat" 288 mess_type = "chat"
301 def presenceUpdate(self, jabber_id, show, priority, statuses, profile): 301 def presenceUpdate(self, jabber_id, show, priority, statuses, profile):
302 if not self.check_profile(profile): 302 if not self.check_profile(profile):
303 return 303 return
304 debug (_("presence update for %(jid)s (show=%(show)s, priority=%(priority)s, statuses=%(statuses)s) [profile:%(profile)s]") % {'jid':jabber_id, 'show':show, 'priority':priority, 'statuses':statuses, 'profile':profile}) 304 debug (_("presence update for %(jid)s (show=%(show)s, priority=%(priority)s, statuses=%(statuses)s) [profile:%(profile)s]") % {'jid':jabber_id, 'show':show, 'priority':priority, 'statuses':statuses, 'profile':profile})
305 from_jid=JID(jabber_id) 305 from_jid=JID(jabber_id)
306 debug ("from_jid.short=%(from_jid)s whoami.short=%(whoami)s" % {'from_jid':from_jid.short, 'whoami':self.profiles[profile]['whoami'].short}) 306 debug ("from_jid.bare=%(from_jid)s whoami.bare=%(whoami)s" % {'from_jid':from_jid.bare, 'whoami':self.profiles[profile]['whoami'].bare})
307 307
308 if from_jid.short==self.profiles[profile]['whoami'].short: 308 if from_jid.bare==self.profiles[profile]['whoami'].bare:
309 if not type: 309 if not type:
310 self.setStatusOnline(True) 310 self.setStatusOnline(True)
311 elif type=="unavailable": 311 elif type=="unavailable":
312 self.setStatusOnline(False) 312 self.setStatusOnline(False)
313 return 313 return
315 self.contact_list.updatePresence(from_jid, show, priority, statuses) 315 self.contact_list.updatePresence(from_jid, show, priority, statuses)
316 316
317 if show != 'unavailable': 317 if show != 'unavailable':
318 318
319 #FIXME: must be moved in a plugin 319 #FIXME: must be moved in a plugin
320 if from_jid.short in self.profiles[profile]['watched'] and not from_jid.short in self.profiles[profile]['onlineContact']: 320 if from_jid.bare in self.profiles[profile]['watched'] and not from_jid.bare in self.profiles[profile]['onlineContact']:
321 self.showAlert(_("Watched jid [%s] is connected !") % from_jid.short) 321 self.showAlert(_("Watched jid [%s] is connected !") % from_jid.bare)
322 322
323 self.profiles[profile]['onlineContact'].add(from_jid) #FIXME onlineContact is useless with CM, must be removed 323 self.profiles[profile]['onlineContact'].add(from_jid) #FIXME onlineContact is useless with CM, must be removed
324 324
325 #TODO: vcard data (avatar) 325 #TODO: vcard data (avatar)
326 326
496 self.chat_wins[room_jid].getGame("Quiz").quizGameTimerRestarted(time_left) 496 self.chat_wins[room_jid].getGame("Quiz").quizGameTimerRestarted(time_left)
497 497
498 def _subscribe_cb(self, answer, data): 498 def _subscribe_cb(self, answer, data):
499 entity, profile = data 499 entity, profile = data
500 if answer: 500 if answer:
501 self.bridge.subscription("subscribed", entity.short, profile_key = profile) 501 self.bridge.subscription("subscribed", entity.bare, profile_key = profile)
502 else: 502 else:
503 self.bridge.subscription("unsubscribed", entity.short, profile_key = profile) 503 self.bridge.subscription("unsubscribed", entity.bare, profile_key = profile)
504 504
505 def subscribe(self, type, raw_jid, profile): 505 def subscribe(self, type, raw_jid, profile):
506 """Called when a subsciption management signal is received""" 506 """Called when a subsciption management signal is received"""
507 if not self.check_profile(profile): 507 if not self.check_profile(profile):
508 return 508 return
509 entity = JID(raw_jid) 509 entity = JID(raw_jid)
510 if type=="subscribed": 510 if type=="subscribed":
511 # this is a subscription confirmation, we just have to inform user 511 # this is a subscription confirmation, we just have to inform user
512 self.showDialog(_("The contact %s has accepted your subscription") % entity.short, _('Subscription confirmation')) 512 self.showDialog(_("The contact %s has accepted your subscription") % entity.bare, _('Subscription confirmation'))
513 elif type=="unsubscribed": 513 elif type=="unsubscribed":
514 # this is a subscription refusal, we just have to inform user 514 # this is a subscription refusal, we just have to inform user
515 self.showDialog(_("The contact %s has refused your subscription") % entity.short, _('Subscription refusal'), 'error') 515 self.showDialog(_("The contact %s has refused your subscription") % entity.bare, _('Subscription refusal'), 'error')
516 elif type=="subscribe": 516 elif type=="subscribe":
517 # this is a subscriptionn request, we have to ask for user confirmation 517 # this is a subscriptionn request, we have to ask for user confirmation
518 answer = self.showDialog(_("The contact %s wants to subscribe to your presence.\nDo you accept ?") % entity.short, _('Subscription confirmation'), 'yes/no', answer_cb = self._subscribe_cb, answer_data=(entity, profile)) 518 answer = self.showDialog(_("The contact %s wants to subscribe to your presence.\nDo you accept ?") % entity.bare, _('Subscription confirmation'), 'yes/no', answer_cb = self._subscribe_cb, answer_data=(entity, profile))
519 519
520 def showDialog(self, message, title, type="info", answer_cb = None): 520 def showDialog(self, message, title, type="info", answer_cb = None):
521 raise NotImplementedError 521 raise NotImplementedError
522 522
523 def showAlert(self, message): 523 def showAlert(self, message):
537 if not self.check_profile(profile): 537 if not self.check_profile(profile):
538 return 538 return
539 target = JID(jid) 539 target = JID(jid)
540 self.contact_list.remove(target) 540 self.contact_list.remove(target)
541 try: 541 try:
542 self.profiles[profile]['onlineContact'].remove(target.short) 542 self.profiles[profile]['onlineContact'].remove(target.bare)
543 except KeyError: 543 except KeyError:
544 pass 544 pass
545 545
546 def entityDataUpdated(self, jid_str, key, value, profile): 546 def entityDataUpdated(self, jid_str, key, value, profile):
547 if not self.check_profile(profile): 547 if not self.check_profile(profile):