From b41b920426e2d4ab2dbc6aa6e5ac6423023ca1e7 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Wed, 15 Mar 2017 17:25:51 +0100 Subject: [PATCH] Refactoring of account creator + tester of account creator --- coreapi/account_creator.c | 1319 ++++++++++++++++------------ coreapi/private.h | 89 +- gtk/setupwizard.c | 42 +- include/linphone/account_creator.h | 755 ++++++++++------ include/linphone/types.h | 143 ++- tester/account_creator_tester.c | 1260 +++++++++++++++++++++++--- tester/rcfiles/account_creator_rc | 5 +- 7 files changed, 2555 insertions(+), 1058 deletions(-) diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index a5dc42705..32048b17d 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -1,6 +1,6 @@ /* linphone -Copyright (C) 2010-2015 Belledonne Communications SARL +Copyright (C) 2010-2017 Belledonne Communications SARL This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,188 +25,33 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include -BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneAccountCreatorCbs); +BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneAccountCreatorRequestCbs); -BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreatorCbs, belle_sip_object_t, +BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreatorRequestCbs, belle_sip_object_t, NULL, // destroy NULL, // clone NULL, // marshal FALSE ); +BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneAccountCreatorResponseCbs); + +BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreatorResponseCbs, belle_sip_object_t, + NULL, // destroy + NULL, // clone + NULL, // marshal + FALSE +); + +/************************** Start Misc **************************/ static const char* ha1_for_passwd(const char* username, const char* realm, const char* passwd) { static char ha1[33]; sal_auth_compute_ha1(username, realm, passwd, ha1); return ha1; } -static LinphoneAccountCreatorCbs * linphone_account_creator_cbs_new(void) { - return belle_sip_object_new(LinphoneAccountCreatorCbs); -} - -LinphoneAccountCreatorCbs * linphone_account_creator_cbs_ref(LinphoneAccountCreatorCbs *cbs) { - belle_sip_object_ref(cbs); - return cbs; -} - -void linphone_account_creator_cbs_unref(LinphoneAccountCreatorCbs *cbs) { - belle_sip_object_unref(cbs); -} - -void *linphone_account_creator_cbs_get_user_data(const LinphoneAccountCreatorCbs *cbs) { - return cbs->user_data; -} - -void linphone_account_creator_cbs_set_user_data(LinphoneAccountCreatorCbs *cbs, void *ud) { - cbs->user_data = ud; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_update_hash(const LinphoneAccountCreatorCbs *cbs) { - return cbs->update_hash; -} - -void linphone_account_creator_cbs_set_update_hash(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->update_hash = cb; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_used(const LinphoneAccountCreatorCbs *cbs) { - return cbs->is_account_used; -} - -void linphone_account_creator_cbs_set_is_account_used(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->is_account_used = cb; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_create_account(const LinphoneAccountCreatorCbs *cbs) { - return cbs->create_account; -} - -void linphone_account_creator_cbs_set_create_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->create_account = cb; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_activate_account(const LinphoneAccountCreatorCbs *cbs) { - return cbs->activate_account; -} - -void linphone_account_creator_cbs_set_activate_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->activate_account = cb; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_link_phone_number_with_account(const LinphoneAccountCreatorCbs *cbs) { - return cbs->link_phone_number_with_account; -} - -void linphone_account_creator_cbs_set_link_phone_number_with_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->link_phone_number_with_account = cb; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_activate_phone_number_link(const LinphoneAccountCreatorCbs *cbs) { - return cbs->activate_phone_number_link; -} - -void linphone_account_creator_cbs_set_activate_phone_number_link(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->activate_phone_number_link = cb; -} - -void linphone_account_creator_cbs_set_is_account_linked(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->is_account_linked = cb; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_linked(const LinphoneAccountCreatorCbs *cbs) { - return cbs->is_account_linked; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_activated(const LinphoneAccountCreatorCbs *cbs) { - return cbs->is_account_activated; -} - -void linphone_account_creator_cbs_set_is_account_activated(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->is_account_activated = cb; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_recover_phone_account(const LinphoneAccountCreatorCbs *cbs) { - return cbs->recover_phone_account; -} - -void linphone_account_creator_cbs_set_recover_phone_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->recover_phone_account = cb; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_phone_number_used(const LinphoneAccountCreatorCbs *cbs) { - return cbs->is_phone_number_used; -} - -void linphone_account_creator_cbs_set_is_phone_number_used(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->is_phone_number_used = cb; -} - - -static void _linphone_account_creator_destroy(LinphoneAccountCreator *creator) { - linphone_xml_rpc_session_release(creator->xmlrpc_session); /*this will drop all pending requests if any*/ - linphone_account_creator_cbs_unref(creator->callbacks); - if (creator->username) ms_free(creator->username); - if (creator->password) ms_free(creator->password); - if (creator->ha1) ms_free(creator->ha1); - if (creator->domain) ms_free(creator->domain); - if (creator->route) ms_free(creator->route); - if (creator->email) ms_free(creator->email); - if (creator->display_name) ms_free(creator->display_name); - if (creator->phone_country_code) ms_free(creator->phone_country_code); - if (creator->activation_code) ms_free(creator->activation_code); - if (creator->language) ms_free(creator->language); -} - -BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneAccountCreator); - -BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreator, belle_sip_object_t, - (belle_sip_object_destroy_t)_linphone_account_creator_destroy, - NULL, // clone - NULL, // marshal - FALSE -); - - -LinphoneAccountCreator * linphone_account_creator_new(LinphoneCore *core, const char *xmlrpc_url) { - LinphoneAccountCreator *creator; - const char* domain = lp_config_get_string(core->config, "assistant", "domain", NULL); - creator = belle_sip_object_new(LinphoneAccountCreator); - creator->callbacks = linphone_account_creator_cbs_new(); - creator->core = core; - creator->xmlrpc_session = linphone_xml_rpc_session_new(core, xmlrpc_url); - if (domain) { - linphone_account_creator_set_domain(creator, domain); - } - return creator; -} - -LinphoneAccountCreator * linphone_account_creator_ref(LinphoneAccountCreator *creator) { - belle_sip_object_ref(creator); - return creator; -} - -void linphone_account_creator_unref(LinphoneAccountCreator *creator) { - belle_sip_object_unref(creator); -} - -void *linphone_account_creator_get_user_data(const LinphoneAccountCreator *creator) { - return creator->user_data; -} - -void linphone_account_creator_set_user_data(LinphoneAccountCreator *creator, void *ud) { - creator->user_data = ud; -} - -static LinphoneAccountCreatorStatus validate_uri(const char* username, const char* domain, const char* route, const char* display_name) { +static unsigned int validate_uri(LinphoneCore *lc, LinphoneProxyConfig *proxy, const char* username, const char* display_name) { LinphoneAddress* addr; - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorOK; - LinphoneProxyConfig* proxy = linphone_proxy_config_new(); - linphone_proxy_config_set_identity(proxy, "sip:userame@domain.com"); - - if (route && linphone_proxy_config_set_route(proxy, route) != 0) { - status = LinphoneAccountCreatorRouteInvalid; - goto end; - } if (username) { addr = linphone_proxy_config_normalize_sip_uri(proxy, username); @@ -214,40 +59,29 @@ static LinphoneAccountCreatorStatus validate_uri(const char* username, const cha addr = linphone_address_clone(linphone_proxy_config_get_identity_address(proxy)); } - if (addr == NULL) { - status = LinphoneAccountCreatorUsernameInvalid; - goto end; - } - - if (domain && linphone_address_set_domain(addr, domain) != 0) { - status = LinphoneAccountCreatorDomainInvalid; - } + if (addr == NULL) + return 1; if (display_name && (!strlen(display_name) || linphone_address_set_display_name(addr, display_name) != 0)) { - status = LinphoneAccountCreatorDisplayNameInvalid; + linphone_address_unref(addr); + return 1; } + linphone_address_unref(addr); -end: - linphone_proxy_config_destroy(proxy); - return status; + return 0; } static char* _get_identity(const LinphoneAccountCreator *creator) { char *identity = NULL; - if ((creator->username || creator->phone_number) && creator->domain) { + if ((creator->username || creator->phone_number)) { //we must escape username - LinphoneProxyConfig* proxy = linphone_proxy_config_new(); + LinphoneProxyConfig* proxy = creator->proxy_cfg; LinphoneAddress* addr; - // creator->domain may contain some port or some transport (eg. toto.org:443;transport=tcp), - // we will accept that - char * tmpidentity = ms_strdup_printf("sip:username@%s", creator->domain); - linphone_proxy_config_set_identity(proxy, tmpidentity); - ms_free(tmpidentity); + addr = linphone_proxy_config_normalize_sip_uri(proxy, creator->username ? creator->username : creator->phone_number); identity = linphone_address_as_string(addr); linphone_address_unref(addr); - linphone_proxy_config_destroy(proxy); } return identity; } @@ -271,258 +105,23 @@ static bool_t is_matching_regex(const char *entry, const char* regex) { #endif } -LinphoneAccountCreatorStatus linphone_account_creator_set_username(LinphoneAccountCreator *creator, const char *username) { - int min_length = lp_config_get_int(creator->core->config, "assistant", "username_min_length", -1); - int fixed_length = lp_config_get_int(creator->core->config, "assistant", "username_length", -1); - int max_length = lp_config_get_int(creator->core->config, "assistant", "username_max_length", -1); - bool_t use_phone_number = lp_config_get_int(creator->core->config, "assistant", "use_phone_number", 0); - const char* regex = lp_config_get_string(creator->core->config, "assistant", "username_regex", 0); - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorOK; - if (!username) { - creator->username = NULL; - return LinphoneAccountCreatorOK; - } else if (min_length > 0 && strlen(username) < (size_t)min_length) { - return LinphoneAccountCreatorUsernameTooShort; - } else if (max_length > 0 && strlen(username) > (size_t)max_length) { - return LinphoneAccountCreatorUsernameTooLong; - } else if (fixed_length > 0 && strlen(username) != (size_t)fixed_length) { - return LinphoneAccountCreatorUsernameInvalidSize; - } else if (use_phone_number && !linphone_proxy_config_is_phone_number(NULL, username)) { - return LinphoneAccountCreatorUsernameInvalid; - } else if (regex && !is_matching_regex(username, regex)) { - return LinphoneAccountCreatorUsernameInvalid; - } else if ((status = validate_uri(username, NULL, NULL, NULL)) != LinphoneAccountCreatorOK) { - return status; - } - - set_string(&creator->username, username, TRUE); - - return LinphoneAccountCreatorOK; -} - -const char * linphone_account_creator_get_username(const LinphoneAccountCreator *creator) { - return creator->username; -} - - -LinphoneAccountCreatorStatus linphone_account_creator_set_phone_number(LinphoneAccountCreator *creator, const char *phone_number, const char *country_code) { - char *normalized_phone_number; - LinphoneAccountCreatorStatus return_status; - if (!phone_number || !country_code) { - if (!phone_number && !country_code) { - creator->phone_number = NULL; - creator->phone_country_code = NULL; - return LinphoneAccountCreatorOK; - } else { - return LinphoneAccountCreatorPhoneNumberInvalid; - } - } else { - LinphoneProxyConfig *numCfg = linphone_proxy_config_new(); - creator->phone_country_code = ms_strdup(country_code[0] == '+' ? &country_code[1] : country_code); - linphone_proxy_config_set_dial_prefix(numCfg, creator->phone_country_code); - normalized_phone_number = linphone_proxy_config_normalize_phone_number(numCfg, phone_number); - linphone_proxy_config_destroy(numCfg); - if (!normalized_phone_number) { - return LinphoneAccountCreatorPhoneNumberInvalid; - } - - // if phone is valid, we lastly want to check that length is OK - { - const LinphoneDialPlan* plan = linphone_dial_plan_by_ccc(creator->phone_country_code); - int size = (int)strlen(phone_number); - if (linphone_dial_plan_is_generic(plan)) { - return_status = LinphoneAccountCreatorCountryCodeInvalid; - goto end; - } - if (size < plan->nnl - 1) { - return_status = LinphoneAccountCreatorPhoneNumberTooShort; - goto end; - } else if (size > plan->nnl + 1) { - return_status = LinphoneAccountCreatorPhoneNumberTooLong; - goto end; - } - } - } - set_string(&creator->phone_number, normalized_phone_number, TRUE); - return_status = LinphoneAccountCreatorOK; - -end: - ms_free(normalized_phone_number); - return return_status; -} - -const char * linphone_account_creator_get_phone_number(const LinphoneAccountCreator *creator) { - return creator->phone_number; -} - -LinphoneAccountCreatorStatus linphone_account_creator_set_password(LinphoneAccountCreator *creator, const char *password){ - int min_length = lp_config_get_int(creator->core->config, "assistant", "password_min_length", -1); - int max_length = lp_config_get_int(creator->core->config, "assistant", "password_max_length", -1); - if (!password) { - creator->password = NULL; - return LinphoneAccountCreatorPasswordTooShort; - } - if (min_length > 0 && strlen(password) < (size_t)min_length) { - return LinphoneAccountCreatorPasswordTooShort; - } else if (max_length > 0 && strlen(password) > (size_t)max_length) { - return LinphoneAccountCreatorPasswordTooLong; - } - set_string(&creator->password, password, FALSE); - return LinphoneAccountCreatorOK; -} - -const char * linphone_account_creator_get_password(const LinphoneAccountCreator *creator) { - return creator->password; -} - -static void _password_updated_cb(LinphoneXmlRpcRequest *request) { - LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->update_hash != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; - const char* resp = linphone_xml_rpc_request_get_string_response(request); - if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { - if (strcmp(resp, "OK") == 0) { - status = LinphoneAccountCreatorOK; - } else if (strcmp(resp, "ERROR_PASSWORD_DOESNT_MATCH") == 0) { - status = LinphoneAccountCreatorAccountNotExist; - } else { - status = LinphoneAccountCreatorErrorServer; - } - } - creator->callbacks->update_hash(creator, status, resp); - } -} - -LinphoneAccountCreatorStatus linphone_account_creator_update_password(LinphoneAccountCreator *creator, const char *new_pwd){ - LinphoneXmlRpcRequest *request; - char *identity = _get_identity(creator); - if (!identity || (!creator->username && !creator->phone_number - && !creator->domain && (!creator->password || !creator->ha1))) { - if (creator->callbacks->update_hash != NULL) { - creator->callbacks->update_hash(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters"); - } - return LinphoneAccountCreatorReqFailed; - } - - const char * username = creator->username ? creator->username : creator->phone_number; - const char * ha1 = ms_strdup(creator->ha1 ? creator->ha1 : ha1_for_passwd(username, creator->domain, creator->password) ); - const char * new_ha1 = ms_strdup(ha1_for_passwd(username, creator->domain, new_pwd)); - - request = linphone_xml_rpc_request_new_with_args("update_hash", LinphoneXmlRpcArgString, - LinphoneXmlRpcArgString, username, - LinphoneXmlRpcArgString, ha1, - LinphoneXmlRpcArgString, new_ha1, - LinphoneXmlRpcArgString, creator->domain, - LinphoneXmlRpcArgNone); - - linphone_xml_rpc_request_set_user_data(request, creator); - linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _password_updated_cb); - linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); - linphone_xml_rpc_request_unref(request); - - return LinphoneAccountCreatorOK; -} - -LinphoneAccountCreatorStatus linphone_account_creator_set_ha1(LinphoneAccountCreator *creator, const char *ha1){ - set_string(&creator->ha1, ha1, FALSE); - return LinphoneAccountCreatorOK; -} - -const char * linphone_account_creator_get_ha1(const LinphoneAccountCreator *creator) { - return creator->ha1; -} - -LinphoneAccountCreatorStatus linphone_account_creator_set_activation_code(LinphoneAccountCreator *creator, const char *activation_code){ - set_string(&creator->activation_code, activation_code, FALSE); - return LinphoneAccountCreatorOK; -} - -LinphoneAccountCreatorStatus linphone_account_creator_set_language(LinphoneAccountCreator *creator, const char *lang) { - set_string(&creator->language, lang, FALSE); - return LinphoneAccountCreatorOK; -} - -LinphoneAccountCreatorStatus linphone_account_creator_set_transport(LinphoneAccountCreator *creator, LinphoneTransportType transport){ - if (!linphone_core_sip_transport_supported(creator->core, transport)) { - return LinphoneAccountCreatorTransportNotSupported; - } - creator->transport = transport; - return LinphoneAccountCreatorOK; -} - -LinphoneTransportType linphone_account_creator_get_transport(const LinphoneAccountCreator *creator) { - return creator->transport; -} - -LinphoneAccountCreatorStatus linphone_account_creator_set_domain(LinphoneAccountCreator *creator, const char *domain){ - if (validate_uri(NULL, domain, NULL, NULL) != 0) { - return LinphoneAccountCreatorDomainInvalid; - } - set_string(&creator->domain, domain, TRUE); - return LinphoneAccountCreatorOK; -} - -const char * linphone_account_creator_get_domain(const LinphoneAccountCreator *creator) { - return creator->domain; -} - -LinphoneAccountCreatorStatus linphone_account_creator_set_route(LinphoneAccountCreator *creator, const char *route) { - if (validate_uri(NULL, NULL, route, NULL) != 0) { - return LinphoneAccountCreatorRouteInvalid; - } - set_string(&creator->route, route, TRUE); - return LinphoneAccountCreatorOK; -} - -const char * linphone_account_creator_get_route(const LinphoneAccountCreator *creator) { - return creator->route; -} - -LinphoneAccountCreatorStatus linphone_account_creator_set_display_name(LinphoneAccountCreator *creator, const char *display_name) { - if (validate_uri(NULL, NULL, NULL, display_name) != 0) { - return LinphoneAccountCreatorDisplayNameInvalid; - } - set_string(&creator->display_name, display_name, FALSE); - return LinphoneAccountCreatorOK; -} - -const char * linphone_account_creator_get_display_name(const LinphoneAccountCreator *creator) { - return creator->display_name; -} - -LinphoneAccountCreatorStatus linphone_account_creator_set_email(LinphoneAccountCreator *creator, const char *email) { - if (!is_matching_regex(email, "^.+@.+\\.[A-Za-z]{2}[A-Za-z]*$")) { - return LinphoneAccountCreatorEmailInvalid; - } - set_string(&creator->email, email, TRUE); - return LinphoneAccountCreatorOK; -} - -const char * linphone_account_creator_get_email(const LinphoneAccountCreator *creator) { - return creator->email; -} - -LinphoneAccountCreatorCbs * linphone_account_creator_get_callbacks(const LinphoneAccountCreator *creator) { - return creator->callbacks; -} - LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCreator *creator) { LinphoneAuthInfo *info; - LinphoneProxyConfig *cfg = linphone_core_create_proxy_config(creator->core); + LinphoneProxyConfig *cfg = creator->proxy_cfg; char *identity_str = _get_identity(creator); - LinphoneAddress *identity = linphone_address_new(identity_str); - char *route = NULL; - char *domain = NULL; + LinphoneAddress *identity = linphone_address_new(identity_str); + // char *route = NULL; + // char *domain = NULL; ms_free(identity_str); if (creator->display_name) { linphone_address_set_display_name(identity, creator->display_name); } - if (creator->route) { - route = ms_strdup_printf("%s;transport=%s", creator->route, linphone_transport_to_string(creator->transport)); - } - if (creator->domain) { - domain = ms_strdup_printf("%s;transport=%s", creator->domain, linphone_transport_to_string(creator->transport)); - } + // if (creator->route) { + // route = ms_strdup_printf("%s;transport=%s", creator->route, linphone_transport_to_string(creator->transport)); + // } + // if (creator->domain) { + // domain = ms_strdup_printf("%s;transport=%s", creator->domain, linphone_transport_to_string(creator->transport)); + // } linphone_proxy_config_set_identity_address(cfg, identity); if (creator->phone_country_code) { linphone_proxy_config_set_dial_prefix(cfg, creator->phone_country_code); @@ -532,14 +131,14 @@ LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCr snprintf(buff, sizeof(buff), "%d", dial_prefix_number); linphone_proxy_config_set_dial_prefix(cfg, buff); } - if (linphone_proxy_config_get_server_addr(cfg) == NULL) - linphone_proxy_config_set_server_addr(cfg, domain); - if (linphone_proxy_config_get_route(cfg) == NULL) - linphone_proxy_config_set_route(cfg, route); + // if (linphone_proxy_config_get_server_addr(cfg) == NULL) + // linphone_proxy_config_set_server_addr(cfg, domain); + // if (linphone_proxy_config_get_route(cfg) == NULL) + // linphone_proxy_config_set_route(cfg, route); linphone_proxy_config_enable_publish(cfg, FALSE); linphone_proxy_config_enable_register(cfg, TRUE); - if (strcmp(creator->domain, "sip.linphone.org") == 0) { + if (strcmp(linphone_proxy_config_get_realm(creator->proxy_cfg), "sip.linphone.org") == 0) { linphone_proxy_config_enable_avpf(cfg, TRUE); // If account created on sip.linphone.org, we configure linphone to use TLS by default if (linphone_core_sip_transport_supported(creator->core, LinphoneTransportTls)) { @@ -575,66 +174,587 @@ LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCr linphone_proxy_config_unref(cfg); return NULL; } +/************************** End Misc **************************/ + +/************************** Start Account Creator requests_cbs **************************/ +static LinphoneAccountCreatorRequestCbs * linphone_account_creator_requests_cbs_new(void) { + return belle_sip_object_new(LinphoneAccountCreatorRequestCbs); +} + +LinphoneAccountCreatorRequestCbs * linphone_account_creator_requests_cbs_ref(LinphoneAccountCreatorRequestCbs *requests_cbs) { + belle_sip_object_ref(requests_cbs); + return requests_cbs; +} + +void linphone_account_creator_requests_cbs_unref(LinphoneAccountCreatorRequestCbs *requests_cbs) { + belle_sip_object_unref(requests_cbs); +} + +void *linphone_account_creator_requests_cbs_get_user_data(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->user_data; +} + +void linphone_account_creator_requests_cbs_set_user_data(LinphoneAccountCreatorRequestCbs *requests_cbs, void *ud) { + requests_cbs->user_data = ud; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_create_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->create_account_request_cb; +} + +void linphone_account_creator_requests_cbs_set_create_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->create_account_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_exist_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->is_account_exist_request_cb; +} + +void linphone_account_creator_requests_cbs_set_is_account_exist_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->is_account_exist_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_activate_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->activate_account_request_cb; +} + +void linphone_account_creator_requests_cbs_set_activate_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->activate_account_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_activated_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->is_account_activated_request_cb; +} + +void linphone_account_creator_requests_cbs_set_is_account_activated_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->is_account_activated_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_link_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->link_account_request_cb; +} + +void linphone_account_creator_requests_cbs_set_link_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->link_account_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_alias_used_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->is_alias_used_request_cb; +} + +void linphone_account_creator_requests_cbs_set_is_alias_used_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->is_alias_used_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_linked_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->is_account_linked_request_cb; +} + +void linphone_account_creator_requests_cbs_set_is_account_linked_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->is_account_linked_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_recover_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->is_account_linked_request_cb; +} + +void linphone_account_creator_requests_cbs_set_recover_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->recover_account_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_update_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->update_account_request_cb; +} + +void linphone_account_creator_requests_cbs_set_update_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->update_account_request_cb = cb; +} + +/************************** End Account Creator requests_cbs **************************/ + +/************************** Start Account Creator Cbs **************************/ + +static LinphoneAccountCreatorResponseCbs * linphone_account_creator_reponses_cbs_new(void) { + return belle_sip_object_new(LinphoneAccountCreatorResponseCbs); +} + +LinphoneAccountCreatorResponseCbs * linphone_account_creator_responses_cbs_ref(LinphoneAccountCreatorResponseCbs *responses_cbs) { + belle_sip_object_ref(responses_cbs); + return responses_cbs; +} + +void linphone_account_creator_responses_cbs_unref(LinphoneAccountCreatorResponseCbs *responses_cbs) { + belle_sip_object_unref(responses_cbs); +} + +void *linphone_account_creator_responses_cbs_get_user_data(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->user_data; +} + +void linphone_account_creator_responses_cbs_set_user_data(LinphoneAccountCreatorResponseCbs *responses_cbs, void *ud) { + responses_cbs->user_data = ud; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_create_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->create_account_response_cb; +} + +void linphone_account_creator_responses_cbs_set_create_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->create_account_response_cb = cb; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_account_exist_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->is_account_exist_response_cb; +} + +void linphone_account_creator_responses_cbs_set_is_account_exist_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->is_account_exist_response_cb = cb; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_activate_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->activate_account_response_cb; +} + +void linphone_account_creator_responses_cbs_set_activate_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->activate_account_response_cb = cb; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_account_activated_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->is_account_activated_response_cb; +} + +void linphone_account_creator_responses_cbs_set_is_account_activated_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->is_account_activated_response_cb = cb; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_link_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->link_account_response_cb; +} + +void linphone_account_creator_responses_cbs_set_link_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->link_account_response_cb = cb; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_activate_alias_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->activate_alias_response_cb; +} + +void linphone_account_creator_responses_cbs_set_activate_alias_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->activate_alias_response_cb = cb; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_alias_used_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->is_alias_used_response_cb; +} + +void linphone_account_creator_responses_cbs_set_is_alias_used_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->is_alias_used_response_cb = cb; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_account_linked_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->is_account_linked_response_cb; +} + +void linphone_account_creator_responses_cbs_set_is_account_linked_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->is_account_linked_response_cb = cb; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_recover_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->recover_account_response_cb; +} + +void linphone_account_creator_responses_cbs_set_recover_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->recover_account_response_cb = cb; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_update_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->update_account_response_cb; +} + +void linphone_account_creator_responses_cbs_set_update_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->update_account_response_cb = cb; +} +/************************** End Account Creator Cbs **************************/ + +/************************** Start Account Creator data **************************/ +static void _linphone_account_creator_destroy(LinphoneAccountCreator *creator) { + linphone_xml_rpc_session_release(creator->xmlrpc_session); /*this will drop all pending requests if any*/ + linphone_account_creator_requests_cbs_unref(creator->requests_cbs); + linphone_account_creator_responses_cbs_unref(creator->responses_cbs); + linphone_proxy_config_destroy(creator->proxy_cfg); + if (creator->username) ms_free(creator->username); + if (creator->display_name) ms_free(creator->display_name); + if (creator->password) ms_free(creator->password); + if (creator->ha1) ms_free(creator->ha1); + if (creator->phone_number) ms_free(creator->phone_number); + if (creator->phone_country_code) ms_free(creator->phone_country_code); + if (creator->email) ms_free(creator->email); + if (creator->language) ms_free(creator->language); + if (creator->activation_code) ms_free(creator->activation_code); +} + +BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneAccountCreator); + +BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreator, belle_sip_object_t, + (belle_sip_object_destroy_t)_linphone_account_creator_destroy, + NULL, // clone + NULL, // marshal + FALSE +); + +LinphoneAccountCreator * linphone_account_creator_new(LinphoneCore *core, const char *xmlrpc_url) { + LinphoneAccountCreator *creator; + creator = belle_sip_object_new(LinphoneAccountCreator); + creator->requests_cbs = linphone_account_creator_requests_cbs_new(); + creator->responses_cbs = linphone_account_creator_reponses_cbs_new(); + creator->core = core; + creator->xmlrpc_session = linphone_xml_rpc_session_new(core, xmlrpc_url); + creator->proxy_cfg = linphone_core_create_proxy_config(core); + linphone_account_creator_set_linphone_impl(creator); + return creator; +} + +void linphone_account_creator_set_linphone_impl(LinphoneAccountCreator *creator) { + creator->requests_cbs->create_account_request_cb = linphone_account_creator_create_account_custom; + creator->requests_cbs->is_account_exist_request_cb = linphone_account_creator_is_account_exist_custom; + creator->requests_cbs->activate_account_request_cb = linphone_account_creator_activate_account_custom; + creator->requests_cbs->is_account_activated_request_cb = linphone_account_creator_is_account_activated_custom; + creator->requests_cbs->link_account_request_cb = linphone_account_creator_link_phone_number_with_account_custom; + creator->requests_cbs->activate_alias_request_cb = linphone_account_creator_activate_phone_number_link_custom; + creator->requests_cbs->is_alias_used_request_cb = linphone_account_creator_is_phone_number_used_custom; + creator->requests_cbs->is_account_linked_request_cb = linphone_account_creator_is_account_linked_custom; + creator->requests_cbs->recover_account_request_cb = linphone_account_creator_recover_phone_account_custom; + creator->requests_cbs->update_account_request_cb = linphone_account_creator_update_password_custom; +} + +LinphoneAccountCreator * linphone_account_creator_ref(LinphoneAccountCreator *creator) { + belle_sip_object_ref(creator); + return creator; +} + +void linphone_account_creator_unref(LinphoneAccountCreator *creator) { + belle_sip_object_unref(creator); +} + +void *linphone_account_creator_get_user_data(const LinphoneAccountCreator *creator) { + return creator->user_data; +} + +void linphone_account_creator_set_user_data(LinphoneAccountCreator *creator, void *ud) { + creator->user_data = ud; +} + +LinphoneUsernameCheck linphone_account_creator_set_username(LinphoneAccountCreator *creator, const char *username) { + int min_length = lp_config_get_int(creator->core->config, "assistant", "username_min_length", -1); + int max_length = lp_config_get_int(creator->core->config, "assistant", "username_max_length", -1); + bool_t use_phone_number = lp_config_get_int(creator->core->config, "assistant", "use_phone_number", 0); + const char* regex = lp_config_get_string(creator->core->config, "assistant", "username_regex", 0); + if (!username) { + creator->username = NULL; + return LinphoneUsernameOk; + } else if (min_length > 0 && strlen(username) < (size_t)min_length) { + return LinphoneUsernameTooShort; + } else if (max_length > 0 && strlen(username) > (size_t)max_length) { + return LinphoneUsernameTooLong; + } else if (use_phone_number && !linphone_proxy_config_is_phone_number(NULL, username)) { + return LinphoneUsernameInvalid; + } else if (regex && !is_matching_regex(username, regex)) { + return LinphoneUsernameInvalidCharacters; + } else if (validate_uri(creator->core, creator->proxy_cfg, username, NULL) != 0) { + return LinphoneUsernameInvalid; + } + + set_string(&creator->username, username, TRUE); + return LinphoneUsernameOk; +} + +const char * linphone_account_creator_get_username(const LinphoneAccountCreator *creator) { + return creator->username; +} + +LinphonePhoneNumberMask linphone_account_creator_set_phone_number(LinphoneAccountCreator *creator, const char *phone_number, const char *country_code) { + char *normalized_phone_number; + LinphonePhoneNumberMask return_status = 0; + if (!phone_number || !country_code) { + if (!phone_number && !country_code) { + creator->phone_number = NULL; + creator->phone_country_code = NULL; + return (LinphonePhoneNumberMask)LinphonePhoneNumberOk; + } else { + return (LinphonePhoneNumberMask)LinphonePhoneNumberInvalid; + } + } else { + LinphoneProxyConfig *numCfg = creator->proxy_cfg; + creator->phone_country_code = ms_strdup(country_code[0] == '+' ? &country_code[1] : country_code); + linphone_proxy_config_set_dial_prefix(numCfg, creator->phone_country_code); + normalized_phone_number = linphone_proxy_config_normalize_phone_number(numCfg, phone_number); + if (!normalized_phone_number) { + return LinphonePhoneNumberInvalid; + } + + // if phone is valid, we lastly want to check that length is OK + { + const LinphoneDialPlan* plan = linphone_dial_plan_by_ccc(creator->phone_country_code); + int size = (int)strlen(phone_number); + if (linphone_dial_plan_is_generic(plan)) { + return_status = LinphonePhoneNumberCountryCodeInvalid; + } + if (size < plan->nnl - 1) { + return_status += LinphonePhoneNumberTooShort; + goto end; + } else if (size > plan->nnl + 1) { + return_status += LinphonePhoneNumberTooLong; + goto end; + } else if (return_status & LinphonePhoneNumberCountryCodeInvalid) { + goto end; + } + } + } + set_string(&creator->phone_number, normalized_phone_number, TRUE); + return_status = LinphonePhoneNumberOk; +end: + ms_free(normalized_phone_number); + return return_status; +} + +const char * linphone_account_creator_get_phone_number(const LinphoneAccountCreator *creator) { + return creator->phone_number; +} + +LinphonePasswordCheck linphone_account_creator_set_password(LinphoneAccountCreator *creator, const char *password) { + int min_length = lp_config_get_int(creator->core->config, "assistant", "password_min_length", -1); + int max_length = lp_config_get_int(creator->core->config, "assistant", "password_max_length", -1); + if (!password) { + creator->password = NULL; + return LinphonePasswordTooShort; + } + if (min_length > 0 && strlen(password) < (size_t)min_length) { + return LinphonePasswordTooShort; + } else if (max_length > 0 && strlen(password) > (size_t)max_length) { + return LinphonePasswordTooLong; + } + set_string(&creator->password, password, FALSE); + return LinphonePasswordOk; +} + +const char * linphone_account_creator_get_password(const LinphoneAccountCreator *creator) { + return creator->password; +} + +LinphonePasswordCheck linphone_account_creator_set_ha1(LinphoneAccountCreator *creator, const char *ha1){ + set_string(&creator->ha1, ha1, FALSE); + return LinphonePasswordOk; +} + +const char * linphone_account_creator_get_ha1(const LinphoneAccountCreator *creator) { + return creator->ha1; +} + +LinphoneActivationCodeCheck linphone_account_creator_set_activation_code(LinphoneAccountCreator *creator, const char *activation_code){ + set_string(&creator->activation_code, activation_code, FALSE); + return LinphoneActivationCodeOk; +} + +const char * linphone_account_creator_get_activation_code(const LinphoneAccountCreator *creator) { + return creator->activation_code; +} + +LinphoneLanguageCheck linphone_account_creator_set_language(LinphoneAccountCreator *creator, const char *lang) { + set_string(&creator->language, lang, FALSE); + return LinphoneLanguageOk; +} + +const char * linphone_account_creator_get_language(const LinphoneAccountCreator *creator) { + return creator->language; +} + +LinphoneUsernameCheck linphone_account_creator_set_display_name(LinphoneAccountCreator *creator, const char *display_name) { + if (validate_uri(creator->core, creator->proxy_cfg, NULL, display_name) != 0) { + return LinphoneUsernameInvalid; + } + set_string(&creator->display_name, display_name, FALSE); + return LinphoneUsernameOk; +} + +const char * linphone_account_creator_get_display_name(const LinphoneAccountCreator *creator) { + return creator->display_name; +} + +LinphoneEmailCheck linphone_account_creator_set_email(LinphoneAccountCreator *creator, const char *email) { + if (!is_matching_regex(email, "^.+@.+\\..*$")) { + return LinphoneEmailMalformed; + } + if (!is_matching_regex(email, "^.+@.+\\.[A-Za-z]{2}[A-Za-z]*$")) { + return LinphoneEmailInvalidCharacters; + } + set_string(&creator->email, email, TRUE); + return LinphoneEmailOk; +} + +const char * linphone_account_creator_get_email(const LinphoneAccountCreator *creator) { + return creator->email; +} + +LinphoneAccountCreatorResponseCbs * linphone_account_creator_get_responses_cbs(const LinphoneAccountCreator *creator) { + return creator->responses_cbs; +} + +LinphoneAccountCreatorRequestCbs * linphone_account_creator_get_requests_cbs(const LinphoneAccountCreator *creator) { + return creator->requests_cbs; +} + +LinphoneRequestStatus linphone_account_creator_is_account_exist(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->is_account_exist_request_cb == NULL + || creator->responses_cbs->is_account_exist_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->is_account_exist_request_cb(creator); +} + +LinphoneRequestStatus linphone_account_creator_create_account(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->create_account_request_cb == NULL + || creator->responses_cbs->create_account_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->create_account_request_cb(creator); +} + +LinphoneRequestStatus linphone_account_creator_is_account_activated(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->is_account_activated_request_cb == NULL + || creator->responses_cbs->is_account_activated_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->is_account_activated_request_cb(creator); +} + +LinphoneRequestStatus linphone_account_creator_activate_account(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->activate_account_request_cb == NULL + || creator->responses_cbs->activate_account_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->activate_account_request_cb(creator); +} + +LinphoneRequestStatus linphone_account_creator_link_account(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->link_account_request_cb == NULL + || creator->responses_cbs->link_account_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->link_account_request_cb(creator); +} + +LinphoneRequestStatus linphone_account_creator_activate_alias(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->activate_alias_request_cb == NULL + || creator->responses_cbs->activate_alias_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->activate_alias_request_cb(creator); +} + +LinphoneRequestStatus linphone_account_creator_is_alias_used(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->is_alias_used_request_cb == NULL + || creator->responses_cbs->is_alias_used_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->is_alias_used_request_cb(creator); +} + +LinphoneRequestStatus linphone_account_creator_is_account_linked(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->is_account_linked_request_cb == NULL + || creator->responses_cbs->is_account_linked_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->is_account_linked_request_cb(creator); +} + +LinphoneRequestStatus linphone_account_creator_recover_account(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->recover_account_request_cb == NULL + || creator->responses_cbs->recover_account_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->recover_account_request_cb(creator); +} + +LinphoneRequestStatus linphone_account_creator_update_account(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->update_account_request_cb == NULL + || creator->responses_cbs->update_account_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->update_account_request_cb(creator); +} +/************************** End Account Creator data **************************/ + +/************************** Start Account Creator Linphone **************************/ /****************** START OF ACCOUNT USED SECTION *****************************/ -static void _is_account_used_cb(LinphoneXmlRpcRequest *request) { +static void _is_account_exist_response_cb(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->is_account_used != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (creator->responses_cbs->is_account_exist_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { - status = (strcmp(resp, "ERROR_ACCOUNT_DOESNT_EXIST") == 0) ? LinphoneAccountCreatorAccountNotExist : ( - (strcmp(resp, "ERROR_ALIAS_DOESNT_EXIST") == 0) ? LinphoneAccountCreatorAccountExist : - LinphoneAccountCreatorAccountExistWithAlias); - if (status == LinphoneAccountCreatorAccountExistWithAlias) { + status = (strcmp(resp, "ERROR_ACCOUNT_DOESNT_EXIST") == 0) ? LinphoneRequestAccountNotExist : ( + (strcmp(resp, "ERROR_ALIAS_DOESNT_EXIST") == 0) ? LinphoneRequestAccountExist : + LinphoneRequestAccountExistWithAlias); + if (status == LinphoneRequestAccountExistWithAlias) { set_string(&creator->phone_number, resp, FALSE); } } - creator->callbacks->is_account_used(creator, status, resp); + creator->responses_cbs->is_account_exist_response_cb(creator, status, resp); } } -LinphoneAccountCreatorStatus linphone_account_creator_is_account_used(LinphoneAccountCreator *creator) { +LinphoneRequestStatus linphone_account_creator_is_account_exist_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; if (!creator->username && !creator->phone_number) { - if (creator->callbacks->is_account_used != NULL) { - creator->callbacks->is_account_used(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters"); + if (creator->responses_cbs->is_account_exist_response_cb != NULL) { + creator->responses_cbs->is_account_exist_response_cb(creator, LinphoneRequestMissingArguments, "Missing required parameters"); } - return LinphoneAccountCreatorReqFailed; + return LinphoneRequestMissingArguments; } request = linphone_xml_rpc_request_new_with_args("get_phone_number_for_account", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, - LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); 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_used_cb); + 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_request_unref(request); - return LinphoneAccountCreatorOK; + return LinphoneRequestOk; } /****************** END OF CREATE ACCOUNT USED SECTION ************************/ /****************** START OF CREATE ACCOUNT SECTION ***************************/ -static void _create_account_cb(LinphoneXmlRpcRequest *request) { +static void _create_account_cb_custom(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->create_account != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (creator->responses_cbs->create_account_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { - status = (strcmp(resp, "OK") == 0) ? LinphoneAccountCreatorAccountCreated - : (strcmp(resp, "ERROR_CANNOT_SEND_SMS") == 0) ? LinphoneAccountCreatorErrorServer - : (strcmp(resp, "ERROR_ACCOUNT_ALREADY_IN_USE") == 0) ? LinphoneAccountCreatorAccountExist - : (strcmp(resp, "ERROR_ALIAS_ALREADY_IN_USE") == 0) ? LinphoneAccountCreatorAccountExistWithAlias - :LinphoneAccountCreatorAccountNotCreated; + status = (strcmp(resp, "OK") == 0) ? LinphoneRequestAccountCreated + : (strcmp(resp, "ERROR_CANNOT_SEND_SMS") == 0) ? LinphoneRequestErrorServer + : (strcmp(resp, "ERROR_ACCOUNT_ALREADY_IN_USE") == 0) ? LinphoneRequestAccountExist + : (strcmp(resp, "ERROR_ALIAS_ALREADY_IN_USE") == 0) ? LinphoneRequestAccountExistWithAlias + :LinphoneRequestAccountNotCreated; } - creator->callbacks->create_account(creator, status, resp); + creator->responses_cbs->create_account_response_cb(creator, status, resp); } } -static LinphoneXmlRpcRequest * _create_account_with_phone(LinphoneAccountCreator *creator) { +static LinphoneXmlRpcRequest * _create_account_with_phone_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; if (!creator->phone_number) { return NULL; @@ -642,78 +762,78 @@ static LinphoneXmlRpcRequest * _create_account_with_phone(LinphoneAccountCreator request = linphone_xml_rpc_request_new_with_args("create_phone_account", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->phone_number, LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, - LinphoneXmlRpcArgString, creator->password ? ha1_for_passwd(creator->username ? creator->username : creator->phone_number, creator->domain, creator->password) : "", + LinphoneXmlRpcArgString, creator->password ? ha1_for_passwd(creator->username ? creator->username : creator->phone_number, linphone_proxy_config_get_domain(creator->proxy_cfg), creator->password) : "", LinphoneXmlRpcArgString, linphone_core_get_user_agent(creator->core), - LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgString, creator->language, LinphoneXmlRpcArgNone); return request; } -static LinphoneXmlRpcRequest * _create_account_with_email(LinphoneAccountCreator *creator) { +static LinphoneXmlRpcRequest * _create_account_with_email_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; - if (!creator->username || !creator->email) { + if (!creator->username || !creator->email || !creator->password) { return NULL; } request = linphone_xml_rpc_request_new_with_args("create_email_account", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->username, LinphoneXmlRpcArgString, creator->email, - LinphoneXmlRpcArgString, ha1_for_passwd(creator->username ? creator->username : creator->phone_number, creator->domain, creator->password), + LinphoneXmlRpcArgString, ha1_for_passwd(creator->username ? creator->username : creator->phone_number, linphone_proxy_config_get_domain(creator->proxy_cfg), creator->password), LinphoneXmlRpcArgString, linphone_core_get_user_agent(creator->core), - LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); return request; } -LinphoneAccountCreatorStatus linphone_account_creator_create_account(LinphoneAccountCreator *creator) { +LinphoneRequestStatus linphone_account_creator_create_account_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; char *identity = _get_identity(creator); - if (!identity || (!(request = _create_account_with_phone(creator)) - && !(request = _create_account_with_email(creator)))) { - if (creator->callbacks->create_account != NULL) { - creator->callbacks->create_account(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters"); + if (!identity || (!(request = _create_account_with_phone_custom(creator)) + && !(request = _create_account_with_email_custom(creator)))) { + if (creator->responses_cbs->create_account_response_cb != NULL) { + creator->responses_cbs->create_account_response_cb(creator, LinphoneRequestMissingArguments, "Missing required parameters"); } if (identity) ms_free(identity); - return LinphoneAccountCreatorReqFailed; + return LinphoneRequestMissingArguments; } 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); + 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_request_unref(request); ms_free(identity); - return LinphoneAccountCreatorOK; + return LinphoneRequestOk; } /****************** END OF CREATE ACCOUNT SECTION *****************************/ /****************** START OF VALIDATE ACCOUNT SECTION *************************/ -static void _activate_account_cb(LinphoneXmlRpcRequest *request) { +static void _activate_account_cb_custom(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->activate_account != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (creator->responses_cbs->activate_account_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { if (strcmp(resp, "ERROR_ACCOUNT_ALREADY_ACTIVATED") == 0) { - status = LinphoneAccountCreatorAccountAlreadyActivated; + status = LinphoneRequestAccountAlreadyActivated; } else if (strstr(resp, "ERROR_") == resp) { - status = LinphoneAccountCreatorAccountNotActivated; + status = LinphoneRequestAccountNotActivated; } else { - status = LinphoneAccountCreatorAccountActivated; + status = LinphoneRequestAccountActivated; set_string(&creator->ha1, resp, FALSE); } } - creator->callbacks->activate_account(creator, status, resp); + creator->responses_cbs->activate_account_response_cb(creator, status, resp); } } -LinphoneAccountCreatorStatus linphone_account_creator_activate_account(LinphoneAccountCreator *creator) { +LinphoneRequestStatus linphone_account_creator_activate_account_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; char *identity = _get_identity(creator); if (!identity || !creator->activation_code) { - if (creator->callbacks->is_account_activated != NULL) { - creator->callbacks->is_account_activated(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters"); + if (creator->responses_cbs->is_account_activated_response_cb != NULL) { + creator->responses_cbs->is_account_activated_response_cb(creator, LinphoneRequestMissingArguments, "Missing required parameters"); } - return LinphoneAccountCreatorReqFailed; + return LinphoneRequestMissingArguments; } if (creator->phone_number) { @@ -721,236 +841,293 @@ LinphoneAccountCreatorStatus linphone_account_creator_activate_account(LinphoneA LinphoneXmlRpcArgString, creator->phone_number, LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, LinphoneXmlRpcArgString, creator->activation_code, - LinphoneXmlRpcArgString, creator->domain, + linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); } else { request = linphone_xml_rpc_request_new_with_args("activate_email_account", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->username, LinphoneXmlRpcArgString, creator->activation_code, - LinphoneXmlRpcArgString, creator->domain, + linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); } 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); + 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_request_unref(request); ms_free(identity); - return LinphoneAccountCreatorOK; + return LinphoneRequestOk; } /****************** END OF CREATE VALIDATE ACCOUNT SECTION ********************/ /****************** START OF ACCOUNT VALIDATED SECTION ************************/ -static void _is_account_activated_cb(LinphoneXmlRpcRequest *request) { +static void _is_account_activated_cb_custom(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->is_account_activated != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (creator->responses_cbs->is_account_activated_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { - status = (strcmp(resp, "OK") == 0) ? LinphoneAccountCreatorAccountActivated : LinphoneAccountCreatorAccountNotActivated; + status = (strcmp(resp, "OK") == 0) ? LinphoneRequestAccountActivated : LinphoneRequestAccountNotActivated; } - creator->callbacks->is_account_activated(creator, status, resp); + creator->responses_cbs->is_account_activated_response_cb(creator, status, resp); } } -LinphoneAccountCreatorStatus linphone_account_creator_is_account_activated(LinphoneAccountCreator *creator) { +LinphoneRequestStatus linphone_account_creator_is_account_activated_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; char *identity = _get_identity(creator); if (!identity) { - if (creator->callbacks->is_account_activated != NULL) { - creator->callbacks->is_account_activated(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters"); + if (creator->responses_cbs->is_account_activated_response_cb != NULL) { + creator->responses_cbs->is_account_activated_response_cb(creator, LinphoneRequestMissingArguments, "Missing required parameters"); } - return LinphoneAccountCreatorReqFailed; + return LinphoneRequestMissingArguments; } request = linphone_xml_rpc_request_new_with_args("is_account_activated", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, - LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); 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); + 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_request_unref(request); ms_free(identity); - return LinphoneAccountCreatorOK; + return LinphoneRequestOk; } /****************** END OF CREATE ACCOUNT VALIDATED SECTION********************/ /****************** START OF PHONE NUMBER VALIDATED SECTION *******************/ -static void _is_phone_number_used_cb(LinphoneXmlRpcRequest *request) { +static void _is_phone_number_used_cb_custom(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->is_phone_number_used != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (creator->responses_cbs->is_alias_used_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { - status = (strcmp(resp, "OK_ACCOUNT") == 0) ? LinphoneAccountCreatorPhoneNumberUsedAccount - : (strcmp(resp, "OK_ALIAS") == 0) ? LinphoneAccountCreatorPhoneNumberUsedAlias - : LinphoneAccountCreatorPhoneNumberNotUsed; + status = (strcmp(resp, "OK_ACCOUNT") == 0) ? LinphoneRequestAliasIsAccount + : (strcmp(resp, "OK_ALIAS") == 0) ? LinphoneRequestAliasExist + : LinphoneRequestAliasNotExist; } - creator->callbacks->is_phone_number_used(creator, status, resp); + creator->responses_cbs->is_alias_used_response_cb(creator, status, resp); } } -LinphoneAccountCreatorStatus linphone_account_creator_is_phone_number_used(LinphoneAccountCreator *creator) { +LinphoneRequestStatus linphone_account_creator_is_phone_number_used_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; char *identity = _get_identity(creator); if (!identity) { - if (creator->callbacks->is_phone_number_used != NULL) { - creator->callbacks->is_phone_number_used(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters"); + if (creator->responses_cbs->is_alias_used_response_cb != NULL) { + creator->responses_cbs->is_alias_used_response_cb(creator, LinphoneRequestMissingArguments, "Missing required parameters"); } - return LinphoneAccountCreatorReqFailed; + return LinphoneRequestMissingArguments; } request = linphone_xml_rpc_request_new_with_args("is_phone_number_used", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->phone_number, - LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); 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); + 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_request_unref(request); ms_free(identity); - return LinphoneAccountCreatorOK; + return LinphoneRequestOk; } /****************** END OF PHONE NUMBER VALIDATED SECTION *********************/ /****************** START OF LINK PHONE NUMBER WITH ACCOUNT SECTION ***********/ -static void _link_phone_number_with_account_cb(LinphoneXmlRpcRequest *request) { +static void _link_phone_number_with_account_cb_custom(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->link_phone_number_with_account != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (creator->responses_cbs->link_account_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { - status = (strcmp(resp, "OK") == 0) ? LinphoneAccountCreatorOK : LinphoneAccountCreatorReqFailed; + status = (strcmp(resp, "OK") == 0) ? LinphoneRequestOk : LinphoneRequestAccountNotLinked; } - creator->callbacks->link_phone_number_with_account(creator, status, resp); + creator->responses_cbs->link_account_response_cb(creator, status, resp); } } -LinphoneAccountCreatorStatus linphone_account_creator_link_phone_number_with_account(LinphoneAccountCreator *creator) { +LinphoneRequestStatus linphone_account_creator_link_phone_number_with_account_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; if (!creator->phone_number || !creator->username) { - if (creator->callbacks->link_phone_number_with_account != NULL) { - creator->callbacks->link_phone_number_with_account(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters"); + if (creator->responses_cbs->link_account_response_cb != NULL) { + creator->responses_cbs->link_account_response_cb(creator, LinphoneRequestMissingArguments, "Missing required parameters"); } - return LinphoneAccountCreatorReqFailed; + return LinphoneRequestMissingArguments; } request = linphone_xml_rpc_request_new_with_args("link_phone_number_with_account", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->phone_number, LinphoneXmlRpcArgString, creator->username, - LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgString, creator->language, LinphoneXmlRpcArgNone); 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); + 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_request_unref(request); - return LinphoneAccountCreatorOK; + return LinphoneRequestOk; } -static void _get_phone_number_for_account_cb(LinphoneXmlRpcRequest *request) { +static void _get_phone_number_for_account_cb_custom(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->is_account_linked != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (creator->responses_cbs->is_account_linked_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { status = (strcmp(resp, "ERROR_USERNAME_PARAMETER_NOT_FOUND") == 0 || strcmp(resp, "ERROR_ACCOUNT_DOESNT_EXIST") == 0 - || strcmp(resp, "ERROR_ALIAS_DOESNT_EXIST") == 0) ? LinphoneAccountCreatorAccountNotLinked : LinphoneAccountCreatorAccountLinked; + || strcmp(resp, "ERROR_ALIAS_DOESNT_EXIST") == 0) ? LinphoneRequestAccountNotLinked : LinphoneRequestAccountLinked; } - creator->callbacks->link_phone_number_with_account(creator, status, resp); + creator->responses_cbs->is_account_linked_response_cb(creator, status, resp); } } -LinphoneAccountCreatorStatus linphone_account_creator_is_account_linked(LinphoneAccountCreator *creator) { +LinphoneRequestStatus linphone_account_creator_is_account_linked_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; - if (!creator->username || !creator->domain) { - return LinphoneAccountCreatorReqFailed; + if (!creator->username || !linphone_proxy_config_get_domain(creator->proxy_cfg)) { + return LinphoneRequestMissingArguments; } request = linphone_xml_rpc_request_new_with_args("get_phone_number_for_account",LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->username, - LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); 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); + 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_request_unref(request); - return LinphoneAccountCreatorOK; + return LinphoneRequestOk; } /****************** END OF LINK PHONE NUMBER WITH ACCOUNT SECTION *************/ /****************** START OF ACTIVE PHONE NUMBER LINK **************************/ -static void _activate_phone_number_link_cb(LinphoneXmlRpcRequest *request) { +static void _activate_phone_number_link_cb_custom(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->activate_phone_number_link != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (creator->responses_cbs->activate_alias_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { - status = (strstr(resp, "ERROR_") == resp) ? LinphoneAccountCreatorReqFailed : LinphoneAccountCreatorOK; + status = (strstr(resp, "ERROR_") == resp) ? LinphoneRequestAccountNotActivated : LinphoneRequestOk; } - creator->callbacks->activate_phone_number_link(creator, status, resp); + creator->responses_cbs->activate_alias_response_cb(creator, status, resp); } } -LinphoneAccountCreatorStatus linphone_account_creator_activate_phone_number_link(LinphoneAccountCreator *creator) { +LinphoneRequestStatus linphone_account_creator_activate_phone_number_link_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; - if (!creator->phone_number || !creator->username || !creator->activation_code || (!creator->password && !creator->ha1) || !creator->domain) { - if (creator->callbacks->activate_phone_number_link != NULL) { - creator->callbacks->activate_phone_number_link(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters"); + if (!creator->phone_number || !creator->username || !creator->activation_code || (!creator->password && !creator->ha1) || !linphone_proxy_config_get_domain(creator->proxy_cfg)) { + if (creator->responses_cbs->activate_alias_response_cb != NULL) { + creator->responses_cbs->activate_alias_response_cb(creator, LinphoneRequestMissingArguments, "Missing required parameters"); } - return LinphoneAccountCreatorReqFailed; + return LinphoneRequestMissingArguments; } request = linphone_xml_rpc_request_new_with_args("activate_phone_number_link", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->phone_number, LinphoneXmlRpcArgString, creator->username, LinphoneXmlRpcArgString, creator->activation_code, - LinphoneXmlRpcArgString, creator->ha1 ? creator->ha1 : ha1_for_passwd(creator->username, creator->domain, creator->password), - LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgString, creator->ha1 ? creator->ha1 : ha1_for_passwd(creator->username, linphone_proxy_config_get_domain(creator->proxy_cfg), creator->password), + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); 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); + 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_request_unref(request); - return LinphoneAccountCreatorOK; + return LinphoneRequestOk; } /****************** END OF ACTIVE PHONE NUMBER LINK **************************/ /****************** START OF ACTIVE PHONE NUMBER LINK **************************/ -static void _recover_phone_account_cb(LinphoneXmlRpcRequest *request) { +static void _recover_phone_account_cb_custom(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->recover_phone_account != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (creator->responses_cbs->recover_account_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { if (strstr(resp, "ERROR_") == resp) { - status = (strstr(resp, "ERROR_CANNOT_SEND_SMS") == resp) ? LinphoneAccountCreatorErrorServer - : (strstr(resp, "ERROR_ACCOUNT_DOESNT_EXIST") == resp) ? LinphoneAccountCreatorAccountNotExist - : LinphoneAccountCreatorReqFailed; + status = (strstr(resp, "ERROR_CANNOT_SEND_SMS") == resp) ? LinphoneRequestErrorServer + : (strstr(resp, "ERROR_ACCOUNT_DOESNT_EXIST") == resp) ? LinphoneRequestAccountNotExist + : LinphoneRequestFailed; } else { - status = LinphoneAccountCreatorOK; + status = LinphoneRequestOk; set_string(&creator->username, resp, FALSE); } } - creator->callbacks->recover_phone_account(creator, status, resp); + creator->responses_cbs->recover_account_response_cb(creator, status, resp); } } -LinphoneAccountCreatorStatus linphone_account_creator_recover_phone_account(LinphoneAccountCreator *creator) { +LinphoneRequestStatus linphone_account_creator_recover_phone_account_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; if (!creator->phone_number) { - if (creator->callbacks->recover_phone_account != NULL) { - creator->callbacks->recover_phone_account(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters"); + if (creator->responses_cbs->recover_account_response_cb != NULL) { + creator->responses_cbs->recover_account_response_cb(creator, LinphoneRequestMissingArguments, "Missing required parameters"); } - return LinphoneAccountCreatorReqFailed; + return LinphoneRequestMissingArguments; } request = linphone_xml_rpc_request_new_with_args("recover_phone_account", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->phone_number, - LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgString, creator->language, LinphoneXmlRpcArgNone); linphone_xml_rpc_request_set_user_data(request, creator); - linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _recover_phone_account_cb); + linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _recover_phone_account_cb_custom); linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); - return LinphoneAccountCreatorOK; + return LinphoneRequestOk; } /****************** END OF ACTIVE PHONE NUMBER LINK **************************/ + +/****************** START OF UPDATE ACCOUNT **************************/ +static void _password_updated_cb_custom(LinphoneXmlRpcRequest *request) { + LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); + if (creator->responses_cbs->update_account_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; + const char* resp = linphone_xml_rpc_request_get_string_response(request); + if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { + if (strcmp(resp, "OK") == 0) { + status = LinphoneRequestOk; + } else if (strcmp(resp, "ERROR_PASSWORD_DOESNT_MATCH") == 0) { + status = LinphoneRequestAccountNotExist; + } else { + status = LinphoneRequestErrorServer; + } + } + creator->responses_cbs->update_account_response_cb(creator, status, resp); + } +} + +LinphoneRequestStatus linphone_account_creator_update_password_custom(LinphoneAccountCreator *creator){ + LinphoneXmlRpcRequest *request; + char *identity = _get_identity(creator); + const char* new_pwd = (const char*)linphone_account_creator_get_user_data(creator); + if (!identity || + (!creator->username || !creator->phone_number + || !linphone_proxy_config_get_domain(creator->proxy_cfg) + || (!creator->password && !creator->ha1) || !new_pwd + ) + ) { + if (creator->responses_cbs->update_account_response_cb != NULL) { + creator->responses_cbs->update_account_response_cb(creator, LinphoneRequestMissingArguments, "Missing required parameters"); + } + return LinphoneRequestMissingArguments; + } + + const char * username = creator->username ? creator->username : creator->phone_number; + const char * ha1 = ms_strdup(creator->ha1 ? creator->ha1 : ha1_for_passwd(username, linphone_proxy_config_get_domain(creator->proxy_cfg), creator->password) ); + const char * new_ha1 = ms_strdup(ha1_for_passwd(username, linphone_proxy_config_get_domain(creator->proxy_cfg), new_pwd)); + + request = linphone_xml_rpc_request_new_with_args("update_hash", LinphoneXmlRpcArgString, + LinphoneXmlRpcArgString, username, + LinphoneXmlRpcArgString, ha1, + LinphoneXmlRpcArgString, new_ha1, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), + LinphoneXmlRpcArgNone); + + linphone_xml_rpc_request_set_user_data(request, creator); + linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _password_updated_cb_custom); + linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); + linphone_xml_rpc_request_unref(request); + + return LinphoneRequestOk; +} +/****************** END OF UPDATE ACCOUNT **************************/ + +/************************** End Account Creator Linphone **************************/ diff --git a/coreapi/private.h b/coreapi/private.h index 543b4efcb..c61e9e4d4 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1389,43 +1389,73 @@ BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneXmlRpcSession); * Account creator interface * ****************************************************************************/ -struct _LinphoneAccountCreatorCbs { +struct _LinphoneAccountCreatorRequestCbs { belle_sip_object_t base; void *user_data; - LinphoneAccountCreatorCbsStatusCb is_account_used; - LinphoneAccountCreatorCbsStatusCb create_account; - LinphoneAccountCreatorCbsStatusCb activate_account; - LinphoneAccountCreatorCbsStatusCb is_account_activated; - LinphoneAccountCreatorCbsStatusCb is_phone_number_used; - LinphoneAccountCreatorCbsStatusCb link_phone_number_with_account; - LinphoneAccountCreatorCbsStatusCb activate_phone_number_link; - LinphoneAccountCreatorCbsStatusCb recover_phone_account; - LinphoneAccountCreatorCbsStatusCb is_account_linked; - LinphoneAccountCreatorCbsStatusCb update_hash; + + LinphoneAccountCreatorRequestFunc create_account_request_cb; /**< Request to create account */ + LinphoneAccountCreatorRequestFunc is_account_exist_request_cb; /**< Request to know if account exist */ + + LinphoneAccountCreatorRequestFunc activate_account_request_cb; /**< Request to activate account */ + LinphoneAccountCreatorRequestFunc is_account_activated_request_cb; /**< Request to know if account is activated */ + + LinphoneAccountCreatorRequestFunc link_account_request_cb; /**< Request to link account with an alias */ + LinphoneAccountCreatorRequestFunc activate_alias_request_cb; /**< Request to activate the link of alias */ + LinphoneAccountCreatorRequestFunc is_alias_used_request_cb; /**< Request to know if alias is used */ + LinphoneAccountCreatorRequestFunc is_account_linked_request_cb; /**< Request to know if account is linked with an alias */ + + LinphoneAccountCreatorRequestFunc recover_account_request_cb; /**< Request to recover account */ + LinphoneAccountCreatorRequestFunc update_account_request_cb; /**< Request to update account */ }; -BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneAccountCreatorCbs); +BELLE_SIP_DECLARE_VPTR(LinphoneAccountCreatorRequestCbs); + +struct _LinphoneAccountCreatorResponseCbs { + belle_sip_object_t base; + void *user_data; + + LinphoneAccountCreatorResponseFunc create_account_response_cb; /**< Response of create_account request */ + LinphoneAccountCreatorResponseFunc is_account_exist_response_cb; /**< Response of is_account_exist request */ + + LinphoneAccountCreatorResponseFunc activate_account_response_cb; /**< Response of activate_account request */ + LinphoneAccountCreatorResponseFunc is_account_activated_response_cb; /**< Response of is_account_activated request */ + + LinphoneAccountCreatorResponseFunc link_account_response_cb; /**< Response of link_account request */ + LinphoneAccountCreatorResponseFunc activate_alias_response_cb; /**< Response of activation alias */ + LinphoneAccountCreatorResponseFunc is_alias_used_response_cb; /**< Response of is_alias_used request */ + LinphoneAccountCreatorResponseFunc is_account_linked_response_cb; /**< Response of is_account_linked request */ + + LinphoneAccountCreatorResponseFunc recover_account_response_cb; /**< Response of recover_account request */ + LinphoneAccountCreatorResponseFunc update_account_response_cb; /**< Response of update_account request */ +}; + +BELLE_SIP_DECLARE_VPTR(LinphoneAccountCreatorResponseCbs); struct _LinphoneAccountCreator { belle_sip_object_t base; void *user_data; - LinphoneAccountCreatorCbs *callbacks; - LinphoneXmlRpcSession *xmlrpc_session; LinphoneCore *core; - char *xmlrpc_url; - char *username; - char *phone_number; - char *password; - char *domain; - char *route; - char *email; - bool_t subscribe_to_newsletter; - char *display_name; - LinphoneTransportType transport; - char *activation_code; - char *ha1; - char *phone_country_code; - char *language; + + /* AccountCreator */ + LinphoneAccountCreatorRequestCbs *requests_cbs; /**< Account creator requests cbs */ + LinphoneAccountCreatorResponseCbs *responses_cbs; /**< Account creator responses cbs */ + LinphoneXmlRpcSession *xmlrpc_session; /**< XML-RPC session */ + LinphoneProxyConfig *proxy_cfg; /**< Default proxy config */ + + /* User */ + char *username; /**< Username */ + char *display_name; /**< Display name */ + /* Password */ + char *password; /**< Plain text password */ + char *ha1; /**< Hash password */ + /* Phone Number(Alias) */ + char *phone_number; /**< User phone number*/ + char *phone_country_code; /**< User phone number country code */ + /* Email(Alias) */ + char *email; /**< User email */ + /* Misc */ + char *language; /**< User language */ + char *activation_code; /**< Account validation code */ }; BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneAccountCreator); @@ -1576,7 +1606,8 @@ LINPHONE_PUBLIC LinphoneImEncryptionEngine *linphone_im_encryption_engine_new(Li BELLE_SIP_DECLARE_TYPES_BEGIN(linphone,10000) BELLE_SIP_TYPE_ID(LinphoneAccountCreator), -BELLE_SIP_TYPE_ID(LinphoneAccountCreatorCbs), +BELLE_SIP_TYPE_ID(LinphoneAccountCreatorRequestCbs), +BELLE_SIP_TYPE_ID(LinphoneAccountCreatorResponseCbs), BELLE_SIP_TYPE_ID(LinphoneBuffer), BELLE_SIP_TYPE_ID(LinphoneContactProvider), BELLE_SIP_TYPE_ID(LinphoneContactSearch), diff --git a/gtk/setupwizard.c b/gtk/setupwizard.c index 1a002f797..accc2e0d7 100644 --- a/gtk/setupwizard.c +++ b/gtk/setupwizard.c @@ -31,9 +31,9 @@ static LinphoneAccountCreator * linphone_gtk_assistant_get_creator(GtkWidget *w) return (LinphoneAccountCreator *)g_object_get_data(G_OBJECT(w), "creator"); } -static void linphone_gtk_create_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char* resp) { +static void linphone_gtk_create_account_cb(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char* resp) { GtkWidget *assistant = (GtkWidget *)linphone_account_creator_get_user_data(creator); - if (status == LinphoneAccountCreatorAccountCreated) { + if (status == LinphoneRequestAccountCreated) { // Go to page_6_linphone_account_validation_wait gtk_assistant_set_current_page(GTK_ASSISTANT(assistant), 6); } else { // Error when attempting to create the account @@ -48,9 +48,9 @@ static void create_account(GtkWidget *assistant) { linphone_account_creator_create_account(creator); } -static void linphone_gtk_test_account_validation_cb(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char* resp) { +static void linphone_gtk_test_account_validation_cb(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char* resp) { GtkWidget *assistant = (GtkWidget *)linphone_account_creator_get_user_data(creator); - if (status == LinphoneAccountCreatorAccountActivated) { + if (status == LinphoneRequestAccountActivated) { // Go to page_9_finish gtk_assistant_set_current_page(GTK_ASSISTANT(assistant), 9); } else { @@ -61,7 +61,9 @@ static void linphone_gtk_test_account_validation_cb(LinphoneAccountCreator *crea static void check_account_validation(GtkWidget *assistant) { LinphoneAccountCreator *creator = linphone_gtk_assistant_get_creator(assistant); - linphone_account_creator_is_account_activated(creator); + (linphone_account_creator_requests_cbs_get_is_account_activated_cb( + linphone_account_creator_get_requests_cbs(creator)) + )(creator); } void linphone_gtk_assistant_closed(GtkWidget *w) { @@ -79,9 +81,7 @@ void linphone_gtk_assistant_prepare(GtkWidget *assistant) { check_account_validation(assistant); break; case 9: - if (linphone_account_creator_configure(linphone_gtk_assistant_get_creator(assistant)) != NULL) { - linphone_gtk_load_identities(); - } + linphone_gtk_load_identities(); gtk_assistant_commit(GTK_ASSISTANT(assistant)); break; default: @@ -128,12 +128,8 @@ static int linphone_gtk_assistant_forward(int curpage, gpointer data) { case 2: { GtkEntry *username_entry = GTK_ENTRY(linphone_gtk_get_widget(w, "p2_entry_username")); - GtkEntry *domain_entry = GTK_ENTRY(linphone_gtk_get_widget(w, "p2_entry_domain")); - GtkEntry *proxy_entry = GTK_ENTRY(linphone_gtk_get_widget(w, "p2_entry_proxy")); GtkEntry *password_entry = GTK_ENTRY(linphone_gtk_get_widget(w, "p2_entry_password")); linphone_account_creator_set_username(creator, gtk_entry_get_text(username_entry)); - linphone_account_creator_set_domain(creator, gtk_entry_get_text(domain_entry)); - linphone_account_creator_set_route(creator, gtk_entry_get_text(proxy_entry)); linphone_account_creator_set_password(creator, gtk_entry_get_text(password_entry)); curpage = 9; // Go to page_9_finish break; @@ -143,8 +139,6 @@ static int linphone_gtk_assistant_forward(int curpage, gpointer data) { GtkEntry *username_entry = GTK_ENTRY(linphone_gtk_get_widget(w, "p3_entry_username")); GtkEntry *password_entry = GTK_ENTRY(linphone_gtk_get_widget(w, "p3_entry_password")); linphone_account_creator_set_username(creator, gtk_entry_get_text(username_entry)); - linphone_account_creator_set_domain(creator, "sip.linphone.org"); - linphone_account_creator_set_route(creator, "sip.linphone.org"); linphone_account_creator_set_password(creator, gtk_entry_get_text(password_entry)); curpage = 9; // Go to page_9_finish break; @@ -215,11 +209,11 @@ static gboolean update_interface_with_username_availability(GtkWidget *page) { GtkLabel* usernameError = GTK_LABEL(linphone_gtk_get_widget(assistant, "p4_label_error")); int account_status = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(page), "is_username_used")); - if (account_status == LinphoneAccountCreatorAccountNotExist) { + if (account_status == LinphoneRequestAccountNotExist) { g_object_set_data(G_OBJECT(page), "is_username_available", GINT_TO_POINTER(1)); gtk_image_set_from_stock(isUsernameOk, GTK_STOCK_OK, GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_label_set_text(usernameError, ""); - } else if (account_status == LinphoneAccountCreatorAccountExist) { + } else if (account_status == LinphoneRequestAccountExist) { gtk_label_set_text(usernameError, _("Username is already in use!")); g_object_set_data(G_OBJECT(page), "is_username_available", GINT_TO_POINTER(0)); gtk_image_set_from_stock(isUsernameOk, GTK_STOCK_NO, GTK_ICON_SIZE_LARGE_TOOLBAR); @@ -232,7 +226,7 @@ static gboolean update_interface_with_username_availability(GtkWidget *page) { return FALSE; } -static void linphone_gtk_test_account_existence_cb(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char* resp) { +static void linphone_gtk_test_account_existence_cb(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char* resp) { GtkWidget *assistant = (GtkWidget *)linphone_account_creator_get_user_data(creator); GtkWidget *page = gtk_assistant_get_nth_page(GTK_ASSISTANT(assistant), gtk_assistant_get_current_page(GTK_ASSISTANT(assistant))); g_object_set_data(G_OBJECT(page), "is_username_used", GINT_TO_POINTER(status)); @@ -243,7 +237,9 @@ static gboolean check_username_availability(GtkWidget *assistant) { LinphoneAccountCreator *creator = linphone_gtk_assistant_get_creator(assistant); GtkWidget *page = gtk_assistant_get_nth_page(GTK_ASSISTANT(assistant), gtk_assistant_get_current_page(GTK_ASSISTANT(assistant))); g_object_set_data(G_OBJECT(page), "usernameAvailabilityTimerID", GUINT_TO_POINTER(0)); - linphone_account_creator_is_account_used(creator); + (linphone_account_creator_requests_cbs_get_is_account_exist_cb( + linphone_account_creator_get_requests_cbs(creator)) + )(creator); return FALSE; } @@ -257,8 +253,6 @@ void linphone_gtk_account_creation_username_changed(GtkEntry *entry) { LinphoneAccountCreator *creator = linphone_gtk_assistant_get_creator(assistant); linphone_account_creator_set_username(creator, gtk_entry_get_text(username)); - linphone_account_creator_set_domain(creator, "sip.linphone.org"); - linphone_account_creator_set_route(creator, "sip.linphone.org"); if (check_username_validity(gtk_entry_get_text(username))) { guint timerID = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(page), "usernameAvailabilityTimerID")); @@ -324,11 +318,11 @@ void linphone_gtk_account_creation_password_changed(GtkEntry *entry) { static void linphone_gtk_assistant_init(GtkWidget *w) { LinphoneAccountCreator *creator = linphone_account_creator_new(linphone_gtk_get_core(), "https://subscribe.linphone.org:444/wizard.php"); - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); linphone_account_creator_set_user_data(creator, w); - linphone_account_creator_cbs_set_is_account_used(cbs, linphone_gtk_test_account_existence_cb); - linphone_account_creator_cbs_set_is_account_activated(cbs, linphone_gtk_test_account_validation_cb); - linphone_account_creator_cbs_set_create_account(cbs, linphone_gtk_create_account_cb); + linphone_account_creator_responses_cbs_set_is_account_exist_cb(cbs, linphone_gtk_test_account_existence_cb); + linphone_account_creator_responses_cbs_set_is_account_activated_cb(cbs, linphone_gtk_test_account_validation_cb); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, linphone_gtk_create_account_cb); g_object_set_data(G_OBJECT(w), "creator", creator); gtk_assistant_set_forward_page_func(GTK_ASSISTANT(w), linphone_gtk_assistant_forward, w, NULL); diff --git a/include/linphone/account_creator.h b/include/linphone/account_creator.h index c17e8c54c..423f2b7eb 100644 --- a/include/linphone/account_creator.h +++ b/include/linphone/account_creator.h @@ -1,6 +1,6 @@ /* account_creator.h -Copyright (C) 2010-2015 Belledonne Communications SARL +Copyright (C) 2010-2017 Belledonne Communications SARL This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -27,25 +27,109 @@ extern "C" { #endif /** - * @addtogroup misc + * @addtogroup account_creator * @{ */ + /** + * Function to set custom server request. + * @param[in] creator LinphoneAccountCreator object + */ + typedef LinphoneRequestStatus (*LinphoneAccountCreatorRequestFunc)(LinphoneAccountCreator *creator); + /** - * Callback to notify a status change of the account creator. + * Callback to notify a response of server. * @param[in] creator LinphoneAccountCreator object * @param[in] status The status of the LinphoneAccountCreator test existence operation that has just finished **/ -typedef void (*LinphoneAccountCreatorCbsStatusCb)(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char* resp); +typedef void (*LinphoneAccountCreatorResponseFunc)(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char* resp); + +/************************** Start Account Creator data **************************/ /** - * Create a LinphoneAccountCreator. + * Create a LinphoneAccountCreator and set Linphone Request callbacks. * @param[in] core The LinphoneCore used for the XML-RPC communication * @param[in] xmlrpc_url The URL to the XML-RPC server. Must be NON NULL. - * @return The new LinphoneAccountCreator object + * @return The new LinphoneAccountCreator object. **/ LINPHONE_PUBLIC LinphoneAccountCreator * linphone_account_creator_new(LinphoneCore *core, const char *xmlrpc_url); +/** + * Set Linphone functions to LinphoneAccountCreator. + * @param[in] creator LinphoneAccountCreator object +**/ +LINPHONE_PUBLIC void linphone_account_creator_set_linphone_impl(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to know the existence of account on server. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_account_exist(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to create an account on server. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_create_account(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to know if an account is activated on server. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_account_activated(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to activate an account on server. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_activate_account(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to link an account to an alias. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_link_account(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to activate an alias. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_activate_alias(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to know if an alias is used. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_alias_used(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to know if an account is linked. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_account_linked(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to recover an account. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_recover_account(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to update an account. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_update_account(LinphoneAccountCreator *creator); + /** * Acquire a reference to the LinphoneAccountCreator. * @param[in] creator LinphoneAccountCreator object. @@ -77,9 +161,9 @@ LINPHONE_PUBLIC void linphone_account_creator_set_user_data(LinphoneAccountCreat * Set the username. * @param[in] creator LinphoneAccountCreator object * @param[in] username The username to set - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. + * @return LinphoneUsernameOk if everything is OK, or a specific error otherwise. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_username(LinphoneAccountCreator *creator, const char *username); +LINPHONE_PUBLIC LinphoneUsernameCheck linphone_account_creator_set_username(LinphoneAccountCreator *creator, const char *username); /** * Get the username. @@ -88,22 +172,14 @@ LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_userna **/ LINPHONE_PUBLIC const char * linphone_account_creator_get_username(const LinphoneAccountCreator *creator); -/** - * Update the password. - * @param[in] creator LinphoneAccountCreator object - * @param[in] new_pwd const char * : new password for the account creator - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_update_password(LinphoneAccountCreator *creator, const char *new_pwd); - /** * Set the phone number normalized. * @param[in] creator LinphoneAccountCreator object * @param[in] phone_number The phone number to set * @param[in] country_code Country code to associate phone number with - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. + * @return LinphonePhoneNumberOk if everything is OK, or specific(s) error(s) otherwise. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_phone_number(LinphoneAccountCreator *creator, const char *phone_number, const char *country_code); +LINPHONE_PUBLIC LinphonePhoneNumberMask linphone_account_creator_set_phone_number(LinphoneAccountCreator *creator, const char *phone_number, const char *country_code); /** * Get the RFC 3966 normalized phone number. @@ -116,9 +192,9 @@ LINPHONE_PUBLIC const char * linphone_account_creator_get_phone_number(const Lin * Set the password. * @param[in] creator LinphoneAccountCreator object * @param[in] password The password to set - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. + * @return LinphonePasswordOk if everything is OK, or specific(s) error(s) otherwise. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_password(LinphoneAccountCreator *creator, const char *password); +LINPHONE_PUBLIC LinphonePasswordCheck linphone_account_creator_set_password(LinphoneAccountCreator *creator, const char *password); /** * Get the password. @@ -131,9 +207,9 @@ LINPHONE_PUBLIC const char * linphone_account_creator_get_password(const Linphon * Set the ha1. * @param[in] creator LinphoneAccountCreator object * @param[in] ha1 The ha1 to set - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. + * @return LinphonePasswordOk if everything is OK, or a specific error otherwise. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_ha1(LinphoneAccountCreator *creator, const char *ha1); +LINPHONE_PUBLIC LinphonePasswordCheck linphone_account_creator_set_ha1(LinphoneAccountCreator *creator, const char *ha1); /** * Get the ha1. @@ -146,71 +222,42 @@ LINPHONE_PUBLIC const char * linphone_account_creator_get_ha1(const LinphoneAcco * Set the activation code. * @param[in] creator LinphoneAccountCreator object * @param[in] activation_code The activation code to set + * @return LinphoneActivationCodeOk if everything is OK, or a specific error otherwise. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_activation_code(LinphoneAccountCreator *creator, const char *activation_code); +LINPHONE_PUBLIC LinphoneActivationCodeCheck linphone_account_creator_set_activation_code(LinphoneAccountCreator *creator, const char *activation_code); + +/** + * Get the activation code. + * @param[in] creator LinphoneAccountCreator object + * @return The activation code of the LinphoneAccountCreator +**/ +LINPHONE_PUBLIC const char * linphone_account_creator_get_activation_code(const LinphoneAccountCreator *creator); /** * Set the language to use in email or SMS if supported. * @param[in] creator LinphoneAccountCreator object * @param[in] lang The language to use + * @return LinphoneLanguageOk if everything is OK, or a specific error otherwise. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_language(LinphoneAccountCreator *creator, const char *lang); +LINPHONE_PUBLIC LinphoneLanguageCheck linphone_account_creator_set_language(LinphoneAccountCreator *creator, const char *lang); /** - * Set the transport. + * Get the language use in email of SMS. * @param[in] creator LinphoneAccountCreator object - * @param[in] transport The transport to set - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error if given transport is not supported by linphone core. + * @return The language of the LinphoneAccountCreator **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_transport(LinphoneAccountCreator *creator, LinphoneTransportType transport); +LINPHONE_PUBLIC const char * linphone_account_creator_get_language(const LinphoneAccountCreator *creator); /** - * Get the transport. - * @param[in] creator LinphoneAccountCreator object - * @return The transport of the LinphoneAccountCreator -**/ -LINPHONE_PUBLIC LinphoneTransportType linphone_account_creator_get_transport(const LinphoneAccountCreator *creator); - -/** - * Set the domain. - * @param[in] creator LinphoneAccountCreator object - * @param[in] domain The domain to set - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_domain(LinphoneAccountCreator *creator, const char *domain); - -/** - * Get the domain. - * @param[in] creator LinphoneAccountCreator object - * @return The domain of the LinphoneAccountCreator -**/ -LINPHONE_PUBLIC const char * linphone_account_creator_get_domain(const LinphoneAccountCreator *creator); - -/** - * Set the route. - * @param[in] creator LinphoneAccountCreator object - * @param[in] route The route to set - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_route(LinphoneAccountCreator *creator, const char *route); - -/** - * Get the route. - * @param[in] creator LinphoneAccountCreator object - * @return The route of the LinphoneAccountCreator -**/ -LINPHONE_PUBLIC const char * linphone_account_creator_get_route(const LinphoneAccountCreator *creator); - -/** - * Set the email. + * Set the display name. * @param[in] creator LinphoneAccountCreator object * @param[in] display_name The display name to set - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. + * @return LinphoneUsernameOk if everything is OK, or a specific error otherwise. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_display_name(LinphoneAccountCreator *creator, const char *display_name); +LINPHONE_PUBLIC LinphoneUsernameCheck linphone_account_creator_set_display_name(LinphoneAccountCreator *creator, const char *display_name); /** - * Get the email. + * Get the display name. * @param[in] creator LinphoneAccountCreator object * @return The display name of the LinphoneAccountCreator **/ @@ -220,9 +267,9 @@ LINPHONE_PUBLIC const char * linphone_account_creator_get_display_name(const Lin * Set the email. * @param[in] creator LinphoneAccountCreator object * @param[in] email The email to set - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. + * @return LinphoneEmailOk if everything is OK, or a specific error otherwise. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_email(LinphoneAccountCreator *creator, const char *email); +LINPHONE_PUBLIC LinphoneEmailCheck linphone_account_creator_set_email(LinphoneAccountCreator *creator, const char *email); /** * Get the email. @@ -232,234 +279,446 @@ LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_email( LINPHONE_PUBLIC const char * linphone_account_creator_get_email(const LinphoneAccountCreator *creator); /** - * Get the LinphoneAccountCreatorCbs object associated with a LinphoneAccountCreator. + * Get the LinphoneAccountCreatorResponseCbs object associated with a LinphoneAccountCreator. * @param[in] creator LinphoneAccountCreator object - * @return The LinphoneAccountCreatorCbs object associated with the LinphoneAccountCreator. + * @return The LinphoneAccountCreatorResponseCbs object associated with the LinphoneAccountCreator. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbs * linphone_account_creator_get_callbacks(const LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneAccountCreatorResponseCbs * linphone_account_creator_get_responses_cbs(const LinphoneAccountCreator *creator); + +/** + * Get the LinphoneAccountCreatorRequestCbs object associated with a LinphoneAccountCreator. + * @param[in] creator LinphoneAccountCreator object + * @return The LinphoneAccountCreatorRequestCbs object associated with the LinphoneAccountCreator. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestCbs * linphone_account_creator_get_requests_cbs(const LinphoneAccountCreator *creator); + +/************************** End Account Creator data **************************/ + +/************************** Start Account Creator Linphone **************************/ /** * Send an XML-RPC request to test the existence of a Linphone account. * @param[in] creator LinphoneAccountCreator object - * @return LinphoneAccountCreatorOk if the request has been sent, LinphoneAccountCreatorReqFailed otherwise + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_is_account_used(LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_account_exist_custom(LinphoneAccountCreator *creator); /** * Send an XML-RPC request to create a Linphone account. * @param[in] creator LinphoneAccountCreator object - * @return LinphoneAccountCreatorOk if the request has been sent, LinphoneAccountCreatorReqFailed otherwise + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_create_account(LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_create_account_custom(LinphoneAccountCreator *creator); /** * Send an XML-RPC request to activate a Linphone account. * @param[in] creator LinphoneAccountCreator object - * @return LinphoneAccountCreatorOk if the request has been sent, LinphoneAccountCreatorReqFailed otherwise + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_activate_account(LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_activate_account_custom(LinphoneAccountCreator *creator); /** * Send an XML-RPC request to test the validation of a Linphone account. * @param[in] creator LinphoneAccountCreator object - * @return LinphoneAccountCreatorOk if the request has been sent, LinphoneAccountCreatorReqFailed otherwise + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_is_account_activated(LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_account_activated_custom(LinphoneAccountCreator *creator); /** * Send an XML-RPC request to test the existence a phone number with a Linphone account. * @param[in] creator LinphoneAccountCreator object - * @return LinphoneAccountCreatorOk if the request has been sent, LinphoneAccountCreatorReqFailed otherwise + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_is_phone_number_used(LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_phone_number_used_custom(LinphoneAccountCreator *creator); /** * Send an XML-RPC request to link a phone number with a Linphone account. * @param[in] creator LinphoneAccountCreator object - * @return LinphoneAccountCreatorOK if the request has been sent, LinphoneAccountCreatorReqFailed otherwise + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_link_phone_number_with_account(LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_link_phone_number_with_account_custom(LinphoneAccountCreator *creator); /** * Send an XML-RPC request to activate the link of a phone number with a Linphone account. * @param[in] creator LinphoneAccountCreator object - * @return LinphoneAccountCreatorOK if the request has been sent, LinphoneAccountCreatorReqFailed otherwise + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_activate_phone_number_link(LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_activate_phone_number_link_custom(LinphoneAccountCreator *creator); -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_recover_phone_account(LinphoneAccountCreator *creator); +/** + * Send an XML-RPC request to a Linphone account with the phone number. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_recover_phone_account_custom(LinphoneAccountCreator *creator); /** * Send an XML-RPC request to ask if an account is linked with a phone number * @param[in] creator LinphoneAccountCreator object * @return if this account is linked with a phone number **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_is_account_linked(LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_account_linked_custom(LinphoneAccountCreator *creator); + +/** + * Send an XML-RPC request to ask if an account is linked with a phone number + * @param[in] creator LinphoneAccountCreator object + * @param[in] new_pwd const char * : new password for the account creator + * @return LinphoneRequestOk if everything is OK, or a specific error otherwise. +**/ +// TODO viré new_pwd qui sera remplacé par le get_user_data de creator +LINPHONE_PUBLIC /*TODO*/ LinphoneRequestStatus linphone_account_creator_update_password_custom(LinphoneAccountCreator *creator); + +/************************** End Account Creator Linphone **************************/ + +/************************** Start Account Creator Requests **************************/ + +/** + * Acquire a reference to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The same LinphoneAccountCreatorRequestCbs object. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestCbs * linphone_account_creator_requests_cbs_ref(LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Release a reference to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_unref(LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Retrieve the user pointer associated with a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The user pointer associated with the LinphoneAccountCreatorRequestCbs object. +**/ +LINPHONE_PUBLIC void *linphone_account_creator_requests_cbs_get_user_data(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] ud The user pointer to associate with the LinphoneAccountCreatorRequestCbs object. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_user_data(LinphoneAccountCreatorRequestCbs *requests_cbs, void *ud); + +/** + * Get the create account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current create account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_create_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The create account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_create_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the is account exist request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current is account exist request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_exist_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The is account exist request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_exist_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the activate account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current activate account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_activate_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The activate account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_activate_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the is account activated request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current is account activated request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_activated_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The is account activated request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_activated_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the link account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current link account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_link_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The link account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_link_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the activate alias request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current link account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_activate_alias_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The activate alias request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_activate_alias_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the is alias used request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current is alias used request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_alias_used_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The is alias used request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_alias_used_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the is account linked request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current is account linked request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_linked_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The is account linked request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_linked_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the recover account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current recover account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_recover_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The recover account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_recover_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the update account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current update account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_update_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The update account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_update_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/************************** End Account Creator Requests **************************/ + +/************************** Start Account Creator Cbs **************************/ + +/** + * Acquire a reference to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The same LinphoneAccountCreatorResponseCbs object. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseCbs * linphone_account_creator_responses_cbs_ref(LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Release a reference to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_unref(LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Retrieve the user pointer associated with a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The user pointer associated with the LinphoneAccountCreatorResponseCbs object. +**/ +LINPHONE_PUBLIC void *linphone_account_creator_responses_cbs_get_user_data(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] ud The user pointer to associate with the LinphoneAccountCreatorResponseCbs object. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_user_data(LinphoneAccountCreatorResponseCbs *responses_cbs, void *ud); + +/** + * Get the create account request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current create account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_create_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The create account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_create_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/** + * Get the is account exist request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current is account exist request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_account_exist_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The is account exist request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_is_account_exist_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/** + * Get the activate account request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current activate account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_activate_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The activate account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_activate_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/** + * Get the is account activated request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current is account activated request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_account_activated_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The is account activated request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_is_account_activated_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/** + * Get the link account request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current link account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_link_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The link account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_link_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/** + * Get the activate alias request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current link account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_activate_alias_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The activate alias request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_activate_alias_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/** + * Get the is alias used request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current is alias used request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_alias_used_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The is alias used request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_is_alias_used_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/** + * Get the is account linked request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current is account linked request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_account_linked_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The is account linked request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_is_account_linked_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/** + * Get the recover account request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current recover account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_recover_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The recover account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_recover_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/** + * Get the update account request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current update account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_update_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The update account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_update_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/************************** End Account Creator Cbs **************************/ /** * Configure an account (create a proxy config and authentication info for it). * @param[in] creator LinphoneAccountCreator object * @return A LinphoneProxyConfig object if successful, NULL otherwise -**/ + **/ LINPHONE_PUBLIC LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCreator *creator); -/** - * Acquire a reference to a LinphoneAccountCreatorCbs object. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The same LinphoneAccountCreatorCbs object. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbs * linphone_account_creator_cbs_ref(LinphoneAccountCreatorCbs *cbs); - -/** - * Release a reference to a LinphoneAccountCreatorCbs object. - * @param[in] cbs LinphoneAccountCreatorCbs object. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_unref(LinphoneAccountCreatorCbs *cbs); - -/** - * Retrieve the user pointer associated with a LinphoneAccountCreatorCbs object. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The user pointer associated with the LinphoneAccountCreatorCbs object. -**/ -LINPHONE_PUBLIC void *linphone_account_creator_cbs_get_user_data(const LinphoneAccountCreatorCbs *cbs); - -/** - * Assign a user pointer to a LinphoneAccountCreatorCbs object. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @param[in] ud The user pointer to associate with the LinphoneAccountCreatorCbs object. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_user_data(LinphoneAccountCreatorCbs *cbs, void *ud); - -/** - * Retrieve the user pointer associated with a LinphoneAccountCreatorCbs object. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The user pointer associated with the LinphoneAccountCreatorCbs object. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_update_hash(const LinphoneAccountCreatorCbs *cbs); - -/** - * Assign a user pointer to a LinphoneAccountCreatorCbs object. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @param[in] cb The update hash callback to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_update_hash(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -/** - * Get the current linked tested callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The current linked tested callback. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_linked(const LinphoneAccountCreatorCbs *cbs); - -/** - * Set the linked tested callback - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @param[in] cb The existence tested callback to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_is_account_linked(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -/** - * Get the existence tested callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The current existence tested callback. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_used(const LinphoneAccountCreatorCbs *cbs); - -/** - * Set the existence tested callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @param[in] cb The existence tested callback to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_is_account_used(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -/** - * Get the create account callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The current create account callback. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_create_account(const LinphoneAccountCreatorCbs *cbs); - -/** - * Set the create account callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @param[in] cb The create account callback to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_create_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -/** - * Get the activate account callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The current activate account callback. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_activate_account(const LinphoneAccountCreatorCbs *cbs); - -/** - * Set the activate account callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @param[in] cb The activate account callback to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_activate_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -/** - * Get the link phone number with account callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The current link phone number with account callback. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_link_phone_number_with_account(const LinphoneAccountCreatorCbs *cbs); - -/** - * Set the link phone number with account callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @param[in] cb The link phone number with account callback to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_link_phone_number_with_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -/** - * Get the activate phone number link callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The current activate phone number link callback. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_activate_phone_number_link(const LinphoneAccountCreatorCbs *cbs); - -/** - * Set the activate phone number link callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @param[in] cb The activate phone number link callback to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_activate_phone_number_link(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -/** - * Get the validation tested callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The current validation tested callback. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_activated(const LinphoneAccountCreatorCbs *cbs); - -/** - * Set the validation tested callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @param[in] cb The validation tested callback to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_is_account_activated(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -/** - * Get the is phone number used callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The current is phone number used callback -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_phone_number_used(const LinphoneAccountCreatorCbs *cbs); - -/** - * Set the is phone number used callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @param[in] cb is phone number to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_is_phone_number_used(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_recover_phone_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_recover_phone_account(const LinphoneAccountCreatorCbs *cbs); - /** * @} */ diff --git a/include/linphone/types.h b/include/linphone/types.h index 4f1f3f4a3..18f73c39f 100644 --- a/include/linphone/types.h +++ b/include/linphone/types.h @@ -28,64 +28,127 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. /** - * The LinphoneAccountCreator object used to create an account on a server via XML-RPC. - * @ingroup misc + * The LinphoneAccountCreator object used to configure an account on a server via XML-RPC. + * @ingroup account_creator **/ typedef struct _LinphoneAccountCreator LinphoneAccountCreator; /** - * An object to handle the callbacks for handling the LinphoneAccountCreator operations. - * @ingroup misc + * An object to handle the requests callbacks for handling the LinphoneAccountCreator server requests. + * @ingroup account_creator **/ -typedef struct _LinphoneAccountCreatorCbs LinphoneAccountCreatorCbs; +typedef struct _LinphoneAccountCreatorRequestCbs LinphoneAccountCreatorRequestCbs; /** -* Enum describing the status of a LinphoneAccountCreator operation. -* @ingroup misc + * An object to handle the responses callbacks for handling the LinphoneAccountCreator operations. + * @ingroup account_creator **/ -typedef enum _LinphoneAccountCreatorStatus { - LinphoneAccountCreatorOK, - LinphoneAccountCreatorReqFailed, +typedef struct _LinphoneAccountCreatorResponseCbs LinphoneAccountCreatorResponseCbs; - LinphoneAccountCreatorAccountCreated, - LinphoneAccountCreatorAccountNotCreated, +/** + * Enum describing Phone number checking. + * @ingroup account_creator_checking +**/ +typedef enum _LinphonePhoneNumberCheck { + LinphonePhoneNumberOk = 0x1, /**< Phone number ok */ + LinphonePhoneNumberTooShort = 0x2, /**< Phone number too short */ + LinphonePhoneNumberTooLong = 0x4, /**< Phone number too long */ + LinphonePhoneNumberCountryCodeInvalid = 0x8, /**< Country code invalid */ + LinphonePhoneNumberInvalid = 0x10, /**< Phone number invalid */ +} LinphonePhoneNumberCheck; - LinphoneAccountCreatorAccountExist, - LinphoneAccountCreatorAccountExistWithAlias, - LinphoneAccountCreatorAccountNotExist, +/** + * A mask of #LinphonePhoneNumberCheck values + * @ingroup account_creator_checking + */ +typedef unsigned int LinphonePhoneNumberMask; - LinphoneAccountCreatorAccountActivated, - LinphoneAccountCreatorAccountAlreadyActivated, - LinphoneAccountCreatorAccountNotActivated, +/** + * Enum describing Username checking. + * @ingroup account_creator_checking +**/ +typedef enum _LinphoneUsernameCheck { + LinphoneUsernameOk, /**< Username ok */ + LinphoneUsernameTooShort, /**< Username too short */ + LinphoneUsernameTooLong, /**< Username too long */ + LinphoneUsernameInvalidCharacters, /**< Contain invalid characters */ + LinphoneUsernameInvalid, /**< Invalid username */ +} LinphoneUsernameCheck; - LinphoneAccountCreatorAccountLinked, - LinphoneAccountCreatorAccountNotLinked, +/** + * Enum describing Email checking. + * @ingroup account_creator_checking +**/ +typedef enum _LinphoneEmailCheck { + LinphoneEmailOk, /**< Email ok */ + LinphoneEmailMalformed, /**< Email malformed */ + LinphoneEmailInvalidCharacters, /**< Contain invalid characters */ +} LinphoneEmailCheck; - LinphoneAccountCreatorEmailInvalid, +/** + * Enum describing Password checking. + * @ingroup account_creator_checking +**/ +typedef enum _LinphonePasswordCheck { + LinphonePasswordOk, /**< Password ok */ + LinphonePasswordTooShort, /**< Password too short */ + LinphonePasswordTooLong, /**< Password too long */ + LinphonePasswordInvalidCharacters, /**< Contain invalid characters */ + LinphonePasswordMissingCharacters, /**< Missing specific characters */ +} LinphonePasswordCheck; - LinphoneAccountCreatorUsernameInvalid, - LinphoneAccountCreatorUsernameTooShort, - LinphoneAccountCreatorUsernameTooLong, - LinphoneAccountCreatorUsernameInvalidSize, +/** + * Enum describing language checking. + * @ingroup account_creator_checking +**/ +typedef enum _LinphoneLanguageCheck { + LinphoneLanguageOk, /**< Language ok */ +} LinphoneLanguageCheck; - LinphoneAccountCreatorPhoneNumberInvalid, - LinphoneAccountCreatorPhoneNumberTooShort, - LinphoneAccountCreatorPhoneNumberTooLong, - LinphoneAccountCreatorPhoneNumberUsedAccount, - LinphoneAccountCreatorPhoneNumberUsedAlias, - LinphoneAccountCreatorPhoneNumberNotUsed, +/** + * Enum describing Activation code checking. + * @ingroup account_creator_checking +**/ +typedef enum _LinphoneActivationCodeCheck { + LinphoneActivationCodeOk, /**< Activation code ok */ + LinphoneActivationCodeTooShort, /**< Activation code too short */ + LinphoneActivationCodeTooLong, /**< Activation code too long */ + LinphoneActivationCodeInvalidCharacters, /**< Contain invalid characters */ +} LinphoneActivationCodeCheck; - LinphoneAccountCreatorPasswordTooShort, - LinphoneAccountCreatorPasswordTooLong, +/** + * Enum describing the status of server request. + * @ingroup account_creator_request +**/ +typedef enum _LinphoneRequestStatus { + /** Request status **/ + LinphoneRequestOk, /**< Request passed */ + LinphoneRequestFailed, /**< Request failed */ + LinphoneRequestMissingArguments, /**< Request failed due to missing argument(s) */ + LinphoneRequestMissingCallbacks, /**< Request failed due to missing callback(s) */ - LinphoneAccountCreatorDomainInvalid, - LinphoneAccountCreatorRouteInvalid, - LinphoneAccountCreatorDisplayNameInvalid, - LinphoneAccountCreatorTransportNotSupported, - LinphoneAccountCreatorCountryCodeInvalid, + /** Account status **/ + /* Creation */ + LinphoneRequestAccountCreated, /**< Account created */ + LinphoneRequestAccountNotCreated, /**< Account not created */ + /* Existence */ + LinphoneRequestAccountExist, /**< Account exist */ + LinphoneRequestAccountExistWithAlias, /**< Account exist with alias */ + LinphoneRequestAccountNotExist, /**< Account not exist */ + LinphoneRequestAliasIsAccount, /**< Account was created with Alias */ + LinphoneRequestAliasExist, /**< Alias exist */ + LinphoneRequestAliasNotExist, /**< Alias not exist */ + /* Activation */ + LinphoneRequestAccountActivated, /**< Account activated */ + LinphoneRequestAccountAlreadyActivated, /**< Account already activated */ + LinphoneRequestAccountNotActivated, /**< Account not activated */ + /* Linking */ + LinphoneRequestAccountLinked, /**< Account linked */ + LinphoneRequestAccountNotLinked, /**< Account not linked */ - LinphoneAccountCreatorErrorServer, -} LinphoneAccountCreatorStatus; + /** Server **/ + LinphoneRequestErrorServer, /**< Error server */ +} LinphoneRequestStatus; struct SalAddress; diff --git a/tester/account_creator_tester.c b/tester/account_creator_tester.c index 2ae8cb6b0..39a6b4c66 100644 --- a/tester/account_creator_tester.c +++ b/tester/account_creator_tester.c @@ -19,10 +19,8 @@ #include "liblinphone_tester.h" static const char XMLRPC_URL[] = "https://sip2.linphone.org:446/xmlrpc.php"; -static const char DOMAIN_URL[] = "sip.accounttest.org"; -static const char ROUTE_URL[] = "sip2.linphone.org:5072"; -static const int TIMEOUT_REQUEST = 100000; +static const int TIMEOUT_REQUEST = 10000; /////////// LOCAL TESTS /////////// @@ -33,8 +31,8 @@ static void local_username_too_short(void) { BC_ASSERT_EQUAL( linphone_account_creator_set_username(creator, ""), - LinphoneAccountCreatorUsernameTooShort, - LinphoneAccountCreatorStatus, + LinphoneUsernameTooShort, + LinphoneUsernameCheck, "%i"); linphone_account_creator_unref(creator); @@ -46,51 +44,37 @@ static void local_username_too_long(void) { LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( - linphone_account_creator_set_username(creator, "usernametoolong"), - LinphoneAccountCreatorUsernameTooLong, - LinphoneAccountCreatorStatus, + linphone_account_creator_set_username(creator, "usernametoolongforyou"), + LinphoneUsernameTooLong, + LinphoneUsernameCheck, "%i"); linphone_account_creator_unref(creator); linphone_core_manager_destroy(marie); } -static void local_username_invalid(void) { +static void local_username_invalid_character(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_username(creator, "use!"), - LinphoneAccountCreatorUsernameInvalid, - LinphoneAccountCreatorStatus, + LinphoneUsernameInvalidCharacters, + LinphoneUsernameCheck, "%i"); linphone_account_creator_unref(creator); linphone_core_manager_destroy(marie); } -static void local_username_invalid_size(void) { - LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); - - BC_ASSERT_EQUAL( - linphone_account_creator_set_username(creator, "sizeinv"), - LinphoneAccountCreatorUsernameInvalidSize, - LinphoneAccountCreatorStatus, - "%i"); - - linphone_account_creator_unref(creator); - linphone_core_manager_destroy(marie); -} - static void local_username_ok(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_username(creator, "user"), - LinphoneAccountCreatorOK, - LinphoneAccountCreatorStatus, + LinphoneUsernameOk, + LinphoneUsernameCheck, "%i"); linphone_account_creator_unref(creator); @@ -105,8 +89,8 @@ static void local_password_too_short(void) { BC_ASSERT_EQUAL( linphone_account_creator_set_password(creator, ""), - LinphoneAccountCreatorPasswordTooShort, - LinphoneAccountCreatorStatus, + LinphonePasswordTooShort, + LinphonePasswordCheck, "%i"); linphone_account_creator_unref(creator); @@ -119,8 +103,8 @@ static void local_password_too_long(void) { BC_ASSERT_EQUAL( linphone_account_creator_set_password(creator, "passwordtoolong"), - LinphoneAccountCreatorPasswordTooLong, - LinphoneAccountCreatorStatus, + LinphonePasswordTooLong, + LinphonePasswordCheck, "%i"); linphone_account_creator_unref(creator); @@ -132,9 +116,9 @@ static void local_password_ok(void) { LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( - linphone_account_creator_set_username(creator, "pass"), - LinphoneAccountCreatorOK, - LinphoneAccountCreatorStatus, + linphone_account_creator_set_password(creator, "pass"), + LinphonePasswordOk, + LinphonePasswordCheck, "%i"); linphone_account_creator_unref(creator); @@ -143,14 +127,52 @@ static void local_password_ok(void) { ////// EMAIL ////// -static void local_email_invalid(void) { +static void local_email_malformed(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_email(creator, "test.linphone.org"), - LinphoneAccountCreatorEmailInvalid, - LinphoneAccountCreatorStatus, + LinphoneEmailMalformed, + LinphoneEmailCheck, + "%i"); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_email(creator, "test@linphone"), + LinphoneEmailMalformed, + LinphoneEmailCheck, + "%i"); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_email(creator, "@linphone.org"), + LinphoneEmailMalformed, + LinphoneEmailCheck, + "%i"); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_email(creator, "linphone@.org"), + LinphoneEmailMalformed, + LinphoneEmailCheck, + "%i"); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_email(creator, ".linphone@.org"), + LinphoneEmailMalformed, + LinphoneEmailCheck, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_email_invalid_character(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_email(creator, "test@linphone.org$"), + LinphoneEmailInvalidCharacters, + LinphoneEmailCheck, "%i"); linphone_account_creator_unref(creator); @@ -163,8 +185,20 @@ static void local_email_ok(void) { BC_ASSERT_EQUAL( linphone_account_creator_set_email(creator, "test@linphone.org"), - LinphoneAccountCreatorOK, - LinphoneAccountCreatorStatus, + LinphoneEmailOk, + LinphoneEmailCheck, + "%i"); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_email(creator, "test02@linphone5252.org"), + LinphoneEmailOk, + LinphoneEmailCheck, + "%i"); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_email(creator, "9053test@50255linphone.org"), + LinphoneEmailOk, + LinphoneEmailCheck, "%i"); linphone_account_creator_unref(creator); @@ -178,9 +212,9 @@ static void local_phone_number_too_short(void) { LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( - linphone_account_creator_set_phone_number(creator, "0123", "33"), - LinphoneAccountCreatorPhoneNumberTooShort, - LinphoneAccountCreatorStatus, + linphone_account_creator_set_phone_number(creator, "0123", "33")&LinphonePhoneNumberTooShort, + LinphonePhoneNumberTooShort, + LinphonePhoneNumberCheck, "%i"); linphone_account_creator_unref(creator); @@ -192,9 +226,9 @@ static void local_phone_number_too_long(void) { LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( - linphone_account_creator_set_phone_number(creator, "01234567891011", "33"), - LinphoneAccountCreatorPhoneNumberTooLong, - LinphoneAccountCreatorStatus, + linphone_account_creator_set_phone_number(creator, "01234567891011", "33")&LinphonePhoneNumberTooLong, + LinphonePhoneNumberTooLong, + LinphonePhoneNumberCheck, "%i"); linphone_account_creator_unref(creator); @@ -206,9 +240,9 @@ static void local_phone_number_invalid(void) { LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( - linphone_account_creator_set_phone_number(creator, NULL, "33"), - LinphoneAccountCreatorPhoneNumberInvalid, - LinphoneAccountCreatorStatus, + linphone_account_creator_set_phone_number(creator, NULL, "33")&LinphonePhoneNumberInvalid, + LinphonePhoneNumberInvalid, + LinphonePhoneNumberCheck, "%i"); linphone_account_creator_unref(creator); @@ -220,68 +254,23 @@ static void local_country_code_invalid(void) { LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( - linphone_account_creator_set_phone_number(creator, "0123", ""), - LinphoneAccountCreatorCountryCodeInvalid, - LinphoneAccountCreatorStatus, + linphone_account_creator_set_phone_number(creator, "0123", "")&LinphonePhoneNumberCountryCodeInvalid, + LinphonePhoneNumberCountryCodeInvalid, + LinphonePhoneNumberCheck, "%i"); linphone_account_creator_unref(creator); linphone_core_manager_destroy(marie); } -////// TRANSPORT ////// - -static void local_transport_not_supported(void) { +static void local_phone_number_ok(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( - linphone_account_creator_set_transport(creator, (LinphoneTransportType)4), - LinphoneAccountCreatorTransportNotSupported, - LinphoneAccountCreatorStatus, - "%i"); - - linphone_account_creator_unref(creator); - linphone_core_manager_destroy(marie); -} - -static void local_transport_ok(void) { - LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); - - BC_ASSERT_EQUAL( - linphone_account_creator_set_transport(creator, LinphoneTransportTcp), - LinphoneAccountCreatorOK, - LinphoneAccountCreatorStatus, - "%i"); - - linphone_account_creator_unref(creator); - linphone_core_manager_destroy(marie); -} - -////// DOMAIN ////// - -// Not implemented -/*static void local_domain_invalid(void) { - LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); - BC_ASSERT_EQUAL( - linphone_account_creator_set_domain(creator, "sop2.linphone.org"), - LinphoneAccountCreatorDomainInvalid, - LinphoneAccountCreatorStatus, - "%i"); - linphone_account_creator_unref(creator); - linphone_core_manager_destroy(marie); -}*/ - -static void local_domain_ok(void) { - LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); - - BC_ASSERT_EQUAL( - linphone_account_creator_set_domain(creator, "sip2.linphone.org"), - LinphoneAccountCreatorOK, - LinphoneAccountCreatorStatus, + linphone_account_creator_set_phone_number(creator, "0123456789", "33")&LinphonePhoneNumberOk, + LinphonePhoneNumberOk, + LinphonePhoneNumberCheck, "%i"); linphone_account_creator_unref(creator); @@ -299,8 +288,8 @@ static LinphoneAccountCreatorStats* new_linphone_account_creator_stats(void) { return stats; } -static void account_creator_set_cb_done(LinphoneAccountCreatorCbs *cbs) { - LinphoneAccountCreatorStats *stats = (LinphoneAccountCreatorStats*) linphone_account_creator_cbs_get_user_data(cbs); +static void account_creator_set_cb_done(LinphoneAccountCreatorResponseCbs *cbs) { + LinphoneAccountCreatorStats *stats = (LinphoneAccountCreatorStats*) linphone_account_creator_responses_cbs_get_user_data(cbs); stats->cb_done++; BC_ASSERT_TRUE(stats->cb_done); } @@ -311,34 +300,36 @@ static void account_creator_set_cb_done(LinphoneAccountCreatorCbs *cbs) { BC_ASSERT_FALSE(stats->cb_done); }*/ -static void account_existence_cb(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char* resp) { - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - LinphoneAccountCreatorStatus expected_status = (LinphoneAccountCreatorStatus)linphone_account_creator_get_user_data(creator); +static void account_creator_cb(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char* resp) { + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneRequestStatus expected_status = (LinphoneRequestStatus)linphone_account_creator_requests_cbs_get_user_data( + linphone_account_creator_get_requests_cbs(creator)); BC_ASSERT_EQUAL( status, expected_status, - LinphoneAccountCreatorStatus, + LinphoneRequestStatus, "%i"); account_creator_set_cb_done(cbs); } +/****************** Start Is Account Exist ************************/ static void server_account_doesnt_exist(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_cbs_set_user_data(cbs, stats); - linphone_account_creator_set_user_data(creator, (void*)LinphoneAccountCreatorAccountNotExist); + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotExist); linphone_account_creator_set_username(creator, "user_not_exist"); - linphone_account_creator_set_route(creator, ROUTE_URL); - linphone_account_creator_set_domain(creator, DOMAIN_URL); - linphone_account_creator_cbs_set_is_account_used(cbs, account_existence_cb); + linphone_account_creator_responses_cbs_set_is_account_exist_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( - linphone_account_creator_is_account_used(creator), - LinphoneAccountCreatorOK, - LinphoneAccountCreatorStatus, + linphone_account_creator_is_account_exist(creator), + LinphoneRequestOk, + LinphoneRequestStatus, "%i"); wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); @@ -351,20 +342,20 @@ static void server_account_doesnt_exist(void) { static void server_account_exist(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_cbs_set_user_data(cbs, stats); - linphone_account_creator_set_user_data(creator, (void*)LinphoneAccountCreatorAccountExist); + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotExist); linphone_account_creator_set_username(creator, "user_exist"); - linphone_account_creator_set_route(creator, ROUTE_URL); - linphone_account_creator_set_domain(creator, DOMAIN_URL); - linphone_account_creator_cbs_set_is_account_used(cbs, account_existence_cb); + linphone_account_creator_responses_cbs_set_is_account_exist_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( - linphone_account_creator_is_account_used(creator), - LinphoneAccountCreatorOK, - LinphoneAccountCreatorStatus, + linphone_account_creator_is_account_exist(creator), + LinphoneRequestOk, + LinphoneRequestStatus, "%i"); wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); @@ -374,27 +365,1008 @@ static void server_account_exist(void) { linphone_core_manager_destroy(marie); } +static void server_is_account_exist_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_username(creator, "user_exist"); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_exist(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_is_account_exist_arg_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_is_account_exist_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_exist(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Is Account Exist ************************/ + +/****************** Start Create Account ************************/ +static void server_account_created_with_email(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountCreated); + linphone_account_creator_set_username(creator, "user_1"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_create_account_already_create_with_email(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotExist); + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_email(creator, "test@bc.com"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_account_created_with_phone_number(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotExist); + linphone_account_creator_set_username(creator, "user_1"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_create_account_already_create_as_account_with_phone_number(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotExist); + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_email(creator, "test@bc.com"); + linphone_account_creator_set_phone_number(creator, "01234567","33"); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_create_account_already_create_as_alias_with_phone_number(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotExist); + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_email(creator, "test@bc.com"); + linphone_account_creator_set_phone_number(creator, "01234567","33"); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_create_account_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_create_account_with_email_arg_username_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_create_account_with_email_arg_email_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_password(creator, "password"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_create_account_with_email_arg_password_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_create_account_with_phone_number_arg_username_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_password(creator, "password"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_create_account_with_phone_number_arg_phone_number_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_password(creator, "password"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Create Account ************************/ + +/****************** Start Is Account Activated ************************/ +static void server_is_account_activated_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_activation_code(creator, "123456789"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_activated(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_is_account_activated_arg_username_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_is_account_activated_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_activated(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Is Account Activated ************************/ + +/****************** Start Activate Account ************************/ +static void server_activate_account_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_username(creator, "user_exist"); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_account(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_account_with_email_activated_arg_username_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_activation_code(creator, "123456789"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_activate_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_account_with_email_activated_arg_activation_code_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_activate_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_account_with_phone_number_activated_arg_username_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_activation_code(creator, "123456789"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_activate_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_account_with_phone_number_activated_arg_activation_code_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_activate_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Activate Account ************************/ + +/****************** Start Link Account ************************/ +static void server_link_account_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + + BC_ASSERT_EQUAL( + linphone_account_creator_link_account(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_link_account_arg_username_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_link_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_link_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_link_account_arg_phone_number_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_link_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_link_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Link Account ************************/ + +/****************** Start Activate Alias ************************/ +static void server_activate_alias_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_activation_code(creator, "12345679"); + linphone_account_creator_set_password(creator, "password"); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_alias(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_alias_arg_username_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_activation_code(creator, "12345679"); + linphone_account_creator_set_password(creator, "password"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_activate_alias_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_alias(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_alias_arg_activation_code_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_password(creator, "password"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_activate_alias_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_alias(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_alias_arg_password_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_activation_code(creator, "12345679"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_activate_alias_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_alias(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_alias_arg_phone_number_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_activation_code(creator, "12345679"); + linphone_account_creator_set_password(creator, "password"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_activate_alias_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_alias(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Activate Alias ************************/ + +/****************** Start Is Alias Used ************************/ +static void server_is_alias_used_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_alias_used(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_is_alias_used_arg_phone_number_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_is_alias_used_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_alias_used(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Is Alias Used ************************/ + +/****************** Start Is Account Linked ************************/ +static void server_is_account_linked_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_username(creator, "user_exist"); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_linked(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_is_account_linked_arg_username_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_is_account_linked_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_linked(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Is Account Linked ************************/ + +/****************** Start Recover Account ************************/ +static void server_recover_account_with_phone_number_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + + BC_ASSERT_EQUAL( + linphone_account_creator_recover_account(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_recover_account_with_phone_number_arg_phone_number_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_recover_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_recover_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Recover Account ************************/ + +/****************** Start Update Account ************************/ +static void server_update_account_password_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_user_data(creator, "newpassword"); + + BC_ASSERT_EQUAL( + linphone_account_creator_update_account(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_update_account_password_arg_username_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_user_data(creator, "newpassword"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_responses_cbs_set_update_account_cb(cbs, account_creator_cb); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + + BC_ASSERT_EQUAL( + linphone_account_creator_update_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_update_account_password_arg_phone_number_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_user_data(creator, "newpassword"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_responses_cbs_set_update_account_cb(cbs, account_creator_cb); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + + BC_ASSERT_EQUAL( + linphone_account_creator_update_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_update_account_password_arg_password_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_user_data(creator, "newpassword"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_responses_cbs_set_update_account_cb(cbs, account_creator_cb); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + + BC_ASSERT_EQUAL( + linphone_account_creator_update_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_update_account_password_arg_new_password_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_password(creator, "password"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_responses_cbs_set_update_account_cb(cbs, account_creator_cb); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + + BC_ASSERT_EQUAL( + linphone_account_creator_update_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Update Account ************************/ + test_t account_creator_tests[] = { - TEST_NO_TAG("Local - Username too short", local_username_too_short), - TEST_NO_TAG("Local - Username too long", local_username_too_long), - TEST_NO_TAG("Local - Username invalid", local_username_invalid), - TEST_NO_TAG("Local - Username invalid size", local_username_invalid_size), - TEST_NO_TAG("Local - Username Ok", local_username_ok), - TEST_NO_TAG("Local - Password too short", local_password_too_short), - TEST_NO_TAG("Local - Password too long", local_password_too_long), - TEST_NO_TAG("Local - Password Ok", local_password_ok), - TEST_NO_TAG("Local - Email invalid", local_email_invalid), - TEST_NO_TAG("Local - Email Ok", local_email_ok), - TEST_NO_TAG("Local - Phone number too short", local_phone_number_too_short), - TEST_NO_TAG("Local - Phone number too long", local_phone_number_too_long), - TEST_NO_TAG("Local - Phone number invalid", local_phone_number_invalid), - TEST_NO_TAG("Local - Country code invalid", local_country_code_invalid), - TEST_NO_TAG("Local - Transport not supported", local_transport_not_supported), - TEST_NO_TAG("Local - Transport Ok", local_transport_ok), - //TEST_NO_TAG("Local - Domain invalid", local_domain_invalid), Not implemented - TEST_NO_TAG("Local - Domain ok", local_domain_ok), - TEST_NO_TAG("Server - Account doesn\'t exist", server_account_doesnt_exist), - TEST_NO_TAG("Server - Account exist", server_account_exist), + TEST_ONE_TAG("Local - Username too short", local_username_too_short, "Local"), + TEST_ONE_TAG("Local - Username too long", local_username_too_long, "Local"), + TEST_ONE_TAG("Local - Username invalid character", local_username_invalid_character, "Local"), + TEST_ONE_TAG("Local - Username Ok", local_username_ok, "Local"), + TEST_ONE_TAG("Local - Password too short", local_password_too_short, "Local"), + TEST_ONE_TAG("Local - Password too long", local_password_too_long, "Local"), + TEST_ONE_TAG("Local - Password Ok", local_password_ok, "Local"), + TEST_ONE_TAG("Local - Email malformed", local_email_malformed, "Local"), + TEST_ONE_TAG("Local - Email invalid character",local_email_invalid_character, "Local"), + TEST_ONE_TAG("Local - Email Ok", local_email_ok, "Local"), + TEST_ONE_TAG("Local - Phone number too short", local_phone_number_too_short, "Local"), + TEST_ONE_TAG("Local - Phone number too long", local_phone_number_too_long, "Local"), + TEST_ONE_TAG("Local - Phone number invalid", local_phone_number_invalid, "Local"), + TEST_ONE_TAG("Local - Country code invalid", local_country_code_invalid, "Local"), + TEST_ONE_TAG("Local - Phone number ok", local_phone_number_ok, "Local"), + + TEST_ONE_TAG("Server - Account doesn\'t exist", server_account_doesnt_exist, "Server"), + TEST_ONE_TAG("Server - Account exist", server_account_exist, "Server"), + TEST_ONE_TAG("Local - Is account exist callback missing", server_is_account_exist_cb_missing, "Local"), + TEST_ONE_TAG("Local - Is account exist arguments missing", server_is_account_exist_arg_missing, "Local"), + TEST_ONE_TAG("Server - Account created with email", server_account_created_with_email, "Server"), + TEST_ONE_TAG("Server - Account already create with email", server_create_account_already_create_with_email, "Server"), + TEST_ONE_TAG("Server - Account created with phone number", server_account_created_with_phone_number, "Server"), + TEST_ONE_TAG("Server - Account already created with phone number as account", server_create_account_already_create_as_account_with_phone_number, "Server"), + TEST_ONE_TAG("Server - Account already created with phone number as alias", server_create_account_already_create_as_alias_with_phone_number, "Server"), + TEST_ONE_TAG("Local - Create Account callback missing", server_create_account_cb_missing, "Local"), + TEST_ONE_TAG("Local - Create Account with email arguments username missing", server_create_account_with_email_arg_username_missing, "Local"), + TEST_ONE_TAG("Local - Create Account with email arguments email missing", server_create_account_with_email_arg_email_missing, "Local"), + TEST_ONE_TAG("Local - Create Account with email arguments password missing", server_create_account_with_email_arg_password_missing, "Local"), + TEST_ONE_TAG("Local - Create Account with phone number arguments username missing", server_create_account_with_phone_number_arg_username_missing, "Local"), + TEST_ONE_TAG("Local - Create Account with phone number arguments phone number missing", server_create_account_with_phone_number_arg_phone_number_missing, "Local"), + TEST_ONE_TAG("Local - Is account activated callbacks missing", server_is_account_activated_cb_missing, "Local"), + TEST_ONE_TAG("Local - Is account activated arguments username missing", server_is_account_activated_arg_username_missing, "Local"), + TEST_ONE_TAG("Local - Activate account callbacks missing", server_activate_account_cb_missing, "Local"), + TEST_ONE_TAG("Local - Activate account with email arguments username missing", server_activate_account_with_email_activated_arg_username_missing, "Local"), + TEST_ONE_TAG("Local - Activate account with email arguments activation code missing", server_activate_account_with_email_activated_arg_activation_code_missing, "Local"), + TEST_ONE_TAG("Local - Activate account with phone number arguments username missing", server_activate_account_with_phone_number_activated_arg_username_missing, "Local"), + TEST_ONE_TAG("Local - Activate account with phone number arguments activation code missing", server_activate_account_with_phone_number_activated_arg_activation_code_missing, "Local"), + TEST_ONE_TAG("Local - Link account callbacks missing", server_link_account_cb_missing, "Local"), + TEST_ONE_TAG("Local - Link account arguments username missing", server_link_account_arg_username_missing, "Local"), + TEST_ONE_TAG("Local - Link account arguments phone number missing", server_link_account_arg_phone_number_missing, "Local"), + TEST_ONE_TAG("Local - Activate alias callbacks missing", server_activate_alias_cb_missing, "Local"), + TEST_ONE_TAG("Local - Activate alias arguments username missing", server_activate_alias_arg_username_missing, "Local"), + TEST_ONE_TAG("Local - Activate alias arguments phone number missing", server_activate_alias_arg_phone_number_missing, "Local"), + TEST_ONE_TAG("Local - Activate alias arguments activation code missing", server_activate_alias_arg_activation_code_missing, "Local"), + TEST_ONE_TAG("Local - Activate alias arguments password missing", server_activate_alias_arg_password_missing, "Local"), + TEST_ONE_TAG("Local - Is alias used callbacks missing", server_is_alias_used_cb_missing, "Local"), + TEST_ONE_TAG("Local - Is alias used arguments phone number missing", server_is_alias_used_arg_phone_number_missing, "Local"), + TEST_ONE_TAG("Local - Is account link callbacks missing", server_is_account_linked_cb_missing, "Local"), + TEST_ONE_TAG("Local - Is account link arguments username missing", server_is_account_linked_arg_username_missing, "Local"), + TEST_ONE_TAG("Local - Recover account with phone number callbacks missing", server_recover_account_with_phone_number_cb_missing, "Local"), + TEST_ONE_TAG("Local - Recover account with phone number arguments phone number missing", server_recover_account_with_phone_number_arg_phone_number_missing, "Local"), + TEST_ONE_TAG("Local - Update account password callbacks missing", server_update_account_password_cb_missing, "Local"), + TEST_ONE_TAG("Local - Update account password arguments username missing", server_update_account_password_arg_username_missing, "Local"), + TEST_ONE_TAG("Local - Update account password arguments phone number missing", server_update_account_password_arg_phone_number_missing, "Local"), + TEST_ONE_TAG("Local - Update account password arguments password missing", server_update_account_password_arg_password_missing, "Local"), + TEST_ONE_TAG("Local - Update account password arguments new password missing", server_update_account_password_arg_new_password_missing, "Local"), }; test_suite_t account_creator_test_suite = {"Account creator", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, diff --git a/tester/rcfiles/account_creator_rc b/tester/rcfiles/account_creator_rc index 7b9aeaa87..864a56e32 100644 --- a/tester/rcfiles/account_creator_rc +++ b/tester/rcfiles/account_creator_rc @@ -3,11 +3,12 @@ domain=sip.accounttest.org password_max_length=8 password_min_length=3 username_length=4 -username_max_length=8 +username_max_length=14 username_min_length=3 username_regex=^[a-z0-9_.\-]*$ xmlrpc_url=https://sip2.linphone.org:445/wizard.php -[proxy] +[proxy_default_values] reg_proxy= realm=sip.accounttest.org +reg_identity=sip:user@sip.accounttest.org