From a30050c8bdf0d1a4480344bba9d387be75a85aa8 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 9 Nov 2017 17:30:27 +0100 Subject: [PATCH] Correct handling of client group chat room joining after it has been left. --- coreapi/callbacks.c | 4 +++- src/chat/chat-room/client-group-chat-room.cpp | 8 +++++--- src/conference/remote-conference-event-handler.cpp | 5 +++++ src/conference/remote-conference-event-handler.h | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 1ec25c68a..b08409a4e 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -797,7 +797,9 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){ return; } } else { - LinphoneChatRoom *cr = _linphone_client_group_chat_room_new(lc, addr.asString().c_str(), nullptr); + LinphoneChatRoom *cr = L_GET_C_BACK_PTR(lc->cppCore->findChatRoom(addr)); + if (!cr) + cr = _linphone_client_group_chat_room_new(lc, addr.asString().c_str(), nullptr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->join(); /* The following causes a crash because chat room hasn't yet a peer address. The above call to join() will create a CallSession which will call onConferenceCreated when it'll reach the Connected state. diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index 75e4eb03e..9c1ba2eb5 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -163,7 +163,7 @@ void ClientGroupChatRoom::join () { L_D_T(RemoteConference, dConference); shared_ptr session = dConference->focus->getPrivate()->getSession(); - if (!session && d->state == ChatRoom::State::Instantiated) { + if (!session && ((d->state == ChatRoom::State::Instantiated) || (d->state == ChatRoom::State::Terminated))) { session = d->createSession(); session->startInvite(nullptr, "", nullptr); d->setState(ChatRoom::State::CreationPending); @@ -266,6 +266,8 @@ void ClientGroupChatRoom::onConferenceCreated (const Address &addr) { void ClientGroupChatRoom::onConferenceTerminated (const Address &addr) { L_D(); + L_D_T(RemoteConference, dConference); + dConference->eventHandler->resetLastNotify(); d->setState(ChatRoom::State::Terminated); } @@ -446,9 +448,9 @@ void ClientGroupChatRoom::onCallSessionStateChanged ( dConference->eventHandler->subscribe(getConferenceAddress()); } else if (d->state == ChatRoom::State::TerminationPending) dConference->focus->getPrivate()->getSession()->terminate(); - } else if (state == LinphoneCallReleased && d->state == ChatRoom::State::TerminationPending) { + } else if ((state == LinphoneCallReleased) && (d->state == ChatRoom::State::TerminationPending)) { onConferenceTerminated(getConferenceAddress()); - } else if (state == LinphoneCallError && d->state == ChatRoom::State::CreationPending) { + } else if ((state == LinphoneCallError) && (d->state == ChatRoom::State::CreationPending)) { d->setState(ChatRoom::State::CreationFailed); } } diff --git a/src/conference/remote-conference-event-handler.cpp b/src/conference/remote-conference-event-handler.cpp index d3a8ae260..9daa6363b 100644 --- a/src/conference/remote-conference-event-handler.cpp +++ b/src/conference/remote-conference-event-handler.cpp @@ -207,4 +207,9 @@ unsigned int RemoteConferenceEventHandler::getLastNotify () const { return d->lastNotify; }; +void RemoteConferenceEventHandler::resetLastNotify () { + L_D(); + d->lastNotify = 0; +} + LINPHONE_END_NAMESPACE diff --git a/src/conference/remote-conference-event-handler.h b/src/conference/remote-conference-event-handler.h index b6cb6949f..2422fdb8d 100644 --- a/src/conference/remote-conference-event-handler.h +++ b/src/conference/remote-conference-event-handler.h @@ -40,6 +40,7 @@ class RemoteConferenceEventHandler : public Object { const Address &getConfAddress () const; unsigned int getLastNotify () const; + void resetLastNotify (); private: L_DECLARE_PRIVATE(RemoteConferenceEventHandler);