Mercurial > libervia-backend
comparison frontends/src/quick_frontend/quick_contact_list.py @ 1333:7c2289090b9b frontends_multi_profiles
quick_frontends (contact list): use of intermediate method for showEmptyGroups and showOfflineMessages to convert bridge values to actual booleans
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 23 Feb 2015 18:04:16 +0100 |
parents | 789e86a8919d |
children | 15e177584d82 |
comparison
equal
deleted
inserted
replaced
1321:e9888db0eb0c | 1333:7c2289090b9b |
---|---|
66 self.show_disconnected = False | 66 self.show_disconnected = False |
67 self.show_empty_groups = True | 67 self.show_empty_groups = True |
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 | 73 |
74 def __contains__(self, entity): | 74 def __contains__(self, entity): |
75 """Check if entity is in contact list | 75 """Check if entity is in contact list |
76 | 76 |
77 @param entity (jid.JID): jid of the entity (resource is not ignored, use bare jid if needed) | 77 @param entity (jid.JID): jid of the entity (resource is not ignored, use bare jid if needed) |
266 return self._selected | 266 return self._selected |
267 | 267 |
268 def entityToShow(self, entity, check_resource=False): | 268 def entityToShow(self, entity, check_resource=False): |
269 """Tell if the contact should be showed or hidden. | 269 """Tell if the contact should be showed or hidden. |
270 | 270 |
271 @param contact (jid.JID): jid of the contact | 271 @param entity (jid.JID): jid of the contact |
272 @param check_resource (bool): True if resource must be significant | 272 @param check_resource (bool): True if resource must be significant |
273 @return: True if that contact should be showed in the list | 273 @return (bool): True if that contact should be showed in the list |
274 """ | 274 """ |
275 show = self.getCache(entity, C.PRESENCE_SHOW) | 275 show = self.getCache(entity, C.PRESENCE_SHOW) |
276 | 276 |
277 if check_resource: | 277 if check_resource: |
278 alerts = self._alerts | 278 alerts = self._alerts |
339 if show == C.PRESENCE_UNAVAILABLE: | 339 if show == C.PRESENCE_UNAVAILABLE: |
340 if not entity.resource: | 340 if not entity.resource: |
341 cache[C.CONTACT_RESOURCES].clear() | 341 cache[C.CONTACT_RESOURCES].clear() |
342 cache[C.CONTACT_MAIN_RESOURCE]= None | 342 cache[C.CONTACT_MAIN_RESOURCE]= None |
343 else: | 343 else: |
344 del cache[C.CONTACT_RESOURCES][entity.resource] | 344 try: |
345 del cache[C.CONTACT_RESOURCES][entity.resource] | |
346 except KeyError: | |
347 log.error("Presence unavailable received for an unknown resource [{}]".format(entity)) | |
345 if not cache[C.CONTACT_RESOURCES]: | 348 if not cache[C.CONTACT_RESOURCES]: |
346 cache[C.CONTACT_MAIN_RESOURCE] = None | 349 cache[C.CONTACT_MAIN_RESOURCE] = None |
347 else: | 350 else: |
348 assert entity.resource | 351 assert entity.resource |
349 resources_data = cache[C.CONTACT_RESOURCES] | 352 resources_data = cache[C.CONTACT_RESOURCES] |
375 @param entity(jid.JID): entity which must displayed in alert mode (resource is significant) | 378 @param entity(jid.JID): entity which must displayed in alert mode (resource is significant) |
376 """ | 379 """ |
377 self._alerts.add(entity) | 380 self._alerts.add(entity) |
378 self.update() | 381 self.update() |
379 | 382 |
383 def _showOfflineContacts(self, show_str): | |
384 self.showOfflineContacts(C.bool(show_str)) | |
385 | |
380 def showOfflineContacts(self, show): | 386 def showOfflineContacts(self, show): |
381 show = C.bool(show) | 387 """Tell if offline contacts should shown |
388 | |
389 @param show(bool): True if offline contacts should be shown | |
390 """ | |
391 assert isinstance(show, bool) | |
382 if self.show_disconnected == show: | 392 if self.show_disconnected == show: |
383 return | 393 return |
384 self.show_disconnected = show | 394 self.show_disconnected = show |
385 self.update() | 395 self.update() |
386 | 396 |
397 def _showEmptyGroups(self, show_str): | |
398 self.showEmptyGroups(C.bool(show_str)) | |
399 | |
387 def showEmptyGroups(self, show): | 400 def showEmptyGroups(self, show): |
388 show = C.bool(show) | 401 assert isinstance(show, bool) |
389 if self.show_empty_groups == show: | 402 if self.show_empty_groups == show: |
390 return | 403 return |
391 self.show_empty_groups = show | 404 self.show_empty_groups = show |
392 self.update() | 405 self.update() |
393 | 406 |