move SnoreSecondaryBackend to its own header

This commit is contained in:
Patrick von Reth 2015-07-16 11:47:58 +02:00
parent cdc651b6e6
commit 92b2c38d07
14 changed files with 114 additions and 58 deletions

View File

@ -3,6 +3,7 @@ set(SnoreNotify_SRCS ${SnoreNotify_SRCS}
plugins/plugins.cpp
plugins/snorefrontend.cpp
plugins/snorebackend.cpp
plugins/snoresecondarybackend.cpp
plugins/pluginsettingswidget.cpp
PARENT_SCOPE)
@ -10,6 +11,7 @@ set(SnoreNotify_HDR
plugins.h
snorefrontend.h
snorebackend.h
snoresecondarybackend.h
pluginsettingswidget.h)

View File

@ -31,7 +31,7 @@ using namespace Snore;
SnoreBackend::SnoreBackend()
{
connect(this, &SnoreSecondaryBackend::enabledChanged, [this](bool enabled) {
connect(this, &SnoreBackend::enabledChanged, [this](bool enabled) {
if (enabled) {
connect(SnoreCorePrivate::instance(), &SnoreCorePrivate::applicationRegistered, this, &SnoreBackend::slotRegisterApplication, Qt::QueuedConnection);
connect(SnoreCorePrivate::instance(), &SnoreCorePrivate::applicationDeregistered, this, &SnoreBackend::slotDeregisterApplication, Qt::QueuedConnection);
@ -89,34 +89,6 @@ void SnoreBackend::slotCloseNotification(Notification notification)
Q_UNUSED(notification)
}
SnoreSecondaryBackend::SnoreSecondaryBackend()
{
connect(this, &SnoreSecondaryBackend::enabledChanged, [this](bool enabled) {
if (enabled) {
connect(SnoreCorePrivate::instance(), &SnoreCorePrivate::notify, this, &SnoreSecondaryBackend::slotNotify, Qt::QueuedConnection);
connect(SnoreCorePrivate::instance(), &SnoreCorePrivate::notificationDisplayed, this, &SnoreSecondaryBackend::slotNotificationDisplayed, Qt::QueuedConnection);
} else {
disconnect(SnoreCorePrivate::instance(), &SnoreCorePrivate::notify, this, &SnoreSecondaryBackend::slotNotify);
disconnect(SnoreCorePrivate::instance(), &SnoreCorePrivate::notificationDisplayed, this, &SnoreSecondaryBackend::slotNotificationDisplayed);
}
});
}
SnoreSecondaryBackend::~SnoreSecondaryBackend()
{
snoreDebug(SNORE_DEBUG) << "Deleting" << name();
}
void SnoreSecondaryBackend::slotNotify(Notification)
{
}
void SnoreSecondaryBackend::slotNotificationDisplayed(Notification)
{
}
bool SnoreBackend::canCloseNotification() const
{
return false;

View File

@ -61,27 +61,4 @@ protected:
Q_DECLARE_INTERFACE(Snore::SnoreBackend,
"org.Snore.NotificationBackend/1.0")
namespace Snore
{
class SnoreCore;
class SNORE_EXPORT SnoreSecondaryBackend : public SnorePlugin
{
Q_OBJECT
Q_INTERFACES(Snore::SnorePlugin Snore::SnorePlugin)
public:
SnoreSecondaryBackend();
virtual ~SnoreSecondaryBackend();
public Q_SLOTS:
virtual void slotNotify(Snore::Notification notification);
virtual void slotNotificationDisplayed(Snore::Notification notification);
};
}
Q_DECLARE_INTERFACE(Snore::SnoreSecondaryBackend,
"org.Snore.SecondaryNotificationBackend/1.0")
#endif//SNORE_BACKEND_H

View File

@ -0,0 +1,51 @@
/*
SnoreNotify is a Notification Framework based on Qt
Copyright (C) 2015 Patrick von Reth <vonreth@kde.org>
SnoreNotify is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SnoreNotify is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
*/
#include "snoresecondarybackend.h"
#include "../snore_p.h"
using namespace Snore;
SnoreSecondaryBackend::SnoreSecondaryBackend()
{
connect(this, &SnoreSecondaryBackend::enabledChanged, [this](bool enabled) {
if (enabled) {
connect(SnoreCorePrivate::instance(), &SnoreCorePrivate::notify, this, &SnoreSecondaryBackend::slotNotify, Qt::QueuedConnection);
connect(SnoreCorePrivate::instance(), &SnoreCorePrivate::notificationDisplayed, this, &SnoreSecondaryBackend::slotNotificationDisplayed, Qt::QueuedConnection);
} else {
disconnect(SnoreCorePrivate::instance(), &SnoreCorePrivate::notify, this, &SnoreSecondaryBackend::slotNotify);
disconnect(SnoreCorePrivate::instance(), &SnoreCorePrivate::notificationDisplayed, this, &SnoreSecondaryBackend::slotNotificationDisplayed);
}
});
}
SnoreSecondaryBackend::~SnoreSecondaryBackend()
{
snoreDebug(SNORE_DEBUG) << "Deleting" << name();
}
void SnoreSecondaryBackend::slotNotify(Notification)
{
}
void SnoreSecondaryBackend::slotNotificationDisplayed(Notification)
{
}

View File

@ -0,0 +1,48 @@
/*
SnoreNotify is a Notification Framework based on Qt
Copyright (C) 2015 Patrick von Reth <vonreth@kde.org>
SnoreNotify is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SnoreNotify is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SNORESECONDARYBACKEND_H
#define SNORESECONDARYBACKEND_H
#include "libsnore/snore_exports.h"
#include "libsnore/plugins/plugins.h"
namespace Snore
{
class SnoreCore;
class SNORE_EXPORT SnoreSecondaryBackend : public SnorePlugin
{
Q_OBJECT
Q_INTERFACES(Snore::SnorePlugin Snore::SnorePlugin)
public:
SnoreSecondaryBackend();
virtual ~SnoreSecondaryBackend();
public Q_SLOTS:
virtual void slotNotify(Snore::Notification notification);
virtual void slotNotificationDisplayed(Snore::Notification notification);
};
}
Q_DECLARE_INTERFACE(Snore::SnoreSecondaryBackend,
"org.Snore.SecondaryNotificationBackend/1.0")
#endif // SNORESECONDARYBACKEND_H

View File

@ -19,7 +19,7 @@ FreedesktopBackend::FreedesktopBackend()
reply.waitForFinished();
QStringList caps = reply.value();
m_supportsRichtext = caps.contains(QLatin1String("body-markup"));
connect(this, &SnoreSecondaryBackend::enabledChanged, [this](bool enabled) {
connect(this, &FreedesktopBackend::enabledChanged, [this](bool enabled) {
if (enabled) {
connect(m_interface, &org::freedesktop::Notifications::ActionInvoked, this, &FreedesktopBackend::slotActionInvoked);
connect(m_interface, &org::freedesktop::Notifications::NotificationClosed, this , &FreedesktopBackend::slotNotificationClosed);

View File

@ -18,7 +18,8 @@
#include "nma.h"
#include "nmasettings.h"
#include"libsnore/utils.h"
#include "libsnore/log.h"
#include "libsnore/utils.h"
#include <QNetworkReply>
#include <QNetworkRequest>

View File

@ -18,7 +18,7 @@
#ifndef NMA_H
#define NMA_H
#include "libsnore/plugins/snorebackend.h"
#include "libsnore/plugins/snoresecondarybackend.h"
#include <QNetworkAccessManager>

View File

@ -18,6 +18,7 @@
#include "pushover.h"
#include "pushoversettings.h"
#include "libsnore/log.h"
#include "libsnore/utils.h"
#include "libsnore/notification/notification_p.h"

View File

@ -18,7 +18,7 @@
#ifndef PUSHOVER_H
#define PUSHOVER_H
#include "libsnore/plugins/snorebackend.h"
#include "libsnore/plugins/snoresecondarybackend.h"
#include <QNetworkAccessManager>

View File

@ -18,6 +18,8 @@
#include "sound.h"
#include "soundsettings.h"
#include "libsnore/log.h"
#include <QtMultimedia/QMediaPlayer>
#include <QTimer>

View File

@ -18,7 +18,7 @@
#ifndef SOUND_H
#define SOUND_H
#include "libsnore/plugins/snorebackend.h"
#include "libsnore/plugins/snoresecondarybackend.h"
class QMediaPlayer;

View File

@ -17,6 +17,8 @@
*/
#include "toasty.h"
#include "toastysettings.h"
#include "libsnore/log.h"
#include "libsnore/utils.h"
#include <QNetworkReply>

View File

@ -18,7 +18,7 @@
#ifndef TOASTY_H
#define TOASTY_H
#include "libsnore/plugins/snorebackend.h"
#include "libsnore/plugins/snoresecondarybackend.h"
#include <QNetworkAccessManager>