fixed action menus in snarl backend, fixed register with snarl if app name contains spaces,version bump to 0.1.5,cleaned up,some improvements in the freedesktopfrontend

This commit is contained in:
Patrick von Reth 2011-07-20 00:57:41 +02:00
parent ea8ab89e8e
commit 1f324d8b27
8 changed files with 24 additions and 23 deletions

View File

@ -13,8 +13,7 @@ include( ${QT_USE_FILE} )
include_directories( include_directories(
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR}
${QT_QTNETWORK_INCLUDE_DIR} ${QT_QTDBUS_INCLUDE_DIR} ${QT_QTNETWORK_INCLUDE_DIR} ${QT_QTDBUS_INCLUDE_DIR})
${CMAKE_SOURCE_DIR}/3party/gntp-send/headers)
if (CMAKE_COMPILER_IS_GNUCXX) if (CMAKE_COMPILER_IS_GNUCXX)

View File

@ -8,19 +8,20 @@ add_subdirectory(core)
QT4_ADD_RESOURCES(SNORENOTIFY_RCS ${SNORE_RCS}) QT4_ADD_RESOURCES(SNORENOTIFY_RCS ${SNORE_RCS})
set(SNORENOTIFY_DEPS ${SNORENOTIFY_DEPS} ${SNORENOTIFY_RCS}) set(SNORENOTIFY_DEPS ${SNORENOTIFY_DEPS} ${SNORENOTIFY_RCS})
#if(WIN32) if(WIN32)
# set(WIN32_SPECIFIC WIN32) set(WIN32_SPECIFIC WIN32)
#else(WIN32) else(WIN32)
set(WIN32_SPECIFIC) set(WIN32_SPECIFIC)
#endif(WIN32) endif(WIN32)
automoc4_add_executable( snorenotify ${WIN32_SPECIFIC} main.cpp snorenotify.cpp trayicon.cpp ${SNORENOTIFY_DEPS}) automoc4_add_executable( snorenotify ${WIN32_SPECIFIC} main.cpp snorenotify.cpp trayicon.cpp ${SNORENOTIFY_DEPS})
target_link_libraries( snorenotify snorecore ${QT_QTGUI_LIBRARY} ${QT_QTXML_LIBRARY} ) target_link_libraries( snorenotify snorecore ${QT_QTGUI_LIBRARY} ${QT_QTXML_LIBRARY} )
if(MSVC) if(MSVC)
set_target_properties(snorenotify PROPERTIES LINK_FLAGS "/ENTRY:\"mainCRTStartup\"") set_target_properties(snorenotify PROPERTIES LINK_FLAGS "/ENTRY:\"mainCRTStartup\"")
endif(MSVC) endif(MSVC)
add_dependencies(snorenotify snorecore) add_dependencies(snorenotify snorecore)
install(TARGETS snorenotify RUNTIME DESTINATION bin install(TARGETS snorenotify RUNTIME DESTINATION bin

View File

@ -1,6 +1,5 @@
set ( SnoreNotify_SRCS set ( SnoreNotify_SRCS
notification.cpp notification.cpp
# notificationdata.cpp
snoreserver.cpp snoreserver.cpp
application.cpp application.cpp
interface.cpp interface.cpp

View File

@ -28,7 +28,7 @@
QString const SnoreServer::version(){ QString const SnoreServer::version(){
return "0.1"; return "0.1.5";
} }
QString const SnoreServer::snoreTMP(){ QString const SnoreServer::snoreTMP(){
@ -143,9 +143,7 @@ int SnoreServer::broadcastNotification ( Notification notification )
emit notify ( notification ); emit notify ( notification );
if ( _notificationBackend!=NULL ) if ( _notificationBackend!=NULL )
{ {
qDebug()<<"Broadcasting";
notification.setId(_notificationBackend->notify ( notification )); notification.setId(_notificationBackend->notify ( notification ));
qDebug()<<"Notification ID: "<<notification.id();
return notification.id(); return notification.id();
} }
return -1; return -1;

View File

@ -47,6 +47,7 @@ void FreedesktopNotification_Frontend::actionInvoked(Notification notification)
void FreedesktopNotification_Frontend::notificationClosed(Notification notification) { void FreedesktopNotification_Frontend::notificationClosed(Notification notification) {
qDebug()<<"Closing Dbus notification"<<notification.id()<<"reason:"<<(int)notification.closeReason(); qDebug()<<"Closing Dbus notification"<<notification.id()<<"reason:"<<(int)notification.closeReason();
activeNotifications.take(notification.id());
emit NotificationClosed(notification.id(),notification.closeReason()); emit NotificationClosed(notification.id(),notification.closeReason());
} }
@ -63,7 +64,6 @@ uint FreedesktopNotification_Frontend::Notify(const QString &app_name, uint repl
const QStringList &actions, const QVariantMap &hints, int timeout) const QStringList &actions, const QVariantMap &hints, int timeout)
{ {
qDebug()<<app_name<<summary<<body<<app_icon; qDebug()<<app_name<<summary<<body<<app_icon;
qDebug()<<"Hints:"<<hints;
QString icon; QString icon;
if(hints.contains("image_data")){ if(hints.contains("image_data")){
@ -83,15 +83,17 @@ uint FreedesktopNotification_Frontend::Notify(const QString &app_name, uint repl
for(int i = 0;i < actions.length(); i+=2){ for(int i = 0;i < actions.length(); i+=2){
noti.addAction(new Action(actions.at(i).toInt(),actions.at(i+1))); noti.addAction(new Action(actions.at(i).toInt(),actions.at(i+1)));
} }
return snore()->broadcastNotification(noti);
snore()->broadcastNotification(noti);
activeNotifications[noti.id()] = noti;
return noti.id();
} }
void FreedesktopNotification_Frontend::CloseNotification(uint id){ void FreedesktopNotification_Frontend::CloseNotification(uint id){
//TODO: do something usefull here Notification noti = activeNotifications.take(id);
Notification n(id); snore()->closeNotification(noti,Notification::TIMED_OUT);
snore()->closeNotification(n,Notification::NONE);
} }
QStringList FreedesktopNotification_Frontend::GetCapabilities() QStringList FreedesktopNotification_Frontend::GetCapabilities()

View File

@ -35,6 +35,9 @@ public:
QStringList GetCapabilities(); QStringList GetCapabilities();
QString GetServerInformation(QString& vendor, QString& version, QString& specVersion); QString GetServerInformation(QString& vendor, QString& version, QString& specVersion);
private:
QHash<uint,Notification> activeNotifications;
signals: signals:
void NotificationClosed( uint id, uint reason ); void NotificationClosed( uint id, uint reason );
void ActionInvoked( uint id, const QString& actionKey ); void ActionInvoked( uint id, const QString& actionKey );

View File

@ -1,6 +1,6 @@
if( WITH_GROWL_BACKEND ) if( WITH_GROWL_BACKEND )
if(CRYPTOPP_LIBRARIES AND Boost_SYSTEM_LIBRARY) if(CRYPTOPP_LIBRARIES AND Boost_SYSTEM_LIBRARY)
message( STATUS "Found libgrowl, adding libgrowl backend" ) message( STATUS "Found Boost and Cryptopp, adding libgrowl backend" )
set( GROWL__SRC set( GROWL__SRC
growl_backend.cpp growl_backend.cpp
) )

View File

@ -63,7 +63,9 @@ void Snarl_Backend::registerApplication(Application *application){
_applications.insert(application->name(),snarlInterface); _applications.insert(application->name(),snarlInterface);
} }
qDebug()<<"Register with Snarl"<<application->name()<<application->icon(); qDebug()<<"Register with Snarl"<<application->name()<<application->icon();
snarlInterface->Register(application->name().toUtf8().constData(), QString appName = application->name();
appName = appName.replace(" ","_");//app sig must not contain spaces
snarlInterface->Register(appName.toUtf8().constData(),
application->name().toUtf8().constData(), application->name().toUtf8().constData(),
application->icon().toUtf8().constData(), application->icon().toUtf8().constData(),
0,winIDWidget->winId(),SNORENOTIFIER_MESSAGE_ID); 0,winIDWidget->winId(),SNORENOTIFIER_MESSAGE_ID);
@ -149,16 +151,13 @@ bool SnarlWidget::winEvent(MSG * msg, long * result){
uint notificationID = msg->lParam; uint notificationID = msg->lParam;
qDebug()<<_snarl->activeNotifications.keys(); qDebug()<<_snarl->activeNotifications.keys();
Notification notification(_snarl->activeNotifications[notificationID]); Notification notification(_snarl->activeNotifications[notificationID]);
qDebug()<<"arg"<<notification.toString(); qDebug()<<"recived a Snarl callback id:"<<notificationID<<"action:"<<action<<"data:"<<data;
qDebug()<<notification.id();
qDebug()<<"recived a Snarl callback id:"<<notificationID<<"action:"<<action;
qDebug()<<"data:"<<data;
Notification::closeReasons reason = Notification::NONE; Notification::closeReasons reason = Notification::NONE;
switch(action){ switch(action){
case SnarlEnums::CallbackInvoked: case SnarlEnums::CallbackInvoked:
reason = Notification::CLOSED; reason = Notification::CLOSED;
break; break;
case SnarlEnums::CallbackMenuSelected: case SnarlEnums::NotifyAction:
reason = Notification::CLOSED; reason = Notification::CLOSED;
notification.setActionInvoked(data); notification.setActionInvoked(data);
_snarl->snore()->notificationActionInvoked(notification); _snarl->snore()->notificationActionInvoked(notification);