comparison libervia.py @ 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
comparison
equal deleted inserted replaced
203:5fdea93b2541 204:890776a6fdb7
98 98
99 class BridgeCall(LiberviaJsonProxy): 99 class BridgeCall(LiberviaJsonProxy):
100 def __init__(self): 100 def __init__(self):
101 LiberviaJsonProxy.__init__(self, "/json_api", 101 LiberviaJsonProxy.__init__(self, "/json_api",
102 ["getContacts", "addContact", "sendMessage", "sendMblog", "sendMblogComment", "getLastMblogs", "getMassiveLastMblogs", "getMblogComments", "getProfileJid", "getHistory", "getPresenceStatus", 102 ["getContacts", "addContact", "sendMessage", "sendMblog", "sendMblogComment", "getLastMblogs", "getMassiveLastMblogs", "getMblogComments", "getProfileJid", "getHistory", "getPresenceStatus",
103 "joinMUC", "mucLeave", "getRoomsJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed", 103 "joinMUC", "mucLeave", "getRoomsJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed", "tarotGamePlayCards",
104 "tarotGamePlayCards", "launchRadioCollective", "getWaitingSub", "subscription", "delContact", "updateContact", "getEntityData", "getParamsUI", 104 "launchRadioCollective", "getWaitingSub", "subscription", "delContact", "updateContact", "getCard", "getEntityData", "getParamsUI",
105 #"setParam", 105 #"setParam",
106 "launchAction", "disconnect", 106 "launchAction", "disconnect",
107 ]) 107 ])
108 108
109 class BridgeSignals(LiberviaJsonProxy): 109 class BridgeSignals(LiberviaJsonProxy):
218 def getAvatar(self, jid_str): 218 def getAvatar(self, jid_str):
219 """Return avatar of a jid if in cache, else ask for it""" 219 """Return avatar of a jid if in cache, else ask for it"""
220 def dataReceived(result): 220 def dataReceived(result):
221 if 'avatar' in result: 221 if 'avatar' in result:
222 self._entityDataUpdatedCb(jid_str, 'avatar', result['avatar']) 222 self._entityDataUpdatedCb(jid_str, 'avatar', result['avatar'])
223 else:
224 self.bridge.call("getCard", None, jid_str)
225 def avatarError(error_data):
226 # The jid is maybe not in our roster, we ask for the VCard
227 self.bridge.call("getCard", None, jid_str)
223 228
224 if jid_str not in self.avatars_cache: 229 if jid_str not in self.avatars_cache:
225 self.bridge.call('getEntityData', dataReceived, jid_str, ['avatar']) 230 self.bridge.call('getEntityData', (dataReceived, avatarError), jid_str, ['avatar'])
226 self.avatars_cache[jid_str] = "/media/misc/empty_avatar" 231 self.avatars_cache[jid_str] = "/media/misc/empty_avatar"
227 return self.avatars_cache[jid_str] 232 return self.avatars_cache[jid_str]
228 233
229 def registerWidget(self, wid): 234 def registerWidget(self, wid):
230 print "Registering", wid 235 print "Registering", wid