diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2008-11-22 00:24:24 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-11-22 00:24:24 +0800 |
commit | 0c8c33990ca059bfc8c023ccf6f3e2e589151bec (patch) | |
tree | b2c7adb9de18ab508eaacaca2bc21fb18fed1748 /libempathy | |
parent | a20b9bd20a53e5f5de6f50e34da62175571862cc (diff) | |
download | gsoc2013-empathy-0c8c33990ca059bfc8c023ccf6f3e2e589151bec.tar gsoc2013-empathy-0c8c33990ca059bfc8c023ccf6f3e2e589151bec.tar.gz gsoc2013-empathy-0c8c33990ca059bfc8c023ccf6f3e2e589151bec.tar.bz2 gsoc2013-empathy-0c8c33990ca059bfc8c023ccf6f3e2e589151bec.tar.lz gsoc2013-empathy-0c8c33990ca059bfc8c023ccf6f3e2e589151bec.tar.xz gsoc2013-empathy-0c8c33990ca059bfc8c023ccf6f3e2e589151bec.tar.zst gsoc2013-empathy-0c8c33990ca059bfc8c023ccf6f3e2e589151bec.zip |
Fix signature of signal cb, start the transfer only if we have the socket path, and switch input/output streams in tp_file_start_transfer.
svn path=/trunk/; revision=1901
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-tp-file.c | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/libempathy/empathy-tp-file.c b/libempathy/empathy-tp-file.c index 38f54a386..c885e0f20 100644 --- a/libempathy/empathy-tp-file.c +++ b/libempathy/empathy-tp-file.c @@ -426,30 +426,36 @@ tp_file_start_transfer (EmpathyTpFile *tp_file) tp_file->priv->cancellable = g_cancellable_new (); if (tp_file->priv->incoming) { - GOutputStream *socket_stream; + GInputStream *socket_stream; - socket_stream = g_unix_output_stream_new (fd, TRUE); - copy_stream (tp_file->priv->in_stream, socket_stream, + socket_stream = g_unix_input_stream_new (fd, TRUE); + copy_stream (socket_stream, tp_file->priv->out_stream, tp_file->priv->cancellable); g_object_unref (socket_stream); } else { - GInputStream *socket_stream; + GOutputStream *socket_stream; - socket_stream = g_unix_input_stream_new (fd, TRUE); - copy_stream (socket_stream, tp_file->priv->out_stream, + socket_stream = g_unix_output_stream_new (fd, TRUE); + copy_stream (tp_file->priv->in_stream, socket_stream, tp_file->priv->cancellable); g_object_unref (socket_stream); } } static void -tp_file_state_changed_cb (DBusGProxy *tp_file_iface, - EmpFileTransferState state, - EmpFileTransferStateChangeReason reason, - EmpathyTpFile *tp_file) +tp_file_state_changed_cb (TpProxy *proxy, + guint state, + guint reason, + gpointer user_data, + GObject *weak_object) { + EmpathyTpFile *tp_file = EMPATHY_TP_FILE (weak_object); + + if (state == tp_file->priv->state) + return; + DEBUG ("File transfer state changed:\n" "\tfilename = %s, old state = %u, state = %u, reason = %u\n" "\tincoming = %s, in_stream = %s, out_stream = %s", @@ -458,7 +464,11 @@ tp_file_state_changed_cb (DBusGProxy *tp_file_iface, tp_file->priv->in_stream ? "present" : "not present", tp_file->priv->out_stream ? "present" : "not present"); - if (state == EMP_FILE_TRANSFER_STATE_OPEN) + /* If the channel is open AND we have the socket path, we can start the + * 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 == EMP_FILE_TRANSFER_STATE_OPEN && + tp_file->priv->unix_socket_path != NULL) tp_file_start_transfer (tp_file); tp_file->priv->state = state; @@ -470,14 +480,15 @@ tp_file_state_changed_cb (DBusGProxy *tp_file_iface, static void tp_file_transferred_bytes_changed_cb (TpProxy *proxy, guint64 count, - EmpathyTpFile *tp_file, + gpointer user_data, GObject *weak_object) { + EmpathyTpFile *tp_file = EMPATHY_TP_FILE (weak_object); + if (tp_file->priv->transferred_bytes == count) return; tp_file->priv->transferred_bytes = count; - g_object_notify (G_OBJECT (tp_file), "transferred-bytes"); } @@ -505,18 +516,12 @@ tp_file_constructor (GType type, G_CALLBACK (tp_file_invalidated_cb), tp_file); emp_cli_channel_type_file_transfer_connect_to_file_transfer_state_changed ( - TP_PROXY (tp_file->priv->channel), - (emp_cli_channel_type_file_transfer_signal_callback_file_transfer_state_changed) - tp_file_state_changed_cb, - tp_file, - NULL, NULL, NULL); + TP_PROXY (tp_file->priv->channel), tp_file_state_changed_cb, NULL, NULL, + G_OBJECT (tp_file), NULL); emp_cli_channel_type_file_transfer_connect_to_transferred_bytes_changed ( - TP_PROXY (tp_file->priv->channel), - (emp_cli_channel_type_file_transfer_signal_callback_transferred_bytes_changed) - tp_file_transferred_bytes_changed_cb, - tp_file, - NULL, NULL, NULL); + TP_PROXY (tp_file->priv->channel), tp_file_transferred_bytes_changed_cb, + NULL, NULL, G_OBJECT (tp_file), NULL); account = empathy_channel_get_account (tp_file->priv->channel); @@ -724,7 +729,6 @@ tp_file_method_cb (TpProxy *proxy, DEBUG ("Got unix socket path: %s", tp_file->priv->unix_socket_path); } - /** * empathy_tp_file_accept: * @tp_file: an #EmpathyTpFile |