Commit a50abfbb authored by Ronan's avatar Ronan

Merge branch 'feature/db-init-before-remote-provisioning' into 'master'

Initialize DB before running remote provisioning and apply factory config after…

See merge request !3
parents 68881ab2 5f5bd423
Pipeline #350 failed with stage
in 0 seconds
......@@ -2110,7 +2110,6 @@ void linphone_configuring_terminated(LinphoneCore *lc, LinphoneConfiguringState
lc->provisioning_http_listener = NULL;
}
L_GET_PRIVATE_FROM_C_OBJECT(lc)->init();
linphone_core_set_state(lc,LinphoneGlobalOn,"Ready");
}
......@@ -2433,6 +2432,8 @@ static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig
void linphone_core_start (LinphoneCore *lc) {
linphone_core_set_state(lc,LinphoneGlobalStartup,"Starting up");
L_GET_PRIVATE_FROM_C_OBJECT(lc)->init();
//to give a chance to change uuid before starting
const char* uuid=lp_config_get_string(lc->config,"misc","uuid",NULL);
if (!uuid){
......
......@@ -88,6 +88,7 @@ struct _LpConfig{
bctbx_vfs_file_t* pFile;
char *filename;
char *tmpfilename;
char *factory_filename;
bctbx_list_t *sections;
bool_t modified;
bool_t readonly;
......@@ -396,6 +397,11 @@ static void _linphone_config_init_from_buffer(LinphoneConfig *conf, const char *
ms_free(ptr);
}
void _linphone_config_apply_factory_config (LpConfig *config) {
if (config->factory_filename)
linphone_config_read_file(config, config->factory_filename);
}
LpConfig * linphone_config_new_from_buffer(const char *buffer){
LpConfig* conf = belle_sip_object_new(LinphoneConfig);
_linphone_config_init_from_buffer(conf, buffer);
......@@ -448,9 +454,7 @@ static int _linphone_config_init_from_files(LinphoneConfig *lpconfig, const char
lpconfig->modified = FALSE;
}
}
if (factory_config_filename != NULL) {
linphone_config_read_file(lpconfig, factory_config_filename);
}
_linphone_config_apply_factory_config(lpconfig);
return 0;
fail:
......@@ -459,6 +463,8 @@ fail:
LpConfig *linphone_config_new_with_factory(const char *config_filename, const char *factory_config_filename) {
LpConfig *lpconfig=belle_sip_object_new(LinphoneConfig);
if (factory_config_filename)
lpconfig->factory_filename = bctbx_strdup(factory_config_filename);
if (_linphone_config_init_from_files(lpconfig, config_filename, factory_config_filename) == 0) {
return lpconfig;
} else {
......@@ -566,6 +572,7 @@ void lp_item_set_value(LpItem *item, const char *value){
static void _linphone_config_uninit(LpConfig *lpconfig){
if (lpconfig->filename!=NULL) ortp_free(lpconfig->filename);
if (lpconfig->tmpfilename) ortp_free(lpconfig->tmpfilename);
if (lpconfig->factory_filename) bctbx_free(lpconfig->factory_filename);
bctbx_list_for_each(lpconfig->sections,(void (*)(void*))lp_section_destroy);
bctbx_list_free(lpconfig->sections);
}
......
......@@ -583,6 +583,7 @@ LinphoneVideoDefinition * linphone_factory_find_supported_video_definition_by_na
const char* _linphone_config_load_from_xml_string(LpConfig *lpc, const char *buffer);
LinphoneNatPolicy * linphone_config_create_nat_policy_from_section(const LinphoneConfig *config, const char* section);
void _linphone_config_apply_factory_config (LpConfig *config);
SalCustomHeader *linphone_info_message_get_headers (const LinphoneInfoMessage *im);
void linphone_info_message_set_headers (LinphoneInfoMessage *im, const SalCustomHeader *headers);
......
......@@ -24,11 +24,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
static void linphone_remote_provisioning_apply(LinphoneCore *lc, const char *xml) {
const char* error_msg = _linphone_config_load_from_xml_string(linphone_core_get_config(lc), xml);
linphone_configuring_terminated(lc
,error_msg ? LinphoneConfiguringFailed : LinphoneConfiguringSuccessful
, error_msg);
LinphoneConfig *config = linphone_core_get_config(lc);
const char *error_msg = _linphone_config_load_from_xml_string(config, xml);
_linphone_config_apply_factory_config(config);
linphone_configuring_terminated(
lc,
error_msg ? LinphoneConfiguringFailed : LinphoneConfiguringSuccessful,
error_msg
);
}
int linphone_remote_provisioning_load_file( LinphoneCore* lc, const char* file_path){
......
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