diff --git a/src/libsnore/notification/notification_p.cpp b/src/libsnore/notification/notification_p.cpp index d686d68..f312290 100644 --- a/src/libsnore/notification/notification_p.cpp +++ b/src/libsnore/notification/notification_p.cpp @@ -113,3 +113,22 @@ bool NotificationData::isBroadcasted() const return m_isBroadcasted; } +void NotificationData::setSource(SnorePlugin *soure) +{ + m_source = soure; +} + +const SnorePlugin *NotificationData::source() const +{ + return m_source; +} + +bool NotificationData::sourceAndTargetAreSimilar(const SnorePlugin *target) +{ + if(source() && source()->name() == target->name()) { + snoreDebug(SNORE_DEBUG) << "Source" << source() << "and Target" << target << "are the same."; + return true; + } + return false; +} + diff --git a/src/libsnore/notification/notification_p.h b/src/libsnore/notification/notification_p.h index c22fed2..7df2e50 100644 --- a/src/libsnore/notification/notification_p.h +++ b/src/libsnore/notification/notification_p.h @@ -58,7 +58,7 @@ public: * Sets the source SnorePlugin. * @see source() */ - void setSource(const SnorePlugin *soure); + void setSource(SnorePlugin *soure); /** @@ -67,6 +67,12 @@ public: */ const SnorePlugin* source() const; + /** + * Returns true if the source->name() and the target->name() are the same. + * @todo rename + */ + bool sourceAndTargetAreSimilar(const SnorePlugin *target); + private: Q_DISABLE_COPY(NotificationData) diff --git a/src/plugins/backends/freedesktop/freedesktopnotification_backend.cpp b/src/plugins/backends/freedesktop/freedesktopnotification_backend.cpp index 7dcb2a5..69e575b 100644 --- a/src/plugins/backends/freedesktop/freedesktopnotification_backend.cpp +++ b/src/plugins/backends/freedesktop/freedesktopnotification_backend.cpp @@ -52,7 +52,7 @@ bool FreedesktopBackend::canUpdateNotification() const void FreedesktopBackend::slotNotify(Notification noti) { - if(noti.data()->source()->name() == name()) { + if(noti.data()->sourceAndTargetAreSimilar(this)) { return; } diff --git a/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp b/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp index 9dfc3e0..2d758cd 100644 --- a/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp +++ b/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp @@ -126,6 +126,7 @@ uint FreedesktopFrontend::Notify(const QString &app_name, uint replaces_id, } noti.addActiveIn(this); + noti.data()->setSource(this); SnoreCore::instance().broadcastNotification(noti); return noti.id(); } diff --git a/src/plugins/frontends/pushover/pushover_frontend.cpp b/src/plugins/frontends/pushover/pushover_frontend.cpp index daffd9d..457a173 100644 --- a/src/plugins/frontends/pushover/pushover_frontend.cpp +++ b/src/plugins/frontends/pushover/pushover_frontend.cpp @@ -263,6 +263,7 @@ void PushoverFrontend::getMessages() if (notification.value(QLatin1String("html")).toInt() == 1) { n.hints().setValue("use-markup", true) ; } + n.data()->setSource(this); SnoreCore::instance().broadcastNotification(n); } if (latestID != -1) { diff --git a/src/plugins/secondary_backends/pushover/pushover.cpp b/src/plugins/secondary_backends/pushover/pushover.cpp index 0e091d3..177da17 100644 --- a/src/plugins/secondary_backends/pushover/pushover.cpp +++ b/src/plugins/secondary_backends/pushover/pushover.cpp @@ -18,7 +18,8 @@ #include "pushover.h" #include "pushoversettings.h" -#include"libsnore/utils.h" +#include "libsnore/utils.h" +#include "libsnore/notification/notification_p.h" #include #include @@ -28,7 +29,7 @@ using namespace Snore; void Pushover::slotNotify(Notification notification) { - if(notification.data()->source()->name() == name()) { + if(notification.data()->sourceAndTargetAreSimilar(this)) { return; }