Commit f94f5152 authored by Ronan's avatar Ronan

feat(core): rename message to chat-message

parent 0130de40
......@@ -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
......
......@@ -16,9 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "linphone/utils/utils.h"
#include <sal/sal.h>
#include "sal/sal.h"
#include "address-p.h"
#include "c-wrapper/c-tools.h"
......
/*
* 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> chatRoom;
Message::Direction direction = Message::Incoming;
ChatMessage::Direction direction = ChatMessage::Incoming;
// LinphoneAddress *from;
// LinphoneAddress *to;
shared_ptr<ErrorInfo> errorInfo;
......@@ -44,18 +44,18 @@ private:
string appData;
list<shared_ptr<Content> > contents;
unordered_map<string, string> customHeaders;
Message::State state = Message::Idle;
ChatMessage::State state = ChatMessage::Idle;
shared_ptr<EventsDb> eventsDb;
L_DECLARE_PUBLIC(Message);
L_DECLARE_PUBLIC(ChatMessage);
};
// -----------------------------------------------------------------------------
Message::Message (MessagePrivate &p) : Object(p) {}
ChatMessage::ChatMessage (ChatMessagePrivate &p) : Object(p) {}
shared_ptr<ChatRoom> Message::getChatRoom () const {
L_D(const Message);
shared_ptr<ChatRoom> ChatMessage::getChatRoom () const {
L_D(const ChatMessage);
shared_ptr<ChatRoom> chatRoom = d->chatRoom.lock();
if (!chatRoom) {
// TODO.
......@@ -63,110 +63,110 @@ shared_ptr<ChatRoom> 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<const Address> Message::getFromAddress () const {
shared_ptr<const Address> ChatMessage::getFromAddress () const {
// TODO.
return nullptr;
}
shared_ptr<const Address> Message::getToAddress () const {
shared_ptr<const Address> ChatMessage::getToAddress () const {
// TODO.
return nullptr;
}
shared_ptr<const Address> Message::getLocalAddress () const {
shared_ptr<const Address> ChatMessage::getLocalAddress () const {
// TODO.
return nullptr;
}
shared_ptr<const Address> Message::getRemoteAddress () const {
shared_ptr<const Address> 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<const ErrorInfo> Message::getErrorInfo () const {
L_D(const Message);
shared_ptr<const ErrorInfo> 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<shared_ptr<const Content> > Message::getContents () const {
L_D(const Message);
list<shared_ptr<const Content> > ChatMessage::getContents () const {
L_D(const ChatMessage);
list<shared_ptr<const Content> > contents;
for (const auto &content : d->contents)
contents.push_back(content);
return contents;
}
void Message::addContent (const shared_ptr<Content> &content) {
L_D(Message);
void ChatMessage::addContent (const shared_ptr<Content> &content) {
L_D(ChatMessage);
d->contents.push_back(content);
}
void Message::removeContent (const shared_ptr<const Content> &content) {
L_D(Message);
void ChatMessage::removeContent (const shared_ptr<const Content> &content) {
L_D(ChatMessage);
d->contents.remove(const_pointer_cast<Content>(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);
}
......
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef _MESSAGE_H_
#define _MESSAGE_H_
#ifndef _CHAT_MESSAGE_H_
#define _CHAT_MESSAGE_H_
#include <list>
#include <memory>
#include <string>
#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_
......@@ -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<Message::State> 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<ChatMessage::State> 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
......
No preview for this file type
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