diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 94c5f0f96..c1143fb8b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -24,12 +24,13 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
address/address-p.h
address/address.h
c-wrapper/c-tools.h
+ chat/chat-message.h
chat/chat-room-p.h
chat/chat-room.h
- content/content.h
- core/core.h
chat/imdn.h
chat/is-composing.h
+ content/content.h
+ core/core.h
cpim/cpim.h
cpim/header/cpim-core-headers.h
cpim/header/cpim-generic-header.h
@@ -53,7 +54,6 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
event-log/event-log.h
event-log/message-event.h
logger/logger.h
- message/message.h
object/clonable-object-p.h
object/clonable-object.h
object/object-p.h
@@ -66,11 +66,12 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
address/address.cpp
c-wrapper/api/c-address.cpp
c-wrapper/api/c-event-log.cpp
+ chat/chat-message.cpp
chat/chat-room.cpp
- content/content.cpp
- core/core.cpp
chat/imdn.cpp
chat/is-composing.cpp
+ content/content.cpp
+ core/core.cpp
cpim/header/cpim-core-headers.cpp
cpim/header/cpim-generic-header.cpp
cpim/header/cpim-header.cpp
@@ -87,7 +88,6 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
event-log/event-log.cpp
event-log/message-event.cpp
logger/logger.cpp
- message/message.cpp
object/clonable-object.cpp
object/object.cpp
utils/content-type.cpp
diff --git a/src/address/address.cpp b/src/address/address.cpp
index ebb88f4ab..7bac71911 100644
--- a/src/address/address.cpp
+++ b/src/address/address.cpp
@@ -16,9 +16,8 @@
* along with this program. If not, see .
*/
-
#include "linphone/utils/utils.h"
-#include
+#include "sal/sal.h"
#include "address-p.h"
#include "c-wrapper/c-tools.h"
diff --git a/src/message/message.cpp b/src/chat/chat-message.cpp
similarity index 53%
rename from src/message/message.cpp
rename to src/chat/chat-message.cpp
index a4e907426..1e6a987ad 100644
--- a/src/message/message.cpp
+++ b/src/chat/chat-message.cpp
@@ -1,5 +1,5 @@
/*
- * message.cpp
+ * chat-message.cpp
* Copyright (C) 2017 Belledonne Communications SARL
*
* This program is free software: you can redistribute it and/or modify
@@ -21,7 +21,7 @@
#include "db/events-db.h"
#include "object/object-p.h"
-#include "message.h"
+#include "chat-message.h"
// =============================================================================
@@ -29,10 +29,10 @@ LINPHONE_BEGIN_NAMESPACE
using namespace std;
-class MessagePrivate : public ObjectPrivate {
+class ChatMessagePrivate : public ObjectPrivate {
private:
weak_ptr chatRoom;
- Message::Direction direction = Message::Incoming;
+ ChatMessage::Direction direction = ChatMessage::Incoming;
// LinphoneAddress *from;
// LinphoneAddress *to;
shared_ptr errorInfo;
@@ -44,18 +44,18 @@ private:
string appData;
list > contents;
unordered_map customHeaders;
- Message::State state = Message::Idle;
+ ChatMessage::State state = ChatMessage::Idle;
shared_ptr eventsDb;
- L_DECLARE_PUBLIC(Message);
+ L_DECLARE_PUBLIC(ChatMessage);
};
// -----------------------------------------------------------------------------
-Message::Message (MessagePrivate &p) : Object(p) {}
+ChatMessage::ChatMessage (ChatMessagePrivate &p) : Object(p) {}
-shared_ptr Message::getChatRoom () const {
- L_D(const Message);
+shared_ptr ChatMessage::getChatRoom () const {
+ L_D(const ChatMessage);
shared_ptr chatRoom = d->chatRoom.lock();
if (!chatRoom) {
// TODO.
@@ -63,110 +63,110 @@ shared_ptr Message::getChatRoom () const {
return chatRoom;
}
-Message::Direction Message::getDirection () const {
- L_D(const Message);
+ChatMessage::Direction ChatMessage::getDirection () const {
+ L_D(const ChatMessage);
return d->direction;
}
-shared_ptr Message::getFromAddress () const {
+shared_ptr ChatMessage::getFromAddress () const {
// TODO.
return nullptr;
}
-shared_ptr Message::getToAddress () const {
+shared_ptr ChatMessage::getToAddress () const {
// TODO.
return nullptr;
}
-shared_ptr Message::getLocalAddress () const {
+shared_ptr ChatMessage::getLocalAddress () const {
// TODO.
return nullptr;
}
-shared_ptr Message::getRemoteAddress () const {
+shared_ptr ChatMessage::getRemoteAddress () const {
// TODO.
return nullptr;
}
-Message::State Message::getState () const {
- L_D(const Message);
+ChatMessage::State ChatMessage::getState () const {
+ L_D(const ChatMessage);
return d->state;
}
-shared_ptr Message::getErrorInfo () const {
- L_D(const Message);
+shared_ptr ChatMessage::getErrorInfo () const {
+ L_D(const ChatMessage);
return d->errorInfo;
}
-string Message::getContentType () const {
- L_D(const Message);
+string ChatMessage::getContentType () const {
+ L_D(const ChatMessage);
return d->contentType;
}
-string Message::getText () const {
- L_D(const Message);
+string ChatMessage::getText () const {
+ L_D(const ChatMessage);
return d->text;
}
-void Message::setText (const string &text) {
- L_D(Message);
+void ChatMessage::setText (const string &text) {
+ L_D(ChatMessage);
d->text = text;
}
-void Message::send () const {
+void ChatMessage::send () const {
// TODO.
}
-bool Message::containsReadableText () const {
+bool ChatMessage::containsReadableText () const {
// TODO: Check content type.
return true;
}
-bool Message::isSecured () const {
- L_D(const Message);
+bool ChatMessage::isSecured () const {
+ L_D(const ChatMessage);
return d->isSecured;
}
-time_t Message::getTime () const {
- L_D(const Message);
+time_t ChatMessage::getTime () const {
+ L_D(const ChatMessage);
return d->time;
}
-string Message::getId () const {
- L_D(const Message);
+string ChatMessage::getId () const {
+ L_D(const ChatMessage);
return d->id;
}
-string Message::getAppdata () const {
- L_D(const Message);
+string ChatMessage::getAppdata () const {
+ L_D(const ChatMessage);
return d->appData;
}
-void Message::setAppdata (const string &appData) {
- L_D(Message);
+void ChatMessage::setAppdata (const string &appData) {
+ L_D(ChatMessage);
d->appData = appData;
}
-list > Message::getContents () const {
- L_D(const Message);
+list > ChatMessage::getContents () const {
+ L_D(const ChatMessage);
list > contents;
for (const auto &content : d->contents)
contents.push_back(content);
return contents;
}
-void Message::addContent (const shared_ptr &content) {
- L_D(Message);
+void ChatMessage::addContent (const shared_ptr &content) {
+ L_D(ChatMessage);
d->contents.push_back(content);
}
-void Message::removeContent (const shared_ptr &content) {
- L_D(Message);
+void ChatMessage::removeContent (const shared_ptr &content) {
+ L_D(ChatMessage);
d->contents.remove(const_pointer_cast(content));
}
-string Message::getCustomHeaderValue (const string &headerName) const {
- L_D(const Message);
+string ChatMessage::getCustomHeaderValue (const string &headerName) const {
+ L_D(const ChatMessage);
try {
return d->customHeaders.at(headerName);
} catch (const exception &) {
@@ -175,13 +175,13 @@ string Message::getCustomHeaderValue (const string &headerName) const {
return "";
}
-void Message::addCustomHeader (const string &headerName, const string &headerValue) {
- L_D(Message);
+void ChatMessage::addCustomHeader (const string &headerName, const string &headerValue) {
+ L_D(ChatMessage);
d->customHeaders[headerName] = headerValue;
}
-void Message::removeCustomHeader (const string &headerName) {
- L_D(Message);
+void ChatMessage::removeCustomHeader (const string &headerName) {
+ L_D(ChatMessage);
d->customHeaders.erase(headerName);
}
diff --git a/src/message/message.h b/src/chat/chat-message.h
similarity index 89%
rename from src/message/message.h
rename to src/chat/chat-message.h
index 3bb643315..830cf9991 100644
--- a/src/message/message.h
+++ b/src/chat/chat-message.h
@@ -1,5 +1,5 @@
/*
- * message.h
+ * chat-message.h
* Copyright (C) 2017 Belledonne Communications SARL
*
* This program is free software: you can redistribute it and/or modify
@@ -16,12 +16,11 @@
* along with this program. If not, see .
*/
-#ifndef _MESSAGE_H_
-#define _MESSAGE_H_
+#ifndef _CHAT_MESSAGE_H_
+#define _CHAT_MESSAGE_H_
#include
#include
-#include
#include "object/object.h"
@@ -33,9 +32,9 @@ class Address;
class ChatRoom;
class Content;
class ErrorInfo;
-class MessagePrivate;
+class ChatMessagePrivate;
-class LINPHONE_PUBLIC Message : public Object {
+class LINPHONE_PUBLIC ChatMessage : public Object {
friend class ChatRoom;
public:
@@ -95,12 +94,12 @@ public:
void removeCustomHeader (const std::string &headerName);
private:
- Message (MessagePrivate &p);
+ ChatMessage (ChatMessagePrivate &p);
- L_DECLARE_PRIVATE(Message);
- L_DISABLE_COPY(Message);
+ L_DECLARE_PRIVATE(ChatMessage);
+ L_DISABLE_COPY(ChatMessage);
};
LINPHONE_END_NAMESPACE
-#endif // ifndef _MESSAGE_H_
+#endif // ifndef _CHAT_MESSAGE_H_
diff --git a/src/db/events-db.cpp b/src/db/events-db.cpp
index a9ce194f7..7fdc13037 100644
--- a/src/db/events-db.cpp
+++ b/src/db/events-db.cpp
@@ -23,10 +23,10 @@
#endif // ifdef SOCI_ENABLED
#include "abstract/abstract-db-p.h"
+#include "chat/chat-message.h"
#include "event-log/call-event.h"
#include "event-log/message-event.h"
#include "logger/logger.h"
-#include "message/message.h"
#include "events-db.h"
@@ -75,25 +75,25 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {}
);
}
- static constexpr EnumToSql messageStateToSql[] = {
- { Message::Idle, "1" },
- { Message::InProgress, "2" },
- { Message::Delivered, "3" },
- { Message::NotDelivered, "4" },
- { Message::FileTransferError, "5" },
- { Message::FileTransferDone, "6" },
- { Message::DeliveredToUser, "7" },
- { Message::Displayed, "8" }
+ static constexpr EnumToSql messageStateToSql[] = {
+ { ChatMessage::Idle, "1" },
+ { ChatMessage::InProgress, "2" },
+ { ChatMessage::Delivered, "3" },
+ { ChatMessage::NotDelivered, "4" },
+ { ChatMessage::FileTransferError, "5" },
+ { ChatMessage::FileTransferDone, "6" },
+ { ChatMessage::DeliveredToUser, "7" },
+ { ChatMessage::Displayed, "8" }
};
- static constexpr const char *mapMessageStateToSql (Message::State state) {
+ static constexpr const char *mapMessageStateToSql (ChatMessage::State state) {
return mapEnumToSql(
messageStateToSql, sizeof messageStateToSql / sizeof messageStateToSql[0], state
);
}
- static constexpr const char *mapMessageDirectionToSql (Message::Direction direction) {
- return direction == Message::Direction::Incoming ? "1" : "2";
+ static constexpr const char *mapMessageDirectionToSql (ChatMessage::Direction direction) {
+ return direction == ChatMessage::Direction::Incoming ? "1" : "2";
}
// -----------------------------------------------------------------------------
@@ -188,6 +188,7 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {}
" dialog_id INT UNSIGNED NOT NULL,"
" state_id TINYINT UNSIGNED NOT NULL,"
" direction_id TINYINT UNSIGNED NOT NULL,"
+ " sender_sip_address_id INT UNSIGNED NOT NULL,"
" imdn_message_id VARCHAR(255) NOT NULL," // See: https://tools.ietf.org/html/rfc5438#section-6.3
" is_secured BOOLEAN NOT NULL,"
" content_type VARCHAR(255) NOT NULL," // Content type of text. (Html or text for example.)
@@ -204,6 +205,9 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {}
" ON DELETE CASCADE,"
" FOREIGN KEY (direction_id)"
" REFERENCES message_direction(id)"
+ " ON DELETE CASCADE,"
+ " FOREIGN KEY (sender_sip_address_id)"
+ " REFERENCES sip_address(id)"
" ON DELETE CASCADE"
")";
@@ -379,8 +383,8 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {}
" SELECT id FROM sip_address WHERE value = :remote_address"
" )"
" )"
- " AND direction_id = " + string(mapMessageDirectionToSql(Message::Incoming)) +
- " AND state_id = " + string(mapMessageStateToSql(Message::Displayed));
+ " AND direction_id = " + string(mapMessageDirectionToSql(ChatMessage::Incoming)) +
+ " AND state_id = " + string(mapMessageStateToSql(ChatMessage::Displayed));
int count = 0;
L_BEGIN_LOG_EXCEPTION
diff --git a/tester/db/linphone.db b/tester/db/linphone.db
index 46eb44d64..948bb10a2 100644
Binary files a/tester/db/linphone.db and b/tester/db/linphone.db differ