diff options
Diffstat (limited to 'backends/cloud')
-rw-r--r-- | backends/cloud/dropbox/dropboxstorage.cpp | 18 | ||||
-rw-r--r-- | backends/cloud/dropbox/dropboxstorage.h | 16 | ||||
-rw-r--r-- | backends/cloud/onedrive/onedrivestorage.cpp | 4 | ||||
-rw-r--r-- | backends/cloud/onedrive/onedrivestorage.h | 16 | ||||
-rw-r--r-- | backends/cloud/storage.h | 26 |
5 files changed, 43 insertions, 37 deletions
diff --git a/backends/cloud/dropbox/dropboxstorage.cpp b/backends/cloud/dropbox/dropboxstorage.cpp index e5041466e9..9acbfc0428 100644 --- a/backends/cloud/dropbox/dropboxstorage.cpp +++ b/backends/cloud/dropbox/dropboxstorage.cpp @@ -84,8 +84,8 @@ void DropboxStorage::printFiles(Common::Array<StorageFile> files) { debug("\t%s", files[i].name().c_str()); } -void DropboxStorage::listDirectory(Common::String path, FileArrayCallback outerCallback, bool recursive) { - ConnMan.addRequest(new DropboxListDirectoryRequest(_token, path, outerCallback, recursive)); +int32 DropboxStorage::listDirectory(Common::String path, FileArrayCallback outerCallback, bool recursive) { + return ConnMan.addRequest(new DropboxListDirectoryRequest(_token, path, outerCallback, recursive)); } Networking::NetworkReadStream *DropboxStorage::streamFile(Common::String path) { @@ -101,30 +101,30 @@ Networking::NetworkReadStream *DropboxStorage::streamFile(Common::String path) { return request->execute(); } -void DropboxStorage::download(Common::String remotePath, Common::String localPath, BoolCallback callback) { +int32 DropboxStorage::download(Common::String remotePath, Common::String localPath, BoolCallback callback) { Common::DumpFile *f = new Common::DumpFile(); if (!f->open(localPath, true)) { warning("DropboxStorage: unable to open file to download into"); if (callback) (*callback)(false); delete f; - return; + return -1; } - ConnMan.addRequest(new DownloadRequest(callback, streamFile(remotePath), f)); + return ConnMan.addRequest(new DownloadRequest(callback, streamFile(remotePath), f)); } -void DropboxStorage::syncSaves(BoolCallback callback) { +int32 DropboxStorage::syncSaves(BoolCallback callback) { //this is not the real syncSaves() implementation //"" is root in Dropbox, not "/" //this must create all these directories: - download("/remote/test.jpg", "local/a/b/c/d/test.jpg", 0); + return download("/remote/test.jpg", "local/a/b/c/d/test.jpg", 0); } -void DropboxStorage::info(StorageInfoCallback outerCallback) { +int32 DropboxStorage::info(StorageInfoCallback outerCallback) { Common::BaseCallback<> *innerCallback = new Common::CallbackBridge<DropboxStorage, StorageInfo>(this, &DropboxStorage::infoInnerCallback, outerCallback); Networking::CurlJsonRequest *request = new Networking::CurlJsonRequest(innerCallback, "https://api.dropboxapi.com/1/account/info"); request->addHeader("Authorization: Bearer " + _token); - ConnMan.addRequest(request); + return ConnMan.addRequest(request); //that callback bridge wraps the outerCallback (passed in arguments from user) into innerCallback //so, when CurlJsonRequest is finished, it calls the innerCallback //innerCallback (which is DropboxStorage::infoInnerCallback in this case) processes the void *ptr diff --git a/backends/cloud/dropbox/dropboxstorage.h b/backends/cloud/dropbox/dropboxstorage.h index 415a3fe5fb..6abd3d1d94 100644 --- a/backends/cloud/dropbox/dropboxstorage.h +++ b/backends/cloud/dropbox/dropboxstorage.h @@ -64,31 +64,31 @@ public: /** Public Cloud API comes down there. */ /** Returns Common::Array<StorageFile>. */ - virtual void listDirectory(Common::String path, FileArrayCallback callback, bool recursive = false); + virtual int32 listDirectory(Common::String path, FileArrayCallback callback, bool recursive = false); /** Calls the callback when finished. */ - virtual void upload(Common::String path, Common::ReadStream *contents, BoolCallback callback) {} //TODO + virtual int32 upload(Common::String path, Common::ReadStream *contents, BoolCallback callback) { return -1; } //TODO /** Returns pointer to Networking::NetworkReadStream. */ virtual Networking::NetworkReadStream *streamFile(Common::String path); /** Calls the callback when finished. */ - virtual void download(Common::String remotePath, Common::String localPath, BoolCallback callback); + virtual int32 download(Common::String remotePath, Common::String localPath, BoolCallback callback); /** Calls the callback when finished. */ - virtual void remove(Common::String path, BoolCallback callback) {} //TODO + virtual int32 remove(Common::String path, BoolCallback callback) { return -1; } //TODO /** Calls the callback when finished. */ - virtual void syncSaves(BoolCallback callback); + virtual int32 syncSaves(BoolCallback callback); /** Calls the callback when finished. */ - virtual void createDirectory(Common::String path, BoolCallback callback) {} //TODO + virtual int32 createDirectory(Common::String path, BoolCallback callback) { return -1; } //TODO /** Calls the callback when finished. */ - virtual void touch(Common::String path, BoolCallback callback) {} //TODO + virtual int32 touch(Common::String path, BoolCallback callback) { return -1; } //TODO /** Returns the StorageInfo struct. */ - virtual void info(StorageInfoCallback callback); + virtual int32 info(StorageInfoCallback callback); /** This method is passed into info(). (Temporary) */ void infoMethodCallback(StorageInfo storageInfo); diff --git a/backends/cloud/onedrive/onedrivestorage.cpp b/backends/cloud/onedrive/onedrivestorage.cpp index 2f10841cc9..b0690be5b0 100644 --- a/backends/cloud/onedrive/onedrivestorage.cpp +++ b/backends/cloud/onedrive/onedrivestorage.cpp @@ -137,12 +137,12 @@ void OneDriveStorage::printJson(void *jsonPointer) { delete json; } -void OneDriveStorage::syncSaves(BoolCallback callback) { +int32 OneDriveStorage::syncSaves(BoolCallback callback) { //this is not the real syncSaves() implementation Common::BaseCallback<> *innerCallback = new Common::Callback<OneDriveStorage>(this, &OneDriveStorage::printJson); Networking::CurlJsonRequest *request = new Networking::CurlJsonRequest(innerCallback, "https://api.onedrive.com/v1.0/drives/"); request->addHeader("Authorization: bearer " + _token); - ConnMan.addRequest(request); + return ConnMan.addRequest(request); } OneDriveStorage *OneDriveStorage::loadFromConfig(Common::String keyPrefix) { diff --git a/backends/cloud/onedrive/onedrivestorage.h b/backends/cloud/onedrive/onedrivestorage.h index 28f37aee2c..4141771f65 100644 --- a/backends/cloud/onedrive/onedrivestorage.h +++ b/backends/cloud/onedrive/onedrivestorage.h @@ -74,31 +74,31 @@ public: /** Public Cloud API comes down there. */ /** Returns Common::Array<StorageFile>. */ - virtual void listDirectory(Common::String path, FileArrayCallback callback, bool recursive = false) {} //TODO + virtual int32 listDirectory(Common::String path, FileArrayCallback callback, bool recursive = false) { return -1; } //TODO /** Calls the callback when finished. */ - virtual void upload(Common::String path, Common::ReadStream *contents, BoolCallback callback) {} //TODO + virtual int32 upload(Common::String path, Common::ReadStream *contents, BoolCallback callback) { return -1; } //TODO /** Returns pointer to Networking::NetworkReadStream. */ virtual Networking::NetworkReadStream *streamFile(Common::String path) { return 0; } //TODO /** Calls the callback when finished. */ - virtual void download(Common::String remotePath, Common::String localPath, BoolCallback callback) {} //TODO + virtual int32 download(Common::String remotePath, Common::String localPath, BoolCallback callback) { return -1; } //TODO /** Calls the callback when finished. */ - virtual void remove(Common::String path, BoolCallback callback) {} //TODO + virtual int32 remove(Common::String path, BoolCallback callback) { return -1; } //TODO /** Calls the callback when finished. */ - virtual void syncSaves(BoolCallback callback); + virtual int32 syncSaves(BoolCallback callback); /** Calls the callback when finished. */ - virtual void createDirectory(Common::String path, BoolCallback callback) {} //TODO + virtual int32 createDirectory(Common::String path, BoolCallback callback) { return -1; } //TODO /** Calls the callback when finished. */ - virtual void touch(Common::String path, BoolCallback callback) {} //TODO + virtual int32 touch(Common::String path, BoolCallback callback) { return -1; } //TODO /** Returns the StorageInfo struct. */ - virtual void info(StorageInfoCallback callback) {} //TODO + virtual int32 info(StorageInfoCallback callback) { return -1; } //TODO /** Returns whether saves sync process is running. */ virtual bool isSyncing() { return false; } //TODO diff --git a/backends/cloud/storage.h b/backends/cloud/storage.h index e38c6bedd9..394fc2c22d 100644 --- a/backends/cloud/storage.h +++ b/backends/cloud/storage.h @@ -57,34 +57,40 @@ public: virtual void saveConfig(Common::String keyPrefix) = 0; - /** Public Cloud API comes down there. */ + /** + * Public Cloud API comes down there. + * + * All Cloud API methods return int32 request id, which might be used to access + * request through ConnectionManager. All methods also accept a callback, which + * would be called, when request is complete. + */ /** Returns Common::Array<StorageFile>. */ - virtual void listDirectory(Common::String path, FileArrayCallback callback, bool recursive = false) = 0; + virtual int32 listDirectory(Common::String path, FileArrayCallback callback, bool recursive = false) = 0; /** Calls the callback when finished. */ - virtual void upload(Common::String path, Common::ReadStream *contents, BoolCallback callback) = 0; + virtual int32 upload(Common::String path, Common::ReadStream *contents, BoolCallback callback) = 0; /** Returns pointer to Networking::NetworkReadStream. */ - virtual Networking::NetworkReadStream *streamFile(Common::String path) = 0; + virtual Networking::NetworkReadStream *streamFile(Common::String path) = 0; //TODO: return int32 somehow /** Calls the callback when finished. */ - virtual void download(Common::String remotePath, Common::String localPath, BoolCallback callback) = 0; + virtual int32 download(Common::String remotePath, Common::String localPath, BoolCallback callback) = 0; /** Calls the callback when finished. */ - virtual void remove(Common::String path, BoolCallback callback) = 0; + virtual int32 remove(Common::String path, BoolCallback callback) = 0; /** Calls the callback when finished. */ - virtual void syncSaves(BoolCallback callback) = 0; + virtual int32 syncSaves(BoolCallback callback) = 0; /** Calls the callback when finished. */ - virtual void createDirectory(Common::String path, BoolCallback callback) = 0; + virtual int32 createDirectory(Common::String path, BoolCallback callback) = 0; /** Calls the callback when finished. */ - virtual void touch(Common::String path, BoolCallback callback) = 0; + virtual int32 touch(Common::String path, BoolCallback callback) = 0; /** Returns the StorageInfo struct. */ - virtual void info(StorageInfoCallback callback) = 0; + virtual int32 info(StorageInfoCallback callback) = 0; /** Returns whether saves sync process is running. */ virtual bool isSyncing() = 0; |