ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

#include <cloudmanager.h>

Inheritance diagram for Cloud::CloudManager:
Collaboration diagram for Cloud::CloudManager:

List of all members.

Classes

struct  StorageConfig

Public Member Functions

 CloudManager ()
virtual ~CloudManager ()
void init ()
 Loads all information from configs and creates current Storage instance.
void save ()
 Saves all information into configuration file.
void replaceStorage (Storage *storage, uint32 index)
 Replace active Storage.
void removeStorage (Storage *storage)
 Adds storage in the list of storages to remove later.
Cloud::StoragegetCurrentStorage () const
 Returns active Storage, which could be used to interact with cloud storage.
uint32 getStorageIndex () const
 Return active Storage's index.
Common::StringArray listStorages () const
 Return Storages names as list.
bool switchStorage (uint32 index)
 Changes the storage to the one with given index.
Common::String getStorageUsername (uint32 index)
 Return username used by Storage.
uint64 getStorageUsedSpace (uint32 index)
 Return space used by Storage.
Common::String getStorageLastSync (uint32 index)
 Return Storage's last sync date.
void setStorageUsername (uint32 index, Common::String name)
 Set Storage's username.
void setStorageUsedSpace (uint32 index, uint64 used)
 Set Storage's used space field.
void setStorageLastSync (uint32 index, Common::String date)
 Set Storage's last sync date.
void connectStorage (uint32 index, Common::String code, Networking::ErrorCallback cb=nullptr)
 Replace Storage which has given index with a storage created with given code.
void disconnectStorage (uint32 index)
 Remove Storage with a given index from config.
Networking::RequestlistDirectory (Common::String path, Storage::ListDirectoryCallback callback, Networking::ErrorCallback errorCallback, bool recursive=false)
 Returns ListDirectoryResponse with list of files.
Networking::RequestdownloadFolder (Common::String remotePath, Common::String localPath, Storage::FileArrayCallback callback, Networking::ErrorCallback errorCallback, bool recursive=false)
 Returns Common::Array<StorageFile> with list of files, which were not downloaded.
Networking::Requestinfo (Storage::StorageInfoCallback callback, Networking::ErrorCallback errorCallback)
 Return the StorageInfo struct.
Common::String savesDirectoryPath ()
 Returns storage's saves directory path with the trailing slash.
bool canSyncFilename (const Common::String &filename) const
 Returns whether given filename could be uploaded to or downloaded from storage.
bool isStorageEnabled () const
 Returns whether current Storage is manually enabled by user (or false, if there is no active Storage).
void enableStorage ()
 Sets Storage::_isEnabled to true and updates the config.
SavesSyncRequestsyncSaves (Cloud::Storage::BoolCallback callback=nullptr, Networking::ErrorCallback errorCallback=nullptr)
 Starts saves syncing process in currently active storage if there is any.
bool isWorking () const
 Returns whether there are any requests running.
bool isSyncing () const
 Returns whether there is a SavesSyncRequest running.
double getSyncDownloadingProgress () const
 Returns a number in [0, 1] range which represents current sync downloading progress (1 = complete).
double getSyncProgress () const
 Returns a number in [0, 1] range which represents current sync progress (1 = complete).
Common::Array< Common::StringgetSyncingFiles () const
 Returns an array of saves names which are not yet synced (thus cannot be used).
void cancelSync () const
 Cancels running sync.
void setSyncTarget (GUI::CommandReceiver *target) const
 Sets SavesSyncRequest's target to given CommandReceiver.
void showCloudDisabledIcon ()
 Shows a "cloud disabled" icon for three seconds.
bool startDownload (Common::String remotePath, Common::String localPath) const
 Starts a folder download.
void cancelDownload () const
 Cancels running download.
void setDownloadTarget (GUI::CommandReceiver *target) const
 Sets FolderDownloadRequest's target to given CommandReceiver.
bool isDownloading () const
 Returns whether there is a FolderDownloadRequest running.
double getDownloadingProgress () const
 Returns a number in [0, 1] range which represents current download progress (1 = complete).
uint64 getDownloadBytesNumber () const
 Returns a number of bytes that is downloaded in current download progress.
uint64 getDownloadTotalBytesNumber () const
 Returns a total number of bytes to be downloaded in current download progress.
uint64 getDownloadSpeed () const
 Returns download speed of current download progress.
Common::String getDownloadRemoteDirectory () const
 Returns remote directory path.
Common::String getDownloadLocalDirectory () const
 Returns local directory path.

Private Member Functions

void loadStorage ()
Common::String getStorageConfigName (uint32 index) const
void freeStorages ()
 Frees memory used by storages which failed to connect.
void passNoStorageConnected (Networking::ErrorCallback errorCallback) const
 Calls the error callback with a special "no storage connected" message.
virtual bool pollEvent (Common::Event &event) override
 Common::EventSource interface.

Private Attributes

Common::Array< StorageConfig_storages
uint _currentStorageIndex
Storage_activeStorage
Common::Array< Storage * > _storagesToRemove
CloudIcon _icon

Static Private Attributes

static const char *const kStoragePrefix = "storage_"

Detailed Description

Definition at line 53 of file cloudmanager.h.


Constructor & Destructor Documentation

Cloud::CloudManager::CloudManager (  ) 

Definition at line 45 of file cloudmanager.cpp.

Cloud::CloudManager::~CloudManager (  )  [virtual]

Definition at line 47 of file cloudmanager.cpp.


Member Function Documentation

void Cloud::CloudManager::cancelDownload (  )  const

Cancels running download.

Definition at line 464 of file cloudmanager.cpp.

void Cloud::CloudManager::cancelSync (  )  const

Cancels running sync.

Definition at line 439 of file cloudmanager.cpp.

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

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

Definition at line 367 of file cloudmanager.cpp.

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

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

Parameters:
index Storage's index
code OAuth2 code received from user
cb callback to notify of success or error

Definition at line 261 of file cloudmanager.cpp.

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

Remove Storage with a given index from config.

Parameters:
index Storage's index

Definition at line 286 of file cloudmanager.cpp.

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

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

Definition at line 336 of file cloudmanager.cpp.

void Cloud::CloudManager::enableStorage (  ) 

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

Definition at line 381 of file cloudmanager.cpp.

void Cloud::CloudManager::freeStorages (  )  [private]

Frees memory used by storages which failed to connect.

Definition at line 174 of file cloudmanager.cpp.

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.

Definition at line 186 of file cloudmanager.cpp.

uint64 Cloud::CloudManager::getDownloadBytesNumber (  )  const

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

Definition at line 490 of file cloudmanager.cpp.

double Cloud::CloudManager::getDownloadingProgress (  )  const

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

Definition at line 483 of file cloudmanager.cpp.

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

Returns local directory path.

Definition at line 518 of file cloudmanager.cpp.

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

Returns remote directory path.

Definition at line 511 of file cloudmanager.cpp.

uint64 Cloud::CloudManager::getDownloadSpeed (  )  const

Returns download speed of current download progress.

Definition at line 504 of file cloudmanager.cpp.

uint64 Cloud::CloudManager::getDownloadTotalBytesNumber (  )  const

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

Definition at line 497 of file cloudmanager.cpp.

Common::String Cloud::CloudManager::getStorageConfigName ( uint32  index  )  const [private]

Definition at line 54 of file cloudmanager.cpp.

uint32 Cloud::CloudManager::getStorageIndex (  )  const

Return active Storage's index.

Returns:
active Storage's index.

Definition at line 190 of file cloudmanager.cpp.

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

Return Storage's last sync date.

Parameters:
Storage's index.
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.

Definition at line 232 of file cloudmanager.cpp.

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

Return space used by Storage.

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

Definition at line 226 of file cloudmanager.cpp.

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

Return username used by Storage.

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

Definition at line 220 of file cloudmanager.cpp.

double Cloud::CloudManager::getSyncDownloadingProgress (  )  const

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

Definition at line 418 of file cloudmanager.cpp.

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

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

Definition at line 432 of file cloudmanager.cpp.

double Cloud::CloudManager::getSyncProgress (  )  const

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

Definition at line 425 of file cloudmanager.cpp.

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

Return the StorageInfo struct.

Definition at line 348 of file cloudmanager.cpp.

void Cloud::CloudManager::init (  ) 

Loads all information from configs and creates current Storage instance.

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

Definition at line 92 of file cloudmanager.cpp.

bool Cloud::CloudManager::isDownloading (  )  const

Returns whether there is a FolderDownloadRequest running.

Definition at line 476 of file cloudmanager.cpp.

bool Cloud::CloudManager::isStorageEnabled (  )  const

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

Definition at line 374 of file cloudmanager.cpp.

bool Cloud::CloudManager::isSyncing (  )  const

Returns whether there is a SavesSyncRequest running.

Definition at line 411 of file cloudmanager.cpp.

bool Cloud::CloudManager::isWorking (  )  const

Returns whether there are any requests running.

Definition at line 402 of file cloudmanager.cpp.

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

Returns ListDirectoryResponse with list of files.

Definition at line 324 of file cloudmanager.cpp.

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

Return Storages names as list.

Returns:
a list of Storages names.

Definition at line 194 of file cloudmanager.cpp.

void Cloud::CloudManager::loadStorage (  )  [private]

Definition at line 68 of file cloudmanager.cpp.

void Cloud::CloudManager::passNoStorageConnected ( Networking::ErrorCallback  errorCallback  )  const [private]

Calls the error callback with a special "no storage connected" message.

Definition at line 180 of file cloudmanager.cpp.

bool Cloud::CloudManager::pollEvent ( Common::Event event  )  [override, private, virtual]

Common::EventSource interface.

The cloud manager registers itself as an event source even if does not actually produce events as a mean to be polled periodically by the GUI or engine code.

The periodical polling is used to update the OSD icon indicating background sync activity.

Implements Common::EventSource.

Definition at line 525 of file cloudmanager.cpp.

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

Adds storage in the list of storages to remove later.

Definition at line 168 of file cloudmanager.cpp.

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

Replace active Storage.

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

Definition at line 136 of file cloudmanager.cpp.

void Cloud::CloudManager::save (  ) 

Saves all information into configuration file.

Definition at line 120 of file cloudmanager.cpp.

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

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

Definition at line 360 of file cloudmanager.cpp.

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

Sets FolderDownloadRequest's target to given CommandReceiver.

Definition at line 470 of file cloudmanager.cpp.

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

Set Storage's last sync date.

Automatically saves changes to the config.

Parameters:
index Storage's index.
date date to set

Definition at line 254 of file cloudmanager.cpp.

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

Set Storage's used space field.

Automatically saves changes to the config.

Parameters:
index Storage's index.
used value to set

Definition at line 247 of file cloudmanager.cpp.

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

Set Storage's username.

Automatically saves changes to the config.

Parameters:
index Storage's index.
name username to set

Definition at line 240 of file cloudmanager.cpp.

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

Sets SavesSyncRequest's target to given CommandReceiver.

Definition at line 445 of file cloudmanager.cpp.

void Cloud::CloudManager::showCloudDisabledIcon (  ) 

Shows a "cloud disabled" icon for three seconds.

Definition at line 451 of file cloudmanager.cpp.

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

Starts a folder download.

Definition at line 457 of file cloudmanager.cpp.

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

Changes the storage to the one with given index.

Parameters:
new Storage's index.

Definition at line 202 of file cloudmanager.cpp.

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.

Definition at line 389 of file cloudmanager.cpp.


Member Data Documentation

Definition at line 64 of file cloudmanager.h.

Definition at line 63 of file cloudmanager.h.

Definition at line 67 of file cloudmanager.h.

const char *const Cloud::CloudManager::kStoragePrefix = "storage_" [static, private]

Definition at line 54 of file cloudmanager.h.


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


Generated on Sat Aug 15 2020 05:05:16 for ResidualVM by doxygen 1.7.1
curved edge   curved edge