diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 420a1e99e7236cddf8a77aea980dd10e30fd5e1b..026b02f60d3613af8a2fef76a777967c41aa6bf7 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -9301,8 +9301,13 @@ static int _linphone_core_delayed_conference_destruction_cb(void *user_data, BCT static void _linphone_core_conference_state_changed(LinphoneConference *conf, LinphoneConferenceState cstate) { if (cstate == LinphoneConferenceStateDeleted) { LinphoneCore *lc = linphone_conference_get_core(conf); - linphone_core_queue_task(lc, _linphone_core_delayed_conference_destruction_cb, conf, - "Conference destruction task"); + if (linphone_core_get_global_state(lc) == LinphoneGlobalShutdown) { + // If the core is in the Shutdown state, there is no time to queue a task + linphone_conference_unref(conf); + } else { + linphone_core_queue_task(lc, _linphone_core_delayed_conference_destruction_cb, conf, + "Conference destruction task"); + } lc->conf_ctx = NULL; } } diff --git a/src/conference/client-conference.cpp b/src/conference/client-conference.cpp index 4f33d69ee62f07908464d020f2263dfbbfcff2d3..96e089cbd0bded4c24f262ec3beedb96e352935d 100644 --- a/src/conference/client-conference.cpp +++ b/src/conference/client-conference.cpp @@ -60,13 +60,15 @@ ClientConference::ClientConference(const shared_ptr<Core> &core, } ClientConference::~ClientConference() { - terminate(); + if (getState() != ConferenceInterface::State::Deleted) { + terminate(); + } if (mJoiningParams) { delete mJoiningParams; } #ifdef HAVE_ADVANCED_IM - eventHandler.reset(); + mEventHandler.reset(); #endif // HAVE_ADVANCED_IM } @@ -217,7 +219,7 @@ void ClientConference::init(SalCallOp *op, BCTBX_UNUSED(ConferenceListener *conf setConferenceAddress(conferenceAddress); } - if (focusSession || mConfParams->chatEnabled()) { + if (focusSession || isChatOnly()) { finalizeCreation(); } } @@ -228,15 +230,16 @@ void ClientConference::createEventHandler(BCTBX_UNUSED(ConferenceListener *confL bool eventLogEnabled = !!linphone_config_get_bool(linphone_core_get_config(getCore()->getCCore()), "misc", "conference_event_log_enabled", TRUE); if (eventLogEnabled) { - if (!eventHandler) { - eventHandler = std::make_shared<ClientConferenceEventHandler>(getCore(), getSharedFromThis(), confListener); + if (!mEventHandler) { + mEventHandler = + std::make_shared<ClientConferenceEventHandler>(getCore(), getSharedFromThis(), confListener); } if (addToListEventHandler) { - getCore()->getPrivate()->clientListEventHandler->addHandler(eventHandler); + getCore()->getPrivate()->clientListEventHandler->addHandler(mEventHandler); } const auto &conferenceId = getConferenceId(); if (conferenceId.isValid()) { - eventHandler->subscribe(conferenceId); + mEventHandler->subscribe(conferenceId); } } else { #endif // HAVE_ADVANCED_IM @@ -857,10 +860,10 @@ void ClientConference::onFocusCallStateChanged(CallSession::State state, BCTBX_U case CallSession::State::StreamsRunning: { #ifdef HAVE_ADVANCED_IM // Handle session reconnection if network dropped only for a short period of time - if (eventHandler && eventHandler->needToSubscribe()) { + if (mEventHandler && mEventHandler->needToSubscribe()) { const auto &conferenceId = getConferenceId(); if (conferenceId.isValid()) { - eventHandler->subscribe(conferenceId); + mEventHandler->subscribe(conferenceId); } } if (mClientEktManager) { @@ -1219,8 +1222,8 @@ void ClientConference::onStateChanged(ConferenceInterface::State state) { break; case ConferenceInterface::State::TerminationPending: #ifdef HAVE_ADVANCED_IM - if (eventHandler) { - eventHandler->unsubscribe(); + if (mEventHandler) { + mEventHandler->unsubscribe(); } #endif // HAVE_ADVANCED_IM resetLastNotify(); @@ -1233,8 +1236,10 @@ void ClientConference::onStateChanged(ConferenceInterface::State state) { } } if (mediaSupported) { - Conference::terminate(); - setState(ConferenceInterface::State::Terminated); + getCore()->doLater([this]() { + Conference::terminate(); + setState(ConferenceInterface::State::Terminated); + }); } break; case ConferenceInterface::State::Deleted: @@ -1587,13 +1592,13 @@ void ClientConference::onConferenceTerminated(BCTBX_UNUSED(const std::shared_ptr #ifdef HAVE_ADVANCED_IM auto chatRoom = getChatRoom(); if (mConfParams->chatEnabled() && chatRoom) { - if (eventHandler) { - eventHandler->unsubscribe(); + if (mEventHandler) { + mEventHandler->unsubscribe(); } resetLastNotify(); // remove event handler from list event handler if used if (getCore()->getPrivate()->clientListEventHandler) { - getCore()->getPrivate()->clientListEventHandler->removeHandler(eventHandler); + getCore()->getPrivate()->clientListEventHandler->removeHandler(mEventHandler); } // No need to notify such event during the core startup. @@ -1943,7 +1948,7 @@ bool ClientConference::isSubscriptionUnderWay() const { underWay = getCore()->getPrivate()->clientListEventHandler->getInitialSubscriptionUnderWayFlag(getConferenceId()); } else { - underWay = eventHandler ? eventHandler->getInitialSubscriptionUnderWayFlag() : false; + underWay = mEventHandler ? mEventHandler->getInitialSubscriptionUnderWayFlag() : false; } #endif // HAVE_ADVANCED_IM @@ -1956,12 +1961,12 @@ bool ClientConference::isSubscriptionUnderWay() const { #endif // _MSC_VER void ClientConference::multipartNotifyReceived(const std::shared_ptr<Event> ¬ifyLev, const Content &content) { #ifdef HAVE_ADVANCED_IM - if (eventHandler) { - const auto initialSubscription = eventHandler->getInitialSubscriptionUnderWayFlag(); - eventHandler->multipartNotifyReceived(notifyLev, content); + if (mEventHandler) { + const auto initialSubscription = mEventHandler->getInitialSubscriptionUnderWayFlag(); + mEventHandler->multipartNotifyReceived(notifyLev, content); const auto &chatRoom = getChatRoom(); if (mConfParams->chatEnabled() && chatRoom && initialSubscription && - !eventHandler->getInitialSubscriptionUnderWayFlag()) { + !mEventHandler->getInitialSubscriptionUnderWayFlag()) { chatRoom->sendPendingMessages(); } return; @@ -1988,12 +1993,12 @@ void ClientConference::notifyReceived(const std::shared_ptr<Event> ¬ifyLev, c return; } } else { - if (eventHandler) { - const auto initialSubscription = eventHandler->getInitialSubscriptionUnderWayFlag(); - eventHandler->notifyReceived(notifyLev, content); + if (mEventHandler) { + const auto initialSubscription = mEventHandler->getInitialSubscriptionUnderWayFlag(); + mEventHandler->notifyReceived(notifyLev, content); const auto &chatRoom = getChatRoom(); if (mConfParams->chatEnabled() && chatRoom && initialSubscription && - !eventHandler->getInitialSubscriptionUnderWayFlag()) { + !mEventHandler->getInitialSubscriptionUnderWayFlag()) { chatRoom->sendPendingMessages(); } return; @@ -2384,8 +2389,8 @@ void ClientConference::leave() { } #ifdef HAVE_ADVANCED_IM } else if (mConfParams->chatEnabled()) { - if (eventHandler) { - eventHandler->unsubscribe(); + if (mEventHandler) { + mEventHandler->unsubscribe(); } shared_ptr<CallSession> session = mFocus->getSession(); if (session) { @@ -2748,20 +2753,20 @@ void ClientConference::onCallSessionSetReleased(const shared_ptr<CallSession> &s void ClientConference::requestFullState() { #ifdef HAVE_ADVANCED_IM - eventHandler->requestFullState(); + mEventHandler->requestFullState(); #endif // HAVE_ADVANCED_IM } void ClientConference::subscribe(BCTBX_UNUSED(bool addToListEventHandler), BCTBX_UNUSED(bool unsubscribeFirst)) { #ifdef HAVE_ADVANCED_IM - if (eventHandler) { + if (mEventHandler) { if (unsubscribeFirst) { - eventHandler->unsubscribe(); // Required for next subscribe to be sent + mEventHandler->unsubscribe(); // Required for next subscribe to be sent } } else { initializeHandlers(this, addToListEventHandler); } - eventHandler->subscribe(getConferenceId()); + mEventHandler->subscribe(getConferenceId()); #endif // HAVE_ADVANCED_IM } diff --git a/src/conference/client-conference.h b/src/conference/client-conference.h index 4b336182a845f7ab864f639867fbbadac386e899..24285440ce926b595d27a41850a769f5073fd48d 100644 --- a/src/conference/client-conference.h +++ b/src/conference/client-conference.h @@ -161,7 +161,7 @@ public: virtual void onEphemeralLifetimeChanged(const std::shared_ptr<ConferenceEphemeralMessageEvent> &event) override; #ifdef HAVE_ADVANCED_IM - std::shared_ptr<ClientConferenceEventHandler> eventHandler; + std::shared_ptr<ClientConferenceEventHandler> mEventHandler; #endif // HAVE_ADVANCED_IM void requestFullState(); diff --git a/src/conference/server-conference.cpp b/src/conference/server-conference.cpp index 68489914b704a2c69bc452cd24e501f083bd9328..ff2e662fbe22e121b128985d009e39e4835c3d6b 100644 --- a/src/conference/server-conference.cpp +++ b/src/conference/server-conference.cpp @@ -183,12 +183,12 @@ void ServerConference::createEventHandler(BCTBX_UNUSED(ConferenceListener *confL bool eventLogEnabled = !!linphone_config_get_bool(linphone_core_get_config(lc), "misc", "conference_event_log_enabled", TRUE); if (eventLogEnabled) { - eventHandler = std::make_shared<ServerConferenceEventHandler>(getSharedFromThis(), confListener); + mEventHandler = std::make_shared<ServerConferenceEventHandler>(getSharedFromThis(), confListener); const auto chatEnabled = mConfParams->chatEnabled(); if (chatEnabled && getCore()->getPrivate()->serverListEventHandler && getConferenceId().isValid()) { - getCore()->getPrivate()->serverListEventHandler->addHandler(eventHandler); + getCore()->getPrivate()->serverListEventHandler->addHandler(mEventHandler); } - addListener(eventHandler); + addListener(mEventHandler); } else { #endif // HAVE_ADVANCED_IM lInfo() << "Unable to add listener to local conference as conference event package (RFC 4575) is disabled or " @@ -1010,7 +1010,7 @@ void ServerConference::finalizeCreation() { #ifdef HAVE_ADVANCED_IM if (chatRoom) { auto serverGroupChatRoom = dynamic_pointer_cast<ServerChatRoom>(chatRoom); - getCore()->getPrivate()->serverListEventHandler->addHandler(eventHandler); + getCore()->getPrivate()->serverListEventHandler->addHandler(mEventHandler); serverGroupChatRoom->setJoiningPendingAfterCreation(true); getCore()->getPrivate()->insertChatRoomWithDb(chatRoom); } @@ -1048,8 +1048,8 @@ void ServerConference::subscribeReceived(const shared_ptr<EventSubscribe> &event inviteDevice(device); } - if (eventHandler) { - if (eventHandler->subscribeReceived(event) == 0) { + if (mEventHandler) { + if (mEventHandler->subscribeReceived(event) == 0) { if (device && chatEnabled) { vector<string> acceptedContents = vector<string>(); const auto message = (belle_sip_message_t *)event->getOp()->getRecvCustomHeaders(); @@ -1094,8 +1094,8 @@ void ServerConference::subscribeReceived(const shared_ptr<EventSubscribe> &event #endif // _MSC_VER void ServerConference::subscriptionStateChanged(shared_ptr<EventSubscribe> event, LinphoneSubscriptionState state) { #ifdef HAVE_ADVANCED_IM - if (eventHandler) { - eventHandler->subscriptionStateChanged(event, state); + if (mEventHandler) { + mEventHandler->subscriptionStateChanged(event, state); } else { #endif // HAVE_ADVANCED_IM lInfo() << "Unable to handle subscription state change because conference event package (RFC 4575) is disabled " @@ -2528,7 +2528,7 @@ void ServerConference::cleanup() { try { #ifdef HAVE_ADVANCED_IM if (isChatOnly() && getCore()->getPrivate()->serverListEventHandler) { - getCore()->getPrivate()->serverListEventHandler->removeHandler(eventHandler); + getCore()->getPrivate()->serverListEventHandler->removeHandler(mEventHandler); } #endif // HAVE_ADVANCED_IM getCore()->getPrivate()->unregisterListener(this); @@ -2536,8 +2536,8 @@ void ServerConference::cleanup() { // Unable to unregister listener here. Core is destroyed and the listener doesn't exist. } #ifdef HAVE_ADVANCED_IM - if (eventHandler) { - eventHandler.reset(); + if (mEventHandler) { + mEventHandler.reset(); } #endif // HAVE_ADVANCED_IM } @@ -2870,17 +2870,20 @@ int ServerConference::terminate() { const auto zeroDevices = (noDevices == 0); if (zeroDevices #ifdef HAVE_ADVANCED_IM - || !eventHandler + || !mEventHandler #endif // HAVE_ADVANCED_IM ) { setState(ConferenceInterface::State::Terminated); } - // The server deletes the conference info once the conference is terminated. - // It avoids having a growing database on the server side - if (conferenceAddress && - (isConferenceEnded() || (linphone_core_get_global_state(getCore()->getCCore()) == LinphoneGlobalOn))) { - getCore()->getPrivate()->deleteConferenceInfo(conferenceAddress); + try { + // The server deletes the conference info once the conference is terminated. + // It avoids having a growing database on the server side + if (conferenceAddress && + (isConferenceEnded() || (linphone_core_get_global_state(getCore()->getCCore()) == LinphoneGlobalOn))) { + getCore()->getPrivate()->deleteConferenceInfo(conferenceAddress); + } + } catch (const bad_weak_ptr &) { } } else { setChatRoom(nullptr); diff --git a/src/conference/server-conference.h b/src/conference/server-conference.h index 01587ac409e7e95f36dee940275e72165bf59a16..333f75debc76c097bd7ce8d6bec7164711e4a495 100644 --- a/src/conference/server-conference.h +++ b/src/conference/server-conference.h @@ -199,10 +199,6 @@ public: virtual void setParticipantAdminStatus(const std::shared_ptr<Participant> &participant, bool isAdmin) override; - // TODO: move to private once server group chat room class has been deleted -#ifdef HAVE_ADVANCED_IM - std::shared_ptr<ServerConferenceEventHandler> eventHandler; -#endif // HAVE_ADVANCED_IM void moveDeviceToPresent(const std::shared_ptr<CallSession> &session); void moveDeviceToPresent(const std::shared_ptr<ParticipantDevice> &device); void setParticipantDeviceState(const std::shared_ptr<ParticipantDevice> &device, @@ -254,6 +250,9 @@ protected: private: L_DISABLE_COPY(ServerConference); +#ifdef HAVE_ADVANCED_IM + std::shared_ptr<ServerConferenceEventHandler> mEventHandler; +#endif // HAVE_ADVANCED_IM std::unique_ptr<MixerSession> mMixerSession; bool mIsIn = false; diff --git a/src/event/event-subscribe.cpp b/src/event/event-subscribe.cpp index 023de487df8ab56ee4aea236ad37f4964cd5a27b..71513d0ea142b291908493ff2f00f902bbd6c700 100644 --- a/src/event/event-subscribe.cpp +++ b/src/event/event-subscribe.cpp @@ -211,7 +211,10 @@ void EventSubscribe::setState(LinphoneSubscriptionState state) { << linphone_subscription_state_to_string(state); mSubscriptionState = state; ref(); - linphone_core_notify_subscription_state_changed(getCore()->getCCore(), this->toC(), state); + try { + linphone_core_notify_subscription_state_changed(getCore()->getCCore(), this->toC(), state); + } catch (const bad_weak_ptr &) { + } LINPHONE_HYBRID_OBJECT_INVOKE_CBS(Event, this, linphone_event_cbs_get_subscribe_state_changed, state); if (state == LinphoneSubscriptionTerminated || state == LinphoneSubscriptionError) { release(); diff --git a/src/event/event-subscribe.h b/src/event/event-subscribe.h index 41df948e7f4220be544cd187765b8b4a3955a504..1f96b7bd8baa576510b2b798c390c4d26b5fe280 100644 --- a/src/event/event-subscribe.h +++ b/src/event/event-subscribe.h @@ -57,6 +57,8 @@ public: const std::string &event, int expires); + virtual ~EventSubscribe() = default; + std::string toString() const override; LinphoneStatus send(const std::shared_ptr<const Content> &body) override; diff --git a/src/event/event.cpp b/src/event/event.cpp index 3f295f2b258994c81baca8f9426ffcb7fd704d51..08a85e38fa56bfa0c0253e07078f30daf221cafb 100644 --- a/src/event/event.cpp +++ b/src/event/event.cpp @@ -42,8 +42,9 @@ Event::~Event() { if (mEi) linphone_error_info_unref(mEi); try { - if (getCore()) { - LinphoneCore *lc = this->getCore()->getCCore(); + auto core = getCore(); + if (core) { + LinphoneCore *lc = core->getCCore(); if (lc != NULL && linphone_core_get_global_state(lc) != LinphoneGlobalOff) { if (mOp) mOp->release(); } diff --git a/tester/conference-event-tester.cpp b/tester/conference-event-tester.cpp index 7a558d5bebd9b31bd1d6e2f780fc0bfabd73b26b..1d3651217e06fb9bf185c07f25ebb3c9b3acda48 100644 --- a/tester/conference-event-tester.cpp +++ b/tester/conference-event-tester.cpp @@ -743,7 +743,7 @@ static const char *aliceUri = "sip:alice@example.com"; static const char *frankUri = "sip:frank@example.com"; static const char *confUri = "sips:conf233@example.com"; -L_ENABLE_ATTR_ACCESS(ServerConference, shared_ptr<ServerConferenceEventHandler>, eventHandler); +L_ENABLE_ATTR_ACCESS(ServerConference, shared_ptr<ServerConferenceEventHandler>, mEventHandler); class ConferenceEventTester : public ClientConference { public: @@ -873,8 +873,7 @@ public: getCurrentParams()->enableAudio(true); getCurrentParams()->enableChat(false); } - virtual ~ServerConferenceTester() { - } + virtual ~ServerConferenceTester() = default; /* ConferenceInterface */ @@ -1034,7 +1033,6 @@ void first_notify_parsing() { linphone_address_unref(bobAddr); linphone_address_unref(aliceAddr); - tester = nullptr; linphone_core_manager_destroy(marie); } @@ -1082,7 +1080,6 @@ void first_notify_with_extensions_parsing() { linphone_address_unref(bobAddr); linphone_address_unref(aliceAddr); - tester = nullptr; linphone_core_manager_destroy(marie); } @@ -1123,7 +1120,6 @@ void first_notify_parsing_wrong_conf() { linphone_address_unref(bobAddr); linphone_address_unref(aliceAddr); - tester = nullptr; linphone_core_manager_destroy(marie); } @@ -1186,7 +1182,6 @@ void participant_added_parsing() { linphone_address_unref(bobAddr); linphone_address_unref(aliceAddr); linphone_address_unref(frankAddr); - tester = nullptr; linphone_core_manager_destroy(marie); } @@ -1289,10 +1284,11 @@ void participant_not_added_parsing() { (initial_marie_stats.number_of_LinphoneSubscriptionOutgoingProgress + 1), liblinphone_tester_sip_timeout)); + tester->handler->unsubscribe(); + linphone_address_unref(bobAddr); linphone_address_unref(aliceAddr); linphone_address_unref(frankAddr); - tester = nullptr; destroy_mgr_in_conference(marie); } @@ -1350,7 +1346,6 @@ void participant_deleted_parsing() { linphone_address_unref(bobAddr); linphone_address_unref(aliceAddr); - tester = nullptr; linphone_core_manager_destroy(marie); } @@ -1407,7 +1402,6 @@ void participant_admined_parsing() { linphone_address_unref(bobAddr); linphone_address_unref(aliceAddr); - tester = nullptr; linphone_core_manager_destroy(marie); } @@ -1464,7 +1458,6 @@ void participant_unadmined_parsing() { linphone_address_unref(bobAddr); linphone_address_unref(aliceAddr); - tester = nullptr; linphone_core_manager_destroy(marie); } @@ -1498,7 +1491,7 @@ void send_first_notify() { alice->setAdmin(true); ServerConferenceEventHandler *localHandler = - (L_ATTR_GET(dynamic_pointer_cast<ServerConference>(localConf).get(), eventHandler)).get(); + (L_ATTR_GET(dynamic_pointer_cast<ServerConference>(localConf).get(), mEventHandler)).get(); localConf->setState(ConferenceInterface::State::Instantiated); localConf->setConferenceAddress(addr); auto content = localHandler->createNotifyFullState(NULL); @@ -1515,9 +1508,6 @@ void send_first_notify() { BC_ASSERT_TRUE(!tester->participants.find(bobAddr->toString())->second); BC_ASSERT_TRUE(tester->participants.find(aliceAddr->toString())->second); - tester = nullptr; - localConf = nullptr; - alice = nullptr; linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } @@ -1572,7 +1562,6 @@ void send_added_notify_through_address() { BC_ASSERT_EQUAL(localConf->getLastNotify(), (lastNotifyCount + 1), size_t, "%zu"); - localConf = nullptr; linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } @@ -2156,7 +2145,6 @@ void send_removed_notify() { BC_ASSERT_TRUE(confListener->participants.find(aliceAddr->toString())->second); BC_ASSERT_EQUAL(localConf->getLastNotify(), (lastNotifyCount + 1), int, "%d"); - localConf = nullptr; linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } @@ -2205,7 +2193,6 @@ void send_admined_notify() { BC_ASSERT_EQUAL(localConf->getLastNotify(), (lastNotifyCount + 1), int, "%d"); - localConf = nullptr; linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } @@ -2252,7 +2239,6 @@ void send_unadmined_notify() { BC_ASSERT_TRUE(!confListener->participants.find(bobAddr->toString())->second); BC_ASSERT_EQUAL(localConf->getLastNotify(), (lastNotifyCount + 1), int, "%d"); - localConf = nullptr; linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } @@ -2303,7 +2289,6 @@ void send_subject_changed_notify() { BC_ASSERT_TRUE(confListener->participants.find(aliceAddr->toString())->second); BC_ASSERT_EQUAL(localConf->getLastNotify(), (lastNotifyCount + 1), int, "%d"); - localConf = nullptr; linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } @@ -2407,7 +2392,6 @@ void send_device_added_notify() { linphone_event_unref(lev); localConf = nullptr; - alice = nullptr; linphone_core_manager_destroy(pauline); } @@ -2463,8 +2447,6 @@ void send_device_removed_notify() { BC_ASSERT_EQUAL(confListener->participantDevices.find(bobAddr->toString())->second, 0, size_t, "%zu"); BC_ASSERT_EQUAL(confListener->participantDevices.find(aliceAddr->toString())->second, 0, size_t, "%zu"); - localConf = nullptr; - alice = nullptr; linphone_core_manager_destroy(pauline); } @@ -2495,7 +2477,7 @@ void one_to_one_keyword() { localConf->Conference::addParticipant(bobAddr); ServerConferenceEventHandler *localHandler = - (L_ATTR_GET(dynamic_pointer_cast<ServerConference>(localConf).get(), eventHandler)).get(); + (L_ATTR_GET(dynamic_pointer_cast<ServerConference>(localConf).get(), mEventHandler)).get(); localConf->setState(ConferenceInterface::State::Instantiated); localConf->setConferenceAddress(addr); auto content = localHandler->createNotifyFullState(NULL); @@ -2509,8 +2491,6 @@ void one_to_one_keyword() { BC_ASSERT_EQUAL(tester->participantDevices.find(bobAddr->toString())->second, 0, size_t, "%zu"); BC_ASSERT_TRUE(tester->oneToOne); - tester = nullptr; - localConf = nullptr; linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c index 2c104481308578a04a23c6a01b0d257a66282e2a..912c8c05bb951589e4dbf2a239fdfa006123e3d1 100644 --- a/tester/liblinphone_tester.c +++ b/tester/liblinphone_tester.c @@ -513,7 +513,7 @@ void liblinphone_tester_add_suites(void) { &local_conference_test_suite_scheduled_conference_audio_only_participant, 581); liblinphone_tester_add_suite_with_default_time( &local_conference_test_suite_scheduled_conference_with_screen_sharing, 581); - liblinphone_tester_add_suite_with_default_time(&local_conference_test_suite_scheduled_conference_with_chat, 200); + liblinphone_tester_add_suite_with_default_time(&local_conference_test_suite_scheduled_conference_with_chat, 600); liblinphone_tester_add_suite_with_default_time(&local_conference_test_suite_scheduled_ice_conference, 563); liblinphone_tester_add_suite_with_default_time(&local_conference_test_suite_impromptu_conference, 384); liblinphone_tester_add_suite_with_default_time(&local_conference_test_suite_encrypted_impromptu_conference, 150); diff --git a/tester/local-conference-tester-functions.cpp b/tester/local-conference-tester-functions.cpp index 1eed350f5839268fcfe5a0a91b9e9d8c8b5e4a72..e5c81fd972854d9fca24caf0e0d0ebbe321aac11 100644 --- a/tester/local-conference-tester-functions.cpp +++ b/tester/local-conference-tester-functions.cpp @@ -8722,7 +8722,24 @@ void conference_joined_multiple_times(LinphoneConferenceSecurityLevel security_l for (auto mgr : conferenceMgrs) { LinphoneConferenceInfo *info = linphone_core_find_conference_information_from_uri(mgr->lc, confAddr); - if (BC_ASSERT_PTR_NOT_NULL(info)) { + bool info_deleted = false; + if (!!linphone_core_conference_server_enabled(mgr->lc) && (focus_cleanup_window > 0) && + (end_time > 0)) { + time_t now = ms_time(NULL); + time_t time_left = end_time - now; + if (time_left < 0) { + ms_message("Attempt #%0d - conference information of conference %s was deleted on the server " + "core %s because the conference ended %ld seconds ago", + attempt, conference_address_str, linphone_core_get_identity(mgr->lc), -time_left); + info_deleted = true; + } + } + if (info_deleted) { + BC_ASSERT_PTR_NULL(info); + } else { + BC_ASSERT_PTR_NOT_NULL(info); + } + if (info) { linphone_conference_info_unref(info); } } @@ -11715,7 +11732,8 @@ void create_conference_dial_out_base(LinphoneConferenceLayout layout, bool_t accept, bool_t participant_codec_mismatch, LinphoneConferenceSecurityLevel security_level, - bool_t version_mismatch) { + bool_t version_mismatch, + bool_t enable_chat) { Focus focus("chloe_rc"); { // to make sure focus is destroyed after clients. bool_t enable_lime = (security_level == LinphoneConferenceSecurityLevelEndToEnd ? TRUE : FALSE); @@ -11817,7 +11835,7 @@ void create_conference_dial_out_base(LinphoneConferenceLayout layout, LinphoneAddress *confAddr = create_conference_on_server(focus, marie, participantList, -1, -1, initialSubject, description, send_ics, - security_level, TRUE, FALSE, NULL); + security_level, TRUE, enable_chat, NULL); BC_ASSERT_PTR_NOT_NULL(confAddr); // Chat room creation to send ICS @@ -12041,7 +12059,7 @@ void create_conference_dial_out_base(LinphoneConferenceLayout layout, (send_ics) ? description : NULL, 0, LinphoneConferenceInfoStateNew, mgr == laure.getCMgr() && version_mismatch ? LinphoneConferenceSecurityLevelNone : security_level, - FALSE, TRUE, TRUE, FALSE); + FALSE, TRUE, TRUE, enable_chat); } LinphoneCall *pcall = linphone_core_get_call_by_remote_address2(mgr->lc, confAddr); @@ -12187,7 +12205,7 @@ void create_conference_dial_out_base(LinphoneConferenceLayout layout, check_conference_info_in_db( mgr, NULL, confAddr, marie.getCMgr()->identity, participants_info3, 0, 0, initialSubject, (send_ics || (mgr == marie.getCMgr())) ? description : NULL, 0, - LinphoneConferenceInfoStateNew, security_level, FALSE, TRUE, TRUE, FALSE); + LinphoneConferenceInfoStateNew, security_level, FALSE, TRUE, TRUE, enable_chat); bctbx_list_free_with_data(participants_info3, (bctbx_list_free_func)linphone_participant_info_unref); @@ -12425,14 +12443,21 @@ void create_conference_dial_out_base(LinphoneConferenceLayout layout, liblinphone_tester_sip_timeout)); BC_ASSERT_TRUE(wait_for_list(coresList, &mgr->stat.number_of_LinphoneConferenceStateTerminated, 1, liblinphone_tester_sip_timeout)); - BC_ASSERT_TRUE(wait_for_list(coresList, &mgr->stat.number_of_LinphoneConferenceStateDeleted, 1, - liblinphone_tester_sip_timeout)); + if (enable_chat) { + BC_ASSERT_FALSE( + wait_for_list(coresList, &mgr->stat.number_of_LinphoneConferenceStateDeleted, 1, 2000)); + } else { + BC_ASSERT_TRUE(wait_for_list(coresList, &mgr->stat.number_of_LinphoneConferenceStateDeleted, 1, + liblinphone_tester_sip_timeout)); + } - LinphoneAddress *uri = linphone_address_new(linphone_core_get_identity(mgr->lc)); LinphoneConference *pconference = - linphone_core_search_conference(mgr->lc, NULL, uri, confAddr, NULL); - BC_ASSERT_PTR_NULL(pconference); - linphone_address_unref(uri); + linphone_core_search_conference(mgr->lc, NULL, mgr->identity, confAddr, NULL); + if (enable_chat) { + BC_ASSERT_PTR_NOT_NULL(pconference); + } else { + BC_ASSERT_PTR_NULL(pconference); + } } } @@ -12571,7 +12596,7 @@ void create_conference_dial_out_base(LinphoneConferenceLayout layout, mgr, NULL, confAddr, marie.getCMgr()->identity, participants_info3, 0, 0, initialSubject, ((accept && send_ics) || (mgr == marie.getCMgr())) ? description : NULL, 0, LinphoneConferenceInfoStateNew, (accept) ? security_level : LinphoneConferenceSecurityLevelNone, FALSE, - TRUE, TRUE, FALSE); + TRUE, TRUE, enable_chat); bctbx_list_free_with_data(participants_info3, (bctbx_list_free_func)linphone_participant_info_unref); } diff --git a/tester/local-conference-tester-functions.h b/tester/local-conference-tester-functions.h index fe14f065757843c07dd604090d29f9d829b2f3ed..57792b8cb86b3f4b13ae7a5b1ab36ce9f7a3c674 100644 --- a/tester/local-conference-tester-functions.h +++ b/tester/local-conference-tester-functions.h @@ -450,7 +450,8 @@ void create_conference_dial_out_base(LinphoneConferenceLayout layout, bool_t accept, bool_t participant_codec_mismatch, LinphoneConferenceSecurityLevel security_level, - bool_t version_mismatch); + bool_t version_mismatch, + bool_t enable_chat); void create_conference_with_audio_only_participants_base(LinphoneConferenceSecurityLevel security_level); diff --git a/tester/local-encrypted-conference-tester.cpp b/tester/local-encrypted-conference-tester.cpp index 1ea12665e9f8d8c78f939e1e967e4338e4060a8c..553f194e4da185dc94c8061ca6e6a33e03dd23b9 100644 --- a/tester/local-encrypted-conference-tester.cpp +++ b/tester/local-encrypted-conference-tester.cpp @@ -228,7 +228,17 @@ static void create_simple_end_to_end_encrypted_conference_dial_out() { linphone_video_activation_policy_set_automatically_initiate(pol, TRUE); create_conference_dial_out_base(LinphoneConferenceLayoutActiveSpeaker, pol, FALSE, FALSE, LinphoneConferenceParticipantListTypeClosed, TRUE, FALSE, - LinphoneConferenceSecurityLevelEndToEnd, FALSE); + LinphoneConferenceSecurityLevelEndToEnd, FALSE, FALSE); + linphone_video_activation_policy_unref(pol); +} + +static void create_simple_end_to_end_encrypted_conference_dial_out_with_chat() { + LinphoneVideoActivationPolicy *pol = linphone_factory_create_video_activation_policy(linphone_factory_get()); + linphone_video_activation_policy_set_automatically_accept(pol, TRUE); + linphone_video_activation_policy_set_automatically_initiate(pol, TRUE); + create_conference_dial_out_base(LinphoneConferenceLayoutActiveSpeaker, pol, FALSE, FALSE, + LinphoneConferenceParticipantListTypeClosed, TRUE, FALSE, + LinphoneConferenceSecurityLevelEndToEnd, FALSE, TRUE); linphone_video_activation_policy_unref(pol); } @@ -238,7 +248,7 @@ static void create_end_to_end_encrypted_conference_dial_out_terminate_call_on_ve linphone_video_activation_policy_set_automatically_initiate(pol, TRUE); create_conference_dial_out_base(LinphoneConferenceLayoutActiveSpeaker, pol, FALSE, FALSE, LinphoneConferenceParticipantListTypeClosed, TRUE, FALSE, - LinphoneConferenceSecurityLevelEndToEnd, TRUE); + LinphoneConferenceSecurityLevelEndToEnd, TRUE, FALSE); linphone_video_activation_policy_unref(pol); } @@ -1236,6 +1246,9 @@ static test_t local_conference_end_to_end_encryption_scheduled_conference_with_c TEST_ONE_TAG("Create encrypted conference with chat network drops and participant rejoining", LinphoneTest::create_encrypted_conference_with_chat_network_drops_and_participant_rejoining, "End2EndConf"), + TEST_ONE_TAG("Create simple end-to-end encrypted dial out conference with chat", + LinphoneTest::create_simple_end_to_end_encrypted_conference_dial_out_with_chat, + "End2EndConf"), }; static test_t local_conference_end_to_end_encryption_scheduled_conference_audio_only_participant_tests[] = { diff --git a/tester/local-impromptu-conference-tester.cpp b/tester/local-impromptu-conference-tester.cpp index befca720f6f2aad37fc498861abff3ef2544bab4..47536c26aef2a3db259e770e81590a450ebcf130 100644 --- a/tester/local-impromptu-conference-tester.cpp +++ b/tester/local-impromptu-conference-tester.cpp @@ -31,7 +31,17 @@ static void create_simple_conference_dial_out(void) { linphone_video_activation_policy_set_automatically_initiate(pol, FALSE); create_conference_dial_out_base(LinphoneConferenceLayoutActiveSpeaker, pol, FALSE, FALSE, LinphoneConferenceParticipantListTypeClosed, TRUE, FALSE, - LinphoneConferenceSecurityLevelNone, FALSE); + LinphoneConferenceSecurityLevelNone, FALSE, FALSE); + linphone_video_activation_policy_unref(pol); +} + +static void create_simple_conference_dial_out_with_chat(void) { + LinphoneVideoActivationPolicy *pol = linphone_factory_create_video_activation_policy(linphone_factory_get()); + linphone_video_activation_policy_set_automatically_accept(pol, FALSE); + linphone_video_activation_policy_set_automatically_initiate(pol, FALSE); + create_conference_dial_out_base(LinphoneConferenceLayoutActiveSpeaker, pol, FALSE, FALSE, + LinphoneConferenceParticipantListTypeClosed, TRUE, FALSE, + LinphoneConferenceSecurityLevelNone, FALSE, TRUE); linphone_video_activation_policy_unref(pol); } @@ -41,7 +51,7 @@ static void create_simple_ice_conference_dial_out(void) { linphone_video_activation_policy_set_automatically_initiate(pol, TRUE); create_conference_dial_out_base(LinphoneConferenceLayoutGrid, pol, TRUE, TRUE, LinphoneConferenceParticipantListTypeOpen, TRUE, FALSE, - LinphoneConferenceSecurityLevelNone, FALSE); + LinphoneConferenceSecurityLevelNone, FALSE, FALSE); linphone_video_activation_policy_unref(pol); } @@ -51,7 +61,7 @@ static void create_simple_conference_dial_out_with_calls_declined(void) { linphone_video_activation_policy_set_automatically_initiate(pol, TRUE); create_conference_dial_out_base(LinphoneConferenceLayoutGrid, pol, TRUE, TRUE, LinphoneConferenceParticipantListTypeOpen, FALSE, FALSE, - LinphoneConferenceSecurityLevelNone, FALSE); + LinphoneConferenceSecurityLevelNone, FALSE, FALSE); linphone_video_activation_policy_unref(pol); } @@ -61,7 +71,7 @@ static void create_simple_point_to_point_encrypted_conference_dial_out(void) { linphone_video_activation_policy_set_automatically_initiate(pol, TRUE); create_conference_dial_out_base(LinphoneConferenceLayoutActiveSpeaker, pol, FALSE, FALSE, LinphoneConferenceParticipantListTypeClosed, TRUE, FALSE, - LinphoneConferenceSecurityLevelPointToPoint, FALSE); + LinphoneConferenceSecurityLevelPointToPoint, FALSE, FALSE); linphone_video_activation_policy_unref(pol); } @@ -71,7 +81,7 @@ static void create_simple_conference_dial_out_participant_codec_mismatch(void) { linphone_video_activation_policy_set_automatically_initiate(pol, FALSE); create_conference_dial_out_base(LinphoneConferenceLayoutActiveSpeaker, pol, FALSE, FALSE, LinphoneConferenceParticipantListTypeClosed, TRUE, TRUE, - LinphoneConferenceSecurityLevelNone, FALSE); + LinphoneConferenceSecurityLevelNone, FALSE, FALSE); linphone_video_activation_policy_unref(pol); } @@ -81,7 +91,7 @@ static void create_simple_conference_dial_out_with_video_not_accepted(void) { linphone_video_activation_policy_set_automatically_initiate(pol, TRUE); create_conference_dial_out_base(LinphoneConferenceLayoutActiveSpeaker, pol, FALSE, FALSE, LinphoneConferenceParticipantListTypeClosed, TRUE, FALSE, - LinphoneConferenceSecurityLevelNone, FALSE); + LinphoneConferenceSecurityLevelNone, FALSE, FALSE); linphone_video_activation_policy_unref(pol); } @@ -91,7 +101,7 @@ static void create_simple_conference_dial_out_with_video_not_initiated(void) { linphone_video_activation_policy_set_automatically_initiate(pol, FALSE); create_conference_dial_out_base(LinphoneConferenceLayoutGrid, pol, FALSE, FALSE, LinphoneConferenceParticipantListTypeClosed, TRUE, FALSE, - LinphoneConferenceSecurityLevelNone, FALSE); + LinphoneConferenceSecurityLevelNone, FALSE, FALSE); linphone_video_activation_policy_unref(pol); } @@ -1016,6 +1026,8 @@ static test_t local_conference_encrypted_impromptu_conference_tests[] = { static test_t local_conference_impromptu_conference_tests[] = { TEST_NO_TAG("Create simple dial out conference", LinphoneTest::create_simple_conference_dial_out), + TEST_NO_TAG("Create simple dial out conference with chat", + LinphoneTest::create_simple_conference_dial_out_with_chat), TEST_NO_TAG("Create simple dial out ICE conference", LinphoneTest::create_simple_ice_conference_dial_out), TEST_NO_TAG("Create simple dial out conference with late participant addition", LinphoneTest::create_simple_conference_dial_out_with_late_participant_addition),