1#ifndef OSMSCOUT_CLIENT_QT_FILEDOWNLOADER_H
2#define OSMSCOUT_CLIENT_QT_FILEDOWNLOADER_H
25#include <QNetworkAccessManager>
26#include <QNetworkReply>
61#ifdef OSMSCOUT_CLIENT_QT_FILEDOWNLOADER_TEST
68 int downloadRetries{0};
73 bool scheduleRestart();
79 QNetworkAccessManager *manager;
83 QNetworkReply *reply{
nullptr};
88 bool finishedSuccessfully{
false};
90 uint64_t downloaded{0};
98 QObject *parent =
nullptr);
101 explicit operator bool()
const {
return isOk; }
102 QString
getFileName()
const {
return QFileInfo(path).fileName(); }
110 void error(QString error_text,
bool recoverable);
175 void start(
const QString &serverBasePath,
const QStringList &files);
#define OSMSCOUT_CLIENT_QT_API
Definition ClientQtImportExport.h:45
QString getError() const
Definition FileDownloader.h:202
DownloadJob(const DownloadJob &)=delete
QList< FileDownloader * > jobs
Definition FileDownloader.h:137
bool isSuccessful() const
Definition FileDownloader.h:192
bool isReplaceExisting() const
Definition FileDownloader.h:207
DownloadJob(QNetworkAccessManager *webCtrl, QDir target, bool replaceExisting)
QNetworkAccessManager * webCtrl
Definition FileDownloader.h:138
void onJobFailed(QString errorMessage, bool recoverable)
bool done
Definition FileDownloader.h:142
QString getDownloadingFile()
bool isDone() const
Definition FileDownloader.h:187
QString error
Definition FileDownloader.h:149
DownloadJob & operator=(const DownloadJob &)=delete
void onJobFinished(QString path)
bool isDownloading() const
Definition FileDownloader.h:197
DownloadJob & operator==(const DownloadJob &&)=delete
bool successful
Definition FileDownloader.h:144
QDir getDestinationDirectory() const
Definition FileDownloader.h:212
bool started
Definition FileDownloader.h:143
QDir target
Definition FileDownloader.h:140
void failed(QString error)
DownloadJob(DownloadJob &&)=delete
void start(const QString &serverBasePath, const QStringList &files)
uint64_t downloadedBytes
Definition FileDownloader.h:147
bool canceledByUser
Definition FileDownloader.h:145
virtual uint64_t expectedSize() const =0
void onDownloadProgress(uint64_t)
bool replaceExisting
Definition FileDownloader.h:151
void onNetworkReadyRead()
void writtenBytes(uint64_t sz)
void finished(QString path)
void error(QString error_text, bool recoverable)
~FileDownloader() override
void onNetworkError(QNetworkReply::NetworkError code)
FileDownloader(QNetworkAccessManager *manager, QString url, QString path, QObject *parent=nullptr)
uint64_t getBytesDownloaded() const
void downloadedBytes(uint64_t sz)
QString getFilePath() const
Definition FileDownloader.h:103
void onError(const QString &err)
bool restartDownload()
Restart download if download retries are not used up.
QString getFileName() const
Definition FileDownloader.h:102
Definition FileDownloader.h:42
static constexpr std::chrono::seconds DownloadReadTimeout
Download read timeout in seconds.
Definition FileDownloader.h:45
static constexpr uint64_t BufferNetwork
Size of network ring buffer.
Definition FileDownloader.h:44
static constexpr std::chrono::seconds BackOffMax
Maximum back-off time.
Definition FileDownloader.h:47
static constexpr char const * TemporaryFileSuffix
suffix of file being downloaded
Definition FileDownloader.h:49
static constexpr int MaxDownloadRetries
Maximal number of download retries before cancelling download.
Definition FileDownloader.h:48
static constexpr std::chrono::seconds BackOffInitial
Initial back-off time.
Definition FileDownloader.h:46