mirror of
https://github.com/status-im/snorenotify.git
synced 2025-01-10 00:25:43 +00:00
prevent notification loops
This commit is contained in:
parent
7713c61fdb
commit
a586ca60e3
@ -113,3 +113,22 @@ bool NotificationData::isBroadcasted() const
|
|||||||
return m_isBroadcasted;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public:
|
|||||||
* Sets the source SnorePlugin.
|
* Sets the source SnorePlugin.
|
||||||
* @see source()
|
* @see source()
|
||||||
*/
|
*/
|
||||||
void setSource(const SnorePlugin *soure);
|
void setSource(SnorePlugin *soure);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,6 +67,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
const SnorePlugin* source() const;
|
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:
|
private:
|
||||||
Q_DISABLE_COPY(NotificationData)
|
Q_DISABLE_COPY(NotificationData)
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ bool FreedesktopBackend::canUpdateNotification() const
|
|||||||
|
|
||||||
void FreedesktopBackend::slotNotify(Notification noti)
|
void FreedesktopBackend::slotNotify(Notification noti)
|
||||||
{
|
{
|
||||||
if(noti.data()->source()->name() == name()) {
|
if(noti.data()->sourceAndTargetAreSimilar(this)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +126,7 @@ uint FreedesktopFrontend::Notify(const QString &app_name, uint replaces_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
noti.addActiveIn(this);
|
noti.addActiveIn(this);
|
||||||
|
noti.data()->setSource(this);
|
||||||
SnoreCore::instance().broadcastNotification(noti);
|
SnoreCore::instance().broadcastNotification(noti);
|
||||||
return noti.id();
|
return noti.id();
|
||||||
}
|
}
|
||||||
|
@ -263,6 +263,7 @@ void PushoverFrontend::getMessages()
|
|||||||
if (notification.value(QLatin1String("html")).toInt() == 1) {
|
if (notification.value(QLatin1String("html")).toInt() == 1) {
|
||||||
n.hints().setValue("use-markup", true) ;
|
n.hints().setValue("use-markup", true) ;
|
||||||
}
|
}
|
||||||
|
n.data()->setSource(this);
|
||||||
SnoreCore::instance().broadcastNotification(n);
|
SnoreCore::instance().broadcastNotification(n);
|
||||||
}
|
}
|
||||||
if (latestID != -1) {
|
if (latestID != -1) {
|
||||||
|
@ -18,7 +18,8 @@
|
|||||||
#include "pushover.h"
|
#include "pushover.h"
|
||||||
#include "pushoversettings.h"
|
#include "pushoversettings.h"
|
||||||
|
|
||||||
#include"libsnore/utils.h"
|
#include "libsnore/utils.h"
|
||||||
|
#include "libsnore/notification/notification_p.h"
|
||||||
|
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
@ -28,7 +29,7 @@ using namespace Snore;
|
|||||||
|
|
||||||
void Pushover::slotNotify(Notification notification)
|
void Pushover::slotNotify(Notification notification)
|
||||||
{
|
{
|
||||||
if(notification.data()->source()->name() == name()) {
|
if(notification.data()->sourceAndTargetAreSimilar(this)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user