mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-15 20:17:56 +00:00
feat(ChatRoom): provide an abstract chat room for chat room migration proxy
This commit is contained in:
parent
91196256ce
commit
9258c5f145
38 changed files with 417 additions and 282 deletions
|
|
@ -87,7 +87,7 @@ static void call_received(SalCallOp *h) {
|
|||
linphone_address_unref(fromAddr);
|
||||
return;
|
||||
} else if (sal_address_has_param(h->get_remote_contact_address(), "text")) {
|
||||
shared_ptr<ChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(
|
||||
shared_ptr<AbstractChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(
|
||||
ChatRoomId(IdentityAddress(h->get_to()), IdentityAddress(h->get_to()))
|
||||
);
|
||||
if (chatRoom) {
|
||||
|
|
@ -681,7 +681,7 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){
|
|||
if (addr.hasUriParam("method") && (addr.getUriParamValue("method") == "BYE")) {
|
||||
if (linphone_core_conference_server_enabled(lc)) {
|
||||
// Removal of a participant at the server side
|
||||
shared_ptr<ChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(
|
||||
shared_ptr<AbstractChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(
|
||||
ChatRoomId(IdentityAddress(op->get_to()), IdentityAddress(op->get_to()))
|
||||
);
|
||||
if (chatRoom) {
|
||||
|
|
|
|||
|
|
@ -137,18 +137,18 @@ int linphone_core_message_received(LinphoneCore *lc, LinphonePrivate::SalOp *op,
|
|||
localAddress = op->get_to();
|
||||
}
|
||||
|
||||
shared_ptr<LinphonePrivate::ChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(
|
||||
shared_ptr<LinphonePrivate::AbstractChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(
|
||||
LinphonePrivate::ChatRoomId(LinphonePrivate::IdentityAddress(peerAddress), LinphonePrivate::IdentityAddress(localAddress))
|
||||
);
|
||||
|
||||
if (chatRoom)
|
||||
reason = L_GET_PRIVATE(chatRoom)->messageReceived(op, sal_msg);
|
||||
reason = L_GET_PRIVATE(chatRoom)->onSipMessageReceived(op, sal_msg);
|
||||
else {
|
||||
LinphoneAddress *addr = linphone_address_new(sal_msg->from);
|
||||
linphone_address_clean(addr);
|
||||
LinphoneChatRoom *cr = linphone_core_get_chat_room(lc, addr);
|
||||
if (cr)
|
||||
reason = L_GET_PRIVATE_FROM_C_OBJECT(cr)->messageReceived(op, sal_msg);
|
||||
reason = L_GET_PRIVATE_FROM_C_OBJECT(cr)->onSipMessageReceived(op, sal_msg);
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
return reason;
|
||||
|
|
|
|||
|
|
@ -2134,7 +2134,7 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve
|
|||
const LinphoneAddress *resource = linphone_event_get_resource(lev);
|
||||
const LinphoneAddress *from = linphone_event_get_from(lev);
|
||||
|
||||
shared_ptr<ChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(LinphonePrivate::ChatRoomId(
|
||||
shared_ptr<AbstractChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(LinphonePrivate::ChatRoomId(
|
||||
IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(resource)),
|
||||
IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(from))
|
||||
));
|
||||
|
|
@ -2164,7 +2164,7 @@ static void _linphone_core_conference_subscription_state_changed(LinphoneCore *l
|
|||
state == LinphoneSubscriptionIncomingReceived
|
||||
) {
|
||||
const LinphoneAddress *resource = linphone_event_get_resource(lev);
|
||||
shared_ptr<ChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(LinphonePrivate::ChatRoomId(
|
||||
shared_ptr<AbstractChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(LinphonePrivate::ChatRoomId(
|
||||
IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(resource)),
|
||||
IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(resource))
|
||||
));
|
||||
|
|
|
|||
|
|
@ -274,7 +274,6 @@ void _linphone_proxy_config_release_ops(LinphoneProxyConfig *obj);
|
|||
/*chat*/
|
||||
LinphoneChatRoom *_linphone_client_group_chat_room_new (LinphoneCore *core, const char *uri, const char *subject);
|
||||
LinphoneChatRoom *_linphone_server_group_chat_room_new (LinphoneCore *core, LinphonePrivate::SalCallOp *op);
|
||||
void linphone_chat_room_release(LinphoneChatRoom *cr);
|
||||
void linphone_chat_room_set_call(LinphoneChatRoom *cr, LinphoneCall *call);
|
||||
LinphoneChatRoomCbs * linphone_chat_room_cbs_new (void);
|
||||
/**/
|
||||
|
|
|
|||
|
|
@ -116,19 +116,6 @@ LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_room_get_local_address(Linp
|
|||
*/
|
||||
LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg);
|
||||
|
||||
/**
|
||||
* Send a message to peer member of this chat room.
|
||||
* @param cr #LinphoneChatRoom object
|
||||
* @param msg #LinphoneChatMessage message to be sent
|
||||
* @param status_cb LinphoneChatMessageStateChangeCb status callback invoked when message is delivered or could not be delivered. May be NULL
|
||||
* @param ud user data for the status cb.
|
||||
* @deprecated Use linphone_chat_message_send() instead.
|
||||
* @note The LinphoneChatMessage must not be destroyed until the the callback is called.
|
||||
* The LinphoneChatMessage reference is transfered to the function and thus doesn't need to be unref'd by the application.
|
||||
* @donotwrap
|
||||
*/
|
||||
LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_room_send_message2(LinphoneChatRoom *cr, LinphoneChatMessage* msg,LinphoneChatMessageStateChangedCb status_cb,void* ud);
|
||||
|
||||
/**
|
||||
* Send a message to peer member of this chat room.
|
||||
* @param[in] cr LinphoneChatRoom object
|
||||
|
|
|
|||
|
|
@ -36,8 +36,11 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
|
|||
call/remote-conference-call.h
|
||||
chat/chat-message/chat-message-p.h
|
||||
chat/chat-message/chat-message.h
|
||||
chat/chat-room/abstract-chat-room-p.h
|
||||
chat/chat-room/abstract-chat-room.h
|
||||
chat/chat-room/basic-chat-room-p.h
|
||||
chat/chat-room/basic-chat-room.h
|
||||
chat/chat-room/basic-to-client-group-chat-room.h
|
||||
chat/chat-room/chat-room-id.h
|
||||
chat/chat-room/chat-room-p.h
|
||||
chat/chat-room/chat-room.h
|
||||
|
|
@ -168,7 +171,9 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
|
|||
call/local-conference-call.cpp
|
||||
call/remote-conference-call.cpp
|
||||
chat/chat-message/chat-message.cpp
|
||||
chat/chat-room/abstract-chat-room.cpp
|
||||
chat/chat-room/basic-chat-room.cpp
|
||||
chat/chat-room/basic-to-client-group-chat-room.cpp
|
||||
chat/chat-room/chat-room-id.cpp
|
||||
chat/chat-room/chat-room.cpp
|
||||
chat/chat-room/client-group-chat-room.cpp
|
||||
|
|
|
|||
|
|
@ -68,12 +68,8 @@ static void _linphone_chat_room_destructor (LinphoneChatRoom *cr) {
|
|||
// Public functions.
|
||||
// =============================================================================
|
||||
|
||||
void linphone_chat_room_release (LinphoneChatRoom *cr) {
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(cr)->release();
|
||||
}
|
||||
|
||||
void linphone_chat_room_send_message (LinphoneChatRoom *cr, const char *msg) {
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(cr)->sendMessage(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createMessage(msg));
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createChatMessage(msg)->send();
|
||||
}
|
||||
|
||||
bool_t linphone_chat_room_is_remote_composing (const LinphoneChatRoom *cr) {
|
||||
|
|
@ -107,7 +103,7 @@ const LinphoneAddress *linphone_chat_room_get_local_address (LinphoneChatRoom *c
|
|||
}
|
||||
|
||||
LinphoneChatMessage *linphone_chat_room_create_message (LinphoneChatRoom *cr, const char *message) {
|
||||
shared_ptr<LinphonePrivate::ChatMessage> cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createMessage(L_C_TO_STRING(message));
|
||||
shared_ptr<LinphonePrivate::ChatMessage> cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createChatMessage(L_C_TO_STRING(message));
|
||||
LinphoneChatMessage *object = L_INIT(ChatMessage);
|
||||
L_SET_CPP_PTR_FROM_C_OBJECT(object, cppPtr);
|
||||
return object;
|
||||
|
|
@ -130,24 +126,13 @@ LinphoneChatMessage *linphone_chat_room_create_message_2 (
|
|||
return msg;
|
||||
}
|
||||
|
||||
void linphone_chat_room_send_message2 (
|
||||
LinphoneChatRoom *cr,
|
||||
LinphoneChatMessage *msg,
|
||||
LinphoneChatMessageStateChangedCb status_cb,
|
||||
void *ud
|
||||
) {
|
||||
linphone_chat_message_set_message_state_changed_cb(msg, status_cb);
|
||||
linphone_chat_message_set_message_state_changed_cb_user_data(msg, ud);
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(cr)->sendMessage(L_GET_CPP_PTR_FROM_C_OBJECT(msg));
|
||||
}
|
||||
|
||||
void linphone_chat_room_send_chat_message_2 (LinphoneChatRoom *cr, LinphoneChatMessage *msg) {
|
||||
linphone_chat_message_ref(msg);
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(cr)->sendMessage(L_GET_CPP_PTR_FROM_C_OBJECT(msg));
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->send();
|
||||
}
|
||||
|
||||
void linphone_chat_room_send_chat_message (LinphoneChatRoom *cr, LinphoneChatMessage *msg) {
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(cr)->sendMessage(L_GET_CPP_PTR_FROM_C_OBJECT(msg));
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->send();
|
||||
}
|
||||
|
||||
void linphone_chat_room_receive_chat_message (LinphoneChatRoom *cr, LinphoneChatMessage *msg) {
|
||||
|
|
@ -235,7 +220,7 @@ LinphoneChatMessage *linphone_chat_room_get_last_message_in_history(LinphoneChat
|
|||
}
|
||||
|
||||
LinphoneChatMessage *linphone_chat_room_find_message (LinphoneChatRoom *cr, const char *message_id) {
|
||||
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->findMessage(message_id));
|
||||
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->findChatMessage(message_id));
|
||||
}
|
||||
|
||||
LinphoneChatRoomCbs *linphone_chat_room_get_callbacks (const LinphoneChatRoom *cr) {
|
||||
|
|
@ -323,8 +308,10 @@ void linphone_chat_room_set_subject (LinphoneChatRoom *cr, const char *subject)
|
|||
L_GET_CPP_PTR_FROM_C_OBJECT(cr)->setSubject(L_C_TO_STRING(subject));
|
||||
}
|
||||
|
||||
const bctbx_list_t * linphone_chat_room_get_composing_addresses(LinphoneChatRoom *cr) {
|
||||
return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getComposingAddresses());
|
||||
const bctbx_list_t *linphone_chat_room_get_composing_addresses (LinphoneChatRoom *cr) {
|
||||
// FIXME
|
||||
// return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getComposingAddresses());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LinphoneChatMessage *linphone_chat_room_create_file_transfer_message(LinphoneChatRoom *cr, const LinphoneContent *initial_content) {
|
||||
|
|
@ -389,7 +376,7 @@ LinphoneChatRoom *_linphone_client_group_chat_room_new (LinphoneCore *core, cons
|
|||
L_SET_CPP_PTR_FROM_C_OBJECT(cr, make_shared<LinphonePrivate::ClientGroupChatRoom>(
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(core), L_C_TO_STRING(uri), me, L_C_TO_STRING(subject))
|
||||
);
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(cr)->setState(LinphonePrivate::ChatRoom::State::Instantiated);
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(cr, ChatRoom)->setState(LinphonePrivate::ChatRoom::State::Instantiated);
|
||||
return cr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
F(Address, Address) \
|
||||
F(Call, Call) \
|
||||
F(ChatMessage, ChatMessage) \
|
||||
F(ChatRoom, ChatRoom) \
|
||||
F(AbstractChatRoom, ChatRoom) \
|
||||
F(Core, Core) \
|
||||
F(DialPlan, DialPlan) \
|
||||
F(EventLog, EventLog) \
|
||||
|
|
@ -43,12 +43,14 @@
|
|||
F(Participant, Participant)
|
||||
|
||||
#define L_REGISTER_SUBTYPES(F) \
|
||||
F(AbstractChatRoom, BasicChatRoom) \
|
||||
F(AbstractChatRoom, BasicToClientGroupChatRoom) \
|
||||
F(AbstractChatRoom, ChatRoom) \
|
||||
F(AbstractChatRoom, ClientGroupChatRoom) \
|
||||
F(AbstractChatRoom, RealTimeTextChatRoom) \
|
||||
F(AbstractChatRoom, ServerGroupChatRoom) \
|
||||
F(Call, LocalConferenceCall) \
|
||||
F(Call, RemoteConferenceCall) \
|
||||
F(ChatRoom, BasicChatRoom) \
|
||||
F(ChatRoom, ClientGroupChatRoom) \
|
||||
F(ChatRoom, RealTimeTextChatRoom) \
|
||||
F(ChatRoom, ServerGroupChatRoom) \
|
||||
F(EventLog, ConferenceCallEvent) \
|
||||
F(EventLog, ConferenceChatMessageEvent) \
|
||||
F(EventLog, ConferenceEvent) \
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ public:
|
|||
mutable MainDbChatMessageKey dbKey;
|
||||
|
||||
private:
|
||||
std::weak_ptr<ChatRoom> chatRoom;
|
||||
std::weak_ptr<AbstractChatRoom> chatRoom;
|
||||
ChatRoomId chatRoomId;
|
||||
IdentityAddress fromAddress;
|
||||
IdentityAddress toAddress;
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ void ChatMessagePrivate::setState (ChatMessage::State s, bool force) {
|
|||
if (force)
|
||||
state = s;
|
||||
|
||||
if (s == state || !q->getChatRoom())
|
||||
if (s == state)
|
||||
return;
|
||||
|
||||
if (
|
||||
|
|
@ -316,7 +316,7 @@ void ChatMessagePrivate::loadFileTransferUrlFromBodyToContent() {
|
|||
void ChatMessagePrivate::sendImdn (Imdn::Type imdnType, LinphoneReason reason) {
|
||||
L_Q();
|
||||
|
||||
shared_ptr<ChatMessage> msg = q->getChatRoom()->createMessage();
|
||||
shared_ptr<ChatMessage> msg = q->getChatRoom()->createChatMessage();
|
||||
|
||||
Content *content = new Content();
|
||||
content->setContentType("message/imdn+xml");
|
||||
|
|
@ -332,7 +332,7 @@ LinphoneReason ChatMessagePrivate::receive () {
|
|||
LinphoneReason reason = LinphoneReasonNone;
|
||||
|
||||
shared_ptr<Core> core = q->getCore();
|
||||
shared_ptr<ChatRoom> chatRoom = q->getChatRoom();
|
||||
shared_ptr<AbstractChatRoom> chatRoom = q->getChatRoom();
|
||||
|
||||
setState(ChatMessage::State::Delivered);
|
||||
|
||||
|
|
@ -357,8 +357,7 @@ LinphoneReason ChatMessagePrivate::receive () {
|
|||
ChatMessageModifier::Result result = ecmm.decode(q->getSharedFromThis(), errorCode);
|
||||
if (result == ChatMessageModifier::Result::Error) {
|
||||
/* Unable to decrypt message */
|
||||
if (chatRoom)
|
||||
chatRoom->getPrivate()->notifyUndecryptableMessageReceived(q->getSharedFromThis());
|
||||
chatRoom->getPrivate()->notifyUndecryptableMessageReceived(q->getSharedFromThis());
|
||||
reason = linphone_error_code_to_reason(errorCode);
|
||||
q->sendDeliveryNotification(reason);
|
||||
return reason;
|
||||
|
|
@ -416,7 +415,7 @@ LinphoneReason ChatMessagePrivate::receive () {
|
|||
setDirection(ChatMessage::Direction::Outgoing);
|
||||
|
||||
// Check if this is a duplicate message.
|
||||
if (chatRoom && chatRoom->findMessageWithDirection(imdnId, direction))
|
||||
if (chatRoom->findChatMessage(imdnId, direction))
|
||||
return core->getCCore()->chat_deny_code;
|
||||
|
||||
if (errorCode > 0) {
|
||||
|
|
@ -632,9 +631,8 @@ void ChatMessagePrivate::store() {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ChatMessage::ChatMessage (const shared_ptr<ChatRoom> &chatRoom, ChatMessage::Direction direction) :
|
||||
ChatMessage::ChatMessage (const shared_ptr<AbstractChatRoom> &chatRoom, ChatMessage::Direction direction) :
|
||||
Object(*new ChatMessagePrivate), CoreAccessor(chatRoom->getCore()) {
|
||||
L_ASSERT(chatRoom);
|
||||
L_D();
|
||||
|
||||
d->chatRoom = chatRoom;
|
||||
|
|
@ -658,12 +656,17 @@ ChatMessage::~ChatMessage () {
|
|||
d->salOp->release();
|
||||
}
|
||||
|
||||
shared_ptr<ChatRoom> ChatMessage::getChatRoom () const {
|
||||
shared_ptr<AbstractChatRoom> ChatMessage::getChatRoom () const {
|
||||
L_D();
|
||||
|
||||
shared_ptr<ChatRoom> chatRoom = d->chatRoom.lock();
|
||||
if (!chatRoom)
|
||||
shared_ptr<AbstractChatRoom> chatRoom = d->chatRoom.lock();
|
||||
if (!chatRoom) {
|
||||
chatRoom = getCore()->getOrCreateBasicChatRoom(d->chatRoomId);
|
||||
if (!chatRoom) {
|
||||
lError() << "Unable to get valid chat room instance.";
|
||||
throw logic_error("Unable to get chat room of chat message.");
|
||||
}
|
||||
}
|
||||
|
||||
return chatRoom;
|
||||
}
|
||||
|
|
@ -813,9 +816,7 @@ void ChatMessage::send () {
|
|||
return;
|
||||
}
|
||||
|
||||
shared_ptr<ChatRoom> chatRoom = getChatRoom();
|
||||
if (chatRoom)
|
||||
chatRoom->getPrivate()->sendMessage(getSharedFromThis());
|
||||
getChatRoom()->getPrivate()->sendChatMessage(getSharedFromThis());
|
||||
}
|
||||
|
||||
void ChatMessage::sendDeliveryNotification (LinphoneReason reason) {
|
||||
|
|
@ -860,9 +861,7 @@ int ChatMessage::putCharacter (uint32_t character) {
|
|||
static const uint32_t crlf = 0x0D0A;
|
||||
static const uint32_t lf = 0x0A;
|
||||
|
||||
shared_ptr<ChatRoom> chatRoom = getChatRoom();
|
||||
if (!chatRoom)
|
||||
return -1;
|
||||
shared_ptr<AbstractChatRoom> chatRoom = getChatRoom();
|
||||
|
||||
shared_ptr<LinphonePrivate::RealTimeTextChatRoom> rttcr =
|
||||
static_pointer_cast<LinphonePrivate::RealTimeTextChatRoom>(chatRoom);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class ChatRoom;
|
||||
class AbstractChatRoom;
|
||||
class Content;
|
||||
class FileTransferContent;
|
||||
class ChatMessagePrivate;
|
||||
|
|
@ -67,7 +67,7 @@ public:
|
|||
void setIsSecured (bool isSecured);
|
||||
// ----- TODO: Remove me.
|
||||
|
||||
std::shared_ptr<ChatRoom> getChatRoom () const;
|
||||
std::shared_ptr<AbstractChatRoom> getChatRoom () const;
|
||||
|
||||
void send ();
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ public:
|
|||
bool downloadFile (FileTransferContent &content);
|
||||
|
||||
private:
|
||||
ChatMessage (const std::shared_ptr<ChatRoom> &chatRoom, ChatMessage::Direction direction);
|
||||
ChatMessage (const std::shared_ptr<AbstractChatRoom> &chatRoom, ChatMessage::Direction direction);
|
||||
|
||||
L_DECLARE_PRIVATE(ChatMessage);
|
||||
L_DISABLE_COPY(ChatMessage);
|
||||
|
|
|
|||
54
src/chat/chat-room/abstract-chat-room-p.h
Normal file
54
src/chat/chat-room/abstract-chat-room-p.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* abstract-chat-room-p.h
|
||||
* Copyright (C) 2010-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 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _ABSTRACT_CHAT_ROOM_P_H_
|
||||
#define _ABSTRACT_CHAT_ROOM_P_H_
|
||||
|
||||
#include "abstract-chat-room.h"
|
||||
#include "object/object-p.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
L_DECL_C_STRUCT_PREFIX_LESS(SalMessage);
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class SalOp;
|
||||
|
||||
class AbstractChatRoomPrivate : public ObjectPrivate {
|
||||
public:
|
||||
virtual void setCreationTime (time_t creationTime) = 0;
|
||||
virtual void setLastUpdateTime (time_t lastUpdateTime) = 0;
|
||||
|
||||
virtual void setState (AbstractChatRoom::State state) = 0;
|
||||
|
||||
virtual void sendChatMessage (const std::shared_ptr<ChatMessage> &chatMessage) = 0;
|
||||
|
||||
virtual void addTransientEvent (const std::shared_ptr<EventLog> &eventLog) = 0;
|
||||
virtual void removeTransientEvent (const std::shared_ptr<EventLog> &eventLog) = 0;
|
||||
|
||||
virtual void notifyUndecryptableMessageReceived (const std::shared_ptr<ChatMessage> &chatMessage) = 0;
|
||||
|
||||
virtual void onChatMessageReceived (const std::shared_ptr<ChatMessage> &chatMessage) = 0;
|
||||
virtual LinphoneReason onSipMessageReceived (SalOp *op, const SalMessage *message) = 0;
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
||||
#endif // ifndef _ABSTRACT_CHAT_ROOM_P_H_
|
||||
35
src/chat/chat-room/abstract-chat-room.cpp
Normal file
35
src/chat/chat-room/abstract-chat-room.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* abstract-chat-room.cpp
|
||||
* Copyright (C) 2010-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 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "abstract-chat-room-p.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
AbstractChatRoom::AbstractChatRoom (
|
||||
AbstractChatRoomPrivate &p,
|
||||
const shared_ptr<Core> &core
|
||||
) : Object(p), CoreAccessor(core) {}
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
98
src/chat/chat-room/abstract-chat-room.h
Normal file
98
src/chat/chat-room/abstract-chat-room.h
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* abstract-chat-room.h
|
||||
* Copyright (C) 2010-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 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _ABSTRACT_CHAT_ROOM_H_
|
||||
#define _ABSTRACT_CHAT_ROOM_H_
|
||||
|
||||
#include "chat/chat-message/chat-message.h"
|
||||
#include "conference/conference-interface.h"
|
||||
#include "core/core-accessor.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class AbstractChatRoomPrivate;
|
||||
class ChatRoomId;
|
||||
class EventLog;
|
||||
|
||||
class LINPHONE_PUBLIC AbstractChatRoom : public Object, public CoreAccessor, public ConferenceInterface {
|
||||
friend class ChatMessage;
|
||||
friend class ChatMessagePrivate;
|
||||
friend class CorePrivate;
|
||||
friend class MainDb;
|
||||
|
||||
public:
|
||||
L_DECLARE_ENUM(Capabilities, L_ENUM_VALUES_CHAT_ROOM_CAPABILITIES);
|
||||
L_DECLARE_ENUM(State, L_ENUM_VALUES_CHAT_ROOM_STATE);
|
||||
|
||||
typedef int CapabilitiesMask;
|
||||
|
||||
virtual const ChatRoomId &getChatRoomId () const = 0;
|
||||
|
||||
virtual const IdentityAddress &getPeerAddress () const = 0;
|
||||
virtual const IdentityAddress &getLocalAddress () const = 0;
|
||||
|
||||
virtual time_t getCreationTime () const = 0;
|
||||
virtual time_t getLastUpdateTime () const = 0;
|
||||
|
||||
virtual CapabilitiesMask getCapabilities () const = 0;
|
||||
virtual State getState () const = 0;
|
||||
virtual bool hasBeenLeft () const = 0;
|
||||
|
||||
virtual std::list<std::shared_ptr<EventLog>> getHistory (int nLast) const = 0;
|
||||
virtual std::list<std::shared_ptr<EventLog>> getHistoryRange (int begin, int end) const = 0;
|
||||
virtual int getHistorySize () const = 0;
|
||||
|
||||
virtual void deleteHistory () = 0;
|
||||
|
||||
virtual std::shared_ptr<ChatMessage> getLastChatMessageInHistory () const = 0;
|
||||
|
||||
virtual int getChatMessageCount () const = 0;
|
||||
virtual int getUnreadChatMessageCount () const = 0;
|
||||
|
||||
virtual void compose () = 0;
|
||||
virtual bool isRemoteComposing () const = 0;
|
||||
virtual std::list<IdentityAddress> getComposingAddresses () const = 0;
|
||||
|
||||
virtual std::shared_ptr<ChatMessage> createChatMessage () = 0;
|
||||
virtual std::shared_ptr<ChatMessage> createChatMessage (const std::string &text) = 0;
|
||||
|
||||
// TODO: Remove LinphoneContent by LinphonePrivate::Content.
|
||||
virtual std::shared_ptr<ChatMessage> createFileTransferMessage (const LinphoneContent *initialContent) = 0;
|
||||
|
||||
virtual std::shared_ptr<ChatMessage> findChatMessage (const std::string &messageId) const = 0;
|
||||
virtual std::shared_ptr<ChatMessage> findChatMessage (
|
||||
const std::string &messageId,
|
||||
ChatMessage::Direction direction
|
||||
) const = 0;
|
||||
|
||||
virtual void markAsRead () = 0;
|
||||
|
||||
protected:
|
||||
explicit AbstractChatRoom (AbstractChatRoomPrivate &p, const std::shared_ptr<Core> &core);
|
||||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(AbstractChatRoom);
|
||||
L_DISABLE_COPY(AbstractChatRoom);
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
||||
#endif // ifndef _ABSTRACT_CHAT_ROOM_H_
|
||||
|
|
@ -32,8 +32,6 @@ public:
|
|||
BasicChatRoomPrivate () = default;
|
||||
|
||||
private:
|
||||
void onChatMessageReceived (const std::shared_ptr<ChatMessage> &chatMessage) override;
|
||||
|
||||
std::string subject;
|
||||
std::list<std::shared_ptr<Participant>> participants;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,10 +31,6 @@ 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) {}
|
||||
|
||||
|
|
|
|||
0
src/chat/chat-room/basic-to-client-group-chat-room.cpp
Normal file
0
src/chat/chat-room/basic-to-client-group-chat-room.cpp
Normal file
0
src/chat/chat-room/basic-to-client-group-chat-room.h
Normal file
0
src/chat/chat-room/basic-to-client-group-chat-room.h
Normal file
|
|
@ -20,46 +20,50 @@
|
|||
#ifndef _CHAT_ROOM_P_H_
|
||||
#define _CHAT_ROOM_P_H_
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
#include "chat/notification/is-composing.h"
|
||||
#include "abstract-chat-room-p.h"
|
||||
#include "chat-room-id.h"
|
||||
#include "chat-room.h"
|
||||
#include "object/object-p.h"
|
||||
#include "chat/notification/is-composing.h"
|
||||
#include "event-log/event-log.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
// TODO: clean and order methods!
|
||||
class ChatRoomPrivate : public ObjectPrivate, public IsComposingListener {
|
||||
class ChatRoomPrivate : public AbstractChatRoomPrivate, public IsComposingListener {
|
||||
public:
|
||||
ChatRoomPrivate () = default;
|
||||
void setCreationTime (time_t creationTime) override {
|
||||
this->creationTime = creationTime;
|
||||
}
|
||||
|
||||
void addTransientEvent (const std::shared_ptr<EventLog> &log);
|
||||
void removeTransientEvent (const std::shared_ptr<EventLog> &log);
|
||||
void setLastUpdateTime (time_t lastUpdateTime) override {
|
||||
this->lastUpdateTime = lastUpdateTime;
|
||||
}
|
||||
|
||||
void release ();
|
||||
void setState (ChatRoom::State state) override;
|
||||
|
||||
void setState (ChatRoom::State newState);
|
||||
void sendChatMessage (const std::shared_ptr<ChatMessage> &chatMessage) override;
|
||||
|
||||
virtual void sendMessage (const std::shared_ptr<ChatMessage> &msg);
|
||||
void addTransientEvent (const std::shared_ptr<EventLog> &eventLog) override;
|
||||
void removeTransientEvent (const std::shared_ptr<EventLog> &eventLog) override;
|
||||
|
||||
void notifyUndecryptableMessageReceived (const std::shared_ptr<ChatMessage> &chatMessage) override;
|
||||
|
||||
void onChatMessageReceived (const std::shared_ptr<ChatMessage> &chatMessage) override;
|
||||
LinphoneReason onSipMessageReceived (SalOp *op, const SalMessage *message) override;
|
||||
|
||||
// TODO: After this point clean and order methods (AND set members private if possible)!!!
|
||||
|
||||
void sendIsComposingNotification ();
|
||||
|
||||
std::list<std::shared_ptr<ChatMessage>> findMessages (const std::string &messageId) const;
|
||||
|
||||
virtual LinphoneReason messageReceived (SalOp *op, const SalMessage *msg);
|
||||
void realtimeTextReceived (uint32_t character, LinphoneCall *call);
|
||||
|
||||
void chatMessageReceived (const std::shared_ptr<ChatMessage> &msg);
|
||||
void imdnReceived (const std::string &text);
|
||||
void isComposingReceived (const Address &remoteAddr, const std::string &text);
|
||||
|
||||
void notifyChatMessageReceived (const std::shared_ptr<ChatMessage> &msg);
|
||||
void notifyIsComposingReceived (const Address &remoteAddr, bool isComposing);
|
||||
void notifyStateChanged ();
|
||||
void notifyUndecryptableMessageReceived (const std::shared_ptr<ChatMessage> &msg);
|
||||
|
||||
/* IsComposingListener */
|
||||
void onIsComposingStateChanged (bool isComposing) override;
|
||||
|
|
@ -70,7 +74,7 @@ public:
|
|||
|
||||
LinphoneCall *call = nullptr;
|
||||
bool isComposing = false;
|
||||
std::list<Address> remoteIsComposing;
|
||||
std::list<IdentityAddress> remoteIsComposing;
|
||||
std::list<std::shared_ptr<EventLog>> transientEvents;
|
||||
|
||||
// TODO: Remove me. Must be present only in rtt chat room.
|
||||
|
|
@ -83,9 +87,6 @@ public:
|
|||
|
||||
ChatRoom::State state = ChatRoom::State::None;
|
||||
|
||||
public:
|
||||
virtual void onChatMessageReceived (const std::shared_ptr<ChatMessage> &chatMessage) = 0;
|
||||
|
||||
ChatRoomId chatRoomId;
|
||||
|
||||
time_t creationTime = std::time(nullptr);
|
||||
|
|
|
|||
|
|
@ -50,12 +50,6 @@ void ChatRoomPrivate::removeTransientEvent (const shared_ptr<EventLog> &log) {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void ChatRoomPrivate::release () {
|
||||
isComposingHandler->stopTimers();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void ChatRoomPrivate::setState (ChatRoom::State newState) {
|
||||
if (newState != state) {
|
||||
state = newState;
|
||||
|
|
@ -93,7 +87,7 @@ list<shared_ptr<ChatMessage> > ChatRoomPrivate::findMessages (const string &mess
|
|||
return q->getCore()->getPrivate()->mainDb->findChatMessages(q->getChatRoomId(), messageId);
|
||||
}
|
||||
|
||||
void ChatRoomPrivate::sendMessage (const shared_ptr<ChatMessage> &msg) {
|
||||
void ChatRoomPrivate::sendChatMessage (const shared_ptr<ChatMessage> &msg) {
|
||||
L_Q();
|
||||
|
||||
// TODO: Check direction.
|
||||
|
|
@ -125,7 +119,7 @@ void ChatRoomPrivate::sendMessage (const shared_ptr<ChatMessage> &msg) {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
LinphoneReason ChatRoomPrivate::messageReceived (SalOp *op, const SalMessage *salMsg) {
|
||||
LinphoneReason ChatRoomPrivate::onSipMessageReceived (SalOp *op, const SalMessage *message) {
|
||||
L_Q();
|
||||
|
||||
bool increaseMsgCount = true;
|
||||
|
|
@ -142,11 +136,11 @@ LinphoneReason ChatRoomPrivate::messageReceived (SalOp *op, const SalMessage *sa
|
|||
);
|
||||
|
||||
Content content;
|
||||
content.setContentType(salMsg->content_type);
|
||||
content.setBody(salMsg->text ? salMsg->text : "");
|
||||
content.setContentType(message->content_type);
|
||||
content.setBody(message->text ? message->text : "");
|
||||
msg->setInternalContent(content);
|
||||
|
||||
msg->getPrivate()->setTime(salMsg->time);
|
||||
msg->getPrivate()->setTime(message->time);
|
||||
msg->getPrivate()->setImdnMessageId(op->get_call_id());
|
||||
|
||||
const SalCustomHeader *ch = op->get_recv_custom_header();
|
||||
|
|
@ -182,7 +176,7 @@ LinphoneReason ChatRoomPrivate::messageReceived (SalOp *op, const SalMessage *sa
|
|||
pendingMessage = msg;
|
||||
}
|
||||
|
||||
chatMessageReceived(msg);
|
||||
onChatMessageReceived(msg);
|
||||
|
||||
pendingMessage = nullptr;
|
||||
|
||||
|
|
@ -192,7 +186,7 @@ end:
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void ChatRoomPrivate::chatMessageReceived (const shared_ptr<ChatMessage> &msg) {
|
||||
void ChatRoomPrivate::onChatMessageReceived (const shared_ptr<ChatMessage> &msg) {
|
||||
L_Q();
|
||||
|
||||
if ((msg->getPrivate()->getContentType() != ContentType::Imdn) && (msg->getPrivate()->getContentType() != ContentType::ImIsComposing)) {
|
||||
|
|
@ -305,7 +299,7 @@ void ChatRoomPrivate::onIsComposingRefreshNeeded () {
|
|||
// =============================================================================
|
||||
|
||||
ChatRoom::ChatRoom (ChatRoomPrivate &p, const shared_ptr<Core> &core, const ChatRoomId &chatRoomId) :
|
||||
Object(p), CoreAccessor(core) {
|
||||
AbstractChatRoom(p, core) {
|
||||
L_D();
|
||||
|
||||
d->chatRoomId = chatRoomId;
|
||||
|
|
@ -343,31 +337,38 @@ time_t ChatRoom::getLastUpdateTime () const {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
list<shared_ptr<EventLog>> ChatRoom::getHistory (int nLast) {
|
||||
ChatRoom::State ChatRoom::getState () const {
|
||||
L_D();
|
||||
return d->state;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
list<shared_ptr<EventLog>> ChatRoom::getHistory (int nLast) const {
|
||||
return getCore()->getPrivate()->mainDb->getHistory(getChatRoomId(), nLast);
|
||||
}
|
||||
|
||||
list<shared_ptr<EventLog>> ChatRoom::getHistoryRange (int begin, int end) {
|
||||
list<shared_ptr<EventLog>> ChatRoom::getHistoryRange (int begin, int end) const {
|
||||
return getCore()->getPrivate()->mainDb->getHistoryRange(getChatRoomId(), begin, end);
|
||||
}
|
||||
|
||||
int ChatRoom::getHistorySize () {
|
||||
int ChatRoom::getHistorySize () const {
|
||||
return getCore()->getPrivate()->mainDb->getHistorySize(getChatRoomId());
|
||||
}
|
||||
|
||||
shared_ptr<ChatMessage> ChatRoom::getLastChatMessageInHistory() const {
|
||||
return getCore()->getPrivate()->mainDb->getLastChatMessage(getChatRoomId());
|
||||
}
|
||||
|
||||
void ChatRoom::deleteHistory () {
|
||||
getCore()->getPrivate()->mainDb->cleanHistory(getChatRoomId());
|
||||
}
|
||||
|
||||
int ChatRoom::getChatMessageCount () {
|
||||
shared_ptr<ChatMessage> ChatRoom::getLastChatMessageInHistory() const {
|
||||
return getCore()->getPrivate()->mainDb->getLastChatMessage(getChatRoomId());
|
||||
}
|
||||
|
||||
int ChatRoom::getChatMessageCount () const {
|
||||
return getCore()->getPrivate()->mainDb->getChatMessageCount(getChatRoomId());
|
||||
}
|
||||
|
||||
int ChatRoom::getUnreadChatMessageCount () {
|
||||
int ChatRoom::getUnreadChatMessageCount () const {
|
||||
return getCore()->getPrivate()->mainDb->getUnreadChatMessageCount(getChatRoomId());
|
||||
}
|
||||
|
||||
|
|
@ -383,27 +384,41 @@ void ChatRoom::compose () {
|
|||
d->isComposingHandler->startIdleTimer();
|
||||
}
|
||||
|
||||
shared_ptr<ChatMessage> ChatRoom::createFileTransferMessage (const LinphoneContent *initialContent) {
|
||||
shared_ptr<ChatMessage> chatMessage = createMessage();
|
||||
chatMessage->getPrivate()->setFileTransferInformation(initialContent);
|
||||
return chatMessage;
|
||||
bool ChatRoom::isRemoteComposing () const {
|
||||
L_D();
|
||||
return !d->remoteIsComposing.empty();
|
||||
}
|
||||
|
||||
shared_ptr<ChatMessage> ChatRoom::createMessage (const string &message) {
|
||||
shared_ptr<ChatMessage> chatMessage = createMessage();
|
||||
Content *content = new Content();
|
||||
content->setContentType(ContentType::PlainText);
|
||||
content->setBody(message);
|
||||
chatMessage->addContent(*content);
|
||||
return chatMessage;
|
||||
std::list<IdentityAddress> ChatRoom::getComposingAddresses () const {
|
||||
L_D();
|
||||
return d->remoteIsComposing;
|
||||
}
|
||||
|
||||
shared_ptr<ChatMessage> ChatRoom::createMessage () {
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
shared_ptr<ChatMessage> ChatRoom::createChatMessage () {
|
||||
L_D();
|
||||
return d->createChatMessage(ChatMessage::Direction::Outgoing);
|
||||
}
|
||||
|
||||
shared_ptr<ChatMessage> ChatRoom::findMessage (const string &messageId) {
|
||||
shared_ptr<ChatMessage> ChatRoom::createChatMessage (const string &text) {
|
||||
shared_ptr<ChatMessage> chatMessage = createChatMessage();
|
||||
Content *content = new Content();
|
||||
content->setContentType(ContentType::PlainText);
|
||||
content->setBody(text);
|
||||
chatMessage->addContent(*content);
|
||||
return chatMessage;
|
||||
}
|
||||
|
||||
shared_ptr<ChatMessage> ChatRoom::createFileTransferMessage (const LinphoneContent *initialContent) {
|
||||
shared_ptr<ChatMessage> chatMessage = createChatMessage();
|
||||
chatMessage->getPrivate()->setFileTransferInformation(initialContent);
|
||||
return chatMessage;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
shared_ptr<ChatMessage> ChatRoom::findChatMessage (const string &messageId) const {
|
||||
L_D();
|
||||
shared_ptr<ChatMessage> cm = nullptr;
|
||||
list<shared_ptr<ChatMessage> > l = d->findMessages(messageId);
|
||||
|
|
@ -413,7 +428,7 @@ shared_ptr<ChatMessage> ChatRoom::findMessage (const string &messageId) {
|
|||
return cm;
|
||||
}
|
||||
|
||||
shared_ptr<ChatMessage> ChatRoom::findMessageWithDirection (const string &messageId, ChatMessage::Direction direction) {
|
||||
shared_ptr<ChatMessage> ChatRoom::findChatMessage (const string &messageId, ChatMessage::Direction direction) const {
|
||||
L_D();
|
||||
shared_ptr<ChatMessage> ret = nullptr;
|
||||
list<shared_ptr<ChatMessage> > l = d->findMessages(messageId);
|
||||
|
|
@ -426,16 +441,6 @@ shared_ptr<ChatMessage> ChatRoom::findMessageWithDirection (const string &messag
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool ChatRoom::isRemoteComposing () const {
|
||||
L_D();
|
||||
return d->remoteIsComposing.size() > 0;
|
||||
}
|
||||
|
||||
std::list<Address> ChatRoom::getComposingAddresses () const {
|
||||
L_D();
|
||||
return d->remoteIsComposing;
|
||||
}
|
||||
|
||||
void ChatRoom::markAsRead () {
|
||||
L_D();
|
||||
|
||||
|
|
@ -455,11 +460,4 @@ void ChatRoom::markAsRead () {
|
|||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ChatRoom::State ChatRoom::getState () const {
|
||||
L_D();
|
||||
return d->state;
|
||||
}
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -20,70 +20,59 @@
|
|||
#ifndef _CHAT_ROOM_H_
|
||||
#define _CHAT_ROOM_H_
|
||||
|
||||
#include "chat/chat-message/chat-message.h"
|
||||
#include "chat/chat-room/chat-room-id.h"
|
||||
#include "conference/conference-interface.h"
|
||||
#include "abstract-chat-room.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class ChatRoomPrivate;
|
||||
class EventLog;
|
||||
|
||||
class LINPHONE_PUBLIC ChatRoom : public Object, public CoreAccessor, public ConferenceInterface {
|
||||
friend class ChatMessage;
|
||||
friend class ChatMessagePrivate;
|
||||
class LINPHONE_PUBLIC ChatRoom : public AbstractChatRoom {
|
||||
friend class Core;
|
||||
friend class CorePrivate;
|
||||
friend class FileTransferChatMessageModifier;
|
||||
friend class MainDb;
|
||||
|
||||
public:
|
||||
L_OVERRIDE_SHARED_FROM_THIS(ChatRoom);
|
||||
|
||||
L_DECLARE_ENUM(Capabilities, L_ENUM_VALUES_CHAT_ROOM_CAPABILITIES);
|
||||
L_DECLARE_ENUM(State, L_ENUM_VALUES_CHAT_ROOM_STATE);
|
||||
const ChatRoomId &getChatRoomId () const override;
|
||||
|
||||
typedef int CapabilitiesMask;
|
||||
const IdentityAddress &getPeerAddress () const override;
|
||||
const IdentityAddress &getLocalAddress () const override;
|
||||
|
||||
virtual ~ChatRoom () = default;
|
||||
time_t getCreationTime () const override;
|
||||
time_t getLastUpdateTime () const override;
|
||||
|
||||
const ChatRoomId &getChatRoomId () const;
|
||||
State getState () const override;
|
||||
|
||||
const IdentityAddress &getPeerAddress () const;
|
||||
const IdentityAddress &getLocalAddress () const;
|
||||
std::list<std::shared_ptr<EventLog>> getHistory (int nLast) const override;
|
||||
std::list<std::shared_ptr<EventLog>> getHistoryRange (int begin, int end) const override;
|
||||
int getHistorySize () const override;
|
||||
|
||||
time_t getCreationTime () const;
|
||||
time_t getLastUpdateTime () const;
|
||||
void deleteHistory () override;
|
||||
|
||||
virtual CapabilitiesMask getCapabilities () const = 0;
|
||||
virtual bool hasBeenLeft () const = 0;
|
||||
std::shared_ptr<ChatMessage> getLastChatMessageInHistory () const override;
|
||||
|
||||
std::list<std::shared_ptr<EventLog>> getHistory (int nLast);
|
||||
std::list<std::shared_ptr<EventLog>> getHistoryRange (int begin, int end);
|
||||
int getHistorySize ();
|
||||
int getChatMessageCount () const override;
|
||||
int getUnreadChatMessageCount () const override;
|
||||
|
||||
std::shared_ptr<ChatMessage> getLastChatMessageInHistory () const;
|
||||
void compose () override;
|
||||
bool isRemoteComposing () const override;
|
||||
std::list<IdentityAddress> getComposingAddresses () const override;
|
||||
|
||||
void deleteHistory ();
|
||||
std::shared_ptr<ChatMessage> createChatMessage () override;
|
||||
std::shared_ptr<ChatMessage> createChatMessage (const std::string &text) override;
|
||||
|
||||
int getChatMessageCount ();
|
||||
int getUnreadChatMessageCount ();
|
||||
// TODO: Remove LinphoneContent by LinphonePrivate::Content.
|
||||
std::shared_ptr<ChatMessage> createFileTransferMessage (const LinphoneContent *initialContent) override;
|
||||
|
||||
// TODO: Remove useless functions.
|
||||
void compose ();
|
||||
std::shared_ptr<ChatMessage> createFileTransferMessage (const LinphoneContent *initialContent);
|
||||
std::shared_ptr<ChatMessage> createMessage (const std::string &msg);
|
||||
std::shared_ptr<ChatMessage> createMessage ();
|
||||
std::shared_ptr<ChatMessage> findMessage (const std::string &messageId);
|
||||
std::shared_ptr<ChatMessage> findMessageWithDirection (const std::string &messageId, ChatMessage::Direction direction);
|
||||
bool isRemoteComposing () const;
|
||||
std::list<Address> getComposingAddresses () const;
|
||||
std::shared_ptr<ChatMessage> findChatMessage (const std::string &messageId) const override;
|
||||
std::shared_ptr<ChatMessage> findChatMessage (
|
||||
const std::string &messageId,
|
||||
ChatMessage::Direction direction
|
||||
) const override;
|
||||
|
||||
virtual void markAsRead ();
|
||||
|
||||
State getState () const;
|
||||
void markAsRead () override;
|
||||
|
||||
protected:
|
||||
explicit ChatRoom (ChatRoomPrivate &p, const std::shared_ptr<Core> &core, const ChatRoomId &chatRoomId);
|
||||
|
|
|
|||
|
|
@ -42,8 +42,6 @@ private:
|
|||
void onCallSessionSetReleased (const std::shared_ptr<const CallSession> &session) override;
|
||||
void onCallSessionStateChanged (const std::shared_ptr<const CallSession> &session, LinphoneCallState state, const std::string &message) override;
|
||||
|
||||
void onChatMessageReceived (const std::shared_ptr<ChatMessage> &chatMessage) override;
|
||||
|
||||
L_DECLARE_PUBLIC(ClientGroupChatRoom);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -114,10 +114,6 @@ void ClientGroupChatRoomPrivate::onCallSessionStateChanged (
|
|||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void ClientGroupChatRoomPrivate::onChatMessageReceived (const shared_ptr<ChatMessage> &) {}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
ClientGroupChatRoom::ClientGroupChatRoom (
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public:
|
|||
~RealTimeTextChatRoomPrivate ();
|
||||
|
||||
void realtimeTextReceived (uint32_t character, LinphoneCall *call);
|
||||
void sendMessage (const std::shared_ptr<ChatMessage> &msg) override;
|
||||
void sendChatMessage (const std::shared_ptr<ChatMessage> &chatMessage) override;
|
||||
|
||||
LinphoneCall *call = nullptr;
|
||||
std::list<LinphoneChatMessageCharacter *> receivedRttCharacters;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ void RealTimeTextChatRoomPrivate::realtimeTextReceived (uint32_t character, Linp
|
|||
LinphoneChatMessageCharacter *cmc = bctbx_new0(LinphoneChatMessageCharacter, 1);
|
||||
|
||||
if (!pendingMessage)
|
||||
pendingMessage = q->createMessage("");
|
||||
pendingMessage = q->createChatMessage("");
|
||||
|
||||
cmc->value = character;
|
||||
cmc->has_been_read = FALSE;
|
||||
|
|
@ -79,7 +79,7 @@ void RealTimeTextChatRoomPrivate::realtimeTextReceived (uint32_t character, Linp
|
|||
if (lp_config_get_int(linphone_core_get_config(cCore), "misc", "store_rtt_messages", 1) == 1)
|
||||
pendingMessage->getPrivate()->store();
|
||||
|
||||
chatMessageReceived(pendingMessage);
|
||||
onChatMessageReceived(pendingMessage);
|
||||
pendingMessage = nullptr;
|
||||
for (auto &rttChars : receivedRttCharacters)
|
||||
ms_free(rttChars);
|
||||
|
|
@ -94,10 +94,10 @@ void RealTimeTextChatRoomPrivate::realtimeTextReceived (uint32_t character, Linp
|
|||
}
|
||||
}
|
||||
|
||||
void RealTimeTextChatRoomPrivate::sendMessage (const shared_ptr<ChatMessage> &msg) {
|
||||
void RealTimeTextChatRoomPrivate::sendChatMessage (const shared_ptr<ChatMessage> &chatMessage) {
|
||||
if (call && linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(call))) {
|
||||
uint32_t new_line = 0x2028;
|
||||
msg->putCharacter(new_line);
|
||||
chatMessage->putCharacter(new_line);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public:
|
|||
void update (SalCallOp *op);
|
||||
|
||||
void dispatchMessage (const IdentityAddress &fromAddr, const Content &content);
|
||||
LinphoneReason messageReceived (SalOp *op, const SalMessage *msg) override;
|
||||
LinphoneReason onSipMessageReceived (SalOp *op, const SalMessage *message) override;
|
||||
void setConferenceAddress (const IdentityAddress &confAddr);
|
||||
|
||||
private:
|
||||
|
|
@ -59,8 +59,6 @@ private:
|
|||
// CallSessionListener
|
||||
void onCallSessionStateChanged (const std::shared_ptr<const CallSession> &session, LinphoneCallState state, const std::string &message) override;
|
||||
|
||||
void onChatMessageReceived (const std::shared_ptr<ChatMessage> &) override;
|
||||
|
||||
std::list<std::shared_ptr<Participant>> removedParticipants;
|
||||
|
||||
L_DECLARE_PUBLIC(ServerGroupChatRoom);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ void ServerGroupChatRoomPrivate::update (SalCallOp *) {}
|
|||
|
||||
void ServerGroupChatRoomPrivate::dispatchMessage (const IdentityAddress &, const Content &) {}
|
||||
|
||||
LinphoneReason ServerGroupChatRoomPrivate::messageReceived (SalOp *, const SalMessage *) {
|
||||
LinphoneReason ServerGroupChatRoomPrivate::onSipMessageReceived (SalOp *, const SalMessage *) {
|
||||
return LinphoneReasonNone;
|
||||
}
|
||||
|
||||
|
|
@ -81,10 +81,6 @@ void ServerGroupChatRoomPrivate::onCallSessionStateChanged (
|
|||
const string &
|
||||
) {}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void ServerGroupChatRoomPrivate::onChatMessageReceived(const shared_ptr<ChatMessage> &) {}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
ServerGroupChatRoom::ServerGroupChatRoom (const shared_ptr<Core> &core, SalCallOp *op) :
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ ChatMessageModifier::Result EncryptionChatMessageModifier::encode (
|
|||
const shared_ptr<ChatMessage> &message,
|
||||
int &errorCode
|
||||
) {
|
||||
shared_ptr<ChatRoom> chatRoom = message->getChatRoom();
|
||||
shared_ptr<AbstractChatRoom> chatRoom = message->getChatRoom();
|
||||
LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(chatRoom->getCore()->getCCore());
|
||||
if (!imee)
|
||||
return ChatMessageModifier::Result::Skipped;
|
||||
|
|
@ -70,7 +70,7 @@ ChatMessageModifier::Result EncryptionChatMessageModifier::decode (
|
|||
const shared_ptr<ChatMessage> &message,
|
||||
int &errorCode
|
||||
) {
|
||||
shared_ptr<ChatRoom> chatRoom = message->getChatRoom();
|
||||
shared_ptr<AbstractChatRoom> chatRoom = message->getChatRoom();
|
||||
LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(chatRoom->getCore()->getCCore());
|
||||
if (!imee)
|
||||
return ChatMessageModifier::Result::Skipped;
|
||||
|
|
@ -95,7 +95,7 @@ ChatMessageModifier::Result EncryptionChatMessageModifier::decode (
|
|||
message->setIsSecured(true);
|
||||
if (retval == 1)
|
||||
return ChatMessageModifier::Result::Suspended;
|
||||
|
||||
|
||||
return ChatMessageModifier::Result::Done;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ void Imdn::parse (ChatRoom &cr, xmlparsing_context_t *xmlCtx) {
|
|||
}
|
||||
|
||||
if (messageIdStr && datetimeStr) {
|
||||
shared_ptr<ChatMessage> cm = cr.findMessageWithDirection(messageIdStr, ChatMessage::Direction::Outgoing);
|
||||
shared_ptr<ChatMessage> cm = cr.findChatMessage(messageIdStr, ChatMessage::Direction::Outgoing);
|
||||
if (!cm) {
|
||||
lWarning() << "Received IMDN for unknown message " << messageIdStr;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -61,28 +61,27 @@ static IdentityAddress getDefaultLocalAddress (const shared_ptr<Core> &core, con
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
shared_ptr<ChatRoom> CorePrivate::createBasicChatRoom (const ChatRoomId &chatRoomId, bool isRtt, bool notifyCreation) {
|
||||
shared_ptr<AbstractChatRoom> CorePrivate::createBasicChatRoom (
|
||||
const ChatRoomId &chatRoomId,
|
||||
bool isRtt
|
||||
) {
|
||||
L_Q();
|
||||
|
||||
shared_ptr<ChatRoom> chatRoom;
|
||||
shared_ptr<AbstractChatRoom> chatRoom;
|
||||
|
||||
if (isRtt)
|
||||
chatRoom.reset(new RealTimeTextChatRoom(q->getSharedFromThis(), chatRoomId));
|
||||
else
|
||||
chatRoom.reset(new BasicChatRoom(q->getSharedFromThis(), chatRoomId));
|
||||
|
||||
ChatRoomPrivate *dChatRoom = chatRoom->getPrivate();
|
||||
|
||||
if (notifyCreation) {
|
||||
dChatRoom->setState(ChatRoom::State::Instantiated);
|
||||
dChatRoom->setState(ChatRoom::State::Created);
|
||||
} else
|
||||
dChatRoom->state = ChatRoom::State::Created;
|
||||
AbstractChatRoomPrivate *dChatRoom = chatRoom->getPrivate();
|
||||
dChatRoom->setState(ChatRoom::State::Instantiated);
|
||||
dChatRoom->setState(ChatRoom::State::Created);
|
||||
|
||||
return chatRoom;
|
||||
}
|
||||
|
||||
void CorePrivate::insertChatRoom (const shared_ptr<ChatRoom> &chatRoom) {
|
||||
void CorePrivate::insertChatRoom (const shared_ptr<AbstractChatRoom> &chatRoom) {
|
||||
L_ASSERT(chatRoom);
|
||||
L_Q();
|
||||
|
||||
|
|
@ -91,19 +90,19 @@ void CorePrivate::insertChatRoom (const shared_ptr<ChatRoom> &chatRoom) {
|
|||
chatRoomsById[chatRoom->getChatRoomId()] = chatRoom;
|
||||
}
|
||||
|
||||
void CorePrivate::insertChatRoomWithDb (const shared_ptr<ChatRoom> &chatRoom) {
|
||||
void CorePrivate::insertChatRoomWithDb (const shared_ptr<AbstractChatRoom> &chatRoom) {
|
||||
L_ASSERT(chatRoom->getState() == ChatRoom::State::Created);
|
||||
mainDb->insertChatRoom(chatRoom);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
const list<shared_ptr<ChatRoom>> &Core::getChatRooms () const {
|
||||
const list<shared_ptr<AbstractChatRoom>> &Core::getChatRooms () const {
|
||||
L_D();
|
||||
return d->chatRooms;
|
||||
}
|
||||
|
||||
shared_ptr<ChatRoom> Core::findChatRoom (const ChatRoomId &chatRoomId) const {
|
||||
shared_ptr<AbstractChatRoom> Core::findChatRoom (const ChatRoomId &chatRoomId) const {
|
||||
L_D();
|
||||
|
||||
auto it = d->chatRoomsById.find(chatRoomId);
|
||||
|
|
@ -116,14 +115,13 @@ shared_ptr<ChatRoom> Core::findChatRoom (const ChatRoomId &chatRoomId) const {
|
|||
return shared_ptr<ChatRoom>();
|
||||
}
|
||||
|
||||
list<shared_ptr<ChatRoom>> Core::findChatRooms (const IdentityAddress &peerAddress) const {
|
||||
list<shared_ptr<AbstractChatRoom>> Core::findChatRooms (const IdentityAddress &peerAddress) const {
|
||||
L_D();
|
||||
|
||||
// TODO: Improve performance if necessary.
|
||||
list<shared_ptr<ChatRoom>> output;
|
||||
list<shared_ptr<AbstractChatRoom>> output;
|
||||
copy_if(
|
||||
d->chatRooms.begin(), d->chatRooms.end(),
|
||||
back_inserter(output), [&peerAddress](const shared_ptr<ChatRoom> &chatRoom) {
|
||||
back_inserter(output), [&peerAddress](const shared_ptr<AbstractChatRoom> &chatRoom) {
|
||||
return chatRoom->getPeerAddress() == peerAddress;
|
||||
}
|
||||
);
|
||||
|
|
@ -131,7 +129,7 @@ list<shared_ptr<ChatRoom>> Core::findChatRooms (const IdentityAddress &peerAddre
|
|||
return output;
|
||||
}
|
||||
|
||||
shared_ptr<ChatRoom> Core::findOneToOneChatRoom (
|
||||
shared_ptr<AbstractChatRoom> Core::findOneToOneChatRoom (
|
||||
const IdentityAddress &localAddress,
|
||||
const IdentityAddress &participantAddress
|
||||
) const {
|
||||
|
|
@ -147,7 +145,7 @@ shared_ptr<ChatRoom> Core::findOneToOneChatRoom (
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
shared_ptr<ChatRoom> Core::createClientGroupChatRoom (const string &subject) {
|
||||
shared_ptr<AbstractChatRoom> Core::createClientGroupChatRoom (const string &subject) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(
|
||||
_linphone_client_group_chat_room_new(
|
||||
getCCore(),
|
||||
|
|
@ -157,10 +155,10 @@ shared_ptr<ChatRoom> Core::createClientGroupChatRoom (const string &subject) {
|
|||
);
|
||||
}
|
||||
|
||||
shared_ptr<ChatRoom> Core::getOrCreateBasicChatRoom (const ChatRoomId &chatRoomId, bool isRtt) {
|
||||
shared_ptr<AbstractChatRoom> Core::getOrCreateBasicChatRoom (const ChatRoomId &chatRoomId, bool isRtt) {
|
||||
L_D();
|
||||
|
||||
shared_ptr<ChatRoom> chatRoom = findChatRoom(chatRoomId);
|
||||
shared_ptr<AbstractChatRoom> chatRoom = findChatRoom(chatRoomId);
|
||||
if (chatRoom)
|
||||
return chatRoom;
|
||||
|
||||
|
|
@ -171,14 +169,14 @@ shared_ptr<ChatRoom> Core::getOrCreateBasicChatRoom (const ChatRoomId &chatRoomI
|
|||
return chatRoom;
|
||||
}
|
||||
|
||||
shared_ptr<ChatRoom> Core::getOrCreateBasicChatRoom (const IdentityAddress &peerAddress, bool isRtt) {
|
||||
shared_ptr<AbstractChatRoom> Core::getOrCreateBasicChatRoom (const IdentityAddress &peerAddress, bool isRtt) {
|
||||
L_D();
|
||||
|
||||
list<shared_ptr<ChatRoom>> chatRooms = findChatRooms(peerAddress);
|
||||
list<shared_ptr<AbstractChatRoom>> chatRooms = findChatRooms(peerAddress);
|
||||
if (!chatRooms.empty())
|
||||
return chatRooms.front();
|
||||
|
||||
shared_ptr<ChatRoom> chatRoom = d->createBasicChatRoom(
|
||||
shared_ptr<AbstractChatRoom> chatRoom = d->createBasicChatRoom(
|
||||
ChatRoomId(peerAddress, getDefaultLocalAddress(getSharedFromThis(), peerAddress)),
|
||||
isRtt
|
||||
);
|
||||
|
|
@ -188,19 +186,19 @@ shared_ptr<ChatRoom> Core::getOrCreateBasicChatRoom (const IdentityAddress &peer
|
|||
return chatRoom;
|
||||
}
|
||||
|
||||
shared_ptr<ChatRoom> Core::getOrCreateBasicChatRoomFromUri (const string &peerAddress, bool isRtt) {
|
||||
shared_ptr<AbstractChatRoom> Core::getOrCreateBasicChatRoomFromUri (const string &peerAddress, bool isRtt) {
|
||||
LinphoneAddress *address = linphone_core_interpret_url(getCCore(), L_STRING_TO_C(peerAddress));
|
||||
if (!address) {
|
||||
lError() << "Cannot make a valid address with: `" << peerAddress << "`.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
shared_ptr<ChatRoom> chatRoom = getOrCreateBasicChatRoom(*L_GET_CPP_PTR_FROM_C_OBJECT(address), isRtt);
|
||||
shared_ptr<AbstractChatRoom> chatRoom = getOrCreateBasicChatRoom(*L_GET_CPP_PTR_FROM_C_OBJECT(address), isRtt);
|
||||
linphone_address_unref(address);
|
||||
return chatRoom;
|
||||
}
|
||||
|
||||
void Core::deleteChatRoom (const shared_ptr<const ChatRoom> &chatRoom) {
|
||||
void Core::deleteChatRoom (const shared_ptr<const AbstractChatRoom> &chatRoom) {
|
||||
CorePrivate *d = chatRoom->getCore()->getPrivate();
|
||||
|
||||
const ChatRoomId &chatRoomId = chatRoom->getChatRoomId();
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@ public:
|
|||
void setCurrentCall (const std::shared_ptr<Call> &call) { currentCall = call; }
|
||||
void unsetVideoWindowId (bool preview, void *id);
|
||||
|
||||
void insertChatRoom (const std::shared_ptr<ChatRoom> &chatRoom);
|
||||
void insertChatRoomWithDb (const std::shared_ptr<ChatRoom> &chatRoom);
|
||||
std::shared_ptr<ChatRoom> createBasicChatRoom (const ChatRoomId &chatRoomId, bool isRtt, bool notifyCreation = true);
|
||||
void insertChatRoom (const std::shared_ptr<AbstractChatRoom> &chatRoom);
|
||||
void insertChatRoomWithDb (const std::shared_ptr<AbstractChatRoom> &chatRoom);
|
||||
std::shared_ptr<AbstractChatRoom> createBasicChatRoom (const ChatRoomId &chatRoomId, bool isRtt);
|
||||
|
||||
std::unique_ptr<MainDb> mainDb;
|
||||
|
||||
|
|
@ -64,8 +64,8 @@ private:
|
|||
std::list<std::shared_ptr<Call>> calls;
|
||||
std::shared_ptr<Call> currentCall;
|
||||
|
||||
std::list<std::shared_ptr<ChatRoom>> chatRooms;
|
||||
std::unordered_map<ChatRoomId, std::shared_ptr<ChatRoom>> chatRoomsById;
|
||||
std::list<std::shared_ptr<AbstractChatRoom>> chatRooms;
|
||||
std::unordered_map<ChatRoomId, std::shared_ptr<AbstractChatRoom>> chatRoomsById;
|
||||
|
||||
L_DECLARE_PUBLIC(Core);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ LINPHONE_BEGIN_NAMESPACE
|
|||
|
||||
class Address;
|
||||
class Call;
|
||||
class ChatRoom;
|
||||
class ChatRoomId;
|
||||
class CorePrivate;
|
||||
class IdentityAddress;
|
||||
class AbstractChatRoom;
|
||||
|
||||
class LINPHONE_PUBLIC Core : public Object {
|
||||
friend class CallPrivate;
|
||||
|
|
@ -86,25 +86,28 @@ public:
|
|||
// ChatRoom.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const std::list<std::shared_ptr<ChatRoom>> &getChatRooms () const;
|
||||
const std::list<std::shared_ptr<AbstractChatRoom>> &getChatRooms () const;
|
||||
|
||||
std::shared_ptr<ChatRoom> findChatRoom (const ChatRoomId &chatRoomId) const;
|
||||
std::list<std::shared_ptr<ChatRoom>> findChatRooms (const IdentityAddress &peerAddress) const;
|
||||
std::shared_ptr<AbstractChatRoom> findChatRoom (const ChatRoomId &chatRoomId) const;
|
||||
std::list<std::shared_ptr<AbstractChatRoom>> findChatRooms (const IdentityAddress &peerAddress) const;
|
||||
|
||||
std::shared_ptr<ChatRoom> findOneToOneChatRoom (
|
||||
std::shared_ptr<AbstractChatRoom> findOneToOneChatRoom (
|
||||
const IdentityAddress &localAddress,
|
||||
const IdentityAddress &participantAddress
|
||||
) const;
|
||||
|
||||
std::shared_ptr<ChatRoom> createClientGroupChatRoom (const std::string &subject);
|
||||
std::shared_ptr<ChatRoom> createClientGroupChatRoom (const std::string &subject, const IdentityAddress &localAddress);
|
||||
std::shared_ptr<AbstractChatRoom> createClientGroupChatRoom (const std::string &subject);
|
||||
std::shared_ptr<AbstractChatRoom> createClientGroupChatRoom (
|
||||
const std::string &subject,
|
||||
const IdentityAddress &localAddress
|
||||
);
|
||||
|
||||
std::shared_ptr<ChatRoom> getOrCreateBasicChatRoom (const ChatRoomId &chatRoomId, bool isRtt = false);
|
||||
std::shared_ptr<ChatRoom> getOrCreateBasicChatRoom (const IdentityAddress &peerAddress, bool isRtt = false);
|
||||
std::shared_ptr<AbstractChatRoom> getOrCreateBasicChatRoom (const ChatRoomId &chatRoomId, bool isRtt = false);
|
||||
std::shared_ptr<AbstractChatRoom> getOrCreateBasicChatRoom (const IdentityAddress &peerAddress, bool isRtt = false);
|
||||
|
||||
std::shared_ptr<ChatRoom> getOrCreateBasicChatRoomFromUri (const std::string &uri, bool isRtt = false);
|
||||
std::shared_ptr<AbstractChatRoom> getOrCreateBasicChatRoomFromUri (const std::string &uri, bool isRtt = false);
|
||||
|
||||
static void deleteChatRoom (const std::shared_ptr<const ChatRoom> &chatRoom);
|
||||
static void deleteChatRoom (const std::shared_ptr<const AbstractChatRoom> &chatRoom);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Paths.
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ private:
|
|||
long long localSipAddressId,
|
||||
const tm &creationTime
|
||||
);
|
||||
long long insertChatRoom (const std::shared_ptr<ChatRoom> &chatRoom);
|
||||
long long insertChatRoom (const std::shared_ptr<AbstractChatRoom> &chatRoom);
|
||||
long long insertChatRoomParticipant (long long chatRoomId, long long participantSipAddressId, bool isAdmin);
|
||||
void insertChatRoomParticipantDevice (long long participantId, long long participantDeviceSipAddressId);
|
||||
void insertChatMessageParticipant (long long messageEventId, long long sipAddressId, int state);
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ static inline string blobToString (soci::blob &in) {
|
|||
return q->getLastInsertId();
|
||||
}
|
||||
|
||||
long long MainDbPrivate::insertChatRoom (const shared_ptr<ChatRoom> &chatRoom) {
|
||||
long long MainDbPrivate::insertChatRoom (const shared_ptr<AbstractChatRoom> &chatRoom) {
|
||||
L_Q();
|
||||
|
||||
soci::session *session = dbSession.getBackendSession<soci::session>();
|
||||
|
|
@ -501,7 +501,7 @@ static inline string blobToString (soci::blob &in) {
|
|||
L_Q();
|
||||
|
||||
shared_ptr<Core> core = q->getCore();
|
||||
shared_ptr<ChatRoom> chatRoom = core->findChatRoom(chatRoomId);
|
||||
shared_ptr<AbstractChatRoom> chatRoom = core->findChatRoom(chatRoomId);
|
||||
if (!chatRoom) {
|
||||
lError() << "Unable to find chat room storage id of (peer=" +
|
||||
chatRoomId.getPeerAddress().asString() +
|
||||
|
|
@ -756,7 +756,7 @@ static inline string blobToString (soci::blob &in) {
|
|||
|
||||
long long MainDbPrivate::insertConferenceChatMessageEvent (const shared_ptr<EventLog> &eventLog) {
|
||||
shared_ptr<ChatMessage> chatMessage = static_pointer_cast<ConferenceChatMessageEvent>(eventLog)->getChatMessage();
|
||||
shared_ptr<ChatRoom> chatRoom = chatMessage->getChatRoom();
|
||||
shared_ptr<AbstractChatRoom> chatRoom = chatMessage->getChatRoom();
|
||||
if (!chatRoom) {
|
||||
lError() << "Unable to get a valid chat room. It was removed from database.";
|
||||
return -1;
|
||||
|
|
@ -794,7 +794,7 @@ static inline string blobToString (soci::blob &in) {
|
|||
|
||||
void MainDbPrivate::updateConferenceChatMessageEvent (const shared_ptr<EventLog> &eventLog) {
|
||||
shared_ptr<ChatMessage> chatMessage = static_pointer_cast<ConferenceChatMessageEvent>(eventLog)->getChatMessage();
|
||||
shared_ptr<ChatRoom> chatRoom = chatMessage->getChatRoom();
|
||||
shared_ptr<AbstractChatRoom> chatRoom = chatMessage->getChatRoom();
|
||||
if (!chatRoom) {
|
||||
lError() << "Unable to get a valid chat room. It was removed from database.";
|
||||
return;
|
||||
|
|
@ -1972,7 +1972,7 @@ static inline string blobToString (soci::blob &in) {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
list<shared_ptr<ChatRoom>> MainDb::getChatRooms () const {
|
||||
list<shared_ptr<AbstractChatRoom>> MainDb::getChatRooms () const {
|
||||
static const string query = "SELECT chat_room.id, peer_sip_address.value, local_sip_address.value, "
|
||||
"creation_time, last_update_time, capabilities, subject, last_notify_id, flags"
|
||||
" FROM chat_room, sip_address AS peer_sip_address, sip_address AS local_sip_address"
|
||||
|
|
@ -1981,7 +1981,7 @@ static inline string blobToString (soci::blob &in) {
|
|||
|
||||
L_D();
|
||||
|
||||
list<shared_ptr<ChatRoom>> chatRooms;
|
||||
list<shared_ptr<AbstractChatRoom>> chatRooms;
|
||||
|
||||
if (!isConnected()) {
|
||||
lWarning() << "Unable to get chat rooms. Not connected.";
|
||||
|
|
@ -2002,7 +2002,7 @@ static inline string blobToString (soci::blob &in) {
|
|||
IdentityAddress(row.get<string>(1)),
|
||||
IdentityAddress(row.get<string>(2))
|
||||
);
|
||||
shared_ptr<ChatRoom> chatRoom = core->findChatRoom(chatRoomId);
|
||||
shared_ptr<AbstractChatRoom> chatRoom = core->findChatRoom(chatRoomId);
|
||||
if (chatRoom) {
|
||||
chatRooms.push_back(chatRoom);
|
||||
continue;
|
||||
|
|
@ -2019,8 +2019,7 @@ static inline string blobToString (soci::blob &in) {
|
|||
if (capabilities & static_cast<int>(ChatRoom::Capabilities::Basic)) {
|
||||
chatRoom = core->getPrivate()->createBasicChatRoom(
|
||||
chatRoomId,
|
||||
capabilities & static_cast<int>(ChatRoom::Capabilities::RealTimeText),
|
||||
false
|
||||
capabilities & static_cast<int>(ChatRoom::Capabilities::RealTimeText)
|
||||
);
|
||||
chatRoom->setSubject(subject);
|
||||
} else if (capabilities & static_cast<int>(ChatRoom::Capabilities::Conference)) {
|
||||
|
|
@ -2081,9 +2080,9 @@ static inline string blobToString (soci::blob &in) {
|
|||
if (!chatRoom)
|
||||
continue; // Not fetched.
|
||||
|
||||
ChatRoomPrivate *dChatRoom = chatRoom->getPrivate();
|
||||
dChatRoom->creationTime = Utils::getTmAsTimeT(creationTime);
|
||||
dChatRoom->lastUpdateTime = Utils::getTmAsTimeT(lastUpdateTime);
|
||||
AbstractChatRoomPrivate *dChatRoom = chatRoom->getPrivate();
|
||||
dChatRoom->setCreationTime(Utils::getTmAsTimeT(creationTime));
|
||||
dChatRoom->setLastUpdateTime(Utils::getTmAsTimeT(lastUpdateTime));
|
||||
|
||||
lInfo() << "Found chat room in DB: (peer=" <<
|
||||
chatRoomId.getPeerAddress().asString() << ", local=" << chatRoomId.getLocalAddress().asString() << ").";
|
||||
|
|
@ -2096,10 +2095,10 @@ static inline string blobToString (soci::blob &in) {
|
|||
L_END_LOG_EXCEPTION
|
||||
|
||||
// Error.
|
||||
return list<shared_ptr<ChatRoom>>();
|
||||
return list<shared_ptr<AbstractChatRoom>>();
|
||||
}
|
||||
|
||||
void MainDb::insertChatRoom (const shared_ptr<ChatRoom> &chatRoom) {
|
||||
void MainDb::insertChatRoom (const shared_ptr<AbstractChatRoom> &chatRoom) {
|
||||
L_D();
|
||||
|
||||
if (!isConnected()) {
|
||||
|
|
@ -2379,11 +2378,11 @@ static inline string blobToString (soci::blob &in) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
list<shared_ptr<ChatRoom>> MainDb::getChatRooms () const {
|
||||
return list<shared_ptr<ChatRoom>>();
|
||||
list<shared_ptr<AbstractChatRoom>> MainDb::getChatRooms () const {
|
||||
return list<shared_ptr<AbstractChatRoom>>();
|
||||
}
|
||||
|
||||
void MainDb::insertChatRoom (const shared_ptr<ChatRoom> &) {}
|
||||
void MainDb::insertChatRoom (const shared_ptr<AbstractChatRoom> &) {}
|
||||
|
||||
void MainDb::deleteChatRoom (const ChatRoomId &) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@
|
|||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class AbstractChatRoom;
|
||||
class ChatMessage;
|
||||
class ChatRoom;
|
||||
class Core;
|
||||
class EventLog;
|
||||
class MainDbKey;
|
||||
|
|
@ -113,8 +113,8 @@ public:
|
|||
// Chat rooms.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
std::list<std::shared_ptr<ChatRoom>> getChatRooms () const;
|
||||
void insertChatRoom (const std::shared_ptr<ChatRoom> &chatRoom);
|
||||
std::list<std::shared_ptr<AbstractChatRoom>> getChatRooms () const;
|
||||
void insertChatRoom (const std::shared_ptr<AbstractChatRoom> &chatRoom);
|
||||
void deleteChatRoom (const ChatRoomId &chatRoomId);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -396,9 +396,9 @@ static void cpim_chat_message_modifier_base(bool_t use_multipart) {
|
|||
lp_config_set_int(config, "sip", "use_cpim", 1);
|
||||
|
||||
IdentityAddress paulineAddress(linphone_address_as_string_uri_only(pauline->identity));
|
||||
shared_ptr<ChatRoom> marieRoom = marie->lc->cppPtr->getOrCreateBasicChatRoom(paulineAddress);
|
||||
shared_ptr<AbstractChatRoom> marieRoom = marie->lc->cppPtr->getOrCreateBasicChatRoom(paulineAddress);
|
||||
|
||||
shared_ptr<ChatMessage> marieMessage = marieRoom->createMessage("Hello CPIM");
|
||||
shared_ptr<ChatMessage> marieMessage = marieRoom->createChatMessage("Hello CPIM");
|
||||
if (use_multipart) {
|
||||
Content *content = new Content();
|
||||
content->setContentType(ContentType::PlainText);
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ static void chat_message_multipart_modifier_base(bool first_file_transfer, bool
|
|||
LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_tcp_rc");
|
||||
|
||||
IdentityAddress paulineAddress(linphone_address_as_string_uri_only(pauline->identity));
|
||||
shared_ptr<ChatRoom> marieRoom = pauline->lc->cppPtr->getOrCreateBasicChatRoom(paulineAddress);
|
||||
shared_ptr<AbstractChatRoom> marieRoom = pauline->lc->cppPtr->getOrCreateBasicChatRoom(paulineAddress);
|
||||
|
||||
shared_ptr<ChatMessage> marieMessage = marieRoom->createMessage();
|
||||
shared_ptr<ChatMessage> marieMessage = marieRoom->createChatMessage();
|
||||
if (first_file_transfer) {
|
||||
char *send_filepath = bc_tester_res("sounds/sintel_trailer_opus_h264.mkv");
|
||||
FileContent *content = new FileContent();
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ blacklisted_functions = [
|
|||
'linphone_chat_message_start_file_download', # callback function in parameter
|
||||
'linphone_chat_message_state_to_string', # There is no use to wrap this function
|
||||
'linphone_chat_room_send_chat_message', # Use linphone_chat_room_send_chat_message_2 instead
|
||||
'linphone_chat_room_send_message2', # callback function in parameter
|
||||
'linphone_config_get_range', # to be handwritten because of result via arguments
|
||||
'linphone_config_load_dict_to_section', # missing LinphoneDictionary
|
||||
'linphone_config_section_to_dict', # missing LinphoneDictionary
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue