Commit e4d97e2a authored by Simon Morlat's avatar Simon Morlat
Browse files

add release methods for friends and friend list, so that the core can properly...

add release methods for friends and friend list, so that the core can properly shutdown without leaving references.
parent 1a7bb846
...@@ -265,12 +265,16 @@ void linphone_friend_close_subscriptions(LinphoneFriend *lf){ ...@@ -265,12 +265,16 @@ void linphone_friend_close_subscriptions(LinphoneFriend *lf){
lf->insubs = ms_list_free_with_data(lf->insubs, (MSIterateFunc)sal_op_release); lf->insubs = ms_list_free_with_data(lf->insubs, (MSIterateFunc)sal_op_release);
} }
static void _linphone_friend_destroy(LinphoneFriend *lf){ static void _linphone_friend_release_ops(LinphoneFriend *lf){
lf->insubs = ms_list_free_with_data(lf->insubs, (MSIterateFunc) sal_op_release); lf->insubs = ms_list_free_with_data(lf->insubs, (MSIterateFunc) sal_op_release);
if (lf->outsub){ if (lf->outsub){
sal_op_release(lf->outsub); sal_op_release(lf->outsub);
lf->outsub=NULL; lf->outsub=NULL;
} }
}
static void _linphone_friend_destroy(LinphoneFriend *lf){
_linphone_friend_release_ops(lf);
if (lf->presence != NULL) linphone_presence_model_unref(lf->presence); if (lf->presence != NULL) linphone_presence_model_unref(lf->presence);
if (lf->uri!=NULL) linphone_address_destroy(lf->uri); if (lf->uri!=NULL) linphone_address_destroy(lf->uri);
if (lf->info!=NULL) buddy_info_free(lf->info); if (lf->info!=NULL) buddy_info_free(lf->info);
...@@ -712,6 +716,13 @@ void linphone_friend_destroy(LinphoneFriend *lf) { ...@@ -712,6 +716,13 @@ void linphone_friend_destroy(LinphoneFriend *lf) {
linphone_friend_unref(lf); linphone_friend_unref(lf);
} }
/*drops all references to the core and unref*/
void _linphone_friend_release(LinphoneFriend *lf){
lf->lc = NULL;
_linphone_friend_release_ops(lf);
linphone_friend_unref(lf);
}
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneFriend); BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneFriend);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneFriend, belle_sip_object_t, BELLE_SIP_INSTANCIATE_VPTR(LinphoneFriend, belle_sip_object_t,
......
...@@ -250,6 +250,14 @@ LinphoneFriendList * linphone_friend_list_ref(LinphoneFriendList *list) { ...@@ -250,6 +250,14 @@ LinphoneFriendList * linphone_friend_list_ref(LinphoneFriendList *list) {
return list; return list;
} }
void _linphone_friend_list_release(LinphoneFriendList *list){
/*drops all references to core and unref*/
list->lc = NULL;
if (list->event != NULL) linphone_event_unref(list->event);
list->friends = ms_list_free_with_data(list->friends, (void (*)(void *))_linphone_friend_release);
belle_sip_object_unref(list);
}
void linphone_friend_list_unref(LinphoneFriendList *list) { void linphone_friend_list_unref(LinphoneFriendList *list) {
belle_sip_object_unref(list); belle_sip_object_unref(list);
} }
......
...@@ -6352,10 +6352,10 @@ static void codecs_config_uninit(LinphoneCore *lc) ...@@ -6352,10 +6352,10 @@ static void codecs_config_uninit(LinphoneCore *lc)
void ui_config_uninit(LinphoneCore* lc) void ui_config_uninit(LinphoneCore* lc)
{ {
ms_message("Destroying friends."); ms_message("Destroying friends.");
linphone_friend_list_unref(lc->friendlist); _linphone_friend_list_release(lc->friendlist);
lc->friendlist = NULL; lc->friendlist = NULL;
if (lc->subscribers){ if (lc->subscribers){
lc->subscribers = ms_list_free_with_data(lc->subscribers, (void (*)(void *))linphone_friend_unref); lc->subscribers = ms_list_free_with_data(lc->subscribers, (void (*)(void *))_linphone_friend_release);
} }
if (lc->presence_model) { if (lc->presence_model) {
linphone_presence_model_unref(lc->presence_model); linphone_presence_model_unref(lc->presence_model);
......
...@@ -393,8 +393,10 @@ const LinphoneAddress* linphone_proxy_config_get_service_route(const LinphonePro ...@@ -393,8 +393,10 @@ const LinphoneAddress* linphone_proxy_config_get_service_route(const LinphonePro
void linphone_friend_list_invalidate_subscriptions(LinphoneFriendList *list); void linphone_friend_list_invalidate_subscriptions(LinphoneFriendList *list);
void linphone_friend_list_notify_presence_received(LinphoneFriendList *list, LinphoneEvent *lev, const LinphoneContent *body); void linphone_friend_list_notify_presence_received(LinphoneFriendList *list, LinphoneEvent *lev, const LinphoneContent *body);
void _linphone_friend_list_release(LinphoneFriendList *list);
void linphone_friend_invalidate_subscription(LinphoneFriend *lf); void linphone_friend_invalidate_subscription(LinphoneFriend *lf);
void linphone_friend_close_subscriptions(LinphoneFriend *lf); void linphone_friend_close_subscriptions(LinphoneFriend *lf);
void _linphone_friend_release(LinphoneFriend *lf);
void linphone_friend_update_subscribes(LinphoneFriend *fr, LinphoneProxyConfig *cfg, bool_t only_when_registered); void linphone_friend_update_subscribes(LinphoneFriend *fr, LinphoneProxyConfig *cfg, bool_t only_when_registered);
void linphone_friend_notify(LinphoneFriend *lf, LinphonePresenceModel *presence); void linphone_friend_notify(LinphoneFriend *lf, LinphonePresenceModel *presence);
void linphone_friend_add_incoming_subscription(LinphoneFriend *lf, SalOp *op); void linphone_friend_add_incoming_subscription(LinphoneFriend *lf, SalOp *op);
......
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