Change linphone_proxy_ocnifg_normalize_number API to return a boolean value: TRUE if input was a phone number, FALSE otherwise

Conflicts:
	coreapi/linphonecore.h
This commit is contained in:
Gautier Pelloux-Prayer 2015-01-08 11:38:39 +01:00
parent a79a5ceaa8
commit b8f297f6be
3 changed files with 53 additions and 44 deletions

View file

@ -962,7 +962,7 @@ LINPHONE_PUBLIC int linphone_proxy_config_get_quality_reporting_interval(Linphon
/**
* Get the registration state of the given proxy config.
* @param[in] obj #LinphoneProxyConfig object.
* @returns The registration state of the proxy config.
* @return The registration state of the proxy config.
**/
LINPHONE_PUBLIC LinphoneRegistrationState linphone_proxy_config_get_state(const LinphoneProxyConfig *obj);
@ -971,21 +971,21 @@ LINPHONE_PUBLIC bool_t linphone_proxy_config_is_registered(const LinphoneProxyCo
/**
* Get the domain name of the given proxy config.
* @param[in] cfg #LinphoneProxyConfig object.
* @returns The domain name of the proxy config.
* @return The domain name of the proxy config.
**/
LINPHONE_PUBLIC const char *linphone_proxy_config_get_domain(const LinphoneProxyConfig *cfg);
/**
* Get the realm of the given proxy config.
* @param[in] cfg #LinphoneProxyConfig object.
* @returns The realm of the proxy config.
* @return The realm of the proxy config.
**/
LINPHONE_PUBLIC const char *linphone_proxy_config_get_realm(const LinphoneProxyConfig *cfg);
/**
* Set the realm of the given proxy config.
* @param[in] cfg #LinphoneProxyConfig object.
* @param[in] realm New realm value.
* @returns The realm of the proxy config.
* @return The realm of the proxy config.
**/
LINPHONE_PUBLIC void linphone_proxy_config_set_realm(LinphoneProxyConfig *cfg, const char * realm);
@ -1006,7 +1006,7 @@ LINPHONE_PUBLIC const char* linphone_proxy_config_get_contact_uri_parameters(con
/**
* Get the #LinphoneCore object to which is associated the #LinphoneProxyConfig.
* @param[in] obj #LinphoneProxyConfig object.
* @returns The #LinphoneCore object to which is associated the #LinphoneProxyConfig.
* @return The #LinphoneCore object to which is associated the #LinphoneProxyConfig.
**/
LINPHONE_PUBLIC LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *obj);
@ -1016,21 +1016,21 @@ LINPHONE_PUBLIC const char * linphone_proxy_config_get_dial_prefix(const Linphon
/**
* Get the reason why registration failed when the proxy config state is LinphoneRegistrationFailed.
* @param[in] cfg #LinphoneProxyConfig object.
* @returns The reason why registration failed for this proxy config.
* @return The reason why registration failed for this proxy config.
**/
LINPHONE_PUBLIC LinphoneReason linphone_proxy_config_get_error(const LinphoneProxyConfig *cfg);
/**
* Get detailed information why registration failed when the proxy config state is LinphoneRegistrationFailed.
* @param[in] cfg #LinphoneProxyConfig object.
* @returns The details why registration failed for this proxy config.
* @return The details why registration failed for this proxy config.
**/
LINPHONE_PUBLIC const LinphoneErrorInfo *linphone_proxy_config_get_error_info(const LinphoneProxyConfig *cfg);
/**
* Get the transport from either service route, route or addr.
* @param[in] cfg #LinphoneProxyConfig object.
* @returns The transport as a string (I.E udp, tcp, tls, dtls)
* @return The transport as a string (I.E udp, tcp, tls, dtls)
**/
LINPHONE_PUBLIC const char* linphone_proxy_config_get_transport(const LinphoneProxyConfig *cfg);
@ -1041,9 +1041,17 @@ LINPHONE_PUBLIC void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cf
SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig *cfg);
LINPHONE_PUBLIC SipSetup *linphone_proxy_config_get_sip_setup(LinphoneProxyConfig *cfg);
/**
* normalize a human readable phone number into a basic string. 888-444-222 becomes 888444222
* 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.
* @param username the string to parse
* @param result the newly normalized number
* @param result_len the size of the normalized number \a result
* @return TRUE if a phone number was recognized, FALSE otherwise.
*/
LINPHONE_PUBLIC int linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const char *username, char *result, size_t result_len);
LINPHONE_PUBLIC bool_t linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const char *username,
char *result, size_t result_len);
/**
* Set default privacy policy for all calls routed through this proxy.
@ -1439,7 +1447,7 @@ LINPHONE_PUBLIC void linphone_chat_room_mark_as_read(LinphoneChatRoom *cr);
/**
* Delete a message from the chat room history.
* @param[in] cr The #LinphoneChatRoom object corresponding to the conversation.
* @param[in] msg The #LinphoneChatMessage object to remove.
* @param[in] msg The #LinphoneChatMessage object to remove.
*/
LINPHONE_PUBLIC void linphone_chat_room_delete_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg);
@ -1839,7 +1847,7 @@ typedef struct _LinphoneCoreVTable{
/**
* Instantiate a vtable with all arguments set to NULL
* @returns newly allocated vtable
* @return newly allocated vtable
*/
LINPHONE_PUBLIC LinphoneCoreVTable *linphone_core_v_table_new();
@ -1861,7 +1869,7 @@ LINPHONE_PUBLIC void* linphone_core_v_table_get_user_data(LinphoneCoreVTable *ta
* Gets the current VTable.
* This is meant only to be called from a callback to be able to get the user_data associated with the vtable that called the callback.
* @param lc the linphonecore
* @returns the vtable that called the last callback
* @returns the vtable that called the last callback
*/
LINPHONE_PUBLIC LinphoneCoreVTable *linphone_core_get_current_vtable(LinphoneCore *lc);
@ -1913,7 +1921,7 @@ typedef enum _LinphoneLogCollectionState {
/**
* Tells whether the linphone core log collection is enabled.
* @ingroup misc
* @returns The state of the linphone core log collection.
* @return The state of the linphone core log collection.
*/
LINPHONE_PUBLIC LinphoneLogCollectionState linphone_core_log_collection_enabled(void);
@ -1927,7 +1935,7 @@ LINPHONE_PUBLIC void linphone_core_enable_log_collection(LinphoneLogCollectionSt
/**
* Get the path where the log files will be written for log collection.
* @ingroup misc
* @returns The path where the log files will be written.
* @return The path where the log files will be written.
*/
LINPHONE_PUBLIC const char * linphone_core_get_log_collection_path(void);
@ -1941,7 +1949,7 @@ LINPHONE_PUBLIC void linphone_core_set_log_collection_path(const char *path);
/**
* Get the prefix of the filenames that will be used for log collection.
* @ingroup misc
* @returns The prefix of the filenames used for log collection.
* @return The prefix of the filenames used for log collection.
*/
LINPHONE_PUBLIC const char * linphone_core_get_log_collection_prefix(void);
@ -1955,7 +1963,7 @@ LINPHONE_PUBLIC void linphone_core_set_log_collection_prefix(const char *prefix)
/**
* Get the max file size in bytes of the files used for log collection.
* @ingroup misc
* @returns The max file size in bytes of the files used for log collection.
* @return The max file size in bytes of the files used for log collection.
*/
LINPHONE_PUBLIC int linphone_core_get_log_collection_max_file_size(void);
@ -2139,7 +2147,7 @@ LINPHONE_PUBLIC int linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall
* @param[in] lc #LinphoneCore object.
* @param[in] call The #LinphoneCall to redirect.
* @param[in] redirect_uri The URI to redirect the call to.
* @returns 0 if successful, -1 on error.
* @return 0 if successful, -1 on error.
* @ingroup call_control
*/
LINPHONE_PUBLIC int linphone_core_redirect_call(LinphoneCore *lc, LinphoneCall *call, const char *redirect_uri);
@ -2245,7 +2253,7 @@ LINPHONE_PUBLIC void linphone_core_enable_dns_srv(LinphoneCore *lc, bool_t enabl
/**
* Tells whether DNS SRV resolution is enabled.
* @param[in] lc #LinphoneCore object.
* @returns TRUE if DNS SRV resolution is enabled, FALSE if disabled.
* @return TRUE if DNS SRV resolution is enabled, FALSE if disabled.
* @ingroup media_parameters
*/
LINPHONE_PUBLIC bool_t linphone_core_dns_srv_enabled(const LinphoneCore *lc);
@ -2263,7 +2271,7 @@ LINPHONE_PUBLIC int linphone_core_set_video_codecs(LinphoneCore *lc, MSList *cod
* Tells whether the specified payload type is enabled.
* @param[in] lc #LinphoneCore object.
* @param[in] pt The #LinphonePayloadType we want to know is enabled or not.
* @returns TRUE if the payload type is enabled, FALSE if disabled.
* @return TRUE if the payload type is enabled, FALSE if disabled.
* @ingroup media_parameters
*/
LINPHONE_PUBLIC bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, const LinphonePayloadType *pt);
@ -2272,7 +2280,7 @@ LINPHONE_PUBLIC bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, cons
* Tells whether the specified payload type represents a variable bitrate codec.
* @param[in] lc #LinphoneCore object.
* @param[in] pt The #LinphonePayloadType we want to know
* @returns TRUE if the payload type represents a VBR codec, FALSE if disabled.
* @return TRUE if the payload type represents a VBR codec, FALSE if disabled.
* @ingroup media_parameters
*/
LINPHONE_PUBLIC bool_t linphone_core_payload_type_is_vbr(LinphoneCore *lc, const LinphonePayloadType *pt);
@ -2397,7 +2405,7 @@ LINPHONE_PUBLIC void linphone_core_enable_audio_adaptive_jittcomp(LinphoneCore *
/**
* Tells whether the audio adaptive jitter compensation is enabled.
* @param[in] lc #LinphoneCore object
* @returns TRUE if the audio adaptive jitter compensation is enabled, FALSE otherwise.
* @return TRUE if the audio adaptive jitter compensation is enabled, FALSE otherwise.
* @ingroup media_parameters
*/
LINPHONE_PUBLIC bool_t linphone_core_audio_adaptive_jittcomp_enabled(LinphoneCore *lc);
@ -2417,7 +2425,7 @@ LINPHONE_PUBLIC void linphone_core_enable_video_adaptive_jittcomp(LinphoneCore *
/**
* Tells whether the video adaptive jitter compensation is enabled.
* @param[in] lc #LinphoneCore object
* @returns TRUE if the video adaptive jitter compensation is enabled, FALSE otherwise.
* @return TRUE if the video adaptive jitter compensation is enabled, FALSE otherwise.
* @ingroup media_parameters
*/
LINPHONE_PUBLIC bool_t linphone_core_video_adaptive_jittcomp_enabled(LinphoneCore *lc);
@ -2496,7 +2504,7 @@ LINPHONE_PUBLIC void linphone_core_set_stun_server(LinphoneCore *lc, const char
/**
* Get the STUN server address being used.
* @param[in] lc #LinphoneCore object
* @returns The STUN server address being used.
* @return The STUN server address being used.
* @ingroup network_parameters
*/
LINPHONE_PUBLIC const char * linphone_core_get_stun_server(const LinphoneCore *lc);
@ -2541,7 +2549,7 @@ LINPHONE_PUBLIC void linphone_core_set_nat_address(LinphoneCore *lc, const char
/**
* Get the public IP address of NAT being used.
* @param[in] lc #LinphoneCore object.
* @returns The public IP address of NAT being used.
* @return The public IP address of NAT being used.
* @ingroup network_parameters
*/
LINPHONE_PUBLIC const char *linphone_core_get_nat_address(const LinphoneCore *lc);
@ -2557,7 +2565,7 @@ LINPHONE_PUBLIC void linphone_core_set_firewall_policy(LinphoneCore *lc, Linphon
/**
* Get the policy that is used to pass through firewalls.
* @param[in] lc #LinphoneCore object.
* @returns The #LinphoneFirewallPolicy that is being used.
* @return The #LinphoneFirewallPolicy that is being used.
* @ingroup network_parameters
*/
LINPHONE_PUBLIC LinphoneFirewallPolicy linphone_core_get_firewall_policy(const LinphoneCore *lc);
@ -2627,7 +2635,7 @@ LINPHONE_PUBLIC void linphone_core_enable_echo_limiter(LinphoneCore *lc, bool_t
/**
* Tells whether echo limiter is enabled.
* @param[in] lc #LinphoneCore object.
* @returns TRUE if the echo limiter is enabled, FALSE otherwise.
* @return TRUE if the echo limiter is enabled, FALSE otherwise.
* @ingroup media_parameters
**/
LINPHONE_PUBLIC bool_t linphone_core_echo_limiter_enabled(const LinphoneCore *lc);
@ -2657,7 +2665,7 @@ LINPHONE_PUBLIC void linphone_core_enable_mic(LinphoneCore *lc, bool_t enable);
/**
* Tells whether the microphone is enabled.
* @param[in] lc #LinphoneCore object
* @returns TRUE if the microphone is enabled, FALSE if disabled.
* @return TRUE if the microphone is enabled, FALSE if disabled.
* @ingroup media_parameters
**/
LINPHONE_PUBLIC bool_t linphone_core_mic_enabled(LinphoneCore *lc);
@ -2694,7 +2702,7 @@ LINPHONE_PUBLIC void linphone_core_clear_call_logs(LinphoneCore *lc);
* Get the number of missed calls.
* Once checked, this counter can be reset with linphone_core_reset_missed_calls_count().
* @param[in] lc #LinphoneCore object.
* @returns The number of missed calls.
* @return The number of missed calls.
**/
LINPHONE_PUBLIC int linphone_core_get_missed_calls_count(LinphoneCore *lc);
@ -2785,7 +2793,7 @@ LINPHONE_PUBLIC void linphone_core_enable_video_source_reuse(LinphoneCore* lc, b
/**
* Tells whether video capture is enabled.
* @param[in] lc #LinphoneCore object.
* @returns TRUE if video capture is enabled, FALSE if disabled.
* @return TRUE if video capture is enabled, FALSE if disabled.
* @ingroup media_parameters
**/
LINPHONE_PUBLIC bool_t linphone_core_video_capture_enabled(LinphoneCore *lc);
@ -2793,7 +2801,7 @@ LINPHONE_PUBLIC bool_t linphone_core_video_capture_enabled(LinphoneCore *lc);
/**
* Tells whether video display is enabled.
* @param[in] lc #LinphoneCore object.
* @returns TRUE if video display is enabled, FALSE if disabled.
* @return TRUE if video display is enabled, FALSE if disabled.
* @ingroup media_parameters
**/
LINPHONE_PUBLIC bool_t linphone_core_video_display_enabled(LinphoneCore *lc);
@ -2817,7 +2825,7 @@ LINPHONE_PUBLIC MSVideoSize linphone_core_get_preferred_video_size(const Linphon
/**
* Get the name of the current preferred video size for sending.
* @param[in] lc #LinphoneCore object.
* @returns A string containing the name of the current preferred video size (to be freed with ms_free()).
* @return A string containing the name of the current preferred video size (to be freed with ms_free()).
*/
LINPHONE_PUBLIC char * linphone_core_get_preferred_video_size_name(const LinphoneCore *lc);
LINPHONE_PUBLIC void linphone_core_set_preferred_video_size_by_name(LinphoneCore *lc, const char *name);
@ -2857,7 +2865,7 @@ LINPHONE_PUBLIC int linphone_core_set_static_picture(LinphoneCore *lc, const cha
/**
* Get the path to the image file streamed when "Static picture" is set as the video device.
* @param[in] lc #LinphoneCore object.
* @returns The path to the image file streamed when "Static picture" is set as the video device.
* @return The path to the image file streamed when "Static picture" is set as the video device.
* @ingroup media_parameters
*/
LINPHONE_PUBLIC const char *linphone_core_get_static_picture(LinphoneCore *lc);
@ -3014,7 +3022,7 @@ LINPHONE_PUBLIC void linphone_core_set_zrtp_secrets_file(LinphoneCore *lc, const
/**
* Get the path to the file storing the zrtp secrets cache.
* @param[in] lc #LinphoneCore object.
* @returns The path to the file storing the zrtp secrets cache.
* @return The path to the file storing the zrtp secrets cache.
* @ingroup initializing
*/
LINPHONE_PUBLIC const char *linphone_core_get_zrtp_secrets_file(LinphoneCore *lc);
@ -3063,7 +3071,7 @@ LINPHONE_PUBLIC bool_t linphone_core_media_encryption_supported(const LinphoneCo
* Choose the media encryption policy to be used for RTP packets.
* @param[in] lc #LinphoneCore object.
* @param[in] menc The media encryption policy to be used.
* @returns 0 if successful, any other value otherwise.
* @return 0 if successful, any other value otherwise.
* @ingroup media_parameters
*/
LINPHONE_PUBLIC int linphone_core_set_media_encryption(LinphoneCore *lc, LinphoneMediaEncryption menc);
@ -3071,7 +3079,7 @@ LINPHONE_PUBLIC int linphone_core_set_media_encryption(LinphoneCore *lc, Linphon
/**
* Get the media encryption policy being used for RTP packets.
* @param[in] lc #LinphoneCore object.
* @returns The media encryption policy being used.
* @return The media encryption policy being used.
* @ingroup media_parameters
*/
LINPHONE_PUBLIC LinphoneMediaEncryption linphone_core_get_media_encryption(LinphoneCore *lc);
@ -3079,7 +3087,7 @@ LINPHONE_PUBLIC LinphoneMediaEncryption linphone_core_get_media_encryption(Linph
/**
* Get behaviour when encryption parameters negociation fails on outgoing call.
* @param[in] lc #LinphoneCore object.
* @returns TRUE means the call will fail; FALSE means an INVITE will be resent with encryption disabled.
* @return TRUE means the call will fail; FALSE means an INVITE will be resent with encryption disabled.
* @ingroup media_parameters
*/
LINPHONE_PUBLIC bool_t linphone_core_is_media_encryption_mandatory(LinphoneCore *lc);

View file

@ -409,7 +409,7 @@ 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);
int linphone_proxy_config_normalize_number(LinphoneProxyConfig *cfg, const char *username, char *result, size_t result_len);
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);

View file

@ -927,8 +927,7 @@ static void replace_plus(const char *src, char *dest, size_t destlen, const char
}
int linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const char *username, char *result, size_t result_len){
int numlen;
bool_t linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const char *username, char *result, size_t result_len){
if (is_a_phone_number(username)){
char *flatten;
flatten=flatten_number(username);
@ -938,7 +937,6 @@ int linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const cha
/*no prefix configured, nothing else to do*/
strncpy(result,flatten,result_len);
ms_free(flatten);
return 0;
}else{
dial_plan_t dialplan;
lookup_dial_plan(proxy->dial_prefix,&dialplan);
@ -949,8 +947,8 @@ int linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const cha
/*eventually replace the plus*/
replace_plus(flatten,result,result_len,proxy->dial_escape_plus ? dialplan.icp : NULL);
ms_free(flatten);
return 0;
}else{
int numlen;
int i=0;
int skip;
numlen=strlen(flatten);
@ -975,8 +973,11 @@ int linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const cha
ms_free(flatten);
}
}
}else strncpy(result,username,result_len);
return 0;
return TRUE;
} else {
strncpy(result,username,result_len);
return FALSE;
}
}
/**