mirror of
https://github.com/status-im/snorenotify.git
synced 2025-01-10 08:35:54 +00:00
only a backend can close a notification
This commit is contained in:
parent
7e7173637b
commit
70c7e8a980
48
src/core/notification/NotificationEnums.h
Normal file
48
src/core/notification/NotificationEnums.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/****************************************************************************************
|
||||||
|
* Copyright (c) 2013 Patrick von Reth <vonreth@kde.org> *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under *
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software *
|
||||||
|
* Foundation; either version 2 of the License, or (at your option) any later *
|
||||||
|
* version. *
|
||||||
|
* *
|
||||||
|
* This program 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 General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License along with *
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NOTIFICATIONENUMS_H
|
||||||
|
#define NOTIFICATIONENUMS_H
|
||||||
|
|
||||||
|
#include <QFlags>
|
||||||
|
|
||||||
|
namespace Snore{
|
||||||
|
namespace NotificationEnums{
|
||||||
|
|
||||||
|
namespace Prioritys{
|
||||||
|
enum priority{
|
||||||
|
LOW = -1,
|
||||||
|
NORMAL = 0,
|
||||||
|
HIGH = +1
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(prioritys, priority)
|
||||||
|
Q_DECLARE_OPERATORS_FOR_FLAGS(prioritys)
|
||||||
|
}
|
||||||
|
namespace CloseReasons{
|
||||||
|
enum closeReason
|
||||||
|
{
|
||||||
|
NONE,
|
||||||
|
TIMED_OUT,
|
||||||
|
DISMISSED,
|
||||||
|
CLOSED
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(closeReasons, closeReason)
|
||||||
|
Q_DECLARE_OPERATORS_FOR_FLAGS(closeReasons)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // NOTIFICATIONENUMS_H
|
@ -19,33 +19,11 @@
|
|||||||
#include "../snore_exports.h"
|
#include "../snore_exports.h"
|
||||||
#include "icon.h"
|
#include "icon.h"
|
||||||
|
|
||||||
|
#include "NotificationEnums.h"
|
||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
namespace Snore{
|
namespace Snore{
|
||||||
|
|
||||||
namespace NotificationEnums{
|
|
||||||
|
|
||||||
namespace Prioritys{
|
|
||||||
enum priority{
|
|
||||||
LOW = -1,
|
|
||||||
NORMAL = 0,
|
|
||||||
HIGH = +1
|
|
||||||
};
|
|
||||||
Q_DECLARE_FLAGS(prioritys, priority)
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(prioritys)
|
|
||||||
}
|
|
||||||
namespace CloseReasons{
|
|
||||||
enum closeReason
|
|
||||||
{
|
|
||||||
NONE,
|
|
||||||
TIMED_OUT,
|
|
||||||
DISMISSED,
|
|
||||||
CLOSED
|
|
||||||
};
|
|
||||||
Q_DECLARE_FLAGS(closeReasons, closeReason)
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(closeReasons)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SNORE_EXPORT Notification
|
class SNORE_EXPORT Notification
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -70,12 +48,10 @@ public:
|
|||||||
QString toString() const;
|
QString toString() const;
|
||||||
|
|
||||||
const uint &id() const;
|
const uint &id() const;
|
||||||
void setId(const uint &id);
|
|
||||||
//timeout in seconds
|
//timeout in seconds
|
||||||
//0 means sticky
|
//0 means sticky
|
||||||
const int &timeout() const;
|
const int &timeout() const;
|
||||||
void setActionInvoked ( Action *action );
|
|
||||||
void setActionInvoked ( const int &actionID);
|
|
||||||
const Action* actionInvoked() const;
|
const Action* actionInvoked() const;
|
||||||
void setSource(class SnoreFrontend *source)const;
|
void setSource(class SnoreFrontend *source)const;
|
||||||
class SnoreFrontend *source() const;
|
class SnoreFrontend *source() const;
|
||||||
@ -99,12 +75,18 @@ public:
|
|||||||
|
|
||||||
const QObject *data() const;
|
const QObject *data() const;
|
||||||
|
|
||||||
|
//protected://TODO::make only accesable from a backend
|
||||||
|
void setActionInvoked ( Action *action );
|
||||||
|
void setActionInvoked ( const int &actionID);
|
||||||
|
void setId(const uint &id);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class NotificationData;
|
class NotificationData;
|
||||||
NotificationData* d;
|
NotificationData* d;
|
||||||
static int notificationCount;
|
static int notificationCount;
|
||||||
static int notificationMetaID;
|
static int notificationMetaID;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ void SnorePlugin::notificationTimedOut(){
|
|||||||
m_timeouts.take(id)->deleteLater();
|
m_timeouts.take(id)->deleteLater();
|
||||||
Notification n = snore()->getActiveNotificationByID(id);
|
Notification n = snore()->getActiveNotificationByID(id);
|
||||||
if(n.isValid()){
|
if(n.isValid()){
|
||||||
snore()->closeNotification(n,NotificationEnums::CloseReasons::TIMED_OUT);
|
snore()->requestCloseNotification(n,NotificationEnums::CloseReasons::TIMED_OUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
#ifndef SNORE_PLUGINS_H
|
#ifndef SNORE_PLUGINS_H
|
||||||
#define SNORE_PLUGINS_H
|
#define SNORE_PLUGINS_H
|
||||||
#include "../snore_exports.h"
|
#include "../snore_exports.h"
|
||||||
#include "../notification/notification.h"
|
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QFlag>
|
#include <QHash>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
namespace Snore{
|
namespace Snore{
|
||||||
class Application;
|
class Application;
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "snorebackend.h"
|
#include "snorebackend.h"
|
||||||
#include "../snore.h"
|
#include "../snore.h"
|
||||||
#include "../application.h"
|
#include "../application.h"
|
||||||
|
#include "../notification/notification.h"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QPluginLoader>
|
#include <QPluginLoader>
|
||||||
@ -41,17 +42,34 @@ bool SnoreBackend::init( SnoreCore *snore )
|
|||||||
{
|
{
|
||||||
if(!SnorePlugin::init(snore))
|
if(!SnorePlugin::init(snore))
|
||||||
return false;
|
return false;
|
||||||
connect( snore,SIGNAL( closeNotify( Snore::Notification ) ),this,SLOT( closeNotification( Snore::Notification) ) );
|
connect( snore,SIGNAL( applicationInitialized( Snore::Application* ) ),this,SLOT( slotRegisterApplication( Snore::Application* ) ) );
|
||||||
connect( snore,SIGNAL( applicationInitialized( Snore::Application* ) ),this,SLOT( registerApplication( Snore::Application* ) ) );
|
connect( snore,SIGNAL( applicationRemoved( Snore::Application* ) ),this,SLOT( slotUnregisterApplication( Snore::Application* ) ) );
|
||||||
connect( snore,SIGNAL( applicationRemoved( Snore::Application* ) ),this,SLOT( unregisterApplication( Snore::Application* ) ) );
|
|
||||||
|
|
||||||
foreach(Application *a,snore->aplications()){
|
foreach(Application *a,snore->aplications()){
|
||||||
this->registerApplication(a);
|
this->slotRegisterApplication(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SnoreBackend::requestCloseNotification ( Notification notification,NotificationEnums::CloseReasons::closeReasons reason )
|
||||||
|
{
|
||||||
|
if(slotCloseNotification(notification))
|
||||||
|
{
|
||||||
|
notification.setCloseReason(reason);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SnoreBackend::closeNotification(Notification n, NotificationEnums::CloseReasons::closeReasons reason)
|
||||||
|
{
|
||||||
|
m_activeNotifications.remove(n.id());
|
||||||
|
n.setCloseReason(reason);
|
||||||
|
emit closeNotification(n);
|
||||||
|
}
|
||||||
|
|
||||||
SnoreSecondaryBackend::SnoreSecondaryBackend(const QString &name)
|
SnoreSecondaryBackend::SnoreSecondaryBackend(const QString &name)
|
||||||
:SnoreBackend(name)
|
:SnoreBackend(name)
|
||||||
{
|
{
|
||||||
@ -65,9 +83,20 @@ SnoreSecondaryBackend::~SnoreSecondaryBackend()
|
|||||||
|
|
||||||
bool SnoreSecondaryBackend::init(SnoreCore *snore)
|
bool SnoreSecondaryBackend::init(SnoreCore *snore)
|
||||||
{
|
{
|
||||||
connect( snore,SIGNAL( notify(SnoreCore::Notification) ),this,SLOT( notify( SnoreCore::Notification ) ) );
|
connect( snore,SIGNAL( slotNotify(SnoreCore::Notification) ),this,SLOT( slotNotify( SnoreCore::Notification ) ) );
|
||||||
return SnoreBackend::init(snore);
|
return SnoreBackend::init(snore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Snore::Notification SnoreBackend::getActiveNotificationByID(uint id)
|
||||||
|
{
|
||||||
|
return m_activeNotifications[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
void SnoreBackend::addActiveNotification(Notification n)
|
||||||
|
{
|
||||||
|
m_activeNotifications[n.id()] = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#include "snorebackend.moc"
|
#include "snorebackend.moc"
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
#ifndef SNORE_BACKEND_H
|
#ifndef SNORE_BACKEND_H
|
||||||
#define SNORE_BACKEND_H
|
#define SNORE_BACKEND_H
|
||||||
#include "../snore_exports.h"
|
#include "../snore_exports.h"
|
||||||
#include "../notification/notification.h"
|
|
||||||
#include "plugins.h"
|
#include "plugins.h"
|
||||||
|
#include "../notification/notification.h"
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QFlag>
|
#include <QFlag>
|
||||||
@ -27,7 +27,7 @@
|
|||||||
namespace Snore{
|
namespace Snore{
|
||||||
class SnoreCore;
|
class SnoreCore;
|
||||||
|
|
||||||
class SNORE_EXPORT SnoreBackend:public SnorePlugin
|
class SNORE_EXPORT SnoreBackend : public SnorePlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES(Snore::SnorePlugin)
|
Q_INTERFACES(Snore::SnorePlugin)
|
||||||
@ -36,13 +36,27 @@ public:
|
|||||||
virtual ~SnoreBackend();
|
virtual ~SnoreBackend();
|
||||||
virtual bool init(SnoreCore *snore);
|
virtual bool init(SnoreCore *snore);
|
||||||
|
|
||||||
|
bool requestCloseNotification( Snore::Notification notification,NotificationEnums::CloseReasons::closeReasons reason );
|
||||||
|
|
||||||
|
Snore::Notification getActiveNotificationByID(uint id);
|
||||||
|
void addActiveNotification(Notification n);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void closeNotification( Snore::Notification );
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void registerApplication ( Snore::Application *application ) = 0;
|
virtual void slotRegisterApplication ( Snore::Application *application ) = 0;
|
||||||
virtual void unregisterApplication ( Snore::Application *application ) = 0;
|
virtual void slotUnregisterApplication ( Snore::Application *application ) = 0;
|
||||||
virtual uint notify ( Snore::Notification notification ) = 0;
|
virtual uint slotNotify ( Snore::Notification notification ) = 0;
|
||||||
virtual void closeNotification ( Snore::Notification notification ) =0;
|
virtual bool slotCloseNotification ( Snore::Notification notification ) =0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void closeNotification(Snore::Notification,Snore::NotificationEnums::CloseReasons::closeReasons);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
QHash<uint,Notification> m_activeNotifications;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ bool SnoreFrontend::init( SnoreCore *snore )
|
|||||||
{
|
{
|
||||||
if(!SnorePlugin::init(snore))
|
if(!SnorePlugin::init(snore))
|
||||||
return false;
|
return false;
|
||||||
connect( snore,SIGNAL ( closeNotify( Snore::Notification ) ),this,SLOT ( notificationClosed( Snore::Notification) ) );
|
connect( snore,SIGNAL ( notificationClosed( Snore::Notification ) ),this,SLOT ( notificationClosed( Snore::Notification) ) );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,11 @@ QSettings *SnoreCore::cacheFile(){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SnoreCore::slotNotificationClosed(Notification n)
|
||||||
|
{
|
||||||
|
emit notificationClosed(n);
|
||||||
|
}
|
||||||
|
|
||||||
QString const SnoreCore::version(){
|
QString const SnoreCore::version(){
|
||||||
static QString ver(QString().append(Version::major()).append(".").append(Version::minor()).append(Version::suffix()));
|
static QString ver(QString().append(Version::major()).append(".").append(Version::minor()).append(Version::suffix()));
|
||||||
return ver;
|
return ver;
|
||||||
@ -223,19 +228,13 @@ uint SnoreCore::broadcastNotification ( Notification notification )
|
|||||||
qDebug()<<"Notification backend "<<m_notificationBackend<<" isnt initialized will snore will exit now";
|
qDebug()<<"Notification backend "<<m_notificationBackend<<" isnt initialized will snore will exit now";
|
||||||
qApp->quit();
|
qApp->quit();
|
||||||
}
|
}
|
||||||
notification.setId(m_notificationBackend->notify( notification ));
|
m_notificationBackend->slotNotify( notification );
|
||||||
m_activeNotifications[notification.id()] = notification;
|
m_notificationBackend->addActiveNotification(notification);
|
||||||
return notification.id();
|
return notification.id();
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnoreCore::closeNotification ( Notification notification,const NotificationEnums::CloseReasons::closeReasons &reason )
|
|
||||||
{
|
|
||||||
notification.setCloseReason(reason);
|
|
||||||
m_activeNotifications.remove(notification.id());
|
|
||||||
emit closeNotify ( notification );
|
|
||||||
}
|
|
||||||
|
|
||||||
void SnoreCore::notificationActionInvoked ( Notification notification )
|
void SnoreCore::notificationActionInvoked ( Notification notification )
|
||||||
{
|
{
|
||||||
@ -299,8 +298,10 @@ void SnoreCore::setPrimaryNotificationBackend ( const QString &backend )
|
|||||||
qDebug()<<"Failed to initialize"<<b->name();
|
qDebug()<<"Failed to initialize"<<b->name();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
connect(b,SIGNAL(closeNotification(Snore::Notification)),this,SLOT(slotNotificationClosed(Snore::Notification)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_notificationBackend = b;
|
m_notificationBackend = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,7 +319,19 @@ QSystemTrayIcon *SnoreCore::trayIcon(){
|
|||||||
|
|
||||||
Notification SnoreCore::getActiveNotificationByID(uint id)
|
Notification SnoreCore::getActiveNotificationByID(uint id)
|
||||||
{
|
{
|
||||||
return m_activeNotifications[id];
|
if(!m_notificationBackend->isInitialized()){
|
||||||
|
qDebug()<<"Notification backend "<<m_notificationBackend<<" isn't initialized will snore will exit now";
|
||||||
|
qApp->quit();
|
||||||
|
}
|
||||||
|
return m_notificationBackend->getActiveNotificationByID(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SnoreCore::requestCloseNotification(Notification n, NotificationEnums::CloseReasons::closeReasons r)
|
||||||
|
{
|
||||||
|
if(m_notificationBackend->requestCloseNotification(n,r))
|
||||||
|
{
|
||||||
|
emit notificationClosed(n);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,6 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
uint broadcastNotification ( Notification notification );
|
uint broadcastNotification ( Notification notification );
|
||||||
void closeNotification ( Notification notification, const NotificationEnums::CloseReasons::closeReasons &reason );
|
|
||||||
void notificationActionInvoked ( Notification notification );
|
void notificationActionInvoked ( Notification notification );
|
||||||
|
|
||||||
void addApplication ( Application *application );
|
void addApplication ( Application *application );
|
||||||
@ -64,6 +63,9 @@ public:
|
|||||||
|
|
||||||
Notification getActiveNotificationByID(uint id);
|
Notification getActiveNotificationByID(uint id);
|
||||||
|
|
||||||
|
void requestCloseNotification(Notification,NotificationEnums::CloseReasons::closeReasons);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -74,7 +76,6 @@ private:
|
|||||||
static QDir *s_pluginDir;
|
static QDir *s_pluginDir;
|
||||||
|
|
||||||
ApplicationsList m_applications;
|
ApplicationsList m_applications;
|
||||||
QHash<uint,Notification> m_activeNotifications;
|
|
||||||
|
|
||||||
|
|
||||||
QStringList m_notificationBackends;
|
QStringList m_notificationBackends;
|
||||||
@ -92,7 +93,10 @@ signals:
|
|||||||
void applicationRemoved( Snore::Application* );
|
void applicationRemoved( Snore::Application* );
|
||||||
void notify( Snore::Notification noti );
|
void notify( Snore::Notification noti );
|
||||||
void actionInvoked( Snore::Notification );
|
void actionInvoked( Snore::Notification );
|
||||||
void closeNotify( Snore::Notification );
|
void notificationClosed(Snore::Notification );
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void slotNotificationClosed(Snore::Notification);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,7 +13,8 @@ if( WITH_GROWL_BACKEND )
|
|||||||
|
|
||||||
if(MINGW)
|
if(MINGW)
|
||||||
#fiexes a multiple defenition error with static boost
|
#fiexes a multiple defenition error with static boost
|
||||||
SET_TARGET_PROPERTIES(growl PROPERTIES LINK_FLAGS -Wl,--allow-multiple-definition)
|
SET_TARGET_PROPERTIES(growl PROPERTIES LINK_FLAGS -Wl,--allow-multiple-definition COMPILE_FLAGS
|
||||||
|
"-Wno-undef -Wno-unused-parameter -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-missing-field-initializers -Wno-strict-aliasing -Wno-reorder -Wno-unused-variable -Wno-unused-function" )
|
||||||
endif(MINGW)
|
endif(MINGW)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
@ -38,12 +38,12 @@ Growl::Growl():
|
|||||||
Growl::~Growl(){
|
Growl::~Growl(){
|
||||||
if(snore() != NULL){
|
if(snore() != NULL){
|
||||||
foreach(Application *a,snore()->aplications()){
|
foreach(Application *a,snore()->aplications()){
|
||||||
this->unregisterApplication(a);
|
this->slotUnregisterApplication(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Growl::registerApplication(Application *application){
|
void Growl::slotRegisterApplication(Application *application){
|
||||||
gntp *growl = new gntp(application->name().toUtf8().constData(),application->icon().localUrl().toUtf8().constData());
|
gntp *growl = new gntp(application->name().toUtf8().constData(),application->icon().localUrl().toUtf8().constData());
|
||||||
|
|
||||||
|
|
||||||
@ -62,14 +62,14 @@ void Growl::registerApplication(Application *application){
|
|||||||
m_applications.insert(application->name(),growl);
|
m_applications.insert(application->name(),growl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Growl::unregisterApplication(Application *application){
|
void Growl::slotUnregisterApplication(Application *application){
|
||||||
gntp *growl = m_applications.take(application->name());
|
gntp *growl = m_applications.take(application->name());
|
||||||
if(growl == NULL)
|
if(growl == NULL)
|
||||||
return;
|
return;
|
||||||
delete growl;
|
delete growl;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint Growl::notify(Notification notification){
|
uint Growl::slotNotify(Notification notification){
|
||||||
gntp *growl = m_applications.value(notification.application());
|
gntp *growl = m_applications.value(notification.application());
|
||||||
if(growl == NULL)
|
if(growl == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
@ -86,8 +86,9 @@ uint Growl::notify(Notification notification){
|
|||||||
return m_id++;
|
return m_id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Growl::closeNotification(Notification notification){
|
bool Growl::slotCloseNotification(Notification notification){
|
||||||
Q_UNUSED(notification);
|
Q_UNUSED(notification);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Growl::gntpCallback(const int &id,const std::string &reason,const std::string &data){
|
void Growl::gntpCallback(const int &id,const std::string &reason,const std::string &data){
|
||||||
@ -103,7 +104,7 @@ void Growl::gntpCallback(const int &id,const std::string &reason,const std::stri
|
|||||||
n.setActionInvoked(QString(data.c_str()).toInt());
|
n.setActionInvoked(QString(data.c_str()).toInt());
|
||||||
s_instance->snore()->notificationActionInvoked(n);
|
s_instance->snore()->notificationActionInvoked(n);
|
||||||
}
|
}
|
||||||
s_instance->snore()->closeNotification(n,r);
|
s_instance->closeNotification(n,r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,10 +36,10 @@ private:
|
|||||||
QHash<QString,class gntp*> m_applications;
|
QHash<QString,class gntp*> m_applications;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void registerApplication(Snore::Application *application);
|
void slotRegisterApplication(Snore::Application *application);
|
||||||
void unregisterApplication(Snore::Application *application);
|
void slotUnregisterApplication(Snore::Application *application);
|
||||||
uint notify(Snore::Notification notification);
|
uint slotNotify(Snore::Notification notification);
|
||||||
void closeNotification(Snore::Notification notification);
|
bool slotCloseNotification(Snore::Notification notification);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,12 +1,17 @@
|
|||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
message(STATUS "Adding Snarl notification backend")
|
message(STATUS "Adding Snarl notification backend")
|
||||||
|
|
||||||
|
|
||||||
set( SNARL_SRC
|
set( SNARL_SRC
|
||||||
SnarlInterface.cpp
|
SnarlInterface.cpp
|
||||||
snarl.cpp
|
snarl.cpp
|
||||||
)
|
)
|
||||||
add_library(snarl MODULE ${SNARL_SRC} )
|
add_library(snarl MODULE ${SNARL_SRC} )
|
||||||
target_link_libraries(snarl snorecore ${QT_QTCORE_LIBRARY} )
|
target_link_libraries(snarl snorecore ${QT_QTCORE_LIBRARY} )
|
||||||
|
if(MINGW)
|
||||||
|
set_target_properties(snarl PROPERTIES COMPILE_FLAGS "-Wno-conversion-null")
|
||||||
|
endif(MINGW)
|
||||||
|
|
||||||
install(TARGETS snarl ${SNORE_BACKEND_INSTALL_PATH})
|
install(TARGETS snarl ${SNORE_BACKEND_INSTALL_PATH})
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef SNARL_INTERFACE_V42_H
|
#ifndef SNARL_INTERFACE_V42_H
|
||||||
#define SNARL_INTERFACE_V42_H
|
#define SNARL_INTERFACE_V42_H
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) && !defined(MINGW_HAS_SECURE_API)
|
||||||
#define MINGW_HAS_SECURE_API
|
#define MINGW_HAS_SECURE_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
int action = msg->wParam;
|
int action = msg->wParam;
|
||||||
if(action == SnarlEnums::SnarlLaunched){
|
if(action == SnarlEnums::SnarlLaunched){
|
||||||
foreach(Application *a,m_snarl->snore()->aplications()){
|
foreach(Application *a,m_snarl->snore()->aplications()){
|
||||||
m_snarl->registerApplication(a);
|
m_snarl->slotRegisterApplication(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ public:
|
|||||||
qDebug()<<"Unknown snarl action found!!";
|
qDebug()<<"Unknown snarl action found!!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_snarl->snore()->closeNotification(notification,reason);
|
m_snarl->closeNotification(notification,reason);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -112,7 +112,7 @@ SnarlBackend::~SnarlBackend()
|
|||||||
{
|
{
|
||||||
if(snore() != NULL){
|
if(snore() != NULL){
|
||||||
foreach(Application *a,snore()->aplications()){
|
foreach(Application *a,snore()->aplications()){
|
||||||
this->unregisterApplication(a);
|
this->slotUnregisterApplication(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(m_defautSnarlinetrface)
|
if(m_defautSnarlinetrface)
|
||||||
@ -130,7 +130,7 @@ bool SnarlBackend::init(SnoreCore *snore){
|
|||||||
return SnoreBackend::init(snore);
|
return SnoreBackend::init(snore);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnarlBackend::registerApplication(Application *application){
|
void SnarlBackend::slotRegisterApplication(Application *application){
|
||||||
SnarlInterface *snarlInterface = NULL;
|
SnarlInterface *snarlInterface = NULL;
|
||||||
if(m_applications.contains(application->name())){
|
if(m_applications.contains(application->name())){
|
||||||
snarlInterface = m_applications.value(application->name());
|
snarlInterface = m_applications.value(application->name());
|
||||||
@ -154,7 +154,7 @@ void SnarlBackend::registerApplication(Application *application){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnarlBackend::unregisterApplication(Application *application){
|
void SnarlBackend::slotUnregisterApplication(Application *application){
|
||||||
SnarlInterface *snarlInterface = m_applications.take(application->name());
|
SnarlInterface *snarlInterface = m_applications.take(application->name());
|
||||||
if(snarlInterface == NULL)
|
if(snarlInterface == NULL)
|
||||||
return;
|
return;
|
||||||
@ -164,7 +164,7 @@ void SnarlBackend::unregisterApplication(Application *application){
|
|||||||
delete snarlInterface;
|
delete snarlInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint SnarlBackend::notify(Notification notification){
|
uint SnarlBackend::slotNotify(Notification notification){
|
||||||
SnarlInterface *snarlInterface = m_applications.value(notification.application());
|
SnarlInterface *snarlInterface = m_applications.value(notification.application());
|
||||||
if(snarlInterface == NULL){
|
if(snarlInterface == NULL){
|
||||||
qDebug()<<notification.application()<<"not in snarl interfaces, defaulting";
|
qDebug()<<notification.application()<<"not in snarl interfaces, defaulting";
|
||||||
@ -200,8 +200,9 @@ uint SnarlBackend::notify(Notification notification){
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnarlBackend::closeNotification(Notification notification){
|
bool SnarlBackend::slotCloseNotification(Notification notification){
|
||||||
m_defautSnarlinetrface->Hide(notification.id());
|
m_defautSnarlinetrface->Hide(notification.id());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "snarl.moc"
|
#include "snarl.moc"
|
||||||
|
@ -37,10 +37,10 @@ private:
|
|||||||
Snarl::V42::SnarlInterface* m_defautSnarlinetrface;
|
Snarl::V42::SnarlInterface* m_defautSnarlinetrface;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void registerApplication(Snore::Application *application);
|
void slotRegisterApplication(Snore::Application *application);
|
||||||
void unregisterApplication(Snore::Application *application);
|
void slotUnregisterApplication(Snore::Application *application);
|
||||||
uint notify(Snore::Notification notification);
|
uint slotNotify(Snore::Notification notification);
|
||||||
void closeNotification(Snore::Notification notification);
|
bool slotCloseNotification(Snore::Notification notification);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,17 +49,17 @@ bool SnoreToast::init(SnoreCore *snore)
|
|||||||
return SnoreBackend::init(snore);
|
return SnoreBackend::init(snore);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnoreToast::registerApplication(Application *application)
|
void SnoreToast::slotRegisterApplication(Application *application)
|
||||||
{
|
{
|
||||||
Q_UNUSED(application)
|
Q_UNUSED(application)
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnoreToast::unregisterApplication(Application *application)
|
void SnoreToast::slotUnregisterApplication(Application *application)
|
||||||
{
|
{
|
||||||
Q_UNUSED(application)
|
Q_UNUSED(application)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint SnoreToast::notify(Notification notification)
|
uint SnoreToast::slotNotify(Notification notification)
|
||||||
{
|
{
|
||||||
QProcess *p = new QProcess(this);
|
QProcess *p = new QProcess(this);
|
||||||
|
|
||||||
@ -87,9 +87,10 @@ uint SnoreToast::notify(Notification notification)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnoreToast::closeNotification(Notification notification)
|
bool SnoreToast::slotCloseNotification(Notification notification)
|
||||||
{
|
{
|
||||||
Q_UNUSED(notification)
|
Q_UNUSED(notification)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnoreToast::slotToastNotificationClosed(int code, QProcess::ExitStatus)
|
void SnoreToast::slotToastNotificationClosed(int code, QProcess::ExitStatus)
|
||||||
@ -123,7 +124,7 @@ void SnoreToast::slotToastNotificationClosed(int code, QProcess::ExitStatus)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
snore()->closeNotification(n,reason);
|
closeNotification(n,reason);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,10 +15,10 @@ public:
|
|||||||
|
|
||||||
// SnoreBackend interface
|
// SnoreBackend interface
|
||||||
public slots:
|
public slots:
|
||||||
void registerApplication(Snore::Application *application);
|
void slotRegisterApplication(Snore::Application *application);
|
||||||
void unregisterApplication(Snore::Application *application);
|
void slotUnregisterApplication(Snore::Application *application);
|
||||||
uint notify(Snore::Notification notification);
|
uint slotNotify(Snore::Notification notification);
|
||||||
void closeNotification(Snore::Notification notification);
|
bool slotCloseNotification(Snore::Notification notification);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotToastNotificationClosed(int code, QProcess::ExitStatus);
|
void slotToastNotificationClosed(int code, QProcess::ExitStatus);
|
||||||
|
@ -12,9 +12,9 @@ Q_EXPORT_PLUGIN2(trayicon,TrayIconNotifer)
|
|||||||
|
|
||||||
TrayIconNotifer::TrayIconNotifer () :
|
TrayIconNotifer::TrayIconNotifer () :
|
||||||
SnoreBackend ( "SystemTray" ),
|
SnoreBackend ( "SystemTray" ),
|
||||||
|
m_trayIcon(NULL),
|
||||||
m_id ( 0 ),
|
m_id ( 0 ),
|
||||||
m_displayed(-1),
|
m_displayed(-1)
|
||||||
m_trayIcon(NULL)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -27,16 +27,16 @@ bool TrayIconNotifer::init(SnoreCore *snore){
|
|||||||
return SnoreBackend::init(snore);
|
return SnoreBackend::init(snore);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrayIconNotifer::registerApplication ( Application *application )
|
void TrayIconNotifer::slotRegisterApplication ( Application *application )
|
||||||
{
|
{
|
||||||
Q_UNUSED ( application )
|
Q_UNUSED ( application )
|
||||||
}
|
}
|
||||||
void TrayIconNotifer::unregisterApplication ( Application *application )
|
void TrayIconNotifer::slotUnregisterApplication ( Application *application )
|
||||||
{
|
{
|
||||||
Q_UNUSED ( application )
|
Q_UNUSED ( application )
|
||||||
}
|
}
|
||||||
|
|
||||||
uint TrayIconNotifer::notify ( Notification notification )
|
uint TrayIconNotifer::slotNotify ( Notification notification )
|
||||||
{
|
{
|
||||||
m_notificationQue.append(notification);
|
m_notificationQue.append(notification);
|
||||||
if(m_lastNotify.elapsed()> Notification::DefaultTimeout * 1000){
|
if(m_lastNotify.elapsed()> Notification::DefaultTimeout * 1000){
|
||||||
@ -45,21 +45,17 @@ uint TrayIconNotifer::notify ( Notification notification )
|
|||||||
return m_id++;
|
return m_id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrayIconNotifer::closeNotification ( Notification notification )
|
bool TrayIconNotifer::slotCloseNotification( Notification notification )
|
||||||
{
|
{
|
||||||
Q_UNUSED ( notification )
|
Q_UNUSED ( notification )
|
||||||
}
|
return false;
|
||||||
|
|
||||||
bool TrayIconNotifer::isPrimaryNotificationBackend()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrayIconNotifer::displayNotification(){
|
void TrayIconNotifer::displayNotification(){
|
||||||
qDebug()<<"Display"<<m_notificationQue.size();
|
qDebug()<<"Display"<<m_notificationQue.size();
|
||||||
Notification notification = m_notificationQue.takeFirst();
|
Notification notification = m_notificationQue.takeFirst();
|
||||||
if(!m_notificationQue.isEmpty()){
|
if(!m_notificationQue.isEmpty()){
|
||||||
QTimer::singleShot(notification.timeout()*1000,this,SLOT(closeNotification()));
|
QTimer::singleShot(notification.timeout()*1000,this,SLOT(slotCloseNotification()));
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug()<<"taking"<<notification.title();
|
qDebug()<<"taking"<<notification.title();
|
||||||
@ -68,10 +64,10 @@ void TrayIconNotifer::displayNotification(){
|
|||||||
m_lastNotify.restart();
|
m_lastNotify.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrayIconNotifer::closeNotification(){
|
void TrayIconNotifer::slotCloseNotification(){
|
||||||
Notification n = snore()->getActiveNotificationByID(m_displayed);
|
Notification n = snore()->getActiveNotificationByID(m_displayed);
|
||||||
if(n.isValid()){
|
if(n.isValid()){
|
||||||
snore()->closeNotification(n,NotificationEnums::CloseReasons::TIMED_OUT);
|
closeNotification(n,NotificationEnums::CloseReasons::TIMED_OUT);
|
||||||
}
|
}
|
||||||
displayNotification();
|
displayNotification();
|
||||||
}
|
}
|
||||||
@ -85,7 +81,7 @@ void TrayIconNotifer::actionInvoked(){
|
|||||||
n.setActionInvoked(n.actions().keys().first());
|
n.setActionInvoked(n.actions().keys().first());
|
||||||
snore()->notificationActionInvoked(n);
|
snore()->notificationActionInvoked(n);
|
||||||
}
|
}
|
||||||
snore()->closeNotification(n,NotificationEnums::CloseReasons::CLOSED);
|
closeNotification(n,NotificationEnums::CloseReasons::CLOSED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,13 +18,12 @@ class TrayIconNotifer:public Snore::SnoreBackend
|
|||||||
public:
|
public:
|
||||||
TrayIconNotifer ();
|
TrayIconNotifer ();
|
||||||
virtual bool init(Snore::SnoreCore *snore);
|
virtual bool init(Snore::SnoreCore *snore);
|
||||||
bool isPrimaryNotificationBackend();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void registerApplication ( Snore::Application *application );
|
void slotRegisterApplication ( Snore::Application *application );
|
||||||
void unregisterApplication ( Snore::Application *application );
|
void slotUnregisterApplication ( Snore::Application *application );
|
||||||
uint notify ( Snore::Notification notification );
|
uint slotNotify ( Snore::Notification notification );
|
||||||
void closeNotification ( Snore::Notification notification );
|
bool slotCloseNotification ( Snore::Notification notification );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSystemTrayIcon *m_trayIcon;
|
QSystemTrayIcon *m_trayIcon;
|
||||||
@ -36,7 +35,7 @@ private:
|
|||||||
private slots:
|
private slots:
|
||||||
void displayNotification();
|
void displayNotification();
|
||||||
void actionInvoked();
|
void actionInvoked();
|
||||||
void closeNotification();
|
void slotCloseNotification();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRAYICONNOTIFER_H
|
#endif // TRAYICONNOTIFER_H
|
||||||
|
@ -107,7 +107,7 @@ void FreedesktopFrontend::CloseNotification(uint id){
|
|||||||
Notification noti = snore()->getActiveNotificationByID(id);
|
Notification noti = snore()->getActiveNotificationByID(id);
|
||||||
if(noti.isValid())
|
if(noti.isValid())
|
||||||
{
|
{
|
||||||
snore()->closeNotification(noti,NotificationEnums::CloseReasons::TIMED_OUT);
|
snore()->requestCloseNotification(noti,NotificationEnums::CloseReasons::TIMED_OUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user