#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'"); } NotificationMonitor::~NotificationMonitor() { } NotificationMonitor *NotificationMonitor::instance() { if (!global_monitor) { global_monitor = new NotificationMonitor; } return global_monitor; } void NotificationMonitor::handleServiceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner) { qDebug() << "Service owner changed" << serviceName << oldOwner << newOwner; }