diff options
author | Alexander Tkachev | 2016-06-07 13:49:26 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | 505d3764cb9c873b1dbefcb0d7b2cc7b587c6a42 (patch) | |
tree | 8cc195cecb86d8cfe19d74749f995ca229cf6c7c /backends/cloud/googledrive/googledrivelistdirectorybyidrequest.cpp | |
parent | d1d71afb0724c372143d2c303c70291ba43d2d68 (diff) | |
download | scummvm-rg350-505d3764cb9c873b1dbefcb0d7b2cc7b587c6a42.tar.gz scummvm-rg350-505d3764cb9c873b1dbefcb0d7b2cc7b587c6a42.tar.bz2 scummvm-rg350-505d3764cb9c873b1dbefcb0d7b2cc7b587c6a42.zip |
CLOUD: Fix GoogleDriveStorage to work with root folder
Now it needs another scope and uses "root" instead of "appDataFolder".
Diffstat (limited to 'backends/cloud/googledrive/googledrivelistdirectorybyidrequest.cpp')
-rw-r--r-- | backends/cloud/googledrive/googledrivelistdirectorybyidrequest.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/backends/cloud/googledrive/googledrivelistdirectorybyidrequest.cpp b/backends/cloud/googledrive/googledrivelistdirectorybyidrequest.cpp index 0915b623f3..f7aa7a1c0c 100644 --- a/backends/cloud/googledrive/googledrivelistdirectorybyidrequest.cpp +++ b/backends/cloud/googledrive/googledrivelistdirectorybyidrequest.cpp @@ -55,7 +55,8 @@ void GoogleDriveListDirectoryByIdRequest::start() { } void GoogleDriveListDirectoryByIdRequest::makeRequest(Common::String pageToken) { - Common::String url = "https://www.googleapis.com/drive/v3/files?spaces=appDataFolder"; + Common::String url = "https://www.googleapis.com/drive/v3/files?spaces=drive&fields=files%28id,mimeType,modifiedTime,name,size%29,nextPageToken"; + //files(id,mimeType,modifiedTime,name,size),nextPageToken if (pageToken != "") url += "&pageToken=" + pageToken; url += "&q=%27" + _requestedId + "%27+in+parents"; @@ -66,6 +67,17 @@ void GoogleDriveListDirectoryByIdRequest::makeRequest(Common::String pageToken) _workingRequest = ConnMan.addRequest(request); } +namespace { +uint64 atoull(Common::String s) { + uint64 result = 0; + for (uint32 i = 0; i < s.size(); ++i) { + if (s[i] < '0' || s[i] > '9') break; + result = result * 10L + (s[i] - '0'); + } + return result; +} +} + void GoogleDriveListDirectoryByIdRequest::responseCallback(Networking::JsonResponse response) { _workingRequest = nullptr; if (_ignoreCallback) return; @@ -100,10 +112,10 @@ void GoogleDriveListDirectoryByIdRequest::responseCallback(Networking::JsonRespo Common::String name = item.getVal("name")->asString(); bool isDirectory = (item.getVal("mimeType")->asString() == "application/vnd.google-apps.folder"); uint32 size = 0, timestamp = 0; - if (!isDirectory) { - size = item.getVal("size")->asIntegerNumber(); + if (item.contains("size") && item.getVal("size")->isString()) + size = atoull(item.getVal("size")->asString()); + if (item.contains("modifiedTime") && item.getVal("modifiedTime")->isString()) timestamp = ISO8601::convertToTimestamp(item.getVal("modifiedTime")->asString()); - } _files.push_back(StorageFile(path, name, size, timestamp, isDirectory)); } } |