1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2007-2008 Collabora Ltd.
4 * Copyright (C) 2007 Marco Barisione <marco@barisione.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * Authors: Marco Barisione <marco@barisione.org>
21 * Jonny Lamb <jonny.lamb@collabora.co.uk>
28 #include <sys/types.h>
29 #include <sys/socket.h>
32 #include <glib/gi18n.h>
35 #include <gio/gunixinputstream.h>
36 #include <gio/gunixoutputstream.h>
38 #include <telepathy-glib/proxy-subclass.h>
40 #include "empathy-tp-file.h"
41 #include "empathy-contact-factory.h"
42 #include "empathy-marshal.h"
43 #include "empathy-time.h"
44 #include "empathy-utils.h"
46 #define DEBUG_FLAG EMPATHY_DEBUG_FT
47 #include "empathy-debug.h"
50 * SECTION:empathy-tp-file
51 * @short_description: File channel
52 * @see_also: #EmpathyTpFile, #EmpathyContact, empathy_dispatcher_send_file()
53 * @include: libempthy/empathy-tp-file.h
55 * The #EmpathyTpFile object represents a Telepathy file channel.
59 * EMPATHY_TP_FILE_UNKNOWN_SIZE:
61 * Value used for the "size" or "estimated-size" properties when the size of
62 * the transferred file is unknown.
65 /* Functions to copy the content of a GInputStream to a GOutputStream */
68 #define BUFFER_SIZE 4096
73 GCancellable *cancellable;
74 char *buff[N_BUFFERS]; /* the temporary buffers */
75 gsize count[N_BUFFERS]; /* how many bytes are used in the buffers */
76 gboolean is_full[N_BUFFERS]; /* whether the buffers contain data */
77 gint curr_read; /* index of the buffer used for reading */
78 gint curr_write; /* index of the buffer used for writing */
79 gboolean is_reading; /* we are reading */
80 gboolean is_writing; /* we are writing */
81 guint n_closed; /* number of streams that have been closed */
85 static void schedule_next (CopyData *copy);
88 copy_data_unref (CopyData *copy)
90 if (--copy->ref_count == 0)
94 /* Free the data only if both the input and output streams have
97 if (copy->n_closed < 2)
100 if (copy->in != NULL)
101 g_object_unref (copy->in);
103 if (copy->out != NULL)
104 g_object_unref (copy->out);
106 for (i = 0; i < N_BUFFERS; i++)
107 g_free (copy->buff[i]);
109 g_object_unref (copy->cancellable);
115 io_error (CopyData *copy,
118 g_cancellable_cancel (copy->cancellable);
121 g_warning ("I/O error");
122 else if (error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED)
123 ; /* Ignore cancellations */
125 g_warning ("I/O error: %d: %s\n", error->code, error->message);
127 if (copy->in != NULL)
128 g_input_stream_close (copy->in, NULL, NULL);
130 if (copy->out != NULL)
131 g_output_stream_close (copy->out, NULL, NULL);
133 copy_data_unref (copy);
137 close_done (GObject *source_object,
141 CopyData *copy = user_data;
143 g_object_unref (source_object);
144 copy_data_unref (copy);
148 write_done_cb (GObject *source_object,
152 CopyData *copy = user_data;
154 GError *error = NULL;
156 count_write = g_output_stream_write_finish (copy->out, res, &error);
158 if (count_write <= 0)
160 io_error (copy, error);
161 g_error_free (error);
165 copy->is_full[copy->curr_write] = FALSE;
166 copy->curr_write = (copy->curr_write + 1) % N_BUFFERS;
167 copy->is_writing = FALSE;
169 schedule_next (copy);
173 read_done_cb (GObject *source_object,
177 CopyData *copy = user_data;
179 GError *error = NULL;
181 count_read = g_input_stream_read_finish (copy->in, res, &error);
185 g_input_stream_close_async (copy->in, 0, copy->cancellable,
189 else if (count_read < 0)
191 io_error (copy, error);
192 g_error_free (error);
196 copy->count[copy->curr_read] = count_read;
197 copy->is_full[copy->curr_read] = TRUE;
198 copy->curr_read = (copy->curr_read + 1) % N_BUFFERS;
199 copy->is_reading = FALSE;
201 schedule_next (copy);
205 schedule_next (CopyData *copy)
207 if (copy->in != NULL &&
209 !copy->is_full[copy->curr_read])
211 /* We are not reading and the current buffer is empty, so
212 * start an async read. */
213 copy->is_reading = TRUE;
214 g_input_stream_read_async (copy->in,
215 copy->buff[copy->curr_read],
216 BUFFER_SIZE, 0, copy->cancellable,
220 if (!copy->is_writing &&
221 copy->is_full[copy->curr_write])
223 if (copy->count[copy->curr_write] == 0)
225 /* The last read on the buffer read 0 bytes, this
226 * means that we got an EOF, so we can close
227 * the output channel. */
228 g_output_stream_close_async (copy->out, 0,
235 /* We are not writing and the current buffer contains
236 * data, so start an async write. */
237 copy->is_writing = TRUE;
238 g_output_stream_write_async (copy->out,
239 copy->buff[copy->curr_write],
240 copy->count[copy->curr_write],
241 0, copy->cancellable,
242 write_done_cb, copy);
248 copy_stream (GInputStream *in,
250 GCancellable *cancellable)
255 g_return_if_fail (in != NULL);
256 g_return_if_fail (out != NULL);
258 copy = g_new0 (CopyData, 1);
259 copy->in = g_object_ref (in);
260 copy->out = g_object_ref (out);
263 if (cancellable != NULL)
264 copy->cancellable = g_object_ref (cancellable);
266 copy->cancellable = g_cancellable_new ();
268 for (i = 0; i < N_BUFFERS; i++)
269 copy->buff[i] = g_malloc (BUFFER_SIZE);
271 schedule_next (copy);
274 /* EmpathyTpFile object */
276 struct _EmpathyTpFilePriv {
277 EmpathyContactFactory *factory;
281 EmpathyContact *contact;
282 GInputStream *in_stream;
283 GOutputStream *out_stream;
285 /* org.freedesktop.Telepathy.Channel.Type.FileTransfer D-Bus properties */
286 EmpFileTransferState state;
290 EmpFileHashType content_hash_type;
293 guint64 transferred_bytes;
296 EmpFileTransferStateChangeReason state_change_reason;
298 gchar *unix_socket_path;
299 GCancellable *cancellable;
310 PROP_TRANSFERRED_BYTES,
311 PROP_CONTENT_HASH_TYPE,
315 G_DEFINE_TYPE (EmpathyTpFile, empathy_tp_file, G_TYPE_OBJECT);
318 empathy_tp_file_init (EmpathyTpFile *tp_file)
320 EmpathyTpFilePriv *priv;
322 priv = G_TYPE_INSTANCE_GET_PRIVATE ((tp_file),
323 EMPATHY_TYPE_TP_FILE, EmpathyTpFilePriv);
325 tp_file->priv = priv;
329 tp_file_invalidated_cb (TpProxy *proxy,
333 EmpathyTpFile *tp_file)
335 DEBUG ("Channel invalidated: %s", message);
337 if (tp_file->priv->state != EMP_FILE_TRANSFER_STATE_COMPLETED &&
338 tp_file->priv->state != EMP_FILE_TRANSFER_STATE_CANCELLED)
340 /* The channel is not in a finished state, an error occured */
341 tp_file->priv->state = EMP_FILE_TRANSFER_STATE_CANCELLED;
342 tp_file->priv->state_change_reason =
343 EMP_FILE_TRANSFER_STATE_CHANGE_REASON_LOCAL_ERROR;
344 g_object_notify (G_OBJECT (tp_file), "state");
349 tp_file_finalize (GObject *object)
351 EmpathyTpFile *tp_file;
353 tp_file = EMPATHY_TP_FILE (object);
355 if (tp_file->priv->channel)
357 DEBUG ("Closing channel..");
358 g_signal_handlers_disconnect_by_func (tp_file->priv->channel,
359 tp_file_invalidated_cb, object);
360 tp_cli_channel_call_close (tp_file->priv->channel, -1, NULL, NULL,
362 g_object_unref (tp_file->priv->channel);
365 if (tp_file->priv->factory)
367 g_object_unref (tp_file->priv->factory);
369 if (tp_file->priv->mc)
371 g_object_unref (tp_file->priv->mc);
374 g_free (tp_file->priv->filename);
375 g_free (tp_file->priv->unix_socket_path);
376 g_free (tp_file->priv->description);
377 g_free (tp_file->priv->content_hash);
378 g_free (tp_file->priv->content_type);
380 if (tp_file->priv->in_stream)
381 g_object_unref (tp_file->priv->in_stream);
383 if (tp_file->priv->out_stream)
384 g_object_unref (tp_file->priv->out_stream);
386 if (tp_file->priv->contact)
387 g_object_unref (tp_file->priv->contact);
389 if (tp_file->priv->cancellable)
390 g_object_unref (tp_file->priv->cancellable);
392 G_OBJECT_CLASS (empathy_tp_file_parent_class)->finalize (object);
396 tp_file_start_transfer (EmpathyTpFile *tp_file)
400 struct sockaddr_un addr;
402 fd = socket (PF_UNIX, SOCK_STREAM, 0);
405 DEBUG ("Failed to create socket, closing channel");
406 empathy_tp_file_cancel (tp_file);
410 memset (&addr, 0, sizeof (addr));
411 addr.sun_family = AF_UNIX;
412 path_len = strlen (tp_file->priv->unix_socket_path);
413 strncpy (addr.sun_path, tp_file->priv->unix_socket_path, path_len);
415 if (connect (fd, (struct sockaddr*) &addr, sizeof (addr)) < 0)
417 DEBUG ("Failed to connect socket, closing channel");
418 empathy_tp_file_cancel (tp_file);
423 DEBUG ("Start the transfer");
425 tp_file->priv->start_time = empathy_time_get_current ();
426 tp_file->priv->cancellable = g_cancellable_new ();
427 if (tp_file->priv->incoming)
429 GOutputStream *socket_stream;
431 socket_stream = g_unix_output_stream_new (fd, TRUE);
432 copy_stream (tp_file->priv->in_stream, socket_stream,
433 tp_file->priv->cancellable);
434 g_object_unref (socket_stream);
438 GInputStream *socket_stream;
440 socket_stream = g_unix_input_stream_new (fd, TRUE);
441 copy_stream (socket_stream, tp_file->priv->out_stream,
442 tp_file->priv->cancellable);
443 g_object_unref (socket_stream);
448 tp_file_state_changed_cb (DBusGProxy *tp_file_iface,
449 EmpFileTransferState state,
450 EmpFileTransferStateChangeReason reason,
451 EmpathyTpFile *tp_file)
453 DEBUG ("File transfer state changed:\n"
454 "\tfilename = %s, old state = %u, state = %u, reason = %u\n"
455 "\tincoming = %s, in_stream = %s, out_stream = %s",
456 tp_file->priv->filename, tp_file->priv->state, state, reason,
457 tp_file->priv->incoming ? "yes" : "no",
458 tp_file->priv->in_stream ? "present" : "not present",
459 tp_file->priv->out_stream ? "present" : "not present");
461 if (state == EMP_FILE_TRANSFER_STATE_OPEN)
462 tp_file_start_transfer (tp_file);
464 tp_file->priv->state = state;
465 tp_file->priv->state_change_reason = reason;
467 g_object_notify (G_OBJECT (tp_file), "state");
471 tp_file_transferred_bytes_changed_cb (TpProxy *proxy,
473 EmpathyTpFile *tp_file,
474 GObject *weak_object)
476 if (tp_file->priv->transferred_bytes == count)
479 tp_file->priv->transferred_bytes = count;
481 g_object_notify (G_OBJECT (tp_file), "transferred-bytes");
485 tp_file_constructor (GType type,
487 GObjectConstructParam *props)
490 EmpathyTpFile *tp_file;
492 GHashTable *properties;
496 file_obj = G_OBJECT_CLASS (empathy_tp_file_parent_class)->constructor (type,
499 tp_file = EMPATHY_TP_FILE (file_obj);
501 tp_file->priv->factory = empathy_contact_factory_new ();
502 tp_file->priv->mc = empathy_mission_control_new ();
504 g_signal_connect (tp_file->priv->channel, "invalidated",
505 G_CALLBACK (tp_file_invalidated_cb), tp_file);
507 emp_cli_channel_type_file_transfer_connect_to_file_transfer_state_changed (
508 TP_PROXY (tp_file->priv->channel),
509 (emp_cli_channel_type_file_transfer_signal_callback_file_transfer_state_changed)
510 tp_file_state_changed_cb,
514 emp_cli_channel_type_file_transfer_connect_to_transferred_bytes_changed (
515 TP_PROXY (tp_file->priv->channel),
516 (emp_cli_channel_type_file_transfer_signal_callback_transferred_bytes_changed)
517 tp_file_transferred_bytes_changed_cb,
521 account = empathy_channel_get_account (tp_file->priv->channel);
523 handle = tp_channel_get_handle (tp_file->priv->channel, NULL);
524 tp_file->priv->contact = empathy_contact_factory_get_from_handle (
525 tp_file->priv->factory, account, (guint) handle);
527 tp_cli_dbus_properties_run_get_all (tp_file->priv->channel,
528 -1, EMP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, &properties, NULL, NULL);
530 tp_cli_dbus_properties_run_get (tp_file->priv->channel,
531 -1, TP_IFACE_CHANNEL, "Requested", &requested, NULL, NULL);
533 tp_file->priv->size = g_value_get_uint64 (
534 g_hash_table_lookup (properties, "Size"));
536 tp_file->priv->state = g_value_get_uint (
537 g_hash_table_lookup (properties, "State"));
539 tp_file->priv->state_change_reason =
540 EMP_FILE_TRANSFER_STATE_CHANGE_REASON_NONE;
542 tp_file->priv->transferred_bytes = g_value_get_uint64 (
543 g_hash_table_lookup (properties, "TransferredBytes"));
545 tp_file->priv->filename = g_value_dup_string (
546 g_hash_table_lookup (properties, "Filename"));
548 tp_file->priv->content_hash = g_value_dup_string (
549 g_hash_table_lookup (properties, "ContentHash"));
551 tp_file->priv->content_hash_type = g_value_get_uint (
552 g_hash_table_lookup (properties, "ContentHashType"));
554 tp_file->priv->content_type = g_value_dup_string (
555 g_hash_table_lookup (properties, "ContentType"));
557 tp_file->priv->description = g_value_dup_string (
558 g_hash_table_lookup (properties, "Description"));
560 tp_file->priv->incoming = !g_value_get_boolean (requested);
562 g_hash_table_destroy (properties);
563 g_object_unref (account);
564 g_value_unset (requested);
570 tp_file_get_property (GObject *object,
575 EmpathyTpFile *tp_file;
577 tp_file = EMPATHY_TP_FILE (object);
582 g_value_set_object (value, tp_file->priv->channel);
585 g_value_set_boolean (value, tp_file->priv->incoming);
588 g_value_set_uint (value, tp_file->priv->state);
590 case PROP_CONTENT_TYPE:
591 g_value_set_string (value, tp_file->priv->content_type);
594 g_value_set_string (value, tp_file->priv->filename);
597 g_value_set_uint64 (value, tp_file->priv->size);
599 case PROP_CONTENT_HASH_TYPE:
600 g_value_set_uint (value, tp_file->priv->content_hash_type);
602 case PROP_CONTENT_HASH:
603 g_value_set_string (value, tp_file->priv->content_hash);
605 case PROP_TRANSFERRED_BYTES:
606 g_value_set_uint64 (value, tp_file->priv->transferred_bytes);
609 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
615 tp_file_channel_set_dbus_property (gpointer proxy,
616 const gchar *property,
619 DEBUG ("Setting %s property", property);
620 tp_cli_dbus_properties_call_set (TP_PROXY (proxy), -1,
621 EMP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, property, value,
622 NULL, NULL, NULL, NULL);
626 tp_file_set_property (GObject *object,
631 EmpathyTpFile *tp_file = (EmpathyTpFile *) object;
635 tp_file->priv->channel = g_object_ref (g_value_get_object (value));
638 tp_file->priv->state = g_value_get_uint (value);
641 tp_file->priv->incoming = g_value_get_boolean (value);
644 g_free (tp_file->priv->filename);
645 tp_file->priv->filename = g_value_dup_string (value);
646 tp_file_channel_set_dbus_property (tp_file->priv->channel,
650 tp_file->priv->size = g_value_get_uint64 (value);
651 tp_file_channel_set_dbus_property (tp_file->priv->channel,
654 case PROP_CONTENT_TYPE:
655 tp_file_channel_set_dbus_property (tp_file->priv->channel,
656 "ContentType", value);
657 g_free (tp_file->priv->content_type);
658 tp_file->priv->content_type = g_value_dup_string (value);
660 case PROP_CONTENT_HASH:
661 tp_file_channel_set_dbus_property (tp_file->priv->channel,
662 "ContentHash", value);
663 g_free (tp_file->priv->content_hash);
664 tp_file->priv->content_hash = g_value_dup_string (value);
667 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
673 * empathy_tp_file_new:
674 * @channel: a Telepathy channel
676 * Creates a new #EmpathyTpFile wrapping @channel.
678 * Returns: a new #EmpathyTpFile
681 empathy_tp_file_new (TpChannel *channel)
683 g_return_val_if_fail (TP_IS_CHANNEL (channel), NULL);
685 return g_object_new (EMPATHY_TYPE_TP_FILE,
691 * empathy_tp_file_get_channel
692 * @tp_file: an #EmpathyTpFile
694 * Returns the Telepathy file transfer channel
696 * Returns: the #TpChannel
699 empathy_tp_file_get_channel (EmpathyTpFile *tp_file)
701 g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file), NULL);
703 return tp_file->priv->channel;
707 tp_file_method_cb (TpProxy *proxy,
708 const GValue *address,
711 GObject *weak_object)
713 EmpathyTpFile *tp_file = (EmpathyTpFile *) weak_object;
717 DEBUG ("Error: %s", error->message);
718 empathy_tp_file_cancel (tp_file);
722 tp_file->priv->unix_socket_path = g_value_dup_string (address);
724 DEBUG ("Got unix socket path: %s", tp_file->priv->unix_socket_path);
729 * empathy_tp_file_accept:
730 * @tp_file: an #EmpathyTpFile
731 * @offset: position where to start the transfer
732 * @gfile: a #GFile where to write transfered data
733 * @error: a #GError set if there is an error when opening @gfile
735 * Accepts a file transfer that's in the "local pending" state (i.e.
736 * EMP_FILE_TRANSFER_STATE_LOCAL_PENDING).
739 empathy_tp_file_accept (EmpathyTpFile *tp_file,
744 GValue nothing = { 0 };
746 g_return_if_fail (EMPATHY_IS_TP_FILE (tp_file));
747 g_return_if_fail (G_IS_FILE (gfile));
749 tp_file->priv->out_stream = G_OUTPUT_STREAM (g_file_replace (gfile, NULL,
750 FALSE, 0, NULL, error));
754 tp_file->priv->filename = g_file_get_basename (gfile);
755 g_object_notify (G_OBJECT (tp_file), "filename");
757 DEBUG ("Accepting file: filename=%s", tp_file->priv->filename);
759 g_value_init (¬hing, G_TYPE_STRING);
760 g_value_set_static_string (¬hing, "");
762 emp_cli_channel_type_file_transfer_call_accept_file (TP_PROXY (
763 tp_file->priv->channel),
764 -1, TP_SOCKET_ADDRESS_TYPE_UNIX, TP_SOCKET_ACCESS_CONTROL_LOCALHOST,
765 ¬hing, offset, tp_file_method_cb, NULL, NULL, G_OBJECT (tp_file));
769 * empathy_tp_file_offer:
770 * @tp_file: an #EmpathyTpFile
771 * @gfile: a #GFile where to read the data to transfer
772 * @error: a #GError set if there is an error when opening @gfile
774 * Offers a file transfer that's in the "not offered" state (i.e.
775 * EMP_FILE_TRANSFER_STATE_NOT_OFFERED).
778 empathy_tp_file_offer (EmpathyTpFile *tp_file, GFile *gfile, GError **error)
780 GValue nothing = { 0 };
782 g_return_if_fail (EMPATHY_IS_TP_FILE (tp_file));
784 tp_file->priv->in_stream = G_INPUT_STREAM (g_file_read (gfile, NULL, error));
788 g_value_init (¬hing, G_TYPE_STRING);
789 g_value_set_static_string (¬hing, "");
791 emp_cli_channel_type_file_transfer_call_provide_file (
792 TP_PROXY (tp_file->priv->channel), -1,
793 TP_SOCKET_ADDRESS_TYPE_UNIX, TP_SOCKET_ACCESS_CONTROL_LOCALHOST,
794 ¬hing, tp_file_method_cb, NULL, NULL, G_OBJECT (tp_file));
798 empathy_tp_file_get_contact (EmpathyTpFile *tp_file)
800 g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file), NULL);
801 return tp_file->priv->contact;
805 empathy_tp_file_get_filename (EmpathyTpFile *tp_file)
807 g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file), NULL);
808 return tp_file->priv->filename;
812 empathy_tp_file_is_incoming (EmpathyTpFile *tp_file)
814 g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file), FALSE);
815 return tp_file->priv->incoming;
819 empathy_tp_file_get_state (EmpathyTpFile *tp_file,
820 EmpFileTransferStateChangeReason *reason)
822 g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file),
823 EMP_FILE_TRANSFER_STATE_NONE);
826 *reason = tp_file->priv->state_change_reason;
828 return tp_file->priv->state;
832 empathy_tp_file_get_size (EmpathyTpFile *tp_file)
834 g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file),
835 EMPATHY_TP_FILE_UNKNOWN_SIZE);
836 return tp_file->priv->size;
840 empathy_tp_file_get_transferred_bytes (EmpathyTpFile *tp_file)
842 g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file), 0);
843 return tp_file->priv->transferred_bytes;
847 empathy_tp_file_get_remaining_time (EmpathyTpFile *tp_file)
849 time_t curr_time, elapsed_time;
850 gdouble time_per_byte;
851 gdouble remaining_time;
853 g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file), -1);
855 if (tp_file->priv->size == EMPATHY_TP_FILE_UNKNOWN_SIZE)
858 if (tp_file->priv->transferred_bytes == tp_file->priv->size)
861 curr_time = empathy_time_get_current ();
862 elapsed_time = curr_time - tp_file->priv->start_time;
863 time_per_byte = (gdouble) elapsed_time /
864 (gdouble) tp_file->priv->transferred_bytes;
865 remaining_time = time_per_byte * (tp_file->priv->size -
866 tp_file->priv->transferred_bytes);
868 return (gint) remaining_time;
872 empathy_tp_file_cancel (EmpathyTpFile *tp_file)
874 g_return_if_fail (EMPATHY_IS_TP_FILE (tp_file));
876 tp_cli_channel_call_close (tp_file->priv->channel, -1, NULL, NULL, NULL, NULL);
878 if (tp_file->priv->cancellable != NULL)
879 g_cancellable_cancel (tp_file->priv->cancellable);
883 empathy_tp_file_class_init (EmpathyTpFileClass *klass)
885 GObjectClass *object_class = G_OBJECT_CLASS (klass);
887 object_class->finalize = tp_file_finalize;
888 object_class->constructor = tp_file_constructor;
889 object_class->get_property = tp_file_get_property;
890 object_class->set_property = tp_file_set_property;
892 /* Construct-only properties */
893 g_object_class_install_property (object_class,
895 g_param_spec_object ("channel",
897 "The file transfer channel",
900 G_PARAM_CONSTRUCT_ONLY));
902 g_object_class_install_property (object_class,
904 g_param_spec_uint ("state",
905 "state of the transfer",
906 "The file transfer state",
913 g_object_class_install_property (object_class,
915 g_param_spec_boolean ("incoming",
917 "Whether the transfer is incoming",
922 g_object_class_install_property (object_class,
924 g_param_spec_string ("filename",
925 "name of the transfer",
926 "The file transfer filename",
930 g_object_class_install_property (object_class,
932 g_param_spec_uint64 ("size",
934 "The file transfer size",
940 g_object_class_install_property (object_class,
942 g_param_spec_string ("content-type",
943 "file transfer content-type",
944 "The file transfer content-type",
948 g_object_class_install_property (object_class,
949 PROP_CONTENT_HASH_TYPE,
950 g_param_spec_uint ("content-hash-type",
951 "file transfer hash type",
952 "The type of the file transfer hash",
958 g_object_class_install_property (object_class,
960 g_param_spec_string ("content-hash",
961 "file transfer hash",
962 "The hash of the transfer's contents",
966 g_object_class_install_property (object_class,
967 PROP_TRANSFERRED_BYTES,
968 g_param_spec_uint64 ("transferred-bytes",
970 "The number of bytes transferred",
976 g_type_class_add_private (object_class, sizeof (EmpathyTpFilePriv));