1#ifndef QX_DOWNLOADMANAGER_H
2#define QX_DOWNLOADMANAGER_H
5#include "qx/network/qx_network_export.h"
9#include <QNetworkAccessManager>
10#include <QAuthenticator>
13#include "qx/network/qx-downloadtask.h"
14#include "qx/network/qx-downloadopreport.h"
15#include "qx/network/qx-downloadmanagerreport.h"
19#include "qx/core/qx-cumulation.h"
20#include "qx/io/qx-filestreamwriter.h"
51 enum Status {Initial, Enumerating, Downloading, Aborting, StoppingOnError};
59 std::optional<QCryptographicHash> mHash;
76 static const qint64 PRESUMED_SIZE = 10485760;
77 static const qint64 SIZE_QUERY_TIMEOUT_MS = 500;
80 static inline const QString ERR_TIMEOUT = u
"The data transfer failed to start before the timeout was reached."_s;
81 static inline const QString ERR_CHECKSUM_MISMATCH = u
"The file's contents did not produce the expected checksum."_s;
84 static inline const QString SSL_ERR = u
"The following SSL issues occurred while attempting to download %1"_s;
85 static inline const QString CONTINUE_QUES = u
"Continue downloading?"_s;
86 static inline const QString AUTH_REQUIRED = u
"Authentication is required to connect to %1"_s;
87 static inline const QString PROXY_AUTH_REQUIRED = u
"Authentication is required to connect to the proxy %1"_s;
90 static inline const QString PROMPT_AUTH = u
"Authentication is required for %1"_s;
91 static inline const QString PROMPT_PRESHARED_AUTH = u
"Pre-shared key authentication is required for %1"_s;
92 static inline const QString PROMPT_PROXY_AUTH = u
"Proxy authentication is required for %1"_s;
98 int mEnumerationTimeout;
101 bool mSkipEnumeration;
102 bool mDeletePartials;
123 DownloadManagerReport::Builder mReportBuilder;
132 void startSizeEnumeration();
133 void pushEnumerationsUntilFinished();
137 void startTrueDownloads();
138 void pushDownloadsUntilFinished();
152 int maxSimultaneous()
const;
154 int transferTimeout()
const;
155 int enumerationTimeout()
const;
156 bool isOverwrite()
const;
157 bool isStopOnError()
const;
158 bool isSkipEnumeration()
const;
159 bool isDeletePartialDownloads()
const;
161 int taskCount()
const;
162 bool hasTasks()
const;
163 bool isProcessing()
const;
165 void setMaxSimultaneous(
int maxSimultaneous);
168 void setEnumerationTimeout(
int timeout = 500);
169 void setOverwrite(
bool overwrite);
170 void setStopOnError(
bool stopOnError);
171 void setSkipEnumeration(
bool skipEnumeration);
172 void setDeletePartialDownloads(
bool deletePartialDownloads);
186 void readyReadHandler();
187 void downloadProgressHandler(qint64 bytesCurrent, qint64 bytesTotal);
230 int maxSimultaneous()
const;
232 int transferTimeout()
const;
233 int enumerationTimeout()
const;
234 bool isOverwrite()
const;
235 bool isStopOnError()
const;
236 bool isSkipEnumeration()
const;
237 bool isDeletePartialDownloads()
const;
239 int taskCount()
const;
240 bool hasTasks()
const;
241 bool isProcessing()
const;
243 void setMaxSimultaneous(
int maxSimultaneous);
246 void setEnumerationTimeout(
int timeout = 500);
247 void setOverwrite(
bool overwrite);
248 void setStopOnError(
bool stopOnError);
249 void setSkipEnumeration(
bool skipEnumeration);
250 void setDeletePartialDownloads(
bool deletePartialDownloads);
The AsyncDownloadManager class is used to queue and process one or more downloads in an asynchronous ...
Definition qx-downloadmanager.h:45
void downloadProgress(qint64 bytesCurrent)
void preSharedKeyAuthenticationRequired(QString prompt, QSslPreSharedKeyAuthenticator *authenticator)
void finished(Qx::DownloadManagerReport report)
void authenticationRequired(QString prompt, QAuthenticator *authenticator)
void downloadTotalChanged(quint64 bytesTotal)
void sslErrors(Qx::Error errorMsg, bool *ignore)
void proxyAuthenticationRequired(QString prompt, QAuthenticator *authenticator)
void downloadFinished(Qx::DownloadOpReport downloadReport)
The Cumulation template class tracks the sum of multiple key-value components that can be changed ind...
Definition qx-cumulation.h:21
The DownloadManagerReport class details the outcome of processing an AsyncDownloadManager or SyncDown...
Definition qx-downloadmanagerreport.h:23
The DownloadOpReport class details the result of a single file download.
Definition qx-downloadopreport.h:17
The Error class acts as an interface for an extensible variety of error objects.
Definition qx-error.h:38
The FileStreamWriter class is a specialized wrapper for QDataStream that narrows and simplifies its u...
Definition qx-filestreamwriter.h:18
The IoOpReport class is a container for details regarding the outcome of an IO operation.
Definition qx-ioopreport.h:53
The SyncDownloadManager class is used to queue and process one or more downloads in a synchronous man...
Definition qx-downloadmanager.h:213
void downloadProgress(qint64 bytesCurrent)
void downloadTotalChanged(quint64 bytesTotal)
void proxyAuthenticationRequired(QString prompt, QAuthenticator *authenticator)
void preSharedKeyAuthenticationRequired(QString prompt, QSslPreSharedKeyAuthenticator *authenticator)
void sslErrors(Qx::Error errorMsg, bool *ignore)
void downloadFinished(Qx::DownloadOpReport downloadReport)
void authenticationRequired(QString prompt, QAuthenticator *authenticator)
The Qx namespace is the main namespace through which all non-global functionality of the Qx library i...
Definition qx-processwaiter.cpp:5
DefaultTransferTimeoutConstant
The qx-error.h header file provides access to the Error interface.
The DownloadTask struct contains the information necessary to download a file from a URL.
Definition qx-downloadtask.h:14