summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/notificationmonitor.cpp10
-rw-r--r--src/notificationmonitor.h5
-rw-r--r--src/org.freedesktop.Notifications.xml2
3 files changed, 13 insertions, 4 deletions
diff --git a/src/notificationmonitor.cpp b/src/notificationmonitor.cpp
index b0f66c9..566143f 100644
--- a/src/notificationmonitor.cpp
+++ b/src/notificationmonitor.cpp
@@ -34,12 +34,18 @@ NotificationMonitor *NotificationMonitor::instance()
return global_monitor;
}
-void NotificationMonitor::Notify(const QString &app_name, uint replaces_id, const QString &app_icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantHash &hints, int expire_timeout)
+uint NotificationMonitor::Notify(const QString &app_name, uint replaces_id, const QString &app_icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantHash &hints, int expire_timeout)
{
QIcon icon;
qDebug() << "Got notification" << app_name << app_icon << summary << body;
+ // Avoid sending a reply for this method call, since we've received it
+ // because we're eavesdropping.
+ // The actual target of the method call will send the proper reply, not us.
+ Q_ASSERT(calledFromDBus());
+ setDelayedReply(true);
+
if (app_icon.startsWith("/")) {
icon = QIcon(app_icon);
} else if (app_icon.startsWith("file:")) {
@@ -50,4 +56,6 @@ void NotificationMonitor::Notify(const QString &app_name, uint replaces_id, cons
}
emit incomingNotification(app_name, icon, summary, body);
+
+ return 0;
}
diff --git a/src/notificationmonitor.h b/src/notificationmonitor.h
index cfa0e17..84f237a 100644
--- a/src/notificationmonitor.h
+++ b/src/notificationmonitor.h
@@ -2,8 +2,9 @@
#define NOTIFICATIONMONITOR_H
#include <QtCore/QObject>
+#include <QtDBus/QDBusContext>
-class NotificationMonitor : public QObject
+class NotificationMonitor : public QObject, protected QDBusContext
{
Q_OBJECT
@@ -20,7 +21,7 @@ private:
private slots:
friend class NotificationsAdaptor;
- void Notify(const QString &app_name, uint replaces_id, const QString &app_icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantHash &hints, int expire_timeout);
+ uint Notify(const QString &app_name, uint replaces_id, const QString &app_icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantHash &hints, int expire_timeout);
};
#endif // NOTIFICATIONMONITOR_H
diff --git a/src/org.freedesktop.Notifications.xml b/src/org.freedesktop.Notifications.xml
index 456fd42..d3f8bef 100644
--- a/src/org.freedesktop.Notifications.xml
+++ b/src/org.freedesktop.Notifications.xml
@@ -11,7 +11,7 @@
<arg name="actions" type="as" direction="in"/>
<arg name="hints" type="a{sv}" direction="in"/>
<arg name="expire_timeout" type="i" direction="in"/>
- <!-- Not needed for eavesdropping: <arg name="id" type="u" direction="out"/> -->
+ <arg name="id" type="u" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In6" value="QVariantHash"/>
</method>
</node>