From e0a6355aa4d3ac3fae11d111e3d9c72c11e9d515 Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Fri, 16 Jul 2010 01:09:43 +0200 Subject: [PATCH] fixed snarl support, added unicode support to snarl, refactored notification class --- CMakeLists.txt | 14 ++- src/CMakeLists.txt | 14 +-- src/core/CMakeLists.txt | 20 +++- src/core/notification.cpp | 98 ++++++++++++---- src/core/notification.h | 52 +++++---- src/core/snoreserver.cpp | 20 ++-- src/core/utils.cpp | 20 ++++ src/core/utils.h | 13 +++ src/plugins/dbusbinding/CMakeLists.txt | 2 +- .../freedesktopfrontend/CMakeLists.txt | 2 +- .../freedesktopnotificationfrontend.cpp | 8 +- .../freedesktopnotification/CMakeLists.txt | 2 +- .../fredesktopnotification.cpp | 6 +- src/plugins/growl/CMakeLists.txt | 2 +- src/plugins/redirector/CMakeLists.txt | 4 +- src/plugins/redirector/redirector.cpp | 10 +- src/plugins/redirector/redirector.h | 1 + src/plugins/registredapps/CMakeLists.txt | 2 +- src/plugins/snarl/CMakeLists.txt | 2 +- src/plugins/snarl/SnarlInterface.cpp | 91 +++++++-------- src/plugins/snarl/SnarlInterface.h | 110 +++++++++--------- src/plugins/snarl/snarl_backend.cpp | 44 +++++-- src/plugins/snarlnetwork/CMakeLists.txt | 2 +- src/plugins/snarlnetwork/parser.cpp | 58 +++++---- src/plugins/snarlnetwork/snarlnetwork.cpp | 21 ++-- src/plugins/webposter/CMakeLists.txt | 2 +- src/plugins/webposter/webposter.cpp | 5 +- src/webinterface/CMakeLists.txt | 2 +- 28 files changed, 390 insertions(+), 237 deletions(-) create mode 100644 src/core/utils.cpp create mode 100644 src/core/utils.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e86e4b..e159ff1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,18 +1,21 @@ project( SnoreNotify ) cmake_minimum_required( VERSION 2.8 ) -add_definitions ( -Wall ) +add_definitions( -Wall ) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules ${CMAKE_PREFIX_PATH}/share/apps/cmake/modules) set(CMAKE_INCLUDE_CURRENT_DIR ON) -find_package ( Qt4 REQUIRED ) +find_package( Qt4 REQUIRED ) find_package( Automoc4 REQUIRED) -include ( ${QT_USE_FILE} ) -include_directories ( +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_QTNETWORK_INCLUDE_DIR} ${QT_QTDBUS_INCLUDE_DIR} ) + +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR} ) +set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH}) if (CMAKE_COMPILER_IS_GNUCXX) set (KDE4_ENABLE_EXCEPTIONS -fexceptions) @@ -37,5 +40,6 @@ if (CMAKE_COMPILER_IS_GNUCXX) endif(CMAKE_COMPILER_IS_GNUCXX) + option(WITH_WEBINTERFACE "Buld with WebInterface" OFF) add_subdirectory(src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d81ab6f..a211681 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,15 +1,13 @@ -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} - ) +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} ) add_subdirectory(core) add_executable ( SnoreNotify main.cpp ) -target_link_libraries ( SnoreNotify snore ${QT_QTGUI_LIBRARY}) -add_dependencies(SnoreNotify snore) +target_link_libraries ( SnoreNotify snorecore ${QT_QTGUI_LIBRARY}) +add_dependencies(SnoreNotify snorecore) add_subdirectory(webinterface) add_subdirectory(plugins) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 15e78a6..33f51ac 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -3,10 +3,22 @@ set ( SnoreNotify_SRCS snoreserver.cpp application.cpp interface.cpp - ) + utils.cpp + ) -automoc4_add_library( snore SHARED ${SnoreNotify_SRCS}) -set_target_properties( snore PROPERTIES COMPILE_FLAGS "-DSNORECORE_DLL" ) -target_link_libraries ( snore ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ) +set ( SnoreNotify_HDR + notification.h + snoreserver.h + application.h + interface.h + snore_exports.h + utils.h + ) + +automoc4_add_library( snorecore SHARED ${SnoreNotify_SRCS}) +set_target_properties( snorecore PROPERTIES COMPILE_FLAGS "-DSNORECORE_DLL" ) +target_link_libraries ( snorecore ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ) + +install(FILES ${SnoreNotify_HDR} DESTINATION include/snore) diff --git a/src/core/notification.cpp b/src/core/notification.cpp index ef9f10f..e3f49cb 100644 --- a/src/core/notification.cpp +++ b/src/core/notification.cpp @@ -23,42 +23,92 @@ int Notification::DefaultTimeout=10; -Notification::Notification(uint id):source("none"),timeout(10),id(id),notification(true){} -Notification::Notification(QString source,QString title,QString text,QString icon,int timeout,uint id):source(source),title(title),text(text),timeout(timeout),id(id),icon(icon),notification(true) -{ -} +QString Notification::toPlainText(const QString &string){ + if(!Qt::mightBeRichText(string)) + return string; + QTextEdit te; + te.setHtml(string); + return te.toPlainText(); + }; -QString Notification::getIcon(){ - return icon; +Notification::Notification(uint id): + _id(id), + _timeout(10), + _source(NULL), + _notification(true) +{} + +Notification::Notification(Notification_Frontend *source,QString title,QString text,QString icon,int timeout,uint id): + _id(id), + _timeout(timeout), + _source(source), + _title(title), + _text(text), + _icon(icon), + _notification(true) +{} + +QString Notification::toString() const{ + return QString("Title: "+_title+"\nText: "+_text); } bool Notification::isNotification(){ - return notification; + return _notification; } void Notification::setIsNotification(bool b){ - notification=b; + _notification=b; } -uint Notification::getID(){ - return id; +const uint &Notification::id() const{ + return _id; } -QString Notification::toSnalrString()const{ - QString out("type=SNP#?version=1.1"); - if(hints.contains("SNaction")) - out+=QString("#?action="+hints.value("SNaction").value()); - if(!app.isEmpty()) - out+=QString("#?app="+app); - if(!alert.isEmpty()) - out+=QString("#?class="+alert); - if(hints.contains("SnarlIcon")) - out+=QString("#?icon="+hints.value("SnarlIcon").value()); - out+=QString("#?title="+title+"#?text="+text+"#?timeout="+QString::number(timeout)); - return out; +const QString &Notification::Notification::icon() const{ + return _icon; } -QDataStream & operator<< ( QDataStream & stream, const Notification & noti){ - stream<icon=icon; } - QString getIcon(); - QVariantHash hints; - uint getID(); + const uint &id() const; + const int &timeout() const; + const Notification::actions &actionInvoked() const; + const class Notification_Frontend *source() const; + const QString &application() const; + const QString &title() const; + const QString &text() const; + const QString &icon() const; + const QString &alert() const; + const QVariant hint(const QString &key) const; + bool hintExists(const QString &key); + void insertHint(const QString &key,const QVariant &val); + private: - uint id; - QString icon; - bool notification; + uint _id; + int _timeout; + actions _actionInvoked; + class Notification_Frontend *_source; + QString _app; + QString _title; + QString _text; + QString _icon; + QString _alert; + QVariantHash _hints; + + bool _notification; diff --git a/src/core/snoreserver.cpp b/src/core/snoreserver.cpp index 3d52eb5..fe6e646 100644 --- a/src/core/snoreserver.cpp +++ b/src/core/snoreserver.cpp @@ -24,7 +24,8 @@ QString const SnoreServer::snoreTMP=QDir::temp().path()+"/SnoreNotify/"; SnoreServer::SnoreServer():primaryNotificationBackend(0) -{ qDebug()<<"Inititalized"; +{ + qDebug()<<"Inititalized"; QDir home(snoreTMP); if(home.exists()){ QStringList filetypes; @@ -63,9 +64,10 @@ void SnoreServer::publicatePlugin(QObject *plugin){ if(primaryNotificationBackend){ notyfier.append(primaryNotificationBackend); connect(this,SIGNAL(notify(QSharedPointer)),primaryNotificationBackend,SLOT(notify(QSharedPointer))); - } primaryNotificationBackend=nb; + primaryNotificationBackend->notify(QSharedPointer(new Notification(NULL,"Welcome","Snore Notify succesfully registred "+plugin->property("name").value(),""))); + }else{ notyfier.append(nb); connect(this,SIGNAL(notify(QSharedPointer)),nb,SLOT(notify(QSharedPointer))); @@ -77,25 +79,25 @@ void SnoreServer::publicatePlugin(QObject *plugin){ int SnoreServer::broadcastNotification(QSharedPointer notification){ emit notify(notification); - qDebug()<<"Broadcasting notification:"<toSnalrString(); + qDebug()<<"Broadcasting notification:"<toString(); if(primaryNotificationBackend!=NULL){ - notification->id=primaryNotificationBackend->notify(notification); - std::cout<<"Notification ID: "<id).toLatin1().data()<id; + notification->_id=primaryNotificationBackend->notify(notification); + std::cout<<"Notification ID: "<_id).toLatin1().data()<_id; } return -1; } void SnoreServer::closeNotification(QSharedPointer notification){ - emit closeNotify(notification->id); - Notification_Frontend *nf= qobject_cast(plugins.value(notification->source)); + emit closeNotify(notification->_id); + Notification_Frontend *nf= notification->_source; if(nf!=0){ nf->notificationClosed(notification); } } void SnoreServer::notificationActionInvoked(QSharedPointer notification){ - Notification_Frontend *nf= qobject_cast(plugins.value(notification->source)); + Notification_Frontend *nf= notification->_source; if(nf!=0){ nf->actionInvoked(notification); } diff --git a/src/core/utils.cpp b/src/core/utils.cpp new file mode 100644 index 0000000..527b2ad --- /dev/null +++ b/src/core/utils.cpp @@ -0,0 +1,20 @@ +#include "utils.h" + +Utils::Utils() +{ +} + + +QString Utils::notificationToSNTPString(QSharedPointer notification){ + QString out("type=SNP#?version=1.1"); + if(notification->hintExists("SNaction")) + out+=QString("#?action="+notification->hint("SNaction").value()); + if(!notification->application().isEmpty()) + out+=QString("#?app="+notification->application()); + if(!notification->alert().isEmpty()) + out+=QString("#?class="+notification->alert()); + if(notification->hintExists("SnarlIcon")) + out+=QString("#?icon="+notification->hint("SnarlIcon").value()); + out+=QString("#?title="+notification->title()+"#?text="+notification->text()+"#?timeout="+QString::number(notification->timeout())); + return out; +} diff --git a/src/core/utils.h b/src/core/utils.h new file mode 100644 index 0000000..d597510 --- /dev/null +++ b/src/core/utils.h @@ -0,0 +1,13 @@ +#ifndef UTILS_H +#define UTILS_H + +#include "snoreserver.h" + +class SNORE_EXPORT Utils +{ +public: + Utils(); + static QString notificationToSNTPString(QSharedPointer notification); +}; + +#endif // UTILS_H diff --git a/src/plugins/dbusbinding/CMakeLists.txt b/src/plugins/dbusbinding/CMakeLists.txt index 870d643..4cb9e8a 100644 --- a/src/plugins/dbusbinding/CMakeLists.txt +++ b/src/plugins/dbusbinding/CMakeLists.txt @@ -5,5 +5,5 @@ if(QT_QTDBUS_FOUND) dbusbinding.cpp ) automoc4_add_library(dbusbinding MODULE ${DBUSBINDING_SRC} ) - target_link_libraries(dbusbinding ${QT_QTDBUS_LIBRARY} snore ) + target_link_libraries(dbusbinding ${QT_QTDBUS_LIBRARY} snorecore ) endif(QT_QTDBUS_FOUND) diff --git a/src/plugins/freedesktopfrontend/CMakeLists.txt b/src/plugins/freedesktopfrontend/CMakeLists.txt index 0f56e13..58e6b2f 100644 --- a/src/plugins/freedesktopfrontend/CMakeLists.txt +++ b/src/plugins/freedesktopfrontend/CMakeLists.txt @@ -9,7 +9,7 @@ if(QT_QTDBUS_FOUND) qt4_add_dbus_adaptor( FREEDESKTOP_NOTIFICATION_FRONTEND_SRC org.freedesktop.Notifications.xml freedesktopnotificationfrontend.h FreedesktopNotification_Frontend) automoc4_add_library(freedesktop_frontend MODULE ${FREEDESKTOP_NOTIFICATION_FRONTEND_SRC} ) - target_link_libraries(freedesktop_frontend snore ${QT_QTDBUS_LIBRARY} ${QT_QTGUI_LIBRARY} ) + target_link_libraries(freedesktop_frontend snorecore ${QT_QTDBUS_LIBRARY} ${QT_QTGUI_LIBRARY} ) endif(QT_QTDBUS_FOUND) diff --git a/src/plugins/freedesktopfrontend/freedesktopnotificationfrontend.cpp b/src/plugins/freedesktopfrontend/freedesktopnotificationfrontend.cpp index 867bd1f..01ac3b6 100644 --- a/src/plugins/freedesktopfrontend/freedesktopnotificationfrontend.cpp +++ b/src/plugins/freedesktopfrontend/freedesktopnotificationfrontend.cpp @@ -38,12 +38,12 @@ FreedesktopNotification_Frontend::~FreedesktopNotification_Frontend(){ } void FreedesktopNotification_Frontend::actionInvoked(QSharedPointernotification){ - emit ActionInvoked(notification->getID(),QString::number(notification->actionInvoked)); + emit ActionInvoked(notification->id(),QString::number(notification->actionInvoked())); } void FreedesktopNotification_Frontend::notificationClosed(QSharedPointernotification){ uint reason; - switch(notification->actionInvoked){ + switch(notification->actionInvoked()){ case Notification::TIMED_OUT: reason=1; break; @@ -56,7 +56,7 @@ void FreedesktopNotification_Frontend::notificationClosed(QSharedPointergetID(),reason); + emit NotificationClosed(notification->id(),reason); } QString FreedesktopNotification_Frontend::getImagefromHint(const FreedesktopImageHint &img){ @@ -85,7 +85,7 @@ uint FreedesktopNotification_Frontend::Notify(const QString &app_name, uint repl icon=getImagefromHint(image); } - QSharedPointer noti(new Notification(property("name").value(),summary,body,icon,timeout==-1?Notification::DefaultTimeout:timeout/1000,replaces_id)); + QSharedPointer noti(new Notification(this,summary,body,icon,timeout==-1?Notification::DefaultTimeout:timeout/1000,replaces_id)); return getSnore()->broadcastNotification(noti); } diff --git a/src/plugins/freedesktopnotification/CMakeLists.txt b/src/plugins/freedesktopnotification/CMakeLists.txt index 785b058..243a1b8 100644 --- a/src/plugins/freedesktopnotification/CMakeLists.txt +++ b/src/plugins/freedesktopnotification/CMakeLists.txt @@ -5,7 +5,7 @@ if(QT_QTDBUS_FOUND AND UNIX AND NOT APPLE) fredesktopnotification.cpp ) automoc4_add_library(freedesktop_backend MODULE ${FREEDESKTOP_NOTIFICATION_SRC} ) - target_link_libraries(freedesktop_backend snore ${QT_QTGUI_LIBRARY} ${QT_QTDBUS_LIBRARY} ) + target_link_libraries(freedesktop_backend snorecore ${QT_QTGUI_LIBRARY} ${QT_QTDBUS_LIBRARY} ) else(QT_QTDBUS_FOUND AND UNIX AND NOT APPLE) message(STATUS "Adding Freedesktop notification backend.... ") endif(QT_QTDBUS_FOUND AND UNIX AND NOT APPLE) diff --git a/src/plugins/freedesktopnotification/fredesktopnotification.cpp b/src/plugins/freedesktopnotification/fredesktopnotification.cpp index fcd1a49..0bf3661 100644 --- a/src/plugins/freedesktopnotification/fredesktopnotification.cpp +++ b/src/plugins/freedesktopnotification/fredesktopnotification.cpp @@ -33,9 +33,9 @@ void FreedesktopNotification::registerTypes(){ QDBusArgument &operator<<(QDBusArgument &a, const FreedesktopNotification &i){ QStringList actions; actions<<"1"<<" "<<"2"<<" "; - a<app<getIcon()<title<text<application()<icon()<title()<text()<getIcon()); + QImage img(i.notification->icon()); if(!img.isNull()){ img=img.scaledToWidth(50,Qt::FastTransformation); a.beginMapEntry(); @@ -44,7 +44,7 @@ QDBusArgument &operator<<(QDBusArgument &a, const FreedesktopNotification &i){ a.endMapEntry(); } a.endMap(); - a<timeout*1000; + a<timeout()*1000; return a; } diff --git a/src/plugins/growl/CMakeLists.txt b/src/plugins/growl/CMakeLists.txt index 2468d58..51f651c 100644 --- a/src/plugins/growl/CMakeLists.txt +++ b/src/plugins/growl/CMakeLists.txt @@ -6,7 +6,7 @@ if( GROWL_CPP ) growl_backend.cpp ) automoc4_add_library(growl_backend MODULE ${GROWL__SRC} ) - target_link_libraries(growl_backend snore ${QT_QTCORE_LIBRARY} ${GROWL_CPP} ) + target_link_libraries(growl_backend snorecore ${QT_QTCORE_LIBRARY} ${GROWL_CPP} ) else( GROWL_CPP ) message( STATUS "libgrowl not found..., get it here http://github.com/mattn/gntp-send" ) endif( GROWL_CPP ) diff --git a/src/plugins/redirector/CMakeLists.txt b/src/plugins/redirector/CMakeLists.txt index d9c265d..2740ee8 100644 --- a/src/plugins/redirector/CMakeLists.txt +++ b/src/plugins/redirector/CMakeLists.txt @@ -3,5 +3,5 @@ if(WITH_WEBINTERFACE) redirector.cpp ) automoc4_add_library(redirector MODULE ${REDIRECTOR_SRC}) - target_link_libraries(redirector snore webinterface) -endif(WITH_WEBINTERFACE) \ No newline at end of file + target_link_libraries(redirector snorecore webinterface) +endif(WITH_WEBINTERFACE) diff --git a/src/plugins/redirector/redirector.cpp b/src/plugins/redirector/redirector.cpp index ec62817..d9e3bfd 100644 --- a/src/plugins/redirector/redirector.cpp +++ b/src/plugins/redirector/redirector.cpp @@ -15,10 +15,13 @@ ****************************************************************************************/ #include "redirector.h" -#include -#include + #include "core/snoreserver.h" #include "core/notification.h" +#include "core/utils.h" + +#include +#include #include #include @@ -91,7 +94,7 @@ int Redircetor::notify(QSharedPointernotification){ foreach(QSharedPointer s,subscribers.values()){ if(s->isWritable()){ qDebug()<<"Sending to subscriber"<peerAddress(); - s->write((notification->toSnalrString()+"\r\n").toLatin1()); + s->write((Utils::notificationToSNTPString(notification)+"\r\n").toLatin1()); } } return -1; @@ -111,4 +114,5 @@ void Redircetor::setSnore(SnoreServer *snore){ this->WebInterface_Plugin::setSnore(snore); } + #include "redirector.moc" diff --git a/src/plugins/redirector/redirector.h b/src/plugins/redirector/redirector.h index 6439f94..a06fda8 100644 --- a/src/plugins/redirector/redirector.h +++ b/src/plugins/redirector/redirector.h @@ -33,6 +33,7 @@ public: class SnoreServer* getSnore(); void setSnore(class SnoreServer *snore); + public slots: int notify(QSharedPointernotification); void closeNotification(int nr); diff --git a/src/plugins/registredapps/CMakeLists.txt b/src/plugins/registredapps/CMakeLists.txt index 16a956b..be54705 100644 --- a/src/plugins/registredapps/CMakeLists.txt +++ b/src/plugins/registredapps/CMakeLists.txt @@ -4,5 +4,5 @@ if(WITH_WEBINTERFACE) ) automoc4_add_library(registredapps MODULE ${REGISTREDAPPS_SRC} ) - target_link_libraries(registredapps snore webinterface) + target_link_libraries(registredapps snorecore webinterface) endif(WITH_WEBINTERFACE) diff --git a/src/plugins/snarl/CMakeLists.txt b/src/plugins/snarl/CMakeLists.txt index 850e62e..ef596a9 100644 --- a/src/plugins/snarl/CMakeLists.txt +++ b/src/plugins/snarl/CMakeLists.txt @@ -5,5 +5,5 @@ if(WIN32) snarl_backend.cpp ) automoc4_add_library(snarln_backend MODULE ${SNARL__SRC} ) - target_link_libraries(snarln_backend snore ${QT_QTCORE_LIBRARY} ) + target_link_libraries(snarln_backend snorecore ${QT_QTCORE_LIBRARY} ) endif(WIN32) diff --git a/src/plugins/snarl/SnarlInterface.cpp b/src/plugins/snarl/SnarlInterface.cpp index 2dde592..f287b8e 100644 --- a/src/plugins/snarl/SnarlInterface.cpp +++ b/src/plugins/snarl/SnarlInterface.cpp @@ -54,7 +54,6 @@ #include "SnarlInterface.h" -#include using namespace Snarl; @@ -63,7 +62,7 @@ using namespace Snarl; // Constructor/Destructor //----------------------------------------------------------------------------- SnarlInterface::SnarlInterface() -:m_nLastMessageId(0),m_hwndFrom(NULL) +: m_hwndFrom(NULL), m_nLastMessageId(0) { } @@ -83,7 +82,7 @@ SnarlInterface::~SnarlInterface() /// which will be displayed alongside the message text. /// Message Id on success or M_RESULT on failure -intptr_t SnarlInterface::ShowMessage(LPCSTR szTitle, LPCSTR szText, intptr_t timeout, LPCSTR szIconPath, HWND hWndReply, WPARAM uReplyMsg) +LONG32 SnarlInterface::ShowMessage(LPCSTR szTitle, LPCSTR szText, LONG32 timeout, LPCSTR szIconPath, HWND hWndReply, WPARAM uReplyMsg) { SNARLSTRUCT ss; ZeroMemory((void*)&ss, sizeof(ss)); @@ -94,20 +93,20 @@ intptr_t SnarlInterface::ShowMessage(LPCSTR szTitle, LPCSTR szText, intptr_t tim StringCbCopyA((LPSTR)&ss.Icon, SNARL_STRING_LENGTH, szIconPath); ss.Timeout = timeout; - ss.LngData2 = reinterpret_cast(hWndReply); - ss.Id = static_cast(uReplyMsg); + ss.LngData2 = reinterpret_cast(hWndReply); + ss.Id = static_cast(uReplyMsg); m_nLastMessageId = Send(ss); return m_nLastMessageId; } -intptr_t SnarlInterface::ShowMessage(LPCWSTR szTitle, LPCWSTR szText, intptr_t timeout, LPCWSTR szIconPath, HWND hWndReply, WPARAM uReplyMsg) +LONG32 SnarlInterface::ShowMessage(LPCWSTR szTitle, LPCWSTR szText, LONG32 timeout, LPCWSTR szIconPath, HWND hWndReply, WPARAM uReplyMsg) { LPSTR szUTF8Title = WideToUTF8(szTitle); LPSTR szUTF8Text = WideToUTF8(szText); LPSTR szUFT8IconPath = WideToUTF8(szIconPath); - intptr_t result = ShowMessage(szUTF8Title, szUTF8Text, timeout, szUFT8IconPath, hWndReply, uReplyMsg); + LONG32 result = ShowMessage(szUTF8Title, szUTF8Text, timeout, szUFT8IconPath, hWndReply, uReplyMsg); delete [] szUTF8Title; delete [] szUTF8Text; @@ -126,15 +125,15 @@ intptr_t SnarlInterface::ShowMessage(LPCWSTR szTitle, LPCWSTR szText, intptr_t t /// Message Id on success or M_RESULT on failure -intptr_t SnarlInterface::ShowMessageEx(LPCSTR szClass, LPCSTR szTitle, LPCSTR szText, intptr_t timeout, LPCSTR szIconPath, HWND hWndReply, WPARAM uReplyMsg, LPCSTR szSoundFile) +LONG32 SnarlInterface::ShowMessageEx(LPCSTR szClass, LPCSTR szTitle, LPCSTR szText, LONG32 timeout, LPCSTR szIconPath, HWND hWndReply, WPARAM uReplyMsg, LPCSTR szSoundFile) { SNARLSTRUCTEX ssex; ZeroMemory((void*)&ssex, sizeof(ssex)); ssex.Cmd = SNARL_EX_SHOW; ssex.Timeout = timeout; - ssex.LngData2 = reinterpret_cast(hWndReply); - ssex.Id = static_cast(uReplyMsg); + ssex.LngData2 = reinterpret_cast(hWndReply); + ssex.Id = static_cast(uReplyMsg); StringCbCopyA((LPSTR)&ssex.Class, SNARL_STRING_LENGTH, szClass); StringCbCopyA((LPSTR)&ssex.Title, SNARL_STRING_LENGTH, szTitle); @@ -146,7 +145,7 @@ intptr_t SnarlInterface::ShowMessageEx(LPCSTR szClass, LPCSTR szTitle, LPCSTR sz return m_nLastMessageId; } -intptr_t SnarlInterface::ShowMessageEx(LPCWSTR szClass, LPCWSTR szTitle, LPCWSTR szText, intptr_t timeout, LPCWSTR szIconPath, HWND hWndReply, WPARAM uReplyMsg, LPCWSTR szSoundFile) +LONG32 SnarlInterface::ShowMessageEx(LPCWSTR szClass, LPCWSTR szTitle, LPCWSTR szText, LONG32 timeout, LPCWSTR szIconPath, HWND hWndReply, WPARAM uReplyMsg, LPCWSTR szSoundFile) { LPSTR szUTF8Class = WideToUTF8(szClass); LPSTR szUTF8Title = WideToUTF8(szTitle); @@ -154,7 +153,7 @@ intptr_t SnarlInterface::ShowMessageEx(LPCWSTR szClass, LPCWSTR szTitle, LPCWSTR LPSTR szUFT8IconPath = WideToUTF8(szIconPath); LPSTR szUFT8SoundFile = WideToUTF8(szSoundFile); - intptr_t result = ShowMessageEx(szUTF8Class, szUTF8Title, szUTF8Text, timeout, szUFT8IconPath, hWndReply, uReplyMsg, szUFT8SoundFile); + LONG32 result = ShowMessageEx(szUTF8Class, szUTF8Title, szUTF8Text, timeout, szUFT8IconPath, hWndReply, uReplyMsg, szUFT8SoundFile); delete [] szUTF8Class; delete [] szUTF8Title; @@ -173,13 +172,13 @@ intptr_t SnarlInterface::ShowMessageEx(LPCWSTR szClass, LPCWSTR szTitle, LPCWSTR /// created. This function returns True if the notification was successfully /// hidden or False otherwise (for example, the notification may no longer exist). -BOOL SnarlInterface::HideMessage(intptr_t Id) +BOOL SnarlInterface::HideMessage(LONG32 Id) { SNARLSTRUCT ss; ss.Cmd = SNARL_HIDE; ss.Id = Id; - intptr_t n = Send(ss); + LONG32 n = Send(ss); return (n == -1 || n == 1) ? TRUE : FALSE; } @@ -195,14 +194,14 @@ BOOL SnarlInterface::HideMessage() /// False if not. Id is the value returned by snShowMessage() or /// snShowMessageEx() when the notification was initially created. -BOOL SnarlInterface::IsMessageVisible(intptr_t Id) +BOOL SnarlInterface::IsMessageVisible(LONG32 Id) { SNARLSTRUCT ss; ss.Cmd = SNARL_IS_VISIBLE; ss.Id = Id; // We are getting -1 when true, checking for 1 just in case. We don't want to return true for the other M_RESULT returns - intptr_t n = Send(ss); + LONG32 n = Send(ss); return (n == -1 || n == 1) ? TRUE : FALSE; } @@ -222,7 +221,7 @@ BOOL SnarlInterface::IsMessageVisible() /// snShowMessage() or snShowMessageEx() when the notification was originally /// created. To change the timeout parameter of a notification, use snSetTimeout() -M_RESULT SnarlInterface::UpdateMessage(intptr_t id, LPCSTR szTitle, LPCSTR szText, LPCSTR szIconPath) +M_RESULT SnarlInterface::UpdateMessage(LONG32 id, LPCSTR szTitle, LPCSTR szText, LPCSTR szIconPath) { SNARLSTRUCT ss; ZeroMemory((void*)&ss, sizeof(ss)); @@ -237,7 +236,7 @@ M_RESULT SnarlInterface::UpdateMessage(intptr_t id, LPCSTR szTitle, LPCSTR szTex return static_cast(Send(ss)); } -M_RESULT SnarlInterface::UpdateMessage(intptr_t id, LPCWSTR szTitle, LPCWSTR szText, LPCWSTR szIconPath) +M_RESULT SnarlInterface::UpdateMessage(LONG32 id, LPCWSTR szTitle, LPCWSTR szText, LPCWSTR szIconPath) { LPSTR szParam1 = WideToUTF8(szTitle); LPSTR szParam2 = WideToUTF8(szText); @@ -269,12 +268,12 @@ M_RESULT SnarlInterface::UpdateMessage(LPCWSTR szTitle, LPCWSTR szText, LPCWSTR /// AppName is the text that's displayed in the Applications list so it should /// be people friendly ("My cool app" rather than "my_cool_app"). -M_RESULT SnarlInterface::RegisterConfig(HWND hWnd, LPCSTR szAppName, intptr_t replyMsg) +M_RESULT SnarlInterface::RegisterConfig(HWND hWnd, LPCSTR szAppName, LONG32 replyMsg) { return RegisterConfig2(hWnd, szAppName, replyMsg, ""); } -M_RESULT SnarlInterface::RegisterConfig(HWND hWnd, LPCWSTR szAppName, intptr_t replyMsg) +M_RESULT SnarlInterface::RegisterConfig(HWND hWnd, LPCWSTR szAppName, LONG32 replyMsg) { return RegisterConfig2(hWnd, szAppName, replyMsg, L""); } @@ -287,7 +286,7 @@ M_RESULT SnarlInterface::RegisterConfig(HWND hWnd, LPCWSTR szAppName, intptr_t r /// used to specify a PNG image which will be displayed against the /// application's entry in Snarl's Preferences panel. -M_RESULT SnarlInterface::RegisterConfig2(HWND hWnd, LPCSTR szAppName, intptr_t replyMsg, LPCSTR szIcon) +M_RESULT SnarlInterface::RegisterConfig2(HWND hWnd, LPCSTR szAppName, LONG32 replyMsg, LPCSTR szIcon) { if (!szAppName || !szIcon) return M_BAD_POINTER; @@ -297,7 +296,7 @@ M_RESULT SnarlInterface::RegisterConfig2(HWND hWnd, LPCSTR szAppName, intptr_t r m_hwndFrom = hWnd; ss.Cmd = SNARL_REGISTER_CONFIG_WINDOW_2; - ss.LngData2 = reinterpret_cast(hWnd); + ss.LngData2 = reinterpret_cast(hWnd); ss.Id = replyMsg; StringCbCopyA((LPSTR)&ss.Title, SNARL_STRING_LENGTH, szAppName); StringCbCopyA((LPSTR)&ss.Icon, SNARL_STRING_LENGTH, szIcon); @@ -305,7 +304,7 @@ M_RESULT SnarlInterface::RegisterConfig2(HWND hWnd, LPCSTR szAppName, intptr_t r return static_cast(Send(ss)); } -M_RESULT SnarlInterface::RegisterConfig2(HWND hWnd, LPCWSTR szAppName, intptr_t replyMsg, LPCWSTR szIcon) +M_RESULT SnarlInterface::RegisterConfig2(HWND hWnd, LPCWSTR szAppName, LONG32 replyMsg, LPCWSTR szIcon) { LPSTR szParam1 = WideToUTF8(szAppName); LPSTR szParam2 = WideToUTF8(szIcon); @@ -332,7 +331,7 @@ M_RESULT SnarlInterface::RevokeConfig(HWND hWnd) m_hwndFrom = NULL; ss.Cmd = SNARL_REVOKE_CONFIG_WINDOW; - ss.LngData2 = reinterpret_cast(hWnd); + ss.LngData2 = reinterpret_cast(hWnd); return static_cast(Send(ss)); } @@ -349,7 +348,7 @@ BOOL SnarlInterface::GetVersion(WORD* Major, WORD* Minor) { SNARLSTRUCT ss; ss.Cmd = SNARL_GET_VERSION; - intptr_t versionInfo = Send(ss); + LONG32 versionInfo = Send(ss); if (versionInfo > 0 && versionInfo != M_FAILED && versionInfo != M_TIMED_OUT) { *Major = HIWORD(versionInfo); *Minor = LOWORD(versionInfo); @@ -366,7 +365,7 @@ BOOL SnarlInterface::GetVersion(WORD* Major, WORD* Minor) /// represents the system build number and can be used to identify the specific /// version of Snarl running -intptr_t SnarlInterface::GetVersionEx() +LONG32 SnarlInterface::GetVersionEx() { SNARLSTRUCT ss; ss.Cmd = SNARL_GET_VERSION_EX; @@ -381,7 +380,7 @@ intptr_t SnarlInterface::GetVersionEx() /// value returned by snShowMessage() or snShowMessageEx() when the notification /// was first created. -M_RESULT SnarlInterface::SetTimeout(intptr_t Id, intptr_t Timeout) +M_RESULT SnarlInterface::SetTimeout(LONG32 Id, LONG32 Timeout) { SNARLSTRUCT ss; ss.Cmd = SNARL_SET_TIMEOUT; @@ -391,7 +390,7 @@ M_RESULT SnarlInterface::SetTimeout(intptr_t Id, intptr_t Timeout) return static_cast(Send(ss)); } -M_RESULT SnarlInterface::SetTimeout(intptr_t Timeout) +M_RESULT SnarlInterface::SetTimeout(LONG32 Timeout) { return SetTimeout(m_nLastMessageId, Timeout); } @@ -432,7 +431,7 @@ M_RESULT SnarlInterface::RegisterAlert(LPCWSTR szAppName, LPCWSTR szClass) /// Windows message. This message is sent by Snarl when it is first starts and /// when it shuts down. -intptr_t SnarlInterface::GetGlobalMsg() +LONG32 SnarlInterface::GetGlobalMsg() { return RegisterWindowMessage(SNARL_GLOBAL_MSG); } @@ -522,7 +521,7 @@ void SnarlInterface::SetAsSnarlApp(HWND hWndOwner, SNARL_APP_FLAGS Flags) /// Returns the global Snarl Application message (V39) -intptr_t SnarlInterface::GetAppMsg() +LONG32 SnarlInterface::GetAppMsg() { return RegisterWindowMessage(SNARL_APP_MSG); } @@ -533,7 +532,7 @@ intptr_t SnarlInterface::GetAppMsg() /// Registers an application with Snarl (V39) -M_RESULT SnarlInterface::RegisterApp(LPCSTR Application, LPCSTR SmallIcon, LPCSTR LargeIcon, HWND hWnd, intptr_t ReplyMsg) +M_RESULT SnarlInterface::RegisterApp(LPCSTR Application, LPCSTR SmallIcon, LPCSTR LargeIcon, HWND hWnd, LONG32 ReplyMsg) { m_hwndFrom = hWnd; @@ -544,14 +543,14 @@ M_RESULT SnarlInterface::RegisterApp(LPCSTR Application, LPCSTR SmallIcon, LPCST StringCbCopyA((LPSTR)&ss.Icon, SNARL_STRING_LENGTH, SmallIcon); StringCbCopyA((LPSTR)&ss.Text, SNARL_STRING_LENGTH, LargeIcon); - ss.LngData2 = reinterpret_cast(hWnd); + ss.LngData2 = reinterpret_cast(hWnd); ss.Id = ReplyMsg; ss.Timeout = GetCurrentProcessId(); return static_cast(Send(ss)); } -M_RESULT SnarlInterface::RegisterApp(LPCWSTR Application, LPCWSTR SmallIcon, LPCWSTR LargeIcon, HWND hWnd, intptr_t ReplyMsg) +M_RESULT SnarlInterface::RegisterApp(LPCWSTR Application, LPCWSTR SmallIcon, LPCWSTR LargeIcon, HWND hWnd, LONG32 ReplyMsg) { LPSTR szParam1 = WideToUTF8(Application); LPSTR szParam2 = WideToUTF8(SmallIcon); @@ -590,7 +589,7 @@ M_RESULT SnarlInterface::UnregisterApp() /// Displays a Snarl notification using registered class (V39) /// Message Id on success or M_RESULT on failure -intptr_t SnarlInterface::ShowNotification(LPCSTR Class, LPCSTR Title, LPCSTR Text, intptr_t Timeout, LPCSTR Icon, HWND hWndReply, intptr_t uReplyMsg, LPCSTR Sound) +LONG32 SnarlInterface::ShowNotification(LPCSTR Class, LPCSTR Title, LPCSTR Text, LONG32 Timeout, LPCSTR Icon, HWND hWndReply, LONG32 uReplyMsg, LPCSTR Sound) { SNARLSTRUCTEX ssex; ssex.Cmd = SNARL_SHOW_NOTIFICATION; @@ -600,7 +599,7 @@ intptr_t SnarlInterface::ShowNotification(LPCSTR Class, LPCSTR Title, LPCSTR Tex StringCbCopyExA((LPSTR)&ssex.Icon, SNARL_STRING_LENGTH, Icon, NULL, NULL, STRSAFE_IGNORE_NULLS); ssex.Timeout = Timeout; - ssex.LngData2 = reinterpret_cast(hWndReply); + ssex.LngData2 = reinterpret_cast(hWndReply); ssex.Id = uReplyMsg; StringCbCopyExA((LPSTR)&ssex.Extra, SNARL_STRING_LENGTH, Sound, NULL, NULL, STRSAFE_IGNORE_NULLS); @@ -612,7 +611,7 @@ intptr_t SnarlInterface::ShowNotification(LPCSTR Class, LPCSTR Title, LPCSTR Tex return m_nLastMessageId; } -intptr_t SnarlInterface::ShowNotification(LPCWSTR Class, LPCWSTR Title, LPCWSTR Text, intptr_t Timeout, LPCWSTR Icon, HWND hWndReply, intptr_t uReplyMsg, LPCWSTR Sound) +LONG32 SnarlInterface::ShowNotification(LPCWSTR Class, LPCWSTR Title, LPCWSTR Text, LONG32 Timeout, LPCWSTR Icon, HWND hWndReply, LONG32 uReplyMsg, LPCWSTR Sound) { LPSTR szParam1 = WideToUTF8(Class); LPSTR szParam2 = WideToUTF8(Title); @@ -620,7 +619,7 @@ intptr_t SnarlInterface::ShowNotification(LPCWSTR Class, LPCWSTR Title, LPCWSTR LPSTR szParam4 = WideToUTF8(Icon); LPSTR szParam5 = WideToUTF8(Sound); - intptr_t result = ShowNotification(szParam1, szParam2, szParam3, Timeout, szParam4, hWndReply, uReplyMsg, szParam5); + LONG32 result = ShowNotification(szParam1, szParam2, szParam3, Timeout, szParam4, hWndReply, uReplyMsg, szParam5); delete [] szParam1; delete [] szParam2; @@ -637,7 +636,7 @@ intptr_t SnarlInterface::ShowNotification(LPCWSTR Class, LPCWSTR Title, LPCWSTR /// (V39) -M_RESULT SnarlInterface::ChangeAttribute(intptr_t Id, SNARL_ATTRIBUTES Attr, LPCSTR Value) +M_RESULT SnarlInterface::ChangeAttribute(LONG32 Id, SNARL_ATTRIBUTES Attr, LPCSTR Value) { SNARLSTRUCT ss; ss.Cmd = SNARL_CHANGE_ATTR; @@ -649,7 +648,7 @@ M_RESULT SnarlInterface::ChangeAttribute(intptr_t Id, SNARL_ATTRIBUTES Attr, LPC return static_cast(Send(ss)); } -M_RESULT SnarlInterface::ChangeAttribute(intptr_t Id, SNARL_ATTRIBUTES Attr, LPCWSTR Value) +M_RESULT SnarlInterface::ChangeAttribute(LONG32 Id, SNARL_ATTRIBUTES Attr, LPCWSTR Value) { LPSTR szParam1 = WideToUTF8(Value); @@ -709,7 +708,7 @@ M_RESULT SnarlInterface::SetClassDefault(LPCWSTR Class, SNARL_ATTRIBUTES Attr, L /// Gets the current Snarl revision (build) number (V39) /// Returns the build version number, or M_RESULT on failure. -intptr_t SnarlInterface::GetRevision() +LONG32 SnarlInterface::GetRevision() { SNARLSTRUCT ss; ss.Cmd = SNARL_GET_REVISION; @@ -724,7 +723,7 @@ intptr_t SnarlInterface::GetRevision() /// (V39) -M_RESULT SnarlInterface::AddClass(LPCSTR Class, LPCSTR Description, SNARL_CLASS_FLAGS Flags, LPCSTR DefaultTitle, LPCSTR DefaultIcon, intptr_t DefaultTimeout) +M_RESULT SnarlInterface::AddClass(LPCSTR Class, LPCSTR Description, SNARL_CLASS_FLAGS Flags, LPCSTR DefaultTitle, LPCSTR DefaultIcon, LONG32 DefaultTimeout) { SNARLSTRUCT ss; ss.Cmd = SNARL_ADD_CLASS; @@ -734,7 +733,7 @@ M_RESULT SnarlInterface::AddClass(LPCSTR Class, LPCSTR Description, SNARL_CLASS_ StringCbCopyExA((LPSTR)&ss.Text, SNARL_STRING_LENGTH, Class, NULL, NULL, STRSAFE_IGNORE_NULLS); StringCbCopyExA((LPSTR)&ss.Title, SNARL_STRING_LENGTH, Description, NULL, NULL, STRSAFE_IGNORE_NULLS); - intptr_t result = Send(ss); + LONG32 result = Send(ss); if (static_cast(result) == M_OK) { @@ -752,7 +751,7 @@ M_RESULT SnarlInterface::AddClass(LPCSTR Class, LPCSTR Description, SNARL_CLASS_ return M_FAILED; } -M_RESULT SnarlInterface::AddClass(LPCWSTR Class, LPCWSTR Description, SNARL_CLASS_FLAGS Flags, LPCWSTR DefaultTitle, LPCWSTR DefaultIcon, intptr_t DefaultTimeout) +M_RESULT SnarlInterface::AddClass(LPCWSTR Class, LPCWSTR Description, SNARL_CLASS_FLAGS Flags, LPCWSTR DefaultTitle, LPCWSTR DefaultIcon, LONG32 DefaultTimeout) { LPCSTR szClass = WideToUTF8(Class); LPCSTR szDescription = WideToUTF8(Description); @@ -774,7 +773,7 @@ M_RESULT SnarlInterface::AddClass(LPCWSTR Class, LPCWSTR Description, SNARL_CLAS //----------------------------------------------------------------------------- template -intptr_t SnarlInterface::Send(T ss) +LONG32 SnarlInterface::Send(T ss) { DWORD_PTR nReturn = M_FAILED; @@ -793,7 +792,7 @@ intptr_t SnarlInterface::Send(T ss) } } - return static_cast(nReturn); + return static_cast(nReturn); } //----------------------------------------------------------------------------- @@ -810,4 +809,4 @@ LPSTR SnarlInterface::WideToUTF8(LPCWSTR szWideStr) WideCharToMultiByte(CP_UTF8, 0, szWideStr, -1, szUTF8, nSize, NULL, NULL); return szUTF8; -} +} \ No newline at end of file diff --git a/src/plugins/snarl/SnarlInterface.h b/src/plugins/snarl/SnarlInterface.h index ae770e7..1591174 100644 --- a/src/plugins/snarl/SnarlInterface.h +++ b/src/plugins/snarl/SnarlInterface.h @@ -5,6 +5,8 @@ #include #include +//be compatible with x64 +#define LONG32 intptr_t namespace Snarl { @@ -14,25 +16,25 @@ namespace Snarl { static const int SNARL_STRING_LENGTH = 1024; static const int SNARL_UNICODE_LENGTH = SNARL_STRING_LENGTH / 2; - static const intptr_t SNARL_LAUNCHED = 1; // Snarl has just started running - static const intptr_t SNARL_QUIT = 2; // Snarl is about to stop running - static const intptr_t SNARL_ASK_APPLET_VER = 3; // (R1.5) Reserved for future use - static const intptr_t SNARL_SHOW_APP_UI = 4; // (R1.6) Application should show its UI + static const LONG32 SNARL_LAUNCHED = 1; // Snarl has just started running + static const LONG32 SNARL_QUIT = 2; // Snarl is about to stop running + static const LONG32 SNARL_ASK_APPLET_VER = 3; // (R1.5) Reserved for future use + static const LONG32 SNARL_SHOW_APP_UI = 4; // (R1.6) Application should show its UI - static const intptr_t SNARL_NOTIFICATION_CLICKED = 32; // notification was right-clicked by user - static const intptr_t SNARL_NOTIFICATION_TIMED_OUT = 33; - static const intptr_t SNARL_NOTIFICATION_ACK = 34; // notification was left-clicked by user - static const intptr_t SNARL_NOTIFICATION_MENU = 35; // V39 - menu item selected - static const intptr_t SNARL_NOTIFICATION_MIDDLE_BUTTON = 36; // V39 - notification middle-clicked by user - static const intptr_t SNARL_NOTIFICATION_CLOSED = 37; // V39 - user clicked the close gadget + static const LONG32 SNARL_NOTIFICATION_CLICKED = 32; // notification was right-clicked by user + static const LONG32 SNARL_NOTIFICATION_TIMED_OUT = 33; + static const LONG32 SNARL_NOTIFICATION_ACK = 34; // notification was left-clicked by user + static const LONG32 SNARL_NOTIFICATION_MENU = 35; // V39 - menu item selected + static const LONG32 SNARL_NOTIFICATION_MIDDLE_BUTTON = 36; // V39 - notification middle-clicked by user + static const LONG32 SNARL_NOTIFICATION_CLOSED = 37; // V39 - user clicked the close gadget - static const intptr_t SNARL_NOTIFICATION_CANCELLED = SNARL_NOTIFICATION_CLICKED; // Added in R1.6 + static const LONG32 SNARL_NOTIFICATION_CANCELLED = SNARL_NOTIFICATION_CLICKED; // Added in R1.6 static const DWORD WM_SNARLTEST = WM_USER + 237; // note hardcoded WM_USER value! // -------------------------------------------------------------------- - enum M_RESULT { + typedef enum M_RESULT { M_ABORTED = 0x80000007, M_ACCESS_DENIED = 0x80000009, M_ALREADY_EXISTS = 0x8000000C, @@ -46,7 +48,7 @@ namespace Snarl { M_OK = 0x00000000, M_OUT_OF_MEMORY = 0x80000002, M_TIMED_OUT = 0x8000000A - } ; + }; enum SNARL_COMMANDS { SNARL_SHOW = 1, @@ -78,13 +80,13 @@ namespace Snarl { static const SNARL_COMMANDS SNARL_GET_REVISION = SNARL_REVOKE_ALERT; - enum SNARL_APP_FLAGS { + typedef enum SNARL_APP_FLAGS { SNARL_APP_HAS_PREFS = 1, SNARL_APP_HAS_ABOUT = 2 }; - static const intptr_t SNARL_APP_PREFS = 1; - static const intptr_t SNARL_APP_ABOUT = 2; + static const LONG32 SNARL_APP_PREFS = 1; + static const LONG32 SNARL_APP_ABOUT = 2; /* --------------- V39 additions --------------- */ @@ -98,7 +100,7 @@ namespace Snarl { }; /* Class attributes */ - enum SNARL_ATTRIBUTES { + typedef enum SNARL_ATTRIBUTES { SNARL_ATTRIBUTE_TITLE = 1, SNARL_ATTRIBUTE_TEXT, SNARL_ATTRIBUTE_ICON, @@ -112,9 +114,9 @@ namespace Snarl { struct SNARLSTRUCT { SNARL_COMMANDS Cmd; - intptr_t Id; - intptr_t Timeout; - intptr_t LngData2; + LONG32 Id; + LONG32 Timeout; + LONG32 LngData2; char Title[SNARL_STRING_LENGTH]; char Text[SNARL_STRING_LENGTH]; char Icon[SNARL_STRING_LENGTH]; @@ -122,9 +124,9 @@ namespace Snarl { struct SNARLSTRUCTEX { SNARL_COMMANDS Cmd; - intptr_t Id; - intptr_t Timeout; - intptr_t LngData2; + LONG32 Id; + LONG32 Timeout; + LONG32 LngData2; char Title[SNARL_STRING_LENGTH]; char Text[SNARL_STRING_LENGTH]; char Icon[SNARL_STRING_LENGTH]; @@ -132,8 +134,8 @@ namespace Snarl { char Class[SNARL_STRING_LENGTH]; char Extra[SNARL_STRING_LENGTH]; char Extra2[SNARL_STRING_LENGTH]; - intptr_t Reserved1; - intptr_t Reserved2; + LONG32 Reserved1; + LONG32 Reserved2; }; @@ -148,67 +150,67 @@ namespace Snarl { ~SnarlInterface(); static HWND GetSnarlWindow(); - static intptr_t GetGlobalMsg(); + static LONG32 GetGlobalMsg(); LPTSTR AllocateString(size_t n) { return new TCHAR[n]; } void FreeString(LPCTSTR str) { delete [] str; str = NULL; } - intptr_t ShowMessage(LPCSTR szTitle, LPCSTR szText, intptr_t timeout = 0, LPCSTR szIconPath = "", HWND hWndReply = NULL, WPARAM uReplyMsg = 0); - intptr_t ShowMessage(LPCWSTR szTitle, LPCWSTR szText, intptr_t timeout = 0, LPCWSTR szIconPath = L"", HWND hWndReply = NULL, WPARAM uReplyMsg = 0); - intptr_t ShowMessageEx(LPCSTR szClass, LPCSTR szTitle, LPCSTR szText, intptr_t timeout = 0, LPCSTR szIconPath = "", HWND hWndReply = NULL, WPARAM uReplyMsg = 0, LPCSTR szSoundFile = ""); - intptr_t ShowMessageEx(LPCWSTR szClass, LPCWSTR szTitle, LPCWSTR szText, intptr_t timeout = 0, LPCWSTR szIconPath = L"", HWND hWndReply = NULL, WPARAM uReplyMsg = 0, LPCWSTR szSoundFile = L""); + LONG32 ShowMessage(LPCSTR szTitle, LPCSTR szText, LONG32 timeout = 0, LPCSTR szIconPath = "", HWND hWndReply = NULL, WPARAM uReplyMsg = 0); + LONG32 ShowMessage(LPCWSTR szTitle, LPCWSTR szText, LONG32 timeout = 0, LPCWSTR szIconPath = L"", HWND hWndReply = NULL, WPARAM uReplyMsg = 0); + LONG32 ShowMessageEx(LPCSTR szClass, LPCSTR szTitle, LPCSTR szText, LONG32 timeout = 0, LPCSTR szIconPath = "", HWND hWndReply = NULL, WPARAM uReplyMsg = 0, LPCSTR szSoundFile = ""); + LONG32 ShowMessageEx(LPCWSTR szClass, LPCWSTR szTitle, LPCWSTR szText, LONG32 timeout = 0, LPCWSTR szIconPath = L"", HWND hWndReply = NULL, WPARAM uReplyMsg = 0, LPCWSTR szSoundFile = L""); LPCTSTR GetAppPath(); // ** Remember to FreeString when finished with the string ! LPCTSTR GetIconsPath(); // ** Remember to FreeString when finished with the string ! BOOL GetVersion(WORD* Major, WORD* Minor); - intptr_t GetVersionEx(); + LONG32 GetVersionEx(); BOOL HideMessage(); - BOOL HideMessage(intptr_t Id); + BOOL HideMessage(LONG32 Id); BOOL IsMessageVisible(); - BOOL IsMessageVisible(intptr_t Id); + BOOL IsMessageVisible(LONG32 Id); M_RESULT RegisterAlert(LPCSTR szAppName, LPCSTR szClass); M_RESULT RegisterAlert(LPCWSTR szAppName, LPCWSTR szClass); - M_RESULT RegisterConfig(HWND hWnd, LPCSTR szAppName, intptr_t replyMsg); - M_RESULT RegisterConfig(HWND hWnd, LPCWSTR szAppName, intptr_t replyMsg); - M_RESULT RegisterConfig2(HWND hWnd, LPCSTR szAppName, intptr_t replyMsg, LPCSTR szIcon); - M_RESULT RegisterConfig2(HWND hWnd, LPCWSTR szAppName, intptr_t replyMsg, LPCWSTR szIcon); + M_RESULT RegisterConfig(HWND hWnd, LPCSTR szAppName, LONG32 replyMsg); + M_RESULT RegisterConfig(HWND hWnd, LPCWSTR szAppName, LONG32 replyMsg); + M_RESULT RegisterConfig2(HWND hWnd, LPCSTR szAppName, LONG32 replyMsg, LPCSTR szIcon); + M_RESULT RegisterConfig2(HWND hWnd, LPCWSTR szAppName, LONG32 replyMsg, LPCWSTR szIcon); M_RESULT RevokeConfig(HWND hWnd); - M_RESULT SetTimeout(intptr_t Timeout); - M_RESULT SetTimeout(intptr_t Id, intptr_t Timeout); + M_RESULT SetTimeout(LONG32 Timeout); + M_RESULT SetTimeout(LONG32 Id, LONG32 Timeout); M_RESULT UpdateMessage(LPCSTR szTitle, LPCSTR szText, LPCSTR szIconPath = ""); M_RESULT UpdateMessage(LPCWSTR szTitle, LPCWSTR szText, LPCWSTR szIconPath = L""); - M_RESULT UpdateMessage(intptr_t Id, LPCSTR szTitle, LPCSTR szText, LPCSTR szIconPath = ""); - M_RESULT UpdateMessage(intptr_t Id, LPCWSTR szTitle, LPCWSTR szText, LPCWSTR szIconPath = L""); + M_RESULT UpdateMessage(LONG32 Id, LPCSTR szTitle, LPCSTR szText, LPCSTR szIconPath = ""); + M_RESULT UpdateMessage(LONG32 Id, LPCWSTR szTitle, LPCWSTR szText, LPCWSTR szIconPath = L""); /* V39 */ - M_RESULT AddClass(LPCSTR Class, LPCSTR Description = NULL, SNARL_CLASS_FLAGS Flags = SNARL_CLASS_ENABLED, LPCSTR DefaultTitle = NULL, LPCSTR DefaultIcon = NULL, intptr_t DefaultTimeout = 0); - M_RESULT AddClass(LPCWSTR Class, LPCWSTR Description = NULL, SNARL_CLASS_FLAGS Flags = SNARL_CLASS_ENABLED, LPCWSTR DefaultTitle = NULL, LPCWSTR DefaultIcon = NULL, intptr_t DefaultTimeout = 0); + M_RESULT AddClass(LPCSTR Class, LPCSTR Description = NULL, SNARL_CLASS_FLAGS Flags = SNARL_CLASS_ENABLED, LPCSTR DefaultTitle = NULL, LPCSTR DefaultIcon = NULL, LONG32 DefaultTimeout = 0); + M_RESULT AddClass(LPCWSTR Class, LPCWSTR Description = NULL, SNARL_CLASS_FLAGS Flags = SNARL_CLASS_ENABLED, LPCWSTR DefaultTitle = NULL, LPCWSTR DefaultIcon = NULL, LONG32 DefaultTimeout = 0); M_RESULT ChangeAttribute(SNARL_ATTRIBUTES Attr, LPCSTR Value); M_RESULT ChangeAttribute(SNARL_ATTRIBUTES Attr, LPCWSTR Value); - M_RESULT ChangeAttribute(intptr_t Id, SNARL_ATTRIBUTES Attr, LPCSTR Value); - M_RESULT ChangeAttribute(intptr_t Id, SNARL_ATTRIBUTES Attr, LPCWSTR Value); - intptr_t GetAppMsg(); - intptr_t GetRevision(); + M_RESULT ChangeAttribute(LONG32 Id, SNARL_ATTRIBUTES Attr, LPCSTR Value); + M_RESULT ChangeAttribute(LONG32 Id, SNARL_ATTRIBUTES Attr, LPCWSTR Value); + LONG32 GetAppMsg(); + LONG32 GetRevision(); - M_RESULT RegisterApp(LPCSTR Application, LPCSTR SmallIcon, LPCSTR LargeIcon, HWND hWnd = 0, intptr_t ReplyMsg = 0); - M_RESULT RegisterApp(LPCWSTR Application, LPCWSTR SmallIcon, LPCWSTR LargeIcon, HWND hWnd = 0, intptr_t ReplyMsg = 0); + M_RESULT RegisterApp(LPCSTR Application, LPCSTR SmallIcon, LPCSTR LargeIcon, HWND hWnd = 0, LONG32 ReplyMsg = 0); + M_RESULT RegisterApp(LPCWSTR Application, LPCWSTR SmallIcon, LPCWSTR LargeIcon, HWND hWnd = 0, LONG32 ReplyMsg = 0); void SetAsSnarlApp(HWND hWndOwner, SNARL_APP_FLAGS Flags = (SNARL_APP_FLAGS)(SNARL_APP_HAS_ABOUT | SNARL_APP_HAS_PREFS)); M_RESULT SetClassDefault(LPCSTR Class, SNARL_ATTRIBUTES Attr, LPCSTR Value); M_RESULT SetClassDefault(LPCWSTR Class, SNARL_ATTRIBUTES Attr, LPCWSTR Value); - intptr_t ShowNotification(LPCSTR Class, LPCSTR Title = NULL, LPCSTR Text = NULL, intptr_t Timeout = 0, LPCSTR Icon = NULL, HWND hWndReply = NULL, intptr_t uReplyMsg = 0, LPCSTR Sound = NULL); - intptr_t ShowNotification(LPCWSTR Class, LPCWSTR Title = NULL, LPCWSTR Text = NULL, intptr_t Timeout = 0, LPCWSTR Icon = NULL, HWND hWndReply = NULL, intptr_t uReplyMsg = 0, LPCWSTR Sound = NULL); + LONG32 ShowNotification(LPCSTR Class, LPCSTR Title = NULL, LPCSTR Text = NULL, LONG32 Timeout = 0, LPCSTR Icon = NULL, HWND hWndReply = NULL, LONG32 uReplyMsg = 0, LPCSTR Sound = NULL); + LONG32 ShowNotification(LPCWSTR Class, LPCWSTR Title = NULL, LPCWSTR Text = NULL, LONG32 Timeout = 0, LPCWSTR Icon = NULL, HWND hWndReply = NULL, LONG32 uReplyMsg = 0, LPCWSTR Sound = NULL); M_RESULT UnregisterApp(); - intptr_t GetLastMessageId() { return m_nLastMessageId; } + LONG32 GetLastMessageId() { return m_nLastMessageId; } private: - template intptr_t Send(T ss); + template LONG32 Send(T ss); LPSTR WideToUTF8(LPCWSTR szWideStr); - intptr_t m_nLastMessageId; + LONG32 m_nLastMessageId; HWND m_hwndFrom; // set during snRegisterConfig() or snRegisterConfig2() }; diff --git a/src/plugins/snarl/snarl_backend.cpp b/src/plugins/snarl/snarl_backend.cpp index 666348b..d0fe5f0 100644 --- a/src/plugins/snarl/snarl_backend.cpp +++ b/src/plugins/snarl/snarl_backend.cpp @@ -18,6 +18,7 @@ #include #include #include +#include @@ -29,7 +30,7 @@ Snarl_Backend::Snarl_Backend() setProperty("name","Snarl_Backend"); snarlInterface=new Snarl::SnarlInterface(); qDebug()<<"Initiating Snarl Backend, Snarl version: "<GetVersionExA(); - this->installEventFilter(this); + this->installEventFilter(this); } Snarl_Backend::~Snarl_Backend(){ @@ -37,22 +38,47 @@ Snarl_Backend::~Snarl_Backend(){ } int Snarl_Backend::notify(QSharedPointernotification){ - int timeout=notification->timeout>=0?notification->timeout:10; - if(notification->getID()==0){ - QString title=Notification::toPlainText(notification->title); - QString text=Notification::toPlainText(notification->text); - std::cout<<"Calling Snarl"<getIcon().toLocal8Bit().data()<ShowMessage(title.toLocal8Bit().data(), text.toLocal8Bit().data(),timeout, notification->getIcon().toLocal8Bit().data()); + QString qtitle(Notification::toPlainText(notification->title())); + QString qtext( Notification::toPlainText(notification->text())); + QString qicon(notification->icon()); + + wchar_t *title = new wchar_t[qtitle.length()+1]; + wchar_t *text = new wchar_t[qtext.length()+1]; + wchar_t *icon = new wchar_t[qicon.length()+1]; + + int i=0; + i=qtitle.toWCharArray(title); + title[i+1]=0; + i=qtext.toWCharArray(text); + text[i+1]=0; + i=qicon.toWCharArray(icon); + icon[i+1]=0; + + if(notification->id()==0){ + wprintf(L"Calling SnarlMessage\n" + L"Title: %s\n" + L"Text:%s\n" + L"Timeout: %i\n" + L"Icon: %s\n",title,text,notification->timeout(),icon); + return snarlInterface->ShowMessage(title,text,notification->timeout(), icon); }else{ //update message - snarlInterface->UpdateMessage(LONG32(notification->getID()),notification->title.toLocal8Bit().data(), notification->text.toLocal8Bit().data(),notification->getIcon().toLocal8Bit().data()); - return notification->getID(); + wprintf(L"Updating SnarlMessage ID: %i\n" + L"Title: %s\n" + L"Text:%s\n" + L"Icon: %s\n",notification->id(),title,text,icon); + snarlInterface->UpdateMessage(notification->id(),title, text,icon); + return notification->id(); } + delete[] title; + delete[] text; + delete[] icon; } void Snarl_Backend::closeNotification(int nr){ snarlInterface->HideMessage(nr); } + bool Snarl_Backend::eventFilter(QObject *obj, QEvent *event){ qDebug()<objectName(); return true; diff --git a/src/plugins/snarlnetwork/CMakeLists.txt b/src/plugins/snarlnetwork/CMakeLists.txt index 541505d..f0b8d1d 100644 --- a/src/plugins/snarlnetwork/CMakeLists.txt +++ b/src/plugins/snarlnetwork/CMakeLists.txt @@ -3,4 +3,4 @@ set( SNARL_NETWORK_SRC parser.cpp ) automoc4_add_library(snarlnetwork MODULE ${SNARL_NETWORK_SRC} ) -target_link_libraries(snarlnetwork snore ${QT_QTNETWORK_LIBRARY} ) +target_link_libraries(snarlnetwork snorecore ${QT_QTNETWORK_LIBRARY} ) diff --git a/src/plugins/snarlnetwork/parser.cpp b/src/plugins/snarlnetwork/parser.cpp index 4b82a1d..55b4822 100644 --- a/src/plugins/snarlnetwork/parser.cpp +++ b/src/plugins/snarlnetwork/parser.cpp @@ -15,9 +15,13 @@ ****************************************************************************************/ #include "parser.h" -#include "core/snoreserver.h" #include "snarlnetwork.h" + +#include "core/snoreserver.h" #include "core/notification.h" +#include "core/utils.h" + + #include #include #include @@ -50,10 +54,9 @@ SnarlNotification Parser::parse(QString &msg,QTcpSocket* client){ SnarlNotification sNotification; sNotification.httpClient=false; - sNotification.vailid=true; - sNotification.notification=QSharedPointer(new Notification()); + sNotification.vailid=true; sNotification.clientSocket=client; - sNotification.notification->setIsNotification(false); + snpTypes action(ERROR); if(msg.startsWith("GET ")){ @@ -65,6 +68,13 @@ SnarlNotification Parser::parse(QString &msg,QTcpSocket* client){ sNotification.httpClient=true; } + QString app; + QString title; + QString text; + QString sntpIcon; + QString icon; + QString alert; + int timeout=10; QString key; QString value; @@ -74,67 +84,71 @@ SnarlNotification Parser::parse(QString &msg,QTcpSocket* client){ value=s.mid(s.indexOf("=")+1); switch(getSnpType.value(key)){ case APP: - sNotification.notification->app=value; + app=value; break; case ACTION: action=getSnpType.value(value); sNotification.action=value; break; case TITLE: - sNotification.notification->title=value; + title=value; break; case TEXT: - sNotification.notification->text=value; + text=value; break; case ICON: - sNotification.notification->hints.insert("SnarlIcon",value); - sNotification.notification->setIcon(downloadIcon(value)); + sntpIcon=value; + icon=downloadIcon(value); break; case CLASS: - sNotification.notification->alert=value; + alert=value; case TIMEOUT: - sNotification.notification->timeout=value.toInt(); + timeout=value.toInt(); break; default: break; } } + sNotification.notification=QSharedPointer(new Notification(snarl,title,text,icon,timeout)); + sNotification.notification->setIsNotification(false); + sNotification.notification->insertHint("SnarlIcon",sntpIcon); + switch(action){ case NOTIFICATION: - if(snarl->getSnore()->applicationListAlertIsActive(sNotification.notification->app,sNotification.notification->alert)) + if(snarl->getSnore()->applicationListAlertIsActive(sNotification.notification->application(),sNotification.notification->alert())) break; sNotification.notification->setIsNotification(true); return sNotification; break; case ADD_CLASS: - if(sNotification.notification->alert.isEmpty()){ + if(sNotification.notification->alert().isEmpty()){ qDebug()<<"Error registering alert with empty name"; break; } - if(sNotification.notification->title.isEmpty()) - sNotification.notification->title = sNotification.notification->alert; - snarl->getSnore()->addAlert(sNotification.notification->app,sNotification.notification->alert,sNotification.notification->title); + if(title.isEmpty()) + title = alert; + snarl->getSnore()->addAlert(sNotification.notification->application(),alert,title); break; case REGISTER: qDebug()<getSnore()->getAplicationList()->keys(); - if(!snarl->getSnore()->getAplicationList()->contains(sNotification.notification->app)&&!sNotification.notification->app.isEmpty()){ - snarl->getSnore()->addApplication(QSharedPointer(new Application(sNotification.notification->app))); + if(!snarl->getSnore()->getAplicationList()->contains(sNotification.notification->application())&&!sNotification.notification->application().isEmpty()){ + snarl->getSnore()->addApplication(QSharedPointer(new Application(sNotification.notification->application()))); } else - qDebug()<app<<"already registred"; + qDebug()<application()<<"already registred"; break; case UNREGISTER: - snarl->getSnore()->removeApplication(sNotification.notification->app); + snarl->getSnore()->removeApplication(sNotification.notification->application()); break; case ERROR: default: sNotification.vailid=false; break; } - qDebug()<toSnalrString(); - sNotification.notification->hints.insert("SNaction",sNotification.action); + qDebug()<insertHint("SNaction",sNotification.action); return sNotification; } diff --git a/src/plugins/snarlnetwork/snarlnetwork.cpp b/src/plugins/snarlnetwork/snarlnetwork.cpp index 53ecc0a..853155d 100644 --- a/src/plugins/snarlnetwork/snarlnetwork.cpp +++ b/src/plugins/snarlnetwork/snarlnetwork.cpp @@ -36,15 +36,15 @@ SnarlNetworkFrontend::SnarlNetworkFrontend(){ void SnarlNetworkFrontend::actionInvoked(QSharedPointernotification){ //TODO:fix callback - SnarlNotification sn=notifications.value(notification->getID()); - if(notification->actionInvoked==1) + SnarlNotification sn=notifications.value(notification->id()); + if(notification->actionInvoked()==1) callback(sn,"SNP/1.1/304/Notification acknowledged/"); - else if(notification->actionInvoked==2) + else if(notification->actionInvoked()==2) callback(sn,"SNP/1.1/302/Notification cancelled/"); } void SnarlNetworkFrontend::notificationClosed(QSharedPointernotification){ - SnarlNotification sn=notifications.value(notification->getID()); - if(notification->actionInvoked==Notification::TIMED_OUT) + SnarlNotification sn=notifications.value(notification->id()); + if(notification->actionInvoked()==Notification::TIMED_OUT) callback(sn,"SNP/1.1/303/Notification timed out/"); else callback(sn,"SNP/1.1/307/Notification closed/"); @@ -62,13 +62,13 @@ void SnarlNetworkFrontend::handleMessages(){ QStringList incommings(QString::fromUtf8(client->readAll()).split("\r\n")); foreach(QString s,incommings){ SnarlNotification noti=parser->parse(s,client); - notifications.insert(noti.notification->getID(),noti); + notifications.insert(noti.notification->id(),noti); if(!noti.vailid) continue; if(noti.notification->isNotification()){ getSnore()->broadcastNotification(noti.notification); - if(noti.notification->getID()!=0){ - out+="/"+QString::number(noti.notification->getID())+"\r\n"; + if(noti.notification->id()!=0){ + out+="/"+QString::number(noti.notification->id())+"\r\n"; } }else{ out+="\r\n"; @@ -88,9 +88,9 @@ void SnarlNetworkFrontend::clientDisconnecd(){ } void SnarlNetworkFrontend::callback(const SnarlNotification &sn,QString msg){ - notifications.remove(sn.notification->getID()); + notifications.remove(sn.notification->id()); if(sn.clientSocket!=NULL&&!msg.isEmpty()){ - msg+=QString::number(sn.notification->getID()); + msg+=QString::number(sn.notification->id()); qDebug()<write(msg.toAscii()+"\n"); sn.clientSocket->flush(); @@ -103,5 +103,4 @@ void SnarlNetworkFrontend::callback(const SnarlNotification &sn,QString msg){ } - #include "snarlnetwork.moc" diff --git a/src/plugins/webposter/CMakeLists.txt b/src/plugins/webposter/CMakeLists.txt index 06d9d1c..4444e82 100644 --- a/src/plugins/webposter/CMakeLists.txt +++ b/src/plugins/webposter/CMakeLists.txt @@ -2,4 +2,4 @@ set( WEBPOSTER_SRC webposter.cpp ) automoc4_add_library(webposter MODULE ${WEBPOSTER_SRC} ) -target_link_libraries(webposter snore ${QT_QTNETWORK_LIBRARY} ) +target_link_libraries(webposter snorecore ${QT_QTNETWORK_LIBRARY} ) diff --git a/src/plugins/webposter/webposter.cpp b/src/plugins/webposter/webposter.cpp index c6fa2f2..73e90fa 100644 --- a/src/plugins/webposter/webposter.cpp +++ b/src/plugins/webposter/webposter.cpp @@ -18,6 +18,9 @@ #include #include #include + +#include "core/utils.h" + Q_EXPORT_PLUGIN2(webposter,WebPoster) WebPoster::WebPoster(){ @@ -26,7 +29,7 @@ WebPoster::WebPoster(){ } int WebPoster::notify(QSharedPointernotification){ - QByteArray byte(notification->toSnalrString().toLatin1().data()); + QByteArray byte(Utils::notificationToSNTPString(notification).toLatin1().data()); QUrl url("http://www.pro-zeit.ch/index.php"); url.addEncodedQueryItem("action","add"); url.addEncodedQueryItem("data",QUrl::toPercentEncoding(byte.toBase64())); diff --git a/src/webinterface/CMakeLists.txt b/src/webinterface/CMakeLists.txt index 95428a9..ec363ed 100644 --- a/src/webinterface/CMakeLists.txt +++ b/src/webinterface/CMakeLists.txt @@ -5,6 +5,6 @@ if(WITH_WEBINTERFACE) ) automoc4_add_library(webinterface SHARED ${WEBINTERFACE_SRC} ) set_target_properties( webinterface PROPERTIES COMPILE_FLAGS "-DWEBINTERFACE_DLL" ) - target_link_libraries(webinterface snore ${QT_QTNETWORK_LIBRARY} ) + target_link_libraries(webinterface snorecore ${QT_QTNETWORK_LIBRARY} ) endif(WITH_WEBINTERFACE)