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.
This commit is contained in:
parent
438ba985a4
commit
772d8ee42b
9 changed files with 39 additions and 36 deletions
|
@ -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
|
||||
if (Cloud::CloudManager::couldUseLocalServer()) {
|
||||
request->addPostField("&redirect_uri=http%3A%2F%2Flocalhost%3A12345");
|
||||
#else
|
||||
} else {
|
||||
request->addPostField("&redirect_uri=https%3A%2F%2Fwww.scummvm.org/c/code");
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
addRequest(request);
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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
|
||||
if (Cloud::CloudManager::couldUseLocalServer()) {
|
||||
request->addPostField("&redirect_uri=http%3A%2F%2Flocalhost%3A12345%2F");
|
||||
#else
|
||||
} else {
|
||||
request->addPostField("&redirect_uri=https%3A%2F%2Fwww.scummvm.org/c/code");
|
||||
#endif
|
||||
}
|
||||
addRequest(request);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
if (Cloud::CloudManager::couldUseLocalServer()) {
|
||||
request->addPostField("&redirect_uri=http%3A%2F%2Flocalhost%3A12345");
|
||||
#else
|
||||
} else {
|
||||
request->addPostField("&redirect_uri=https%3A%2F%2Fwww.scummvm.org/c/code");
|
||||
#endif
|
||||
}
|
||||
addRequest(request);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
if (Cloud::CloudManager::couldUseLocalServer()) {
|
||||
request->addPostField("&redirect_uri=http%3A%2F%2Flocalhost%3A12345%2F");
|
||||
#else
|
||||
} else {
|
||||
request->addPostField("&redirect_uri=https%3A%2F%2Fwww.scummvm.org/c/code");
|
||||
#endif
|
||||
}
|
||||
addRequest(request);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue