Commit f9eaa1a0 authored by Ghislain MARY's avatar Ghislain MARY

Handle body compression for presence list.

parent b961e494
......@@ -595,6 +595,10 @@ int sal_transport_available(Sal *sal, SalTransport t){
return FALSE;
}
bool_t sal_content_encoding_available(Sal *sal, const char *content_encoding) {
return (bool_t)belle_sip_stack_content_encoding_available(sal->stack, content_encoding);
}
static int sal_add_listen_port(Sal *ctx, SalAddress* addr, bool_t is_tunneled){
int result;
belle_sip_listening_point_t* lp;
......
......@@ -419,6 +419,10 @@ void linphone_friend_list_update_subscriptions(LinphoneFriendList *list, Linphon
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);
......
......@@ -2454,6 +2454,12 @@ void linphone_core_enable_ipv6(LinphoneCore *lc, bool_t val){
}
bool_t linphone_core_content_encoding_supported(const LinphoneCore *lc, const char *content_encoding) {
const char *handle_content_encoding = lp_config_get_string(lc->config, "sip", "handle_content_encoding", "deflate");
return (strcmp(handle_content_encoding, content_encoding) == 0) && sal_content_encoding_available(lc->sal, content_encoding);
}
static void monitor_network_state(LinphoneCore *lc, time_t curtime){
bool_t new_status=lc->network_last_status;
char newip[LINPHONE_IPADDR_SIZE];
......
......@@ -3073,6 +3073,8 @@ LINPHONE_PUBLIC void linphone_core_get_sip_transports_used(LinphoneCore *lc, LCS
LINPHONE_PUBLIC bool_t linphone_core_sip_transport_supported(const LinphoneCore *lc, LinphoneTransportType tp);
LINPHONE_PUBLIC bool_t linphone_core_content_encoding_supported(const LinphoneCore *lc, const char *content_encoding);
/**
*
* Give access to the UDP sip socket. Can be useful to configure this socket as persistent I.E kCFStreamNetworkServiceType set to kCFStreamNetworkServiceTypeVoIP)
......
......@@ -587,6 +587,7 @@ int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int i
int sal_get_listening_port(Sal *ctx, SalTransport tr);
int sal_unlisten_ports(Sal *ctx);
LINPHONE_PUBLIC int sal_transport_available(Sal *ctx, SalTransport t);
LINPHONE_PUBLIC bool_t sal_content_encoding_available(Sal *ctx, const char *content_encoding);
void sal_set_dscp(Sal *ctx, int dscp);
void sal_set_supported_tags(Sal *ctx, const char* tags);
void sal_add_supported_tag(Sal *ctx, const char* tag);
......
......@@ -677,7 +677,15 @@ static void enable_publish(LinphoneCoreManager *mgr, bool_t enable) {
linphone_proxy_config_done(cfg);
}
static void test_presence_list(void) {
static void enable_deflate_content_encoding(LinphoneCoreManager *mgr, bool_t enable) {
LinphoneCore *lc = mgr->lc;
if (enable == TRUE)
lp_config_set_string(lc->config, "sip", "handle_content_encoding", "deflate");
else
lp_config_set_string(lc->config, "sip", "handle_content_encoding", "none");
}
static void test_presence_list_base(bool_t enable_compression) {
LinphoneCoreManager *laure = linphone_core_manager_new("laure_tcp_rc");
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc");
......@@ -696,6 +704,9 @@ static void test_presence_list(void) {
enable_publish(marie, TRUE);
enable_publish(pauline, TRUE);
enable_publish(laure, TRUE);
enable_deflate_content_encoding(marie, enable_compression);
enable_deflate_content_encoding(pauline, enable_compression);
enable_deflate_content_encoding(laure, enable_compression);
linphone_core_set_presence_model(marie->lc, linphone_core_create_presence_model_with_activity(marie->lc, LinphonePresenceActivityBusy, NULL));
linphone_core_set_presence_model(pauline->lc, linphone_core_create_presence_model_with_activity(pauline->lc, LinphonePresenceActivityVacation, NULL));
......@@ -801,6 +812,15 @@ static void test_presence_list(void) {
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void test_presence_list(void) {
test_presence_list_base(TRUE);
}
static void test_presence_list_without_compression(void) {
test_presence_list_base(FALSE);
}
#if 0
static void test_presence_list_subscribe_before_publish(void) {
LinphoneCoreManager *laure = linphone_core_manager_new("laure_tcp_rc");
......@@ -852,6 +872,7 @@ static void test_presence_list_subscribe_before_publish(void) {
linphone_core_manager_destroy(pauline);
}
#endif
static void test_presence_list_subscription_expire_for_unknown(void) {
LinphoneCoreManager *laure = linphone_core_manager_new("laure_tcp_rc");
const char *rls_uri = "sip:rls@sip.example.org";
......@@ -968,6 +989,7 @@ test_t presence_tests[] = {
TEST_NO_TAG("Subscribe with late publish", test_subscribe_notify_publish),
TEST_NO_TAG("Forked subscribe with late publish", test_forked_subscribe_notify_publish),
TEST_NO_TAG("Presence list", test_presence_list),
TEST_NO_TAG("Presence list without compression", test_presence_list_without_compression),
TEST_NO_TAG("Presence list, subscription expiration for unknown contact",test_presence_list_subscription_expire_for_unknown),
TEST_NO_TAG("Presence list, silent subscription expiration", test_presence_list_subscribe_dialog_expire),
TEST_NO_TAG("Presence list, io error",test_presence_list_subscribe_io_error)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment