From 29691485bf5808bc656eb9eb14d33c07ef2dd33e Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Mon, 24 Nov 2025 15:17:34 +0100 Subject: [PATCH] hide conference joined/left events if not in a chat group #LINQT-2146 --- Linphone/core/chat/ChatCore.cpp | 6 +++--- Linphone/core/chat/ChatList.cpp | 9 +++++---- Linphone/core/chat/message/EventLogCore.cpp | 19 ++++++++++++++----- Linphone/core/chat/message/EventLogCore.hpp | 9 ++++++--- Linphone/core/chat/message/EventLogList.cpp | 15 ++++++++------- 5 files changed, 36 insertions(+), 22 deletions(-) diff --git a/Linphone/core/chat/ChatCore.cpp b/Linphone/core/chat/ChatCore.cpp index 937f69702..c60cc6dce 100644 --- a/Linphone/core/chat/ChatCore.cpp +++ b/Linphone/core/chat/ChatCore.cpp @@ -209,7 +209,7 @@ void ChatCore::setSelf(QSharedPointer me) { const std::shared_ptr &eventLog) { if (mChatModel->getMonitor() != chatRoom) return; lDebug() << "EVENT LOG RECEIVED IN CHATROOM" << mChatModel->getTitle(); - auto event = EventLogCore::create(eventLog); + auto event = EventLogCore::create(eventLog, chatRoom); if (event->isHandled()) { mChatModelConnection->invokeToCore([this, event]() { emit eventsInserted({event}); }); } @@ -224,7 +224,7 @@ void ChatCore::setSelf(QSharedPointer me) { lDebug() << "CHAT MESSAGE RECEIVED IN CHATROOM" << mChatModel->getTitle(); QList> list; for (auto &e : eventsLog) { - auto event = EventLogCore::create(e); + auto event = EventLogCore::create(e, chatRoom); list.push_back(event); } mChatModelConnection->invokeToCore([this, list]() { @@ -287,7 +287,7 @@ void ChatCore::setSelf(QSharedPointer me) { mChatModelConnection->makeConnectToModel( &ChatModel::chatMessageSending, [this](const std::shared_ptr &chatRoom, const std::shared_ptr &eventLog) { - auto event = EventLogCore::create(eventLog); + auto event = EventLogCore::create(eventLog, chatRoom); mChatModelConnection->invokeToCore([this, event]() { emit eventsInserted({event}); }); }); mChatModelConnection->makeConnectToCore( diff --git a/Linphone/core/chat/ChatList.cpp b/Linphone/core/chat/ChatList.cpp index f98bca9a3..7d0a662c2 100644 --- a/Linphone/core/chat/ChatList.cpp +++ b/Linphone/core/chat/ChatList.cpp @@ -143,7 +143,7 @@ void ChatList::setSelf(QSharedPointer me) { return; } auto chatCore = ChatCore::create(room); - addChatInList(chatCore); + mModelConnection->invokeToCore([this, chatCore] { addChatInList(chatCore); }); }; mModelConnection->makeConnectToModel(&CoreModel::messageReceived, [this, addChatToList](const std::shared_ptr &core, @@ -183,9 +183,10 @@ void ChatList::setSelf(QSharedPointer me) { lInfo() << "ChatRoom created, add it to the list" << chatRoom.get(); auto chatCore = ChatCore::create(chatRoom); if (chatCore) { - bool added = addChatInList(chatCore); - if (added) - mModelConnection->invokeToCore([this, chatCore] { emit chatCreated(new ChatGui(chatCore)); }); + mModelConnection->invokeToCore([this, chatCore] { + bool added = addChatInList(chatCore); + if (added) emit chatCreated(new ChatGui(chatCore)); + }); } } }); diff --git a/Linphone/core/chat/message/EventLogCore.cpp b/Linphone/core/chat/message/EventLogCore.cpp index 53faca722..c2e689d71 100644 --- a/Linphone/core/chat/message/EventLogCore.cpp +++ b/Linphone/core/chat/message/EventLogCore.cpp @@ -26,14 +26,16 @@ DEFINE_ABSTRACT_OBJECT(EventLogCore) -QSharedPointer EventLogCore::create(const std::shared_ptr &eventLog) { - auto sharedPointer = QSharedPointer(new EventLogCore(eventLog), &QObject::deleteLater); +QSharedPointer EventLogCore::create(const std::shared_ptr &eventLog, + const std::shared_ptr &chatRoom) { + auto sharedPointer = QSharedPointer(new EventLogCore(eventLog, chatRoom), &QObject::deleteLater); sharedPointer->setSelf(sharedPointer); sharedPointer->moveToThread(App::getInstance()->thread()); return sharedPointer; } -EventLogCore::EventLogCore(const std::shared_ptr &eventLog) { +EventLogCore::EventLogCore(const std::shared_ptr &eventLog, + const std::shared_ptr &chatRoom) { mustBeInLinphoneThread(getClassName()); App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership); mEventLogType = LinphoneEnums::fromLinphone(eventLog->getType()); @@ -52,7 +54,7 @@ EventLogCore::EventLogCore(const std::shared_ptr &even QString type = QString::fromLatin1( QMetaEnum::fromType().valueToKey(static_cast(mEventLogType))); mEventId = type + QString::number(static_cast(eventLog->getCreationTime())); - computeEvent(eventLog); + computeEvent(eventLog, chatRoom); } } @@ -94,7 +96,8 @@ std::shared_ptr EventLogCore::getModel() const { // Events (other than ChatMessage and CallLog which are handled in their respective Core) -void EventLogCore::computeEvent(const std::shared_ptr &eventLog) { +void EventLogCore::computeEvent(const std::shared_ptr &eventLog, + const std::shared_ptr &chatRoom) { mustBeInLinphoneThread(getClassName()); mHandled = true; mImportant = false; @@ -104,9 +107,15 @@ void EventLogCore::computeEvent(const std::shared_ptr switch (eventLog->getType()) { case linphone::EventLog::Type::ConferenceCreated: + if (chatRoom->hasCapability((int)linphone::ChatRoom::Capabilities::OneToOne) && + !chatRoom->hasCapability((int)linphone::ChatRoom::Capabilities::Conference)) + mHandled = false; mEventDetails = tr("conference_created_event"); break; case linphone::EventLog::Type::ConferenceTerminated: + if (chatRoom->hasCapability((int)linphone::ChatRoom::Capabilities::OneToOne) && + !chatRoom->hasCapability((int)linphone::ChatRoom::Capabilities::Conference)) + mHandled = false; mEventDetails = tr("conference_created_terminated"); mImportant = true; break; diff --git a/Linphone/core/chat/message/EventLogCore.hpp b/Linphone/core/chat/message/EventLogCore.hpp index fe0b4c550..0bf8ae5fd 100644 --- a/Linphone/core/chat/message/EventLogCore.hpp +++ b/Linphone/core/chat/message/EventLogCore.hpp @@ -51,8 +51,10 @@ class EventLogCore : public QObject, public AbstractObject { Q_PROPERTY(QDateTime timestamp READ getTimestamp CONSTANT) public: - static QSharedPointer create(const std::shared_ptr &eventLog); - EventLogCore(const std::shared_ptr &eventLog); + static QSharedPointer create(const std::shared_ptr &eventLog, + const std::shared_ptr &chatRoom); + EventLogCore(const std::shared_ptr &eventLog, + const std::shared_ptr &chatRoom); ~EventLogCore(); void setSelf(QSharedPointer me); QString getEventLogId(); @@ -87,7 +89,8 @@ private: ChatMessageCore *getChatMessageCorePointer(); CallHistoryCore *getCallHistoryCorePointer(); std::shared_ptr mEventLogModel; - void computeEvent(const std::shared_ptr &eventLog); + void computeEvent(const std::shared_ptr &eventLog, + const std::shared_ptr &chatRoom); }; #endif // EventLogCore_H_ diff --git a/Linphone/core/chat/message/EventLogList.cpp b/Linphone/core/chat/message/EventLogList.cpp index 41c28e703..1fd0d3d13 100644 --- a/Linphone/core/chat/message/EventLogList.cpp +++ b/Linphone/core/chat/message/EventLogList.cpp @@ -138,7 +138,7 @@ void EventLogList::displayMore() { auto linphoneLogs = chatModel->getHistoryRange(totalItemsCount, newCount); QList> *events = new QList>(); for (auto it : linphoneLogs) { - auto model = EventLogCore::create(it); + auto model = EventLogCore::create(it, chatModel->getMonitor()); events->push_back(model); } mCoreModelConnection->invokeToCore([this, events] { @@ -176,16 +176,17 @@ void EventLogList::loadMessagesUpTo(std::shared_ptr event) { auto beforeEvents = chatModel->getHistoryRangeNear(mItemsToLoadBeforeSearchResult, 0, event, filters); auto linphoneLogs = chatModel->getHistoryRangeBetween(event, linOldest, filters); QList> *events = new QList>(); - for (auto it : beforeEvents) { - auto model = EventLogCore::create(it); + const auto &linChatRoom = chatModel->getMonitor(); + for (const auto &it : beforeEvents) { + auto model = EventLogCore::create(it, linChatRoom); events->push_back(model); } - for (auto it : linphoneLogs) { - auto model = EventLogCore::create(it); + for (const auto &it : linphoneLogs) { + auto model = EventLogCore::create(it, linChatRoom); events->push_back(model); } mCoreModelConnection->invokeToCore([this, events, event] { - for (auto &e : *events) { + for (const auto &e : *events) { connectItem(e); add(e); } @@ -286,7 +287,7 @@ void EventLogList::setSelf(QSharedPointer me) { auto linphoneLogs = chatModel->getHistoryRange(0, mDisplayItemsStep); QList> *events = new QList>(); for (auto it : linphoneLogs) { - auto model = EventLogCore::create(it); + auto model = EventLogCore::create(it, chatModel->getMonitor()); events->push_back(model); } mCoreModelConnection->invokeToCore([this, events] {