QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgscplhttpfetchoverrider.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscplhttpfetchoverrider.h
3 --------------------------
4 begin : September 2020
5 copyright : (C) 2020 by Even Rouault
6 email : even.rouault at spatialys.com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSCPLHTTPFETCHOVERRIDER_H
17#define QGSCPLHTTPFETCHOVERRIDER_H
18
19#define SIP_NO_FILE
20
21#include <QNetworkRequest>
22#include <QString>
23#include <QPointer>
24#include "qgsnetworkaccessmanager.h" // for QgsSetRequestInitiatorClass
25
26#include "cpl_http.h"
27#include "gdal.h"
28
29class QgsFeedback;
30
31#ifndef SIP_RUN
32#define QgsSetCPLHTTPFetchOverriderInitiatorClass(overrider, _class) QgsSetRequestInitiatorClass((overrider), _class)
33#endif
34
46{
47 public:
49 explicit QgsCPLHTTPFetchOverrider( const QString &authCfg = QString(), QgsFeedback *feedback = nullptr );
50
53
55 void setAttribute( QNetworkRequest::Attribute code, const QVariant &value );
56
62 void setFeedback( QgsFeedback *feedback );
63
69 QThread *thread() const;
70
71 private:
72
73#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,2,0)
74 static CPLHTTPResult *callback( const char *pszURL,
75 CSLConstList papszOptions,
76 GDALProgressFunc pfnProgress,
77 void *pProgressArg,
78 CPLHTTPFetchWriteFunc pfnWrite,
79 void *pWriteArg,
80 void *pUserData );
81#endif
82
83 QString mAuthCfg;
84
85 QgsFeedback *mFeedback = nullptr;
86
87 QPointer< QThread > mThread;
88
89 std::map<QNetworkRequest::Attribute, QVariant> mAttributes;
90};
91
92#endif // QGSCPLHTTPFETCHOVERRIDER_H
Utility class to redirect GDAL's CPL HTTP calls through QgsBlockingNetworkRequest.
void setAttribute(QNetworkRequest::Attribute code, const QVariant &value)
Define attribute that must be forwarded to the actual QNetworkRequest.
QThread * thread() const
Returns the thread associated with the overrider.
void setFeedback(QgsFeedback *feedback)
Sets the feedback cancellation object for the redirection.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:45