[telepathy-gabble/telepathy-gabble-0.8] fd.o#25341: Always sets its own vcard on login

Andre Moreira Magalhaes (andrunko) andrunko at andrunko.cbg.collabora.co.uk
Mon Dec 7 06:04:16 PST 2009


Note that gmail only stores vcard fields FN and PHOTO, so when using empathy the
nickname (alias) will be updated on every login.
---
 src/vcard-manager.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/vcard-manager.c b/src/vcard-manager.c
index c93332d..28601df 100644
--- a/src/vcard-manager.c
+++ b/src/vcard-manager.c
@@ -1000,6 +1000,27 @@ vcard_copy (LmMessageNode *parent, LmMessageNode *src)
     return new;
 }
 
+static gboolean
+check_vcard_changed (gpointer k, gpointer v, gpointer user_data)
+{
+  const gchar *key = k;
+  const gchar *value = v;
+  LmMessageNode *vcard_node = user_data;
+  LmMessageNode *node;
+
+  node = lm_message_node_get_child (vcard_node, key);
+  if (node != NULL)
+    {
+      const gchar *node_value = lm_message_node_get_value (node);
+
+      if (!tp_strdiff (node_value, value))
+        return FALSE;
+    }
+
+  DEBUG ("vcard node %s changed, vcard needs update", key);
+  return TRUE;
+}
+
 static void
 manager_patch_vcard (GabbleVCardManager *self,
                      LmMessageNode *vcard_node)
@@ -1015,6 +1036,12 @@ manager_patch_vcard (GabbleVCardManager *self,
   if (priv->edits == NULL || priv->edit_pipeline_item != NULL)
       return;
 
+  if (g_hash_table_find (priv->edits, check_vcard_changed, vcard_node) == NULL)
+    {
+      DEBUG ("nothing changed, not updating vcard");
+      goto out;
+    }
+
   DEBUG("patching vcard");
 
   msg = lm_message_new_with_sub_type (NULL, LM_MESSAGE_TYPE_IQ,
@@ -1036,6 +1063,7 @@ manager_patch_vcard (GabbleVCardManager *self,
 
   lm_message_unref (msg);
 
+out:
   /* We've applied those, forget about them */
   g_hash_table_destroy (priv->edits);
   priv->edits = NULL;
-- 
1.5.6.5




More information about the telepathy-commits mailing list