QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgswebdavexternalstorage_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
24
25#include <QPointer>
26#include <QUrl>
27
28class QgsFeedback;
29class QgsWebDAVExternalStorageStoreTask;
31
33#define SIP_NO_FILE
34
41class CORE_EXPORT QgsWebDAVExternalStorage : public QgsExternalStorage
42{
43 public:
44
45 QString type() const override;
46
47 QString displayName() const override;
48
49 protected:
50
51 QgsExternalStorageStoredContent *doStore( const QString &filePath, const QString &url, const QString &authcfg = QString() ) const override;
52
53 QgsExternalStorageFetchedContent *doFetch( const QString &url, const QString &authConfig = QString() ) const override;
54};
55
62class QgsWebDAVExternalStorageStoredContent : public QgsExternalStorageStoredContent
63{
64 Q_OBJECT
65
66 public:
67
68 QgsWebDAVExternalStorageStoredContent( const QString &filePath, const QString &url, const QString &authcfg = QString() );
69
70 void cancel() override;
71
72 QString url() const override;
73
74 void store() override;
75
76 private:
77
78 QPointer<QgsWebDAVExternalStorageStoreTask> mUploadTask;
79 QString mUrl;
80};
81
88class QgsWebDAVExternalStorageFetchedContent : public QgsExternalStorageFetchedContent
89{
90 Q_OBJECT
91
92 public:
93
94 QgsWebDAVExternalStorageFetchedContent( QgsFetchedContent *fetchedContent );
95
96 QString filePath() const override;
97
98 void cancel() override;
99
100 void fetch() override;
101
102 private slots:
103
104 void onFetched();
105
106 private:
107
108 QPointer<QgsFetchedContent> mFetchedContent;
109};
110
111
118class QgsWebDAVExternalStorageStoreTask : public QgsTask
119{
120 Q_OBJECT
121
122 public:
123
124 QgsWebDAVExternalStorageStoreTask( const QUrl &url, const QString &filePath, const QString &authCfg );
125
126 bool run() override;
127
128 void cancel() override;
129
130 QString errorString() const;
131
132 private:
133
134 const QUrl mUrl;
135 const QString mFilePath;
136 const QString mAuthCfg;
137 std::unique_ptr<QgsFeedback> mFeedback;
138 QString mErrorString;
139};
140
141
143#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:45
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.