From 0c449e7a6e7738540b677b1716aef71c3367ec2f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 15 May 2018 09:28:05 +0200 Subject: [PATCH] Activate compression for conference event lists. --- src/c-wrapper/api/c-content.cpp | 7 +++---- .../handlers/local-conference-list-event-handler.cpp | 6 ++++++ .../handlers/local-conference-list-event-handler.h | 5 ++++- .../handlers/remote-conference-list-event-handler.cpp | 2 -- src/core/core.cpp | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/c-wrapper/api/c-content.cpp b/src/c-wrapper/api/c-content.cpp index 741f2a24d..1b94349bb 100644 --- a/src/c-wrapper/api/c-content.cpp +++ b/src/c-wrapper/api/c-content.cpp @@ -45,7 +45,6 @@ L_DECLARE_C_CLONABLE_OBJECT_IMPL_WITH_XTORS(Content, string name; string type; string subtype; - string encoding; string buffer; } mutable cache; ) @@ -148,11 +147,11 @@ void linphone_content_set_size (LinphoneContent *content, size_t size) { } const char *linphone_content_get_encoding (const LinphoneContent *content) { - return content->cache.encoding.c_str(); + return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentEncoding()); } void linphone_content_set_encoding (LinphoneContent *content, const char *encoding) { - content->cache.encoding = L_C_TO_STRING(encoding); + L_GET_CPP_PTR_FROM_C_OBJECT(content)->setContentEncoding(L_C_TO_STRING(encoding)); } const char *linphone_content_get_name (const LinphoneContent *content) { @@ -332,7 +331,7 @@ SalBodyHandler *sal_body_handler_from_content (const LinphoneContent *content, b for (const auto ¶m : contentType.getParameters()) sal_body_handler_set_content_type_parameter(body_handler, param.getName().c_str(), param.getValue().c_str()); - if (!content->cache.encoding.empty()) + if (linphone_content_get_encoding(content)) sal_body_handler_set_encoding(body_handler, linphone_content_get_encoding(content)); return body_handler; diff --git a/src/conference/handlers/local-conference-list-event-handler.cpp b/src/conference/handlers/local-conference-list-event-handler.cpp index 7da5a72a3..ddc441877 100644 --- a/src/conference/handlers/local-conference-list-event-handler.cpp +++ b/src/conference/handlers/local-conference-list-event-handler.cpp @@ -52,6 +52,10 @@ namespace { // ----------------------------------------------------------------------------- +LocalConferenceListEventHandler::LocalConferenceListEventHandler (const std::shared_ptr &core) : CoreAccessor(core) {} + +// ----------------------------------------------------------------------------- + void LocalConferenceListEventHandler::subscribeReceived (LinphoneEvent *lev, const LinphoneContent *body) { LinphoneSubscriptionState subscriptionState = linphone_event_get_subscription_state(lev); @@ -162,6 +166,8 @@ void LocalConferenceListEventHandler::subscribeReceived (LinphoneEvent *lev, con contents.push_front(rlmiContent); Content multipart = ContentManager::contentListToMultipart(contents, MultipartBoundaryListEventHandler); + if (linphone_core_content_encoding_supported(getCore()->getCCore(), "deflate")) + multipart.setContentEncoding("deflate"); LinphoneContent *cContent = L_GET_C_BACK_PTR(&multipart); linphone_event_notify(lev, cContent); contents.clear(); diff --git a/src/conference/handlers/local-conference-list-event-handler.h b/src/conference/handlers/local-conference-list-event-handler.h index 70c7750d2..854fa37c1 100644 --- a/src/conference/handlers/local-conference-list-event-handler.h +++ b/src/conference/handlers/local-conference-list-event-handler.h @@ -24,6 +24,7 @@ #include #include "chat/chat-room/chat-room-id.h" +#include "core/core-accessor.h" #include "linphone/utils/general.h" // ============================================================================= @@ -32,8 +33,10 @@ LINPHONE_BEGIN_NAMESPACE class LocalConferenceEventHandler; -class LocalConferenceListEventHandler { +class LocalConferenceListEventHandler : public CoreAccessor { public: + LocalConferenceListEventHandler (const std::shared_ptr &core); + void subscribeReceived (LinphoneEvent *lev, const LinphoneContent *body); void addHandler (LocalConferenceEventHandler *handler); void removeHandler (LocalConferenceEventHandler *handler); diff --git a/src/conference/handlers/remote-conference-list-event-handler.cpp b/src/conference/handlers/remote-conference-list-event-handler.cpp index fa4e2e89b..ea0035e58 100644 --- a/src/conference/handlers/remote-conference-list-event-handler.cpp +++ b/src/conference/handlers/remote-conference-list-event-handler.cpp @@ -113,12 +113,10 @@ void RemoteConferenceListEventHandler::subscribe () { linphone_event_add_custom_header(lev, "Require", "recipient-list-subscribe"); linphone_event_add_custom_header(lev, "Accept", "multipart/related, application/conference-info+xml, application/rlmi+xml"); linphone_event_add_custom_header(lev, "Content-Disposition", "recipient-list"); - /* TODO: enable compression if (linphone_core_content_encoding_supported(lc, "deflate")) { content.setContentEncoding("deflate"); linphone_event_add_custom_header(lev, "Accept-Encoding", "deflate"); } - */ linphone_event_set_user_data(lev, this); LinphoneContent *cContent = L_GET_C_BACK_PTR(&content); linphone_event_send_subscribe(lev, cContent); diff --git a/src/core/core.cpp b/src/core/core.cpp index b6b1e57b9..f9a82dfcc 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -47,7 +47,7 @@ void CorePrivate::init () { L_Q(); mainDb.reset(new MainDb(q->getSharedFromThis())); remoteListEventHandler = makeUnique(q->getSharedFromThis()); - localListEventHandler = makeUnique(); + localListEventHandler = makeUnique(q->getSharedFromThis()); AbstractDb::Backend backend; string uri = L_C_TO_STRING(lp_config_get_string(linphone_core_get_config(L_GET_C_BACK_PTR(q)), "storage", "uri", nullptr));