made dbus backend compile again

This commit is contained in:
Patrick von Reth 2010-08-04 17:06:22 +02:00
parent 1281aefdcf
commit ceeacf0225
8 changed files with 64 additions and 39 deletions

View File

@ -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)

View File

@ -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;
}

View File

@ -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;

View File

@ -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(){

View File

@ -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)

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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: