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)
 Replace Storage which has given index with a storage created with given code.
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.
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.

Static Public Member Functions

static bool couldUseLocalServer ()
 Returns whether LocalWebserver is available to use for auth.

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 402 of file cloudmanager.cpp.

void Cloud::CloudManager::cancelSync (  )  const

Cancels running sync.

Definition at line 377 of file cloudmanager.cpp.

void Cloud::CloudManager::connectStorage ( uint32  index,
Common::String  code 
)

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

Parameters:
index Storage's index
code OAuth2 code received from user

Definition at line 253 of file cloudmanager.cpp.

bool Cloud::CloudManager::couldUseLocalServer (  )  [static]

Returns whether LocalWebserver is available to use for auth.

Definition at line 339 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 288 of file cloudmanager.cpp.

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

Frees memory used by storages which failed to connect.

Definition at line 166 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 178 of file cloudmanager.cpp.

uint64 Cloud::CloudManager::getDownloadBytesNumber (  )  const

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

Definition at line 428 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 421 of file cloudmanager.cpp.

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

Returns local directory path.

Definition at line 456 of file cloudmanager.cpp.

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

Returns remote directory path.

Definition at line 449 of file cloudmanager.cpp.

uint64 Cloud::CloudManager::getDownloadSpeed (  )  const

Returns download speed of current download progress.

Definition at line 442 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 435 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 182 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 224 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 218 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 212 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 356 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 370 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 363 of file cloudmanager.cpp.

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

Return the StorageInfo struct.

Definition at line 300 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 89 of file cloudmanager.cpp.

bool Cloud::CloudManager::isDownloading (  )  const

Returns whether there is a FolderDownloadRequest running.

Definition at line 414 of file cloudmanager.cpp.

bool Cloud::CloudManager::isSyncing (  )  const

Returns whether there is a SavesSyncRequest running.

Definition at line 349 of file cloudmanager.cpp.

bool Cloud::CloudManager::isWorking (  )  const

Returns whether there are any requests running.

Definition at line 332 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 276 of file cloudmanager.cpp.

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

Return Storages names as list.

Returns:
a list of Storages names.

Definition at line 186 of file cloudmanager.cpp.

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

Definition at line 66 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 172 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 463 of file cloudmanager.cpp.

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

Adds storage in the list of storages to remove later.

Definition at line 160 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 133 of file cloudmanager.cpp.

void Cloud::CloudManager::save (  ) 

Saves all information into configuration file.

Definition at line 117 of file cloudmanager.cpp.

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

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

Definition at line 312 of file cloudmanager.cpp.

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

Sets FolderDownloadRequest's target to given CommandReceiver.

Definition at line 408 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 246 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 239 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 232 of file cloudmanager.cpp.

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

Sets SavesSyncRequest's target to given CommandReceiver.

Definition at line 383 of file cloudmanager.cpp.

void Cloud::CloudManager::showCloudDisabledIcon (  ) 

Shows a "cloud disabled" icon for three seconds.

Definition at line 389 of file cloudmanager.cpp.

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

Starts a folder download.

Definition at line 395 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 194 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 319 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 Jul 13 2019 05:03:32 for ResidualVM by doxygen 1.7.1
curved edge   curved edge