From 90b653f60fb1933b4d57819fb7af7b0c85b142b3 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 22 Nov 2017 15:26:10 +0100 Subject: [PATCH] fix(chat-room): hide public onChatMessageReceived handler! --- src/c-wrapper/api/c-chat-message.cpp | 7 +++---- src/chat/chat-message/chat-message.cpp | 6 +++--- src/chat/chat-room/basic-chat-room-p.h | 2 ++ src/chat/chat-room/basic-chat-room.cpp | 9 ++++++--- src/chat/chat-room/basic-chat-room.h | 3 --- src/chat/chat-room/chat-room-p.h | 2 ++ src/chat/chat-room/chat-room.cpp | 2 +- src/chat/chat-room/chat-room.h | 2 -- src/chat/chat-room/client-group-chat-room-p.h | 2 ++ src/chat/chat-room/client-group-chat-room.cpp | 4 ++-- src/chat/chat-room/client-group-chat-room.h | 2 -- src/chat/chat-room/server-group-chat-room-p.h | 2 ++ .../chat-room/server-group-chat-room-stub.cpp | 4 ++-- src/chat/chat-room/server-group-chat-room.h | 1 - src/content/content.cpp | 2 -- src/content/content.h | 5 ++--- src/content/file-content.cpp | 15 ++++++-------- src/content/file-content.h | 20 +++++++++---------- src/core/core.cpp | 8 ++++++-- src/core/core.h | 14 ++++++------- 20 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/c-wrapper/api/c-chat-message.cpp b/src/c-wrapper/api/c-chat-message.cpp index 6482a9d91..c04cee0d6 100644 --- a/src/c-wrapper/api/c-chat-message.cpp +++ b/src/c-wrapper/api/c-chat-message.cpp @@ -292,11 +292,10 @@ bool_t linphone_chat_message_has_text_content(const LinphoneChatMessage *msg) { return L_GET_PRIVATE_FROM_C_OBJECT(msg)->hasTextContent(); } -const char * linphone_chat_message_get_text_content(const LinphoneChatMessage *msg) { +const char *linphone_chat_message_get_text_content(const LinphoneChatMessage *msg) { const LinphonePrivate::Content *content = L_GET_PRIVATE_FROM_C_OBJECT(msg)->getTextContent(); - if (*content == LinphonePrivate::Content::Empty) { - return NULL; - } + if (content->isEmpty()) + return nullptr; return L_STRING_TO_C(content->getBodyAsString()); } diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index 137a684e6..220602ff8 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -159,7 +159,7 @@ const Content* ChatMessagePrivate::getTextContent() const { return c; } } - return &Content::Empty; + return &Utils::getEmptyConstRefObject(); } bool ChatMessagePrivate::hasFileTransferContent() const { @@ -177,7 +177,7 @@ const Content* ChatMessagePrivate::getFileTransferContent() const { return c; } } - return &Content::Empty; + return &Utils::getEmptyConstRefObject(); } const string &ChatMessagePrivate::getFileTransferFilepath () const { @@ -414,7 +414,7 @@ void ChatMessagePrivate::sendImdn (Imdn::Type imdnType, LinphoneReason reason) { L_Q(); shared_ptr msg = q->getChatRoom()->createMessage(); - + Content *content = new Content(); content->setContentType("message/imdn+xml"); content->setBody(createImdnXml(imdnType, reason)); diff --git a/src/chat/chat-room/basic-chat-room-p.h b/src/chat/chat-room/basic-chat-room-p.h index a6103d172..2429431bf 100644 --- a/src/chat/chat-room/basic-chat-room-p.h +++ b/src/chat/chat-room/basic-chat-room-p.h @@ -32,6 +32,8 @@ public: BasicChatRoomPrivate () = default; private: + void onChatMessageReceived (const std::shared_ptr &chatMessage) override; + std::string subject; L_DECLARE_PUBLIC(BasicChatRoom); diff --git a/src/chat/chat-room/basic-chat-room.cpp b/src/chat/chat-room/basic-chat-room.cpp index 42bfa4459..7b580914c 100644 --- a/src/chat/chat-room/basic-chat-room.cpp +++ b/src/chat/chat-room/basic-chat-room.cpp @@ -29,6 +29,12 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE +// ----------------------------------------------------------------------------- + +void BasicChatRoomPrivate::onChatMessageReceived (const shared_ptr &) {} + +// ----------------------------------------------------------------------------- + BasicChatRoom::BasicChatRoom (const shared_ptr &core, const ChatRoomId &chatRoomId) : ChatRoom(*new BasicChatRoomPrivate, core, chatRoomId) {} @@ -107,7 +113,4 @@ void BasicChatRoom::leave () { lError() << "leave() is not allowed on a BasicChatRoom"; } -// TODO: Move me in BasicChatRoomPrivate. -void BasicChatRoom::onChatMessageReceived (const shared_ptr &) {} - LINPHONE_END_NAMESPACE diff --git a/src/chat/chat-room/basic-chat-room.h b/src/chat/chat-room/basic-chat-room.h index a234eee30..283a2ad80 100644 --- a/src/chat/chat-room/basic-chat-room.h +++ b/src/chat/chat-room/basic-chat-room.h @@ -64,9 +64,6 @@ protected: private: BasicChatRoom (const std::shared_ptr &core, const ChatRoomId &chatRoomId); - // TODO: Remove me. Move me in private object. - void onChatMessageReceived (const std::shared_ptr &msg) override; - L_DECLARE_PRIVATE(BasicChatRoom); L_DISABLE_COPY(BasicChatRoom); }; diff --git a/src/chat/chat-room/chat-room-p.h b/src/chat/chat-room/chat-room-p.h index 9fafcb6f5..a4fd64b20 100644 --- a/src/chat/chat-room/chat-room-p.h +++ b/src/chat/chat-room/chat-room-p.h @@ -97,6 +97,8 @@ public: // TODO: Check all fields before this point. public: + virtual void onChatMessageReceived (const std::shared_ptr &chatMessage) = 0; + ChatRoomId chatRoomId; time_t creationTime = -1; diff --git a/src/chat/chat-room/chat-room.cpp b/src/chat/chat-room/chat-room.cpp index 2135002cb..652c30d83 100644 --- a/src/chat/chat-room/chat-room.cpp +++ b/src/chat/chat-room/chat-room.cpp @@ -306,7 +306,7 @@ void ChatRoomPrivate::chatMessageReceived (const shared_ptr &msg) { L_Q(); if ((msg->getPrivate()->getContentType() != ContentType::Imdn) && (msg->getPrivate()->getContentType() != ContentType::ImIsComposing)) { - q->onChatMessageReceived(msg); + onChatMessageReceived(msg); LinphoneChatRoom *cr = L_GET_C_BACK_PTR(q); LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr); diff --git a/src/chat/chat-room/chat-room.h b/src/chat/chat-room/chat-room.h index f6c671b3f..b7e557353 100644 --- a/src/chat/chat-room/chat-room.h +++ b/src/chat/chat-room/chat-room.h @@ -81,8 +81,6 @@ public: protected: explicit ChatRoom (ChatRoomPrivate &p, const std::shared_ptr &core, const ChatRoomId &chatRoomId); - virtual void onChatMessageReceived (const std::shared_ptr &msg) = 0; - private: L_DECLARE_PRIVATE(ChatRoom); L_DISABLE_COPY(ChatRoom); diff --git a/src/chat/chat-room/client-group-chat-room-p.h b/src/chat/chat-room/client-group-chat-room-p.h index 82366fef3..f261c191b 100644 --- a/src/chat/chat-room/client-group-chat-room-p.h +++ b/src/chat/chat-room/client-group-chat-room-p.h @@ -37,6 +37,8 @@ public: void multipartNotifyReceived (const std::string &body); private: + void onChatMessageReceived (const std::shared_ptr &chatMessage) override; + L_DECLARE_PUBLIC(ClientGroupChatRoom); }; diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index 996ece990..501beb279 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -79,6 +79,8 @@ void ClientGroupChatRoomPrivate::multipartNotifyReceived (const string &body) { qConference->getPrivate()->eventHandler->multipartNotifyReceived(body); } +void ClientGroupChatRoomPrivate::onChatMessageReceived (const shared_ptr &) {} + // ============================================================================= ClientGroupChatRoom::ClientGroupChatRoom ( @@ -262,8 +264,6 @@ void ClientGroupChatRoom::leave () { // ----------------------------------------------------------------------------- -void ClientGroupChatRoom::onChatMessageReceived (const shared_ptr &msg) {} - void ClientGroupChatRoom::onConferenceCreated (const IdentityAddress &addr) { L_D(); L_D_T(RemoteConference, dConference); diff --git a/src/chat/chat-room/client-group-chat-room.h b/src/chat/chat-room/client-group-chat-room.h index 0702f59c9..8efa00801 100644 --- a/src/chat/chat-room/client-group-chat-room.h +++ b/src/chat/chat-room/client-group-chat-room.h @@ -71,8 +71,6 @@ private: // TODO: Move me in ClientGroupChatRoomPrivate. // ALL METHODS AFTER THIS POINT. - void onChatMessageReceived (const std::shared_ptr &msg) override; - void onConferenceCreated (const IdentityAddress &addr) override; void onConferenceTerminated (const IdentityAddress &addr) override; void onFirstNotifyReceived (const IdentityAddress &addr) override; diff --git a/src/chat/chat-room/server-group-chat-room-p.h b/src/chat/chat-room/server-group-chat-room-p.h index b2a945e0d..2b003fdac 100644 --- a/src/chat/chat-room/server-group-chat-room-p.h +++ b/src/chat/chat-room/server-group-chat-room-p.h @@ -56,6 +56,8 @@ private: void finalizeCreation (); bool isAdminLeft () const; + void onChatMessageReceived (const std::shared_ptr &) override; + std::list> removedParticipants; L_DECLARE_PUBLIC(ServerGroupChatRoom); diff --git a/src/chat/chat-room/server-group-chat-room-stub.cpp b/src/chat/chat-room/server-group-chat-room-stub.cpp index 6ad6d6d73..1a3999e9f 100644 --- a/src/chat/chat-room/server-group-chat-room-stub.cpp +++ b/src/chat/chat-room/server-group-chat-room-stub.cpp @@ -75,6 +75,8 @@ bool ServerGroupChatRoomPrivate::isAdminLeft () const { return false; } +void ServerGroupChatRoomPrivate::onChatMessageReceived(const shared_ptr &) {} + // ============================================================================= ServerGroupChatRoom::ServerGroupChatRoom (const shared_ptr &core, SalCallOp *op) : @@ -131,8 +133,6 @@ void ServerGroupChatRoom::leave () {} // ----------------------------------------------------------------------------- -void ServerGroupChatRoom::onChatMessageReceived(const shared_ptr &msg) {} - void ServerGroupChatRoom::onCallSessionStateChanged ( const shared_ptr &, LinphoneCallState, diff --git a/src/chat/chat-room/server-group-chat-room.h b/src/chat/chat-room/server-group-chat-room.h index c93e593de..73d0295de 100644 --- a/src/chat/chat-room/server-group-chat-room.h +++ b/src/chat/chat-room/server-group-chat-room.h @@ -67,7 +67,6 @@ public: private: // TODO: Move me in ServerGroupChatRoomPrivate. - void onChatMessageReceived (const std::shared_ptr &msg) override; void onCallSessionStateChanged (const std::shared_ptr &session, LinphoneCallState state, const std::string &message) override; L_DECLARE_PRIVATE(ServerGroupChatRoom); diff --git a/src/content/content.cpp b/src/content/content.cpp index 1033332f9..0bd2554d0 100644 --- a/src/content/content.cpp +++ b/src/content/content.cpp @@ -29,8 +29,6 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -const Content Content::Empty; - // ----------------------------------------------------------------------------- Content::Content () : ClonableObject(*new ContentPrivate) {} diff --git a/src/content/content.h b/src/content/content.h index d51c51e7e..762b2fd01 100644 --- a/src/content/content.h +++ b/src/content/content.h @@ -67,9 +67,8 @@ public: bool isEmpty () const; - virtual LinphoneContent * toLinphoneContent() const; - - static const Content Empty; + // TODO: Remove me later. + virtual LinphoneContent *toLinphoneContent() const; protected: explicit Content (ContentPrivate &p); diff --git a/src/content/file-content.cpp b/src/content/file-content.cpp index 8bb303e09..ecf445dbd 100644 --- a/src/content/file-content.cpp +++ b/src/content/file-content.cpp @@ -36,9 +36,7 @@ public: // ----------------------------------------------------------------------------- -FileContent::FileContent() : Content(*new FileContentPrivate()) { - -} +FileContent::FileContent() : Content(*new FileContentPrivate()) {} FileContent::FileContent (const FileContent &src) : Content(*new FileContentPrivate) { L_D(); @@ -102,20 +100,19 @@ const string& FileContent::getFileName() const { L_D(); return d->fileName; } - -void FileContent::setFilePath(const string &path) { + +void FileContent::setFilePath (const string &path) { L_D(); d->filePath = path; } -const string& FileContent::getFilePath() const { +const string& FileContent::getFilePath () const { L_D(); return d->filePath; } -LinphoneContent * FileContent::toLinphoneContent() const { - LinphoneContent* content; - content = linphone_core_create_content(NULL); +LinphoneContent *FileContent::toLinphoneContent() const { + LinphoneContent *content = linphone_core_create_content(nullptr); linphone_content_set_type(content, getContentType().getType().c_str()); linphone_content_set_subtype(content, getContentType().getSubType().c_str()); linphone_content_set_name(content, getFileName().c_str()); diff --git a/src/content/file-content.h b/src/content/file-content.h index 15aa279e1..9aefb0552 100644 --- a/src/content/file-content.h +++ b/src/content/file-content.h @@ -30,7 +30,7 @@ class FileContentPrivate; class LINPHONE_PUBLIC FileContent : public Content { public: - FileContent(); + FileContent (); FileContent (const FileContent &src); FileContent (FileContent &&src); @@ -38,16 +38,16 @@ public: FileContent &operator= (FileContent &&src); bool operator== (const FileContent &content) const; - void setFileSize(size_t size); - size_t getFileSize() const; - - void setFileName(const std::string &name); - const std::string& getFileName() const; - - void setFilePath(const std::string &path); - const std::string& getFilePath() const; + void setFileSize (size_t size); + size_t getFileSize () const; - LinphoneContent * toLinphoneContent() const override; + void setFileName (const std::string &name); + const std::string &getFileName() const; + + void setFilePath (const std::string &path); + const std::string &getFilePath() const; + + LinphoneContent *toLinphoneContent() const override; private: L_DECLARE_PRIVATE(FileContent); diff --git a/src/core/core.cpp b/src/core/core.cpp index 3f68e32d9..906b135d7 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -24,10 +24,10 @@ // TODO: Remove me later. #include "c-wrapper/c-wrapper.h" -// ============================================================================= - #define LINPHONE_DB "linphone.db" +// ============================================================================= + using namespace std; LINPHONE_BEGIN_NAMESPACE @@ -73,6 +73,10 @@ LinphoneCore *Core::getCCore () const { return d->cCore; } +// ----------------------------------------------------------------------------- +// Paths. +// ----------------------------------------------------------------------------- + string Core::getDataPath() const { L_D(); return Paths::getPath(Paths::Data, static_cast(d->cCore->platform_helper)); diff --git a/src/core/core.h b/src/core/core.h index 35514f5e0..2558e49bc 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -58,13 +58,6 @@ public: // TODO: Remove me later. LinphoneCore *getCCore () const; - // --------------------------------------------------------------------------- - // Paths. - // --------------------------------------------------------------------------- - - std::string getDataPath() const; - std::string getConfigPath() const; - // --------------------------------------------------------------------------- // ChatRoom. // --------------------------------------------------------------------------- @@ -84,6 +77,13 @@ public: static void deleteChatRoom (const std::shared_ptr &chatRoom); + // --------------------------------------------------------------------------- + // Paths. + // --------------------------------------------------------------------------- + + std::string getDataPath() const; + std::string getConfigPath() const; + private: Core ();