mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-22 13:48:09 +00:00
friendlist.c: fix linphone_friend_list_update_subscriptions to avoid switching to P2P presence in case of disabled subscriptions list
This commit is contained in:
parent
8c521d1ba3
commit
8377540fc5
1 changed files with 43 additions and 39 deletions
|
|
@ -619,48 +619,52 @@ static void linphone_friend_list_close_subscriptions(LinphoneFriendList *list) {
|
|||
|
||||
void linphone_friend_list_update_subscriptions(LinphoneFriendList *list, LinphoneProxyConfig *cfg, bool_t only_when_registered) {
|
||||
const MSList *elem;
|
||||
if (list->enable_subscriptions && 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) && (linphone_friend_list_has_subscribe_inactive(list) == TRUE)) {
|
||||
unsigned char digest[16];
|
||||
bctoolbox_md5((unsigned char *)xml_content, strlen(xml_content), digest);
|
||||
if ((list->event != NULL) && (list->content_digest != NULL) && (memcmp(list->content_digest, digest, sizeof(digest)) == 0)) {
|
||||
/* The content has not changed, only refresh the event. */
|
||||
linphone_event_refresh_subscribe(list->event);
|
||||
} else {
|
||||
LinphoneContent *content;
|
||||
int expires = lp_config_get_int(list->lc->config, "sip", "rls_presence_expires", 3600);
|
||||
list->expected_notification_version = 0;
|
||||
if (list->content_digest != NULL) ms_free(list->content_digest);
|
||||
list->content_digest = ms_malloc(sizeof(digest));
|
||||
memcpy(list->content_digest, digest, sizeof(digest));
|
||||
if (list->event != NULL) {
|
||||
linphone_event_terminate(list->event);
|
||||
linphone_event_unref(list->event);
|
||||
if (list->rls_uri != NULL) {
|
||||
if (list->enable_subscriptions) {
|
||||
LinphoneAddress *address = linphone_address_new(list->rls_uri);
|
||||
char *xml_content = create_resource_list_xml(list);
|
||||
if ((address != NULL) && (xml_content != NULL) && (linphone_friend_list_has_subscribe_inactive(list) == TRUE)) {
|
||||
unsigned char digest[16];
|
||||
bctoolbox_md5((unsigned char *)xml_content, strlen(xml_content), digest);
|
||||
if ((list->event != NULL) && (list->content_digest != NULL) && (memcmp(list->content_digest, digest, sizeof(digest)) == 0)) {
|
||||
/* The content has not changed, only refresh the event. */
|
||||
linphone_event_refresh_subscribe(list->event);
|
||||
} else {
|
||||
LinphoneContent *content;
|
||||
int expires = lp_config_get_int(list->lc->config, "sip", "rls_presence_expires", 3600);
|
||||
list->expected_notification_version = 0;
|
||||
if (list->content_digest != NULL) ms_free(list->content_digest);
|
||||
list->content_digest = ms_malloc(sizeof(digest));
|
||||
memcpy(list->content_digest, digest, sizeof(digest));
|
||||
if (list->event != NULL) {
|
||||
linphone_event_terminate(list->event);
|
||||
linphone_event_unref(list->event);
|
||||
}
|
||||
list->event = linphone_core_create_subscribe(list->lc, address, "presence", expires);
|
||||
linphone_event_ref(list->event);
|
||||
linphone_event_set_internal(list->event, TRUE);
|
||||
linphone_event_add_custom_header(list->event, "Require", "recipient-list-subscribe");
|
||||
linphone_event_add_custom_header(list->event, "Supported", "eventlist");
|
||||
linphone_event_add_custom_header(list->event, "Accept", "multipart/related, application/pidf+xml, application/rlmi+xml");
|
||||
linphone_event_add_custom_header(list->event, "Content-Disposition", "recipient-list");
|
||||
content = linphone_core_create_content(list->lc);
|
||||
linphone_content_set_type(content, "application");
|
||||
linphone_content_set_subtype(content, "resource-lists+xml");
|
||||
linphone_content_set_string_buffer(content, xml_content);
|
||||
if (linphone_core_content_encoding_supported(list->lc, "deflate")) {
|
||||
linphone_content_set_encoding(content, "deflate");
|
||||
linphone_event_add_custom_header(list->event, "Accept-Encoding", "deflate");
|
||||
}
|
||||
linphone_event_send_subscribe(list->event, content);
|
||||
linphone_content_unref(content);
|
||||
linphone_event_set_user_data(list->event, list);
|
||||
}
|
||||
list->event = linphone_core_create_subscribe(list->lc, address, "presence", expires);
|
||||
linphone_event_ref(list->event);
|
||||
linphone_event_set_internal(list->event, TRUE);
|
||||
linphone_event_add_custom_header(list->event, "Require", "recipient-list-subscribe");
|
||||
linphone_event_add_custom_header(list->event, "Supported", "eventlist");
|
||||
linphone_event_add_custom_header(list->event, "Accept", "multipart/related, application/pidf+xml, application/rlmi+xml");
|
||||
linphone_event_add_custom_header(list->event, "Content-Disposition", "recipient-list");
|
||||
content = linphone_core_create_content(list->lc);
|
||||
linphone_content_set_type(content, "application");
|
||||
linphone_content_set_subtype(content, "resource-lists+xml");
|
||||
linphone_content_set_string_buffer(content, xml_content);
|
||||
if (linphone_core_content_encoding_supported(list->lc, "deflate")) {
|
||||
linphone_content_set_encoding(content, "deflate");
|
||||
linphone_event_add_custom_header(list->event, "Accept-Encoding", "deflate");
|
||||
}
|
||||
linphone_event_send_subscribe(list->event, content);
|
||||
linphone_content_unref(content);
|
||||
linphone_event_set_user_data(list->event, list);
|
||||
}
|
||||
if (address != NULL) linphone_address_unref(address);
|
||||
if (xml_content != NULL) ms_free(xml_content);
|
||||
} else {
|
||||
ms_message("Friends list [%p] subscription update skipped since subscriptions not enabled yet", list);
|
||||
}
|
||||
if (address != NULL) linphone_address_unref(address);
|
||||
if (xml_content != NULL) ms_free(xml_content);
|
||||
} else {
|
||||
for (elem = list->friends; elem != NULL; elem = elem->next) {
|
||||
LinphoneFriend *lf = (LinphoneFriend *)elem->data;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue