comparison frontends/src/quick_frontend/quick_contact_list.py @ 1332:0f92b6a150ff frontends_multi_profiles

quick_frontend, primitivus: use a listener to update the contact list when receiving a presence
author souliane <souliane@mailoo.org>
date Sun, 22 Feb 2015 21:30:20 +0100
parents 7a3a232d4938
children f29beedb33b0
comparison
equal deleted inserted replaced
1331:7fa07c7b0761 1332:0f92b6a150ff
68 self.show_resources = False 68 self.show_resources = False
69 self.show_status = False 69 self.show_status = False
70 # TODO: this may lead to two successive UI refresh and needs an optimization 70 # TODO: this may lead to two successive UI refresh and needs an optimization
71 self.host.bridge.asyncGetParamA(C.SHOW_EMPTY_GROUPS, "General", profile_key=profile, callback=self.showEmptyGroups) 71 self.host.bridge.asyncGetParamA(C.SHOW_EMPTY_GROUPS, "General", profile_key=profile, callback=self.showEmptyGroups)
72 self.host.bridge.asyncGetParamA(C.SHOW_OFFLINE_CONTACTS, "General", profile_key=profile, callback=self.showOfflineContacts) 72 self.host.bridge.asyncGetParamA(C.SHOW_OFFLINE_CONTACTS, "General", profile_key=profile, callback=self.showOfflineContacts)
73
74 # FIXME: workaround for a pyjamas issue: calling hash on a class method always return a different value if that method is defined directly within the class (with the "def" keyword)
75 self.presenceListener = self.updatePresence
76 self.host.addListener('presence', self.presenceListener, [profile])
73 77
74 def __contains__(self, entity): 78 def __contains__(self, entity):
75 """Check if entity is in contact list 79 """Check if entity is in contact list
76 80
77 @param entity (jid.JID): jid of the entity (resource is not ignored, use bare jid if needed) 81 @param entity (jid.JID): jid of the entity (resource is not ignored, use bare jid if needed)
416 show = C.bool(show) 420 show = C.bool(show)
417 if self.show_resources == show: 421 if self.show_resources == show:
418 return 422 return
419 self.show_resources = show 423 self.show_resources = show
420 self.update() 424 self.update()
425
426 def onDelete(self):
427 QuickWidget.onDelete(self)
428 self.host.removeListener('presence', self.presenceListener)