changeset 204:890776a6fdb7

browser + server: vcard is requested when no avatar data is found in cache
author Goffi <goffi@goffi.org>
date Thu, 20 Jun 2013 12:16:46 +0200
parents 5fdea93b2541
children ee744ffed7fc
files libervia.py libervia.tac
diffstat 2 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libervia.py	Thu Jun 20 12:16:46 2013 +0200
+++ b/libervia.py	Thu Jun 20 12:16:46 2013 +0200
@@ -100,8 +100,8 @@
     def __init__(self):
         LiberviaJsonProxy.__init__(self, "/json_api",
                         ["getContacts", "addContact", "sendMessage", "sendMblog", "sendMblogComment", "getLastMblogs", "getMassiveLastMblogs", "getMblogComments", "getProfileJid", "getHistory", "getPresenceStatus",
-                         "joinMUC", "mucLeave", "getRoomsJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed",
-                         "tarotGamePlayCards", "launchRadioCollective", "getWaitingSub", "subscription", "delContact", "updateContact", "getEntityData", "getParamsUI",
+                         "joinMUC", "mucLeave", "getRoomsJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed", "tarotGamePlayCards",
+                         "launchRadioCollective", "getWaitingSub", "subscription", "delContact", "updateContact", "getCard", "getEntityData", "getParamsUI",
                          #"setParam",
                          "launchAction", "disconnect",
                         ])
@@ -220,9 +220,14 @@
         def dataReceived(result):
             if 'avatar' in result:
                 self._entityDataUpdatedCb(jid_str, 'avatar', result['avatar'])
+            else:
+                self.bridge.call("getCard", None, jid_str)
+        def avatarError(error_data):
+            # The jid is maybe not in our roster, we ask for the VCard
+            self.bridge.call("getCard", None, jid_str)
         
         if jid_str not in self.avatars_cache:
-            self.bridge.call('getEntityData', dataReceived, jid_str, ['avatar'])
+            self.bridge.call('getEntityData', (dataReceived, avatarError), jid_str, ['avatar'])
             self.avatars_cache[jid_str] = "/media/misc/empty_avatar"
         return self.avatars_cache[jid_str]
 
--- a/libervia.tac	Thu Jun 20 12:16:46 2013 +0200
+++ b/libervia.tac	Thu Jun 20 12:16:46 2013 +0200
@@ -345,6 +345,13 @@
         profile = ISATSession(self.session).profile
         return self.sat_host.bridge.getEntityData(jid, keys, profile)
 
+    def jsonrpc_getCard(self, jid):
+        """Get VCard for entiry
+        @param jid: jid of contact from who we want data
+        @return: id to retrieve the profile"""
+        profile = ISATSession(self.session).profile
+        return self.sat_host.bridge.getCard(jid, profile)
+
     #def jsonrpc_getParamsUI(self):
     #    """Return the parameters XMLUI for profile"""
     #    profile = ISATSession(self.session).profile