Commit 90b653f6 authored by Ronan's avatar Ronan

fix(chat-room): hide public onChatMessageReceived handler!

parent ec2ffd8a
......@@ -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());
}
......
......@@ -159,7 +159,7 @@ const Content* ChatMessagePrivate::getTextContent() const {
return c;
}
}
return &Content::Empty;
return &Utils::getEmptyConstRefObject<Content>();
}
bool ChatMessagePrivate::hasFileTransferContent() const {
......@@ -177,7 +177,7 @@ const Content* ChatMessagePrivate::getFileTransferContent() const {
return c;
}
}
return &Content::Empty;
return &Utils::getEmptyConstRefObject<Content>();
}
const string &ChatMessagePrivate::getFileTransferFilepath () const {
......@@ -414,7 +414,7 @@ void ChatMessagePrivate::sendImdn (Imdn::Type imdnType, LinphoneReason reason) {
L_Q();
shared_ptr<ChatMessage> msg = q->getChatRoom()->createMessage();
Content *content = new Content();
content->setContentType("message/imdn+xml");
content->setBody(createImdnXml(imdnType, reason));
......
......@@ -32,6 +32,8 @@ public:
BasicChatRoomPrivate () = default;
private:
void onChatMessageReceived (const std::shared_ptr<ChatMessage> &chatMessage) override;
std::string subject;
L_DECLARE_PUBLIC(BasicChatRoom);
......
......@@ -29,6 +29,12 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
// -----------------------------------------------------------------------------
void BasicChatRoomPrivate::onChatMessageReceived (const shared_ptr<ChatMessage> &) {}
// -----------------------------------------------------------------------------
BasicChatRoom::BasicChatRoom (const shared_ptr<Core> &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<ChatMessage> &) {}
LINPHONE_END_NAMESPACE
......@@ -64,9 +64,6 @@ protected:
private:
BasicChatRoom (const std::shared_ptr<Core> &core, const ChatRoomId &chatRoomId);
// TODO: Remove me. Move me in private object.
void onChatMessageReceived (const std::shared_ptr<ChatMessage> &msg) override;
L_DECLARE_PRIVATE(BasicChatRoom);
L_DISABLE_COPY(BasicChatRoom);
};
......
......@@ -97,6 +97,8 @@ public:
// TODO: Check all fields before this point.
public:
virtual void onChatMessageReceived (const std::shared_ptr<ChatMessage> &chatMessage) = 0;
ChatRoomId chatRoomId;
time_t creationTime = -1;
......
......@@ -306,7 +306,7 @@ void ChatRoomPrivate::chatMessageReceived (const shared_ptr<ChatMessage> &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);
......
......@@ -81,8 +81,6 @@ public:
protected:
explicit ChatRoom (ChatRoomPrivate &p, const std::shared_ptr<Core> &core, const ChatRoomId &chatRoomId);
virtual void onChatMessageReceived (const std::shared_ptr<ChatMessage> &msg) = 0;
private:
L_DECLARE_PRIVATE(ChatRoom);
L_DISABLE_COPY(ChatRoom);
......
......@@ -37,6 +37,8 @@ public:
void multipartNotifyReceived (const std::string &body);
private:
void onChatMessageReceived (const std::shared_ptr<ChatMessage> &chatMessage) override;
L_DECLARE_PUBLIC(ClientGroupChatRoom);
};
......
......@@ -79,6 +79,8 @@ void ClientGroupChatRoomPrivate::multipartNotifyReceived (const string &body) {
qConference->getPrivate()->eventHandler->multipartNotifyReceived(body);
}
void ClientGroupChatRoomPrivate::onChatMessageReceived (const shared_ptr<ChatMessage> &) {}
// =============================================================================
ClientGroupChatRoom::ClientGroupChatRoom (
......@@ -262,8 +264,6 @@ void ClientGroupChatRoom::leave () {
// -----------------------------------------------------------------------------
void ClientGroupChatRoom::onChatMessageReceived (const shared_ptr<ChatMessage> &msg) {}
void ClientGroupChatRoom::onConferenceCreated (const IdentityAddress &addr) {
L_D();
L_D_T(RemoteConference, dConference);
......
......@@ -71,8 +71,6 @@ private:
// TODO: Move me in ClientGroupChatRoomPrivate.
// ALL METHODS AFTER THIS POINT.
void onChatMessageReceived (const std::shared_ptr<ChatMessage> &msg) override;
void onConferenceCreated (const IdentityAddress &addr) override;
void onConferenceTerminated (const IdentityAddress &addr) override;
void onFirstNotifyReceived (const IdentityAddress &addr) override;
......
......@@ -56,6 +56,8 @@ private:
void finalizeCreation ();
bool isAdminLeft () const;
void onChatMessageReceived (const std::shared_ptr<ChatMessage> &) override;
std::list<std::shared_ptr<Participant>> removedParticipants;
L_DECLARE_PUBLIC(ServerGroupChatRoom);
......
......@@ -75,6 +75,8 @@ bool ServerGroupChatRoomPrivate::isAdminLeft () const {
return false;
}
void ServerGroupChatRoomPrivate::onChatMessageReceived(const shared_ptr<ChatMessage> &) {}
// =============================================================================
ServerGroupChatRoom::ServerGroupChatRoom (const shared_ptr<Core> &core, SalCallOp *op) :
......@@ -131,8 +133,6 @@ void ServerGroupChatRoom::leave () {}
// -----------------------------------------------------------------------------
void ServerGroupChatRoom::onChatMessageReceived(const shared_ptr<ChatMessage> &msg) {}
void ServerGroupChatRoom::onCallSessionStateChanged (
const shared_ptr<const CallSession> &,
LinphoneCallState,
......
......@@ -67,7 +67,6 @@ public:
private:
// TODO: Move me in ServerGroupChatRoomPrivate.
void onChatMessageReceived (const std::shared_ptr<ChatMessage> &msg) override;
void onCallSessionStateChanged (const std::shared_ptr<const CallSession> &session, LinphoneCallState state, const std::string &message) override;
L_DECLARE_PRIVATE(ServerGroupChatRoom);
......
......@@ -29,8 +29,6 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
const Content Content::Empty;
// -----------------------------------------------------------------------------
Content::Content () : ClonableObject(*new ContentPrivate) {}
......
......@@ -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);
......
......@@ -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());
......
......@@ -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);
......
......@@ -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<PlatformHelpers *>(d->cCore->platform_helper));
......
......@@ -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<const ChatRoom> &chatRoom);
// ---------------------------------------------------------------------------
// Paths.
// ---------------------------------------------------------------------------
std::string getDataPath() const;
std::string getConfigPath() const;
private:
Core ();
......
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