The session-bus server for org.freedesktop.Notifications (Desktop Notifications Spec 1.3). More...
#include <PhosphorServiceNotifications/NotificationServer.h>
Public Slots | |
| uint | Notify (const QString &appName, uint replacesId, const QString &appIcon, const QString &summary, const QString &body, const QStringList &actions, const QVariantMap &hints, int expireTimeout, const QString &sender=QString()) |
| void | CloseNotification (uint id) |
| QStringList | GetCapabilities () |
| QString | GetServerInformation (QString &vendor, QString &version, QString &specVersion) |
Signals | |
| void | notificationAdded (Notification *notification) |
| A fresh notification (new id) was ingested and decoded. | |
| void | NotificationClosed (uint id, uint reason) |
A notification was closed; reason is the spec close-reason code (1 expired, 2 dismissed, 3 closed by CloseNotification, 4 undefined). | |
| void | ActionInvoked (uint id, const QString &actionKey) |
The user invoked action actionKey on notification id. | |
| void | ActivationToken (uint id, const QString &activationToken) |
Carries the XDG activation token for id ahead of an ActionInvoked, so the activated app can raise its window. | |
| void | replySent (uint id, const QString &text) |
| Local confirmation only. Reply text is sent as a targeted D-Bus signal. | |
| void | nameAcquiredChanged () |
| void | defaultExpireTimeoutChanged () |
Public Member Functions | |
| NotificationServer (QObject *parent=nullptr) | |
| Construct on the session bus under the spec's well-known name. | |
| NotificationServer (QDBusConnection connection, QString service, QObject *parent=nullptr) | |
| Dependency-injected ctor (tests drive a private peer-to-peer bus, so the whole ingest path runs with no real session daemon and no name conflict). | |
| ~NotificationServer () override | |
| bool | nameAcquired () const |
| True once this process owns the well-known name and is the active notification server. | |
| bool | acquireName (bool replaceExisting=false) |
| (Re)acquire the well-known name. | |
| QList< Notification * > | notifications () const |
| The live notifications, in ascending id order. | |
| int | defaultExpireTimeout () const |
| Timeout (ms) applied to a Notify whose expire_timeout is -1 (the spec's "server decides"). | |
| void | setDefaultExpireTimeout (int ms) |
| void | dismissNotification (uint id) |
The user dismissed id (close reason 2): for a shell/toast to call when the user swipes or clicks the notification away. | |
| void | invokeAction (uint id, const QString &actionKey, const QString &activationToken=QString()) |
Invoke actionKey on id. | |
| bool | reply (uint id, const QString &text) |
| KDE inline-reply extension; only advertised actions accept replies. | |
| void | setExpiryPaused (uint id, bool paused) |
| Preserve the remaining lifetime while a surface is being read/edited. | |
Static Public Member Functions | |
| static QString | serviceName () |
| The well-known name + object path defined by the spec. | |
| static QString | objectPath () |
The session-bus server for org.freedesktop.Notifications (Desktop Notifications Spec 1.3).
This library OWNS the well-known name org.freedesktop.Notifications and answers it: it is the notification daemon, not a client of one. Because exactly one process may own the name, a notification daemon already running (dunst / mako / Plasma) is a hard conflict, surfaced as nameAcquired() == false rather than a degraded backend. The server then stays inert.
The four spec methods are exported through NotificationsAdaptor, which forwards synchronous calls and records their transport sender. Standard action/close signals are relayed; inline reply text is sent only to its origin.
Notify decodes the hint set (including the image-data → QImage path) into a typed Notification, allocates ids, and updates in place on replaces_id. Notifications expire per their expire_timeout (Critical never auto-expires), can be dismissed or have an action invoked, and are exposed as a list through NotificationModel.
|
explicit |
Construct on the session bus under the spec's well-known name.
| PhosphorServiceNotifications::NotificationServer::NotificationServer | ( | QDBusConnection | connection, |
| QString | service, | ||
| QObject * | parent = nullptr ) |
Dependency-injected ctor (tests drive a private peer-to-peer bus, so the whole ingest path runs with no real session daemon and no name conflict).
|
override |
| bool PhosphorServiceNotifications::NotificationServer::acquireName | ( | bool | replaceExisting = false | ) |
(Re)acquire the well-known name.
The constructor calls this with replaceExisting false (inert when the name is taken). A daemon that wants to take over from another notification server (the CLI's --replace path) calls it with true, which succeeds when the current owner allows replacement. Returns nameAcquired(). A no-op once the name is held.
|
signal |
The user invoked action actionKey on notification id.
Auto-relayed to the bus by the adaptor.
|
signal |
Carries the XDG activation token for id ahead of an ActionInvoked, so the activated app can raise its window.
Auto-relayed by the adaptor.
|
slot |
|
nodiscard |
Timeout (ms) applied to a Notify whose expire_timeout is -1 (the spec's "server decides").
Critical notifications ignore this and never auto-expire. Default 5000. Changing it affects only future notifications, not timers already armed.
|
signal |
| void PhosphorServiceNotifications::NotificationServer::dismissNotification | ( | uint | id | ) |
The user dismissed id (close reason 2): for a shell/toast to call when the user swipes or clicks the notification away.
Q_INVOKABLE (not a slot) so it is callable from QML/CLI but never exported on the bus.
|
nodiscardslot |
|
slot |
| void PhosphorServiceNotifications::NotificationServer::invokeAction | ( | uint | id, |
| const QString & | actionKey, | ||
| const QString & | activationToken = QString() ) |
Invoke actionKey on id.
When activationToken is non-empty it is announced via ActivationToken(id, token) first (XDG activation, so the target app can raise its window), then ActionInvoked(id, key). A non-resident notification is closed afterwards (reason 2); a resident one stays open. Q_INVOKABLE, not a slot: callable from QML/CLI, never exported (the bluetooth Agent1 keeps its respond* methods off the bus the same way).
|
nodiscard |
True once this process owns the well-known name and is the active notification server.
False when another daemon holds it (see class docs).
|
signal |
|
signal |
A fresh notification (new id) was ingested and decoded.
A replaces_id update does NOT re-emit this; it mutates the existing object in place and fires that object's Notification::changed() instead.
|
signal |
A notification was closed; reason is the spec close-reason code (1 expired, 2 dismissed, 3 closed by CloseNotification, 4 undefined).
Auto-relayed to the bus by the adaptor. The matching object is deleted right after this fires, so consumers must drop their pointer here.
|
nodiscard |
The live notifications, in ascending id order.
Each is owned by this server; the list is a snapshot (pointers stay valid until the matching NotificationClosed fires). The NotificationModel (milestone 5) seeds itself from this and tracks notificationAdded / NotificationClosed.
|
slot |
|
staticnodiscard |
| bool PhosphorServiceNotifications::NotificationServer::reply | ( | uint | id, |
| const QString & | text ) |
KDE inline-reply extension; only advertised actions accept replies.
|
signal |
Local confirmation only. Reply text is sent as a targeted D-Bus signal.
|
staticnodiscard |
The well-known name + object path defined by the spec.
| void PhosphorServiceNotifications::NotificationServer::setDefaultExpireTimeout | ( | int | ms | ) |
| void PhosphorServiceNotifications::NotificationServer::setExpiryPaused | ( | uint | id, |
| bool | paused ) |
Preserve the remaining lifetime while a surface is being read/edited.