hide conference joined/left events if not in a chat group #LINQT-2146

This commit is contained in:
Gaelle Braud 2025-11-24 15:17:34 +01:00
parent 735c473b3c
commit 29691485bf
5 changed files with 36 additions and 22 deletions

View file

@ -209,7 +209,7 @@ void ChatCore::setSelf(QSharedPointer<ChatCore> me) {
const std::shared_ptr<const linphone::EventLog> &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<ChatCore> me) {
lDebug() << "CHAT MESSAGE RECEIVED IN CHATROOM" << mChatModel->getTitle();
QList<QSharedPointer<EventLogCore>> 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<ChatCore> me) {
mChatModelConnection->makeConnectToModel(
&ChatModel::chatMessageSending, [this](const std::shared_ptr<linphone::ChatRoom> &chatRoom,
const std::shared_ptr<const linphone::EventLog> &eventLog) {
auto event = EventLogCore::create(eventLog);
auto event = EventLogCore::create(eventLog, chatRoom);
mChatModelConnection->invokeToCore([this, event]() { emit eventsInserted({event}); });
});
mChatModelConnection->makeConnectToCore(

View file

@ -143,7 +143,7 @@ void ChatList::setSelf(QSharedPointer<ChatList> 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<linphone::Core> &core,
@ -183,9 +183,10 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
lInfo() << "ChatRoom created, add it to the list" << chatRoom.get();
auto chatCore = ChatCore::create(chatRoom);
if (chatCore) {
mModelConnection->invokeToCore([this, chatCore] {
bool added = addChatInList(chatCore);
if (added)
mModelConnection->invokeToCore([this, chatCore] { emit chatCreated(new ChatGui(chatCore)); });
if (added) emit chatCreated(new ChatGui(chatCore));
});
}
}
});

View file

@ -26,14 +26,16 @@
DEFINE_ABSTRACT_OBJECT(EventLogCore)
QSharedPointer<EventLogCore> EventLogCore::create(const std::shared_ptr<const linphone::EventLog> &eventLog) {
auto sharedPointer = QSharedPointer<EventLogCore>(new EventLogCore(eventLog), &QObject::deleteLater);
QSharedPointer<EventLogCore> EventLogCore::create(const std::shared_ptr<const linphone::EventLog> &eventLog,
const std::shared_ptr<linphone::ChatRoom> &chatRoom) {
auto sharedPointer = QSharedPointer<EventLogCore>(new EventLogCore(eventLog, chatRoom), &QObject::deleteLater);
sharedPointer->setSelf(sharedPointer);
sharedPointer->moveToThread(App::getInstance()->thread());
return sharedPointer;
}
EventLogCore::EventLogCore(const std::shared_ptr<const linphone::EventLog> &eventLog) {
EventLogCore::EventLogCore(const std::shared_ptr<const linphone::EventLog> &eventLog,
const std::shared_ptr<linphone::ChatRoom> &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<const linphone::EventLog> &even
QString type = QString::fromLatin1(
QMetaEnum::fromType<LinphoneEnums::EventLogType>().valueToKey(static_cast<int>(mEventLogType)));
mEventId = type + QString::number(static_cast<qint64>(eventLog->getCreationTime()));
computeEvent(eventLog);
computeEvent(eventLog, chatRoom);
}
}
@ -94,7 +96,8 @@ std::shared_ptr<EventLogModel> EventLogCore::getModel() const {
// Events (other than ChatMessage and CallLog which are handled in their respective Core)
void EventLogCore::computeEvent(const std::shared_ptr<const linphone::EventLog> &eventLog) {
void EventLogCore::computeEvent(const std::shared_ptr<const linphone::EventLog> &eventLog,
const std::shared_ptr<linphone::ChatRoom> &chatRoom) {
mustBeInLinphoneThread(getClassName());
mHandled = true;
mImportant = false;
@ -104,9 +107,15 @@ void EventLogCore::computeEvent(const std::shared_ptr<const linphone::EventLog>
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;

View file

@ -51,8 +51,10 @@ class EventLogCore : public QObject, public AbstractObject {
Q_PROPERTY(QDateTime timestamp READ getTimestamp CONSTANT)
public:
static QSharedPointer<EventLogCore> create(const std::shared_ptr<const linphone::EventLog> &eventLog);
EventLogCore(const std::shared_ptr<const linphone::EventLog> &eventLog);
static QSharedPointer<EventLogCore> create(const std::shared_ptr<const linphone::EventLog> &eventLog,
const std::shared_ptr<linphone::ChatRoom> &chatRoom);
EventLogCore(const std::shared_ptr<const linphone::EventLog> &eventLog,
const std::shared_ptr<linphone::ChatRoom> &chatRoom);
~EventLogCore();
void setSelf(QSharedPointer<EventLogCore> me);
QString getEventLogId();
@ -87,7 +89,8 @@ private:
ChatMessageCore *getChatMessageCorePointer();
CallHistoryCore *getCallHistoryCorePointer();
std::shared_ptr<EventLogModel> mEventLogModel;
void computeEvent(const std::shared_ptr<const linphone::EventLog> &eventLog);
void computeEvent(const std::shared_ptr<const linphone::EventLog> &eventLog,
const std::shared_ptr<linphone::ChatRoom> &chatRoom);
};
#endif // EventLogCore_H_

View file

@ -138,7 +138,7 @@ void EventLogList::displayMore() {
auto linphoneLogs = chatModel->getHistoryRange(totalItemsCount, newCount);
QList<QSharedPointer<EventLogCore>> *events = new QList<QSharedPointer<EventLogCore>>();
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<linphone::EventLog> event) {
auto beforeEvents = chatModel->getHistoryRangeNear(mItemsToLoadBeforeSearchResult, 0, event, filters);
auto linphoneLogs = chatModel->getHistoryRangeBetween(event, linOldest, filters);
QList<QSharedPointer<EventLogCore>> *events = new QList<QSharedPointer<EventLogCore>>();
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<EventLogList> me) {
auto linphoneLogs = chatModel->getHistoryRange(0, mDisplayItemsStep);
QList<QSharedPointer<EventLogCore>> *events = new QList<QSharedPointer<EventLogCore>>();
for (auto it : linphoneLogs) {
auto model = EventLogCore::create(it);
auto model = EventLogCore::create(it, chatModel->getMonitor());
events->push_back(model);
}
mCoreModelConnection->invokeToCore([this, events] {