From 05271e86030d983354bd559bd846a7f3f0e03926 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 4 Dec 2017 15:11:54 +0100 Subject: [PATCH] Change the state of ClientGroupChatRoom and ServerGroupChatRoom outside of their constructors. --- src/chat/chat-room/client-group-chat-room.cpp | 6 +----- src/chat/chat-room/client-group-chat-room.h | 3 +-- src/db/main-db.cpp | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index bb72ded64..3ce328667 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -103,11 +103,9 @@ ClientGroupChatRoom::ClientGroupChatRoom ( shared_ptr &me, const string &subject, list> &&participants, - unsigned int lastNotifyId, - bool hasBeenLeft + unsigned int lastNotifyId ) : ChatRoom(*new ClientGroupChatRoomPrivate, core, ChatRoomId(peerAddress, me->getAddress())), RemoteConference(core, me->getAddress(), nullptr) { - L_D(); L_D_T(RemoteConference, dConference); dConference->focus = make_shared(peerAddress); @@ -115,8 +113,6 @@ RemoteConference(core, me->getAddress(), nullptr) { dConference->subject = subject; dConference->participants = move(participants); - d->state = hasBeenLeft ? ChatRoom::State::Terminated : ChatRoom::State::Created; - getMe()->getPrivate()->setAdmin(me->isAdmin()); dConference->eventHandler->setLastNotify(lastNotifyId); diff --git a/src/chat/chat-room/client-group-chat-room.h b/src/chat/chat-room/client-group-chat-room.h index 05efc6ae7..41f201961 100644 --- a/src/chat/chat-room/client-group-chat-room.h +++ b/src/chat/chat-room/client-group-chat-room.h @@ -45,8 +45,7 @@ public: std::shared_ptr &me, const std::string &subject, std::list> &&participants, - unsigned int lastNotifyId, - bool hasBeenLeft + unsigned int lastNotifyId ); std::shared_ptr getCore () const; diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index 549c4ffa2..e316e7db2 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -1906,17 +1906,22 @@ MainDb::MainDb (const shared_ptr &core) : AbstractDb(*new MainDbPrivate), continue; } - if (!linphone_core_conference_server_enabled(core->getCCore())) + if (!linphone_core_conference_server_enabled(core->getCCore())) { + bool hasBeenLeft = !!row.get(8, 0); chatRoom = make_shared( core, chatRoomId.getPeerAddress(), me, subject, move(participants), - lastNotifyId, - !!row.get(8, 0) + lastNotifyId ); - else + chatRoom->getPrivate()->setState(LinphonePrivate::ChatRoom::State::Instantiated); + chatRoom->getPrivate()->setState(hasBeenLeft + ? ChatRoom::State::Terminated + : ChatRoom::State::Created + ); + } else { chatRoom = make_shared( core, chatRoomId.getPeerAddress(), @@ -1924,6 +1929,9 @@ MainDb::MainDb (const shared_ptr &core) : AbstractDb(*new MainDbPrivate), move(participants), lastNotifyId ); + chatRoom->getPrivate()->setState(LinphonePrivate::ChatRoom::State::Instantiated); + chatRoom->getPrivate()->setState(LinphonePrivate::ChatRoom::State::Created); + } } if (!chatRoom)