aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorAlexander Tkachev2016-06-10 14:28:04 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit6a93e8dd09ae2eeab616d14189a58633fd928c07 (patch)
tree80f8c7e52ad62321d8eed5864fa168803c99e272 /backends
parentc99b24c16d1111a701d915832f24ac457aef697d (diff)
downloadscummvm-rg350-6a93e8dd09ae2eeab616d14189a58633fd928c07.tar.gz
scummvm-rg350-6a93e8dd09ae2eeab616d14189a58633fd928c07.tar.bz2
scummvm-rg350-6a93e8dd09ae2eeab616d14189a58633fd928c07.zip
CLOUD: Add ConnMan::urlEncode()
Tried to use it everywhere I should've use it.
Diffstat (limited to 'backends')
-rw-r--r--backends/cloud/googledrive/googledrivestorage.cpp2
-rw-r--r--backends/cloud/googledrive/googledriveuploadrequest.cpp2
-rw-r--r--backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp2
-rw-r--r--backends/cloud/onedrive/onedrivelistdirectoryrequest.cpp5
-rw-r--r--backends/cloud/onedrive/onedrivestorage.cpp2
-rw-r--r--backends/cloud/onedrive/onedriveuploadrequest.cpp4
-rw-r--r--backends/networking/curl/connectionmanager.cpp11
-rw-r--r--backends/networking/curl/connectionmanager.h3
8 files changed, 23 insertions, 8 deletions
diff --git a/backends/cloud/googledrive/googledrivestorage.cpp b/backends/cloud/googledrive/googledrivestorage.cpp
index 91d8c819e7..5eab071599 100644
--- a/backends/cloud/googledrive/googledrivestorage.cpp
+++ b/backends/cloud/googledrive/googledrivestorage.cpp
@@ -234,7 +234,7 @@ Networking::Request *GoogleDriveStorage::streamFile(Common::String path, Network
Networking::Request *GoogleDriveStorage::streamFileById(Common::String id, Networking::NetworkReadStreamCallback callback, Networking::ErrorCallback errorCallback) {
if (callback) {
- Common::String url = "https://www.googleapis.com/drive/v3/files/" + id + "?alt=media";
+ Common::String url = "https://www.googleapis.com/drive/v3/files/" + ConnMan.urlEncode(id) + "?alt=media";
Common::String header = "Authorization: Bearer " + _token;
curl_slist *headersList = curl_slist_append(nullptr, header.c_str());
Networking::NetworkReadStream *stream = new Networking::NetworkReadStream(url.c_str(), headersList, "");
diff --git a/backends/cloud/googledrive/googledriveuploadrequest.cpp b/backends/cloud/googledrive/googledriveuploadrequest.cpp
index 8dd8ffcc9a..ce1fae2579 100644
--- a/backends/cloud/googledrive/googledriveuploadrequest.cpp
+++ b/backends/cloud/googledrive/googledriveuploadrequest.cpp
@@ -108,7 +108,7 @@ void GoogleDriveUploadRequest::startUpload() {
}
Common::String url = "https://www.googleapis.com/upload/drive/v3/files";
- if (_resolvedId != "") url += "/" + _resolvedId;
+ if (_resolvedId != "") url += "/" + ConnMan.urlEncode(_resolvedId);
url += "?uploadType=resumable&fields=id,mimeType,modifiedTime,name,size";
Networking::JsonCallback callback = new Common::Callback<GoogleDriveUploadRequest, Networking::JsonResponse>(this, &GoogleDriveUploadRequest::startUploadCallback);
Networking::ErrorCallback failureCallback = new Common::Callback<GoogleDriveUploadRequest, Networking::ErrorResponse>(this, &GoogleDriveUploadRequest::startUploadErrorCallback);
diff --git a/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp b/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp
index c48ae1dfbe..fe1128bd5b 100644
--- a/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp
+++ b/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp
@@ -63,7 +63,7 @@ void OneDriveCreateDirectoryRequest::start() {
}
Common::String url = "https://api.onedrive.com/v1.0/drive/special/approot";
- if (parent != "") url += ":/" + parent + ":";
+ if (parent != "") url += ":/" + ConnMan.urlEncode(parent) + ":";
url += "/children";
Networking::JsonCallback innerCallback = new Common::Callback<OneDriveCreateDirectoryRequest, Networking::JsonResponse>(this, &OneDriveCreateDirectoryRequest::responseCallback);
Networking::ErrorCallback errorCallback = new Common::Callback<OneDriveCreateDirectoryRequest, Networking::ErrorResponse>(this, &OneDriveCreateDirectoryRequest::errorCallback);
diff --git a/backends/cloud/onedrive/onedrivelistdirectoryrequest.cpp b/backends/cloud/onedrive/onedrivelistdirectoryrequest.cpp
index e362600389..040ef153db 100644
--- a/backends/cloud/onedrive/onedrivelistdirectoryrequest.cpp
+++ b/backends/cloud/onedrive/onedrivelistdirectoryrequest.cpp
@@ -70,8 +70,9 @@ void OneDriveListDirectoryRequest::listNextDirectory() {
if (_currentDirectory != "" && _currentDirectory.lastChar() != '/' && _currentDirectory.lastChar() != '\\')
_currentDirectory += '/';
- Common::String url = "https://api.onedrive.com/v1.0/drive/special/approot:/" + _currentDirectory;
- url.deleteLastChar();
+ Common::String dir = _currentDirectory;
+ dir.deleteLastChar();
+ Common::String url = "https://api.onedrive.com/v1.0/drive/special/approot:/" + ConnMan.urlEncode(dir);
url += ":/children";
makeRequest(url);
}
diff --git a/backends/cloud/onedrive/onedrivestorage.cpp b/backends/cloud/onedrive/onedrivestorage.cpp
index 178d43c8be..d1971f904a 100644
--- a/backends/cloud/onedrive/onedrivestorage.cpp
+++ b/backends/cloud/onedrive/onedrivestorage.cpp
@@ -214,7 +214,7 @@ Networking::Request *OneDriveStorage::upload(Common::String path, Common::Seekab
}
Networking::Request *OneDriveStorage::streamFileById(Common::String path, Networking::NetworkReadStreamCallback outerCallback, Networking::ErrorCallback errorCallback) {
- Common::String url = "https://api.onedrive.com/v1.0/drive/special/approot:/" + path;
+ Common::String url = "https://api.onedrive.com/v1.0/drive/special/approot:/" + ConnMan.urlEncode(path);
Networking::JsonCallback innerCallback = new Common::CallbackBridge<OneDriveStorage, Networking::NetworkReadStreamResponse, Networking::JsonResponse>(this, &OneDriveStorage::fileInfoCallback, outerCallback);
Networking::CurlJsonRequest *request = new OneDriveTokenRefresher(this, innerCallback, errorCallback, url.c_str());
request->addHeader("Authorization: Bearer " + _token);
diff --git a/backends/cloud/onedrive/onedriveuploadrequest.cpp b/backends/cloud/onedrive/onedriveuploadrequest.cpp
index 752907f333..bc54a811a9 100644
--- a/backends/cloud/onedrive/onedriveuploadrequest.cpp
+++ b/backends/cloud/onedrive/onedriveuploadrequest.cpp
@@ -63,7 +63,7 @@ void OneDriveUploadRequest::uploadNextPart() {
const uint32 UPLOAD_PER_ONE_REQUEST = 10 * 1024 * 1024;
if (_uploadUrl == "" && _contentsStream->size() > UPLOAD_PER_ONE_REQUEST) {
- Common::String url = "https://api.onedrive.com/v1.0/drive/special/approot:/"+_savePath+":/upload.createSession"; //folder must exist
+ Common::String url = "https://api.onedrive.com/v1.0/drive/special/approot:/"+ConnMan.urlEncode(_savePath)+":/upload.createSession"; //folder must exist
Networking::JsonCallback callback = new Common::Callback<OneDriveUploadRequest, Networking::JsonResponse>(this, &OneDriveUploadRequest::partUploadedCallback);
Networking::ErrorCallback failureCallback = new Common::Callback<OneDriveUploadRequest, Networking::ErrorResponse>(this, &OneDriveUploadRequest::partUploadedErrorCallback);
Networking::CurlJsonRequest *request = new OneDriveTokenRefresher(_storage, callback, failureCallback, url.c_str());
@@ -75,7 +75,7 @@ void OneDriveUploadRequest::uploadNextPart() {
Common::String url;
if (_uploadUrl == "") {
- url = "https://api.onedrive.com/v1.0/drive/special/approot:/"+_savePath+":/content";
+ url = "https://api.onedrive.com/v1.0/drive/special/approot:/"+ConnMan.urlEncode(_savePath)+":/content";
} else {
url = _uploadUrl;
}
diff --git a/backends/networking/curl/connectionmanager.cpp b/backends/networking/curl/connectionmanager.cpp
index edc7e81229..5a1e3e97c1 100644
--- a/backends/networking/curl/connectionmanager.cpp
+++ b/backends/networking/curl/connectionmanager.cpp
@@ -78,6 +78,17 @@ void ConnectionManager::showCloudDisabledIcon() {
startTimer();
}
+Common::String ConnectionManager::urlEncode(Common::String s) {
+ if (!_multi) return "";
+ char *output = curl_easy_escape(_multi, s.c_str(), s.size());
+ if (output) {
+ Common::String result = output;
+ curl_free(output);
+ return result;
+ }
+ return "";
+}
+
//private goes here:
void connectionsThread(void *ignored) {
diff --git a/backends/networking/curl/connectionmanager.h b/backends/networking/curl/connectionmanager.h
index 66994f0a79..602f8930cd 100644
--- a/backends/networking/curl/connectionmanager.h
+++ b/backends/networking/curl/connectionmanager.h
@@ -117,6 +117,9 @@ public:
/** Shows a "cloud disabled" icon for a three seconds. */
void showCloudDisabledIcon();
+
+ /** Return URL-encoded version of given string. */
+ Common::String urlEncode(Common::String s);
};
/** Shortcut for accessing the connection manager. */