[empathy] Add unsupported contact fields to details_to_set (#630427)



commit 0f7279a3bbbe4bfd4dceb06e54ec983082d6c58f
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Fri Sep 24 11:27:16 2010 +0200

    Add unsupported contact fields to details_to_set (#630427)
    
    This avoid to loss unsupported fields when closing the dialog.

 libempathy-gtk/empathy-contact-widget.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c
index f20ec81..2cb725d 100644
--- a/libempathy-gtk/empathy-contact-widget.c
+++ b/libempathy-gtk/empathy-contact-widget.c
@@ -290,7 +290,7 @@ contact_widget_details_update_edit (EmpathyContactWidget *information)
   for (l = specs; l != NULL; l = l->next)
     {
       TpContactInfoFieldSpec *spec = l->data;
-      TpContactInfoField *field;
+      TpContactInfoField *field = NULL;
       InfoFieldData *field_data;
       GList *ll;
       GtkWidget *w;
@@ -299,15 +299,15 @@ contact_widget_details_update_edit (EmpathyContactWidget *information)
       if (field_data == NULL)
         {
           DEBUG ("Unhandled ContactInfo field spec: %s", spec->name);
-          continue;
         }
 
       /* Search initial value */
-      for (ll = info; ll != NULL; ll = ll->next)
+      for (ll = info; ll != NULL && field == NULL; ll = ll->next)
         {
-          field = ll->data;
-          if (!tp_strdiff (field->field_name, spec->name))
-            break;
+          TpContactInfoField *tmp = ll->data;
+
+          if (!tp_strdiff (tmp->field_name, spec->name))
+            field = tmp;
         }
 
       if (field != NULL)
@@ -317,6 +317,11 @@ contact_widget_details_update_edit (EmpathyContactWidget *information)
         }
       else
         {
+          /* Empathy doesn't support editing this file and it's not in the
+           * contact's fields so we can't do much with it. */
+          if (field_data == NULL)
+            continue;
+
           field = tp_contact_info_field_new (spec->name, spec->parameters,
               NULL);
         }
@@ -324,6 +329,12 @@ contact_widget_details_update_edit (EmpathyContactWidget *information)
       information->details_to_set = g_list_prepend (information->details_to_set,
           field);
 
+      /* Empathy doesn't display this field so we can't change it. But we put
+       * it in the details_to_set list so it won't be erased when calling
+       * SetContactInfo (bgo #630427) */
+      if (field_data == NULL)
+        continue;
+
       /* Add Title */
       w = gtk_label_new (_(field_data->title));
       gtk_table_attach (GTK_TABLE (information->table_details),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]