Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[External Storage] Define API and implement SimpleCopy backlend (#43882)
* [External Storage] Define API * [External Storage] Add QgsCopyFileTask * [External Storage] Add SimpleCopy backend * change SIP_CONCAT_PARTS to fix compilation * Add ContentStatus enum in Qgis class * Add test for QgsCopyFileTask * Move addTask after signals connect * fix header Co-authored-by: Paul Blottiere <blottiere.paul@gmail.com> * s/store/stores Co-authored-by: Paul Blottiere <blottiere.paul@gmail.com> * s/Fetch/Fetches Co-authored-by: Paul Blottiere <blottiere.paul@gmail.com> * fix typos Co-authored-by: Paul Blottiere <blottiere.paul@gmail.com> * s/authentification/authentication * change comment singleton * use unique_ptr for projectexternalstorage instance * fix cppcheck * Add StartLater / StartImmediately distinction * Add enum ActionStart * s/OnGoing/Running/g * constify externalStorageFromType * Fix SIP Co-authored-by: Paul Blottiere <blottiere.paul@gmail.com>
- Loading branch information
Showing
29 changed files
with
1,771 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
210 changes: 210 additions & 0 deletions
210
python/core/auto_generated/externalstorage/qgsexternalstorage.sip.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/externalstorage/qgsexternalstorage.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
class QgsExternalStorage | ||
{ | ||
%Docstring(signature="appended") | ||
Abstract interface for external storage - to be implemented by various backends | ||
and registered in :py:class:`QgsExternalStorageRegistry`. | ||
|
||
.. versionadded:: 3.22 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsexternalstorage.h" | ||
%End | ||
public: | ||
|
||
virtual ~QgsExternalStorage(); | ||
|
||
virtual QString type() const = 0; | ||
%Docstring | ||
Unique identifier of the external storage type. | ||
%End | ||
|
||
QgsExternalStorageStoredContent *store( const QString &filePath, const QString &url, const QString &authCfg = QString(), Qgis::ActionStart storingMode = Qgis::ActionStart::Deferred ) const /Factory/; | ||
%Docstring | ||
Stores file ``filePath`` to the ``url`` for this project external storage. | ||
Storing process is run in background. | ||
Returns a :py:class:`QgsExternalStorageStoredContent` to follow the status of the stored resource. | ||
|
||
``storingMode`` defines if the download will start immediately or shall be manually triggered | ||
calling :py:func:`QgsExternalStorageStoredContent.store()`. User should use | ||
Qgis.ActionStart.Deferred if he needs to connect the :py:func:`~QgsExternalStorage.stored` signal. | ||
|
||
After using this method, user wait for :py:func:`QgsExternalStorageStoredContent.stored()`, | ||
:py:func:`QgsExternalStorageStoredContent.errorOccurred()` or :py:func:`QgsExternalStorageStoredContent.canceled()` signals. | ||
|
||
It's possible to give ``authCfg`` authentication configuration id in case its needed. | ||
|
||
Caller takes ownership of the returned symbol. | ||
%End | ||
|
||
QgsExternalStorageFetchedContent *fetch( const QString &url, const QString &authCfg = QString(), Qgis::ActionStart fetchingMode = Qgis::ActionStart::Deferred ) const /Factory/; | ||
%Docstring | ||
Fetches file from ``url`` for this project external storage. | ||
Fetching process is run in background. | ||
Returns a :py:class:`QgsExternalStorageFetchedContent` to follow the status of the fetched resource. | ||
|
||
``fetchingMode`` defines if the download will start immediately or shall be manually triggered | ||
calling :py:func:`QgsExternalStorageFetchedContent.fetch()`. User should use | ||
Qgis.ActionStart.Deferred if he needs to connect the :py:func:`~QgsExternalStorage.fetched` signal. | ||
|
||
After using this method, user should wait for :py:func:`QgsExternalStorageStoredContent.fetched()`, | ||
:py:func:`QgsExternalStorageStoredContent.errorOccurred()` or :py:func:`QgsExternalStorageStoredContent.canceled()` signals. | ||
|
||
It's possible to give ``authCfg`` authentication configuration id in case its needed. | ||
%End | ||
|
||
protected: | ||
|
||
virtual QgsExternalStorageStoredContent *doStore( const QString &filePath, const QString &url, const QString &authCfg = QString() ) const = 0 /Factory/; | ||
%Docstring | ||
Stores file ``filePath`` to the ``url`` using ``authCfg`` authentication for this project external storage. | ||
|
||
.. seealso:: :py:func:`QgsExternalStorage.store` | ||
%End | ||
|
||
virtual QgsExternalStorageFetchedContent *doFetch( const QString &url, const QString &authCfg = QString() ) const = 0 /Factory/; | ||
%Docstring | ||
Fetches file from ``url`` using ``authCfg`` for this project external storage. | ||
|
||
.. seealso:: :py:func:`QgsExternalStorage.fetch` | ||
%End | ||
}; | ||
|
||
class QgsExternalStorageContent : QObject | ||
{ | ||
%Docstring(signature="appended") | ||
Base class for QgsExternalStorage stored and fetched content | ||
|
||
.. versionadded:: 3.22 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsexternalstorage.h" | ||
%End | ||
public: | ||
|
||
Qgis::ContentStatus status() const; | ||
%Docstring | ||
Returns content status | ||
%End | ||
|
||
const QString &errorString() const; | ||
%Docstring | ||
Returns error textual description if an error occured and :py:func:`~QgsExternalStorageContent.status` returns Failed | ||
%End | ||
|
||
public slots: | ||
|
||
virtual void cancel(); | ||
%Docstring | ||
Cancels content fetching/storing | ||
%End | ||
signals: | ||
|
||
void errorOccurred( const QString &errorString ); | ||
%Docstring | ||
The signal is emitted when an error occurred. ``errorString`` is a textual description of the error | ||
%End | ||
|
||
void progressChanged( double progress ); | ||
%Docstring | ||
The signal is emitted whenever content fetching/storing estimated progression value ``progress`` has changed. | ||
``progress`` value is between 0 and 100. | ||
%End | ||
|
||
void canceled(); | ||
%Docstring | ||
The signal is emitted when content fetching/storing has been canceled | ||
%End | ||
|
||
protected: | ||
|
||
void reportError( const QString &errorMsg ); | ||
%Docstring | ||
Update content according to given ``errorMsg`` error message | ||
Inherited classes should call this method whenever they meet an error. | ||
%End | ||
|
||
}; | ||
|
||
class QgsExternalStorageFetchedContent : QgsExternalStorageContent | ||
{ | ||
%Docstring(signature="appended") | ||
Class for :py:class:`QgsExternalStorage` fetched content | ||
|
||
.. versionadded:: 3.22 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsexternalstorage.h" | ||
%End | ||
public: | ||
|
||
virtual QString filePath() const = 0; | ||
%Docstring | ||
Returns fetched resource file path | ||
%End | ||
|
||
virtual void fetch() = 0; | ||
%Docstring | ||
Starts fetching | ||
%End | ||
|
||
signals: | ||
|
||
void fetched(); | ||
%Docstring | ||
The signal is emitted when the resource has successfully been fetched | ||
%End | ||
}; | ||
|
||
class QgsExternalStorageStoredContent : QgsExternalStorageContent | ||
{ | ||
%Docstring(signature="appended") | ||
Class for :py:class:`QgsExternalStorage` stored content | ||
|
||
.. versionadded:: 3.22 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsexternalstorage.h" | ||
%End | ||
public: | ||
|
||
virtual QString url() const = 0; | ||
%Docstring | ||
Returns stored resource URL | ||
%End | ||
|
||
virtual void store() = 0; | ||
%Docstring | ||
Starts storing | ||
%End | ||
|
||
signals: | ||
|
||
void stored(); | ||
%Docstring | ||
The signal is emitted when the resource has successfully been stored | ||
%End | ||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/externalstorage/qgsexternalstorage.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
65 changes: 65 additions & 0 deletions
65
python/core/auto_generated/externalstorage/qgsexternalstorageregistry.sip.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/externalstorage/qgsexternalstorageregistry.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
class QgsExternalStorageRegistry | ||
{ | ||
%Docstring(signature="appended") | ||
Registry of external storage backends used by :py:class:`QgsExternalResourceWidget` | ||
|
||
:py:class:`QgsExternalStorageRegistry` is not usually directly created, but rather accessed through | ||
:py:func:`QgsApplication.projectStorageRegistry()`. | ||
|
||
.. versionadded:: 3.22 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsexternalstorageregistry.h" | ||
%End | ||
public: | ||
|
||
QgsExternalStorageRegistry(); | ||
%Docstring | ||
Constructor - creates a registry of external storage backends | ||
%End | ||
|
||
~QgsExternalStorageRegistry(); | ||
|
||
QgsExternalStorage *externalStorageFromType( const QString &type ) const; | ||
%Docstring | ||
Returns external storage implementation if the storage ``type`` matches one. | ||
Returns None otherwise | ||
%End | ||
|
||
QList<QgsExternalStorage *> externalStorages() const; | ||
%Docstring | ||
Returns a list of registered project storage implementations | ||
%End | ||
|
||
void registerExternalStorage( QgsExternalStorage *storage /Transfer/ ); | ||
%Docstring | ||
Registers a ``storage`` backend and takes ownership of it | ||
%End | ||
|
||
void unregisterExternalStorage( QgsExternalStorage *storage ); | ||
%Docstring | ||
Unregisters a ``storage`` backend and destroys its instance | ||
%End | ||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/externalstorage/qgsexternalstorageregistry.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.