LinphoneAccountCreatorStatus linphone_account_creator_activate_account(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); } return LinphoneAccountCreatorReqFailed; } if (creator->phone_number) { request = linphone_xml_rpc_request_new_with_args("activate_phone_account", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->phone_number, LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, LinphoneXmlRpcArgString, creator->activation_code, LinphoneXmlRpcArgNone); } else { request = linphone_xml_rpc_request_new_with_args("activate_email_account", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->username, LinphoneXmlRpcArgString, creator->activation_code, 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_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); ms_free(identity); return LinphoneAccountCreatorOK; }
LinphoneAccountCreatorStatus linphone_account_creator_create_account(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; char *identity; 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, LinphoneXmlRpcArgString, identity, LinphoneXmlRpcArgString, creator->password, LinphoneXmlRpcArgString, creator->email, LinphoneXmlRpcArgInt, (creator->subscribe_to_newsletter == TRUE) ? 1 : 0, LinphoneXmlRpcArgNone); 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_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); ms_free(identity); return LinphoneAccountCreatorOk; }
static void process_auth_requested_from_post_xml_rpc_request(void *data, belle_sip_auth_event_t *event) { LinphoneXmlRpcRequest *request = (LinphoneXmlRpcRequest *)data; ms_error("Authentication error during XML-RPC request sending"); request->status = LinphoneXmlRpcStatusFailed; if (request->callbacks->response != NULL) { request->callbacks->response(request); } linphone_xml_rpc_request_unref(request); }
static void process_io_error_from_post_xml_rpc_request(void *data, const belle_sip_io_error_event_t *event) { LinphoneXmlRpcRequest *request = (LinphoneXmlRpcRequest *)data; ms_error("I/O Error during XML-RPC request sending"); if (!linphone_xml_rpc_request_aborted(request)){ request->status = LinphoneXmlRpcStatusFailed; if (request->callbacks->response != NULL) { request->callbacks->response(request); } } linphone_xml_rpc_request_unref(request); }
static void process_response_from_post_xml_rpc_request(void *data, const belle_http_response_event_t *event) { LinphoneXmlRpcRequest *request = (LinphoneXmlRpcRequest *)data; /* Check the answer code */ if (event->response) { int code = belle_http_response_get_status_code(event->response); if (code == 200) { /* Valid response from the server. */ parse_valid_xml_rpc_response(request, belle_sip_message_get_body((belle_sip_message_t *)event->response)); } else { notify_xml_rpc_error(request); } } linphone_xml_rpc_request_unref(request); }
LinphoneAccountCreatorStatus linphone_account_creator_test_validation(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; char *identity; if (!creator->username || !creator->domain) return LinphoneAccountCreatorFailed; identity = ms_strdup_printf("%s@%s", creator->username, creator->domain); request = linphone_xml_rpc_request_new_with_args("check_account_validated", LinphoneXmlRpcArgInt, _test_validation_cb, creator, LinphoneXmlRpcArgString, identity, LinphoneXmlRpcArgNone); linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); ms_free(identity); return LinphoneAccountCreatorOk; }
LinphoneAccountCreatorStatus linphone_account_creator_test_existence(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; char *identity; if (!creator->username || !creator->domain) 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, LinphoneXmlRpcArgNone); linphone_xml_rpc_request_set_user_data(request, creator); linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _test_existence_cb); linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); ms_free(identity); return LinphoneAccountCreatorOk; }
LinphoneAccountCreatorStatus linphone_account_creator_recover_phone_account(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; if (!creator->phone_number) { if (creator->callbacks->recover_phone_account != NULL) { creator->callbacks->recover_phone_account(creator, LinphoneAccountCreatorReqFailed); } return LinphoneAccountCreatorReqFailed; } request = linphone_xml_rpc_request_new_with_args("recover_phone_account", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->phone_number, 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_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); return LinphoneAccountCreatorOK; }
LinphoneAccountCreatorStatus linphone_account_creator_validate(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; char *identity; if (!creator->username || !creator->domain) return LinphoneAccountCreatorFailed; identity = ms_strdup_printf("%s@%s", creator->username, creator->domain); request = linphone_xml_rpc_request_new_with_args("create_account", LinphoneXmlRpcArgInt, _validate_cb, creator, LinphoneXmlRpcArgString, identity, LinphoneXmlRpcArgString, creator->password, LinphoneXmlRpcArgString, creator->email, LinphoneXmlRpcArgInt, (creator->subscribe_to_newsletter == TRUE) ? 1 : 0, LinphoneXmlRpcArgNone); linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); ms_free(identity); return LinphoneAccountCreatorOk; }
LinphoneAccountCreatorStatus linphone_account_creator_test_validation(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; char *identity = _get_identity(creator); if (!identity) { if (creator->callbacks->validation_tested != NULL) { creator->callbacks->validation_tested(creator, LinphoneAccountCreatorReqFailed); } return LinphoneAccountCreatorReqFailed; } request = linphone_xml_rpc_request_new_with_args("check_account_validated", LinphoneXmlRpcArgInt, LinphoneXmlRpcArgString, identity, LinphoneXmlRpcArgNone); linphone_xml_rpc_request_set_user_data(request, creator); linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _test_validation_cb); linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); ms_free(identity); return LinphoneAccountCreatorOK; }
LinphoneAccountCreatorStatus linphone_account_creator_create_account(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); } if (identity) ms_free(identity); return LinphoneAccountCreatorReqFailed; } 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_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); ms_free(identity); return LinphoneAccountCreatorOK; }
LinphoneAccountCreatorStatus linphone_account_creator_activate_phone_number_link(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; if (!creator->phone_number || !creator->username || !creator->activation_code || !creator->password || !creator->domain) { if (creator->callbacks->activate_phone_number_link != NULL) { creator->callbacks->activate_phone_number_link(creator, LinphoneAccountCreatorReqFailed); } return LinphoneAccountCreatorReqFailed; } request = linphone_xml_rpc_request_new_with_args("activate_phone_number_link", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->phone_number, LinphoneXmlRpcArgString, creator->username, LinphoneXmlRpcArgString, creator->activation_code, LinphoneXmlRpcArgString, ha1_for_passwd(creator->username, creator->password, 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), _activate_phone_number_link_cb); linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); return LinphoneAccountCreatorOK; }