aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-contact.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2008-07-17 02:05:08 +0800
committerXavier Claessens <xclaesse@gmail.com>2009-06-12 00:06:28 +0800
commitc9b74c0e4891a12133aab46312b6038c3a2d0047 (patch)
tree8c258e236a86d34eff9746beec398f9ae29ce3b4 /libempathy/empathy-contact.c
parent250c6aaadcfd00470f670bc6bf4b1098c1640179 (diff)
downloadgsoc2013-empathy-c9b74c0e4891a12133aab46312b6038c3a2d0047.tar
gsoc2013-empathy-c9b74c0e4891a12133aab46312b6038c3a2d0047.tar.gz
gsoc2013-empathy-c9b74c0e4891a12133aab46312b6038c3a2d0047.tar.bz2
gsoc2013-empathy-c9b74c0e4891a12133aab46312b6038c3a2d0047.tar.lz
gsoc2013-empathy-c9b74c0e4891a12133aab46312b6038c3a2d0047.tar.xz
gsoc2013-empathy-c9b74c0e4891a12133aab46312b6038c3a2d0047.tar.zst
gsoc2013-empathy-c9b74c0e4891a12133aab46312b6038c3a2d0047.zip
Add the filename in EmpathyAvatar and fallback to stock_person
Diffstat (limited to 'libempathy/empathy-contact.c')
-rw-r--r--libempathy/empathy-contact.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index 6800c8e30..a99e66b13 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -863,7 +863,7 @@ contact_get_avatar_filename (EmpathyContact *contact,
void
empathy_contact_load_avatar_data (EmpathyContact *contact,
- const guchar *data,
+ const guchar *data,
const gsize len,
const gchar *format,
const gchar *token)
@@ -879,13 +879,13 @@ empathy_contact_load_avatar_data (EmpathyContact *contact,
g_return_if_fail (!EMP_STR_EMPTY (token));
/* Load and set the avatar */
+ filename = contact_get_avatar_filename (contact, token);
avatar = empathy_avatar_new (g_memdup (data, len), len, g_strdup (format),
- g_strdup (token));
+ g_strdup (token), filename);
empathy_contact_set_avatar (contact, avatar);
empathy_avatar_unref (avatar);
/* Save to cache if not yet in it */
- filename = contact_get_avatar_filename (contact, token);
if (filename && !g_file_test (filename, G_FILE_TEST_EXISTS))
{
if (!empathy_avatar_save_to_file (avatar, filename, &error))
@@ -897,7 +897,6 @@ empathy_contact_load_avatar_data (EmpathyContact *contact,
else
DEBUG ("Avatar saved to %s", filename);
}
- g_free (filename);
}
gboolean
@@ -928,28 +927,14 @@ empathy_contact_load_avatar_cache (EmpathyContact *contact,
if (data)
{
DEBUG ("Avatar loaded from %s", filename);
- avatar = empathy_avatar_new (data, len, NULL, g_strdup (token));
+ avatar = empathy_avatar_new (data, len, NULL, g_strdup (token), filename);
empathy_contact_set_avatar (contact, avatar);
empathy_avatar_unref (avatar);
}
- g_free (filename);
-
return data != NULL;
}
-gchar *
-empathy_contact_get_avatar_filename (EmpathyContact *contact)
-{
- EmpathyContactPriv *priv = GET_PRIV (contact);
-
- if (priv->avatar)
- return contact_get_avatar_filename (contact, priv->avatar->token);
-
- return NULL;
-}
-
-
GType
empathy_avatar_get_type (void)
{
@@ -969,7 +954,8 @@ EmpathyAvatar *
empathy_avatar_new (guchar *data,
gsize len,
gchar *format,
- gchar *token)
+ gchar *token,
+ gchar *filename)
{
EmpathyAvatar *avatar;
@@ -978,6 +964,7 @@ empathy_avatar_new (guchar *data,
avatar->len = len;
avatar->format = format;
avatar->token = token;
+ avatar->filename = filename;
avatar->refcount = 1;
return avatar;