aboutsummaryrefslogtreecommitdiff
path: root/backends/cloud/dropbox
diff options
context:
space:
mode:
authorAlexander Tkachev2016-05-27 20:59:40 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit0ef1cda1724e973c36c76e07763f681cb14bd597 (patch)
tree1a63efae14cb5a3d44e5d21ab809281760efcdd9 /backends/cloud/dropbox
parentcdf30e9d584f81029311f111f314fabdc1bf6d60 (diff)
downloadscummvm-rg350-0ef1cda1724e973c36c76e07763f681cb14bd597.tar.gz
scummvm-rg350-0ef1cda1724e973c36c76e07763f681cb14bd597.tar.bz2
scummvm-rg350-0ef1cda1724e973c36c76e07763f681cb14bd597.zip
CLOUD: Add FolderDownloadRequest
Uses Storage's listDirectory() and download() methods to download contents.
Diffstat (limited to 'backends/cloud/dropbox')
-rw-r--r--backends/cloud/dropbox/dropboxstorage.cpp15
-rw-r--r--backends/cloud/dropbox/dropboxstorage.h5
2 files changed, 17 insertions, 3 deletions
diff --git a/backends/cloud/dropbox/dropboxstorage.cpp b/backends/cloud/dropbox/dropboxstorage.cpp
index a1a97e00dd..379d7bb611 100644
--- a/backends/cloud/dropbox/dropboxstorage.cpp
+++ b/backends/cloud/dropbox/dropboxstorage.cpp
@@ -24,6 +24,7 @@
#include "backends/cloud/dropbox/dropboxstorage.h"
#include "backends/cloud/dropbox/dropboxlistdirectoryrequest.h"
#include "backends/cloud/downloadrequest.h"
+#include "backends/cloud/folderdownloadrequest.h"
#include "backends/networking/curl/connectionmanager.h"
#include "backends/networking/curl/curljsonrequest.h"
#include "common/config-manager.h"
@@ -79,8 +80,9 @@ void DropboxStorage::saveConfig(Common::String keyPrefix) {
ConfMan.set(keyPrefix + "user_id", _uid, "cloud");
}
-void DropboxStorage::printFiles(Common::Array<StorageFile> files) {
+void DropboxStorage::printFiles(FileArrayResponse pair) {
debug("files:");
+ Common::Array<StorageFile> &files = pair.value;
for (uint32 i = 0; i < files.size(); ++i)
debug("\t%s", files[i].name().c_str());
}
@@ -116,11 +118,20 @@ Networking::Request *DropboxStorage::download(Common::String remotePath, Common:
return ConnMan.addRequest(new DownloadRequest(this, callback, remotePath, f));
}
+Networking::Request *DropboxStorage::downloadFolder(Common::String remotePath, Common::String localPath, FileArrayCallback callback, bool recursive) {
+ return ConnMan.addRequest(new FolderDownloadRequest(this, callback, remotePath, localPath, recursive));
+}
+
Networking::Request *DropboxStorage::syncSaves(BoolCallback callback) {
//this is not the real syncSaves() implementation
//"" is root in Dropbox, not "/"
//this must create all these directories:
- return 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);
+ return downloadFolder(
+ "/not_flat", "local/not_flat_1_level/",
+ new Common::Callback<DropboxStorage, FileArrayResponse>(this, &DropboxStorage::printFiles),
+ false
+ );
}
Networking::Request *DropboxStorage::info(StorageInfoCallback outerCallback) {
diff --git a/backends/cloud/dropbox/dropboxstorage.h b/backends/cloud/dropbox/dropboxstorage.h
index f95d0c9812..19f2f9cdd4 100644
--- a/backends/cloud/dropbox/dropboxstorage.h
+++ b/backends/cloud/dropbox/dropboxstorage.h
@@ -43,7 +43,7 @@ class DropboxStorage: public Cloud::Storage {
/** Constructs StorageInfo based on JSON response from cloud. */
void infoInnerCallback(StorageInfoCallback outerCallback, Networking::JsonResponse json);
- void printFiles(Common::Array<StorageFile> files);
+ void printFiles(FileArrayResponse pair);
public:
virtual ~DropboxStorage();
@@ -76,6 +76,9 @@ public:
/** Calls the callback when finished. */
virtual Networking::Request *download(Common::String remotePath, Common::String localPath, BoolCallback callback);
+ /** Returns Common::Array<StorageFile> with list of files, which were not downloaded. */
+ Networking::Request *downloadFolder(Common::String remotePath, Common::String localPath, FileArrayCallback callback, bool recursive = false);
+
/** Calls the callback when finished. */
virtual Networking::Request *remove(Common::String path, BoolCallback callback) { return nullptr; } //TODO