Move avatar cache to ~/.cache and don't mix avatar from different contacts, tokens...
authorXavier Claessens <xclaesse@src.gnome.org>
Tue, 27 May 2008 17:34:44 +0000 (17:34 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Tue, 27 May 2008 17:34:44 +0000 (17:34 +0000)
svn path=/trunk/; revision=1128

16 files changed:
docs/libempathy/libempathy-docs.sgml
docs/libempathy/libempathy.types
libempathy-gtk/empathy-avatar-chooser.h
libempathy-gtk/empathy-avatar-image.h
libempathy-gtk/empathy-ui-utils.h
libempathy/Makefile.am
libempathy/empathy-avatar.c [deleted file]
libempathy/empathy-avatar.h [deleted file]
libempathy/empathy-contact.c
libempathy/empathy-contact.h
libempathy/empathy-log-manager.c
libempathy/empathy-tp-contact-factory.c
megaphone/src/megaphone-applet.c
python/pyempathy/pyempathy.defs
python/pyempathy/pyempathy.override
python/update-binding.sh

index 6e040b0cb10952b950b2b4da63fb1883c8741902..e3ca78b537ca0f3883792fb111f07ec1973cea53 100644 (file)
@@ -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"/>
index dead1e5c4e2a34fe69556a1fbc007bf671e033c9..87963c222a06e74fb8850c3a4a02289eea17f828 100644 (file)
@@ -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
 
index 7db880df7e85c7de18352e3336f84a0b259d09d7..bdc5b40ae1a159905dfd9a8c7f3c1092f6c67f88 100644 (file)
@@ -26,7 +26,7 @@
 
 #include <gtk/gtkbutton.h>
 
-#include <libempathy/empathy-avatar.h>
+#include <libempathy/empathy-contact.h>
 
 G_BEGIN_DECLS
 
index bd83e4bb8871c937f8dc1754b2442dd08645faf4..d6a6cd0b08ccfd1a223ccca42bf61e02f9ea4b02 100644 (file)
@@ -26,7 +26,7 @@
 
 #include <gtk/gtkeventbox.h>
 
-#include <libempathy/empathy-avatar.h>
+#include <libempathy/empathy-contact.h>
 
 G_BEGIN_DECLS
 
index b7478140e81568142ce8ec41236902b900663840..24ab01fb414baa9a6d6dff16532edd489c5de6f3 100644 (file)
@@ -38,7 +38,6 @@
 #include <libmissioncontrol/mc-profile.h>
 
 #include <libempathy/empathy-contact.h>
-#include <libempathy/empathy-avatar.h>
 
 #include "empathy-chat-view.h"
 
index 0db883d3d94ce71409433ff24449f192cf69e486..3fb491855240cb81b97a3b967235e921c3d36bd0 100644 (file)
@@ -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 (file)
index 41395d6..0000000
+++ /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 (file)
index 63be370..0000000
+++ /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__ */
index 19283cc72ff8f00857dcd146f7d4e4a01f043ee1..39d6148a21067f25fb00e5e4509ff47d63d9f343 100644 (file)
@@ -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;
+}
+
index 4abca99bd9da133b86d18dde6195b5cd84d91ee0..fe27a04c8ec979c334e05152dd0465d7eb3b7858 100644 (file)
@@ -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
 
index 1115e43c3d5dbc53a2153d857ac8a0415d885090..aa70b49dac49fc7129cc708902b85cd0b4449028 100644 (file)
@@ -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);
index 7cf0b53ccf281003096cb179384603b3b89b596d..fe68ed0a7d50d188f4ad4eb8442a097f5ee40649 100644 (file)
@@ -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);
 }
index 5deeb6c9809e799d0903f8d713a7a7c6764b8e84..449bad3202346e2c994e49c991717fcc76188ca4 100644 (file)
@@ -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;
 
index 45e347175b9616b11314375164fd8ab40b198331..2c3e8d20be3bea71b935d56ee641ba8470957bcd 100644 (file)
 )
 
 
-;; 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
   )
 )
 
+(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
index 0b44a265d9710d034545d4ccc5cc4021c05d0b25..169f375adb17644c4f5ad95bd68cf9132ca695a3 100644 (file)
@@ -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"
index d07c4d6e0fc875c4dfd41364e8713b0b2e6ab2bd..fbc5b4c798a67e74d061325c8e851871445ae7aa 100755 (executable)
@@ -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                         \