mirror of
https://github.com/status-im/snorenotify.git
synced 2025-02-17 02:46:23 +00:00
refactoring
This commit is contained in:
parent
1b6f1f9fcd
commit
b34d7de18f
@ -14,6 +14,7 @@ add_subdirectory(plugins)
|
||||
|
||||
set ( SnoreNotify_SRCS ${SnoreNotify_SRCS}
|
||||
snore.cpp
|
||||
snore_p.cpp
|
||||
application.cpp
|
||||
hint.cpp
|
||||
${CMAKE_CURRENT_BINARY_DIR}/version.cpp
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "icon.h"
|
||||
#include "../snore.h"
|
||||
#include "../snore_p.h"
|
||||
|
||||
#include "notification/icon_p.h"
|
||||
|
||||
@ -71,7 +72,7 @@ QString Icon::localUrl()const{
|
||||
}
|
||||
else
|
||||
{
|
||||
d->m_localUrl = QString("%1%2.png").arg(SnoreCore::snoreTMP(), hash());
|
||||
d->m_localUrl = QString("%1%2.png").arg(SnoreCorePrivate::snoreTMP(), hash());
|
||||
image().save(d->m_localUrl ,"PNG");
|
||||
m_localImageCache[hash()] = d->m_localUrl;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
#include "../snore.h"
|
||||
#include "../snore_p.h"
|
||||
#include "plugins.h"
|
||||
#include "snorebackend.h"
|
||||
#include "snorefrontend.h"
|
||||
@ -35,7 +36,7 @@ QSettings &PluginContainer::cacheFile(){
|
||||
#ifdef Q_OS_LINUX
|
||||
static QSettings cache("TheOneRing","libsnore");
|
||||
#else
|
||||
static QSettings cache(SnoreCore::pluginDir().absoluteFilePath("plugin.cache"),QSettings::IniFormat);
|
||||
static QSettings cache(SnoreCorePrivate::pluginDir().absoluteFilePath("plugin.cache"),QSettings::IniFormat);
|
||||
#endif
|
||||
return cache;
|
||||
}
|
||||
@ -60,7 +61,7 @@ SnorePlugin *PluginContainer::load()
|
||||
{
|
||||
if(m_instance != NULL)
|
||||
return m_instance;
|
||||
QPluginLoader loader ( SnoreCore::pluginDir().absoluteFilePath(file()));
|
||||
QPluginLoader loader ( SnoreCorePrivate::pluginDir().absoluteFilePath(file()));
|
||||
qDebug() << "Trying to load" << file();
|
||||
if ( !loader.load())
|
||||
{
|
||||
@ -131,7 +132,7 @@ void PluginContainer::updatePluginCache(){
|
||||
cache.clear();
|
||||
|
||||
foreach(const QString &type,PluginContainer::types()){
|
||||
QDir plPath(SnoreCore::pluginDir().absoluteFilePath(type));
|
||||
QDir plPath(SnoreCorePrivate::pluginDir().absoluteFilePath(type));
|
||||
qDebug() << "Searching for plugins in" << plPath.path();
|
||||
foreach (QString fileName, plPath.entryList(QDir::Files)) {
|
||||
QString filepath(plPath.absoluteFilePath(fileName));
|
||||
@ -148,7 +149,7 @@ void PluginContainer::updatePluginCache(){
|
||||
plugin->deleteLater();
|
||||
continue;
|
||||
}
|
||||
PluginContainer *info = new PluginContainer( SnoreCore::pluginDir().relativeFilePath(filepath),sp->name(),PluginContainer::typeFromString(type));
|
||||
PluginContainer *info = new PluginContainer( SnoreCorePrivate::pluginDir().relativeFilePath(filepath),sp->name(),PluginContainer::typeFromString(type));
|
||||
s_pluginCache.insert(info->name(),info);
|
||||
sp->deleteLater();
|
||||
qDebug() << "added" << info->name() << "to cache";
|
||||
@ -157,7 +158,7 @@ void PluginContainer::updatePluginCache(){
|
||||
|
||||
qDebug()<<s_pluginCache.keys();
|
||||
cache.setValue("version",Version::revision());
|
||||
cache.setValue("pluginPath",SnoreCore::pluginDir().path());
|
||||
cache.setValue("pluginPath",SnoreCorePrivate::pluginDir().path());
|
||||
QList<PluginContainer*> plugins = s_pluginCache.values();
|
||||
cache.beginWriteArray("plugins");
|
||||
for(int i=0;i< plugins.size();++i) {
|
||||
@ -176,7 +177,7 @@ QHash<QString, PluginContainer *> PluginContainer::pluginCache(){
|
||||
QString version = cache.value("version").toString();
|
||||
QString path = cache.value("pluginPath").toString();
|
||||
int size = cache.beginReadArray("plugins");
|
||||
if(size == 0 || version != Version::revision() || path != SnoreCore::pluginDir().path()){
|
||||
if(size == 0 || version != Version::revision() || path != SnoreCorePrivate::pluginDir().path()){
|
||||
cache.endArray();
|
||||
updatePluginCache();
|
||||
}else{
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "snorebackend.h"
|
||||
#include "../snore.h"
|
||||
#include "../snore_p.h"
|
||||
#include "../application.h"
|
||||
#include "../notification/notification.h"
|
||||
|
||||
@ -26,6 +27,7 @@
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
namespace Snore{
|
||||
|
||||
SnoreBackend::SnoreBackend (const QString &name , bool canCloseNotification, bool supportsRichtext) :
|
||||
@ -45,9 +47,11 @@ SnoreBackend::~SnoreBackend()
|
||||
bool SnoreBackend::init( SnoreCore *snore )
|
||||
{
|
||||
if(!SnorePlugin::init(snore))
|
||||
{
|
||||
return false;
|
||||
connect( snore,SIGNAL( applicationInitialized( Snore::Application* ) ),this,SLOT( slotRegisterApplication( Snore::Application* ) ) );
|
||||
connect( snore,SIGNAL( applicationRemoved( Snore::Application* ) ),this,SLOT( slotUnregisterApplication( Snore::Application* ) ) );
|
||||
}
|
||||
connect( snore->d(), SIGNAL(applicationRegistered(Snore::Application*)), this, SLOT(slotRegisterApplication(Snore::Application*)));
|
||||
connect( snore->d(), SIGNAL(applicationDeregistered(Snore::Application*)), this, SLOT(slotUnregisterApplication(Snore::Application*)));
|
||||
|
||||
foreach(Application *a,snore->aplications()){
|
||||
this->slotRegisterApplication(a);
|
||||
@ -78,7 +82,7 @@ void SnoreBackend::closeNotification(Notification n, NotificationEnums::CloseRea
|
||||
}
|
||||
n.setCloseReason(reason);
|
||||
slotCloseNotification(n);
|
||||
emit closeNotification(n);
|
||||
emit notificationClosed(n);
|
||||
}
|
||||
|
||||
void SnoreBackend::slotCloseNotification(Notification notification)
|
||||
@ -99,7 +103,7 @@ SnoreSecondaryBackend::~SnoreSecondaryBackend()
|
||||
|
||||
bool SnoreSecondaryBackend::init(SnoreCore *snore)
|
||||
{
|
||||
connect( snore,SIGNAL( slotNotify(SnoreCore::Notification) ),this,SLOT( slotNotify( SnoreCore::Notification ) ) );
|
||||
connect( snore->d() ,SIGNAL( slotNotify(SnoreCore::Notification) ),this,SLOT( slotNotify( SnoreCore::Notification ) ) );
|
||||
return SnoreBackend::init(snore);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
bool supportsRichtext();
|
||||
|
||||
signals:
|
||||
void closeNotification( Snore::Notification );
|
||||
void notificationClosed( Snore::Notification );
|
||||
|
||||
|
||||
public slots:
|
||||
|
@ -40,8 +40,10 @@ SnoreFrontend::~SnoreFrontend()
|
||||
bool SnoreFrontend::init( SnoreCore *snore )
|
||||
{
|
||||
if(!SnorePlugin::init(snore))
|
||||
{
|
||||
return false;
|
||||
connect( snore,SIGNAL ( notificationClosed( Snore::Notification ) ),this,SLOT ( notificationClosed( Snore::Notification) ) );
|
||||
}
|
||||
connect(snore, SIGNAL(notificationClosed(Snore::Notification)), this, SLOT(notificationClosed(Snore::Notification)));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "snore.h"
|
||||
#include "snore_p.h"
|
||||
#include "notification/notification.h"
|
||||
#include "plugins/plugincontainer.h"
|
||||
#include "plugins/plugins.h"
|
||||
@ -36,41 +37,23 @@
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
void SnoreCore::slotNotificationClosed(Notification n)
|
||||
|
||||
SnoreCore::SnoreCore(QSystemTrayIcon *trayIcon ):
|
||||
d_ptr(new SnoreCorePrivate(trayIcon ))
|
||||
{
|
||||
emit notificationClosed(n);
|
||||
Q_D(SnoreCore);
|
||||
d->q_ptr = this;
|
||||
}
|
||||
|
||||
QString const SnoreCore::snoreTMP(){
|
||||
static const QString tmp = QString("%1/SnoreNotify/").arg(QDir::temp().path());
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
SnoreCore::SnoreCore ( QSystemTrayIcon *trayIcon ) :
|
||||
m_trayIcon ( trayIcon )
|
||||
SnoreCore::~SnoreCore()
|
||||
{
|
||||
QDir home ( snoreTMP() );
|
||||
if ( !home.exists() ){
|
||||
home.cdUp();
|
||||
home.mkdir("SnoreNotify");
|
||||
}
|
||||
|
||||
Q_D(SnoreCore);
|
||||
d->deleteLater();
|
||||
}
|
||||
|
||||
const QDir &SnoreCore::pluginDir(){
|
||||
static QDir path(QString("%1/snoreplugins").arg(qApp->applicationDirPath()));
|
||||
if(!path.exists())
|
||||
{
|
||||
path = QDir(LIBSNORE_PLUGIN_PATH);
|
||||
}
|
||||
qDebug() << "PluginDir" << path.absolutePath();
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
void SnoreCore::loadPlugins ( PluginContainer::PluginTypes types )
|
||||
void SnoreCore::loadPlugins( PluginContainer::PluginTypes types )
|
||||
{
|
||||
Q_D(SnoreCore);
|
||||
qDebug() << "PluginInfo" << PluginContainer::pluginCache().keys();
|
||||
foreach ( PluginContainer *info, PluginContainer::pluginCache().values())
|
||||
{
|
||||
@ -81,7 +64,7 @@ void SnoreCore::loadPlugins ( PluginContainer::PluginTypes types )
|
||||
case PluginContainer::BACKEND:
|
||||
{
|
||||
qDebug() <<info->name()<<"is a Notification_Backend";
|
||||
m_notificationBackends.append( info->name());
|
||||
d->m_notificationBackends.append( info->name());
|
||||
break;
|
||||
}
|
||||
case PluginContainer::SECONDARY_BACKEND:
|
||||
@ -90,7 +73,7 @@ void SnoreCore::loadPlugins ( PluginContainer::PluginTypes types )
|
||||
info->unload();
|
||||
break;
|
||||
}
|
||||
m_secondaryNotificationBackends.append(info->name());
|
||||
d->m_secondaryNotificationBackends.append(info->name());
|
||||
break;
|
||||
}
|
||||
case PluginContainer::FRONTEND:
|
||||
@ -100,7 +83,7 @@ void SnoreCore::loadPlugins ( PluginContainer::PluginTypes types )
|
||||
info->unload();
|
||||
break;
|
||||
}
|
||||
m_Frontends.append(info->name());
|
||||
d->m_Frontends.append(info->name());
|
||||
break;
|
||||
}
|
||||
case PluginContainer::PLUGIN:
|
||||
@ -110,7 +93,7 @@ void SnoreCore::loadPlugins ( PluginContainer::PluginTypes types )
|
||||
info->unload();
|
||||
break;
|
||||
}
|
||||
m_plugins.append(info->name());
|
||||
d->m_plugins.append(info->name());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -127,87 +110,69 @@ void SnoreCore::loadPlugins ( PluginContainer::PluginTypes types )
|
||||
|
||||
void SnoreCore::broadcastNotification ( Notification notification )
|
||||
{
|
||||
Q_D(SnoreCore);
|
||||
qDebug()<<"Broadcasting"<<notification<<"timeout:"<<notification.timeout();
|
||||
emit notify ( notification );
|
||||
if ( m_notificationBackend != NULL )
|
||||
emit d->notify ( notification );
|
||||
if ( d->m_notificationBackend != NULL )
|
||||
{
|
||||
if(!m_notificationBackend->isInitialized()){
|
||||
qDebug()<<"Notification backend "<<m_notificationBackend<<" isnt initialized will snore will exit now";
|
||||
if(!d->m_notificationBackend->isInitialized()){
|
||||
qDebug()<<"Notification backend "<<d->m_notificationBackend<<" isnt initialized will snore will exit now";
|
||||
qApp->quit();
|
||||
}
|
||||
m_notificationBackend->slotNotify( notification );
|
||||
m_notificationBackend->addActiveNotification(notification);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SnoreCore::notificationActionInvoked ( Notification notification )
|
||||
{
|
||||
emit actionInvoked(notification);
|
||||
SnoreFrontend *nf = notification.source();
|
||||
if ( nf != NULL )
|
||||
{
|
||||
nf->actionInvoked ( notification );
|
||||
d->m_notificationBackend->slotNotify( notification );
|
||||
d->m_notificationBackend->addActiveNotification(notification);
|
||||
}
|
||||
}
|
||||
|
||||
void SnoreCore::registerApplication(Application *application)
|
||||
{
|
||||
if(!m_applications.contains(application->name()))
|
||||
Q_D(SnoreCore);
|
||||
if(!d->m_applications.contains(application->name()))
|
||||
{
|
||||
m_applications.insert ( application->name(),application );
|
||||
emit applicationInitialized ( application );
|
||||
d->m_applications.insert ( application->name(),application );
|
||||
emit d->applicationRegistered ( application );
|
||||
}
|
||||
}
|
||||
|
||||
void SnoreCore::addApplication ( Application *application )
|
||||
{
|
||||
registerApplication(application);
|
||||
}
|
||||
|
||||
void SnoreCore::applicationIsInitialized ( Application *application )
|
||||
{
|
||||
registerApplication(application);
|
||||
}
|
||||
|
||||
void SnoreCore::removeApplication ( const QString& appName )
|
||||
{
|
||||
deregisterApplication( m_applications.value ( appName ) );
|
||||
}
|
||||
|
||||
void SnoreCore::deregisterApplication(Application *application)
|
||||
{
|
||||
emit applicationRemoved (application );
|
||||
m_applications.take ( application->name() );
|
||||
Q_D(SnoreCore);
|
||||
emit d->applicationDeregistered (application );
|
||||
d->m_applications.take ( application->name() );
|
||||
application->deleteLater();
|
||||
}
|
||||
|
||||
const ApplicationsList &SnoreCore::aplications() const
|
||||
{
|
||||
return m_applications;
|
||||
Q_D(const SnoreCore);
|
||||
return d->m_applications;
|
||||
}
|
||||
|
||||
|
||||
const QStringList &SnoreCore::notificationBackends() const
|
||||
{
|
||||
return m_notificationBackends;
|
||||
Q_D(const SnoreCore);
|
||||
return d->m_notificationBackends;
|
||||
}
|
||||
|
||||
const QStringList &SnoreCore::notificationFrontends() const
|
||||
{
|
||||
return m_Frontends;
|
||||
Q_D(const SnoreCore);
|
||||
return d->m_Frontends;
|
||||
}
|
||||
|
||||
const QStringList &SnoreCore::secondaryNotificationBackends() const
|
||||
{
|
||||
return m_secondaryNotificationBackends;
|
||||
Q_D(const SnoreCore);
|
||||
return d->m_secondaryNotificationBackends;
|
||||
}
|
||||
|
||||
bool SnoreCore::setPrimaryNotificationBackend ( const QString &backend )
|
||||
{
|
||||
Q_D(SnoreCore);
|
||||
if(!PluginContainer::pluginCache().contains(backend)){
|
||||
qDebug()<<"Unknown Backend:"<<backend;
|
||||
return false;
|
||||
return setPrimaryNotificationBackend();
|
||||
}
|
||||
qDebug() << "Setting Notification Backend to:" << backend;
|
||||
SnoreBackend* b = qobject_cast<SnoreBackend*>(PluginContainer::pluginCache()[backend]->load());
|
||||
@ -216,13 +181,13 @@ bool SnoreCore::setPrimaryNotificationBackend ( const QString &backend )
|
||||
qDebug() << "Failed to initialize" << b->name();
|
||||
return false;
|
||||
}
|
||||
if(m_notificationBackend)
|
||||
if(d->m_notificationBackend)
|
||||
{
|
||||
disconnect(m_notificationBackend, SIGNAL(closeNotification));
|
||||
disconnect(d->m_notificationBackend, SIGNAL(notificationClosed(Snore::Notification)));
|
||||
}
|
||||
connect(b, SIGNAL(closeNotification), this, SLOT(slotNotificationClosed));
|
||||
connect(b, SIGNAL(notificationClosed(Snore::Notification)), d, SLOT(slotNotificationClosed(Snore::Notification)));
|
||||
}
|
||||
m_notificationBackend = b;
|
||||
d->m_notificationBackend = b;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -265,37 +230,49 @@ bool SnoreCore::setPrimaryNotificationBackend()
|
||||
|
||||
const QString SnoreCore::primaryNotificationBackend() const
|
||||
{
|
||||
if(m_notificationBackend.isNull())
|
||||
Q_D(const SnoreCore);
|
||||
if(d->m_notificationBackend.isNull())
|
||||
{
|
||||
return QString::null;
|
||||
}
|
||||
return m_notificationBackend->name();
|
||||
return d->m_notificationBackend->name();
|
||||
}
|
||||
|
||||
QSystemTrayIcon *SnoreCore::trayIcon(){
|
||||
return m_trayIcon;
|
||||
Q_D(SnoreCore);
|
||||
return d->m_trayIcon;
|
||||
}
|
||||
|
||||
Notification SnoreCore::getActiveNotificationByID(uint id)
|
||||
{
|
||||
if(!m_notificationBackend->isInitialized()){
|
||||
qDebug()<<"Notification backend "<<m_notificationBackend<<" isn't initialized will snore will exit now";
|
||||
Q_D(SnoreCore);
|
||||
if(!d->m_notificationBackend->isInitialized()){
|
||||
qDebug() << "Notification backend " << d->m_notificationBackend << " isn't initialized will snore will exit now";
|
||||
qApp->quit();
|
||||
}
|
||||
return m_notificationBackend->getActiveNotificationByID(id);
|
||||
return d->m_notificationBackend->getActiveNotificationByID(id);
|
||||
}
|
||||
|
||||
void SnoreCore::requestCloseNotification(Notification n, NotificationEnums::CloseReasons::closeReasons r)
|
||||
{
|
||||
m_notificationBackend->requestCloseNotification(n,r);
|
||||
Q_D(SnoreCore);
|
||||
d->m_notificationBackend->requestCloseNotification(n,r);
|
||||
}
|
||||
|
||||
bool SnoreCore::primaryBackendSupportsRichtext()
|
||||
{
|
||||
return m_notificationBackend->supportsRichtext();
|
||||
Q_D(SnoreCore);
|
||||
return d->m_notificationBackend->supportsRichtext();
|
||||
}
|
||||
|
||||
Hint &SnoreCore::hints()
|
||||
{
|
||||
return m_hints;
|
||||
Q_D(SnoreCore);
|
||||
return d->m_hints;
|
||||
}
|
||||
|
||||
const SnoreCorePrivate *SnoreCore::d()
|
||||
{
|
||||
Q_D(SnoreCore);
|
||||
return d;
|
||||
}
|
||||
|
@ -31,32 +31,26 @@
|
||||
#include <QTextDocumentFragment>
|
||||
|
||||
class QSystemTrayIcon;
|
||||
class QDir;
|
||||
|
||||
|
||||
namespace Snore{
|
||||
class SnoreCorePrivate;
|
||||
|
||||
class SNORE_EXPORT SnoreCore : public QObject
|
||||
{
|
||||
Q_DECLARE_PRIVATE(SnoreCore)
|
||||
Q_OBJECT
|
||||
public:
|
||||
static const QString snoreTMP();
|
||||
static const QDir &pluginDir();
|
||||
|
||||
public:
|
||||
SnoreCore (QSystemTrayIcon *trayIcon = NULL );
|
||||
~SnoreCore();
|
||||
void loadPlugins ( PluginContainer::PluginTypes types );
|
||||
|
||||
|
||||
void broadcastNotification( Notification notification );
|
||||
void notificationActionInvoked( Notification notification );//TODO: move to private header
|
||||
|
||||
void registerApplication( Application *application );
|
||||
void deregisterApplication( Application *application );
|
||||
|
||||
void Q_DECL_DEPRECATED addApplication ( Application *application );
|
||||
void Q_DECL_DEPRECATED applicationIsInitialized ( Application* application );
|
||||
void Q_DECL_DEPRECATED removeApplication ( const QString& appName );
|
||||
|
||||
const ApplicationsList &aplications() const;
|
||||
|
||||
const QStringList ¬ificationBackends() const;
|
||||
@ -76,31 +70,17 @@ public:
|
||||
|
||||
Hint &hints();
|
||||
|
||||
const SnoreCorePrivate *d();
|
||||
|
||||
|
||||
signals:
|
||||
void applicationInitialized( Snore::Application* );
|
||||
void applicationRemoved( Snore::Application* );
|
||||
void notify( Snore::Notification noti );
|
||||
void actionInvoked( Snore::Notification );
|
||||
void notificationClosed(Snore::Notification );
|
||||
|
||||
private slots:
|
||||
void slotNotificationClosed(Snore::Notification);
|
||||
|
||||
|
||||
private:
|
||||
Hint m_hints;
|
||||
|
||||
ApplicationsList m_applications;
|
||||
SnoreCorePrivate *d_ptr;
|
||||
|
||||
|
||||
QStringList m_notificationBackends;
|
||||
QStringList m_Frontends;
|
||||
QStringList m_secondaryNotificationBackends;
|
||||
QStringList m_plugins;
|
||||
|
||||
QPointer<SnoreBackend> m_notificationBackend;
|
||||
|
||||
QSystemTrayIcon *m_trayIcon;
|
||||
};
|
||||
|
||||
|
||||
|
59
src/core/snore_p.cpp
Normal file
59
src/core/snore_p.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
#include "snore_p.h"
|
||||
#include "snore.h"
|
||||
#include "plugins/plugins.h"
|
||||
#include "plugins/snorebackend.h"
|
||||
#include "plugins/snorefrontend.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
|
||||
QString const SnoreCorePrivate::snoreTMP(){
|
||||
static const QString tmp = QString("%1/SnoreNotify/").arg(QDir::temp().path());
|
||||
return tmp;
|
||||
}
|
||||
|
||||
const QDir &SnoreCorePrivate::pluginDir(){
|
||||
static QDir path(QString("%1/snoreplugins").arg(qApp->applicationDirPath()));
|
||||
if(!path.exists())
|
||||
{
|
||||
path = QDir(LIBSNORE_PLUGIN_PATH);
|
||||
}
|
||||
qDebug() << "PluginDir" << path.absolutePath();
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
SnoreCorePrivate::SnoreCorePrivate(QSystemTrayIcon *trayIcon):
|
||||
m_trayIcon(trayIcon)
|
||||
{
|
||||
QDir home ( snoreTMP() );
|
||||
if ( !home.exists() ){
|
||||
home.cdUp();
|
||||
home.mkdir("SnoreNotify");
|
||||
}
|
||||
}
|
||||
|
||||
SnoreCorePrivate::~SnoreCorePrivate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SnoreCorePrivate::notificationActionInvoked(Notification notification) const
|
||||
{
|
||||
Q_Q(const SnoreCore);
|
||||
emit const_cast<SnoreCore*>(q)->actionInvoked(notification);
|
||||
SnoreFrontend *nf = notification.source();
|
||||
if ( nf != NULL )
|
||||
{
|
||||
nf->actionInvoked ( notification );
|
||||
}
|
||||
}
|
||||
|
||||
void SnoreCorePrivate::slotNotificationClosed(Notification n)
|
||||
{
|
||||
Q_Q(SnoreCore);
|
||||
emit q->notificationClosed(n);
|
||||
}
|
||||
|
51
src/core/snore_p.h
Normal file
51
src/core/snore_p.h
Normal file
@ -0,0 +1,51 @@
|
||||
#ifndef SNORECOREPRIVATE_H
|
||||
#define SNORECOREPRIVATE_H
|
||||
|
||||
#include "snore.h"
|
||||
|
||||
#include <QDir>
|
||||
|
||||
namespace Snore
|
||||
{
|
||||
class SNORE_EXPORT SnoreCorePrivate : public QObject
|
||||
{
|
||||
Q_DECLARE_PUBLIC(SnoreCore)
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static const QString snoreTMP();
|
||||
static const QDir &pluginDir();
|
||||
public:
|
||||
SnoreCorePrivate(QSystemTrayIcon *trayIcon);
|
||||
~SnoreCorePrivate();
|
||||
|
||||
|
||||
void notificationActionInvoked(Notification notification) const;
|
||||
|
||||
signals:
|
||||
void applicationRegistered(Snore::Application*);
|
||||
void applicationDeregistered(Snore::Application*);
|
||||
void notify(Snore::Notification noti);
|
||||
|
||||
private slots:
|
||||
void slotNotificationClosed(Snore::Notification);
|
||||
|
||||
private:
|
||||
SnoreCore *q_ptr;
|
||||
Hint m_hints;
|
||||
|
||||
ApplicationsList m_applications;
|
||||
|
||||
|
||||
QStringList m_notificationBackends;
|
||||
QStringList m_Frontends;
|
||||
QStringList m_secondaryNotificationBackends;
|
||||
QStringList m_plugins;
|
||||
|
||||
QPointer<SnoreBackend> m_notificationBackend;
|
||||
|
||||
QSystemTrayIcon *m_trayIcon;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SNORECOREPRIVATE_H
|
@ -22,4 +22,8 @@ const QString Version::revision(){
|
||||
return QLatin1String("${SNORE_REVISION}");
|
||||
}
|
||||
|
||||
const QString Version::buildTime(){
|
||||
return QLatin1String(__TIMESTAMP__);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ static const QString suffix();
|
||||
|
||||
static const QString revision();
|
||||
|
||||
static const QString buildTime();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "gntp.h"
|
||||
|
||||
#include "core/snore.h"
|
||||
#include "core/snore_p.h"
|
||||
|
||||
|
||||
#include <QtCore>
|
||||
@ -147,7 +148,7 @@ void Growl::gntpCallback(const int &id,const std::string &reason,const std::stri
|
||||
else if(reason == "CLICK")
|
||||
{
|
||||
r = NotificationEnums::CloseReasons::CLOSED;
|
||||
s_instance->snore()->notificationActionInvoked(n);
|
||||
s_instance->snore()->d()->notificationActionInvoked(n);
|
||||
}
|
||||
s_instance->closeNotification(n,r);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "snarl.h"
|
||||
|
||||
#include "core/snore.h"
|
||||
#include "core/snore_p.h"
|
||||
#include "core/plugins/plugins.h"
|
||||
#include "core/plugins/snorebackend.h"
|
||||
|
||||
@ -88,7 +89,7 @@ public:
|
||||
if(notification.isValid())
|
||||
{
|
||||
notification.setActionInvoked(data);
|
||||
m_snarl->snore()->notificationActionInvoked(notification);
|
||||
m_snarl->snore()->d()->notificationActionInvoked(notification);
|
||||
}
|
||||
break;
|
||||
case SnarlEnums::CallbackClosed:
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "snoretoast.h"
|
||||
#include "core/snore.h"
|
||||
#include "core/snore_p.h"
|
||||
#include "core/plugins/plugins.h"
|
||||
#include "core/plugins/snorebackend.h"
|
||||
|
||||
@ -110,7 +111,7 @@ void SnoreToast::slotToastNotificationClosed(int code, QProcess::ExitStatus)
|
||||
{
|
||||
case 0:
|
||||
reason = NotificationEnums::CloseReasons::CLOSED;
|
||||
snore()->notificationActionInvoked(n);
|
||||
snore()->d()->notificationActionInvoked(n);
|
||||
break;
|
||||
case 1:
|
||||
//hidden;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "trayiconnotifer.h"
|
||||
#include "core/snore.h"
|
||||
#include "core/snore_p.h"
|
||||
|
||||
#include <QtCore>
|
||||
#include <QSystemTrayIcon>
|
||||
@ -70,7 +71,7 @@ void TrayIconNotifer::actionInvoked(){
|
||||
|
||||
Notification n = snore()->getActiveNotificationByID(m_displayed);
|
||||
if(n.isValid()){
|
||||
snore()->notificationActionInvoked(n);
|
||||
snore()->d()->notificationActionInvoked(n);
|
||||
closeNotification(n,NotificationEnums::CloseReasons::CLOSED);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user