aboutsummaryrefslogtreecommitdiff
path: root/backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp
diff options
context:
space:
mode:
authorAlexander Tkachev2016-05-26 19:02:55 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commitf4547f44df32ce1f49a6a36df083e7703751adcd (patch)
treea69e2f703a42348d9766ad128bb88b2c169719ad /backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp
parent62ccf1f902100febfb1be02b67e84a6e4938ebbf (diff)
downloadscummvm-rg350-f4547f44df32ce1f49a6a36df083e7703751adcd.tar.gz
scummvm-rg350-f4547f44df32ce1f49a6a36df083e7703751adcd.tar.bz2
scummvm-rg350-f4547f44df32ce1f49a6a36df083e7703751adcd.zip
CLOUD: Add RequestIdPair struct
Can be used with Callback<T> (means it's still type safe). It's used to pass not only Request id to user's callback, but also a value user wanted. void *data field is removed from RequestInfo.
Diffstat (limited to 'backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp')
-rw-r--r--backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp b/backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp
index 3dada884a0..be9304081e 100644
--- a/backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp
+++ b/backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp
@@ -25,6 +25,7 @@
#include "backends/networking/curl/connectionmanager.h"
#include "backends/networking/curl/curljsonrequest.h"
#include "common/json.h"
+#include "backends/cloud/storage.h"
namespace Cloud {
namespace Dropbox {
@@ -39,7 +40,7 @@ void DropboxListDirectoryRequest::startupWork() {
_files.clear();
_complete = false;
- Common::BaseCallback<> *innerCallback = new Common::Callback<DropboxListDirectoryRequest>(this, &DropboxListDirectoryRequest::responseCallback);
+ Networking::DataCallback innerCallback = new Common::Callback<DropboxListDirectoryRequest, Networking::RequestDataPair>(this, &DropboxListDirectoryRequest::responseCallback);
Networking::CurlJsonRequest *request = new Networking::CurlJsonRequest(innerCallback, "https://api.dropboxapi.com/2/files/list_folder");
request->addHeader("Authorization: Bearer " + _token);
request->addHeader("Content-Type: application/json");
@@ -57,8 +58,8 @@ void DropboxListDirectoryRequest::startupWork() {
}
-void DropboxListDirectoryRequest::responseCallback(void *jsonPtr) {
- Common::JSONValue *json = (Common::JSONValue *)jsonPtr;
+void DropboxListDirectoryRequest::responseCallback(Networking::RequestDataPair pair) {
+ Common::JSONValue *json = (Common::JSONValue *)pair.value;
if (json) {
Common::JSONObject response = json->asObject();
@@ -88,7 +89,7 @@ void DropboxListDirectoryRequest::responseCallback(void *jsonPtr) {
bool hasMore = response.getVal("has_more")->asBool();
if (hasMore) {
- Common::BaseCallback<> *innerCallback = new Common::Callback<DropboxListDirectoryRequest>(this, &DropboxListDirectoryRequest::responseCallback);
+ Networking::DataCallback innerCallback = new Common::Callback<DropboxListDirectoryRequest, Networking::RequestDataPair>(this, &DropboxListDirectoryRequest::responseCallback);
Networking::CurlJsonRequest *request = new Networking::CurlJsonRequest(innerCallback, "https://api.dropboxapi.com/2/files/list_folder/continue");
request->addHeader("Authorization: Bearer " + _token);
request->addHeader("Content-Type: application/json");
@@ -114,7 +115,7 @@ void DropboxListDirectoryRequest::responseCallback(void *jsonPtr) {
bool DropboxListDirectoryRequest::handle() {
if (_complete && _filesCallback) {
ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
- if (_filesCallback) (*_filesCallback)(_files);
+ if (_filesCallback) (*_filesCallback)(Storage::RequestFileArrayPair(_id, _files));
}
return _complete;