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

cloudmanager.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef CLOUD_CLOUDMANAGER_H
00024 #define CLOUD_CLOUDMANAGER_H
00025 
00026 #include "backends/cloud/storage.h"
00027 #include "backends/cloud/cloudicon.h"
00028 
00029 #include "common/array.h"
00030 #include "common/singleton.h"
00031 #include "common/str-array.h"
00032 #include "common/events.h"
00033 
00034 namespace GUI {
00035 
00036 class CommandReceiver;
00037 
00038 }
00039 
00040 namespace Cloud {
00041 
00042 // The actual indexes in CloudManager's array
00043 enum StorageID {
00044     kStorageNoneId = 0,
00045     kStorageDropboxId = 1,
00046     kStorageOneDriveId = 2,
00047     kStorageGoogleDriveId = 3,
00048     kStorageBoxId = 4,
00049 
00050     kStorageTotal
00051 };
00052 
00053 class CloudManager : public Common::Singleton<CloudManager>, public Common::EventSource {
00054     static const char *const kStoragePrefix;
00055 
00056     struct StorageConfig {
00057         Common::String name, username;
00058         uint64 usedBytes;
00059         Common::String lastSyncDate;
00060     };
00061 
00062     Common::Array<StorageConfig> _storages;
00063     uint _currentStorageIndex;
00064     Storage *_activeStorage;
00065     Common::Array<Storage *> _storagesToRemove;
00066 
00067     CloudIcon _icon;
00068 
00069     void loadStorage();
00070 
00071     Common::String getStorageConfigName(uint32 index) const;
00072 
00074     void freeStorages();
00075 
00077     void passNoStorageConnected(Networking::ErrorCallback errorCallback) const;
00078 
00089     virtual bool pollEvent(Common::Event &event) override;
00090 
00091 public:
00092     CloudManager();
00093     virtual ~CloudManager();
00094 
00100     void init();
00101 
00105     void save();
00106 
00114     void replaceStorage(Storage *storage, uint32 index);
00115 
00117     void removeStorage(Storage *storage);
00118 
00125     Cloud::Storage *getCurrentStorage() const;
00126 
00132     uint32 getStorageIndex() const;
00133 
00139     Common::StringArray listStorages() const;
00140 
00146     bool switchStorage(uint32 index);
00147 
00154     Common::String getStorageUsername(uint32 index);
00155 
00162     uint64 getStorageUsedSpace(uint32 index);
00163 
00172     Common::String getStorageLastSync(uint32 index);
00173 
00181     void setStorageUsername(uint32 index, Common::String name);
00182 
00190     void setStorageUsedSpace(uint32 index, uint64 used);
00191 
00199     void setStorageLastSync(uint32 index, Common::String date);
00200 
00208     void connectStorage(uint32 index, Common::String code);
00209 
00211     Networking::Request *listDirectory(Common::String path, Storage::ListDirectoryCallback callback, Networking::ErrorCallback errorCallback, bool recursive = false);
00212 
00214     Networking::Request *downloadFolder(Common::String remotePath, Common::String localPath, Storage::FileArrayCallback callback, Networking::ErrorCallback errorCallback, bool recursive = false);
00215 
00217     Networking::Request *info(Storage::StorageInfoCallback callback, Networking::ErrorCallback errorCallback);
00218 
00220     Common::String savesDirectoryPath();
00221 
00225     SavesSyncRequest *syncSaves(Cloud::Storage::BoolCallback callback = nullptr, Networking::ErrorCallback errorCallback = nullptr);
00226 
00228     bool isWorking() const;
00229 
00231     static bool couldUseLocalServer();
00232 
00234 
00236     bool isSyncing() const;
00237 
00239     double getSyncDownloadingProgress() const;
00240 
00242     double getSyncProgress() const;
00243 
00245     Common::Array<Common::String> getSyncingFiles() const;
00246 
00248     void cancelSync() const;
00249 
00251     void setSyncTarget(GUI::CommandReceiver *target) const;
00252 
00254     void showCloudDisabledIcon();
00255 
00257 
00259     bool startDownload(Common::String remotePath, Common::String localPath) const;
00260 
00262     void cancelDownload() const;
00263 
00265     void setDownloadTarget(GUI::CommandReceiver *target) const;
00266 
00268     bool isDownloading() const;
00269 
00271     double getDownloadingProgress() const;
00272 
00274     uint64 getDownloadBytesNumber() const;
00275 
00277     uint64 getDownloadTotalBytesNumber() const;
00278 
00280     uint64 getDownloadSpeed() const;
00281 
00283     Common::String getDownloadRemoteDirectory() const;
00284 
00286     Common::String getDownloadLocalDirectory() const;
00287 };
00288 
00290 #define CloudMan        Cloud::CloudManager::instance()
00291 
00292 } // End of namespace Cloud
00293 
00294 #endif


Generated on Sat Mar 23 2019 05:01:23 for ResidualVM by doxygen 1.7.1
curved edge   curved edge