From 5c7fe8a92b57883b89f5dd4940090a4b12ac36b0 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 23 Nov 2017 11:32:05 +0100 Subject: [PATCH] feat(MainDb): supports fetching of client group chat room --- src/chat/chat-room/client-group-chat-room.cpp | 26 +++++++++++++++---- src/chat/chat-room/client-group-chat-room.h | 6 +++++ src/conference/conference-p.h | 13 +++++----- src/db/main-db.cpp | 19 +++++--------- 4 files changed, 40 insertions(+), 24 deletions(-) diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index 501beb279..a30efac9c 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -84,10 +84,10 @@ void ClientGroupChatRoomPrivate::onChatMessageReceived (const shared_ptr &core, - const std::string &factoryUri, + const shared_ptr &core, + const string &factoryUri, const IdentityAddress &me, - const std::string &subject + const string &subject ) : ChatRoom(*new ClientGroupChatRoomPrivate, core, ChatRoomId(IdentityAddress(), me)), RemoteConference(core, me, nullptr) { L_D_T(RemoteConference, dConference); @@ -95,6 +95,21 @@ RemoteConference(core, me, nullptr) { RemoteConference::setSubject(subject); } +ClientGroupChatRoom::ClientGroupChatRoom ( + const shared_ptr &core, + const ChatRoomId &chatRoomId, + const string &subject +) : ChatRoom(*new ClientGroupChatRoomPrivate, core, chatRoomId), +RemoteConference(core, chatRoomId.getLocalAddress(), nullptr) { + L_D(); + L_D_T(RemoteConference, dConference); + const IdentityAddress &peerAddress = chatRoomId.getPeerAddress(); + dConference->focus = make_shared(peerAddress); + dConference->conferenceAddress = peerAddress; + dConference->subject = subject; + d->state = ChatRoom::State::Created; +} + shared_ptr ClientGroupChatRoom::getCore () const { return ChatRoom::getCore(); } @@ -268,6 +283,7 @@ void ClientGroupChatRoom::onConferenceCreated (const IdentityAddress &addr) { L_D(); L_D_T(RemoteConference, dConference); dConference->conferenceAddress = addr; + dConference->focus = make_shared(addr); d->chatRoomId = ChatRoomId(addr, d->chatRoomId.getLocalAddress()); getCore()->getPrivate()->insertChatRoom(getSharedFromThis()); } @@ -432,7 +448,7 @@ void ClientGroupChatRoom::onParticipantDeviceRemoved (const shared_ptr &session) { +void ClientGroupChatRoom::onCallSessionSetReleased (const shared_ptr &session) { L_D_T(RemoteConference, dConference); ParticipantPrivate *participantPrivate = dConference->focus->getPrivate(); @@ -441,7 +457,7 @@ void ClientGroupChatRoom::onCallSessionSetReleased (const std::shared_ptr &session, + const shared_ptr &session, LinphoneCallState state, const string &message ) { diff --git a/src/chat/chat-room/client-group-chat-room.h b/src/chat/chat-room/client-group-chat-room.h index 8efa00801..a8e569945 100644 --- a/src/chat/chat-room/client-group-chat-room.h +++ b/src/chat/chat-room/client-group-chat-room.h @@ -39,6 +39,12 @@ public: const std::string &subject ); + ClientGroupChatRoom ( + const std::shared_ptr &core, + const ChatRoomId &chatRoomId, + const std::string &subject + ); + std::shared_ptr getCore () const; CapabilitiesMask getCapabilities () const override; diff --git a/src/conference/conference-p.h b/src/conference/conference-p.h index 1a163cf34..f738da3a5 100644 --- a/src/conference/conference-p.h +++ b/src/conference/conference-p.h @@ -34,17 +34,18 @@ class ConferencePrivate { public: IdentityAddress conferenceAddress; std::list> participants; - -protected: - CallListener *callListener = nullptr; - - std::shared_ptr activeParticipant; - std::shared_ptr me; std::string subject; +protected: Conference *mPublic = nullptr; + std::shared_ptr activeParticipant; + private: + CallListener *callListener = nullptr; + + std::shared_ptr me; + L_DECLARE_PUBLIC(Conference); }; diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index 76af6928e..09dbad22b 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -1398,23 +1398,16 @@ MainDb::MainDb (const shared_ptr &core) : AbstractDb(*new MainDbPrivate), capabilities & static_cast(ChatRoom::Capabilities::RealTimeText) ); chatRoom->setSubject(subject); - - ChatRoomPrivate *dChatRoom = chatRoom->getPrivate(); - dChatRoom->creationTime = Utils::getTmAsTimeT(creationDate); - dChatRoom->lastUpdateTime = Utils::getTmAsTimeT(lastUpdateDate); - } else if (capabilities & static_cast(ChatRoom::Capabilities::Conference)) { - // TODO: Fetch! - // chatRoom = make_shared( - // getCore(), - // Address("sip:titi@sip.linphone.org"), // TODO: Fix me!!! - // chatRoomId, - // subject - // ); - } + } else if (capabilities & static_cast(ChatRoom::Capabilities::Conference)) + chatRoom = make_shared(core, chatRoomId, subject); if (!chatRoom) continue; // Not fetched. + ChatRoomPrivate *dChatRoom = chatRoom->getPrivate(); + dChatRoom->creationTime = Utils::getTmAsTimeT(creationDate); + dChatRoom->lastUpdateTime = Utils::getTmAsTimeT(lastUpdateDate); + chatRooms.push_back(chatRoom); }