diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2014-02-25 12:39:59 +0100 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2014-02-25 12:39:59 +0100 |
commit | 410e44a648eb3bd2eb5db31a39326b01ac953eac (patch) | |
tree | b1cc0f0a4a0ca6f63f1139c00fc08077749d69ed | |
parent | 8cc41d121d1579893c2c7f7cc7bc90670170380f (diff) | |
download | telepathy-glib-410e44a648eb3bd2eb5db31a39326b01ac953eac.tar.gz |
add tp_account_channel_request_set_file_transfer_hash()
-rw-r--r-- | docs/reference/telepathy-glib-sections.txt | 1 | ||||
-rw-r--r-- | telepathy-glib/account-channel-request.c | 33 | ||||
-rw-r--r-- | telepathy-glib/account-channel-request.h | 6 | ||||
-rw-r--r-- | tests/dbus/account-channel-request.c | 10 |
4 files changed, 49 insertions, 1 deletions
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt index c6ac9fffb..be7287b30 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 5269a39f6..a1000f986 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 f05571417..f143df821 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 7016338ad..fc7d90cae 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); } |