From d9f41fff5aedbcb995eb8bb5cf1a9581c505d67d Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 29 Jul 2015 11:34:31 +0200 Subject: [PATCH] proxy config: modify linphone_proxy_config_get_contact and add linphone_proxy_config_get_identity_address returning LinphoneAddress and move all documentation to linphone_proxy_config.h --- coreapi/CMakeLists.txt | 48 +- coreapi/Makefile.am | 10 +- coreapi/account_creator.c | 5 +- coreapi/linphone_proxy_config.h | 501 ++++++++++++++++ coreapi/linphonecall.c | 11 +- coreapi/linphonecore.h | 368 +----------- coreapi/plugins/buddylookup/src/lookup.c | 33 +- coreapi/private.h | 7 +- coreapi/proxy.c | 699 +++++++++-------------- gtk/chat.c | 20 +- gtk/loginframe.c | 12 +- tester/call_tester.c | 11 +- tester/tester.c | 2 +- tester/tunnel_tester.c | 10 +- 14 files changed, 872 insertions(+), 865 deletions(-) create mode 100644 coreapi/linphone_proxy_config.h diff --git a/coreapi/CMakeLists.txt b/coreapi/CMakeLists.txt index 68f7b82b7..518218da6 100644 --- a/coreapi/CMakeLists.txt +++ b/coreapi/CMakeLists.txt @@ -32,7 +32,6 @@ endif() set(SOURCE_FILES account_creator.c - account_creator.h address.c authentication.c bellesip_sal/sal_address_impl.c @@ -61,18 +60,13 @@ set(SOURCE_FILES enum.c enum.h event.c - event.h friend.c info.c ldap/ldapprovider.c lime.c linphonecall.c linphonecore.c - linphonecore.h - linphonecore_utils.h - linphonefriend.h linphone_tunnel_config.c - linphone_tunnel.h localplayer.c lpconfig.c lpconfig.h @@ -90,14 +84,30 @@ set(SOURCE_FILES sal.c siplogin.c sipsetup.c - sipsetup.h xml2lpc.c - xml2lpc.h xml.c xmlrpc.c - xmlrpc.h vtables.c ) + +set(HEADER_FILES + account_creator.h + buffer.h + call_log.h + call_params.h + content.h + event.h + linphonecore.h + linphonecore_utils.h + linphonefriend.h + linphonepresence.h + linphone_tunnel.h + lpc2xml.h + lpconfig.h + sipsetup.h + xml2lpc.h + xmlrpc.h +) if(ENABLE_TUNNEL) list(APPEND SOURCE_FILES linphone_tunnel.cc @@ -183,26 +193,6 @@ install(TARGETS linphone EXPORT LinphoneTargets PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) - -set(HEADER_FILES - account_creator.h - buffer.h - call_log.h - call_params.h - content.h - event.h - linphonecore.h - linphonecore_utils.h - linphonefriend.h - linphonepresence.h - linphone_tunnel.h - lpc2xml.h - lpconfig.h - sipsetup.h - xml2lpc.h - xmlrpc.h -) - install(FILES ${HEADER_FILES} DESTINATION include/linphone PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ diff --git a/coreapi/Makefile.am b/coreapi/Makefile.am index b16105aea..d4c4516ce 100644 --- a/coreapi/Makefile.am +++ b/coreapi/Makefile.am @@ -35,6 +35,7 @@ linphone_include_HEADERS=\ linphonecore_utils.h \ linphonefriend.h \ linphonepresence.h \ + linphone_proxy_config.h \ linphone_tunnel.h \ lpc2xml.h \ lpconfig.h \ @@ -59,17 +60,16 @@ liblinphone_la_SOURCES=\ dict.c \ ec-calibrator.c \ enum.c enum.h \ - event.c event.h \ + event.c \ friend.c \ info.c \ ldap/ldapprovider.c ldap/ldapprovider.h \ linphonecall.c \ - linphonecore.c linphonecore.h \ - linphonecore_utils.h \ + linphonecore.c \ localplayer.c \ lpc2xml.c \ lime.c lime.h\ - lpconfig.c lpconfig.h \ + lpconfig.c \ lsd.c \ message_storage.c \ misc.c \ @@ -82,7 +82,7 @@ liblinphone_la_SOURCES=\ remote_provisioning.c \ sal.c \ siplogin.c \ - sipsetup.c sipsetup.h \ + sipsetup.c \ xml2lpc.c \ xml.c \ xmlrpc.c \ diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index d93bd4a5e..33c592d7e 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -269,7 +269,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_validate(LinphoneAccountCr } LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCreator *creator) { - LinphoneAddress *identity; + const LinphoneAddress *identity; LinphoneAuthInfo *info; LinphoneProxyConfig *cfg = linphone_core_create_proxy_config(creator->core); char *identity_str = ms_strdup_printf("sip:%s@%s", creator->username, creator->domain); @@ -298,10 +298,9 @@ LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCr linphone_core_set_firewall_policy(creator->core, LinphonePolicyUseIce); } - identity = linphone_address_new(linphone_proxy_config_get_identity(cfg)); + identity = linphone_proxy_config_get_identity_address(cfg); info = linphone_auth_info_new(linphone_address_get_username(identity), NULL, creator->password, NULL, NULL, linphone_address_get_domain(identity)); linphone_core_add_auth_info(creator->core, info); - linphone_address_destroy(identity); if (linphone_core_add_proxy_config(creator->core, cfg) != -1) { linphone_core_set_default_proxy(creator->core, cfg); diff --git a/coreapi/linphone_proxy_config.h b/coreapi/linphone_proxy_config.h new file mode 100644 index 000000000..c4b7dee23 --- /dev/null +++ b/coreapi/linphone_proxy_config.h @@ -0,0 +1,501 @@ +/* +Copyright (C) 2000 - 2010 Simon MORLAT (simon.morlat@linphone.org) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#ifndef LINPHONE_PROXY_CONFIG_H +#define LINPHONE_PROXY_CONFIG_H + +/** + * Creates an empty proxy config. + * @deprecated, use #linphone_core_create_proxy_config instead +**/ +LINPHONE_PUBLIC LinphoneProxyConfig *linphone_proxy_config_new(void); + +/** + * Acquire a reference to the proxy config. + * @param[in] cfg #LinphoneProxyConfig object. + * @return The same proxy config. +**/ +LINPHONE_PUBLIC LinphoneProxyConfig *linphone_proxy_config_ref(LinphoneProxyConfig *cfg); + +/** + * Release reference to the proxy config. + * @param[in] cfg #LinphoneProxyConfig object. +**/ +LINPHONE_PUBLIC void linphone_proxy_config_unref(LinphoneProxyConfig *cfg); + +/** + * Retrieve the user pointer associated with the proxy config. + * @param[in] cfg #LinphoneProxyConfig object. + * @return The user pointer associated with the proxy config. +**/ +LINPHONE_PUBLIC void *linphone_proxy_config_get_user_data(const LinphoneProxyConfig *cfg); + +/** + * Assign a user pointer to the proxy config. + * @param[in] cfg #LinphoneProxyConfig object. + * @param[in] ud The user pointer to associate with the proxy config. +**/ +LINPHONE_PUBLIC void linphone_proxy_config_set_user_data(LinphoneProxyConfig *cfg, void *ud); + +/** + * Sets the proxy address + * + * Examples of valid sip proxy address are: + * - IP address: sip:87.98.157.38 + * - IP address with port: sip:87.98.157.38:5062 + * - hostnames : sip:sip.example.net +**/ +LINPHONE_PUBLIC int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *cfg, const char *server_addr); + +/** + * @deprecated Use linphone_proxy_config_set_identity_address() +**/ +LINPHONE_PUBLIC int linphone_proxy_config_set_identity(LinphoneProxyConfig *cfg, const char *identity); + +/** + * Sets the user identity as a SIP address. + * + * This identity is normally formed with display name, username and domain, such + * as: + * Alice + * The REGISTER messages will have from and to set to this identity. + * +**/ +LINPHONE_PUBLIC int linphone_proxy_config_set_identity_address(LinphoneProxyConfig *cfg, const LinphoneAddress *identity); + +/** + * Sets a SIP route. + * When a route is set, all outgoing calls will go to the route's destination if this proxy + * is the default one (see linphone_core_set_default_proxy() ). +**/ +LINPHONE_PUBLIC int linphone_proxy_config_set_route(LinphoneProxyConfig *cfg, const char *route); + +/** + * Sets the registration expiration time in seconds. +**/ +LINPHONE_PUBLIC void linphone_proxy_config_set_expires(LinphoneProxyConfig *cfg, int expires); + +#define linphone_proxy_config_expires linphone_proxy_config_set_expires +/** + * Indicates either or not, REGISTRATION must be issued for this #LinphoneProxyConfig . + *
In case this #LinphoneProxyConfig has been added to #LinphoneCore, follows the linphone_proxy_config_edit() rule. + * @param[in] cfg #LinphoneProxyConfig object. + * @param val if true, registration will be engaged + */ +LINPHONE_PUBLIC void linphone_proxy_config_enable_register(LinphoneProxyConfig *cfg, bool_t val); + +#define linphone_proxy_config_enableregister linphone_proxy_config_enable_register + +/** + * Starts editing a proxy configuration. + * + * Because proxy configuration must be consistent, applications MUST + * call linphone_proxy_config_edit() before doing any attempts to modify + * proxy configuration (such as identity, proxy address and so on). + * Once the modifications are done, then the application must call + * linphone_proxy_config_done() to commit the changes. +**/ +LINPHONE_PUBLIC void linphone_proxy_config_edit(LinphoneProxyConfig *cfg); + +/** + * Commits modification made to the proxy configuration. +**/ +LINPHONE_PUBLIC int linphone_proxy_config_done(LinphoneProxyConfig *cfg); +/** + * Indicates either or not, PUBLISH must be issued for this #LinphoneProxyConfig . + *
In case this #LinphoneProxyConfig has been added to #LinphoneCore, follows the linphone_proxy_config_edit() rule. + * @param[in] cfg #LinphoneProxyConfig object. + * @param val if true, publish will be engaged + * + */ +LINPHONE_PUBLIC void linphone_proxy_config_enable_publish(LinphoneProxyConfig *cfg, bool_t val); +/** + * Set the publish expiration time in second. + * @param[in] cfg #LinphoneProxyConfig object. + * @param expires in second + * */ + +LINPHONE_PUBLIC void linphone_proxy_config_set_publish_expires(LinphoneProxyConfig *cfg, int expires); +/** + * get the publish expiration time in second. Default value is the registration expiration value. + * @param[in] cfg #LinphoneProxyConfig object. + * @return expires in second + * */ + +LINPHONE_PUBLIC int linphone_proxy_config_get_publish_expires(const LinphoneProxyConfig *cfg); + +/** + * Sets whether liblinphone should replace "+" by international calling prefix in dialed numbers (passed to + * #linphone_core_invite ). + * +**/ +LINPHONE_PUBLIC void linphone_proxy_config_set_dial_escape_plus(LinphoneProxyConfig *cfg, bool_t val); + +/** + * Sets a dialing prefix to be automatically prepended when inviting a number with + * linphone_core_invite(); + * This dialing prefix shall usually be the country code of the country where the user is living, without "+". + * +**/ +LINPHONE_PUBLIC void linphone_proxy_config_set_dial_prefix(LinphoneProxyConfig *cfg, const char *prefix); + + /** + * Indicates whether quality statistics during call should be stored and sent to a collector according to RFC 6035. + * @param[in] cfg #LinphoneProxyConfig object. + * @param[in] enable True to sotre quality statistics and sent them to the collector, false to disable it. + */ +LINPHONE_PUBLIC void linphone_proxy_config_enable_quality_reporting(LinphoneProxyConfig *cfg, bool_t enable); + +/** + * Indicates whether quality statistics during call should be stored and sent to a collector according to RFC 6035. + * @param[in] cfg #LinphoneProxyConfig object. + * @return True if quality repotring is enabled, false otherwise. + */ +LINPHONE_PUBLIC bool_t linphone_proxy_config_quality_reporting_enabled(LinphoneProxyConfig *cfg); + + /** + * Set the route of the collector end-point when using quality reporting. This SIP address + * should be used on server-side to process packets directly before discarding packets. Collector address + * should be a non existing account and will not receive any messages. + * If NULL, reports will be send to the proxy domain. + * @param[in] cfg #LinphoneProxyConfig object. + * @param[in] collector route of the collector end-point, if NULL PUBLISH will be sent to the proxy domain. + */ +LINPHONE_PUBLIC void linphone_proxy_config_set_quality_reporting_collector(LinphoneProxyConfig *cfg, const char *collector); + + /** + * Get the route of the collector end-point when using quality reporting. This SIP address + * should be used on server-side to process packets directly before discarding packets. Collector address + * should be a non existing account and will not receive any messages. + * If NULL, reports will be send to the proxy domain. + * @param[in] cfg #LinphoneProxyConfig object. + * @return The SIP address of the collector end-point. + */ +LINPHONE_PUBLIC const char *linphone_proxy_config_get_quality_reporting_collector(const LinphoneProxyConfig *cfg); + +/** + * Set the interval between 2 interval reports sending when using quality reporting. If call exceed interval size, an + * interval report will be sent to the collector. On call termination, a session report will be sent + * for the remaining period. Value must be 0 (disabled) or positive. + * @param[in] cfg #LinphoneProxyConfig object. + * @param[in] interval The interval in seconds, 0 means interval reports are disabled. + */ +LINPHONE_PUBLIC void linphone_proxy_config_set_quality_reporting_interval(LinphoneProxyConfig *cfg, uint8_t interval); + +/** + * Get the interval between interval reports when using quality reporting. + * @param[in] cfg #LinphoneProxyConfig object. + * @return The interval in seconds, 0 means interval reports are disabled. + */ + +LINPHONE_PUBLIC int linphone_proxy_config_get_quality_reporting_interval(LinphoneProxyConfig *cfg); + +/** + * Get the registration state of the given proxy config. + * @param[in] cfg #LinphoneProxyConfig object. + * @return The registration state of the proxy config. +**/ +LINPHONE_PUBLIC LinphoneRegistrationState linphone_proxy_config_get_state(const LinphoneProxyConfig *cfg); + +/** + * @return a boolean indicating that the user is sucessfully registered on the proxy. + * @deprecated Use linphone_proxy_config_get_state() instead. +**/ +LINPHONE_PUBLIC bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *cfg); + +/** + * Get the domain name of the given proxy config. + * @param[in] cfg #LinphoneProxyConfig object. + * @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. + * @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. + * @return The realm of the proxy config. +**/ +LINPHONE_PUBLIC void linphone_proxy_config_set_realm(LinphoneProxyConfig *cfg, const char * realm); + +/** + * @return the route set for this proxy configuration. +**/ +LINPHONE_PUBLIC const char *linphone_proxy_config_get_route(const LinphoneProxyConfig *cfg); + +/** + * @return the SIP identity that belongs to this proxy configuration. +**/ +LINPHONE_PUBLIC const LinphoneAddress *linphone_proxy_config_get_identity_address(const LinphoneProxyConfig *cfg); + +/** + * @deprecated use linphone_proxy_config_get_identity_address() +**/ +LINPHONE_PUBLIC const char *linphone_proxy_config_get_identity(const LinphoneProxyConfig *cfg); + +/** + * @return TRUE if PUBLISH request is enabled for this proxy. +**/ +LINPHONE_PUBLIC bool_t linphone_proxy_config_publish_enabled(const LinphoneProxyConfig *cfg); + +/** + * @return the proxy's SIP address. +**/ +LINPHONE_PUBLIC const char *linphone_proxy_config_get_server_addr(const LinphoneProxyConfig *cfg); +#define linphone_proxy_config_get_addr linphone_proxy_config_get_server_addr +/** + * @return the duration of registration. +**/ +LINPHONE_PUBLIC int linphone_proxy_config_get_expires(const LinphoneProxyConfig *cfg); +/** + * @return TRUE if registration to the proxy is enabled. +**/ +LINPHONE_PUBLIC bool_t linphone_proxy_config_register_enabled(const LinphoneProxyConfig *cfg); +/** + * Refresh a proxy registration. + * This is useful if for example you resuming from suspend, thus IP address may have changed. +**/ +LINPHONE_PUBLIC void linphone_proxy_config_refresh_register(LinphoneProxyConfig *cfg); +/** + * Prevent a proxy config from refreshing its registration. + * This is useful to let registrations to expire naturally (or) when the application wants to keep control on when + * refreshes are sent. + * However, linphone_core_set_network_reachable(lc,TRUE) will always request the proxy configs to refresh their registrations. + * The refreshing operations can be resumed with linphone_proxy_config_refresh_register(). + * @param[in] cfg #LinphoneProxyConfig object. +**/ +LINPHONE_PUBLIC void linphone_proxy_config_pause_register(LinphoneProxyConfig *cfg); +/** + * @return previously set contact parameters. +**/ +LINPHONE_PUBLIC const char *linphone_proxy_config_get_contact_parameters(const LinphoneProxyConfig *cfg); +/** + * Set optional contact parameters that will be added to the contact information sent in the registration. + * @param[in] cfg #LinphoneProxyConfig object. + * @param contact_params a string contaning the additional parameters in text form, like "myparam=something;myparam2=something_else" + * + * The main use case for this function is provide the proxy additional information regarding the user agent, like for example unique identifier or apple push id. + * As an example, the contact address in the SIP register sent will look like ;apple-push-id=43143-DFE23F-2323-FA2232. +**/ +LINPHONE_PUBLIC void linphone_proxy_config_set_contact_parameters(LinphoneProxyConfig *cfg, const char *contact_params); + +/** + * Set optional contact parameters that will be added to the contact information sent in the registration, inside the URI. + * @param[in] cfg #LinphoneProxyConfig object. + * @param contact_uri_params a string containing the additional parameters in text form, like "myparam=something;myparam2=something_else" + * + * The main use case for this function is provide the proxy additional information regarding the user agent, like for example unique identifier or apple push id. + * As an example, the contact address in the SIP register sent will look like . +**/ +LINPHONE_PUBLIC void linphone_proxy_config_set_contact_uri_parameters(LinphoneProxyConfig *cfg, const char *contact_uri_params); + +/** + * @return previously set contact URI parameters. +**/ +LINPHONE_PUBLIC const char* linphone_proxy_config_get_contact_uri_parameters(const LinphoneProxyConfig *cfg); + +/** + * Get the #LinphoneCore object to which is associated the #LinphoneProxyConfig. + * @param[in] cfg #LinphoneProxyConfig object. + * @return The #LinphoneCore object to which is associated the #LinphoneProxyConfig. +**/ +LINPHONE_PUBLIC LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *cfg); + +/** + * @return whether liblinphone should replace "+" by "00" in dialed numbers (passed to + * #linphone_core_invite ). + * +**/ +LINPHONE_PUBLIC bool_t linphone_proxy_config_get_dial_escape_plus(const LinphoneProxyConfig *cfg); + +/** + * @return dialing prefix. +**/ +LINPHONE_PUBLIC const char * linphone_proxy_config_get_dial_prefix(const LinphoneProxyConfig *cfg); + +/** + * Get the reason why registration failed when the proxy config state is LinphoneRegistrationFailed. + * @param[in] cfg #LinphoneProxyConfig object. + * @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. + * @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. + * @return The transport as a string (I.E udp, tcp, tls, dtls) +**/ +LINPHONE_PUBLIC const char* linphone_proxy_config_get_transport(const LinphoneProxyConfig *cfg); + + +/** + * Destroys a proxy config. + * @deprecated + * + * @note: LinphoneProxyConfig that have been removed from LinphoneCore with + * linphone_core_remove_proxy_config() must not be freed. +**/ +LINPHONE_PUBLIC void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg); + +LINPHONE_PUBLIC void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type); +LINPHONE_PUBLIC SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig *cfg); +LINPHONE_PUBLIC SipSetup *linphone_proxy_config_get_sip_setup(LinphoneProxyConfig *cfg); + +/** + * Detect if the given input is a phone number or not. + * @param proxy #LinphoneProxyConfig argument, unused yet but may contain useful data. Can be NULL. + * @param username string to parse. + * @return TRUE if input is a phone number, FALSE otherwise. +**/ +LINPHONE_PUBLIC bool_t linphone_proxy_config_is_phone_number(LinphoneProxyConfig *proxy, const char *username); + +/** + * Normalize a human readable phone number into a basic string. 888-444-222 becomes 888444222 + * 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 + * @return TRUE if a phone number was recognized, FALSE otherwise. + */ +LINPHONE_PUBLIC bool_t linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const char *username, + char *result, size_t result_len); + +/** + * Same objective as linphone_proxy_config_normalize_number but allocates a new string + * @param proxy #LinphoneProxyConfig object containing country code and/or escape symbol. If NULL passed, will use default configuration. + * @param username the string to parse + * @return NULL if invalid phone number, normalized phone number from username input otherwise. +*/ +LINPHONE_PUBLIC char* linphone_proxy_config_normalize_phone_number(LinphoneProxyConfig *proxy, const char *username); + +/** + * Normalize a human readable sip uri into a fully qualified LinphoneAddress. + * A sip address should look like DisplayName \ . + * Basically this function performs the following tasks + * - if a phone number is entered, prepend country prefix and eventually escape the '+' by 00 of the proxy config. + * - if no domain part is supplied, append the domain name of the proxy config. Returns NULL if no proxy is provided at this point. + * - if no sip: is present, prepend it. + * + * The result is a syntactically correct SIP address. + * @param proxy #LinphoneProxyConfig object containing country code, escape symbol and/or domain name. Can be NULL if domain is already provided. + * @param username the string to parse + * @return NULL if invalid input, normalized sip address otherwise. +*/ +LINPHONE_PUBLIC LinphoneAddress* linphone_proxy_config_normalize_sip_uri(LinphoneProxyConfig *proxy, const char *username); + +/** + * Set default privacy policy for all calls routed through this proxy. + * @param[in] cfg #LinphoneProxyConfig object. + * @param privacy LinphonePrivacy to configure privacy + * */ +LINPHONE_PUBLIC void linphone_proxy_config_set_privacy(LinphoneProxyConfig *cfg, LinphonePrivacyMask privacy); +/** + * Get default privacy policy for all calls routed through this proxy. + * @param[in] cfg #LinphoneProxyConfig object. + * @return Privacy mode + * */ +LINPHONE_PUBLIC LinphonePrivacyMask linphone_proxy_config_get_privacy(const LinphoneProxyConfig *cfg); +/** + * Set the http file transfer server to be used for content type application/vnd.gsma.rcs-ft-http+xml + * @param[in] cfg #LinphoneProxyConfig object. + * @param server_url URL of the file server like https://file.linphone.org/upload.php + * */ +LINPHONE_PUBLIC void linphone_proxy_config_set_file_transfer_server(LinphoneProxyConfig *cfg, const char * server_url); +/** + * Get the http file transfer server to be used for content type application/vnd.gsma.rcs-ft-http+xml + * @param[in] cfg #LinphoneProxyConfig object. + * @return URL of the file server like https://file.linphone.org/upload.php + * */ +LINPHONE_PUBLIC const char* linphone_proxy_config_get_file_transfer_server(const LinphoneProxyConfig *cfg); + +/** + * Indicates whether AVPF/SAVPF must be used for calls using this proxy config. + * @param[in] cfg #LinphoneProxyConfig object. + * @param[in] enable True to enable AVPF/SAVF, false to disable it. + * @deprecated use linphone_proxy_config_set_avpf_mode() + */ +LINPHONE_PUBLIC void linphone_proxy_config_enable_avpf(LinphoneProxyConfig *cfg, bool_t enable); + +/** + * Indicates whether AVPF/SAVPF is being used for calls using this proxy config. + * @param[in] cfg #LinphoneProxyConfig object. + * @return True if AVPF/SAVPF is enabled, false otherwise. + * @deprecated use linphone_proxy_config_set_avpf_mode() + */ +LINPHONE_PUBLIC bool_t linphone_proxy_config_avpf_enabled(LinphoneProxyConfig *cfg); + +/** + * Set the interval between regular RTCP reports when using AVPF/SAVPF. + * @param[in] cfg #LinphoneProxyConfig object. + * @param[in] interval The interval in seconds (between 0 and 5 seconds). + */ +LINPHONE_PUBLIC void linphone_proxy_config_set_avpf_rr_interval(LinphoneProxyConfig *cfg, uint8_t interval); + +/** + * Get the interval between regular RTCP reports when using AVPF/SAVPF. + * @param[in] cfg #LinphoneProxyConfig object. + * @return The interval in seconds. + */ +LINPHONE_PUBLIC uint8_t linphone_proxy_config_get_avpf_rr_interval(const LinphoneProxyConfig *cfg); + +/** + * Get enablement status of RTCP feedback (also known as AVPF profile). + * @param[in] cfg #LinphoneProxyConfig object. + * @return the enablement mode, which can be LinphoneAVPFDefault (use LinphoneCore's mode), LinphoneAVPFEnabled (avpf is enabled), or LinphoneAVPFDisabled (disabled). +**/ +LINPHONE_PUBLIC LinphoneAVPFMode linphone_proxy_config_get_avpf_mode(const LinphoneProxyConfig *cfg); + +/** + * Enable the use of RTCP feedback (also known as AVPF profile). + * @param[in] cfg #LinphoneProxyConfig object. + * @param[in] mode the enablement mode, which can be LinphoneAVPFDefault (use LinphoneCore's mode), LinphoneAVPFEnabled (avpf is enabled), or LinphoneAVPFDisabled (disabled). +**/ +LINPHONE_PUBLIC void linphone_proxy_config_set_avpf_mode(LinphoneProxyConfig *cfg, LinphoneAVPFMode mode); + +/** + * Obtain the value of a header sent by the server in last answer to REGISTER. + * @param[in] cfg #LinphoneProxyConfig object. + * @param header_name the header name for which to fetch corresponding value + * @return the value of the queried header. +**/ +LINPHONE_PUBLIC const char *linphone_proxy_config_get_custom_header(LinphoneProxyConfig *cfg, const char *header_name); + +/** + * Set the value of a custom header sent to the server in REGISTERs request. + * @param[in] cfg #LinphoneProxyConfig object. + * @param header_name the header name + * @param header_value the header's value +**/ +LINPHONE_PUBLIC void linphone_proxy_config_set_custom_header(LinphoneProxyConfig *cfg, const char *header_name, const char *header_value); + +#endif diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 94ebefcaf..c13a5b396 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -584,7 +584,6 @@ void linphone_call_make_local_media_description_with_params(LinphoneCore *lc, Li SalMediaDescription *old_md=call->localdesc; int i; int nb_active_streams = 0; - const char *me; SalMediaDescription *md=sal_media_description_new(); LinphoneAddress *addr; const char *subject; @@ -605,11 +604,11 @@ void linphone_call_make_local_media_description_with_params(LinphoneCore *lc, Li linphone_core_adapt_to_network(lc,call->ping_time,params); - if (call->dest_proxy) - me=linphone_proxy_config_get_identity(call->dest_proxy); - else - me=linphone_core_get_identity(lc); - addr=linphone_address_new(me); + if (call->dest_proxy) { + addr=linphone_address_clone(linphone_proxy_config_get_identity_address(call->dest_proxy)); + } else { + addr=linphone_address_new(linphone_core_get_identity(lc)); + } md->session_id=(old_md ? old_md->session_id : (rand() & 0xfff)); md->session_ver=(old_md ? (old_md->session_ver+1) : (rand() & 0xfff)); diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 1e9124534..25bc56821 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -867,346 +867,8 @@ typedef enum _LinphoneRegistrationState{ * @param cs sate */ LINPHONE_PUBLIC const char *linphone_registration_state_to_string(LinphoneRegistrationState cs); -LINPHONE_PUBLIC LinphoneProxyConfig *linphone_proxy_config_new(void); -/** - * Acquire a reference to the proxy config. - * @param[in] cfg The proxy config. - * @return The same proxy config. -**/ -LINPHONE_PUBLIC LinphoneProxyConfig *linphone_proxy_config_ref(LinphoneProxyConfig *cfg); - -/** - * Release reference to the proxy config. - * @param[in] cfg The proxy config. -**/ -LINPHONE_PUBLIC void linphone_proxy_config_unref(LinphoneProxyConfig *cfg); - -/** - * Retrieve the user pointer associated with the proxy config. - * @param[in] cfg The proxy config. - * @return The user pointer associated with the proxy config. -**/ -LINPHONE_PUBLIC void *linphone_proxy_config_get_user_data(const LinphoneProxyConfig *cfg); - -/** - * Assign a user pointer to the proxy config. - * @param[in] cfg The proxy config. - * @param[in] ud The user pointer to associate with the proxy config. -**/ -LINPHONE_PUBLIC void linphone_proxy_config_set_user_data(LinphoneProxyConfig *cfg, void *ud); - -LINPHONE_PUBLIC int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *obj, const char *server_addr); -LINPHONE_PUBLIC int linphone_proxy_config_set_identity(LinphoneProxyConfig *obj, const char *identity); -LINPHONE_PUBLIC int linphone_proxy_config_set_route(LinphoneProxyConfig *obj, const char *route); - -/** - * Sets the registration expiration time in seconds. -**/ -LINPHONE_PUBLIC void linphone_proxy_config_set_expires(LinphoneProxyConfig *obj, int expires); - -#define linphone_proxy_config_expires linphone_proxy_config_set_expires -/** - * Indicates either or not, REGISTRATION must be issued for this #LinphoneProxyConfig . - *
In case this #LinphoneProxyConfig has been added to #LinphoneCore, follows the linphone_proxy_config_edit() rule. - * @param obj object pointer - * @param val if true, registration will be engaged - */ -LINPHONE_PUBLIC void linphone_proxy_config_enable_register(LinphoneProxyConfig *obj, bool_t val); -#define linphone_proxy_config_enableregister linphone_proxy_config_enable_register -LINPHONE_PUBLIC void linphone_proxy_config_edit(LinphoneProxyConfig *obj); -LINPHONE_PUBLIC int linphone_proxy_config_done(LinphoneProxyConfig *obj); -/** - * Indicates either or not, PUBLISH must be issued for this #LinphoneProxyConfig . - *
In case this #LinphoneProxyConfig has been added to #LinphoneCore, follows the linphone_proxy_config_edit() rule. - * @param obj object pointer - * @param val if true, publish will be engaged - * - */ -LINPHONE_PUBLIC void linphone_proxy_config_enable_publish(LinphoneProxyConfig *obj, bool_t val); -/** - * Set the publish expiration time in second. - * @param obj proxy config - * @param expires in second - * */ - -LINPHONE_PUBLIC void linphone_proxy_config_set_publish_expires(LinphoneProxyConfig *obj, int expires); -/** - * get the publish expiration time in second. Default value is the registration expiration value. - * @param obj proxy config - * @return expires in second - * */ - -LINPHONE_PUBLIC int linphone_proxy_config_get_publish_expires(const LinphoneProxyConfig *obj); - -LINPHONE_PUBLIC void linphone_proxy_config_set_dial_escape_plus(LinphoneProxyConfig *cfg, bool_t val); -LINPHONE_PUBLIC void linphone_proxy_config_set_dial_prefix(LinphoneProxyConfig *cfg, const char *prefix); - - /** - * Indicates whether quality statistics during call should be stored and sent to a collector according to RFC 6035. - * @param[in] cfg #LinphoneProxyConfig object - * @param[in] enable True to sotre quality statistics and sent them to the collector, false to disable it. - */ -LINPHONE_PUBLIC void linphone_proxy_config_enable_quality_reporting(LinphoneProxyConfig *cfg, bool_t enable); - -/** - * Indicates whether quality statistics during call should be stored and sent to a collector according to RFC 6035. - * @param[in] cfg #LinphoneProxyConfig object - * @return True if quality repotring is enabled, false otherwise. - */ -LINPHONE_PUBLIC bool_t linphone_proxy_config_quality_reporting_enabled(LinphoneProxyConfig *cfg); - - /** - * Set the route of the collector end-point when using quality reporting. This SIP address - * should be used on server-side to process packets directly before discarding packets. Collector address - * should be a non existing account and will not receive any messages. - * If NULL, reports will be send to the proxy domain. - * @param[in] cfg #LinphoneProxyConfig object - * @param[in] collector route of the collector end-point, if NULL PUBLISH will be sent to the proxy domain. - */ -LINPHONE_PUBLIC void linphone_proxy_config_set_quality_reporting_collector(LinphoneProxyConfig *cfg, const char *collector); - - /** - * Get the route of the collector end-point when using quality reporting. This SIP address - * should be used on server-side to process packets directly before discarding packets. Collector address - * should be a non existing account and will not receive any messages. - * If NULL, reports will be send to the proxy domain. - * @param[in] cfg #LinphoneProxyConfig object - * @return The SIP address of the collector end-point. - */ -LINPHONE_PUBLIC const char *linphone_proxy_config_get_quality_reporting_collector(const LinphoneProxyConfig *cfg); - -/** - * Set the interval between 2 interval reports sending when using quality reporting. If call exceed interval size, an - * interval report will be sent to the collector. On call termination, a session report will be sent - * for the remaining period. Value must be 0 (disabled) or positive. - * @param[in] cfg #LinphoneProxyConfig object - * @param[in] interval The interval in seconds, 0 means interval reports are disabled. - */ -LINPHONE_PUBLIC void linphone_proxy_config_set_quality_reporting_interval(LinphoneProxyConfig *cfg, uint8_t interval); - -/** - * Get the interval between interval reports when using quality reporting. - * @param[in] cfg #LinphoneProxyConfig object - * @return The interval in seconds, 0 means interval reports are disabled. - */ - -LINPHONE_PUBLIC int linphone_proxy_config_get_quality_reporting_interval(LinphoneProxyConfig *cfg); - -/** - * Get the registration state of the given proxy config. - * @param[in] obj #LinphoneProxyConfig object. - * @return The registration state of the proxy config. -**/ -LINPHONE_PUBLIC LinphoneRegistrationState linphone_proxy_config_get_state(const LinphoneProxyConfig *obj); - -LINPHONE_PUBLIC bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj); - -/** - * Get the domain name of the given proxy config. - * @param[in] cfg #LinphoneProxyConfig object. - * @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. - * @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. - * @return The realm of the proxy config. -**/ -LINPHONE_PUBLIC void linphone_proxy_config_set_realm(LinphoneProxyConfig *cfg, const char * realm); - -LINPHONE_PUBLIC const char *linphone_proxy_config_get_route(const LinphoneProxyConfig *obj); -LINPHONE_PUBLIC const char *linphone_proxy_config_get_identity(const LinphoneProxyConfig *obj); -LINPHONE_PUBLIC bool_t linphone_proxy_config_publish_enabled(const LinphoneProxyConfig *obj); -LINPHONE_PUBLIC const char *linphone_proxy_config_get_server_addr(const LinphoneProxyConfig *obj); -#define linphone_proxy_config_get_addr linphone_proxy_config_get_server_addr -LINPHONE_PUBLIC int linphone_proxy_config_get_expires(const LinphoneProxyConfig *obj); -LINPHONE_PUBLIC bool_t linphone_proxy_config_register_enabled(const LinphoneProxyConfig *obj); -LINPHONE_PUBLIC void linphone_proxy_config_refresh_register(LinphoneProxyConfig *obj); -LINPHONE_PUBLIC void linphone_proxy_config_pause_register(LinphoneProxyConfig *obj); -LINPHONE_PUBLIC const char *linphone_proxy_config_get_contact_parameters(const LinphoneProxyConfig *obj); -LINPHONE_PUBLIC void linphone_proxy_config_set_contact_parameters(LinphoneProxyConfig *obj, const char *contact_params); -LINPHONE_PUBLIC void linphone_proxy_config_set_contact_uri_parameters(LinphoneProxyConfig *obj, const char *contact_uri_params); -LINPHONE_PUBLIC const char* linphone_proxy_config_get_contact_uri_parameters(const LinphoneProxyConfig *obj); - -/** - * Get the #LinphoneCore object to which is associated the #LinphoneProxyConfig. - * @param[in] obj #LinphoneProxyConfig object. - * @return The #LinphoneCore object to which is associated the #LinphoneProxyConfig. -**/ -LINPHONE_PUBLIC LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *obj); - -LINPHONE_PUBLIC bool_t linphone_proxy_config_get_dial_escape_plus(const LinphoneProxyConfig *cfg); -LINPHONE_PUBLIC const char * linphone_proxy_config_get_dial_prefix(const LinphoneProxyConfig *cfg); - -/** - * Get the reason why registration failed when the proxy config state is LinphoneRegistrationFailed. - * @param[in] cfg #LinphoneProxyConfig object. - * @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. - * @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. - * @return The transport as a string (I.E udp, tcp, tls, dtls) -**/ -LINPHONE_PUBLIC const char* linphone_proxy_config_get_transport(const LinphoneProxyConfig *cfg); - - -/* destruction is called automatically when removing the proxy config */ -LINPHONE_PUBLIC void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg); -LINPHONE_PUBLIC void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type); -LINPHONE_PUBLIC SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig *cfg); -LINPHONE_PUBLIC SipSetup *linphone_proxy_config_get_sip_setup(LinphoneProxyConfig *cfg); - -/** - * Detect if the given input is a phone number or not. - * @param proxy #LinphoneProxyConfig argument, unused yet but may contain useful data. Can be NULL. - * @param username string to parse. - * @return TRUE if input is a phone number, FALSE otherwise. -**/ -LINPHONE_PUBLIC bool_t linphone_proxy_config_is_phone_number(LinphoneProxyConfig *proxy, const char *username); - -/** - * Normalize a human readable phone number into a basic string. 888-444-222 becomes 888444222 - * 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 - * @return TRUE if a phone number was recognized, FALSE otherwise. - */ -LINPHONE_PUBLIC bool_t linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const char *username, - char *result, size_t result_len); - -/** - * Same objective as linphone_proxy_config_normalize_number but allocates a new string - * @param proxy #LinphoneProxyConfig object containing country code and/or escape symbol. If NULL passed, will use default configuration. - * @param username the string to parse - * @return NULL if invalid phone number, normalized phone number from username input otherwise. -*/ -LINPHONE_PUBLIC char* linphone_proxy_config_normalize_phone_number(LinphoneProxyConfig *proxy, const char *username); - -/** - * Normalize a human readable sip uri into a fully qualified LinphoneAddress. - * A sip address should look like DisplayName \ . - * Basically this function performs the following tasks - * - if a phone number is entered, prepend country prefix and eventually escape the '+' by 00 of the proxy config. - * - if no domain part is supplied, append the domain name of the proxy config. Returns NULL if no proxy is provided at this point. - * - if no sip: is present, prepend it. - * - * The result is a syntactically correct SIP address. - * @param proxy #LinphoneProxyConfig object containing country code, escape symbol and/or domain name. Can be NULL if domain is already provided. - * @param username the string to parse - * @return NULL if invalid input, normalized sip address otherwise. -*/ -LINPHONE_PUBLIC LinphoneAddress* linphone_proxy_config_normalize_sip_uri(LinphoneProxyConfig *proxy, const char *username); - -/** - * Set default privacy policy for all calls routed through this proxy. - * @param cfg #LinphoneProxyConfig object to be modified - * @param privacy LinphonePrivacy to configure privacy - * */ -LINPHONE_PUBLIC void linphone_proxy_config_set_privacy(LinphoneProxyConfig *cfg, LinphonePrivacyMask privacy); -/** - * Get default privacy policy for all calls routed through this proxy. - * @param cfg #LinphoneProxyConfig object - * @return Privacy mode - * */ -LINPHONE_PUBLIC LinphonePrivacyMask linphone_proxy_config_get_privacy(const LinphoneProxyConfig *cfg); -/** - * Set the http file transfer server to be used for content type application/vnd.gsma.rcs-ft-http+xml - * @param cfg #LinphoneProxyConfig object to be modified - * @param server_url URL of the file server like https://file.linphone.org/upload.php - * */ -LINPHONE_PUBLIC void linphone_proxy_config_set_file_transfer_server(LinphoneProxyConfig *cfg, const char * server_url); -/** - * Get the http file transfer server to be used for content type application/vnd.gsma.rcs-ft-http+xml - * @param cfg #LinphoneProxyConfig object - * @return URL of the file server like https://file.linphone.org/upload.php - * */ -LINPHONE_PUBLIC const char* linphone_proxy_config_get_file_transfer_server(const LinphoneProxyConfig *cfg); - -/** - * Indicates whether AVPF/SAVPF must be used for calls using this proxy config. - * @param[in] cfg #LinphoneProxyConfig object - * @param[in] enable True to enable AVPF/SAVF, false to disable it. - * @deprecated use linphone_proxy_config_set_avpf_mode() - */ -LINPHONE_PUBLIC void linphone_proxy_config_enable_avpf(LinphoneProxyConfig *cfg, bool_t enable); - -/** - * Indicates whether AVPF/SAVPF is being used for calls using this proxy config. - * @param[in] cfg #LinphoneProxyConfig object - * @return True if AVPF/SAVPF is enabled, false otherwise. - * @deprecated use linphone_proxy_config_set_avpf_mode() - */ -LINPHONE_PUBLIC bool_t linphone_proxy_config_avpf_enabled(LinphoneProxyConfig *cfg); - -/** - * Set the interval between regular RTCP reports when using AVPF/SAVPF. - * @param[in] cfg #LinphoneProxyConfig object - * @param[in] interval The interval in seconds (between 0 and 5 seconds). - */ -LINPHONE_PUBLIC void linphone_proxy_config_set_avpf_rr_interval(LinphoneProxyConfig *cfg, uint8_t interval); - -/** - * Get the interval between regular RTCP reports when using AVPF/SAVPF. - * @param[in] cfg #LinphoneProxyConfig object - * @return The interval in seconds. - */ -LINPHONE_PUBLIC uint8_t linphone_proxy_config_get_avpf_rr_interval(const LinphoneProxyConfig *cfg); - -/** - * Get enablement status of RTCP feedback (also known as AVPF profile). - * @param[in] cfg the proxy config - * @return the enablement mode, which can be LinphoneAVPFDefault (use LinphoneCore's mode), LinphoneAVPFEnabled (avpf is enabled), or LinphoneAVPFDisabled (disabled). -**/ -LINPHONE_PUBLIC LinphoneAVPFMode linphone_proxy_config_get_avpf_mode(const LinphoneProxyConfig *cfg); - -/** - * Enable the use of RTCP feedback (also known as AVPF profile). - * @param[in] cfg the proxy config - * @param[in] mode the enablement mode, which can be LinphoneAVPFDefault (use LinphoneCore's mode), LinphoneAVPFEnabled (avpf is enabled), or LinphoneAVPFDisabled (disabled). -**/ -LINPHONE_PUBLIC void linphone_proxy_config_set_avpf_mode(LinphoneProxyConfig *cfg, LinphoneAVPFMode mode); - -/** - * Obtain the value of a header sent by the server in last answer to REGISTER. - * @param cfg the proxy config object - * @param header_name the header name for which to fetch corresponding value - * @return the value of the queried header. -**/ -LINPHONE_PUBLIC const char *linphone_proxy_config_get_custom_header(LinphoneProxyConfig *cfg, const char *header_name); - -/** - * Set the value of a custom header sent to the server in REGISTERs request. - * @param cfg the proxy config object - * @param header_name the header name - * @param header_value the header's value -**/ -LINPHONE_PUBLIC void linphone_proxy_config_set_custom_header(LinphoneProxyConfig *cfg, const char *header_name, const char *header_value); -/** - * @} -**/ +#include "linphone_proxy_config.h" struct _LinphoneAuthInfo; @@ -2946,6 +2608,10 @@ LINPHONE_PUBLIC bool_t linphone_core_check_payload_type_usability(LinphoneCore * */ LINPHONE_PUBLIC LinphoneProxyConfig * linphone_core_create_proxy_config(LinphoneCore *lc); +/** + * Add a proxy configuration. + * This will start registration on the proxy, if registration is enabled. +**/ LINPHONE_PUBLIC int linphone_core_add_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config); /** @@ -2955,6 +2621,12 @@ LINPHONE_PUBLIC int linphone_core_add_proxy_config(LinphoneCore *lc, LinphonePro **/ LINPHONE_PUBLIC void linphone_core_clear_proxy_config(LinphoneCore *lc); +/** + * Removes a proxy configuration. + * + * LinphoneCore will then automatically unregister and place the proxy configuration + * on a deleted list. For that reason, a removed proxy does NOT need to be freed. +**/ LINPHONE_PUBLIC void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config); /** @@ -2969,10 +2641,28 @@ LINPHONE_PUBLIC const MSList *linphone_core_get_proxy_config_list(const Linphone LINPHONE_PUBLIC void linphone_core_set_default_proxy_index(LinphoneCore *lc, int index); +/** + * @return the default proxy configuration, that is the one used to determine the current identity. + * @deprecated Use linphone_core_get_default_proxy_config() instead. +**/ LINPHONE_PUBLIC int linphone_core_get_default_proxy(LinphoneCore *lc, LinphoneProxyConfig **config); +/** + * @return the default proxy configuration, that is the one used to determine the current identity. + * @param[in] lc LinphoneCore object + * @return The default proxy configuration. +**/ LINPHONE_PUBLIC LinphoneProxyConfig * linphone_core_get_default_proxy_config(LinphoneCore *lc); +/** + * Sets the default proxy. + * + * This default proxy must be part of the list of already entered LinphoneProxyConfig. + * Toggling it as default will make LinphoneCore use the identity associated with + * the proxy configuration in all incoming and outgoing calls. + * @param[in] lc LinphoneCore object + * @param[in] config The proxy configuration to use as the default one. +**/ LINPHONE_PUBLIC void linphone_core_set_default_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config); /** diff --git a/coreapi/plugins/buddylookup/src/lookup.c b/coreapi/plugins/buddylookup/src/lookup.c index 48a8d3bb2..736e7aa35 100644 --- a/coreapi/plugins/buddylookup/src/lookup.c +++ b/coreapi/plugins/buddylookup/src/lookup.c @@ -81,7 +81,7 @@ static void fill_buddy_info(BLReq *blreq, BuddyInfo *bi, GHashTable *ht){ }else{ strncpy(bi->sip_uri,tmp,sizeof(bi->sip_uri)-1); } - + fill_item(ht,"street",bi->address.street,sizeof(bi->address.street)); fill_item(ht,"zip",bi->address.zip,sizeof(bi->address.zip)); fill_item(ht,"city",bi->address.town,sizeof(bi->address.town)); @@ -105,7 +105,7 @@ static void fill_buddy_info(BLReq *blreq, BuddyInfo *bi, GHashTable *ht){ ms_error("Fail to fetch the image %i",status); } } - + } static MSList * make_buddy_list(BLReq *blreq, GValue *retval){ @@ -156,7 +156,7 @@ static int xml_rpc_parse_response(BLReq *blreq, SoupMessage *sm){ #if SERIALIZE_HTTPS /*on windows libsoup support for threads with gnutls is not yet functionnal (only in git) -This will come in next release of libsoup, probably. +This will come in next release of libsoup, probably. In the meantime, we are forced to serialize all soup https processing with a big ugly global mutex...*/ @@ -191,27 +191,26 @@ static int lookup_buddy(SipSetupContext *ctx, BLReq *req){ LinphoneProxyConfig *cfg=sip_setup_context_get_proxy_config(ctx); LinphoneCore *lc=linphone_proxy_config_get_core(cfg); LpConfig *config=linphone_core_get_config(lc); - const char *identity=linphone_proxy_config_get_identity(cfg); + LinphoneAddress *from=linphone_proxy_config_get_identity_address(cfg); const char *url=lp_config_get_string(config,"BuddyLookup","url",NULL); - const LinphoneAuthInfo *aa; + const LinphoneAuthInfo *auth_info; SoupMessage *sm; - LinphoneAddress *from; - + char *identity; + if (url==NULL){ ms_error("No url defined for BuddyLookup in config file, aborting search."); return -1; } - - from=linphone_address_new(identity); - if (from==NULL){ - ms_error("Could not parse identity %s",identity); - return -1; + auth_info=linphone_core_find_auth_info(lc,linphone_address_get_domain(from),linphone_address_get_username(from)); + if (auth_info) { + ms_message("There is a password: %s",auth_info->passwd); + } else { + ms_message("No password for %s on %s",linphone_address_get_username(from),linphone_address_get_domain(from)); } - aa=linphone_core_find_auth_info(lc,linphone_address_get_domain(from),linphone_address_get_username(from)); - if (aa) ms_message("There is a password: %s",aa->passwd); - else ms_message("No password for %s on %s",linphone_address_get_username(from),linphone_address_get_domain(from)); - sm=build_xmlrpc_request(identity, aa ? aa->passwd : NULL, req->base.key, linphone_address_get_domain(from), url, req->base.max_results); - linphone_address_destroy(from); + + identity=linphone_proxy_config_get_identity(cfg); + sm=build_xmlrpc_request(identity, auth_info ? auth_info->passwd : NULL, req->base.key, linphone_address_get_domain(from), url, req->base.max_results); + ms_free(identity); req->msg=sm; ortp_thread_create(&req->th,NULL,process_xml_rpc_request,req); if (!sm) return -1; diff --git a/coreapi/private.h b/coreapi/private.h index b48111c67..c4470258a 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -340,7 +340,7 @@ void _linphone_proxy_config_release(LinphoneProxyConfig *cfg); * Can be NULL * */ const LinphoneAddress* linphone_proxy_config_get_service_route(const LinphoneProxyConfig* cfg); -LINPHONE_PUBLIC char* linphone_proxy_config_get_contact(const LinphoneProxyConfig *cfg); +const LinphoneAddress* linphone_proxy_config_get_contact(const LinphoneProxyConfig *cfg); void linphone_friend_close_subscriptions(LinphoneFriend *lf); void linphone_friend_update_subscribes(LinphoneFriend *fr, LinphoneProxyConfig *cfg, bool_t only_when_registered); @@ -478,6 +478,9 @@ typedef enum _LinphoneProxyConfigAddressComparisonResult{ LINPHONE_PUBLIC LinphoneProxyConfigAddressComparisonResult linphone_proxy_config_address_equal(const LinphoneAddress *a, const LinphoneAddress *b); LINPHONE_PUBLIC LinphoneProxyConfigAddressComparisonResult linphone_proxy_config_is_server_config_changed(const LinphoneProxyConfig* obj); +/** + * unregister without moving the register_enable flag + */ void _linphone_proxy_config_unregister(LinphoneProxyConfig *obj); void _linphone_proxy_config_release_ops(LinphoneProxyConfig *obj); @@ -494,9 +497,9 @@ struct _LinphoneProxyConfig struct _LinphoneCore *lc; char *reg_proxy; char *reg_identity; + LinphoneAddress* identity_address; char *reg_route; char *quality_reporting_collector; - char *domain; char *realm; char *contact_params; char *contact_uri_params; diff --git a/coreapi/proxy.c b/coreapi/proxy.c index ecbeb1533..d7e116c27 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -28,18 +28,18 @@ Copyright (C) 2000 Simon MORLAT (simon.morlat@linphone.org) #include /*store current config related to server location*/ -static void linphone_proxy_config_store_server_config(LinphoneProxyConfig* obj) { - if (obj->saved_identity) linphone_address_destroy(obj->saved_identity); - if (obj->reg_identity) - obj->saved_identity = linphone_address_new(obj->reg_identity); +static void linphone_proxy_config_store_server_config(LinphoneProxyConfig* cfg) { + if (cfg->saved_identity) linphone_address_destroy(cfg->saved_identity); + if (cfg->identity_address) + cfg->saved_identity = linphone_address_clone(cfg->identity_address); else - obj->saved_identity = NULL; + cfg->saved_identity = NULL; - if (obj->saved_proxy) linphone_address_destroy(obj->saved_proxy); - if (obj->reg_proxy) - obj->saved_proxy = linphone_address_new(obj->reg_proxy); + if (cfg->saved_proxy) linphone_address_destroy(cfg->saved_proxy); + if (cfg->reg_proxy) + cfg->saved_proxy = linphone_address_new(cfg->reg_proxy); else - obj->saved_proxy = NULL; + cfg->saved_proxy = NULL; } LinphoneProxyConfigAddressComparisonResult linphone_proxy_config_address_equal(const LinphoneAddress *a, const LinphoneAddress *b) { @@ -60,17 +60,16 @@ LinphoneProxyConfigAddressComparisonResult linphone_proxy_config_address_equal(c return LinphoneProxyConfigAddressDifferent; /*either username, domain or port ar not equals*/ } -LinphoneProxyConfigAddressComparisonResult linphone_proxy_config_is_server_config_changed(const LinphoneProxyConfig* obj) { - LinphoneAddress *current_identity=obj->reg_identity?linphone_address_new(obj->reg_identity):NULL; - LinphoneAddress *current_proxy=obj->reg_proxy?linphone_address_new(obj->reg_proxy):NULL; +LinphoneProxyConfigAddressComparisonResult linphone_proxy_config_is_server_config_changed(const LinphoneProxyConfig* cfg) { + LinphoneAddress *current_proxy=cfg->reg_proxy?linphone_address_new(cfg->reg_proxy):NULL; LinphoneProxyConfigAddressComparisonResult result_identity; LinphoneProxyConfigAddressComparisonResult result; - result = linphone_proxy_config_address_equal(obj->saved_identity,current_identity); + result = linphone_proxy_config_address_equal(cfg->saved_identity,cfg->identity_address); if (result == LinphoneProxyConfigAddressDifferent) goto end; result_identity = result; - result = linphone_proxy_config_address_equal(obj->saved_proxy,current_proxy); + result = linphone_proxy_config_address_equal(cfg->saved_proxy,current_proxy); if (result == LinphoneProxyConfigAddressDifferent) goto end; /** If the proxies are equal use the result of the difference between the identities, * otherwise the result is weak-equal and so weak-equal must be returned even if the @@ -79,7 +78,6 @@ LinphoneProxyConfigAddressComparisonResult linphone_proxy_config_is_server_confi if (result == LinphoneProxyConfigAddressEqual) result = result_identity; end: - if (current_identity) linphone_address_destroy(current_identity); if (current_proxy) linphone_address_destroy(current_proxy); return result; } @@ -98,7 +96,7 @@ void linphone_proxy_config_write_all_to_config_file(LinphoneCore *lc){ lp_config_set_int(lc->config,"sip","default_proxy",linphone_core_get_default_proxy(lc,NULL)); } -static void linphone_proxy_config_init(LinphoneCore* lc, LinphoneProxyConfig *obj) { +static void linphone_proxy_config_init(LinphoneCore* lc, LinphoneProxyConfig *cfg) { const char *dial_prefix = lc ? lp_config_get_default_string(lc->config,"proxy","dial_prefix",NULL) : NULL; const char *identity = lc ? lp_config_get_default_string(lc->config, "proxy", "reg_identity", NULL) : NULL; const char *proxy = lc ? lp_config_get_default_string(lc->config, "proxy", "reg_proxy", NULL) : NULL; @@ -108,40 +106,31 @@ static void linphone_proxy_config_init(LinphoneCore* lc, LinphoneProxyConfig *ob const char *contact_params = lc ? lp_config_get_default_string(lc->config, "proxy", "contact_parameters", NULL) : NULL; const char *contact_uri_params = lc ? lp_config_get_default_string(lc->config, "proxy", "contact_uri_parameters", NULL) : NULL; - obj->expires = lc ? lp_config_get_default_int(lc->config, "proxy", "reg_expires", 3600) : 3600; - obj->reg_sendregister = lc ? lp_config_get_default_int(lc->config, "proxy", "reg_sendregister", 1) : 1; - obj->dial_prefix = dial_prefix ? ms_strdup(dial_prefix) : NULL; - obj->dial_escape_plus = lc ? lp_config_get_default_int(lc->config, "proxy", "dial_escape_plus", 0) : 0; - obj->privacy = lc ? lp_config_get_default_int(lc->config, "proxy", "privacy", LinphonePrivacyDefault) : LinphonePrivacyDefault; - obj->reg_identity = identity ? ms_strdup(identity) : NULL; - obj->reg_proxy = proxy ? ms_strdup(proxy) : NULL; - obj->reg_route = route ? ms_strdup(route) : NULL; - obj->domain = NULL; - obj->realm = realm ? ms_strdup(realm) : NULL; - obj->quality_reporting_enabled = lc ? lp_config_get_default_int(lc->config, "proxy", "quality_reporting_enabled", 0) : 0; - obj->quality_reporting_collector = quality_reporting_collector ? ms_strdup(quality_reporting_collector) : NULL; - obj->quality_reporting_interval = lc ? lp_config_get_default_int(lc->config, "proxy", "quality_reporting_interval", 0) : 0; - obj->contact_params = contact_params ? ms_strdup(contact_params) : NULL; - obj->contact_uri_params = contact_uri_params ? ms_strdup(contact_uri_params) : NULL; - obj->avpf_mode = lc ? lp_config_get_default_int(lc->config, "proxy", "avpf", LinphoneAVPFDefault) : LinphoneAVPFDefault; - obj->avpf_rr_interval = lc ? lp_config_get_default_int(lc->config, "proxy", "avpf_rr_interval", 5) : 5; - obj->publish_expires=-1; + cfg->expires = lc ? lp_config_get_default_int(lc->config, "proxy", "reg_expires", 3600) : 3600; + cfg->reg_sendregister = lc ? lp_config_get_default_int(lc->config, "proxy", "reg_sendregister", 1) : 1; + cfg->dial_prefix = dial_prefix ? ms_strdup(dial_prefix) : NULL; + cfg->dial_escape_plus = lc ? lp_config_get_default_int(lc->config, "proxy", "dial_escape_plus", 0) : 0; + cfg->privacy = lc ? lp_config_get_default_int(lc->config, "proxy", "privacy", LinphonePrivacyDefault) : LinphonePrivacyDefault; + cfg->identity_address = identity ? linphone_address_new(identity) : NULL; + cfg->reg_identity = cfg->identity_address ? linphone_address_as_string(cfg->identity_address) : NULL; + cfg->reg_proxy = proxy ? ms_strdup(proxy) : NULL; + cfg->reg_route = route ? ms_strdup(route) : NULL; + cfg->realm = realm ? ms_strdup(realm) : NULL; + cfg->quality_reporting_enabled = lc ? lp_config_get_default_int(lc->config, "proxy", "quality_reporting_enabled", 0) : 0; + cfg->quality_reporting_collector = quality_reporting_collector ? ms_strdup(quality_reporting_collector) : NULL; + cfg->quality_reporting_interval = lc ? lp_config_get_default_int(lc->config, "proxy", "quality_reporting_interval", 0) : 0; + cfg->contact_params = contact_params ? ms_strdup(contact_params) : NULL; + cfg->contact_uri_params = contact_uri_params ? ms_strdup(contact_uri_params) : NULL; + cfg->avpf_mode = lc ? lp_config_get_default_int(lc->config, "proxy", "avpf", LinphoneAVPFDefault) : LinphoneAVPFDefault; + cfg->avpf_rr_interval = lc ? lp_config_get_default_int(lc->config, "proxy", "avpf_rr_interval", 5) : 5; + cfg->publish_expires=-1; } -/** - * @addtogroup proxies - * @{ -**/ - -/** - * @deprecated, use #linphone_core_create_proxy_config instead - *Creates an empty proxy config. -**/ LinphoneProxyConfig *linphone_proxy_config_new() { return linphone_core_create_proxy_config(NULL); } -static void _linphone_proxy_config_destroy(LinphoneProxyConfig *obj); +static void _linphone_proxy_config_destroy(LinphoneProxyConfig *cfg); BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneProxyConfig); @@ -153,47 +142,40 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneProxyConfig, belle_sip_object_t, ); LinphoneProxyConfig * linphone_core_create_proxy_config(LinphoneCore *lc) { - LinphoneProxyConfig *obj = belle_sip_object_new(LinphoneProxyConfig); - linphone_proxy_config_init(lc,obj); - return obj; + LinphoneProxyConfig *cfg = belle_sip_object_new(LinphoneProxyConfig); + linphone_proxy_config_init(lc,cfg); + return cfg; } -void _linphone_proxy_config_release_ops(LinphoneProxyConfig *obj){ - if (obj->op) { - sal_op_release(obj->op); - obj->op=NULL; +void _linphone_proxy_config_release_ops(LinphoneProxyConfig *cfg){ + if (cfg->op) { + sal_op_release(cfg->op); + cfg->op=NULL; } - if (obj->publish_op){ - sal_op_release(obj->publish_op); - obj->publish_op=NULL; + if (cfg->publish_op){ + sal_op_release(cfg->publish_op); + cfg->publish_op=NULL; } } -void _linphone_proxy_config_destroy(LinphoneProxyConfig *obj){ - if (obj->reg_proxy!=NULL) ms_free(obj->reg_proxy); - if (obj->reg_identity!=NULL) ms_free(obj->reg_identity); - if (obj->reg_route!=NULL) ms_free(obj->reg_route); - if (obj->quality_reporting_collector!=NULL) ms_free(obj->quality_reporting_collector); - if (obj->ssctx!=NULL) sip_setup_context_free(obj->ssctx); - if (obj->domain!=NULL) ms_free(obj->domain); - if (obj->realm!=NULL) ms_free(obj->realm); - if (obj->type!=NULL) ms_free(obj->type); - if (obj->dial_prefix!=NULL) ms_free(obj->dial_prefix); - if (obj->contact_params) ms_free(obj->contact_params); - if (obj->contact_uri_params) ms_free(obj->contact_uri_params); - if (obj->saved_proxy!=NULL) linphone_address_destroy(obj->saved_proxy); - if (obj->saved_identity!=NULL) linphone_address_destroy(obj->saved_identity); - if (obj->sent_headers!=NULL) sal_custom_header_free(obj->sent_headers); - _linphone_proxy_config_release_ops(obj); +void _linphone_proxy_config_destroy(LinphoneProxyConfig *cfg){ + if (cfg->reg_proxy!=NULL) ms_free(cfg->reg_proxy); + if (cfg->reg_identity!=NULL) ms_free(cfg->reg_identity); + if (cfg->identity_address!=NULL) linphone_address_destroy(cfg->identity_address); + if (cfg->reg_route!=NULL) ms_free(cfg->reg_route); + if (cfg->quality_reporting_collector!=NULL) ms_free(cfg->quality_reporting_collector); + if (cfg->ssctx!=NULL) sip_setup_context_free(cfg->ssctx); + if (cfg->realm!=NULL) ms_free(cfg->realm); + if (cfg->type!=NULL) ms_free(cfg->type); + if (cfg->dial_prefix!=NULL) ms_free(cfg->dial_prefix); + if (cfg->contact_params) ms_free(cfg->contact_params); + if (cfg->contact_uri_params) ms_free(cfg->contact_uri_params); + if (cfg->saved_proxy!=NULL) linphone_address_destroy(cfg->saved_proxy); + if (cfg->saved_identity!=NULL) linphone_address_destroy(cfg->saved_identity); + if (cfg->sent_headers!=NULL) sal_custom_header_free(cfg->sent_headers); + _linphone_proxy_config_release_ops(cfg); } -/** - * Destroys a proxy config. - * @deprecated - * - * @note: LinphoneProxyConfig that have been removed from LinphoneCore with - * linphone_core_remove_proxy_config() must not be freed. -**/ void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg) { belle_sip_object_unref(cfg); } @@ -212,28 +194,16 @@ void linphone_proxy_config_unref(LinphoneProxyConfig *cfg) { belle_sip_object_unref(cfg); } -/** - * Returns a boolean indicating that the user is sucessfully registered on the proxy. - * @deprecated Use linphone_proxy_config_get_state() instead. -**/ -bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj){ - return obj->state == LinphoneRegistrationOk; +bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *cfg){ + return cfg->state == LinphoneRegistrationOk; } -/** - * Sets the proxy address - * - * Examples of valid sip proxy address are: - * - IP address: sip:87.98.157.38 - * - IP address with port: sip:87.98.157.38:5062 - * - hostnames : sip:sip.example.net -**/ -int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *obj, const char *server_addr){ +int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *cfg, const char *server_addr){ LinphoneAddress *addr=NULL; char *modified=NULL; - if (obj->reg_proxy!=NULL) ms_free(obj->reg_proxy); - obj->reg_proxy=NULL; + if (cfg->reg_proxy!=NULL) ms_free(cfg->reg_proxy); + cfg->reg_proxy=NULL; if (server_addr!=NULL && strlen(server_addr)>0){ if (strstr(server_addr,"sip:")==NULL && strstr(server_addr,"sips:")==NULL){ @@ -244,7 +214,7 @@ int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *obj, const char * if (addr==NULL) addr=linphone_address_new(server_addr); if (addr){ - obj->reg_proxy=linphone_address_as_string(addr); + cfg->reg_proxy=linphone_address_as_string(addr); linphone_address_destroy(addr); }else{ ms_warning("Could not parse %s",server_addr); @@ -254,43 +224,38 @@ int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *obj, const char * return 0; } -/** - * Sets the user identity as a SIP address. - * - * This identity is normally formed with display name, username and domain, such - * as: - * Alice - * The REGISTER messages will have from and to set to this identity. - * -**/ -int linphone_proxy_config_set_identity(LinphoneProxyConfig *obj, const char *identity){ - LinphoneAddress *addr; + +int linphone_proxy_config_set_identity_address(LinphoneProxyConfig *cfg, const LinphoneAddress *addr){ + if (!addr || linphone_address_get_username(addr)==NULL){ + char* as_string = linphone_address_as_string(addr); + ms_warning("Invalid sip identity: %s", addr?as_string:"NULL"); + ms_free(as_string); + return -1; + } + if (cfg->identity_address != NULL) { + linphone_address_destroy(cfg->identity_address); + } + cfg->identity_address=linphone_address_clone(addr); + + if (cfg->reg_identity!=NULL) { + ms_free(cfg->reg_identity); + } + cfg->reg_identity= linphone_address_as_string(cfg->identity_address); + return 0; +} + +int linphone_proxy_config_set_identity(LinphoneProxyConfig *cfg, const char *identity){ if (identity!=NULL && strlen(identity)>0){ - addr=linphone_address_new(identity); - if (!addr || linphone_address_get_username(addr)==NULL){ - ms_warning("Invalid sip identity: %s",identity); - if (addr) - linphone_address_destroy(addr); - return -1; - }else{ - if (obj->reg_identity!=NULL) { - ms_free(obj->reg_identity); - obj->reg_identity=NULL; - } - obj->reg_identity=ms_strdup(identity); - if (obj->domain){ - ms_free(obj->domain); - } - obj->domain=ms_strdup(linphone_address_get_domain(addr)); - linphone_address_destroy(addr); - return 0; - } + LinphoneAddress *addr=linphone_address_new(identity); + int ret=linphone_proxy_config_set_identity_address(cfg, addr); + linphone_address_destroy(addr); + return ret; } return -1; } const char *linphone_proxy_config_get_domain(const LinphoneProxyConfig *cfg){ - return cfg->domain; + return cfg->identity_address ? linphone_address_get_domain(cfg->identity_address) : NULL; } /** @@ -298,11 +263,11 @@ const char *linphone_proxy_config_get_domain(const LinphoneProxyConfig *cfg){ * When a route is set, all outgoing calls will go to the route's destination if this proxy * is the default one (see linphone_core_set_default_proxy() ). **/ -int linphone_proxy_config_set_route(LinphoneProxyConfig *obj, const char *route) +int linphone_proxy_config_set_route(LinphoneProxyConfig *cfg, const char *route) { - if (obj->reg_route!=NULL){ - ms_free(obj->reg_route); - obj->reg_route=NULL; + if (cfg->reg_route!=NULL){ + ms_free(cfg->reg_route); + cfg->reg_route=NULL; } if (route!=NULL && route[0] !='\0'){ SalAddress *addr; @@ -318,19 +283,19 @@ int linphone_proxy_config_set_route(LinphoneProxyConfig *obj, const char *route) ms_free(tmp); tmp=NULL; } - obj->reg_route=tmp; + cfg->reg_route=tmp; } return 0; } -bool_t linphone_proxy_config_check(LinphoneCore *lc, LinphoneProxyConfig *obj){ - if (obj->reg_proxy==NULL){ +bool_t linphone_proxy_config_check(LinphoneCore *lc, LinphoneProxyConfig *cfg){ + if (cfg->reg_proxy==NULL){ if (lc) linphone_core_notify_display_warning(lc,_("The sip proxy address you entered is invalid, it must start with \"sip:\"" " followed by a hostname.")); return FALSE; } - if (obj->reg_identity==NULL){ + if (cfg->identity_address==NULL){ if (lc) linphone_core_notify_display_warning(lc,_("The sip identity you entered is invalid.\nIt should look like " "sip:username@proxydomain, such as sip:alice@example.net")); @@ -339,76 +304,56 @@ bool_t linphone_proxy_config_check(LinphoneCore *lc, LinphoneProxyConfig *obj){ return TRUE; } -/** - * Indicates whether a REGISTER request must be sent to the proxy. -**/ -void linphone_proxy_config_enableregister(LinphoneProxyConfig *obj, bool_t val){ - obj->reg_sendregister=val; +void linphone_proxy_config_enableregister(LinphoneProxyConfig *cfg, bool_t val){ + cfg->reg_sendregister=val; } -void linphone_proxy_config_set_expires(LinphoneProxyConfig *obj, int val){ +void linphone_proxy_config_set_expires(LinphoneProxyConfig *cfg, int val){ if (val<0) val=600; - obj->expires=val; + cfg->expires=val; } -void linphone_proxy_config_enable_publish(LinphoneProxyConfig *obj, bool_t val){ - obj->publish=val; +void linphone_proxy_config_enable_publish(LinphoneProxyConfig *cfg, bool_t val){ + cfg->publish=val; } -/** - * Prevent a proxy config from refreshing its registration. - * This is useful to let registrations to expire naturally (or) when the application wants to keep control on when - * refreshes are sent. - * However, linphone_core_set_network_reachable(lc,TRUE) will always request the proxy configs to refresh their registrations. - * The refreshing operations can be resumed with linphone_proxy_config_refresh_register(). - * @param obj the proxy config -**/ -void linphone_proxy_config_pause_register(LinphoneProxyConfig *obj){ - if (obj->op) sal_op_stop_refreshing(obj->op); +void linphone_proxy_config_pause_register(LinphoneProxyConfig *cfg){ + if (cfg->op) sal_op_stop_refreshing(cfg->op); } -/** - * Starts editing a proxy configuration. - * - * Because proxy configuration must be consistent, applications MUST - * call linphone_proxy_config_edit() before doing any attempts to modify - * proxy configuration (such as identity, proxy address and so on). - * Once the modifications are done, then the application must call - * linphone_proxy_config_done() to commit the changes. -**/ -void linphone_proxy_config_edit(LinphoneProxyConfig *obj){ - if (obj->publish && obj->publish_op){ - /*unpublish*/ - sal_publish_presence(obj->publish_op,NULL,NULL,0,(SalPresenceModel *)NULL); - sal_op_release(obj->publish_op); - obj->publish_op=NULL; +void linphone_proxy_config_edit(LinphoneProxyConfig *cfg){ + if (cfg->publish && cfg->publish_op){ + /*unpublish*/ + sal_publish_presence(cfg->publish_op,NULL,NULL,0,(SalPresenceModel *)NULL); + sal_op_release(cfg->publish_op); + cfg->publish_op=NULL; } /*store current config related to server location*/ - linphone_proxy_config_store_server_config(obj); + linphone_proxy_config_store_server_config(cfg); /*stop refresher in any case*/ - linphone_proxy_config_pause_register(obj); + linphone_proxy_config_pause_register(cfg); } -void linphone_proxy_config_apply(LinphoneProxyConfig *obj,LinphoneCore *lc){ - obj->lc=lc; - linphone_proxy_config_done(obj); +void linphone_proxy_config_apply(LinphoneProxyConfig *cfg,LinphoneCore *lc){ + cfg->lc=lc; + linphone_proxy_config_done(cfg); } -void linphone_proxy_config_stop_refreshing(LinphoneProxyConfig *obj){ - if (obj->publish_op){ - sal_op_release(obj->publish_op); - obj->publish_op=NULL; +void linphone_proxy_config_stop_refreshing(LinphoneProxyConfig *cfg){ + if (cfg->publish_op){ + sal_op_release(cfg->publish_op); + cfg->publish_op=NULL; } - if (obj->op){ - sal_op_release(obj->op); - obj->op=NULL; + if (cfg->op){ + sal_op_release(cfg->op); + cfg->op=NULL; } } -LinphoneAddress *guess_contact_for_register(LinphoneProxyConfig *obj){ +LinphoneAddress *guess_contact_for_register(LinphoneProxyConfig *cfg){ LinphoneAddress *ret=NULL; - LinphoneAddress *proxy=linphone_address_new(obj->reg_proxy); + LinphoneAddress *proxy=linphone_address_new(cfg->reg_proxy); const char *host; if (proxy==NULL) return NULL; @@ -416,22 +361,22 @@ LinphoneAddress *guess_contact_for_register(LinphoneProxyConfig *obj){ if (host!=NULL){ int localport = -1; const char *localip = NULL; - LinphoneAddress *contact=linphone_address_new(obj->reg_identity); + LinphoneAddress *contact=linphone_address_clone(cfg->identity_address); linphone_address_clean(contact); - if (obj->contact_params) { + if (cfg->contact_params) { // We want to add a list of contacts params to the linphone address - sal_address_set_params(contact,obj->contact_params); + sal_address_set_params(contact,cfg->contact_params); } - if (obj->contact_uri_params){ - sal_address_set_uri_params(contact,obj->contact_uri_params); + if (cfg->contact_uri_params){ + sal_address_set_uri_params(contact,cfg->contact_uri_params); } #ifdef BUILD_UPNP - if (obj->lc->upnp != NULL && linphone_core_get_firewall_policy(obj->lc)==LinphonePolicyUseUpnp && - linphone_upnp_context_get_state(obj->lc->upnp) == LinphoneUpnpStateOk) { - localip = linphone_upnp_context_get_external_ipaddress(obj->lc->upnp); - localport = linphone_upnp_context_get_external_port(obj->lc->upnp); + if (cfg->lc->upnp != NULL && linphone_core_get_firewall_policy(cfg->lc)==LinphonePolicyUseUpnp && + linphone_upnp_context_get_state(cfg->lc->upnp) == LinphoneUpnpStateOk) { + localip = linphone_upnp_context_get_external_ipaddress(cfg->lc->upnp); + localport = linphone_upnp_context_get_external_port(cfg->lc->upnp); } #endif //BUILD_UPNP linphone_address_set_port(contact,localport); @@ -444,73 +389,59 @@ LinphoneAddress *guess_contact_for_register(LinphoneProxyConfig *obj){ return ret; } -/** - * unregister without moving the register_enable flag - */ -void _linphone_proxy_config_unregister(LinphoneProxyConfig *obj) { - if (obj->op && obj->state == LinphoneRegistrationOk) { - sal_unregister(obj->op); +void _linphone_proxy_config_unregister(LinphoneProxyConfig *cfg) { + if (cfg->op && cfg->state == LinphoneRegistrationOk) { + sal_unregister(cfg->op); } } -static void linphone_proxy_config_register(LinphoneProxyConfig *obj){ - if (obj->reg_sendregister){ - LinphoneAddress* proxy=linphone_address_new(obj->reg_proxy); - LinphoneAddress* to=linphone_address_new(obj->reg_identity); +static void linphone_proxy_config_register(LinphoneProxyConfig *cfg){ + if (cfg->reg_sendregister){ + LinphoneAddress* proxy=linphone_address_new(cfg->reg_proxy); char* proxy_string; + char * from = linphone_address_as_string(cfg->identity_address); LinphoneAddress *contact; - ms_message("LinphoneProxyConfig [%p] about to register (LinphoneCore version: %s)",obj,linphone_core_get_version()); + ms_message("LinphoneProxyConfig [%p] about to register (LinphoneCore version: %s)",cfg,linphone_core_get_version()); proxy_string=linphone_address_as_string_uri_only(proxy); linphone_address_destroy(proxy); - if (obj->op) - sal_op_release(obj->op); - obj->op=sal_op_new(obj->lc->sal); + if (cfg->op) + sal_op_release(cfg->op); + cfg->op=sal_op_new(cfg->lc->sal); - linphone_configure_op(obj->lc, obj->op, to, obj->sent_headers, FALSE); - linphone_address_destroy(to); + linphone_configure_op(cfg->lc, cfg->op, cfg->identity_address, cfg->sent_headers, FALSE); - if ((contact=guess_contact_for_register(obj))) { - sal_op_set_contact_address(obj->op,contact); + if ((contact=guess_contact_for_register(cfg))) { + sal_op_set_contact_address(cfg->op,contact); linphone_address_destroy(contact); } - sal_op_set_user_pointer(obj->op,obj); + sal_op_set_user_pointer(cfg->op,cfg); - - if (sal_register(obj->op,proxy_string,obj->reg_identity,obj->expires)==0) { - linphone_proxy_config_set_state(obj,LinphoneRegistrationProgress,"Registration in progress"); + if (sal_register(cfg->op,proxy_string,from,cfg->expires)==0) { + linphone_proxy_config_set_state(cfg,LinphoneRegistrationProgress,"Registration in progress"); } else { - linphone_proxy_config_set_state(obj,LinphoneRegistrationFailed,"Registration failed"); + linphone_proxy_config_set_state(cfg,LinphoneRegistrationFailed,"Registration failed"); } ms_free(proxy_string); + ms_free(from); } else { /* unregister if registered*/ - if (obj->state == LinphoneRegistrationProgress) { - linphone_proxy_config_set_state(obj,LinphoneRegistrationCleared,"Registration cleared"); + if (cfg->state == LinphoneRegistrationProgress) { + linphone_proxy_config_set_state(cfg,LinphoneRegistrationCleared,"Registration cleared"); } - _linphone_proxy_config_unregister(obj); + _linphone_proxy_config_unregister(cfg); } } -/** - * Refresh a proxy registration. - * This is useful if for example you resuming from suspend, thus IP address may have changed. -**/ -void linphone_proxy_config_refresh_register(LinphoneProxyConfig *obj){ - if (obj->reg_sendregister && obj->op && obj->state!=LinphoneRegistrationProgress){ - if (sal_register_refresh(obj->op,obj->expires) == 0) { - linphone_proxy_config_set_state(obj,LinphoneRegistrationProgress, "Refresh registration"); +void linphone_proxy_config_refresh_register(LinphoneProxyConfig *cfg){ + if (cfg->reg_sendregister && cfg->op && cfg->state!=LinphoneRegistrationProgress){ + if (sal_register_refresh(cfg->op,cfg->expires) == 0) { + linphone_proxy_config_set_state(cfg,LinphoneRegistrationProgress, "Refresh registration"); } } } -/** - * Sets a dialing prefix to be automatically prepended when inviting a number with - * linphone_core_invite(); - * This dialing prefix shall usually be the country code of the country where the user is living, without "+". - * -**/ void linphone_proxy_config_set_dial_prefix(LinphoneProxyConfig *cfg, const char *prefix){ if (cfg->dial_prefix!=NULL){ ms_free(cfg->dial_prefix); @@ -519,29 +450,14 @@ void linphone_proxy_config_set_dial_prefix(LinphoneProxyConfig *cfg, const char if (prefix && prefix[0]!='\0') cfg->dial_prefix=ms_strdup(prefix); } -/** - * Returns dialing prefix. - * - * -**/ const char *linphone_proxy_config_get_dial_prefix(const LinphoneProxyConfig *cfg){ return cfg->dial_prefix; } -/** - * Sets whether liblinphone should replace "+" by international calling prefix in dialed numbers (passed to - * #linphone_core_invite ). - * -**/ void linphone_proxy_config_set_dial_escape_plus(LinphoneProxyConfig *cfg, bool_t val){ cfg->dial_escape_plus=val; } -/** - * Returns whether liblinphone should replace "+" by "00" in dialed numbers (passed to - * #linphone_core_invite ). - * -**/ bool_t linphone_proxy_config_get_dial_escape_plus(const LinphoneProxyConfig *cfg){ return cfg->dial_escape_plus; } @@ -598,8 +514,6 @@ typedef struct dial_plan{ }dial_plan_t; -/* TODO: fill with information for all countries over the world*/ - static dial_plan_t const dial_plans[]={ //Country , iso country code, e164 country calling code, number length, international usual prefix {"Afghanistan" ,"AF" , "93" , 9 , "00" }, @@ -885,10 +799,10 @@ bool_t linphone_proxy_config_is_phone_number(LinphoneProxyConfig *proxy, const c const char *p; for(p=username;*p!='\0';++p){ if (isdigit(*p) || - *p==' ' || - *p=='.' || - *p=='-' || - *p==')' || + *p==' ' || + *p=='.' || + *p=='-' || + *p==')' || *p=='(' || *p=='/' || *p=='+' || @@ -1104,18 +1018,20 @@ LinphoneAddress* linphone_proxy_config_normalize_sip_uri(LinphoneProxyConfig *pr if (proxy!=NULL){ /* append the proxy domain suffix */ - const char *identity=linphone_proxy_config_get_identity(proxy); - char normalized_username[128]; - uri=linphone_address_new(identity); + LinphoneAddress *uri=linphone_address_clone(linphone_proxy_config_get_identity_address(proxy)); if (uri==NULL){ return NULL; + } else { + char normalized_username[128]; + linphone_address_set_display_name(uri,NULL); + linphone_proxy_config_normalize_number(proxy,username,normalized_username, + sizeof(normalized_username)); + linphone_address_set_username(uri,normalized_username); + return _linphone_core_destroy_addr_if_not_sip(uri); } - linphone_address_set_display_name(uri,NULL); - linphone_proxy_config_normalize_number(proxy,username,normalized_username, - sizeof(normalized_username)); - linphone_address_set_username(uri,normalized_username); - return _linphone_core_destroy_addr_if_not_sip(uri); - }else return NULL; + } else { + return NULL; + } } uri=linphone_address_new(username); if (uri!=NULL){ @@ -1128,28 +1044,28 @@ LinphoneAddress* linphone_proxy_config_normalize_sip_uri(LinphoneProxyConfig *pr /** * Commits modification made to the proxy configuration. **/ -int linphone_proxy_config_done(LinphoneProxyConfig *obj) +int linphone_proxy_config_done(LinphoneProxyConfig *cfg) { LinphoneProxyConfigAddressComparisonResult res; - if (!linphone_proxy_config_check(obj->lc,obj)) + if (!linphone_proxy_config_check(cfg->lc,cfg)) return -1; /*check if server address as changed*/ - res = linphone_proxy_config_is_server_config_changed(obj); + res = linphone_proxy_config_is_server_config_changed(cfg); if (res != LinphoneProxyConfigAddressEqual) { /* server config has changed, need to unregister from previous first*/ - if (obj->op) { + if (cfg->op) { if (res == LinphoneProxyConfigAddressDifferent) { - _linphone_proxy_config_unregister(obj); + _linphone_proxy_config_unregister(cfg); } - sal_op_set_user_pointer(obj->op,NULL); /*we don't want to receive status for this un register*/ - sal_op_unref(obj->op); /*but we keep refresher to handle authentication if needed*/ - obj->op=NULL; + sal_op_set_user_pointer(cfg->op,NULL); /*we don't want to receive status for this un register*/ + sal_op_unref(cfg->op); /*but we keep refresher to handle authentication if needed*/ + cfg->op=NULL; } } - obj->commit=TRUE; - linphone_proxy_config_write_all_to_config_file(obj->lc); + cfg->commit=TRUE; + linphone_proxy_config_write_all_to_config_file(cfg->lc); return 0; } @@ -1170,19 +1086,14 @@ int linphone_proxy_config_send_publish(LinphoneProxyConfig *proxy, LinphonePrese if (proxy->state==LinphoneRegistrationOk || proxy->state==LinphoneRegistrationCleared){ if (proxy->publish_op==NULL){ - LinphoneAddress *to=linphone_address_new(linphone_proxy_config_get_identity(proxy)); + const LinphoneAddress *to=linphone_proxy_config_get_identity_address(proxy); proxy->publish_op=sal_op_new(proxy->lc->sal); linphone_configure_op(proxy->lc, proxy->publish_op, to, NULL, FALSE); - if (to!=NULL){ - linphone_address_destroy(to); - } if (lp_config_get_int(proxy->lc->config,"sip","publish_msg_with_contact",0)){ - SalAddress *addr=sal_address_new(linphone_proxy_config_get_identity(proxy)); - sal_op_set_contact_address(proxy->publish_op,addr); - sal_address_unref(addr); + sal_op_set_contact_address(proxy->publish_op,linphone_proxy_config_get_identity_address(proxy)); } } err=sal_publish_presence(proxy->publish_op @@ -1194,102 +1105,67 @@ int linphone_proxy_config_send_publish(LinphoneProxyConfig *proxy, LinphonePrese return err; } -/** - * Returns the route set for this proxy configuration. -**/ -const char *linphone_proxy_config_get_route(const LinphoneProxyConfig *obj){ - return obj->reg_route; +const char *linphone_proxy_config_get_route(const LinphoneProxyConfig *cfg){ + return cfg->reg_route; +} + +const LinphoneAddress *linphone_proxy_config_get_identity_address(const LinphoneProxyConfig *cfg){ + return cfg->identity_address; +} + +const char *linphone_proxy_config_get_identity(const LinphoneProxyConfig *cfg){ + return cfg->reg_identity; +} + +bool_t linphone_proxy_config_publish_enabled(const LinphoneProxyConfig *cfg){ + return cfg->publish; +} + +const char *linphone_proxy_config_get_server_addr(const LinphoneProxyConfig *cfg){ + return cfg->reg_proxy; } /** - * Returns the SIP identity that belongs to this proxy configuration. - * - * The SIP identity is a SIP address (Display Name ) + * @return the duration of registration. **/ -const char *linphone_proxy_config_get_identity(const LinphoneProxyConfig *obj){ - return obj->reg_identity; +int linphone_proxy_config_get_expires(const LinphoneProxyConfig *cfg){ + return cfg->expires; } -/** - * Returns TRUE if PUBLISH request is enabled for this proxy. -**/ -bool_t linphone_proxy_config_publish_enabled(const LinphoneProxyConfig *obj){ - return obj->publish; +bool_t linphone_proxy_config_register_enabled(const LinphoneProxyConfig *cfg){ + return cfg->reg_sendregister; } -/** - * Returns the proxy's SIP address. -**/ -const char *linphone_proxy_config_get_server_addr(const LinphoneProxyConfig *obj){ - return obj->reg_proxy; -} - -/** - * Returns the duration of registration. -**/ -int linphone_proxy_config_get_expires(const LinphoneProxyConfig *obj){ - return obj->expires; -} - -/** - * Returns TRUE if registration to the proxy is enabled. -**/ -bool_t linphone_proxy_config_register_enabled(const LinphoneProxyConfig *obj){ - return obj->reg_sendregister; -} - -/** - * Set optional contact parameters that will be added to the contact information sent in the registration. - * @param obj the proxy config object - * @param contact_params a string contaning the additional parameters in text form, like "myparam=something;myparam2=something_else" - * - * The main use case for this function is provide the proxy additional information regarding the user agent, like for example unique identifier or apple push id. - * As an example, the contact address in the SIP register sent will look like ;apple-push-id=43143-DFE23F-2323-FA2232. -**/ -void linphone_proxy_config_set_contact_parameters(LinphoneProxyConfig *obj, const char *contact_params){ - if (obj->contact_params) { - ms_free(obj->contact_params); - obj->contact_params=NULL; +void linphone_proxy_config_set_contact_parameters(LinphoneProxyConfig *cfg, const char *contact_params){ + if (cfg->contact_params) { + ms_free(cfg->contact_params); + cfg->contact_params=NULL; } if (contact_params){ - obj->contact_params=ms_strdup(contact_params); + cfg->contact_params=ms_strdup(contact_params); } } -/** - * Set optional contact parameters that will be added to the contact information sent in the registration, inside the URI. - * @param obj the proxy config object - * @param contact_uri_params a string containing the additional parameters in text form, like "myparam=something;myparam2=something_else" - * - * The main use case for this function is provide the proxy additional information regarding the user agent, like for example unique identifier or apple push id. - * As an example, the contact address in the SIP register sent will look like . -**/ -void linphone_proxy_config_set_contact_uri_parameters(LinphoneProxyConfig *obj, const char *contact_uri_params){ - if (obj->contact_uri_params) { - ms_free(obj->contact_uri_params); - obj->contact_uri_params=NULL; +void linphone_proxy_config_set_contact_uri_parameters(LinphoneProxyConfig *cfg, const char *contact_uri_params){ + if (cfg->contact_uri_params) { + ms_free(cfg->contact_uri_params); + cfg->contact_uri_params=NULL; } if (contact_uri_params){ - obj->contact_uri_params=ms_strdup(contact_uri_params); + cfg->contact_uri_params=ms_strdup(contact_uri_params); } } -/** - * Returns previously set contact parameters. -**/ -const char *linphone_proxy_config_get_contact_parameters(const LinphoneProxyConfig *obj){ - return obj->contact_params; +const char *linphone_proxy_config_get_contact_parameters(const LinphoneProxyConfig *cfg){ + return cfg->contact_params; } -/** - * Returns previously set contact URI parameters. -**/ -const char *linphone_proxy_config_get_contact_uri_parameters(const LinphoneProxyConfig *obj){ - return obj->contact_uri_params; +const char *linphone_proxy_config_get_contact_uri_parameters(const LinphoneProxyConfig *cfg){ + return cfg->contact_uri_params; } -struct _LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *obj){ - return obj->lc; +struct _LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *cfg){ + return cfg->lc; } const char *linphone_proxy_config_get_custom_header(LinphoneProxyConfig *cfg, const char *header_name){ @@ -1303,10 +1179,6 @@ void linphone_proxy_config_set_custom_header(LinphoneProxyConfig *cfg, const cha cfg->sent_headers=sal_custom_header_append(cfg->sent_headers, header_name, header_value); } -/** - * Add a proxy configuration. - * This will start registration on the proxy, if registration is enabled. -**/ int linphone_core_add_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *cfg){ if (!linphone_proxy_config_check(lc,cfg)) { return -1; @@ -1320,12 +1192,6 @@ int linphone_core_add_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *cfg){ return 0; } -/** - * Removes a proxy configuration. - * - * LinphoneCore will then automatically unregister and place the proxy configuration - * on a deleted list. For that reason, a removed proxy does NOT need to be freed. -**/ void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *cfg){ /* check this proxy config is in the list before doing more*/ if (ms_list_find(lc->sip_conf.proxies,cfg)==NULL){ @@ -1369,15 +1235,6 @@ static int linphone_core_get_default_proxy_config_index(LinphoneCore *lc) { return pos; } -/** - * Sets the default proxy. - * - * This default proxy must be part of the list of already entered LinphoneProxyConfig. - * Toggling it as default will make LinphoneCore use the identity associated with - * the proxy configuration in all incoming and outgoing calls. - * @param[in] lc LinphoneCore object - * @param[in] config The proxy configuration to use as the default one. -**/ void linphone_core_set_default_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config){ /* check if this proxy is in our list */ if (config!=NULL){ @@ -1397,20 +1254,11 @@ void linphone_core_set_default_proxy_index(LinphoneCore *lc, int index){ else linphone_core_set_default_proxy(lc,ms_list_nth_data(lc->sip_conf.proxies,index)); } -/** - * Returns the default proxy configuration, that is the one used to determine the current identity. - * @deprecated Use linphone_core_get_default_proxy_config() instead. -**/ int linphone_core_get_default_proxy(LinphoneCore *lc, LinphoneProxyConfig **config){ if (config!=NULL) *config=lc->default_proxy; return linphone_core_get_default_proxy_config_index(lc); } -/** - * Returns the default proxy configuration, that is the one used to determine the current identity. - * @param[in] lc LinphoneCore object - * @return The default proxy configuration. -**/ LinphoneProxyConfig * linphone_core_get_default_proxy_config(LinphoneCore *lc) { return lc->default_proxy; } @@ -1419,64 +1267,64 @@ const MSList *linphone_core_get_proxy_config_list(const LinphoneCore *lc){ return lc->sip_conf.proxies; } -void linphone_proxy_config_write_to_config_file(LpConfig *config, LinphoneProxyConfig *obj, int index) +void linphone_proxy_config_write_to_config_file(LpConfig *config, LinphoneProxyConfig *cfg, int index) { char key[50]; sprintf(key,"proxy_%i",index); lp_config_clean_section(config,key); - if (obj==NULL){ + if (cfg==NULL){ return; } - if (obj->type!=NULL){ - lp_config_set_string(config,key,"type",obj->type); + if (cfg->type!=NULL){ + lp_config_set_string(config,key,"type",cfg->type); } - if (obj->reg_proxy!=NULL){ - lp_config_set_string(config,key,"reg_proxy",obj->reg_proxy); + if (cfg->reg_proxy!=NULL){ + lp_config_set_string(config,key,"reg_proxy",cfg->reg_proxy); } - if (obj->reg_route!=NULL){ - lp_config_set_string(config,key,"reg_route",obj->reg_route); + if (cfg->reg_route!=NULL){ + lp_config_set_string(config,key,"reg_route",cfg->reg_route); } - if (obj->reg_identity!=NULL){ - lp_config_set_string(config,key,"reg_identity",obj->reg_identity); + if (cfg->reg_identity!=NULL){ + lp_config_set_string(config,key,"reg_identity",cfg->reg_identity); } - if (obj->realm!=NULL){ - lp_config_set_string(config,key,"realm",obj->realm); + if (cfg->realm!=NULL){ + lp_config_set_string(config,key,"realm",cfg->realm); } - if (obj->contact_params!=NULL){ - lp_config_set_string(config,key,"contact_parameters",obj->contact_params); + if (cfg->contact_params!=NULL){ + lp_config_set_string(config,key,"contact_parameters",cfg->contact_params); } - if (obj->contact_uri_params!=NULL){ - lp_config_set_string(config,key,"contact_uri_parameters",obj->contact_uri_params); + if (cfg->contact_uri_params!=NULL){ + lp_config_set_string(config,key,"contact_uri_parameters",cfg->contact_uri_params); } - if (obj->quality_reporting_collector!=NULL){ - lp_config_set_string(config,key,"quality_reporting_collector",obj->quality_reporting_collector); + if (cfg->quality_reporting_collector!=NULL){ + lp_config_set_string(config,key,"quality_reporting_collector",cfg->quality_reporting_collector); } - lp_config_set_int(config,key,"quality_reporting_enabled",obj->quality_reporting_enabled); - lp_config_set_int(config,key,"quality_reporting_interval",obj->quality_reporting_interval); - lp_config_set_int(config,key,"reg_expires",obj->expires); - lp_config_set_int(config,key,"reg_sendregister",obj->reg_sendregister); - lp_config_set_int(config,key,"publish",obj->publish); - lp_config_set_int(config, key, "avpf", obj->avpf_mode); - lp_config_set_int(config, key, "avpf_rr_interval", obj->avpf_rr_interval); - lp_config_set_int(config,key,"dial_escape_plus",obj->dial_escape_plus); - lp_config_set_string(config,key,"dial_prefix",obj->dial_prefix); - lp_config_set_int(config,key,"privacy",obj->privacy); + lp_config_set_int(config,key,"quality_reporting_enabled",cfg->quality_reporting_enabled); + lp_config_set_int(config,key,"quality_reporting_interval",cfg->quality_reporting_interval); + lp_config_set_int(config,key,"reg_expires",cfg->expires); + lp_config_set_int(config,key,"reg_sendregister",cfg->reg_sendregister); + lp_config_set_int(config,key,"publish",cfg->publish); + lp_config_set_int(config, key, "avpf", cfg->avpf_mode); + lp_config_set_int(config, key, "avpf_rr_interval", cfg->avpf_rr_interval); + lp_config_set_int(config,key,"dial_escape_plus",cfg->dial_escape_plus); + lp_config_set_string(config,key,"dial_prefix",cfg->dial_prefix); + lp_config_set_int(config,key,"privacy",cfg->privacy); } -#define CONFIGURE_STRING_VALUE(obj,config,key,param,param_name) \ +#define CONFIGURE_STRING_VALUE(cfg,config,key,param,param_name) \ {\ - char* default_value = linphone_proxy_config_get_##param(obj)?ms_strdup(linphone_proxy_config_get_##param(obj)):NULL;\ - linphone_proxy_config_set_##param(obj,lp_config_get_string(config,key,param_name,default_value)); \ + char* default_value = linphone_proxy_config_get_##param(cfg)?ms_strdup(linphone_proxy_config_get_##param(cfg)):NULL;\ + linphone_proxy_config_set_##param(cfg,lp_config_get_string(config,key,param_name,default_value)); \ if ( default_value) ms_free(default_value); \ } -#define CONFIGURE_BOOL_VALUE(obj,config,key,param,param_name) \ - linphone_proxy_config_enable_##param(obj,lp_config_get_int(config,key,param_name,linphone_proxy_config_##param##_enabled(obj))); +#define CONFIGURE_BOOL_VALUE(cfg,config,key,param,param_name) \ + linphone_proxy_config_enable_##param(cfg,lp_config_get_int(config,key,param_name,linphone_proxy_config_##param##_enabled(cfg))); -#define CONFIGURE_INT_VALUE(obj,config,key,param,param_name) \ - linphone_proxy_config_set_##param(obj,lp_config_get_int(config,key,param_name,linphone_proxy_config_get_##param(obj))); +#define CONFIGURE_INT_VALUE(cfg,config,key,param,param_name) \ + linphone_proxy_config_set_##param(cfg,lp_config_get_int(config,key,param_name,linphone_proxy_config_get_##param(cfg))); LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LinphoneCore* lc, int index) { @@ -1611,10 +1459,6 @@ SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig return cfg->ssctx; } -/** - * @} -**/ - void linphone_proxy_config_set_user_data(LinphoneProxyConfig *cfg, void *ud) { cfg->user_data = ud; } @@ -1712,16 +1556,15 @@ void linphone_proxy_config_set_privacy(LinphoneProxyConfig *params, LinphonePriv LinphonePrivacyMask linphone_proxy_config_get_privacy(const LinphoneProxyConfig *params) { return params->privacy; } -void linphone_proxy_config_set_publish_expires(LinphoneProxyConfig *obj, int expires) { - obj->publish_expires=expires; +void linphone_proxy_config_set_publish_expires(LinphoneProxyConfig *cfg, int expires) { + cfg->publish_expires=expires; } -int linphone_proxy_config_get_publish_expires(const LinphoneProxyConfig *obj) { - if (obj->publish_expires<0) { - return obj->expires; /*default value is same as register*/ +int linphone_proxy_config_get_publish_expires(const LinphoneProxyConfig *cfg) { + if (cfg->publish_expires<0) { + return cfg->expires; /*default value is same as register*/ } else { - return obj->publish_expires; + return cfg->publish_expires; } - } void linphone_proxy_config_enable_avpf(LinphoneProxyConfig *cfg, bool_t enable) { @@ -1752,6 +1595,6 @@ uint8_t linphone_proxy_config_get_avpf_rr_interval(const LinphoneProxyConfig *cf return cfg->avpf_rr_interval; } -char* linphone_proxy_config_get_contact(const LinphoneProxyConfig *cfg) { - return sal_op_get_public_uri(cfg->op); +const LinphoneAddress* linphone_proxy_config_get_contact(const LinphoneProxyConfig *cfg) { + return sal_op_get_contact_address(cfg->op); } diff --git a/gtk/chat.c b/gtk/chat.c index be66dabb0..2075a9fb7 100644 --- a/gtk/chat.c +++ b/gtk/chat.c @@ -244,14 +244,6 @@ void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from, g_idle_add((GSourceFunc)scroll_to_end,text); } -const LinphoneAddress* linphone_gtk_get_used_identity(){ - LinphoneCore *lc=linphone_gtk_get_core(); - LinphoneProxyConfig *cfg; - linphone_core_get_default_proxy(lc,&cfg); - if (cfg) return linphone_address_new(linphone_proxy_config_get_identity(cfg)); - else return linphone_core_get_primary_contact_parsed(lc); -} - void update_chat_state_message(LinphoneChatMessageState state,LinphoneChatMessage *msg){ GtkWidget *main_window=linphone_gtk_get_main_window(); GtkWidget *friendlist=linphone_gtk_get_widget(main_window,"contact_list"); @@ -406,7 +398,7 @@ static GdkColor *_linphone_gtk_chatroom_get_link_color(GtkWidget *chatview) { gtk_widget_get_style(chatview), G_OBJECT_TYPE(chatview), "link-color", &color_value); - + return (GdkColor *)g_value_get_boxed(&color_value); } @@ -515,26 +507,26 @@ GtkWidget* linphone_gtk_init_chatroom(LinphoneChatRoom *cr, const LinphoneAddres g_object_set_data(G_OBJECT(chat_view),"cr",cr); g_object_set_data(G_OBJECT(chat_view),"from_message",NULL); g_object_set_data(G_OBJECT(chat_view),"table",table); - + gtk_text_buffer_create_tag( gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)), "me", "foreground_gdk", &color_black, "paragraph-background-gdk", &color_light_grey, NULL); - + gtk_text_buffer_create_tag( gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)), "from", "weight", PANGO_WEIGHT_BOLD, NULL); - + gtk_text_buffer_create_tag( gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)), "body", "indent", 10, NULL); - + gtk_text_buffer_create_tag( gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)), "status", @@ -557,7 +549,7 @@ GtkWidget* linphone_gtk_init_chatroom(LinphoneChatRoom *cr, const LinphoneAddres gtk_widget_show_all(link_ctx_menu); g_object_set_data_full(G_OBJECT(text), "link_ctx_menu", link_ctx_menu, g_object_unref); g_object_ref_sink(G_OBJECT(link_ctx_menu)); - + messages = linphone_chat_room_get_history(cr,NB_MSG_HIST); display_history_message(chat_view,messages,with); button = linphone_gtk_get_widget(chat_view,"send"); diff --git a/gtk/loginframe.c b/gtk/loginframe.c index 727a746d1..cbe384c42 100644 --- a/gtk/loginframe.c +++ b/gtk/loginframe.c @@ -39,7 +39,7 @@ static gboolean do_login_noprompt(LinphoneProxyConfig *cfg){ linphone_gtk_show_login_frame(cfg,TRUE); return FALSE; } - addr=linphone_address_new(linphone_proxy_config_get_identity(cfg)); + addr=linphone_address_clone(linphone_proxy_config_get_identity_address(cfg)); linphone_address_set_username(addr,username); tmp=linphone_address_as_string (addr); do_login(ssctx,tmp,NULL,NULL); @@ -58,14 +58,14 @@ void linphone_gtk_show_login_frame(LinphoneProxyConfig *cfg, gboolean disable_au const char *passwd=NULL; const char *userid=NULL; gboolean auto_login=linphone_gtk_get_ui_config_int("automatic_login",0); - + if (auto_login && !disable_auto_login){ g_timeout_add(250,(GSourceFunc)do_login_noprompt,cfg); return; } gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(mw,"automatic_login")),auto_login); - + { const char *login_image=linphone_gtk_get_ui_config("login_image","linphone-banner.png"); if (login_image){ @@ -95,7 +95,7 @@ void linphone_gtk_show_login_frame(LinphoneProxyConfig *cfg, gboolean disable_au if (username) linphone_address_set_username(from,username); } - + ai=linphone_core_find_auth_info(lc,linphone_proxy_config_get_domain(cfg),linphone_address_get_username(from),NULL); /*display the last entered username, if not '?????'*/ if (linphone_address_get_username(from)[0]!='?') @@ -109,7 +109,7 @@ void linphone_gtk_show_login_frame(LinphoneProxyConfig *cfg, gboolean disable_au passwd!=NULL ? passwd : ""); gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(mw,"login_userid")), userid ? userid : ""); - + linphone_address_destroy(from); } @@ -150,7 +150,7 @@ void linphone_gtk_login_frame_connect_clicked(GtkWidget *button){ username=gtk_entry_get_text(GTK_ENTRY(linphone_gtk_get_widget(mw,"login_username"))); password=gtk_entry_get_text(GTK_ENTRY(linphone_gtk_get_widget(mw,"login_password"))); userid=gtk_entry_get_text(GTK_ENTRY(linphone_gtk_get_widget(mw,"login_userid"))); - + if (username==NULL || username[0]=='\0') return; diff --git a/tester/call_tester.c b/tester/call_tester.c index 419089f91..53ac91a3d 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -363,7 +363,6 @@ void simple_call_base(bool_t enable_multicast_recv_side) { const LinphoneAddress *from; LinphoneCall *pauline_call; LinphoneProxyConfig* marie_cfg; - const char* marie_id = NULL; belle_sip_object_enable_leak_detector(TRUE); begin=belle_sip_object_get_object_count(); @@ -373,9 +372,8 @@ void simple_call_base(bool_t enable_multicast_recv_side) { /* with the account manager, we might lose the identity */ marie_cfg = linphone_core_get_default_proxy_config(marie->lc); - marie_id = linphone_proxy_config_get_identity(marie_cfg); { - LinphoneAddress* marie_addr = linphone_address_new(marie_id); + LinphoneAddress* marie_addr = linphone_address_clone(linphone_proxy_config_get_identity_address(marie_cfg)); char* marie_tmp_id = NULL; linphone_address_set_display_name(marie_addr, "Super Marie"); marie_tmp_id = linphone_address_as_string(marie_addr); @@ -385,7 +383,7 @@ void simple_call_base(bool_t enable_multicast_recv_side) { linphone_proxy_config_done(marie_cfg); ms_free(marie_tmp_id); - linphone_address_unref(marie_addr); + linphone_address_destroy(marie_addr); } linphone_core_enable_audio_multicast(pauline->lc,enable_multicast_recv_side); @@ -695,14 +693,14 @@ static void simple_call_compatibility_mode(void) { stats* stat_marie=&marie->stat; stats* stat_pauline=&pauline->stat; LinphoneProxyConfig* proxy; - LinphoneAddress* identity; + const LinphoneAddress* identity; LinphoneAddress* proxy_address; char*tmp; LCSipTransports transport; linphone_core_get_default_proxy(lc_marie,&proxy); BC_ASSERT_PTR_NOT_NULL (proxy); - identity = linphone_address_new(linphone_proxy_config_get_identity(proxy)); + identity = linphone_proxy_config_get_identity_address(proxy); proxy_address=linphone_address_new(linphone_proxy_config_get_addr(proxy)); @@ -733,7 +731,6 @@ static void simple_call_compatibility_mode(void) { BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call_remote_address(lc_pauline)); if (linphone_core_get_current_call_remote_address(lc_pauline)) { BC_ASSERT_TRUE(linphone_address_weak_equal(identity,linphone_core_get_current_call_remote_address(lc_pauline))); - linphone_address_destroy(identity); linphone_core_accept_call(lc_pauline,linphone_core_get_current_call(lc_pauline)); diff --git a/tester/tester.c b/tester/tester.c index a9c406487..b3ffddec0 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -331,7 +331,7 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, const char* rc_file, linphone_core_get_default_proxy(mgr->lc,&proxy); if (proxy) { - mgr->identity = linphone_address_new(linphone_proxy_config_get_identity(proxy)); + mgr->identity = linphone_address_clone(linphone_proxy_config_get_identity_address(proxy)); linphone_address_clean(mgr->identity); } } diff --git a/tester/tunnel_tester.c b/tester/tunnel_tester.c index 98a28e7c1..425247eb8 100644 --- a/tester/tunnel_tester.c +++ b/tester/tunnel_tester.c @@ -46,15 +46,9 @@ static const char* get_ip_from_hostname(const char * tunnel_hostname){ return output; } static char* get_public_contact_ip(LinphoneCore* lc) { - long contact_host_ip_len; - char contact_host_ip[255]; - char * contact = linphone_proxy_config_get_contact(linphone_core_get_default_proxy_config(lc)); + const LinphoneAddress * contact = linphone_proxy_config_get_contact(linphone_core_get_default_proxy_config(lc)); BC_ASSERT_PTR_NOT_NULL(contact); - contact_host_ip_len = strchr(contact, ':')-contact; - strncpy(contact_host_ip, contact, contact_host_ip_len); - contact_host_ip[contact_host_ip_len]='\0'; - ms_free(contact); - return ms_strdup(contact_host_ip); + return ms_strdup(linphone_address_get_domain(contact)); }