diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ddf728a6..d64ef8f1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -312,10 +312,9 @@ else() set(EXPORT_TARGETS_NAME "Linphone") endif() - +add_subdirectory(include) add_subdirectory(java) add_subdirectory(coreapi) -add_subdirectory(include) add_subdirectory(share) if(ENABLE_CONSOLE_UI) add_subdirectory(console) diff --git a/build/android/Android.mk b/build/android/Android.mk index 705ddc2ab..e4f847250 100755 --- a/build/android/Android.mk +++ b/build/android/Android.mk @@ -27,6 +27,7 @@ LOCAL_CPP_EXTENSION := .cc LOCAL_SRC_FILES := \ account_creator.c \ + account_creator_request_engine.c \ address.c \ authentication.c \ bellesip_sal/sal_address_impl.c \ @@ -192,10 +193,10 @@ endif ifneq ($(BUILD_WEBRTC_AECM),0) LOCAL_STATIC_LIBRARIES += \ - libwebrtc_aecm + libwebrtc_aecm ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) LOCAL_STATIC_LIBRARIES += \ - libwebrtc_aecm_neon + libwebrtc_aecm_neon endif endif @@ -211,7 +212,7 @@ endif ifneq ($(BUILD_ILBC),0) LOCAL_STATIC_LIBRARIES += \ - libwebrtc_ilbc + libwebrtc_ilbc endif @@ -323,4 +324,3 @@ LOCAL_CFLAGS += -Wdeclaration-after-statement LOCAL_LDFLAGS := -Wl,-soname,$(LOCAL_MODULE_FILENAME).so $(call import-module,android/cpufeatures) - diff --git a/coreapi/CMakeLists.txt b/coreapi/CMakeLists.txt index c107c22eb..21b1c7c35 100644 --- a/coreapi/CMakeLists.txt +++ b/coreapi/CMakeLists.txt @@ -52,6 +52,7 @@ set(LINPHONE_PRIVATE_HEADER_FILES set(LINPHONE_SOURCE_FILES_C account_creator.c + account_creator_request_engine.c address.c authentication.c bellesip_sal/sal_address_impl.c diff --git a/coreapi/Makefile.am b/coreapi/Makefile.am index 1ea19e35c..41c36f4f9 100644 --- a/coreapi/Makefile.am +++ b/coreapi/Makefile.am @@ -26,6 +26,7 @@ lib_LTLIBRARIES=liblinphone.la liblinphone_la_SOURCES=\ account_creator.c \ + account_creator_request_engine.c \ address.c \ authentication.c \ buffer.c \ diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index a5dc42705..5c48e7529 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 @@ -18,6 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphone/account_creator.h" +#include "linphone/core.h" #include "private.h" #if !_WIN32 #include "regex.h" @@ -25,189 +26,28 @@ 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(LinphoneAccountCreatorResponseCbs); -BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreatorCbs, belle_sip_object_t, +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(const char* username, const char* domain, const char* display_name) { LinphoneAddress* addr; - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorOK; + int status = 0; 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); } else { @@ -215,16 +55,16 @@ static LinphoneAccountCreatorStatus validate_uri(const char* username, const cha } if (addr == NULL) { - status = LinphoneAccountCreatorUsernameInvalid; + status = 1; goto end; } if (domain && linphone_address_set_domain(addr, domain) != 0) { - status = LinphoneAccountCreatorDomainInvalid; + status = 1; } if (display_name && (!strlen(display_name) || linphone_address_set_display_name(addr, display_name) != 0)) { - status = LinphoneAccountCreatorDisplayNameInvalid; + status = 1; } linphone_address_unref(addr); end: @@ -234,20 +74,16 @@ end: 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); + if (addr == NULL) return NULL; identity = linphone_address_as_string(addr); linphone_address_unref(addr); - linphone_proxy_config_destroy(proxy); } return identity; } @@ -271,246 +107,11 @@ 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); + LinphoneAddress *identity = linphone_address_new(identity_str); char *route = NULL; char *domain = NULL; ms_free(identity_str); @@ -518,10 +119,10 @@ LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCr 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)); + route = ms_strdup_printf("%s", creator->route); } if (creator->domain) { - domain = ms_strdup_printf("%s;transport=%s", creator->domain, linphone_transport_to_string(creator->transport)); + domain = ms_strdup_printf("%s", creator->domain); } linphone_proxy_config_set_identity_address(cfg, identity); if (creator->phone_country_code) { @@ -536,10 +137,12 @@ LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCr 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 (linphone_proxy_config_get_realm(cfg) != NULL + && strcmp(linphone_proxy_config_get_realm(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,382 +178,894 @@ LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCr linphone_proxy_config_unref(cfg); return NULL; } +/************************** End Misc **************************/ + +/************************** 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) { + /*this will drop all pending requests if any*/ + if (creator->xmlrpc_session) linphone_xml_rpc_session_release(creator->xmlrpc_session); + if (creator->requests_cbs != NULL && linphone_account_creator_requests_cbs_get_destructor_cb(creator->requests_cbs) != NULL) + linphone_account_creator_requests_cbs_get_destructor_cb(creator->requests_cbs)(creator); + 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); + if (creator->domain) ms_free(creator->domain); + if (creator->route) ms_free(creator->route); +} + +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->requests_cbs = linphone_core_get_account_creator_request_engine_cbs(core); + creator->responses_cbs = linphone_account_creator_reponses_cbs_new(); + creator->core = core; + creator->xmlrpc_session = (xmlrpc_url) ? linphone_xml_rpc_session_new(core, xmlrpc_url) : NULL; + if (domain) { + linphone_account_creator_set_domain(creator, domain); + } + creator->proxy_cfg = linphone_core_create_proxy_config(core); + if (creator->requests_cbs != NULL && linphone_account_creator_requests_cbs_get_constructor_cb(creator->requests_cbs) != NULL) + linphone_account_creator_requests_cbs_get_constructor_cb(creator->requests_cbs)(creator); + 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; +} + +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(username, NULL, 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(NULL, display_name, NULL) != 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; +} + +LinphoneRequestStatus linphone_account_creator_set_domain(LinphoneAccountCreator *creator, const char *domain) { + if (domain && validate_uri(NULL, domain, NULL) != 0) { + return LinphoneRequestFailed; + } + + set_string(&creator->domain, domain, TRUE); + return LinphoneRequestOk; + } + +const char * linphone_account_creator_get_domain(const LinphoneAccountCreator *creator) { + return creator->domain; +} + +LinphoneRequestStatus linphone_account_creator_set_route(LinphoneAccountCreator *creator, const char *route) { + if (!route || linphone_proxy_config_set_route(creator->proxy_cfg, route) != 0) + return LinphoneRequestFailed; + + set_string(&creator->route, route, TRUE); + return LinphoneRequestOk; +} + +const char * linphone_account_creator_get_route(const LinphoneAccountCreator *creator) { + return creator->route; +} + +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 **************************/ + +LinphoneRequestStatus linphone_account_creator_constructor_custom(LinphoneAccountCreator *creator) { + linphone_proxy_config_set_realm(creator->proxy_cfg, "sip.linphone.org"); + linphone_proxy_config_set_route(creator->proxy_cfg, "sip.linphone.org"); + linphone_proxy_config_set_server_addr(creator->proxy_cfg, "sip.linphone.org"); + linphone_proxy_config_set_identity(creator->proxy_cfg, "sip:username@sip.linphone.org"); + + return LinphoneRequestOk; +} /****************** 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, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "get_phone_number_for_account", 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; } - request = linphone_xml_rpc_request_new_with_args("create_phone_account", LinphoneXmlRpcArgString, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "create_phone_account", 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, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "create_email_account", 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) { - request = linphone_xml_rpc_request_new_with_args("activate_phone_account", LinphoneXmlRpcArgString, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "activate_phone_account", 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, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "activate_email_account", 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, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "is_account_activated", 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, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "is_phone_number_used", 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, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "link_phone_number_with_account", 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, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "get_phone_number_for_account", 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 : LinphoneRequestAccountActivated; } - 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, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "activate_phone_number_link", 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, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "recover_phone_account", 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(LinphoneXmlRpcArgString, "update_hash", + 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/account_creator_request_engine.c b/coreapi/account_creator_request_engine.c new file mode 100644 index 000000000..fce88ea79 --- /dev/null +++ b/coreapi/account_creator_request_engine.c @@ -0,0 +1,161 @@ +/* +account_creator_request_engine.c +Copyright (C) 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 +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "linphone/account_creator_request_engine.h" +#include "linphone/core.h" +#include "private.h" + +BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneAccountCreatorRequestCbs); + +BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreatorRequestCbs, belle_sip_object_t, + NULL, // destroy + NULL, // clone + NULL, // marshal + FALSE +); + +/************************** Start Account Creator requests_cbs **************************/ +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_constructor_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->account_creator_request_constructor_cb; +} + +void linphone_account_creator_requests_cbs_set_constructor_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->account_creator_request_constructor_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_destructor_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->account_creator_request_destructor_cb; +} + +void linphone_account_creator_requests_cbs_set_destructor_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->account_creator_request_destructor_cb = cb; +} + +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_activate_alias_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->activate_alias_request_cb; +} + +void linphone_account_creator_requests_cbs_set_activate_alias_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->activate_alias_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 **************************/ + +void linphone_core_set_account_creator_request_engine_cbs(LinphoneCore *lc, LinphoneAccountCreatorRequestCbs *cbs) { + if (lc->default_ac_request_cbs) + linphone_account_creator_requests_cbs_unref(lc->default_ac_request_cbs); + lc->default_ac_request_cbs = cbs; +} + +LinphoneAccountCreatorRequestCbs* linphone_core_get_account_creator_request_engine_cbs(LinphoneCore *lc) { + return lc->default_ac_request_cbs; +} diff --git a/coreapi/bellesip_sal/sal_address_impl.c b/coreapi/bellesip_sal/sal_address_impl.c index 3ee8343d7..6a9afe9d5 100644 --- a/coreapi/bellesip_sal/sal_address_impl.c +++ b/coreapi/bellesip_sal/sal_address_impl.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. SalAddress * sal_address_new(const char *uri){ belle_sip_header_address_t* result; if (uri) { - result=belle_sip_header_address_parse (uri); + result=belle_sip_header_address_fast_parse (uri); /*may return NULL*/ } else { result = belle_sip_header_address_new(); diff --git a/coreapi/contact_providers_priv.h b/coreapi/contact_providers_priv.h index 58527c9d6..d52af6c5f 100644 --- a/coreapi/contact_providers_priv.h +++ b/coreapi/contact_providers_priv.h @@ -24,7 +24,7 @@ struct _LinphoneContactSearch{ belle_sip_object_t base; - ContactSearchID id; + LinphoneContactSearchID id; char* predicate; ContactSearchCallback cb; void* data; diff --git a/coreapi/contactprovider.c b/coreapi/contactprovider.c index ac5d9fc4d..5c1a36b75 100644 --- a/coreapi/contactprovider.c +++ b/coreapi/contactprovider.c @@ -38,7 +38,7 @@ static void linphone_contact_search_destroy( LinphoneContactSearch* req) { if( req->predicate ) ms_free(req->predicate); } -ContactSearchID linphone_contact_search_get_id(LinphoneContactSearch* obj) +LinphoneContactSearchID linphone_contact_search_get_id(LinphoneContactSearch* obj) { return obj->id; } diff --git a/coreapi/friend.c b/coreapi/friend.c index 216ba4c00..485739750 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -115,7 +115,11 @@ static LinphoneFriendPresence * find_presence_model_for_uri_or_tel(const Linphon ms_warning("Cannot find uri of tel [%s] from friend [%p] because not associated to any Linphone core object",uri_or_tel,lf); return NULL; } - iterator = lf->presence_models; + if ((iterator = lf->presence_models) == NULL) { + /*no need to move forward, just reutn to avoid useless uri parsing*/ + return NULL; + }; + uri_or_tel_addr = linphone_core_interpret_url(lf->lc, uri_or_tel); while (uri_or_tel_addr && iterator) { diff --git a/coreapi/help/CMakeLists.txt b/coreapi/help/CMakeLists.txt index 21051817a..5520284fc 100644 --- a/coreapi/help/CMakeLists.txt +++ b/coreapi/help/CMakeLists.txt @@ -26,14 +26,13 @@ if (ENABLE_DOC OR CXX_WRAPPER) if(DOXYGEN_DOT_FOUND) set(top_srcdir "${CMAKE_CURRENT_LIST_DIR}/../../") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) - file(GLOB DOC_INPUT_FILES - [^.]*.c - [^.]*.dox - ../../include/linphone/[^.]*.h + set(DOC_INPUT_FILES ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile + ${LINPHONE_HEADER_FILES} + ${CMAKE_CURRENT_SOURCE_DIR}/doxygen.dox ) add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/doc/html/index.html" COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile ${DOC_INPUT_FILES} + DEPENDS ${DOC_INPUT_FILES} ) add_custom_target(linphone-doc ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/doc/html/index.html") install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doc/html" "${CMAKE_CURRENT_BINARY_DIR}/doc/xml" diff --git a/coreapi/help/Doxyfile.in b/coreapi/help/Doxyfile.in index f01cbd771..169f6cf2a 100644 --- a/coreapi/help/Doxyfile.in +++ b/coreapi/help/Doxyfile.in @@ -228,7 +228,8 @@ TAB_SIZE = 8 # "Side Effects:". You can put \n's in the value part of an alias to insert # newlines. -ALIASES = "bctbx_list{1}=A list of \ref \1 objects. \xmlonly \1 \endxmlonly" +ALIASES = bctbx_list{1}="A list of \ref \1 objects. \xmlonly \1 \endxmlonly" +ALIASES += donotwrap="\xmlonly \endxmlonly" # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 6a74909c5..504e549f0 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -4149,6 +4149,10 @@ bool_t linphone_call_media_in_progress(LinphoneCall *call){ return ret; } +LinphoneStreamType linphone_call_stats_get_type(const LinphoneCallStats *stats) { + return stats->type; +} + float linphone_call_stats_get_sender_loss_rate(const LinphoneCallStats *stats) { const report_block_t *srb = NULL; @@ -4255,6 +4259,14 @@ LinphoneUpnpState linphone_call_stats_get_upnp_state(const LinphoneCallStats *st return stats->upnp_state; } +LinphoneAddressFamily linphone_call_stats_get_ip_family_of_remote(const LinphoneCallStats *stats) { + return (LinphoneAddressFamily)stats->rtp_remote_family; +} + +float linphone_call_stats_get_jitter_buffer_size_ms(const LinphoneCallStats *stats) { + return stats->jitter_stats.jitter_buffer_size_ms; +} + void linphone_call_start_recording(LinphoneCall *call){ if (!call->params->record_file){ ms_error("linphone_call_start_recording(): no output file specified. Use linphone_call_params_set_record_file()."); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 8e4314581..b41c20dea 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1179,7 +1179,7 @@ static void sound_config_read(LinphoneCore *lc) } lc->sound_conf.latency=0; -#ifndef __ios +#if TARGET_OS_IPHONE tmp=TRUE; #else tmp=FALSE; /* on iOS we have builtin echo cancellation.*/ @@ -1231,7 +1231,7 @@ static void certificates_config_read(LinphoneCore *lc) { static void sip_config_read(LinphoneCore *lc) { char *contact; const char *tmpstr; - LCSipTransports tr; + LinphoneSipTransports tr; int i,tmp; int ipv6_default = TRUE; @@ -1687,7 +1687,7 @@ static void video_config_read(LinphoneCore *lc){ linphone_core_set_preferred_framerate(lc,lp_config_get_float(lc->config,"video","framerate",0)); -#if defined(__ANDROID__) || defined(__ios) +#if defined(__ANDROID__) || TARGET_OS_IPHONE automatic_video=0; #endif capture=lp_config_get_int(lc->config,"video","capture",1); @@ -2072,6 +2072,23 @@ static void linphone_core_internal_subscription_state_changed(LinphoneCore *lc, } } +static void _linphone_core_init_account_creator_request_cbs(LinphoneCore *lc) { + LinphoneAccountCreatorRequestCbs *cbs = linphone_account_creator_requests_cbs_new(); + cbs->account_creator_request_constructor_cb = linphone_account_creator_constructor_custom; + cbs->account_creator_request_destructor_cb = NULL; + cbs->create_account_request_cb = linphone_account_creator_create_account_custom; + cbs->is_account_exist_request_cb = linphone_account_creator_is_account_exist_custom; + cbs->activate_account_request_cb = linphone_account_creator_activate_account_custom; + cbs->is_account_activated_request_cb = linphone_account_creator_is_account_activated_custom; + cbs->link_account_request_cb = linphone_account_creator_link_phone_number_with_account_custom; + cbs->activate_alias_request_cb = linphone_account_creator_activate_phone_number_link_custom; + cbs->is_alias_used_request_cb = linphone_account_creator_is_phone_number_used_custom; + cbs->is_account_linked_request_cb = linphone_account_creator_is_account_linked_custom; + cbs->recover_account_request_cb = linphone_account_creator_recover_phone_account_custom; + cbs->update_account_request_cb = linphone_account_creator_update_password_custom; + linphone_core_set_account_creator_request_engine_cbs(lc, cbs); +} + static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig *config, void * userdata){ const char *remote_provisioning_uri = NULL; LinphoneFactory *lfactory = linphone_factory_get(); @@ -2087,6 +2104,8 @@ static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig linphone_task_list_init(&lc->hooks); + _linphone_core_init_account_creator_request_cbs(lc); + linphone_core_cbs_set_notify_received(internal_cbs, linphone_core_internal_notify_received); linphone_core_cbs_set_subscription_state_changed(internal_cbs, linphone_core_internal_subscription_state_changed); _linphone_core_add_callbacks(lc, internal_cbs, TRUE); @@ -2442,6 +2461,14 @@ void linphone_core_get_audio_port_range(const LinphoneCore *lc, int *min_port, i *max_port = lc->rtp_conf.audio_rtp_max_port; } +LinphoneIntRange linphone_core_get_audio_port_range_2(const LinphoneCore *lc) { + LinphoneIntRange range = { + .min = lc->rtp_conf.audio_rtp_min_port, + .max = lc->rtp_conf.audio_rtp_max_port + }; + return range; +} + int linphone_core_get_video_port(const LinphoneCore *lc){ return lc->rtp_conf.video_rtp_min_port; } @@ -2451,6 +2478,14 @@ void linphone_core_get_video_port_range(const LinphoneCore *lc, int *min_port, i *max_port = lc->rtp_conf.video_rtp_max_port; } +LinphoneIntRange linphone_core_get_video_port_range_2(const LinphoneCore *lc) { + LinphoneIntRange range = { + .min = lc->rtp_conf.video_rtp_min_port, + .max = lc->rtp_conf.video_rtp_max_port + }; + return range; +} + int linphone_core_get_text_port(const LinphoneCore *lc) { return lc->rtp_conf.text_rtp_min_port; } @@ -2460,6 +2495,14 @@ void linphone_core_get_text_port_range(const LinphoneCore *lc, int *min_port, in *max_port = lc->rtp_conf.text_rtp_max_port; } +LinphoneIntRange linphone_core_get_text_port_range_2(const LinphoneCore *lc) { + LinphoneIntRange range = { + .min = lc->rtp_conf.text_rtp_min_port, + .max = lc->rtp_conf.text_rtp_max_port + }; + return range; +} + int linphone_core_get_nortp_timeout(const LinphoneCore *lc){ return lc->rtp_conf.nortp_timeout; } @@ -2557,7 +2600,7 @@ void linphone_core_set_use_rfc2833_for_dtmf(LinphoneCore *lc,bool_t use_rfc2833) } int linphone_core_get_sip_port(LinphoneCore *lc){ - LCSipTransports tr; + LinphoneSipTransports tr; linphone_core_get_sip_transports_used(lc,&tr); return tr.udp_port>0 ? tr.udp_port : (tr.tcp_port > 0 ? tr.tcp_port : tr.tls_port); } @@ -2592,7 +2635,7 @@ static void transport_error(LinphoneCore *lc, const char* transport, int port){ ms_free(msg); } -static bool_t transports_unchanged(const LCSipTransports * tr1, const LCSipTransports * tr2){ +static bool_t transports_unchanged(const LinphoneSipTransports * tr1, const LinphoneSipTransports * tr2){ return tr2->udp_port==tr1->udp_port && tr2->tcp_port==tr1->tcp_port && @@ -2614,7 +2657,7 @@ static void __linphone_core_invalidate_registers(LinphoneCore* lc){ int _linphone_core_apply_transports(LinphoneCore *lc){ Sal *sal=lc->sal; const char *anyaddr; - LCSipTransports *tr=&lc->sip_conf.transports; + LinphoneSipTransports *tr=&lc->sip_conf.transports; const char* listening_address; /*first of all invalidate all current registrations so that we can register again with new transports*/ __linphone_core_invalidate_registers(lc); @@ -2662,7 +2705,7 @@ bool_t linphone_core_sip_transport_supported(const LinphoneCore *lc, LinphoneTra } int linphone_core_set_sip_transports(LinphoneCore *lc, const LCSipTransports * tr_config /*config to be saved*/){ - LCSipTransports tr=*tr_config; + LinphoneSipTransports tr=*tr_config; if (lp_config_get_int(lc->config,"sip","sip_random_port",0)==1) { /*legacy random mode*/ @@ -2707,7 +2750,7 @@ void linphone_core_get_sip_transports_used(LinphoneCore *lc, LinphoneSipTranspor } void linphone_core_set_sip_port(LinphoneCore *lc,int port) { - LCSipTransports tr; + LinphoneSipTransports tr; memset(&tr,0,sizeof(tr)); tr.udp_port=port; linphone_core_set_sip_transports (lc,&tr); @@ -5712,6 +5755,9 @@ static void linphone_core_uninit(LinphoneCore *lc) if (lc->im_encryption_engine) { linphone_im_encryption_engine_unref(lc->im_encryption_engine); } + if (lc->default_ac_request_cbs) { + linphone_account_creator_requests_cbs_unref(lc->default_ac_request_cbs); + } linphone_core_free_payload_types(lc); if (lc->supported_formats) ms_free((void *)lc->supported_formats); diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 352258055..2eb94f8e1 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -112,33 +112,34 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreFactoryImpl__1setLogHa } static void linphone_android_ortp_log_handler(const char *domain, OrtpLogLevel lev, const char *fmt, va_list args) { - char str[4096]; - const char *levname = "undef"; - vsnprintf(str, sizeof(str) - 1, fmt, args); - str[sizeof(str) - 1] = '\0'; + char* str = bctbx_strdup_vprintf(fmt, args); + const char *levname = "undef"; - int prio; - switch(lev) { - case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; levname="debug"; break; - case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; levname="message"; break; - case ORTP_WARNING: prio = ANDROID_LOG_WARN; levname="warning"; break; - case ORTP_ERROR: prio = ANDROID_LOG_ERROR; levname="error"; break; - case ORTP_FATAL: prio = ANDROID_LOG_FATAL; levname="fatal"; break; - default: prio = ANDROID_LOG_DEFAULT; break; - } + if (str == NULL) return; - if (handler_obj) { - JNIEnv *env = ms_get_jni_env(); - jstring jdomain = env->NewStringUTF(LogDomain); - jstring jlevname = env->NewStringUTF(levname); - jstring jstr = env->NewStringUTF(str); - env->CallVoidMethod(handler_obj, loghandler_id, jdomain, (jint)lev, jlevname, jstr, NULL); - if (jdomain) env->DeleteLocalRef(jdomain); - if (jlevname) env->DeleteLocalRef(jlevname); - if (jstr) env->DeleteLocalRef(jstr); - } else { - linphone_android_log_handler(prio, str); - } + int prio; + switch(lev) { + case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; levname="debug"; break; + case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; levname="message"; break; + case ORTP_WARNING: prio = ANDROID_LOG_WARN; levname="warning"; break; + case ORTP_ERROR: prio = ANDROID_LOG_ERROR; levname="error"; break; + case ORTP_FATAL: prio = ANDROID_LOG_FATAL; levname="fatal"; break; + default: prio = ANDROID_LOG_DEFAULT; break; + } + + if (handler_obj) { + JNIEnv *env = ms_get_jni_env(); + jstring jdomain = env->NewStringUTF(LogDomain); + jstring jlevname = env->NewStringUTF(levname); + jstring jstr = env->NewStringUTF(str); + env->CallVoidMethod(handler_obj, loghandler_id, jdomain, (jint)lev, jlevname, jstr, NULL); + if (jdomain) env->DeleteLocalRef(jdomain); + if (jlevname) env->DeleteLocalRef(jlevname); + if (jstr) env->DeleteLocalRef(jstr); + } else { + linphone_android_log_handler(prio, str); + } + bctbx_free(str); } int dumbMethodForAllowingUsageOfCpuFeaturesFromStaticLibMediastream() { @@ -386,8 +387,20 @@ public: accountCreatorClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAccountCreatorImpl")); accountCreatorCtrId = env->GetMethodID(accountCreatorClass, "", "(J)V"); - accountCreatorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAccountCreator$Status")); - accountCreatorStatusFromIntId = env->GetStaticMethodID(accountCreatorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneAccountCreator$Status;"); + accountCreatorRequestStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAccountCreator$RequestStatus")); + accountCreatorRequestStatusFromIntId = env->GetStaticMethodID(accountCreatorRequestStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;"); + accountCreatorUsernameCheckClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAccountCreator$UsernameCheck")); + accountCreatorUsernameCheckFromIntId = env->GetStaticMethodID(accountCreatorUsernameCheckClass,"fromInt","(I)Lorg/linphone/core/LinphoneAccountCreator$UsernameCheck;"); + accountCreatorPasswordCheckClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAccountCreator$PasswordCheck")); + accountCreatorPasswordCheckFromIntId = env->GetStaticMethodID(accountCreatorPasswordCheckClass,"fromInt","(I)Lorg/linphone/core/LinphoneAccountCreator$PasswordCheck;"); + accountCreatorEmailCheckClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAccountCreator$EmailCheck")); + accountCreatorEmailCheckFromIntId = env->GetStaticMethodID(accountCreatorEmailCheckClass,"fromInt","(I)Lorg/linphone/core/LinphoneAccountCreator$EmailCheck;"); + accountCreatorLanguageCheckClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAccountCreator$LanguageCheck")); + accountCreatorLanguageCheckFromIntId = env->GetStaticMethodID(accountCreatorLanguageCheckClass,"fromInt","(I)Lorg/linphone/core/LinphoneAccountCreator$LanguageCheck;"); + accountCreatorCodeActivationCheckClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAccountCreator$ActivationCodeCheck")); + accountCreatorCodeActivationCheckFromIntId = env->GetStaticMethodID(accountCreatorCodeActivationCheckClass,"fromInt","(I)Lorg/linphone/core/LinphoneAccountCreator$ActivationCodeCheck;"); + accountCreatorPhoneNumberCheckClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAccountCreator$PhoneNumberCheck")); + accountCreatorPhoneNumberCheckFromIntId = env->GetStaticMethodID(accountCreatorPhoneNumberCheckClass,"fromInt","(I)Lorg/linphone/core/LinphoneAccountCreator$PhoneNumberCheck;"); } void setCore(jobject c) { @@ -424,7 +437,13 @@ public: env->DeleteGlobalRef(logCollectionUploadStateClass); env->DeleteGlobalRef(msFactoryClass); env->DeleteGlobalRef(accountCreatorClass); - env->DeleteGlobalRef(accountCreatorStatusClass); + env->DeleteGlobalRef(accountCreatorRequestStatusClass); + env->DeleteGlobalRef(accountCreatorUsernameCheckClass); + env->DeleteGlobalRef(accountCreatorPasswordCheckClass); + env->DeleteGlobalRef(accountCreatorEmailCheckClass); + env->DeleteGlobalRef(accountCreatorLanguageCheckClass); + env->DeleteGlobalRef(accountCreatorCodeActivationCheckClass); + env->DeleteGlobalRef(accountCreatorPhoneNumberCheckClass); } jobject core; @@ -538,8 +557,20 @@ public: jclass accountCreatorClass; jmethodID accountCreatorCtrId; - jclass accountCreatorStatusClass; - jmethodID accountCreatorStatusFromIntId; + jclass accountCreatorRequestStatusClass; + jmethodID accountCreatorRequestStatusFromIntId; + jclass accountCreatorUsernameCheckClass; + jmethodID accountCreatorUsernameCheckFromIntId; + jclass accountCreatorPasswordCheckClass; + jmethodID accountCreatorPasswordCheckFromIntId; + jclass accountCreatorEmailCheckClass; + jmethodID accountCreatorEmailCheckFromIntId; + jclass accountCreatorLanguageCheckClass; + jmethodID accountCreatorLanguageCheckFromIntId; + jclass accountCreatorCodeActivationCheckClass; + jmethodID accountCreatorCodeActivationCheckFromIntId; + jclass accountCreatorPhoneNumberCheckClass; + jmethodID accountCreatorPhoneNumberCheckFromIntId; }; /* @@ -8157,15 +8188,15 @@ extern "C" void Java_org_linphone_core_LinphoneXmlRpcSessionImpl_sendRequest(JNI // Account creator -static void account_creator_is_account_used(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_is_account_used(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { ms_error("cannot attach VM\n"); return; } - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8175,14 +8206,14 @@ static void account_creator_is_account_used(LinphoneAccountCreator *creator, Lin LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorIsAccountUsed","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorIsAccountUsed","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } -static void account_creator_create_account(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_create_account(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -8190,8 +8221,8 @@ static void account_creator_create_account(LinphoneAccountCreator *creator, Linp return; } - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8201,14 +8232,14 @@ static void account_creator_create_account(LinphoneAccountCreator *creator, Linp LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorAccountCreated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorAccountCreated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } -static void account_creator_activate_account(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_activate_account(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -8216,8 +8247,8 @@ static void account_creator_activate_account(LinphoneAccountCreator *creator, Li return; } - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8227,14 +8258,14 @@ static void account_creator_activate_account(LinphoneAccountCreator *creator, Li LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorAccountActivated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorAccountActivated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } -static void account_creator_link_phone_number_with_account(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_link_phone_number_with_account(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -8242,8 +8273,8 @@ static void account_creator_link_phone_number_with_account(LinphoneAccountCreato return; } - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8253,14 +8284,14 @@ static void account_creator_link_phone_number_with_account(LinphoneAccountCreato LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorAccountLinkedWithPhoneNumber","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorAccountLinkedWithPhoneNumber","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } -static void account_creator_activate_phone_number_link(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_activate_phone_number_link(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -8268,8 +8299,8 @@ static void account_creator_activate_phone_number_link(LinphoneAccountCreator *c return; } - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8279,14 +8310,14 @@ static void account_creator_activate_phone_number_link(LinphoneAccountCreator *c LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorPhoneNumberLinkActivated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorPhoneNumberLinkActivated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } -static void account_creator_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_is_account_linked(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -8294,8 +8325,8 @@ static void account_creator_is_account_linked(LinphoneAccountCreator *creator, L return; } - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8305,14 +8336,14 @@ static void account_creator_is_account_linked(LinphoneAccountCreator *creator, L LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorIsAccountLinked","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorIsAccountLinked","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } -static void account_creator_is_phone_number_used(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_is_phone_number_used(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -8320,8 +8351,8 @@ static void account_creator_is_phone_number_used(LinphoneAccountCreator *creator return; } - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8331,14 +8362,14 @@ static void account_creator_is_phone_number_used(LinphoneAccountCreator *creator LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorIsPhoneNumberUsed","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorIsPhoneNumberUsed","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } -static void account_creator_is_account_activated(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_is_account_activated(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -8346,8 +8377,8 @@ static void account_creator_is_account_activated(LinphoneAccountCreator *creator return; } - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8357,14 +8388,14 @@ static void account_creator_is_account_activated(LinphoneAccountCreator *creator LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorIsAccountActivated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorIsAccountActivated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } -static void account_creator_phone_account_recovered(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_phone_account_recovered(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -8372,8 +8403,8 @@ static void account_creator_phone_account_recovered(LinphoneAccountCreator *crea return; } - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8383,14 +8414,14 @@ static void account_creator_phone_account_recovered(LinphoneAccountCreator *crea LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorPhoneAccountRecovered","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorPhoneAccountRecovered","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } -static void account_creator_password_updated(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_password_updated(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -8398,10 +8429,8 @@ static void account_creator_password_updated(LinphoneAccountCreator *creator, Li return; } - ms_warning("test callback password updated"); - - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8411,10 +8440,10 @@ static void account_creator_password_updated(LinphoneAccountCreator *creator, Li LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorPasswordUpdated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorPasswordUpdated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } @@ -8434,26 +8463,26 @@ extern "C" void Java_org_linphone_core_LinphoneAccountCreatorImpl_unref(JNIEnv * extern "C" void Java_org_linphone_core_LinphoneAccountCreatorImpl_setListener(JNIEnv* env, jobject thiz, jlong ptr, jobject jlistener) { LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; jobject listener = env->NewGlobalRef(jlistener); - LinphoneAccountCreatorCbs *cbs; + LinphoneAccountCreatorResponseCbs *cbs; - cbs = linphone_account_creator_get_callbacks(account_creator); - linphone_account_creator_cbs_set_user_data(cbs, listener); - linphone_account_creator_cbs_set_is_account_used(cbs, account_creator_is_account_used); - linphone_account_creator_cbs_set_create_account(cbs, account_creator_create_account); - linphone_account_creator_cbs_set_activate_account(cbs, account_creator_activate_account); - linphone_account_creator_cbs_set_link_phone_number_with_account(cbs, account_creator_link_phone_number_with_account); - linphone_account_creator_cbs_set_activate_phone_number_link(cbs, account_creator_activate_phone_number_link); - linphone_account_creator_cbs_set_is_account_activated(cbs, account_creator_is_account_activated); - linphone_account_creator_cbs_set_recover_phone_account(cbs, account_creator_phone_account_recovered); - linphone_account_creator_cbs_set_is_phone_number_used(cbs, account_creator_is_phone_number_used); - linphone_account_creator_cbs_set_is_account_linked(cbs, account_creator_is_account_linked); - linphone_account_creator_cbs_set_update_hash(cbs, account_creator_password_updated); + cbs = linphone_account_creator_get_responses_cbs(account_creator); + linphone_account_creator_responses_cbs_set_user_data(cbs, listener); + linphone_account_creator_responses_cbs_set_is_account_exist_cb(cbs, account_creator_is_account_used); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_create_account); + linphone_account_creator_responses_cbs_set_activate_account_cb(cbs, account_creator_activate_account); + linphone_account_creator_responses_cbs_set_link_account_cb(cbs, account_creator_link_phone_number_with_account); + linphone_account_creator_responses_cbs_set_activate_alias_cb(cbs, account_creator_activate_phone_number_link); + linphone_account_creator_responses_cbs_set_is_account_activated_cb(cbs, account_creator_is_account_activated); + linphone_account_creator_responses_cbs_set_recover_account_cb(cbs, account_creator_phone_account_recovered); + linphone_account_creator_responses_cbs_set_is_alias_used_cb(cbs, account_creator_is_phone_number_used); + linphone_account_creator_responses_cbs_set_is_account_linked_cb(cbs, account_creator_is_account_linked); + linphone_account_creator_responses_cbs_set_update_account_cb(cbs, account_creator_password_updated); } extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setUsername(JNIEnv *env, jobject thiz, jlong ptr, jstring jusername) { const char *username = GetStringUTFChars(env, jusername); LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_username(account_creator, username); + LinphoneUsernameCheck status = linphone_account_creator_set_username(account_creator, username); ReleaseStringUTFChars(env, jusername, username); return (jint) status; } @@ -8468,7 +8497,7 @@ extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setPhoneNumber const char *phone_number = GetStringUTFChars(env, jphonenumber); const char *country_code = GetStringUTFChars(env, jcountrycode); LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_phone_number(account_creator, phone_number, country_code); + LinphonePhoneNumberMask status = linphone_account_creator_set_phone_number(account_creator, phone_number, country_code); ReleaseStringUTFChars(env, jphonenumber, phone_number); ReleaseStringUTFChars(env, jcountrycode, country_code); return (jint) status; @@ -8483,7 +8512,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneAccountCreatorImpl_getPhoneNum extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setPassword(JNIEnv *env, jobject thiz, jlong ptr, jstring jpassword) { const char *password = GetStringUTFChars(env, jpassword); LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_password(account_creator, password); + LinphonePasswordCheck status = linphone_account_creator_set_password(account_creator, password); ReleaseStringUTFChars(env, jpassword, password); return (jint) status; } @@ -8497,7 +8526,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneAccountCreatorImpl_getPassword extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setHa1(JNIEnv *env, jobject thiz, jlong ptr, jstring jha1) { const char *ha1 = GetStringUTFChars(env, jha1); LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_ha1(account_creator, ha1); + LinphonePasswordCheck status = linphone_account_creator_set_ha1(account_creator, ha1); ReleaseStringUTFChars(env, jha1, ha1); return (jint) status; } @@ -8511,7 +8540,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneAccountCreatorImpl_getHa1(JNIE extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setActivationCode(JNIEnv *env, jobject thiz, jlong ptr, jstring jcode) { const char *activation_code = GetStringUTFChars(env, jcode); LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_activation_code(account_creator, activation_code); + LinphoneActivationCodeCheck status = linphone_account_creator_set_activation_code(account_creator, activation_code); ReleaseStringUTFChars(env, jcode, activation_code); return (jint) status; } @@ -8519,55 +8548,15 @@ extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setActivationC extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setLanguage(JNIEnv *env, jobject thiz, jlong ptr, jstring jlang) { const char *lang = GetStringUTFChars(env, jlang); LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_language(account_creator, lang); + LinphoneLanguageCheck status = linphone_account_creator_set_language(account_creator, lang); ReleaseStringUTFChars(env, jlang, lang); return (jint) status; } -extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setTransport(JNIEnv *env, jobject thiz, jlong ptr, jint jtransport) { - LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_transport(account_creator, (LinphoneTransportType)jtransport); - return (jint) status; -} - -extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_getTransport(JNIEnv *env, jobject thiz, jlong ptr) { - LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneTransportType transport = linphone_account_creator_get_transport(account_creator); - return (jint) transport; -} - -extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setDomain(JNIEnv *env, jobject thiz, jlong ptr, jstring jdomain) { - const char *domain = GetStringUTFChars(env, jdomain); - LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_domain(account_creator, domain); - ReleaseStringUTFChars(env, jdomain, domain); - return (jint) status; -} - -extern "C" jstring Java_org_linphone_core_LinphoneAccountCreatorImpl_getDomain(JNIEnv *env, jobject thiz, jlong ptr) { - LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - const char *domain = linphone_account_creator_get_domain(account_creator); - return domain ? env->NewStringUTF(domain) : NULL; -} - -extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setRoute(JNIEnv *env, jobject thiz, jlong ptr, jstring jroute) { - const char *route = GetStringUTFChars(env, jroute); - LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_route(account_creator, route); - ReleaseStringUTFChars(env, jroute, route); - return (jint) status; -} - -extern "C" jstring Java_org_linphone_core_LinphoneAccountCreatorImpl_getRoute(JNIEnv *env, jobject thiz, jlong ptr) { - LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - const char *route = linphone_account_creator_get_route(account_creator); - return route ? env->NewStringUTF(route) : NULL; -} - extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setDisplayName(JNIEnv *env, jobject thiz, jlong ptr, jstring jname) { const char *name = GetStringUTFChars(env, jname); LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_display_name(account_creator, name); + LinphoneUsernameCheck status = linphone_account_creator_set_display_name(account_creator, name); ReleaseStringUTFChars(env, jname, name); return (jint) status; } @@ -8581,7 +8570,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneAccountCreatorImpl_getDisplayN extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setEmail(JNIEnv *env, jobject thiz, jlong ptr, jstring jemail) { const char *email = GetStringUTFChars(env, jemail); LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_email(account_creator, email); + LinphoneEmailCheck status = linphone_account_creator_set_email(account_creator, email); ReleaseStringUTFChars(env, jemail, email); return (jint) status; } @@ -8603,7 +8592,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneAccountCreatorImpl_getEmail(JN extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_isAccountUsed(JNIEnv *env, jobject thiz, jlong ptr) { LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - return (jint) linphone_account_creator_is_account_used(account_creator); + return (jint) linphone_account_creator_is_account_exist(account_creator); } extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_createAccount(JNIEnv *env, jobject thiz, jlong ptr) { @@ -8623,7 +8612,7 @@ extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_isAccountLinke extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_isPhoneNumberUsed(JNIEnv *env, jobject thiz, jlong ptr) { LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - return (jint) linphone_account_creator_is_phone_number_used(account_creator); + return (jint) linphone_account_creator_is_alias_used(account_creator); } extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_isAccountActivated(JNIEnv *env, jobject thiz, jlong ptr) { @@ -8633,26 +8622,28 @@ extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_isAccountActiv extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_linkPhoneNumberWithAccount(JNIEnv *env, jobject thiz, jlong ptr) { LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - return (jint) linphone_account_creator_link_phone_number_with_account(account_creator); + return (jint) linphone_account_creator_link_account(account_creator); } extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_activatePhoneNumberLink(JNIEnv *env, jobject thiz, jlong ptr) { LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - return (jint) linphone_account_creator_activate_phone_number_link(account_creator); + return (jint) linphone_account_creator_activate_alias(account_creator); } extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_recoverPhoneAccount(JNIEnv *env, jobject thiz, jlong ptr) { LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - return (jint) linphone_account_creator_recover_phone_account(account_creator); + return (jint) linphone_account_creator_recover_account(account_creator); } extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_updatePassword(JNIEnv *env, jobject thiz, jlong ptr, jstring jpasswd) { jint status; - LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - const char* passwd = GetStringUTFChars(env, jpasswd); - status = (jint) linphone_account_creator_update_password(account_creator, passwd); - ReleaseStringUTFChars(env, jpasswd, passwd); - return status; + LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; + const char* passwd = GetStringUTFChars(env, jpasswd); + linphone_account_creator_set_user_data(account_creator, (void*)passwd); + status = (jint) linphone_account_creator_update_account(account_creator); + linphone_account_creator_set_user_data(account_creator, (void*)NULL); + ReleaseStringUTFChars(env, jpasswd, passwd); + return status; } extern "C" jobject Java_org_linphone_core_LinphoneAccountCreatorImpl_configure(JNIEnv *env, jobject thiz, jlong ptr) { diff --git a/coreapi/misc.c b/coreapi/misc.c index c57dfe764..862d8f570 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -1291,7 +1291,7 @@ void linphone_core_queue_task(LinphoneCore *lc, belle_sip_source_func_t task_fun } static int get_unique_transport(LinphoneCore *lc, LinphoneTransportType *type, int *port){ - LCSipTransports tp; + LinphoneSipTransports tp; linphone_core_get_sip_transports(lc,&tp); if (tp.tcp_port==0 && tp.tls_port==0 && tp.udp_port!=0){ *type=LinphoneTransportUdp; @@ -1341,7 +1341,7 @@ int linphone_core_migrate_to_multi_transport(LinphoneCore *lc){ LinphoneTransportType tpt; int port; if (get_unique_transport(lc,&tpt,&port)==0){ - LCSipTransports newtp={0}; + LinphoneSipTransports newtp={0}; if (lp_config_get_int(lc->config,"sip","sip_random_port",0)) port=-1; ms_message("Core is using a single SIP transport, migrating proxy config and enabling multi-transport."); @@ -1884,3 +1884,22 @@ void linphone_call_update_ice_from_remote_media_description(LinphoneCall *call, linphone_call_set_symmetric_rtp(call, linphone_core_symmetric_rtp_enabled(linphone_call_get_core(call))); } } + + +/* Functions to mainpulate the LinphoneIntRange structure */ + +int linphone_int_range_get_min(const LinphoneIntRange *range) { + return range->min; +} + +int linphone_int_range_get_max(const LinphoneIntRange *range) { + return range->max; +} + +void linphone_int_range_set_min(LinphoneIntRange *range, int min) { + range->min = min; +} + +void linphone_int_range_set_max(LinphoneIntRange *range, int max) { + range->max = max; +} diff --git a/coreapi/private.h b/coreapi/private.h index b4d8d7ce2..7573bcabc 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -813,7 +813,7 @@ typedef struct sip_config int in_call_timeout; /*timeout after a call is hangup */ int delayed_timeout; /*timeout after a delayed call is resumed */ unsigned int keepalive_period; /* interval in ms between keep alive messages sent to the proxy server*/ - LCSipTransports transports; + LinphoneSipTransports transports; bool_t guess_hostname; bool_t loopback_only; bool_t ipv6_enabled; @@ -1106,6 +1106,7 @@ struct _LinphoneCore LinphoneAddress *default_rls_addr; /*default resource list server*/ LinphoneImEncryptionEngine *im_encryption_engine; + struct _LinphoneAccountCreatorRequestCbs *default_ac_request_cbs; MSBandwidthController *bw_controller; }; @@ -1391,43 +1392,80 @@ 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 account_creator_request_constructor_cb; /**< Constructor */ + LinphoneAccountCreatorRequestFunc account_creator_request_destructor_cb; /**< Destructor */ + + 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; + + /* 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 */ + + /* Deprecated */ 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; }; BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneAccountCreator); @@ -1578,7 +1616,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/coreapi/proxy.c b/coreapi/proxy.c index 1968d7896..9018ad3c1 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -64,7 +64,7 @@ LinphoneProxyConfigAddressComparisonResult linphone_proxy_config_is_server_confi LinphoneAddress *current_proxy=cfg->reg_proxy?linphone_address_new(cfg->reg_proxy):NULL; LinphoneProxyConfigAddressComparisonResult result_identity; LinphoneProxyConfigAddressComparisonResult result; - + result = linphone_proxy_config_address_equal(cfg->saved_identity,cfg->identity_address); if (result == LinphoneProxyConfigAddressDifferent) goto end; result_identity = result; @@ -629,7 +629,7 @@ char* linphone_proxy_config_normalize_phone_number(LinphoneProxyConfig *proxy, c LinphoneDialPlan dialplan = {0}; char * nationnal_significant_number = NULL; int ccc = -1; - + if (linphone_proxy_config_is_phone_number(tmpproxy, username)){ char * flatten=flatten_number(username); ms_debug("Flattened number is '%s' for '%s'",flatten, username); @@ -688,7 +688,7 @@ char* linphone_proxy_config_normalize_phone_number(LinphoneProxyConfig *proxy, c ms_free(flatten); } } - if (proxy==NULL) linphone_proxy_config_destroy(tmpproxy); + if (proxy==NULL) linphone_proxy_config_unref(tmpproxy); return result; } @@ -739,13 +739,13 @@ LinphoneAddress* linphone_proxy_config_normalize_sip_uri(LinphoneProxyConfig *pr } } - if (proxy!=NULL){ + if (proxy!=NULL && linphone_proxy_config_get_identity_address(proxy)!=NULL){ /* append the proxy domain suffix but remove any custom parameters/headers */ LinphoneAddress *uri=linphone_address_clone(linphone_proxy_config_get_identity_address(proxy)); - linphone_address_clean(uri); if (uri==NULL){ return NULL; } else { + linphone_address_clean(uri); linphone_address_set_display_name(uri,NULL); linphone_address_set_username(uri,username); return _linphone_core_destroy_addr_if_not_sip(uri); @@ -798,7 +798,7 @@ int linphone_proxy_config_done(LinphoneProxyConfig *cfg) if (cfg->commit){ linphone_proxy_config_pause_register(cfg); } - + if (linphone_proxy_config_compute_publish_params_hash(cfg)) { ms_message("Publish params have changed on proxy config [%p]",cfg); if (cfg->long_term_event) { @@ -818,7 +818,7 @@ int linphone_proxy_config_done(LinphoneProxyConfig *cfg) } else { ms_message("Publish params have not changed on proxy config [%p]",cfg); } - + linphone_proxy_config_write_all_to_config_file(cfg->lc); return 0; } diff --git a/coreapi/ringtoneplayer.c b/coreapi/ringtoneplayer.c index c6921c6f1..d3f7ae58b 100644 --- a/coreapi/ringtoneplayer.c +++ b/coreapi/ringtoneplayer.c @@ -21,11 +21,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "private.h" #include +#if __APPLE__ +#include "TargetConditionals.h" +#endif + int linphone_ringtoneplayer_start(MSFactory *factory, LinphoneRingtonePlayer* rp, MSSndCard* card, const char* ringtone, int loop_pause_ms) { return linphone_ringtoneplayer_start_with_cb(factory, rp, card, ringtone, loop_pause_ms, NULL, NULL); } -#ifdef __ios +#if TARGET_OS_IPHONE #include "ringtoneplayer_ios.h" diff --git a/coreapi/xmlrpc.c b/coreapi/xmlrpc.c index e65587d91..c7f8b7ea2 100644 --- a/coreapi/xmlrpc.c +++ b/coreapi/xmlrpc.c @@ -251,7 +251,7 @@ static void process_response_from_post_xml_rpc_request(void *data, const belle_h } -static LinphoneXmlRpcRequest * _linphone_xml_rpc_request_new(const char *method, LinphoneXmlRpcArgType return_type) { +static LinphoneXmlRpcRequest * _linphone_xml_rpc_request_new(LinphoneXmlRpcArgType return_type, const char *method) { LinphoneXmlRpcRequest *request = belle_sip_object_new(LinphoneXmlRpcRequest); request->callbacks = linphone_xml_rpc_request_cbs_new(); request->status = LinphoneXmlRpcStatusPending; @@ -306,18 +306,18 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneXmlRpcSession, belle_sip_object_t, ); -LinphoneXmlRpcRequest * linphone_xml_rpc_request_new(const char *method, LinphoneXmlRpcArgType return_type) { - LinphoneXmlRpcRequest *request = _linphone_xml_rpc_request_new(method, return_type); +LinphoneXmlRpcRequest * linphone_xml_rpc_request_new(LinphoneXmlRpcArgType return_type, const char *method) { + LinphoneXmlRpcRequest *request = _linphone_xml_rpc_request_new(return_type, method); format_request(request); return request; } -LinphoneXmlRpcRequest * linphone_xml_rpc_request_new_with_args(const char *method, LinphoneXmlRpcArgType return_type, ...) { +LinphoneXmlRpcRequest * linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgType return_type, const char *method, ...) { bool_t cont = TRUE; va_list args; LinphoneXmlRpcArgType arg_type; - LinphoneXmlRpcRequest *request = _linphone_xml_rpc_request_new(method, return_type); - va_start(args, return_type); + LinphoneXmlRpcRequest *request = _linphone_xml_rpc_request_new(return_type, method); + va_start(args, method); while (cont) { arg_type = va_arg(args, LinphoneXmlRpcArgType); switch (arg_type) { diff --git a/daemon/daemon.cc b/daemon/daemon.cc index 757276d29..dc1980e60 100644 --- a/daemon/daemon.cc +++ b/daemon/daemon.cc @@ -149,43 +149,11 @@ static ostream &printCallStatsHelper(ostream &ostr, const LinphoneCallStats *sta // ostr << prefix << "MaxJitterTs: " << stats->jitter_stats.max_jitter_ts << "\n"; ostr << prefix << "JitterBufferSizeMs: " << stats->jitter_stats.jitter_buffer_size_ms << "\n"; - const report_block_t *rrb = NULL; - if (stats->received_rtcp != NULL) { - if (stats->received_rtcp->b_cont != NULL) - msgpullup(stats->received_rtcp, -1); - if (rtcp_is_SR(stats->received_rtcp)) { - rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0); - } else if (rtcp_is_RR(stats->received_rtcp)) { - rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0); - } - } - if (rrb) { - unsigned int ij; - float flost; - ij = report_block_get_interarrival_jitter(rrb); - flost = (float) (100.0 * report_block_get_fraction_lost(rrb) / 256.0); - ostr << prefix << "Received-InterarrivalJitter: " << ij << "\n"; - ostr << prefix << "Received-FractionLost: " << flost << "\n"; - } + ostr << prefix << "Received-InterarrivalJitter: " << linphone_call_stats_get_receiver_interarrival_jitter(stats) << "\n"; + ostr << prefix << "Received-FractionLost: " << linphone_call_stats_get_receiver_loss_rate(stats) << "\n"; - const report_block_t *srb = NULL; - if (stats->sent_rtcp != NULL) { - if (stats->sent_rtcp->b_cont != NULL) - msgpullup(stats->sent_rtcp, -1); - if (rtcp_is_SR(stats->sent_rtcp)) { - srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0); - } else if (rtcp_is_RR(stats->sent_rtcp)) { - srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0); - } - } - if (srb) { - unsigned int ij; - float flost; - ij = report_block_get_interarrival_jitter(srb); - flost = (float) (100.0 * report_block_get_fraction_lost(srb) / 256.0); - ostr << prefix << "Sent-InterarrivalJitter: " << ij << "\n"; - ostr << prefix << "Sent-FractionLost: " << flost << "\n"; - } + ostr << prefix << "Sent-InterarrivalJitter: " << linphone_call_stats_get_sender_interarrival_jitter(stats) << "\n"; + ostr << prefix << "Sent-FractionLost: " << linphone_call_stats_get_sender_loss_rate(stats) << "\n"; return ostr; } diff --git a/gtk/setupwizard.c b/gtk/setupwizard.c index 1a002f797..96d37776d 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 { @@ -215,11 +215,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 +232,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 +243,7 @@ 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_is_account_exist(creator); return FALSE; } @@ -324,11 +324,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/CMakeLists.txt b/include/CMakeLists.txt index a26d72714..3884222bc 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -22,6 +22,7 @@ set(HEADER_FILES account_creator.h + account_creator_request_engine.h address.h auth_info.h buffer.h diff --git a/include/linphone/Makefile.am b/include/linphone/Makefile.am index 55e8edb0e..7056185cf 100644 --- a/include/linphone/Makefile.am +++ b/include/linphone/Makefile.am @@ -2,6 +2,7 @@ linphone_includedir=$(includedir)/linphone linphone_include_HEADERS=\ account_creator.h \ + account_creator_request_engine.h \ address.h \ auth_info.h \ buffer.h \ diff --git a/include/linphone/account_creator.h b/include/linphone/account_creator.h index c17e8c54c..30f48556f 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,97 @@ extern "C" { #endif /** - * @addtogroup misc + * @addtogroup account_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); +/** + * Send a 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 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 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 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 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 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 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 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 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 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 +149,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 +160,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 +180,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 +195,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 +210,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 +255,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 +267,337 @@ 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. + * Set the domain. * @param[in] creator LinphoneAccountCreator object - * @return The LinphoneAccountCreatorCbs object associated with the LinphoneAccountCreator. + * @param[in] domain The domain to set + * @return LinphoneRequestOk if everything is OK, or a specific error otherwise. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbs * linphone_account_creator_get_callbacks(const LinphoneAccountCreator *creator); +LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneRequestStatus 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_DEPRECATED 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 LinphoneRequestOk if everything is OK, or a specific error otherwise. +**/ +LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneRequestStatus 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_DEPRECATED LINPHONE_PUBLIC const char * linphone_account_creator_get_route(const LinphoneAccountCreator *creator); + +/** + * Get the LinphoneAccountCreatorResponseCbs object associated with a LinphoneAccountCreator. + * @param[in] creator LinphoneAccountCreator object + * @return The LinphoneAccountCreatorResponseCbs object associated with the LinphoneAccountCreator. + * @donotwrap +**/ +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. + * @donotwrap +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestCbs * linphone_account_creator_get_requests_cbs(const LinphoneAccountCreator *creator); + +/************************** End Account Creator data **************************/ + +/************************** Start Account Creator Linphone **************************/ + +/** + * Account creator custom to set Linphone default values + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_constructor_custom(LinphoneAccountCreator *creator); /** * 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. +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_update_password_custom(LinphoneAccountCreator *creator); + +/************************** End Account Creator Linphone **************************/ + +/************************** Start Account Creator Cbs **************************/ + +/** + * Acquire a reference to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The same LinphoneAccountCreatorResponseCbs object. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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/account_creator_request_engine.h b/include/linphone/account_creator_request_engine.h new file mode 100644 index 000000000..3094887d9 --- /dev/null +++ b/include/linphone/account_creator_request_engine.h @@ -0,0 +1,282 @@ +/* +account_creator_request_engine.h +Copyright (C) 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 +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef LINPHONE_ACCOUNT_CREATOR_REQUEST_ENGINE_H_ +#define LINPHONE_ACCOUNT_CREATOR_REQUEST_ENGINE_H_ + +#include "linphone/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Function to set custom server request. + * @param[in] creator LinphoneAccountCreator object + */ +typedef LinphoneRequestStatus (*LinphoneAccountCreatorRequestFunc)(LinphoneAccountCreator *creator); + +/** + * @addtogroup account_creator_request + * @{ + */ + +/************************** Start Account Creator Requests **************************/ + +/** + * Create a new LinphoneAccountCreatorRequestCbs object. + * @return a new LinphoneAccountCreatorRequestCbs object. + * @donotwrap +**/ +LinphoneAccountCreatorRequestCbs * linphone_account_creator_requests_cbs_new(void); + +/** + * Acquire a reference to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The same LinphoneAccountCreatorRequestCbs object. + * @donotwrap +**/ +LinphoneAccountCreatorRequestCbs * linphone_account_creator_requests_cbs_ref(LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Release a reference to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @donotwrap +**/ +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. + * @donotwrap +**/ +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. + * @donotwrap +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_user_data(LinphoneAccountCreatorRequestCbs *requests_cbs, void *ud); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] cb The constructor of account creator requests. + * @donotwrap +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_constructor_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); + +/** + * Get the constructor of account creator requests. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current constructor of create account request. + * @donotwrap +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_constructor_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] cb The destructor. + * @donotwrap +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_destructor_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); + +/** + * Get the destructor of create account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current destructor of create account request. + * @donotwrap +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_destructor_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Get the create account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current create account request. + * @donotwrap +**/ +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] cb The create account request to be used. + * @donotwrap +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_create_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); + +/** + * Get the is account exist request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current is account exist request. + * @donotwrap +**/ +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] cb The is account exist request to be used. + * @donotwrap +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_exist_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); + +/** + * Get the activate account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current activate account request. + * @donotwrap +**/ +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] cb The activate account request to be used. + * @donotwrap +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_activate_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); + +/** + * Get the is account activated request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current is account activated request. + * @donotwrap +**/ +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] cb The is account activated request to be used. + * @donotwrap +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_activated_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); + +/** + * Get the link account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current link account request. + * @donotwrap +**/ +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] cb The link account request to be used. + * @donotwrap +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_link_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); + +/** + * Get the activate alias request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current link account request. + * @donotwrap +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_activate_alias_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] cb The activate alias request to be used. + * @donotwrap +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_activate_alias_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); + +/** + * Get the is alias used request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current is alias used request. + * @donotwrap +**/ +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] cb The is alias used request to be used. + * @donotwrap +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_alias_used_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); + +/** + * Get the is account linked request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current is account linked request. + * @donotwrap +**/ +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] cb The is account linked request to be used. + * @donotwrap +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_linked_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); + +/** + * Get the recover account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current recover account request. + * @donotwrap +**/ +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] cb The recover account request to be used. + * @donotwrap +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_recover_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); + +/** + * Get the update account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current update account request. + * @donotwrap +**/ +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] cb The update account request to be used. + * @donotwrap +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_update_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); + +/************************** End Account Creator Requests **************************/ + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* LINPHONE_ACCOUNT_CREATOR_REQUEST_ENGINE_H_ */ diff --git a/include/linphone/address.h b/include/linphone/address.h index b5f0f55f9..3ad35fa5c 100644 --- a/include/linphone/address.h +++ b/include/linphone/address.h @@ -110,6 +110,7 @@ LINPHONE_PUBLIC void linphone_address_clean(LinphoneAddress *uri); /** * Returns true if address refers to a secure location (sips) * @deprecated use linphone_address_get_secure() + * @donotwrap **/ LINPHONE_DEPRECATED LINPHONE_PUBLIC bool_t linphone_address_is_secure(const LinphoneAddress *addr); @@ -219,6 +220,7 @@ LINPHONE_PUBLIC const char * linphone_address_get_uri_param(const LinphoneAddres /** * Destroys a LinphoneAddress object (actually calls linphone_address_unref()). * @deprecated Use linphone_address_unref() instead + * @donotwrap **/ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_address_destroy(LinphoneAddress *u); diff --git a/include/linphone/call.h b/include/linphone/call.h index 61e48c807..d23c10867 100644 --- a/include/linphone/call.h +++ b/include/linphone/call.h @@ -303,6 +303,7 @@ LINPHONE_PUBLIC void linphone_call_cancel_dtmfs(LinphoneCall *call); * @param call #LinphoneCall * @return TRUE if part of a conference. * @deprecated Use linphone_call_get_conference() instead. + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED bool_t linphone_call_is_in_conference(const LinphoneCall *call); diff --git a/include/linphone/call_log.h b/include/linphone/call_log.h index 7ed668913..914fab331 100644 --- a/include/linphone/call_log.h +++ b/include/linphone/call_log.h @@ -211,8 +211,9 @@ LINPHONE_PUBLIC void linphone_call_log_unref(LinphoneCallLog *cl); * Destroy a LinphoneCallLog. * @param cl LinphoneCallLog object * @deprecated Use linphone_call_log_unref() instead. + * @donotwrap */ -LINPHONE_PUBLIC void linphone_call_log_destroy(LinphoneCallLog *cl); +LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_call_log_destroy(LinphoneCallLog *cl); /** * @} diff --git a/include/linphone/call_params.h b/include/linphone/call_params.h index f9517b66d..2220f595c 100644 --- a/include/linphone/call_params.h +++ b/include/linphone/call_params.h @@ -441,6 +441,7 @@ LINPHONE_PUBLIC void linphone_call_params_clear_custom_sdp_media_attributes(Linp * Destroy a LinphoneCallParams object. * @param[in] cp LinphoneCallParams object * @deprecated Use linphone_call_params_unref() instead. + * @donotwrap **/ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_call_params_destroy(LinphoneCallParams *cp); diff --git a/include/linphone/call_stats.h b/include/linphone/call_stats.h index a56a71548..11044c1c6 100644 --- a/include/linphone/call_stats.h +++ b/include/linphone/call_stats.h @@ -68,6 +68,13 @@ struct _LinphoneCallStats { bool_t rtcp_received_via_mux; /*private flag, for non-regression test only*/ }; +/** + * Get the type of the stream the stats refer to. + * @param[in] stats LinphoneCallStats object + * @return The type of the stream the stats refer to + */ +LINPHONE_PUBLIC LinphoneStreamType linphone_call_stats_get_type(const LinphoneCallStats *stats); + /** * Get the local loss rate since last report * @return The sender loss rate @@ -131,6 +138,20 @@ LINPHONE_PUBLIC LinphoneIceState linphone_call_stats_get_ice_state(const Linphon */ LINPHONE_PUBLIC LinphoneUpnpState linphone_call_stats_get_upnp_state(const LinphoneCallStats *stats); +/** + * Get the IP address family of the remote peer. + * @param[in] stats LinphoneCallStats object + * @return The IP address family of the remote peer. + */ +LINPHONE_PUBLIC LinphoneAddressFamily linphone_call_stats_get_ip_family_of_remote(const LinphoneCallStats *stats); + +/** + * Get the jitter buffer size in ms. + * @param[in] stats LinphoneCallStats object + * @return The jitter buffer size in ms. + */ +LINPHONE_PUBLIC float linphone_call_stats_get_jitter_buffer_size_ms(const LinphoneCallStats *stats); + /** * @} */ diff --git a/include/linphone/chat.h b/include/linphone/chat.h index fc78c9ce9..7d41e3c59 100644 --- a/include/linphone/chat.h +++ b/include/linphone/chat.h @@ -39,6 +39,7 @@ extern "C" { * @param status LinphoneChatMessageState * @param ud application user data * @deprecated Use LinphoneChatMessageCbsMsgStateChangedCb instead. + * @donotwrap */ typedef void (*LinphoneChatMessageStateChangedCb)(LinphoneChatMessage* msg,LinphoneChatMessageState state,void* ud); @@ -80,6 +81,7 @@ typedef void (*LinphoneChatMessageCbsFileTransferProgressIndicationCb)(LinphoneC * Destroy a LinphoneChatRoom. * @param cr #LinphoneChatRoom object * @deprecated Use linphone_chat_room_unref() instead. + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_room_destroy(LinphoneChatRoom *cr); /** @@ -150,6 +152,7 @@ LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_room_get_peer_address(Linph * @deprecated Use linphone_chat_room_send_chat_message() instead. * @param cr #LinphoneChatRoom object * @param msg message to be sent + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg); @@ -162,6 +165,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_room_send_message(Linphon * @deprecated Use linphone_chat_room_send_chat_message() instead. * @note The LinphoneChatMessage must not be destroyed until the the callback is called. * The LinphoneChatMessage reference is transfered to the function and thus doesn't need to be unref'd by the application. + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_room_send_message2(LinphoneChatRoom *cr, LinphoneChatMessage* msg,LinphoneChatMessageStateChangedCb status_cb,void* ud); @@ -172,6 +176,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_room_send_message2(Linpho * The state of the message sending will be notified via the callbacks defined in the LinphoneChatMessageCbs object that can be obtained * by calling linphone_chat_message_get_callbacks(). * The LinphoneChatMessage reference is transfered to the function and thus doesn't need to be unref'd by the application. + * @donotwrap */ LINPHONE_PUBLIC void linphone_chat_room_send_chat_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg); @@ -244,6 +249,7 @@ LINPHONE_PUBLIC int linphone_chat_room_get_unread_messages_count(LinphoneChatRoo /** * Returns back pointer to #LinphoneCore object. * @deprecated use linphone_chat_room_get_core() + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneCore* linphone_chat_room_get_lc(LinphoneChatRoom *cr); @@ -426,6 +432,7 @@ LINPHONE_PUBLIC void linphone_chat_message_set_to_be_stored(LinphoneChatMessage * @param status_cb LinphoneChatMessageStateChangeCb status callback invoked when file is downloaded or could not be downloaded * @param ud user data * @deprecated Use linphone_chat_message_download_file() instead. + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_message_start_file_download(LinphoneChatMessage* message, LinphoneChatMessageStateChangedCb status_cb, void* ud); @@ -444,6 +451,7 @@ LINPHONE_PUBLIC void linphone_chat_message_cancel_file_transfer(LinphoneChatMess /** * Resend a chat message if it is in the 'not delivered' state for whatever reason. * @param[in] msg LinphoneChatMessage object + * @donotwrap */ LINPHONE_PUBLIC void linphone_chat_message_resend(LinphoneChatMessage *msg); diff --git a/include/linphone/conference.h b/include/linphone/conference.h index a5e3e8890..1334da06c 100644 --- a/include/linphone/conference.h +++ b/include/linphone/conference.h @@ -61,6 +61,7 @@ LINPHONE_PUBLIC void linphone_conference_params_unref(LinphoneConferenceParams * * Free a #LinphoneConferenceParams * @param params #LinphoneConferenceParams to free * @deprecated Use linphone_conference_params_unref() instead. + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_conference_params_free(LinphoneConferenceParams *params); diff --git a/include/linphone/contactprovider.h b/include/linphone/contactprovider.h index bb435cd41..7dd83974a 100644 --- a/include/linphone/contactprovider.h +++ b/include/linphone/contactprovider.h @@ -28,7 +28,7 @@ extern "C" { /* LinphoneContactSearchRequest */ void linphone_contact_search_init(LinphoneContactSearch *obj, const char *predicate, ContactSearchCallback cb, void *cb_data); -ContactSearchID linphone_contact_search_get_id(LinphoneContactSearch *obj); +LinphoneContactSearchID linphone_contact_search_get_id(LinphoneContactSearch *obj); const char* linphone_contact_search_get_predicate(LinphoneContactSearch *obj); void linphone_contact_search_invoke_cb(LinphoneContactSearch *req, MSList *friends); LINPHONE_PUBLIC LinphoneContactSearch* linphone_contact_search_ref(void *obj); diff --git a/include/linphone/core.h b/include/linphone/core.h index 51714ed15..599a6a1b7 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "linphone/sipsetup.h" #include "linphone/account_creator.h" +#include "linphone/account_creator_request_engine.h" #include "linphone/address.h" #include "linphone/auth_info.h" #include "linphone/buffer.h" @@ -183,24 +184,28 @@ typedef LinphoneCoreCbsRegistrationStateChangedCb LinphoneCoreRegistrationStateC /** * Callback prototype * @deprecated + * @donotwrap */ typedef void (*ShowInterfaceCb)(LinphoneCore *lc); /** * Callback prototype * @deprecated + * @donotwrap */ typedef void (*DisplayStatusCb)(LinphoneCore *lc, const char *message); /** * Callback prototype * @deprecated + * @donotwrap */ typedef void (*DisplayMessageCb)(LinphoneCore *lc, const char *message); /** * Callback prototype * @deprecated + * @donotwrap */ typedef void (*DisplayUrlCb)(LinphoneCore *lc, const char *message, const char *url); @@ -288,11 +293,12 @@ typedef LinphoneCoreCbsCallLogUpdatedCb LinphoneCoreCallLogUpdatedCb; /** * Callback prototype - * @deprecated use #LinphoneCoreMessageReceivedCb instead. * @param lc #LinphoneCore object * @param room #LinphoneChatRoom involved in this conversation. Can be be created by the framework in case \link #LinphoneAddress the from \endlink is not present in any chat room. * @param from #LinphoneAddress from * @param message incoming message + * @deprecated use #LinphoneCoreMessageReceivedCb instead. + * @donotwrap */ typedef void (*LinphoneCoreTextMessageReceivedCb)(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message); @@ -604,6 +610,7 @@ LINPHONE_PUBLIC void *linphone_core_cbs_get_user_data(const LinphoneCoreCbs *cbs * This is meant only to be called from a callback to be able to get the user_data associated with the #LinphoneCoreCbs that is calling the callback. * @param lc the linphonecore * @return the #LinphoneCoreCbs that has called the last callback + * @donotwrap */ LINPHONE_PUBLIC LinphoneCoreCbs *linphone_core_get_current_callbacks(const LinphoneCore *lc); @@ -1094,29 +1101,25 @@ LINPHONE_PUBLIC void linphone_core_set_log_level_mask(unsigned int loglevel); /** * Enable logs in supplied FILE*. - * - * @deprecated Use #linphone_core_set_log_file and #linphone_core_set_log_level instead. - * * @param file a C FILE* where to fprintf logs. If null stdout is used. - * + * @deprecated Use #linphone_core_set_log_file and #linphone_core_set_log_level instead. + * @donotwrap **/ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_enable_logs(FILE *file); /** * Enable logs through the user's supplied log callback. - * - * @deprecated Use #linphone_core_set_log_handler and #linphone_core_set_log_level instead. - * * @param logfunc The address of a OrtpLogFunc callback whose protoype is * typedef void (*OrtpLogFunc)(OrtpLogLevel lev, const char *fmt, va_list args); - * + * @deprecated Use #linphone_core_set_log_handler and #linphone_core_set_log_level instead. + * @donotwrap **/ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc); /** * Entirely disable logging. - * * @deprecated Use #linphone_core_set_log_level instead. + * @donotwrap **/ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_disable_logs(void); @@ -1138,11 +1141,13 @@ LINPHONE_PUBLIC const char *linphone_core_get_user_agent(LinphoneCore *lc); /** * @deprecated Use #linphone_core_get_user_agent instead. + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_core_get_user_agent_name(void); /** * @deprecated Use #linphone_core_get_user_agent instead. + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_core_get_user_agent_version(void); @@ -1169,6 +1174,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_core_get_user_agent_ver * callbacks) using linphone_core_get_user_data(). * @see linphone_core_new_with_config * @deprecated Use linphone_factory_create_core() instead. + * @donotwrap **/ LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable, const char *config_path, const char *factory_config_path, void* userdata); @@ -1185,6 +1191,7 @@ LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneCore *linphone_core_new(const Linpho * callbacks) using linphone_core_get_user_data(). * @see linphone_core_new * @deprecated Use linphone_factory_create_core_with_config() instead. + * @donotwrap **/ LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneCore *linphone_core_new_with_config(const LinphoneCoreVTable *vtable, LpConfig *config, void *userdata); @@ -1228,6 +1235,7 @@ LINPHONE_PUBLIC void linphone_core_iterate(LinphoneCore *lc); * @param vtable a LinphoneCoreVTable structure holding your application callbacks. Object is owned by linphone core until linphone_core_remove_listener. * @param lc object * @deprecated Use linphone_core_add_callbacks() instead. + * @donotwrap */ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_add_listener(LinphoneCore *lc, LinphoneCoreVTable *vtable); @@ -1246,6 +1254,7 @@ LINPHONE_PUBLIC void linphone_core_add_callbacks(LinphoneCore *lc, LinphoneCoreC * @param lc object * @param vtable a LinphoneCoreVTable structure holding your application callbacks. * @deprecated Use linphone_core_remove_callbacks() instead. + * @donotwrap */ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_remove_listener(LinphoneCore *lc, const LinphoneCoreVTable *vtable); @@ -1631,7 +1640,7 @@ LINPHONE_PUBLIC LinphoneCall *linphone_core_get_call_by_remote_address2(Linphone * This function only works during calls. The dtmf is automatically played to the user. * @param lc The LinphoneCore object * @param dtmf The dtmf name specified as a char, such as '0', '#' etc... - * + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_send_dtmf(LinphoneCore *lc, char dtmf); @@ -2011,6 +2020,7 @@ LINPHONE_PUBLIC bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, cons * @return TRUE if the payload type represents a VBR codec, FALSE if disabled. * @ingroup media_parameters * @deprecated Use linphone_payload_type_is_vbr() instead + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED bool_t linphone_core_payload_type_is_vbr(LinphoneCore *lc, const LinphonePayloadType *pt); @@ -2070,6 +2080,7 @@ LINPHONE_PUBLIC LinphonePayloadType* linphone_core_find_payload_type(LinphoneCor * Returns the payload type number assigned for this codec. * @ingroup media_parameters * @deprecated Use linphone_payload_type_get_number() instead + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_payload_type_number(LinphoneCore *lc, const PayloadType *pt); @@ -2078,6 +2089,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_payload_type_number(Li * to override the automatic assignment mechanism. * @ingroup media_parameters * @deprecated Use linphone_payload_type_set_number() instead + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_payload_type_number(LinphoneCore *lc, PayloadType *pt, int number); @@ -2135,6 +2147,7 @@ LINPHONE_PUBLIC void linphone_core_set_default_proxy_index(LinphoneCore *lc, int /** * @return the default proxy configuration, that is the one used to determine the current identity. * @deprecated Use linphone_core_get_default_proxy_config() instead. + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_default_proxy(LinphoneCore *lc, LinphoneProxyConfig **config); @@ -2223,6 +2236,20 @@ LINPHONE_PUBLIC void linphone_core_abort_authentication(LinphoneCore *lc, Linpho **/ LINPHONE_PUBLIC void linphone_core_clear_all_auth_info(LinphoneCore *lc); +/** + * Sets an default account creator request cbs in the core + * @param lc LinphoneCore object + * @param cbs LinphoneAccountCreatorRequestCbs object +**/ +LINPHONE_PUBLIC void linphone_core_set_account_creator_request_engine_cbs(LinphoneCore *lc, LinphoneAccountCreatorRequestCbs *cbs); + +/** + * Get default account creator request cbs from the core + * @param lc LinphoneCore object + * @return LinphoneAccountCreatorRequestCbs object +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestCbs* linphone_core_get_account_creator_request_engine_cbs(LinphoneCore *lc); + /** * Enable or disable the audio adaptive jitter compensation. * @param[in] lc #LinphoneCore object @@ -2301,9 +2328,16 @@ LINPHONE_PUBLIC int linphone_core_get_audio_port(const LinphoneCore *lc); * @param[out] min_port The lower bound of the audio port range being used * @param[out] max_port The upper bound of the audio port range being used * @ingroup network_parameters + * @donotwrap */ LINPHONE_PUBLIC void linphone_core_get_audio_port_range(const LinphoneCore *lc, int *min_port, int *max_port); +/** + * Overload of linphone_core_get_audio_port_range(). + * @ingroup network_parameters + */ +LINPHONE_PUBLIC LinphoneIntRange linphone_core_get_audio_port_range_2(const LinphoneCore *lc); + /** * Gets the UDP port used for video streaming. * @param[in] lc LinphoneCore object @@ -2318,9 +2352,16 @@ LINPHONE_PUBLIC int linphone_core_get_video_port(const LinphoneCore *lc); * @param[out] min_port The lower bound of the video port range being used * @param[out] max_port The upper bound of the video port range being used * @ingroup network_parameters + * @donotwrap */ LINPHONE_PUBLIC void linphone_core_get_video_port_range(const LinphoneCore *lc, int *min_port, int *max_port); +/** + * Overload of linphone_core_get_video_port_range(). + * @ingroup network_parameters + */ +LINPHONE_PUBLIC LinphoneIntRange linphone_core_get_video_port_range_2(const LinphoneCore *lc); + /** * Gets the UDP port used for text streaming. * @param[in] lc LinphoneCore object @@ -2335,9 +2376,16 @@ LINPHONE_PUBLIC int linphone_core_get_text_port(const LinphoneCore *lc); * @param[out] min_port The lower bound of the text port range being used * @param[out] max_port The upper bound of the text port range being used * @ingroup network_parameters + * @donotwrap */ LINPHONE_PUBLIC void linphone_core_get_text_port_range(const LinphoneCore *lc, int *min_port, int *max_port); +/** + * Overload of linphone_core_get_text_port_range(). + * @ingroup network_parameters + */ +LINPHONE_PUBLIC LinphoneIntRange linphone_core_get_text_port_range_2(const LinphoneCore *lc); + /** * Gets the value of the no-rtp timeout. * @@ -2455,8 +2503,9 @@ LINPHONE_PUBLIC bool_t linphone_core_get_use_rfc2833_for_dtmf(LinphoneCore *lc); * @param[in] port The UDP port to be used by SIP * @ingroup network_parameters * @deprecated use linphone_core_set_sip_transports() instead. + * @donotwrap **/ -LINPHONE_PUBLIC void linphone_core_set_sip_port(LinphoneCore *lc, int port); +LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_sip_port(LinphoneCore *lc, int port); /** * Gets the UDP port used by SIP. @@ -2464,8 +2513,9 @@ LINPHONE_PUBLIC void linphone_core_set_sip_port(LinphoneCore *lc, int port); * @return The UDP port used by SIP * @ingroup network_parameters * @deprecated use linphone_core_get_sip_transports() instead. + * @donotwrap **/ -LINPHONE_PUBLIC int linphone_core_get_sip_port(LinphoneCore *lc); +LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_sip_port(LinphoneCore *lc); /** * Sets the ports to be used for each of transport (UDP or TCP) @@ -2486,6 +2536,7 @@ LINPHONE_PUBLIC int linphone_core_set_sip_transports(LinphoneCore *lc, const Lin * @param[out] transports A #LinphoneSipTransports structure that will receive the configured ports * @return 0 * @ingroup network_parameters + * @donotwrap **/ LINPHONE_PUBLIC int linphone_core_get_sip_transports(LinphoneCore *lc, LinphoneSipTransports *transports); @@ -2496,6 +2547,7 @@ LINPHONE_PUBLIC int linphone_core_get_sip_transports(LinphoneCore *lc, LinphoneS * @param[in] lc LinphoneCore object * @param[out] tr A #LinphoneSipTransports structure that will receive the ports being used * @ingroup network_parameters + * @donotwrap **/ LINPHONE_PUBLIC void linphone_core_get_sip_transports_used(LinphoneCore *lc, LinphoneSipTransports *tr); @@ -2637,6 +2689,7 @@ LINPHONE_PUBLIC const char *linphone_core_get_nat_address(const LinphoneCore *lc * @param[in] pol The #LinphoneFirewallPolicy to use. * @ingroup network_parameters * @deprecated Use linphone_core_set_nat_policy() instead. + * @donotwrap */ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy pol); @@ -2645,7 +2698,8 @@ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_set_firewall_policy(Linph * @param[in] lc #LinphoneCore object. * @return The #LinphoneFirewallPolicy that is being used. * @ingroup network_parameters - * @deprecated Use linphone_core_get_nat_policy() instead. + * @deprecated Use linphone_core_get_nat_policy() instead + * @donotwrap */ LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneFirewallPolicy linphone_core_get_firewall_policy(const LinphoneCore *lc); @@ -2714,6 +2768,7 @@ LINPHONE_PUBLIC bool_t linphone_core_sound_device_can_playback(LinphoneCore *lc, * Get ring sound level in 0-100 scale. * @ingroup media_parameters * @deprecated + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_ring_level(LinphoneCore *lc); @@ -2721,6 +2776,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_ring_level(LinphoneCor * Get playback sound level in 0-100 scale. * @ingroup media_parameters * @deprecated + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_play_level(LinphoneCore *lc); @@ -2728,6 +2784,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_play_level(LinphoneCor * Get sound capture level in 0-100 scale. * @ingroup media_parameters * @deprecated + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_rec_level(LinphoneCore *lc); @@ -2735,6 +2792,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_rec_level(LinphoneCore * Set sound ring level in 0-100 scale. * @ingroup media_parameters * @deprecated + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_ring_level(LinphoneCore *lc, int level); @@ -2742,6 +2800,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_ring_level(LinphoneCo * Set sound playback level in 0-100 scale. * @deprecated * @ingroup media_parameters + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_play_level(LinphoneCore *lc, int level); @@ -2749,6 +2808,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_play_level(LinphoneCo * Set sound capture level in 0-100 scale. * @deprecated * @ingroup media_parameters + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_rec_level(LinphoneCore *lc, int level); @@ -3021,12 +3081,14 @@ bool_t linphone_core_agc_enabled(const LinphoneCore *lc); /** * @deprecated Use #linphone_core_enable_mic instead. + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_mute_mic(LinphoneCore *lc, bool_t muted); /** * Get mic state. * @deprecated Use #linphone_core_mic_enabled instead + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED bool_t linphone_core_is_mic_muted(LinphoneCore *lc); @@ -3170,6 +3232,7 @@ LINPHONE_PUBLIC bool_t linphone_core_video_supported(LinphoneCore *lc); * @param display_enabled indicates whether video display should be shown * @ingroup media_parameters * @deprecated Use #linphone_core_enable_video_capture and #linphone_core_enable_video_display instead. + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_enable_video(LinphoneCore *lc, bool_t vcap_enabled, bool_t display_enabled); @@ -3732,6 +3795,7 @@ LINPHONE_PUBLIC LinphoneConfig * linphone_core_get_config(LinphoneCore *lc); * @param[in] filename The filename of the config file to read to fill the instantiated LpConfig * @ingroup misc * @deprecated Use linphone_core_create_config() instead. + * @donotwrap */ LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneConfig * linphone_core_create_lp_config(LinphoneCore *lc, const char *filename); @@ -3758,6 +3822,7 @@ LINPHONE_PUBLIC const bctbx_list_t * linphone_core_get_sip_setups(LinphoneCore * * @param[in] lc LinphoneCore object * @ingroup initializing * @deprecated Use linphone_core_unref() instead. + * @donotwrap **/ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_destroy(LinphoneCore *lc); @@ -4805,8 +4870,9 @@ LINPHONE_PUBLIC LinphoneFriend * linphone_core_create_friend_with_address(Linpho * @param[in] alternative_contact sip uri used to redirect call in state #LinphoneStatusMoved * @param[in] os #LinphoneOnlineStatus * @deprecated Use linphone_core_set_presence_model() instead + * @donotwrap */ -LINPHONE_PUBLIC void linphone_core_set_presence_info(LinphoneCore *lc,int minutes_away,const char *alternative_contact,LinphoneOnlineStatus os); +LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_presence_info(LinphoneCore *lc,int minutes_away,const char *alternative_contact,LinphoneOnlineStatus os); /** * Set my presence model @@ -4820,8 +4886,9 @@ LINPHONE_PUBLIC void linphone_core_set_presence_model(LinphoneCore *lc, Linphone * @param[in] lc #LinphoneCore object * @return #LinphoneOnlineStatus * @deprecated Use linphone_core_get_presence_model() instead + * @donotwrap */ -LINPHONE_PUBLIC LinphoneOnlineStatus linphone_core_get_presence_info(const LinphoneCore *lc); +LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneOnlineStatus linphone_core_get_presence_info(const LinphoneCore *lc); /** * Get my presence model @@ -4846,8 +4913,9 @@ LINPHONE_PUBLIC void linphone_core_set_consolidated_presence(LinphoneCore *lc, L /** * @deprecated Use linphone_core_interpret_url() instead + * @donotwrap */ -LINPHONE_PUBLIC void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char **result); +LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char **result); /** * Add a friend to the current buddy list, if \link linphone_friend_enable_subscribes() subscription attribute \endlink is set, a SIP SUBSCRIBE message is sent. @@ -4862,8 +4930,9 @@ LINPHONE_PUBLIC void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend * * @param lc #LinphoneCore object * @param fr #LinphoneFriend to remove * @deprecated use linphone_friend_list_remove_friend() instead. + * @donotwrap */ -LINPHONE_PUBLIC void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend *fr); +LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend *fr); /** * Black list a friend. same as linphone_friend_set_inc_subscribe_policy() with #LinphoneSPDeny policy; @@ -4877,8 +4946,9 @@ LINPHONE_PUBLIC void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneF * @param[in] lc #LinphoneCore object * @return \bctbx_list{LinphoneFriend} * @deprecated use linphone_core_get_friends_lists() or linphone_friend_list_get_friends() instead. + * @donotwrap */ -LINPHONE_PUBLIC const bctbx_list_t * linphone_core_get_friend_list(const LinphoneCore *lc); +LINPHONE_PUBLIC LINPHONE_DEPRECATED const bctbx_list_t * linphone_core_get_friend_list(const LinphoneCore *lc); /** * Notify all friends that have subscribed @@ -4893,8 +4963,9 @@ LINPHONE_PUBLIC void linphone_core_notify_all_friends(LinphoneCore *lc, Linphone * @param[in] addr The address to use to search the friend. * @return The #LinphoneFriend object corresponding to the given address. * @deprecated use linphone_core_find_friend() instead. + * @donotwrap */ -LINPHONE_PUBLIC LinphoneFriend *linphone_core_get_friend_by_address(const LinphoneCore *lc, const char *addr); +LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneFriend *linphone_core_get_friend_by_address(const LinphoneCore *lc, const char *addr); /** * Search a LinphoneFriend by its address. diff --git a/include/linphone/friend.h b/include/linphone/friend.h index f3520f857..3c1e5d1b5 100644 --- a/include/linphone/friend.h +++ b/include/linphone/friend.h @@ -35,6 +35,7 @@ extern "C" { * Contructor * @return a new empty #LinphoneFriend * @deprecated use #linphone_core_create_friend instead + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneFriend * linphone_friend_new(void); @@ -43,6 +44,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneFriend * linphone_friend_new(void); * @param addr a buddy address, must be a sip uri like sip:joe@sip.linphone.org * @return a new #LinphoneFriend with \link linphone_friend_get_address() address initialized \endlink * @deprecated use #linphone_core_create_friend_with_address instead + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneFriend *linphone_friend_new_with_address(const char *addr); @@ -56,8 +58,9 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneFriend *linphone_friend_new_with_add * Destroy a LinphoneFriend. * @param lf LinphoneFriend object * @deprecated Use linphone_friend_unref() instead. + * @donotwrap */ -LINPHONE_PUBLIC void linphone_friend_destroy(LinphoneFriend *lf); +LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_friend_destroy(LinphoneFriend *lf); /** * Set #LinphoneAddress for this friend @@ -191,8 +194,9 @@ LINPHONE_PUBLIC void linphone_friend_done(LinphoneFriend *fr); * @param[in] lf A #LinphoneFriend object * @return #LinphoneOnlineStatus * @deprecated Use linphone_friend_get_presence_model() instead + * @donotwrap */ -LINPHONE_PUBLIC LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf); +LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf); /** * Get subscription state of a friend diff --git a/include/linphone/im_encryption_engine.h b/include/linphone/im_encryption_engine.h index a65fac88e..9141c5361 100644 --- a/include/linphone/im_encryption_engine.h +++ b/include/linphone/im_encryption_engine.h @@ -22,6 +22,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "linphone/types.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * @addtogroup misc * @{ @@ -242,4 +246,8 @@ LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_generate_file_transfe * @} */ +#ifdef __cplusplus +} +#endif + #endif /* LINPHONE_IM_ENCRYPTION_ENGINE_H */ diff --git a/include/linphone/info_message.h b/include/linphone/info_message.h index 5fe3e5db2..06a59ee2a 100644 --- a/include/linphone/info_message.h +++ b/include/linphone/info_message.h @@ -77,6 +77,7 @@ LINPHONE_PUBLIC void linphone_info_message_unref(LinphoneInfoMessage *im); /** * Destroy a LinphoneInfoMessage. * @deprecated Use linphone_info_message_unref() instead. + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_info_message_destroy(LinphoneInfoMessage *im); diff --git a/include/linphone/lpconfig.h b/include/linphone/lpconfig.h index 330d7e8ff..a76a1580e 100644 --- a/include/linphone/lpconfig.h +++ b/include/linphone/lpconfig.h @@ -276,6 +276,7 @@ LINPHONE_PUBLIC void linphone_config_write_relative_file(const LinphoneConfig *l * @param data Buffer where read string will be stored * @param max_length Length of the buffer * @return 0 on success, -1 on failure + * @donotwrap */ LINPHONE_PUBLIC int linphone_config_read_relative_file(const LinphoneConfig *lpconfig, const char *filename, char *data, size_t max_length); diff --git a/include/linphone/misc.h b/include/linphone/misc.h index ce9d2e74a..cb27cbe54 100644 --- a/include/linphone/misc.h +++ b/include/linphone/misc.h @@ -113,8 +113,9 @@ LINPHONE_PUBLIC const char *linphone_reason_to_string(LinphoneReason err); * Return humain readable presence status * @param ss * @deprecated Use #LinphonePresenceModel, #LinphonePresenceActivity and linphone_presence_activity_to_string() instead. + * @donotwrap */ -LINPHONE_PUBLIC const char *linphone_online_status_to_string(LinphoneOnlineStatus ss); +LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_online_status_to_string(LinphoneOnlineStatus ss); /** * Convert a string into LinphoneTunnelMode enum diff --git a/include/linphone/proxy_config.h b/include/linphone/proxy_config.h index eb6a30d02..6c305140b 100644 --- a/include/linphone/proxy_config.h +++ b/include/linphone/proxy_config.h @@ -33,8 +33,9 @@ extern "C" { /** * Creates an empty proxy config. * @deprecated, use #linphone_core_create_proxy_config instead + * @donotwrap **/ -LINPHONE_PUBLIC LinphoneProxyConfig *linphone_proxy_config_new(void); +LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneProxyConfig *linphone_proxy_config_new(void); /** * Acquire a reference to the proxy config. @@ -75,8 +76,9 @@ LINPHONE_PUBLIC int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *c /** * @deprecated Use linphone_proxy_config_set_identity_address() + * @donotwrap **/ -LINPHONE_PUBLIC int linphone_proxy_config_set_identity(LinphoneProxyConfig *cfg, const char *identity); +LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_proxy_config_set_identity(LinphoneProxyConfig *cfg, const char *identity); /** * Sets the user identity as a SIP address. @@ -228,8 +230,9 @@ LINPHONE_PUBLIC LinphoneRegistrationState linphone_proxy_config_get_state(const /** * @return a boolean indicating that the user is sucessfully registered on the proxy. * @deprecated Use linphone_proxy_config_get_state() instead. + * @donotwrap **/ -LINPHONE_PUBLIC bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *cfg); +LINPHONE_PUBLIC LINPHONE_DEPRECATED bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *cfg); /** * Get the domain name of the given proxy config. @@ -249,7 +252,6 @@ LINPHONE_PUBLIC const char *linphone_proxy_config_get_realm(const LinphoneProxyC * Set the realm of the given proxy config. * @param[in] cfg #LinphoneProxyConfig object. * @param[in] realm New realm value. - * @return The realm of the proxy config. **/ LINPHONE_PUBLIC void linphone_proxy_config_set_realm(LinphoneProxyConfig *cfg, const char * realm); @@ -265,8 +267,9 @@ LINPHONE_PUBLIC const LinphoneAddress *linphone_proxy_config_get_identity_addres /** * @deprecated use linphone_proxy_config_get_identity_address() + * @donotwrap **/ -LINPHONE_PUBLIC const char *linphone_proxy_config_get_identity(const LinphoneProxyConfig *cfg); +LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_proxy_config_get_identity(const LinphoneProxyConfig *cfg); /** * @return TRUE if PUBLISH request is enabled for this proxy. @@ -380,12 +383,12 @@ LINPHONE_PUBLIC const char* linphone_proxy_config_get_transport(const LinphonePr /** * Destroys a proxy config. - * @deprecated - * * @note: LinphoneProxyConfig that have been removed from LinphoneCore with * linphone_core_remove_proxy_config() must not be freed. + * @deprecated + * @donotwrap **/ -LINPHONE_PUBLIC void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg); +LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg); LINPHONE_PUBLIC void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type); @@ -409,6 +412,7 @@ LINPHONE_PUBLIC bool_t linphone_proxy_config_is_phone_number(LinphoneProxyConfig * @param result_len the size of the normalized number \a result * @return TRUE if a phone number was recognized, FALSE otherwise. * @deprecated use linphone_proxy_config_normalize_phone_number() + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED bool_t linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const char *username, char *result, size_t result_len); @@ -456,6 +460,7 @@ LINPHONE_PUBLIC LinphonePrivacyMask linphone_proxy_config_get_privacy(const Linp * @param[in] cfg #LinphoneProxyConfig object. * @param server_url URL of the file server like https://file.linphone.org/upload.php * @warning That function isn't implemented yet. + * @donotwrap * */ LINPHONE_PUBLIC void linphone_proxy_config_set_file_transfer_server(LinphoneProxyConfig *cfg, const char * server_url); @@ -464,6 +469,7 @@ LINPHONE_PUBLIC void linphone_proxy_config_set_file_transfer_server(LinphoneProx * @param[in] cfg #LinphoneProxyConfig object. * @return URL of the file server like https://file.linphone.org/upload.php * @warning That function isn't implemented yet. + * @donotwrap * */ LINPHONE_PUBLIC const char* linphone_proxy_config_get_file_transfer_server(const LinphoneProxyConfig *cfg); @@ -472,16 +478,18 @@ LINPHONE_PUBLIC const char* linphone_proxy_config_get_file_transfer_server(const * @param[in] cfg #LinphoneProxyConfig object. * @param[in] enable True to enable AVPF/SAVF, false to disable it. * @deprecated use linphone_proxy_config_set_avpf_mode() + * @donotwrap */ -LINPHONE_PUBLIC void linphone_proxy_config_enable_avpf(LinphoneProxyConfig *cfg, bool_t enable); +LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_proxy_config_enable_avpf(LinphoneProxyConfig *cfg, bool_t enable); /** * Indicates whether AVPF/SAVPF is being used for calls using this proxy config. * @param[in] cfg #LinphoneProxyConfig object. * @return True if AVPF/SAVPF is enabled, false otherwise. * @deprecated use linphone_proxy_config_set_avpf_mode() + * @donotwrap */ -LINPHONE_PUBLIC bool_t linphone_proxy_config_avpf_enabled(LinphoneProxyConfig *cfg); +LINPHONE_DEPRECATED LINPHONE_PUBLIC bool_t linphone_proxy_config_avpf_enabled(LinphoneProxyConfig *cfg); /** * Set the interval between regular RTCP reports when using AVPF/SAVPF. diff --git a/include/linphone/tunnel.h b/include/linphone/tunnel.h index 462a49fc3..3fbfa9c4b 100644 --- a/include/linphone/tunnel.h +++ b/include/linphone/tunnel.h @@ -208,6 +208,7 @@ LINPHONE_PUBLIC void linphone_tunnel_config_unref(LinphoneTunnelConfig *cfg); * Destroy a tunnel configuration * @param tunnel LinphoneTunnelConfig object * @deprecated use linphone_tunnel_config_unref(). + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_tunnel_config_destroy(LinphoneTunnelConfig *tunnel); @@ -342,6 +343,7 @@ LINPHONE_PUBLIC void linphone_tunnel_set_http_proxy(LinphoneTunnel *tunnel, cons * @param port http proxy port * @param username Optional http proxy username if the proxy request authentication. Currently only basic authentication is supported. Use NULL if not needed. * @param passwd Optional http proxy password. Use NULL if not needed. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_tunnel_get_http_proxy(LinphoneTunnel*tunnel,const char **host, int *port, const char **username, const char **passwd); @@ -359,6 +361,7 @@ LINPHONE_PUBLIC void linphone_tunnel_set_http_proxy_auth_info(LinphoneTunnel*tun * @param enabled If true enter in tunneled mode, if false exits from tunneled mode. * The TunnelManager takes care of refreshing SIP registration when switching on or off the tunneled mode. * @deprecated Replaced by linphone_tunnel_set_mode() + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_tunnel_enable(LinphoneTunnel *tunnel, bool_t enabled); @@ -367,6 +370,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_tunnel_enable(LinphoneTunnel * * @param tunnel Tunnel object * @return Returns a boolean indicating whether tunneled operation is enabled. * @deprecated Replaced by linphone_tunnel_get_mode() + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED bool_t linphone_tunnel_enabled(const LinphoneTunnel *tunnel); @@ -377,6 +381,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED bool_t linphone_tunnel_enabled(const Linphon *
In case of success, the tunnel is automatically turned off. Otherwise, if no udp communication is feasible, tunnel mode is turned on. *
Call this method each time to run the auto detection algorithm * @deprecated Replaced by linphone_tunnel_set_mode(LinphoneTunnelModeAuto) + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_tunnel_auto_detect(LinphoneTunnel *tunnel); @@ -385,6 +390,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_tunnel_auto_detect(LinphoneTun * @param[in] tunnel LinphoneTunnel object. * @return TRUE if auto detection is enabled, FALSE otherwise. * @deprecated Replaced by linphone_tunnel_get_mode() + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED bool_t linphone_tunnel_auto_detect_enabled(LinphoneTunnel *tunnel); diff --git a/include/linphone/types.h b/include/linphone/types.h index 1b6f2f6ad..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; @@ -227,8 +290,8 @@ typedef enum _LinphoneCallState{ LinphoneCallIncomingEarlyMedia, /**< We are proposing early media to an incoming call */ LinphoneCallUpdating, /**< A call update has been initiated by us */ LinphoneCallReleased, /**< The call object is no more retained by the core */ - LinphoneCallEarlyUpdatedByRemote, /*< The call is updated by remote while not yet answered (early dialog SIP UPDATE received) */ - LinphoneCallEarlyUpdating /*< We are updating the call while not yet answered (early dialog SIP UPDATE sent) */ + LinphoneCallEarlyUpdatedByRemote, /**< The call is updated by remote while not yet answered (early dialog SIP UPDATE received) */ + LinphoneCallEarlyUpdating /**< We are updating the call while not yet answered (early dialog SIP UPDATE sent) */ } LinphoneCallState; /** @@ -362,8 +425,9 @@ typedef unsigned int LinphoneContactSearchID; /** * Old name of LinphoneContactSearchID * @deprecated + * @donotwrap */ -typedef LinphoneContactSearchID ContactSearchID; +LINPHONE_DEPRECATED typedef LinphoneContactSearchID ContactSearchID; /** * The LinphoneContent object holds data that can be embedded in a signaling message. @@ -428,6 +492,7 @@ typedef struct _LinphoneFactory LinphoneFactory; * Policy to use to pass through firewalls. * @ingroup network_parameters * @deprecated Use #LinphoneNatPolicy instead. + * @donotwrap **/ typedef enum _LinphoneFirewallPolicy { LinphonePolicyNoFirewall, /**< Do not use any mechanism to pass through firewalls */ @@ -590,6 +655,7 @@ typedef struct _LinphoneNatPolicy LinphoneNatPolicy; /** * Enum describing remote friend status * @deprecated Use #LinphonePresenceModel and #LinphonePresenceActivity instead + * @donotwrap */ typedef enum _LinphoneOnlineStatus{ LinphoneStatusOffline, /**< Offline */ @@ -912,8 +978,9 @@ typedef struct _LinphoneSipTransports { /** * Old name of LinphoneSipTransports * @deprecated + * @donotwrap */ -typedef struct _LinphoneSipTransports LCSipTransports; +LINPHONE_DEPRECATED typedef struct _LinphoneSipTransports LCSipTransports; typedef struct _LinphoneSoundDaemon LinphoneSoundDaemon; @@ -1100,4 +1167,14 @@ typedef enum _LinphoneXmlRpcStatus { typedef struct _LsdPlayer LsdPlayer; +/** + * Structure describing a range of integers + * @ingroup misc + */ +typedef struct _LinphoneIntRange { + int min; /**< Minimum value */ + int max; /**< Maximum value */ +} LinphoneIntRange; + + #endif /* LINPHONE_TYPES_H_ */ diff --git a/include/linphone/vcard.h b/include/linphone/vcard.h index ef82e91c1..23b3e9d42 100644 --- a/include/linphone/vcard.h +++ b/include/linphone/vcard.h @@ -41,6 +41,7 @@ extern "C" * Creates a LinphoneVcard object that has a pointer to an empty vCard * @return a new LinphoneVcard object * @deprecated Use linphone_factory_create_vcard() instead. + * @donotwrap */ LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneVcard* linphone_vcard_new(void); @@ -48,6 +49,7 @@ LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneVcard* linphone_vcard_new(void); * Deletes a LinphoneVcard object properly * @param[in] vCard the LinphoneVcard to destroy * @deprecated Use linphone_vcard_unref() or belle_sip_object_unref() instead. + * @donotwrap */ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_vcard_free(LinphoneVcard *vCard); diff --git a/include/linphone/wrapper_utils.h b/include/linphone/wrapper_utils.h index 5c05a1cc0..d06d5eab3 100644 --- a/include/linphone/wrapper_utils.h +++ b/include/linphone/wrapper_utils.h @@ -65,6 +65,30 @@ LINPHONE_PUBLIC void linphone_chat_message_resend(LinphoneChatMessage *msg); */ LINPHONE_PUBLIC void *linphone_vcard_get_belcard(LinphoneVcard *vcard); + + +/* Functions to mainpulate the LinphoneIntRange structure */ + +/** + * Get the minimum value of a #LinphoneIntRange. + */ +LINPHONE_PUBLIC int linphone_int_range_get_min(const LinphoneIntRange *range); + +/** + * Get the maximum value of a #LinphoneIntRange. + */ +LINPHONE_PUBLIC int linphone_int_range_get_max(const LinphoneIntRange *range); + +/** + * Set the minimum value of a #LinphoneIntRange. + */ +LINPHONE_PUBLIC void linphone_int_range_set_min(LinphoneIntRange *range, int min); + +/** + * Set the maximum value of a #LinphoneIntRange. + */ +LINPHONE_PUBLIC void linphone_int_range_set_max(LinphoneIntRange *range, int max); + /** * @} */ diff --git a/include/linphone/xmlrpc.h b/include/linphone/xmlrpc.h index efcf50ed1..706105a3e 100644 --- a/include/linphone/xmlrpc.h +++ b/include/linphone/xmlrpc.h @@ -43,19 +43,19 @@ typedef void (*LinphoneXmlRpcRequestCbsResponseCb)(LinphoneXmlRpcRequest *reques /** * Create a new LinphoneXmlRpcRequest object. - * @param[in] method The XML-RPC method to call. * @param[in] return_type The expected XML-RPC response type. + * @param[in] method The XML-RPC method to call. * @return A new LinphoneXmlRpcRequest object. **/ -LINPHONE_PUBLIC LinphoneXmlRpcRequest * linphone_xml_rpc_request_new(const char *method, LinphoneXmlRpcArgType return_type); +LINPHONE_PUBLIC LinphoneXmlRpcRequest * linphone_xml_rpc_request_new(LinphoneXmlRpcArgType return_type, const char *method); /** * Create a new LinphoneXmlRpcRequest object giving the arguments to the method call. - * @param[in] method The XML-RPC method to call. * @param[in] return_type The expected XML-RPC response type. + * @param[in] method The XML-RPC method to call. * @return A new LinphoneXmlRpcRequest object. **/ -LINPHONE_PUBLIC LinphoneXmlRpcRequest * linphone_xml_rpc_request_new_with_args(const char *method, LinphoneXmlRpcArgType return_type, ...); +LINPHONE_PUBLIC LinphoneXmlRpcRequest * linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgType return_type, const char *method, ...); /** * Acquire a reference to the XML-RPC request. diff --git a/java/common/org/linphone/core/LinphoneAccountCreator.java b/java/common/org/linphone/core/LinphoneAccountCreator.java index 72cdebbab..4b716521d 100644 --- a/java/common/org/linphone/core/LinphoneAccountCreator.java +++ b/java/common/org/linphone/core/LinphoneAccountCreator.java @@ -23,68 +23,263 @@ import org.linphone.core.LinphoneAddress.TransportType; public interface LinphoneAccountCreator { interface LinphoneAccountCreatorListener { - void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, Status status); - void onAccountCreatorAccountCreated(LinphoneAccountCreator accountCreator, Status status); - void onAccountCreatorAccountActivated(LinphoneAccountCreator accountCreator, Status status); - void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, Status status); - void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, Status status); - void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, Status status); - void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, Status status); - void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, Status status); - void onAccountCreatorIsPhoneNumberUsed(LinphoneAccountCreator accountCreator, Status status); - void onAccountCreatorPasswordUpdated(LinphoneAccountCreator accountCreator, Status status); + void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); + void onAccountCreatorAccountCreated(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); + void onAccountCreatorAccountActivated(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); + void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); + void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); + void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); + void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); + void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); + void onAccountCreatorIsPhoneNumberUsed(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); + void onAccountCreatorPasswordUpdated(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); } - public static class Status { - static private Vector values = new Vector(); + public static class UsernameCheck { + static private Vector values = new Vector(); private final int mValue; private final String mStringValue; public final int value() { return mValue; } - public final static Status Ok = new Status(0, "Ok"); - public final static Status Failed = new Status(1, "Failed"); - public final static Status AccountCreated = new Status(2, "AccountCreated"); - public final static Status AccountNotCreated = new Status(3, "AccountNotCreated"); - public final static Status AccountExist = new Status(4, "AccountExist"); - public final static Status AccountExistWithAlias = new Status(5, "AccountExistWithAlias"); - public final static Status AccountNotExist = new Status(6, "AccountNotExist"); - public final static Status AccountActivated = new Status(7, "AccountActivated"); - public final static Status AccountAlreadyActivated = new Status(8, "AccountAlreadyActivated"); - public final static Status AccountNotActivated = new Status(9, "AccountNotActivated"); - public final static Status AccountLinked = new Status(10, "AccountLinked"); - public final static Status AccountNotLinked = new Status(11, "AccountNotLinked"); - public final static Status EmailInvalid = new Status(12, "EmailInvalid"); - public final static Status UsernameInvalid = new Status(13, "UsernameInvalid"); - public final static Status UsernameTooShort = new Status(14, "UsernameTooShort"); - public final static Status UsernameTooLong = new Status(15, "UsernameTooLong"); - public final static Status UsernameInvalidSize = new Status(16, "UsernameInvalidSize"); - public final static Status PhoneNumberInvalid = new Status(17, "PhoneNumberInvalid"); - public final static Status PhoneNumberTooShort = new Status(18, "PhoneNumberTooShort"); - public final static Status PhoneNumberTooLong = new Status(19, "PhoneNumberTooLong"); - public final static Status PhoneNumberUsedAccount = new Status(20, "PhoneNumberUsed"); - public final static Status PhoneNumberUsedAlias = new Status(21, "PhoneNumberUsed"); - public final static Status PhoneNumberNotUsed = new Status(22, "PhoneNumberNotUsed"); - public final static Status PasswordTooShort = new Status(23, "PasswordTooShort"); - public final static Status PasswordTooLong = new Status(24, "PasswordTooLong"); - public final static Status DomainInvalid = new Status(25, "DomainInvalid"); - public final static Status RouteInvalid = new Status(26, "RouteInvalid"); - public final static Status DisplayNameInvalid = new Status(27, "DisplayNameInvalid"); - public final static Status TransportNotSupported = new Status(28, "TransportNotSupported"); - public final static Status CountryCodeInvalid = new Status(29, "CountryCodeInvalid"); - public final static Status ErrorServer = new Status(30, "ErrorServer"); + public final static UsernameCheck Ok = new UsernameCheck(0, "Ok"); + public final static UsernameCheck TooShort = new UsernameCheck(1, "TooShort"); + public final static UsernameCheck TooLong = new UsernameCheck(2, "TooLong"); + public final static UsernameCheck InvalidCharacters = new UsernameCheck(3, "InvalidCharacters"); + public final static UsernameCheck Invalid = new UsernameCheck(4, "Invalid"); - private Status(int value, String stringValue) { + private UsernameCheck(int value, String stringValue) { mValue = value; values.addElement(this); mStringValue = stringValue; } - public static Status fromInt(int value) { + public static UsernameCheck fromInt(int value) { for (int i=0; i < values.size(); i++) { - Status state = (Status) values.elementAt(i); + UsernameCheck state = (UsernameCheck) values.elementAt(i); if (state.mValue == value) return state; } - throw new RuntimeException("Status not found [" + value + "]"); + throw new RuntimeException("UsernameCheck not found [" + value + "]"); + } + + public String toString() { + return mStringValue; + } + + public int toInt() { + return mValue; + } + } + + public static class PhoneNumberCheck { + static private Vector values = new Vector(); + private final int mValue; + private final String mStringValue; + public final int value() { return mValue; } + + public final static PhoneNumberCheck Ok = new PhoneNumberCheck(0x1, "Ok"); + public final static PhoneNumberCheck TooShort = new PhoneNumberCheck(0x2, "TooShort"); + public final static PhoneNumberCheck TooLong = new PhoneNumberCheck(0x4, "TooLong"); + public final static PhoneNumberCheck CountryCodeInvalid = new PhoneNumberCheck(0x8, "CountryCodeInvalid"); + public final static PhoneNumberCheck Invalid = new PhoneNumberCheck(0x10, "Invalid"); + + private PhoneNumberCheck(int value, String stringValue) { + mValue = value; + values.addElement(this); + mStringValue = stringValue; + } + + public static PhoneNumberCheck fromInt(int value) { + for (int i=0; i < values.size(); i++) { + PhoneNumberCheck state = (PhoneNumberCheck) values.elementAt(i); + if (state.mValue == value) return state; + } + throw new RuntimeException("UsernameCheck not found [" + value + "]"); + } + + public String toString() { + return mStringValue; + } + + public int toInt() { + return mValue; + } + } + + public static class EmailCheck { + static private Vector values = new Vector(); + private final int mValue; + private final String mStringValue; + public final int value() { return mValue; } + + public final static EmailCheck Ok = new EmailCheck(0, "Ok"); + public final static EmailCheck Malformed = new EmailCheck(1, "Malformed"); + public final static EmailCheck InvalidCharacters = new EmailCheck(2, "InvalidCharacters"); + + private EmailCheck(int value, String stringValue) { + mValue = value; + values.addElement(this); + mStringValue = stringValue; + } + + public static EmailCheck fromInt(int value) { + for (int i=0; i < values.size(); i++) { + EmailCheck state = (EmailCheck) values.elementAt(i); + if (state.mValue == value) return state; + } + throw new RuntimeException("EmailCheck not found [" + value + "]"); + } + + public String toString() { + return mStringValue; + } + + public int toInt() { + return mValue; + } + } + + public static class PasswordCheck { + static private Vector values = new Vector(); + private final int mValue; + private final String mStringValue; + public final int value() { return mValue; } + + public final static PasswordCheck Ok = new PasswordCheck(0, "Ok"); + public final static PasswordCheck TooShort = new PasswordCheck(1, "TooShort"); + public final static PasswordCheck TooLong = new PasswordCheck(2, "TooLong"); + public final static PasswordCheck InvalidCharacters = new PasswordCheck(3, "InvalidCharacters"); + public final static PasswordCheck MissingCharacters = new PasswordCheck(4, "MissingCharacters"); + + private PasswordCheck(int value, String stringValue) { + mValue = value; + values.addElement(this); + mStringValue = stringValue; + } + + public static PasswordCheck fromInt(int value) { + for (int i=0; i < values.size(); i++) { + PasswordCheck state = (PasswordCheck) values.elementAt(i); + if (state.mValue == value) return state; + } + throw new RuntimeException("PasswordCheck not found [" + value + "]"); + } + + public String toString() { + return mStringValue; + } + + public int toInt() { + return mValue; + } + } + + public static class LanguageCheck { + static private Vector values = new Vector(); + private final int mValue; + private final String mStringValue; + public final int value() { return mValue; } + + public final static LanguageCheck Ok = new LanguageCheck(0, "Ok"); + + private LanguageCheck(int value, String stringValue) { + mValue = value; + values.addElement(this); + mStringValue = stringValue; + } + + public static LanguageCheck fromInt(int value) { + for (int i=0; i < values.size(); i++) { + LanguageCheck state = (LanguageCheck) values.elementAt(i); + if (state.mValue == value) return state; + } + throw new RuntimeException("LanguageCheck not found [" + value + "]"); + } + + public String toString() { + return mStringValue; + } + + public int toInt() { + return mValue; + } + } + + public static class ActivationCodeCheck { + static private Vector values = new Vector(); + private final int mValue; + private final String mStringValue; + public final int value() { return mValue; } + + public final static ActivationCodeCheck Ok = new ActivationCodeCheck(0, "Ok"); + public final static ActivationCodeCheck TooShort = new ActivationCodeCheck(1, "TooShort"); + public final static ActivationCodeCheck TooLong = new ActivationCodeCheck(2, "TooLong"); + public final static ActivationCodeCheck InvalidCharacters = new ActivationCodeCheck(3, "InvalidCharacters"); + + private ActivationCodeCheck(int value, String stringValue) { + mValue = value; + values.addElement(this); + mStringValue = stringValue; + } + + public static ActivationCodeCheck fromInt(int value) { + for (int i=0; i < values.size(); i++) { + ActivationCodeCheck state = (ActivationCodeCheck) values.elementAt(i); + if (state.mValue == value) return state; + } + throw new RuntimeException("ActivationCodeCheck not found [" + value + "]"); + } + + public String toString() { + return mStringValue; + } + + public int toInt() { + return mValue; + } + } + + public static class RequestStatus { + static private Vector values = new Vector(); + private final int mValue; + private final String mStringValue; + public final int value() { return mValue; } + + public final static RequestStatus Ok = new RequestStatus(0, "Ok"); + public final static RequestStatus Failed = new RequestStatus(1, "Failed"); + public final static RequestStatus MissingArguments = new RequestStatus(2, "MissingArguments"); + public final static RequestStatus MissingCallbacks = new RequestStatus(3, "MissingCallbacks"); + + public final static RequestStatus AccountCreated = new RequestStatus(4, "AccountCreated"); + public final static RequestStatus AccountNotCreated = new RequestStatus(5, "AccountNotCreated"); + + public final static RequestStatus AccountExist = new RequestStatus(6, "AccountExist"); + public final static RequestStatus AccountExistWithAlias = new RequestStatus(7, "AccountExistWithAlias"); + public final static RequestStatus AccountNotExist = new RequestStatus(8, "AccountNotExist"); + public final static RequestStatus AliasIsAccount = new RequestStatus(9, "AliasIsAccount"); + public final static RequestStatus AliasExist = new RequestStatus(10, "AliasExist"); + public final static RequestStatus AliasNotExist = new RequestStatus(11, "AliasNotExist"); + + public final static RequestStatus AccountActivated = new RequestStatus(12, "AccountActivated"); + public final static RequestStatus AccountAlreadyActivated = new RequestStatus(13, "AccountAlreadyActivated"); + public final static RequestStatus AccountNotActivated = new RequestStatus(14, "AccountNotActivated"); + + public final static RequestStatus AccountLinked = new RequestStatus(15, "AccountLinked"); + public final static RequestStatus AccountNotLinked = new RequestStatus(16, "AccountNotLinked"); + + public final static RequestStatus ErrorServer = new RequestStatus(17, "ErrorServer"); + + private RequestStatus(int value, String stringValue) { + mValue = value; + values.addElement(this); + mStringValue = stringValue; + } + + public static RequestStatus fromInt(int value) { + for (int i=0; i < values.size(); i++) { + RequestStatus state = (RequestStatus) values.elementAt(i); + if (state.mValue == value) return state; + } + throw new RuntimeException("RequestStatus not found [" + value + "]"); } public String toString() { @@ -98,67 +293,53 @@ public interface LinphoneAccountCreator { void setListener(LinphoneAccountCreatorListener listener); - Status setUsername(String username); + UsernameCheck setUsername(String username); String getUsername(); - Status setPhoneNumber(String phoneNumber, String countryCode); + int setPhoneNumber(String phoneNumber, String countryCode); String getPhoneNumber(); - Status setPassword(String password); + PasswordCheck setPassword(String password); String getPassword(); - Status setHa1(String ha1); + PasswordCheck setHa1(String ha1); String getHa1(); - Status setActivationCode(String activationCode); + ActivationCodeCheck setActivationCode(String activationCode); - Status setLanguage(String lang); + LanguageCheck setLanguage(String lang); - Status setTransport(TransportType transport); - - TransportType getTransport(); - - Status setDomain(String domain); - - String getDomain(); - - Status setRoute(String route); - - String getRoute(); - - Status setDisplayName(String displayName); + UsernameCheck setDisplayName(String displayName); String getDisplayName(); - Status setEmail(String email); + EmailCheck setEmail(String email); String getEmail(); String getPrefix(String phone); - Status isAccountUsed(); + RequestStatus isAccountUsed(); - Status createAccount(); + RequestStatus createAccount(); - Status activateAccount(); + RequestStatus activateAccount(); - Status isAccountActivated(); + RequestStatus isAccountActivated(); - Status linkPhoneNumberWithAccount(); + RequestStatus linkPhoneNumberWithAccount(); - Status activatePhoneNumberLink(); + RequestStatus activatePhoneNumberLink(); - Status isAccountLinked(); + RequestStatus isAccountLinked(); - Status isPhoneNumberUsed(); + RequestStatus isPhoneNumberUsed(); - Status recoverPhoneAccount(); + RequestStatus recoverPhoneAccount(); - Status updatePassword(String newPassword); - - LinphoneProxyConfig configure(); + RequestStatus updatePassword(String newPassword); } diff --git a/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java b/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java index 66333eec8..6519a693e 100644 --- a/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java +++ b/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java @@ -17,8 +17,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; -import org.linphone.core.LinphoneAddress.TransportType; - public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { protected long nativePtr; @@ -48,8 +46,8 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { private native int setUsername(long ptr, String username); @Override - public Status setUsername(String username) { - return Status.fromInt(setUsername(nativePtr, username)); + public UsernameCheck setUsername(String username) { + return UsernameCheck.fromInt(setUsername(nativePtr, username)); } private native String getUsername(long ptr); @@ -60,8 +58,8 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { private native int setPhoneNumber(long ptr, String phoneNumber, String countryCode); @Override - public Status setPhoneNumber(String phoneNumber, String countryCode) { - return Status.fromInt(setPhoneNumber(nativePtr, phoneNumber, countryCode)); + public int setPhoneNumber(String phoneNumber, String countryCode) { + return setPhoneNumber(nativePtr, phoneNumber, countryCode); } private native String getPhoneNumber(long ptr); @@ -72,8 +70,8 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { private native int setPassword(long ptr, String password); @Override - public Status setPassword(String password) { - return Status.fromInt(setPassword(nativePtr, password)); + public PasswordCheck setPassword(String password) { + return PasswordCheck.fromInt(setPassword(nativePtr, password)); } private native String getPassword(long ptr); @@ -84,8 +82,8 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { private native int setHa1(long ptr, String ha1); @Override - public Status setHa1(String ha1) { - return Status.fromInt(setHa1(nativePtr, ha1)); + public PasswordCheck setHa1(String ha1) { + return PasswordCheck.fromInt(setHa1(nativePtr, ha1)); } private native String getHa1(long ptr); @@ -96,56 +94,20 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { private native int setActivationCode(long ptr, String activationCode); @Override - public Status setActivationCode(String activationCode) { - return Status.fromInt(setActivationCode(nativePtr, activationCode)); + public ActivationCodeCheck setActivationCode(String activationCode) { + return ActivationCodeCheck.fromInt(setActivationCode(nativePtr, activationCode)); } private native int setLanguage(long ptr, String lang); @Override - public Status setLanguage(String lang) { - return Status.fromInt(setLanguage(nativePtr, lang)); - } - - private native int setTransport(long ptr, int transport); - @Override - public Status setTransport(TransportType transport) { - return Status.fromInt(setTransport(nativePtr, transport.toInt())); - } - - private native int getTransport(long ptr); - @Override - public TransportType getTransport() { - return TransportType.fromInt(getTransport(nativePtr)); - } - - private native int setDomain(long ptr, String domain); - @Override - public Status setDomain(String domain) { - return Status.fromInt(setDomain(nativePtr, domain)); - } - - private native String getDomain(long ptr); - @Override - public String getDomain() { - return getDomain(nativePtr); - } - - private native int setRoute(long ptr, String route); - @Override - public Status setRoute(String route) { - return Status.fromInt(setRoute(nativePtr, route)); - } - - private native String getRoute(long ptr); - @Override - public String getRoute() { - return getRoute(nativePtr); + public LanguageCheck setLanguage(String lang) { + return LanguageCheck.fromInt(setLanguage(nativePtr, lang)); } private native int setDisplayName(long ptr, String displayName); @Override - public Status setDisplayName(String displayName) { - return Status.fromInt(setDisplayName(nativePtr, displayName)); + public UsernameCheck setDisplayName(String displayName) { + return UsernameCheck.fromInt(setDisplayName(nativePtr, displayName)); } private native String getDisplayName(long ptr); @@ -156,8 +118,8 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { private native int setEmail(long ptr, String email); @Override - public Status setEmail(String email) { - return Status.fromInt(setEmail(nativePtr, email)); + public EmailCheck setEmail(String email) { + return EmailCheck.fromInt(setEmail(nativePtr, email)); } private native String getEmail(long ptr); @@ -174,67 +136,61 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { private native int isAccountUsed(long ptr); @Override - public Status isAccountUsed() { - return Status.fromInt(isAccountUsed(nativePtr)); + public RequestStatus isAccountUsed() { + return RequestStatus.fromInt(isAccountUsed(nativePtr)); } private native int createAccount(long ptr); @Override - public Status createAccount() { - return Status.fromInt(createAccount(nativePtr)); + public RequestStatus createAccount() { + return RequestStatus.fromInt(createAccount(nativePtr)); } private native int activateAccount(long ptr); @Override - public Status activateAccount() { - return Status.fromInt(activateAccount(nativePtr)); + public RequestStatus activateAccount() { + return RequestStatus.fromInt(activateAccount(nativePtr)); } private native int isAccountLinked(long ptr); @Override - public Status isAccountLinked() { - return Status.fromInt(isAccountLinked(nativePtr)); + public RequestStatus isAccountLinked() { + return RequestStatus.fromInt(isAccountLinked(nativePtr)); } private native int isPhoneNumberUsed(long ptr); @Override - public Status isPhoneNumberUsed() { - return Status.fromInt(isPhoneNumberUsed(nativePtr)); + public RequestStatus isPhoneNumberUsed() { + return RequestStatus.fromInt(isPhoneNumberUsed(nativePtr)); } private native int isAccountActivated(long ptr); @Override - public Status isAccountActivated() { - return Status.fromInt(isAccountActivated(nativePtr)); + public RequestStatus isAccountActivated() { + return RequestStatus.fromInt(isAccountActivated(nativePtr)); } private native int linkPhoneNumberWithAccount(long ptr); @Override - public Status linkPhoneNumberWithAccount() { - return Status.fromInt(linkPhoneNumberWithAccount(nativePtr)); + public RequestStatus linkPhoneNumberWithAccount() { + return RequestStatus.fromInt(linkPhoneNumberWithAccount(nativePtr)); } private native int activatePhoneNumberLink(long ptr); @Override - public Status activatePhoneNumberLink() { - return Status.fromInt(activatePhoneNumberLink(nativePtr)); + public RequestStatus activatePhoneNumberLink() { + return RequestStatus.fromInt(activatePhoneNumberLink(nativePtr)); } private native int recoverPhoneAccount(long ptr); @Override - public Status recoverPhoneAccount() { - return Status.fromInt(recoverPhoneAccount(nativePtr)); + public RequestStatus recoverPhoneAccount() { + return RequestStatus.fromInt(recoverPhoneAccount(nativePtr)); } private native int updatePassword(long ptr, String newPassword); @Override - public Status updatePassword(String newPassword) { - return Status.fromInt(updatePassword(nativePtr, newPassword)); - } - - private native LinphoneProxyConfig configure(long ptr); - @Override - public LinphoneProxyConfig configure() { - return configure(nativePtr); + public RequestStatus updatePassword(String newPassword) { + return RequestStatus.fromInt(updatePassword(nativePtr, newPassword)); } } diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index e6073ef7c..e90af0224 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -77,6 +77,7 @@ set(CERTIFICATE_CLIENT_FILES set(CERTIFICATE_FILES ${CERTIFICATE_ALT_FILES} ${CERTIFICATE_CN_FILES} ${CERTIFICATE_CLIENT_FILES}) set(RC_FILES + rcfiles/account_creator_rc rcfiles/carddav_rc rcfiles/conference_focus_rc rcfiles/empty_rc @@ -159,6 +160,7 @@ set(IOS_RESOURCES_FILES set(SOURCE_FILES_C accountmanager.c + account_creator_tester.c audio_bypass_tester.c call_multicast_tester.c call_multi_tester.c diff --git a/tester/Makefile.am b/tester/Makefile.am index edcfd27d7..f54380a5c 100644 --- a/tester/Makefile.am +++ b/tester/Makefile.am @@ -34,7 +34,10 @@ CERTIFICATE_CLIENT_FILES = certificates/client/cert.pem \ CERTIFICATE_FILES = $(CERTIFICATE_ALT_FILES) $(CERTIFICATE_CN_FILES) $(CERTIFICATE_CLIENT_FILES) RCFILES = \ + rcfiles/account_creator_rc\ + rcfiles/carddav_rc\ rcfiles/empty_rc\ + rcfiles/friends_rc\ rcfiles/laure_call_logs_rc\ rcfiles/laure_rc_udp\ rcfiles/marie_early_rc\ @@ -75,8 +78,7 @@ RCFILES = \ rcfiles/stun_rc\ rcfiles/upnp_rc\ rcfiles/zero_length_params_rc\ - rcfiles/friends_rc\ - rcfiles/carddav_rc + IMAGE_FILES = images/linphone.svg images/nowebcamCIF.jpg images/nowebcamVGA.jpg @@ -122,6 +124,7 @@ liblinphonetester_la_HEADERS = audio_bypass_wav_header.h liblinphonetester_la_SOURCES = \ accountmanager.c \ + account_creator_tester.c \ audio_bypass_tester.c \ call_multi_tester.c \ call_multicast_tester.c \ diff --git a/tester/account_creator_tester.c b/tester/account_creator_tester.c new file mode 100644 index 000000000..233258abc --- /dev/null +++ b/tester/account_creator_tester.c @@ -0,0 +1,2351 @@ +/* + liblinphone_tester - liblinphone test suite + Copyright (C) 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 as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "liblinphone_tester.h" +#include "private.h" + +static const char XMLRPC_URL[] = "https://sip2.linphone.org:446/xmlrpc.php"; + +static const int TIMEOUT_REQUEST = 10000; + +/////////// INIT ////////////// + +static void init_account_creator_request_cbs(LinphoneCore *lc) { + LinphoneAccountCreatorRequestCbs *cbs = linphone_account_creator_requests_cbs_new(); + linphone_account_creator_requests_cbs_set_constructor_cb(cbs, NULL); + linphone_account_creator_requests_cbs_set_destructor_cb(cbs, NULL); + linphone_account_creator_requests_cbs_set_create_account_cb(cbs, linphone_account_creator_create_account_custom); + linphone_account_creator_requests_cbs_set_is_account_exist_cb(cbs, linphone_account_creator_is_account_exist_custom); + linphone_account_creator_requests_cbs_set_activate_account_cb(cbs, linphone_account_creator_activate_account_custom); + linphone_account_creator_requests_cbs_set_is_account_activated_cb(cbs, linphone_account_creator_is_account_activated_custom); + linphone_account_creator_requests_cbs_set_link_account_cb(cbs, linphone_account_creator_link_phone_number_with_account_custom); + linphone_account_creator_requests_cbs_set_activate_alias_cb(cbs, linphone_account_creator_activate_phone_number_link_custom); + linphone_account_creator_requests_cbs_set_is_alias_used_cb(cbs, linphone_account_creator_is_phone_number_used_custom); + linphone_account_creator_requests_cbs_set_is_account_linked_cb(cbs, linphone_account_creator_is_account_linked_custom); + linphone_account_creator_requests_cbs_set_recover_account_cb(cbs, linphone_account_creator_recover_phone_account_custom); + linphone_account_creator_requests_cbs_set_update_account_cb(cbs, linphone_account_creator_update_password_custom); + linphone_core_set_account_creator_request_engine_cbs(lc, cbs); +} + +static LinphoneAccountCreator * _linphone_account_creator_new(LinphoneCore *lc, const char * url) { + init_account_creator_request_cbs(lc); + LinphoneAccountCreator *creator = linphone_account_creator_new(lc, url); + return creator; +} + +/////////// LOCAL TESTS /////////// + +////// USERNAME ////// +static void local_username_too_short(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, ""), + LinphoneUsernameTooShort, + LinphoneUsernameCheck, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_username_too_long(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, "usernametoolongforyou"), + LinphoneUsernameTooLong, + LinphoneUsernameCheck, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +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!"), + LinphoneUsernameInvalidCharacters, + LinphoneUsernameCheck, + "%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, "XXXTESTuser_1"), + LinphoneUsernameOk, + LinphoneUsernameCheck, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +////// PASSWORD ////// + +static void local_password_too_short(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_password(creator, ""), + LinphonePasswordTooShort, + LinphonePasswordCheck, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_password_too_long(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_password(creator, "passwordtoolong"), + LinphonePasswordTooLong, + LinphonePasswordCheck, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_password_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_password(creator, "pass"), + LinphonePasswordOk, + LinphonePasswordCheck, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +////// EMAIL ////// + +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"), + 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); + linphone_core_manager_destroy(marie); +} + +static void local_email_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_email(creator, "test@linphone.org"), + 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); + linphone_core_manager_destroy(marie); +} + +////// PHONE NUMBER ////// + +static void local_phone_number_too_short(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_phone_number(creator, "0123", "33")&LinphonePhoneNumberTooShort, + LinphonePhoneNumberTooShort, + LinphonePhoneNumberCheck, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_phone_number_too_long(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_phone_number(creator, "01234567891011", "33")&LinphonePhoneNumberTooLong, + LinphonePhoneNumberTooLong, + LinphonePhoneNumberCheck, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_phone_number_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_phone_number(creator, NULL, "33")&LinphonePhoneNumberInvalid, + LinphonePhoneNumberInvalid, + LinphonePhoneNumberCheck, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_country_code_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_phone_number(creator, "0123", "")&LinphonePhoneNumberCountryCodeInvalid, + LinphonePhoneNumberCountryCodeInvalid, + LinphonePhoneNumberCheck, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +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_phone_number(creator, "000555455", "1")&LinphonePhoneNumberOk, + LinphonePhoneNumberOk, + LinphonePhoneNumberCheck, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +/////////// SERVER TESTS /////////// + +typedef struct _LinphoneAccountCreatorStats { + int cb_done; +} LinphoneAccountCreatorStats; + +static LinphoneAccountCreatorStats* new_linphone_account_creator_stats(void) { + LinphoneAccountCreatorStats *stats = (LinphoneAccountCreatorStats*) ms_new0(LinphoneAccountCreatorStats, 1); + return stats; +} + +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); +} + +static void account_creator_reset_cb_done(LinphoneAccountCreatorResponseCbs *cbs) { + LinphoneAccountCreatorStats *stats = (LinphoneAccountCreatorStats*) linphone_account_creator_responses_cbs_get_user_data(cbs); + stats->cb_done = 0; + BC_ASSERT_FALSE(stats->cb_done); +} + +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, + LinphoneRequestStatus, + "%i"); + account_creator_set_cb_done(cbs); +} + +static void _get_activation_code_cb(LinphoneXmlRpcRequest *request) { + LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); + 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 = LinphoneRequestFailed; + } else { + status = LinphoneRequestOk; + set_string(&creator->activation_code, resp, FALSE); + } + } + account_creator_cb(creator, status, resp); +} + +LinphoneRequestStatus get_activation_code_account_cb(LinphoneAccountCreator *creator) { + LinphoneXmlRpcRequest *request; + if ((!creator->username && !creator->phone_number) || !creator->password) { + return LinphoneRequestMissingArguments; + } + + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "get_confirmation_key", + LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, + LinphoneXmlRpcArgString, 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), _get_activation_code_cb); + linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); + linphone_xml_rpc_request_unref(request); + + return LinphoneRequestOk; +} + +static void _delete_account_cb(LinphoneXmlRpcRequest *request) { + LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); + LinphoneRequestStatus status = LinphoneRequestFailed; + const char* resp = linphone_xml_rpc_request_get_string_response(request); + if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { + // We want to delete account from table but it's not an error if it doesn't exist or password doesn't match + if (strstr(resp, "ERROR_ACCOUNT_DOESNT_EXIST") == resp + || strstr(resp, "ERROR_PASSWORD_DOESNT_MATCH") == resp) { + status = LinphoneRequestOk; + } else if (strstr(resp, "ERROR_") == resp) { + status = LinphoneRequestFailed; + } else { + status = LinphoneRequestOk; + } + } + account_creator_cb(creator, status, resp); +} + +LinphoneRequestStatus delete_account_cb(LinphoneAccountCreator *creator) { + LinphoneXmlRpcRequest *request; + if ((!creator->username && !creator->phone_number) || !creator->password) { + return LinphoneRequestMissingArguments; + } + + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "delete_account", + LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, + LinphoneXmlRpcArgString, 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), _delete_account_cb); + linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); + linphone_xml_rpc_request_unref(request); + + return LinphoneRequestOk; +} + +static void get_activation_code(LinphoneAccountCreator *creator, int *cb_done) { + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestOk); + + BC_ASSERT_EQUAL( + get_activation_code_account_cb(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(creator->core, NULL, cb_done, 1, TIMEOUT_REQUEST); +} + +static void server_delete_account_test(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*)LinphoneRequestOk); + linphone_account_creator_set_email(creator, "user_2@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_phone_number(creator, "000555455","1"); + + BC_ASSERT_EQUAL( + delete_account_cb(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + linphone_account_creator_unref(creator); + + // First attempt with the first password + creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); + cbs = linphone_account_creator_get_responses_cbs(creator); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + account_creator_reset_cb_done(cbs); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestOk); + linphone_account_creator_set_username(creator, "XXXTESTuser_1"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + + BC_ASSERT_EQUAL( + delete_account_cb(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + linphone_account_creator_unref(creator); + + // Second attempt with the second password + creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); + cbs = linphone_account_creator_get_responses_cbs(creator); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + account_creator_reset_cb_done(cbs); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestOk); + linphone_account_creator_set_username(creator, "XXXTESTuser_1"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + linphone_account_creator_set_password(creator, "newpassword"); + + BC_ASSERT_EQUAL( + delete_account_cb(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); +} + +/****************** 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); + 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_not_exist"); + linphone_account_creator_responses_cbs_set_is_account_exist_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_exist(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_exist(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*)LinphoneRequestAccountExist); + linphone_account_creator_set_username(creator, "XXXTESTuser_1"); + linphone_account_creator_responses_cbs_set_is_account_exist_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_exist(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_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, "XXXTESTuser_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*)LinphoneRequestAccountExist); + linphone_account_creator_set_username(creator, "XXXTESTuser_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_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*)LinphoneRequestAccountCreated); + linphone_account_creator_set_email(creator, "user_2@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_phone_number(creator, "000555455","1"); + 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*)LinphoneRequestAccountExist); + linphone_account_creator_set_email(creator, "user_2@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_phone_number(creator, "000555455","1"); + 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*)LinphoneRequestAccountExistWithAlias); + linphone_account_creator_set_username(creator, "XXXTESTuser_3"); + linphone_account_creator_set_email(creator, "user_2@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_phone_number(creator, "000555456","1"); + 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_account_not_activated(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, "XXXTESTuser_1"); + + 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*)LinphoneRequestAccountNotActivated); + linphone_account_creator_responses_cbs_set_is_account_activated_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_activated(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_already_activated(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, "XXXTESTuser_1"); + + 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*)LinphoneRequestAccountActivated); + linphone_account_creator_responses_cbs_set_is_account_activated_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_activated(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_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"); + + 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_not_activated(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_set_username(creator, "XXXTESTuser_1"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + get_activation_code(creator, &stats->cb_done); + account_creator_reset_cb_done(creator->responses_cbs); + + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountActivated); + linphone_account_creator_responses_cbs_set_activate_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_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_activate_account_already_activated(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_set_username(creator, "XXXTESTuser_1"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + get_activation_code(creator, &stats->cb_done); + account_creator_reset_cb_done(creator->responses_cbs); + + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountAlreadyActivated); + linphone_account_creator_responses_cbs_set_activate_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_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_activate_non_existent_account(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, "unknown_user"); + linphone_account_creator_set_activation_code(creator, "58c9"); + 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*)LinphoneRequestAccountNotActivated); + linphone_account_creator_responses_cbs_set_activate_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_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_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_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_set_username(creator, "XXXTESTuser_1"); + linphone_account_creator_set_phone_number(creator, "000555456", "1"); + + 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*)LinphoneRequestOk); + linphone_account_creator_responses_cbs_set_link_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_link_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_link_non_existent_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_set_username(creator, "unknown_user"); + linphone_account_creator_set_phone_number(creator, "012345678", "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*)LinphoneRequestAccountNotLinked); + linphone_account_creator_responses_cbs_set_link_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_link_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_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_phone_number_for_non_existent_account(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, "unknown_user"); + linphone_account_creator_set_phone_number(creator, "012345678", "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*)LinphoneRequestAccountNotActivated); + linphone_account_creator_responses_cbs_set_activate_alias_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_alias(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_activate_phone_number_for_account(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_set_username(creator, "XXXTESTuser_1"); + linphone_account_creator_set_phone_number(creator, "000555456", "1"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + get_activation_code(creator, &stats->cb_done); + account_creator_reset_cb_done(creator->responses_cbs); + + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountActivated); + linphone_account_creator_responses_cbs_set_activate_alias_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_alias(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_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, "012345678", "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, "012345678", "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, "012345678", "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, "012345678", "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_phone_number_is_used_as_alias(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, "000555456", "1"); + + 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*)LinphoneRequestAliasExist); + linphone_account_creator_responses_cbs_set_is_alias_used_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_alias_used(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_phone_number_is_used_as_account(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, "000555455", "1"); + + 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*)LinphoneRequestAliasIsAccount); + linphone_account_creator_responses_cbs_set_is_alias_used_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_alias_used(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_phone_number_not_used(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, "012345678", "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*)LinphoneRequestAliasNotExist); + linphone_account_creator_responses_cbs_set_is_alias_used_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_alias_used(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_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, "012345678", "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_account_link_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_set_username(creator, "XXXTESTuser_1"); + + 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*)LinphoneRequestAccountLinked); + linphone_account_creator_responses_cbs_set_is_account_linked_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_linked(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_not_link_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_set_username(creator, "XXXTESTuser_1"); + + 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*)LinphoneRequestAccountNotLinked); + linphone_account_creator_responses_cbs_set_is_account_linked_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_linked(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_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_used(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, "000555456", "1"); + + 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*)LinphoneRequestOk); + linphone_account_creator_responses_cbs_set_recover_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_recover_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_recover_account_with_phone_number_not_used(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, "012345678", "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*)LinphoneRequestAccountNotExist); + linphone_account_creator_responses_cbs_set_recover_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_recover_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_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_with_wrong_password(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, "XXXTESTuser_1"); + linphone_account_creator_set_password(creator, "pssword"); + linphone_account_creator_set_user_data(creator, "newpassword"); + + 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_responses_cbs_set_update_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_update_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_update_account_password_with_correct_password(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, "XXXTESTuser_1"); + 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_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestOk); + linphone_account_creator_responses_cbs_set_update_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_update_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_update_account_password_for_non_existent_account(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, "unknown_user"); + 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_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestErrorServer); + linphone_account_creator_responses_cbs_set_update_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_update_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_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_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( + "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( + "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"), + /* These tests must be carried in a specific order */ + TEST_ONE_TAG( + "Server - Delete accounts test", + server_delete_account_test, + "Server"), + TEST_ONE_TAG( + "Server - Account doesn\'t exist", + server_account_doesnt_exist, + "Server"), + TEST_ONE_TAG( + "Server - Activate a non existent account", + server_activate_non_existent_account, + "Server"), + TEST_ONE_TAG( + "Server - Activate phone number for a non existent account", + server_activate_phone_number_for_non_existent_account, + "Server"), + TEST_ONE_TAG( + "Server - Phone number not used", + server_phone_number_not_used, + "Server"), + TEST_ONE_TAG( + "Server - Update account password for a non existent account", + server_update_account_password_for_non_existent_account, + "Server"), + TEST_ONE_TAG( + "Server - Recover account with phone number not used", + server_recover_account_with_phone_number_not_used, + "Server"), + TEST_ONE_TAG( + "Server - Link a non existent account with phone number", + server_link_non_existent_account_with_phone_number, + "Server"), + TEST_ONE_TAG( + "Server - Account created with email", + server_account_created_with_email, + "Server"), + TEST_ONE_TAG( + "Server - Account exist", + server_account_exist, + "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 not activated", + server_account_not_activated, + "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 - Phone number is used as account", + server_phone_number_is_used_as_account, + "Server"), + TEST_ONE_TAG( + "Server - Account not link with phone number", + server_account_not_link_with_phone_number, + "Server"), + TEST_ONE_TAG( + "Server - Activate account", + server_activate_account_not_activated, + "Server"), + TEST_ONE_TAG( + "Server - Account already activated", + server_account_already_activated, + "Server"), + TEST_ONE_TAG( + "Server - Activate account already activated", + server_activate_account_already_activated, + "Server"), + TEST_ONE_TAG( + "Server - Link account with phone number", + server_link_account_with_phone_number, + "Server"), + TEST_ONE_TAG( + "Server - Activate phone number for an account", + server_activate_phone_number_for_account, + "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( + "Server - Phone number is used as alias", + server_phone_number_is_used_as_alias, + "Server"), + TEST_ONE_TAG( + "Server - Account link with phone number", + server_account_link_with_phone_number, + "Server"), + TEST_ONE_TAG( + "Server - Update account password with wrong password", + server_update_account_password_with_wrong_password, + "Server"), + TEST_ONE_TAG( + "Server - Update account password with correct password", + server_update_account_password_with_correct_password, + "Server"), + TEST_ONE_TAG( + "Server - Recover account with phone number used", + server_recover_account_with_phone_number_used, + "Server"), +}; + +test_suite_t account_creator_test_suite = { + "Account creator", + NULL, + NULL, + liblinphone_tester_before_each, + liblinphone_tester_after_each, + sizeof(account_creator_tests) / sizeof(account_creator_tests[0]), + account_creator_tests}; diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index 7ffcb969a..cf180625c 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -61,6 +61,7 @@ extern test_suite_t video_test_suite; extern test_suite_t multicast_call_test_suite; extern test_suite_t multi_call_test_suite; extern test_suite_t proxy_config_test_suite; +extern test_suite_t account_creator_test_suite; #ifdef VCARD_ENABLED extern test_suite_t vcard_test_suite; #endif diff --git a/tester/rcfiles/account_creator_rc b/tester/rcfiles/account_creator_rc new file mode 100644 index 000000000..443827462 --- /dev/null +++ b/tester/rcfiles/account_creator_rc @@ -0,0 +1,13 @@ +[assistant] +domain=sip.accounttest.org +password_max_length=12 +password_min_length=3 +username_max_length=14 +username_min_length=3 +username_regex=^[A-Za-z0-9_.\-]*$ +xmlrpc_url=https://sip2.linphone.org:446/wizard.php + +[proxy_default_values] +reg_proxy= +realm=sip.accounttest.org +reg_identity=sip:user@sip.accounttest.org diff --git a/tester/tester.c b/tester/tester.c index 1049ec17e..363e84b4e 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -419,7 +419,7 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies LinphoneCoreManager* linphone_core_manager_new3(const char* rc_file, int check_for_proxies, const char* phone_alias) { LinphoneCoreManager *manager = ms_new0(LinphoneCoreManager, 1); - + linphone_core_manager_init(manager, rc_file, phone_alias); linphone_core_manager_start(manager, check_for_proxies); return manager; @@ -560,6 +560,7 @@ void liblinphone_tester_add_suites() { bc_tester_add_suite(&message_test_suite); bc_tester_add_suite(&presence_test_suite); bc_tester_add_suite(&presence_server_test_suite); + bc_tester_add_suite(&account_creator_test_suite); #ifdef UPNP bc_tester_add_suite(&upnp_test_suite); #endif @@ -895,5 +896,6 @@ LinphoneConferenceServer* linphone_conference_server_new(const char *rc_file, bo } void linphone_conference_server_destroy(LinphoneConferenceServer *conf_srv) { + linphone_core_cbs_unref(conf_srv->cbs); linphone_core_manager_destroy((LinphoneCoreManager *)conf_srv); } diff --git a/tools/genapixml.py b/tools/genapixml.py index bd8d9d493..dc3a132b0 100755 --- a/tools/genapixml.py +++ b/tools/genapixml.py @@ -304,6 +304,9 @@ class Project: descriptionNode.tag = 'description' descriptionNode.attrib = {} return descriptionNode + + def __canBeWrapped(self, node): + return node.find('./detaileddescription//donotwrap') is None def __discoverClasses(self): for td in self.__typedefs: @@ -491,6 +494,8 @@ class Project: self.add(td) def __parseCFunctionMemberdef(self, node): + if not Project.__canBeWrapped(self, node): + return None internal = node.find("./detaileddescription/internal") if internal is not None: return None diff --git a/wrappers/cpp/CMakeLists.txt b/wrappers/cpp/CMakeLists.txt index 4720a3054..2ff57dd1f 100644 --- a/wrappers/cpp/CMakeLists.txt +++ b/wrappers/cpp/CMakeLists.txt @@ -22,7 +22,14 @@ add_custom_command(OUTPUT include/linphone++/linphone.hh src/linphone++.cc COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/genwrapper.py" "${PROJECT_BINARY_DIR}/coreapi/help/doc/xml" - DEPENDS abstractapi.py genwrapper.py class_header.mustache class_impl.mustache enums_header.mustache main_header.mustache linphone-doc + DEPENDS ${PROJECT_SOURCE_DIR}/tools/genapixml.py + abstractapi.py + genwrapper.py + class_header.mustache + class_impl.mustache + enums_header.mustache + main_header.mustache + linphone-doc "${PROJECT_BINARY_DIR}/coreapi/help/doc/xml/index.xml" ) @@ -37,8 +44,8 @@ target_link_libraries(linphone++ ) target_include_directories(linphone++ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include - PRIVATE ${CMAKE_BINARY_DIR}/include - PRIVATE ${CMAKE_SOURCE_DIR}/include + PRIVATE ${PROJECT_BINARY_DIR}/include + PRIVATE ${PROJECT_SOURCE_DIR}/include PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${BCTOOLBOX_INCLUDE_DIRS} PRIVATE ${BELLESIP_INCLUDE_DIRS} diff --git a/wrappers/cpp/abstractapi.py b/wrappers/cpp/abstractapi.py index ef27d4ec0..01489ba41 100644 --- a/wrappers/cpp/abstractapi.py +++ b/wrappers/cpp/abstractapi.py @@ -433,68 +433,13 @@ class CParser(object): self.cListType = 'bctbx_list_t' self.regexFixedSizeInteger = '^(u?)int(\d?\d)_t$' self.methodBl = ['ref', 'unref', 'new', 'destroy', 'getCurrentCallbacks', 'setUserData', 'getUserData'] - self.functionBl = ['linphone_tunnel_get_http_proxy', - 'linphone_core_can_we_add_call', - 'linphone_core_add_listener', - 'linphone_core_remove_listener', + self.functionBl = [ 'linphone_core_get_current_callbacks', - 'linphone_proxy_config_set_file_transfer_server', - 'linphone_proxy_config_get_file_transfer_server', 'linphone_factory_create_core', # manualy wrapped 'linphone_factory_create_core_with_config', # manualy wrapped - 'linphone_buffer_get_content', - 'linphone_chat_room_send_chat_message', # overloaded - 'linphone_chat_message_resend', # overloaded - 'linphone_config_read_relative_file', - 'linphone_vcard_get_belcard', # manualy wrapped - 'linphone_chat_room_destroy', # was deprecated when the wrapper generator was made - 'linphone_chat_room_send_message', # was deprecated when the wrapper generator was made - 'linphone_chat_room_send_message2', # was deprecated when the wrapper generator was made - 'linphone_chat_room_get_lc', # was deprecated when the wrapper generator was made - 'linphone_chat_message_start_file_download', # was deprecated when the wrapper generator was made - 'linphone_vcard_new', # was deprecated when the wrapper generator was made - 'linphone_vcard_free', # was deprecated when the wrapper generator was made - 'linphone_call_params_destroy', # was deprecated when the wrapper generator was made - 'linphone_address_is_secure', # was deprecated when the wrapper generator was made - 'linphone_address_destroy', # was deprecated when the wrapper generator was made - 'linphone_core_enable_logs', # was deprecated when the wrapper generator was made - 'linphone_core_enable_logs_with_cb', # was deprecated when the wrapper generator was made - 'linphone_core_disable_logs', # was deprecated when the wrapper generator was made - 'linphone_core_get_user_agent_name', # was deprecated when the wrapper generator was made - 'linphone_core_get_user_agent_version', # was deprecated when the wrapper generator was made - 'linphone_core_new', # was deprecated when the wrapper generator was made - 'linphone_core_new_with_config', # was deprecated when the wrapper generator was made - 'linphone_core_add_listener', # was deprecated when the wrapper generator was made - 'linphone_core_remove_listener', # was deprecated when the wrapper generator was made - 'linphone_core_send_dtmf', # was deprecated when the wrapper generator was made - 'linphone_core_get_default_proxy', # was deprecated when the wrapper generator was made - 'linphone_core_set_firewall_policy', # was deprecated when the wrapper generator was made - 'linphone_core_get_firewall_policy', # was deprecated when the wrapper generator was made - 'linphone_core_get_ring_level', # was deprecated when the wrapper generator was made - 'linphone_core_get_play_level', # was deprecated when the wrapper generator was made - 'linphone_core_get_rec_level', # was deprecated when the wrapper generator was made - 'linphone_core_set_ring_level', # was deprecated when the wrapper generator was made - 'linphone_core_set_play_level', # was deprecated when the wrapper generator was made - 'linphone_core_set_rec_level', # was deprecated when the wrapper generator was made - 'linphone_core_mute_mic', # was deprecated when the wrapper generator was made - 'linphone_core_is_mic_muted', # was deprecated when the wrapper generator was made - 'linphone_core_enable_video', # was deprecated when the wrapper generator was made - 'linphone_core_create_lp_config', # was deprecated when the wrapper generator was made - 'linphone_core_destroy', # was deprecated when the wrapper generator was made - 'linphone_proxy_config_normalize_number', # was deprecated when the wrapper generator was made - 'linphone_call_is_in_conference', # was deprecated when the wrapper generator was made - 'linphone_friend_new', # was deprecated when the wrapper generator was made - 'linphone_friend_new_with_address', # was deprecated when the wrapper generator was made - 'linphone_core_get_sound_source', # was deprecated when the wrapper generator was made - 'linphone_core_set_sound_source', # was deprecated when the wrapper generator was made - 'linphone_core_get_sip_transports', # not wrappable - 'linphone_core_get_sip_transports_used'] # not wrappable + 'linphone_vcard_get_belcard'] # manualy wrapped - self.classBl = ['LinphoneImEncryptionEngine', - 'LinphoneImEncryptionEngineCbs', - 'LinphoneImNotifPolicy', - 'LpConfig', - 'LinphoneErrorInfo', + self.classBl = ['LpConfig', 'LinphonePayloadType', 'LinphonePlayer'] # temporarly blacklisted @@ -781,6 +726,7 @@ class CParser(object): elif cType.ctype in self.classesIndex or cType.ctype in self.interfacesIndex: absType = ClassType(cType.ctype) absType.isconst = cType.completeType.startswith('const ') + absType.isref = cType.completeType.endswith('*') elif cType.ctype == self.cListType: absType = ListType(cType.containedType) else: diff --git a/wrappers/cpp/genwrapper.py b/wrappers/cpp/genwrapper.py index 751c90428..0fb8cd558 100755 --- a/wrappers/cpp/genwrapper.py +++ b/wrappers/cpp/genwrapper.py @@ -274,8 +274,6 @@ class CppTranslator(object): if type(exprtype) is AbsApi.BaseType: if exprtype.name == 'string': cExpr = 'StringUtilities::cppStringToC({0})'.format(cppExpr); - elif exprtype.name not in ['void', 'string', 'string_array'] and exprtype.isref: - cExpr = '&' + cppExpr else: cExpr = cppExpr elif type(exprtype) is AbsApi.EnumType: @@ -293,7 +291,10 @@ class CppTranslator(object): } cExpr = '(::{cPtrType} *)Object::sharedPtrToCPtr(std::static_pointer_cast<{object},{ptrType}>({cppExpr}))'.format(**param) else: - cExpr = '(const ::{_type} *)({expr}).c_struct()'.format(_type=cPtrType, expr=cppExpr) + if exprtype.isref: + cExpr = '(const ::{_type} *)({expr}).c_struct()'.format(_type=cPtrType, expr=cppExpr) + else: + cExpr = '*(const ::{_type} *)({expr}).c_struct()'.format(_type=cPtrType, expr=cppExpr) elif type(exprtype) is AbsApi.ListType: if type(exprtype.containedTypeDesc) is AbsApi.BaseType and exprtype.containedTypeDesc.name == 'string': cExpr = 'StringBctbxListWrapper({0}).c_list()'.format(cppExpr) @@ -315,9 +316,7 @@ class CppTranslator(object): def _wrap_c_expression_to_cpp(self, cExpr, exprtype, usedNamespace=None): if type(exprtype) is AbsApi.BaseType: - if exprtype.name == 'void' and not exprtype.isref: - return cExpr - elif exprtype.name == 'string': + if exprtype.name == 'string': return 'StringUtilities::cStringToCpp({0})'.format(cExpr) elif exprtype.name == 'string_array': return 'StringUtilities::cStringArrayToCppList({0})'.format(cExpr) @@ -338,7 +337,13 @@ class CppTranslator(object): else: return 'Object::cPtrToSharedPtr<{0}>({1})'.format(cppReturnType, cExpr) else: - return '{0}({1})'.format(exprtype.desc.name.to_camel_case(), cExpr); + if exprtype.isref: + return '{0}({1})'.format(exprtype.desc.name.to_camel_case(), cExpr) + else: + return '{0}(StructWrapper<::{1}>({2}).ptr())'.format( + exprtype.desc.name.to_camel_case(), + exprtype.desc.name.to_c(), + cExpr) elif type(exprtype) is AbsApi.ListType: if type(exprtype.containedTypeDesc) is AbsApi.BaseType and exprtype.containedTypeDesc.name == 'string': return 'StringBctbxListWrapper::bctbxListToCppList({0})'.format(cExpr) @@ -391,6 +396,7 @@ class CppTranslator(object): res = _type.size else: res = 'int{0}_t'.format(_type.size) + elif _type.name == 'floatant': if _type.size is not None and _type.size == 'double': res = 'double' @@ -418,7 +424,7 @@ class CppTranslator(object): res = 'const ' + res if _type.isref: - res += ' &' + res += ' *' return res def translate_enum_type(self, _type, **params): diff --git a/wrappers/cpp/tools.hh b/wrappers/cpp/tools.hh index 5d2fae0da..4ef512992 100644 --- a/wrappers/cpp/tools.hh +++ b/wrappers/cpp/tools.hh @@ -119,6 +119,20 @@ namespace linphone { static std::list cStringArrayToCppList(const char **cArray); }; + template + class StructWrapper { + public: + StructWrapper(const T &s) { + mStruct = s; + } + const void *ptr() const { + return &mStruct; + } + + private: + T mStruct; + }; + }; #endif // _TOOLS_HH