aboutsummaryrefslogtreecommitdiff
path: root/backends/cloud
diff options
context:
space:
mode:
authorAlexander Tkachev2019-07-14 04:42:40 +0700
committerMatan Bareket2019-07-30 14:51:41 -0400
commitddcfcc18b2b4fc17e2217014ad069dc95fbf4fa1 (patch)
tree87a6313ba9dc199d239a9dc8e6ea44669533fb19 /backends/cloud
parent1bebaf96f7ba1b11417fb16b69b7baebb711ae42 (diff)
downloadscummvm-rg350-ddcfcc18b2b4fc17e2217014ad069dc95fbf4fa1.tar.gz
scummvm-rg350-ddcfcc18b2b4fc17e2217014ad069dc95fbf4fa1.tar.bz2
scummvm-rg350-ddcfcc18b2b4fc17e2217014ad069dc95fbf4fa1.zip
CLOUD: Update DropboxStorage to work via scummvm.org & StorageWizardDialog correspondingly
Diffstat (limited to 'backends/cloud')
-rw-r--r--backends/cloud/cloudmanager.cpp8
-rw-r--r--backends/cloud/cloudmanager.h3
-rw-r--r--backends/cloud/dropbox/dropboxstorage.cpp40
-rw-r--r--backends/cloud/dropbox/dropboxstorage.h4
-rw-r--r--backends/cloud/googledrive/googledrivestorage.cpp6
-rw-r--r--backends/cloud/onedrive/onedrivestorage.cpp6
6 files changed, 7 insertions, 60 deletions
diff --git a/backends/cloud/cloudmanager.cpp b/backends/cloud/cloudmanager.cpp
index 5519e4baab..20c279323c 100644
--- a/backends/cloud/cloudmanager.cpp
+++ b/backends/cloud/cloudmanager.cpp
@@ -336,14 +336,6 @@ 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 f58ea8373a..eb882a63af 100644
--- a/backends/cloud/cloudmanager.h
+++ b/backends/cloud/cloudmanager.h
@@ -227,9 +227,6 @@ 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 b856c6cb2c..bf964ae51b 100644
--- a/backends/cloud/dropbox/dropboxstorage.cpp
+++ b/backends/cloud/dropbox/dropboxstorage.cpp
@@ -42,29 +42,9 @@
namespace Cloud {
namespace Dropbox {
-#define DROPBOX_OAUTH2_TOKEN "https://api.dropboxapi.com/oauth2/token"
+#define DROPBOX_OAUTH2_TOKEN "https://scummvm.org/admin/cloud/cloud/dropbox/token/"
#define DROPBOX_API_FILES_DOWNLOAD "https://content.dropboxapi.com/2/files/download"
-char *DropboxStorage::KEY = nullptr; //can't use CloudConfig there yet, loading it on instance creation/auth
-char *DropboxStorage::SECRET = nullptr;
-
-void DropboxStorage::loadKeyAndSecret() {
-#ifdef ENABLE_RELEASE
- KEY = RELEASE_DROPBOX_KEY;
- SECRET = RELEASE_DROPBOX_SECRET;
-#else
- Common::String k = ConfMan.get("DROPBOX_KEY", ConfMan.kCloudDomain);
- KEY = new char[k.size() + 1];
- memcpy(KEY, k.c_str(), k.size());
- KEY[k.size()] = 0;
-
- k = ConfMan.get("DROPBOX_SECRET", ConfMan.kCloudDomain);
- SECRET = new char[k.size() + 1];
- memcpy(SECRET, k.c_str(), k.size());
- SECRET[k.size()] = 0;
-#endif
-}
-
DropboxStorage::DropboxStorage(Common::String accessToken, Common::String userId): _token(accessToken), _uid(userId) {}
DropboxStorage::DropboxStorage(Common::String code) {
@@ -74,20 +54,12 @@ DropboxStorage::DropboxStorage(Common::String code) {
DropboxStorage::~DropboxStorage() {}
void DropboxStorage::getAccessToken(Common::String code) {
- if (!KEY || !SECRET)
- loadKeyAndSecret();
Networking::JsonCallback callback = new Common::Callback<DropboxStorage, Networking::JsonResponse>(this, &DropboxStorage::codeFlowComplete);
Networking::ErrorCallback errorCallback = new Common::Callback<DropboxStorage, Networking::ErrorResponse>(this, &DropboxStorage::codeFlowFailed);
- Networking::CurlJsonRequest *request = new Networking::CurlJsonRequest(callback, errorCallback, DROPBOX_OAUTH2_TOKEN);
- request->addPostField("code=" + code);
- request->addPostField("grant_type=authorization_code");
- request->addPostField("client_id=" + Common::String(KEY));
- request->addPostField("client_secret=" + Common::String(SECRET));
- 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");
- }
+
+ Common::String url = Common::String(DROPBOX_OAUTH2_TOKEN) + code;
+ Networking::CurlJsonRequest *request = new Networking::CurlJsonRequest(callback, errorCallback, url);
+
addRequest(request);
}
@@ -177,8 +149,6 @@ Networking::Request *DropboxStorage::info(StorageInfoCallback callback, Networki
Common::String DropboxStorage::savesDirectoryPath() { return "/saves/"; }
DropboxStorage *DropboxStorage::loadFromConfig(Common::String keyPrefix) {
- loadKeyAndSecret();
-
if (!ConfMan.hasKey(keyPrefix + "access_token", ConfMan.kCloudDomain)) {
warning("DropboxStorage: no access_token found");
return nullptr;
diff --git a/backends/cloud/dropbox/dropboxstorage.h b/backends/cloud/dropbox/dropboxstorage.h
index 44fb8a3475..eec34d8bc5 100644
--- a/backends/cloud/dropbox/dropboxstorage.h
+++ b/backends/cloud/dropbox/dropboxstorage.h
@@ -31,10 +31,6 @@ namespace Cloud {
namespace Dropbox {
class DropboxStorage: public Cloud::Storage {
- static char *KEY, *SECRET;
-
- static void loadKeyAndSecret();
-
Common::String _token, _uid;
/** This private constructor is called from loadFromConfig(). */
diff --git a/backends/cloud/googledrive/googledrivestorage.cpp b/backends/cloud/googledrive/googledrivestorage.cpp
index 4a870c01b6..8bd9228714 100644
--- a/backends/cloud/googledrive/googledrivestorage.cpp
+++ b/backends/cloud/googledrive/googledrivestorage.cpp
@@ -105,11 +105,7 @@ void GoogleDriveStorage::getAccessToken(BoolCallback callback, Networking::Error
}
request->addPostField("client_id=" + Common::String(KEY));
request->addPostField("client_secret=" + Common::String(SECRET));
- 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");
- }
+ 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 9f7cad2e01..396370e23f 100644
--- a/backends/cloud/onedrive/onedrivestorage.cpp
+++ b/backends/cloud/onedrive/onedrivestorage.cpp
@@ -105,11 +105,7 @@ void OneDriveStorage::getAccessToken(BoolCallback callback, Networking::ErrorCal
}
request->addPostField("client_id=" + Common::String(KEY));
request->addPostField("client_secret=" + Common::String(SECRET));
- 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");
- }
+ request->addPostField("&redirect_uri=https%3A%2F%2Fwww.scummvm.org/c/code");
addRequest(request);
}