From 8429c40362b1e4d4010f808740b79baae69c97ed Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 11 May 2016 01:10:37 +0600 Subject: CLOUD: Add SimpleJSON library as Common::JSON This commit also adds CloudThread class, which work() method is called every second by TimerManager. Right now it prints JSON examples on the console, so that's why it's introduced with SimpleJSON library. --- base/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'base/main.cpp') diff --git a/base/main.cpp b/base/main.cpp index 1667106543..593179d80e 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -66,6 +66,7 @@ #endif #include "backends/keymapper/keymapper.h" +#include "backends/cloud/cloudthread.h" #if defined(_WIN32_WCE) #include "backends/platform/wince/CELauncherDialog.h" @@ -475,6 +476,11 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { dlg.runModal(); } #endif + + CloudThread thread; + Common::TimerManager *manager = system.getTimerManager(); + if (!manager->installTimerProc(cloudThread, 1000000, &thread, "Cloud Thread")) + warning("Failed to create cloud thread"); // Unless a game was specified, show the launcher dialog if (0 == ConfMan.getActiveDomain()) -- cgit v1.2.3 From 7446ffd73bd184610d550a354a8e252b0b7f334d Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 11 May 2016 15:15:23 +0600 Subject: CLOUD: Integrate CloudThread into OSystem Would be changed soon. --- base/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'base/main.cpp') diff --git a/base/main.cpp b/base/main.cpp index 593179d80e..ce69117bc6 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -477,10 +477,10 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { } #endif - CloudThread thread; - Common::TimerManager *manager = system.getTimerManager(); - if (!manager->installTimerProc(cloudThread, 1000000, &thread, "Cloud Thread")) - warning("Failed to create cloud thread"); + //TODO: define USE_CLOUD +//#ifdef USE_CLOUD + system.getCloudThread()->start(); +//#endif // Unless a game was specified, show the launcher dialog if (0 == ConfMan.getActiveDomain()) -- cgit v1.2.3 From ca2eeb221455e54505aaef7039cfc0b01b807179 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 11 May 2016 20:24:53 +0600 Subject: CLOUD: Add Cloud::Manager and Cloud::Storage This commit introduces Common::CloudManager, which can be accessed from OSystem. The backend for this manager is Cloud::Manager (defined in backends/cloud/manager.h). It should load all users storages from configs and provide access to current Storage instance. For now it just creates a new one. Cloud::Storage (backends/cloud/storage.h) provides an API to interact with cloud storage, for example, create new directory or sync files. Right now it's not ready and has only two dummy methods: listDirectory() and syncSaves(). There is Cloud::Dropbox::DropboxStorage backend (backends/cloud/dropbox/dropboxstorage.h) for Cloud::Storage. Right now it implements both listDirectory() and syncSaves() with starting timer task and handling it by printing out some JSON examples. --- base/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'base/main.cpp') diff --git a/base/main.cpp b/base/main.cpp index ce69117bc6..001d864355 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -66,7 +66,7 @@ #endif #include "backends/keymapper/keymapper.h" -#include "backends/cloud/cloudthread.h" +#include "common/cloudmanager.h" #if defined(_WIN32_WCE) #include "backends/platform/wince/CELauncherDialog.h" @@ -479,7 +479,7 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { //TODO: define USE_CLOUD //#ifdef USE_CLOUD - system.getCloudThread()->start(); + system.getCloudManager()->syncSaves(); //#endif // Unless a game was specified, show the launcher dialog -- cgit v1.2.3 From fade746f374cc801870e68934f1dbb3e9c726198 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 11 May 2016 22:52:14 +0600 Subject: CLOUD: Add USE_CLOUD feature Adds USE_CLOUD in both configure and create_project. --- base/main.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'base/main.cpp') diff --git a/base/main.cpp b/base/main.cpp index 001d864355..ac24376e37 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -476,11 +476,10 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { dlg.runModal(); } #endif - - //TODO: define USE_CLOUD -//#ifdef USE_CLOUD + +#ifdef USE_CLOUD system.getCloudManager()->syncSaves(); -//#endif +#endif // Unless a game was specified, show the launcher dialog if (0 == ConfMan.getActiveDomain()) -- cgit v1.2.3 From e743a65636a674def45e955cb7a5632aead2a033 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 18 May 2016 14:08:05 +0600 Subject: CLOUD: Add Dropbox into CloudManager's configs This commit adds: * ConfMan's new "cloud" domain; * CloudManager's init() method, where it loads keys from "cloud" configs domain; * CurlJsonRequest's addHeader() and addPostField() methods; * temporary Storage's printInfo() method; * DropboxStorage's implementation of printInfo(), which is using access token and user id; * DropboxStorage's loadFromConfig() static method to load access token and user id from configs and create a Storage instance with those; * temporary DropboxStorage's authThroughConsole() static method, which guides user through auth process from the console. So, in CloudManager's init() implementation ScummVM checks that there is "current_storage_type" key in "cloud" domain of configs, and loads corresponding storage if there is such key. If there is no such key, ScummVM offers user to auth with Dropbox. That's done through console, and thus it's temporary (it also requires restarting ScummVM twice and manually editing config.ini file). --- base/main.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'base/main.cpp') diff --git a/base/main.cpp b/base/main.cpp index ac24376e37..f629eb98d8 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -478,6 +478,7 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { #endif #ifdef USE_CLOUD + system.getCloudManager()->init(); system.getCloudManager()->syncSaves(); #endif -- cgit v1.2.3 From 4e7dec550077bc37cf254311aefb621cdeebbdfe Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Tue, 31 May 2016 20:54:41 +0600 Subject: CLOUD: Add DropboxCreateDirectoryRequest Also add CloudManager::testFeature(), because syncSaves() now works fine and I don't want to break it again and again with my testing requests. --- base/main.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'base/main.cpp') diff --git a/base/main.cpp b/base/main.cpp index f629eb98d8..36dd8c6f18 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -480,6 +480,7 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { #ifdef USE_CLOUD system.getCloudManager()->init(); system.getCloudManager()->syncSaves(); + system.getCloudManager()->testFeature(); //TODO: remove later #endif // Unless a game was specified, show the launcher dialog -- cgit v1.2.3 From 1f974a7a2a2073074391fbf090d2bf909006e773 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 1 Jun 2016 14:07:50 +0600 Subject: CLOUD: Fix ConnectionManager's destructor It now terminates active Requests. --- base/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'base/main.cpp') diff --git a/base/main.cpp b/base/main.cpp index 36dd8c6f18..aede61790c 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -67,6 +67,9 @@ #include "backends/keymapper/keymapper.h" #include "common/cloudmanager.h" +#ifdef USE_LIBCURL +#include "backends/networking/curl/connectionmanager.h" +#endif #if defined(_WIN32_WCE) #include "backends/platform/wince/CELauncherDialog.h" @@ -591,6 +594,9 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { launcherDialog(); } } +#ifdef USE_LIBCURL + Networking::ConnectionManager::destroy(); +#endif PluginManager::instance().unloadAllPlugins(); PluginManager::destroy(); GUI::GuiManager::destroy(); -- cgit v1.2.3 From b3bf5322117d03c003011839ea1e7897c48183fa Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 1 Jun 2016 16:22:42 +0600 Subject: CLOUD: Make CloudManager singleton It's needed to ::destroy() it in main(). --- base/main.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'base/main.cpp') diff --git a/base/main.cpp b/base/main.cpp index aede61790c..4edc7a957a 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -66,7 +66,9 @@ #endif #include "backends/keymapper/keymapper.h" -#include "common/cloudmanager.h" +#ifdef USE_CLOUD +#include "backends/cloud/cloudmanager.h" +#endif #ifdef USE_LIBCURL #include "backends/networking/curl/connectionmanager.h" #endif @@ -481,9 +483,9 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { #endif #ifdef USE_CLOUD - system.getCloudManager()->init(); - system.getCloudManager()->syncSaves(); - system.getCloudManager()->testFeature(); //TODO: remove later + CloudMan.init(); + CloudMan.syncSaves(); + CloudMan.testFeature(); //TODO: remove later #endif // Unless a game was specified, show the launcher dialog @@ -596,6 +598,10 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { } #ifdef USE_LIBCURL Networking::ConnectionManager::destroy(); +#endif +#ifdef USE_CLOUD + //I think it's important to destroy it after ConnectionManager + Cloud::CloudManager::destroy(); #endif PluginManager::instance().unloadAllPlugins(); PluginManager::destroy(); -- cgit v1.2.3 From 0af97e59bc63538d18d2241285b68ed287ccd87c Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 15 Jun 2016 16:38:37 +0600 Subject: CLOUD: Add LocalWebserver Available as LocalServer singleton. It's being started and stopped by StorageWizardDialog. It doesn't handle clients yet, though. --- base/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'base/main.cpp') diff --git a/base/main.cpp b/base/main.cpp index 4edc7a957a..6c91305381 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -72,6 +72,9 @@ #ifdef USE_LIBCURL #include "backends/networking/curl/connectionmanager.h" #endif +#ifdef USE_SDL_NET +#include "backends/networking/sdl_net/localwebserver.h" +#endif #if defined(_WIN32_WCE) #include "backends/platform/wince/CELauncherDialog.h" @@ -596,6 +599,9 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { launcherDialog(); } } +#ifdef USE_SDL_NET + Networking::LocalWebserver::destroy(); +#endif #ifdef USE_LIBCURL Networking::ConnectionManager::destroy(); #endif -- cgit v1.2.3 From 3da38ca60b65d3f1bd67b049f3c4b2a90a4d6a19 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Tue, 5 Jul 2016 15:05:30 +0600 Subject: CLOUD: Replace USE_CLOUD with USE_LIBCURL In most cases that's the right one to check. USE_CLOUD is defined when either USE_LIBCURL or USE_SDL_NET are, which means if there is no curl, USE_CLOUD still could be defined and linking errors would appear. --- base/main.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'base/main.cpp') diff --git a/base/main.cpp b/base/main.cpp index 6c91305381..dd2c3f54e6 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -66,10 +66,8 @@ #endif #include "backends/keymapper/keymapper.h" -#ifdef USE_CLOUD -#include "backends/cloud/cloudmanager.h" -#endif #ifdef USE_LIBCURL +#include "backends/cloud/cloudmanager.h" #include "backends/networking/curl/connectionmanager.h" #endif #ifdef USE_SDL_NET @@ -485,7 +483,7 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { } #endif -#ifdef USE_CLOUD +#ifdef USE_LIBCURL CloudMan.init(); CloudMan.syncSaves(); CloudMan.testFeature(); //TODO: remove later @@ -604,8 +602,6 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { #endif #ifdef USE_LIBCURL Networking::ConnectionManager::destroy(); -#endif -#ifdef USE_CLOUD //I think it's important to destroy it after ConnectionManager Cloud::CloudManager::destroy(); #endif -- cgit v1.2.3 From b180c73675846f45abab2190b39e0b9d0d6addbf Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 20 Jul 2016 18:47:34 +0600 Subject: CLOUD: Do some refactoring/cleanup Nothing really major. --- base/main.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'base/main.cpp') diff --git a/base/main.cpp b/base/main.cpp index dd2c3f54e6..6b6868b78a 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -486,7 +486,6 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { #ifdef USE_LIBCURL CloudMan.init(); CloudMan.syncSaves(); - CloudMan.testFeature(); //TODO: remove later #endif // Unless a game was specified, show the launcher dialog -- cgit v1.2.3