diff options
author | Xavier Claessens <xclaesse@gmail.com> | 2007-11-04 07:47:03 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2007-11-04 07:47:03 +0800 |
commit | 2268caa6f387e4780708d8513d668bcebb4ea2dd (patch) | |
tree | b7cbc93b9bab936dd2c8acadc1ca2bb90fea6191 /libempathy | |
parent | 48334a065723ce15f191adf391de444f72ae2efb (diff) | |
download | gsoc2013-empathy-2268caa6f387e4780708d8513d668bcebb4ea2dd.tar gsoc2013-empathy-2268caa6f387e4780708d8513d668bcebb4ea2dd.tar.gz gsoc2013-empathy-2268caa6f387e4780708d8513d668bcebb4ea2dd.tar.bz2 gsoc2013-empathy-2268caa6f387e4780708d8513d668bcebb4ea2dd.tar.lz gsoc2013-empathy-2268caa6f387e4780708d8513d668bcebb4ea2dd.tar.xz gsoc2013-empathy-2268caa6f387e4780708d8513d668bcebb4ea2dd.tar.zst gsoc2013-empathy-2268caa6f387e4780708d8513d668bcebb4ea2dd.zip |
Call ClearAvatar if the data is NULL or size <= 0 in
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().
svn path=/trunk/; revision=418
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-contact-factory.c | 38 |
1 files changed, 30 insertions, 8 deletions
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 |