From 7fde21d4966218644c3bfa7cebe1fedd7e281455 Mon Sep 17 00:00:00 2001 From: theonering Date: Mon, 1 Mar 2010 20:37:22 +0100 Subject: [PATCH] some cleaning up --- src/plugins/snarlnetwork/parser.cpp | 3 ++- src/plugins/snarlnetwork/parser.h | 3 ++- src/plugins/snarlnetwork/snarlnetwork.cpp | 5 +++-- src/plugins/snarlnetwork/snarlnetwork.h | 2 +- src/plugins/webposter/webposter.cpp | 20 +++++++++----------- src/plugins/webposter/webposter.h | 3 +-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/plugins/snarlnetwork/parser.cpp b/src/plugins/snarlnetwork/parser.cpp index 2f8f1fc..5f8b74d 100644 --- a/src/plugins/snarlnetwork/parser.cpp +++ b/src/plugins/snarlnetwork/parser.cpp @@ -12,6 +12,7 @@ Parser::Parser(SnarlNetworkFrontend *snarl):snarl(snarl) { + setParent(snarl); getSnpType.insert("type",TYPE); getSnpType.insert("app",APP); getSnpType.insert("version",VERSION); @@ -155,4 +156,4 @@ QByteArray Parser::download(const QUrl &address){ return reply->readAll(); } -//#include "parser.moc" +#include "parser.moc" diff --git a/src/plugins/snarlnetwork/parser.h b/src/plugins/snarlnetwork/parser.h index 8e18525..a56ce12 100644 --- a/src/plugins/snarlnetwork/parser.h +++ b/src/plugins/snarlnetwork/parser.h @@ -9,7 +9,8 @@ -class Parser{ +class Parser:public QObject{ + Q_OBJECT public: static class QByteArray download(const QUrl &address); diff --git a/src/plugins/snarlnetwork/snarlnetwork.cpp b/src/plugins/snarlnetwork/snarlnetwork.cpp index 1fee85d..ff67e18 100644 --- a/src/plugins/snarlnetwork/snarlnetwork.cpp +++ b/src/plugins/snarlnetwork/snarlnetwork.cpp @@ -6,7 +6,8 @@ Q_EXPORT_PLUGIN2(snalnetwork,SnarlNetworkFrontend) -SnarlNetworkFrontend::SnarlNetworkFrontend():parser(this){ +SnarlNetworkFrontend::SnarlNetworkFrontend(){ + parser=new Parser(this); setProperty("name","SnarlNetworkFrontend"); tcpServer=new QTcpServer(this); if(!tcpServer->listen(QHostAddress::Any,port)){ @@ -43,7 +44,7 @@ void SnarlNetworkFrontend::handleMessages(){ QTcpSocket *client=qobject_cast(sender()); QStringList incommings(QString::fromUtf8(client->readAll()).split("\r\n")); foreach(QString s,incommings){ - SnarlNotification noti=parser.parse(s,client); + SnarlNotification noti=parser->parse(s,client); notifications.insert(noti.notification->getID(),noti); if(!noti.vailid) continue; diff --git a/src/plugins/snarlnetwork/snarlnetwork.h b/src/plugins/snarlnetwork/snarlnetwork.h index cac231b..3927cfe 100644 --- a/src/plugins/snarlnetwork/snarlnetwork.h +++ b/src/plugins/snarlnetwork/snarlnetwork.h @@ -30,7 +30,7 @@ private slots: private: class QTcpServer *tcpServer; - Parser parser; + Parser *parser; QHash notifications; void callback(const SnarlNotification &sn,QString msg); diff --git a/src/plugins/webposter/webposter.cpp b/src/plugins/webposter/webposter.cpp index 6bc88bc..62f769c 100644 --- a/src/plugins/webposter/webposter.cpp +++ b/src/plugins/webposter/webposter.cpp @@ -1,10 +1,12 @@ #include "webposter.h" #include #include +#include Q_EXPORT_PLUGIN2(webposter,WebPoster) -WebPoster::WebPoster():manager(new QNetworkAccessManager(this)){ +WebPoster::WebPoster(){ setProperty("name","WebPoster"); + manager=new QNetworkAccessManager(this); } int WebPoster::notify(QSharedPointernotification){ @@ -15,23 +17,19 @@ int WebPoster::notify(QSharedPointernotification){ QNetworkRequest request(url); request.setRawHeader("User-Agent", "SnoreNotify"); QNetworkReply *reply=manager->get(request); - connect(reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead())); + QEventLoop loop; + connect(reply, SIGNAL(readyRead()), &loop, SLOT(quit())); + loop.exec(); + std::cout<<"WbPoster"<readAll().data()<(sender()); - qDebug()<url(); - qDebug()<readAll(); - if(reply->errorString()!="Unknown error") - qWarning()<errorString(); - reply->deleteLater(); -} + #include "webposter.moc" diff --git a/src/plugins/webposter/webposter.h b/src/plugins/webposter/webposter.h index c2f420d..56ad734 100644 --- a/src/plugins/webposter/webposter.h +++ b/src/plugins/webposter/webposter.h @@ -18,8 +18,7 @@ public slots: private: QNetworkAccessManager *manager; -public slots: - void slotReadyRead(); + }; #endif//WEBPOSTER_H