From 4cd5e7aeabef65ca9d20e6f168f8b346088b0a9a Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 8 Nov 2017 12:14:02 +0100 Subject: [PATCH] Change the state of the ClientGroupChatRoom to created only when the first NOTIFY has been received. --- src/chat/chat-room/client-group-chat-room.cpp | 8 ++++++-- src/chat/chat-room/client-group-chat-room.h | 1 + src/conference/conference-listener.h | 1 + src/conference/remote-conference-event-handler.cpp | 3 +++ src/conference/remote-conference.cpp | 2 ++ src/conference/remote-conference.h | 1 + tester/conference-event-tester.cpp | 3 +++ 7 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index 329ef2c8c..071e88193 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -254,8 +254,6 @@ void ClientGroupChatRoom::onConferenceCreated (const Address &addr) { dConference->conferenceAddress = addr; d->peerAddress = addr; CoreAccessor::getCore()->getPrivate()->insertChatRoom(getSharedFromThis()); - d->setState(ChatRoom::State::Created); - CoreAccessor::getCore()->getPrivate()->insertChatRoomWithDb(getSharedFromThis()); } void ClientGroupChatRoom::onConferenceTerminated (const Address &addr) { @@ -263,6 +261,12 @@ void ClientGroupChatRoom::onConferenceTerminated (const Address &addr) { d->setState(ChatRoom::State::Terminated); } +void ClientGroupChatRoom::onFirstNotifyReceived (const Address &addr) { + L_D(); + d->setState(ChatRoom::State::Created); + CoreAccessor::getCore()->getPrivate()->insertChatRoomWithDb(getSharedFromThis()); +} + void ClientGroupChatRoom::onParticipantAdded (const shared_ptr &event, bool isFullState) { L_D_T(RemoteConference, dConference); diff --git a/src/chat/chat-room/client-group-chat-room.h b/src/chat/chat-room/client-group-chat-room.h index d9a3f0dc4..9d1614ccf 100644 --- a/src/chat/chat-room/client-group-chat-room.h +++ b/src/chat/chat-room/client-group-chat-room.h @@ -64,6 +64,7 @@ private: /* ConferenceListener */ void onConferenceCreated (const Address &addr) override; void onConferenceTerminated (const Address &addr) override; + void onFirstNotifyReceived (const Address &addr) override; void onParticipantAdded (const std::shared_ptr &event, bool isFullState) override; void onParticipantRemoved (const std::shared_ptr &event, bool isFullState) override; void onParticipantSetAdmin (const std::shared_ptr &event, bool isFullState) override; diff --git a/src/conference/conference-listener.h b/src/conference/conference-listener.h index de5e4604c..b4946cd9d 100644 --- a/src/conference/conference-listener.h +++ b/src/conference/conference-listener.h @@ -37,6 +37,7 @@ class ConferenceListener { public: virtual void onConferenceCreated (const Address &addr) = 0; virtual void onConferenceTerminated (const Address &addr) = 0; + virtual void onFirstNotifyReceived (const Address &addr) = 0; virtual void onParticipantAdded (const std::shared_ptr &event, bool isFullState) = 0; virtual void onParticipantRemoved (const std::shared_ptr &event, bool isFullState) = 0; virtual void onParticipantSetAdmin (const std::shared_ptr &event, bool isFullState) = 0; diff --git a/src/conference/remote-conference-event-handler.cpp b/src/conference/remote-conference-event-handler.cpp index 7578c9b82..d3a8ae260 100644 --- a/src/conference/remote-conference-event-handler.cpp +++ b/src/conference/remote-conference-event-handler.cpp @@ -189,6 +189,9 @@ void RemoteConferenceEventHandler::notifyReceived (const string &xmlBody) { } linphone_address_unref(cAddr); } + + if (isFullState) + d->listener->onFirstNotifyReceived(d->confAddress); } } diff --git a/src/conference/remote-conference.cpp b/src/conference/remote-conference.cpp index 4ace4ee14..9386b93cd 100644 --- a/src/conference/remote-conference.cpp +++ b/src/conference/remote-conference.cpp @@ -89,6 +89,8 @@ void RemoteConference::onConferenceTerminated (const Address &addr) { d->eventHandler->unsubscribe(); } +void RemoteConference::onFirstNotifyReceived (const Address &addr) {} + void RemoteConference::onParticipantAdded (const std::shared_ptr &event, bool isFullState) { (void)event; // unused (void)isFullState; // unused diff --git a/src/conference/remote-conference.h b/src/conference/remote-conference.h index 0567160a2..bf630cfb1 100644 --- a/src/conference/remote-conference.h +++ b/src/conference/remote-conference.h @@ -46,6 +46,7 @@ protected: /* ConferenceListener */ void onConferenceCreated (const Address &addr) override; void onConferenceTerminated (const Address &addr) override; + void onFirstNotifyReceived (const Address &addr) override; void onParticipantAdded (const std::shared_ptr &event, bool isFullState) override; void onParticipantRemoved (const std::shared_ptr &event, bool isFullState) override; void onParticipantSetAdmin (const std::shared_ptr &event, bool isFullState) override; diff --git a/tester/conference-event-tester.cpp b/tester/conference-event-tester.cpp index 76fe22e6e..9152e1dac 100644 --- a/tester/conference-event-tester.cpp +++ b/tester/conference-event-tester.cpp @@ -447,6 +447,7 @@ public: private: void onConferenceCreated (const Address &addr) override; void onConferenceTerminated (const Address &addr) override; + void onFirstNotifyReceived (const Address &addr) override; void onParticipantAdded (const shared_ptr &event, bool isFullState) override; void onParticipantRemoved (const shared_ptr &event, bool isFullState) override; void onParticipantSetAdmin (const shared_ptr &event, bool isFullState) override; @@ -473,6 +474,8 @@ void ConferenceEventTester::onConferenceCreated (const Address &addr) {} void ConferenceEventTester::onConferenceTerminated (const Address &addr) {} +void ConferenceEventTester::onFirstNotifyReceived (const Address &addr) {} + void ConferenceEventTester::onParticipantAdded (const shared_ptr &event, bool isFullState) { (void)isFullState; // unused const Address addr = event->getParticipantAddress();