diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -274,7 +274,6 @@ install(FILES ${kscreensaver_dbusXML} DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR}) - install(FILES updaters/kscreenlocker.upd DESTINATION ${KDE_INSTALL_DATADIR}/kconf_update) install(PROGRAMS updaters/ksreenlocker_5_3_separate_autologin.pl DESTINATION ${KDE_INSTALL_DATADIR}/kconf_update) diff --git a/dbus/org.freedesktop.Notifications.xml b/dbus/org.freedesktop.Notifications.xml new file mode 100644 --- /dev/null +++ b/dbus/org.freedesktop.Notifications.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dbus/org.kde.screensaver.Greeter.xml b/dbus/org.kde.screensaver.Greeter.xml new file mode 100644 --- /dev/null +++ b/dbus/org.kde.screensaver.Greeter.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/greeter/CMakeLists.txt b/greeter/CMakeLists.txt --- a/greeter/CMakeLists.txt +++ b/greeter/CMakeLists.txt @@ -1,6 +1,9 @@ remove_definitions(-DTRANSLATION_DOMAIN=\"kscreenlocker\") add_definitions(-DTRANSLATION_DOMAIN=\"kscreenlocker_greet\") +set(greeter_dbusXML ../dbus/org.kde.screensaver.Greeter.xml) +set(fdo_notifications_xml ../dbus/org.freedesktop.Notifications.xml) + include_directories( ${CMAKE_CURRENT_BINARY_DIR} ../kcheckpass @@ -15,8 +18,12 @@ lnf_integration.cpp wallpaper_integration.cpp kwinglplatform.cpp + notifications.cpp ) +qt5_add_dbus_adaptor(kscreenlocker_greet_SRCS ${greeter_dbusXML} greeterapp.h ScreenLocker::UnlockApp greeteradapter GreeterAdapter) +qt5_add_dbus_interface(kscreenlocker_greet_SRCS ${fdo_notifications_xml} notifications_interface) + if(HAVE_SECCOMP) set(kscreenlocker_greet_SRCS ${kscreenlocker_greet_SRCS} seccomp_filter.cpp) endif() @@ -52,6 +59,9 @@ install(TARGETS kscreenlocker_greet DESTINATION ${KDE_INSTALL_LIBEXECDIR}) +install(FILES ${greeter_dbusXML} + DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR}) + install(DIRECTORY themes/org.kde.passworddialog DESTINATION ${KDE_INSTALL_DATADIR}/ksmserver/screenlocker) add_subdirectory(autotests) diff --git a/greeter/greeterapp.h b/greeter/greeterapp.h --- a/greeter/greeterapp.h +++ b/greeter/greeterapp.h @@ -44,6 +44,7 @@ { class WallpaperIntegration; class LnFIntegration; +class Notifications; class UnlockApp : public QGuiApplication { @@ -73,6 +74,12 @@ public Q_SLOTS: void desktopResized(); + // dbus + void Notify(uint id, const QString &app_name, uint replaces_id, const QString &app_icon, + const QString &summary, const QString &body, const QStringList &actions, + const QVariantMap &hints, int timeout); + void CloseNotification(uint id); + protected: bool eventFilter(QObject *obj, QEvent *event) override; @@ -120,6 +127,8 @@ WallpaperIntegration *m_wallpaperIntegration; LnFIntegration *m_lnfIntegration; + Notifications *m_notification = nullptr; + bool m_supportsSeccomp = false; }; } // namespace diff --git a/greeter/greeterapp.cpp b/greeter/greeterapp.cpp --- a/greeter/greeterapp.cpp +++ b/greeter/greeterapp.cpp @@ -19,11 +19,13 @@ along with this program. If not, see . *********************************************************************/ #include "greeterapp.h" +#include "greeteradapter.h" #include "kscreensaversettingsbase.h" #include "authenticator.h" #include "noaccessnetworkaccessmanagerfactory.h" #include "wallpaper_integration.h" #include "lnf_integration.h" +#include "notifications.h" #include @@ -123,6 +125,7 @@ , m_defaultToSwitchUser(false) , m_wallpaperIntegration(new WallpaperIntegration(this)) , m_lnfIntegration(new LnFIntegration(this)) + , m_notification(new Notifications(this)) { m_authenticator = createAuthenticator(); connect(m_authenticator, &Authenticator::succeeded, this, &QCoreApplication::quit); @@ -133,6 +136,10 @@ if (QX11Info::isPlatformX11()) { installNativeEventFilter(new FocusOutEventFilter); } + + (void) new GreeterAdapter(this); + QDBusConnection::sessionBus().registerObject(QStringLiteral("/Greeter"), this); + QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.screensaver.Greeter")); } UnlockApp::~UnlockApp() @@ -340,6 +347,7 @@ context->setContextProperty(QStringLiteral("org_kde_plasma_screenlocker_greeter_view"), view); context->setContextProperty(QStringLiteral("defaultToSwitchUser"), m_defaultToSwitchUser); context->setContextProperty(QStringLiteral("config"), m_lnfIntegration->configuration()); + context->setContextProperty(QStringLiteral("notifications"), m_notification); view->setSource(m_mainQmlPath); // on error, load the fallback lockscreen to not lock the user out of the system @@ -479,6 +487,25 @@ } } +void UnlockApp::Notify(uint id, const QString &app_name, uint replaces_id, const QString &app_icon, + const QString &summary, const QString &body, const QStringList &actions, + const QVariantMap &hints, int timeout) +{ + if (!m_notification) { + return; + } + // trigger signal notification of the ScreenLocker::Notifications object + Q_EMIT m_notification->notification(id, app_name, replaces_id, app_icon, summary, body, actions, hints, timeout); +} + +void UnlockApp::CloseNotification(uint id) +{ + if (!m_notification) { + return; + } + Q_EMIT m_notification->closeNotification(id); +} + void UnlockApp::resetRequestIgnore() { m_ignoreRequests = false; diff --git a/greeter/notifications.h b/greeter/notifications.h new file mode 100644 --- /dev/null +++ b/greeter/notifications.h @@ -0,0 +1,46 @@ +/******************************************************************** + KSld - the KDE Screenlocker Daemon + This file is part of the KDE project. + +Copyright (C) 2020 Shah Bhushan + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*********************************************************************/ +#ifndef NOTIFICATION_H +#define NOTIFICATION_H + +#include + +namespace ScreenLocker +{ + +class Notifications : public QObject +{ + Q_OBJECT +public: + explicit Notifications(QObject *parent); + +Q_SIGNALS: + // used by greeterapp + void notification(uint id, const QString &app_name, uint replaces_id, const QString &app_icon, + const QString &summary, const QString &body, const QStringList &actions, + const QVariantMap &hints, int timeout); + void closeNotification(uint id); + +public Q_SLOTS: + // used by the greeter theme + void triggerAction(uint id, const QString &action_key); +}; +} +#endif diff --git a/greeter/notifications.cpp b/greeter/notifications.cpp new file mode 100644 --- /dev/null +++ b/greeter/notifications.cpp @@ -0,0 +1,41 @@ +/******************************************************************** + KSld - the KDE Screenlocker Daemon + This file is part of the KDE project. + +Copyright (C) 2020 Shah Bhushan + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*********************************************************************/ + +#include "notifications.h" + +#include "notifications_interface.h" + +namespace ScreenLocker +{ + +Notifications::Notifications(QObject* parent) + : QObject(parent) +{ +} + +void Notifications::triggerAction(uint id, const QString &action_key) +{ + OrgFreedesktopNotificationsInterface iface(QStringLiteral("org.freedesktop.Notifications"), + QStringLiteral("/org/freedesktop/Notifications"), + QDBusConnection::sessionBus()); + iface.ActionInvoked(id, action_key); +} + +}