static void upload_collected_traces() { LinphoneCoreManager* marie = setup(TRUE); if (transport_supported(marie->lc, LinphoneTransportTls)) { int waiting = 100; LinphoneCoreVTable *v_table = linphone_core_v_table_new(); v_table->log_collection_upload_state_changed = logCollectionUploadStateChangedCb; linphone_core_add_listener(marie->lc, v_table); linphone_core_set_log_collection_max_file_size(5000); linphone_core_set_log_collection_upload_server_url(marie->lc,"https://www.linphone.org:444/lft.php"); // Generate some logs while (--waiting) ms_error("(test error)Waiting %d...", waiting); linphone_core_compress_log_collection(marie->lc); linphone_core_upload_log_collection(marie->lc); BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphoneCoreLogCollectionUploadStateDelivered,1)); /*try 2 times*/ waiting=100; linphone_core_reset_log_collection(marie->lc); while (--waiting) ms_error("(test error)Waiting %d...", waiting); linphone_core_compress_log_collection(marie->lc); linphone_core_upload_log_collection(marie->lc); BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphoneCoreLogCollectionUploadStateDelivered,2)); } collect_cleanup(marie); }
static void text_message_with_credential_from_auth_cb(void) { char* to; LinphoneChatRoom* chat_room; LinphoneCoreVTable* vtable = linphone_core_v_table_new(); LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); text_message_with_credential_from_auth_cb_auth_info=linphone_auth_info_clone((LinphoneAuthInfo*)(linphone_core_get_auth_info_list(marie->lc)->data)); /*to force cb to be called*/ linphone_core_clear_all_auth_info(marie->lc); vtable->auth_info_requested=text_message_with_credential_from_auth_cb_auth_info_requested; linphone_core_add_listener(marie->lc, vtable); to = linphone_address_as_string(marie->identity); chat_room = linphone_core_create_chat_room(pauline->lc,to); ms_free(to); { int dummy=0; wait_for_until(marie->lc,pauline->lc,&dummy,1,100); /*just to have time to purge message stored in the server*/ reset_counters(&marie->stat); reset_counters(&pauline->stat); } linphone_chat_room_send_message(chat_room,"Bla bla bla bla"); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1)); CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageReceivedLegacy,1); CU_ASSERT_PTR_NOT_NULL(linphone_core_get_chat_room(marie->lc,pauline->identity)); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); }
static void simple_publish_with_expire(int expires) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneProxyConfig* proxy; LinphonePresenceModel* presence; LinphoneCoreVTable *vtable = linphone_core_v_table_new(); vtable->publish_state_changed = linphone_publish_state_changed; _linphone_core_add_listener(marie->lc, vtable, TRUE, TRUE ); proxy = linphone_core_get_default_proxy_config(marie->lc); linphone_proxy_config_edit(proxy); if (expires >0) { linphone_proxy_config_set_publish_expires(proxy,expires); } linphone_proxy_config_enable_publish(proxy,TRUE); linphone_proxy_config_done(proxy); BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishProgress,1)); BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishOk,1)); presence =linphone_presence_model_new_with_activity(LinphonePresenceActivityOffline,NULL); linphone_core_set_presence_model(marie->lc,presence); BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishProgress,2)); BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishOk,2)); linphone_proxy_config_edit(proxy); linphone_proxy_config_done(proxy); /*make sure no publish is sent*/ BC_ASSERT_FALSE(wait_for_until(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishProgress,3,2000)); linphone_proxy_config_edit(proxy); linphone_proxy_config_enable_publish(proxy,FALSE); linphone_proxy_config_done(proxy); /*fixme PUBLISH state machine is too simple, clear state should only be propagated at API level when 200ok is received*/ /*BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishProgress,3));*/ wait_for_until(marie->lc,marie->lc,NULL,0,2000); BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishCleared,1)); linphone_proxy_config_edit(proxy); linphone_proxy_config_enable_publish(proxy,TRUE); linphone_proxy_config_done(proxy); BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishProgress,3)); BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishOk,3)); linphone_proxy_config_edit(proxy); linphone_proxy_config_set_publish_expires(proxy, linphone_proxy_config_get_publish_expires(proxy)+1); linphone_proxy_config_done(proxy); BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishProgress,4)); BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishOk,4)); linphone_core_manager_destroy(marie); /*fixme we should wait untill 200okBC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishCleared,2,int,"%i");*/ BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,4,int,"%i"); }
static LinphoneCoreManager* create_lcm_with_auth(unsigned int with_auth) { LinphoneCoreManager* lcm=linphone_core_manager_new(NULL); if (with_auth) { LinphoneCoreVTable* vtable = linphone_core_v_table_new(); vtable->auth_info_requested=auth_info_requested; linphone_core_add_listener(lcm->lc,vtable); } /*to allow testing with 127.0.0.1*/ linphone_core_set_network_reachable(lcm->lc,TRUE); return lcm; }
LinphoneConferenceServer* linphone_conference_server_new(const char *rc_file, bool_t do_registration) { LinphoneConferenceServer *conf_srv = (LinphoneConferenceServer *)ms_new0(LinphoneConferenceServer, 1); LinphoneCoreManager *lm = (LinphoneCoreManager *)conf_srv; conf_srv->vtable = linphone_core_v_table_new(); conf_srv->vtable->call_state_changed = linphone_conference_server_call_state_changed; conf_srv->vtable->refer_received = linphone_conference_server_refer_received; conf_srv->vtable->registration_state_changed = linphone_conference_server_registration_state_changed; conf_srv->vtable->user_data = conf_srv; conf_srv->reg_state = LinphoneRegistrationNone; linphone_core_manager_init(lm, rc_file); linphone_core_add_listener(lm->lc, conf_srv->vtable); linphone_core_manager_start(lm, do_registration); return conf_srv; }
static LinphoneCallParams * _configure_for_video(LinphoneCoreManager *manager, LinphoneCoreCallStateChangedCb cb) { LinphoneCallParams *params; LinphoneCoreVTable *vtable = linphone_core_v_table_new(); vtable->call_state_changed = cb; linphone_core_add_listener(manager->lc, vtable); linphone_core_set_video_device(manager->lc, "StaticImage: Static picture"); linphone_core_enable_video_capture(manager->lc, TRUE); linphone_core_enable_video_display(manager->lc, TRUE); params = linphone_core_create_default_call_parameters(manager->lc); linphone_call_params_enable_video(params, TRUE); if (linphone_core_find_payload_type(manager->lc,"VP8", 90000, -1)!=NULL){ disable_all_video_codecs_except_one(manager->lc, "VP8"); }else{ ms_warning("VP8 codec not available, will use MP4V-ES instead"); disable_all_video_codecs_except_one(manager->lc, "MP4V-ES"); } return params; }
static void authenticated_register_with_no_initial_credentials(){ LinphoneCoreManager *mgr; LinphoneCoreVTable* vtable = linphone_core_v_table_new(); stats* counters; char route[256]; sprintf(route,"sip:%s",test_route); mgr = linphone_core_manager_new(NULL); vtable->auth_info_requested=auth_info_requested; linphone_core_add_listener(mgr->lc,vtable); counters= get_stats(mgr->lc); counters->number_of_auth_info_requested=0; register_with_refresh(mgr,FALSE,auth_domain,route); CU_ASSERT_EQUAL(counters->number_of_auth_info_requested,1); linphone_core_manager_destroy(mgr); }
static void friends_sqlite_storage(void) { LinphoneCoreVTable *v_table = linphone_core_v_table_new(); LinphoneCore* lc = NULL; LinphoneFriendList *lfl = NULL; LinphoneFriend *lf = NULL; LinphoneFriend *lf2 = NULL; LinphoneVcard *lvc = linphone_vcard_new(); LinphoneAddress *addr = linphone_address_new("sip:[email protected]"); const bctbx_list_t *friends = NULL; bctbx_list_t *friends_from_db = NULL; bctbx_list_t *friends_lists_from_db = NULL; char *friends_db = bc_tester_file("friends.db"); LinphoneFriendListStats *stats = (LinphoneFriendListStats *)ms_new0(LinphoneFriendListStats, 1); LinphoneAddress *laddress = NULL, *laddress2 = NULL; char *address = NULL, *address2 = NULL; v_table->friend_list_created = friend_list_created_cb; v_table->friend_list_removed = friend_list_removed_cb; lc = linphone_core_new(v_table, NULL, NULL, NULL); friends = linphone_friend_list_get_friends(linphone_core_get_default_friend_list(lc)); lfl = linphone_core_create_friend_list(lc); linphone_friend_list_set_user_data(lfl, stats); BC_ASSERT_EQUAL(bctbx_list_size(friends), 0, int, "%d"); unlink(friends_db); linphone_core_set_friends_database_path(lc, friends_db); friends_from_db = linphone_core_fetch_friends_from_db(lc, linphone_core_get_default_friend_list(lc)); BC_ASSERT_EQUAL(bctbx_list_size(friends_from_db), 0, int, "%d"); linphone_vcard_set_etag(lvc, "\"123-456789\""); linphone_vcard_set_url(lvc, "http://dav.somewhere.fr/addressbook/me/someone.vcf"); lf = linphone_friend_new_from_vcard(lvc); linphone_friend_set_address(lf, addr); linphone_friend_set_name(lf, "Sylvain"); linphone_core_add_friend_list(lc, lfl); wait_for_until(lc, NULL, &stats->new_list_count, 1, 1000); BC_ASSERT_EQUAL(stats->new_list_count, 1, int, "%i"); linphone_friend_list_unref(lfl); linphone_friend_list_set_display_name(lfl, "Test"); BC_ASSERT_EQUAL(linphone_friend_list_add_friend(lfl, lf), LinphoneFriendListOK, int, "%i"); linphone_friend_unref(lf); BC_ASSERT_EQUAL(lfl->storage_id, 1, unsigned int, "%u"); BC_ASSERT_EQUAL(lf->storage_id, 1, unsigned int, "%u"); friends = linphone_friend_list_get_friends(linphone_core_get_default_friend_list(lc)); BC_ASSERT_EQUAL(bctbx_list_size(friends), 0, int, "%d"); friends_lists_from_db = linphone_core_fetch_friends_lists_from_db(lc); BC_ASSERT_EQUAL(bctbx_list_size(friends_lists_from_db), 1, int, "%d"); friends_from_db = ((LinphoneFriendList *)friends_lists_from_db->data)->friends; BC_ASSERT_EQUAL(bctbx_list_size(friends_from_db), 1, int, "%d"); lf2 = (LinphoneFriend *)friends_from_db->data; BC_ASSERT_PTR_NOT_NULL(lf2->lc); BC_ASSERT_PTR_NOT_NULL(lf2->friend_list); friends_lists_from_db = bctbx_list_free_with_data(friends_lists_from_db, (void (*)(void *))linphone_friend_list_unref); friends_from_db = linphone_core_fetch_friends_from_db(lc, lfl); BC_ASSERT_EQUAL(bctbx_list_size(friends_from_db), 1, int, "%d"); if (bctbx_list_size(friends_from_db) < 1) { goto end; } lf2 = (LinphoneFriend *)friends_from_db->data; BC_ASSERT_STRING_EQUAL(linphone_friend_get_name(lf2), linphone_friend_get_name(lf)); BC_ASSERT_EQUAL(lf2->storage_id, lf->storage_id, unsigned int, "%u"); BC_ASSERT_STRING_EQUAL(linphone_vcard_get_etag(linphone_friend_get_vcard(lf2)), linphone_vcard_get_etag(linphone_friend_get_vcard(lf))); BC_ASSERT_STRING_EQUAL(linphone_vcard_get_url(linphone_friend_get_vcard(lf2)), linphone_vcard_get_url(linphone_friend_get_vcard(lf))); laddress = linphone_friend_get_address(lf); address = linphone_address_as_string(laddress); laddress2 = linphone_friend_get_address(lf2); address2 = linphone_address_as_string(laddress2); BC_ASSERT_STRING_EQUAL(address2, address); linphone_address_unref(laddress); linphone_address_unref(laddress2); ms_free(address); ms_free(address2); linphone_friend_edit(lf); linphone_friend_set_name(lf, "Margaux"); linphone_friend_done(lf); friends_from_db = bctbx_list_free_with_data(friends_from_db, (void (*)(void *))linphone_friend_unref); friends_from_db = linphone_core_fetch_friends_from_db(lc, lfl); BC_ASSERT_EQUAL(bctbx_list_size(friends_from_db), 1, int, "%d"); if (bctbx_list_size(friends_from_db) < 1) { goto end; } lf2 = (LinphoneFriend *)friends_from_db->data; BC_ASSERT_STRING_EQUAL(linphone_friend_get_name(lf2), "Margaux"); friends_from_db = bctbx_list_free_with_data(friends_from_db, (void (*)(void *))linphone_friend_unref); linphone_friend_list_remove_friend(lfl, lf); friends = linphone_friend_list_get_friends(linphone_core_get_default_friend_list(lc)); BC_ASSERT_EQUAL(bctbx_list_size(friends), 0, int, "%d"); friends_from_db = linphone_core_fetch_friends_from_db(lc, lfl); BC_ASSERT_EQUAL(bctbx_list_size(friends_from_db), 0, int, "%d"); linphone_core_remove_friend_list(lc, lfl); wait_for_until(lc, NULL, &stats->removed_list_count, 1, 1000); BC_ASSERT_EQUAL(stats->removed_list_count, 1, int, "%i"); end: ms_free(stats); unlink(friends_db); ms_free(friends_db); linphone_address_unref(addr); linphone_core_destroy(lc); linphone_core_v_table_destroy(v_table); }