QGIS API Documentation 3.99.0-Master (21b3aa880ba)
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 "qgsexternalstorage.h"
22#include "qgstaskmanager.h"
23
24#include <QPointer>
25#include <QUrl>
26
27class QgsFeedback;
28class QgsHttpExternalStorageStoreTask;
30
32#define SIP_NO_FILE
33
39class CORE_EXPORT QgsWebDavExternalStorage : public QgsExternalStorage
40{
41 public:
42
43 QString type() const override;
44
45 QString displayName() const override;
46
47 protected:
48
49 QgsExternalStorageStoredContent *doStore( const QString &filePath, const QString &url, const QString &authcfg = QString() ) const override;
50
51 QgsExternalStorageFetchedContent *doFetch( const QString &url, const QString &authConfig = QString() ) const override;
52};
53
59class CORE_EXPORT QgsAwsS3ExternalStorage : public QgsExternalStorage
60{
61 public:
62
63 QString type() const override;
64
65 QString displayName() const override;
66
67 protected:
68
69 QgsExternalStorageStoredContent *doStore( const QString &filePath, const QString &url, const QString &authcfg = QString() ) const override;
70
71 QgsExternalStorageFetchedContent *doFetch( const QString &url, const QString &authConfig = QString() ) const override;
72};
73
79class QgsHttpExternalStorageStoredContent : public QgsExternalStorageStoredContent
80{
81 Q_OBJECT
82
83 public:
84
85 QgsHttpExternalStorageStoredContent( const QString &filePath, const QString &url, const QString &authcfg = QString() );
86
87 void cancel() override;
88
89 QString url() const override;
90
91 void store() override;
92
93 void setPrepareRequestHandler( std::function< void( QNetworkRequest &request, QFile *f ) > );
94
95 private:
96
97 std::function< void( QNetworkRequest &request, QFile *f ) > mPrepareRequestHandler = nullptr;
98 QPointer<QgsHttpExternalStorageStoreTask> mUploadTask;
99 QString mUrl;
100};
101
107class QgsHttpExternalStorageFetchedContent : public QgsExternalStorageFetchedContent
108{
109 Q_OBJECT
110
111 public:
112
113 QgsHttpExternalStorageFetchedContent( QgsFetchedContent *fetchedContent );
114
115 QString filePath() const override;
116
117 void cancel() override;
118
119 void fetch() override;
120
121 private slots:
122
123 void onFetched();
124
125 private:
126
127 QPointer<QgsFetchedContent> mFetchedContent;
128};
129
130
136class QgsHttpExternalStorageStoreTask : public QgsTask
137{
138 Q_OBJECT
139
140 public:
141
142 QgsHttpExternalStorageStoreTask( const QUrl &url, const QString &filePath, const QString &authCfg );
143
144 bool run() override;
145
146 void cancel() override;
147
148 QString errorString() const;
149
150 void setPrepareRequestHandler( std::function< void( QNetworkRequest &request, QFile *f ) > );
151
152 private:
153
154 std::function< void( QNetworkRequest &request, QFile *f ) > mPrepareRequestHandler = nullptr;
155 const QUrl mUrl;
156 const QString mFilePath;
157 const QString mAuthCfg;
158 std::unique_ptr<QgsFeedback> mFeedback;
159 QString mErrorString;
160};
161
162
164#endif // QGSWEBDAVEXTERNALSTORAGE_H
virtual void cancel()
Cancels content fetching/storing.
Abstract base class for QgsExternalStorage fetched content.
virtual QString filePath() const =0
Returns fetched resource file path.
virtual void fetch()=0
Starts fetching.
Abstract base 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
Holds information about fetched network content.
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.