diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index 370d2b4a9..c796f5fee 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -310,6 +310,10 @@ void ClientGroupChatRoom::addParticipants ( content.setBody(getResourceLists(addressesList)); content.setContentType("application/resource-lists+xml"); content.setContentDisposition("recipient-list"); + // TODO: Activate compression + //if (linphone_core_content_encoding_supported(getCore()->getCCore(), "deflate")) + // content.setContentEncoding("deflate"); + // TODO: Activate compression shared_ptr session = dConference->focus->getPrivate()->getSession(); if (session) diff --git a/src/conference/handlers/local-conference-event-handler.cpp b/src/conference/handlers/local-conference-event-handler.cpp index 9e246f9b0..f9f5e2f8a 100644 --- a/src/conference/handlers/local-conference-event-handler.cpp +++ b/src/conference/handlers/local-conference-event-handler.cpp @@ -372,6 +372,10 @@ void LocalConferenceEventHandlerPrivate::notifyParticipantDevice (const string & content, multipart ? "mixed;boundary=---------------------------14737809831466499882746641449" : "conference-info" ); + // TODO: Activate compression + //if (linphone_core_content_encoding_supported(conf->getCore()->getCCore(), "deflate")) + // linphone_content_set_encoding(content, "deflate"); + // TODO: Activate compression linphone_event_notify(ev, content); linphone_content_unref(content); } diff --git a/src/content/content-p.h b/src/content/content-p.h index bb4daced3..d0b8738c6 100644 --- a/src/content/content-p.h +++ b/src/content/content-p.h @@ -33,6 +33,7 @@ private: std::vector body; ContentType contentType; std::string contentDisposition; + std::string contentEncoding; std::list> headers; L_DECLARE_PUBLIC(Content); diff --git a/src/content/content.cpp b/src/content/content.cpp index c6c218ea3..c538141cf 100644 --- a/src/content/content.cpp +++ b/src/content/content.cpp @@ -40,7 +40,8 @@ Content::Content (const Content &other) : ClonableObject(*new ContentPrivate), A L_D(); d->body = other.getBody(); d->contentType = other.getContentType(); - d->contentDisposition = other.getContentDisposition();; + d->contentDisposition = other.getContentDisposition(); + d->contentEncoding = other.getContentEncoding(); d->headers = other.getHeaders(); } @@ -50,6 +51,7 @@ Content::Content (Content &&other) : ClonableObject(*new ContentPrivate), AppDat d->body = move(dOther->body); d->contentType = move(dOther->contentType); d->contentDisposition = move(dOther->contentDisposition); + d->contentEncoding = move(dOther->contentEncoding); d->headers = move(dOther->headers); } @@ -71,6 +73,7 @@ Content &Content::operator= (const Content &other) { d->body = other.getBody(); d->contentType = other.getContentType(); d->contentDisposition = other.getContentDisposition(); + d->contentEncoding = other.getContentEncoding(); d->headers = other.getHeaders(); } return *this; @@ -83,6 +86,7 @@ Content &Content::operator= (Content &&other) { d->body = move(dOther->body); d->contentType = move(dOther->contentType); d->contentDisposition = move(dOther->contentDisposition); + d->contentEncoding = move(dOther->contentEncoding); d->headers = move(dOther->headers); return *this; } @@ -92,6 +96,7 @@ bool Content::operator== (const Content &other) const { return d->contentType == other.getContentType() && d->body == other.getBody() && d->contentDisposition == other.getContentDisposition() && + d->contentEncoding == other.getContentEncoding() && d->headers == other.getHeaders(); } @@ -120,6 +125,16 @@ void Content::setContentDisposition (const string &contentDisposition) { d->contentDisposition = contentDisposition; } +const string &Content::getContentEncoding () const { + L_D(); + return d->contentEncoding; +} + +void Content::setContentEncoding (const string &contentEncoding) { + L_D(); + d->contentEncoding = contentEncoding; +} + const vector &Content::getBody () const { L_D(); return d->body; diff --git a/src/content/content.h b/src/content/content.h index a74bdd147..d3be11f51 100644 --- a/src/content/content.h +++ b/src/content/content.h @@ -54,6 +54,9 @@ public: const std::string &getContentDisposition () const; void setContentDisposition (const std::string &contentDisposition); + const std::string &getContentEncoding () const; + void setContentEncoding (const std::string &contentEncoding); + const std::vector &getBody () const; std::string getBodyAsString () const; std::string getBodyAsUtf8String () const; diff --git a/src/sal/call-op.cpp b/src/sal/call-op.cpp index d2f494064..5a8583479 100644 --- a/src/sal/call-op.cpp +++ b/src/sal/call-op.cpp @@ -103,6 +103,7 @@ belle_sip_header_allow_t *SalCallOp::create_allow(bool_t enable_update) { int SalCallOp::set_custom_body(belle_sip_message_t *msg, const Content &body) { ContentType contentType = body.getContentType(); string contentDisposition = body.getContentDisposition(); + string contentEncoding = body.getContentEncoding(); size_t bodySize = body.getBody().size(); if (bodySize > SIP_MESSAGE_BODY_LIMIT) { @@ -118,12 +119,15 @@ int SalCallOp::set_custom_body(belle_sip_message_t *msg, const Content &body) { belle_sip_header_content_disposition_t *contentDispositionHeader = belle_sip_header_content_disposition_create(contentDisposition.c_str()); belle_sip_message_add_header(msg, BELLE_SIP_HEADER(contentDispositionHeader)); } + if (!contentEncoding.empty()) + belle_sip_message_add_header(msg, belle_sip_header_create("Content-Encoding", contentEncoding.c_str())); belle_sip_header_content_length_t *content_length = belle_sip_header_content_length_create(bodySize); belle_sip_message_add_header(msg, BELLE_SIP_HEADER(content_length)); if (bodySize > 0) { - char *buffer = bctbx_new(char, bodySize); + char *buffer = bctbx_new(char, bodySize + 1); memcpy(buffer, body.getBody().data(), bodySize); + buffer[bodySize] = '\0'; belle_sip_message_assign_body(msg, buffer, bodySize); }