Codebase list telepathy-glib / 747174e
add tp_account_channel_request_set_initial_invitees Guillaume Desmottes 10 years ago
4 changed file(s) with 106 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
62846284 tp_account_channel_request_set_sms_channel
62856285 tp_account_channel_request_set_conference_initial_channels
62866286 tp_account_channel_request_set_initial_invitee_ids
6287 tp_account_channel_request_set_initial_invitees
62876288 tp_account_channel_request_new_audio_call
62886289 tp_account_channel_request_new_audio_video_call
62896290 tp_account_channel_request_new_file_transfer
26072607 g_strdup (TP_PROP_CHANNEL_INTERFACE_CONFERENCE_INITIAL_INVITEE_IDS),
26082608 tp_g_value_slice_new_boxed (G_TYPE_STRV, ids));
26092609 }
2610
2611 /**
2612 * tp_account_channel_request_set_initial_invitees:
2613 * @self: a #TpAccountChannelRequest
2614 * @contacts: (element-type TelepathyGLib.Contact): a #GPtrArray of #TpContact
2615 *
2616 * Indicate that the contacts listed in @contacts have to be invited to the
2617 * conference represented by the channel which is going to be requested
2618 * using @self.
2619 *
2620 * This function can't be called once @self has been used to request a
2621 * channel.
2622 *
2623 * Since: UNRELEASED
2624 */
2625 void
2626 tp_account_channel_request_set_initial_invitees (
2627 TpAccountChannelRequest *self,
2628 GPtrArray *contacts)
2629 {
2630 guint i;
2631 GPtrArray *ids;
2632
2633 g_return_if_fail (contacts != NULL);
2634
2635 ids = g_ptr_array_new ();
2636
2637 for (i = 0; i < contacts->len; i++)
2638 {
2639 TpContact *contact = g_ptr_array_index (contacts, i);
2640
2641 g_ptr_array_add (ids, (gchar *) tp_contact_get_identifier (contact));
2642 }
2643
2644 g_ptr_array_add (ids, NULL);
2645
2646 tp_account_channel_request_set_initial_invitee_ids (self,
2647 (const gchar * const *) ids->pdata);
2648
2649 g_ptr_array_unref (ids);
2650 }
187187 TpAccountChannelRequest *self,
188188 const gchar * const * ids);
189189
190 _TP_AVAILABLE_IN_0_24
191 void tp_account_channel_request_set_initial_invitees (
192 TpAccountChannelRequest *self,
193 GPtrArray *contacts);
194
190195 /* Channel target (shared between all channel types) */
191196
192197 _TP_AVAILABLE_IN_0_20
13601360 g_assert_cmpuint (chans->len, ==, 2);
13611361 g_assert_cmpstr (g_ptr_array_index (chans, 0), ==, "/chan1");
13621362 g_assert_cmpstr (g_ptr_array_index (chans, 1), ==, "/chan2");
1363
1364 strv = tp_asv_get_boxed (test->cd_service->last_request,
1365 TP_PROP_CHANNEL_INTERFACE_CONFERENCE_INITIAL_INVITEE_IDS,
1366 G_TYPE_STRV);
1367 g_assert (strv != NULL);
1368 g_assert_cmpuint (g_strv_length ((GStrv) strv), ==, 2);
1369 g_assert (tp_strv_contains (strv, "badger@badger.com"));
1370 g_assert (tp_strv_contains (strv, "snake@badger.com"));
1371 }
1372
1373 static void
1374 test_initial_invitees (Test *test,
1375 gconstpointer data G_GNUC_UNUSED)
1376 {
1377 TpAccountChannelRequest *req;
1378 gboolean valid;
1379 GPtrArray *invitees;
1380 TpContact *contact;
1381 const gchar * const *strv;
1382
1383 req = tp_account_channel_request_new_text (test->account, 0);
1384
1385 invitees = g_ptr_array_new_with_free_func (g_object_unref);
1386
1387 contact = tp_tests_connection_run_until_contact_by_id (test->connection,
1388 "badger@badger.com", 0, NULL);
1389 g_ptr_array_add (invitees, contact);
1390 contact = tp_tests_connection_run_until_contact_by_id (test->connection,
1391 "snake@badger.com", 0, NULL);
1392 g_ptr_array_add (invitees, contact);
1393
1394 tp_account_channel_request_set_initial_invitees (req, invitees);
1395 g_ptr_array_unref (invitees);
1396
1397 /* Ask to the CR to fire the signal */
1398 tp_account_channel_request_set_request_property (req, "FireFailed",
1399 g_variant_new_boolean (TRUE));
1400
1401 tp_account_channel_request_create_and_handle_channel_async (req,
1402 NULL, create_and_handle_cb, test);
1403
1404 g_object_unref (req);
1405
1406 g_main_loop_run (test->mainloop);
1407 g_assert_error (test->error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT);
1408 g_assert (test->channel == NULL);
1409
1410 /* The request had the properties we wanted */
1411 g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request,
1412 TP_PROP_CHANNEL_CHANNEL_TYPE), ==, TP_IFACE_CHANNEL_TYPE_TEXT);
1413 g_assert_cmpuint (tp_asv_get_uint32 (test->cd_service->last_request,
1414 TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, &valid), ==, TP_HANDLE_TYPE_NONE);
1415 g_assert (valid);
1416 g_assert_cmpuint (tp_asv_get_boolean (test->cd_service->last_request,
1417 "FireFailed", NULL), ==, TRUE);
1418 g_assert_cmpuint (tp_asv_size (test->cd_service->last_request), ==, 4);
1419 g_assert_cmpuint (test->cd_service->last_user_action_time, ==, 0);
13631420
13641421 strv = tp_asv_get_boxed (test->cd_service->last_request,
13651422 TP_PROP_CHANNEL_INTERFACE_CONFERENCE_INITIAL_INVITEE_IDS,
14421499 setup, test_dbus_tube_props, teardown);
14431500 g_test_add ("/account-channels/test-no-handle-type", Test, NULL,
14441501 setup, test_no_handle_type, teardown);
1502 g_test_add ("/account-channels/test-initial-invitees", Test, NULL,
1503 setup, test_initial_invitees, teardown);
14451504
14461505 return tp_tests_run_with_bus ();
14471506 }