2018-04-14 20:44:39 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QNetworkRequest>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
|
|
|
class lcHttpReply : public QThread
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
lcHttpReply(QObject* Parent, const QString& URL);
|
|
|
|
|
2020-03-22 23:44:41 +01:00
|
|
|
void run() override;
|
2018-04-14 20:44:39 +02:00
|
|
|
|
|
|
|
bool error() const
|
|
|
|
{
|
|
|
|
return mError;
|
|
|
|
}
|
|
|
|
|
|
|
|
void abort()
|
|
|
|
{
|
|
|
|
mAbort = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray readAll() const
|
|
|
|
{
|
|
|
|
return mBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool mError;
|
|
|
|
bool mAbort;
|
|
|
|
QByteArray mBuffer;
|
|
|
|
QString mURL;
|
|
|
|
};
|
|
|
|
|
|
|
|
class lcHttpManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
lcHttpManager(QObject* Owner = nullptr);
|
|
|
|
|
|
|
|
lcHttpReply* DownloadFile(const QString& Url);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void DownloadFinished(lcHttpReply* Reply);
|
|
|
|
};
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2018-04-14 20:53:00 +02:00
|
|
|
class lcHttpReply : public QNetworkReply
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
lcHttpReply(QObject* Parent)
|
|
|
|
: QNetworkReply(Parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
2018-04-14 20:44:39 +02:00
|
|
|
|
|
|
|
class lcHttpManager : public QNetworkAccessManager
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
lcHttpManager(QObject* Owner = nullptr);
|
|
|
|
|
|
|
|
lcHttpReply* DownloadFile(const QString& Url);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void DownloadFinished(lcHttpReply* Reply);
|
|
|
|
|
|
|
|
protected slots:
|
|
|
|
void Finished(QNetworkReply* Reply);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|