Commit 1cfa3b20 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

This should fix domain issue in account creator

parent 6e1beee2
......@@ -46,6 +46,12 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreatorCbs, belle_sip_object_t,
);
/************************** Start Misc **************************/
static const char *_get_domain(LinphoneAccountCreator *creator) {
if (creator->domain)
return creator->domain;
return linphone_proxy_config_get_domain(creator->proxy_cfg);
}
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);
......@@ -689,10 +695,10 @@ LinphoneAccountCreatorStatus linphone_account_creator_is_account_exist_linphone(
ms_debug("Account creator: is_account_exist (%s=%s, domain=%s)",
(creator->username) ? "username" : "phone number",
(creator->username) ? creator->username : creator->phone_number,
linphone_proxy_config_get_domain(creator->proxy_cfg));
_get_domain(creator));
request = linphone_xml_rpc_request_new(LinphoneXmlRpcArgString, "get_phone_number_for_account");
linphone_xml_rpc_request_add_string_arg(request, creator->username ? creator->username : creator->phone_number);
linphone_xml_rpc_request_add_string_arg(request, linphone_proxy_config_get_domain(creator->proxy_cfg));
linphone_xml_rpc_request_add_string_arg(request, _get_domain(creator));
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _is_account_exist_response_cb);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
......@@ -729,16 +735,16 @@ static LinphoneXmlRpcRequest * _create_account_with_phone_custom(LinphoneAccount
ms_debug("Account creator: create_account_with_phone (phone number=%s, username=%s, domain=%s, language=%s)",
creator->phone_number,
(creator->username) ? creator->username : creator->phone_number,
linphone_proxy_config_get_domain(creator->proxy_cfg),
_get_domain(creator),
creator->language);
request = linphone_xml_rpc_request_new(LinphoneXmlRpcArgString, "create_phone_account");
linphone_xml_rpc_request_add_string_arg(request, creator->phone_number);
linphone_xml_rpc_request_add_string_arg(request, creator->username ? creator->username : creator->phone_number);
linphone_xml_rpc_request_add_string_arg(request, creator->password ?
ha1_for_passwd(creator->username ? creator->username : creator->phone_number, linphone_proxy_config_get_domain(creator->proxy_cfg), creator->password) : "");
ha1_for_passwd(creator->username ? creator->username : creator->phone_number, _get_domain(creator), creator->password) : "");
linphone_xml_rpc_request_add_string_arg(request, linphone_core_get_user_agent(creator->core));
linphone_xml_rpc_request_add_string_arg(request, linphone_proxy_config_get_domain(creator->proxy_cfg));
linphone_xml_rpc_request_add_string_arg(request, _get_domain(creator));
linphone_xml_rpc_request_add_string_arg(request, creator->language);
return request;
}
......@@ -751,15 +757,15 @@ static LinphoneXmlRpcRequest * _create_account_with_email_custom(LinphoneAccount
ms_debug("Account creator: create_account_with_email (username=%s, email=%s, domain=%s)",
creator->username,
creator->email,
linphone_proxy_config_get_domain(creator->proxy_cfg));
_get_domain(creator));
request = linphone_xml_rpc_request_new(LinphoneXmlRpcArgString, "create_email_account");
linphone_xml_rpc_request_add_string_arg(request, creator->username);
linphone_xml_rpc_request_add_string_arg(request, creator->email);
linphone_xml_rpc_request_add_string_arg(request,
ha1_for_passwd(creator->username ? creator->username : creator->phone_number, linphone_proxy_config_get_domain(creator->proxy_cfg), creator->password));
ha1_for_passwd(creator->username ? creator->username : creator->phone_number, _get_domain(creator), creator->password));
linphone_xml_rpc_request_add_string_arg(request, linphone_core_get_user_agent(creator->core));
linphone_xml_rpc_request_add_string_arg(request, linphone_proxy_config_get_domain(creator->proxy_cfg));
linphone_xml_rpc_request_add_string_arg(request, _get_domain(creator));
return request;
}
......@@ -822,13 +828,13 @@ LinphoneAccountCreatorStatus linphone_account_creator_activate_account_linphone(
creator->phone_number,
creator->username ? creator->username : creator->phone_number,
creator->activation_code,
linphone_proxy_config_get_domain(creator->proxy_cfg));
_get_domain(creator));
request = linphone_xml_rpc_request_new(LinphoneXmlRpcArgString, "activate_phone_account");
linphone_xml_rpc_request_add_string_arg(request, creator->phone_number);
linphone_xml_rpc_request_add_string_arg(request, creator->username ? creator->username : creator->phone_number);
linphone_xml_rpc_request_add_string_arg(request, creator->activation_code);
linphone_xml_rpc_request_add_string_arg(request, linphone_proxy_config_get_domain(creator->proxy_cfg));
linphone_xml_rpc_request_add_string_arg(request, _get_domain(creator));
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _activate_account_cb_custom);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
......@@ -851,12 +857,12 @@ LinphoneAccountCreatorStatus linphone_account_creator_activate_email_account_lin
ms_debug("Account creator: activate_account_email (username=%s, activation code=%s, domain=%s)",
creator->username,
creator->activation_code,
linphone_proxy_config_get_domain(creator->proxy_cfg));
_get_domain(creator));
request = linphone_xml_rpc_request_new(LinphoneXmlRpcArgString, "activate_email_account");
linphone_xml_rpc_request_add_string_arg(request, creator->username);
linphone_xml_rpc_request_add_string_arg(request, creator->activation_code);
linphone_xml_rpc_request_add_string_arg(request, linphone_proxy_config_get_domain(creator->proxy_cfg));
linphone_xml_rpc_request_add_string_arg(request, _get_domain(creator));
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _activate_account_cb_custom);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
......@@ -893,11 +899,11 @@ LinphoneAccountCreatorStatus linphone_account_creator_is_account_activated_linph
if (creator->xmlrpc_session) {
ms_debug("Account creator: is_account_activated (username=%s, domain=%s)",
creator->username ? creator->username : creator->phone_number,
linphone_proxy_config_get_domain(creator->proxy_cfg));
_get_domain(creator));
request = linphone_xml_rpc_request_new(LinphoneXmlRpcArgString, "is_account_activated");
linphone_xml_rpc_request_add_string_arg(request, creator->username ? creator->username : creator->phone_number);
linphone_xml_rpc_request_add_string_arg(request, linphone_proxy_config_get_domain(creator->proxy_cfg));
linphone_xml_rpc_request_add_string_arg(request, _get_domain(creator));
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _is_account_activated_cb_custom);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
......@@ -939,11 +945,11 @@ LinphoneAccountCreatorStatus linphone_account_creator_is_phone_number_used_linph
if (creator->xmlrpc_session) {
ms_debug("Account creator: is_phone_number_used (phone number=%s, domain=%s)",
creator->phone_number,
linphone_proxy_config_get_domain(creator->proxy_cfg));
_get_domain(creator));
request = linphone_xml_rpc_request_new(LinphoneXmlRpcArgString, "is_phone_number_used");
linphone_xml_rpc_request_add_string_arg(request, creator->phone_number);
linphone_xml_rpc_request_add_string_arg(request, linphone_proxy_config_get_domain(creator->proxy_cfg));
linphone_xml_rpc_request_add_string_arg(request, _get_domain(creator));
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _is_phone_number_used_cb_custom);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
......@@ -983,13 +989,13 @@ LinphoneAccountCreatorStatus linphone_account_creator_link_phone_number_with_acc
ms_debug("Account creator: link_phone_number_with_account (phone number=%s, username=%s, domain=%s, language=%s)",
creator->phone_number,
creator->username,
linphone_proxy_config_get_domain(creator->proxy_cfg),
_get_domain(creator),
creator->language);
request = linphone_xml_rpc_request_new(LinphoneXmlRpcArgString, "link_phone_number_with_account");
linphone_xml_rpc_request_add_string_arg(request, creator->phone_number);
linphone_xml_rpc_request_add_string_arg(request, creator->username);
linphone_xml_rpc_request_add_string_arg(request, linphone_proxy_config_get_domain(creator->proxy_cfg));
linphone_xml_rpc_request_add_string_arg(request, _get_domain(creator));
linphone_xml_rpc_request_add_string_arg(request, creator->language);
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _link_phone_number_with_account_cb_custom);
......@@ -1016,18 +1022,18 @@ static void _get_phone_number_for_account_cb_custom(LinphoneXmlRpcRequest *reque
LinphoneAccountCreatorStatus linphone_account_creator_is_account_linked_linphone(LinphoneAccountCreator *creator) {
LinphoneXmlRpcRequest *request = NULL;
if (!creator->username || !linphone_proxy_config_get_domain(creator->proxy_cfg)) {
if (!creator->username || !_get_domain(creator)) {
return LinphoneAccountCreatorStatusMissingArguments;
}
if (creator->xmlrpc_session) {
ms_debug("Account creator: is_account_linked (username=%s, domain=%s)",
creator->username,
linphone_proxy_config_get_domain(creator->proxy_cfg));
_get_domain(creator));
request = linphone_xml_rpc_request_new(LinphoneXmlRpcArgString, "get_phone_number_for_account");
linphone_xml_rpc_request_add_string_arg(request, creator->username);
linphone_xml_rpc_request_add_string_arg(request, linphone_proxy_config_get_domain(creator->proxy_cfg));
linphone_xml_rpc_request_add_string_arg(request, _get_domain(creator));
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _get_phone_number_for_account_cb_custom);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
......@@ -1053,7 +1059,7 @@ static void _activate_phone_number_link_cb_custom(LinphoneXmlRpcRequest *request
LinphoneAccountCreatorStatus linphone_account_creator_activate_phone_number_link_linphone(LinphoneAccountCreator *creator) {
LinphoneXmlRpcRequest *request = NULL;
if (!creator->phone_number || !creator->username || !creator->activation_code || (!creator->password && !creator->ha1) || !linphone_proxy_config_get_domain(creator->proxy_cfg)) {
if (!creator->phone_number || !creator->username || !creator->activation_code || (!creator->password && !creator->ha1) || !_get_domain(creator)) {
if (creator->cbs->activate_alias_response_cb != NULL) {
creator->cbs->activate_alias_response_cb(creator, LinphoneAccountCreatorStatusMissingArguments, "Missing required parameters");
}
......@@ -1065,14 +1071,14 @@ LinphoneAccountCreatorStatus linphone_account_creator_activate_phone_number_link
creator->phone_number,
creator->username,
creator->activation_code,
linphone_proxy_config_get_domain(creator->proxy_cfg));
_get_domain(creator));
request = linphone_xml_rpc_request_new(LinphoneXmlRpcArgString, "activate_phone_number_link");
linphone_xml_rpc_request_add_string_arg(request, creator->phone_number);
linphone_xml_rpc_request_add_string_arg(request, creator->username);
linphone_xml_rpc_request_add_string_arg(request, creator->activation_code);
linphone_xml_rpc_request_add_string_arg(request, creator->ha1 ? creator->ha1 : ha1_for_passwd(creator->username, linphone_proxy_config_get_domain(creator->proxy_cfg), creator->password));
linphone_xml_rpc_request_add_string_arg(request, linphone_proxy_config_get_domain(creator->proxy_cfg));
linphone_xml_rpc_request_add_string_arg(request, creator->ha1 ? creator->ha1 : ha1_for_passwd(creator->username, _get_domain(creator), creator->password));
linphone_xml_rpc_request_add_string_arg(request, _get_domain(creator));
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _activate_phone_number_link_cb_custom);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
......@@ -1115,12 +1121,12 @@ LinphoneAccountCreatorStatus linphone_account_creator_recover_phone_account_linp
if (creator->xmlrpc_session) {
ms_debug("Account creator: recover_phone_account (phone number=%s, domain=%s, language=%s)",
creator->phone_number,
linphone_proxy_config_get_domain(creator->proxy_cfg),
_get_domain(creator),
creator->language);
request = linphone_xml_rpc_request_new(LinphoneXmlRpcArgString, "recover_phone_account");
linphone_xml_rpc_request_add_string_arg(request, creator->phone_number);
linphone_xml_rpc_request_add_string_arg(request, linphone_proxy_config_get_domain(creator->proxy_cfg));
linphone_xml_rpc_request_add_string_arg(request, _get_domain(creator));
linphone_xml_rpc_request_add_string_arg(request, creator->language);
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _recover_phone_account_cb_custom);
......@@ -1157,7 +1163,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_update_password_linphone(L
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)
|| !_get_domain(creator)
|| (!creator->password && !creator->ha1) || !new_pwd
)
) {
......@@ -1169,18 +1175,18 @@ LinphoneAccountCreatorStatus linphone_account_creator_update_password_linphone(L
if (creator->xmlrpc_session) {
const char *username = creator->username ? creator->username : creator->phone_number;
char *ha1 = bctbx_strdup(creator->ha1 ? creator->ha1 : ha1_for_passwd(username, linphone_proxy_config_get_domain(creator->proxy_cfg), creator->password) );
char *new_ha1 = bctbx_strdup(ha1_for_passwd(username, linphone_proxy_config_get_domain(creator->proxy_cfg), new_pwd));
char *ha1 = bctbx_strdup(creator->ha1 ? creator->ha1 : ha1_for_passwd(username, _get_domain(creator), creator->password) );
char *new_ha1 = bctbx_strdup(ha1_for_passwd(username, _get_domain(creator), new_pwd));
ms_debug("Account creator: update_password (username=%s, domain=%s)",
creator->username,
linphone_proxy_config_get_domain(creator->proxy_cfg));
_get_domain(creator));
request = linphone_xml_rpc_request_new(LinphoneXmlRpcArgString, "update_hash");
linphone_xml_rpc_request_add_string_arg(request, username);
linphone_xml_rpc_request_add_string_arg(request, ha1);
linphone_xml_rpc_request_add_string_arg(request, new_ha1);
linphone_xml_rpc_request_add_string_arg(request, linphone_proxy_config_get_domain(creator->proxy_cfg));
linphone_xml_rpc_request_add_string_arg(request, _get_domain(creator));
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _password_updated_cb_custom);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment