diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index 54160d720..dbb526e49 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -100,7 +100,8 @@ RemoteConference(core, me, nullptr) { ClientGroupChatRoom::ClientGroupChatRoom ( const shared_ptr &core, const ChatRoomId &chatRoomId, - const string &subject + const string &subject, + list> &&participants ) : ChatRoom(*new ClientGroupChatRoomPrivate, core, chatRoomId), RemoteConference(core, chatRoomId.getLocalAddress(), nullptr) { L_D(); @@ -109,6 +110,7 @@ RemoteConference(core, chatRoomId.getLocalAddress(), nullptr) { dConference->focus = make_shared(peerAddress); dConference->conferenceAddress = peerAddress; dConference->subject = subject; + dConference->participants = move(participants); d->state = ChatRoom::State::Created; } diff --git a/src/chat/chat-room/client-group-chat-room.h b/src/chat/chat-room/client-group-chat-room.h index a8e569945..c0b240538 100644 --- a/src/chat/chat-room/client-group-chat-room.h +++ b/src/chat/chat-room/client-group-chat-room.h @@ -42,7 +42,8 @@ public: ClientGroupChatRoom ( const std::shared_ptr &core, const ChatRoomId &chatRoomId, - const std::string &subject + const std::string &subject, + std::list> &&participants ); std::shared_ptr getCore () const; diff --git a/src/conference/participant.h b/src/conference/participant.h index f80bb77a0..4dd008c3c 100644 --- a/src/conference/participant.h +++ b/src/conference/participant.h @@ -43,6 +43,7 @@ class Participant : public Object { friend class LocalConference; friend class LocalConferenceEventHandler; friend class LocalConferenceEventHandlerPrivate; + friend class MainDb; friend class MediaSessionPrivate; friend class RemoteConference; friend class ServerGroupChatRoom; diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index 7c537f0b5..b30a24bf7 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -27,9 +27,9 @@ #include "linphone/utils/utils.h" #include "chat/chat-message/chat-message-p.h" -#include "chat/chat-room/client-group-chat-room.h" #include "chat/chat-room/chat-room-p.h" -#include "conference/participant.h" +#include "chat/chat-room/client-group-chat-room.h" +#include "conference/participant-p.h" #include "content/content-type.h" #include "content/content.h" #include "core/core-p.h" @@ -1553,8 +1553,22 @@ MainDb::MainDb (const shared_ptr &core) : AbstractDb(*new MainDbPrivate), ); chatRoom->setSubject(subject); } else if (capabilities & static_cast(ChatRoom::Capabilities::Conference)) { + list> participants; - chatRoom = make_shared(core, chatRoomId, subject); + string query = "SELECT sip_address.value, is_admin" + " FROM sip_address, chat_room, chat_room_participant" + " WHERE chat_room.id = :chatRoomId" + " AND sip_address.id = chat_room_participant.participant_sip_address_id" + " AND chat_room_participant.chat_room_id = chat_room.id"; + + soci::rowset rows = (session->prepare << query); + for (const auto &row : rows) { + shared_ptr participant = make_shared(IdentityAddress(row.get(0))); + participant->getPrivate()->setAdmin(!!row.get(1)); + participants.push_back(participant); + } + + chatRoom = make_shared(core, chatRoomId, subject, move(participants)); } if (!chatRoom)