APMRemoteParamsDownloader.h 1.21 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#ifndef APMREMOTEPARAMSCONTROLLER_H
#define APMREMOTEPARAMSCONTROLLER_H

#include <QObject>
#include <QNetworkAccessManager>
#include <QUrl>
#include <QJsonArray>

class QNetworkReply;
class QFile;
class QUrl;

class APMRemoteParamsDownloader : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QString statusText READ statusText)
public:
    explicit APMRemoteParamsDownloader(const QString& file);
    QString statusText() const;
    void refreshParamList();
    void httpParamListFinished();
    void httpFinished();
    void httpReadyRead();
    void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes);
25

26 27 28 29 30 31
private:
    void setStatusText(const QString& text);
    void startFileDownloadRequest();
    void manualListSetup();
    void processDownloadedVersionObject(const QByteArray& listObject);
    void startDownloadingRemoteParams();
32

33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
signals:
    void finished();
private:
    QString m_fileToDownload;
    QString m_statusText;
    QNetworkAccessManager m_networkAccessManager;
    QNetworkReply* m_networkReply;
    QFile* m_downloadedParamFile;

    // the list of needed documents.
    QJsonArray m_documentArray;
    QJsonArray::const_iterator curr;
    QJsonArray::const_iterator end;
};

#endif // APMREMOTEPARAMSCONTROLLER_H