aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-10-20 19:38:03 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-11-03 15:45:23 +0800
commit60ceff650179f376d3f35831a4170b3bc0a2577a (patch)
tree0920726af1abfd4a9db110b389e8d5d8358b3917 /libempathy-gtk
parent56b38154b0c236a158a41989c0cc72e0302cf6ff (diff)
downloadgsoc2013-empathy-60ceff650179f376d3f35831a4170b3bc0a2577a.tar
gsoc2013-empathy-60ceff650179f376d3f35831a4170b3bc0a2577a.tar.gz
gsoc2013-empathy-60ceff650179f376d3f35831a4170b3bc0a2577a.tar.bz2
gsoc2013-empathy-60ceff650179f376d3f35831a4170b3bc0a2577a.tar.lz
gsoc2013-empathy-60ceff650179f376d3f35831a4170b3bc0a2577a.tar.xz
gsoc2013-empathy-60ceff650179f376d3f35831a4170b3bc0a2577a.tar.zst
gsoc2013-empathy-60ceff650179f376d3f35831a4170b3bc0a2577a.zip
Add fields which are supported but not in the vCard
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-contact-widget.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c
index c0a6b8226..26713ebe4 100644
--- a/libempathy-gtk/empathy-contact-widget.c
+++ b/libempathy-gtk/empathy-contact-widget.c
@@ -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);