aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorGuillaume Desmottes <gdesmott@gnome.org>2009-03-18 07:43:14 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-03-18 07:43:14 +0800
commit945889b6bb1cf1c05fd0cbabded207fd96ec0afb (patch)
tree38f86d510d889ebd81092768c936ceb1e84935f6 /libempathy
parentc1e9e11bfdd18eb2a92ae2082526264240288310 (diff)
downloadgsoc2013-empathy-945889b6bb1cf1c05fd0cbabded207fd96ec0afb.tar
gsoc2013-empathy-945889b6bb1cf1c05fd0cbabded207fd96ec0afb.tar.gz
gsoc2013-empathy-945889b6bb1cf1c05fd0cbabded207fd96ec0afb.tar.bz2
gsoc2013-empathy-945889b6bb1cf1c05fd0cbabded207fd96ec0afb.tar.lz
gsoc2013-empathy-945889b6bb1cf1c05fd0cbabded207fd96ec0afb.tar.xz
gsoc2013-empathy-945889b6bb1cf1c05fd0cbabded207fd96ec0afb.tar.zst
gsoc2013-empathy-945889b6bb1cf1c05fd0cbabded207fd96ec0afb.zip
Merge branch 'fix-ft' into to-merge
From: Guillaume Desmottes <gdesmott@gnome.org> svn path=/trunk/; revision=2713
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-tp-file.c46
1 files changed, 38 insertions, 8 deletions
diff --git a/libempathy/empathy-tp-file.c b/libempathy/empathy-tp-file.c
index 2d43cbba6..2b657007b 100644
--- a/libempathy/empathy-tp-file.c
+++ b/libempathy/empathy-tp-file.c
@@ -36,6 +36,7 @@
#include <gio/gunixoutputstream.h>
#include <telepathy-glib/proxy-subclass.h>
+#include <telepathy-glib/util.h>
#include "empathy-tp-file.h"
#include "empathy-contact-factory.h"
@@ -297,7 +298,7 @@ struct _EmpathyTpFilePriv {
gboolean incoming;
TpFileTransferStateChangeReason state_change_reason;
time_t start_time;
- gchar *unix_socket_path;
+ GValue *socket_address;
GCancellable *cancellable;
};
@@ -370,7 +371,8 @@ tp_file_finalize (GObject *object)
}
g_free (tp_file->priv->filename);
- g_free (tp_file->priv->unix_socket_path);
+ if (tp_file->priv->socket_address != NULL)
+ tp_g_value_slice_free (tp_file->priv->socket_address);
g_free (tp_file->priv->description);
g_free (tp_file->priv->content_hash);
g_free (tp_file->priv->content_type);
@@ -394,8 +396,8 @@ static void
tp_file_start_transfer (EmpathyTpFile *tp_file)
{
gint fd;
- size_t path_len;
struct sockaddr_un addr;
+ GArray *array;
fd = socket (PF_UNIX, SOCK_STREAM, 0);
if (fd < 0)
@@ -405,10 +407,11 @@ tp_file_start_transfer (EmpathyTpFile *tp_file)
return;
}
+ array = g_value_get_boxed (tp_file->priv->socket_address);
+
memset (&addr, 0, sizeof (addr));
addr.sun_family = AF_UNIX;
- path_len = strlen (tp_file->priv->unix_socket_path);
- strncpy (addr.sun_path, tp_file->priv->unix_socket_path, path_len);
+ strncpy (addr.sun_path, array->data, array->len);
if (connect (fd, (struct sockaddr*) &addr, sizeof (addr)) < 0)
{
@@ -466,7 +469,7 @@ tp_file_state_changed_cb (TpChannel *channel,
* transfer. The socket path could be NULL if we are not doing the actual
* data transfer but are just an observer for the channel. */
if (state == TP_FILE_TRANSFER_STATE_OPEN &&
- tp_file->priv->unix_socket_path != NULL)
+ tp_file->priv->socket_address != NULL)
tp_file_start_transfer (tp_file);
tp_file->priv->state = state;
@@ -742,6 +745,7 @@ tp_file_method_cb (TpChannel *channel,
GObject *weak_object)
{
EmpathyTpFile *tp_file = (EmpathyTpFile *) weak_object;
+ GArray *array;
if (error)
{
@@ -750,9 +754,35 @@ tp_file_method_cb (TpChannel *channel,
return;
}
- tp_file->priv->unix_socket_path = g_value_dup_string (address);
+ if (G_VALUE_TYPE (address) == DBUS_TYPE_G_UCHAR_ARRAY)
+ {
+ tp_file->priv->socket_address = tp_g_value_slice_dup (address);
+ }
+ else if (G_VALUE_TYPE (address) == G_TYPE_STRING)
+ {
+ /* Old bugged version of telepathy-salut used to store the address
+ * as a 's' instead of an 'ay' */
+ const gchar *path;
+
+ path = g_value_get_string (address);
+ array = g_array_sized_new (TRUE, FALSE, sizeof (gchar), strlen (path));
+ g_array_insert_vals (array, 0, path, strlen (path));
+
+ tp_file->priv->socket_address = tp_g_value_slice_new (
+ DBUS_TYPE_G_UCHAR_ARRAY);
+ g_value_set_boxed (tp_file->priv->socket_address, array);
+
+ g_array_free (array, TRUE);
+ }
+ else
+ {
+ DEBUG ("Wrong address type: %s", G_VALUE_TYPE_NAME (address));
+ empathy_tp_file_cancel (tp_file);
+ return;
+ }
- DEBUG ("Got unix socket path: %s", tp_file->priv->unix_socket_path);
+ array = g_value_get_boxed (tp_file->priv->socket_address);
+ DEBUG ("Got unix socket path: %s", array->data);
if (tp_file->priv->state == TP_FILE_TRANSFER_STATE_OPEN)
tp_file_start_transfer (tp_file);