diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt index 465ee1b..687d127 100644 --- a/docs/reference/telepathy-glib-sections.txt +++ b/docs/reference/telepathy-glib-sections.txt @@ -6285,6 +6285,7 @@ tp_account_channel_request_set_sms_channel tp_account_channel_request_set_conference_initial_channels tp_account_channel_request_set_initial_invitee_ids +tp_account_channel_request_set_initial_invitees tp_account_channel_request_new_audio_call tp_account_channel_request_new_audio_video_call tp_account_channel_request_new_file_transfer diff --git a/telepathy-glib/account-channel-request.c b/telepathy-glib/account-channel-request.c index b8b127e..8c3bb95 100644 --- a/telepathy-glib/account-channel-request.c +++ b/telepathy-glib/account-channel-request.c @@ -2608,3 +2608,44 @@ g_strdup (TP_PROP_CHANNEL_INTERFACE_CONFERENCE_INITIAL_INVITEE_IDS), tp_g_value_slice_new_boxed (G_TYPE_STRV, ids)); } + +/** + * tp_account_channel_request_set_initial_invitees: + * @self: a #TpAccountChannelRequest + * @contacts: (element-type TelepathyGLib.Contact): a #GPtrArray of #TpContact + * + * Indicate that the contacts listed in @contacts have to be invited to the + * conference represented by the channel which is going to be requested + * using @self. + * + * This function can't be called once @self has been used to request a + * channel. + * + * Since: UNRELEASED + */ +void +tp_account_channel_request_set_initial_invitees ( + TpAccountChannelRequest *self, + GPtrArray *contacts) +{ + guint i; + GPtrArray *ids; + + g_return_if_fail (contacts != NULL); + + ids = g_ptr_array_new (); + + for (i = 0; i < contacts->len; i++) + { + TpContact *contact = g_ptr_array_index (contacts, i); + + g_ptr_array_add (ids, (gchar *) tp_contact_get_identifier (contact)); + } + + g_ptr_array_add (ids, NULL); + + tp_account_channel_request_set_initial_invitee_ids (self, + (const gchar * const *) ids->pdata); + + g_ptr_array_unref (ids); +} diff --git a/telepathy-glib/account-channel-request.h b/telepathy-glib/account-channel-request.h index f414e88..45eea63 100644 --- a/telepathy-glib/account-channel-request.h +++ b/telepathy-glib/account-channel-request.h @@ -188,6 +188,11 @@ TpAccountChannelRequest *self, const gchar * const * ids); +_TP_AVAILABLE_IN_0_24 +void tp_account_channel_request_set_initial_invitees ( + TpAccountChannelRequest *self, + GPtrArray *contacts); + /* 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 258ec6d..49e5f9b 100644 --- a/tests/dbus/account-channel-request.c +++ b/tests/dbus/account-channel-request.c @@ -1361,6 +1361,63 @@ g_assert_cmpuint (chans->len, ==, 2); g_assert_cmpstr (g_ptr_array_index (chans, 0), ==, "/chan1"); g_assert_cmpstr (g_ptr_array_index (chans, 1), ==, "/chan2"); + + strv = tp_asv_get_boxed (test->cd_service->last_request, + TP_PROP_CHANNEL_INTERFACE_CONFERENCE_INITIAL_INVITEE_IDS, + G_TYPE_STRV); + g_assert (strv != NULL); + g_assert_cmpuint (g_strv_length ((GStrv) strv), ==, 2); + g_assert (tp_strv_contains (strv, "badger@badger.com")); + g_assert (tp_strv_contains (strv, "snake@badger.com")); +} + +static void +test_initial_invitees (Test *test, + gconstpointer data G_GNUC_UNUSED) +{ + TpAccountChannelRequest *req; + gboolean valid; + GPtrArray *invitees; + TpContact *contact; + const gchar * const *strv; + + req = tp_account_channel_request_new_text (test->account, 0); + + invitees = g_ptr_array_new_with_free_func (g_object_unref); + + contact = tp_tests_connection_run_until_contact_by_id (test->connection, + "badger@badger.com", 0, NULL); + g_ptr_array_add (invitees, contact); + contact = tp_tests_connection_run_until_contact_by_id (test->connection, + "snake@badger.com", 0, NULL); + g_ptr_array_add (invitees, contact); + + tp_account_channel_request_set_initial_invitees (req, invitees); + g_ptr_array_unref (invitees); + + /* 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_TEXT); + g_assert_cmpuint (tp_asv_get_uint32 (test->cd_service->last_request, + TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, &valid), ==, TP_HANDLE_TYPE_NONE); + g_assert (valid); + 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), ==, 4); + g_assert_cmpuint (test->cd_service->last_user_action_time, ==, 0); strv = tp_asv_get_boxed (test->cd_service->last_request, TP_PROP_CHANNEL_INTERFACE_CONFERENCE_INITIAL_INVITEE_IDS, @@ -1443,6 +1500,8 @@ setup, test_dbus_tube_props, teardown); g_test_add ("/account-channels/test-no-handle-type", Test, NULL, setup, test_no_handle_type, teardown); + g_test_add ("/account-channels/test-initial-invitees", Test, NULL, + setup, test_initial_invitees, teardown); return tp_tests_run_with_bus (); }