19#ifndef QGSNETWORKCONTENTFETCHERREGISTRY_H
20#define QGSNETWORKCONTENTFETCHERREGISTRY_H
30#include <QNetworkReply>
33#include <QTemporaryFile>
75 QFile *
file()
const {
return mFile.get();}
79 const QString
filePath()
const {
return mFilePath;}
85 QNetworkReply::NetworkError
error()
const {
return mError;}
98 void download(
bool redownload =
false );
114 void errorOccurred( QNetworkReply::NetworkError code,
const QString &errorMsg );
117 void taskCompleted();
121 std::unique_ptr<QTemporaryFile> mFile;
123 QPointer< QgsNetworkContentFetcherTask > mFetchingTask;
125 QNetworkReply::NetworkError mError = QNetworkReply::NoError;
127 QString mErrorString;
169 QFile *
localFile(
const QString &filePathOrUrl );
176 QString
localPath(
const QString &filePathOrUrl );
179 QMap<QString, QgsFetchedContent *> mFileRegistry;
ActionStart
Enum to determine when an operation would begin.
@ Deferred
Do not start immediately the action.
Holds information about fetched network content.
QNetworkReply::NetworkError error() const
Returns the potential error of the download.
~QgsFetchedContent() override
QFile * file() const
Returns a pointer to the local file, or nullptr if the file is not accessible yet.
ContentStatus status() const
Returns the status of the download.
const QString filePath() const
Returns the path to the local file, an empty string if the file is not accessible yet.
void errorOccurred(QNetworkReply::NetworkError code, const QString &errorMsg)
Emitted when an error with code error occurred while processing the request errorMsg is a textual des...
QgsFetchedContent(const QString &url, QTemporaryFile *file=nullptr, ContentStatus status=NotStarted, const QString &authConfig=QString(), const QgsHttpHeaders &headers=QgsHttpHeaders())
Constructs a FetchedContent with pointer to the downloaded file and status of the download.
ContentStatus
Status of fetched content.
@ Finished
Download finished and successful.
@ NotStarted
No download started for such URL.
@ Downloading
Currently downloading.
void fetched()
Emitted when the file is fetched and accessible.
QString authConfig() const
Returns the authentication configuration id use for this fetched content.
QString localPath(const QString &filePathOrUrl)
Returns the path to a local file or to a temporary file previously fetched by the registry.
QgsFetchedContent * fetch(const QString &url, Qgis::ActionStart fetchingMode=Qgis::ActionStart::Deferred, const QString &authConfig=QString(), const QgsHttpHeaders &headers=QgsHttpHeaders())
Initialize a download for the given URL.
QFile * localFile(const QString &filePathOrUrl)
Returns a QFile from a local file or to a temporary file previously fetched by the registry.
QgsNetworkContentFetcherRegistry()=default
Create the registry for temporary downloaded files.