aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-05-28 01:34:44 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-05-28 01:34:44 +0800
commit891dd64e17fe816e6bab0b1e1d3ea35eb61a2e35 (patch)
treeff5389343502b4121a6eebb5496edb6d83d52245
parent1403c791daa33f39c3dc86917c2f133ced2ae8f4 (diff)
downloadgsoc2013-empathy-891dd64e17fe816e6bab0b1e1d3ea35eb61a2e35.tar
gsoc2013-empathy-891dd64e17fe816e6bab0b1e1d3ea35eb61a2e35.tar.gz
gsoc2013-empathy-891dd64e17fe816e6bab0b1e1d3ea35eb61a2e35.tar.bz2
gsoc2013-empathy-891dd64e17fe816e6bab0b1e1d3ea35eb61a2e35.tar.lz
gsoc2013-empathy-891dd64e17fe816e6bab0b1e1d3ea35eb61a2e35.tar.xz
gsoc2013-empathy-891dd64e17fe816e6bab0b1e1d3ea35eb61a2e35.tar.zst
gsoc2013-empathy-891dd64e17fe816e6bab0b1e1d3ea35eb61a2e35.zip
Move avatar cache to ~/.cache and don't mix avatar from different contacts, tokens are not garanteed to be different.
svn path=/trunk/; revision=1128
-rw-r--r--docs/libempathy/libempathy-docs.sgml1
-rw-r--r--docs/libempathy/libempathy.types18
-rw-r--r--libempathy-gtk/empathy-avatar-chooser.h2
-rw-r--r--libempathy-gtk/empathy-avatar-image.h2
-rw-r--r--libempathy-gtk/empathy-ui-utils.h1
-rw-r--r--libempathy/Makefile.am2
-rw-r--r--libempathy/empathy-avatar.c179
-rw-r--r--libempathy/empathy-avatar.h53
-rw-r--r--libempathy/empathy-contact.c163
-rw-r--r--libempathy/empathy-contact.h26
-rw-r--r--libempathy/empathy-log-manager.c10
-rw-r--r--libempathy/empathy-tp-contact-factory.c23
-rw-r--r--megaphone/src/megaphone-applet.c6
-rw-r--r--python/pyempathy/pyempathy.defs91
-rw-r--r--python/pyempathy/pyempathy.override1
-rwxr-xr-xpython/update-binding.sh1
16 files changed, 266 insertions, 313 deletions
diff --git a/docs/libempathy/libempathy-docs.sgml b/docs/libempathy/libempathy-docs.sgml
index 6e040b0cb..e3ca78b53 100644
--- a/docs/libempathy/libempathy-docs.sgml
+++ b/docs/libempathy/libempathy-docs.sgml
@@ -16,7 +16,6 @@
<title>API Reference</title>
<chapter id="libempathy_api">
<title>libempathy API reference</title>
- <xi:include href="xml/empathy-avatar.xml"/>
<xi:include href="xml/empathy-chatroom-manager.xml"/>
<xi:include href="xml/empathy-chatroom.xml"/>
<xi:include href="xml/empathy-contact-factory.xml"/>
diff --git a/docs/libempathy/libempathy.types b/docs/libempathy/libempathy.types
index dead1e5c4..87963c222 100644
--- a/docs/libempathy/libempathy.types
+++ b/docs/libempathy/libempathy.types
@@ -1,11 +1,23 @@
+empathy_chatroom_get_type
+empathy_chatroom_manager_get_type
+empathy_contact_factory_get_type
+empathy_contact_get_type
+empathy_avatar_get_type
empathy_contact_list_get_type
empathy_contact_manager_get_type
+empathy_dispatcher_get_type
+empathy_dispatcher_tube_get_type
+empathy_debug_flags_get_type
empathy_reg_ex_type_get_type
empathy_capabilities_get_type
+empathy_contact_ready_get_type
+empathy_tp_call_status_get_type
empathy_idle_get_type
+empathy_irc_network_get_type
+empathy_irc_network_manager_get_type
+empathy_irc_server_get_type
empathy_log_manager_get_type
empathy_message_get_type
-empathy_tp_call_status_get_type
empathy_tp_call_get_type
empathy_tp_chat_get_type
empathy_tp_contact_factory_get_type
@@ -14,8 +26,4 @@ empathy_tp_group_get_type
empathy_tp_roomlist_get_type
empathy_tp_tube_get_type
empathy_tube_handler_get_type
-empathy_irc_server_get_type
-empathy_irc_network_get_type
-empathy_irc_network_manager_get_type
-empathy_dispatcher_get_type
diff --git a/libempathy-gtk/empathy-avatar-chooser.h b/libempathy-gtk/empathy-avatar-chooser.h
index 7db880df7..bdc5b40ae 100644
--- a/libempathy-gtk/empathy-avatar-chooser.h
+++ b/libempathy-gtk/empathy-avatar-chooser.h
@@ -26,7 +26,7 @@
#include <gtk/gtkbutton.h>
-#include <libempathy/empathy-avatar.h>
+#include <libempathy/empathy-contact.h>
G_BEGIN_DECLS
diff --git a/libempathy-gtk/empathy-avatar-image.h b/libempathy-gtk/empathy-avatar-image.h
index bd83e4bb8..d6a6cd0b0 100644
--- a/libempathy-gtk/empathy-avatar-image.h
+++ b/libempathy-gtk/empathy-avatar-image.h
@@ -26,7 +26,7 @@
#include <gtk/gtkeventbox.h>
-#include <libempathy/empathy-avatar.h>
+#include <libempathy/empathy-contact.h>
G_BEGIN_DECLS
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index b7478140e..24ab01fb4 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -38,7 +38,6 @@
#include <libmissioncontrol/mc-profile.h>
#include <libempathy/empathy-contact.h>
-#include <libempathy/empathy-avatar.h>
#include "empathy-chat-view.h"
diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am
index 0db883d3d..3fb491855 100644
--- a/libempathy/Makefile.am
+++ b/libempathy/Makefile.am
@@ -16,7 +16,6 @@ BUILT_SOURCES = \
lib_LTLIBRARIES = libempathy.la
libempathy_la_SOURCES = \
- empathy-avatar.c \
empathy-time.c \
empathy-status-presets.c \
empathy-debug.c \
@@ -57,7 +56,6 @@ libempathy_la_LDFLAGS = \
-export-symbols-regex ^empathy_
libempathy_headers = \
- empathy-avatar.h \
empathy-time.h \
empathy-status-presets.h \
empathy-debug.h \
diff --git a/libempathy/empathy-avatar.c b/libempathy/empathy-avatar.c
deleted file mode 100644
index 41395d6e9..000000000
--- a/libempathy/empathy-avatar.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2006 Xavier Claessens <xclaesse@gmail.com>
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-
-#include "config.h"
-
-#include <telepathy-glib/util.h>
-
-#include "empathy-avatar.h"
-#include "empathy-utils.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include "empathy-debug.h"
-
-GType
-empathy_avatar_get_type (void)
-{
- static GType type_id = 0;
-
- if (!type_id) {
- type_id = g_boxed_type_register_static ("EmpathyAvatar",
- (GBoxedCopyFunc) empathy_avatar_ref,
- (GBoxedFreeFunc) empathy_avatar_unref);
- }
-
- return type_id;
-}
-
-static gchar *
-avatar_get_filename (const gchar *token)
-{
- gchar *avatar_path;
- gchar *avatar_file;
- gchar *token_escaped;
-
- avatar_path = g_build_filename (g_get_home_dir (),
- ".gnome2",
- PACKAGE_NAME,
- "avatars",
- NULL);
- g_mkdir_with_parents (avatar_path, 0700);
-
- token_escaped = tp_escape_as_identifier (token);
- avatar_file = g_build_filename (avatar_path, token_escaped, NULL);
-
- g_free (token_escaped);
- g_free (avatar_path);
-
- return avatar_file;
-}
-
-static EmpathyAvatar *
-avatar_new (guchar *data,
- gsize len,
- gchar *format,
- gchar *token)
-{
- EmpathyAvatar *avatar;
-
- avatar = g_slice_new0 (EmpathyAvatar);
- avatar->data = data;
- avatar->len = len;
- avatar->format = format;
- avatar->token = token;
- avatar->refcount = 1;
-
- return avatar;
-}
-
-EmpathyAvatar *
-empathy_avatar_new (const guchar *data,
- const gsize len,
- const gchar *format,
- const gchar *token)
-{
- EmpathyAvatar *avatar;
- gchar *filename;
- GError *error = NULL;
-
- g_return_val_if_fail (data != NULL, NULL);
- g_return_val_if_fail (len > 0, NULL);
- g_return_val_if_fail (format != NULL, NULL);
- g_return_val_if_fail (!G_STR_EMPTY (token), NULL);
-
- avatar = avatar_new (g_memdup (data, len),
- len,
- g_strdup (format),
- g_strdup (token));
-
- /* Save to cache if not yet in it */
- filename = avatar_get_filename (token);
- if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
- if (!g_file_set_contents (filename, data, len, &error)) {
- DEBUG ("Failed to save avatar in cache: %s",
- error ? error->message : "No error given");
- g_clear_error (&error);
- } else {
- DEBUG ("Avatar saved to %s", filename);
- }
- }
- g_free (filename);
-
- return avatar;
-}
-
-EmpathyAvatar *
-empathy_avatar_new_from_cache (const gchar *token)
-{
- EmpathyAvatar *avatar = NULL;
- gchar *filename;
- gchar *data = NULL;
- gsize len;
- GError *error = NULL;
-
- g_return_val_if_fail (!G_STR_EMPTY (token), NULL);
-
- /* Load the avatar from file if it exists */
- filename = avatar_get_filename (token);
- if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
- if (!g_file_get_contents (filename, &data, &len, &error)) {
- DEBUG ("Failed to load avatar from cache: %s",
- error ? error->message : "No error given");
- g_clear_error (&error);
- }
- }
-
- if (data) {
- DEBUG ("Avatar loaded from %s", filename);
- avatar = avatar_new (data, len, NULL, g_strdup (token));
- }
-
- g_free (filename);
-
- return avatar;
-}
-
-void
-empathy_avatar_unref (EmpathyAvatar *avatar)
-{
- g_return_if_fail (avatar != NULL);
-
- avatar->refcount--;
- if (avatar->refcount == 0) {
- g_free (avatar->data);
- g_free (avatar->format);
- g_free (avatar->token);
- g_slice_free (EmpathyAvatar, avatar);
- }
-}
-
-EmpathyAvatar *
-empathy_avatar_ref (EmpathyAvatar *avatar)
-{
- g_return_val_if_fail (avatar != NULL, NULL);
-
- avatar->refcount++;
-
- return avatar;
-}
-
diff --git a/libempathy/empathy-avatar.h b/libempathy/empathy-avatar.h
deleted file mode 100644
index 63be370a2..000000000
--- a/libempathy/empathy-avatar.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2006 Xavier Claessens <xclaesse@gmail.com>
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_AVATAR_H__
-#define __EMPATHY_AVATAR_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_AVATAR (empathy_avatar_get_type ())
-
-typedef struct _EmpathyAvatar EmpathyAvatar;
-
-struct _EmpathyAvatar {
- guchar *data;
- gsize len;
- gchar *format;
- gchar *token;
- guint refcount;
-};
-
-GType empathy_avatar_get_type (void) G_GNUC_CONST;
-EmpathyAvatar * empathy_avatar_new (const guchar *avatar,
- const gsize len,
- const gchar *format,
- const gchar *token);
-EmpathyAvatar * empathy_avatar_new_from_cache (const gchar *token);
-EmpathyAvatar * empathy_avatar_ref (EmpathyAvatar *avatar);
-void empathy_avatar_unref (EmpathyAvatar *avatar);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_AVATAR_H__ */
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index 19283cc72..39d6148a2 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -759,3 +759,166 @@ empathy_contact_run_until_ready (EmpathyContact *contact,
loop);
}
+static gchar *
+contact_get_avatar_filename (EmpathyContact *contact,
+ const gchar *token)
+{
+ EmpathyContactPriv *priv = GET_PRIV (contact);
+ gchar *avatar_path;
+ gchar *avatar_file;
+ gchar *token_escaped;
+ gchar *contact_escaped;
+
+ contact_escaped = tp_escape_as_identifier (priv->id);
+ token_escaped = tp_escape_as_identifier (token);
+
+ avatar_path = g_build_filename (g_get_user_cache_dir (),
+ PACKAGE_NAME,
+ "avatars",
+ mc_account_get_unique_name (priv->account),
+ contact_escaped,
+ NULL);
+ g_mkdir_with_parents (avatar_path, 0700);
+
+ avatar_file = g_build_filename (avatar_path, token_escaped, NULL);
+
+ g_free (contact_escaped);
+ g_free (token_escaped);
+ g_free (avatar_path);
+
+ return avatar_file;
+}
+
+void
+empathy_contact_load_avatar_data (EmpathyContact *contact,
+ const guchar *data,
+ const gsize len,
+ const gchar *format,
+ const gchar *token)
+{
+ EmpathyContactPriv *priv = GET_PRIV (contact);
+ EmpathyAvatar *avatar;
+ gchar *filename;
+ GError *error = NULL;
+
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+ g_return_if_fail (!G_STR_EMPTY (priv->id));
+ g_return_if_fail (data != NULL);
+ g_return_if_fail (len > 0);
+ g_return_if_fail (format != NULL);
+ g_return_if_fail (!G_STR_EMPTY (token));
+
+ /* Load and set the avatar */
+ avatar = empathy_avatar_new (g_memdup (data, len), len,
+ g_strdup (format),
+ g_strdup (token));
+ 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 (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
+ if (!g_file_set_contents (filename, data, len, &error)) {
+ DEBUG ("Failed to save avatar in cache: %s",
+ error ? error->message : "No error given");
+ g_clear_error (&error);
+ } else {
+ DEBUG ("Avatar saved to %s", filename);
+ }
+ }
+ g_free (filename);
+}
+
+gboolean
+empathy_contact_load_avatar_cache (EmpathyContact *contact,
+ const gchar *token)
+{
+ EmpathyContactPriv *priv = GET_PRIV (contact);
+ EmpathyAvatar *avatar = NULL;
+ gchar *filename;
+ gchar *data = NULL;
+ gsize len;
+ GError *error = NULL;
+
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
+ g_return_val_if_fail (!G_STR_EMPTY (priv->id), FALSE);
+ g_return_val_if_fail (!G_STR_EMPTY (token), FALSE);
+
+ /* Load the avatar from file if it exists */
+ filename = contact_get_avatar_filename (contact, token);
+ if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
+ if (!g_file_get_contents (filename, &data, &len, &error)) {
+ DEBUG ("Failed to load avatar from cache: %s",
+ error ? error->message : "No error given");
+ g_clear_error (&error);
+ }
+ }
+
+ if (data) {
+ DEBUG ("Avatar loaded from %s", filename);
+ avatar = empathy_avatar_new (data, len, NULL, g_strdup (token));
+ empathy_contact_set_avatar (contact, avatar);
+ empathy_avatar_unref (avatar);
+ }
+
+ g_free (filename);
+
+ return data != NULL;
+}
+
+GType
+empathy_avatar_get_type (void)
+{
+ static GType type_id = 0;
+
+ if (!type_id) {
+ type_id = g_boxed_type_register_static ("EmpathyAvatar",
+ (GBoxedCopyFunc) empathy_avatar_ref,
+ (GBoxedFreeFunc) empathy_avatar_unref);
+ }
+
+ return type_id;
+}
+
+EmpathyAvatar *
+empathy_avatar_new (guchar *data,
+ gsize len,
+ gchar *format,
+ gchar *token)
+{
+ EmpathyAvatar *avatar;
+
+ avatar = g_slice_new0 (EmpathyAvatar);
+ avatar->data = data;
+ avatar->len = len;
+ avatar->format = format;
+ avatar->token = token;
+ avatar->refcount = 1;
+
+ return avatar;
+}
+
+void
+empathy_avatar_unref (EmpathyAvatar *avatar)
+{
+ g_return_if_fail (avatar != NULL);
+
+ avatar->refcount--;
+ if (avatar->refcount == 0) {
+ g_free (avatar->data);
+ g_free (avatar->format);
+ g_free (avatar->token);
+ g_slice_free (EmpathyAvatar, avatar);
+ }
+}
+
+EmpathyAvatar *
+empathy_avatar_ref (EmpathyAvatar *avatar)
+{
+ g_return_val_if_fail (avatar != NULL, NULL);
+
+ avatar->refcount++;
+
+ return avatar;
+}
+
diff --git a/libempathy/empathy-contact.h b/libempathy/empathy-contact.h
index 4abca99bd..fe27a04c8 100644
--- a/libempathy/empathy-contact.h
+++ b/libempathy/empathy-contact.h
@@ -31,8 +31,6 @@
#include <libmissioncontrol/mc-account.h>
#include <libmissioncontrol/mission-control.h>
-#include "empathy-avatar.h"
-
G_BEGIN_DECLS
#define EMPATHY_TYPE_CONTACT (empathy_contact_get_type ())
@@ -54,6 +52,14 @@ struct _EmpathyContactClass {
GObjectClass parent_class;
};
+typedef struct {
+ guchar *data;
+ gsize len;
+ gchar *format;
+ gchar *token;
+ guint refcount;
+} EmpathyAvatar;
+
typedef enum {
EMPATHY_CAPABILITIES_NONE = 0,
EMPATHY_CAPABILITIES_AUDIO = 1 << 0,
@@ -111,6 +117,22 @@ guint empathy_contact_hash (gconstpointer key
void empathy_contact_run_until_ready (EmpathyContact *contact,
EmpathyContactReady ready,
GMainLoop **loop);
+void empathy_contact_load_avatar_data (EmpathyContact *contact,
+ const guchar *data,
+ const gsize len,
+ const gchar *format,
+ const gchar *token);
+gboolean empathy_contact_load_avatar_cache (EmpathyContact *contact,
+ const gchar *token);
+
+#define EMPATHY_TYPE_AVATAR (empathy_avatar_get_type ())
+GType empathy_avatar_get_type (void) G_GNUC_CONST;
+EmpathyAvatar * empathy_avatar_new (guchar *data,
+ gsize len,
+ gchar *format,
+ gchar *token);
+EmpathyAvatar * empathy_avatar_ref (EmpathyAvatar *avatar);
+void empathy_avatar_unref (EmpathyAvatar *avatar);
G_END_DECLS
diff --git a/libempathy/empathy-log-manager.c b/libempathy/empathy-log-manager.c
index 1115e43c3..aa70b49da 100644
--- a/libempathy/empathy-log-manager.c
+++ b/libempathy/empathy-log-manager.c
@@ -337,7 +337,6 @@ empathy_log_manager_get_messages_for_file (EmpathyLogManager *manager,
for (node = log_node->children; node; node = node->next) {
EmpathyMessage *message;
EmpathyContact *sender;
- EmpathyAvatar *avatar = NULL;
gchar *time;
time_t t;
gchar *sender_id;
@@ -361,9 +360,6 @@ empathy_log_manager_get_messages_for_file (EmpathyLogManager *manager,
is_user_str = xmlGetProp (node, "isuser");
msg_type_str = xmlGetProp (node, "type");
- if (!G_STR_EMPTY (sender_avatar_token)) {
- avatar = empathy_avatar_new_from_cache (sender_avatar_token);
- }
if (is_user_str) {
is_user = strcmp (is_user_str, "true") == 0;
}
@@ -375,9 +371,9 @@ empathy_log_manager_get_messages_for_file (EmpathyLogManager *manager,
sender = empathy_contact_new_full (account, sender_id, sender_name);
empathy_contact_set_is_user (sender, is_user);
- if (avatar) {
- empathy_contact_set_avatar (sender, avatar);
- empathy_avatar_unref (avatar);
+ if (!G_STR_EMPTY (sender_avatar_token)) {
+ empathy_contact_load_avatar_cache (sender,
+ sender_avatar_token);
}
message = empathy_message_new (body);
diff --git a/libempathy/empathy-tp-contact-factory.c b/libempathy/empathy-tp-contact-factory.c
index 7cf0b53cc..fe68ed0a7 100644
--- a/libempathy/empathy-tp-contact-factory.c
+++ b/libempathy/empathy-tp-contact-factory.c
@@ -323,7 +323,6 @@ tp_contact_factory_avatar_retrieved_cb (TpConnection *connection,
GObject *tp_factory)
{
EmpathyContact *contact;
- EmpathyAvatar *avatar;
contact = tp_contact_factory_find_by_handle (EMPATHY_TP_CONTACT_FACTORY (tp_factory),
handle);
@@ -335,13 +334,11 @@ tp_contact_factory_avatar_retrieved_cb (TpConnection *connection,
empathy_contact_get_id (contact),
handle);
- avatar = empathy_avatar_new (avatar_data->data,
- avatar_data->len,
- mime_type,
- token);
-
- empathy_contact_set_avatar (contact, avatar);
- empathy_avatar_unref (avatar);
+ empathy_contact_load_avatar_data (contact,
+ avatar_data->data,
+ avatar_data->len,
+ mime_type,
+ token);
}
static void
@@ -381,11 +378,8 @@ tp_contact_factory_avatar_maybe_update (EmpathyTpContactFactory *tp_factory,
}
/* The avatar changed, search the new one in the cache */
- avatar = empathy_avatar_new_from_cache (token);
- if (avatar) {
+ if (empathy_contact_load_avatar_cache (contact, token)) {
/* Got from cache, use it */
- empathy_contact_set_avatar (contact, avatar);
- empathy_avatar_unref (avatar);
return TRUE;
}
@@ -804,8 +798,6 @@ tp_contact_factory_got_self_handle_cb (TpConnection *proxy,
handle_needed_contacts, tp_contact_factory_list_free,
G_OBJECT (tp_factory));
- tp_contact_factory_request_everything ((EmpathyTpContactFactory*) tp_factory,
- id_needed);
tp_cli_connection_call_inspect_handles (priv->connection,
-1,
TP_HANDLE_TYPE_CONTACT,
@@ -814,6 +806,9 @@ tp_contact_factory_got_self_handle_cb (TpConnection *proxy,
id_needed_contacts, tp_contact_factory_list_free,
G_OBJECT (tp_factory));
+ tp_contact_factory_request_everything ((EmpathyTpContactFactory*) tp_factory,
+ id_needed);
+
g_array_free (handle_needed, TRUE);
g_array_free (id_needed, TRUE);
}
diff --git a/megaphone/src/megaphone-applet.c b/megaphone/src/megaphone-applet.c
index 5deeb6c98..449bad320 100644
--- a/megaphone/src/megaphone-applet.c
+++ b/megaphone/src/megaphone-applet.c
@@ -177,18 +177,16 @@ megaphone_applet_update_icon (MegaphoneApplet *applet)
"avatar_token",
NULL);
if (!G_STR_EMPTY (avatar_token)) {
- avatar = empathy_avatar_new_from_cache (avatar_token);
+ empathy_contact_load_avatar_cache (priv->contact, avatar_token);
+ avatar = empathy_contact_get_avatar (priv->contact);
}
g_free (avatar_token);
- } else {
- empathy_avatar_ref (avatar);
}
if (avatar) {
avatar_pixbuf = empathy_pixbuf_from_avatar_scaled (avatar,
priv->image_size - 2,
priv->image_size - 2);
- empathy_avatar_unref (avatar);
} else {
GtkIconTheme *icon_theme;
diff --git a/python/pyempathy/pyempathy.defs b/python/pyempathy/pyempathy.defs
index 45e347175..2c3e8d20b 100644
--- a/python/pyempathy/pyempathy.defs
+++ b/python/pyempathy/pyempathy.defs
@@ -217,47 +217,6 @@
)
-;; From empathy-avatar.h
-
-(define-function empathy_avatar_get_type
- (c-name "empathy_avatar_get_type")
- (return-type "GType")
-)
-
-(define-function empathy_avatar_new
- (c-name "empathy_avatar_new")
- (is-constructor-of "EmpathyAvatar")
- (return-type "EmpathyAvatar*")
- (parameters
- '("const-guchar*" "avatar")
- '("const-gsize" "len")
- '("const-gchar*" "format")
- '("const-gchar*" "token")
- )
-)
-
-(define-function empathy_avatar_new_from_cache
- (c-name "empathy_avatar_new_from_cache")
- (return-type "EmpathyAvatar*")
- (parameters
- '("const-gchar*" "token")
- )
-)
-
-(define-method ref
- (of-object "EmpathyAvatar")
- (c-name "empathy_avatar_ref")
- (return-type "EmpathyAvatar*")
-)
-
-(define-method unref
- (of-object "EmpathyAvatar")
- (c-name "empathy_avatar_unref")
- (return-type "none")
-)
-
-
-
;; From empathy-time.h
(define-function empathy_time_get_current
@@ -1099,6 +1058,56 @@
)
)
+(define-method load_avatar_data
+ (of-object "EmpathyContact")
+ (c-name "empathy_contact_load_avatar_data")
+ (return-type "none")
+ (parameters
+ '("const-guchar*" "data")
+ '("const-gsize" "len")
+ '("const-gchar*" "format")
+ '("const-gchar*" "token")
+ )
+)
+
+(define-method load_avatar_cache
+ (of-object "EmpathyContact")
+ (c-name "empathy_contact_load_avatar_cache")
+ (return-type "gboolean")
+ (parameters
+ '("const-gchar*" "token")
+ )
+)
+
+(define-function empathy_avatar_get_type
+ (c-name "empathy_avatar_get_type")
+ (return-type "GType")
+)
+
+(define-function empathy_avatar_new
+ (c-name "empathy_avatar_new")
+ (is-constructor-of "EmpathyAvatar")
+ (return-type "EmpathyAvatar*")
+ (parameters
+ '("guchar*" "data")
+ '("gsize" "len")
+ '("gchar*" "format")
+ '("gchar*" "token")
+ )
+)
+
+(define-method ref
+ (of-object "EmpathyAvatar")
+ (c-name "empathy_avatar_ref")
+ (return-type "EmpathyAvatar*")
+)
+
+(define-method unref
+ (of-object "EmpathyAvatar")
+ (c-name "empathy_avatar_unref")
+ (return-type "none")
+)
+
;; From empathy-contact-groups.h
diff --git a/python/pyempathy/pyempathy.override b/python/pyempathy/pyempathy.override
index 0b44a265d..169f375ad 100644
--- a/python/pyempathy/pyempathy.override
+++ b/python/pyempathy/pyempathy.override
@@ -2,7 +2,6 @@
headers
#include <Python.h>
#include <pygobject.h>
-#include "empathy-avatar.h"
#include "empathy-chatroom.h"
#include "empathy-chatroom-manager.h"
#include "empathy-contact.h"
diff --git a/python/update-binding.sh b/python/update-binding.sh
index d07c4d6e0..fbc5b4c79 100755
--- a/python/update-binding.sh
+++ b/python/update-binding.sh
@@ -4,7 +4,6 @@
# Update the list of headers from Makefile.am
cd ../libempathy
python /usr/share/pygtk/2.0/codegen/h2def.py \
- empathy-avatar.h \
empathy-time.h \
empathy-status-presets.h \
empathy-debug.h \