diff --git a/libnotificationmanager/CMakeLists.txt b/libnotificationmanager/CMakeLists.txt --- a/libnotificationmanager/CMakeLists.txt +++ b/libnotificationmanager/CMakeLists.txt @@ -52,6 +52,8 @@ qt5_add_dbus_adaptor(notificationmanager_LIB_SRCS dbus/org.kde.JobViewServerV2.xml jobsmodel_p.h NotificationManager::JobsModelPrivate) qt5_add_dbus_adaptor(notificationmanager_LIB_SRCS dbus/org.kde.JobViewV2.xml job_p.h NotificationManager::JobPrivate) qt5_add_dbus_adaptor(notificationmanager_LIB_SRCS dbus/org.kde.JobViewV3.xml job_p.h NotificationManager::JobPrivate) +# Lockscreen +qt5_add_dbus_interface(notificationmanager_LIB_SRCS ${KSCREENLOCKER_DBUS_INTERFACES_DIR}/org.kde.screensaver.Greeter.xml greeter_interface ) add_library(notificationmanager ${notificationmanager_LIB_SRCS}) add_library(PW::LibNotificationManager ALIAS notificationmanager) diff --git a/libnotificationmanager/notification.h b/libnotificationmanager/notification.h --- a/libnotificationmanager/notification.h +++ b/libnotificationmanager/notification.h @@ -106,6 +106,8 @@ bool userActionFeedback() const; + bool showOnLockscreen() const; + int timeout() const; void setTimeout(int timeout); diff --git a/libnotificationmanager/notification.cpp b/libnotificationmanager/notification.cpp --- a/libnotificationmanager/notification.cpp +++ b/libnotificationmanager/notification.cpp @@ -386,6 +386,9 @@ read = true; } + // if notification is supposed to be shown on lockscreen, set show on lockscreen + showOnLockScreen = hints.value(QStringLiteral("x-kde-show-on-lockscreen")).toBool(); + urls = QUrl::fromStringList(hints.value(QStringLiteral("x-kde-urls")).toStringList()); replyPlaceholderText = hints.value(QStringLiteral("x-kde-reply-placeholder-text")).toString(); @@ -684,6 +687,11 @@ return d->userActionFeedback; } +bool Notification::showOnLockscreen() const +{ + return d->showOnLockScreen; +} + int Notification::timeout() const { return d->timeout; diff --git a/libnotificationmanager/notification_p.h b/libnotificationmanager/notification_p.h --- a/libnotificationmanager/notification_p.h +++ b/libnotificationmanager/notification_p.h @@ -99,6 +99,7 @@ QList urls; bool userActionFeedback = false; + bool showOnLockScreen = false; Notifications::Urgency urgency = Notifications::NormalUrgency; int timeout = -1; diff --git a/libnotificationmanager/server_p.cpp b/libnotificationmanager/server_p.cpp --- a/libnotificationmanager/server_p.cpp +++ b/libnotificationmanager/server_p.cpp @@ -23,6 +23,7 @@ #include "debug.h" #include "notificationsadaptor.h" +#include "greeter_interface.h" #include "notification.h" #include "notification_p.h" @@ -223,11 +224,26 @@ emit static_cast(parent())->notificationAdded(notification); } + // we check if notification should be shown on lockscreen? if so we forward this to ksld + if (notification.showOnLockscreen()) { + OrgKdeScreensaverGreeterInterface iface(QStringLiteral("org.kde.screensaver.Greeter"), + QStringLiteral("/Greeter"), QDBusConnection::sessionBus()); + iface.Notify(notificationId, notification.applicationName(), replaces_id, notification.applicationIconName(), + notification.summary(), notification.body(), notification.actionNames(), + hints, notification.timeout()); + } + return notificationId; } void ServerPrivate::CloseNotification(uint id) { + // here we notify to ksldapp regardless if notification was shown on the lockscreen + // to simplify the code base, if notification with id doesn't exist on the ksld, it can + // just ignore it. + OrgKdeScreensaverGreeterInterface iface(QStringLiteral("org.kde.screensaver.Greeter"), + QStringLiteral("/Greeter"), QDBusConnection::sessionBus()); + iface.CloseNotification(id); // spec says "If the notification no longer exists, an empty D-BUS Error message is sent back." static_cast(parent())->closeNotification(id, Server::CloseReason::Revoked); } @@ -247,6 +263,7 @@ QStringLiteral("x-kde-urls"), QStringLiteral("x-kde-origin-name"), QStringLiteral("x-kde-display-appname"), + QStringLiteral("x-kde-show-on-lockscreen"), QStringLiteral("inhibitions") };