From 6a581ace4f14c30f1c66daf28064d7aefde546fc Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Sun, 14 Sep 2014 20:56:29 +0200 Subject: simplify notification monitoring for now --- src/notificationmonitor.cpp | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) (limited to 'src/notificationmonitor.cpp') diff --git a/src/notificationmonitor.cpp b/src/notificationmonitor.cpp index 50f7b91..50b2e3e 100644 --- a/src/notificationmonitor.cpp +++ b/src/notificationmonitor.cpp @@ -1,33 +1,25 @@ #include #include #include - #include "notificationmonitor.h" static NotificationMonitor *global_monitor = 0; -namespace -{ - -} - NotificationMonitor::NotificationMonitor(QObject *parent) : QObject(parent) { QDBusConnection bus = QDBusConnection::sessionBus(); - - _watcher = new QDBusServiceWatcher("org.freedesktop.Notifications", bus, - QDBusServiceWatcher::WatchForOwnerChange, - this); - connect(_watcher, &QDBusServiceWatcher::serviceOwnerChanged, - this, &NotificationMonitor::handleServiceOwnerChanged); - - bus.interface()->call("AddMatch", - "interface='org.freedesktop.Notifications',member='Notify',type='method_call',eavesdrop='true'"); + QDBusConnectionInterface *dbus = bus.interface(); + dbus->call("AddMatch", + "interface='org.freedesktop.Notifications',member='Notify',type='method_call',eavesdrop='true'"); } NotificationMonitor::~NotificationMonitor() { + QDBusConnection bus = QDBusConnection::sessionBus(); + QDBusConnectionInterface *dbus = bus.interface(); + dbus->call("RemoveMatch", + "interface='org.freedesktop.Notifications',member='Notify',type='method_call',eavesdrop='true'"); } NotificationMonitor *NotificationMonitor::instance() @@ -37,8 +29,3 @@ NotificationMonitor *NotificationMonitor::instance() } return global_monitor; } - -void NotificationMonitor::handleServiceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner) -{ - qDebug() << "Service owner changed" << serviceName << oldOwner << newOwner; -} -- cgit v1.2.3