mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 19:18:06 +00:00
Started cpp ChatMessage
This commit is contained in:
parent
bd02b8968d
commit
bb9c6de6d6
4 changed files with 35 additions and 9 deletions
|
|
@ -31,8 +31,12 @@ class ChatMessagePrivate : public ObjectPrivate {
|
|||
friend class CpimChatMessageModifier;
|
||||
friend class MultipartChatMessageModifier;
|
||||
|
||||
public:
|
||||
ChatMessagePrivate (const std::shared_ptr<ChatRoom> &room);
|
||||
virtual ~ChatMessagePrivate ();
|
||||
|
||||
private:
|
||||
std::weak_ptr<ChatRoom> chatRoom;
|
||||
std::shared_ptr<ChatRoom> chatRoom;
|
||||
ChatMessage::Direction direction = ChatMessage::Incoming;
|
||||
// LinphoneAddress *from;
|
||||
// LinphoneAddress *to;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include "linphone/types.h"
|
||||
#include "linphone/core.h"
|
||||
#include "linphone/lpconfig.h"
|
||||
#include "c-wrapper/c-wrapper.h"
|
||||
|
||||
#include "chat-message-p.h"
|
||||
#include "chat-message.h"
|
||||
|
|
@ -30,6 +31,8 @@
|
|||
#include "modifier/cpim-chat-message-modifier.h"
|
||||
#include "chat-room.h"
|
||||
|
||||
#define GET_BACK_PTR(object) L_GET_C_BACK_PTR(object->shared_from_this(), ChatMessage)
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
|
@ -38,15 +41,24 @@ using namespace std;
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ChatMessagePrivate::ChatMessagePrivate (const std::shared_ptr<ChatRoom> &room)
|
||||
: chatRoom(room) {}
|
||||
|
||||
ChatMessagePrivate::~ChatMessagePrivate () {}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ChatMessage::ChatMessage (const std::shared_ptr<ChatRoom> &room) : Object(*new ChatMessagePrivate(room)) {}
|
||||
|
||||
ChatMessage::ChatMessage (ChatMessagePrivate &p) : Object(p) {}
|
||||
|
||||
LinphoneChatMessage * ChatMessage::getBackPtr() {
|
||||
return GET_BACK_PTR(this);
|
||||
}
|
||||
|
||||
shared_ptr<ChatRoom> ChatMessage::getChatRoom () const {
|
||||
L_D(const ChatMessage);
|
||||
shared_ptr<ChatRoom> chatRoom = d->chatRoom.lock();
|
||||
if (!chatRoom) {
|
||||
// TODO.
|
||||
}
|
||||
return chatRoom;
|
||||
return d->chatRoom;
|
||||
}
|
||||
|
||||
ChatMessage::Direction ChatMessage::getDirection () const {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
#include "linphone/api/c-chat-message.h"
|
||||
|
||||
#include "object/object.h"
|
||||
|
||||
// =============================================================================
|
||||
|
|
@ -54,6 +56,11 @@ public:
|
|||
Displayed
|
||||
};
|
||||
|
||||
ChatMessage (const std::shared_ptr<ChatRoom> &room);
|
||||
virtual ~ChatMessage () = default;
|
||||
|
||||
LinphoneChatMessage * getBackPtr();
|
||||
|
||||
std::shared_ptr<ChatRoom> getChatRoom () const;
|
||||
|
||||
Direction getDirection () const;
|
||||
|
|
@ -89,9 +96,10 @@ public:
|
|||
void addCustomHeader (const std::string &headerName, const std::string &headerValue);
|
||||
void removeCustomHeader (const std::string &headerName);
|
||||
|
||||
private:
|
||||
ChatMessage (ChatMessagePrivate &p);
|
||||
protected:
|
||||
explicit ChatMessage (ChatMessagePrivate &p);
|
||||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(ChatMessage);
|
||||
L_DISABLE_COPY(ChatMessage);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "imdn.h"
|
||||
#include "logger/logger.h"
|
||||
|
||||
#include "chat-message.h"
|
||||
#include "chat-room.h"
|
||||
|
||||
#define GET_BACK_PTR(object) L_GET_C_BACK_PTR(object->shared_from_this(), ChatRoom)
|
||||
|
|
@ -609,7 +610,8 @@ LinphoneChatMessage *ChatRoom::createFileTransferMessage (const LinphoneContent
|
|||
}
|
||||
|
||||
LinphoneChatMessage *ChatRoom::createMessage (const string &message) {
|
||||
LinphoneChatMessage *msg = createMessage("");
|
||||
ChatMessage chatMessage(static_pointer_cast<ChatRoom>(shared_from_this()));
|
||||
LinphoneChatMessage *msg = chatMessage.getBackPtr();
|
||||
linphone_chat_message_set_chat_room(msg, GET_BACK_PTR(this));
|
||||
linphone_chat_message_set_state(msg, LinphoneChatMessageStateIdle);
|
||||
linphone_chat_message_set_text(msg, message.empty() ? nullptr : ms_strdup(message.c_str()));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue