From d678615e26cb1c9d078aa157c9bd70de7bc374a7 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 3 Feb 2016 15:49:25 +0100 Subject: [PATCH] make sure LinphoneFriend created on core always have core back pointer set --- coreapi/friend.c | 16 ++++++++++++++-- coreapi/linphonefriend.h | 6 ++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/coreapi/friend.c b/coreapi/friend.c index 1c11ab21a..0ba8af361 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -483,13 +483,25 @@ void linphone_friend_done(LinphoneFriend *fr){ linphone_friend_apply(fr,fr->lc); } +#if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) +#pragma GCC diagnostic push +#endif +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" LinphoneFriend * linphone_core_create_friend(LinphoneCore *lc) { - return linphone_friend_new(); + LinphoneFriend * lf = linphone_friend_new(); + lf->lc = lc; + return lf; } LinphoneFriend * linphone_core_create_friend_with_address(LinphoneCore *lc, const char *address) { - return linphone_friend_new_with_address(address); + LinphoneFriend * lf = linphone_friend_new_with_address(address); + if (lf) + lf->lc = lc; + return lf; } +#if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) +#pragma GCC diagnostic pop +#endif void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend *lf) { if ((lc->friendlist == NULL) || (linphone_friend_list_add_friend(lc->friendlist, lf) != LinphoneFriendListOK)) return; diff --git a/coreapi/linphonefriend.h b/coreapi/linphonefriend.h index e158d41b5..f0823eaed 100644 --- a/coreapi/linphonefriend.h +++ b/coreapi/linphonefriend.h @@ -118,15 +118,17 @@ typedef struct _LinphoneFriend LinphoneFriend; /** * Contructor * @return a new empty #LinphoneFriend + * @deprecated use #linphone_core_create_friend instead */ -LINPHONE_PUBLIC LinphoneFriend * linphone_friend_new(void); +LINPHONE_PUBLIC MS2_DEPRECATED LinphoneFriend * linphone_friend_new(void); /*fix me me replace MS2_DEPRECATED by LINPHONE_DEPRECATED*/ /** * Contructor same as linphone_friend_new() + linphone_friend_set_address() * @param addr a buddy address, must be a sip uri like sip:joe@sip.linphone.org * @return a new #LinphoneFriend with \link linphone_friend_get_address() address initialized \endlink + * @deprecated use #linphone_core_create_friend_with_address instead */ -LINPHONE_PUBLIC LinphoneFriend *linphone_friend_new_with_address(const char *addr); +LINPHONE_PUBLIC MS2_DEPRECATED LinphoneFriend *linphone_friend_new_with_address(const char *addr); /*fix me me replace MS2_DEPRECATED by LINPHONE_DEPRECATED*/ /** * Contructor same as linphone_friend_new() + linphone_friend_set_address()