1#ifndef BALL_SYSTEM_SIMPLEDOWNLOADER_H
2#define BALL_SYSTEM_SIMPLEDOWNLOADER_H
4#ifndef BALL_DATATYPE_STRING_H
8#include <QtCore/QThread>
11#include <QtNetwork/QNetworkReply>
17 namespace SimpleDownloaderHelper
143 int download_(SimpleDownloaderHelper::HelperThread& thread);
146 unsigned int timeout_;
149 namespace SimpleDownloaderHelper
151 class HelperThread :
public QThread
154 HelperThread(
const QUrl& url, QByteArray* result,
SimpleDownloader* parent);
160 virtual QNetworkReply* getReply_(QNetworkAccessManager* man) = 0;
171 class DLThread :
public HelperThread
174 DLThread(
const QUrl& url, QByteArray* result, SimpleDownloader* parent);
175 DLThread(
const QUrl& url,
const String& path, SimpleDownloader* parent);
178 virtual QNetworkReply* getReply_(QNetworkAccessManager* man);
181 class UPThread :
public HelperThread
184 UPThread(
const QUrl& url,
const QByteArray* data, QByteArray* result, SimpleDownloader* parent);
185 UPThread(
const QUrl& url,
const QByteArray* data,
const String& path, SimpleDownloader* parent);
186 UPThread(
const QUrl& url, QIODevice* file, QByteArray* result, SimpleDownloader* parent);
187 UPThread(
const QUrl& url, QIODevice* file,
const String& path, SimpleDownloader* parent);
190 virtual QNetworkReply* getReply_(QNetworkAccessManager* man);
192 const QByteArray* data_;
196 class BasicHelper :
public QObject
201 BasicHelper(HelperThread* caller, QNetworkReply* reply);
202 virtual ~BasicHelper(){}
205 void error(QNetworkReply::NetworkError error);
207 void sslErrors(
const QList<QSslError>& errors);
209 virtual void finished() = 0;
212 HelperThread* caller_;
213 QNetworkReply* reply_;
216 class DLArrayHelper :
public BasicHelper
221 DLArrayHelper(HelperThread* caller, QNetworkReply* reply, QByteArray* result);
230 class DLHelper :
public BasicHelper
235 DLHelper(HelperThread* caller, QNetworkReply* reply,
const String& path);
SimpleDownloader(const QUrl &url, unsigned int timeout=UINT_MAX)
int uploadStringToFile(const String &data, const String &response)
int uploadFileToBuffer(const String &path, std::vector< char > &response)
int downloadToFile(const String &path)
void setURL(const QUrl &url)
int downloadToBuffer(std::vector< char > &buffer)
const QUrl & getURL() const
void setTimeout(unsigned int timeout)
int uploadStringToBuffer(const String &data, std::vector< char > &response)
int uploadFileToFile(const String &path, const String &response)
void setURL(const String &url)
SimpleDownloader(const String &url, unsigned int timeout=UINT_MAX)