ScummVM API documentation
Cloud::Storage Class Referenceabstract
Inheritance diagram for Cloud::Storage:
Cloud::BaseStorage Cloud::Dropbox::DropboxStorage Cloud::Id::IdStorage Cloud::OneDrive::OneDriveStorage Cloud::Box::BoxStorage Cloud::GoogleDrive::GoogleDriveStorage

Classes

struct  SyncDownloadingInfo
 

Public Types

typedef Networking::Response< const Common::Array< StorageFile > & > FileArrayResponse
 
typedef Networking::Response< const StorageInfo & > StorageInfoResponse
 
typedef Networking::Response< bool > BoolResponse
 
typedef Networking::Response< const StorageFile & > UploadResponse
 
typedef Networking::Response< const Common::Array< StorageFile > & > ListDirectoryResponse
 
typedef Common::BaseCallback< const FileArrayResponse & > * FileArrayCallback
 
typedef Common::BaseCallback< const StorageInfoResponse & > * StorageInfoCallback
 
typedef Common::BaseCallback< const BoolResponse & > * BoolCallback
 
typedef Common::BaseCallback< const UploadResponse & > * UploadCallback
 
typedef Common::BaseCallback< const ListDirectoryResponse & > * ListDirectoryCallback
 

Public Member Functions

virtual void saveConfig (const Common::String &keyPrefix)=0
 
virtual Common::String name () const =0
 
bool isEnabled () const
 
void enable ()
 
virtual Networking::RequestlistDirectory (const Common::String &path, ListDirectoryCallback callback, Networking::ErrorCallback errorCallback, bool recursive=false)=0
 
virtual Networking::Requestupload (const Common::String &path, Common::SeekableReadStream *contents, UploadCallback callback, Networking::ErrorCallback errorCallback)=0
 
virtual Networking::Requestupload (const Common::String &remotePath, const Common::Path &localPath, UploadCallback callback, Networking::ErrorCallback errorCallback)
 
virtual bool uploadStreamSupported ()
 
virtual Networking::RequeststreamFile (const Common::String &path, Networking::NetworkReadStreamCallback callback, Networking::ErrorCallback errorCallback)
 
virtual Networking::RequeststreamFileById (const Common::String &id, Networking::NetworkReadStreamCallback callback, Networking::ErrorCallback errorCallback)=0
 
virtual Networking::Requestdownload (const Common::String &remotePath, const Common::Path &localPath, BoolCallback callback, Networking::ErrorCallback errorCallback)
 
virtual Networking::RequestdownloadById (const Common::String &remoteId, const Common::Path &localPath, BoolCallback callback, Networking::ErrorCallback errorCallback)
 
virtual Networking::RequestdownloadFolder (const Common::String &remotePath, const Common::Path &localPath, FileArrayCallback callback, Networking::ErrorCallback errorCallback, bool recursive=false)
 
virtual SavesSyncRequestsyncSaves (BoolCallback callback, Networking::ErrorCallback errorCallback)
 
virtual Networking::RequestcreateDirectory (const Common::String &path, BoolCallback callback, Networking::ErrorCallback errorCallback)=0
 
virtual Networking::Requestinfo (StorageInfoCallback callback, Networking::ErrorCallback errorCallback)=0
 
virtual Common::String savesDirectoryPath ()=0
 
virtual bool isWorking ()
 
virtual bool isSyncing ()
 
virtual double getSyncDownloadingProgress ()
 
virtual void getSyncDownloadingInfo (SyncDownloadingInfo &info)
 
virtual double getSyncProgress ()
 
virtual Common::Array< Common::StringgetSyncingFiles ()
 
virtual void cancelSync ()
 
virtual bool startDownload (const Common::String &remotePath, const Common::Path &localPath)
 
virtual void cancelDownload ()
 
virtual void setDownloadTarget (GUI::CommandReceiver *target)
 
virtual bool isDownloading ()
 
virtual double getDownloadingProgress ()
 
virtual uint64 getDownloadBytesNumber ()
 
virtual uint64 getDownloadTotalBytesNumber ()
 
virtual uint64 getDownloadSpeed ()
 
virtual Common::String getDownloadRemoteDirectory ()
 
virtual Common::Path getDownloadLocalDirectory ()
 

Protected Member Functions

virtual Networking::ErrorCallback getErrorPrintingCallback ()
 
virtual void printErrorResponse (const Networking::ErrorResponse &error)
 
virtual Networking::RequestaddRequest (Networking::Request *request)
 
virtual void requestFinishedCallback (Networking::Request *invalidRequestPointer)
 
virtual void savesSyncDefaultCallback (const BoolResponse &response)
 
virtual void savesSyncDefaultErrorCallback (const Networking::ErrorResponse &error)
 
virtual void directoryDownloadedCallback (const FileArrayResponse &response)
 
virtual void directoryDownloadedErrorCallback (const Networking::ErrorResponse &error)
 

Protected Attributes

uint32 _runningRequestsCount
 
Common::Mutex _runningRequestsMutex
 
SavesSyncRequest_savesSyncRequest
 
bool _syncRestartRequestsed
 
FolderDownloadRequest_downloadFolderRequest
 
bool _isEnabled
 

Member Function Documentation

◆ getErrorPrintingCallback()

virtual Networking::ErrorCallback Cloud::Storage::getErrorPrintingCallback ( )
protectedvirtual

Returns default error callback (printErrorResponse).

◆ printErrorResponse()

virtual void Cloud::Storage::printErrorResponse ( const Networking::ErrorResponse error)
protectedvirtual

Prints ErrorResponse contents with debug().

◆ addRequest()

virtual Networking::Request* Cloud::Storage::addRequest ( Networking::Request request)
protectedvirtual

Adds request to the ConnMan, but also increases _runningRequestsCount. This method should be used by Storage implementations instead of direct ConnMan.addRequest() call.

Returns
the same Request pointer, just as a shortcut

◆ requestFinishedCallback()

virtual void Cloud::Storage::requestFinishedCallback ( Networking::Request invalidRequestPointer)
protectedvirtual

Decreases _runningRequestCount. It's called from ConnMan automatically. Passed pointer is dangling, but one can use the address to determine some special Requests (which addresses were remembered somewhere).

◆ saveConfig()

virtual void Cloud::Storage::saveConfig ( const Common::String keyPrefix)
pure virtual

Storage methods, which are used by CloudManager to save storage in configuration file. Save storage data using ConfMan.

Parameters
keyPrefixall saved keys must start with this prefix.
Note
every Storage must write keyPrefix + "type" key with common value (e.g. "Dropbox").

Implemented in Cloud::GoogleDrive::GoogleDriveStorage, Cloud::Box::BoxStorage, Cloud::OneDrive::OneDriveStorage, and Cloud::Dropbox::DropboxStorage.

◆ name()

virtual Common::String Cloud::Storage::name ( ) const
pure virtual

Return unique storage name.

Returns
some unique storage name (for example, "Dropbox (user@example.com)")

Implemented in Cloud::GoogleDrive::GoogleDriveStorage, Cloud::Box::BoxStorage, Cloud::OneDrive::OneDriveStorage, and Cloud::Dropbox::DropboxStorage.

◆ isEnabled()

bool Cloud::Storage::isEnabled ( ) const

Return whether Storage has been manually enabled by user.

◆ enable()

void Cloud::Storage::enable ( )

Set _isEnabled to true.

◆ listDirectory()

virtual Networking::Request* Cloud::Storage::listDirectory ( const Common::String path,
ListDirectoryCallback  callback,
Networking::ErrorCallback  errorCallback,
bool  recursive = false 
)
pure virtual

Public Cloud API comes down there.

All Cloud API methods return Networking::Request *, which might be used to control request. All methods also accept a callback, which is called, when request is complete.Returns ListDirectoryResponse with list of files.

Implemented in Cloud::OneDrive::OneDriveStorage, Cloud::Dropbox::DropboxStorage, and Cloud::Id::IdStorage.

◆ upload()

virtual Networking::Request* Cloud::Storage::upload ( const Common::String path,
Common::SeekableReadStream contents,
UploadCallback  callback,
Networking::ErrorCallback  errorCallback 
)
pure virtual

◆ uploadStreamSupported()

virtual bool Cloud::Storage::uploadStreamSupported ( )
virtual

Returns whether Storage supports upload(ReadStream).

Reimplemented in Cloud::Box::BoxStorage.

◆ streamFile()

virtual Networking::Request* Cloud::Storage::streamFile ( const Common::String path,
Networking::NetworkReadStreamCallback  callback,
Networking::ErrorCallback  errorCallback 
)
virtual

Returns pointer to Networking::NetworkReadStream.

Reimplemented in Cloud::Id::IdStorage.

◆ download()

virtual Networking::Request* Cloud::Storage::download ( const Common::String remotePath,
const Common::Path localPath,
BoolCallback  callback,
Networking::ErrorCallback  errorCallback 
)
virtual

Calls the callback when finished.

Reimplemented in Cloud::Id::IdStorage.

◆ downloadFolder()

virtual Networking::Request* Cloud::Storage::downloadFolder ( const Common::String remotePath,
const Common::Path localPath,
FileArrayCallback  callback,
Networking::ErrorCallback  errorCallback,
bool  recursive = false 
)
virtual

Returns Common::Array<StorageFile> with list of files, which were not downloaded.

◆ syncSaves()

virtual SavesSyncRequest* Cloud::Storage::syncSaves ( BoolCallback  callback,
Networking::ErrorCallback  errorCallback 
)
virtual

Calls the callback when finished.

◆ createDirectory()

virtual Networking::Request* Cloud::Storage::createDirectory ( const Common::String path,
BoolCallback  callback,
Networking::ErrorCallback  errorCallback 
)
pure virtual

Calls the callback when finished.

Implemented in Cloud::OneDrive::OneDriveStorage, Cloud::Dropbox::DropboxStorage, and Cloud::Id::IdStorage.

◆ info()

virtual Networking::Request* Cloud::Storage::info ( StorageInfoCallback  callback,
Networking::ErrorCallback  errorCallback 
)
pure virtual

Returns the StorageInfo struct via <callback>. Calls the <errorCallback> if failed to get information.

Note
on success Storage should also call CloudMan.setStorageUsername().

Implemented in Cloud::GoogleDrive::GoogleDriveStorage, Cloud::Box::BoxStorage, Cloud::OneDrive::OneDriveStorage, and Cloud::Dropbox::DropboxStorage.

◆ savesDirectoryPath()

virtual Common::String Cloud::Storage::savesDirectoryPath ( )
pure virtual

Returns storage's saves directory path with the trailing slash.

Implemented in Cloud::GoogleDrive::GoogleDriveStorage, Cloud::Box::BoxStorage, Cloud::OneDrive::OneDriveStorage, and Cloud::Dropbox::DropboxStorage.

◆ isWorking()

virtual bool Cloud::Storage::isWorking ( )
virtual

Returns whether there are any requests running.

◆ isSyncing()

virtual bool Cloud::Storage::isSyncing ( )
virtual

Returns whether there is a SavesSyncRequest running.

◆ getSyncDownloadingProgress()

virtual double Cloud::Storage::getSyncDownloadingProgress ( )
virtual

Returns a number in [0, 1] range which represents current sync downloading progress (1 = complete).

◆ getSyncDownloadingInfo()

virtual void Cloud::Storage::getSyncDownloadingInfo ( SyncDownloadingInfo info)
virtual

Fills a struct with numbers about current sync downloading progress.

◆ getSyncProgress()

virtual double Cloud::Storage::getSyncProgress ( )
virtual

Returns a number in [0, 1] range which represents current sync progress (1 = complete).

◆ getSyncingFiles()

virtual Common::Array<Common::String> Cloud::Storage::getSyncingFiles ( )
virtual

Returns an array of saves names which are not yet synced (thus cannot be used).

◆ cancelSync()

virtual void Cloud::Storage::cancelSync ( )
virtual

Cancels running sync.

◆ savesSyncDefaultCallback()

virtual void Cloud::Storage::savesSyncDefaultCallback ( const BoolResponse response)
protectedvirtual

Finishes the sync. Shows an OSD message.

◆ savesSyncDefaultErrorCallback()

virtual void Cloud::Storage::savesSyncDefaultErrorCallback ( const Networking::ErrorResponse error)
protectedvirtual

Finishes the sync. Shows an OSD message.

◆ startDownload()

virtual bool Cloud::Storage::startDownload ( const Common::String remotePath,
const Common::Path localPath 
)
virtual

Starts a folder download.

◆ cancelDownload()

virtual void Cloud::Storage::cancelDownload ( )
virtual

Cancels running download.

◆ setDownloadTarget()

virtual void Cloud::Storage::setDownloadTarget ( GUI::CommandReceiver target)
virtual

Sets FolderDownloadRequest's target to given CommandReceiver.

◆ isDownloading()

virtual bool Cloud::Storage::isDownloading ( )
virtual

Returns whether there is a FolderDownloadRequest running.

◆ getDownloadingProgress()

virtual double Cloud::Storage::getDownloadingProgress ( )
virtual

Returns a number in [0, 1] range which represents current download progress (1 = complete).

◆ getDownloadBytesNumber()

virtual uint64 Cloud::Storage::getDownloadBytesNumber ( )
virtual

Returns a number of bytes that is downloaded in current download progress.

◆ getDownloadTotalBytesNumber()

virtual uint64 Cloud::Storage::getDownloadTotalBytesNumber ( )
virtual

Returns a total number of bytes to be downloaded in current download progress.

◆ getDownloadSpeed()

virtual uint64 Cloud::Storage::getDownloadSpeed ( )
virtual

Returns download speed of current download progress.

◆ getDownloadRemoteDirectory()

virtual Common::String Cloud::Storage::getDownloadRemoteDirectory ( )
virtual

Returns remote directory path.

◆ getDownloadLocalDirectory()

virtual Common::Path Cloud::Storage::getDownloadLocalDirectory ( )
virtual

Returns local directory path.

◆ directoryDownloadedCallback()

virtual void Cloud::Storage::directoryDownloadedCallback ( const FileArrayResponse response)
protectedvirtual

Finishes the download. Shows an OSD message.

◆ directoryDownloadedErrorCallback()

virtual void Cloud::Storage::directoryDownloadedErrorCallback ( const Networking::ErrorResponse error)
protectedvirtual

Finishes the download. Shows an OSD message.

Member Data Documentation

◆ _runningRequestsCount

uint32 Cloud::Storage::_runningRequestsCount
protected

Keeps track of running requests.

◆ _savesSyncRequest

SavesSyncRequest* Cloud::Storage::_savesSyncRequest
protected

SavesSyncRequest-related

◆ _downloadFolderRequest

FolderDownloadRequest* Cloud::Storage::_downloadFolderRequest
protected

FolderDownloadRequest-related

◆ _isEnabled

bool Cloud::Storage::_isEnabled
protected

Whether user manually enabled the Storage.


The documentation for this class was generated from the following file: