From 45a015e40bf6c3aa2761a82167a7ffc95e4e6710 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 11 Jan 2018 14:49:50 +0100 Subject: [PATCH] Read core config at instantiation, not at start. --- coreapi/im_notif_policy.c | 2 ++ coreapi/linphonecore.c | 30 ++++++++++++++++-------------- tester/setup_tester.c | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/coreapi/im_notif_policy.c b/coreapi/im_notif_policy.c index dff428f73..87867f83f 100644 --- a/coreapi/im_notif_policy.c +++ b/coreapi/im_notif_policy.c @@ -205,6 +205,8 @@ LinphoneImNotifPolicy * linphone_core_get_im_notif_policy(const LinphoneCore *lc } void linphone_core_create_im_notif_policy(LinphoneCore *lc) { + if (lc->im_notif_policy) + linphone_im_notif_policy_unref(lc->im_notif_policy); lc->im_notif_policy = belle_sip_object_new(LinphoneImNotifPolicy); lc->im_notif_policy->lc = lc; load_im_notif_policy_from_config(lc->im_notif_policy); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 9ff41f2be..4bc1769d4 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1084,7 +1084,9 @@ static void net_config_read(LinphoneCore *lc) { nat_policy_ref = lp_config_get_string(lc->config, "net", "nat_policy_ref", NULL); if (nat_policy_ref != NULL) { - lc->nat_policy = linphone_core_create_nat_policy_from_config(lc, nat_policy_ref); + LinphoneNatPolicy *nat_policy = linphone_core_create_nat_policy_from_config(lc, nat_policy_ref); + linphone_core_set_nat_policy(lc, nat_policy); + linphone_nat_policy_unref(nat_policy); } if (lc->nat_policy == NULL){ /*this will create a default nat policy according to deprecated config keys, or an empty nat policy otherwise*/ @@ -1991,12 +1993,7 @@ void linphone_core_reload_ms_plugins(LinphoneCore *lc, const char *path){ codecs_config_read(lc); } -static void _linphone_core_start(LinphoneCore * lc) { - LinphoneFriendList *list = linphone_core_create_friend_list(lc); - linphone_friend_list_set_display_name(list, "_default"); - linphone_core_add_friend_list(lc, list); - linphone_friend_list_unref(list); - +static void _linphone_core_read_config(LinphoneCore * lc) { sip_setup_register_all(lc->factory); sound_config_read(lc); net_config_read(lc); @@ -2005,8 +2002,6 @@ static void _linphone_core_start(LinphoneCore * lc) { sip_config_read(lc); video_config_read(lc); //autoreplier_config_init(&lc->autoreplier_conf); - lc->presence_model=linphone_presence_model_new(); - linphone_presence_model_set_basic_status(lc->presence_model, LinphonePresenceBasicStatusOpen); misc_config_read(lc); ui_config_read(lc); #ifdef TUNNEL_ENABLED @@ -2016,10 +2011,6 @@ static void _linphone_core_start(LinphoneCore * lc) { #endif lc->auto_net_state_mon=lc->sip_conf.auto_net_state_mon; - - L_GET_PRIVATE_FROM_C_OBJECT(lc)->init(); - - linphone_core_set_state(lc,LinphoneGlobalOn,"Ready"); } void linphone_configuring_terminated(LinphoneCore *lc, LinphoneConfiguringState state, const char *message) { @@ -2028,12 +2019,15 @@ void linphone_configuring_terminated(LinphoneCore *lc, LinphoneConfiguringState if (state == LinphoneConfiguringSuccessful) { if (linphone_core_is_provisioning_transient(lc) == TRUE) linphone_core_set_provisioning_uri(lc, NULL); + _linphone_core_read_config(lc); } if (lc->provisioning_http_listener){ belle_sip_object_unref(lc->provisioning_http_listener); lc->provisioning_http_listener = NULL; } - _linphone_core_start(lc); + + L_GET_PRIVATE_FROM_C_OBJECT(lc)->init(); + linphone_core_set_state(lc,LinphoneGlobalOn,"Ready"); } @@ -2306,6 +2300,14 @@ static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig linphone_core_initialize_supported_content_types(lc); lc->bw_controller = ms_bandwidth_controller_new(); + LinphoneFriendList *list = linphone_core_create_friend_list(lc); + linphone_friend_list_set_display_name(list, "_default"); + linphone_core_add_friend_list(lc, list); + linphone_friend_list_unref(list); + lc->presence_model = linphone_presence_model_new(); + linphone_presence_model_set_basic_status(lc->presence_model, LinphonePresenceBasicStatusOpen); + + _linphone_core_read_config(lc); if (automatically_start) { linphone_core_start(lc); } diff --git a/tester/setup_tester.c b/tester/setup_tester.c index e34dcc4cb..16209aeda 100644 --- a/tester/setup_tester.c +++ b/tester/setup_tester.c @@ -404,7 +404,7 @@ test_t setup_tests[] = { TEST_NO_TAG("LPConfig from buffer", linphone_lpconfig_from_buffer), TEST_NO_TAG("LPConfig zero_len value from buffer", linphone_lpconfig_from_buffer_zerolen_value), TEST_NO_TAG("LPConfig zero_len value from file", linphone_lpconfig_from_file_zerolen_value), - TEST_ONE_TAG("LPConfig zero_len value from XML", linphone_lpconfig_from_xml_zerolen_value, "LeaksMemory"), + TEST_NO_TAG("LPConfig zero_len value from XML", linphone_lpconfig_from_xml_zerolen_value), TEST_NO_TAG("Chat room", chat_room_test), TEST_NO_TAG("Devices reload", devices_reload_test), TEST_NO_TAG("Codec usability", codec_usability_test),