aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--gui/options.cpp2
-rw-r--r--gui/storagewizarddialog.cpp16
-rw-r--r--gui/storagewizarddialog.h3
9 files changed, 39 insertions, 36 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);
}
diff --git a/gui/options.cpp b/gui/options.cpp
index ee7e584e1c..34044b7acb 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -1320,7 +1320,7 @@ GlobalOptionsDialog::GlobalOptionsDialog(LauncherDialog *launcher)
_serverInfoLabel = new StaticTextWidget(container, "GlobalOptions_Cloud_Container.ServerInfoLabel", _("Not running"));
uint32 port = Networking::LocalWebserver::getPort();
- _serverPortDesc = new StaticTextWidget(container, "GlobalOptions_Cloud_Container.ServerPortDesc", _("Server's port:"), _("Which port is used by server"));
+ _serverPortDesc = new StaticTextWidget(container, "GlobalOptions_Cloud_Container.ServerPortDesc", _("Server's port:"), _("Which port is used by server\nAuth with server is not available with non-default port"));
_serverPort = new EditTextWidget(container, "GlobalOptions_Cloud_Container.ServerPortEditText", Common::String::format("%u", port), 0);
_serverPortClearButton = addClearButton(container, "GlobalOptions_Cloud_Container.ServerPortClearButton", kServerPortClearCmd);
diff --git a/gui/storagewizarddialog.cpp b/gui/storagewizarddialog.cpp
index b411a2e0dc..5838dd1f11 100644
--- a/gui/storagewizarddialog.cpp
+++ b/gui/storagewizarddialog.cpp
@@ -61,7 +61,7 @@ StorageWizardDialog::StorageWizardDialog(uint32 storageId):
new ButtonWidget(this, "GlobalOptions_Cloud_ConnectionWizard.OpenUrlButton", _("Open URL"), 0, kOpenUrlCmd);
_connectWidget = new ButtonWidget(this, "GlobalOptions_Cloud_ConnectionWizard.ConnectButton", _("Connect"), 0, kConnectCmd);
- if (couldUseLocalServer()) {
+ if (Cloud::CloudManager::couldUseLocalServer()) {
// hide fields and even the button if local webserver is on
returnLine1->setLabel(_s("You would be navigated to ScummVM's page"));
returnLine2->setLabel(_s("when you'd allow it to use your storage."));
@@ -97,7 +97,7 @@ void StorageWizardDialog::open() {
}
}
- if (couldUseLocalServer()) {
+ if (Cloud::CloudManager::couldUseLocalServer()) {
_stopServerOnClose = !LocalServer.isRunning();
LocalServer.start();
LocalServer.indexPageHandler().setTarget(this);
@@ -105,7 +105,7 @@ void StorageWizardDialog::open() {
}
void StorageWizardDialog::close() {
- if (couldUseLocalServer()) {
+ if (Cloud::CloudManager::couldUseLocalServer()) {
if (_stopServerOnClose) LocalServer.stopOnIdle();
LocalServer.indexPageHandler().setTarget(nullptr);
}
@@ -209,18 +209,10 @@ Common::String StorageWizardDialog::getUrl() const {
case Cloud::kStorageBoxId: url += "bx"; break;
}
- if (couldUseLocalServer()) url += "s";
+ if (Cloud::CloudManager::couldUseLocalServer()) url += "s";
return url;
}
-bool StorageWizardDialog::couldUseLocalServer() const {
-#ifdef USE_SDL_NET
- return Networking::LocalWebserver::getPort() == Networking::LocalWebserver::DEFAULT_SERVER_PORT;
-#else
- return false;
-#endif
-}
-
int StorageWizardDialog::decodeHashchar(char c) {
const char HASHCHARS[65] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ?!";
for (uint32 i = 0; i < 64; ++i)
diff --git a/gui/storagewizarddialog.h b/gui/storagewizarddialog.h
index 26e8cd42ab..6b00d60915 100644
--- a/gui/storagewizarddialog.h
+++ b/gui/storagewizarddialog.h
@@ -51,9 +51,6 @@ class StorageWizardDialog : public Dialog {
/** Return short scummvm.org URL for user to navigate to. */
Common::String getUrl() const;
- /** Return whether fields should be used or not. */
- bool couldUseLocalServer() const;
-
/**
* Return the value corresponding to the given character.
*