QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgshttpexternalstorage_p.h
Go to the documentation of this file.
1/***************************************************************************
2 qgswebdavexternalstorage.h
3 --------------------------------------
4 Date : March 2021
5 Copyright : (C) 2021 by Julien Cabieces
6 Email : julien dot cabieces at oslandia dot 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 QGSWEBDAVEXTERNALSTORAGE_H
17#define QGSWEBDAVEXTERNALSTORAGE_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21#include "qgstaskmanager.h"
22
23#include "qgsexternalstorage.h"
24
25#include <QPointer>
26#include <QUrl>
27
28class QgsFeedback;
29class QgsHttpExternalStorageStoreTask;
31
33#define SIP_NO_FILE
34
40class CORE_EXPORT QgsWebDavExternalStorage : public QgsExternalStorage
41{
42 public:
43
44 QString type() const override;
45
46 QString displayName() const override;
47
48 protected:
49
50 QgsExternalStorageStoredContent *doStore( const QString &filePath, const QString &url, const QString &authcfg = QString() ) const override;
51
52 QgsExternalStorageFetchedContent *doFetch( const QString &url, const QString &authConfig = QString() ) const override;
53};
54
60class CORE_EXPORT QgsAwsS3ExternalStorage : public QgsExternalStorage
61{
62 public:
63
64 QString type() const override;
65
66 QString displayName() const override;
67
68 protected:
69
70 QgsExternalStorageStoredContent *doStore( const QString &filePath, const QString &url, const QString &authcfg = QString() ) const override;
71
72 QgsExternalStorageFetchedContent *doFetch( const QString &url, const QString &authConfig = QString() ) const override;
73};
74
80class QgsHttpExternalStorageStoredContent : public QgsExternalStorageStoredContent
81{
82 Q_OBJECT
83
84 public:
85
86 QgsHttpExternalStorageStoredContent( const QString &filePath, const QString &url, const QString &authcfg = QString() );
87
88 void cancel() override;
89
90 QString url() const override;
91
92 void store() override;
93
94 void setPrepareRequestHandler( std::function< void( QNetworkRequest &request, QFile *f ) > );
95
96 private:
97
98 std::function< void( QNetworkRequest &request, QFile *f ) > mPrepareRequestHandler = nullptr;
99 QPointer<QgsHttpExternalStorageStoreTask> mUploadTask;
100 QString mUrl;
101};
102
108class QgsHttpExternalStorageFetchedContent : public QgsExternalStorageFetchedContent
109{
110 Q_OBJECT
111
112 public:
113
114 QgsHttpExternalStorageFetchedContent( QgsFetchedContent *fetchedContent );
115
116 QString filePath() const override;
117
118 void cancel() override;
119
120 void fetch() override;
121
122 private slots:
123
124 void onFetched();
125
126 private:
127
128 QPointer<QgsFetchedContent> mFetchedContent;
129};
130
131
137class QgsHttpExternalStorageStoreTask : public QgsTask
138{
139 Q_OBJECT
140
141 public:
142
143 QgsHttpExternalStorageStoreTask( const QUrl &url, const QString &filePath, const QString &authCfg );
144
145 bool run() override;
146
147 void cancel() override;
148
149 QString errorString() const;
150
151 void setPrepareRequestHandler( std::function< void( QNetworkRequest &request, QFile *f ) > );
152
153 private:
154
155 std::function< void( QNetworkRequest &request, QFile *f ) > mPrepareRequestHandler = nullptr;
156 const QUrl mUrl;
157 const QString mFilePath;
158 const QString mAuthCfg;
159 std::unique_ptr<QgsFeedback> mFeedback;
160 QString mErrorString;
161};
162
163
165#endif // QGSWEBDAVEXTERNALSTORAGE_H
virtual void cancel()
Cancels content fetching/storing.
Class for QgsExternalStorage fetched content.
virtual QString filePath() const =0
Returns fetched resource file path.
virtual void fetch()=0
Starts fetching.
Class for QgsExternalStorage stored content.
virtual QString url() const =0
Returns stored resource URL.
virtual void store()=0
Starts storing.
Abstract interface for external storage - to be implemented by various backends and registered in Qgs...
virtual QString type() const =0
Unique identifier of the external storage type.
virtual QgsExternalStorageFetchedContent * doFetch(const QString &url, const QString &authCfg=QString()) const =0
Fetches file from url using authCfg for this project external storage.
virtual QgsExternalStorageStoredContent * doStore(const QString &filePath, const QString &url, const QString &authCfg=QString()) const =0
Stores file filePath to the url using authCfg authentication for this project external storage.
virtual QString displayName() const =0
Returns the translated external storage name, which should be used for any user-visible display of th...
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
FetchedContent holds useful information about a network content being fetched.
Abstract base class for long running background tasks.
virtual bool run()=0
Performs the task's operation.
virtual void cancel()
Notifies the task that it should terminate.