diff --git a/panels/notification/server/CMakeLists.txt b/panels/notification/server/CMakeLists.txt
index 5991a48fc..0f4bb6148 100644
--- a/panels/notification/server/CMakeLists.txt
+++ b/panels/notification/server/CMakeLists.txt
@@ -6,18 +6,6 @@ set(NOTIFICATION_SERVER "notificationserver")
file (GLOB SERVER_SOURCES *.cpp *.h)
-set_source_files_properties(
- ${CMAKE_CURRENT_SOURCE_DIR}/dbus/xml/org.deepin.dde.SessionManager1.xml
- PROPERTIES
- CLASSNAME
- SessionManager1
-)
-
-qt6_add_dbus_interfaces(
- DBUS_INTERFACES
- ${CMAKE_CURRENT_SOURCE_DIR}/dbus/xml/org.deepin.dde.SessionManager1.xml
-)
-
add_library(${NOTIFICATION_SERVER} SHARED
${DBUS_INTERFACES}
${SERVER_SOURCES}
diff --git a/panels/notification/server/dbus/xml/org.deepin.dde.SessionManager1.xml b/panels/notification/server/dbus/xml/org.deepin.dde.SessionManager1.xml
deleted file mode 100644
index d2b2c134f..000000000
--- a/panels/notification/server/dbus/xml/org.deepin.dde.SessionManager1.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/panels/notification/server/dbusadaptor.cpp b/panels/notification/server/dbusadaptor.cpp
index 785fed734..8fadbab04 100644
--- a/panels/notification/server/dbusadaptor.cpp
+++ b/panels/notification/server/dbusadaptor.cpp
@@ -5,7 +5,10 @@
#include "dbusadaptor.h"
#include "notificationmanager.h"
+#include
+#include
#include
+
namespace notification {
Q_DECLARE_LOGGING_CATEGORY(notifyLog)
}
diff --git a/panels/notification/server/notificationmanager.cpp b/panels/notification/server/notificationmanager.cpp
index 0ad34e59a..2d3ca62e1 100644
--- a/panels/notification/server/notificationmanager.cpp
+++ b/panels/notification/server/notificationmanager.cpp
@@ -8,14 +8,17 @@
#include "notificationsetting.h"
#include "notifyentity.h"
-#include
#include
#include
-#include
#include
#include
+#include
+#include
+#include
+#include
+#include
#include
#include
#include
@@ -44,7 +47,6 @@ NotificationManager::NotificationManager(QObject *parent)
: QObject(parent)
, m_persistence(DataAccessorProxy::instance())
, m_setting(new NotificationSetting(this))
- , m_userSessionManager(new UserSessionManager(SessionDBusService, SessionDaemonDBusPath, QDBusConnection::sessionBus(), this))
, m_pendingTimeout(new QTimer(this))
{
m_pendingTimeout->setSingleShot(true);
@@ -74,6 +76,8 @@ NotificationManager::NotificationManager(QObject *parent)
m_systemApps = config->value("systemApps").toStringList();
// TODO temporary fix for AppNamesMap
m_appNamesMap = config->value("AppNamesMap").toMap();
+
+ initScreenLockedState();
}
NotificationManager::~NotificationManager()
@@ -216,8 +220,7 @@ uint NotificationManager::Notify(const QString &appName, uint replacesId, const
bool lockScreenShow = true;
bool dndMode = isDoNotDisturb();
bool systemNotification = m_systemApps.contains(appId);
- bool lockScreen = m_userSessionManager->locked();
- const bool desktopScreen = !lockScreen;
+ const bool desktopScreen = !m_screenLocked;
if (!systemNotification) {
lockScreenShow = m_setting->appValue(appId, NotificationSetting::ShowOnLockScreen).toBool();
@@ -232,7 +235,7 @@ uint NotificationManager::Notify(const QString &appName, uint replacesId, const
if (systemNotification) { // 系统通知
entity.setProcessedType(NotifyEntity::NotProcessed);
- } else if (lockScreen && !lockScreenShow) { // 锁屏不显示通知
+ } else if (m_screenLocked && !lockScreenShow) { // 锁屏不显示通知
entity.setProcessedType(NotifyEntity::Processed);
} else if (desktopScreen && !onDesktopShow) { // 桌面不显示通知
entity.setProcessedType(NotifyEntity::Processed);
@@ -351,9 +354,8 @@ bool NotificationManager::isDoNotDisturb() const
return true;
}
- bool lockScreen = m_userSessionManager->locked();
// 点击锁屏时 并且 锁屏状态 任何时候都勿扰模式
- if (m_setting->systemValue(NotificationSetting::LockScreenOpenDNDMode).toBool() && lockScreen)
+ if (m_setting->systemValue(NotificationSetting::LockScreenOpenDNDMode).toBool() && m_screenLocked)
return true;
QTime currentTime = QTime::fromString(QDateTime::currentDateTime().toString("hh:mm"));
@@ -550,6 +552,26 @@ bool NotificationManager::invokeShellAction(const QString &data)
return false;
}
+void NotificationManager::initScreenLockedState()
+{
+ const QString interfaceAndServiceName = "org.deepin.dde.LockFront1";
+ const QString path = "/org/deepin/dde/LockFront1";
+
+ QDBusInterface interface(interfaceAndServiceName, path,
+ "org.freedesktop.DBus.Properties", QDBusConnection::sessionBus());
+
+ QDBusReply reply = interface.call("Get", "org.deepin.dde.LockFront1", "Visible");
+ if (reply.isValid()) {
+ m_screenLocked = reply.value().variant().toBool();
+ } else {
+ m_screenLocked = false;
+ qWarning(notifyLog) << "Failed to get the lock visible property:" << reply.error().message();
+ }
+
+ QDBusConnection::sessionBus().connect(interfaceAndServiceName, path, interfaceAndServiceName,
+ "Visible", this, SLOT(onScreenLockedChanged(bool)));
+}
+
void NotificationManager::onHandingPendingEntities()
{
QList timeoutEntities;
@@ -600,4 +622,9 @@ void NotificationManager::removePendingEntity(const NotifyEntity &entity)
}
}
+void NotificationManager::onScreenLockedChanged(bool screenLocked)
+{
+ m_screenLocked = screenLocked;
+}
+
} // notification
diff --git a/panels/notification/server/notificationmanager.h b/panels/notification/server/notificationmanager.h
index 3c6633c31..e58dcafd0 100644
--- a/panels/notification/server/notificationmanager.h
+++ b/panels/notification/server/notificationmanager.h
@@ -4,14 +4,10 @@
#pragma once
-#include
#include
#include
-#include "sessionmanager1interface.h"
-
-using UserSessionManager = org::deepin::dde::SessionManager1;
-
+class QTimer;
namespace notification {
class NotifyEntity;
@@ -79,17 +75,19 @@ public Q_SLOTS:
QString appIdByAppName(const QString &appName) const;
void doActionInvoked(const NotifyEntity &entity, const QString &actionId);
bool invokeShellAction(const QString &data);
+ void initScreenLockedState();
private slots:
void onHandingPendingEntities();
void removePendingEntity(const NotifyEntity &entity);
+ void onScreenLockedChanged(bool);
private:
uint m_replacesCount = 0;
+ bool m_screenLocked = false;
DataAccessor *m_persistence = nullptr;
NotificationSetting *m_setting = nullptr;
- UserSessionManager *m_userSessionManager = nullptr;
QTimer *m_pendingTimeout = nullptr;
qint64 m_lastTimeoutPoint = std::numeric_limits::max();
QMultiHash m_pendingTimeoutEntities;
diff --git a/panels/notification/server/notifyserverapplet.cpp b/panels/notification/server/notifyserverapplet.cpp
index 2c75fd470..d7abd2431 100644
--- a/panels/notification/server/notifyserverapplet.cpp
+++ b/panels/notification/server/notifyserverapplet.cpp
@@ -7,6 +7,9 @@
#include "dbusadaptor.h"
#include "pluginfactory.h"
+#include
+#include
+
namespace notification {
Q_DECLARE_LOGGING_CATEGORY(notifyLog)
}