diff frontends/src/quick_frontend/quick_app.py @ 1318:6c7d89843f1b frontends_multi_profiles

frontends (quick frontend): use of new getEntitiesData to get cached values for avatars on profile connection.
author Goffi <goffi@goffi.org>
date Mon, 09 Feb 2015 21:39:51 +0100
parents faa1129559b8
children 781ee3539252
line wrap: on
line diff
--- 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: