diff frontends/src/quick_frontend/quick_app.py @ 504:65ecbb473cbb

core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard: - bridge: new bridge method getEntityData and signal entityDataUpdated - core: entityDataUpdated signal sent on new string data - quick frontend: fixed avatars/vcard infos, fixed _replace in quick_contact_list - plugin xep-0054: dropped updatedValue signal, use entities data instead
author Goffi <goffi@goffi.org>
date Wed, 26 Sep 2012 01:23:56 +0200
parents 10119c2a9d33
children f98bef71a918
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_app.py	Wed Sep 26 00:38:41 2012 +0200
+++ b/frontends/src/quick_frontend/quick_app.py	Wed Sep 26 01:23:56 2012 +0200
@@ -52,7 +52,7 @@
         self.bridge.register("subscribe", self.subscribe)
         self.bridge.register("paramUpdate", self.paramUpdate)
         self.bridge.register("contactDeleted", self.contactDeleted)
-        self.bridge.register("updatedValue", self.updatedValue)
+        self.bridge.register("entityDataUpdated", self.entityDataUpdated)
         self.bridge.register("askConfirmation", self.askConfirmation)
         self.bridge.register("actionResult", self.actionResult)
         self.bridge.register("actionResultExt", self.actionResult)
@@ -165,6 +165,10 @@
                     priority = presences[contact][res][1]
                     statuses = presences[contact][res][2]
                     self.presenceUpdate(jabber_id, show, priority, statuses, profile)
+                    data = self.bridge.getEntityData(contact, ['avatar','nick'], profile)
+                    for key in ('avatar', 'nick'):
+                        if key in data:
+                            self.entityDataUpdated(contact, key, data[key], profile)
 
             #The waiting subscription requests
             waitingSub = self.bridge.getWaitingSub(profile)
@@ -476,21 +480,19 @@
         except KeyError:
             pass
 
-    def updatedValue(self, name, data, profile):
-        #FIXME: to be removed
+    def entityDataUpdated(self, jid_str, key, value, profile):
         if not self.check_profile(profile):
             return
-        if name == "card_nick":
-            target = JID(data['jid'])
-            if target in self.contact_list:
-                #self.CM.update(target, 'nick', unicode(data['nick']))
-                self.contact_list._replace(target)
-        elif name == "card_avatar":
-            target = JID(data['jid'])
-            if target in self.contact_list:
-                filename = self.bridge.getAvatarFile(data['avatar'])
-                #self.CM.update(target, 'avatar', filename)
-                self.contact_list._replace(target)
+        jid = JID(jid_str)
+        if key == "nick":
+            if jid in self.contact_list:
+                self.contact_list.setCache(jid, 'nick', value)
+                self.contact_list._replace(jid)
+        elif key == "avatar":
+            if jid in self.contact_list:
+                filename = self.bridge.getAvatarFile(value)
+                self.contact_list.setCache(jid, 'avatar', filename)
+                self.contact_list._replace(jid)
 
     def askConfirmation(self, type, id, data):
         raise NotImplementedError