|
QGroundControl
Ground Control Station for MAVLink Drones
|
File download with progress, decompression, and hash verification. More...
#include <QGCFileDownload.h>
Inheritance diagram for QGCFileDownload:
Collaboration diagram for QGCFileDownload:Public Types | |
| enum class | State { Idle , Downloading , Decompressing , Verifying , Completed , Failed , Cancelled } |
| Current download progress (0.0 to 1.0) More... | |
Public Slots | |
| bool | start (const QString &remoteUrl) |
| bool | start (const QString &remoteUrl, const QGCNetworkHelper::RequestConfig &config) |
| void | cancel () |
| Cancel current download. | |
Signals | |
| void | progressChanged (qreal progress) |
| Emitted when download progress changes. | |
| void | runningChanged (bool running) |
| Emitted when running state changes. | |
| void | errorStringChanged (const QString &errorString) |
| Emitted when error string changes. | |
| void | urlChanged (const QUrl &url) |
| Emitted when URL changes. | |
| void | localPathChanged (const QString &localPath) |
| Emitted when local path changes. | |
| void | totalBytesChanged (qint64 totalBytes) |
| Emitted when total bytes changes. | |
| void | bytesReceivedChanged (qint64 bytesReceived) |
| Emitted when bytes received changes. | |
| void | autoDecompressChanged (bool autoDecompress) |
| Emitted when auto-decompress setting changes. | |
| void | outputPathChanged (const QString &outputPath) |
| Emitted when output path setting changes. | |
| void | expectedHashChanged (const QString &expectedHash) |
| Emitted when expected hash setting changes. | |
| void | stateChanged (State state) |
| Emitted when state changes. | |
| void | finished (bool success, const QString &localPath, const QString &errorMessage) |
| void | downloadProgress (qint64 bytesReceived, qint64 totalBytes) |
| Emitted during download with byte counts. | |
| void | decompressionProgress (qreal progress) |
| Emitted during decompression (0.0 to 1.0) | |
Public Member Functions | |
| QGCFileDownload (QObject *parent=nullptr) | |
| ~QGCFileDownload () override | |
| qreal | progress () const |
| bool | isRunning () const |
| QString | errorString () const |
| QUrl | url () const |
| QString | localPath () const |
| qint64 | totalBytes () const |
| qint64 | bytesReceived () const |
| bool | autoDecompress () const |
| QString | outputPath () const |
| QString | expectedHash () const |
| State | state () const |
| bool | lastResultFromCache () const |
| void | setAutoDecompress (bool enabled) |
| void | setOutputPath (const QString &path) |
| void | setExpectedHash (const QString &hash) |
| void | setCache (QAbstractNetworkCache *cache) |
| Set network cache for downloads. | |
| void | setTimeout (int timeoutMs) |
| Set request timeout in milliseconds. | |
| QNetworkAccessManager * | networkManager () const |
| Get the network access manager (for advanced configuration) | |
File download with progress, decompression, and hash verification.
Features:
Example C++ usage:
Example QML usage:
Definition at line 60 of file QGCFileDownload.h.
|
strong |
Current download progress (0.0 to 1.0)
Whether a download is currently in progress Error message from last failed download (empty if successful) Remote URL being downloaded Local file path where download is saved Total bytes to download (-1 if unknown) Bytes downloaded so far Whether to auto-decompress compressed files after download Custom output path (empty = auto-generate in temp directory) Expected SHA-256 hash for verification (empty = skip verification) Download state
Definition at line 97 of file QGCFileDownload.h.
|
explicit |
Definition at line 14 of file QGCFileDownload.cc.
|
override |
Definition at line 21 of file QGCFileDownload.cc.
References cancel().
|
inline |
Definition at line 122 of file QGCFileDownload.h.
|
signal |
Emitted when auto-decompress setting changes.
Referenced by setAutoDecompress().
|
inline |
Definition at line 121 of file QGCFileDownload.h.
|
signal |
Emitted when bytes received changes.
Referenced by start().
|
slot |
Cancel current download.
Definition at line 175 of file QGCFileDownload.cc.
References QGCCompressionJob::cancel(), Cancelled, Completed, Failed, Idle, and QGCCompressionJob::isRunning().
Referenced by QGCCachedFileDownload::cancel(), and ~QGCFileDownload().
|
signal |
Emitted during decompression (0.0 to 1.0)
|
signal |
Emitted during download with byte counts.
Referenced by QGCCachedFileDownload::QGCCachedFileDownload(), and QGCCachedFileDownload::QGCCachedFileDownload().
|
inline |
Definition at line 117 of file QGCFileDownload.h.
Referenced by APMAirframeComponentController::loadParameters().
|
signal |
Emitted when error string changes.
|
inline |
Definition at line 124 of file QGCFileDownload.h.
|
signal |
Emitted when expected hash setting changes.
Referenced by setExpectedHash().
|
signal |
Emitted when download completes (success or failure)
| success | true if download succeeded |
| localPath | Path to downloaded file (empty on failure) |
| errorMessage | Error message (empty on success) |
Referenced by FirmwarePlugin::checkIfIsLatestStable(), APMAirframeComponentController::loadParameters(), QGCCachedFileDownload::QGCCachedFileDownload(), and QGCCachedFileDownload::QGCCachedFileDownload().
|
inline |
Definition at line 113 of file QGCFileDownload.h.
References Decompressing, Downloading, and Verifying.
Referenced by start().
|
inline |
Definition at line 126 of file QGCFileDownload.h.
|
inline |
Definition at line 119 of file QGCFileDownload.h.
|
signal |
Emitted when local path changes.
Referenced by start().
|
inline |
Get the network access manager (for advanced configuration)
Definition at line 140 of file QGCFileDownload.h.
|
inline |
Definition at line 123 of file QGCFileDownload.h.
|
signal |
Emitted when output path setting changes.
Referenced by setOutputPath().
|
inline |
Definition at line 112 of file QGCFileDownload.h.
|
signal |
Emitted when download progress changes.
|
signal |
Emitted when running state changes.
| void QGCFileDownload::setAutoDecompress | ( | bool | enabled | ) |
Definition at line 31 of file QGCFileDownload.cc.
References autoDecompressChanged().
| void QGCFileDownload::setCache | ( | QAbstractNetworkCache * | cache | ) |
Set network cache for downloads.
Definition at line 55 of file QGCFileDownload.cc.
| void QGCFileDownload::setExpectedHash | ( | const QString & | hash | ) |
Definition at line 47 of file QGCFileDownload.cc.
References expectedHashChanged().
| void QGCFileDownload::setOutputPath | ( | const QString & | path | ) |
Definition at line 39 of file QGCFileDownload.cc.
References outputPathChanged().
| void QGCFileDownload::setTimeout | ( | int | timeoutMs | ) |
Set request timeout in milliseconds.
Definition at line 60 of file QGCFileDownload.cc.
|
slot |
Start downloading a file
| remoteUrl | URL or file path to download |
Definition at line 69 of file QGCFileDownload.cc.
References QGCNetworkHelper::RequestConfig::allowRedirects, start(), and QGCNetworkHelper::RequestConfig::timeoutMs.
Referenced by FirmwarePlugin::checkIfIsLatestStable(), APMAirframeComponentController::loadParameters(), and start().
|
slot |
Start downloading a file with custom request configuration
| remoteUrl | URL or file path to download |
| config | Request configuration (timeout, headers, etc.) |
Definition at line 77 of file QGCFileDownload.cc.
References bytesReceivedChanged(), QGCNetworkHelper::createRequest(), Downloading, QGCFileHelper::ensureParentExists(), QGCNetworkHelper::ignoreSslErrorsIfNeeded(), QGCFileHelper::isLocalPath(), isRunning(), localPathChanged(), QGCFileHelper::toLocalPath(), totalBytesChanged(), url(), and urlChanged().
|
inline |
Definition at line 125 of file QGCFileDownload.h.
|
signal |
Emitted when state changes.
|
inline |
Definition at line 120 of file QGCFileDownload.h.
|
signal |
Emitted when total bytes changes.
Referenced by start().
|
inline |
Definition at line 118 of file QGCFileDownload.h.
Referenced by start().
|
signal |
Emitted when URL changes.
Referenced by start().