mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-27 07:59:20 +00:00
Fix remote provisioning
This commit is contained in:
parent
a17e2be2fa
commit
b3df86baf2
3 changed files with 43 additions and 17 deletions
|
|
@ -481,29 +481,45 @@ LinphoneStatus linphone_config_read_file(LpConfig *lpconfig, const char *filenam
|
|||
return -1;
|
||||
}
|
||||
|
||||
static char* _linphone_config_xml_convert(LpConfig *lpc, xml2lpc_context *context, int result) {
|
||||
char* error_msg = NULL;
|
||||
if (result == 0) {
|
||||
result = xml2lpc_convert(context, lpc);
|
||||
if (result == 0) {
|
||||
// if the remote provisioning added a proxy config and none was set before, set it
|
||||
if (lp_config_has_section(lpc, "proxy_0") && lp_config_get_int(lpc, "sip", "default_proxy", -1) == -1){
|
||||
lp_config_set_int(lpc, "sip", "default_proxy", 0);
|
||||
}
|
||||
lp_config_sync(lpc);
|
||||
} else {
|
||||
error_msg = "xml to lpc failed";
|
||||
}
|
||||
} else {
|
||||
error_msg = "invalid xml";
|
||||
}
|
||||
return error_msg;
|
||||
}
|
||||
|
||||
char* linphone_config_load_from_xml_file(LpConfig *lpc, const char *filename, void* lc, void* ctx) {
|
||||
xml2lpc_context *context = NULL;
|
||||
char* path = lp_realpath(filename, NULL);
|
||||
char* error_msg = NULL;
|
||||
|
||||
if (path) {
|
||||
int result = -1;
|
||||
context = xml2lpc_context_new(ctx, lc);
|
||||
result = xml2lpc_set_xml_file(context, path);
|
||||
if (result == 0) {
|
||||
result = xml2lpc_convert(context, lpc);
|
||||
if (result == 0) {
|
||||
// if the remote provisioning added a proxy config and none was set before, set it
|
||||
if (lp_config_has_section(lpc, "proxy_0") && lp_config_get_int(lpc, "sip", "default_proxy", -1) == -1){
|
||||
lp_config_set_int(lpc, "sip", "default_proxy", 0);
|
||||
}
|
||||
lp_config_sync(lpc);
|
||||
} else {
|
||||
error_msg = "xml to lpc failed";
|
||||
}
|
||||
} else {
|
||||
error_msg = "invalid xml";
|
||||
}
|
||||
error_msg = _linphone_config_xml_convert(lpc, context, xml2lpc_set_xml_file(context, path));
|
||||
}
|
||||
if (context) xml2lpc_context_destroy(context);
|
||||
return error_msg;
|
||||
}
|
||||
|
||||
char* linphone_config_load_from_xml_string(LpConfig *lpc, const char *buffer, void* lc, void* ctx) {
|
||||
xml2lpc_context *context = NULL;
|
||||
char* error_msg = NULL;
|
||||
|
||||
if (buffer != NULL) {
|
||||
context = xml2lpc_context_new(ctx, lc);
|
||||
error_msg = _linphone_config_xml_convert(lpc, context, xml2lpc_set_xml_string(context, buffer));
|
||||
}
|
||||
if (context) xml2lpc_context_destroy(context);
|
||||
return error_msg;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ static void xml2lpc_callback(void *ctx, xml2lpc_log_level level, const char *fmt
|
|||
}
|
||||
|
||||
static void linphone_remote_provisioning_apply(LinphoneCore *lc, const char *xml) {
|
||||
char* error_msg = linphone_config_load_from_xml_file(linphone_core_get_config(lc), xml, lc, xml2lpc_callback);
|
||||
char* error_msg = linphone_config_load_from_xml_string(linphone_core_get_config(lc), xml, lc, xml2lpc_callback);
|
||||
|
||||
linphone_configuring_terminated(lc
|
||||
,error_msg ? LinphoneConfiguringFailed : LinphoneConfiguringSuccessful
|
||||
|
|
|
|||
|
|
@ -92,6 +92,16 @@ LINPHONE_PUBLIC LinphoneStatus linphone_config_read_file(LinphoneConfig *lpconfi
|
|||
*/
|
||||
LINPHONE_PUBLIC char* linphone_config_load_from_xml_file(LpConfig *lpc, const char *filename, void* lc, void* ctx);
|
||||
|
||||
/**
|
||||
* Reads a xml config string and fill the LinphoneConfig with the read config dynamic values.
|
||||
* @ingroup misc
|
||||
* @param lpconfig The LinphoneConfig object to fill with the content of the file
|
||||
* @param buffer The string of the config file to fill the LinphoneConfig
|
||||
* @param lc LinphoneCore to share with xml2lpc
|
||||
* @param ctx The context given to xml2lpc callback
|
||||
*/
|
||||
LINPHONE_PUBLIC char* linphone_config_load_from_xml_string(LpConfig *lpc, const char *buffer, void* lc, void* ctx);
|
||||
|
||||
/**
|
||||
* Retrieves a configuration item as a string, given its section, key, and default value.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue