diff --git a/CMakeLists.txt b/CMakeLists.txt index 86647c052..f83e275e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ option(ENABLE_CONSOLE_UI "Turn on or off compilation of console interface." YES) option(ENABLE_DATE "Use build date in internal version number." NO) cmake_dependent_option(ENABLE_DAEMON "Enable the linphone daemon interface." YES "NOT WIN32" NO) option(ENABLE_DOC "Enable documentation generation with Doxygen." YES) +option(ENABLE_JAVADOC "Add a target to generate documentation for Java API" NO) option(ENABLE_GTK_UI "Turn on or off compilation of gtk interface." YES) option(ENABLE_LDAP "Enable LDAP support." NO) option(ENABLE_LIME "Enable Instant Messaging Encryption." YES) diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index c1a6fb00e..ead252c1f 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -101,6 +101,14 @@ void linphone_account_creator_cbs_set_activate_phone_number_link(LinphoneAccount cbs->activate_phone_number_link = cb; } +void linphone_account_creator_cbs_set_is_account_linked(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { + cbs->is_account_linked = cb; +} + +LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_linked(const LinphoneAccountCreatorCbs *cbs) { + return cbs->is_account_linked; +} + LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_activated(const LinphoneAccountCreatorCbs *cbs) { return cbs->is_account_activated; } @@ -302,8 +310,11 @@ LinphoneAccountCreatorStatus linphone_account_creator_set_phone_number(LinphoneA // if phone is valid, we lastly want to check that length is OK { - const LinphoneDialPlan* plan = linphone_dial_plan_by_ccc(country_code); + const LinphoneDialPlan* plan = linphone_dial_plan_by_ccc(creator->phone_country_code); int size = (int)strlen(phone_number); + if (linphone_dial_plan_is_generic(plan)) { + return LinphoneAccountCreatorCountryCodeInvalid; + } if (size < plan->nnl - 1) { return LinphoneAccountCreatorPhoneNumberTooShort; } else if (size > plan->nnl + 1) { @@ -698,6 +709,36 @@ LinphoneAccountCreatorStatus linphone_account_creator_link_phone_number_with_acc linphone_xml_rpc_request_unref(request); return LinphoneAccountCreatorOK; } + +static void _get_phone_number_for_account_cb(LinphoneXmlRpcRequest *request) { + LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); + if (creator->callbacks->is_account_linked != NULL) { + LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + const char* resp = linphone_xml_rpc_request_get_string_response(request); + if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { + status = (strcmp(resp, "ERROR_USERNAME_PARAMETER_NOT_FOUND") == 0 + || strcmp(resp, "ERROR_ACCOUNT_DOESNT_EXIST") == 0 + || strcmp(resp, "ERROR_ALIAS_DOESNT_EXIST") == 0) ? LinphoneAccountCreatorAccountNotLinked : LinphoneAccountCreatorAccountLinked; + } + creator->callbacks->link_phone_number_with_account(creator, status, resp); + } +} + +LinphoneAccountCreatorStatus linphone_account_creator_is_account_linked(LinphoneAccountCreator *creator) { + LinphoneXmlRpcRequest *request; + if (!creator->username || !creator->domain) { + return LinphoneAccountCreatorReqFailed; + } + request = linphone_xml_rpc_request_new_with_args("get_phone_number_for_account",LinphoneXmlRpcArgString, + LinphoneXmlRpcArgString, creator->username, + LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgNone); + linphone_xml_rpc_request_set_user_data(request, creator); + linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _get_phone_number_for_account_cb); + linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); + linphone_xml_rpc_request_unref(request); + return LinphoneAccountCreatorOK; +} /****************** END OF LINK PHONE NUMBER WITH ACCOUNT SECTION *************/ /****************** START OF ACTIVE PHONE NUMBER LINK **************************/ diff --git a/coreapi/account_creator.h b/coreapi/account_creator.h index 32a4cd9ad..f8400f02d 100644 --- a/coreapi/account_creator.h +++ b/coreapi/account_creator.h @@ -49,6 +49,9 @@ typedef enum _LinphoneAccountCreatorStatus { LinphoneAccountCreatorAccountAlreadyActivated, LinphoneAccountCreatorAccountNotActivated, + LinphoneAccountCreatorAccountLinked, + LinphoneAccountCreatorAccountNotLinked, + LinphoneAccountCreatorEmailInvalid, LinphoneAccountCreatorUsernameInvalid, LinphoneAccountCreatorUsernameTooShort, @@ -63,6 +66,7 @@ typedef enum _LinphoneAccountCreatorStatus { LinphoneAccountCreatorRouteInvalid, LinphoneAccountCreatorDisplayNameInvalid, LinphoneAccountCreatorTransportNotSupported, + LinphoneAccountCreatorCountryCodeInvalid, } LinphoneAccountCreatorStatus; /** @@ -311,6 +315,13 @@ LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_activate_p LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_recover_phone_account(LinphoneAccountCreator *creator); +/** + * Send an XML-RPC request to ask if an account is linked with a phone number + * @param[in] creator LinphoneAccountCreator object + * @return if this account is linked with a phone number +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_is_account_linked(LinphoneAccountCreator *creator); + /** * Configure an account (create a proxy config and authentication info for it). * @param[in] creator LinphoneAccountCreator object @@ -345,6 +356,20 @@ LINPHONE_PUBLIC void *linphone_account_creator_cbs_get_user_data(const LinphoneA **/ LINPHONE_PUBLIC void linphone_account_creator_cbs_set_user_data(LinphoneAccountCreatorCbs *cbs, void *ud); +/** + * Get the current linked tested callback. + * @param[in] cbs LinphoneAccountCreatorCbs object. + * @return The current linked tested callback. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_linked(const LinphoneAccountCreatorCbs *cbs); + +/** + * Set the linked tested callback + * @param[in] cbs LinphoneAccountCreatorCbs object. + * @param[in] cb The existence tested callback to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_cbs_set_is_account_linked(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); + /** * Get the existence tested callback. * @param[in] cbs LinphoneAccountCreatorCbs object. diff --git a/coreapi/bellesip_sal/sal_op_impl.c b/coreapi/bellesip_sal/sal_op_impl.c index 2608b453e..634bd22fb 100644 --- a/coreapi/bellesip_sal/sal_op_impl.c +++ b/coreapi/bellesip_sal/sal_op_impl.c @@ -355,6 +355,9 @@ static int _sal_op_send_request_with_contact(SalOp* op, belle_sip_request_t* req } #endif } + /*because in case of tunnel, transport can be changed*/ + transport=belle_sip_uri_get_transport_param(next_hop_uri); + if ((strcmp(method,"REGISTER")==0 || strcmp(method,"SUBSCRIBE")==0) && transport && (strcasecmp(transport,"TCP")==0 || strcasecmp(transport,"TLS")==0)){ /*RFC 5923: add 'alias' parameter to tell the server that we want it to keep the connection for future requests*/ diff --git a/coreapi/dial_plan.c b/coreapi/dial_plan.c index 4f23b05e6..bcd9c3ae4 100644 --- a/coreapi/dial_plan.c +++ b/coreapi/dial_plan.c @@ -310,3 +310,9 @@ const LinphoneDialPlan* linphone_dial_plan_by_ccc(const char *ccc) { const LinphoneDialPlan* linphone_dial_plan_get_all() { return dial_plans; } + +const bool_t linphone_dial_plan_is_generic(const LinphoneDialPlan *ccc) { + if (strcmp(ccc->country, most_common_dialplan.country) == 0) + return TRUE; + return FALSE; +} diff --git a/coreapi/event.c b/coreapi/event.c index f4f69b7a5..c50ca460d 100644 --- a/coreapi/event.c +++ b/coreapi/event.c @@ -70,9 +70,8 @@ LINPHONE_PUBLIC const char *linphone_publish_state_to_string(LinphonePublishStat static void linphone_event_release(LinphoneEvent *lev){ if (lev->op) { - /*this will stop the refreesher*/ - sal_op_release(lev->op); - lev->op = NULL; + /*this will stop the refresher*/ + sal_op_stop_refreshing(lev->op); } linphone_event_unref(lev); } @@ -133,14 +132,9 @@ void linphone_event_set_publish_state(LinphoneEvent *lev, LinphonePublishState s linphone_core_notify_publish_state_changed(lev->lc,lev,state); switch(state){ case LinphonePublishCleared: - if (lev->expires!=-1){ - linphone_event_release(lev); - } + linphone_event_release(lev); break; case LinphonePublishOk: - if (lev->expires==-1){ - linphone_event_release(lev); - } break; case LinphonePublishError: linphone_event_release(lev); @@ -200,7 +194,7 @@ int linphone_event_send_subscribe(LinphoneEvent *lev, const LinphoneContent *bod switch (lev->subscription_state){ case LinphoneSubscriptionIncomingReceived: case LinphoneSubscriptionTerminated: - case LinphoneSubscriptionOutgoingInit: + case LinphoneSubscriptionOutgoingProgress: ms_error("linphone_event_send_subscribe(): cannot update subscription while in state [%s]", linphone_subscription_state_to_string(lev->subscription_state)); return -1; break; @@ -223,7 +217,7 @@ int linphone_event_send_subscribe(LinphoneEvent *lev, const LinphoneContent *bod err=sal_subscribe(lev->op,NULL,NULL,lev->name,lev->expires,body_handler); if (err==0){ if (lev->subscription_state==LinphoneSubscriptionNone) - linphone_event_set_state(lev,LinphoneSubscriptionOutgoingInit); + linphone_event_set_state(lev,LinphoneSubscriptionOutgoingProgress); } return err; } @@ -372,8 +366,8 @@ void linphone_event_terminate(LinphoneEvent *lev){ if (lev->publish_state!=LinphonePublishNone){ if (lev->publish_state==LinphonePublishOk && lev->expires!=-1){ - sal_publish(lev->op,NULL,NULL,NULL,0,NULL); - }else sal_op_unpublish(lev->op); + sal_op_unpublish(lev->op); + } linphone_event_set_publish_state(lev,LinphonePublishCleared); return; } diff --git a/coreapi/event.h b/coreapi/event.h index 7f281b629..247df2a9d 100644 --- a/coreapi/event.h +++ b/coreapi/event.h @@ -49,6 +49,7 @@ typedef enum _LinphoneSubscriptionDir LinphoneSubscriptionDir; /** * Enum for subscription states. + * LinphoneSubscriptionTerminated and LinphoneSubscriptionError are final states. **/ enum _LinphoneSubscriptionState{ LinphoneSubscriptionNone, /**< Initial state, should not be used.**/ @@ -57,13 +58,10 @@ enum _LinphoneSubscriptionState{ LinphoneSubscriptionPending, /**refresh_generic_subscribe property is set to 0.*/ }; -/*typo compatibility*/ -#define LinphoneSubscriptionOutoingInit LinphoneSubscriptionOutgoingInit -#define LinphoneSubscriptionOutgoingInit LinphoneSubscriptionOutgoingProgress /** * Typedef for subscription state enum. **/ diff --git a/coreapi/help/CMakeLists.txt b/coreapi/help/CMakeLists.txt index f407e72e9..64a18c024 100644 --- a/coreapi/help/CMakeLists.txt +++ b/coreapi/help/CMakeLists.txt @@ -45,6 +45,25 @@ if (ENABLE_DOC) endif() endif() +if(ENABLE_JAVADOC) + find_package(Java REQUIRED) + set(JAVADOC_PACKAGES "org.linphone.core org.linphone.mediastream") + set(JAVADOC_CLASSPATHS + "${PROJECT_SOURCE_DIR}/java/common" + "${PROJECT_SOURCE_DIR}/java/j2se" + "${PROJECT_SOURCE_DIR}/mediastreamer2/java/src" + ) + string(REPLACE ";" ":" JAVADOC_CLASSPATHS "${JAVADOC_CLASSPATHS}") + set(JAVADOC_TITLE "Linphone SDK ${PROJECT_VERSION} reference documentation") + set(JAVADOC_JAVA_REFERENCE "http://docs.oracle.com/javase/8/docs/api/") + set(JAVADOC_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc/java") + set(JAVADOC_LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/javadoc.log") + configure_file("generate_javadoc.sh.in" "generate_javadoc.sh" @ONLY) + add_custom_target(javadoc ALL + COMMAND "${CMAKE_CURRENT_BINARY_DIR}/generate_javadoc.sh" + ) +endif() + if (ENABLE_TOOLS) set(USE_BUNDLE ) if (IOS) diff --git a/coreapi/help/generate_javadoc.sh.in b/coreapi/help/generate_javadoc.sh.in new file mode 100755 index 000000000..b2af1b048 --- /dev/null +++ b/coreapi/help/generate_javadoc.sh.in @@ -0,0 +1,11 @@ +#!/bin/bash + +packages='@JAVADOC_PACKAGES@' +classpaths='@JAVADOC_CLASSPATHS@' +title='@JAVADOC_TITLE@' +javaref='@JAVADOC_JAVA_REFERENCE@' +outputdir='@JAVADOC_OUTPUT_DIR@' + +@Java_JAVADOC_EXECUTABLE@ ${packages} -classpath ${classpaths} -doctitle "${title}" -link ${javaref} -d ${outputdir} 2>&1 | tee @JAVADOC_LOGFILE@ +grep -E '^[0-9]{1,3} errors?' @JAVADOC_LOGFILE@ &> /dev/null && exit 1 +exit 0 diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 9ce22d197..244673afd 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -5056,12 +5056,17 @@ void linphone_call_repair_if_broken(LinphoneCall *call){ LinphoneCallParams *params; if (!call->broken) return; - - /*First, make sure that the proxy from which we received this call, or to which we routed this call is registered*/ - if (!call->dest_proxy || linphone_proxy_config_get_state(call->dest_proxy) != LinphoneRegistrationOk) return; - if (!call->core->media_network_reachable) return; + /*Make sure that the proxy from which we received this call, or to which we routed this call is registered first*/ + if (call->dest_proxy){ + /*in all other cases, ie no proxy config, or a proxy config for which no registration was requested, we can start the + * call repair immediately.*/ + if (linphone_proxy_config_register_enabled(call->dest_proxy) + && linphone_proxy_config_get_state(call->dest_proxy) != LinphoneRegistrationOk) return; + } + + switch (call->state){ case LinphoneCallStreamsRunning: case LinphoneCallPaused: diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 0ad4bb216..057b3dde7 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2411,6 +2411,17 @@ static bool_t transports_unchanged(const LCSipTransports * tr1, const LCSipTrans tr2->tls_port==tr1->tls_port; } +static void __linphone_core_invalidate_registers(LinphoneCore* lc){ + const bctbx_list_t *elem=linphone_core_get_proxy_config_list(lc); + for(;elem!=NULL;elem=elem->next){ + LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data; + if (linphone_proxy_config_register_enabled(cfg)) { + /*this will force a re-registration at next iterate*/ + cfg->commit = TRUE; + } + } +} + int _linphone_core_apply_transports(LinphoneCore *lc){ Sal *sal=lc->sal; const char *anyaddr; @@ -5103,7 +5114,7 @@ void linphone_core_enable_mic(LinphoneCore *lc, bool_t enable) { call = (LinphoneCall *)elem->data; call->audio_muted = !enable; if (call->audiostream) - linphone_core_mute_audio_stream(lc, call->audiostream, enable); + linphone_core_mute_audio_stream(lc, call->audiostream, call->audio_muted); } } @@ -6514,14 +6525,7 @@ void sip_config_uninit(LinphoneCore *lc) lc->auth_info=bctbx_list_free_with_data(lc->auth_info,(void (*)(void*))linphone_auth_info_destroy); - /*now that we are unregisted, we no longer need the tunnel.*/ -#ifdef TUNNEL_ENABLED - if (lc->tunnel) { - linphone_tunnel_destroy(lc->tunnel); - lc->tunnel=NULL; - ms_message("Tunnel destroyed."); - } -#endif + if (lc->vcard_context) { linphone_vcard_context_destroy(lc->vcard_context); @@ -6537,9 +6541,20 @@ void sip_config_uninit(LinphoneCore *lc) belle_sip_object_unref(lc->http_crypto_config); lc->http_crypto_config=NULL; } + + /*now that we are unregisted, there is no more channel using tunnel socket we no longer need the tunnel.*/ +#ifdef TUNNEL_ENABLED + if (lc->tunnel) { + linphone_tunnel_destroy(lc->tunnel); + lc->tunnel=NULL; + ms_message("Tunnel destroyed."); + } +#endif + sal_iterate(lc->sal); /*make sure event are purged*/ sal_uninit(lc->sal); lc->sal=NULL; + if (lc->sip_conf.guessed_contact) ms_free(lc->sip_conf.guessed_contact); @@ -6876,16 +6891,6 @@ void linphone_core_refresh_registers(LinphoneCore* lc) { } } -void __linphone_core_invalidate_registers(LinphoneCore* lc){ - const bctbx_list_t *elem=linphone_core_get_proxy_config_list(lc); - for(;elem!=NULL;elem=elem->next){ - LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data; - if (linphone_proxy_config_register_enabled(cfg)) { - linphone_proxy_config_edit(cfg); - linphone_proxy_config_done(cfg); - } - } -} static void disable_internal_network_reachability_detection(LinphoneCore *lc){ if (lc->auto_net_state_mon) { @@ -7431,6 +7436,10 @@ void linphone_core_set_media_encryption_mandatory(LinphoneCore *lc, bool_t m) { void linphone_core_init_default_params(LinphoneCore*lc, LinphoneCallParams *params) { params->has_audio = TRUE; params->has_video=linphone_core_video_enabled(lc) && lc->video_policy.automatically_initiate; + if (!linphone_core_video_enabled(lc) && lc->video_policy.automatically_initiate){ + ms_error("LinphoneCore has video disabled for both capture and display, but video policy is to start the call with video. " + "This is a possible mis-use of the API. In this case, video is disabled in default LinphoneCallParams"); + } params->media_encryption=linphone_core_get_media_encryption(lc); params->in_conference=FALSE; params->realtimetext_enabled = linphone_core_realtime_text_enabled(lc); diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 1e3f9a8c7..d81056acf 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -189,7 +189,7 @@ enum _LinphoneReason{ LinphoneReasonIOError, /**NewStringUTF(ms_factory_get_encoder(linphone_core_get_ms_factory(lc), jpayload->mime_type)->text); + return jencodername; +} + +extern "C" jstring Java_org_linphone_core_LinphoneCallStatsImpl_getDecoderName(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr, jlong payload_ptr) { + LinphoneCore *lc = linphone_call_get_core((LinphoneCall*)call_ptr); + PayloadType* jpayload = (PayloadType*)payload_ptr; + jstring jdecodername =env->NewStringUTF(ms_factory_get_decoder(linphone_core_get_ms_factory(lc), jpayload->mime_type)->text); + return jdecodername; +} + /*payloadType*/ extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) { PayloadType* pt = (PayloadType*)ptr; @@ -8052,6 +8066,32 @@ static void account_creator_activate_phone_number_link(LinphoneAccountCreator *c ms_error("cannot attach VM\n"); return; } + + LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); + jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + if (listener == NULL) { + ms_error("account_creator_response() notification without listener"); + return ; + } + + LinphoneCore *lc = (LinphoneCore *)creator->core; + LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); + + jclass clazz = (jclass) env->GetObjectClass(listener); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorPhoneNumberLinkActivated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + env->DeleteLocalRef(clazz); + + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); +} + +static void account_creator_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { + JNIEnv *env = 0; + jint result = jvm->AttachCurrentThread(&env,NULL); + if (result != 0) { + ms_error("cannot attach VM\n"); + return; + } LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); @@ -8064,7 +8104,7 @@ static void account_creator_activate_phone_number_link(LinphoneAccountCreator *c LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorPhoneNumberLinkActivated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorIsAccountLinked","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); env->DeleteLocalRef(clazz); jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); @@ -8301,6 +8341,11 @@ extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_activateAccoun return (jint) linphone_account_creator_activate_account(account_creator); } +extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_isAccountLinked(JNIEnv *env, jobject thiz, jlong ptr) { + LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; + return (jint) linphone_account_creator_is_account_linked(account_creator); +} + extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_isAccountActivated(JNIEnv *env, jobject thiz, jlong ptr) { LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; return (jint) linphone_account_creator_is_account_activated(account_creator); diff --git a/coreapi/linphonecore_utils.h b/coreapi/linphonecore_utils.h index 1eb87893f..30c3f583d 100644 --- a/coreapi/linphonecore_utils.h +++ b/coreapi/linphonecore_utils.h @@ -134,6 +134,11 @@ LINPHONE_PUBLIC const LinphoneDialPlan* linphone_dial_plan_get_all(void); **/ LINPHONE_PUBLIC const LinphoneDialPlan* linphone_dial_plan_by_ccc(const char *ccc); +/** + * Return if given plan is generic +**/ +LINPHONE_PUBLIC const bool_t linphone_dial_plan_is_generic(const LinphoneDialPlan *ccc); + #ifdef __cplusplus } #endif diff --git a/coreapi/private.h b/coreapi/private.h index fcce6908e..d5a418c84 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -652,6 +652,9 @@ struct _LinphoneProxyConfig /*use to check if server config has changed between edit() and done()*/ LinphoneAddress *saved_proxy; LinphoneAddress *saved_identity; + int saved_expires; + bool_t saved_sendregister; + bool_t unused[3]; /*---*/ LinphoneAddress *pending_contact; /*use to store previous contact in case of network failure*/ LinphoneEvent *long_term_event; @@ -1160,7 +1163,6 @@ bool_t linphone_core_sound_resources_available(LinphoneCore *lc); void linphone_core_notify_refer_state(LinphoneCore *lc, LinphoneCall *referer, LinphoneCall *newcall); unsigned int linphone_core_get_audio_features(LinphoneCore *lc); -void __linphone_core_invalidate_registers(LinphoneCore* lc); void _linphone_core_codec_config_write(LinphoneCore *lc); #define HOLD_OFF (0) @@ -1336,6 +1338,7 @@ struct _LinphoneAccountCreatorCbs { LinphoneAccountCreatorCbsStatusCb link_phone_number_with_account; LinphoneAccountCreatorCbsStatusCb activate_phone_number_link; LinphoneAccountCreatorCbsStatusCb recover_phone_account; + LinphoneAccountCreatorCbsStatusCb is_account_linked; }; BELLE_SIP_DECLARE_VPTR(LinphoneAccountCreatorCbs); diff --git a/coreapi/proxy.c b/coreapi/proxy.c index b15c57453..a3b963a43 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -29,6 +29,7 @@ Copyright (C) 2000 Simon MORLAT (simon.morlat@linphone.org) /*store current config related to server location*/ static void linphone_proxy_config_store_server_config(LinphoneProxyConfig* cfg) { + cfg->saved_sendregister = cfg->reg_sendregister; if (cfg->saved_identity) linphone_address_destroy(cfg->saved_identity); if (cfg->identity_address) cfg->saved_identity = linphone_address_clone(cfg->identity_address); @@ -64,7 +65,7 @@ LinphoneProxyConfigAddressComparisonResult linphone_proxy_config_is_server_confi LinphoneAddress *current_proxy=cfg->reg_proxy?linphone_address_new(cfg->reg_proxy):NULL; LinphoneProxyConfigAddressComparisonResult result_identity; LinphoneProxyConfigAddressComparisonResult result; - + result = linphone_proxy_config_address_equal(cfg->saved_identity,cfg->identity_address); if (result == LinphoneProxyConfigAddressDifferent) goto end; result_identity = result; @@ -79,6 +80,7 @@ LinphoneProxyConfigAddressComparisonResult linphone_proxy_config_is_server_confi end: if (current_proxy) linphone_address_destroy(current_proxy); + ms_message("linphone_proxy_config_is_server_config_changed : %i", result); return result; } @@ -762,7 +764,7 @@ int linphone_proxy_config_done(LinphoneProxyConfig *cfg) if (!linphone_proxy_config_check(cfg->lc,cfg)) return -1; - /*check if server address as changed*/ + /*check if server address has changed*/ res = linphone_proxy_config_is_server_config_changed(cfg); if (res != LinphoneProxyConfigAddressEqual) { /* server config has changed, need to unregister from previous first*/ @@ -778,22 +780,26 @@ int linphone_proxy_config_done(LinphoneProxyConfig *cfg) if (res == LinphoneProxyConfigAddressDifferent) { _linphone_proxy_config_unpublish(cfg); } - } + cfg->commit = TRUE; } + if ((cfg->saved_sendregister != cfg->reg_sendregister) + || (cfg->saved_expires != cfg->expires)){ + cfg->commit = TRUE; + } + if (linphone_proxy_config_compute_publish_params_hash(cfg)) { ms_message("Publish params have changed on proxy config [%p]",cfg); if (cfg->long_term_event) { - if (!cfg->publish) { - /*publish is terminated*/ - linphone_event_terminate(cfg->long_term_event); - } else { + if (cfg->publish) { const char * sip_etag = linphone_event_get_custom_header(cfg->long_term_event, "SIP-ETag"); if (sip_etag) { if (cfg->sip_etag) ms_free(cfg->sip_etag); cfg->sip_etag = ms_strdup(sip_etag); } } + /*publish is terminated*/ + linphone_event_terminate(cfg->long_term_event); linphone_event_unref(cfg->long_term_event); cfg->long_term_event = NULL; } @@ -801,7 +807,7 @@ int linphone_proxy_config_done(LinphoneProxyConfig *cfg) } else { ms_message("Publish params have not changed on proxy config [%p]",cfg); } - cfg->commit=TRUE; + linphone_proxy_config_write_all_to_config_file(cfg->lc); return 0; } diff --git a/java/common/org/linphone/core/LinphoneAccountCreator.java b/java/common/org/linphone/core/LinphoneAccountCreator.java index 9bf198658..298a4acb9 100644 --- a/java/common/org/linphone/core/LinphoneAccountCreator.java +++ b/java/common/org/linphone/core/LinphoneAccountCreator.java @@ -30,6 +30,7 @@ public interface LinphoneAccountCreator { void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, Status status); void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, Status status); void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, Status status); + void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, Status status); } public static class Status { @@ -48,20 +49,23 @@ public interface LinphoneAccountCreator { public final static Status AccountActivated = new Status(7, "AccountActivated"); public final static Status AccountAlreadyActivated = new Status(8, "AccountAlreadyActivated"); public final static Status AccountNotActivated = new Status(9, "AccountNotActivated"); - public final static Status EmailInvalid = new Status(10, "EmailInvalid"); - public final static Status UsernameInvalid = new Status(11, "UsernameInvalid"); - public final static Status UsernameTooShort = new Status(12, "UsernameTooShort"); - public final static Status UsernameTooLong = new Status(13, "UsernameTooLong"); - public final static Status UsernameInvalidSize = new Status(14, "UsernameInvalidSize"); - public final static Status PhoneNumberInvalid = new Status(15, "PhoneNumberInvalid"); - public final static Status PhoneNumberTooShort = new Status(16, "PhoneNumberTooShort"); - public final static Status PhoneNumberTooLong = new Status(17, "PhoneNumberTooLong"); - public final static Status PasswordTooShort = new Status(18, "PasswordTooShort"); - public final static Status PasswordTooLong = new Status(19, "PasswordTooLong"); - public final static Status DomainInvalid = new Status(20, "DomainInvalid"); - public final static Status RouteInvalid = new Status(21, "RouteInvalid"); - public final static Status DisplayNameInvalid = new Status(22, "DisplayNameInvalid"); - public final static Status TransportNotSupported = new Status(23, "TransportNotSupported"); + public final static Status AccountLinked = new Status(10, "AccountLinked"); + public final static Status AccountNotLinked = new Status(11, "AccountNotLinked"); + public final static Status EmailInvalid = new Status(12, "EmailInvalid"); + public final static Status UsernameInvalid = new Status(13, "UsernameInvalid"); + public final static Status UsernameTooShort = new Status(14, "UsernameTooShort"); + public final static Status UsernameTooLong = new Status(15, "UsernameTooLong"); + public final static Status UsernameInvalidSize = new Status(16, "UsernameInvalidSize"); + public final static Status PhoneNumberInvalid = new Status(17, "PhoneNumberInvalid"); + public final static Status PhoneNumberTooShort = new Status(18, "PhoneNumberTooShort"); + public final static Status PhoneNumberTooLong = new Status(19, "PhoneNumberTooLong"); + public final static Status PasswordTooShort = new Status(20, "PasswordTooShort"); + public final static Status PasswordTooLong = new Status(21, "PasswordTooLong"); + public final static Status DomainInvalid = new Status(22, "DomainInvalid"); + public final static Status RouteInvalid = new Status(23, "RouteInvalid"); + public final static Status DisplayNameInvalid = new Status(24, "DisplayNameInvalid"); + public final static Status TransportNotSupported = new Status(25, "TransportNotSupported"); + public final static Status CountryCodeInvalid = new Status(26, "CountryCodeInvalid"); private Status(int value, String stringValue) { mValue = value; @@ -137,7 +141,9 @@ public interface LinphoneAccountCreator { Status linkPhoneNumberWithAccount(); Status activatePhoneNumberLink(); - + + Status isAccountLinked(); + Status recoverPhoneAccount(); LinphoneProxyConfig configure(); diff --git a/java/common/org/linphone/core/LinphoneCallStats.java b/java/common/org/linphone/core/LinphoneCallStats.java index 20d40185d..4f56f9ec3 100644 --- a/java/common/org/linphone/core/LinphoneCallStats.java +++ b/java/common/org/linphone/core/LinphoneCallStats.java @@ -177,4 +177,18 @@ public interface LinphoneCallStats { * @return The local late rate percentage. **/ public float getLocalLateRate(); + + /** + * Get the encoder name of specified payload + * @param pl payload + * @return The name of encoder + */ + public String getEncoderName(PayloadType pl); + + /** + * Get the decoder name of specified payload + * @param pl payload + * @return The name of decoder + */ + public String getDecoderName(PayloadType pl); } diff --git a/java/common/org/linphone/core/LinphoneCoreFactory.java b/java/common/org/linphone/core/LinphoneCoreFactory.java index 80ca5f82c..7b33532d2 100644 --- a/java/common/org/linphone/core/LinphoneCoreFactory.java +++ b/java/common/org/linphone/core/LinphoneCoreFactory.java @@ -181,4 +181,9 @@ abstract public class LinphoneCoreFactory { * Create TunnelConfig object, used to configure voip anti blocking extension. */ abstract public TunnelConfig createTunnelConfig(); + + /** + * Create LinphoneAccountCreator object + */ + abstract public LinphoneAccountCreator createAccountCreator(LinphoneCore lc, String url); } diff --git a/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java b/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java index aa6a0199b..d47cedc7e 100644 --- a/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java +++ b/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java @@ -177,6 +177,12 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { public Status activateAccount() { return Status.fromInt(activateAccount(nativePtr)); } + + private native int isAccountLinked(long ptr); + @Override + public Status isAccountLinked() { + return Status.fromInt(isAccountLinked(nativePtr)); + } private native int isAccountActivated(long ptr); @Override diff --git a/java/impl/org/linphone/core/LinphoneCallStatsImpl.java b/java/impl/org/linphone/core/LinphoneCallStatsImpl.java index 3897c03f6..3c68bffd7 100644 --- a/java/impl/org/linphone/core/LinphoneCallStatsImpl.java +++ b/java/impl/org/linphone/core/LinphoneCallStatsImpl.java @@ -34,6 +34,7 @@ class LinphoneCallStatsImpl implements LinphoneCallStats { private float localLossRate; private float localLateRate; private long nativePtr; + private long nativeCPtr; private native int getMediaType(long nativeStatsPtr); private native int getIceState(long nativeStatsPtr); @@ -48,10 +49,13 @@ class LinphoneCallStatsImpl implements LinphoneCallStats { private native float getJitterBufferSize(long nativeStatsPtr); private native float getLocalLossRate(long nativeStatsPtr); private native float getLocalLateRate(long nativeStatsPtr); + private native String getEncoderName(long nativeStatsPtr, long nativeCallPtr, long payloadPtr); + private native String getDecoderName(long nativeStatsPtr, long nativeCallPtr, long payloadPtr); private native void updateStats(long nativeCallPtr, int mediaType); protected LinphoneCallStatsImpl(long nativeCallPtr, long nativeStatsPtr) { - nativePtr=nativeStatsPtr; + nativePtr = nativeStatsPtr; + nativeCPtr = nativeCallPtr; mediaType = getMediaType(nativeStatsPtr); iceState = getIceState(nativeStatsPtr); downloadBandwidth = getDownloadBandwidth(nativeStatsPtr); @@ -123,4 +127,16 @@ class LinphoneCallStatsImpl implements LinphoneCallStats { public float getLocalLateRate(){ return localLateRate; } + + public String getEncoderName(PayloadType pl) { + if (pl == null) + return ""; + return getEncoderName(nativePtr, nativeCPtr, ((PayloadTypeImpl)pl).nativePtr); + } + + public String getDecoderName(PayloadType pl) { + if (pl == null) + return ""; + return getDecoderName(nativePtr, nativeCPtr, ((PayloadTypeImpl)pl).nativePtr); + } } diff --git a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java index 11cb0d87e..3e6a07e22 100644 --- a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java @@ -239,4 +239,9 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { public TunnelConfig createTunnelConfig() { return (TunnelConfig)_createTunnelConfig(); } + + @Override + public LinphoneAccountCreator createAccountCreator(LinphoneCore lc, String url) { + return new LinphoneAccountCreatorImpl(lc, url); + } } diff --git a/mediastreamer2 b/mediastreamer2 index 26f884bf9..8b4fca52b 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 26f884bf977977041fe6f98a0af186be1580bf22 +Subproject commit 8b4fca52b0e6939f908a33da9952cf4a8c862a07 diff --git a/tester/call_multi_tester.c b/tester/call_multi_tester.c index 9a23a3205..7b1e85778 100644 --- a/tester/call_multi_tester.c +++ b/tester/call_multi_tester.c @@ -254,19 +254,21 @@ static void simple_conference_base(LinphoneCoreManager* marie, LinphoneCoreManag bool_t is_remote_conf; bool_t focus_is_up = (focus && ((LinphoneConferenceServer *)focus)->reg_state == LinphoneRegistrationOk); bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); + lcs=bctbx_list_append(lcs,pauline->lc); lcs=bctbx_list_append(lcs,laure->lc); - if(focus) lcs=bctbx_list_append(lcs,focus->lc); + if (focus) lcs=bctbx_list_append(lcs,focus->lc); is_remote_conf = (strcmp(lp_config_get_string(marie->lc->config, "misc", "conference_type", "local"), "remote") == 0); if(is_remote_conf) BC_ASSERT_PTR_NOT_NULL(focus); - BC_ASSERT_TRUE(call(marie,pauline)); + if (!BC_ASSERT_TRUE(call(marie,pauline))) goto end; + marie_call_pauline=linphone_core_get_current_call(marie->lc); pauline_called_by_marie=linphone_core_get_current_call(pauline->lc); BC_ASSERT_TRUE(pause_call_1(marie,marie_call_pauline,pauline,pauline_called_by_marie)); - BC_ASSERT_TRUE(call(marie,laure)); + if (!BC_ASSERT_TRUE(call(marie,laure))) goto end; initial_marie_stat=marie->stat; initial_pauline_stat=pauline->stat; initial_laure_stat=laure->stat; diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index 6e265113b..872a77efb 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -1381,8 +1381,8 @@ static void call_with_custom_headers(void) { linphone_call_params_add_custom_header(params,"Weather","bad"); linphone_call_params_add_custom_header(params,"Working","yes"); - BC_ASSERT_TRUE(call_with_caller_params(pauline,marie,params)); - linphone_call_params_destroy(params); + if (!BC_ASSERT_TRUE(call_with_caller_params(pauline,marie,params))) goto end; + call_marie=linphone_core_get_current_call(marie->lc); call_pauline=linphone_core_get_current_call(pauline->lc); @@ -1419,7 +1419,9 @@ static void call_with_custom_headers(void) { ms_free(marie_remote_contact_header); end_call(pauline, marie); - + +end: + linphone_call_params_destroy(params); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } diff --git a/tester/call_video_tester.c b/tester/call_video_tester.c index 2c5e7bc06..03e631207 100644 --- a/tester/call_video_tester.c +++ b/tester/call_video_tester.c @@ -871,22 +871,50 @@ static void _call_with_ice_video(LinphoneVideoPolicy caller_policy, LinphoneVide bool_t video_added_by_caller, bool_t video_added_by_callee, bool_t video_removed_by_caller, bool_t video_removed_by_callee) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - bool_t call_ok; unsigned int nb_media_starts = 1; + const LinphoneCallParams *marie_remote_params; + const LinphoneCallParams *pauline_current_params; + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, TRUE); linphone_core_set_video_policy(pauline->lc, &caller_policy); linphone_core_set_video_policy(marie->lc, &callee_policy); linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); + /* This is to activate media relay on Flexisip server. + * Indeed, we want to test ICE with relay candidates as well, even though + * they will not be used at the end.*/ + linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); + linphone_core_set_user_agent(pauline->lc,"Natted Linphone",NULL); + linphone_core_set_audio_port(marie->lc, -1); linphone_core_set_video_port(marie->lc, -1); linphone_core_set_audio_port(pauline->lc, -1); linphone_core_set_video_port(pauline->lc, -1); - BC_ASSERT_TRUE(call_ok = call(pauline, marie)); - if (!call_ok) goto end; - + + linphone_core_invite_address(pauline->lc, marie->identity); + if (!BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallIncomingReceived, 1))) goto end; + marie_remote_params = linphone_call_get_remote_params(linphone_core_get_current_call(marie->lc)); + BC_ASSERT_PTR_NOT_NULL(marie_remote_params); + if (marie_remote_params){ + BC_ASSERT_TRUE(linphone_call_params_video_enabled(marie_remote_params) == caller_policy.automatically_initiate); + } + + linphone_core_accept_call(marie->lc, linphone_core_get_current_call(marie->lc)); + BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1) + && wait_for(pauline->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1)); + + pauline_current_params = linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc)); + BC_ASSERT_PTR_NOT_NULL(pauline_current_params); + if (pauline_current_params){ + BC_ASSERT_TRUE(linphone_call_params_video_enabled(pauline_current_params) == + (caller_policy.automatically_initiate && callee_policy.automatically_accept)); + } + /* Wait for ICE reINVITEs to complete. */ BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2) && wait_for(pauline->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2)); @@ -954,7 +982,11 @@ static void call_with_ice_video_added_with_video_policies_to_false(void) { _call_with_ice_video(vpol, vpol, FALSE, TRUE, FALSE, FALSE); } -#if ICE_WAS_WORKING_WITH_REAL_TIME_TEXT /*which is not the case at the moment*/ +static void call_with_ice_video_declined_then_added_by_callee(void) { + LinphoneVideoPolicy caller_policy = { TRUE, TRUE }; + LinphoneVideoPolicy callee_policy = { FALSE, FALSE }; + _call_with_ice_video(caller_policy, callee_policy, FALSE, TRUE, FALSE, FALSE); +} static void call_with_ice_video_and_rtt(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); @@ -980,7 +1012,7 @@ static void call_with_ice_video_and_rtt(void) { linphone_core_set_video_port(pauline->lc, -1); linphone_core_set_text_port(pauline->lc, -1); - params = linphone_core_create_default_call_parameters(pauline->lc); + params = linphone_core_create_call_params(pauline->lc, NULL); linphone_call_params_enable_realtime_text(params, TRUE); BC_ASSERT_TRUE(call_ok = call_with_caller_params(pauline, marie, params)); if (!call_ok) goto end; @@ -998,7 +1030,6 @@ end: linphone_core_manager_destroy(pauline); } -#endif static void video_call_with_early_media_no_matching_audio_codecs(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); @@ -1750,9 +1781,8 @@ test_t call_video_tests[] = { TEST_ONE_TAG("Call with ICE and video added 3", call_with_ice_video_added_3, "ICE"), TEST_ONE_TAG("Call with ICE and video added and refused", call_with_ice_video_added_and_refused, "ICE"), TEST_ONE_TAG("Call with ICE and video added with video policies to false", call_with_ice_video_added_with_video_policies_to_false, "ICE"), -#if ICE_WAS_WORKING_WITH_REAL_TIME_TEXT + TEST_ONE_TAG("Call with ICE and video declined then added by callee", call_with_ice_video_declined_then_added_by_callee, "ICE"), TEST_ONE_TAG("Call with ICE, video and realtime text", call_with_ice_video_and_rtt, "ICE"), -#endif TEST_ONE_TAG("Video call with ICE accepted using call params", video_call_ice_params, "ICE"), TEST_ONE_TAG("Audio call with ICE paused with caller video policy enabled", audio_call_with_ice_with_video_policy_enabled, "ICE"), TEST_NO_TAG("Video call recording (H264)", video_call_recording_h264_test), diff --git a/tester/eventapi_tester.c b/tester/eventapi_tester.c index e98e40c70..76533857b 100644 --- a/tester/eventapi_tester.c +++ b/tester/eventapi_tester.c @@ -436,8 +436,9 @@ static void publish_test_with_args(bool_t refresh, int expires){ lev=linphone_core_create_publish(marie->lc,pauline->identity,"dodo",expires); linphone_event_add_custom_header(lev,"CustomHeader","someValue"); - linphone_event_send_publish(lev,content); linphone_event_ref(lev); + linphone_event_send_publish(lev,content); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishProgress,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishOk,1,3000)); diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index 7f68bb684..600d20f1f 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -675,6 +675,7 @@ static void call_with_sips_not_achievable(void){ if (ei){ BC_ASSERT_EQUAL(linphone_error_info_get_reason(ei), LinphoneReasonTemporarilyUnavailable, int, "%d"); } + linphone_call_unref(call); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline1); @@ -946,7 +947,7 @@ static void dos_module_trigger(void) { } while (i < number_of_messge_to_send); // At this point we should be banned for a minute - ms_usleep(65000000); // Wait several seconds to ensure we are not banned anymore + ms_sleep(65); // Wait several seconds to ensure we are not banned anymore BC_ASSERT_LOWER(marie->stat.number_of_LinphoneMessageReceived, number_of_messge_to_send, int, "%d"); reset_counters(&marie->stat); @@ -1203,7 +1204,7 @@ test_t flexisip_tests[] = { TEST_NO_TAG("Call forking not responded", call_forking_not_responded), TEST_NO_TAG("Early-media call forking", early_media_call_forking), TEST_NO_TAG("Call with sips", call_with_sips), - TEST_ONE_TAG("Call with sips not achievable", call_with_sips_not_achievable, "LeaksMemory"), + TEST_NO_TAG("Call with sips not achievable", call_with_sips_not_achievable), TEST_NO_TAG("Call ipv6 to ipv6", call_with_ipv6), TEST_NO_TAG("Call ipv6 to ipv4", call_ipv6_to_ipv4), TEST_NO_TAG("Call ipv4 to ipv6", call_ipv4_to_ipv6), @@ -1212,7 +1213,7 @@ test_t flexisip_tests[] = { /*TEST_ONE_TAG("Subscribe Notify with sipp double publish", test_subscribe_notify_with_sipp_publisher_double_publish, "LeaksMemory"),*/ #endif TEST_NO_TAG("Publish/unpublish", test_publish_unpublish), - TEST_ONE_TAG("List subscribe", test_list_subscribe,"LeaksMemory"), + TEST_NO_TAG("List subscribe", test_list_subscribe), TEST_NO_TAG("File transfer message rcs to external body client", file_transfer_message_rcs_to_external_body_client), TEST_ONE_TAG("File transfer message external body to rcs client", file_transfer_message_external_body_to_rcs_client, "LeaksMemory"), TEST_ONE_TAG("File transfer message external body to external body client", file_transfer_message_external_body_to_external_body_client, "LeaksMemory"), diff --git a/tester/presence_server_tester.c b/tester/presence_server_tester.c index fbed526bb..e60b28396 100644 --- a/tester/presence_server_tester.c +++ b/tester/presence_server_tester.c @@ -447,7 +447,7 @@ static void test_presence_list_base(bool_t enable_compression) { reset_counters(&laure->stat); reset_counters(&marie->stat); - /*keep in ming long terme presence*/ + /*keep in mind long terme presence*/ if (!BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphonePresenceActivityOnline, 1, 4000))) goto end; diff --git a/tester/rcfiles/pauline_nat64_rc b/tester/rcfiles/pauline_nat64_rc index c90b6a363..6cfa5ace0 100644 --- a/tester/rcfiles/pauline_nat64_rc +++ b/tester/rcfiles/pauline_nat64_rc @@ -15,8 +15,8 @@ realm=sip.example.org [proxy_0] -reg_proxy=sipv4-nat64.example.org;transport=tls -reg_route=sipv4-nat64.example.org;transport=tls +reg_proxy=sipv4-nat64.example.org;transport=tcp +reg_route=sipv4-nat64.example.org;transport=tcp reg_identity=sip:pauline@sip.example.org reg_expires=3600 reg_sendregister=1 diff --git a/tester/rcfiles/pauline_v4proxy_rc b/tester/rcfiles/pauline_v4proxy_rc index b2255c3c6..9b850e715 100644 --- a/tester/rcfiles/pauline_v4proxy_rc +++ b/tester/rcfiles/pauline_v4proxy_rc @@ -15,8 +15,8 @@ realm=sip.example.org [proxy_0] -reg_proxy=sipv4.example.org;transport=tls -reg_route=sipv4.example.org;transport=tls +reg_proxy=sipv4.example.org;transport=tcp +reg_route=sipv4.example.org;transport=tcp reg_identity=sip:pauline@sip.example.org reg_expires=3600 reg_sendregister=1 diff --git a/tester/stun_tester.c b/tester/stun_tester.c index eb97d7472..0a2b1b608 100644 --- a/tester/stun_tester.c +++ b/tester/stun_tester.c @@ -47,11 +47,19 @@ static void linphone_stun_test_encode(void) static void linphone_stun_test_grab_ip(void) { + LinphoneCoreManager* lc_stun = linphone_core_manager_new2("stun_rc", FALSE); LinphoneCall dummy_call; int ping_time; int tmp = 0; + /*this test verifies the very basic STUN support of liblinphone, which is deprecated. + * It works only in IPv4 mode and there is no plan to make it work over ipv6.*/ + if (liblinphone_tester_ipv4_available()){ + goto end; + } + linphone_core_enable_ipv6(lc_stun->lc, FALSE); + memset(&dummy_call, 0, sizeof(LinphoneCall)); dummy_call.main_audio_stream_index = 0; dummy_call.main_video_stream_index = 1; @@ -85,6 +93,7 @@ static void linphone_stun_test_grab_ip(void) #endif ms_message("STUN test result: local text port maps to %s:%i", dummy_call.tc.addr, dummy_call.tc.port); +end: linphone_core_manager_destroy(lc_stun); } diff --git a/tester/tester.c b/tester/tester.c index 131252823..c48887034 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -424,7 +424,7 @@ void linphone_core_manager_stop(LinphoneCoreManager *mgr){ if (mgr->lc) { const char *record_file = linphone_core_get_record_file(mgr->lc); char *chatdb = ms_strdup(linphone_core_get_chat_database_path(mgr->lc)); - if (!liblinphone_tester_keep_record_files && record_file) { + if (!liblinphone_tester_keep_record_files && record_file && ortp_file_exist(record_file)) { if ((bc_get_number_of_failures() - mgr->number_of_bcunit_error_at_creation)>0) { ms_error("Test has failed, keeping recorded file [%s]", record_file); } diff --git a/tester/tunnel_tester.c b/tester/tunnel_tester.c index cf02ff267..48bebd4cf 100644 --- a/tester/tunnel_tester.c +++ b/tester/tunnel_tester.c @@ -24,26 +24,21 @@ #include "liblinphone_tester.h" /* Retrieve the public IP from a given hostname */ -static const char* get_ip_from_hostname(const char * tunnel_hostname){ +int get_ip_from_hostname(const char * tunnel_hostname, char *ip, size_t ip_size){ struct addrinfo hints; - struct addrinfo *res = NULL, *it = NULL; - struct sockaddr_in *add; - char * output = NULL; + struct addrinfo *res = NULL; int err; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; if ((err = getaddrinfo(tunnel_hostname, NULL, &hints, &res))){ ms_error("error while retrieving IP from %s: %s", tunnel_hostname, gai_strerror(err)); - return NULL; + return err; } - for (it=res; it!=NULL; it=it->ai_next){ - add = (struct sockaddr_in *) it->ai_addr; - output = inet_ntoa( add->sin_addr ); - } + bctbx_addrinfo_to_ip_address(res, ip, ip_size, NULL); freeaddrinfo(res); - return output; + return err; } static char* get_public_contact_ip(LinphoneCore* lc) { const LinphoneAddress * contact = linphone_proxy_config_get_contact(linphone_core_get_default_proxy_config(lc)); @@ -60,9 +55,10 @@ static void call_with_tunnel_base(LinphoneTunnelMode tunnel_mode, bool_t with_si LinphoneProxyConfig *proxy = linphone_core_get_default_proxy_config(pauline->lc); LinphoneAddress *server_addr = linphone_address_new(linphone_proxy_config_get_server_addr(proxy)); LinphoneAddress *route = linphone_address_new(linphone_proxy_config_get_route(proxy)); - const char * tunnel_ip = get_ip_from_hostname("tunnel.linphone.org"); + char tunnel_ip[64]; char *public_ip, *public_ip2=NULL; - + BC_ASSERT_FALSE(get_ip_from_hostname("tunnel.linphone.org",tunnel_ip,sizeof(tunnel_ip))); + BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_LinphoneRegistrationOk,1)); public_ip = get_public_contact_ip(pauline->lc); BC_ASSERT_STRING_NOT_EQUAL(public_ip, tunnel_ip); @@ -245,9 +241,10 @@ static void register_on_second_tunnel(void) { LinphoneTunnel *tunnel = linphone_core_get_tunnel(pauline->lc); LinphoneTunnelConfig *config1 = linphone_tunnel_config_new(); LinphoneTunnelConfig *config2 = linphone_tunnel_config_new(); - const char * tunnel_ip = get_ip_from_hostname("tunnel.linphone.org"); + char tunnel_ip[64]; char* public_ip; - + + BC_ASSERT_FALSE(get_ip_from_hostname("tunnel.linphone.org",tunnel_ip,sizeof(tunnel_ip))); linphone_tunnel_simulate_udp_loss(tunnel, TRUE); // add a first tunnel config with an invalid port diff --git a/tester/vcard_tester.c b/tester/vcard_tester.c index 9754acccf..526cf2a1c 100644 --- a/tester/vcard_tester.c +++ b/tester/vcard_tester.c @@ -799,8 +799,8 @@ test_t vcard_tests[] = { TEST_NO_TAG("vCard creation for existing friends", linphone_vcard_update_existing_friends_test), TEST_NO_TAG("vCard phone numbers and SIP addresses", linphone_vcard_phone_numbers_and_sip_addresses), #ifdef SQLITE_STORAGE_ENABLED - TEST_ONE_TAG("Friends working if no db set", friends_if_no_db_set, "LeaksMemory"), - TEST_ONE_TAG("Friends storage migration from rc to db", friends_migration, "LeaksMemory"), + TEST_NO_TAG("Friends working if no db set", friends_if_no_db_set), + TEST_NO_TAG("Friends storage migration from rc to db", friends_migration), TEST_NO_TAG("Friends storage in sqlite database", friends_sqlite_storage), #endif TEST_NO_TAG("CardDAV clean", carddav_clean), // This is to ensure the content of the test addressbook is in the correct state for the following tests