QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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
27#define SIP_NO_FILE
28
29class QgsFeedback;
30class QgsHttpExternalStorageStoreTask;
32
34
40class CORE_EXPORT QgsWebDavExternalStorage : public QgsExternalStorage
41{
42 public:
43 QString type() const override;
44
45 QString displayName() const override;
46
47 protected:
48 QgsExternalStorageStoredContent *doStore( const QString &filePath, const QString &url, const QString &authcfg = QString() ) const override;
49
50 QgsExternalStorageFetchedContent *doFetch( const QString &url, const QString &authConfig = QString() ) const override;
51};
52
58class CORE_EXPORT QgsAwsS3ExternalStorage : public QgsExternalStorage
59{
60 public:
61 QString type() const override;
62
63 QString displayName() const override;
64
65 protected:
66 QgsExternalStorageStoredContent *doStore( const QString &filePath, const QString &url, const QString &authcfg = QString() ) const override;
67
68 QgsExternalStorageFetchedContent *doFetch( const QString &url, const QString &authConfig = QString() ) const override;
69};
70
76class QgsHttpExternalStorageStoredContent : public QgsExternalStorageStoredContent
77{
78 Q_OBJECT
79
80 public:
81 QgsHttpExternalStorageStoredContent( const QString &filePath, const QString &url, const QString &authcfg = QString() );
82
83 void cancel() override;
84
85 QString url() const override;
86
87 void store() override;
88
89 void setPrepareRequestHandler( std::function< void( QNetworkRequest &request, QFile *f ) > );
90
91 private:
92 std::function< void( QNetworkRequest &request, QFile *f ) > mPrepareRequestHandler = nullptr;
93 QPointer<QgsHttpExternalStorageStoreTask> mUploadTask;
94 QString mUrl;
95};
96
102class QgsHttpExternalStorageFetchedContent : public QgsExternalStorageFetchedContent
103{
104 Q_OBJECT
105
106 public:
107 QgsHttpExternalStorageFetchedContent( QgsFetchedContent *fetchedContent );
108
109 QString filePath() const override;
110
111 void cancel() override;
112
113 void fetch() override;
114
115 private slots:
116
117 void onFetched();
118
119 private:
120 QPointer<QgsFetchedContent> mFetchedContent;
121};
122
123
129class QgsHttpExternalStorageStoreTask : public QgsTask
130{
131 Q_OBJECT
132
133 public:
134 QgsHttpExternalStorageStoreTask( const QUrl &url, const QString &filePath, const QString &authCfg );
135
136 ~QgsHttpExternalStorageStoreTask() override;
137
138 bool run() override;
139
140 void cancel() override;
141
142 QString errorString() const;
143
144 void setPrepareRequestHandler( std::function< void( QNetworkRequest &request, QFile *f ) > );
145
146 private:
147 std::function< void( QNetworkRequest &request, QFile *f ) > mPrepareRequestHandler = nullptr;
148 const QUrl mUrl;
149 const QString mFilePath;
150 const QString mAuthCfg;
151 std::unique_ptr<QgsFeedback> mFeedback;
152 QString mErrorString;
153};
154
155
157#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.