diff --git a/CMakeLists.txt b/CMakeLists.txt index 93369d3..de4142a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,43 +4,19 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules ${C set(CMAKE_INCLUDE_CURRENT_DIR ON) -find_package( Qt4 REQUIRED ) -find_package( Automoc4 REQUIRED) +find_package(KDE4) + +if(KDE4_FOUND) + add_definitions(-DHAVE_KDE ${KDE4_DEFINITIONS} -D_UNICODE) + include_directories(${KDE4_INCLUDES}) +else(KDE4_FOUND) + include(NoKDE) +endif(KDE4_FOUND) + + find_package( CryptoPP ) find_package( Boost COMPONENTS system ) -include( ${QT_USE_FILE} ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} - ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTNETWORK_INCLUDE_DIR} ${QT_QTDBUS_INCLUDE_DIR}) - - -if (CMAKE_COMPILER_IS_GNUCXX) - set (KDE4_ENABLE_EXCEPTIONS -fexceptions) - # Select flags. - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") - set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG") - set(CMAKE_CXX_FLAGS_DEBUG "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline") - set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -fno-inline") - set(CMAKE_CXX_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs") - set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") - set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG") - set(CMAKE_C_FLAGS_DEBUG "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline") - set(CMAKE_C_FLAGS_DEBUGFULL "-g3 -fno-inline") - set(CMAKE_C_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs") - - if (CMAKE_SYSTEM_NAME MATCHES Linux) - set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common") - set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -fno-exceptions -fno-check-new -fno-common") - add_definitions (-D_BSD_SOURCE) - endif (CMAKE_SYSTEM_NAME MATCHES Linux) - -endif(CMAKE_COMPILER_IS_GNUCXX) - -if(MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t-") -endif(MSVC) option(WITH_FREEDESKTOP_FRONTEND "Build the freedesktop frontend" OFF) option(WITH_GROWL_BACKEND "Build the Growl backend" ON) diff --git a/cmake/modules/NoKDE.cmake b/cmake/modules/NoKDE.cmake new file mode 100644 index 0000000..5ce391f --- /dev/null +++ b/cmake/modules/NoKDE.cmake @@ -0,0 +1,33 @@ +find_package( Qt4 REQUIRED ) +find_package( Automoc4 REQUIRED) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} + ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTNETWORK_INCLUDE_DIR} ${QT_QTDBUS_INCLUDE_DIR}) + + + +include( ${QT_USE_FILE} ) + +if (CMAKE_COMPILER_IS_GNUCXX) + set (KDE4_ENABLE_EXCEPTIONS -fexceptions) + # Select flags. + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") + set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG") + set(CMAKE_CXX_FLAGS_DEBUG "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline") + set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -fno-inline") + set(CMAKE_CXX_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") + set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG") + set(CMAKE_C_FLAGS_DEBUG "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline") + set(CMAKE_C_FLAGS_DEBUGFULL "-g3 -fno-inline") + set(CMAKE_C_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs") + + if (CMAKE_SYSTEM_NAME MATCHES Linux) + set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common") + set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -fno-exceptions -fno-check-new -fno-common") + add_definitions (-D_BSD_SOURCE) + endif (CMAKE_SYSTEM_NAME MATCHES Linux) + +endif(CMAKE_COMPILER_IS_GNUCXX) diff --git a/src/core/application.cpp b/src/core/application.cpp index b1b7d4c..4f42064 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -67,7 +67,7 @@ void Application::setInitialized ( bool b ) _initialized = b; } -Alert::Alert (const QString &name, const QString &title, const QString &icon, bool active) : +Alert::Alert (const QString &name, const QString &title, const SnoreIcon &icon, bool active) : _name ( name ), _title ( title ), _icon(icon), @@ -89,7 +89,7 @@ const QString &Alert::title() const return _title; } -const QString &Alert::icon() const +const SnoreIcon &Alert::icon() const { return _icon; } diff --git a/src/core/application.h b/src/core/application.h index 5055fcf..3db6542 100644 --- a/src/core/application.h +++ b/src/core/application.h @@ -28,7 +28,7 @@ class SNORE_EXPORT Application:public QObject { Q_OBJECT public: - Application ( const QString &name, const SnoreIcon &icon = SnoreIcon(QImage(":/root/zzz.png"))); + Application ( const QString &name, const SnoreIcon &icon = SnoreIcon(":/root/zzz.png")); Application(); ~Application(); void addAlert ( Alert *alert ); @@ -51,17 +51,17 @@ class SNORE_EXPORT Alert:public QObject { Q_OBJECT public: - Alert ( const QString &name,const QString &title="",const QString &icon="",bool active=true ); + Alert ( const QString &name,const QString &title="",const SnoreIcon &icon = SnoreIcon(":/root/zzz.png"),bool active=true ); Alert(); const QString &name() const; const QString &title() const; - const QString &icon() const; + const SnoreIcon &icon() const; bool isActive() const; private: QString _name; QString _title; - QString _icon; + SnoreIcon _icon; bool _active; }; diff --git a/src/core/notification/icon.cpp b/src/core/notification/icon.cpp index 8a9475f..661cb69 100644 --- a/src/core/notification/icon.cpp +++ b/src/core/notification/icon.cpp @@ -42,10 +42,13 @@ public: if(QFile(url).exists()){ _isLocalFile = true; _localFileName = url; - } + }else if(url.startsWith(":/")){ + _img = QImage(url); + _isLocalFile = false; + } } ~SnoreIconData() - { } + {/*nothing to do*/ } QImage _img; diff --git a/src/core/notification/notification.h b/src/core/notification/notification.h index 6f7526f..c933e0e 100644 --- a/src/core/notification/notification.h +++ b/src/core/notification/notification.h @@ -26,11 +26,13 @@ namespace NotificationEnums{ namespace Prioritys{ - enum prioritys{ + enum priority{ LOW=-1, NORMAL, HIGH }; + Q_DECLARE_FLAGS(prioritys, priority) + Q_DECLARE_OPERATORS_FOR_FLAGS(prioritys) } namespace CloseReasons{ enum closeReason diff --git a/src/plugins/freedesktopfrontend/CMakeLists.txt b/src/plugins/freedesktopfrontend/CMakeLists.txt index 503d964..741d8c1 100644 --- a/src/plugins/freedesktopfrontend/CMakeLists.txt +++ b/src/plugins/freedesktopfrontend/CMakeLists.txt @@ -11,6 +11,9 @@ if(QT_QTDBUS_FOUND AND WITH_FREEDESKTOP_FRONTEND) automoc4_add_library(freedesktop_frontend MODULE ${FREEDESKTOP_NOTIFICATION_FRONTEND_SRC} ) target_link_libraries(freedesktop_frontend snorecore ${QT_QTDBUS_LIBRARY} ${QT_QTGUI_LIBRARY} ) + if(KDE4_FOUND) + target_link_libraries(freedesktop_frontend ${KDE4_KDEUI_LIBRARY}) + endif(KDE4_FOUND) install(TARGETS freedesktop_frontend ${PLUGIN_INSTALL_PATH}) endif(QT_QTDBUS_FOUND AND WITH_FREEDESKTOP_FRONTEND) diff --git a/src/plugins/freedesktopfrontend/freedesktopnotificationfrontend.cpp b/src/plugins/freedesktopfrontend/freedesktopnotificationfrontend.cpp index 4894814..192bbd4 100644 --- a/src/plugins/freedesktopfrontend/freedesktopnotificationfrontend.cpp +++ b/src/plugins/freedesktopfrontend/freedesktopnotificationfrontend.cpp @@ -1,111 +1,131 @@ -/**************************************************************************************** - * Copyright (c) 2010 Patrick von Reth * - * * - * 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 . * - ****************************************************************************************/ - -#include "freedesktopnotificationfrontend.h" -#include "notificationsadaptor.h" - -#include "plugins/freedesktopnotification/fredesktopnotification.h" -#include "core/snoreserver.h" - -#include -#include -#include - -Q_EXPORT_PLUGIN2(freedesktop_frontend,FreedesktopNotification_Frontend) - -FreedesktopNotification_Frontend::FreedesktopNotification_Frontend(SnoreServer *snore): -Notification_Frontend("FreedesktopNotification_Frontend",snore) -{ - new NotificationsAdaptor(this); - QDBusConnection dbus = QDBusConnection::sessionBus(); - dbus.registerService( "org.freedesktop.Notifications" ); - dbus.registerObject( "/org/freedesktop/Notifications", this ); -} - -FreedesktopNotification_Frontend::~FreedesktopNotification_Frontend(){ - QDBusConnection dbus = QDBusConnection::sessionBus(); - dbus.unregisterService( "org.freedesktop.Notifications" ); -} - -void FreedesktopNotification_Frontend::actionInvoked(Notification notification) { - emit ActionInvoked(notification.id(),QString::number(notification.actionInvoked()->id)); -} - -void FreedesktopNotification_Frontend::notificationClosed(Notification notification) { - - qDebug()<<"Closing Dbus notification"<()>>image; - icon = SnoreIcon(image.toQImage()); - } - if(!snore()->aplications().contains(app_name)){ - Application *a = new Application(app_name,SnoreIcon(QImage(":/root/images/freedesktop-dbus.png"))); - a->addAlert(new Alert("DBus Alert","DBus Alert",app_icon)); - snore()->addApplication(a); - snore()->applicationIsInitialized(a); - } - Notification noti(this,app_name,"DBus Alert",summary,body,icon,timeout==-1?Notification::DefaultTimeout:timeout/1000,replaces_id); - qDebug()<<"Actions"<broadcastNotification(noti); - activeNotifications[noti.id()] = noti; - return noti.id(); -} - - - -void FreedesktopNotification_Frontend::CloseNotification(uint id){ - Notification noti = activeNotifications.take(id); - snore()->closeNotification(noti,NotificationEnums::CloseReasons::TIMED_OUT); -} - -QStringList FreedesktopNotification_Frontend::GetCapabilities() -{ - return QStringList() - << "body" - // << "body-hyperlinks" - // << "body-markup" - << "icon-static" - << "actions" - ; -} - -QString FreedesktopNotification_Frontend::GetServerInformation(QString& vendor, QString& version, QString& specVersion) -{ - vendor = "Snore"; - version = snore()->version(); - specVersion = "0"; - return "Snore"; -} - - -#include "freedesktopnotificationfrontend.moc" +/**************************************************************************************** +* Copyright (c) 2010 Patrick von Reth * +* * +* 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 . * +****************************************************************************************/ + +#include "freedesktopnotificationfrontend.h" +#include "notificationsadaptor.h" + +#include "plugins/freedesktopnotification/fredesktopnotification.h" +#include "core/snoreserver.h" + +#include +#include +#include + +#ifdef HAVE_KDE +#include +#endif + +Q_EXPORT_PLUGIN2(freedesktop_frontend,FreedesktopNotification_Frontend) + + FreedesktopNotification_Frontend::FreedesktopNotification_Frontend(SnoreServer *snore): +Notification_Frontend("FreedesktopNotification_Frontend",snore) +{ + new NotificationsAdaptor(this); + QDBusConnection dbus = QDBusConnection::sessionBus(); + dbus.registerService( "org.freedesktop.Notifications" ); + dbus.registerObject( "/org/freedesktop/Notifications", this ); +} + +FreedesktopNotification_Frontend::~FreedesktopNotification_Frontend(){ + QDBusConnection dbus = QDBusConnection::sessionBus(); + dbus.unregisterService( "org.freedesktop.Notifications" ); +} + +void FreedesktopNotification_Frontend::actionInvoked(Notification notification) { + emit ActionInvoked(notification.id(),QString::number(notification.actionInvoked()->id)); +} + +void FreedesktopNotification_Frontend::notificationClosed(Notification notification) { + + qDebug()<<"Closing Dbus notification"<()>>image; + icon = SnoreIcon(image.toQImage()); + } + if(!snore()->aplications().contains(app_name)){ + SnoreIcon appIcon; +#ifdef HAVE_KDE + KIcon kicon(app_icon); + appIcon = SnoreIcon(kicon.pixmap(100,100).toImage()); +#else + appIcon = SnoreIcon(":/root/images/freedesktop-dbus.png"); +#endif + Application *a = new Application(app_name,SnoreIcon(appIcon)); + a->addAlert(new Alert("DBus Alert","DBus Alert",SnoreIcon(":/root/images/freedesktop-dbus.png"))); + snore()->addApplication(a); + snore()->applicationIsInitialized(a); + } + + if (hints.contains("urgency")) { + priotity = NotificationEnums::Prioritys::prioritys(hints["urgency"].toInt()-1); + } + + + + Notification noti(this,app_name,"DBus Alert",summary,body,icon,timeout==-1?Notification::DefaultTimeout:timeout/1000,replaces_id,priotity); + qDebug()<<"Actions"<broadcastNotification(noti); + activeNotifications[noti.id()] = noti; + return noti.id(); +} + + + +void FreedesktopNotification_Frontend::CloseNotification(uint id){ + Notification noti = activeNotifications.take(id); + snore()->closeNotification(noti,NotificationEnums::CloseReasons::TIMED_OUT); +} + +QStringList FreedesktopNotification_Frontend::GetCapabilities() +{ + return QStringList() + << "body" + // << "body-hyperlinks" + // << "body-markup" + << "icon-static" + << "actions" + ; +} + +QString FreedesktopNotification_Frontend::GetServerInformation(QString& vendor, QString& version, QString& specVersion) +{ + vendor = "Snore"; + version = snore()->version(); + specVersion = "0"; + return "Snore"; +} + + +#include "freedesktopnotificationfrontend.moc" diff --git a/src/plugins/snarl/SnarlInterface.cpp b/src/plugins/snarl/SnarlInterface.cpp index bf975c7..e7653cb 100644 --- a/src/plugins/snarl/SnarlInterface.cpp +++ b/src/plugins/snarl/SnarlInterface.cpp @@ -55,8 +55,8 @@ namespace V42 { // workaround for mingw-w64 bug #ifdef __MINGW64_VERSION_MAJOR extern "C" { - __declspec(dllimport) errno_t __cdecl strcpy_s(char * _Dst, size_t _SizeInBytes, const char *_Src); - __declspec(dllimport) errno_t __cdecl wcscpy_s(wchar_t * _Dst, size_t _SizeInBytes, const wchar_t *_Src); + __declspec(dllimport) errno_t __cdecl strcpy_s(char * _Dst, size_t _SizeInBytes, const char *_Src); + __declspec(dllimport) errno_t __cdecl wcscpy_s(wchar_t * _Dst, size_t _SizeInBytes, const wchar_t *_Src); __declspec(dllimport) errno_t __cdecl strncat_s(char *_Dst, size_t _DstSizeInChars, const char *_Src, size_t _MaxCount); } #endif //__MINGW64_VERSION_MAJOR diff --git a/src/plugins/snarl/SnarlInterface.h b/src/plugins/snarl/SnarlInterface.h index 9f1fcc2..436cb94 100644 --- a/src/plugins/snarl/SnarlInterface.h +++ b/src/plugins/snarl/SnarlInterface.h @@ -3,7 +3,7 @@ #ifdef __MINGW32__ #define MINGW_HAS_SECURE_API -#endif +#endif #include #include @@ -16,7 +16,6 @@ #define SMTO_NOTIMEOUTIFNOTHUNG 8 #endif - namespace Snarl { namespace V42 { diff --git a/src/plugins/snarl/snarl_backend.cpp b/src/plugins/snarl/snarl_backend.cpp index 2a5d7da..60d953c 100644 --- a/src/plugins/snarl/snarl_backend.cpp +++ b/src/plugins/snarl/snarl_backend.cpp @@ -73,7 +73,7 @@ void Snarl_Backend::registerApplication(Application *application){ foreach(Alert *alert,application->alerts()){ snarlInterface->AddClass(application->name().toUtf8().constData(), alert->name().toUtf8().constData(), - 0,0,alert->icon().toUtf8().constData()); + 0,0,alert->icon().localUrl().toUtf8().constData()); } }