mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-07 14:18:25 +00:00
Changes for ChatMessage & ChatMessageModifiers
This commit is contained in:
parent
8fce516b8f
commit
207a871090
9 changed files with 113 additions and 47 deletions
|
|
@ -30,6 +30,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
|
|||
call/call.h
|
||||
chat/basic-chat-room-p.h
|
||||
chat/basic-chat-room.h
|
||||
chat/chat-message-p.h
|
||||
chat/chat-message.h
|
||||
chat/chat-room-p.h
|
||||
chat/chat-room.h
|
||||
|
|
|
|||
59
src/chat/chat-message-p.h
Normal file
59
src/chat/chat-message-p.h
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* chat-message-p.h
|
||||
* Copyright (C) 2017 Belledonne Communications SARL
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _CHAT_MESSAGE_P_H_
|
||||
#define _CHAT_MESSAGE_P_H_
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "chat-message.h"
|
||||
#include "db/events-db.h"
|
||||
#include "object/object-p.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class ChatMessagePrivate : public ObjectPrivate {
|
||||
private:
|
||||
std::weak_ptr<ChatRoom> chatRoom;
|
||||
ChatMessage::Direction direction = ChatMessage::Incoming;
|
||||
// LinphoneAddress *from;
|
||||
// LinphoneAddress *to;
|
||||
std::shared_ptr<ErrorInfo> errorInfo;
|
||||
std::string contentType;
|
||||
std::string text;
|
||||
bool isSecured = false;
|
||||
bool isReadOnly = false;
|
||||
time_t time = 0;
|
||||
std::string id;
|
||||
std::string appData;
|
||||
std::list<std::shared_ptr<Content> > contents;
|
||||
std::shared_ptr<Content> internalContent;
|
||||
std::unordered_map<std::string, std::string> customHeaders;
|
||||
ChatMessage::State state = ChatMessage::Idle;
|
||||
std::shared_ptr<EventsDb> eventsDb;
|
||||
|
||||
L_DECLARE_PUBLIC(ChatMessage);
|
||||
friend class CpimChatMessageModifier;
|
||||
friend class MultipartChatMessageModifier;
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
||||
#endif // ifndef _CHAT_MESSAGE_P_H_
|
||||
|
|
@ -21,37 +21,23 @@
|
|||
#include "db/events-db.h"
|
||||
#include "object/object-p.h"
|
||||
|
||||
#include "linphone/types.h"
|
||||
#include "linphone/core.h"
|
||||
#include "linphone/lpconfig.h"
|
||||
|
||||
#include "chat-message-p.h"
|
||||
#include "chat-message.h"
|
||||
|
||||
#include "modifier/multipart-chat-message-modifier.h"
|
||||
#include "modifier/cpim-chat-message-modifier.h"
|
||||
#include "chat-room.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
using namespace std;
|
||||
|
||||
class ChatMessagePrivate : public ObjectPrivate {
|
||||
private:
|
||||
weak_ptr<ChatRoom> chatRoom;
|
||||
ChatMessage::Direction direction = ChatMessage::Incoming;
|
||||
// LinphoneAddress *from;
|
||||
// LinphoneAddress *to;
|
||||
shared_ptr<ErrorInfo> errorInfo;
|
||||
string contentType;
|
||||
string text;
|
||||
bool isSecured = false;
|
||||
bool isReadOnly = false;
|
||||
time_t time = 0;
|
||||
string id;
|
||||
string appData;
|
||||
list<shared_ptr<Content> > contents;
|
||||
shared_ptr<Content> private_content;
|
||||
unordered_map<string, string> customHeaders;
|
||||
ChatMessage::State state = ChatMessage::Idle;
|
||||
shared_ptr<EventsDb> eventsDb;
|
||||
|
||||
L_DECLARE_PUBLIC(ChatMessage);
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ChatMessage::ChatMessage (ChatMessagePrivate &p) : Object(p) {}
|
||||
|
|
@ -105,17 +91,21 @@ string ChatMessage::getContentType () const {
|
|||
return d->contentType;
|
||||
}
|
||||
|
||||
string ChatMessage::getText () const {
|
||||
L_D(const ChatMessage);
|
||||
return d->text;
|
||||
}
|
||||
|
||||
void ChatMessage::setText (const string &text) {
|
||||
L_D(ChatMessage);
|
||||
d->text = text;
|
||||
}
|
||||
|
||||
void ChatMessage::send () const {
|
||||
L_D(const ChatMessage);
|
||||
|
||||
if (d->contents.size() > 1) {
|
||||
MultipartChatMessageModifier mcmm;
|
||||
mcmm.encode(d);
|
||||
}
|
||||
|
||||
LinphoneCore *lc = getChatRoom()->getCore();
|
||||
LpConfig *lpc = linphone_core_get_config(lc);
|
||||
if (lp_config_get_int(lpc, "sip", "use_cpim", 0) == 1) {
|
||||
CpimChatMessageModifier ccmm;
|
||||
ccmm.encode(d);
|
||||
}
|
||||
|
||||
// TODO.
|
||||
}
|
||||
|
||||
|
|
@ -164,11 +154,15 @@ list<shared_ptr<const Content> > ChatMessage::getContents () const {
|
|||
|
||||
void ChatMessage::addContent (const shared_ptr<Content> &content) {
|
||||
L_D(ChatMessage);
|
||||
if (d->isReadOnly) return;
|
||||
|
||||
d->contents.push_back(content);
|
||||
}
|
||||
|
||||
void ChatMessage::removeContent (const shared_ptr<const Content> &content) {
|
||||
L_D(ChatMessage);
|
||||
if (d->isReadOnly) return;
|
||||
|
||||
d->contents.remove(const_pointer_cast<Content>(content));
|
||||
}
|
||||
|
||||
|
|
@ -184,11 +178,15 @@ string ChatMessage::getCustomHeaderValue (const string &headerName) const {
|
|||
|
||||
void ChatMessage::addCustomHeader (const string &headerName, const string &headerValue) {
|
||||
L_D(ChatMessage);
|
||||
if (d->isReadOnly) return;
|
||||
|
||||
d->customHeaders[headerName] = headerValue;
|
||||
}
|
||||
|
||||
void ChatMessage::removeCustomHeader (const string &headerName) {
|
||||
L_D(ChatMessage);
|
||||
if (d->isReadOnly) return;
|
||||
|
||||
d->customHeaders.erase(headerName);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,9 +69,6 @@ public:
|
|||
|
||||
std::string getContentType () const;
|
||||
|
||||
std::string getText () const;
|
||||
void setText (const std::string &text);
|
||||
|
||||
void send () const;
|
||||
|
||||
bool containsReadableText () const;
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@
|
|||
|
||||
class ChatMessageModifier {
|
||||
public:
|
||||
virtual void encode(std::shared_ptr<ChatMessagePrivate> msg) = 0;
|
||||
virtual void decode(std::shared_ptr<ChatMessagePrivate> msg) = 0;
|
||||
virtual void encode(const LinphonePrivate::ChatMessagePrivate* msg) = 0;
|
||||
virtual void decode(const LinphonePrivate::ChatMessagePrivate* msg) = 0;
|
||||
virtual ~ChatMessageModifier () = default;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -16,17 +16,23 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "chat/chat-message-p.h"
|
||||
#include "cpim-chat-message-modifier.h"
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
using namespace std;
|
||||
|
||||
void CpimChatMessageModifier::encode(shared_ptr<ChatMessagePrivate> msg) {
|
||||
void CpimChatMessageModifier::encode(const LinphonePrivate::ChatMessagePrivate* msg) {
|
||||
//TODO
|
||||
if (msg->internalContent) {
|
||||
// Another ChatMessageModifier was called before this one, we apply our changes on the private content
|
||||
} else {
|
||||
// We're the first ChatMessageModifier to be called, we'll create the private content from the public one
|
||||
}
|
||||
}
|
||||
|
||||
void CpimChatMessageModifier::decode(shared_ptr<ChatMessagePrivate> msg) {
|
||||
void CpimChatMessageModifier::decode(const LinphonePrivate::ChatMessagePrivate* msg) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,9 @@
|
|||
|
||||
class CpimChatMessageModifier : ChatMessageModifier {
|
||||
public:
|
||||
virtual void encode(std::shared_ptr<ChatMessagePrivate> msg) = 0;
|
||||
virtual void decode(std::shared_ptr<ChatMessagePrivate> msg) = 0;
|
||||
CpimChatMessageModifier() {};
|
||||
virtual void encode(const LinphonePrivate::ChatMessagePrivate* msg);
|
||||
virtual void decode(const LinphonePrivate::ChatMessagePrivate* msg);
|
||||
virtual ~CpimChatMessageModifier () = default;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -16,17 +16,20 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "chat/chat-message-p.h"
|
||||
#include "multipart-chat-message-modifier.h"
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
using namespace std;
|
||||
|
||||
void MultipartChatMessageModifier::encode(shared_ptr<ChatMessagePrivate> msg) {
|
||||
//TODO
|
||||
void MultipartChatMessageModifier::encode(const LinphonePrivate::ChatMessagePrivate* msg) {
|
||||
if (msg->contents.size() > 1) {
|
||||
//TODO
|
||||
}
|
||||
}
|
||||
|
||||
void MultipartChatMessageModifier::decode(shared_ptr<ChatMessagePrivate> msg) {
|
||||
void MultipartChatMessageModifier::decode(const LinphonePrivate::ChatMessagePrivate* msg) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,9 @@
|
|||
|
||||
class MultipartChatMessageModifier : ChatMessageModifier {
|
||||
public:
|
||||
virtual void encode(std::shared_ptr<ChatMessagePrivate> msg) = 0;
|
||||
virtual void decode(std::shared_ptr<ChatMessagePrivate> msg) = 0;
|
||||
MultipartChatMessageModifier() {};
|
||||
virtual void encode(const LinphonePrivate::ChatMessagePrivate* msg);
|
||||
virtual void decode(const LinphonePrivate::ChatMessagePrivate* msg);
|
||||
virtual ~MultipartChatMessageModifier () = default;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue