Commit f5ec7565 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Added linphone_xml_rpc_request_get_list_response

parent 9c0f3720
......@@ -998,7 +998,7 @@ static void _login_account_confirmation_key_cb_custom(LinphoneXmlRpcRequest *req
}
} else if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) {
status = LinphoneAccountCreatorStatusRequestOk;
const bctbx_map_t *resp = linphone_xml_rpc_request_get_string_struct_response(request);
/*const bctbx_map_t *resp = linphone_xml_rpc_request_get_string_struct_response(request);
const auto &it = bctbx_map_cchar_find_key(resp, "password");
if (!bctbx_iterator_equals(it, bctbx_map_cchar_end(resp))) {
const char *ha1 = (const char *)bctbx_pair_cchar_get_second(bctbx_iterator_cchar_get_pair(it));
......@@ -1021,6 +1021,26 @@ static void _login_account_confirmation_key_cb_custom(LinphoneXmlRpcRequest *req
} else {
ms_error("Couldn't get algorithm from struct response !");
}
}*/
const bctbx_list_t *list = linphone_xml_rpc_request_get_list_response(request);
const char *ha1 = (char *)bctbx_list_get_data(list);
set_string(&creator->ha1, ha1, FALSE);
if (bctbx_list_size(list) > 1) {
const char *algo = (char *)bctbx_list_get_data(bctbx_list_next(list));
if (algo) {
if (creator->algorithm) {
if (strcmp(algo, creator->algorithm) != 0) {
ms_warning("Asked for password hashed using %s, got algorithm %s", creator->algorithm, algo);
} else {
ms_debug("Got password hashed using %s that we requested", algo);
}
} else {
ms_debug("Account creator wasn't configured for a specific alogithm, got %s", algo);
}
set_string(&creator->algorithm, algo, FALSE);
} else {
ms_error("Couldn't get algorithm from struct response !");
}
}
}
......
......@@ -520,7 +520,8 @@ struct _LinphoneXmlRpcArg {
union {
int i;
char *s;
bctbx_map_t *m;
//bctbx_map_t *m;
bctbx_list_t *l;
} data;
};
......
......@@ -251,7 +251,8 @@ static void parse_valid_xml_rpc_response(LinphoneXmlRpcRequest *request, const c
} else {
xmlXPathObjectPtr responses = linphone_get_xml_xpath_object_for_node_list(xml_ctx, "/methodResponse/params/param/value/struct/member");
if (responses != NULL && responses->nodesetval != NULL) {
request->response.data.m = bctbx_mmap_cchar_new();
//request->response.data.m = bctbx_mmap_cchar_new();
request->response.data.l = NULL;
request->status = LinphoneXmlRpcStatusOk;
xmlNodeSetPtr responses_nodes = responses->nodesetval;
......@@ -263,9 +264,11 @@ static void parse_valid_xml_rpc_response(LinphoneXmlRpcRequest *request, const c
{
char *name = linphone_get_xml_text_content(xml_ctx, "name");
char *value = linphone_get_xml_text_content(xml_ctx, "value/string");
ms_message("Found pair with key=[%s] and value=[%s]", name, value);
request->response.data.l = bctbx_list_append(request->response.data.l, bctbx_strdup(value));
const bctbx_pair_cchar_t *pair = bctbx_pair_cchar_new(bctbx_strdup(name), (void *)bctbx_strdup(value));
bctbx_map_cchar_insert(request->response.data.m, (const bctbx_pair_t *)pair);
/*bctbx_pair_t *pair = (bctbx_pair_t*) bctbx_pair_cchar_new(name, (void *)bctbx_strdup(value));
bctbx_map_cchar_insert_and_delete(request->response.data.m, pair);*/
linphone_free_xml_text_content(name);
linphone_free_xml_text_content(value);
......@@ -347,8 +350,16 @@ static void _linphone_xml_rpc_request_destroy(LinphoneXmlRpcRequest *request) {
if ((request->response.type == LinphoneXmlRpcArgString) && (request->response.data.s != NULL)) {
belle_sip_free(request->response.data.s);
} else if (request->response.type == LinphoneXmlRpcArgStringStruct) {
if (request->status == LinphoneXmlRpcStatusOk && request->response.data.m != NULL) {
bctbx_mmap_cchar_delete_with_data(request->response.data.m, bctbx_free);
if (request->status == LinphoneXmlRpcStatusOk) {
/*if (request->response.data.m != NULL) {
bctbx_mmap_cchar_delete_with_data(request->response.data.m, bctbx_free);
request->response.data.m = NULL;
}*/
if (request->response.data.l) {
bctbx_list_free_with_data(request->response.data.l, bctbx_free);
request->response.data.l = NULL;
}
} else if (request->status == LinphoneXmlRpcStatusFailed && request->response.data.s != NULL) {
belle_sip_free(request->response.data.s);
}
......@@ -464,7 +475,12 @@ const char * linphone_xml_rpc_request_get_raw_response(const LinphoneXmlRpcReque
}
const bctbx_map_t* linphone_xml_rpc_request_get_string_struct_response(const LinphoneXmlRpcRequest *request) {
return request->response.data.m;
return NULL;
//return request->response.data.m;
}
const bctbx_list_t *linphone_xml_rpc_request_get_list_response(const LinphoneXmlRpcRequest *request) {
return request->response.data.l;
}
LinphoneXmlRpcSession * linphone_xml_rpc_session_new(LinphoneCore *core, const char *url) {
......
......@@ -148,6 +148,13 @@ LINPHONE_PUBLIC const char * linphone_xml_rpc_request_get_raw_response(const Lin
**/
const bctbx_map_t* linphone_xml_rpc_request_get_string_struct_response(const LinphoneXmlRpcRequest *request);
/**
* Get the response to an XML-RPC request sent with linphone_xml_rpc_session_send_request() and returning a string response.
* @param request LinphoneXmlRpcRequest object. @notnil
* @return \bctbx_list{const char *} A list of all string responses in the XML-RPC request. @maybenil
**/
LINPHONE_PUBLIC const bctbx_list_t *linphone_xml_rpc_request_get_list_response(const LinphoneXmlRpcRequest *request);
/**
* Create a new #LinphoneXmlRpcSession object.
* @param core The #LinphoneCore object used to send the XML-RPC requests. @notnil
......
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