1 /* 2 * ft-channel.h - Header for GabbleFileTransferChannel 3 * Copyright (C) 2009 Collabora Ltd. 4 * @author: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> 5 * 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. 10 * 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. 15 * 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 19 */ 20 21 #ifndef __GABBLE_FILE_TRANSFER_CHANNEL_H__ 22 #define __GABBLE_FILE_TRANSFER_CHANNEL_H__ 23 24 #include "config.h" 25 26 #include <glib-object.h> 27 #include <extensions/extensions.h> 28 29 #include <telepathy-glib/telepathy-glib.h> 30 31 typedef struct _GabbleFileTransferChannel GabbleFileTransferChannel; 32 33 #ifdef ENABLE_JINGLE_FILE_TRANSFER 34 #include "gtalk-file-collection.h" 35 #endif 36 37 #include "bytestream-factory.h" 38 39 G_BEGIN_DECLS 40 41 typedef struct _GabbleFileTransferChannelClass GabbleFileTransferChannelClass; 42 typedef struct _GabbleFileTransferChannelPrivate GabbleFileTransferChannelPrivate; 43 44 struct _GabbleFileTransferChannelClass { 45 TpBaseChannelClass parent_class; 46 TpDBusPropertiesMixinClass dbus_props_class; 47 }; 48 49 struct _GabbleFileTransferChannel { 50 TpBaseChannel parent; 51 52 GabbleFileTransferChannelPrivate *priv; 53 }; 54 55 GType gabble_file_transfer_channel_get_type (void); 56 57 /* TYPE MACROS */ 58 #define GABBLE_TYPE_FILE_TRANSFER_CHANNEL \ 59 (gabble_file_transfer_channel_get_type ()) 60 #define GABBLE_FILE_TRANSFER_CHANNEL(obj) \ 61 (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_FILE_TRANSFER_CHANNEL, GabbleFileTransferChannel)) 62 #define GABBLE_FILE_TRANSFER_CHANNEL_CLASS(klass) \ 63 (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_FILE_TRANSFER_CHANNEL, \ 64 GabbleFileTransferChannelClass)) 65 #define GABBLE_IS_FILE_TRANSFER_CHANNEL(obj) \ 66 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_FILE_TRANSFER_CHANNEL)) 67 #define GABBLE_IS_FILE_TRANSFER_CHANNEL_CLASS(klass) \ 68 (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_FILE_TRANSFER_CHANNEL)) 69 #define GABBLE_FILE_TRANSFER_CHANNEL_GET_CLASS(obj) \ 70 (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_FILE_TRANSFER_CHANNEL, \ 71 GabbleFileTransferChannelClass)) 72 73 GabbleFileTransferChannel * 74 gabble_file_transfer_channel_new (GabbleConnection *conn, 75 TpHandle handle, TpHandle initiator_handle, TpFileTransferState state, 76 const gchar *content_type, const gchar *filename, guint64 size, 77 TpFileHashType content_hash_type, const gchar *content_hash, 78 const gchar *description, guint64 date, guint64 initial_offset, 79 gboolean resume_supported, GabbleBytestreamIface *bytestream, 80 #ifdef ENABLE_JINGLE_FILE_TRANSFER 81 GTalkFileCollection *gtalk_fc, 82 #else 83 /* It's easier for the calling code if we don't change the number of 84 * arguments based on a #ifdef */ 85 gpointer gtalk_fc_dummy, 86 #endif 87 const gchar *file_collection, const gchar *uri, const gchar *service_name, 88 const GHashTable *metadata); 89 90 gboolean gabble_file_transfer_channel_offer_file ( 91 GabbleFileTransferChannel *self, GError **error); 92 93 #ifdef ENABLE_JINGLE_FILE_TRANSFER 94 /* The following methods are a hack, they are 'signal-like' callbacks for the 95 GTalkFileCollection. They have to be made this way because the FileCollection 96 can't send out signals since it needs its signals to be sent to a specific 97 channel only. So instead it calls these callbacks directly on the channel it 98 needs to notify. This is a known layering violation and accepted as the lesser 99 of any other evil [hack]. */ 100 void gabble_file_transfer_channel_gtalk_file_collection_state_changed ( 101 GabbleFileTransferChannel *self, GTalkFileCollectionState gtalk_fc_state, 102 gboolean local_terminator); 103 104 void gabble_file_transfer_channel_gtalk_file_collection_write_blocked ( 105 GabbleFileTransferChannel *self, gboolean blocked); 106 107 void gabble_file_transfer_channel_gtalk_file_collection_data_received ( 108 GabbleFileTransferChannel *self, const gchar *data, guint len); 109 #endif 110 111 G_END_DECLS 112 113 #endif /* #ifndef __GABBLE_FILE_TRANSFER_CHANNEL_H__*/ 114