comparison frontends/src/quick_frontend/quick_app.py @ 735:682933ca304c

frontends: presence update in quick app: - bug fix "s/type/show/g" - better PEP8 compliance - all "show" value different then "unavailable" mean (more or less) "online"
author souliane <souliane@mailoo.org>
date Sun, 24 Nov 2013 11:22:20 +0100
parents d731ae066158
children 6246eb6d64a0
comparison
equal deleted inserted replaced
734:b26dfac8e46c 735:682933ca304c
292 if not self.check_profile(profile): 292 if not self.check_profile(profile):
293 return 293 return
294 assert alert_type in ['INFO','ERROR'] 294 assert alert_type in ['INFO','ERROR']
295 self.showDialog(unicode(msg),unicode(title),alert_type.lower()) 295 self.showDialog(unicode(msg),unicode(title),alert_type.lower())
296 296
297
298 def setStatusOnline(self, online=True): 297 def setStatusOnline(self, online=True):
299 pass 298 pass
300 299
301 def presenceUpdate(self, jabber_id, show, priority, statuses, profile): 300 def presenceUpdate(self, jabber_id, show, priority, statuses, profile):
302 if not self.check_profile(profile): 301 if not self.check_profile(profile):
303 return 302 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}) 303 debug(_("presence update for %(jid)s (show=%(show)s, priority=%(priority)s, statuses=%(statuses)s) [profile:%(profile)s]")
305 from_jid=JID(jabber_id) 304 % {'jid': jabber_id, 'show': show, 'priority': priority, 'statuses': statuses, 'profile': profile})
306 debug ("from_jid.bare=%(from_jid)s whoami.bare=%(whoami)s" % {'from_jid':from_jid.bare, 'whoami':self.profiles[profile]['whoami'].bare}) 305 from_jid = JID(jabber_id)
307 306 debug("from_jid.bare=%(from_jid)s whoami.bare=%(whoami)s" % {'from_jid': from_jid.bare, 'whoami': self.profiles[profile]['whoami'].bare})
308 if from_jid.bare==self.profiles[profile]['whoami'].bare: 307
309 if not type: 308 if from_jid.bare == self.profiles[profile]['whoami'].bare:
309 if show == "unavailable":
310 self.setStatusOnline(False)
311 else:
310 self.setStatusOnline(True) 312 self.setStatusOnline(True)
311 elif type=="unavailable":
312 self.setStatusOnline(False)
313 return 313 return
314 314
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.bare in self.profiles[profile]['watched'] and not from_jid.bare 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.bare) 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
327 if show=="unavailable" and from_jid in self.profiles[profile]['onlineContact']: 327 if show == "unavailable" and from_jid in self.profiles[profile]['onlineContact']:
328 self.profiles[profile]['onlineContact'].remove(from_jid) 328 self.profiles[profile]['onlineContact'].remove(from_jid)
329 329
330 def roomJoined(self, room_jid, room_nicks, user_nick, profile): 330 def roomJoined(self, room_jid, room_nicks, user_nick, profile):
331 """Called when a MUC room is joined""" 331 """Called when a MUC room is joined"""
332 if not self.check_profile(profile): 332 if not self.check_profile(profile):