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

storage.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 BACKENDS_CLOUD_STORAGE_H
00024 #define BACKENDS_CLOUD_STORAGE_H
00025 
00026 #include "backends/cloud/storagefile.h"
00027 #include "backends/cloud/storageinfo.h"
00028 #include "backends/networking/curl/request.h"
00029 #include "backends/networking/curl/curlrequest.h"
00030 #include "common/array.h"
00031 #include "common/callback.h"
00032 #include "common/mutex.h"
00033 #include "common/stream.h"
00034 #include "common/str.h"
00035 
00036 namespace GUI {
00037 
00038 class CommandReceiver;
00039 
00040 }
00041 
00042 namespace Cloud {
00043 
00044 class SavesSyncRequest;
00045 class FolderDownloadRequest;
00046 
00047 class Storage {
00048 public:
00049     typedef Networking::Response<Common::Array<StorageFile>&> FileArrayResponse;
00050     typedef Networking::Response<StorageInfo> StorageInfoResponse;
00051     typedef Networking::Response<bool> BoolResponse;
00052     typedef Networking::Response<StorageFile> UploadResponse;
00053     typedef Networking::Response<Common::Array<StorageFile> &> ListDirectoryResponse;
00054 
00055     typedef Common::BaseCallback<FileArrayResponse> *FileArrayCallback;
00056     typedef Common::BaseCallback<StorageInfoResponse> *StorageInfoCallback;
00057     typedef Common::BaseCallback<BoolResponse> *BoolCallback;
00058     typedef Common::BaseCallback<UploadResponse> *UploadCallback;
00059     typedef Common::BaseCallback<ListDirectoryResponse> *ListDirectoryCallback;
00060 
00061 protected:
00063     uint32 _runningRequestsCount;
00064     Common::Mutex _runningRequestsMutex;
00065 
00067     SavesSyncRequest *_savesSyncRequest;
00068     bool _syncRestartRequestsed;
00069 
00071     FolderDownloadRequest *_downloadFolderRequest;
00072 
00074     bool _isEnabled;
00075 
00077     virtual Networking::ErrorCallback getErrorPrintingCallback();
00078 
00080     virtual void printErrorResponse(Networking::ErrorResponse error);
00081 
00089     virtual Networking::Request *addRequest(Networking::Request *request);
00090 
00096     virtual void requestFinishedCallback(Networking::Request *invalidRequestPointer);
00097 
00098 public:
00099     Storage();
00100     virtual ~Storage();
00101 
00113     virtual void saveConfig(Common::String keyPrefix) = 0;
00114 
00119     virtual Common::String name() const = 0;
00120 
00124     bool isEnabled() const;
00125 
00129     void enable();
00130 
00140     virtual Networking::Request *listDirectory(Common::String path, ListDirectoryCallback callback, Networking::ErrorCallback errorCallback, bool recursive = false) = 0;
00141 
00143     virtual Networking::Request *upload(Common::String path, Common::SeekableReadStream *contents, UploadCallback callback, Networking::ErrorCallback errorCallback) = 0;
00144     virtual Networking::Request *upload(Common::String remotePath, Common::String localPath, UploadCallback callback, Networking::ErrorCallback errorCallback);
00145 
00147     virtual bool uploadStreamSupported();
00148 
00150     virtual Networking::Request *streamFile(Common::String path, Networking::NetworkReadStreamCallback callback, Networking::ErrorCallback errorCallback);
00151     virtual Networking::Request *streamFileById(Common::String id, Networking::NetworkReadStreamCallback callback, Networking::ErrorCallback errorCallback) = 0;
00152 
00154     virtual Networking::Request *download(Common::String remotePath, Common::String localPath, BoolCallback callback, Networking::ErrorCallback errorCallback);
00155     virtual Networking::Request *downloadById(Common::String remoteId, Common::String localPath, BoolCallback callback, Networking::ErrorCallback errorCallback);
00156 
00158     virtual Networking::Request *downloadFolder(Common::String remotePath, Common::String localPath, FileArrayCallback callback, Networking::ErrorCallback errorCallback, bool recursive = false);
00159 
00161     virtual SavesSyncRequest *syncSaves(BoolCallback callback, Networking::ErrorCallback errorCallback);
00162 
00164     virtual Networking::Request *createDirectory(Common::String path, BoolCallback callback, Networking::ErrorCallback errorCallback) = 0;
00165 
00173     virtual Networking::Request *info(StorageInfoCallback callback, Networking::ErrorCallback errorCallback) = 0;
00174 
00176     virtual Common::String savesDirectoryPath() = 0;
00177 
00179     virtual bool isWorking();
00180 
00182 
00184     virtual bool isSyncing();
00185 
00187     virtual double getSyncDownloadingProgress();
00188 
00190     virtual double getSyncProgress();
00191 
00193     virtual Common::Array<Common::String> getSyncingFiles();
00194 
00196     virtual void cancelSync();
00197 
00199     virtual void setSyncTarget(GUI::CommandReceiver *target);
00200 
00201 protected:
00203     virtual void savesSyncDefaultCallback(BoolResponse response);
00204 
00206     virtual void savesSyncDefaultErrorCallback(Networking::ErrorResponse error);
00207 
00208 public:
00210 
00212     virtual bool startDownload(Common::String remotePath, Common::String localPath);
00213 
00215     virtual void cancelDownload();
00216 
00218     virtual void setDownloadTarget(GUI::CommandReceiver *target);
00219 
00221     virtual bool isDownloading();
00222 
00224     virtual double getDownloadingProgress();
00225 
00227     virtual uint64 getDownloadBytesNumber();
00228 
00230     virtual uint64 getDownloadTotalBytesNumber();
00231 
00233     virtual uint64 getDownloadSpeed();
00234 
00236     virtual Common::String getDownloadRemoteDirectory();
00237 
00239     virtual Common::String getDownloadLocalDirectory();
00240 
00241 protected:
00243     virtual void directoryDownloadedCallback(FileArrayResponse response);
00244 
00246     virtual void directoryDownloadedErrorCallback(Networking::ErrorResponse error);
00247 };
00248 
00249 } // End of namespace Cloud
00250 
00251 #endif


Generated on Sat Dec 14 2019 05:00:26 for ResidualVM by doxygen 1.7.1
curved edge   curved edge