diff --git a/CHANGELOG.md b/CHANGELOG.md index 0db0f1b65..5c4a34e68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Screen Sharing -## 5.2.2 - 2024-03-08 +## 5.2.2 - 2024-03-11 ### Fixed - Day offset in start date when scheduling a conference. diff --git a/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp b/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp index ce218288e..2f614fa7a 100644 --- a/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp +++ b/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp @@ -22,33 +22,69 @@ #include "components/call/CallModel.hpp" #include "components/core/CoreManager.hpp" +#include "components/settings/AccountSettingsModel.hpp" #include "components/settings/SettingsModel.hpp" +#include "components/timeline/TimelineListModel.hpp" #include "AbstractEventCountNotifier.hpp" +#include "components/timeline/TimelineModel.hpp" // ============================================================================= using namespace std; -AbstractEventCountNotifier::AbstractEventCountNotifier (QObject *parent) : QObject(parent) { - CoreManager *coreManager = CoreManager::getInstance(); - connect(coreManager, &CoreManager::eventCountChanged, this, &AbstractEventCountNotifier::eventCountChanged); - connect(this, &AbstractEventCountNotifier::eventCountChanged, this, &AbstractEventCountNotifier::internalNotifyEventCount); +AbstractEventCountNotifier::AbstractEventCountNotifier(QObject *parent) + : QObject(parent) +{ + CoreManager *coreManager = CoreManager::getInstance(); + connect(coreManager, + &CoreManager::eventCountChanged, + this, + &AbstractEventCountNotifier::eventCountChanged); + connect(coreManager->getAccountSettingsModel(), + &AccountSettingsModel::defaultAccountChanged, + this, + &AbstractEventCountNotifier::internalNotifyEventCount); + connect(this, + &AbstractEventCountNotifier::eventCountChanged, + this, + &AbstractEventCountNotifier::internalNotifyEventCount); } // ----------------------------------------------------------------------------- -int AbstractEventCountNotifier::getEventCount () const { +int AbstractEventCountNotifier::getEventCount() const +{ auto coreManager = CoreManager::getInstance(); int count = coreManager->getCore()->getMissedCallsCount(); - if( coreManager->getSettingsModel()->getStandardChatEnabled() || coreManager->getSettingsModel()->getSecureChatEnabled()) - count += coreManager->getCore()->getUnreadChatMessageCount(); + if (coreManager->getSettingsModel()->getStandardChatEnabled() + || coreManager->getSettingsModel()->getSecureChatEnabled()) + count += coreManager->getCore()->getUnreadChatMessageCountFromActiveLocals(); return count; } -void AbstractEventCountNotifier::internalNotifyEventCount () { - int n = getEventCount(); - qInfo() << QStringLiteral("Notify event count: %1.").arg(n); - n = n > 99 ? 99 : n; - notifyEventCount(n); -} \ No newline at end of file +int AbstractEventCountNotifier::getCurrentEventCount() const +{ + auto coreManager = CoreManager::getInstance(); + int count = coreManager->getCore()->getMissedCallsCount(); + auto timelines = coreManager->getTimelineListModel()->getSharedList(); + bool filtered = CoreManager::getInstance()->getSettingsModel()->isSystrayNotificationFiltered(); + bool global = CoreManager::getInstance()->getSettingsModel()->isSystrayNotificationGlobal(); + if( global && !filtered) return getEventCount(); + for (const auto &timeline : timelines) { + auto chatRoom = timeline->getChatRoomModel(); + if (!coreManager->getCore()->getDefaultAccount() + || ((global || chatRoom->isCurrentAccount()) && (!filtered || chatRoom->isNotificationsEnabled()))) + count += chatRoom->getUnreadMessagesCount(); + } + return count; +} + +void AbstractEventCountNotifier::internalNotifyEventCount() +{ + int n = getCurrentEventCount(); + + qInfo() << QStringLiteral("Notify event count: %1.").arg(n); + n = n > 99 ? 99 : n; + notifyEventCount(n); +} diff --git a/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.hpp b/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.hpp index e5a438152..ab6191079 100644 --- a/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.hpp +++ b/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.hpp @@ -45,7 +45,8 @@ public: int getUnreadMessageCount () const; int getMissedCallCount () const; - int getEventCount () const; + int getEventCount () const;// global + int getCurrentEventCount () const;// Current account signals: void eventCountChanged (); diff --git a/linphone-app/src/components/core/event-count-notifier/EventCountNotifierSystemTrayIcon.cpp b/linphone-app/src/components/core/event-count-notifier/EventCountNotifierSystemTrayIcon.cpp index 707710feb..244c75989 100644 --- a/linphone-app/src/components/core/event-count-notifier/EventCountNotifierSystemTrayIcon.cpp +++ b/linphone-app/src/components/core/event-count-notifier/EventCountNotifierSystemTrayIcon.cpp @@ -28,7 +28,9 @@ #include "app/App.hpp" #include "utils/Utils.hpp" #include "utils/Constants.hpp" +#include "components/core/CoreManager.hpp" #include "components/other/colors/ColorListModel.hpp" +#include "components/settings/SettingsModel.hpp" #include "EventCountNotifierSystemTrayIcon.hpp" @@ -102,7 +104,9 @@ void EventCountNotifier::notifyEventCount (int n) { // Change counter. mBlinkTimer->stop(); - mBlinkTimer->start(); + auto coreManager = CoreManager::getInstance(); + if(!coreManager->isInitialized() || coreManager->getSettingsModel()->isSystrayNotificationBlinkEnabled()) + mBlinkTimer->start(); mDisplayCounter = true; update(); } diff --git a/linphone-app/src/components/settings/SettingsModel.cpp b/linphone-app/src/components/settings/SettingsModel.cpp index d8ca0ff24..dae374abb 100644 --- a/linphone-app/src/components/settings/SettingsModel.cpp +++ b/linphone-app/src/components/settings/SettingsModel.cpp @@ -1067,6 +1067,18 @@ int SettingsModel::getNotificationOrigin() const { ); } +bool SettingsModel::isSystrayNotificationBlinkEnabled() const { + return !!mConfig->getInt(UiSection, "systray_notification_blink", 1); +} + +bool SettingsModel::isSystrayNotificationGlobal() const { + return !!mConfig->getInt(UiSection, "systray_notification_global", 1); +} + +bool SettingsModel::isSystrayNotificationFiltered() const { + return !!mConfig->getInt(UiSection, "systray_notification_filtered", 0); +} + // ----------------------------------------------------------------------------- QString SettingsModel::getFileTransferUrl() const { diff --git a/linphone-app/src/components/settings/SettingsModel.hpp b/linphone-app/src/components/settings/SettingsModel.hpp index 5703ba742..412b9b71d 100644 --- a/linphone-app/src/components/settings/SettingsModel.hpp +++ b/linphone-app/src/components/settings/SettingsModel.hpp @@ -533,6 +533,10 @@ public: int getNotificationOrigin() const; + bool isSystrayNotificationBlinkEnabled() const; + bool isSystrayNotificationGlobal() const; + bool isSystrayNotificationFiltered() const; + QString getFileTransferUrl() const; void setFileTransferUrl(const QString &url);