From 41259c585abc15258e6bdec8749a6ea9db8f1f64 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 16 Apr 2018 16:47:59 +0200 Subject: [PATCH] Compress body of imdn and is-composing messages. --- src/chat/chat-message/chat-message-p.h | 1 + src/chat/chat-message/chat-message.cpp | 2 ++ src/chat/chat-message/notification-message.cpp | 1 + src/sal/message-op-interface.h | 6 ++++++ 4 files changed, 10 insertions(+) diff --git a/src/chat/chat-message/chat-message-p.h b/src/chat/chat-message/chat-message-p.h index a8e9ae60f..464ed8077 100644 --- a/src/chat/chat-message/chat-message-p.h +++ b/src/chat/chat-message/chat-message-p.h @@ -174,6 +174,7 @@ protected: bool negativeDeliveryNotificationRequired = true; bool positiveDeliveryNotificationRequired = true; bool toBeStored = true; + std::string contentEncoding; private: // TODO: Clean attributes. diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index 22321eda6..a8e0855cc 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -770,6 +770,8 @@ void ChatMessagePrivate::send () { } else { if (!internalContent.getContentType().isValid()) internalContent.setContentType(ContentType::PlainText); + if (!contentEncoding.empty()) + internalContent.setContentEncoding(contentEncoding); msgOp->sendMessage(internalContent); } diff --git a/src/chat/chat-message/notification-message.cpp b/src/chat/chat-message/notification-message.cpp index eefcdaf20..16c649d13 100644 --- a/src/chat/chat-message/notification-message.cpp +++ b/src/chat/chat-message/notification-message.cpp @@ -37,6 +37,7 @@ NotificationMessage::NotificationMessage (NotificationMessagePrivate &p) : ChatM d->negativeDeliveryNotificationRequired = false; d->positiveDeliveryNotificationRequired = false; d->toBeStored = false; + d->contentEncoding = "deflate"; } void NotificationMessage::setToBeStored (bool value) { diff --git a/src/sal/message-op-interface.h b/src/sal/message-op-interface.h index ea00bdc6a..981f20e1d 100644 --- a/src/sal/message-op-interface.h +++ b/src/sal/message-op-interface.h @@ -41,6 +41,12 @@ protected: BELLE_SIP_MESSAGE(req), BELLE_SIP_HEADER(belle_sip_header_date_create_from_time(&curtime)) ); + std::string contentEncoding = content.getContentEncoding(); + if (!contentEncoding.empty()) + belle_sip_message_add_header( + BELLE_SIP_MESSAGE(req), + belle_sip_header_create("Content-Encoding", contentEncoding.c_str()) + ); const ContentType &contentType = content.getContentType(); std::string contentTypeStr = std::string(BELLE_SIP_CONTENT_TYPE ": ") + contentType.asString(); belle_sip_message_add_header(