]> git.0d.be Git - empathy.git/blob - libempathy-gtk/empathy-user-info.c
4c447772b39d894fdeb0e2201fe3e4ca49eb3ac4
[empathy.git] / libempathy-gtk / empathy-user-info.c
1 /*
2  * empathy-user-info.c - Source for EmpathyUserInfo
3  *
4  * Copyright (C) 2012 - Collabora Ltd.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with This library. If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #include "config.h"
21 #include "empathy-user-info.h"
22
23 #include <glib/gi18n-lib.h>
24
25 #define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
26 #include "libempathy/empathy-debug.h"
27 #include "libempathy/empathy-time.h"
28 #include "libempathy/empathy-utils.h"
29
30 #include "empathy-avatar-chooser.h"
31 #include "empathy-calendar-button.h"
32 #include "empathy-contactinfo-utils.h"
33
34 G_DEFINE_TYPE (EmpathyUserInfo, empathy_user_info, GTK_TYPE_GRID)
35
36 struct _EmpathyUserInfoPrivate
37 {
38   TpAccount *account;
39
40   GtkWidget *avatar_chooser;
41   GtkWidget *nickname_entry;
42   GtkWidget *details_label;
43   GtkWidget *details_spinner;
44
45   GList *details_to_set;
46   gboolean details_changed;
47   GCancellable *details_cancellable;
48 };
49
50 enum
51 {
52   PROP_0,
53   PROP_ACCOUNT,
54 };
55
56 #define DATA_FIELD "contact-info-field"
57 #define DATA_IS_CONTACT_INFO "is-contact-info"
58
59 static void
60 contact_info_changed_cb (GtkEntry *entry,
61     EmpathyUserInfo *self)
62 {
63   const gchar *strv[] = { NULL, NULL };
64   TpContactInfoField *field;
65
66   self->priv->details_changed = TRUE;
67
68   field = g_object_get_data ((GObject *) entry, DATA_FIELD);
69   g_assert (field != NULL);
70
71   strv[0] = gtk_entry_get_text (entry);
72
73   if (field->field_value != NULL)
74     g_strfreev (field->field_value);
75   field->field_value = g_strdupv ((GStrv) strv);
76 }
77
78 static void
79 bday_changed_cb (EmpathyCalendarButton *button,
80     GDate *date,
81     EmpathyUserInfo *self)
82 {
83   const gchar *strv[] = { NULL, NULL };
84   TpContactInfoField *field;
85
86   self->priv->details_changed = TRUE;
87
88   field = g_object_get_data ((GObject *) button, DATA_FIELD);
89   g_assert (field != NULL);
90
91   if (date != NULL)
92     {
93       gchar tmp[255];
94
95       g_date_strftime (tmp, sizeof (tmp), EMPATHY_DATE_FORMAT_DISPLAY_SHORT,
96           date);
97       strv[0] = tmp;
98     }
99
100   if (field->field_value != NULL)
101     g_strfreev (field->field_value);
102   field->field_value = g_strdupv ((GStrv) strv);
103 }
104
105 static gboolean
106 field_name_in_field_list (GList *list,
107     const gchar *name)
108 {
109   GList *l;
110
111   for (l = list; l != NULL; l = g_list_next (l))
112     {
113       TpContactInfoField *field = l->data;
114
115       if (!tp_strdiff (field->field_name, name))
116         return TRUE;
117     }
118
119   return FALSE;
120 }
121
122 static TpContactInfoFieldSpec *
123 get_spec_from_list (GList *list,
124     const gchar *name)
125 {
126   GList *l;
127
128   for (l = list; l != NULL; l = g_list_next (l))
129     {
130       TpContactInfoFieldSpec *spec = l->data;
131
132       if (!tp_strdiff (spec->name, name))
133         return spec;
134     }
135
136   return NULL;
137 }
138
139 static void
140 add_row (GtkGrid *grid,
141     GtkWidget *title,
142     GtkWidget *value,
143     gboolean contact_info)
144 {
145   /* Title */
146   gtk_grid_attach_next_to (grid, title, NULL, GTK_POS_BOTTOM, 1, 1);
147   gtk_misc_set_alignment (GTK_MISC (title), 1, 0.5);
148   gtk_style_context_add_class (gtk_widget_get_style_context (title),
149       GTK_STYLE_CLASS_DIM_LABEL);
150   gtk_widget_show (title);
151
152   /* Value */
153   gtk_grid_attach_next_to (grid, value, title, GTK_POS_RIGHT,
154       contact_info ? 2 : 1, 1);
155   gtk_widget_set_hexpand (value, TRUE);
156   if (GTK_IS_LABEL (value))
157     {
158       gtk_misc_set_alignment (GTK_MISC (value), 0, 0.5);
159       gtk_label_set_selectable (GTK_LABEL (value), TRUE);
160     }
161   gtk_widget_show (value);
162
163   if (contact_info)
164     {
165       g_object_set_data (G_OBJECT (title),
166           DATA_IS_CONTACT_INFO, (gpointer) TRUE);
167       g_object_set_data (G_OBJECT (value),
168           DATA_IS_CONTACT_INFO, (gpointer) TRUE);
169     }
170 }
171
172 static guint
173 fill_contact_info_grid (EmpathyUserInfo *self)
174 {
175   TpConnection *connection;
176   TpContact *contact;
177   GList *specs, *l;
178   guint n_rows = 0;
179   GList *info;
180   const char **field_names = empathy_contact_info_get_field_names (NULL);
181   guint i;
182
183   g_assert (self->priv->details_to_set == NULL);
184
185   connection = tp_account_get_connection (self->priv->account);
186   contact = tp_connection_get_self_contact (connection);
187   specs = tp_connection_dup_contact_info_supported_fields (connection);
188   info = tp_contact_dup_contact_info (contact);
189
190   /* Look at the fields set in our vCard */
191   for (l = info; l != NULL; l = l->next)
192     {
193       TpContactInfoField *field = l->data;
194
195       /* make a copy for the details_to_set list */
196       field = tp_contact_info_field_copy (field);
197       DEBUG ("Field %s is in our vCard", field->field_name);
198
199       self->priv->details_to_set = g_list_prepend (self->priv->details_to_set,
200           field);
201     }
202
203   /* Add fields which are supported but not in the vCard */
204   for (i = 0; field_names[i] != NULL; i++)
205     {
206       TpContactInfoFieldSpec *spec;
207       TpContactInfoField *field;
208
209       /* Check if the field was in the vCard */
210       if (field_name_in_field_list (self->priv->details_to_set,
211             field_names[i]))
212         continue;
213
214       /* Check if the CM supports the field */
215       spec = get_spec_from_list (specs, field_names[i]);
216       if (spec == NULL)
217         continue;
218
219       /* add an empty field so user can set a value */
220       field = tp_contact_info_field_new (spec->name, spec->parameters, NULL);
221
222       self->priv->details_to_set = g_list_prepend (self->priv->details_to_set,
223           field);
224     }
225
226   /* Add widgets for supported fields */
227   self->priv->details_to_set = g_list_sort (self->priv->details_to_set,
228       (GCompareFunc) empathy_contact_info_field_spec_cmp);
229
230   for (l = self->priv->details_to_set; l != NULL; l= g_list_next (l))
231     {
232       TpContactInfoField *field = l->data;
233       GtkWidget *label, *w;
234       TpContactInfoFieldSpec *spec;
235       gboolean has_field;
236       char *title;
237
238       has_field = empathy_contact_info_lookup_field (field->field_name,
239           NULL, NULL);
240       if (!has_field)
241         {
242           /* Empathy doesn't display this field so we can't change it.
243            * But we put it in the details_to_set list so it won't be erased
244            * when calling SetContactInfo (bgo #630427) */
245           DEBUG ("Unhandled ContactInfo field spec: %s", field->field_name);
246           continue;
247         }
248
249       spec = get_spec_from_list (specs, field->field_name);
250       /* We shouldn't have added the field to details_to_set if it's not
251        * supported by the CM */
252       g_assert (spec != NULL);
253
254       if (spec->flags & TP_CONTACT_INFO_FIELD_FLAG_OVERWRITTEN_BY_NICKNAME)
255         {
256           DEBUG ("Ignoring field '%s' due it to having the "
257               "Overwritten_By_Nickname flag", field->field_name);
258           continue;
259         }
260
261       /* Add Title */
262       title = empathy_contact_info_field_label (field->field_name,
263           field->parameters,
264           (spec->flags & TP_CONTACT_INFO_FIELD_FLAG_PARAMETERS_EXACT));
265       label = gtk_label_new (title);
266       g_free (title);
267
268       /* TODO: if TP_CONTACT_INFO_FIELD_FLAG_PARAMETERS_EXACT is not set we
269        * should allow user to tag the vCard fields (bgo#672034) */
270
271       /* Add Value */
272       if (!tp_strdiff (field->field_name, "bday"))
273         {
274           w = empathy_calendar_button_new ();
275
276           if (field->field_value[0])
277             {
278               GDate date;
279
280               g_date_set_parse (&date, field->field_value[0]);
281               if (g_date_valid (&date))
282                 {
283                   empathy_calendar_button_set_date (EMPATHY_CALENDAR_BUTTON (w),
284                       &date);
285                 }
286             }
287
288           g_signal_connect (w, "date-changed",
289             G_CALLBACK (bday_changed_cb), self);
290         }
291       else
292         {
293           w = gtk_entry_new ();
294           gtk_entry_set_text (GTK_ENTRY (w),
295               field->field_value[0] ? field->field_value[0] : "");
296           g_signal_connect (w, "changed",
297             G_CALLBACK (contact_info_changed_cb), self);
298         }
299
300       add_row (GTK_GRID (self), label, w, TRUE);
301
302       g_object_set_data ((GObject *) w, DATA_FIELD, field);
303
304       n_rows++;
305     }
306
307   tp_contact_info_spec_list_free (specs);
308   tp_contact_info_list_free (info);
309
310   return n_rows;
311 }
312
313 static void
314 grid_foreach_cb (GtkWidget *widget,
315     gpointer data)
316 {
317   if (g_object_get_data (G_OBJECT (widget), DATA_IS_CONTACT_INFO) != NULL)
318     gtk_widget_destroy (widget);
319 }
320
321 static void
322 request_contact_info_cb (GObject *object,
323     GAsyncResult *res,
324     gpointer user_data)
325 {
326   EmpathyUserInfo *self = user_data;
327   TpContact *contact = TP_CONTACT (object);
328   guint n_rows;
329   GError *error = NULL;
330
331   if (!tp_contact_request_contact_info_finish (contact, res, &error))
332     {
333       /* If the request got cancelled it could mean the contact widget is
334        * destroyed, so we should not dereference self */
335       if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
336         {
337           g_clear_error (&error);
338           return;
339         }
340       g_clear_error (&error);
341     }
342
343   n_rows = fill_contact_info_grid (self);
344
345   gtk_widget_set_visible (self->priv->details_label, n_rows > 0);
346   gtk_spinner_stop (GTK_SPINNER (self->priv->details_spinner));
347   gtk_widget_hide (self->priv->details_spinner);
348 }
349
350 static void
351 reload_contact_info (EmpathyUserInfo *self)
352 {
353   TpConnection *connection;
354   TpContact *contact = NULL;
355   TpContactInfoFlags flags;
356
357   /* Cancel previous RequestContactInfo, if any */
358   if (self->priv->details_cancellable != NULL)
359     g_cancellable_cancel (self->priv->details_cancellable);
360   g_clear_object (&self->priv->details_cancellable);
361
362   /* Remove current contact info widgets, if any */
363   gtk_container_foreach (GTK_CONTAINER (self), grid_foreach_cb, NULL);
364   gtk_widget_hide (self->priv->details_label);
365   gtk_widget_hide (self->priv->details_spinner);
366
367   tp_clear_pointer (&self->priv->details_to_set, tp_contact_info_list_free);
368   self->priv->details_changed = FALSE;
369
370   connection = tp_account_get_connection (self->priv->account);
371   if (connection != NULL)
372     contact = tp_connection_get_self_contact (connection);
373
374   /* Display infobar if we don't have a self contact (probably offline) */
375   if (contact == NULL)
376     {
377       GtkWidget *infobar;
378       GtkWidget *content;
379       GtkWidget *label;
380
381       infobar = gtk_info_bar_new ();
382       gtk_info_bar_set_message_type (GTK_INFO_BAR (infobar), GTK_MESSAGE_INFO);
383       content = gtk_info_bar_get_content_area (GTK_INFO_BAR (infobar));
384       label = gtk_label_new (_("Go online to edit your personal information."));
385       gtk_container_add (GTK_CONTAINER (content), label);
386       gtk_widget_show (label);
387
388       gtk_grid_attach_next_to ((GtkGrid *) self, infobar,
389           NULL, GTK_POS_BOTTOM, 3, 1);
390       gtk_widget_show (infobar);
391
392       g_object_set_data (G_OBJECT (infobar),
393           DATA_IS_CONTACT_INFO, (gpointer) TRUE);
394       return;
395     }
396
397   if (!tp_proxy_has_interface_by_id (connection,
398           TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_INFO))
399     return;
400
401   flags = tp_connection_get_contact_info_flags (connection);
402   if ((flags & TP_CONTACT_INFO_FLAG_CAN_SET) == 0)
403     return;
404
405   /* Request the contact's info */
406   gtk_widget_show (self->priv->details_spinner);
407   gtk_spinner_start (GTK_SPINNER (self->priv->details_spinner));
408
409   g_assert (self->priv->details_cancellable == NULL);
410   self->priv->details_cancellable = g_cancellable_new ();
411   tp_contact_request_contact_info_async (contact,
412       self->priv->details_cancellable, request_contact_info_cb,
413       self);
414 }
415
416 static void
417 connection_notify_cb (EmpathyUserInfo *self)
418 {
419   TpConnection *connection = tp_account_get_connection (self->priv->account);
420
421   if (connection != NULL)
422     {
423       tp_g_signal_connect_object (connection, "notify::self-contact",
424           G_CALLBACK (reload_contact_info), self, G_CONNECT_SWAPPED);
425     }
426
427   reload_contact_info (self);
428 }
429
430 static void
431 empathy_user_info_constructed (GObject *object)
432 {
433   EmpathyUserInfo *self = (EmpathyUserInfo *) object;
434   GtkGrid *grid = (GtkGrid *) self;
435   GtkWidget *title;
436   GtkWidget *value;
437
438   G_OBJECT_CLASS (empathy_user_info_parent_class)->constructed (object);
439
440   gtk_grid_set_column_spacing (grid, 6);
441   gtk_grid_set_row_spacing (grid, 6);
442
443   /* Setup id label */
444   title = gtk_label_new (_("Identifier"));
445   value = gtk_label_new (tp_account_get_normalized_name (self->priv->account));
446   add_row (grid, title, value, FALSE);
447
448   /* Setup nickname entry */
449   title = gtk_label_new (_("Alias"));
450   self->priv->nickname_entry = gtk_entry_new ();
451   gtk_entry_set_text (GTK_ENTRY (self->priv->nickname_entry),
452       tp_account_get_nickname (self->priv->account));
453   add_row (grid, title, self->priv->nickname_entry, FALSE);
454
455   /* Set up avatar chooser */
456   self->priv->avatar_chooser = empathy_avatar_chooser_new (self->priv->account);
457   gtk_grid_attach (grid, self->priv->avatar_chooser,
458       2, 0, 1, 3);
459   gtk_widget_show (self->priv->avatar_chooser);
460
461   /* Details label */
462   self->priv->details_label = gtk_label_new (NULL);
463   gtk_label_set_markup (GTK_LABEL (self->priv->details_label),
464       _("<b>Personal Details</b>"));
465   gtk_misc_set_alignment (GTK_MISC (self->priv->details_label), 0, 0.5);
466   gtk_grid_attach_next_to (grid, self->priv->details_label, NULL,
467       GTK_POS_BOTTOM, 3, 1);
468
469   /* Details spinner */
470   self->priv->details_spinner = gtk_spinner_new ();
471   gtk_widget_set_hexpand (self->priv->details_spinner, TRUE);
472   gtk_widget_set_vexpand (self->priv->details_spinner, TRUE);
473   gtk_grid_attach_next_to (grid, self->priv->details_spinner, NULL,
474       GTK_POS_BOTTOM, 3, 1);
475
476   g_signal_connect_swapped (self->priv->account, "notify::connection",
477       G_CALLBACK (connection_notify_cb), self);
478   connection_notify_cb (self);
479 }
480
481 static void
482 empathy_user_info_dispose (GObject *object)
483 {
484   EmpathyUserInfo *self = (EmpathyUserInfo *) object;
485
486   if (self->priv->account != NULL)
487     {
488       /* Disconnect the signal manually, because TpAccount::dispose will emit
489        * "notify::connection" signal before tp_g_signal_connect_object() had
490        * a chance to disconnect. */
491       g_signal_handlers_disconnect_by_func (self->priv->account,
492           connection_notify_cb, self);
493       g_clear_object (&self->priv->account);
494     }
495
496   if (self->priv->details_cancellable != NULL)
497     g_cancellable_cancel (self->priv->details_cancellable);
498   g_clear_object (&self->priv->details_cancellable);
499
500   G_OBJECT_CLASS (empathy_user_info_parent_class)->dispose (object);
501 }
502
503 static void
504 empathy_user_info_get_property (GObject *object,
505     guint property_id,
506     GValue *value,
507     GParamSpec *pspec)
508 {
509   EmpathyUserInfo *self = (EmpathyUserInfo *) object;
510
511   switch (property_id)
512     {
513       case PROP_ACCOUNT:
514         g_value_set_object (value, self->priv->account);
515         break;
516       default:
517         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
518         break;
519     }
520 }
521
522 static void
523 empathy_user_info_set_property (GObject *object,
524     guint property_id,
525     const GValue *value,
526     GParamSpec *pspec)
527 {
528   EmpathyUserInfo *self = (EmpathyUserInfo *) object;
529
530   switch (property_id)
531     {
532       case PROP_ACCOUNT:
533         g_assert (self->priv->account == NULL); /* construct-only */
534         self->priv->account = g_value_dup_object (value);
535         break;
536       default:
537         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
538         break;
539     }
540 }
541
542 static void
543 empathy_user_info_init (EmpathyUserInfo *self)
544 {
545   self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
546       EMPATHY_TYPE_USER_INFO, EmpathyUserInfoPrivate);
547 }
548
549 static void
550 empathy_user_info_class_init (EmpathyUserInfoClass *klass)
551 {
552   GObjectClass *object_class = G_OBJECT_CLASS (klass);
553   GParamSpec *param_spec;
554
555   object_class->constructed = empathy_user_info_constructed;
556   object_class->dispose = empathy_user_info_dispose;
557   object_class->get_property = empathy_user_info_get_property;
558   object_class->set_property = empathy_user_info_set_property;
559
560   g_type_class_add_private (object_class, sizeof (EmpathyUserInfoPrivate));
561
562   param_spec = g_param_spec_object ("account",
563       "account",
564       "The #TpAccount on which user info should be edited",
565       TP_TYPE_ACCOUNT,
566       G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
567   g_object_class_install_property (object_class, PROP_ACCOUNT, param_spec);
568 }
569
570 GtkWidget *
571 empathy_user_info_new (TpAccount *account)
572 {
573   g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
574
575   return g_object_new (EMPATHY_TYPE_USER_INFO,
576       "account", account,
577       NULL);
578 }
579
580 void
581 empathy_user_info_discard (EmpathyUserInfo *self)
582 {
583   g_return_if_fail (EMPATHY_IS_USER_INFO (self));
584
585   reload_contact_info (self);
586   gtk_entry_set_text ((GtkEntry *) self->priv->nickname_entry,
587       tp_account_get_nickname (self->priv->account));
588 }
589
590 static void
591 apply_complete_one (GSimpleAsyncResult *result)
592 {
593   guint count;
594
595   count = g_simple_async_result_get_op_res_gssize (result);
596   count--;
597   g_simple_async_result_set_op_res_gssize (result, count);
598
599   if (count == 0)
600     g_simple_async_result_complete (result);
601 }
602
603 static void
604 avatar_chooser_apply_cb (GObject *source,
605     GAsyncResult *result,
606     gpointer user_data)
607 {
608   EmpathyAvatarChooser *avatar_chooser = (EmpathyAvatarChooser *) source;
609   GSimpleAsyncResult *my_result = user_data;
610   GError *error = NULL;
611
612   if (!empathy_avatar_chooser_apply_finish (avatar_chooser, result, &error))
613     g_simple_async_result_take_error (my_result, error);
614
615   apply_complete_one (my_result);
616   g_object_unref (my_result);
617 }
618
619 static void
620 set_nickname_cb (GObject *source,
621     GAsyncResult *result,
622     gpointer user_data)
623 {
624   TpAccount *account = (TpAccount *) source;
625   GSimpleAsyncResult *my_result = user_data;
626   GError *error = NULL;
627
628   if (!tp_account_set_nickname_finish (account, result, &error))
629     g_simple_async_result_take_error (my_result, error);
630
631   apply_complete_one (my_result);
632   g_object_unref (my_result);
633 }
634
635 static void
636 set_contact_info_cb (GObject *source,
637     GAsyncResult *result,
638     gpointer user_data)
639 {
640   TpConnection *connection = (TpConnection *) source;
641   GSimpleAsyncResult *my_result = user_data;
642   GError *error = NULL;
643
644   if (!tp_connection_set_contact_info_finish (connection, result, &error))
645     g_simple_async_result_take_error (my_result, error);
646
647   apply_complete_one (my_result);
648   g_object_unref (my_result);
649 }
650
651 static gboolean
652 field_value_is_empty (TpContactInfoField *field)
653 {
654   guint i;
655
656   if (field->field_value == NULL)
657     return TRUE;
658
659   /* Field is empty if all its values are empty */
660   for (i = 0; field->field_value[i] != NULL; i++)
661     {
662       if (!tp_str_empty (field->field_value[i]))
663         return FALSE;
664     }
665
666   return TRUE;
667 }
668
669 void
670 empathy_user_info_apply_async (EmpathyUserInfo *self,
671     GAsyncReadyCallback callback,
672     gpointer user_data)
673 {
674   GSimpleAsyncResult *result;
675   const gchar *new_nickname;
676   guint count = 0;
677   GList *l, *next;
678
679   g_return_if_fail (EMPATHY_IS_USER_INFO (self));
680
681   result = g_simple_async_result_new ((GObject *) self, callback, user_data,
682       empathy_user_info_apply_async);
683
684   /* Apply avatar */
685   empathy_avatar_chooser_apply_async (
686       (EmpathyAvatarChooser *) self->priv->avatar_chooser,
687       avatar_chooser_apply_cb, g_object_ref (result));
688   count++;
689
690   /* Apply nickname */
691   new_nickname = gtk_entry_get_text (GTK_ENTRY (self->priv->nickname_entry));
692   if (tp_strdiff (new_nickname, tp_account_get_nickname (self->priv->account)))
693     {
694       tp_account_set_nickname_async (self->priv->account, new_nickname,
695           set_nickname_cb, g_object_ref (result));
696       count++;
697     }
698
699   /* Remove empty fields */
700   for (l = self->priv->details_to_set; l != NULL; l = next)
701     {
702       TpContactInfoField *field = l->data;
703
704       next = l->next;
705       if (field_value_is_empty (field))
706         {
707           DEBUG ("Drop empty field: %s", field->field_name);
708           tp_contact_info_field_free (field);
709           self->priv->details_to_set =
710               g_list_delete_link (self->priv->details_to_set, l);
711         }
712     }
713
714   if (self->priv->details_to_set != NULL)
715     {
716       if (self->priv->details_changed)
717         {
718           tp_connection_set_contact_info_async (
719               tp_account_get_connection (self->priv->account),
720               self->priv->details_to_set, set_contact_info_cb,
721               g_object_ref (result));
722           count++;
723         }
724
725       tp_contact_info_list_free (self->priv->details_to_set);
726       self->priv->details_to_set = NULL;
727     }
728
729   self->priv->details_changed = FALSE;
730
731   g_simple_async_result_set_op_res_gssize (result, count);
732
733   g_object_unref (result);
734 }
735
736 gboolean
737 empathy_user_info_apply_finish (EmpathyUserInfo *self,
738     GAsyncResult *result,
739     GError **error)
740 {
741   empathy_implement_finish_void (self, empathy_user_info_apply_async);
742 }