diff --git a/dbus/org.kde.screensaver.xml b/dbus/org.kde.screensaver.xml --- a/dbus/org.kde.screensaver.xml +++ b/dbus/org.kde.screensaver.xml @@ -7,5 +7,27 @@ + + + + + + + + + + + + + + + + + + + diff --git a/greeter/greeterapp.h b/greeter/greeterapp.h --- a/greeter/greeterapp.h +++ b/greeter/greeterapp.h @@ -63,6 +63,9 @@ void osdProgress(const QString &icon, int percent, const QString &additionalText); void osdText(const QString &icon, const QString &additionalText); + // we name method notification here instead of the notify, since otherwise + // it gives warning regarding QGuiApplication::notify + void notification(uint id, const QString &appName, uint replacesId, const QString &appIcon, const QString &summary, const QString &body, int timeout); void updateCanSuspend(bool set); void updateCanHibernate(bool set); diff --git a/greeter/greeterapp.cpp b/greeter/greeterapp.cpp --- a/greeter/greeterapp.cpp +++ b/greeter/greeterapp.cpp @@ -667,11 +667,21 @@ reinterpret_cast(data)->updateCanHibernate(hibernate); } +static void notify(void *data, org_kde_ksld *org_kde_ksld, uint id, const char *app_name, + uint replaces_id, const char *app_icon, const char *summary, const char *body, int timeout) +{ + Q_UNUSED(org_kde_ksld) + reinterpret_cast(data)->notification(id, QString::fromUtf8(app_name), replaces_id, + QString::fromUtf8(app_icon), QString::fromUtf8(summary), + QString::fromUtf8(body), timeout); +} + static const struct org_kde_ksld_listener s_listener { osdProgress, osdText, canSuspend, - canHibernate + canHibernate, + notify }; void UnlockApp::setKsldSocket(int socket) @@ -730,6 +740,12 @@ } } +void UnlockApp::notification(uint id, const QString& appName, uint replacesId, const QString& appIcon, const QString& summary, const QString& body, int timeout) +{ + qDebug() << "dummy"; +} + + void UnlockApp::osdText(const QString &icon, const QString &additionalText) { for (auto v : qAsConst(m_views)) { diff --git a/interface.h b/interface.h --- a/interface.h +++ b/interface.h @@ -109,6 +109,12 @@ // org.kde.screensvar void configure(); + // notifications (org.kde.screensaver) + 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); + Q_SIGNALS: // DBus signals void ActiveChanged(bool state); diff --git a/interface.cpp b/interface.cpp --- a/interface.cpp +++ b/interface.cpp @@ -210,5 +210,16 @@ m_lockReplies.clear(); } +void Interface::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 Interface::CloseNotification(uint id) +{ +} + + } // namespace diff --git a/protocols/ksld.xml b/protocols/ksld.xml --- a/protocols/ksld.xml +++ b/protocols/ksld.xml @@ -1,6 +1,6 @@ - + @@ -21,6 +21,22 @@ + + + + + + + + + + + + + diff --git a/waylandserver.h b/waylandserver.h --- a/waylandserver.h +++ b/waylandserver.h @@ -21,6 +21,7 @@ #define SCREENLOCKER_WAYLANDSERVER_H #include +#include struct wl_client; struct wl_global; @@ -53,6 +54,9 @@ private Q_SLOTS: void osdProgress(const QString &icon, int percent, const QString &additionalText); void osdText(const QString &icon, const QString &additionalText); + void notify(uint id, const QString &appName, uint &replacesId, + const QString &appIcon, const QString &summary, const QString &body, + const QStringList &actions, const QVariantMap &hints, int timeout); private: static void bind(wl_client *client, void *data, uint32_t version, uint32_t id); diff --git a/waylandserver.cpp b/waylandserver.cpp --- a/waylandserver.cpp +++ b/waylandserver.cpp @@ -88,7 +88,7 @@ return -1; } connect(m_allowedClient, &KWayland::Server::ClientConnection::disconnected, this, [this] { m_allowedClient = nullptr; }); - m_interface = wl_global_create(*m_display.data(), &org_kde_ksld_interface, 3, this, bind); + m_interface = wl_global_create(*m_display.data(), &org_kde_ksld_interface, 4, this, bind); return socketPair[1]; } @@ -113,7 +113,7 @@ wl_client_post_no_memory(client); return; } - wl_resource *r = s->m_allowedClient->createResource(&org_kde_ksld_interface, qMin(version, 3u), id); + wl_resource *r = s->m_allowedClient->createResource(&org_kde_ksld_interface, qMin(version, 4u), id); if (!r) { wl_client_post_no_memory(client); return; @@ -197,6 +197,22 @@ } } +void WaylandServer::notify(uint id, const QString &appName, uint &replacesId, + const QString &appIcon, const QString &summary, const QString &body, + const QStringList &actions, const QVariantMap &hints, int timeout) +{ + if (!m_allowedClient) { + return; + } + Q_FOREACH (auto r, m_resources) { + if (wl_resource_get_version(r) < ORG_KDE_KSLD_NOTIFY_SINCE_VERSION) { + continue; + } + org_kde_ksld_send_notify(r, id, appName.toUtf8().constData(), replacesId, appIcon.toUtf8().constData(), + summary.toUtf8().constData(), body.toUtf8().constData(), timeout); + } +} + void WaylandServer::sendCanSuspend() { if (!m_allowedClient) {