telepathy-glib: add tp_account_channel_request_set_file_transfer_hash()

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Wed Feb 26 01:31:20 PST 2014


Module: telepathy-glib
Branch: master
Commit: 410e44a648eb3bd2eb5db31a39326b01ac953eac
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=410e44a648eb3bd2eb5db31a39326b01ac953eac

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Tue Feb 25 12:39:59 2014 +0100

add tp_account_channel_request_set_file_transfer_hash()

---

 docs/reference/telepathy-glib-sections.txt |    1 +
 telepathy-glib/account-channel-request.c   |   33 ++++++++++++++++++++++++++++
 telepathy-glib/account-channel-request.h   |    6 +++++
 tests/dbus/account-channel-request.c       |   10 ++++++++-
 4 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index c6ac9ff..be7287b 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -6289,6 +6289,7 @@ tp_account_channel_request_set_file_transfer_description
 tp_account_channel_request_set_file_transfer_initial_offset
 tp_account_channel_request_set_file_transfer_timestamp
 tp_account_channel_request_set_file_transfer_uri
+tp_account_channel_request_set_file_transfer_hash
 tp_account_channel_request_create_and_handle_channel_async
 tp_account_channel_request_create_and_handle_channel_finish
 tp_account_channel_request_ensure_and_handle_channel_async
diff --git a/telepathy-glib/account-channel-request.c b/telepathy-glib/account-channel-request.c
index 5269a39..a1000f9 100644
--- a/telepathy-glib/account-channel-request.c
+++ b/telepathy-glib/account-channel-request.c
@@ -2390,3 +2390,36 @@ tp_account_channel_request_set_file_transfer_initial_offset (
           tp_g_value_slice_new_uint64 (offset));
     }
 }
+
+/**
+ * tp_account_channel_request_set_file_transfer_hash:
+ * @self: a #TpAccountChannelRequest
+ * @hash_type: a type of @hash
+ * @hash: hash of the contents of the file transfer
+ *
+ * Configure this channel request to accompany the file transfer with
+ * the hash of the file.
+ *
+ * This function can't be called once @self has been used to request a
+ * channel.
+ *
+ * Since: UNRELEASED
+ */
+void
+tp_account_channel_request_set_file_transfer_hash (
+    TpAccountChannelRequest *self,
+    TpFileHashType hash_type,
+    const gchar *hash)
+{
+  g_return_if_fail (TP_IS_ACCOUNT_CHANNEL_REQUEST (self));
+  g_return_if_fail (!self->priv->requested);
+  g_return_if_fail (hash_type < TP_NUM_FILE_HASH_TYPES);
+
+  g_hash_table_insert (self->priv->request,
+      g_strdup (TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_HASH_TYPE),
+      tp_g_value_slice_new_uint (hash_type));
+
+  g_hash_table_insert (self->priv->request,
+      g_strdup (TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_HASH),
+      tp_g_value_slice_new_string (hash));
+}
diff --git a/telepathy-glib/account-channel-request.h b/telepathy-glib/account-channel-request.h
index f055714..f143df8 100644
--- a/telepathy-glib/account-channel-request.h
+++ b/telepathy-glib/account-channel-request.h
@@ -152,6 +152,12 @@ void tp_account_channel_request_set_file_transfer_initial_offset (
     TpAccountChannelRequest *self,
     guint64 offset);
 
+_TP_AVAILABLE_IN_0_24
+void tp_account_channel_request_set_file_transfer_hash (
+    TpAccountChannelRequest *self,
+    TpFileHashType hash_type,
+    const gchar *hash);
+
 /* Channel target (shared between all channel types) */
 
 _TP_AVAILABLE_IN_0_20
diff --git a/tests/dbus/account-channel-request.c b/tests/dbus/account-channel-request.c
index 7016338..fc7d90c 100644
--- a/tests/dbus/account-channel-request.c
+++ b/tests/dbus/account-channel-request.c
@@ -374,6 +374,8 @@ test_ft_props (Test *test,
       1111222233);
   tp_account_channel_request_set_file_transfer_uri (req,
       "file:///home/Downloads/warez.rar");
+  tp_account_channel_request_set_file_transfer_hash (req,
+      TP_FILE_HASH_TYPE_SHA256, "This is not a hash");
 
   /* Ask to the CR to fire the signal */
   tp_account_channel_request_set_request_property (req, "FireFailed",
@@ -411,9 +413,15 @@ test_ft_props (Test *test,
   g_assert_cmpuint (tp_asv_get_uint64 (test->cd_service->last_request,
         TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_DATE, NULL), ==,
       1111222233);
+  g_assert_cmpuint (tp_asv_get_uint32 (test->cd_service->last_request,
+        TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_HASH_TYPE, NULL), ==,
+      TP_FILE_HASH_TYPE_SHA256);
+  g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request,
+        TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_HASH), ==,
+      "This is not a hash");
   g_assert_cmpuint (tp_asv_get_boolean (test->cd_service->last_request,
         "FireFailed", NULL), ==, TRUE);
-  g_assert_cmpuint (tp_asv_size (test->cd_service->last_request), ==, 9);
+  g_assert_cmpuint (tp_asv_size (test->cd_service->last_request), ==, 11);
   g_assert_cmpuint (test->cd_service->last_user_action_time, ==, 0);
 }
 



More information about the telepathy-commits mailing list