QGIS API Documentation  3.24.2-Tisler (13c1a02865)
qgsexternalstorage.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsexternalstorage.cpp
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 #include "qgsexternalstorage.h"
17 
18 void QgsExternalStorageContent::reportError( const QString &errorMsg )
19 {
21  mErrorString = errorMsg;
23 }
24 
26 {
27  return mStatus;
28 }
29 
31 {
32  return mErrorString;
33 };
34 
35 QgsExternalStorageStoredContent *QgsExternalStorage::store( const QString &filePath, const QString &url, const QString &authCfg, Qgis::ActionStart storingMode ) const
36 {
37  QgsExternalStorageStoredContent *content = doStore( filePath, url, authCfg );
38  if ( storingMode == Qgis::ActionStart::Immediate )
39  content->store();
40 
41  return content;
42 }
43 
44 QgsExternalStorageFetchedContent *QgsExternalStorage::fetch( const QString &url, const QString &authCfg, Qgis::ActionStart fetchingMode ) const
45 {
46  QgsExternalStorageFetchedContent *content = doFetch( url, authCfg );
47  if ( fetchingMode == Qgis::ActionStart::Immediate )
48  content->fetch();
49 
50  return content;
51 }
ContentStatus
Status for fetched or stored content.
Definition: qgis.h:600
@ Failed
Content fetching/storing has failed.
ActionStart
Enum to determine when an operation would begin.
Definition: qgis.h:432
Qgis::ContentStatus mStatus
void reportError(const QString &errorMsg)
Update content according to given errorMsg error message Inherited classes should call this method wh...
void errorOccurred(const QString &errorString)
The signal is emitted when an error occurred.
Qgis::ContentStatus status() const
Returns content status.
const QString & errorString() const
Returns error textual description if an error occurred and status() returns Failed.
Class for QgsExternalStorage fetched content.
virtual void fetch()=0
Starts fetching.
Class for QgsExternalStorage stored content.
virtual void store()=0
Starts storing.
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.
QgsExternalStorageStoredContent * store(const QString &filePath, const QString &url, const QString &authCfg=QString(), Qgis::ActionStart storingMode=Qgis::ActionStart::Deferred) const
Stores file filePath to the url for this project external storage.
QgsExternalStorageFetchedContent * fetch(const QString &url, const QString &authCfg=QString(), Qgis::ActionStart fetchingMode=Qgis::ActionStart::Deferred) const
Fetches file from url for this project external storage.
virtual QgsExternalStorageFetchedContent * doFetch(const QString &url, const QString &authCfg=QString()) const =0
Fetches file from url using authCfg for this project external storage.