diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | libempathy/empathy-contact-factory.c | 38 |
2 files changed, 35 insertions, 8 deletions
@@ -1,5 +1,10 @@ 2007-11-03 Xavier Claessens <xclaesse@gmail.com> + * libempathy/empathy-contact-factory.c: Call ClearAvatar if the data + is NULL or size <= 0 in empathy_contact_factory_set_avatar(). + +2007-11-03 Xavier Claessens <xclaesse@gmail.com> + * libempathy-gtk/empathy-contact-widget.c: * libempathy-gtk/empathy-avatar-chooser.c: * libempathy-gtk/empathy-avatar-chooser.h: diff --git a/libempathy/empathy-contact-factory.c b/libempathy/empathy-contact-factory.c index 2aaa8fad3..7d6e6f663 100644 --- a/libempathy/empathy-contact-factory.c +++ b/libempathy/empathy-contact-factory.c @@ -399,6 +399,21 @@ contact_factory_set_avatar_cb (DBusGProxy *proxy, } static void +contact_factory_clear_avatar_cb (DBusGProxy *proxy, + GError *error, + gpointer user_data) +{ + ContactFactoryAccountData *account_data = user_data; + + if (error) { + empathy_debug (DEBUG_DOMAIN, "Error clearing avatar: %s", + error->message); + } + + contact_factory_account_data_unref (account_data); +} + +static void contact_factory_avatar_retrieved_cb (DBusGProxy *proxy, guint handle, gchar *token, @@ -1256,7 +1271,6 @@ empathy_contact_factory_set_avatar (EmpathyContactFactory *factory, const gchar *mime_type) { ContactFactoryAccountData *account_data; - GArray avatar; g_return_if_fail (EMPATHY_IS_CONTACT_FACTORY (factory)); g_return_if_fail (MC_IS_ACCOUNT (account)); @@ -1270,13 +1284,21 @@ empathy_contact_factory_set_avatar (EmpathyContactFactory *factory, empathy_debug (DEBUG_DOMAIN, "Setting avatar on account %s", mc_account_get_unique_name (account)); - avatar.data = (gchar*) data; - avatar.len = size; - tp_conn_iface_avatars_set_avatar_async (account_data->avatars_iface, - &avatar, - mime_type, - contact_factory_set_avatar_cb, - contact_factory_account_data_ref (account_data)); + if (data && size > 0 && size < G_MAXUINT) { + GArray avatar; + + avatar.data = (gchar*) data; + avatar.len = size; + tp_conn_iface_avatars_set_avatar_async (account_data->avatars_iface, + &avatar, + mime_type, + contact_factory_set_avatar_cb, + contact_factory_account_data_ref (account_data)); + } else { + tp_conn_iface_avatars_clear_avatar_async (account_data->avatars_iface, + contact_factory_clear_avatar_cb, + contact_factory_account_data_ref (account_data)); + } } static void |