prevent notification loops

This commit is contained in:
Patrick von Reth 2015-07-10 12:17:57 +02:00
parent f724133f31
commit 7713c61fdb
4 changed files with 23 additions and 1 deletions

View File

@ -54,6 +54,19 @@ public:
bool isBroadcasted() const;
/**
* Sets the source SnorePlugin.
* @see source()
*/
void setSource(const SnorePlugin *soure);
/**
* Returns the source SnorePlugin.
* This is used to prevent notification loops between the frontend and the backend.
*/
const SnorePlugin* source() const;
private:
Q_DISABLE_COPY(NotificationData)
@ -74,6 +87,7 @@ private:
QScopedPointer<QTimer> m_timeoutTimer;
QSet<const QObject *> m_activeIn;
bool m_isBroadcasted = false;
SnorePlugin *m_source = nullptr;
static uint notificationCount;
static uint m_idCount;

View File

@ -52,6 +52,10 @@ bool FreedesktopBackend::canUpdateNotification() const
void FreedesktopBackend::slotNotify(Notification noti)
{
if(noti.data()->source()->name() == name()) {
return;
}
QStringList actions;
foreach (int k, noti.actions().keys()) {
actions << QString::number(k) << noti.actions()[k].name();

View File

@ -1 +1 @@
{ "type" : "frontend", "name" : "Pushover Frontend" }
{ "type" : "frontend", "name" : "Pushover" }

View File

@ -28,6 +28,10 @@ using namespace Snore;
void Pushover::slotNotify(Notification notification)
{
if(notification.data()->source()->name() == name()) {
return;
}
QString key = settingsValue(QLatin1String("UserKey")).toString();
if (key.isEmpty()) {
return;