From 8ceebd625229e18de791ea2cc0445cd6691db069 Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 12 Jul 2015 02:18:25 +0200 Subject: load category, add additional nemo fields --- notification.cpp | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) (limited to 'notification.cpp') diff --git a/notification.cpp b/notification.cpp index 51d5325..ba8456e 100644 --- a/notification.cpp +++ b/notification.cpp @@ -16,11 +16,26 @@ * along with this program. If not, see . */ +#include +#include +#include #include "notification.h" namespace watchfish { +namespace +{ +struct Action +{ + QString service; + QString path; + QString iface; + QString method; + QStringList args; +}; +} + struct NotificationPrivate { uint id; @@ -29,6 +44,11 @@ struct NotificationPrivate QString body; QDateTime timestamp; QString icon; + quint8 urgency; + bool transient; + QString previewSummary; + QString previewBody; + QHash actions; }; Notification::Notification(uint id, QObject *parent) : QObject(parent), d_ptr(new NotificationPrivate) @@ -122,4 +142,107 @@ void Notification::setIcon(const QString &icon) } } +int Notification::urgency() const +{ + Q_D(const Notification); + return d->urgency; +} + +void Notification::setUrgency(int urgency) +{ + Q_D(Notification); + if (urgency != d->urgency) { + d->urgency = urgency; + emit urgencyChanged(); + } +} + +bool Notification::transient() const +{ + Q_D(const Notification); + return d->transient; +} + +void Notification::setTransient(bool transient) +{ + Q_D(Notification); + if (transient != d->transient) { + d->transient = transient; + emit transientChanged(); + } +} + +QString Notification::previewSummary() const +{ + Q_D(const Notification); + return d->previewSummary; +} + +void Notification::setPreviewSummary(const QString &summary) +{ + Q_D(Notification); + if (summary != d->previewSummary) { + d->previewSummary = summary; + emit previewSummaryChanged(); + } +} + +QString Notification::previewBody() const +{ + Q_D(const Notification); + return d->previewBody; +} + +void Notification::setPreviewBody(const QString &body) +{ + Q_D(Notification); + if (body != d->previewBody) { + d->previewBody = body; + emit previewBodyChanged(); + } +} + +QStringList Notification::actions() const +{ + Q_D(const Notification); + return d->actions.keys(); +} + +void Notification::addDBusAction(const QString &action, const QString &service, const QString &path, const QString &iface, const QString &method, const QStringList &args) +{ + Q_D(Notification); + Action &a = d->actions[action]; + a.service = service; + a.path = path; + a.iface = iface; + a.method = method; + a.args = args; +} + +void Notification::invokeAction(const QString &action) +{ + Q_D(Notification); + if (d->actions.contains(action)) { + const Action &a = d->actions[action]; + if (!a.service.isEmpty()) { + QDBusMessage msg = QDBusMessage::createMethodCall(a.service, a.path, a.iface, a.method); + foreach (const QString &arg, a.args) { + msg << arg; + } + QDBusConnection::sessionBus().asyncCall(msg); + } + } +} + +void Notification::close() +{ + Q_D(Notification); + QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.Notifications", + "/org/freedesktop/Notifications", + "org.freedesktop.Notifications", + "CloseNotification"); + msg << quint32(d->id); + QDBusConnection::sessionBus().asyncCall(msg); +} + } -- cgit v1.2.3