From eda575a660543884b1a4addd21b676a67d2c2a31 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Thu, 26 May 2016 17:12:40 +0600 Subject: CLOUD: Add Requests id (Upgrading ConnectionManager step by step.) --- backends/cloud/dropbox/dropboxstorage.cpp | 18 +++++++++--------- backends/cloud/dropbox/dropboxstorage.h | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'backends/cloud/dropbox') 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 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(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. */ - 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); -- cgit v1.2.3