diff options
author | Javier <dev.git@javispedro.com> | 2015-07-12 02:18:25 +0200 |
---|---|---|
committer | Javier <dev.git@javispedro.com> | 2015-07-12 02:18:25 +0200 |
commit | 8ceebd625229e18de791ea2cc0445cd6691db069 (patch) | |
tree | 6b86545b81f61e41b97def0f77df7572bf371547 /notification.cpp | |
parent | 28a02ed82d1ede2c242c105a86f80c90515bde3b (diff) | |
download | libwatchfish-8ceebd625229e18de791ea2cc0445cd6691db069.tar.gz libwatchfish-8ceebd625229e18de791ea2cc0445cd6691db069.zip |
load category, add additional nemo fields
Diffstat (limited to 'notification.cpp')
-rw-r--r-- | notification.cpp | 123 |
1 files changed, 123 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>. */ +#include <QtDBus/QDBusConnection> +#include <QtDBus/QDBusPendingCall> +#include <QtDBus/QDBusMessage> #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<QString, Action> 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); +} + } |