コード例 #1
0
ファイル: friendlist.c プロジェクト: smking1122/heqinphone
void linphone_friend_list_update_subscriptions(LinphoneFriendList *list, LinphoneProxyConfig *cfg, bool_t only_when_registered) {
	const bctbx_list_t *elem;
	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];
				bctbx_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);
				}
			}
			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);
		}
	} else if (list->enable_subscriptions) {
		for (elem = list->friends; elem != NULL; elem = elem->next) {
			LinphoneFriend *lf = (LinphoneFriend *)elem->data;
			linphone_friend_update_subscribes(lf, cfg, only_when_registered);
		}
	}
}
コード例 #2
0
int linphone_event_update_subscribe(LinphoneEvent *lev, const LinphoneContent *body){
	return linphone_event_send_subscribe(lev,body);
}
コード例 #3
0
LinphoneEvent *linphone_core_subscribe(LinphoneCore *lc, const LinphoneAddress *resource, const char *event, int expires, const LinphoneContent *body){
	LinphoneEvent *lev=linphone_core_create_subscribe(lc,resource,event,expires);
	linphone_event_send_subscribe(lev,body);
	return lev;
}