static void profile_call_base(bool_t avpf1, LinphoneMediaEncryption srtp1,bool_t avpf2, LinphoneMediaEncryption srtp2, bool_t encryption_mandatory, const char *expected_profile) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc"); LinphoneProxyConfig *lpc; const LinphoneCallParams *params; if (avpf1) { linphone_core_get_default_proxy(marie->lc, &lpc); linphone_proxy_config_enable_avpf(lpc, TRUE); linphone_proxy_config_set_avpf_rr_interval(lpc, 3); } if (avpf2) { linphone_core_get_default_proxy(pauline->lc, &lpc); linphone_proxy_config_enable_avpf(lpc, TRUE); linphone_proxy_config_set_avpf_rr_interval(lpc, 3); } if (encryption_mandatory) { linphone_core_set_media_encryption_mandatory(marie->lc,TRUE); linphone_core_set_media_encryption_mandatory(pauline->lc,TRUE); } if (linphone_core_media_encryption_supported(marie->lc, srtp1)) { linphone_core_set_media_encryption(marie->lc, srtp1); } else { ms_message("Unsupported [%s] encryption type, cannot test",linphone_media_encryption_to_string(srtp1)); goto end; } if (linphone_core_media_encryption_supported(pauline->lc, srtp2)) { linphone_core_set_media_encryption(pauline->lc, srtp2); }else { ms_message("Unsupported [%s] encryption type, cannot test",linphone_media_encryption_to_string(srtp2)); goto end; } CU_ASSERT_TRUE(call(marie, pauline)); CU_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1)); CU_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1)); if (linphone_core_get_current_call(marie->lc)) { params = linphone_call_get_current_params(linphone_core_get_current_call(marie->lc)); CU_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params), expected_profile); } if (linphone_core_get_current_call(pauline->lc)) { params = linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc)); CU_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params), expected_profile); } linphone_core_terminate_all_calls(marie->lc); CU_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallEnd, 1)); CU_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallEnd, 1)); CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallConnected, 1); CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallConnected, 1); end: linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie); }
static void subscribe_failure_handle_by_app(void) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_rc"); LinphoneProxyConfig* config; LinphoneFriend* lf; char* lf_identity=linphone_address_as_string_uri_only(pauline->identity); linphone_core_get_default_proxy(marie->lc,&config); CU_ASSERT_TRUE(subscribe_to_callee_presence(marie,pauline)); wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_NewSubscriptionRequest,1); /*just to wait for unsubscription even if not notified*/ sal_set_recv_error(marie->lc->sal, 0); /*simulate an error*/ CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneRegistrationProgress,2)); CU_ASSERT_EQUAL(linphone_proxy_config_get_error(config),LinphoneReasonIOError); sal_set_recv_error(marie->lc->sal, 1); lf = linphone_core_get_friend_by_address(marie->lc,lf_identity); linphone_friend_edit(lf); linphone_friend_enable_subscribes(lf,FALSE); /*disable subscription*/ linphone_friend_done(lf); CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneRegistrationOk,2)); /*wait for register ok*/ linphone_friend_edit(lf); linphone_friend_enable_subscribes(lf,TRUE); linphone_friend_done(lf); CU_ASSERT_FALSE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_NewSubscriptionRequest,2)); /*just to wait for unsubscription even if not notified*/ linphone_core_manager_destroy(marie); CU_ASSERT_FALSE(wait_for(NULL,pauline->lc,&pauline->stat.number_of_NewSubscriptionRequest,3)); /*just to wait for unsubscription even if not notified*/ linphone_core_manager_destroy(pauline); }
void SipClient::shutdown() { qDebug() << __PRETTY_FUNCTION__; if (m_authInfo) { linphone_auth_info_destroy(m_authInfo); // Get default proxy config linphone_core_get_default_proxy(lc, &m_proxyCfg); // start editing proxy configuration linphone_proxy_config_edit(m_proxyCfg); // De-activate registration for this proxy config linphone_proxy_config_enable_register(m_proxyCfg, FALSE); linphone_proxy_config_done(m_proxyCfg); while (linphone_proxy_config_get_state(m_proxyCfg) != LinphoneRegistrationCleared) { //...to make sure we receive call backs before shutting down linphone_core_iterate(lc); ms_usleep(50000); } m_authInfo = 0; } // delete m_loopTimer; if (lc) { linphone_core_destroy(lc); lc = 0; } }
static void proxy_transport_change_with_wrong_port_givin_up() { LinphoneCoreManager* lcm = create_lcm(); stats* counters = &lcm->stat; LinphoneProxyConfig* proxy_config; LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/ char route[256]; LCSipTransports transport= {LC_SIP_TRANSPORT_RANDOM,LC_SIP_TRANSPORT_RANDOM,LC_SIP_TRANSPORT_RANDOM,LC_SIP_TRANSPORT_RANDOM}; sprintf(route,"sip:%s",test_route); linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/ register_with_refresh_base_3(lcm->lc, FALSE, auth_domain, "sip2.linphone.org:5987", 0,transport,LinphoneRegistrationProgress); linphone_core_get_default_proxy(lcm->lc,&proxy_config); linphone_proxy_config_edit(proxy_config); CU_ASSERT_FALSE(wait_for_until(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationCleared,1,3000)); linphone_proxy_config_enableregister(proxy_config,FALSE); linphone_proxy_config_done(proxy_config); CU_ASSERT(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationCleared,1)); CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationOk,0); CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationProgress,1); CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0); linphone_core_manager_destroy(lcm); }
const char* linphone_gtk_get_used_identity(){ LinphoneCore *lc=linphone_gtk_get_core(); LinphoneProxyConfig *cfg; linphone_core_get_default_proxy(lc,&cfg); if (cfg) return linphone_proxy_config_get_identity(cfg); else return linphone_core_get_primary_contact(lc); }
static void proxy_transport_change(){ LinphoneCoreManager* lcm = create_lcm(); stats* counters = &lcm->stat; LinphoneProxyConfig* proxy_config; LinphoneAddress* addr; char* addr_as_string; LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/ linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/ register_with_refresh_base(lcm->lc,FALSE,auth_domain,NULL); linphone_core_get_default_proxy(lcm->lc,&proxy_config); reset_counters(counters); /*clear stats*/ linphone_proxy_config_edit(proxy_config); CU_ASSERT_FALSE(wait_for_until(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationCleared,1,3000)); addr = linphone_address_new(linphone_proxy_config_get_addr(proxy_config)); if (LinphoneTransportTcp == linphone_address_get_transport(addr)) { linphone_address_set_transport(addr,LinphoneTransportUdp); } else { linphone_address_set_transport(addr,LinphoneTransportTcp); } linphone_proxy_config_set_server_addr(proxy_config,addr_as_string=linphone_address_as_string(addr)); linphone_proxy_config_done(proxy_config); CU_ASSERT(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,1)); /*as we change p[roxy server destination, we should'nt be notified about the clear*/ CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationCleared,0); ms_free(addr_as_string); linphone_address_destroy(addr); linphone_core_manager_destroy(lcm); }
void linphone_core_manager_start(LinphoneCoreManager *mgr, const char* rc_file, int check_for_proxies) { LinphoneProxyConfig* proxy; int proxy_count; /*CU_ASSERT_EQUAL(ms_list_size(linphone_core_get_proxy_config_list(lc)),proxy_count);*/ if (check_for_proxies && rc_file) /**/ proxy_count=ms_list_size(linphone_core_get_proxy_config_list(mgr->lc)); else proxy_count=0; if (proxy_count){ #define REGISTER_TIMEOUT 20 /* seconds */ int success = wait_for_until(mgr->lc,NULL,&mgr->stat.number_of_LinphoneRegistrationOk, proxy_count,(REGISTER_TIMEOUT * 1000 * proxy_count)); if( !success ){ ms_error("Did not register after %d seconds for %d proxies", REGISTER_TIMEOUT, proxy_count); } } CU_ASSERT_EQUAL(mgr->stat.number_of_LinphoneRegistrationOk,proxy_count); enable_codec(mgr->lc,"PCMU",8000); linphone_core_get_default_proxy(mgr->lc,&proxy); if (proxy) { mgr->identity = linphone_address_new(linphone_proxy_config_get_identity(proxy)); linphone_address_clean(mgr->identity); } }
const LinphoneAddress* linphone_gtk_get_used_identity(){ LinphoneCore *lc=linphone_gtk_get_core(); LinphoneProxyConfig *cfg; linphone_core_get_default_proxy(lc,&cfg); if (cfg) return linphone_address_new(linphone_proxy_config_get_identity(cfg)); else return linphone_core_get_primary_contact_parsed(lc); }
static void change_expires(){ LinphoneCoreManager* lcm = create_lcm(); stats* counters = &lcm->stat; LinphoneProxyConfig* proxy_config; register_with_refresh_base(lcm->lc,FALSE,NULL,NULL); linphone_core_get_default_proxy(lcm->lc,&proxy_config); linphone_proxy_config_edit(proxy_config); reset_counters(counters); /*clear stats*/ /*nothing is supposed to arrive until done*/ CU_ASSERT_FALSE(wait_for_until(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationCleared,1,3000)); linphone_proxy_config_set_expires(proxy_config,3); linphone_proxy_config_done(proxy_config); CU_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,1)); /*wait 2s without receive refresh*/ CU_ASSERT_FALSE(wait_for_until(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,2,2000)); /* now, it should be ok*/ CU_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,2)); linphone_core_manager_destroy(lcm); }
static void text_message_with_privacy(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); LinphoneProxyConfig* pauline_proxy; char* to = linphone_address_as_string(marie->identity); LinphoneChatRoom* chat_room = linphone_core_create_chat_room(pauline->lc,to); ms_free(to); /*test proxy config privacy*/ linphone_core_get_default_proxy(pauline->lc,&pauline_proxy); linphone_proxy_config_set_privacy(pauline_proxy,LinphonePrivacyId); CU_ASSERT_PTR_NOT_NULL(linphone_core_get_chat_room(marie->lc,pauline->identity)); { 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); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); }
LinphoneCoreManager* linphone_core_manager_new2(const char* rc_file, int check_for_proxies) { LinphoneCoreManager* mgr= ms_new0(LinphoneCoreManager,1); LinphoneProxyConfig* proxy; char *rc_path = NULL; int proxy_count; mgr->v_table.registration_state_changed=registration_state_changed; mgr->v_table.auth_info_requested=auth_info_requested; mgr->v_table.call_state_changed=call_state_changed; mgr->v_table.text_received=text_message_received; mgr->v_table.message_received=message_received; mgr->v_table.file_transfer_recv=file_transfer_received; mgr->v_table.file_transfer_send=file_transfer_send; mgr->v_table.file_transfer_progress_indication=file_transfer_progress_indication; mgr->v_table.is_composing_received=is_composing_received; mgr->v_table.new_subscription_requested=new_subscription_requested; mgr->v_table.notify_presence_received=notify_presence_received; mgr->v_table.transfer_state_changed=linphone_transfer_state_changed; mgr->v_table.info_received=info_message_received; mgr->v_table.subscription_state_changed=linphone_subscription_state_change; mgr->v_table.notify_received=linphone_notify_received; mgr->v_table.publish_state_changed=linphone_publish_state_changed; mgr->v_table.configuring_status=linphone_configuration_status; mgr->v_table.call_encryption_changed=linphone_call_encryption_changed; mgr->v_table.network_reachable=network_reachable; reset_counters(&mgr->stat); if (rc_file) rc_path = ms_strdup_printf("rcfiles/%s", rc_file); mgr->lc=configure_lc_from(&mgr->v_table, liblinphone_tester_file_prefix, rc_path, mgr); /*CU_ASSERT_EQUAL(ms_list_size(linphone_core_get_proxy_config_list(lc)),proxy_count);*/ if (check_for_proxies && rc_file) /**/ proxy_count=ms_list_size(linphone_core_get_proxy_config_list(mgr->lc)); else proxy_count=0; #if TARGET_OS_IPHONE linphone_core_set_playback_device( mgr->lc, "AU: Audio Unit Tester"); linphone_core_set_capture_device( mgr->lc, "AU: Audio Unit Tester"); linphone_core_set_ringer_device( mgr->lc, "AQ: Audio Queue Device"); linphone_core_set_ringback(mgr->lc, NULL); #endif if (proxy_count) wait_for_until(mgr->lc,NULL,&mgr->stat.number_of_LinphoneRegistrationOk,proxy_count,5000*proxy_count); CU_ASSERT_EQUAL(mgr->stat.number_of_LinphoneRegistrationOk,proxy_count); enable_codec(mgr->lc,"PCMU",8000); linphone_core_get_default_proxy(mgr->lc,&proxy); if (proxy) { mgr->identity = linphone_address_new(linphone_proxy_config_get_identity(proxy)); linphone_address_clean(mgr->identity); } if (rc_path) ms_free(rc_path); return mgr; }
/** * Sets the default proxy. * * This default proxy must be part of the list of already entered LinphoneProxyConfig. * Toggling it as default will make LinphoneCore use the identity associated with * the proxy configuration in all incoming and outgoing calls. **/ void linphone_core_set_default_proxy(LinphoneCore *lc, LinphoneProxyConfig *config){ /* check if this proxy is in our list */ if (config!=NULL){ if (ms_list_find(lc->sip_conf.proxies,config)==NULL){ ms_warning("Bad proxy address: it is not in the list !"); lc->default_proxy=NULL; return ; } } lc->default_proxy=config; if (linphone_core_ready(lc)) lp_config_set_int(lc->config,"sip","default_proxy",linphone_core_get_default_proxy(lc,NULL)); }
void linphone_proxy_config_write_all_to_config_file(LinphoneCore *lc){ MSList *elem; int i; if (!linphone_core_ready(lc)) return; for(elem=lc->sip_conf.proxies,i=0;elem!=NULL;elem=ms_list_next(elem),i++){ LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data; linphone_proxy_config_write_to_config_file(lc->config,cfg,i); } /*to ensure removed configs are erased:*/ linphone_proxy_config_write_to_config_file(lc->config,NULL,i); lp_config_set_int(lc->config,"sip","default_proxy",linphone_core_get_default_proxy(lc,NULL)); }
static void test_subscribe_notify_publish(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); LinphoneProxyConfig* proxy; LinphonePresenceModel* presence; LpConfig *pauline_lp = linphone_core_get_config(pauline->lc); char* lf_identity=linphone_address_as_string_uri_only(marie->identity); LinphoneFriend *lf = linphone_core_create_friend_with_address(pauline->lc,lf_identity); lp_config_set_int(pauline_lp,"sip","subscribe_expires",5); linphone_core_add_friend(pauline->lc,lf); /*wait for subscribe acknowledgment*/ wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_NotifyReceived,1,2000); CU_ASSERT_EQUAL(LinphoneStatusOffline,linphone_friend_get_status(lf)); /*enable publish*/ linphone_core_get_default_proxy(marie->lc,&proxy); linphone_proxy_config_edit(proxy); linphone_proxy_config_enable_publish(proxy,TRUE); linphone_proxy_config_set_publish_expires(proxy,3); linphone_proxy_config_done(proxy); /*wait for marie status*/ wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_NotifyReceived,2,2000); CU_ASSERT_EQUAL(LinphoneStatusOnline,linphone_friend_get_status(lf)); presence =linphone_presence_model_new_with_activity(LinphonePresenceActivityBusy,NULL); linphone_core_set_presence_model(marie->lc,presence); /*wait for new status*/ wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_NotifyReceived,3,2000); CU_ASSERT_EQUAL(LinphoneStatusBusy,linphone_friend_get_status(lf)); /*wait for refresh*/ wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_NotifyReceived,4,5000); CU_ASSERT_EQUAL(LinphoneStatusBusy,linphone_friend_get_status(lf)); /*linphone_core_remove_friend(pauline->lc,lf);*/ /*wait for final notify*/ /*wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_NotifyReceived,4,5000); CU_ASSERT_EQUAL(LinphonePresenceActivityOffline,linphone_friend_get_status(lf)); */ linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); }
G_MODULE_EXPORT void linphone_gtk_logout_clicked(){ LinphoneCore *lc=linphone_gtk_get_core(); LinphoneProxyConfig *cfg=NULL; linphone_core_get_default_proxy(lc,&cfg); if (cfg){ SipSetupContext *ss=linphone_proxy_config_get_sip_setup_context(cfg); if (ss){ sip_setup_context_logout(ss); linphone_gtk_set_ui_config_int("automatic_login",FALSE); linphone_gtk_show_login_frame(cfg); } } }
static void simple_publish(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneProxyConfig* proxy; LinphonePresenceModel* presence; linphone_core_get_default_proxy(marie->lc,&proxy); linphone_proxy_config_edit(proxy); linphone_proxy_config_enable_publish(proxy,TRUE); linphone_proxy_config_done(proxy); wait_core(marie->lc); presence =linphone_presence_model_new_with_activity(LinphonePresenceActivityOffline,NULL); linphone_core_set_presence_model(marie->lc,presence); wait_core(marie->lc); linphone_core_manager_destroy(marie); }
static void authenticated_register_with_wrong_credentials_2() { LinphoneCoreManager *mgr = linphone_core_manager_new(NULL); stats* counters = get_stats(mgr->lc); int current_in_progress; LinphoneProxyConfig* proxy; authenticated_register_with_wrong_credentials_with_params_base(NULL,mgr); linphone_core_get_default_proxy(mgr->lc,&proxy); /*Make sure registration attempts are stopped*/ linphone_proxy_config_edit(proxy); linphone_proxy_config_enable_register(proxy,FALSE); linphone_proxy_config_done(proxy); current_in_progress=counters->number_of_LinphoneRegistrationProgress; CU_ASSERT_FALSE(wait_for(mgr->lc,mgr->lc,&counters->number_of_LinphoneRegistrationProgress,current_in_progress+1)); linphone_core_manager_destroy(mgr); }
static void simple_unregister(){ LinphoneCoreManager* lcm = create_lcm(); stats* counters = &lcm->stat; LinphoneProxyConfig* proxy_config; register_with_refresh_base(lcm->lc,FALSE,NULL,NULL); linphone_core_get_default_proxy(lcm->lc,&proxy_config); linphone_proxy_config_edit(proxy_config); reset_counters(counters); /*clear stats*/ /*nothing is supposed to arrive until done*/ CU_ASSERT_FALSE(wait_for_until(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationCleared,1,3000)); linphone_proxy_config_enable_register(proxy_config,FALSE); linphone_proxy_config_done(proxy_config); CU_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationCleared,1)); linphone_core_manager_destroy(lcm); }
static void text_message_compatibility_mode(void) { char route[256]; LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); LinphoneProxyConfig* proxy; LinphoneAddress* proxy_address; char*tmp; LCSipTransports transport; char* to = linphone_address_as_string(pauline->identity); LinphoneChatRoom* chat_room; linphone_core_get_default_proxy(marie->lc,&proxy); CU_ASSERT_PTR_NOT_NULL (proxy); proxy_address=linphone_address_new(linphone_proxy_config_get_addr(proxy)); linphone_address_clean(proxy_address); tmp=linphone_address_as_string_uri_only(proxy_address); linphone_proxy_config_set_server_addr(proxy,tmp); sprintf(route,"sip:%s",test_route); linphone_proxy_config_set_route(proxy,route); ms_free(tmp); linphone_address_destroy(proxy_address); linphone_core_get_sip_transports(marie->lc,&transport); transport.udp_port=0; transport.tls_port=0; transport.dtls_port=0; /*only keep tcp*/ linphone_core_set_sip_transports(marie->lc,&transport); marie->stat.number_of_LinphoneRegistrationOk=0; CU_ASSERT_TRUE (wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphoneRegistrationOk,1)); chat_room = linphone_core_create_chat_room(marie->lc,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,&pauline->stat.number_of_LinphoneMessageReceived,1)); CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageReceivedLegacy,1); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); }
/*the purpose of this test is to check that will not block the proxy config during SSL handshake for entire life in case of mistaken configuration*/ static void tls_with_non_tls_server(){ LinphoneCoreManager *mgr; LinphoneProxyConfig* proxy_cfg; LinphoneAddress* addr; char tmp[256]; LinphoneCore *lc; mgr=linphone_core_manager_new2( "marie_rc", 0); lc=mgr->lc; sal_set_transport_timeout(lc->sal,3000); linphone_core_get_default_proxy(lc,&proxy_cfg); linphone_proxy_config_edit(proxy_cfg); addr=linphone_address_new(linphone_proxy_config_get_addr(proxy_cfg)); snprintf(tmp,sizeof(tmp),"sip:%s:%i;transport=tls" ,linphone_address_get_domain(addr) ,(linphone_address_get_port(addr)>0?linphone_address_get_port(addr):5060)); linphone_proxy_config_set_server_addr(proxy_cfg,tmp); linphone_proxy_config_done(proxy_cfg); linphone_address_destroy(addr); CU_ASSERT_TRUE(wait_for_until(lc,lc,&mgr->stat.number_of_LinphoneRegistrationFailed,1,5000)); linphone_core_manager_destroy(mgr); }
static void tls_with_non_tls_server(){ LinphoneCoreManager *mgr; LinphoneProxyConfig* proxy_cfg; LinphoneAddress* addr; char tmp[256]; LinphoneCore *lc; mgr=linphone_core_manager_new2( "marie_rc", 0); lc=mgr->lc; linphone_core_get_default_proxy(lc,&proxy_cfg); linphone_proxy_config_edit(proxy_cfg); addr=linphone_address_new(linphone_proxy_config_get_addr(proxy_cfg)); snprintf(tmp,sizeof(tmp),"sip:%s:%i;transport=tls" ,linphone_address_get_domain(addr) ,(linphone_address_get_port_int(addr)>0?linphone_address_get_port_int(addr):5060)); linphone_proxy_config_set_server_addr(proxy_cfg,tmp); linphone_proxy_config_done(proxy_cfg); linphone_address_destroy(addr); /* FIXME http://git.linphone.org/mantis/view.php?id=758 CU_ASSERT_TRUE(wait_for(lc,lc,&mgr->stat.number_of_LinphoneRegistrationFailed,1)); */ linphone_core_manager_destroy(mgr); }
static void authenticated_register_with_wrong_credentials_with_params_base(const char* user_agent,LinphoneCoreManager *mgr) { stats* counters; LCSipTransports transport = {5070,5070,0,5071}; LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,"wrong passwd",NULL,auth_domain,NULL); /*create authentication structure from identity*/ char route[256]; sprintf(route,"sip:%s",test_route); sal_set_refresher_retry_after(mgr->lc->sal,500); if (user_agent) { linphone_core_set_user_agent(mgr->lc,user_agent,NULL); } linphone_core_add_auth_info(mgr->lc,info); /*add wrong authentication info to LinphoneCore*/ counters = get_stats(mgr->lc); register_with_refresh_base_3(mgr->lc,TRUE,auth_domain,route,FALSE,transport,LinphoneRegistrationFailed); //CU_ASSERT_EQUAL(counters->number_of_auth_info_requested,3); register_with_refresh_base_3 does not alow to precisely check number of number_of_auth_info_requested /*wait for retry*/ CU_ASSERT_TRUE(wait_for(mgr->lc,mgr->lc,&counters->number_of_auth_info_requested,4)); CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,1); /*check the detailed error info */ if (!user_agent || strcmp(user_agent,"tester-no-403")!=0){ LinphoneProxyConfig *cfg=NULL; linphone_core_get_default_proxy(mgr->lc,&cfg); CU_ASSERT_PTR_NOT_NULL(cfg); if (cfg){ const LinphoneErrorInfo *ei=linphone_proxy_config_get_error_info(cfg); const char *phrase=linphone_error_info_get_phrase(ei); CU_ASSERT_PTR_NOT_NULL(phrase); if (phrase) CU_ASSERT_TRUE(strcmp(phrase,"Forbidden")==0); CU_ASSERT_EQUAL(linphone_error_info_get_protocol_code(ei),403); CU_ASSERT_PTR_NULL(linphone_error_info_get_details(ei)); } } }
static void test_forked_subscribe_notify_publish(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); LinphoneProxyConfig* proxy; LinphonePresenceModel* presence; LpConfig *pauline_lp; char* lf_identity; LinphoneFriend *lf; MSList* lcs=ms_list_append(NULL,pauline->lc); lcs=ms_list_append(lcs,marie->lc); lcs=ms_list_append(lcs,marie->lc); lcs=ms_list_append(lcs,marie2->lc); pauline_lp = linphone_core_get_config(pauline->lc); lf_identity=linphone_address_as_string_uri_only(marie->identity); lf = linphone_core_create_friend_with_address(pauline->lc,lf_identity); lp_config_set_int(pauline_lp,"sip","subscribe_expires",5); linphone_core_add_friend(pauline->lc,lf); /*wait for subscribe acknowledgment*/ wait_for_list(lcs,&pauline->stat.number_of_NotifyReceived,1,2000); CU_ASSERT_EQUAL(LinphoneStatusOffline,linphone_friend_get_status(lf)); /*enable publish*/ linphone_core_get_default_proxy(marie->lc,&proxy); linphone_proxy_config_edit(proxy); linphone_proxy_config_enable_publish(proxy,TRUE); linphone_proxy_config_set_publish_expires(proxy,3); linphone_proxy_config_done(proxy); linphone_core_get_default_proxy(marie2->lc,&proxy); linphone_proxy_config_edit(proxy); linphone_proxy_config_enable_publish(proxy,TRUE); linphone_proxy_config_set_publish_expires(proxy,3); linphone_proxy_config_done(proxy); /*wait for marie status*/ wait_for_list(lcs,&pauline->stat.number_of_NotifyReceived,3,2000); CU_ASSERT_EQUAL(LinphoneStatusOnline,linphone_friend_get_status(lf)); presence =linphone_presence_model_new_with_activity(LinphonePresenceActivityBusy,NULL); linphone_core_set_presence_model(marie->lc,presence); /*wait for new status*/ wait_for_list(lcs,&pauline->stat.number_of_NotifyReceived,4,2000); CU_ASSERT_EQUAL(LinphoneStatusBusy,linphone_friend_get_status(lf)); presence =linphone_presence_model_new_with_activity( LinphonePresenceActivityMeeting,NULL); linphone_core_set_presence_model(marie2->lc,presence); /*wait for new status*/ wait_for_list(lcs,&pauline->stat.number_of_NotifyReceived,5,2000); CU_ASSERT_EQUAL(LinphoneStatusBusy,linphone_friend_get_status(lf)); /*because liblinphone compositor is very simple for now (I.E only take first occurence)*/ linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie2); linphone_core_manager_destroy(pauline); }
LinphoneCoreManager* linphone_core_manager_new2(const char* rc_file, int check_for_proxies) { LinphoneCoreManager* mgr= ms_new0(LinphoneCoreManager,1); LinphoneProxyConfig* proxy; char *rc_path = NULL; int proxy_count; mgr->v_table.registration_state_changed=registration_state_changed; mgr->v_table.auth_info_requested=auth_info_requested; mgr->v_table.call_state_changed=call_state_changed; mgr->v_table.text_received=text_message_received; mgr->v_table.message_received=message_received; mgr->v_table.is_composing_received=is_composing_received; mgr->v_table.new_subscription_requested=new_subscription_requested; mgr->v_table.notify_presence_received=notify_presence_received; mgr->v_table.transfer_state_changed=linphone_transfer_state_changed; mgr->v_table.info_received=info_message_received; mgr->v_table.subscription_state_changed=linphone_subscription_state_change; mgr->v_table.notify_received=linphone_notify_received; mgr->v_table.publish_state_changed=linphone_publish_state_changed; mgr->v_table.configuring_status=linphone_configuration_status; mgr->v_table.call_encryption_changed=linphone_call_encryption_changed; mgr->v_table.network_reachable=network_reachable; mgr->v_table.dtmf_received=dtmf_received; mgr->v_table.call_stats_updated=call_stats_updated; reset_counters(&mgr->stat); if (rc_file) rc_path = ms_strdup_printf("rcfiles/%s", rc_file); mgr->lc=configure_lc_from(&mgr->v_table, liblinphone_tester_file_prefix, rc_path, mgr); linphone_core_manager_check_accounts(mgr); /*CU_ASSERT_EQUAL(ms_list_size(linphone_core_get_proxy_config_list(lc)),proxy_count);*/ if (check_for_proxies && rc_file) /**/ proxy_count=ms_list_size(linphone_core_get_proxy_config_list(mgr->lc)); else proxy_count=0; manager_count++; #if TARGET_OS_IPHONE linphone_core_set_ringer_device( mgr->lc, "AQ: Audio Queue Device"); linphone_core_set_ringback(mgr->lc, NULL); #endif if( manager_count >= 2){ char hellopath[512]; ms_message("Manager for '%s' using files", rc_file ? rc_file : "--"); linphone_core_use_files(mgr->lc, TRUE); snprintf(hellopath,sizeof(hellopath), "%s/sounds/hello8000.wav", liblinphone_tester_file_prefix); linphone_core_set_play_file(mgr->lc,hellopath); } if (proxy_count){ #define REGISTER_TIMEOUT 20 /* seconds */ int success = wait_for_until(mgr->lc,NULL,&mgr->stat.number_of_LinphoneRegistrationOk, proxy_count,(REGISTER_TIMEOUT * 1000 * proxy_count)); if( !success ){ ms_error("Did not register after %d seconds for %d proxies", REGISTER_TIMEOUT, proxy_count); } } CU_ASSERT_EQUAL(mgr->stat.number_of_LinphoneRegistrationOk,proxy_count); enable_codec(mgr->lc,"PCMU",8000); linphone_core_get_default_proxy(mgr->lc,&proxy); if (proxy) { mgr->identity = linphone_address_new(linphone_proxy_config_get_identity(proxy)); linphone_address_clean(mgr->identity); } if (rc_path) ms_free(rc_path); return mgr; }
int main(int argc, char *argv[]){ LinphoneCoreVTable vtable={0}; MyAppData *data=ms_new0(MyAppData,1); char* identity=NULL; char* password=NULL; int i; LinphoneProxyConfig* proxy_cfg; LinphoneAddress *from; LinphoneAuthInfo *info; const char* server_addr; /* takes sip uri identity from the command line arguments */ if (argc>1){ identity=argv[1]; } /* takes password from the command line arguments */ if (argc>2){ password=argv[2]; } signal(SIGINT,stop); #ifdef DEBUG linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/ #endif /* Fill the LinphoneCoreVTable with application callbacks. All are optional. Here we only use the registration_state_changed callbacks in order to get notifications about the progress of the registration. */ vtable.registration_state_changed=registration_state_changed; vtable.subscription_state_changed=subscription_state_changed; /* Instanciate a LinphoneCore object given the LinphoneCoreVTable */ lc=linphone_core_new(&vtable,NULL,NULL,data); /*create proxy config*/ proxy_cfg = linphone_proxy_config_new(); /*parse identity*/ from = linphone_address_new(identity); if (from==NULL){ printf("%s not a valid sip uri, must be like sip:[email protected] \n",identity); goto end; } if (password!=NULL){ info=linphone_auth_info_new(linphone_address_get_username(from),NULL,password,NULL,NULL,NULL); /*create authentication structure from identity*/ linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/ } // configure proxy entries linphone_proxy_config_set_identity(proxy_cfg,identity); /*set identity with user name and domain*/ server_addr = linphone_address_get_domain(from); /*extract domain address from identity*/ linphone_proxy_config_set_server_addr(proxy_cfg,server_addr); /* we assume domain = proxy server address*/ linphone_proxy_config_enable_register(proxy_cfg,TRUE); /*activate registration for this proxy config*/ linphone_address_destroy(from); /*release resource*/ linphone_core_add_proxy_config(lc,proxy_cfg); /*add proxy config to linphone core*/ linphone_core_set_default_proxy(lc,proxy_cfg); /*set to default proxy*/ i=0; /* main loop for receiving notifications and doing background linphonecore work: */ while(running){ linphone_core_iterate(lc); /* first iterate initiates registration */ ms_usleep(50000); ++i; if (data->ev && i%100==0){ LinphoneContentPrivate content; content.type="application"; content.subtype="goodxml"; content.data="really cool"; content.size=strlen((const char*)content.data); linphone_event_notify(data->ev,LINPHONE_CONTENT(&content)); } } linphone_core_get_default_proxy(lc,&proxy_cfg); /* get default proxy config*/ linphone_proxy_config_edit(proxy_cfg); /*start editing proxy configuration*/ linphone_proxy_config_enable_register(proxy_cfg,FALSE); /*de-activate registration for this proxy config*/ linphone_proxy_config_done(proxy_cfg); /*initiate REGISTER with expire = 0*/ if (data->ev){ linphone_event_terminate(data->ev); } while(linphone_proxy_config_get_state(proxy_cfg) != LinphoneRegistrationCleared){ linphone_core_iterate(lc); /*to make sure we receive call backs before shutting down*/ ms_usleep(50000); } end: printf("Shutting down...\n"); linphone_core_destroy(lc); ms_free(data); printf("Exited\n"); return 0; }