From ffc4abad2d3268d34a9d94c80fc69344f6da7e63 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 19 Sep 2017 11:20:41 +0200 Subject: [PATCH] fix(chat): coding style --- src/chat/chat-message-p.h | 5 +- .../modifier/cpim-chat-message-modifier.cpp | 138 +++++++++--------- 2 files changed, 73 insertions(+), 70 deletions(-) diff --git a/src/chat/chat-message-p.h b/src/chat/chat-message-p.h index 87198de32..7b77764cd 100644 --- a/src/chat/chat-message-p.h +++ b/src/chat/chat-message-p.h @@ -28,6 +28,9 @@ LINPHONE_BEGIN_NAMESPACE class ChatMessagePrivate : public ObjectPrivate { + friend class CpimChatMessageModifier; + friend class MultipartChatMessageModifier; + private: std::weak_ptr chatRoom; ChatMessage::Direction direction = ChatMessage::Incoming; @@ -47,8 +50,6 @@ private: std::shared_ptr eventsDb; L_DECLARE_PUBLIC(ChatMessage); - friend class CpimChatMessageModifier; - friend class MultipartChatMessageModifier; }; LINPHONE_END_NAMESPACE diff --git a/src/chat/modifier/cpim-chat-message-modifier.cpp b/src/chat/modifier/cpim-chat-message-modifier.cpp index d03344abe..e36095c71 100644 --- a/src/chat/modifier/cpim-chat-message-modifier.cpp +++ b/src/chat/modifier/cpim-chat-message-modifier.cpp @@ -16,83 +16,85 @@ * along with this program. If not, see . */ - #include +#include - #include "content/content-type.h" - #include "content/content.h" - #include "chat/chat-message-p.h" - #include "chat/cpim/cpim.h" +#include "chat/chat-message-p.h" +#include "chat/cpim/cpim.h" +#include "content/content-type.h" +#include "content/content.h" - #include "cpim-chat-message-modifier.h" +#include "cpim-chat-message-modifier.h" - LINPHONE_BEGIN_NAMESPACE - - using namespace std; +// ============================================================================= - void CpimChatMessageModifier::encode(LinphonePrivate::ChatMessagePrivate* msg) { - Cpim::Message message; - Cpim::GenericHeader cpimContentTypeHeader; +using namespace std; + +LINPHONE_BEGIN_NAMESPACE + +void CpimChatMessageModifier::encode(LinphonePrivate::ChatMessagePrivate* msg) { + Cpim::Message message; + Cpim::GenericHeader cpimContentTypeHeader; cpimContentTypeHeader.setName("Content-Type"); - cpimContentTypeHeader.setValue("Message/CPIM"); - message.addCpimHeader(cpimContentTypeHeader); - - shared_ptr content; - if (msg->internalContent) { - // Another ChatMessageModifier was called before this one, we apply our changes on the private content - content = msg->internalContent; - } else { - // We're the first ChatMessageModifier to be called, we'll create the private content from the public one - // We take the first one because if there is more of them, the multipart modifier should have been called first - // So we should not be in this block - content = msg->contents.front(); - } + cpimContentTypeHeader.setValue("Message/CPIM"); + message.addCpimHeader(cpimContentTypeHeader); - string contentType = content->getContentType().asString(); - const vector body = content->getBody(); - string contentBody(body.begin(), body.end()); + shared_ptr content; + if (msg->internalContent) { + // Another ChatMessageModifier was called before this one, we apply our changes on the private content + content = msg->internalContent; + } else { + // We're the first ChatMessageModifier to be called, we'll create the private content from the public one + // We take the first one because if there is more of them, the multipart modifier should have been called first + // So we should not be in this block + content = msg->contents.front(); + } - Cpim::GenericHeader contentTypeHeader; + string contentType = content->getContentType().asString(); + const vector body = content->getBody(); + string contentBody(body.begin(), body.end()); + + Cpim::GenericHeader contentTypeHeader; contentTypeHeader.setName("Content-Type"); - contentTypeHeader.setValue(contentType); - message.addContentHeader(contentTypeHeader); + contentTypeHeader.setValue(contentType); + message.addContentHeader(contentTypeHeader); - message.setContent(contentBody); + message.setContent(contentBody); - if (!message.isValid()) { - //TODO - } else { - shared_ptr newContent = make_shared(); - ContentType newContentType("Message/CPIM"); - newContent->setContentType(newContentType); - newContent->setBody(message.asString()); - msg->internalContent = newContent; - } - } + if (!message.isValid()) { + //TODO + } else { + shared_ptr newContent = make_shared(); + ContentType newContentType("Message/CPIM"); + newContent->setContentType(newContentType); + newContent->setBody(message.asString()); + msg->internalContent = newContent; + } +} - void CpimChatMessageModifier::decode(LinphonePrivate::ChatMessagePrivate* msg) { - shared_ptr content; - if (msg->internalContent) { - content = msg->internalContent; - } else { - content = msg->contents.front(); - } +void CpimChatMessageModifier::decode(LinphonePrivate::ChatMessagePrivate* msg) { + shared_ptr content; + if (msg->internalContent) { + content = msg->internalContent; + } else { + content = msg->contents.front(); + } - ContentType contentType = content->getContentType(); - if (contentType.asString() == "Message/CPIM") { - const vector body = content->getBody(); - string contentBody(body.begin(), body.end()); - shared_ptr message = Cpim::Message::createFromString(contentBody); - if (message && message->isValid()) { - shared_ptr newContent = make_shared(); - ContentType newContentType(message->getContentHeaders()->front()->getValue()); - newContent->setContentType(newContentType); - newContent->setBody(message->getContent()); - } else { - //TODO - } - } else { - //TODO - } - } - -LINPHONE_END_NAMESPACE \ No newline at end of file + ContentType contentType = content->getContentType(); + if (contentType.asString() == "Message/CPIM") { + const vector body = content->getBody(); + string contentBody(body.begin(), body.end()); + shared_ptr message = Cpim::Message::createFromString(contentBody); + if (message && message->isValid()) { + shared_ptr newContent = make_shared(); + ContentType newContentType(message->getContentHeaders()->front()->getValue()); + newContent->setContentType(newContentType); + newContent->setBody(message->getContent()); + } else { + //TODO + } + } else { + //TODO + } +} + +LINPHONE_END_NAMESPACE