# HG changeset patch # User Goffi # Date 1423514391 -3600 # Node ID 6c7d89843f1bd1e1f98696a34b655977c7ca4347 # Parent bd69d341d9693a30eb4b4fea8183fd33c7329073 frontends (quick frontend): use of new getEntitiesData to get cached values for avatars on profile connection. diff -r bd69d341d969 -r 6c7d89843f1b frontends/src/quick_frontend/constants.py --- a/frontends/src/quick_frontend/constants.py Mon Feb 09 21:39:51 2015 +0100 +++ b/frontends/src/quick_frontend/constants.py Mon Feb 09 21:39:51 2015 +0100 @@ -30,3 +30,5 @@ CONTACT_SPECIAL_GROUP = 'group' # group chat special entity CONTACT_SPECIAL_ALLOWED = (CONTACT_SPECIAL_GROUP,) # set of allowed values for special flag CONTACT_DATA_FORBIDDEN = {CONTACT_GROUPS, CONTACT_RESOURCES, CONTACT_MAIN_RESOURCE} # set of forbidden names for contact data + + LISTENERS = {'avatar'} diff -r bd69d341d969 -r 6c7d89843f1b frontends/src/quick_frontend/quick_app.py --- a/frontends/src/quick_frontend/quick_app.py Mon Feb 09 21:39:51 2015 +0100 +++ b/frontends/src/quick_frontend/quick_app.py Mon Feb 09 21:39:51 2015 +0100 @@ -33,6 +33,7 @@ """Class managing all data relative to one profile, and plugging in mechanism""" host = None bridge = None + cache_keys_to_get = ['avatar'] def __init__(self, profile): self.profile = profile @@ -65,9 +66,21 @@ def _plug_profile_afterconnect(self): # Profile can be connected or not + # we get cached data + self.host.bridge.getEntitiesData([], ProfileManager.cache_keys_to_get, profile=self.profile, callback=self._plug_profile_gotCachedValues, errback=self._plug_profile_failedCachedValues) + + def _plug_profile_failedCachedValues(self, failure): + log.error("Couldn't get cached values: {}".format(failure)) + self._plug_profile_gotCachedValues({}) + + def _plug_profile_gotCachedValues(self, cached_values): # TODO: watched plugin contact_list = self.host.addContactList(self.profile) + for entity, data in cached_values.iteritems(): + for key, value in data.iteritems(): + self.host.contact_lists[self.profile].setCache(jid.JID(entity), key, value) + if not self.bridge.isConnected(self.profile): self.host.setStatusOnline(False, profile=self.profile) else: