diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e89ccdb4..7e9e6e7c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,7 @@ option(ENABLE_LIME "Enable Instant Messaging Encryption." NO) option(ENABLE_MSG_STORAGE "Turn on compilation of message storage." YES) cmake_dependent_option(ENABLE_NOTIFY "Enable libnotify support." YES "ENABLE_GTK_UI" NO) option(ENABLE_RELATIVE_PREFIX "Find resources relatively to the installation directory." NO) +option(ENABLE_STRICT "Build with strict compile options." YES) option(ENABLE_TOOLS "Turn on or off compilation of tools." YES) option(ENABLE_TUNNEL "Turn on compilation of tunnel support." NO) option(ENABLE_TUTORIALS "Enable compilation of tutorials." YES) @@ -58,6 +59,22 @@ option(ENABLE_NLS "Build with internationalisation support" YES) option(ENABLE_CALL_LOGS_STORAGE "Turn on compilation of call logs storage." YES) +macro(apply_compile_flags SOURCE_FILES) + if(${SOURCE_FILES}) + set(options "") + foreach(a ${ARGV}) + if(STRICT_OPTIONS_${a}) + string(REPLACE ";" " " options_${a} "${STRICT_OPTIONS_${a}}") + set(options "${options} ${options_${a}}") + endif() + endforeach() + if(options) + set_source_files_properties(${${SOURCE_FILES}} PROPERTIES COMPILE_FLAGS "${options}") + endif() + endif() +endmacro() + + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(CheckSymbolExists) @@ -197,22 +214,27 @@ if(ENABLE_DEBUG_LOGS) add_definitions("-DDEBUG") endif() -if(MSVC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3") -else() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wuninitialized -Wdeclaration-after-statement -fno-strict-aliasing -Werror") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wuninitialized -Werror") +set(STRICT_OPTIONS_CPP ) +set(STRICT_OPTIONS_C ) +set(STRICT_OPTIONS_OBJC ) +if(NOT MSVC) + list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized") + list(APPEND STRICT_OPTIONS_C "-Wdeclaration-after-statement") if(CMAKE_C_COMPILER_ID STREQUAL "Clang") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments -Wno-array-bounds") - endif() - if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -Wno-array-bounds") + list(APPEND STRICT_OPTIONS_CPP "-Qunused-arguments" "-Wno-array-bounds") endif() if(APPLE) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unknown-warning-option -Wno-tautological-compare -Wno-unused-function") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unknown-warning-option -Wno-tautological-compare -Wno-unused-function") + list(APPEND STRICT_OPTIONS_CPP "-Wno-error=unknown-warning-option" "-Qunused-arguments" "-Wno-tautological-compare" "-Wno-unused-function" "-Wno-array-bounds") endif() + if(ENABLE_STRICT) + list(APPEND STRICT_OPTIONS_CPP "-Werror" "-fno-strict-aliasing") + endif() +endif() +if(STRICT_OPTIONS_CPP) + list(REMOVE_DUPLICATES STRICT_OPTIONS_CPP) +endif() +if(STRICT_OPTIONS_C) + list(REMOVE_DUPLICATES STRICT_OPTIONS_C) endif() diff --git a/NEWS b/NEWS index 3791448b8..1e8481d78 100644 --- a/NEWS +++ b/NEWS @@ -28,7 +28,7 @@ linphone-3.8.2 -- May 7th, 2015 * add support of the StatusNotifierItem standard to display a status icon on KDE5 * auto-answering can be set through the preferences panel * bug fixes - + Liblinphone level improvements: * fix audio bug with opus codec * fix ICE corner case not properly handled and resulting bad final ice status @@ -76,14 +76,14 @@ linphone-3.7.0 -- February 20th, 2014 * Keyboard can be used for DTMF input * Faster and higly responsive UI thanks to fully asynchronous operation of the liblinphone. * Addon of opus codec - * Possibility to specify a remote provisionning http URI for configuration + * Possibility to specify a remote provisioning http URI for configuration * LDAP search integration for Linux and MacOSX - * is-composing notification in chat area + * is-composing notification in chat area Liblinphone level improvements thanks to new "belle-sip" SIP stack: * multiple SIP transports simultaneously now allowed * IP dual stack: can use IPv6 and IPv4 simultaneously - * fully asynchronous behavior: no more lengthly DNS or connections + * fully asynchronous behavior: no more lengthly DNS or connections * +sip.instance parameter (RFC5626) * alias parameter (RFC5923) * better management of network disconnections @@ -101,7 +101,7 @@ linphone-3.7.0 -- February 20th, 2014 linphone-3.6.1 -- June 17, 2013 * fix memory leak with some video cameras on windows. - + Requires: mediastreamer2 = 2.9.1 and ortp = 0.22.0 linphone-3.6.0 -- May 27, 2013 @@ -166,9 +166,9 @@ linphone-3.4.1 -- February 17th, 2011 Requires mediastreamer-2.7.1 linphone-3.4.0 -- February 7th, 2011 - * implement multiple calls feature: + * implement multiple calls feature: - call hold (with possibility to play a music file) - - call resume + - call resume - acceptance of 2nd call while putting the others on hold - creation of another outgoing call while already in call - blind call transfer @@ -339,7 +339,7 @@ linphone-1.4.1 -- September 18, 2006 * do not change mixer settings at startup linphone-1.4.0 -- September 11, 2006 - * no more glib dependency at all + * no more glib dependency at all * new mediastreamer2 framework for audio/video streaming * stable video support with H.263-1998 * echo cancelation diff --git a/console/CMakeLists.txt b/console/CMakeLists.txt index 328fdbcf2..4b7f4df24 100644 --- a/console/CMakeLists.txt +++ b/console/CMakeLists.txt @@ -29,6 +29,7 @@ set(LINPHONECSH_SOURCE_FILES shell.c ) +apply_compile_flags(LINPHONEC_SOURCE_FILES "CPP" "C") add_executable(linphonec ${LINPHONEC_SOURCE_FILES}) target_link_libraries(linphonec linphone) diff --git a/coreapi/CMakeLists.txt b/coreapi/CMakeLists.txt index 238db5bd4..2f2d59712 100644 --- a/coreapi/CMakeLists.txt +++ b/coreapi/CMakeLists.txt @@ -50,7 +50,7 @@ set(LINPHONE_HEADER_FILES xmlrpc.h ) -set(LINPHONE_SOURCE_FILES +set(LINPHONE_SOURCE_FILES_C account_creator.c address.c authentication.c @@ -111,15 +111,16 @@ set(LINPHONE_SOURCE_FILES xmlrpc.c vtables.c ) +set(LINPHONE_SOURCE_FILES_CXX ) if(ENABLE_TUNNEL) - list(APPEND LINPHONE_SOURCE_FILES + list(APPEND LINPHONE_SOURCE_FILES_CXX linphone_tunnel.cc TunnelManager.cc ) add_definitions(-DTUNNEL_ENABLED) else() - list(APPEND LINPHONE_SOURCE_FILES linphone_tunnel_stubs.c) + list(APPEND LINPHONE_SOURCE_FILES_C linphone_tunnel_stubs.c) endif() find_package(Git) @@ -133,6 +134,9 @@ add_definitions( -DLIBLINPHONE_EXPORTS ) +apply_compile_flags(LINPHONE_SOURCE_FILES_C "CPP" "C") +apply_compile_flags(LINPHONE_SOURCE_FILES_CXX "CPP" "CXX") + set(LIBS ${BELLESIP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES} @@ -161,10 +165,10 @@ if(INTL_FOUND) endif() if(ENABLE_STATIC) - add_library(linphone STATIC ${LINPHONE_HEADER_FILES} ${LINPHONE_SOURCE_FILES}) + add_library(linphone STATIC ${LINPHONE_HEADER_FILES} ${LINPHONE_SOURCE_FILES_C} ${LINPHONE_SOURCE_FILES_CXX}) target_link_libraries(linphone ${LIBS}) else() - add_library(linphone SHARED ${LINPHONE_HEADER_FILES} ${LINPHONE_SOURCE_FILES}) + add_library(linphone SHARED ${LINPHONE_HEADER_FILES} ${LINPHONE_SOURCE_FILES_C} ${LINPHONE_SOURCE_FILES_CXX}) set_target_properties(linphone PROPERTIES VERSION ${LINPHONE_SO_VERSION} LINKER_LANGUAGE CXX) target_link_libraries(linphone ${LIBS}) if(MSVC) diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index c588fa7d5..4646806f0 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -162,7 +162,7 @@ static LinphoneAccountCreatorStatus validate_uri(const char* username, const cha } linphone_address_unref(addr); - return LinphoneAccountCreatorOk; + return LinphoneAccountCreatorOK; } static bool_t is_matching_regex(const char *entry, const char* regex) { @@ -198,11 +198,11 @@ LinphoneAccountCreatorStatus linphone_account_creator_set_username(LinphoneAccou return LinphoneAccountCreatorUsernameInvalid; } else if (regex && !is_matching_regex(username, regex)) { return LinphoneAccountCreatorUsernameInvalid; - } else if ((status = validate_uri(username, NULL, NULL, NULL)) != LinphoneAccountCreatorOk) { + } else if ((status = validate_uri(username, NULL, NULL, NULL)) != LinphoneAccountCreatorOK) { return status; } set_string(&creator->username, username, TRUE); - return LinphoneAccountCreatorOk; + return LinphoneAccountCreatorOK; } const char * linphone_account_creator_get_username(const LinphoneAccountCreator *creator) { @@ -215,7 +215,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_set_password(LinphoneAccou return LinphoneAccountCreatorPasswordTooShort; } set_string(&creator->password, password, FALSE); - return LinphoneAccountCreatorOk; + return LinphoneAccountCreatorOK; } const char * linphone_account_creator_get_password(const LinphoneAccountCreator *creator) { @@ -227,7 +227,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_set_transport(LinphoneAcco return LinphoneAccountCreatorTransportNotSupported; } creator->transport = transport; - return LinphoneAccountCreatorOk; + return LinphoneAccountCreatorOK; } LinphoneTransportType linphone_account_creator_get_transport(const LinphoneAccountCreator *creator) { @@ -239,7 +239,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_set_domain(LinphoneAccount return LinphoneAccountCreatorDomainInvalid; } set_string(&creator->domain, domain, TRUE); - return LinphoneAccountCreatorOk; + return LinphoneAccountCreatorOK; } const char * linphone_account_creator_get_domain(const LinphoneAccountCreator *creator) { @@ -251,7 +251,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_set_route(LinphoneAccountC return LinphoneAccountCreatorRouteInvalid; } set_string(&creator->route, route, TRUE); - return LinphoneAccountCreatorOk; + return LinphoneAccountCreatorOK; } const char * linphone_account_creator_get_route(const LinphoneAccountCreator *creator) { @@ -263,7 +263,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_set_display_name(LinphoneA return LinphoneAccountCreatorDisplayNameInvalid; } set_string(&creator->display_name, display_name, FALSE); - return LinphoneAccountCreatorOk; + return LinphoneAccountCreatorOK; } const char * linphone_account_creator_get_display_name(const LinphoneAccountCreator *creator) { @@ -275,7 +275,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_set_email(LinphoneAccountC return LinphoneAccountCreatorEmailInvalid; } set_string(&creator->email, email, TRUE); - return LinphoneAccountCreatorOk; + return LinphoneAccountCreatorOK; } const char * linphone_account_creator_get_email(const LinphoneAccountCreator *creator) { @@ -297,10 +297,10 @@ LinphoneAccountCreatorCbs * linphone_account_creator_get_callbacks(const Linphon static void _test_existence_cb(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); if (creator->callbacks->existence_tested != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorFailed; - if ((linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) - && (linphone_xml_rpc_request_get_int_response(request) == 0)) { - status = LinphoneAccountCreatorOk; + LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { + int resp = linphone_xml_rpc_request_get_int_response(request); + status = (resp == 0) ? LinphoneAccountCreatorAccountNotExist : LinphoneAccountCreatorAccountExist; } creator->callbacks->existence_tested(creator, status); } @@ -312,9 +312,9 @@ LinphoneAccountCreatorStatus linphone_account_creator_test_existence(LinphoneAcc if (!creator->username || !creator->domain) { if (creator->callbacks->existence_tested != NULL) { - creator->callbacks->existence_tested(creator, LinphoneAccountCreatorFailed); + creator->callbacks->existence_tested(creator, LinphoneAccountCreatorReqFailed); } - return LinphoneAccountCreatorFailed; + return LinphoneAccountCreatorReqFailed; } identity = ms_strdup_printf("%s@%s", creator->username, creator->domain); request = linphone_xml_rpc_request_new_with_args("check_account", LinphoneXmlRpcArgInt, @@ -325,16 +325,16 @@ LinphoneAccountCreatorStatus linphone_account_creator_test_existence(LinphoneAcc linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); ms_free(identity); - return LinphoneAccountCreatorOk; + return LinphoneAccountCreatorOK; } static void _test_validation_cb(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); if (creator->callbacks->validation_tested != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorFailed; - if ((linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) - && (linphone_xml_rpc_request_get_int_response(request) == 1)) { - status = LinphoneAccountCreatorOk; + LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { + int resp = linphone_xml_rpc_request_get_int_response(request); + status = (resp == 0) ? LinphoneAccountCreatorAccountNotValidated : LinphoneAccountCreatorAccountValidated; } creator->callbacks->validation_tested(creator, status); } @@ -346,9 +346,9 @@ LinphoneAccountCreatorStatus linphone_account_creator_test_validation(LinphoneAc if (!creator->username || !creator->domain) { if (creator->callbacks->validation_tested != NULL) { - creator->callbacks->validation_tested(creator, LinphoneAccountCreatorFailed); + creator->callbacks->validation_tested(creator, LinphoneAccountCreatorReqFailed); } - return LinphoneAccountCreatorFailed; + return LinphoneAccountCreatorReqFailed; } identity = ms_strdup_printf("%s@%s", creator->username, creator->domain); @@ -360,16 +360,16 @@ LinphoneAccountCreatorStatus linphone_account_creator_test_validation(LinphoneAc linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); ms_free(identity); - return LinphoneAccountCreatorOk; + return LinphoneAccountCreatorOK; } static void _create_account_cb(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); if (creator->callbacks->create_account != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorFailed; - if ((linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) - && (linphone_xml_rpc_request_get_int_response(request) == 0)) { - status = LinphoneAccountCreatorOk; + LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { + int resp = linphone_xml_rpc_request_get_int_response(request); + status = (resp == 0) ? LinphoneAccountCreatorAccountCreated : LinphoneAccountCreatorAccountNotCreated; } creator->callbacks->create_account(creator, status); } @@ -379,11 +379,11 @@ LinphoneAccountCreatorStatus linphone_account_creator_create_account(LinphoneAcc LinphoneXmlRpcRequest *request; char *identity; - if (!creator->username || !creator->domain) { + if (!creator->username || !creator->domain || !creator->email) { if (creator->callbacks->create_account != NULL) { - creator->callbacks->create_account(creator, LinphoneAccountCreatorFailed); + creator->callbacks->create_account(creator, LinphoneAccountCreatorReqFailed); } - return LinphoneAccountCreatorFailed; + return LinphoneAccountCreatorReqFailed; } identity = ms_strdup_printf("%s@%s", creator->username, creator->domain); @@ -398,7 +398,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_create_account(LinphoneAcc linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); ms_free(identity); - return LinphoneAccountCreatorOk; + return LinphoneAccountCreatorOK; } LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCreator *creator) { diff --git a/coreapi/account_creator.h b/coreapi/account_creator.h index 87a31149e..fe6c46c3d 100644 --- a/coreapi/account_creator.h +++ b/coreapi/account_creator.h @@ -36,18 +36,27 @@ extern "C" { * Enum describing the status of a LinphoneAccountCreator operation. **/ typedef enum _LinphoneAccountCreatorStatus { - LinphoneAccountCreatorOk = 0, - LinphoneAccountCreatorFailed = 1 << 0, + LinphoneAccountCreatorOK, + LinphoneAccountCreatorReqFailed, - LinphoneAccountCreatorEmailInvalid = 1 << 1, - LinphoneAccountCreatorUsernameInvalid = 1 << 2, - LinphoneAccountCreatorUsernameTooShort = 1 << 3, - LinphoneAccountCreatorUsernameInvalidSize = 1 << 4, - LinphoneAccountCreatorPasswordTooShort = 1 << 5, - LinphoneAccountCreatorDomainInvalid = 1 << 6, - LinphoneAccountCreatorRouteInvalid = 1 << 7, - LinphoneAccountCreatorDisplayNameInvalid = 1 << 8, - LinphoneAccountCreatorTransportNotSupported = 1 << 9, + LinphoneAccountCreatorAccountCreated, + LinphoneAccountCreatorAccountNotCreated, + + LinphoneAccountCreatorAccountExist, + LinphoneAccountCreatorAccountNotExist, + + LinphoneAccountCreatorAccountValidated, + LinphoneAccountCreatorAccountNotValidated, + + LinphoneAccountCreatorEmailInvalid, + LinphoneAccountCreatorUsernameInvalid, + LinphoneAccountCreatorUsernameTooShort, + LinphoneAccountCreatorUsernameInvalidSize, + LinphoneAccountCreatorPasswordTooShort, + LinphoneAccountCreatorDomainInvalid, + LinphoneAccountCreatorRouteInvalid, + LinphoneAccountCreatorDisplayNameInvalid, + LinphoneAccountCreatorTransportNotSupported, } LinphoneAccountCreatorStatus; /** @@ -245,21 +254,21 @@ LINPHONE_PUBLIC LinphoneAccountCreatorCbs * linphone_account_creator_get_callbac /** * Send an XML-RPC request to test the existence of a Linphone account. * @param[in] creator LinphoneAccountCreator object - * @return LinphoneAccountCreatorOk if the request has been sent, LinphoneAccountCreatorFailed otherwise + * @return LinphoneAccountCreatorOk if the request has been sent, LinphoneAccountCreatorReqFailed otherwise **/ LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_test_existence(LinphoneAccountCreator *creator); /** * Send an XML-RPC request to test the validation of a Linphone account. * @param[in] creator LinphoneAccountCreator object - * @return LinphoneAccountCreatorOk if the request has been sent, LinphoneAccountCreatorFailed otherwise + * @return LinphoneAccountCreatorOk if the request has been sent, LinphoneAccountCreatorReqFailed otherwise **/ LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_test_validation(LinphoneAccountCreator *creator); /** * Send an XML-RPC request to create a Linphone account. * @param[in] creator LinphoneAccountCreator object - * @return LinphoneAccountCreatorOk if the request has been sent, LinphoneAccountCreatorFailed otherwise + * @return LinphoneAccountCreatorOk if the request has been sent, LinphoneAccountCreatorReqFailed otherwise **/ LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_create_account(LinphoneAccountCreator *creator); diff --git a/coreapi/enum.c b/coreapi/enum.c index 1c0651675..419e7000e 100644 --- a/coreapi/enum.c +++ b/coreapi/enum.c @@ -33,8 +33,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static char *create_enum_domain(const char *number){ size_t len=strlen(number); char *domain=ms_malloc((len*2)+10); - size_t i,j; - + long i,j; + for (i=0,j=len-1;j>=0;j--){ domain[i]=number[j]; i++; @@ -105,11 +105,11 @@ int enum_lookup(const char *enum_domain, enum_lookup_res_t **res){ /* ns_msg handle; int count; - + memset(&handle,0,sizeof(handle)); *res=NULL; ms_message("Resolving %s...",enum_domain); - + err=res_search(enum_domain,ns_c_in,ns_t_naptr,dns_answer,DNS_ANSWER_MAX_SIZE); if (err<0){ ms_warning("Error resolving enum:",herror(h_errno)); @@ -117,7 +117,7 @@ int enum_lookup(const char *enum_domain, enum_lookup_res_t **res){ } ns_initparse(dns_answer,DNS_ANSWER_MAX_SIZE,&handle); count=ns_msg_count(handle,ns_s_an); - + for(i=0;iDeleteLocalRef(d); } } + static void setCoreIfNotDone(JNIEnv *env, jobject jcore, LinphoneCore *lc){ + jclass objClass = env->GetObjectClass(jcore); + jfieldID myFieldID = env->GetFieldID(objClass, "nativePtr", "J"); + jlong fieldVal = env->GetLongField(jcore, myFieldID); + if (fieldVal == 0){ + env->SetLongField(jcore, myFieldID, (jlong)lc); + } + } + static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); @@ -668,6 +677,11 @@ public: } LinphoneCoreVTable *table = linphone_core_get_current_vtable(lc); LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_v_table_get_user_data(table); + + jobject jcore = lcData->core; + /*at this stage, the java object may not be aware of its C object, because linphone_core_new() hasn't returned yet.*/ + setCoreIfNotDone(env,jcore, lc); + jstring msg = message ? env->NewStringUTF(message) : NULL; env->CallVoidMethod(lcData->listener ,lcData->globalStateId @@ -6465,3 +6479,72 @@ JNIEXPORT void JNICALL Java_org_linphone_core_TunnelConfigImpl_destroy(JNIEnv *e } +/* + * Class: org_linphone_core_LinphoneCallLogImpl + * Method: getCallId + * Signature: (J)I + */ +JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneCallLogImpl_getCallId(JNIEnv *env, jobject jobj, jlong pcl){ + const char *str = linphone_call_log_get_call_id((LinphoneCallLog*)pcl); + return str ? env->NewStringUTF(str) : NULL; +} + +/* + * Class: org_linphone_core_LinphoneCoreImpl + * Method: setHttpProxyHost + * Signature: (JLjava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setHttpProxyHost(JNIEnv *env, jobject jobj, jlong core, jstring jhost){ + const char *host = jhost ? env->GetStringUTFChars(jhost, NULL) : NULL; + linphone_core_set_http_proxy_host((LinphoneCore*)core, host); + if (host) env->ReleaseStringUTFChars(jhost, host); +} + +/* + * Class: org_linphone_core_LinphoneCoreImpl + * Method: setHttpProxyPort + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setHttpProxyPort(JNIEnv *env, jobject jobj, jlong core, jint port){ + linphone_core_set_http_proxy_port((LinphoneCore*)core, port); +} + +/* + * Class: org_linphone_core_LinphoneCoreImpl + * Method: getHttpProxyHost + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneCoreImpl_getHttpProxyHost(JNIEnv *env , jobject jobj, jlong core){ + const char * host = linphone_core_get_http_proxy_host((LinphoneCore *)core); + return host ? env->NewStringUTF(host) : NULL; +} + +/* + * Class: org_linphone_core_LinphoneCoreImpl + * Method: getHttpProxyPort + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_getHttpProxyPort(JNIEnv *env, jobject jobj, jlong core){ + return linphone_core_get_http_proxy_port((LinphoneCore *)core); +} + + +/* + * Class: org_linphone_core_LinphoneCoreImpl + * Method: setSipTransportTimeout + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setSipTransportTimeout(JNIEnv *env, jobject jobj, jlong pcore, jint timeout){ + linphone_core_set_sip_transport_timeout((LinphoneCore*)pcore, timeout); +} + +/* + * Class: org_linphone_core_LinphoneCoreImpl + * Method: getSipTransportTimeout + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_getSipTransportTimeout(JNIEnv *env, jobject jobj, jlong pcore){ + return linphone_core_get_sip_transport_timeout((LinphoneCore*)pcore); +} + + diff --git a/coreapi/proxy.c b/coreapi/proxy.c index ae60dd071..c7351522e 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -868,7 +868,7 @@ char* linphone_proxy_config_normalize_phone_number(LinphoneProxyConfig *proxy, c if (linphone_proxy_config_is_phone_number(tmpproxy, username)){ dial_plan_t dialplan = {0}; char * flatten=flatten_number(username); - ms_debug("Flattened number is '%s'",flatten); + ms_debug("Flattened number is '%s' for '%s'",flatten, username); /*if proxy has a dial prefix, modify phonenumber accordingly*/ if (tmpproxy->dial_prefix!=NULL && tmpproxy->dial_prefix[0]!='\0'){ @@ -884,15 +884,17 @@ char* linphone_proxy_config_normalize_phone_number(LinphoneProxyConfig *proxy, c } }else{ /*0. keep at most national number significant digits */ - char* flatten_start = flatten + MAX(0, strlen(flatten) - dialplan.nnl); + char* flatten_start = flatten + MAX(0, (int)strlen(flatten) - (int)dialplan.nnl); + ms_debug("Prefix not present. Keeping at most %d digits: %s", dialplan.nnl, flatten_start); + /*1. First prepend international calling prefix or +*/ /*2. Second add prefix*/ /*3. Finally add user digits */ - result = ms_strdup_printf("%s%s%s" , tmpproxy->dial_escape_plus ? dialplan.icp : "+" , dialplan.ccc , flatten_start); + ms_debug("Prepended prefix resulted in %s", result); } } if (result==NULL) { @@ -1149,6 +1151,8 @@ void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *cf linphone_proxy_config_enable_register(cfg,FALSE); linphone_proxy_config_done(cfg); linphone_proxy_config_update(cfg); + } else if (cfg->state != LinphoneRegistrationNone) { + linphone_proxy_config_set_state(cfg, LinphoneRegistrationNone,"Registration disabled"); } linphone_proxy_config_write_all_to_config_file(lc); } diff --git a/coreapi/remote_provisioning.c b/coreapi/remote_provisioning.c index 2d7091bd7..d79598758 100644 --- a/coreapi/remote_provisioning.c +++ b/coreapi/remote_provisioning.c @@ -108,8 +108,10 @@ int linphone_remote_provisioning_download_and_apply(LinphoneCore *lc, const char if( scheme && (strcmp(scheme,"file") == 0) ){ // We allow for 'local remote-provisioning' in case the file is to be opened from the hard drive. const char* file_path = remote_provisioning_uri + strlen("file://"); // skip scheme + if (uri) { + belle_sip_object_unref(uri); + } return linphone_remote_provisioning_load_file(lc, file_path); - } else if( scheme && strncmp(scheme, "http", 4) == 0 && host && strlen(host) > 0) { belle_http_request_listener_callbacks_t belle_request_listener={0}; belle_http_request_t *request; @@ -122,15 +124,29 @@ int linphone_remote_provisioning_download_and_apply(LinphoneCore *lc, const char lc->provisioning_http_listener = belle_http_request_listener_create_from_callbacks(&belle_request_listener, lc); request=belle_http_request_create("GET",uri, NULL); + return belle_http_provider_send_request(lc->http_provider, request, lc->provisioning_http_listener); } else { ms_error("Invalid provisioning URI [%s] (missing scheme or host ?)",remote_provisioning_uri); + if (uri) { + belle_sip_object_unref(uri); + } return -1; } } -void linphone_core_set_provisioning_uri(LinphoneCore *lc, const char *uri) { - lp_config_set_string(lc->config,"misc","config-uri",uri); +int linphone_core_set_provisioning_uri(LinphoneCore *lc, const char *remote_provisioning_uri) { + belle_generic_uri_t *uri=remote_provisioning_uri?belle_generic_uri_parse(remote_provisioning_uri):NULL; + if (!remote_provisioning_uri||uri) { + lp_config_set_string(lc->config,"misc","config-uri",remote_provisioning_uri); + if (uri) { + belle_sip_object_unref(uri); + } + return 0; + } + ms_error("Invalid provisioning URI [%s] (could not be parsed)",remote_provisioning_uri); + return -1; + } const char*linphone_core_get_provisioning_uri(const LinphoneCore *lc){ diff --git a/gtk/CMakeLists.txt b/gtk/CMakeLists.txt index 604a845d3..ce3166cc3 100644 --- a/gtk/CMakeLists.txt +++ b/gtk/CMakeLists.txt @@ -78,6 +78,7 @@ if(WIN32) list(APPEND SOURCE_FILES linphone.rc) endif() +apply_compile_flags(SOURCE_FILES "CPP" "C") if(WIN32) add_executable(linphone-gtk WIN32 ${SOURCE_FILES}) else() diff --git a/gtk/linphone.h b/gtk/linphone.h index 0ae175dd9..fd7dd074f 100644 --- a/gtk/linphone.h +++ b/gtk/linphone.h @@ -349,3 +349,4 @@ LINPHONE_PUBLIC void linphone_gtk_reload_video_devices(void); LINPHONE_PUBLIC bool_t linphone_gtk_is_friend(LinphoneCore *lc, const char *contact); LINPHONE_PUBLIC gboolean linphone_gtk_auto_answer_enabled(void); LINPHONE_PUBLIC void linphone_gtk_update_status_bar_icons(void); +LINPHONE_PUBLIC void linphone_gtk_enable_auto_answer(GtkToggleButton *checkbox, gpointer user_data); diff --git a/gtk/main.ui b/gtk/main.ui index b40737c07..98dc3400a 100644 --- a/gtk/main.ui +++ b/gtk/main.ui @@ -171,7 +171,7 @@ - + True False Set configuration URI diff --git a/gtk/setup_wizard.ui b/gtk/setup_wizard.ui index 65b106a77..337163f3d 100644 --- a/gtk/setup_wizard.ui +++ b/gtk/setup_wizard.ui @@ -28,6 +28,9 @@ + + + True @@ -715,7 +718,6 @@ Please go back and try again. Error - True diff --git a/gtk/setupwizard.c b/gtk/setupwizard.c index ffd5a8ba7..63b6cec6f 100644 --- a/gtk/setupwizard.c +++ b/gtk/setupwizard.c @@ -33,7 +33,7 @@ static LinphoneAccountCreator * linphone_gtk_assistant_get_creator(GtkWidget *w) static void linphone_gtk_create_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status) { GtkWidget *assistant = (GtkWidget *)linphone_account_creator_get_user_data(creator); - if (status == LinphoneAccountCreatorOk) { + if (status == LinphoneAccountCreatorAccountCreated) { // Go to page_6_linphone_account_validation_wait gtk_assistant_set_current_page(GTK_ASSISTANT(assistant), 6); } else { // Error when attempting to create the account @@ -50,7 +50,7 @@ static void create_account(GtkWidget *assistant) { static void linphone_gtk_test_account_validation_cb(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status) { GtkWidget *assistant = (GtkWidget *)linphone_account_creator_get_user_data(creator); - if (status == LinphoneAccountCreatorOk) { + if (status == LinphoneAccountCreatorAccountValidated) { // Go to page_9_finish gtk_assistant_set_current_page(GTK_ASSISTANT(assistant), 9); } else { @@ -209,14 +209,18 @@ static gboolean update_interface_with_username_availability(GtkWidget *page) { GtkWidget *assistant = gtk_widget_get_toplevel(page); GtkImage* isUsernameOk = GTK_IMAGE(linphone_gtk_get_widget(assistant, "p4_image_username_ok")); GtkLabel* usernameError = GTK_LABEL(linphone_gtk_get_widget(assistant, "p4_label_error")); - int account_existing = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(page), "is_username_used")); + int account_status = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(page), "is_username_used")); - if (account_existing == 0) { + if (account_status == LinphoneAccountCreatorAccountNotExist) { g_object_set_data(G_OBJECT(page), "is_username_available", GINT_TO_POINTER(1)); gtk_image_set_from_stock(isUsernameOk, GTK_STOCK_OK, GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_label_set_text(usernameError, ""); + } else if (account_status == LinphoneAccountCreatorAccountExist) { + gtk_label_set_text(usernameError, _("Username is already in use!")); + g_object_set_data(G_OBJECT(page), "is_username_available", GINT_TO_POINTER(0)); + gtk_image_set_from_stock(isUsernameOk, GTK_STOCK_NO, GTK_ICON_SIZE_LARGE_TOOLBAR); } else { - gtk_label_set_text(usernameError, "Username is already in use!"); + gtk_label_set_text(usernameError, _("Failed to check username availability. Please try again later.")); g_object_set_data(G_OBJECT(page), "is_username_available", GINT_TO_POINTER(0)); gtk_image_set_from_stock(isUsernameOk, GTK_STOCK_NO, GTK_ICON_SIZE_LARGE_TOOLBAR); } @@ -227,8 +231,7 @@ static gboolean update_interface_with_username_availability(GtkWidget *page) { static void linphone_gtk_test_account_existence_cb(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status) { GtkWidget *assistant = (GtkWidget *)linphone_account_creator_get_user_data(creator); GtkWidget *page = gtk_assistant_get_nth_page(GTK_ASSISTANT(assistant), gtk_assistant_get_current_page(GTK_ASSISTANT(assistant))); - gboolean account_existing = (status != LinphoneAccountCreatorOk); - g_object_set_data(G_OBJECT(page), "is_username_used", GINT_TO_POINTER(account_existing)); + g_object_set_data(G_OBJECT(page), "is_username_used", GINT_TO_POINTER(status)); gdk_threads_add_idle((GSourceFunc)update_interface_with_username_availability, page); } @@ -323,7 +326,7 @@ static void linphone_gtk_assistant_init(GtkWidget *w) { linphone_account_creator_cbs_set_validation_tested(cbs, linphone_gtk_test_account_validation_cb); linphone_account_creator_cbs_set_create_account(cbs, linphone_gtk_create_account_cb); g_object_set_data(G_OBJECT(w), "creator", creator); - + gtk_assistant_set_forward_page_func(GTK_ASSISTANT(w), linphone_gtk_assistant_forward, w, NULL); } diff --git a/java/common/org/linphone/core/LinphoneCallLog.java b/java/common/org/linphone/core/LinphoneCallLog.java index f1dd742b3..67b1977e1 100644 --- a/java/common/org/linphone/core/LinphoneCallLog.java +++ b/java/common/org/linphone/core/LinphoneCallLog.java @@ -118,7 +118,7 @@ public interface LinphoneCallLog { public int getCallDuration(); /** * Call id from signaling - * @return int + * @return the SIP call-id. */ - public int getCallId(); + public String getCallId(); } diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 70c71d799..2a2c93766 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -959,6 +959,18 @@ public interface LinphoneCore { */ void setSipDscp(int dscp); + /** + * Set the timeout in milliseconds for SIP transport (TCP or TLS connection establishment maximum time). + * @param timeout_ms + **/ + void setSipTransportTimeout(int timeout_ms); + + /** + * Get the current SIP transport timeout. + * @param timeout_ms + **/ + int getSipTransportTimeout(); + /** * Get DSCP used for SIP socket. * @return the DSCP value used for the SIP socket. @@ -2179,4 +2191,22 @@ public interface LinphoneCore { * Get the provisioning URI previously set. **/ public String getProvisioningUri(); + + /** + * Set an http proxy hostname or IP address to use for SIP connection. + */ + public void setHttpProxyHost(String host); + /** + * Set an http proxy port to use for SIP connection. + */ + public void setHttpProxyPort(int port); + /** + * Get the http proxy host previously set. + **/ + public String getHttpProxyHost(); + /** + * Get the http proxy port previously set. + **/ + public int getHttpProxyPort(); + } diff --git a/java/impl/org/linphone/core/LinphoneCallLogImpl.java b/java/impl/org/linphone/core/LinphoneCallLogImpl.java index 7078a2a9f..3c78e4046 100644 --- a/java/impl/org/linphone/core/LinphoneCallLogImpl.java +++ b/java/impl/org/linphone/core/LinphoneCallLogImpl.java @@ -29,7 +29,7 @@ class LinphoneCallLogImpl implements LinphoneCallLog { private native int getStatus(long nativePtr); private native String getStartDate(long nativePtr); private native int getCallDuration(long nativePtr); - private native int getCallId(long nativePtr); + private native String getCallId(long nativePtr); private native long getTimestamp(long nativePtr); LinphoneCallLogImpl(long aNativePtr) { @@ -62,7 +62,7 @@ class LinphoneCallLogImpl implements LinphoneCallLog { public int getCallDuration() { return getCallDuration(nativePtr); } - public int getCallId() { + public String getCallId() { return getCallId(nativePtr); } diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index 297ebc0f1..67f019232 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -1535,4 +1535,39 @@ class LinphoneCoreImpl implements LinphoneCore { public GlobalState getGlobalState(){ return GlobalState.fromInt(getGlobalState(nativePtr)); } + private native void setHttpProxyHost(long nativePtr, String host); + @Override + public void setHttpProxyHost(String host){ + setHttpProxyHost(nativePtr, host); + } + + private native void setHttpProxyPort(long nativePtr, int port); + @Override + public void setHttpProxyPort(int port){ + setHttpProxyPort(nativePtr, port); + } + + private native String getHttpProxyHost(long nativePtr); + @Override + public String getHttpProxyHost(){ + return getHttpProxyHost(nativePtr); + } + + private native int getHttpProxyPort(long nativePtr); + @Override + public int getHttpProxyPort(){ + return getHttpProxyPort(nativePtr); + } + private native void setSipTransportTimeout(long nativePtr, int timeout_ms); + @Override + public void setSipTransportTimeout(int timeout_ms){ + setSipTransportTimeout(nativePtr, timeout_ms); + } + + private native int getSipTransportTimeout(long nativePtr); + @Override + public int getSipTransportTimeout(){ + return getSipTransportTimeout(nativePtr); + } + } diff --git a/oRTP b/oRTP index cb4f9f5ce..f590eac0e 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit cb4f9f5ce7d984b81d6a71416abc77bda2f82bdb +Subproject commit f590eac0e77e918b3cf035a864e86c083723e65b diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index 656de9bfe..7ed25ecaa 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -46,7 +46,9 @@ set(SOURCE_FILES tunnel_tester.c upnp_tester.c video_tester.c - ) +) + +apply_compile_flags(SOURCE_FILES "CPP" "C") #executable must be available on root path, not host one find_program(SIPP_PROGRAM NAMES sipp sipp.exe ONLY_CMAKE_FIND_ROOT_PATH) diff --git a/tester/call_tester.c b/tester/call_tester.c index 818fe8ee3..80353aa22 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -4871,8 +4871,8 @@ end: typedef struct _RtpTransportModifierData { uint64_t packetSentCount; uint64_t packetReceivedCount; - mblk_t *msg_to_send; - mblk_t *msg_to_recv; + MSQueue to_send; + MSQueue to_recv; } RtpTransportModifierData; const char *XOR_KEY = "BELLEDONNECOMMUNICATIONS"; @@ -4889,7 +4889,7 @@ static int rtptm_on_send(RtpTransportModifier *rtptm, mblk_t *msg) { } data->packetSentCount += 1; - data->msg_to_send = dupmsg(msg); + ms_queue_put(&data->to_send, dupmsg(msg)); return 0; // Return 0 to drop the packet, it will be injected later } @@ -4905,15 +4905,15 @@ static int rtptm_on_receive(RtpTransportModifier *rtptm, mblk_t *msg) { } data->packetReceivedCount += 1; - data->msg_to_recv = dupmsg(msg); + ms_queue_put(&data->to_recv, dupmsg(msg)); return 0; // Return 0 to drop the packet, it will be injected later } static void rtptm_on_schedule(RtpTransportModifier *rtptm) { RtpTransportModifierData *data = rtptm->data; + mblk_t *msg = NULL; - if (data->msg_to_send != NULL) { - mblk_t *msg = data->msg_to_send; + while ((msg = ms_queue_get(&data->to_send)) != NULL) { int size = 0; unsigned char *src; int i = 0; @@ -4931,11 +4931,10 @@ static void rtptm_on_schedule(RtpTransportModifier *rtptm) { } meta_rtp_transport_modifier_inject_packet_to_send(rtptm->transport, rtptm, msg, 0); - data->msg_to_send = NULL; } - if (data->msg_to_recv != NULL) { - mblk_t *msg = data->msg_to_recv; + msg = NULL; + while ((msg = ms_queue_get(&data->to_recv)) != NULL) { int size = 0; unsigned char *src; int i = 0; @@ -4950,7 +4949,6 @@ static void rtptm_on_schedule(RtpTransportModifier *rtptm) { } meta_rtp_transport_modifier_inject_packet_to_recv(rtptm->transport, rtptm, msg, 0); - data->msg_to_recv = NULL; } } @@ -4969,6 +4967,8 @@ void static call_state_changed_4(LinphoneCore *lc, LinphoneCall *call, LinphoneC RtpTransport *rtpt = NULL; RtpTransportModifierData *data = ms_new0(RtpTransportModifierData, 1); RtpTransportModifier *rtptm = ms_new0(RtpTransportModifier, 1); + ms_queue_init(&data->to_send); + ms_queue_init(&data->to_recv); rtptm->data = data; rtptm->t_process_on_send = rtptm_on_send; rtptm->t_process_on_receive = rtptm_on_receive; @@ -5133,7 +5133,8 @@ static void custom_rtp_modifier(bool_t pauseResumeTest, bool_t recordTest) { ms_message("Pauline sent %i RTP packets and received %i (for real)", (int)pauline_rtp_stats.packet_sent, (int)pauline_rtp_stats.packet_recv); BC_ASSERT_TRUE(data_marie->packetReceivedCount == marie_rtp_stats.packet_recv); BC_ASSERT_TRUE(data_marie->packetSentCount == marie_rtp_stats.packet_sent); - BC_ASSERT_TRUE(data_pauline->packetReceivedCount == pauline_rtp_stats.packet_recv); + // There can be a small difference between the number of packets received in the modifier and the number processed in reception because the processing is asynchronous + BC_ASSERT_TRUE(data_pauline->packetReceivedCount - pauline_rtp_stats.packet_recv < 20); BC_ASSERT_TRUE(data_pauline->packetSentCount == pauline_rtp_stats.packet_sent); } diff --git a/tester/message_tester.c b/tester/message_tester.c index 756d8ee73..0e9aa0adf 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -1557,7 +1557,7 @@ static void real_time_text_message_accented_chars() { BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room), message[i], unsigned long, "%lu"); } - _linphone_chat_room_send_message(pauline_chat_room, rtt_message); + linphone_chat_room_send_chat_message(pauline_chat_room, rtt_message); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1)); BC_ASSERT_EQUAL(strcmp(marie->stat.last_received_chat_message->message, "ãæçéîøùÿ"), 0, int, "%i"); } diff --git a/tester/proxy_config_tester.c b/tester/proxy_config_tester.c index ac8e266a5..771403e84 100644 --- a/tester/proxy_config_tester.c +++ b/tester/proxy_config_tester.c @@ -41,6 +41,18 @@ static void phone_normalization_without_proxy(void) { BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "+3301234567891"), "+3301234567891"); BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "+33 01234567891"), "+3301234567891"); BC_ASSERT_PTR_NULL(phone_normalization(NULL, "I_AM_NOT_A_NUMBER")); // invalid phone number + + BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "0"), "0"); + BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "01"), "01"); + BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "012"), "012"); + BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "0123"), "0123"); + BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "01234"), "01234"); + BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "012345"), "012345"); + BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "0123456"), "0123456"); + BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "01234567"), "01234567"); + BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "012345678"), "012345678"); + BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "0123456789"), "0123456789"); + BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "01234567890"), "01234567890"); } static void phone_normalization_with_proxy(void) { @@ -70,8 +82,45 @@ static void phone_normalization_with_proxy(void) { BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0033952636505"), "+33952636505"); BC_ASSERT_PTR_NULL(phone_normalization(proxy, "toto")); + + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0"), "+330"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "01"), "+3301"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "012"), "+33012"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0123"), "+330123"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "01234"), "+3301234"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "012345"), "+33012345"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0123456"), "+330123456"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "01234567"), "+3301234567"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "012345678"), "+33012345678"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0123456789"), "+33123456789"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "01234567890"), "+33234567890"); + + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+330"), "+330"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+3301"), "+3301"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+33012"), "+33012"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+330123"), "+330123"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+3301234"), "+3301234"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+33012345"), "+33012345"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+330123456"), "+330123456"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+3301234567"), "+3301234567"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+33012345678"), "+33012345678"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+330123456789"), "+330123456789"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+3301234567890"), "+3301234567890"); + + // invalid prefix - use a generic dialplan with 10 max length linphone_proxy_config_set_dial_prefix(proxy, "99"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0012345678"), "+12345678"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0"), "+990"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "01"), "+9901"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "012"), "+99012"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0123"), "+990123"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "01234"), "+9901234"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "012345"), "+99012345"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0123456"), "+990123456"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "01234567"), "+9901234567"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "012345678"), "+99012345678"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0123456789"), "+990123456789"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "01234567890"), "+991234567890"); linphone_proxy_config_destroy(proxy); } @@ -83,6 +132,20 @@ static void phone_normalization_with_dial_escape_plus(void){ BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0033952636505"), "0033952636505"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0952636505"), "0033952636505"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+34952636505"), "0034952636505"); + + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0"), "00330"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "01"), "003301"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "012"), "0033012"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0123"), "00330123"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "01234"), "003301234"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "012345"), "0033012345"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0123456"), "00330123456"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "01234567"), "003301234567"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "012345678"), "0033012345678"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0123456789"), "0033123456789"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "01234567890"), "0033234567890"); + + linphone_proxy_config_destroy(proxy); } diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 6d383a4a7..104f2346c 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -43,6 +43,7 @@ set(LP_GEN_WRAPPERS_LIBS ${XML2_LIBRARIES} ) +apply_compile_flags(LP_GEN_WRAPPERS_SOURCE_FILES "CPP" "CXX") add_executable(lp-gen-wrappers ${LP_GEN_WRAPPERS_SOURCE_FILES}) target_link_libraries(lp-gen-wrappers ${LP_GEN_WRAPPERS_LIBS})