summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2014-02-25 12:47:18 +0100
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2014-02-25 14:16:10 +0100
commitb99443c02d20923988dc97318e6cf572e9b5e66f (patch)
tree86bc530f403acb8acc575c395353732c59567da3
parent410e44a648eb3bd2eb5db31a39326b01ac953eac (diff)
downloadtelepathy-glib-b99443c02d20923988dc97318e6cf572e9b5e66f.tar.gz
add tp_account_channel_request_new_stream_tube()
-rw-r--r--docs/reference/telepathy-glib-sections.txt1
-rw-r--r--telepathy-glib/account-channel-request.c52
-rw-r--r--telepathy-glib/account-channel-request.h8
-rw-r--r--tests/dbus/account-channel-request.c35
4 files changed, 96 insertions, 0 deletions
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index be7287b30..202630095 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -6290,6 +6290,7 @@ 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_new_stream_tube
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 a1000f986..deb9c367d 100644
--- a/telepathy-glib/account-channel-request.c
+++ b/telepathy-glib/account-channel-request.c
@@ -2423,3 +2423,55 @@ tp_account_channel_request_set_file_transfer_hash (
g_strdup (TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_HASH),
tp_g_value_slice_new_string (hash));
}
+
+/**
+ * tp_account_channel_request_new_stream_tube:
+ * @account: a #TpAccount
+ * @service: the service name that will be used over the tube. It should be a
+ * well-known TCP service name as defined by
+ * http://www.iana.org/assignments/port-numbers or
+ * http://www.dns-sd.org/ServiceTypes.html, for instance "rsync" or "daap".
+ * @user_action_time: the time of the user action that caused this request,
+ * or one of the special values %TP_USER_ACTION_TIME_NOT_USER_ACTION or
+ * %TP_USER_ACTION_TIME_CURRENT_TIME (see
+ * #TpAccountChannelRequest:user-action-time)
+ *
+ * Convenience function to create a new #TpAccountChannelRequest object,
+ * which will yield a StreamTube channel.
+ *
+ * After creating the request, you will also need to set the "target"
+ * of the channel by calling one of the following functions:
+ *
+ * - tp_account_channel_request_set_target_contact()
+ * - tp_account_channel_request_set_target_id()
+ *
+ * Returns: a new #TpAccountChannelRequest object
+ *
+ * Since: UNRELEASED
+ */
+TpAccountChannelRequest *
+tp_account_channel_request_new_stream_tube (TpAccount *account,
+ const gchar *service,
+ gint64 user_action_time)
+{
+ TpAccountChannelRequest *self;
+ GHashTable *request;
+
+ g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
+ g_return_val_if_fail (!tp_str_empty (service), NULL);
+
+ request = tp_asv_new (
+ TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
+ TP_IFACE_CHANNEL_TYPE_STREAM_TUBE,
+ TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE, G_TYPE_STRING, service,
+ NULL);
+
+ self = g_object_new (TP_TYPE_ACCOUNT_CHANNEL_REQUEST,
+ "account", account,
+ "request", request,
+ "user-action-time", user_action_time,
+ NULL);
+
+ g_hash_table_unref (request);
+ return self;
+}
diff --git a/telepathy-glib/account-channel-request.h b/telepathy-glib/account-channel-request.h
index f143df821..b670222fd 100644
--- a/telepathy-glib/account-channel-request.h
+++ b/telepathy-glib/account-channel-request.h
@@ -158,6 +158,14 @@ void tp_account_channel_request_set_file_transfer_hash (
TpFileHashType hash_type,
const gchar *hash);
+/* Tube */
+
+_TP_AVAILABLE_IN_0_24
+TpAccountChannelRequest *tp_account_channel_request_new_stream_tube (
+ TpAccount *account,
+ const gchar *service,
+ gint64 user_action_time) G_GNUC_WARN_UNUSED_RESULT;
+
/* 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 fc7d90cae..cff2b1be6 100644
--- a/tests/dbus/account-channel-request.c
+++ b/tests/dbus/account-channel-request.c
@@ -426,6 +426,39 @@ test_ft_props (Test *test,
}
static void
+test_stream_tube_props (Test *test,
+ gconstpointer data G_GNUC_UNUSED)
+{
+ TpAccountChannelRequest *req;
+
+ req = tp_account_channel_request_new_stream_tube (test->account, "daap",
+ 0);
+
+ /* Ask to the CR to fire the signal */
+ tp_account_channel_request_set_request_property (req, "FireFailed",
+ g_variant_new_boolean (TRUE));
+
+ tp_account_channel_request_create_and_handle_channel_async (req,
+ NULL, create_and_handle_cb, test);
+
+ g_object_unref (req);
+
+ g_main_loop_run (test->mainloop);
+ g_assert_error (test->error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT);
+ g_assert (test->channel == NULL);
+
+ /* The request had the properties we wanted */
+ g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request,
+ TP_PROP_CHANNEL_CHANNEL_TYPE), ==, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE);
+ g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request,
+ TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE), ==, "daap");
+ 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), ==, 3);
+ g_assert_cmpuint (test->cd_service->last_user_action_time, ==, 0);
+}
+
+static void
ensure_and_handle_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
@@ -1305,6 +1338,8 @@ main (int argc,
/* Particular properties of the request */
g_test_add ("/account-channels/test-ft-props", Test, NULL,
setup, test_ft_props, teardown);
+ g_test_add ("/account-channels/test-stream-tube-props", Test, NULL,
+ setup, test_stream_tube_props, teardown);
return tp_tests_run_with_bus ();
}