diff options
author | Alexander Tkachev | 2016-06-01 12:39:10 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | a66322408f95ff7b29cf6967eaecaac06dfe5b31 (patch) | |
tree | a55a9390a3ab12566aec0478e633d30ae988103d /backends/cloud/dropbox | |
parent | 4b3a8be0b9db448971e6095a24501c66714c484f (diff) | |
download | scummvm-rg350-a66322408f95ff7b29cf6967eaecaac06dfe5b31.tar.gz scummvm-rg350-a66322408f95ff7b29cf6967eaecaac06dfe5b31.tar.bz2 scummvm-rg350-a66322408f95ff7b29cf6967eaecaac06dfe5b31.zip |
CLOUD: Implement Storage's isWorking()
It now keeps track of how many Requests are running.
To achieve that, we had to pass a callback to ConnectionManager, so each
Request has a callback paired with it. If that's one of Storage's
Requests, it has a callback, which would decrease a counter. When
Storage adds a Request, it also increases a counter and passes that
callback. Callback is called by ConnMan when Request is deleted.
isWorking() returns true if there is at least one Request running.
Diffstat (limited to 'backends/cloud/dropbox')
-rw-r--r-- | backends/cloud/dropbox/dropboxstorage.cpp | 8 | ||||
-rw-r--r-- | backends/cloud/dropbox/dropboxstorage.h | 3 |
2 files changed, 4 insertions, 7 deletions
diff --git a/backends/cloud/dropbox/dropboxstorage.cpp b/backends/cloud/dropbox/dropboxstorage.cpp index f51819ccae..861a58db4b 100644 --- a/backends/cloud/dropbox/dropboxstorage.cpp +++ b/backends/cloud/dropbox/dropboxstorage.cpp @@ -110,11 +110,11 @@ void DropboxStorage::printStorageFile(UploadResponse response) { } Networking::Request *DropboxStorage::listDirectory(Common::String path, ListDirectoryCallback outerCallback, Networking::ErrorCallback errorCallback, bool recursive) { - return ConnMan.addRequest(new DropboxListDirectoryRequest(_token, path, outerCallback, errorCallback, recursive)); + return addRequest(new DropboxListDirectoryRequest(_token, path, outerCallback, errorCallback, recursive)); } Networking::Request *DropboxStorage::upload(Common::String path, Common::SeekableReadStream *contents, UploadCallback callback, Networking::ErrorCallback errorCallback) { - return ConnMan.addRequest(new DropboxUploadRequest(_token, path, contents, callback, errorCallback)); + return addRequest(new DropboxUploadRequest(_token, path, contents, callback, errorCallback)); } Networking::Request *DropboxStorage::streamFile(Common::String path, Networking::NetworkReadStreamCallback callback, Networking::ErrorCallback errorCallback) { @@ -134,14 +134,14 @@ Networking::Request *DropboxStorage::streamFile(Common::String path, Networking: Networking::Request *DropboxStorage::createDirectory(Common::String path, BoolCallback callback, Networking::ErrorCallback errorCallback) { if (!errorCallback) errorCallback = getErrorPrintingCallback(); - return ConnMan.addRequest(new DropboxCreateDirectoryRequest(_token, path, callback, errorCallback)); + return addRequest(new DropboxCreateDirectoryRequest(_token, path, callback, errorCallback)); } Networking::Request *DropboxStorage::info(StorageInfoCallback outerCallback, Networking::ErrorCallback errorCallback) { Networking::JsonCallback innerCallback = new Common::CallbackBridge<DropboxStorage, StorageInfoResponse, Networking::JsonResponse>(this, &DropboxStorage::infoInnerCallback, outerCallback); Networking::CurlJsonRequest *request = new Networking::CurlJsonRequest(innerCallback, errorCallback, "https://api.dropboxapi.com/1/account/info"); request->addHeader("Authorization: Bearer " + _token); - return ConnMan.addRequest(request); + return 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 2c60097701..c186d1e5d6 100644 --- a/backends/cloud/dropbox/dropboxstorage.h +++ b/backends/cloud/dropbox/dropboxstorage.h @@ -91,9 +91,6 @@ public: /** Returns storage's saves directory path with the trailing slash. */ virtual Common::String savesDirectoryPath(); - /** Returns whether there are any requests running. */ - virtual bool isWorking() { return false; } //TODO - /** * Load token and user id from configs and return DropboxStorage for those. * @return pointer to the newly created DropboxStorage or 0 if some problem occured. |