Activate compression for conference event lists.

This commit is contained in:
Ghislain MARY 2018-05-15 09:28:05 +02:00
parent 575069db12
commit 0c449e7a6e
5 changed files with 14 additions and 8 deletions

View file

@ -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 &param : 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;

View file

@ -52,6 +52,10 @@ namespace {
// -----------------------------------------------------------------------------
LocalConferenceListEventHandler::LocalConferenceListEventHandler (const std::shared_ptr<Core> &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();

View file

@ -24,6 +24,7 @@
#include <list>
#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> &core);
void subscribeReceived (LinphoneEvent *lev, const LinphoneContent *body);
void addHandler (LocalConferenceEventHandler *handler);
void removeHandler (LocalConferenceEventHandler *handler);

View file

@ -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);

View file

@ -47,7 +47,7 @@ void CorePrivate::init () {
L_Q();
mainDb.reset(new MainDb(q->getSharedFromThis()));
remoteListEventHandler = makeUnique<RemoteConferenceListEventHandler>(q->getSharedFromThis());
localListEventHandler = makeUnique<LocalConferenceListEventHandler>();
localListEventHandler = makeUnique<LocalConferenceListEventHandler>(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));