aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorAlexander Tkachev2016-05-11 15:15:23 +0600
committerAlexander Tkachev2016-08-24 16:05:07 +0600
commit7446ffd73bd184610d550a354a8e252b0b7f334d (patch)
tree66527d233886549ed881230f275cb3ebeb9c94a4 /backends
parent52240c68c7301b941f51ea315994ee7e4665707b (diff)
downloadscummvm-rg350-7446ffd73bd184610d550a354a8e252b0b7f334d.tar.gz
scummvm-rg350-7446ffd73bd184610d550a354a8e252b0b7f334d.tar.bz2
scummvm-rg350-7446ffd73bd184610d550a354a8e252b0b7f334d.zip
CLOUD: Integrate CloudThread into OSystem
Would be changed soon.
Diffstat (limited to 'backends')
-rw-r--r--backends/cloud/cloudthread.cpp21
-rw-r--r--backends/cloud/cloudthread.h11
-rw-r--r--backends/platform/sdl/sdl.cpp7
3 files changed, 34 insertions, 5 deletions
diff --git a/backends/cloud/cloudthread.cpp b/backends/cloud/cloudthread.cpp
index f8d93d2baa..813354f43f 100644
--- a/backends/cloud/cloudthread.cpp
+++ b/backends/cloud/cloudthread.cpp
@@ -23,6 +23,8 @@
#include "cloudthread.h"
#include "common/debug.h"
#include "common/json.h"
+#include "common/system.h"
+#include "common/timer.h"
void example1();
void example2();
@@ -30,10 +32,10 @@ void example3();
void cloudThread(void *thread) {
CloudThread *cloudThread = (CloudThread *)thread;
- cloudThread->work();
+ cloudThread->handler();
};
-void CloudThread::work() {
+void CloudThread::handler() {
if (_firstTime) {
_firstTime = false;
@@ -43,6 +45,21 @@ void CloudThread::work() {
} else { }
}
+void CloudThread::setTimeout(int interval) {
+ Common::TimerManager *manager = g_system->getTimerManager();
+ if (!manager->installTimerProc(cloudThread, interval, this, "Cloud Thread"))
+ warning("Failed to create cloud thread");
+}
+
+void CloudThread::unsetTimeout() {
+ Common::TimerManager *manager = g_system->getTimerManager();
+ manager->removeTimerProc(cloudThread);
+}
+
+void CloudThread::start() {
+ setTimeout(1000000); //in one second
+}
+
/// SimpleJSON examples:
using Common::JSON;
diff --git a/backends/cloud/cloudthread.h b/backends/cloud/cloudthread.h
index ce448b7274..334a163dde 100644
--- a/backends/cloud/cloudthread.h
+++ b/backends/cloud/cloudthread.h
@@ -23,14 +23,19 @@
#ifndef BACKENDS_CLOUD_CLOUDTHREAD_H
#define BACKENDS_CLOUD_CLOUDTHREAD_H
-void cloudThread(void *thread); //this one is passed to TimerManager in main()
-
class CloudThread {
+ friend void cloudThread(void*); //calls private handler()
+
bool _firstTime;
+
+ void handler();
+ void setTimeout(int interval);
+ void unsetTimeout();
+
public:
CloudThread(): _firstTime(true) {};
- void work();
+ void start();
};
#endif
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index dca6891fef..84aa5c8421 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -33,6 +33,7 @@
#include "gui/EventRecorder.h"
#include "common/taskbar.h"
#include "common/textconsole.h"
+#include "backends/cloud/cloudthread.h"
#include "backends/saves/default/default-saves.h"
@@ -158,6 +159,12 @@ void OSystem_SDL::init() {
_taskbarManager = new Common::TaskbarManager();
#endif
+//TODO: define USE_CLOUD
+//#if defined(USE_CLOUD)
+ if (_cloudThread == 0)
+ _cloudThread = new CloudThread();
+//#endif
+
}
void OSystem_SDL::initBackend() {