[vino] Use TP_CONTACT_FEATURE_AVATAR_DATA
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vino] Use TP_CONTACT_FEATURE_AVATAR_DATA
- Date: Wed, 25 Apr 2012 09:59:09 +0000 (UTC)
commit 2467ca1d3239456dacc68f303b9f146db6587de8
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Tue Apr 24 14:44:46 2012 +0200
Use TP_CONTACT_FEATURE_AVATAR_DATA
See bug 674707.
server/vino-status-tube-icon.c | 8 ++-
server/vino-tube-server.c | 96 +++---------------------------------
server/vino-tube-server.h | 2 +-
server/vino-tube-servers-manager.c | 2 +-
4 files changed, 15 insertions(+), 93 deletions(-)
---
diff --git a/server/vino-status-tube-icon.c b/server/vino-status-tube-icon.c
index 34982f2..717922d 100644
--- a/server/vino-status-tube-icon.c
+++ b/server/vino-status-tube-icon.c
@@ -393,7 +393,7 @@ vino_status_tube_icon_show_notif (VinoStatusTubeIcon *icon,
#define NOTIFICATION_TIMEOUT 5
GError *error;
- const gchar *filename = NULL;
+ gchar *filename;
if (!notify_is_initted () && !notify_init (g_get_application_name ()))
{
@@ -408,10 +408,10 @@ vino_status_tube_icon_show_notif (VinoStatusTubeIcon *icon,
icon->priv->new_client_notification = NULL;
}
- filename = vino_tube_server_get_avatar_filename (icon->priv->server);
+ filename = vino_tube_server_dup_avatar_filename (icon->priv->server);
if (filename == NULL)
- filename = "stock_person";
+ filename = g_strdup ("stock_person");
icon->priv->new_client_notification =
#ifdef VINO_HAVE_LIBNOTIFY_0_7
@@ -421,6 +421,8 @@ vino_status_tube_icon_show_notif (VinoStatusTubeIcon *icon,
filename, GTK_STATUS_ICON (icon));
#endif
+ g_free (filename);
+
notify_notification_set_timeout (icon->priv->new_client_notification,
NOTIFICATION_TIMEOUT * 1000);
diff --git a/server/vino-tube-server.c b/server/vino-tube-server.c
index 24811be..0bc3806 100644
--- a/server/vino-tube-server.c
+++ b/server/vino-tube-server.c
@@ -44,7 +44,6 @@ G_DEFINE_TYPE (VinoTubeServer, vino_tube_server, VINO_TYPE_SERVER);
struct _VinoTubeServerPrivate
{
TpChannel *tube;
- gchar *filename;
gulong signal_invalidated_id;
VinoStatusTubeIcon *icon_tube;
TpTubeChannelState state;
@@ -65,38 +64,6 @@ enum
static guint signals[LAST_SIGNAL] = { 0 };
-static gchar * vino_tube_server_contact_get_avatar_filename (TpContact *contact,
- const gchar *token,
- VinoTubeServer *self);
-
-static void
-vino_tube_server_constructed (GObject *object)
-{
- VinoTubeServer *self = VINO_TUBE_SERVER (object);
- TpContact *contact;
- const gchar *token;
-
- if (G_OBJECT_CLASS (vino_tube_server_parent_class)->constructed)
- G_OBJECT_CLASS (vino_tube_server_parent_class)->constructed (object);
-
- g_assert (self->priv->tube != NULL);
-
- contact = tp_channel_get_target_contact (self->priv->tube);
- g_assert (contact != NULL);
-
- token = tp_contact_get_avatar_token (contact);
-
- if (!tp_str_empty (token))
- {
- self->priv->filename = NULL;
- }
- else
- {
- self->priv->filename = vino_tube_server_contact_get_avatar_filename
- (contact, token, self);
- }
-}
-
static void
vino_tube_server_dispose (GObject *object)
{
@@ -124,14 +91,6 @@ vino_tube_server_dispose (GObject *object)
static void
vino_tube_server_finalize (GObject *object)
{
- VinoTubeServer *server = VINO_TUBE_SERVER (object);
-
- if (server->priv->filename != NULL)
- {
- g_free (server->priv->filename);
- server->priv->filename = NULL;
- }
-
dprintf (TUBE, "Destruction of a VinoTubeServer\n");
if (G_OBJECT_CLASS (vino_tube_server_parent_class)->finalize)
@@ -200,7 +159,6 @@ vino_tube_server_class_init (VinoTubeServerClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->dispose = vino_tube_server_dispose;
- gobject_class->constructed = vino_tube_server_constructed;
gobject_class->finalize = vino_tube_server_finalize;
gobject_class->set_property = vino_tube_server_set_property;
gobject_class->get_property = vino_tube_server_get_property;
@@ -326,49 +284,6 @@ vino_tube_server_offer_cb (TpChannel *proxy,
}
}
-static gchar *
-vino_tube_server_contact_get_avatar_filename (TpContact *contact,
- const gchar *token,
- VinoTubeServer *self)
-{
- gchar *avatar_path;
- gchar *avatar_file;
- gchar *token_escaped;
- TpConnection *connection;
- gchar *cm;
- gchar *protocol;
-
- if (contact == NULL)
- return NULL;
-
- token_escaped = tp_escape_as_identifier (token);
-
- connection = tp_contact_get_connection (contact);
-
- if (!tp_connection_parse_object_path (connection, &protocol, &cm))
- {
- dprintf (TUBE, "Impossible to parse object path\n");
- return NULL;
- }
-
- avatar_path = g_build_filename (g_get_user_cache_dir (),
- "telepathy",
- "avatars",
- cm,
- protocol,
- NULL);
- g_mkdir_with_parents (avatar_path, 0700);
-
- avatar_file = g_build_filename (avatar_path, token_escaped, NULL);
-
- g_free (token_escaped);
- g_free (avatar_path);
- g_free (cm);
- g_free (protocol);
-
- return avatar_file;
-}
-
gboolean
vino_tube_server_share_with_tube (VinoTubeServer *server,
GError **error)
@@ -432,13 +347,18 @@ vino_tube_server_get_alias (VinoTubeServer *self)
return tp_contact_get_alias (contact);
}
-const gchar*
-vino_tube_server_get_avatar_filename (VinoTubeServer *self)
+gchar*
+vino_tube_server_dup_avatar_filename (VinoTubeServer *self)
{
TpContact *contact;
+ GFile *file;
contact = tp_channel_get_target_contact (self->priv->tube);
g_return_val_if_fail (contact != NULL, NULL);
- return tp_contact_get_alias (contact);
+ file = tp_contact_get_avatar_file (contact);
+ if (file == NULL)
+ return NULL;
+
+ return g_file_get_path (file);
}
diff --git a/server/vino-tube-server.h b/server/vino-tube-server.h
index 66461f6..d8d949b 100644
--- a/server/vino-tube-server.h
+++ b/server/vino-tube-server.h
@@ -64,7 +64,7 @@ GType vino_tube_server_get_type (void) G_GNUC_CONST;
gboolean vino_tube_server_share_with_tube (VinoTubeServer *server,
GError **error);
const gchar* vino_tube_server_get_alias (VinoTubeServer *self);
-const gchar* vino_tube_server_get_avatar_filename (VinoTubeServer *self);
+gchar* vino_tube_server_dup_avatar_filename (VinoTubeServer *self);
void vino_tube_server_close_tube (VinoTubeServer *server);
void vino_tube_server_fire_closed (VinoTubeServer *server);
diff --git a/server/vino-tube-servers-manager.c b/server/vino-tube-servers-manager.c
index a5dab53..2b03cd2 100644
--- a/server/vino-tube-servers-manager.c
+++ b/server/vino-tube-servers-manager.c
@@ -119,7 +119,7 @@ vino_tube_servers_manager_init (VinoTubeServersManager *self)
tp_simple_client_factory_add_contact_features_varargs (factory,
TP_CONTACT_FEATURE_ALIAS,
- TP_CONTACT_FEATURE_AVATAR_TOKEN,
+ TP_CONTACT_FEATURE_AVATAR_DATA,
TP_CONTACT_FEATURE_INVALID);
tp_simple_client_factory_add_channel_features_varargs (factory,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]