| Line | |
|---|
| 1 | #ifndef BNCNETQUERY_H
|
|---|
| 2 | #define BNCNETQUERY_H
|
|---|
| 3 |
|
|---|
| 4 | #include <QtNetwork>
|
|---|
| 5 | #include "bncconst.h"
|
|---|
| 6 |
|
|---|
| 7 | class bncNetQuery : public QObject {
|
|---|
| 8 | Q_OBJECT
|
|---|
| 9 |
|
|---|
| 10 | public:
|
|---|
| 11 | enum queryStatus {init, running, finished, error};
|
|---|
| 12 |
|
|---|
| 13 | bncNetQuery();
|
|---|
| 14 | ~bncNetQuery();
|
|---|
| 15 |
|
|---|
| 16 | void waitForRequestResult(const QUrl& url, QByteArray& outData);
|
|---|
| 17 | void startRequest(const QUrl& url);
|
|---|
| 18 | void waitForReadyRead(QByteArray& outData);
|
|---|
| 19 |
|
|---|
| 20 | queryStatus status() const {return _status;}
|
|---|
| 21 |
|
|---|
| 22 | signals:
|
|---|
| 23 | void newMessage(QByteArray msg, bool showOnScreen);
|
|---|
| 24 |
|
|---|
| 25 | private slots:
|
|---|
| 26 | void slotError(QNetworkReply::NetworkError);
|
|---|
| 27 | void slotReadyRead();
|
|---|
| 28 | void slotFinished();
|
|---|
| 29 |
|
|---|
| 30 | private:
|
|---|
| 31 | void startRequest(const QUrl& url, bool full);
|
|---|
| 32 |
|
|---|
| 33 | QNetworkAccessManager* _manager;
|
|---|
| 34 | QNetworkReply* _reply;
|
|---|
| 35 | QEventLoop* _eventLoop;
|
|---|
| 36 | queryStatus _status;
|
|---|
| 37 | };
|
|---|
| 38 |
|
|---|
| 39 | #endif
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.