diff --git a/coreapi/friend.c b/coreapi/friend.c index c5de8a872..d46124f58 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -462,8 +462,9 @@ void linphone_friend_apply(LinphoneFriend *fr, LinphoneCore *lc){ } fr->inc_subscribe_pending=FALSE; } - if (fr->lc) - linphone_friend_update_subscribes(fr,NULL,linphone_core_should_subscribe_friends_only_when_registered(fr->lc)); + if (fr->lc) { + linphone_friend_list_update_subscriptions(fr->lc->friendlist, NULL, linphone_core_should_subscribe_friends_only_when_registered(fr->lc)); + } ms_message("linphone_friend_apply() done."); lc->bl_refresh=TRUE; fr->commit=FALSE; diff --git a/coreapi/friendlist.c b/coreapi/friendlist.c index ef9c13a23..97636341e 100644 --- a/coreapi/friendlist.c +++ b/coreapi/friendlist.c @@ -175,6 +175,7 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList if (cid != NULL) linphone_free_xml_text_content(cid); } if (state != NULL) linphone_free_xml_text_content(state); + friend->subscribe_active = TRUE; } linphone_free_xml_text_content(uri); } @@ -198,6 +199,19 @@ end: linphone_xmlparsing_context_destroy(xml_ctx); } +static bool_t linphone_friend_list_has_subscribe_inactive(const LinphoneFriendList *list) { + MSList *l = list->friends; + bool_t has_subscribe_inactive = FALSE; + for (; l != NULL; l = l->next) { + LinphoneFriend *friend = (LinphoneFriend *)l->data; + if (friend->subscribe_active != TRUE) { + has_subscribe_inactive = TRUE; + break; + } + } + return has_subscribe_inactive; +} + static LinphoneFriendList * linphone_friend_list_new(void) { LinphoneFriendList *list = belle_sip_object_new(LinphoneFriendList); belle_sip_object_ref(list); @@ -350,10 +364,11 @@ void linphone_friend_list_update_subscriptions(LinphoneFriendList *list, Linphon if (list->rls_uri != NULL) { LinphoneAddress *address = linphone_address_new(list->rls_uri); char *xml_content = create_resource_list_xml(list); - if ((address != NULL) && (xml_content != NULL)) { + if ((address != NULL) && (xml_content != NULL) && (linphone_friend_list_has_subscribe_inactive(list) == TRUE)) { LinphoneEvent *event; LinphoneContent *content; int expires = lp_config_get_int(list->lc->config, "sip", "rls_presence_expires", 3600); + list->expected_notification_version = 0; event = linphone_core_create_subscribe(list->lc, address, "presence", expires); linphone_event_add_custom_header(event, "Require", "recipient-list-subscribe"); linphone_event_add_custom_header(event, "Supported", "eventlist");