diff options
author | Javier S. Pedro <dev.git@javispedro.com> | 2014-09-20 19:28:34 +0200 |
---|---|---|
committer | Javier S. Pedro <dev.git@javispedro.com> | 2014-09-20 19:28:34 +0200 |
commit | 4a79b503f107632dd1b2204499a31e91b86dd0e4 (patch) | |
tree | 590fba5987f24366fa1ab0712e21eb536bafea1c | |
parent | 7ce4bd53266444ddcc58a70d9ddcf71fbd2c06bb (diff) | |
download | salmeta-4a79b503f107632dd1b2204499a31e91b86dd0e4.tar.gz salmeta-4a79b503f107632dd1b2204499a31e91b86dd0e4.zip |
fix for "dup notifications in event view" bug
avoid sending a reply for eavesdropped method calls
-rw-r--r-- | src/notificationmonitor.cpp | 10 | ||||
-rw-r--r-- | src/notificationmonitor.h | 5 | ||||
-rw-r--r-- | src/org.freedesktop.Notifications.xml | 2 |
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> |