mirror of
https://github.com/status-im/snorenotify.git
synced 2025-01-23 06:49:27 +00:00
made dbus backend compile again
This commit is contained in:
parent
1281aefdcf
commit
ceeacf0225
@ -39,6 +39,7 @@ if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
option(WITH_FREEDESKTOP_FRONTEND "Build the freedesktop frontend" OFF)
|
||||
option(WITH_WEBINTERFACE "Buld with WebInterface" OFF)
|
||||
|
||||
set(PLUGIN_INSTALL_PATH LIBRARY DESTINATION bin/snoreplugins)
|
||||
|
@ -81,6 +81,10 @@ const Notification::actions &Notification::actionInvoked() const{
|
||||
return _actionInvoked;
|
||||
}
|
||||
|
||||
void Notification::setActionInvoked(const Notification::actions &action){
|
||||
_actionInvoked = action;
|
||||
}
|
||||
|
||||
const Notification_Frontend *Notification::source() const{
|
||||
return _source;
|
||||
}
|
||||
|
@ -30,13 +30,6 @@ class SNORE_EXPORT Notification:public QObject
|
||||
public:
|
||||
static int DefaultTimeout;
|
||||
static QString toPlainText(const QString &string);
|
||||
public:
|
||||
Notification(uint id=0);
|
||||
Notification(class Notification_Frontend *source,const QString &application,const QString &alert,const QString &title,const QString &text,const QString &icon,int timeout=10,uint id=0);
|
||||
QString toString() const;
|
||||
bool isNotification();
|
||||
void setIsNotification(bool b);
|
||||
|
||||
enum actions{
|
||||
TIMED_OUT=0,
|
||||
ACTION_1=1,
|
||||
@ -44,11 +37,17 @@ public:
|
||||
ACTION_3=3,
|
||||
CLOSED=4
|
||||
};
|
||||
|
||||
public:
|
||||
Notification(uint id=0);
|
||||
Notification(class Notification_Frontend *source,const QString &application,const QString &alert,const QString &title,const QString &text,const QString &icon,int timeout=10,uint id=0);
|
||||
QString toString() const;
|
||||
bool isNotification();
|
||||
void setIsNotification(bool b);
|
||||
|
||||
|
||||
const uint &id() const;
|
||||
const int &timeout() const;
|
||||
void setActionInvoked(const Notification::actions &action);
|
||||
const Notification::actions &actionInvoked() const;
|
||||
const class Notification_Frontend *source() const;
|
||||
const QString &application() const;
|
||||
|
@ -9,11 +9,11 @@ TrayIconNotifer::TrayIconNotifer(SnoreServer *snore, QSystemTrayIcon *icon):
|
||||
{}
|
||||
|
||||
void TrayIconNotifer::registerApplication(Application *application){
|
||||
|
||||
Q_UNUSED(application)
|
||||
}
|
||||
void TrayIconNotifer::unregisterApplication(Application *application){
|
||||
|
||||
}
|
||||
Q_UNUSED(application)
|
||||
}
|
||||
|
||||
int TrayIconNotifer::notify(QSharedPointer<Notification> notification){
|
||||
_trayIcon->showMessage(notification->title(),notification->text(),QSystemTrayIcon::NoIcon,notification->timeout()*1000);
|
||||
@ -21,7 +21,7 @@ int TrayIconNotifer::notify(QSharedPointer<Notification> notification){
|
||||
}
|
||||
|
||||
void TrayIconNotifer::closeNotification(QSharedPointer<Notification> notification){
|
||||
|
||||
Q_UNUSED(notification)
|
||||
}
|
||||
|
||||
bool TrayIconNotifer::isPrimaryNotificationBackend(){
|
||||
|
@ -1,7 +1,10 @@
|
||||
SET(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH}/snoreplugins)
|
||||
|
||||
add_subdirectory(freedesktopnotification)
|
||||
add_subdirectory(freedesktopfrontend)
|
||||
if(WITH_FREEDESKTOP_FRONTEND)
|
||||
add_subdirectory(freedesktopnotification)
|
||||
else(WITH_FREEDESKTOP_FRONTEND)
|
||||
add_subdirectory(freedesktopfrontend)
|
||||
endif(WITH_FREEDESKTOP_FRONTEND)
|
||||
#add_subdirectory(webposter)
|
||||
add_subdirectory(snarlnetwork)
|
||||
add_subdirectory(snarl)
|
||||
|
@ -48,7 +48,7 @@ QDBusArgument &operator<<(QDBusArgument &a, const FreedesktopNotification &i){
|
||||
return a;
|
||||
}
|
||||
|
||||
const QDBusArgument & operator >>(const QDBusArgument &a, FreedesktopNotification &i){
|
||||
const QDBusArgument & operator >>(const QDBusArgument &a, FreedesktopNotification &){
|
||||
//not supported
|
||||
return a;
|
||||
}
|
||||
|
@ -9,19 +9,35 @@
|
||||
|
||||
Q_EXPORT_PLUGIN2(freedesktopnotificationbackend,FreedesktopNotification_Backend)
|
||||
|
||||
FreedesktopNotification_Backend::FreedesktopNotification_Backend(SnoreServer *snore):
|
||||
Notification_Backend("FreedesktopNotification_Backend",snore)
|
||||
{
|
||||
}
|
||||
|
||||
bool FreedesktopNotification_Backend::isPrimaryNotificationBackend(){
|
||||
return true;
|
||||
}
|
||||
|
||||
void FreedesktopNotification_Backend::registerApplication(Application *application){
|
||||
Q_UNUSED(application);
|
||||
}
|
||||
|
||||
void FreedesktopNotification_Backend::unregisterApplication(Application *application){
|
||||
Q_UNUSED(application);
|
||||
}
|
||||
|
||||
int FreedesktopNotification_Backend::notify( QSharedPointer<Notification> noti){
|
||||
fNotification *n=new fNotification(this);
|
||||
fNotification *n = new fNotification(this);
|
||||
qDebug()<<noti;
|
||||
n->notification=noti;
|
||||
n->notification = noti;
|
||||
return n->send();
|
||||
}
|
||||
|
||||
void FreedesktopNotification_Backend::closeNotification(int id){
|
||||
void FreedesktopNotification_Backend::closeNotification(QSharedPointer<Notification> notification){
|
||||
//TODO: fix
|
||||
// fNotification *fn=new fNotification();
|
||||
// fn->notification=new Notification();
|
||||
// fn->notification->id=id;
|
||||
// fn->close();
|
||||
fNotification *fn=new fNotification(this);
|
||||
fn->notification=notification;
|
||||
fn->close();
|
||||
}
|
||||
|
||||
|
||||
@ -44,7 +60,7 @@ uint fNotification::send(){
|
||||
selfdistruct.setParent(this);
|
||||
selfdistruct.setSingleShot(true);
|
||||
connect(&selfdistruct, SIGNAL(timeout()), this, SLOT(close()));
|
||||
selfdistruct.start(notification->timeout*1000);
|
||||
selfdistruct.start(notification->timeout()*1000);
|
||||
QDBusConnection::sessionBus().connect("org.freedesktop.Notifications","/org/freedesktop/Notifications","org.freedesktop.Notifications","ActionInvoked",this,SLOT(action(uint,QString)));
|
||||
if(getVendor()=="GNOME")
|
||||
QDBusConnection::sessionBus().connect("org.freedesktop.Notifications","/org/freedesktop/Notifications","org.freedesktop.Notifications","NotificationClosed",this,SLOT(closed(uint,uint)));
|
||||
@ -52,7 +68,7 @@ uint fNotification::send(){
|
||||
}
|
||||
|
||||
void fNotification::action(const uint &id, const QString &action_key){
|
||||
if(id!=notification->getID())return;
|
||||
if(id!=notification->id())return;
|
||||
close();
|
||||
qDebug()<<id<<"|"<<action_key ;
|
||||
|
||||
@ -60,19 +76,20 @@ void fNotification::action(const uint &id, const QString &action_key){
|
||||
//default is only working on gnome
|
||||
|
||||
|
||||
notification->actionInvoked=(action_key=="default"?Notification::ACTION_1:Notification::actions(action_key.toInt()));
|
||||
parent->getSnore()->notificationActionInvoked(notification);
|
||||
notification->setActionInvoked(action_key=="default"?Notification::ACTION_1:Notification::actions(action_key.toInt()));
|
||||
parent->snore()->notificationActionInvoked(notification);
|
||||
selfDelete();
|
||||
}
|
||||
|
||||
void fNotification::closed(const uint &id,const uint &reason){
|
||||
qDebug()<<id<<"|"<<reason;;
|
||||
if(id!=notification->getID())return;
|
||||
if(id!=notification->id())return;
|
||||
close();
|
||||
if(reason==1)
|
||||
notification->actionInvoked=Notification::TIMED_OUT;
|
||||
notification->setActionInvoked(Notification::TIMED_OUT);
|
||||
if(reason==2)
|
||||
notification->actionInvoked=Notification::CLOSED;
|
||||
parent->getSnore()->closeNotification(notification);
|
||||
notification->setActionInvoked(Notification::CLOSED);
|
||||
parent->snore()->closeNotification(notification);
|
||||
selfDelete();
|
||||
}
|
||||
|
||||
@ -81,8 +98,8 @@ void fNotification::closed(const uint &id,const uint &reason){
|
||||
void fNotification::close(){
|
||||
blockSignals(true);
|
||||
if( !selfdistruct.isActive()){
|
||||
notification->actionInvoked=Notification::TIMED_OUT;
|
||||
parent->getSnore()->closeNotification(notification);
|
||||
notification->setActionInvoked(Notification::TIMED_OUT);
|
||||
parent->snore()->closeNotification(notification);
|
||||
selfDelete();
|
||||
}
|
||||
selfdistruct.stop();
|
||||
@ -98,7 +115,7 @@ QString fNotification::getVendor(){
|
||||
}
|
||||
void fNotification::selfDelete(){
|
||||
notification.clear();
|
||||
delete this;
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,14 +11,14 @@ class FreedesktopNotification_Backend:public Notification_Backend
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(Notification_Backend)
|
||||
public:
|
||||
FreedesktopNotification_Backend()
|
||||
{
|
||||
setProperty("name","FreedesktopNotification_Backend");
|
||||
};
|
||||
bool isPrimaryNotificationBackend(){return true;}
|
||||
FreedesktopNotification_Backend(class SnoreServer *snore=0);
|
||||
bool isPrimaryNotificationBackend();
|
||||
public slots:
|
||||
void registerApplication(Application *application);
|
||||
void unregisterApplication(Application *application);
|
||||
int notify(QSharedPointer<class Notification>notification);
|
||||
void closeNotification(int id);
|
||||
void closeNotification(QSharedPointer<Notification> notification);
|
||||
|
||||
|
||||
};
|
||||
|
||||
@ -27,6 +27,7 @@ public slots:
|
||||
|
||||
class fNotification:public QObject{
|
||||
Q_OBJECT
|
||||
friend class FreedesktopNotification_Backend;
|
||||
public:
|
||||
static QDBusInterface notificationInterface;
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user