Commit f9e89679 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added implementation of == operator on Content object + added logs and return...

Added implementation of == operator on Content object + added logs and return values in CPIM Chat Message Modifier
parent b7fdc471
......@@ -22,6 +22,7 @@
#include "content/content-type.h"
#include "content/content.h"
#include "address/address.h"
#include "logger/logger.h"
#include "chat/chat-message-p.h"
// =============================================================================
......@@ -60,7 +61,8 @@ int CpimChatMessageModifier::encode (ChatMessagePrivate *messagePrivate) {
message.setContent(contentBody);
if (!message.isValid()) {
//TODO
lError() << "[CPIM] Message is invalid: " << contentBody;
return 500;
} else {
Content newContent;
ContentType newContentType("Message/CPIM");
......@@ -80,7 +82,7 @@ int CpimChatMessageModifier::decode (ChatMessagePrivate *messagePrivate) {
}
ContentType contentType = content.getContentType();
if (contentType.asString() == "Message/CPIM") {
if (ContentType::isCpim(contentType.asString())) {
const vector<char> body = content.getBody();
string contentBody(body.begin(), body.end());
shared_ptr<const Cpim::Message> message = Cpim::Message::createFromString(contentBody);
......@@ -91,10 +93,12 @@ int CpimChatMessageModifier::decode (ChatMessagePrivate *messagePrivate) {
newContent.setBody(message->getContent());
messagePrivate->internalContent = newContent;
} else {
//TODO
lError() << "[CPIM] Message is invalid: " << contentBody;
return 500;
}
} else {
//TODO
lError() << "[CPIM] Message is not CPIM but " << contentType.asString();
return -1;
}
return 0;
}
......
......@@ -72,8 +72,8 @@ Content &Content::operator= (Content &&src) {
}
bool Content::operator==(const Content& content) {
// return true if the two are equal, and false otherwise.
return true;
L_D();
return d->contentType == content.getContentType() && d->body == content.getBody() && d->contentDisposition == content.getContentDisposition();
}
const ContentType &Content::getContentType () const {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment