aboutsummaryrefslogtreecommitdiff
path: root/backends/cloud
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-21 12:06:00 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit772d8ee42b820a5c19a8d9a9efb215f17606fb8f (patch)
treec1bc3232d74fce1bdb12910e35b26c5de1f5d919 /backends/cloud
parent438ba985a4a97a8695a6e6fdda6930694976c07b (diff)
downloadscummvm-rg350-772d8ee42b820a5c19a8d9a9efb215f17606fb8f.tar.gz
scummvm-rg350-772d8ee42b820a5c19a8d9a9efb215f17606fb8f.tar.bz2
scummvm-rg350-772d8ee42b820a5c19a8d9a9efb215f17606fb8f.zip
CLOUD: Fix `redirect_uri` selection code
Now it's not hardcoded based on USE_SDL_NET, but one or another value is used depending on currently selected LocalWebserver's port.
Diffstat (limited to 'backends/cloud')
-rw-r--r--backends/cloud/box/boxstorage.cpp10
-rw-r--r--backends/cloud/cloudmanager.cpp11
-rw-r--r--backends/cloud/cloudmanager.h3
-rw-r--r--backends/cloud/dropbox/dropboxstorage.cpp10
-rw-r--r--backends/cloud/googledrive/googledrivestorage.cpp10
-rw-r--r--backends/cloud/onedrive/onedrivestorage.cpp10
6 files changed, 34 insertions, 20 deletions
diff --git a/backends/cloud/box/boxstorage.cpp b/backends/cloud/box/boxstorage.cpp
index 6d4b5efd8e..873e4fabc1 100644
--- a/backends/cloud/box/boxstorage.cpp
+++ b/backends/cloud/box/boxstorage.cpp
@@ -88,11 +88,11 @@ void BoxStorage::getAccessToken(BoolCallback callback, Networking::ErrorCallback
request->addPostField("client_id=" + Common::String(KEY));
request->addPostField("client_secret=" + Common::String(SECRET));
/*
-#ifdef USE_SDL_NET
- request->addPostField("&redirect_uri=http%3A%2F%2Flocalhost%3A12345");
-#else
- request->addPostField("&redirect_uri=https%3A%2F%2Fwww.scummvm.org/c/code");
-#endif
+ if (Cloud::CloudManager::couldUseLocalServer()) {
+ request->addPostField("&redirect_uri=http%3A%2F%2Flocalhost%3A12345");
+ } else {
+ request->addPostField("&redirect_uri=https%3A%2F%2Fwww.scummvm.org/c/code");
+ }
*/
addRequest(request);
}
diff --git a/backends/cloud/cloudmanager.cpp b/backends/cloud/cloudmanager.cpp
index a4763dba2d..f5b7c97afc 100644
--- a/backends/cloud/cloudmanager.cpp
+++ b/backends/cloud/cloudmanager.cpp
@@ -28,6 +28,9 @@
#include "common/translation.h"
#include "common/config-manager.h"
#include "common/str.h"
+#ifdef USE_SDL_NET
+#include "backends/networking/sdl_net/localwebserver.h"
+#endif
namespace Common {
@@ -296,6 +299,14 @@ bool CloudManager::isWorking() const {
return false;
}
+bool CloudManager::couldUseLocalServer() {
+#ifdef USE_SDL_NET
+ return Networking::LocalWebserver::getPort() == Networking::LocalWebserver::DEFAULT_SERVER_PORT;
+#else
+ return false;
+#endif
+}
+
///// SavesSyncRequest-related /////
bool CloudManager::isSyncing() const {
diff --git a/backends/cloud/cloudmanager.h b/backends/cloud/cloudmanager.h
index 0146a4118e..42aa7189b9 100644
--- a/backends/cloud/cloudmanager.h
+++ b/backends/cloud/cloudmanager.h
@@ -207,6 +207,9 @@ public:
/** Returns whether there are any requests running. */
bool isWorking() const;
+ /** Returns whether LocalWebserver is available to use for auth. */
+ static bool couldUseLocalServer();
+
///// SavesSyncRequest-related /////
/** Returns whether there is a SavesSyncRequest running. */
diff --git a/backends/cloud/dropbox/dropboxstorage.cpp b/backends/cloud/dropbox/dropboxstorage.cpp
index 7ef07a5a65..d35e29fb05 100644
--- a/backends/cloud/dropbox/dropboxstorage.cpp
+++ b/backends/cloud/dropbox/dropboxstorage.cpp
@@ -69,11 +69,11 @@ void DropboxStorage::getAccessToken(Common::String code) {
request->addPostField("grant_type=authorization_code");
request->addPostField("client_id=" + Common::String(KEY));
request->addPostField("client_secret=" + Common::String(SECRET));
-#ifdef USE_SDL_NET
- request->addPostField("&redirect_uri=http%3A%2F%2Flocalhost%3A12345%2F");
-#else
- request->addPostField("&redirect_uri=https%3A%2F%2Fwww.scummvm.org/c/code");
-#endif
+ if (Cloud::CloudManager::couldUseLocalServer()) {
+ request->addPostField("&redirect_uri=http%3A%2F%2Flocalhost%3A12345%2F");
+ } else {
+ request->addPostField("&redirect_uri=https%3A%2F%2Fwww.scummvm.org/c/code");
+ }
addRequest(request);
}
diff --git a/backends/cloud/googledrive/googledrivestorage.cpp b/backends/cloud/googledrive/googledrivestorage.cpp
index 2d9f33cfce..fbb5e69881 100644
--- a/backends/cloud/googledrive/googledrivestorage.cpp
+++ b/backends/cloud/googledrive/googledrivestorage.cpp
@@ -87,11 +87,11 @@ void GoogleDriveStorage::getAccessToken(BoolCallback callback, Networking::Error
}
request->addPostField("client_id=" + Common::String(KEY));
request->addPostField("client_secret=" + Common::String(SECRET));
-#ifdef USE_SDL_NET
- request->addPostField("&redirect_uri=http%3A%2F%2Flocalhost%3A12345");
-#else
- request->addPostField("&redirect_uri=https%3A%2F%2Fwww.scummvm.org/c/code");
-#endif
+ if (Cloud::CloudManager::couldUseLocalServer()) {
+ request->addPostField("&redirect_uri=http%3A%2F%2Flocalhost%3A12345");
+ } else {
+ request->addPostField("&redirect_uri=https%3A%2F%2Fwww.scummvm.org/c/code");
+ }
addRequest(request);
}
diff --git a/backends/cloud/onedrive/onedrivestorage.cpp b/backends/cloud/onedrive/onedrivestorage.cpp
index 5fc10b748c..7c1849e0da 100644
--- a/backends/cloud/onedrive/onedrivestorage.cpp
+++ b/backends/cloud/onedrive/onedrivestorage.cpp
@@ -88,11 +88,11 @@ void OneDriveStorage::getAccessToken(BoolCallback callback, Networking::ErrorCal
}
request->addPostField("client_id=" + Common::String(KEY));
request->addPostField("client_secret=" + Common::String(SECRET));
-#ifdef USE_SDL_NET
- request->addPostField("&redirect_uri=http%3A%2F%2Flocalhost%3A12345%2F");
-#else
- request->addPostField("&redirect_uri=https%3A%2F%2Fwww.scummvm.org/c/code");
-#endif
+ if (Cloud::CloudManager::couldUseLocalServer()) {
+ request->addPostField("&redirect_uri=http%3A%2F%2Flocalhost%3A12345%2F");
+ } else {
+ request->addPostField("&redirect_uri=https%3A%2F%2Fwww.scummvm.org/c/code");
+ }
addRequest(request);
}