diff options
author | Alexander Tkachev | 2016-05-22 00:04:00 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | b570499164bf94fc4735bad54e7a722498ae56ea (patch) | |
tree | a6951e5d15eb474d0283944f04790f86a54be4ce /backends/cloud/dropbox | |
parent | 9e531e3ce7f5b3a1cc87b43beb6f72911cb41bdd (diff) | |
download | scummvm-rg350-b570499164bf94fc4735bad54e7a722498ae56ea.tar.gz scummvm-rg350-b570499164bf94fc4735bad54e7a722498ae56ea.tar.bz2 scummvm-rg350-b570499164bf94fc4735bad54e7a722498ae56ea.zip |
CLOUD: Add Callback typedefs
And do some minor cleanup work.
Diffstat (limited to 'backends/cloud/dropbox')
-rw-r--r-- | backends/cloud/dropbox/dropboxstorage.cpp | 10 | ||||
-rw-r--r-- | backends/cloud/dropbox/dropboxstorage.h | 24 |
2 files changed, 18 insertions, 16 deletions
diff --git a/backends/cloud/dropbox/dropboxstorage.cpp b/backends/cloud/dropbox/dropboxstorage.cpp index 964b95bb09..49355fa845 100644 --- a/backends/cloud/dropbox/dropboxstorage.cpp +++ b/backends/cloud/dropbox/dropboxstorage.cpp @@ -66,14 +66,14 @@ DropboxStorage::~DropboxStorage() { curl_global_cleanup(); } -void DropboxStorage::syncSaves(Common::BaseCallback<bool> *callback) { +void DropboxStorage::syncSaves(BoolCallback callback) { //this is not the real syncSaves() implementation info(new Common::Callback<DropboxStorage, StorageInfo>(this, &DropboxStorage::infoMethodCallback)); //that line meant the following: //"please, do the info API request and, when it's finished, call the infoMethodCallback() of me" } -void DropboxStorage::info(Common::BaseCallback<StorageInfo> *outerCallback) { +void 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); @@ -84,8 +84,8 @@ void DropboxStorage::info(Common::BaseCallback<StorageInfo> *outerCallback) { //and then calls the outerCallback (which wants to receive StorageInfo, not void *) } -void DropboxStorage::infoInnerCallback(Common::BaseCallback<StorageInfo> *outerCallback, void *ptr) { - Common::JSONValue *json = (Common::JSONValue *)ptr; +void DropboxStorage::infoInnerCallback(StorageInfoCallback outerCallback, void *jsonPointer) { + Common::JSONValue *json = (Common::JSONValue *)jsonPointer; if (!json) { warning("NULL passed instead of JSON"); delete outerCallback; @@ -93,6 +93,8 @@ void DropboxStorage::infoInnerCallback(Common::BaseCallback<StorageInfo> *outerC } if (outerCallback) { + //TODO: check that JSON doesn't contain some error message instead of an actual response + //TODO: use JSON fields to construct StorageInfo (*outerCallback)(StorageInfo(json->stringify())); delete outerCallback; } diff --git a/backends/cloud/dropbox/dropboxstorage.h b/backends/cloud/dropbox/dropboxstorage.h index 8cc9312a87..3fc38bc1bb 100644 --- a/backends/cloud/dropbox/dropboxstorage.h +++ b/backends/cloud/dropbox/dropboxstorage.h @@ -39,37 +39,37 @@ class DropboxStorage: public Cloud::Storage { static void getAccessToken(Common::String code); + /** Constructs StorageInfo based on JSON response from cloud. */ + void infoInnerCallback(StorageInfoCallback outerCallback, void *json); + public: virtual ~DropboxStorage(); /** Returns pointer to Common::Array<StorageFile>. */ - virtual void listDirectory(Common::String path, Common::BaseCallback< Common::Array<StorageFile> > *callback) {} //TODO + virtual void listDirectory(Common::String path, FileArrayCallback callback) {} //TODO /** Calls the callback when finished. */ - virtual void upload(Common::String path, Common::ReadStream* contents, Common::BaseCallback<bool> *callback) {} //TODO + virtual void upload(Common::String path, Common::ReadStream* contents, BoolCallback callback) {} //TODO /** Returns pointer to Common::ReadStream. */ - virtual void download(Common::String path, Common::BaseCallback<Common::ReadStream> *callback) {} //TODO + virtual void download(Common::String path, ReadStreamCallback callback) {} //TODO /** Calls the callback when finished. */ - virtual void remove(Common::String path, Common::BaseCallback<bool> *callback) {} //TODO + virtual void remove(Common::String path, BoolCallback callback) {} //TODO /** Calls the callback when finished. */ - virtual void syncSaves(Common::BaseCallback<bool> *callback); + virtual void syncSaves(BoolCallback callback); /** Calls the callback when finished. */ - virtual void createDirectory(Common::String path, Common::BaseCallback<bool> *callback) {} //TODO + virtual void createDirectory(Common::String path, BoolCallback callback) {} //TODO /** Calls the callback when finished. */ - virtual void touch(Common::String path, Common::BaseCallback<bool> *callback) {} //TODO + virtual void touch(Common::String path, BoolCallback callback) {} //TODO /** Returns pointer to the StorageInfo struct. */ - virtual void info(Common::BaseCallback<StorageInfo> *callback); - - /** This is what is called by CurlJsonRequest. */ - void infoInnerCallback(Common::BaseCallback<StorageInfo> *outerCallback, void *ptr); + virtual void info(StorageInfoCallback callback); - /** This is what is called by infoInnerCallback() (it's its outer callback). */ + /** This method is passed into info(). (Temporary) */ void infoMethodCallback(StorageInfo storageInfo); /** Returns whether saves sync process is running. */ |