|
|
|
@ -1,15 +1,14 @@ |
|
|
|
|
#include "notifications/Manager.h" |
|
|
|
|
|
|
|
|
|
#include <QImage> |
|
|
|
|
#include <QDebug> |
|
|
|
|
#include <QImage> |
|
|
|
|
#include <QtDBus/QDBusConnection> |
|
|
|
|
#include <QtDBus/QDBusMessage> |
|
|
|
|
#include <QtDBus/QDBusMetaType> |
|
|
|
|
#include <QtDBus/QDBusConnection> |
|
|
|
|
|
|
|
|
|
NotificationsManager::NotificationsManager(QObject *parent) : |
|
|
|
|
QObject(parent), |
|
|
|
|
dbus( |
|
|
|
|
"org.freedesktop.Notifications", |
|
|
|
|
NotificationsManager::NotificationsManager(QObject *parent) |
|
|
|
|
: QObject(parent) |
|
|
|
|
, dbus("org.freedesktop.Notifications", |
|
|
|
|
"/org/freedesktop/Notifications", |
|
|
|
|
"org.freedesktop.Notifications", |
|
|
|
|
QDBusConnection::sessionBus(), |
|
|
|
@ -17,17 +16,13 @@ NotificationsManager::NotificationsManager(QObject *parent) : |
|
|
|
|
{ |
|
|
|
|
qDBusRegisterMetaType<QImage>(); |
|
|
|
|
|
|
|
|
|
//connectSlot("ActionInvoked", SLOT(actionInvoked(uint, QString)));
|
|
|
|
|
//connectSlot("NotificationClosed", SLOT(notificationClosed(uint, uint)));
|
|
|
|
|
QDBusConnection::sessionBus().connect( |
|
|
|
|
"org.freedesktop.Notifications", |
|
|
|
|
QDBusConnection::sessionBus().connect("org.freedesktop.Notifications", |
|
|
|
|
"/org/freedesktop/Notifications", |
|
|
|
|
"org.freedesktop.Notifications", |
|
|
|
|
"ActionInvoked", |
|
|
|
|
this, |
|
|
|
|
SLOT(actionInvoked(uint, QString))); |
|
|
|
|
QDBusConnection::sessionBus().connect( |
|
|
|
|
"org.freedesktop.Notifications", |
|
|
|
|
QDBusConnection::sessionBus().connect("org.freedesktop.Notifications", |
|
|
|
|
"/org/freedesktop/Notifications", |
|
|
|
|
"org.freedesktop.Notifications", |
|
|
|
|
"NotificationClosed", |
|
|
|
@ -53,7 +48,9 @@ NotificationsManager::postNotification(const QString &roomid, |
|
|
|
|
* Licensed under the GNU General Public License, version 3 |
|
|
|
|
*/ |
|
|
|
|
uint |
|
|
|
|
NotificationsManager::showNotification(const QString summary, const QString text, const QImage image) |
|
|
|
|
NotificationsManager::showNotification(const QString summary, |
|
|
|
|
const QString text, |
|
|
|
|
const QImage image) |
|
|
|
|
{ |
|
|
|
|
QVariantMap hints; |
|
|
|
|
hints["image_data"] = image; |
|
|
|
@ -67,14 +64,11 @@ NotificationsManager::showNotification(const QString summary, const QString text |
|
|
|
|
argumentList << hints; // hints
|
|
|
|
|
argumentList << (int)0; // timeout in ms
|
|
|
|
|
|
|
|
|
|
static QDBusInterface notifyApp( |
|
|
|
|
"org.freedesktop.Notifications", |
|
|
|
|
static QDBusInterface notifyApp("org.freedesktop.Notifications", |
|
|
|
|
"/org/freedesktop/Notifications", |
|
|
|
|
"org.freedesktop.Notifications"); |
|
|
|
|
QDBusMessage reply = notifyApp.callWithArgumentList( |
|
|
|
|
QDBus::AutoDetect, |
|
|
|
|
"Notify", |
|
|
|
|
argumentList); |
|
|
|
|
QDBusMessage reply = |
|
|
|
|
notifyApp.callWithArgumentList(QDBus::AutoDetect, "Notify", argumentList); |
|
|
|
|
if (reply.type() == QDBusMessage::ErrorMessage) { |
|
|
|
|
qDebug() << "D-Bus Error:" << reply.errorMessage(); |
|
|
|
|
return 0; |
|
|
|
@ -109,7 +103,9 @@ NotificationsManager::notificationClosed(uint id, uint reason) |
|
|
|
|
* |
|
|
|
|
* Copyright 2010, David Sansome <me@davidsansome.com> |
|
|
|
|
*/ |
|
|
|
|
QDBusArgument& operator<<(QDBusArgument& arg, const QImage& image) { |
|
|
|
|
QDBusArgument & |
|
|
|
|
operator<<(QDBusArgument &arg, const QImage &image) |
|
|
|
|
{ |
|
|
|
|
if (image.isNull()) { |
|
|
|
|
arg.beginStructure(); |
|
|
|
|
arg << 0 << 0 << 0 << false << 0 << 0 << QByteArray(); |
|
|
|
@ -151,7 +147,9 @@ QDBusArgument& operator<<(QDBusArgument& arg, const QImage& image) { |
|
|
|
|
return arg; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const QDBusArgument& operator>>(const QDBusArgument& arg, QImage&) { |
|
|
|
|
const QDBusArgument & |
|
|
|
|
operator>>(const QDBusArgument &arg, QImage &) |
|
|
|
|
{ |
|
|
|
|
// This is needed to link but shouldn't be called.
|
|
|
|
|
Q_ASSERT(0); |
|
|
|
|
return arg; |
|
|
|
|