diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index c2488a050..cfeb48e7e 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -1077,9 +1077,10 @@ LINPHONE_PUBLIC bool_t linphone_proxy_config_is_phone_number(LinphoneProxyConfig /** * Normalize a human readable phone number into a basic string. 888-444-222 becomes 888444222 - * or +33888444222 depending on the #LinphoneProxyConfig argument. This function will always - * generate a normalized username; if input is not a phone number, output will be a copy of input. - * @param proxy #LinphoneProxyConfig object containing country code and/or escape symbol. + * or +33888444222 depending on the #LinphoneProxyConfig object. However this argument is OPTIONNAL + * and if not provided, a default one will be used. + * This function will always generate a normalized username; if input is not a phone number, output will be a copy of input. + * @param proxy #LinphoneProxyConfig object containing country code and/or escape symbol. If NULL passed, will use default configuration. * @param username the string to parse * @param result the newly normalized number * @param result_len the size of the normalized number \a result diff --git a/coreapi/private.h b/coreapi/private.h index d53a7d780..b095ae525 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -416,8 +416,6 @@ void linphone_core_get_local_ip(LinphoneCore *lc, int af, const char *dest, char LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LinphoneCore *lc, int index); void linphone_proxy_config_write_to_config_file(struct _LpConfig* config,LinphoneProxyConfig *obj, int index); -bool_t linphone_proxy_config_normalize_number(LinphoneProxyConfig *cfg, const char *username, char *result, size_t result_len); - void linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessage *msg); void linphone_core_is_composing_received(LinphoneCore *lc, SalOp *op, const SalIsComposing *is_composing); @@ -781,7 +779,7 @@ struct _LinphoneCore char* user_certificates_path; LinphoneVideoPolicy video_policy; time_t network_last_check; - + bool_t use_files; bool_t apply_nat_settings; bool_t initial_subscribes_sent; @@ -791,7 +789,7 @@ struct _LinphoneCore bool_t auto_net_state_mon; bool_t network_reachable; bool_t network_reachable_to_be_notified; /*set to true when state must be notified in next iterate*/ - + bool_t use_preview_window; bool_t network_last_status; bool_t ringstream_autorelease; diff --git a/coreapi/proxy.c b/coreapi/proxy.c index c66bdc4d4..4283712d9 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -937,11 +937,12 @@ static void replace_icp(const char *src, char *dest, size_t destlen, const char } -bool_t linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const char *username, char *result, size_t result_len){ +bool_t linphone_proxy_config_normalize_number(LinphoneProxyConfig *inproxy, const char *username, char *result, size_t result_len){ + bool_t ret; + LinphoneProxyConfig *proxy = inproxy ? inproxy : linphone_proxy_config_new(); memset(result, 0, result_len); if (linphone_proxy_config_is_phone_number(proxy, username)){ - char *flatten; - flatten=flatten_number(username); + char *flatten=flatten_number(username); ms_debug("Flattened number is '%s'",flatten); if (proxy->dial_prefix==NULL || proxy->dial_prefix[0]=='\0'){ @@ -987,11 +988,13 @@ bool_t linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const } } ms_free(flatten); - return TRUE; + ret = TRUE; } else { strncpy(result,username,result_len-1); - return FALSE; + ret = FALSE; } + if (inproxy==NULL) ms_free(proxy); + return ret; } /**