summaryrefslogtreecommitdiff
path: root/notification.cpp
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-07-12 02:18:25 +0200
committerJavier <dev.git@javispedro.com>2015-07-12 02:18:25 +0200
commit8ceebd625229e18de791ea2cc0445cd6691db069 (patch)
tree6b86545b81f61e41b97def0f77df7572bf371547 /notification.cpp
parent28a02ed82d1ede2c242c105a86f80c90515bde3b (diff)
downloadlibwatchfish-8ceebd625229e18de791ea2cc0445cd6691db069.tar.gz
libwatchfish-8ceebd625229e18de791ea2cc0445cd6691db069.zip
load category, add additional nemo fields
Diffstat (limited to 'notification.cpp')
-rw-r--r--notification.cpp123
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);
+}
+
}