[telepathy-gabble/master] add 'resume-supported' property to FT channel
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Apr 17 06:37:05 PDT 2009
---
src/ft-channel.c | 21 ++++++++++++++++++++-
src/ft-channel.h | 2 +-
src/ft-manager.c | 8 +++++---
3 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/src/ft-channel.c b/src/ft-channel.c
index 1ac7f0d..331168c 100644
--- a/src/ft-channel.c
+++ b/src/ft-channel.c
@@ -103,6 +103,7 @@ enum
PROP_AVAILABLE_SOCKET_TYPES,
PROP_TRANSFERRED_BYTES,
PROP_INITIAL_OFFSET,
+ PROP_RESUME_SUPPORTED,
PROP_CONNECTION,
PROP_BYTESTREAM,
@@ -122,6 +123,7 @@ struct _GabbleFileTransferChannelPrivate {
GValue *socket_address;
TpHandle initiator;
gboolean remote_accepted;
+ gboolean resume_supported;
GabbleBytestreamIface *bytestream;
GibberListener *listener;
@@ -262,6 +264,9 @@ gabble_file_transfer_channel_get_property (GObject *object,
case PROP_CHANNEL_DESTROYED:
g_value_set_boolean (value, self->priv->closed);
break;
+ case PROP_RESUME_SUPPORTED:
+ g_value_set_boolean (value, self->priv->resume_supported);
+ break;
case PROP_CHANNEL_PROPERTIES:
g_value_take_boxed (value,
tp_dbus_properties_mixin_make_properties_hash (object,
@@ -365,6 +370,9 @@ gabble_file_transfer_channel_set_property (GObject *object,
set_bytestream (self,
GABBLE_BYTESTREAM_IFACE (g_value_get_object (value)));
break;
+ case PROP_RESUME_SUPPORTED:
+ self->priv->resume_supported = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -729,6 +737,15 @@ gabble_file_transfer_channel_class_init (
g_object_class_install_property (object_class, PROP_BYTESTREAM,
param_spec);
+ param_spec = g_param_spec_boolean (
+ "resume-supported",
+ "resume is supported",
+ "TRUE if resume is supported on this file transfer channel",
+ FALSE,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_RESUME_SUPPORTED,
+ param_spec);
+
gabble_file_transfer_channel_class->dbus_props_class.interfaces =
prop_interfaces;
tp_dbus_properties_mixin_class_init (object_class,
@@ -1753,7 +1770,8 @@ gabble_file_transfer_channel_new (GabbleConnection *conn,
const gchar *description,
guint64 date,
guint64 initial_offset,
- GabbleBytestreamIface *bytestream)
+ GabbleBytestreamIface *bytestream,
+ gboolean resume_supported)
{
return g_object_new (GABBLE_TYPE_FILE_TRANSFER_CHANNEL,
@@ -1770,5 +1788,6 @@ gabble_file_transfer_channel_new (GabbleConnection *conn,
"date", date,
"initial-offset", initial_offset,
"bytestream", bytestream,
+ "resume-supported", resume_supported,
NULL);
}
diff --git a/src/ft-channel.h b/src/ft-channel.h
index 4442673..2bd339d 100644
--- a/src/ft-channel.h
+++ b/src/ft-channel.h
@@ -68,7 +68,7 @@ gabble_file_transfer_channel_new (GabbleConnection *conn,
const gchar *content_type, const gchar *filename, guint64 size,
TpFileHashType content_hash_type, const gchar *content_hash,
const gchar *description, guint64 date, guint64 initial_offset,
- GabbleBytestreamIface *bytestream);
+ GabbleBytestreamIface *bytestream, gboolean resume_supported);
gboolean gabble_file_transfer_channel_offer_file (
GabbleFileTransferChannel *self, GError **error);
diff --git a/src/ft-manager.c b/src/ft-manager.c
index 327b360..bc83939 100644
--- a/src/ft-manager.c
+++ b/src/ft-manager.c
@@ -393,7 +393,7 @@ gabble_ft_manager_handle_request (TpChannelManager *manager,
chan = gabble_file_transfer_channel_new (self->priv->connection,
handle, base_connection->self_handle, TP_FILE_TRANSFER_STATE_PENDING,
content_type, filename, size, content_hash_type, content_hash,
- description, date, initial_offset, NULL);
+ description, date, initial_offset, NULL, TRUE);
if (!gabble_file_transfer_channel_offer_file (chan, &error))
{
@@ -479,6 +479,7 @@ void gabble_ft_manager_handle_si_request (GabbleFtManager *self,
guint64 date = 0;
TpFileHashType content_hash_type;
GabbleFileTransferChannel *chan;
+ gboolean resume_supported;
si_node = lm_message_node_get_child_with_namespace (msg->node, "si", NS_SI);
g_assert (si_node != NULL);
@@ -545,11 +546,12 @@ void gabble_ft_manager_handle_si_request (GabbleFtManager *self,
date = (guint64) mktime (&tm);
}
- /* TODO: initial offset */
+ resume_supported = (lm_message_node_get_child (file_node, "range") != NULL);
+
chan = gabble_file_transfer_channel_new (self->priv->connection,
handle, handle, TP_FILE_TRANSFER_STATE_PENDING,
content_type, filename, size, content_hash_type, content_hash,
- description, date, 0, bytestream);
+ description, date, 0, bytestream, resume_supported);
gabble_ft_manager_channel_created (self, chan, NULL);
}
--
1.5.6.5
More information about the telepathy-commits
mailing list