ScummVM API documentation
Cloud::CloudManager Class Reference
Inheritance diagram for Cloud::CloudManager:
Common::Singleton< CloudManager > Common::EventSource Common::NonCopyable

Public Member Functions

void init ()
 
void save ()
 
void replaceStorage (Storage *storage, uint32 index)
 
void removeStorage (Storage *storage)
 
Cloud::StoragegetCurrentStorage () const
 
uint32 getStorageIndex () const
 
Common::StringArray listStorages () const
 
bool switchStorage (uint32 index)
 
Common::String getStorageUsername (uint32 index)
 
uint64 getStorageUsedSpace (uint32 index)
 
Common::String getStorageLastSync (uint32 index)
 
void setStorageUsername (uint32 index, const Common::String &name)
 
void setStorageUsedSpace (uint32 index, uint64 used)
 
void setStorageLastSync (uint32 index, const Common::String &date)
 
void connectStorage (uint32 index, const Common::String &code, Networking::ErrorCallback cb=nullptr)
 
void connectStorage (uint32 index, Networking::JsonResponse codeFlowJson, Networking::ErrorCallback cb=nullptr)
 
bool connectStorage (Networking::JsonResponse codeFlowJson, Networking::ErrorCallback cb=nullptr)
 
void disconnectStorage (uint32 index)
 
Networking::RequestlistDirectory (const Common::String &path, Storage::ListDirectoryCallback callback, Networking::ErrorCallback errorCallback, bool recursive=false)
 
Networking::RequestdownloadFolder (const Common::String &remotePath, const Common::Path &localPath, Storage::FileArrayCallback callback, Networking::ErrorCallback errorCallback, bool recursive=false)
 
Networking::Requestinfo (Storage::StorageInfoCallback callback, Networking::ErrorCallback errorCallback)
 
Common::String savesDirectoryPath ()
 
bool canSyncFilename (const Common::String &filename) const
 
bool isStorageEnabled () const
 
void enableStorage ()
 
SavesSyncRequestsyncSaves (Cloud::Storage::BoolCallback callback=nullptr, Networking::ErrorCallback errorCallback=nullptr)
 
bool isWorking () const
 
bool isSyncing () const
 
double getSyncDownloadingProgress () const
 
void getSyncDownloadingInfo (Storage::SyncDownloadingInfo &info) const
 
double getSyncProgress () const
 
Common::Array< Common::StringgetSyncingFiles () const
 
void cancelSync () const
 
void showCloudDisabledIcon ()
 
bool startDownload (const Common::String &remotePath, const Common::Path &localPath) const
 
void cancelDownload () const
 
void setDownloadTarget (GUI::CommandReceiver *target) const
 
bool isDownloading () const
 
double getDownloadingProgress () const
 
uint64 getDownloadBytesNumber () const
 
uint64 getDownloadTotalBytesNumber () const
 
uint64 getDownloadSpeed () const
 
Common::String getDownloadRemoteDirectory () const
 
Common::Path getDownloadLocalDirectory () const
 
- Public Member Functions inherited from Common::EventSource
virtual bool allowMapping () const
 

Additional Inherited Members

- Static Public Member Functions inherited from Common::Singleton< CloudManager >
static bool hasInstance ()
 
static CloudManager & instance ()
 
static void destroy ()
 
- Protected Types inherited from Common::Singleton< CloudManager >
typedef CloudManager SingletonBaseType
 
- Static Protected Attributes inherited from Common::Singleton< CloudManager >
static CloudManager * _singleton
 

Member Function Documentation

◆ init()

void Cloud::CloudManager::init ( )

Loads all information from configs and creates current Storage instance.

Note
It's called once on startup in scummvm_main().

◆ save()

void Cloud::CloudManager::save ( )

Saves all information into configuration file.

◆ replaceStorage()

void Cloud::CloudManager::replaceStorage ( Storage storage,
uint32  index 
)

Replace active Storage.

Note
this method automatically saves the changes with ConfMan.
Parameters
storageCloud::Storage to replace active storage with.
indexone of Cloud::StorageID enum values to indicate what storage type is replaced.

◆ removeStorage()

void Cloud::CloudManager::removeStorage ( Storage storage)

Adds storage in the list of storages to remove later.

◆ getCurrentStorage()

Cloud::Storage* Cloud::CloudManager::getCurrentStorage ( ) const

Returns active Storage, which could be used to interact with cloud storage.

Returns
active Cloud::Storage or null, if there is no active Storage.

◆ getStorageIndex()

uint32 Cloud::CloudManager::getStorageIndex ( ) const

Return active Storage's index.

Returns
active Storage's index.

◆ listStorages()

Common::StringArray Cloud::CloudManager::listStorages ( ) const

Return Storages names as list.

Returns
a list of Storages names.

◆ switchStorage()

bool Cloud::CloudManager::switchStorage ( uint32  index)

Changes the storage to the one with given index.

Parameters
newStorage's index.

◆ getStorageUsername()

Common::String Cloud::CloudManager::getStorageUsername ( uint32  index)

Return username used by Storage.

Parameters
Storage'sindex.
Returns
username or "" if index is invalid (no such Storage).

◆ getStorageUsedSpace()

uint64 Cloud::CloudManager::getStorageUsedSpace ( uint32  index)

Return space used by Storage.

Parameters
Storage'sindex.
Returns
used space in bytes or 0 if index is invalid (no such Storage).

◆ getStorageLastSync()

Common::String Cloud::CloudManager::getStorageLastSync ( uint32  index)

Return Storage's last sync date.

Parameters
Storage'sindex.
Returns
last sync date or "" if index is invalid (no such Storage). It also returns "" if there never was any sync or if storage is syncing right now.

◆ setStorageUsername()

void Cloud::CloudManager::setStorageUsername ( uint32  index,
const Common::String name 
)

Set Storage's username. Automatically saves changes to the config.

Parameters
indexStorage's index.
nameusername to set

◆ setStorageUsedSpace()

void Cloud::CloudManager::setStorageUsedSpace ( uint32  index,
uint64  used 
)

Set Storage's used space field. Automatically saves changes to the config.

Parameters
indexStorage's index.
usedvalue to set

◆ setStorageLastSync()

void Cloud::CloudManager::setStorageLastSync ( uint32  index,
const Common::String date 
)

Set Storage's last sync date. Automatically saves changes to the config.

Parameters
indexStorage's index.
datedate to set

◆ connectStorage() [1/3]

void Cloud::CloudManager::connectStorage ( uint32  index,
const Common::String code,
Networking::ErrorCallback  cb = nullptr 
)

Replace Storage which has given index with a storage created with given code.

Parameters
indexStorage's index
codeOAuth2 code received from user
cbcallback to notify of success or error

◆ connectStorage() [2/3]

void Cloud::CloudManager::connectStorage ( uint32  index,
Networking::JsonResponse  codeFlowJson,
Networking::ErrorCallback  cb = nullptr 
)

Replace Storage which has given index with a storage created with given JSON response.

Parameters
indexStorage's index
codeFlowJsonOAuth2 code flow JSON response (acquired from cloud.scummvm.org)
cbcallback to notify of success or error

◆ connectStorage() [3/3]

bool Cloud::CloudManager::connectStorage ( Networking::JsonResponse  codeFlowJson,
Networking::ErrorCallback  cb = nullptr 
)

From given JSON response, extract Storage index and replace Storage that has this index with a storage created with given JSON.

Parameters
codeFlowJsonOAuth2 code flow JSON response (acquired from cloud.scummvm.org)
cbcallback to notify of success or error
Returns
whether Storage index was found and is correct

◆ disconnectStorage()

void Cloud::CloudManager::disconnectStorage ( uint32  index)

Remove Storage with a given index from config.

Parameters
indexStorage's index

◆ listDirectory()

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

Returns ListDirectoryResponse with list of files.

◆ downloadFolder()

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

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

◆ info()

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

Return the StorageInfo struct.

◆ savesDirectoryPath()

Common::String Cloud::CloudManager::savesDirectoryPath ( )

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

◆ canSyncFilename()

bool Cloud::CloudManager::canSyncFilename ( const Common::String filename) const

Returns whether given filename could be uploaded to or downloaded from storage.

◆ isStorageEnabled()

bool Cloud::CloudManager::isStorageEnabled ( ) const

Returns whether current Storage is manually enabled by user (or false, if there is no active Storage).

◆ enableStorage()

void Cloud::CloudManager::enableStorage ( )

Sets Storage::_isEnabled to true and updates the config.

◆ syncSaves()

SavesSyncRequest* Cloud::CloudManager::syncSaves ( Cloud::Storage::BoolCallback  callback = nullptr,
Networking::ErrorCallback  errorCallback = nullptr 
)

Starts saves syncing process in currently active storage if there is any.

◆ isWorking()

bool Cloud::CloudManager::isWorking ( ) const

Returns whether there are any requests running.

◆ isSyncing()

bool Cloud::CloudManager::isSyncing ( ) const

Returns whether there is a SavesSyncRequest running.

◆ getSyncDownloadingProgress()

double Cloud::CloudManager::getSyncDownloadingProgress ( ) const

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

◆ getSyncDownloadingInfo()

void Cloud::CloudManager::getSyncDownloadingInfo ( Storage::SyncDownloadingInfo info) const

Fills a struct with numbers about current sync downloading progress.

◆ getSyncProgress()

double Cloud::CloudManager::getSyncProgress ( ) const

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

◆ getSyncingFiles()

Common::Array<Common::String> Cloud::CloudManager::getSyncingFiles ( ) const

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

◆ cancelSync()

void Cloud::CloudManager::cancelSync ( ) const

Cancels running sync.

◆ showCloudDisabledIcon()

void Cloud::CloudManager::showCloudDisabledIcon ( )

Shows a "cloud disabled" icon for three seconds.

◆ startDownload()

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

Starts a folder download.

◆ cancelDownload()

void Cloud::CloudManager::cancelDownload ( ) const

Cancels running download.

◆ setDownloadTarget()

void Cloud::CloudManager::setDownloadTarget ( GUI::CommandReceiver target) const

Sets FolderDownloadRequest's target to given CommandReceiver.

◆ isDownloading()

bool Cloud::CloudManager::isDownloading ( ) const

Returns whether there is a FolderDownloadRequest running.

◆ getDownloadingProgress()

double Cloud::CloudManager::getDownloadingProgress ( ) const

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

◆ getDownloadBytesNumber()

uint64 Cloud::CloudManager::getDownloadBytesNumber ( ) const

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

◆ getDownloadTotalBytesNumber()

uint64 Cloud::CloudManager::getDownloadTotalBytesNumber ( ) const

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

◆ getDownloadSpeed()

uint64 Cloud::CloudManager::getDownloadSpeed ( ) const

Returns download speed of current download progress.

◆ getDownloadRemoteDirectory()

Common::String Cloud::CloudManager::getDownloadRemoteDirectory ( ) const

Returns remote directory path.

◆ getDownloadLocalDirectory()

Common::Path Cloud::CloudManager::getDownloadLocalDirectory ( ) const

Returns local directory path.


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