LibrePCB Developers Documentation
|
This class is used to download a file asynchronously in a separate thread. More...
#include <filedownload.h>
Signals | |
void | fileDownloaded (librepcb::FilePath filepath) |
File successfully downloaded signal (emitted right before finished()) | |
void | zipFileExtracted (librepcb::FilePath directory) |
ZIP file successfully extracted signal (emitted right before finished()) | |
Signals inherited from NetworkRequestBase | |
void | startRequested () |
Internal signal, don't use it from outside. | |
void | progressState (QString state) |
Reply progress / state changed signal. | |
void | progressPercent (int percent) |
Reply content download progress signal (simple) | |
void | progress (qint64 bytesReceived, qint64 bytesTotal, int percent) |
Reply content download progress signal (extended) | |
void | aborted () |
Request aborted signal (emitted right before finished()) | |
void | succeeded () |
Request succeeded signal (emitted right before finished()) | |
void | errored (QString errorMsg) |
Request errored signal (emitted right before finished()) | |
void | finished (bool success) |
Request finished signal. | |
Public Member Functions | |
FileDownload ()=delete | |
FileDownload (const FileDownload &other)=delete | |
FileDownload (const QUrl &url, const FilePath &dest) noexcept | |
Constructor. | |
~FileDownload () noexcept | |
void | setExpectedChecksum (QCryptographicHash::Algorithm algorithm, const QByteArray &checksum) noexcept |
Set the expected checksum of the file to download. | |
void | setZipExtractionDirectory (const FilePath &dir) noexcept |
Set extraction directory of the ZIP file to download. | |
FileDownload & | operator= (const FileDownload &rhs)=delete |
Public Member Functions inherited from NetworkRequestBase | |
NetworkRequestBase ()=delete | |
NetworkRequestBase (const NetworkRequestBase &other)=delete | |
NetworkRequestBase (const QUrl &url, const QByteArray &postData=QByteArray()) noexcept | |
virtual | ~NetworkRequestBase () noexcept |
void | setHeaderField (const QByteArray &name, const QByteArray &value) noexcept |
Set a HTTP header field for the network request. | |
void | setCacheLoadControl (QNetworkRequest::CacheLoadControl value) noexcept |
Set the cache load control attribute. | |
void | setExpectedReplyContentSize (qint64 bytes) noexcept |
Set the expected size of the requested content. | |
void | setMinimumCacheTime (int seconds) noexcept |
Set the minimum time the request should be cached. | |
void | useBrowserUserAgent () noexcept |
Use a typical browser user agent for this request. | |
NetworkRequestBase & | operator= (const NetworkRequestBase &rhs)=delete |
Private Member Functions | |
void | prepareRequest () override |
void | finalizeRequest () override |
void | emitSuccessfullyFinishedSignals (QString contentType) noexcept override |
void | fetchNewData (QIODevice &device) noexcept override |
Private Attributes | |
FilePath | mDestination |
QScopedPointer< QSaveFile > | mFile |
QCryptographicHash::Algorithm | mHashAlgorithm |
QByteArray | mExpectedChecksum |
FilePath | mExtractZipToDir |
Additional Inherited Members | |
Public Slots inherited from NetworkRequestBase | |
void | start () noexcept |
Start downloading the requested content. | |
void | abort () noexcept |
Abort downloading the requested content. | |
Protected Attributes inherited from NetworkRequestBase | |
QUrl | mUrl |
QByteArray | mPostData |
qint64 | mExpectedContentSize |
int | mMinimumCacheTime |
QList< QUrl > | mRedirectedUrls |
QNetworkRequest | mRequest |
std::unique_ptr< QNetworkReply > | mReply |
bool | mStarted |
bool | mAborted |
bool | mErrored |
bool | mFinished |
This class is used to download a file asynchronously in a separate thread.
|
delete |
|
delete |
|
noexcept |
Constructor.
url | The URL to the file to download |
dest | The path to the destination file (must not exist!) |
|
noexcept |
|
noexcept |
Set the expected checksum of the file to download.
If set, the checksum of the downloaded file will be compared with this checksum. If they differ, the file gets removed and an error will be reported.
algorithm | The checksum algorithm to be used |
checksum | The expected checksum of the file to download |
|
noexcept |
Set extraction directory of the ZIP file to download.
If set (and valid), the downloaded file (must be a ZIP!) will be extracted into this directory after downloading it.
dir | Destination directory (may or may not exist) |
|
delete |
|
signal |
File successfully downloaded signal (emitted right before finished())
|
signal |
ZIP file successfully extracted signal (emitted right before finished())
|
overrideprivatevirtual |
|
overrideprivatevirtual |
|
overrideprivatevirtualnoexcept |
Implements NetworkRequestBase.
|
overrideprivatevirtualnoexcept |
Implements NetworkRequestBase.
|
private |
|
private |
|
private |
|
private |
|
private |