mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-25 07:08:11 +00:00
account_creator: fix crashes when URL is invalid and set default domain if any
This commit is contained in:
parent
c95c01a16a
commit
8e3f9a337a
2 changed files with 34 additions and 7 deletions
|
|
@ -99,10 +99,14 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreator, belle_sip_object_t,
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -294,8 +298,12 @@ LinphoneAccountCreatorStatus linphone_account_creator_test_existence(LinphoneAcc
|
|||
LinphoneXmlRpcRequest *request;
|
||||
char *identity;
|
||||
|
||||
if (!creator->username || !creator->domain) return LinphoneAccountCreatorFailed;
|
||||
|
||||
if (!creator->username || !creator->domain) {
|
||||
if (creator->callbacks->existence_tested != NULL) {
|
||||
creator->callbacks->existence_tested(creator, LinphoneAccountCreatorFailed);
|
||||
}
|
||||
return LinphoneAccountCreatorFailed;
|
||||
}
|
||||
identity = ms_strdup_printf("%s@%s", creator->username, creator->domain);
|
||||
request = linphone_xml_rpc_request_new_with_args("check_account", LinphoneXmlRpcArgInt,
|
||||
LinphoneXmlRpcArgString, identity,
|
||||
|
|
@ -324,7 +332,12 @@ LinphoneAccountCreatorStatus linphone_account_creator_test_validation(LinphoneAc
|
|||
LinphoneXmlRpcRequest *request;
|
||||
char *identity;
|
||||
|
||||
if (!creator->username || !creator->domain) return LinphoneAccountCreatorFailed;
|
||||
if (!creator->username || !creator->domain) {
|
||||
if (creator->callbacks->validation_tested != NULL) {
|
||||
creator->callbacks->validation_tested(creator, LinphoneAccountCreatorFailed);
|
||||
}
|
||||
return LinphoneAccountCreatorFailed;
|
||||
}
|
||||
|
||||
identity = ms_strdup_printf("%s@%s", creator->username, creator->domain);
|
||||
request = linphone_xml_rpc_request_new_with_args("check_account_validated", LinphoneXmlRpcArgInt,
|
||||
|
|
@ -354,7 +367,12 @@ LinphoneAccountCreatorStatus linphone_account_creator_create_account(LinphoneAcc
|
|||
LinphoneXmlRpcRequest *request;
|
||||
char *identity;
|
||||
|
||||
if (!creator->username || !creator->domain) return LinphoneAccountCreatorFailed;
|
||||
if (!creator->username || !creator->domain) {
|
||||
if (creator->callbacks->create_account != NULL) {
|
||||
creator->callbacks->create_account(creator, LinphoneAccountCreatorFailed);
|
||||
}
|
||||
return LinphoneAccountCreatorFailed;
|
||||
}
|
||||
|
||||
identity = ms_strdup_printf("%s@%s", creator->username, creator->domain);
|
||||
request = linphone_xml_rpc_request_new_with_args("create_account", LinphoneXmlRpcArgInt,
|
||||
|
|
|
|||
|
|
@ -400,14 +400,23 @@ void linphone_xml_rpc_session_send_request(LinphoneXmlRpcSession *session, Linph
|
|||
belle_sip_memory_body_handler_t *bh;
|
||||
const char *data;
|
||||
LinphoneContent *content;
|
||||
|
||||
linphone_xml_rpc_request_ref(request);
|
||||
|
||||
uri = belle_generic_uri_parse(session->url);
|
||||
if (!uri) {
|
||||
ms_error("Could not send request, URL %s is invalid", session->url);
|
||||
belle_sip_object_unref(uri);
|
||||
process_io_error_from_post_xml_rpc_request(request, NULL);
|
||||
return;
|
||||
}
|
||||
req = belle_http_request_create("POST", uri, belle_sip_header_content_type_create("text", "xml"), NULL);
|
||||
if (!req) {
|
||||
process_io_error_from_post_xml_rpc_request(request, NULL);
|
||||
}
|
||||
content = linphone_content_new();
|
||||
linphone_content_set_type(content, "text");
|
||||
linphone_content_set_subtype(content, "xml");
|
||||
linphone_content_set_string_buffer(content, linphone_xml_rpc_request_get_content(request));
|
||||
uri = belle_generic_uri_parse(session->url);
|
||||
req = belle_http_request_create("POST", uri, belle_sip_header_content_type_create("text", "xml"), NULL);
|
||||
data = linphone_xml_rpc_request_get_content(request);
|
||||
bh = belle_sip_memory_body_handler_new_copy_from_buffer(data, strlen(data), NULL, NULL);
|
||||
belle_sip_message_set_body_handler(BELLE_SIP_MESSAGE(req), BELLE_SIP_BODY_HANDLER(bh));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue