some cleaning up
This commit is contained in:
parent
18adeb0326
commit
7fde21d496
|
@ -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"
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
|
||||
|
||||
|
||||
class Parser{
|
||||
class Parser:public QObject{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static class QByteArray download(const QUrl &address);
|
||||
|
||||
|
|
|
@ -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<QTcpSocket*>(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;
|
||||
|
|
|
@ -30,7 +30,7 @@ private slots:
|
|||
|
||||
private:
|
||||
class QTcpServer *tcpServer;
|
||||
Parser parser;
|
||||
Parser *parser;
|
||||
QHash<int,SnarlNotification> notifications;
|
||||
|
||||
void callback(const SnarlNotification &sn,QString msg);
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
#include "webposter.h"
|
||||
#include <QDebug>
|
||||
#include <QtCore>
|
||||
#include <iostream>
|
||||
Q_EXPORT_PLUGIN2(webposter,WebPoster)
|
||||
|
||||
WebPoster::WebPoster():manager(new QNetworkAccessManager(this)){
|
||||
WebPoster::WebPoster(){
|
||||
setProperty("name","WebPoster");
|
||||
manager=new QNetworkAccessManager(this);
|
||||
}
|
||||
|
||||
int WebPoster::notify(QSharedPointer<Notification>notification){
|
||||
|
@ -15,23 +17,19 @@ int WebPoster::notify(QSharedPointer<Notification>notification){
|
|||
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"<<reply->readAll().data()<<std::endl;
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
void WebPoster::closeNotification(int id){
|
||||
//not supportted
|
||||
//not supportted
|
||||
}
|
||||
|
||||
void WebPoster::slotReadyRead(){
|
||||
QNetworkReply *reply=qobject_cast<QNetworkReply*>(sender());
|
||||
qDebug()<<reply->url();
|
||||
qDebug()<<reply->readAll();
|
||||
if(reply->errorString()!="Unknown error")
|
||||
qWarning()<<reply->errorString();
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "webposter.moc"
|
||||
|
|
|
@ -18,8 +18,7 @@ public slots:
|
|||
|
||||
private:
|
||||
QNetworkAccessManager *manager;
|
||||
public slots:
|
||||
void slotReadyRead();
|
||||
|
||||
|
||||
};
|
||||
#endif//WEBPOSTER_H
|
||||
|
|
Loading…
Reference in New Issue