diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 2c5af175206f416d9081b3eb953af8b989a3b71f..92e4c2fd76a6c577b5534272740fc737afd4ac7b 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1340,6 +1340,9 @@ static void certificates_config_read(LinphoneCore *lc) { } static void bodyless_config_read(LinphoneCore *lc) { + // Clean previous friend lists + linphone_core_clear_friend_lists(lc); + bctbx_list_t *bodyless_lists = linphone_config_get_string_list(lc->config, "sip", "bodyless_lists", NULL); while (bodyless_lists) { char *name = (char *)bodyless_lists->data; @@ -1440,13 +1443,13 @@ static void sip_config_read(LinphoneCore *lc) { tmp=lp_config_get_int(lc->config,"sip","delayed_timeout",4); linphone_core_set_delayed_timeout(lc,tmp); - + /*In case of remote provisionning, function sip_config_read is initialy called in core_init, then in state ConfiguringSuccessfull*/ /*Accordingly, to avoid proxy_config to be added twice, it is mandatory to reset proxy config list from LinphoneCore*/ /*We assume, lc->config contains an accurate list of proxy_config, so no need to keep it from LinphoneCore */ /*Consequence in case of remote provisionning, linphone_core_add_proxy function should not be called before state GlobalOn*/ linphone_core_clear_proxy_config(lc); - + /* get proxies config */ for(i=0;; i++){ LinphoneProxyConfig *cfg=linphone_proxy_config_new_from_config_file(lc,i); @@ -2773,6 +2776,15 @@ void linphone_core_remove_friend_list(LinphoneCore *lc, LinphoneFriendList *list lc->friends_lists = bctbx_list_erase_link(lc->friends_lists, elem); } +void linphone_core_clear_friend_lists(LinphoneCore *lc) { + bctbx_list_t* list = bctbx_list_copy(linphone_core_get_friends_lists((const LinphoneCore *)lc)); + bctbx_list_t* copy = list; + for (; list != NULL; list = list->next) { + linphone_core_remove_friend_list(lc, (LinphoneFriendList *)list->data); + } + bctbx_list_free(copy); +} + void linphone_core_add_friend_list(LinphoneCore *lc, LinphoneFriendList *list) { if (!list->lc) { list->lc = lc; diff --git a/include/linphone/core.h b/include/linphone/core.h index 3afe6ae4af6dcb0e061d69eb64cb443f096e9203..547dfe45a9dca25013bdbb032b00d200459508c0 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -5520,6 +5520,12 @@ LINPHONE_PUBLIC void linphone_core_add_friend_list(LinphoneCore *lc, LinphoneFri */ LINPHONE_PUBLIC void linphone_core_remove_friend_list(LinphoneCore *lc, LinphoneFriendList *list); +/** + * Removes all friend lists. + * @param[in] lc #LinphoneCore object + */ +LINPHONE_PUBLIC void linphone_core_clear_friend_lists(LinphoneCore *lc); + /** * Retrieves the list of #LinphoneFriendList from the core. * @param[in] lc #LinphoneCore object