Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions panels/notification/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

This file was deleted.

3 changes: 3 additions & 0 deletions panels/notification/server/dbusadaptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
#include "dbusadaptor.h"
#include "notificationmanager.h"

#include <QDBusConnection>

Check warning on line 8 in panels/notification/server/dbusadaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusConnection> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusMessage>

Check warning on line 9 in panels/notification/server/dbusadaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusMessage> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QLoggingCategory>

Check warning on line 10 in panels/notification/server/dbusadaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QLoggingCategory> not found. Please note: Cppcheck does not need standard library headers to get proper results.

namespace notification {
Q_DECLARE_LOGGING_CATEGORY(notifyLog)
}
Expand Down
43 changes: 35 additions & 8 deletions panels/notification/server/notificationmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
#include "dataaccessorproxy.h"
#include "dbaccessor.h"
#include "notificationsetting.h"
#include "notifyentity.h"

Check warning on line 9 in panels/notification/server/notificationmanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "notifyentity.h" not found.

#include <QDateTime>
#include <DDesktopServices>

Check warning on line 11 in panels/notification/server/notificationmanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DDesktopServices> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DSGApplication>

Check warning on line 12 in panels/notification/server/notificationmanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DSGApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusConnection>
#include <QDBusConnectionInterface>

Check warning on line 13 in panels/notification/server/notificationmanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusConnectionInterface> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <DConfig>

Check warning on line 15 in panels/notification/server/notificationmanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DConfig> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <QAbstractItemModel>

Check warning on line 17 in panels/notification/server/notificationmanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QAbstractItemModel> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusInterface>

Check warning on line 18 in panels/notification/server/notificationmanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusInterface> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QProcess>
#include <QTimer>
#include <QLoggingCategory>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
Expand Down Expand Up @@ -44,7 +47,6 @@
: 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);
Expand Down Expand Up @@ -74,6 +76,8 @@
m_systemApps = config->value("systemApps").toStringList();
// TODO temporary fix for AppNamesMap
m_appNamesMap = config->value("AppNamesMap").toMap();

initScreenLockedState();
}

NotificationManager::~NotificationManager()
Expand Down Expand Up @@ -216,8 +220,7 @@
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();
Expand All @@ -232,7 +235,7 @@

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);
Expand Down Expand Up @@ -351,9 +354,8 @@
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"));
Expand Down Expand Up @@ -550,6 +552,26 @@
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<QDBusVariant> 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<NotifyEntity> timeoutEntities;
Expand Down Expand Up @@ -600,4 +622,9 @@
}
}

void NotificationManager::onScreenLockedChanged(bool screenLocked)
{
m_screenLocked = screenLocked;
}

} // notification
10 changes: 4 additions & 6 deletions panels/notification/server/notificationmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@

#pragma once

#include <QObject>
#include <QDBusContext>
#include <QDBusVariant>

#include "sessionmanager1interface.h"

using UserSessionManager = org::deepin::dde::SessionManager1;

class QTimer;
namespace notification {

class NotifyEntity;
Expand Down Expand Up @@ -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<qint64>::max();
QMultiHash<qint64, NotifyEntity> m_pendingTimeoutEntities;
Expand Down
3 changes: 3 additions & 0 deletions panels/notification/server/notifyserverapplet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include "dbusadaptor.h"
#include "pluginfactory.h"

#include <QThread>
#include <QLoggingCategory>

namespace notification {
Q_DECLARE_LOGGING_CATEGORY(notifyLog)
}
Expand Down