From 1d93356d22476598cc8f46aebabff4cae2317793 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 1 Dec 2015 16:59:43 +0100 Subject: [PATCH] Add linphone_core_set_friend_list() function. --- coreapi/friendlist.h | 7 +++++++ coreapi/linphonecore.c | 22 +++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/coreapi/friendlist.h b/coreapi/friendlist.h index 17b805add..a3b7ad7ab 100644 --- a/coreapi/friendlist.h +++ b/coreapi/friendlist.h @@ -56,6 +56,13 @@ typedef struct _LinphoneFriendList LinphoneFriendList; **/ LINPHONE_PUBLIC LinphoneFriendList * linphone_core_create_friend_list(LinphoneCore *lc); +/** + * Set the friend list. + * @param[in] lc LinphoneCore object + * @param[in] list LinphoneFriendList object + */ +LINPHONE_PUBLIC void linphone_core_set_friend_list(LinphoneCore *lc, LinphoneFriendList *list); + /** * Acquire a reference to the friend list. * @param[in] list LinphoneFriendList object. diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 79235453f..20778fd95 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1671,7 +1671,6 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve } static void linphone_core_init(LinphoneCore * lc, const LinphoneCoreVTable *vtable, LpConfig *config, void * userdata){ - const char *rls_uri = NULL; const char *remote_provisioning_uri = NULL; LinphoneCoreVTable* local_vtable= linphone_core_v_table_new(); LinphoneCoreVTable *internal_vtable = linphone_core_v_table_new(); @@ -1680,10 +1679,7 @@ static void linphone_core_init(LinphoneCore * lc, const LinphoneCoreVTable *vtab lc->config=lp_config_ref(config); lc->data=userdata; lc->ringstream_autorelease=TRUE; - lc->friendlist = linphone_core_create_friend_list(lc); - rls_uri = lp_config_get_string(lc->config, "sip", "rls_uri", NULL); - if (rls_uri && lp_config_get_int(lc->config, "sip", "use_rls_presence", 0)) - linphone_friend_list_set_rls_uri(lc->friendlist, rls_uri); + linphone_core_set_friend_list(lc, NULL); linphone_task_list_init(&lc->hooks); internal_vtable->notify_received = linphone_core_internal_notify_received; @@ -1922,6 +1918,22 @@ const MSList * linphone_core_get_friend_list(const LinphoneCore *lc) return lc->friendlist->friends; } +void linphone_core_set_friend_list(LinphoneCore *lc, LinphoneFriendList *list) { + if (lc->friendlist != NULL) { + linphone_friend_list_unref(lc->friendlist); + lc->friendlist = NULL; + } + if (list != NULL) { + lc->friendlist = linphone_friend_list_ref(list); + } else { + const char *rls_uri = NULL; + lc->friendlist = linphone_core_create_friend_list(lc); + rls_uri = lp_config_get_string(lc->config, "sip", "rls_uri", NULL); + if (rls_uri && lp_config_get_int(lc->config, "sip", "use_rls_presence", 0)) + linphone_friend_list_set_rls_uri(lc->friendlist, rls_uri); + } +} + void linphone_core_enable_audio_adaptive_jittcomp(LinphoneCore* lc, bool_t val) { lc->rtp_conf.audio_adaptive_jitt_comp_enabled = val;