Ejemplo n.º 1
0
static void linphone_vcard_phone_numbers_and_sip_addresses(void) {
	LinphoneCoreManager* manager = linphone_core_manager_new2("empty_rc", FALSE);
	LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:[email protected]\r\nIMPP;TYPE=home:sip:[email protected]\r\nTEL;TYPE=work:0952636505\r\nEND:VCARD\r\n");
	LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc);
	bctbx_list_t *sip_addresses = linphone_friend_get_addresses(lf);
	bctbx_list_t *phone_numbers = linphone_friend_get_phone_numbers(lf);
	LinphoneAddress *addr = NULL;

	BC_ASSERT_EQUAL(bctbx_list_size(sip_addresses), 2, int, "%i");
	BC_ASSERT_EQUAL(bctbx_list_size(phone_numbers), 1, int, "%i");
	if (sip_addresses) bctbx_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref);
	if (phone_numbers) bctbx_list_free(phone_numbers);
	linphone_friend_unref(lf);

	lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nTEL;TYPE=work:0952636505\r\nTEL:0476010203\r\nEND:VCARD\r\n");
	lf = linphone_friend_new_from_vcard(lvc);
	sip_addresses = linphone_friend_get_addresses(lf);
	phone_numbers = linphone_friend_get_phone_numbers(lf);

	BC_ASSERT_EQUAL(bctbx_list_size(sip_addresses), 0, int, "%i");
	BC_ASSERT_EQUAL(bctbx_list_size(phone_numbers), 2, int, "%i");
	if (sip_addresses) bctbx_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref);
	if (phone_numbers) bctbx_list_free(phone_numbers);

	addr = linphone_address_new("sip:[email protected]");
	linphone_friend_add_address(lf, addr);
	linphone_address_unref(addr);
	sip_addresses = linphone_friend_get_addresses(lf);
	BC_ASSERT_EQUAL(bctbx_list_size(sip_addresses), 1, int, "%i");
	if (sip_addresses) bctbx_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref);

	linphone_friend_remove_phone_number(lf, "0952636505");
	phone_numbers = linphone_friend_get_phone_numbers(lf);
	BC_ASSERT_EQUAL(bctbx_list_size(phone_numbers), 1, int, "%i");
	if (phone_numbers) bctbx_list_free(phone_numbers);

	linphone_friend_remove_phone_number(lf, "0476010203");
	phone_numbers = linphone_friend_get_phone_numbers(lf);
	BC_ASSERT_EQUAL(bctbx_list_size(phone_numbers), 0, int, "%i");
	if (phone_numbers) bctbx_list_free(phone_numbers);

	addr = linphone_address_new("sip:[email protected]");
	linphone_friend_remove_address(lf, addr);
	linphone_address_unref(addr);
	sip_addresses = linphone_friend_get_addresses(lf);
	BC_ASSERT_EQUAL(bctbx_list_size(sip_addresses), 0, int, "%i");
	if (sip_addresses) bctbx_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref);

	linphone_friend_add_phone_number(lf, "+33952636505");
	phone_numbers = linphone_friend_get_phone_numbers(lf);
	BC_ASSERT_EQUAL(bctbx_list_size(phone_numbers), 1, int, "%i");
	if (phone_numbers) bctbx_list_free(phone_numbers);

	linphone_friend_unref(lf);
	lf = NULL;
	lvc = NULL;
	linphone_core_manager_destroy(manager);
}
Ejemplo n.º 2
0
static void linphone_vcard_phone_numbers_and_sip_addresses(void) {
	LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:[email protected]\r\nIMPP;TYPE=home:sip:[email protected]\r\nTEL;TYPE=work:0952636505\r\nEND:VCARD\r\n");
	LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc);
	MSList *sip_addresses = linphone_friend_get_addresses(lf);
	MSList *phone_numbers = linphone_friend_get_phone_numbers(lf);
	LinphoneAddress *addr = NULL;
	
	BC_ASSERT_EQUAL(ms_list_size(sip_addresses), 2, int, "%i");
	BC_ASSERT_EQUAL(ms_list_size(phone_numbers), 1, int, "%i");
	if (sip_addresses) ms_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref);
	if (phone_numbers) ms_list_free(phone_numbers);
	linphone_friend_unref(lf);
	
	lvc = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nTEL;TYPE=work:0952636505\r\nTEL:0476010203\r\nEND:VCARD\r\n");
	lf = linphone_friend_new_from_vcard(lvc);
	sip_addresses = linphone_friend_get_addresses(lf);
	phone_numbers = linphone_friend_get_phone_numbers(lf);
	
	BC_ASSERT_EQUAL(ms_list_size(sip_addresses), 0, int, "%i");
	BC_ASSERT_EQUAL(ms_list_size(phone_numbers), 2, int, "%i");
	if (sip_addresses) ms_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref);
	if (phone_numbers) ms_list_free(phone_numbers);
	
	addr = linphone_address_new("sip:[email protected]");
	linphone_friend_add_address(lf, addr);
	linphone_address_unref(addr);
	sip_addresses = linphone_friend_get_addresses(lf);
	BC_ASSERT_EQUAL(ms_list_size(sip_addresses), 1, int, "%i");
	if (sip_addresses) ms_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref);
	
	linphone_friend_remove_phone_number(lf, "0952636505");
	phone_numbers = linphone_friend_get_phone_numbers(lf);
	BC_ASSERT_EQUAL(ms_list_size(phone_numbers), 1, int, "%i");
	if (phone_numbers) ms_list_free(phone_numbers);
	
	linphone_friend_remove_phone_number(lf, "0476010203");
	phone_numbers = linphone_friend_get_phone_numbers(lf);
	BC_ASSERT_EQUAL(ms_list_size(phone_numbers), 0, int, "%i");
	if (phone_numbers) ms_list_free(phone_numbers);
	
	addr = linphone_address_new("sip:[email protected]");
	linphone_friend_remove_address(lf, addr);
	linphone_address_unref(addr);
	sip_addresses = linphone_friend_get_addresses(lf);
	BC_ASSERT_EQUAL(ms_list_size(sip_addresses), 0, int, "%i");
	if (sip_addresses) ms_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref);
	
	linphone_friend_add_phone_number(lf, "+33952636505");
	phone_numbers = linphone_friend_get_phone_numbers(lf);
	BC_ASSERT_EQUAL(ms_list_size(phone_numbers), 1, int, "%i");
	if (phone_numbers) ms_list_free(phone_numbers);
	
	linphone_friend_unref(lf);
	lf = NULL;
	lvc = NULL;
}