Commit e97343cb authored by Ronan's avatar Ronan

feat(Event): ChatMessageEvent is now a ConferenceEvent

parent c88983da
......@@ -56,12 +56,12 @@ LINPHONE_PUBLIC const LinphoneAddress *linphone_conference_participant_event_get
const LinphoneConferenceParticipantEvent *conference_participant_event
);
LINPHONE_PUBLIC LinphoneChatMessageEvent *linphone_chat_message_event_new (
LINPHONE_PUBLIC LinphoneConferenceChatMessageEvent *linphone_chat_message_event_new (
LinphoneChatMessage *chat_message,
time_t time
);
LINPHONE_PUBLIC LinphoneChatMessage *linphone_chat_message_event_get_chat_message (
const LinphoneChatMessageEvent *chat_message_event
const LinphoneConferenceChatMessageEvent *chat_message_event
);
#ifdef __cplusplus
......
......@@ -133,7 +133,7 @@ typedef struct _LinphoneConferenceParticipantEvent LinphoneConferenceParticipant
typedef struct _LinphoneConferenceParticipantDeviceEvent LinphoneConferenceParticipantDeviceEvent;
typedef struct _LinphoneConferenceSubjectEvent LinphoneConferenceSubjectEvent;
typedef struct _LinphoneEventLog LinphoneEventLog;
typedef struct _LinphoneChatMessageEvent LinphoneChatMessageEvent;
typedef struct _LinphoneConferenceChatMessageEvent LinphoneConferenceChatMessageEvent;
// =============================================================================
// C Enums.
......
......@@ -24,11 +24,11 @@
#define L_ENUM_VALUES_EVENT_LOG_TYPE(F) \
F(None) \
F(ChatMessage) \
F(CallStart) \
F(CallEnd) \
F(ConferenceCreated) \
F(ConferenceDestroyed) \
F(ConferenceChatMessage) \
F(ConferenceParticipantAdded) \
F(ConferenceParticipantRemoved) \
F(ConferenceParticipantSetAdmin) \
......
......@@ -94,7 +94,6 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
dial-plan/dial-plan.h
enums.h
event-log/call/call-event.h
event-log/chat/chat-message-event.h
event-log/conference/conference-event-p.h
event-log/conference/conference-event.h
event-log/conference/conference-notified-event-p.h
......@@ -183,7 +182,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
db/session/db-session.cpp
dial-plan/dial-plan.cpp
event-log/call/call-event.cpp
event-log/chat/chat-message-event.cpp
event-log/conference/conference-chat-message-event.cpp
event-log/conference/conference-event.cpp
event-log/conference/conference-notified-event.cpp
event-log/conference/conference-participant-device-event.cpp
......
......@@ -27,13 +27,13 @@
// =============================================================================
L_DECLARE_C_BASE_OBJECT_IMPL(EventLog);
L_DECLARE_C_BASE_OBJECT_IMPL(CallEvent);
L_DECLARE_C_BASE_OBJECT_IMPL(ConferenceChatMessageEvent);
L_DECLARE_C_BASE_OBJECT_IMPL(ConferenceEvent);
L_DECLARE_C_BASE_OBJECT_IMPL(ConferenceParticipantEvent);
L_DECLARE_C_BASE_OBJECT_IMPL(ConferenceParticipantDeviceEvent);
L_DECLARE_C_BASE_OBJECT_IMPL(ConferenceParticipantEvent);
L_DECLARE_C_BASE_OBJECT_IMPL(ConferenceSubjectEvent);
L_DECLARE_C_BASE_OBJECT_IMPL(ChatMessageEvent);
L_DECLARE_C_BASE_OBJECT_IMPL(EventLog);
using namespace std;
......@@ -124,11 +124,11 @@ const LinphoneAddress *linphone_conference_participant_event_get_participant_add
// Message event.
// -----------------------------------------------------------------------------
LinphoneChatMessageEvent *linphone_chat_message_event_new (LinphoneChatMessage *chat_message, time_t time) {
LinphoneChatMessageEvent *chat_message_event = _linphone_ChatMessageEvent_init();
LinphoneConferenceChatMessageEvent *linphone_chat_message_event_new (LinphoneChatMessage *chat_message, time_t time) {
LinphoneConferenceChatMessageEvent *chat_message_event = _linphone_ConferenceChatMessageEvent_init();
L_SET_CPP_PTR_FROM_C_OBJECT(
chat_message_event,
new LinphonePrivate::ChatMessageEvent(
new LinphonePrivate::ConferenceChatMessageEvent(
time,
L_GET_CPP_PTR_FROM_C_OBJECT(chat_message)
)
......@@ -136,7 +136,9 @@ LinphoneChatMessageEvent *linphone_chat_message_event_new (LinphoneChatMessage *
return chat_message_event;
}
LinphoneChatMessage *linphone_chat_message_event_get_chat_message (const LinphoneChatMessageEvent *chat_message_event) {
LinphoneChatMessage *linphone_chat_message_event_get_chat_message (
const LinphoneConferenceChatMessageEvent *chat_message_event
) {
return L_GET_C_BACK_PTR(
L_GET_CPP_PTR_FROM_C_OBJECT(chat_message_event)->getChatMessage()
);
......
......@@ -33,11 +33,11 @@
F(Call, Call) \
F(CallEvent, CallEvent) \
F(ChatMessage, ChatMessage) \
F(ChatMessageEvent, ChatMessageEvent) \
F(ChatRoom, ChatRoom) \
F(ConferenceChatMessageEvent, ConferenceChatMessageEvent) \
F(ConferenceEvent, ConferenceEvent) \
F(ConferenceParticipantEvent, ConferenceParticipantEvent) \
F(ConferenceParticipantDeviceEvent, ConferenceParticipantDeviceEvent) \
F(ConferenceParticipantEvent, ConferenceParticipantEvent) \
F(ConferenceSubjectEvent, ConferenceSubjectEvent) \
F(DialPlan, DialPlan) \
F(EventLog, EventLog) \
......
......@@ -1364,6 +1364,13 @@ const list<Content >& ChatMessage::getContents () const {
return d->contents;
}
void ChatMessage::addContent (Content &&content) {
L_D();
if (d->isReadOnly) return;
d->contents.push_back(move(content));
}
void ChatMessage::addContent (const Content &content) {
L_D();
if (d->isReadOnly) return;
......
......@@ -94,6 +94,7 @@ public:
bool isReadOnly () const;
const std::list<Content> &getContents () const;
void addContent (Content &&content);
void addContent (const Content &content);
void removeContent (const Content &content);
......
......@@ -42,29 +42,18 @@ private:
long insertSipAddress (const std::string &sipAddress);
void insertContent (long messageEventId, const Content &content);
long insertContentType (const std::string &contentType);
long insertEvent (EventLog::Type type, const tm &date);
long insertChatRoom (long sipAddressId, int capabilities, const tm &date);
void insertChatRoomParticipant (long chatRoomId, long sipAddressId, bool isAdmin);
long insertMessageEvent (
const MessageEventReferences &references,
int state,
int direction,
const std::string &imdnMessageId,
bool isSecured,
const std::list<Content> &contents
);
void insertMessageParticipant (long messageEventId, long sipAddressId, int state);
void insertChatMessageParticipant (long messageEventId, long sipAddressId, int state);
// ---------------------------------------------------------------------------
// Events API.
// ---------------------------------------------------------------------------
long insertEvent (const EventLog &eventLog);
long insertCallEvent (const EventLog &eventLog);
long insertMessageEvent (const EventLog &eventLog);
long insertConferenceEvent (const EventLog &eventLog, long *chatRoomId = nullptr);
long insertConferenceCallEvent (const EventLog &eventLog);
long insertConferenceChatMessageEvent (const EventLog &eventLog);
long insertConferenceNotifiedEvent (const EventLog &eventLog);
long insertConferenceParticipantEvent (const EventLog &eventLog);
long insertConferenceParticipantDeviceEvent (const EventLog &eventLog);
......
This diff is collapsed.
......@@ -38,9 +38,9 @@ class LINPHONE_PUBLIC MainDb : public AbstractDb {
public:
enum Filter {
NoFilter = 0x0,
MessageFilter = 0x1,
CallFilter = 0x2,
ConferenceFilter = 0x4
ConferenceCallFilter = 0x1,
ConferenceChatMessageFilter = 0x2,
ConferenceInfoFilter = 0x4
};
typedef int FilterMask;
......
/*
* chat-message-event.cpp
* conference-chat-message-event.cpp
* Copyright (C) 2010-2017 Belledonne Communications SARL
*
* This program is free software; you can redistribute it and/or
......@@ -17,8 +17,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "chat-message-event.h"
#include "event-log/event-log-p.h"
#include "chat/chat-message/chat-message.h"
#include "conference-chat-message-event.h"
#include "conference-event-p.h"
// =============================================================================
......@@ -26,23 +27,28 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
class ChatMessageEventPrivate : public EventLogPrivate {
class ConferenceChatMessageEventPrivate : public ConferenceEventPrivate {
public:
shared_ptr<ChatMessage> chatMessage;
};
// -----------------------------------------------------------------------------
ChatMessageEvent::ChatMessageEvent (
ConferenceChatMessageEvent::ConferenceChatMessageEvent (
time_t time,
const shared_ptr<ChatMessage> &chatMessage
) : EventLog(*new ChatMessageEventPrivate, EventLog::Type::ChatMessage, time) {
) : ConferenceEvent(
*new ConferenceChatMessageEventPrivate,
EventLog::Type::ConferenceChatMessage,
time,
chatMessage->getRemoteAddress()
) {
L_D();
L_ASSERT(chatMessage);
d->chatMessage = chatMessage;
}
shared_ptr<ChatMessage> ChatMessageEvent::getChatMessage () const {
shared_ptr<ChatMessage> ConferenceChatMessageEvent::getChatMessage () const {
L_D();
return d->chatMessage;
}
......
......@@ -22,24 +22,24 @@
#include <memory>
#include "event-log/event-log.h"
#include "conference-event.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
class ChatMessage;
class ChatMessageEventPrivate;
class ConferenceChatMessageEventPrivate;
class LINPHONE_PUBLIC ChatMessageEvent : public EventLog {
class LINPHONE_PUBLIC ConferenceChatMessageEvent : public ConferenceEvent {
public:
ChatMessageEvent (std::time_t time, const std::shared_ptr<ChatMessage> &chatMessage);
ConferenceChatMessageEvent (std::time_t time, const std::shared_ptr<ChatMessage> &chatMessage);
std::shared_ptr<ChatMessage> getChatMessage () const;
private:
L_DECLARE_PRIVATE(ChatMessageEvent);
L_DISABLE_COPY(ChatMessageEvent);
L_DECLARE_PRIVATE(ConferenceChatMessageEvent);
L_DISABLE_COPY(ConferenceChatMessageEvent);
};
LINPHONE_END_NAMESPACE
......
......@@ -21,7 +21,7 @@
#define _EVENTS_H_
#include "call/call-event.h"
#include "chat/chat-message-event.h"
#include "conference/conference-chat-message-event.h"
#include "conference/conference-participant-device-event.h"
#include "conference/conference-subject-event.h"
......
......@@ -44,9 +44,9 @@ static void get_events_count () {
MainDb eventsDb;
BC_ASSERT_TRUE(eventsDb.connect(MainDb::Sqlite3, getDatabasePath()));
BC_ASSERT_EQUAL(eventsDb.getEventsCount(), 4976, int, "%d");
BC_ASSERT_EQUAL(eventsDb.getEventsCount(MainDb::CallFilter), 0, int, "%d");
BC_ASSERT_EQUAL(eventsDb.getEventsCount(MainDb::ConferenceFilter), 0, int, "%d");
BC_ASSERT_EQUAL(eventsDb.getEventsCount(MainDb::MessageFilter), 4976, int, "%d");
BC_ASSERT_EQUAL(eventsDb.getEventsCount(MainDb::ConferenceCallFilter), 0, int, "%d");
BC_ASSERT_EQUAL(eventsDb.getEventsCount(MainDb::ConferenceInfoFilter), 0, int, "%d");
BC_ASSERT_EQUAL(eventsDb.getEventsCount(MainDb::ConferenceChatMessageFilter), 4976, int, "%d");
BC_ASSERT_EQUAL(eventsDb.getEventsCount(MainDb::NoFilter), 4976, int, "%d");
}
......
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