Commit ff804c02 authored by Timothée Jaussoin's avatar Timothée Jaussoin
Browse files

Remove xmlrpc_session from the account creator

Simplify the account creator internal methods
Move the configuration to account_creator in the Core config
Define a LinphoneAccountCreatorBackend enum
Code cleanup
parent 06b2254d
......@@ -2653,13 +2653,20 @@ static void linphone_core_internal_publish_state_changed(LinphoneCore *lc, Linph
}
}
void linphone_core_set_account_creator_url(LinphoneCore *lc, const char *url) {
linphone_config_set_string(lc->config, "account_creator", "url", url);
}
void linphone_core_set_account_creator_backend(LinphoneCore *lc, LinphoneAccountCreatorBackend backend) {
linphone_config_set_int(lc->config, "account_creator", "backend", (int)backend);
}
static void _linphone_core_init_account_creator_service(LinphoneCore *lc) {
LinphoneAccountCreatorService *service = linphone_account_creator_service_new();
#ifdef HAVE_FLEXIAPI
const char* uri = linphone_config_get_string(lc->config, "sip", "flexiapi_url", NULL);
if (uri == NULL) {
if (linphone_config_get_int(lc->config, "account_creator", "backend", LinphoneAccountCreatorBackendFlexiAPI)
== LinphoneAccountCreatorBackendXMLRPC) {
#endif
linphone_account_creator_service_set_constructor_cb(service, linphone_account_creator_constructor_linphone_xmlrpc);
linphone_account_creator_service_set_destructor_cb(service, NULL);
......
......@@ -54,11 +54,18 @@ typedef void (*LinphoneAccountCreatorCbsStatusCb)(LinphoneAccountCreator *creato
/**
* Create a #LinphoneAccountCreator and set Linphone Request callbacks.
* @param core The #LinphoneCore used for the XML-RPC communication @notnil
* @param xmlrpc_url The URL to the XML-RPC server. @maybenil
* @return The new #LinphoneAccountCreator object. @notnil
**/
LINPHONE_PUBLIC LinphoneAccountCreator * linphone_account_creator_new(LinphoneCore *core, const char *xmlrpc_url);
LINPHONE_PUBLIC LinphoneAccountCreator* linphone_account_creator_create(LinphoneCore *core);
/**
* Create a #LinphoneAccountCreator and set Linphone Request callbacks.
* @param core The #LinphoneCore used for the XML-RPC communication @notnil
* @param xmlrpc_url The URL to the XML-RPC server. @maybenil
* @return The new #LinphoneAccountCreator object. @notnil
* @deprecated 13/04/2020 Use linphone_account_creator_create() instead
**/
LINPHONE_PUBLIC LinphoneAccountCreator* linphone_account_creator_new(LinphoneCore *core, const char *xmlrpc_url);
/**
* Reset the account creator entries like username, password, phone number...
......
......@@ -1194,7 +1194,7 @@ LINPHONE_PUBLIC void linphone_core_set_user_agent(LinphoneCore *core, const char
/**
* Constructs a #LinphoneAddress from the given string if possible.
*
*
* In case of just a username, characters will be unescaped.
* If a phone number is detected, it will be flattened.
* sip: or sips: prefix will be added if not present.
......@@ -1317,10 +1317,10 @@ LINPHONE_PUBLIC LinphoneStatus linphone_core_pause_all_calls(LinphoneCore *core)
/**
* Create a #LinphoneCallParams suitable for linphone_core_invite_with_params(), linphone_core_accept_call_with_params(),
* Create a #LinphoneCallParams suitable for linphone_core_invite_with_params(), linphone_core_accept_call_with_params(),
* linphone_core_accept_early_media_with_params() or linphone_core_accept_call_update().
* The parameters are initialized according to the current #LinphoneCore configuration and the last used local #LinphoneCallParams,
* the ones passed through linphone_call_update(), linphone_call_accept_with_params() or linphone_call_accept_update_with_params().
* The parameters are initialized according to the current #LinphoneCore configuration and the last used local #LinphoneCallParams,
* the ones passed through linphone_call_update(), linphone_call_accept_with_params() or linphone_call_accept_update_with_params().
* @param core #LinphoneCore object
* @param call #LinphoneCall for which the parameters are to be build, or NULL in the case where the parameters are to be used for a new outgoing call. @maybenil
* @return A new #LinphoneCallParams object. @maybenil
......@@ -1995,6 +1995,21 @@ LINPHONE_PUBLIC void linphone_core_abort_authentication(LinphoneCore *core, Linp
**/
LINPHONE_PUBLIC void linphone_core_clear_all_auth_info(LinphoneCore *core);
/**
* Set the #LinphoneAccountCreator url on the #LinphoneCore
* @param core The #LinphoneCore used for the XML-RPC communication @notnil
* @param url The URL to reach
**/
LINPHONE_PUBLIC void linphone_core_set_account_creator_url(LinphoneCore *lc, const char *url);
/**
* Set the #LinphoneAccountCreator backend on the #LinphoneCore
* @param core The #LinphoneCore used for the XML-RPC communication @notnil
* @param backend The #LinphoneAccountCreatorBackend
**/
LINPHONE_PUBLIC void linphone_core_set_account_creator_backend(LinphoneCore *lc, LinphoneAccountCreatorBackend backend);
/**
* Sets an default account creator service in the core
* @param core #LinphoneCore object @notnil
......@@ -3206,7 +3221,7 @@ LINPHONE_PUBLIC void linphone_video_activation_policy_set_automatically_initiate
* This policy defines whether:
* - video shall be initiated by default for outgoing calls
* - video shall be accepted by default for incoming calls
*
*
* @param core the #LinphoneCore object @notnil
* @param policy The #LinphoneVideoActivationPolicy to use @notnil
* @ingroup media_parameters
......@@ -4464,7 +4479,7 @@ LINPHONE_PUBLIC void linphone_core_set_call_error_tone(LinphoneCore *core, Linph
LINPHONE_PUBLIC void linphone_core_set_tone(LinphoneCore *core, LinphoneToneID tone_id, const char *audiofile);
/**
* Globaly set an http file transfer server to be used for content type application/vnd.gsma.rcs-ft-http+xml.
* Globaly set an http file transfer server to be used for content type application/vnd.gsma.rcs-ft-http+xml.
* Url may be like: "https://file.linphone.org/upload.php".
* This value can also be set for a dedicated account using #linphone_proxy_config_set_file_transfer_server().
* @param core #LinphoneCore to be modified @notnil
......@@ -5617,7 +5632,7 @@ LINPHONE_PUBLIC void linphone_core_set_default_output_audio_device(LinphoneCore
LINPHONE_PUBLIC const LinphoneAudioDevice* linphone_core_get_default_input_audio_device(const LinphoneCore *core);
/**
* Gets the default output audio device
* Gets the default output audio device
* @param core The #LinphoneCore @notnil
* @returns The default output audio device @notnil
* @ingroup audio
......
......@@ -35,24 +35,24 @@
/**
* @brief Represents an account configuration to be used by #LinphoneCore.
*
* In addition to the #LinphoneAuthInfo that stores the credentials,
*
* In addition to the #LinphoneAuthInfo that stores the credentials,
* you need to configure a #LinphoneProxyConfig as well to be able to connect to a proxy server.
*
* A minimal proxy config consists of an identity address (sip:username@domain.tld)
*
* A minimal proxy config consists of an identity address (sip:username@domain.tld)
* and the proxy server address, @see linphone_proxy_config_set_server_addr().
*
*
* If any, it will be stored inside the default configuration file, so it will survive the destruction
* of the #LinphoneCore and be available at the next start.
*
* The account set with linphone_core_set_default_proxy_config() will be used as default
* The account set with linphone_core_set_default_proxy_config() will be used as default
* for outgoing calls & chat messages unless specified otherwise.
* @ingroup proxies
**/
typedef struct _LinphoneProxyConfig LinphoneProxyConfig;
/**
* @brief The object used to configure an account on a server via XML-RPC,
* @brief The object used to configure an account on a server via XML-RPC,
* see @link https://wiki.linphone.org/xwiki/wiki/public/view/Lib/Features/Override%20account%20creator%20request/
* @ingroup account_creator
**/
......@@ -89,6 +89,15 @@ typedef enum _LinphoneAccountCreatorPhoneNumberStatus {
*/
typedef unsigned int LinphoneAccountCreatorPhoneNumberStatusMask;
/**
* @brief Enum describing backend used in the #LinphoneAccountCreator.
* @ingroup account_creator
**/
typedef enum _LinphoneAccountCreatorBackend {
LinphoneAccountCreatorBackendXMLRPC, /**< XMLRPC Backend */
LinphoneAccountCreatorBackendFlexiAPI, /**< FlexiAPI Backend */
} LinphoneAccountCreatorBackend;
/**
* @brief Enum describing username checking, used by the #LinphoneAccountCreator.
* @ingroup account_creator
......@@ -225,7 +234,7 @@ typedef enum _LinphoneCallDir {
/**
* @brief This object carry various statistic informations regarding the quality of an audio or video stream for a given #LinphoneCall.
*
* To receive these informations periodically and as soon as they are computed,
* To receive these informations periodically and as soon as they are computed,
* implement the call_stats_updated() callback inside a #LinphoneCoreCbs.
*
* At any time, the application can access latest computed statistics using linphone_call_get_audio_stats() and linphone_call_get_video_stats().
......@@ -253,13 +262,13 @@ typedef enum _LinphoneCallStatus {
/**
* @brief This object is used to store a SIP address.
*
*
* #LinphoneFriend is mainly used to implement an adressbook feature, and are used as data for the #LinphoneMagicSearch object.
* If your proxy supports it, you can also use it to subscribe to presence information.
*
*
* The objects are stored in a #LinphoneFriendList which are in turn stored inside the #LinphoneCore.
* They can be stored inside a database if the path to it is configured, otherwise they will be lost after the #LinphoneCore is destroyed.
*
*
* Thanks to the vCard plugin, you can also store more information like phone numbers, organization, etc...
* @ingroup buddy_list
*/
......@@ -278,7 +287,7 @@ typedef enum _LinphoneFriendCapability {
/**
* @brief This object representing a list of #LinphoneFriend.
*
*
* You can use it to store contacts locally or synchronize them through CardDAV protocol.
* @ingroup buddy_list
**/
......@@ -321,12 +330,12 @@ typedef enum _LinphoneFriendListSyncStatus {
* - sections are defined in []
* - each section contains a sequence of key=value pairs
* - each line starting by a # is a comment
*
*
* Various types can be used: strings and lists of strings, integers, floats, booleans (written as 0 or 1) and range of integers.
*
*
* Usually a #LinphoneCore is initialized using two #LinphoneConfig, one default (where configuration changes through API calls will be saved)
* and one named 'factory' which is read-only and overwrites any setting that may exists in the default one.
*
*
* It is also possible to use only one (either default or factory) or even none.
* @ingroup initializing
**/
......@@ -339,7 +348,7 @@ typedef struct _LpConfig LinphoneConfig;
/**
* @brief Describes the state of the remote configuring process of the #LinphoneCore object, 'Skipped' when the feature is disabled.
*
*
* It is notified via the configuring_status() callback in #LinphoneCoreCbs.
* @ingroup initializing
**/
......@@ -351,7 +360,7 @@ typedef enum _LinphoneConfiguringState {
/**
* @brief Describes the global state of the #LinphoneCore object.
*
*
* It is notified via the global_state_changed() callback in #LinphoneCoreCbs.
* @ingroup initializing
**/
......@@ -372,7 +381,7 @@ typedef enum _LinphoneGlobalState {
/**
* @brief Describes proxy registration states.
*
*
* It is notified via the registration_state_changed() callback in #LinphoneCoreCbs.
* @ingroup proxies
**/
......@@ -386,21 +395,21 @@ typedef enum _LinphoneRegistrationState {
/**
* @brief Main object to instanciate and on which to keep a reference.
*
*
* This object is the first object to instanciante, and will allow you to perform all kind of tasks.
* To create it, use either linphone_factory_create_core_3() or linphone_factory_create_core_with_config_3(),
* see #LinphoneConfig for more information about factory and default config.
* On some platforms like Android or iOS you will need to give it the Context of your application.
*
* Once the #LinphoneCore is in state #LinphoneGlobalReady, use linphone_core_start().
*
* Once the #LinphoneCore is in state #LinphoneGlobalReady, use linphone_core_start().
* It will then go to state #LinphoneGlobalOn and from that you can start using it for calls and chat messages.
* It is recommended to add a #LinphoneCoreCbs listener using linphone_core_add_listener() to it to monitor different events.
*
*
* To be able to receive events from the network, you must schedule a call linphone_core_iterate() often, like every 20ms.
* On Android & iOS linphone_core_is_auto_iterate_enabled() is enabled by default so you don't have to worry about that unless you disable it
* using linphone_core_set_auto_iterate_enabled() or by setting in the [misc] section of your configuration auto_iterate=0.
* @warning Our API isn't thread-safe but also isn't blocking, so it is strongly recommend to always call our methods from the main thread.
*
*
* Once you don't need it anymore, call linphone_core_stop() and release the reference on it so it can gracefully shutdown.
* @ingroup initializing
*/
......@@ -409,7 +418,7 @@ typedef struct _LinphoneCore LinphoneCore;
/**
* @brief The factory is a singleton object devoted to the creation of all the objects
* of Liblinphone that cannot be created by #LinphoneCore itself.
*
*
* It is also used to configure a few behaviors before creating the #LinphoneCore, like the logs verbosity or collection.
* @ingroup initializing
*/
......@@ -419,9 +428,9 @@ typedef struct _LinphoneFactory LinphoneFactory;
* @brief That class holds all the callbacks which are called by #LinphoneCore.
*
* Once created, add your #LinphoneCoreCbs using linphone_core_add_listener().
* Keep a reference on it as long as you need it.
* Keep a reference on it as long as you need it.
* You can use linphone_core_remove_listener() to remove it but that isn't mandatory.
*
*
* The same applies to all listeners in our API.
* @ingroup initializing
*/
......@@ -433,10 +442,10 @@ typedef struct _LinphoneCoreCbs LinphoneCoreCbs;
/**
* @brief SIP transports & ports configuration object.
*
*
* Indicates which transport among UDP, TCP, TLS and DTLS should be enabled and if so on which port to listen.
* You can use special values like #LC_SIP_TRANSPORT_DISABLED (0), #LC_SIP_TRANSPORT_RANDOM (-1) and #LC_SIP_TRANSPORT_DONTBIND (-2).
*
*
* Once configuration is complete, use linphone_core_set_transports() to apply it.
* This will be saved in configuration file so you don't have to do it each time the #LinphoneCore starts.
* @ingroup initializing
......@@ -445,10 +454,10 @@ typedef struct _LinphoneTransports LinphoneTransports;
/**
* @brief Object describing policy regarding video streams establishments.
*
*
* Use linphone_video_activation_policy_set_automatically_accept() and linphone_video_activation_policy_set_automatically_initiate()
* to tell the Core to automatically accept or initiate video during calls.
*
*
* Even if disabled, you'll still be able to add it later while the call is running.
* @ingroup media_parameters
**/
......@@ -456,7 +465,7 @@ typedef struct _LinphoneVideoActivationPolicy LinphoneVideoActivationPolicy;
/**
* @brief This object represents a video definition, eg. it's width, it's height and possibly it's name.
*
*
* It is mostly used to configure the default video size sent by your camera during a video call with
* linphone_core_set_preferred_video_definition() method.
* @ingroup media_parameters
......@@ -544,7 +553,7 @@ typedef enum _LinphoneEcCalibratorStatus {
/**
* @brief Object representing full details about a signaling error or status.
*
*
* All #LinphoneErrorInfo object returned by the liblinphone API are readonly and transcients. For safety they must be used immediately
* after obtaining them. Any other function call to the liblinphone may change their content or invalidate the pointer.
* @ingroup misc
......@@ -553,7 +562,7 @@ typedef struct _LinphoneErrorInfo LinphoneErrorInfo;
/**
* @brief Object representing an event state, which is subcribed or published.
*
*
* @see linphone_core_publish()
* @see linphone_core_subscribe()
* @ingroup event_api
......@@ -595,7 +604,7 @@ typedef enum _LinphoneIceState {
/**
* @brief IM encryption engine.
*
*
* @see https://wiki.linphone.org/xwiki/wiki/public/view/Lib/Features/Instant%20Messaging%20Encryption%20Engine/
* @ingroup misc
* @donotwrap
......@@ -611,7 +620,7 @@ typedef struct _LinphoneImEncryptionEngineCbs LinphoneImEncryptionEngineCbs;
/**
* @brief Policy to use to send/receive instant messaging composing/delivery/display notifications.
*
*
* The sending of this information is done as in the RFCs 3994 (is_composing) and 5438 (imdn delivered/displayed).
* @ingroup chatroom
*/
......
......@@ -274,7 +274,7 @@ void FlexiAPIClient::prepareRequest(string path, string type, JsonParams params)
belle_http_request_listener_t *listener;
belle_http_request_t *req;
string uri = linphone_config_get_string(mCore->config, "sip", "flexiapi_url", NULL);
string uri = linphone_config_get_string(mCore->config, "account_creator", "url", NULL);
req = belle_http_request_create(type.c_str(), belle_generic_uri_parse(uri.append(path).c_str()),
belle_sip_header_content_type_create("application", "json"),
......
......@@ -234,7 +234,12 @@ LinphoneAccountCreatorStatus linphone_account_creator_is_account_exist_linphone_
fill_domain_and_algorithm_if_needed(creator);
if (creator->xmlrpc_session) {
LinphoneXmlRpcSession* xmlrpc_session = (LinphoneXmlRpcSession*)belle_sip_object_data_get(
BELLE_SIP_OBJECT(creator),
"xmlrpc_session"
);
if (xmlrpc_session) {
ms_debug("Account creator: is_account_exist (%s=%s, domain=%s)",
(creator->username) ? "username" : "phone number",
(creator->username) ? creator->username : creator->phone_number,
......@@ -245,7 +250,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_is_account_exist_linphone_
linphone_xml_rpc_request_add_string_arg(request, _get_domain(creator));
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _is_account_exist_response_cb);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
linphone_xml_rpc_session_send_request(xmlrpc_session, request);
linphone_xml_rpc_request_unref(request);
return LinphoneAccountCreatorStatusRequestOk;
......@@ -337,10 +342,15 @@ LinphoneAccountCreatorStatus linphone_account_creator_create_account_linphone_xm
return LinphoneAccountCreatorStatusMissingArguments;
}
if (creator->xmlrpc_session) {
LinphoneXmlRpcSession* xmlrpc_session = (LinphoneXmlRpcSession*)belle_sip_object_data_get(
BELLE_SIP_OBJECT(creator),
"xmlrpc_session"
);
if (xmlrpc_session) {
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _create_account_cb_custom);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
linphone_xml_rpc_session_send_request(xmlrpc_session, request);
linphone_xml_rpc_request_unref(request);
ms_free(identity);
return LinphoneAccountCreatorStatusRequestOk;
......@@ -386,6 +396,11 @@ LinphoneAccountCreatorStatus linphone_account_creator_delete_account_linphone_xm
linphone_proxy_config_get_domain(creator->proxy_cfg),
creator->algorithm);
LinphoneXmlRpcSession* xmlrpc_session = (LinphoneXmlRpcSession*)belle_sip_object_data_get(
BELLE_SIP_OBJECT(creator),
"xmlrpc_session"
);
LinphoneXmlRpcRequest *request = linphone_xml_rpc_request_new(LinphoneXmlRpcArgString, "delete_account");
linphone_xml_rpc_request_add_string_arg(request, creator->username ? creator->username : creator->phone_number);
linphone_xml_rpc_request_add_string_arg(request, creator->password);
......@@ -393,7 +408,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_delete_account_linphone_xm
linphone_xml_rpc_request_add_string_arg(request, creator->algorithm);
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _delete_linphone_account_response_cb);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
linphone_xml_rpc_session_send_request(xmlrpc_session, request);
linphone_xml_rpc_request_unref(request);
return LinphoneAccountCreatorStatusRequestOk;
......@@ -485,8 +500,13 @@ LinphoneAccountCreatorStatus linphone_account_creator_login_linphone_account_lin
return LinphoneAccountCreatorStatusMissingArguments;
}
LinphoneXmlRpcSession* xmlrpc_session = (LinphoneXmlRpcSession*)belle_sip_object_data_get(
BELLE_SIP_OBJECT(creator),
"xmlrpc_session"
);
fill_domain_and_algorithm_if_needed(creator);
if (creator->xmlrpc_session) {
if (xmlrpc_session) {
ms_debug("Account creator: recover_account_from_confirmation_key (username=%s, activation code=%s, domain=%s, algo=%s)",
creator->username ? creator->username : creator->phone_number,
creator->activation_code,
......@@ -500,7 +520,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_login_linphone_account_lin
linphone_xml_rpc_request_add_string_arg(request, creator->algorithm);
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _login_account_confirmation_key_cb_custom);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
linphone_xml_rpc_session_send_request(xmlrpc_session, request);
linphone_xml_rpc_request_unref(request);
return LinphoneAccountCreatorStatusRequestOk;
}
......@@ -547,8 +567,13 @@ LinphoneAccountCreatorStatus linphone_account_creator_activate_phone_account_lin
return LinphoneAccountCreatorStatusMissingArguments;
}
LinphoneXmlRpcSession* xmlrpc_session = (LinphoneXmlRpcSession*)belle_sip_object_data_get(
BELLE_SIP_OBJECT(creator),
"xmlrpc_session"
);
fill_domain_and_algorithm_if_needed(creator);
if (creator->xmlrpc_session) {
if (xmlrpc_session) {
ms_debug("Account creator: activate_account_phone (phone number=%s, username=%s, activation code=%s, domain=%s, algo=%s)",
creator->phone_number,
creator->username ? creator->username : creator->phone_number,
......@@ -564,7 +589,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_activate_phone_account_lin
linphone_xml_rpc_request_add_string_arg(request, creator->algorithm);
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _activate_account_cb_custom);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
linphone_xml_rpc_session_send_request(xmlrpc_session, request);
linphone_xml_rpc_request_unref(request);
return LinphoneAccountCreatorStatusRequestOk;
}
......@@ -582,8 +607,13 @@ LinphoneAccountCreatorStatus linphone_account_creator_activate_email_account_lin
return LinphoneAccountCreatorStatusMissingArguments;
}
LinphoneXmlRpcSession* xmlrpc_session = (LinphoneXmlRpcSession*)belle_sip_object_data_get(
BELLE_SIP_OBJECT(creator),
"xmlrpc_session"
);
fill_domain_and_algorithm_if_needed(creator);
if (creator->xmlrpc_session) {
if (xmlrpc_session) {
ms_debug("Account creator: activate_account_email (username=%s, activation code=%s, domain=%s, algo=%s)",
creator->username,
creator->activation_code,
......@@ -597,7 +627,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_activate_email_account_lin
linphone_xml_rpc_request_add_string_arg(request, creator->algorithm);
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _activate_account_cb_custom);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
linphone_xml_rpc_session_send_request(xmlrpc_session, request);
linphone_xml_rpc_request_unref(request);
return LinphoneAccountCreatorStatusRequestOk;
}
......@@ -647,6 +677,11 @@ LinphoneAccountCreatorStatus linphone_account_creator_get_confirmation_key_linph
linphone_proxy_config_get_domain(creator->proxy_cfg),
creator->algorithm);
LinphoneXmlRpcSession* xmlrpc_session = (LinphoneXmlRpcSession*)belle_sip_object_data_get(
BELLE_SIP_OBJECT(creator),
"xmlrpc_session"
);
LinphoneXmlRpcRequest *request = linphone_xml_rpc_request_new(LinphoneXmlRpcArgString, "get_confirmation_key");
linphone_xml_rpc_request_add_string_arg(request, creator->username);
linphone_xml_rpc_request_add_string_arg(request, ha1_for_passwd(creator->username, linphone_proxy_config_get_domain(creator->proxy_cfg), creator->password, creator->algorithm));
......@@ -654,7 +689,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_get_confirmation_key_linph
linphone_xml_rpc_request_add_string_arg(request, creator->algorithm);
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), get_linphone_confirmation_key_response_cb);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
linphone_xml_rpc_session_send_request(xmlrpc_session, request);
linphone_xml_rpc_request_unref(request);
return LinphoneAccountCreatorStatusRequestOk;
}
......@@ -687,8 +722,13 @@ LinphoneAccountCreatorStatus linphone_account_creator_is_account_activated_linph
return LinphoneAccountCreatorStatusMissingArguments;
}
LinphoneXmlRpcSession* xmlrpc_session = (LinphoneXmlRpcSession*)belle_sip_object_data_get(
BELLE_SIP_OBJECT(creator),
"xmlrpc_session"
);
fill_domain_and_algorithm_if_needed(creator);
if (creator->xmlrpc_session) {
if (xmlrpc_session) {
ms_debug("Account creator: is_account_activated (username=%s, domain=%s, algo=%s)",
creator->username ? creator->username : creator->phone_number,
_get_domain(creator),
......@@ -700,7 +740,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_is_account_activated_linph
linphone_xml_rpc_request_add_string_arg(request, creator->algorithm);
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _is_account_activated_cb_custom);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
linphone_xml_rpc_session_send_request(xmlrpc_session, request);
linphone_xml_rpc_request_unref(request);
ms_free(identity);
return LinphoneAccountCreatorStatusRequestOk;
......@@ -741,8 +781,13 @@ LinphoneAccountCreatorStatus linphone_account_creator_is_phone_number_used_linph
return LinphoneAccountCreatorStatusMissingArguments;
}
LinphoneXmlRpcSession* xmlrpc_session = (LinphoneXmlRpcSession*)belle_sip_object_data_get(
BELLE_SIP_OBJECT(creator),
"xmlrpc_session"
);
fill_domain_and_algorithm_if_needed(creator);
if (creator->xmlrpc_session) {
if (xmlrpc_session) {
ms_debug("Account creator: is_phone_number_used (phone number=%s, domain=%s)",
creator->phone_number,
_get_domain(creator));
......@@ -752,7 +797,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_is_phone_number_used_linph
linphone_xml_rpc_request_add_string_arg(request, _get_domain(creator));
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _is_phone_number_used_cb_custom);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
linphone_xml_rpc_session_send_request(xmlrpc_session, request);
linphone_xml_rpc_request_unref(request);
ms_free(identity);
return LinphoneAccountCreatorStatusRequestOk;
......@@ -793,8 +838,13 @@ LinphoneAccountCreatorStatus linphone_account_creator_link_phone_number_with_acc
return LinphoneAccountCreatorStatusMissingArguments;
}
LinphoneXmlRpcSession* xmlrpc_session = (LinphoneXmlRpcSession*)belle_sip_object_data_get(
BELLE_SIP_OBJECT(creator),
"xmlrpc_session"
);
fill_domain_and_algorithm_if_needed(creator);
if (creator->xmlrpc_session) {
if (xmlrpc_session) {
ms_debug("Account creator: link_phone_number_with_account (phone number=%s, username=%s, domain=%s, language=%s)",
creator->phone_number,
creator->username,
......@@ -808,7 +858,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_link_phone_number_with_acc
linphone_xml_rpc_request_add_string_arg(request, creator->language);
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _link_phone_number_with_account_cb_custom);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
linphone_xml_rpc_session_send_request(xmlrpc_session, request);
linphone_xml_rpc_request_unref(request);
return LinphoneAccountCreatorStatusRequestOk;
}
......@@ -843,8 +893,13 @@ LinphoneAccountCreatorStatus linphone_account_creator_is_account_linked_linphone
return LinphoneAccountCreatorStatusMissingArguments;
}
LinphoneXmlRpcSession* xmlrpc_session = (LinphoneXmlRpcSession*)belle_sip_object_data_get(
BELLE_SIP_OBJECT(creator),
"xmlrpc_session"
);
fill_domain_and_algorithm_if_needed(creator);
if (creator->xmlrpc_session) {
if (xmlrpc_session) {
ms_debug("Account creator: is_account_linked (username=%s, domain=%s)",
creator->username,
_get_domain(creator));
......@@ -854,7 +909,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_is_account_linked_linphone
linphone_xml_rpc_request_add_string_arg(request, _get_domain(creator));
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _get_phone_number_for_account_cb_custom);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
linphone_xml_rpc_session_send_request(xmlrpc_session, request);
linphone_xml_rpc_request_unref(request);
return LinphoneAccountCreatorStatusRequestOk;
}
......@@ -889,8 +944,13 @@ LinphoneAccountCreatorStatus linphone_account_creator_activate_phone_number_link
return LinphoneAccountCreatorStatusMissingArguments;
}
LinphoneXmlRpcSession* xmlrpc_session = (LinphoneXmlRpcSession*)belle_sip_object_data_get(
BELLE_SIP_OBJECT(creator),
"xmlrpc_session"
);
fill_domain_and_algorithm_if_needed(creator);
if (creator->xmlrpc_session) {
if (xmlrpc_session) {
ms_debug("Account creator: activate_phone_number_link (phone number=%s, username=%s, activation code=%s, domain=%s, algo=%s)",
creator->phone_number,
creator->username,
......@@ -907,7 +967,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_activate_phone_number_link
linphone_xml_rpc_request_add_string_arg(request, creator->algorithm);
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _activate_phone_number_link_cb_custom);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
linphone_xml_rpc_session_send_request(xmlrpc_session, request);
linphone_xml_rpc_request_unref(request);
return LinphoneAccountCreatorStatusRequestOk;
}
......@@ -950,8 +1010,13 @@ LinphoneAccountCreatorStatus linphone_account_creator_recover_phone_account_linp
return LinphoneAccountCreatorStatusMissingArguments;