diff --git a/coreapi/friend.c b/coreapi/friend.c index c24902f2d..41e756a64 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -464,12 +464,16 @@ void linphone_friend_invalidate_subscription(LinphoneFriend *lf){ lf->initial_subscribes_sent=FALSE; } -void linphone_friend_close_subscriptions(LinphoneFriend *lf){ - linphone_friend_unsubscribe(lf); +static void linphone_friend_close_incoming_subscriptions(LinphoneFriend *lf) { bctbx_list_for_each(lf->insubs, (MSIterateFunc) sal_notify_presence_close); lf->insubs = bctbx_list_free_with_data(lf->insubs, (MSIterateFunc)sal_op_release); } +void linphone_friend_close_subscriptions(LinphoneFriend *lf){ + linphone_friend_unsubscribe(lf); + linphone_friend_close_incoming_subscriptions(lf); +} + static void _linphone_friend_release_ops(LinphoneFriend *lf){ lf->insubs = bctbx_list_free_with_data(lf->insubs, (MSIterateFunc) sal_op_release); if (lf->outsub){ @@ -744,6 +748,10 @@ void linphone_friend_apply(LinphoneFriend *fr, LinphoneCore *lc) { } fr->inc_subscribe_pending = FALSE; } + + if (fr->pol == LinphoneSPDeny && fr->insubs) { + linphone_friend_close_incoming_subscriptions(fr); + } linphone_friend_update_subscribes(fr, linphone_core_should_subscribe_friends_only_when_registered(lc)); diff --git a/coreapi/presence.c b/coreapi/presence.c index d24459cc9..66395d885 100644 --- a/coreapi/presence.c +++ b/coreapi/presence.c @@ -1551,12 +1551,17 @@ void linphone_subscription_new(LinphoneCore *lc, SalOp *op, const char *from){ /* check if we answer to this subscription */ lf = linphone_core_find_friend(lc, uri); if (lf!=NULL){ - linphone_friend_add_incoming_subscription(lf, op); - lf->inc_subscribe_pending=TRUE; - if (lp_config_get_int(lc->config,"sip","notify_pending_state",0)) { - sal_notify_pending_state(op); + if (lf->pol != LinphoneSPDeny) { + linphone_friend_add_incoming_subscription(lf, op); + lf->inc_subscribe_pending=TRUE; + if (lp_config_get_int(lc->config,"sip","notify_pending_state",0)) { + sal_notify_pending_state(op); + } + sal_subscribe_accept(op); + } else { + ms_message("%s is not authorized to subscribe", from); + sal_subscribe_decline(op, SalReasonDeclined); } - sal_subscribe_accept(op); linphone_friend_done(lf); /*this will do all necessary actions */ }else{ /* check if this subscriber is in our black list */