2 * empathy-ft-handler.c - Source for EmpathyFTHandler
3 * Copyright (C) 2009 Collabora Ltd.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Author: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
22 /* empathy-ft-handler.c */
24 #include <extensions/extensions.h>
26 #include <glib/gi18n.h>
27 #include <telepathy-glib/util.h>
29 #include "empathy-ft-handler.h"
30 #include "empathy-contact-factory.h"
31 #include "empathy-dispatcher.h"
32 #include "empathy-marshal.h"
33 #include "empathy-utils.h"
35 #define DEBUG_FLAG EMPATHY_DEBUG_FT
36 #include "empathy-debug.h"
38 G_DEFINE_TYPE (EmpathyFTHandler, empathy_ft_handler, G_TYPE_OBJECT)
40 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyFTHandler)
42 #define BUFFER_SIZE 4096
63 gboolean done_reading;
69 EmpathyFTHandler *handler;
73 EmpathyFTHandlerReadyCallback callback;
75 EmpathyFTHandler *handler;
82 EmpathyTpFile *tpfile;
83 GCancellable *cancellable;
85 /* request for the new transfer */
88 /* transfer properties */
89 EmpathyContact *contact;
94 guint64 transferred_bytes;
97 EmpFileHashType content_hash_type;
98 } EmpathyFTHandlerPriv;
100 static guint signals[LAST_SIGNAL] = { 0 };
103 static void schedule_hash_chunk (HashingData *hash_data);
105 /* GObject implementations */
107 do_get_property (GObject *object,
112 EmpathyFTHandlerPriv *priv = GET_PRIV (object);
117 g_value_set_object (value, priv->contact);
120 g_value_set_object (value, priv->gfile);
123 g_value_set_object (value, priv->tpfile);
126 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
131 do_set_property (GObject *object,
136 EmpathyFTHandlerPriv *priv = GET_PRIV (object);
141 priv->contact = g_value_dup_object (value);
144 priv->gfile = g_value_dup_object (value);
147 priv->tpfile = g_value_dup_object (value);
150 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
155 do_dispose (GObject *object)
157 EmpathyFTHandlerPriv *priv = GET_PRIV (object);
159 if (priv->dispose_run)
162 priv->dispose_run = TRUE;
165 g_object_unref (priv->contact);
166 priv->contact = NULL;
170 g_object_unref (priv->gfile);
175 empathy_tp_file_close (priv->tpfile);
176 g_object_unref (priv->tpfile);
180 if (priv->cancellable) {
181 g_object_unref (priv->cancellable);
182 priv->cancellable = NULL;
185 G_OBJECT_CLASS (empathy_ft_handler_parent_class)->dispose (object);
189 do_finalize (GObject *object)
191 EmpathyFTHandlerPriv *priv = GET_PRIV (object);
193 g_free (priv->content_type);
194 priv->content_type = NULL;
196 g_free (priv->filename);
197 priv->filename = NULL;
199 g_free (priv->description);
200 priv->description = NULL;
202 g_free (priv->content_hash);
203 priv->content_hash = NULL;
205 if (priv->request != NULL)
207 g_hash_table_destroy (priv->request);
208 priv->request = NULL;
211 G_OBJECT_CLASS (empathy_ft_handler_parent_class)->finalize (object);
215 empathy_ft_handler_class_init (EmpathyFTHandlerClass *klass)
217 GObjectClass *object_class = G_OBJECT_CLASS (klass);
218 GParamSpec *param_spec;
220 g_type_class_add_private (klass, sizeof (EmpathyFTHandlerPriv));
222 object_class->get_property = do_get_property;
223 object_class->set_property = do_set_property;
224 object_class->dispose = do_dispose;
225 object_class->finalize = do_finalize;
228 param_spec = g_param_spec_object ("contact",
229 "contact", "The remote contact",
230 EMPATHY_TYPE_CONTACT,
231 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
232 g_object_class_install_property (object_class, PROP_CONTACT, param_spec);
234 param_spec = g_param_spec_object ("gfile",
235 "gfile", "The GFile we're handling",
237 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
238 g_object_class_install_property (object_class, PROP_G_FILE, param_spec);
240 param_spec = g_param_spec_object ("tp-file",
241 "tp-file", "The file's channel wrapper",
242 EMPATHY_TYPE_TP_FILE,
243 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
244 g_object_class_install_property (object_class, PROP_TP_FILE, param_spec);
247 signals[TRANSFER_STARTED] =
248 g_signal_new ("transfer-started", G_TYPE_FROM_CLASS (klass),
249 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
250 g_cclosure_marshal_VOID__OBJECT,
252 1, EMPATHY_TYPE_TP_FILE);
254 signals[TRANSFER_DONE] =
255 g_signal_new ("transfer-done", G_TYPE_FROM_CLASS (klass),
256 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
257 g_cclosure_marshal_VOID__OBJECT,
259 1, EMPATHY_TYPE_TP_FILE);
261 signals[TRANSFER_ERROR] =
262 g_signal_new ("transfer-error", G_TYPE_FROM_CLASS (klass),
263 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
264 g_cclosure_marshal_VOID__POINTER,
268 signals[TRANSFER_PROGRESS] =
269 g_signal_new ("transfer-progress", G_TYPE_FROM_CLASS (klass),
270 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
271 _empathy_marshal_VOID__UINT64_UINT64,
273 2, G_TYPE_UINT64, G_TYPE_UINT64);
275 signals[HASHING_STARTED] =
276 g_signal_new ("hashing-started", G_TYPE_FROM_CLASS (klass),
277 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
278 g_cclosure_marshal_VOID__VOID,
281 signals[HASHING_PROGRESS] =
282 g_signal_new ("hashing-progress", G_TYPE_FROM_CLASS (klass),
283 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
284 _empathy_marshal_VOID__UINT64_UINT64,
286 2, G_TYPE_UINT64, G_TYPE_UINT64);
288 signals[HASHING_DONE] =
289 g_signal_new ("hashing-done", G_TYPE_FROM_CLASS (klass),
290 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
291 g_cclosure_marshal_VOID__VOID,
296 empathy_ft_handler_init (EmpathyFTHandler *self)
298 EmpathyFTHandlerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
299 EMPATHY_TYPE_FT_HANDLER, EmpathyFTHandlerPriv);
304 /* private functions */
307 hash_data_free (HashingData *data)
309 if (data->buffer != NULL)
311 g_free (data->buffer);
315 if (data->stream != NULL)
317 g_object_unref (data->stream);
321 if (data->checksum != NULL)
323 g_checksum_free (data->checksum);
324 data->checksum = NULL;
327 if (data->error != NULL)
329 g_error_free (data->error);
332 if (data->handler != NULL)
334 g_object_unref (data->handler);
335 data->handler = NULL;
338 g_slice_free (HashingData, data);
342 ft_transfer_operation_callback (EmpathyTpFile *tp_file,
346 EmpathyFTHandler *handler = user_data;
349 g_signal_emit (handler, signals[TRANSFER_ERROR], 0, error);
351 g_signal_emit (handler, signals[TRANSFER_DONE], 0);
355 ft_transfer_progress_callback (EmpathyTpFile *tp_file,
356 guint64 transferred_bytes,
359 EmpathyFTHandler *handler = user_data;
360 EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
362 if (priv->transferred_bytes != transferred_bytes)
364 priv->transferred_bytes = transferred_bytes;
365 g_signal_emit (handler, signals[TRANSFER_PROGRESS], 0,
366 transferred_bytes, priv->total_bytes);
371 ft_handler_create_channel_cb (EmpathyDispatchOperation *operation,
375 EmpathyFTHandler *handler = user_data;
376 EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
378 DEBUG ("FT: dispatcher create channel CB");
382 /* TODO: error handling */
386 priv->tpfile = g_object_ref
387 (empathy_dispatch_operation_get_channel_wrapper (operation));
388 empathy_tp_file_offer (priv->tpfile, priv->gfile, priv->cancellable,
389 ft_transfer_progress_callback, handler,
390 ft_transfer_operation_callback, handler);
392 empathy_dispatch_operation_claim (operation);
396 ft_handler_push_to_dispatcher (EmpathyFTHandler *handler)
398 EmpathyDispatcher *dispatcher;
400 EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
402 DEBUG ("FT: pushing request to the dispatcher");
404 dispatcher = empathy_dispatcher_dup_singleton ();
405 account = empathy_contact_get_account (priv->contact);
407 empathy_dispatcher_create_channel (dispatcher, account, priv->request,
408 ft_handler_create_channel_cb, handler);
410 g_object_unref (dispatcher);
414 ft_handler_check_if_allowed (EmpathyFTHandler *handler)
416 EmpathyDispatcher *dispatcher;
417 EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
422 dispatcher = empathy_dispatcher_dup_singleton ();
423 account = empathy_contact_get_account (priv->contact);
425 allowed = empathy_dispatcher_find_channel_class (dispatcher, account,
426 EMP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, TP_HANDLE_TYPE_CONTACT);
428 if (!tp_strv_contains ((const gchar * const *) allowed,
429 TP_IFACE_CHANNEL ".TargetHandle"))
432 g_object_unref (dispatcher);
438 ft_handler_populate_outgoing_request (EmpathyFTHandler *handler)
440 guint contact_handle;
443 EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
445 request = priv->request = g_hash_table_new_full (g_str_hash, g_str_equal,
446 NULL, (GDestroyNotify) tp_g_value_slice_free);
448 contact_handle = empathy_contact_get_handle (priv->contact);
450 /* org.freedesktop.Telepathy.Channel.ChannelType */
451 value = tp_g_value_slice_new (G_TYPE_STRING);
452 g_value_set_string (value, EMP_IFACE_CHANNEL_TYPE_FILE_TRANSFER);
453 g_hash_table_insert (request, TP_IFACE_CHANNEL ".ChannelType", value);
455 /* org.freedesktop.Telepathy.Channel.TargetHandleType */
456 value = tp_g_value_slice_new (G_TYPE_UINT);
457 g_value_set_uint (value, TP_HANDLE_TYPE_CONTACT);
458 g_hash_table_insert (request, TP_IFACE_CHANNEL ".TargetHandleType", value);
460 /* org.freedesktop.Telepathy.Channel.TargetHandle */
461 value = tp_g_value_slice_new (G_TYPE_UINT);
462 g_value_set_uint (value, contact_handle);
463 g_hash_table_insert (request, TP_IFACE_CHANNEL ".TargetHandle", value);
465 /* org.freedesktop.Telepathy.Channel.Type.FileTransfer.ContentType */
466 value = tp_g_value_slice_new (G_TYPE_STRING);
467 g_value_set_string (value, priv->content_type);
468 g_hash_table_insert (request,
469 EMP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".ContentType", value);
471 /* org.freedesktop.Telepathy.Channel.Type.FileTransfer.Filename */
472 value = tp_g_value_slice_new (G_TYPE_STRING);
473 g_value_set_string (value, priv->filename);
474 g_hash_table_insert (request,
475 EMP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".Filename", value);
477 /* org.freedesktop.Telepathy.Channel.Type.FileTransfer.Size */
478 value = tp_g_value_slice_new (G_TYPE_UINT64);
479 g_value_set_uint64 (value, (guint64) priv->total_bytes);
480 g_hash_table_insert (request,
481 EMP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".Size", value);
483 /* org.freedesktop.Telepathy.Channel.Type.FileTransfer.Date */
484 value = tp_g_value_slice_new (G_TYPE_UINT64);
485 g_value_set_uint64 (value, (guint64) priv->mtime);
486 g_hash_table_insert (request,
487 EMP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".Date", value);
491 hash_job_async_close_stream_cb (GObject *source,
495 HashingData *hash_data = user_data;
496 EmpathyFTHandler *handler = hash_data->handler;
497 EmpathyFTHandlerPriv *priv;
498 GError *error = NULL;
501 DEBUG ("FT: closing stream after hashing.");
503 priv = GET_PRIV (handler);
505 /* if we're here we for sure have done reading, check if we stopped due
508 g_input_stream_close_finish (hash_data->stream, res, &error);
511 if (hash_data->error != NULL)
513 /* if we already stopped due to an error, probably we're completely
514 * hosed for some reason. just return the first read error
517 g_clear_error (&error);
518 error = hash_data->error;
524 if (hash_data->error != NULL)
526 error = hash_data->error;
530 /* set the checksum in the request */
532 DEBUG ("FT: got file hash %s", g_checksum_get_string (hash_data->checksum));
534 /* org.freedesktop.Telepathy.Channel.Type.FileTransfer.ContentHash */
535 value = tp_g_value_slice_new (G_TYPE_STRING);
536 g_value_set_string (value, g_checksum_get_string (hash_data->checksum));
537 g_hash_table_insert (priv->request,
538 EMP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".ContentHash", value);
541 hash_data_free (hash_data);
545 g_signal_emit (handler, signals[TRANSFER_ERROR], 0, error);
546 g_clear_error (&error);
550 g_signal_emit (handler, signals[HASHING_DONE], 0);
552 /* the request is complete now, push it to the dispatcher */
553 ft_handler_push_to_dispatcher (handler);
558 hash_job_async_read_cb (GObject *source,
562 HashingData *hash_data = user_data;
564 GError *error = NULL;
566 DEBUG ("FT: reading a chunk for hashing.");
568 bytes_read = g_input_stream_read_finish (hash_data->stream, res, &error);
571 hash_data->error = error;
572 hash_data->done_reading = TRUE;
576 hash_data->total_read += bytes_read;
578 /* we now have the chunk */
581 hash_data->done_reading = TRUE;
586 g_checksum_update (hash_data->checksum, hash_data->buffer, bytes_read);
587 g_signal_emit (hash_data->handler, signals[HASHING_PROGRESS], 0,
588 (guint64) hash_data->total_read, (guint64) hash_data->total_bytes);
592 g_free (hash_data->buffer);
593 hash_data->buffer = NULL;
595 schedule_hash_chunk (hash_data);
599 schedule_hash_chunk (HashingData *hash_data)
601 EmpathyFTHandlerPriv *priv;
603 priv = GET_PRIV (hash_data->handler);
605 if (hash_data->done_reading)
607 g_input_stream_close_async (hash_data->stream, G_PRIORITY_DEFAULT,
608 priv->cancellable, hash_job_async_close_stream_cb, hash_data);
612 if (hash_data->buffer == NULL)
613 hash_data->buffer = g_malloc0 (BUFFER_SIZE);
615 g_input_stream_read_async (hash_data->stream, hash_data->buffer,
616 BUFFER_SIZE, G_PRIORITY_DEFAULT, priv->cancellable,
617 hash_job_async_read_cb, hash_data);
622 ft_handler_read_async_cb (GObject *source,
626 GFileInputStream *stream;
627 GError *error = NULL;
628 HashingData *hash_data;
630 EmpathyFTHandler *handler = user_data;
631 EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
633 DEBUG ("FT: GFile read async CB.");
635 stream = g_file_read_finish (priv->gfile, res, &error);
638 g_signal_emit (handler, signals[TRANSFER_ERROR], 0, error);
639 g_clear_error (&error);
644 hash_data = g_slice_new0 (HashingData);
645 hash_data->stream = G_INPUT_STREAM (stream);
646 hash_data->done_reading = FALSE;
647 hash_data->total_bytes = priv->total_bytes;
648 hash_data->handler = g_object_ref (handler);
649 /* FIXME: should look at the CM capabilities before setting the
652 hash_data->checksum = g_checksum_new (G_CHECKSUM_MD5);
654 /* org.freedesktop.Telepathy.Channel.Type.FileTransfer.ContentHashType */
655 value = tp_g_value_slice_new (G_TYPE_UINT);
656 g_value_set_uint (value, EMP_FILE_HASH_TYPE_MD5);
657 g_hash_table_insert (priv->request,
658 EMP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".ContentHashType", value);
660 g_signal_emit (handler, signals[HASHING_STARTED], 0);
662 schedule_hash_chunk (hash_data);
666 ft_handler_complete_request (EmpathyFTHandler *handler)
668 EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
669 GError *myerr = NULL;
671 /* check if FT is allowed before firing up the I/O machinery */
672 if (!ft_handler_check_if_allowed (handler))
674 g_set_error_literal (&myerr, EMPATHY_FT_ERROR_QUARK,
675 EMPATHY_FT_ERROR_NOT_SUPPORTED,
676 _("File transfer not supported by remote contact"));
678 g_signal_emit (handler, signals[TRANSFER_ERROR], 0, myerr);
679 g_clear_error (&myerr);
684 /* populate the request table with all the known properties */
685 ft_handler_populate_outgoing_request (handler);
687 /* now start hashing the file */
688 g_file_read_async (priv->gfile, G_PRIORITY_DEFAULT,
689 priv->cancellable, ft_handler_read_async_cb, handler);
693 callbacks_data_free (gpointer user_data)
695 CallbacksData *data = user_data;
698 g_object_unref (data->handler);
700 g_slice_free (CallbacksData, data);
704 ft_handler_gfile_ready_cb (GObject *source,
706 CallbacksData *cb_data)
709 GError *error = NULL;
711 EmpathyFTHandlerPriv *priv = GET_PRIV (cb_data->handler);
713 DEBUG ("FT: got GFileInfo.");
715 info = g_file_query_info_finish (priv->gfile, res, &error);
720 priv->content_type = g_strdup (g_file_info_get_content_type (info));
721 priv->filename = g_strdup (g_file_info_get_display_name (info));
722 priv->total_bytes = g_file_info_get_size (info);
723 g_file_info_get_modification_time (info, &mtime);
724 priv->mtime = mtime.tv_sec;
725 priv->transferred_bytes = 0;
726 priv->description = NULL;
728 g_object_unref (info);
733 cb_data->callback (cb_data->handler, NULL, cb_data->user_data);
737 cb_data->callback (NULL, error, cb_data->user_data);
738 g_error_free (error);
739 g_object_unref (cb_data->handler);
742 callbacks_data_free (cb_data);
746 ft_handler_contact_ready_cb (EmpathyContact *contact,
749 GObject *weak_object)
751 CallbacksData *cb_data = user_data;
752 EmpathyFTHandlerPriv *priv = GET_PRIV (weak_object);
754 g_assert (priv->contact != NULL);
755 g_assert (priv->gfile != NULL);
757 DEBUG ("FT: contact is ready.");
759 /* start collecting info about the file */
760 g_file_query_info_async (priv->gfile,
761 G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME ","
762 G_FILE_ATTRIBUTE_STANDARD_SIZE ","
763 G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
764 G_FILE_ATTRIBUTE_TIME_MODIFIED,
765 G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT,
766 NULL, (GAsyncReadyCallback) ft_handler_gfile_ready_cb,
771 channel_get_all_properties_cb (TpProxy *proxy,
772 GHashTable *properties,
775 GObject *weak_object)
777 CallbacksData *cb_data = user_data;
778 EmpathyFTHandler *handler = EMPATHY_FT_HANDLER (weak_object);
779 EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
780 EmpathyContactFactory *c_factory;
786 cb_data->callback (NULL, (GError *) error, cb_data->user_data);
787 g_object_unref (handler);
791 priv->total_bytes = g_value_get_uint64 (
792 g_hash_table_lookup (properties, "Size"));
794 priv->transferred_bytes = g_value_get_uint64 (
795 g_hash_table_lookup (properties, "TransferredBytes"));
797 priv->filename = g_value_dup_string (
798 g_hash_table_lookup (properties, "Filename"));
800 priv->content_hash = g_value_dup_string (
801 g_hash_table_lookup (properties, "ContentHash"));
803 priv->content_hash_type = g_value_get_uint (
804 g_hash_table_lookup (properties, "ContentHashType"));
806 priv->content_type = g_value_dup_string (
807 g_hash_table_lookup (properties, "ContentType"));
809 priv->description = g_value_dup_string (
810 g_hash_table_lookup (properties, "Description"));
812 g_hash_table_destroy (properties);
814 c_factory = empathy_contact_factory_dup_singleton ();
815 account = empathy_channel_get_account (TP_CHANNEL (proxy));
816 c_handle = tp_channel_get_handle (TP_CHANNEL (proxy), NULL);
817 priv->contact = empathy_contact_factory_get_from_handle
818 (c_factory, account,c_handle);
820 g_object_unref (c_factory);
821 g_object_unref (account);
823 cb_data->callback (handler, NULL, cb_data->user_data);
829 empathy_ft_handler_new_outgoing (EmpathyContact *contact,
831 EmpathyFTHandlerReadyCallback callback,
834 EmpathyFTHandler *handler;
836 EmpathyFTHandlerPriv *priv;
838 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
839 g_return_if_fail (G_IS_FILE (source));
841 handler = g_object_new (EMPATHY_TYPE_FT_HANDLER,
842 "contact", contact, "gfile", source, NULL);
844 priv = GET_PRIV (handler);
846 data = g_slice_new0 (CallbacksData);
847 data->callback = callback;
848 data->user_data = user_data;
849 data->handler = g_object_ref (handler);
851 empathy_contact_call_when_ready (priv->contact,
852 EMPATHY_CONTACT_READY_HANDLE,
853 ft_handler_contact_ready_cb, data, NULL, G_OBJECT (handler));
857 empathy_ft_handler_new_incoming (EmpathyTpFile *tp_file,
859 EmpathyFTHandlerReadyCallback callback,
862 EmpathyFTHandler *handler;
866 g_return_if_fail (EMPATHY_IS_TP_FILE (tp_file));
867 g_return_if_fail (G_IS_FILE (destination));
869 handler = g_object_new (EMPATHY_TYPE_FT_HANDLER,
870 "tp-file", tp_file, "gfile", destination, NULL);
872 g_object_get (tp_file, "channel", &channel, NULL);
874 data = g_slice_new0 (CallbacksData);
875 data->callback = callback;
876 data->user_data = user_data;
877 data->handler = g_object_ref (handler);
879 tp_cli_dbus_properties_call_get_all (channel,
880 -1, EMP_IFACE_CHANNEL_TYPE_FILE_TRANSFER,
881 channel_get_all_properties_cb, data, callbacks_data_free, G_OBJECT (handler));
885 empathy_ft_handler_start_transfer (EmpathyFTHandler *handler,
886 GCancellable *cancellable)
888 EmpathyFTHandlerPriv *priv;
890 g_return_if_fail (EMPATHY_IS_FT_HANDLER (handler));
892 priv = GET_PRIV (handler);
893 priv->cancellable = g_object_ref (cancellable);
895 if (priv->tpfile == NULL)
897 ft_handler_complete_request (handler);
901 /* emit the start signal now, so that we can catch errors in the
904 g_signal_emit (handler, signals[TRANSFER_STARTED], 0, priv->tpfile);
906 /* TODO: add support for resume. */
907 empathy_tp_file_accept (priv->tpfile, 0, priv->gfile, priv->cancellable,
908 ft_transfer_progress_callback, handler,
909 ft_transfer_operation_callback, handler);