diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5922943..d81ab6f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,7 +8,7 @@ include_directories ( add_subdirectory(core) add_executable ( SnoreNotify main.cpp ) -target_link_libraries ( SnoreNotify snore) +target_link_libraries ( SnoreNotify snore ${QT_QTGUI_LIBRARY}) add_dependencies(SnoreNotify snore) add_subdirectory(webinterface) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 6c76de0..15e78a6 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -7,6 +7,6 @@ set ( SnoreNotify_SRCS automoc4_add_library( snore SHARED ${SnoreNotify_SRCS}) set_target_properties( snore PROPERTIES COMPILE_FLAGS "-DSNORECORE_DLL" ) -target_link_libraries ( snore ${QT_QTCORE_LIBRARY} ) +target_link_libraries ( snore ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ) diff --git a/src/core/notification.cpp b/src/core/notification.cpp index 736f3a5..0bc16b5 100644 --- a/src/core/notification.cpp +++ b/src/core/notification.cpp @@ -4,6 +4,8 @@ #include "snoreserver.h" + + Notification::Notification():source("none"),timeout(10),notification(true){} Notification::Notification(QString source,QString title,QString text,QString icon,int timeout):source(source),title(title),text(text),timeout(timeout),icon(icon),notification(true) { diff --git a/src/core/notification.h b/src/core/notification.h index 44ae7fd..ed7e8ce 100644 --- a/src/core/notification.h +++ b/src/core/notification.h @@ -1,16 +1,11 @@ #ifndef NOTIFICATION_H #define NOTIFICATION_H #include "snore_exports.h" -#include -#include -#include -#include -#include -#include "QHash" +#include #include #include "application.h" -#include - +#include +#include @@ -18,6 +13,13 @@ class SNORE_EXPORT Notification:public QObject { Q_OBJECT +public: + static inline QString toPlainText(const QString &string){ + if(!Qt::mightBeRichText ( string))return string; + QTextEdit te; + te.setHtml(string); + return te.toPlainText(); + }; public: Notification(); Notification(QString source,QString title,QString text,QString icon,int timeout); @@ -31,7 +33,7 @@ public: ACTION_3=3, CLOSED=4 - }; + }; actions actionInvoked; QString source; diff --git a/src/main.cpp b/src/main.cpp index 5fbff42..ecc9265 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ -#include +#include #include "core/snoreserver.h" #include #include @@ -8,7 +8,7 @@ int main(int argc, char *argv[]) { - QCoreApplication a(argc, argv); + QApplication a(argc, argv); SnoreServer s; QDir pluginsDir(a.applicationDirPath()+"/plugins"); diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 7071e25..14bb7c6 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -7,5 +7,5 @@ add_subdirectory(webposter) add_subdirectory(registredapps) add_subdirectory(snarlnetwork) add_subdirectory(snarl) -add_subdirectory(dbusbinding) +#add_subdirectory(dbusbinding) diff --git a/src/plugins/snarl/snarl_backend.cpp b/src/plugins/snarl/snarl_backend.cpp index 5cc83dc..587c194 100644 --- a/src/plugins/snarl/snarl_backend.cpp +++ b/src/plugins/snarl/snarl_backend.cpp @@ -1,5 +1,8 @@ #include "snarl_backend.h" #include +#include +#include + @@ -14,10 +17,14 @@ Snarl_Backend::Snarl_Backend() } + int Snarl_Backend::notify(QSharedPointernotification){ int timeout=notification->timeout>=0?notification->timeout/1000:10; if(notification->id==0){ - return snarlInterface->ShowMessage(notification->title.toLocal8Bit().data(), notification->text.toLocal8Bit().data(),timeout, notification->getIcon().toLocal8Bit().data()); + QString title=Notification::toPlainText(notification->title); + QString text=Notification::toPlainText(notification->text); + qDebug()<<"Calling Snarl"<getIcon(); + return snarlInterface->ShowMessage(title.toLocal8Bit().data(), text.toLocal8Bit().data(),timeout, notification->getIcon().toLocal8Bit().data()); }else{ //update message snarlInterface->UpdateMessage(LONG32(notification->id),notification->title.toLocal8Bit().data(), notification->text.toLocal8Bit().data(),notification->getIcon().toLocal8Bit().data()); diff --git a/src/plugins/snarlnetwork/parser.cpp b/src/plugins/snarlnetwork/parser.cpp index 9d93e68..379bf51 100644 --- a/src/plugins/snarlnetwork/parser.cpp +++ b/src/plugins/snarlnetwork/parser.cpp @@ -8,6 +8,7 @@ #include #include #include +#include Parser::Parser(SnarlNetworkFrontend *snarl):snarl(snarl) { @@ -68,7 +69,7 @@ Parser::Parser(SnarlNetworkFrontend *snarl):snarl(snarl) sNotification.notification->text=value; break; case ICON: - sNotification.notification->setIcon(download(value)); + sNotification.notification->setIcon(downloadIcon(value)); break; case CLASS: sNotification.notification->alert=value; @@ -117,7 +118,7 @@ Parser::Parser(SnarlNetworkFrontend *snarl):snarl(snarl) return sNotification; } - QString Parser::download(const QString &address){ + QString Parser::downloadIcon(const QString &address){ if(address=="") return ""; if(address.startsWith("file://")) @@ -132,15 +133,7 @@ Parser::Parser(SnarlNetworkFrontend *snarl):snarl(snarl) if(file.exists()) return filename; - QNetworkAccessManager manager; - QEventLoop loop; - QNetworkRequest request(url); - request.setRawHeader("User-Agent", "SnoreNotify"); - QNetworkReply *reply=manager.get(request); - QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); - - loop.exec(); - + QNetworkReply * reply=download(url); file.open(QIODevice::WriteOnly); file.write(reply->readAll()); @@ -150,5 +143,15 @@ Parser::Parser(SnarlNetworkFrontend *snarl):snarl(snarl) } + QNetworkReply* Parser::download(const QUrl &address){ + QNetworkAccessManager manager; + QEventLoop loop; + QNetworkRequest request(address); + request.setRawHeader("User-Agent", "SnoreNotify"); + QNetworkReply *reply=manager.get(request); + QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); + loop.exec(); + return reply; + } //#include "parser.moc" diff --git a/src/plugins/snarlnetwork/parser.h b/src/plugins/snarlnetwork/parser.h index da34858..6a38d3d 100644 --- a/src/plugins/snarlnetwork/parser.h +++ b/src/plugins/snarlnetwork/parser.h @@ -10,14 +10,17 @@ class Parser{ +public: + static class QNetworkReply* download(const QUrl &address); + public: Parser(class SnarlNetworkFrontend* snarl); - struct SnarlNotification parse(QString &msg,QTcpSocket* client); + struct SnarlNotification parse(QString &msg,class QTcpSocket* client); private: class SnarlNetworkFrontend *snarl; - QString download(const QString &address); + QString downloadIcon(const QString &address); enum snpTypes{ TYPE, APP, diff --git a/src/plugins/snarlnetwork/snarlnetwork.cpp b/src/plugins/snarlnetwork/snarlnetwork.cpp index 0105d15..1a40936 100644 --- a/src/plugins/snarlnetwork/snarlnetwork.cpp +++ b/src/plugins/snarlnetwork/snarlnetwork.cpp @@ -68,6 +68,7 @@ void SnarlNetworkFrontend::clientDisconnecd(){ } void SnarlNetworkFrontend::callback(const SnarlNotification &sn,QString msg){ + notifications.remove(sn.notification->id); if(sn.clientSocket!=NULL&&!msg.isEmpty()){ msg+=QString::number(sn.notification->id); qDebug()<notification){ connect(reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead())); return -1; - } void WebPoster::closeNotification(int id){