1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
3 * Copyright (C) 2004 Imendio AB
4 * Copyright (C) 2007-2008 Collabora Ltd.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program 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 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
21 * Authors: Mikael Hallendal <micke@imendio.com>
22 * Martyn Russell <martyn@imendio.com>
23 * Xavier Claessens <xclaesse@gmail.com>
24 * Sjoerd Simons <sjoerd.simons@collabora.co.uk>
31 #include <glib/gi18n-lib.h>
33 #include <telepathy-glib/util.h>
34 #include <libmissioncontrol/mc-enum-types.h>
36 #include "empathy-contact.h"
37 #include "empathy-utils.h"
38 #include "empathy-enum-types.h"
39 #include "empathy-marshal.h"
41 #define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
42 #include "empathy-debug.h"
44 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyContact)
48 EmpathyAvatar *avatar;
51 gchar *presence_message;
53 EmpathyCapabilities capabilities;
56 EmpathyContactReady ready;
57 GList *ready_callbacks;
61 EmpathyContactReady ready;
62 EmpathyContactReadyCb *callback;
64 GDestroyNotify destroy;
68 static void contact_finalize (GObject *object);
69 static void contact_get_property (GObject *object, guint param_id,
70 GValue *value, GParamSpec *pspec);
71 static void contact_set_property (GObject *object, guint param_id,
72 const GValue *value, GParamSpec *pspec);
74 G_DEFINE_TYPE (EmpathyContact, empathy_contact, G_TYPE_OBJECT);
84 PROP_PRESENCE_MESSAGE,
96 static guint signals[LAST_SIGNAL];
99 empathy_contact_class_init (EmpathyContactClass *class)
101 GObjectClass *object_class;
103 object_class = G_OBJECT_CLASS (class);
105 object_class->finalize = contact_finalize;
106 object_class->get_property = contact_get_property;
107 object_class->set_property = contact_set_property;
109 g_object_class_install_property (object_class,
111 g_param_spec_string ("id",
113 "String identifying contact",
117 g_object_class_install_property (object_class,
119 g_param_spec_string ("name",
121 "The name of the contact",
125 g_object_class_install_property (object_class,
127 g_param_spec_boxed ("avatar",
133 g_object_class_install_property (object_class,
135 g_param_spec_object ("account",
137 "The account associated with the contact",
141 g_object_class_install_property (object_class,
143 g_param_spec_uint ("presence",
145 "Presence of contact",
151 g_object_class_install_property (object_class,
152 PROP_PRESENCE_MESSAGE,
153 g_param_spec_string ("presence-message",
154 "Contact presence message",
155 "Presence message of contact",
159 g_object_class_install_property (object_class,
161 g_param_spec_uint ("handle",
163 "The handle of the contact",
169 g_object_class_install_property (object_class,
171 g_param_spec_flags ("capabilities",
172 "Contact Capabilities",
173 "Capabilities of the contact",
174 EMPATHY_TYPE_CAPABILITIES,
175 EMPATHY_CAPABILITIES_UNKNOWN,
176 G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
178 g_object_class_install_property (object_class,
180 g_param_spec_boolean ("is-user",
182 "Is contact the user",
186 g_object_class_install_property (object_class,
188 g_param_spec_flags ("ready",
189 "Contact ready flags",
190 "Flags for ready properties",
191 EMPATHY_TYPE_CONTACT_READY,
192 EMPATHY_CONTACT_READY_NONE,
195 signals[PRESENCE_CHANGED] =
196 g_signal_new ("presence-changed",
197 G_TYPE_FROM_CLASS (class),
201 _empathy_marshal_VOID__ENUM_ENUM,
206 g_type_class_add_private (object_class, sizeof (EmpathyContactPriv));
210 empathy_contact_init (EmpathyContact *contact)
212 EmpathyContactPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (contact,
213 EMPATHY_TYPE_CONTACT, EmpathyContactPriv);
215 contact->priv = priv;
219 contact_finalize (GObject *object)
221 EmpathyContactPriv *priv;
224 priv = GET_PRIV (object);
226 DEBUG ("finalize: %p", object);
230 g_free (priv->presence_message);
232 for (l = priv->ready_callbacks; l != NULL; l = g_list_next (l))
234 ReadyCbData *d = (ReadyCbData *)l->data;
236 if (d->destroy != NULL)
237 d->destroy (d->user_data);
238 g_slice_free (ReadyCbData, d);
241 g_list_free (priv->ready_callbacks);
242 priv->ready_callbacks = NULL;
245 empathy_avatar_unref (priv->avatar);
248 g_object_unref (priv->account);
250 G_OBJECT_CLASS (empathy_contact_parent_class)->finalize (object);
254 contact_get_property (GObject *object,
259 EmpathyContactPriv *priv;
261 priv = GET_PRIV (object);
266 g_value_set_string (value, priv->id);
269 g_value_set_string (value,
270 empathy_contact_get_name (EMPATHY_CONTACT (object)));
273 g_value_set_boxed (value, priv->avatar);
276 g_value_set_object (value, priv->account);
279 g_value_set_uint (value, priv->presence);
281 case PROP_PRESENCE_MESSAGE:
282 g_value_set_string (value, priv->presence_message);
285 g_value_set_uint (value, priv->handle);
287 case PROP_CAPABILITIES:
288 g_value_set_flags (value, priv->capabilities);
291 g_value_set_boolean (value, priv->is_user);
294 g_value_set_flags (value, priv->ready);
297 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
303 contact_set_property (GObject *object,
308 EmpathyContactPriv *priv;
310 priv = GET_PRIV (object);
315 empathy_contact_set_id (EMPATHY_CONTACT (object),
316 g_value_get_string (value));
319 empathy_contact_set_name (EMPATHY_CONTACT (object),
320 g_value_get_string (value));
323 empathy_contact_set_avatar (EMPATHY_CONTACT (object),
324 g_value_get_boxed (value));
327 empathy_contact_set_account (EMPATHY_CONTACT (object),
328 MC_ACCOUNT (g_value_get_object (value)));
331 empathy_contact_set_presence (EMPATHY_CONTACT (object),
332 g_value_get_uint (value));
334 case PROP_PRESENCE_MESSAGE:
335 empathy_contact_set_presence_message (EMPATHY_CONTACT (object),
336 g_value_get_string (value));
339 empathy_contact_set_handle (EMPATHY_CONTACT (object),
340 g_value_get_uint (value));
342 case PROP_CAPABILITIES:
343 empathy_contact_set_capabilities (EMPATHY_CONTACT (object),
344 g_value_get_flags (value));
347 empathy_contact_set_is_user (EMPATHY_CONTACT (object),
348 g_value_get_boolean (value));
351 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
357 contact_is_ready (EmpathyContact *contact, EmpathyContactReady ready)
359 EmpathyContactPriv *priv = GET_PRIV (contact);
361 /* When the name is NULL, empathy_contact_get_name() fallback to the id.
362 * When the caller want to wait the name to be ready, it also want to wait
363 * the id to be ready in case of fallback. */
364 if ((ready & EMPATHY_CONTACT_READY_NAME) && G_STR_EMPTY (priv->name))
365 ready |= EMPATHY_CONTACT_READY_ID;
367 return (priv->ready & ready) == ready;
371 contact_weak_object_notify (gpointer data, GObject *old_object)
373 EmpathyContact *contact = EMPATHY_CONTACT (data);
374 EmpathyContactPriv *priv = GET_PRIV (contact);
378 for (l = priv->ready_callbacks ; l != NULL ; l = ln )
380 ReadyCbData *d = (ReadyCbData *)l->data;
381 ln = g_list_next (l);
383 if (d->weak_object == old_object)
385 if (d->destroy != NULL)
386 d->destroy (d->user_data);
388 priv->ready_callbacks = g_list_delete_link (priv->ready_callbacks,
391 g_slice_free (ReadyCbData, d);
397 contact_call_ready_callback (EmpathyContact *contact, const GError *error,
400 data->callback (contact, error, data->user_data, data->weak_object);
401 if (data->destroy != NULL)
402 data->destroy (data->user_data);
404 if (data->weak_object)
405 g_object_weak_unref (data->weak_object,
406 contact_weak_object_notify, contact);
411 contact_set_ready_flag (EmpathyContact *contact,
412 EmpathyContactReady flag)
414 EmpathyContactPriv *priv = GET_PRIV (contact);
416 if (!(priv->ready & flag))
421 g_object_notify (G_OBJECT (contact), "ready");
423 for (l = priv->ready_callbacks ; l != NULL ; l = ln )
425 ReadyCbData *d = (ReadyCbData *)l->data;
426 ln = g_list_next (l);
428 if (contact_is_ready (contact, d->ready))
430 contact_call_ready_callback (contact, NULL, d);
431 priv->ready_callbacks = g_list_delete_link
432 (priv->ready_callbacks, l);
433 g_slice_free (ReadyCbData, d);
440 empathy_contact_new (McAccount *account)
442 return g_object_new (EMPATHY_TYPE_CONTACT,
448 empathy_contact_new_full (McAccount *account,
452 return g_object_new (EMPATHY_TYPE_CONTACT,
460 empathy_contact_get_id (EmpathyContact *contact)
462 EmpathyContactPriv *priv;
464 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
466 priv = GET_PRIV (contact);
472 empathy_contact_set_id (EmpathyContact *contact,
475 EmpathyContactPriv *priv;
477 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
478 g_return_if_fail (id != NULL);
480 priv = GET_PRIV (contact);
482 /* We temporally ref the contact because it could be destroyed
483 * during the signal emition */
484 g_object_ref (contact);
485 if (tp_strdiff (id, priv->id))
488 priv->id = g_strdup (id);
490 g_object_notify (G_OBJECT (contact), "id");
491 if (G_STR_EMPTY (priv->name))
492 g_object_notify (G_OBJECT (contact), "name");
494 contact_set_ready_flag (contact, EMPATHY_CONTACT_READY_ID);
496 g_object_unref (contact);
500 empathy_contact_get_name (EmpathyContact *contact)
502 EmpathyContactPriv *priv;
504 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
506 priv = GET_PRIV (contact);
508 if (G_STR_EMPTY (priv->name))
509 return empathy_contact_get_id (contact);
515 empathy_contact_set_name (EmpathyContact *contact,
518 EmpathyContactPriv *priv;
520 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
522 priv = GET_PRIV (contact);
524 g_object_ref (contact);
525 if (tp_strdiff (name, priv->name))
528 priv->name = g_strdup (name);
529 g_object_notify (G_OBJECT (contact), "name");
531 contact_set_ready_flag (contact, EMPATHY_CONTACT_READY_NAME);
532 g_object_unref (contact);
536 empathy_contact_get_avatar (EmpathyContact *contact)
538 EmpathyContactPriv *priv;
540 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
542 priv = GET_PRIV (contact);
548 empathy_contact_set_avatar (EmpathyContact *contact,
549 EmpathyAvatar *avatar)
551 EmpathyContactPriv *priv;
553 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
555 priv = GET_PRIV (contact);
557 if (priv->avatar == avatar)
562 empathy_avatar_unref (priv->avatar);
567 priv->avatar = empathy_avatar_ref (avatar);
569 g_object_notify (G_OBJECT (contact), "avatar");
573 empathy_contact_get_account (EmpathyContact *contact)
575 EmpathyContactPriv *priv;
577 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
579 priv = GET_PRIV (contact);
581 return priv->account;
585 empathy_contact_set_account (EmpathyContact *contact,
588 EmpathyContactPriv *priv;
590 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
591 g_return_if_fail (MC_IS_ACCOUNT (account));
593 priv = GET_PRIV (contact);
595 if (account == priv->account)
599 g_object_unref (priv->account);
600 priv->account = g_object_ref (account);
602 g_object_notify (G_OBJECT (contact), "account");
606 empathy_contact_get_presence (EmpathyContact *contact)
608 EmpathyContactPriv *priv;
610 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), MC_PRESENCE_UNSET);
612 priv = GET_PRIV (contact);
614 return priv->presence;
618 empathy_contact_set_presence (EmpathyContact *contact,
621 EmpathyContactPriv *priv;
622 McPresence old_presence;
624 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
626 priv = GET_PRIV (contact);
628 if (presence == priv->presence)
631 old_presence = priv->presence;
632 priv->presence = presence;
634 g_signal_emit (contact, signals[PRESENCE_CHANGED], 0, presence, old_presence);
636 g_object_notify (G_OBJECT (contact), "presence");
640 empathy_contact_get_presence_message (EmpathyContact *contact)
642 EmpathyContactPriv *priv;
644 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
646 priv = GET_PRIV (contact);
648 return priv->presence_message;
652 empathy_contact_set_presence_message (EmpathyContact *contact,
653 const gchar *message)
655 EmpathyContactPriv *priv = GET_PRIV (contact);
657 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
659 if (!tp_strdiff (message, priv->presence_message))
662 g_free (priv->presence_message);
663 priv->presence_message = g_strdup (message);
665 g_object_notify (G_OBJECT (contact), "presence-message");
669 empathy_contact_get_handle (EmpathyContact *contact)
671 EmpathyContactPriv *priv;
673 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), 0);
675 priv = GET_PRIV (contact);
681 empathy_contact_set_handle (EmpathyContact *contact,
684 EmpathyContactPriv *priv;
686 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
688 priv = GET_PRIV (contact);
690 g_object_ref (contact);
691 if (handle != priv->handle)
693 priv->handle = handle;
694 g_object_notify (G_OBJECT (contact), "handle");
696 contact_set_ready_flag (contact, EMPATHY_CONTACT_READY_HANDLE);
697 g_object_unref (contact);
701 empathy_contact_get_capabilities (EmpathyContact *contact)
703 EmpathyContactPriv *priv;
705 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), 0);
707 priv = GET_PRIV (contact);
709 return priv->capabilities;
713 empathy_contact_set_capabilities (EmpathyContact *contact,
714 EmpathyCapabilities capabilities)
716 EmpathyContactPriv *priv;
718 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
720 priv = GET_PRIV (contact);
722 if (priv->capabilities == capabilities)
725 priv->capabilities = capabilities;
727 g_object_notify (G_OBJECT (contact), "capabilities");
731 empathy_contact_is_user (EmpathyContact *contact)
733 EmpathyContactPriv *priv;
735 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
737 priv = GET_PRIV (contact);
739 return priv->is_user;
743 empathy_contact_set_is_user (EmpathyContact *contact,
746 EmpathyContactPriv *priv;
748 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
750 priv = GET_PRIV (contact);
752 if (priv->is_user == is_user)
755 priv->is_user = is_user;
757 g_object_notify (G_OBJECT (contact), "is-user");
761 empathy_contact_is_online (EmpathyContact *contact)
763 EmpathyContactPriv *priv;
765 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
767 priv = GET_PRIV (contact);
769 return (priv->presence > MC_PRESENCE_OFFLINE);
773 empathy_contact_get_status (EmpathyContact *contact)
775 EmpathyContactPriv *priv;
777 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), "");
779 priv = GET_PRIV (contact);
781 if (priv->presence_message)
782 return priv->presence_message;
784 return empathy_presence_get_default_message (priv->presence);
788 empathy_contact_can_voip (EmpathyContact *contact)
790 EmpathyContactPriv *priv;
792 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
794 priv = GET_PRIV (contact);
796 return priv->capabilities & (EMPATHY_CAPABILITIES_AUDIO |
797 EMPATHY_CAPABILITIES_VIDEO);
801 empathy_contact_can_send_files (EmpathyContact *contact)
803 EmpathyContactPriv *priv;
805 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
807 priv = GET_PRIV (contact);
809 return priv->capabilities & EMPATHY_CAPABILITIES_FT;
813 empathy_contact_get_ready (EmpathyContact *contact)
815 EmpathyContactPriv *priv;
817 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
819 priv = GET_PRIV (contact);
825 empathy_contact_equal (gconstpointer v1,
828 McAccount *account_a;
829 McAccount *account_b;
833 g_return_val_if_fail (EMPATHY_IS_CONTACT (v1), FALSE);
834 g_return_val_if_fail (EMPATHY_IS_CONTACT (v2), FALSE);
836 account_a = empathy_contact_get_account (EMPATHY_CONTACT (v1));
837 account_b = empathy_contact_get_account (EMPATHY_CONTACT (v2));
839 id_a = empathy_contact_get_id (EMPATHY_CONTACT (v1));
840 id_b = empathy_contact_get_id (EMPATHY_CONTACT (v2));
842 return empathy_account_equal (account_a, account_b) &&
843 !tp_strdiff (id_a, id_b);
847 empathy_contact_hash (gconstpointer key)
849 EmpathyContactPriv *priv;
851 g_return_val_if_fail (EMPATHY_IS_CONTACT (key), +1);
853 priv = GET_PRIV (EMPATHY_CONTACT (key));
857 priv->hash = empathy_account_hash (priv->account) ^
858 g_str_hash (priv->id);
864 void empathy_contact_call_when_ready (EmpathyContact *contact,
865 EmpathyContactReady ready, EmpathyContactReadyCb *callback,
866 gpointer user_data, GDestroyNotify destroy, GObject *weak_object)
868 EmpathyContactPriv *priv = GET_PRIV (contact);
870 g_return_if_fail (contact != NULL);
871 g_return_if_fail (callback != NULL);
873 if (contact_is_ready (contact, ready))
875 callback (contact, NULL, user_data, weak_object);
881 ReadyCbData *d = g_slice_new0 (ReadyCbData);
883 d->callback = callback;
884 d->user_data = user_data;
885 d->destroy = destroy;
886 d->weak_object = weak_object;
888 if (weak_object != NULL)
889 g_object_weak_ref (weak_object, contact_weak_object_notify, contact);
891 priv->ready_callbacks = g_list_prepend (priv->ready_callbacks, d);
896 contact_is_ready_func (GObject *contact,
899 return contact_is_ready (EMPATHY_CONTACT (contact),
900 GPOINTER_TO_UINT (user_data));
904 empathy_contact_run_until_ready (EmpathyContact *contact,
905 EmpathyContactReady ready,
908 empathy_run_until_ready_full (contact, "notify::ready",
909 contact_is_ready_func, GUINT_TO_POINTER (ready),
914 contact_get_avatar_filename (EmpathyContact *contact,
917 EmpathyContactPriv *priv = GET_PRIV (contact);
920 gchar *token_escaped;
921 gchar *contact_escaped;
923 if (G_STR_EMPTY (priv->id))
926 contact_escaped = tp_escape_as_identifier (priv->id);
927 token_escaped = tp_escape_as_identifier (token);
929 avatar_path = g_build_filename (g_get_user_cache_dir (),
932 mc_account_get_unique_name (priv->account),
935 g_mkdir_with_parents (avatar_path, 0700);
937 avatar_file = g_build_filename (avatar_path, token_escaped, NULL);
939 g_free (contact_escaped);
940 g_free (token_escaped);
941 g_free (avatar_path);
947 empathy_contact_load_avatar_data (EmpathyContact *contact,
953 EmpathyAvatar *avatar;
955 GError *error = NULL;
957 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
958 g_return_if_fail (data != NULL);
959 g_return_if_fail (len > 0);
960 g_return_if_fail (format != NULL);
961 g_return_if_fail (!G_STR_EMPTY (token));
963 /* Load and set the avatar */
964 avatar = empathy_avatar_new (g_memdup (data, len), len, g_strdup (format),
966 empathy_contact_set_avatar (contact, avatar);
967 empathy_avatar_unref (avatar);
969 /* Save to cache if not yet in it */
970 filename = contact_get_avatar_filename (contact, token);
971 if (filename && !g_file_test (filename, G_FILE_TEST_EXISTS))
973 if (!empathy_avatar_save_to_file (avatar, filename, &error))
975 DEBUG ("Failed to save avatar in cache: %s",
976 error ? error->message : "No error given");
977 g_clear_error (&error);
980 DEBUG ("Avatar saved to %s", filename);
986 empathy_contact_load_avatar_cache (EmpathyContact *contact,
989 EmpathyAvatar *avatar = NULL;
993 GError *error = NULL;
995 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
996 g_return_val_if_fail (!G_STR_EMPTY (token), FALSE);
998 /* Load the avatar from file if it exists */
999 filename = contact_get_avatar_filename (contact, token);
1000 if (filename && g_file_test (filename, G_FILE_TEST_EXISTS))
1002 if (!g_file_get_contents (filename, &data, &len, &error))
1004 DEBUG ("Failed to load avatar from cache: %s",
1005 error ? error->message : "No error given");
1006 g_clear_error (&error);
1012 DEBUG ("Avatar loaded from %s", filename);
1013 avatar = empathy_avatar_new (data, len, NULL, g_strdup (token));
1014 empathy_contact_set_avatar (contact, avatar);
1015 empathy_avatar_unref (avatar);
1020 return data != NULL;
1024 empathy_avatar_get_type (void)
1026 static GType type_id = 0;
1030 type_id = g_boxed_type_register_static ("EmpathyAvatar",
1031 (GBoxedCopyFunc) empathy_avatar_ref,
1032 (GBoxedFreeFunc) empathy_avatar_unref);
1039 empathy_avatar_new (guchar *data,
1044 EmpathyAvatar *avatar;
1046 avatar = g_slice_new0 (EmpathyAvatar);
1047 avatar->data = data;
1049 avatar->format = format;
1050 avatar->token = token;
1051 avatar->refcount = 1;
1057 empathy_avatar_unref (EmpathyAvatar *avatar)
1059 g_return_if_fail (avatar != NULL);
1062 if (avatar->refcount == 0)
1064 g_free (avatar->data);
1065 g_free (avatar->format);
1066 g_free (avatar->token);
1067 g_slice_free (EmpathyAvatar, avatar);
1072 empathy_avatar_ref (EmpathyAvatar *avatar)
1074 g_return_val_if_fail (avatar != NULL, NULL);
1082 * empathy_avatar_save_to_file:
1083 * @avatar: the avatar
1084 * @filename: name of a file to write avatar to
1085 * @error: return location for a GError, or NULL
1087 * Save the avatar to a file named filename
1089 * Returns: %TRUE on success, %FALSE if an error occurred
1092 empathy_avatar_save_to_file (EmpathyAvatar *self,
1093 const gchar *filename,
1096 return g_file_set_contents (filename, self->data, self->len, error);