]> git.0d.be Git - empathy.git/commitdiff
Add fields which are supported but not in the vCard
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 20 Oct 2010 11:38:03 +0000 (13:38 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 3 Nov 2010 07:45:23 +0000 (08:45 +0100)
libempathy-gtk/empathy-contact-widget.c

index c0a6b82260196620f421ce0b29497b089ad56aff..26713ebe421c34dbadf5f8f2f2b9dd00bba97bd1 100644 (file)
@@ -298,6 +298,40 @@ contact_info_field_cmp (TpContactInfoField *field1,
   return contact_info_field_name_cmp (field1->field_name, field2->field_name);
 }
 
+static gboolean
+field_name_in_field_list (GList *list,
+    const gchar *name)
+{
+  GList *l;
+
+  for (l = list; l != NULL; l = g_list_next (l))
+    {
+      TpContactInfoField *field = l->data;
+
+      if (!tp_strdiff (field->field_name, name))
+        return TRUE;
+    }
+
+  return FALSE;
+}
+
+static TpContactInfoFieldSpec *
+get_spec_from_list (GList *list,
+    const gchar *name)
+{
+  GList *l;
+
+  for (l = list; l != NULL; l = g_list_next (l))
+    {
+      TpContactInfoFieldSpec *spec = l->data;
+
+      if (!tp_strdiff (spec->name, name))
+        return spec;
+    }
+
+  return NULL;
+}
+
 static guint
 contact_widget_details_update_edit (EmpathyContactWidget *information)
 {
@@ -306,6 +340,7 @@ contact_widget_details_update_edit (EmpathyContactWidget *information)
   GList *specs, *l;
   guint n_rows = 0;
   GList *info;
+  guint i;
 
   g_assert (information->details_to_set == NULL);
 
@@ -329,6 +364,29 @@ contact_widget_details_update_edit (EmpathyContactWidget *information)
           field);
     }
 
+  /* Add fields which are supported but not in the vCard */
+  for (i = 0; info_field_datas[i].field_name != NULL; i++)
+    {
+      TpContactInfoFieldSpec *spec;
+      TpContactInfoField *field;
+
+      /* Check if the field was in the vCard */
+      if (field_name_in_field_list (information->details_to_set,
+            info_field_datas[i].field_name))
+        continue;
+
+      /* Check if the CM supports the field */
+      spec = get_spec_from_list (specs, info_field_datas[i].field_name);
+      if (spec == NULL)
+        continue;
+
+      /* add an empty field so user can set a value */
+      field = tp_contact_info_field_new (spec->name, spec->parameters, NULL);
+
+      information->details_to_set = g_list_prepend (information->details_to_set,
+          field);
+    }
+
   /* Add widgets for supported fields */
   information->details_to_set = g_list_sort (information->details_to_set,
       (GCompareFunc) contact_info_field_cmp);