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     virtual Networking::ErrorCallback getErrorPrintingCallback();
00075 
00077     virtual void printErrorResponse(Networking::ErrorResponse error);
00078 
00086     virtual Networking::Request *addRequest(Networking::Request *request);
00087 
00093     virtual void requestFinishedCallback(Networking::Request *invalidRequestPointer);
00094 
00095 public:
00096     Storage();
00097     virtual ~Storage();
00098 
00110     virtual void saveConfig(Common::String keyPrefix) = 0;
00111 
00116     virtual Common::String name() const = 0;
00117 
00127     virtual Networking::Request *listDirectory(Common::String path, ListDirectoryCallback callback, Networking::ErrorCallback errorCallback, bool recursive = false) = 0;
00128 
00130     virtual Networking::Request *upload(Common::String path, Common::SeekableReadStream *contents, UploadCallback callback, Networking::ErrorCallback errorCallback) = 0;
00131     virtual Networking::Request *upload(Common::String remotePath, Common::String localPath, UploadCallback callback, Networking::ErrorCallback errorCallback);
00132 
00134     virtual bool uploadStreamSupported();
00135 
00137     virtual Networking::Request *streamFile(Common::String path, Networking::NetworkReadStreamCallback callback, Networking::ErrorCallback errorCallback);
00138     virtual Networking::Request *streamFileById(Common::String id, Networking::NetworkReadStreamCallback callback, Networking::ErrorCallback errorCallback) = 0;
00139 
00141     virtual Networking::Request *download(Common::String remotePath, Common::String localPath, BoolCallback callback, Networking::ErrorCallback errorCallback);
00142     virtual Networking::Request *downloadById(Common::String remoteId, Common::String localPath, BoolCallback callback, Networking::ErrorCallback errorCallback);
00143 
00145     virtual Networking::Request *downloadFolder(Common::String remotePath, Common::String localPath, FileArrayCallback callback, Networking::ErrorCallback errorCallback, bool recursive = false);
00146 
00148     virtual SavesSyncRequest *syncSaves(BoolCallback callback, Networking::ErrorCallback errorCallback);
00149 
00151     virtual Networking::Request *createDirectory(Common::String path, BoolCallback callback, Networking::ErrorCallback errorCallback) = 0;
00152 
00160     virtual Networking::Request *info(StorageInfoCallback callback, Networking::ErrorCallback errorCallback) = 0;
00161 
00163     virtual Common::String savesDirectoryPath() = 0;
00164 
00166     virtual bool isWorking();
00167 
00169 
00171     virtual bool isSyncing();
00172 
00174     virtual double getSyncDownloadingProgress();
00175 
00177     virtual double getSyncProgress();
00178 
00180     virtual Common::Array<Common::String> getSyncingFiles();
00181 
00183     virtual void cancelSync();
00184 
00186     virtual void setSyncTarget(GUI::CommandReceiver *target);
00187 
00188 protected:
00190     virtual void savesSyncDefaultCallback(BoolResponse response);
00191 
00193     virtual void savesSyncDefaultErrorCallback(Networking::ErrorResponse error);
00194 
00195 public:
00197 
00199     virtual bool startDownload(Common::String remotePath, Common::String localPath);
00200 
00202     virtual void cancelDownload();
00203 
00205     virtual void setDownloadTarget(GUI::CommandReceiver *target);
00206 
00208     virtual bool isDownloading();
00209 
00211     virtual double getDownloadingProgress();
00212 
00214     virtual uint64 getDownloadBytesNumber();
00215 
00217     virtual uint64 getDownloadTotalBytesNumber();
00218 
00220     virtual uint64 getDownloadSpeed();
00221 
00223     virtual Common::String getDownloadRemoteDirectory();
00224 
00226     virtual Common::String getDownloadLocalDirectory();
00227 
00228 protected:
00230     virtual void directoryDownloadedCallback(FileArrayResponse response);
00231 
00233     virtual void directoryDownloadedErrorCallback(Networking::ErrorResponse error);
00234 };
00235 
00236 } // End of namespace Cloud
00237 
00238 #endif


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