aboutsummaryrefslogtreecommitdiff
path: root/backends/cloud/onedrive
diff options
context:
space:
mode:
authorAlexander Tkachev2016-06-01 12:39:10 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commita66322408f95ff7b29cf6967eaecaac06dfe5b31 (patch)
treea55a9390a3ab12566aec0478e633d30ae988103d /backends/cloud/onedrive
parent4b3a8be0b9db448971e6095a24501c66714c484f (diff)
downloadscummvm-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/onedrive')
-rw-r--r--backends/cloud/onedrive/onedrivestorage.cpp12
-rw-r--r--backends/cloud/onedrive/onedrivestorage.h3
2 files changed, 6 insertions, 9 deletions
diff --git a/backends/cloud/onedrive/onedrivestorage.cpp b/backends/cloud/onedrive/onedrivestorage.cpp
index 190a7ab603..98f0ac5a4d 100644
--- a/backends/cloud/onedrive/onedrivestorage.cpp
+++ b/backends/cloud/onedrive/onedrivestorage.cpp
@@ -84,7 +84,7 @@ void OneDriveStorage::getAccessToken(BoolCallback callback, Common::String code)
request->addPostField("client_id=" + Common::String(KEY));
request->addPostField("client_secret=" + Common::String(SECRET));
request->addPostField("&redirect_uri=http%3A%2F%2Flocalhost%3A12345%2F");
- ConnMan.addRequest(request);
+ addRequest(request);
}
void OneDriveStorage::tokenRefreshed(BoolCallback callback, Networking::JsonResponse response) {
@@ -198,11 +198,11 @@ void OneDriveStorage::fileInfoCallback(Networking::NetworkReadStreamCallback out
}
Networking::Request *OneDriveStorage::listDirectory(Common::String path, ListDirectoryCallback callback, Networking::ErrorCallback errorCallback, bool recursive) {
- return ConnMan.addRequest(new OneDriveListDirectoryRequest(this, path, callback, errorCallback, recursive));
+ return addRequest(new OneDriveListDirectoryRequest(this, path, callback, errorCallback, recursive));
}
Networking::Request *OneDriveStorage::upload(Common::String path, Common::SeekableReadStream *contents, UploadCallback callback, Networking::ErrorCallback errorCallback) {
- return ConnMan.addRequest(new OneDriveUploadRequest(this, path, contents, callback, errorCallback));
+ return addRequest(new OneDriveUploadRequest(this, path, contents, callback, errorCallback));
}
Networking::Request *OneDriveStorage::streamFile(Common::String path, Networking::NetworkReadStreamCallback outerCallback, Networking::ErrorCallback errorCallback) {
@@ -210,7 +210,7 @@ Networking::Request *OneDriveStorage::streamFile(Common::String path, Networking
Networking::JsonCallback innerCallback = new Common::CallbackBridge<OneDriveStorage, Networking::NetworkReadStreamResponse, Networking::JsonResponse>(this, &OneDriveStorage::fileInfoCallback, outerCallback);
Networking::CurlJsonRequest *request = new OneDriveTokenRefresher(this, innerCallback, errorCallback, url.c_str());
request->addHeader("Authorization: Bearer " + _token);
- return ConnMan.addRequest(request);
+ return addRequest(request);
}
void OneDriveStorage::fileDownloaded(BoolResponse response) {
@@ -238,14 +238,14 @@ void OneDriveStorage::printFile(UploadResponse response) {
Networking::Request *OneDriveStorage::createDirectory(Common::String path, BoolCallback callback, Networking::ErrorCallback errorCallback) {
if (!errorCallback) errorCallback = getErrorPrintingCallback();
- return ConnMan.addRequest(new OneDriveCreateDirectoryRequest(this, path, callback, errorCallback));
+ return addRequest(new OneDriveCreateDirectoryRequest(this, path, callback, errorCallback));
}
Networking::Request *OneDriveStorage::info(StorageInfoCallback callback, Networking::ErrorCallback errorCallback) {
Networking::JsonCallback innerCallback = new Common::CallbackBridge<OneDriveStorage, StorageInfoResponse, Networking::JsonResponse>(this, &OneDriveStorage::infoInnerCallback, callback);
Networking::CurlJsonRequest *request = new OneDriveTokenRefresher(this, innerCallback, errorCallback, "https://api.onedrive.com/v1.0/drive/special/approot");
request->addHeader("Authorization: bearer " + _token);
- return ConnMan.addRequest(request);
+ return addRequest(request);
}
Common::String OneDriveStorage::savesDirectoryPath() { return "saves/"; }
diff --git a/backends/cloud/onedrive/onedrivestorage.h b/backends/cloud/onedrive/onedrivestorage.h
index 5edd96e59c..a09d68b6fd 100644
--- a/backends/cloud/onedrive/onedrivestorage.h
+++ b/backends/cloud/onedrive/onedrivestorage.h
@@ -98,9 +98,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 OneDriveStorage for those.
* @return pointer to the newly created OneDriveStorage or 0 if some problem occured.