frontends (quick frontend): use of new getEntitiesData to get cached values for avatars on profile connection.
This commit is contained in:
parent
027ab18369
commit
b705b5688f
1 changed files with 15 additions and 0 deletions
|
|
@ -33,6 +33,7 @@ class ProfileManager(object):
|
|||
"""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 @@ class ProfileManager(object):
|
|||
|
||||
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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue