[Pkg-telepathy-commits] ./packages/unstable/telepathy-mission-control r59: the original string is freed. From sf #1849202.
Sjoerd Simons
sjoerd at luon.net
Sat Jan 5 17:45:44 UTC 2008
------------------------------------------------------------
revno: 59
committer: Sjoerd Simons <sjoerd at luon.net>
branch nick: telepathy-mission-control
timestamp: Sat 2008-01-05 18:45:44 +0100
message:
the original string is freed. From sf #1849202.
* patches/set_avatar_if_none_set.patch
- Added. Set the saved avatar iff there is no avatar configured on the
connection.
added:
patches/set_avatar_if_none_set.patch
modified:
changelog
-------------- next part --------------
=== added file 'patches/set_avatar_if_none_set.patch'
--- a/patches/set_avatar_if_none_set.patch 1970-01-01 00:00:00 +0000
+++ b/patches/set_avatar_if_none_set.patch 2008-01-05 17:45:44 +0000
@@ -0,0 +1,137 @@
+Index: src/mcd-connection.c
+===================================================================
+--- src/mcd-connection.c (revision 219)
++++ src/mcd-connection.c (working copy)
+@@ -848,10 +848,76 @@
+ }
+
+ static void
++_mcd_connection_set_avatar (McdConnectionPrivate *priv, gchar *filename,
++ gchar *mime_type)
++{
++ GError *error = NULL;
++ gchar *data = NULL;
++ size_t length;
++
++ if (filename == NULL || !g_file_test (filename, G_FILE_TEST_EXISTS))
++ {
++ return;
++ }
++
++ if (g_file_get_contents (filename, &data, &length, &error))
++ {
++ if (length > 0 && length < G_MAXUINT)
++ {
++ GArray avatar;
++ avatar.data = data;
++ avatar.len = (guint)length;
++ tp_conn_iface_avatars_set_avatar_async (priv->avatars_proxy,
++ &avatar, mime_type, set_avatar_cb, priv);
++ }
++ else
++ tp_conn_iface_avatars_clear_avatar_async(priv->avatars_proxy,
++ clear_avatar_cb, g_strdup (filename));
++ }
++ else
++ {
++ g_debug ("%s: error reading %s: %s", G_STRFUNC, filename, error->message);
++ g_error_free (error);
++ }
++ g_free(data);
++}
++
++static void
++request_tokens_cb (DBusGProxy *proxy, GHashTable *tokens,
++ GError *error, gpointer user_data)
++{
++ McdConnectionPrivate *priv = (McdConnectionPrivate *)user_data;
++ const gchar *token;
++ gchar *filename, *mime_type;
++
++ if (error)
++ {
++ g_warning ("%s: error: %s", G_STRFUNC, error->message);
++ g_error_free (error);
++ return;
++ }
++
++ token = g_hash_table_lookup (tokens, GUINT_TO_POINTER (priv->self_handle));
++ if (token == NULL || *token != '\0')
++ return;
++
++ if (!mc_account_get_avatar (priv->account, &filename, &mime_type, NULL))
++ {
++ g_debug ("%s: mc_account_get_avatar() returned FALSE", G_STRFUNC);
++ return;
++ }
++
++ g_debug ("No avatar set, setting our own");
++ _mcd_connection_set_avatar (priv, filename, mime_type);
++
++ g_free (filename);
++ g_free (mime_type);
++}
++
++static void
+ _mcd_connection_setup_avatar (McdConnectionPrivate *priv)
+ {
+ gchar *filename, *mime_type, *token;
+- GError *error = NULL;
+
+ priv->avatars_proxy = tp_conn_get_interface (priv->tp_conn,
+ TELEPATHY_CONN_IFACE_AVATARS_QUARK);
+@@ -873,36 +939,24 @@
+ return;
+ }
+
+- /* if the token is set, we have nothing to do */
+- if (!token && filename && g_file_test (filename, G_FILE_TEST_EXISTS))
+- {
+- gchar *data = NULL;
+- size_t length;
+- if (g_file_get_contents (filename, &data, &length, &error))
+- {
+- if (length > 0 && length < G_MAXUINT)
+- {
+- GArray avatar;
+- avatar.data = data;
+- avatar.len = (guint)length;
+- tp_conn_iface_avatars_set_avatar_async (priv->avatars_proxy,
+- &avatar, mime_type,
+- set_avatar_cb, priv);
+- }
+- else
+- tp_conn_iface_avatars_clear_avatar_async(priv->avatars_proxy,
+- clear_avatar_cb,
+- g_strdup (filename));
+-
+- }
+- else
+- {
+- g_debug ("%s: error reading %s: %s", G_STRFUNC, filename, error->message);
+- g_error_free (error);
+- }
+- g_free(data);
+- }
+-
++ if (filename)
++ {
++ if (!token)
++ _mcd_connection_set_avatar (priv, filename, mime_type);
++ else
++ {
++ /* Set the avatar only if no other one was set */
++ GArray *handles = g_array_sized_new (FALSE, FALSE,
++ sizeof (guint), 1);
++ g_array_append_val (handles, priv->self_handle);
++ tp_conn_iface_avatars_get_known_avatar_tokens_async (
++ priv->avatars_proxy,
++ handles,
++ request_tokens_cb,
++ priv);
++ g_array_free (handles, TRUE);
++ }
++ }
+ g_free (filename);
+ g_free (mime_type);
+ g_free (token);
=== modified file 'changelog'
--- a/changelog 2008-01-05 15:44:30 +0000
+++ b/changelog 2008-01-05 17:45:44 +0000
@@ -9,7 +9,10 @@
[ Sjoerd Simons ]
* patches/mcd_copy_channel_type.patch
- Added. Copy the channel type string to prevent crashes when the owner of
- the original string is freed. From sf #1849202.
+ the original string is freed. From sf #1849202.
+ * patches/set_avatar_if_none_set.patch
+ - Added. Set the saved avatar iff there is no avatar configured on the
+ connection.
-- Laurent Bigonville <bigon at bigon.be> Sun, 09 Dec 2007 18:10:14 +0100
More information about the Pkg-telepathy-commits
mailing list