QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
28 class QgsFeedback;
29 class QgsWebDAVExternalStorageStoreTask;
30 class QgsFetchedContent;
31 
33 #define SIP_NO_FILE
34 
41 class 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 
62 class 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 
88 class 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 
118 class 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
QgsExternalStorage::doFetch
virtual QgsExternalStorageFetchedContent * doFetch(const QString &url, const QString &authCfg=QString()) const =0
Fetches file from url using authCfg for this project external storage.
QgsExternalStorageFetchedContent
Class for QgsExternalStorage fetched content.
Definition: qgsexternalstorage.h:170
qgstaskmanager.h
QgsExternalStorage::displayName
virtual QString displayName() const =0
Returns the translated external storage name, which should be used for any user-visible display of th...
QgsExternalStorageFetchedContent::filePath
virtual QString filePath() const =0
Returns fetched resource file path.
QgsTask::cancel
virtual void cancel()
Notifies the task that it should terminate.
Definition: qgstaskmanager.cpp:91
QgsExternalStorage::doStore
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.
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
qgsexternalstorage.h
qgis_sip.h
QgsFetchedContent
FetchedContent holds useful information about a network content being fetched.
Definition: qgsnetworkcontentfetcherregistry.h:40
QgsExternalStorageStoredContent
Class for QgsExternalStorage stored content.
Definition: qgsexternalstorage.h:200
QgsExternalStorageStoredContent::store
virtual void store()=0
Starts storing.
QgsExternalStorageStoredContent::url
virtual QString url() const =0
Returns stored resource URL.
QgsExternalStorage
Abstract interface for external storage - to be implemented by various backends and registered in Qgs...
Definition: qgsexternalstorage.h:36
QgsExternalStorageFetchedContent::fetch
virtual void fetch()=0
Starts fetching.
QgsTask::run
virtual bool run()=0
Performs the task's operation.
QgsExternalStorage::type
virtual QString type() const =0
Unique identifier of the external storage type.
QgsExternalStorageContent::cancel
virtual void cancel()
Cancels content fetching/storing.
Definition: qgsexternalstorage.h:132
QgsTask
Abstract base class for long running background tasks. Tasks can be controlled directly,...
Definition: qgstaskmanager.h:54