diff options
author | Alexander Tkachev | 2016-05-21 21:30:25 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | e1109c0c328aaf671e2b03b3b4e6de1ae9061754 (patch) | |
tree | df4beeb28006b68c6d60953c164f53660f74b376 /backends/networking | |
parent | ca456a7241fb4b46f9c76c86eeecc273ca31d8f6 (diff) | |
download | scummvm-rg350-e1109c0c328aaf671e2b03b3b4e6de1ae9061754.tar.gz scummvm-rg350-e1109c0c328aaf671e2b03b3b4e6de1ae9061754.tar.bz2 scummvm-rg350-e1109c0c328aaf671e2b03b3b4e6de1ae9061754.zip |
CLOUD: Add CallbackBridge
This commit also adds GlobalFunctionCallback, because it was needed in
order to replace plain C pointers to functions (which were used in
Request) into our object-oriented BaseCallback pointers.
Diffstat (limited to 'backends/networking')
-rw-r--r-- | backends/networking/curl/curljsonrequest.cpp | 4 | ||||
-rw-r--r-- | backends/networking/curl/curljsonrequest.h | 6 | ||||
-rw-r--r-- | backends/networking/curl/request.h | 5 |
3 files changed, 10 insertions, 5 deletions
diff --git a/backends/networking/curl/curljsonrequest.cpp b/backends/networking/curl/curljsonrequest.cpp index fe6e218269..c3064681ef 100644 --- a/backends/networking/curl/curljsonrequest.cpp +++ b/backends/networking/curl/curljsonrequest.cpp @@ -31,7 +31,7 @@ namespace Networking { -CurlJsonRequest::CurlJsonRequest(SimpleCallback cb, const char *url) : Request(cb), _stream(0), _headersList(0), _contentsStream(DisposeAfterUse::YES) { +CurlJsonRequest::CurlJsonRequest(Common::BaseCallback* cb, const char *url) : Request(cb), _stream(0), _headersList(0), _contentsStream(DisposeAfterUse::YES) { _url = url; } @@ -75,7 +75,7 @@ bool CurlJsonRequest::handle() { if (_callback) { char *contents = getPreparedContents(); Common::JSONValue *json = Common::JSON::parse(contents); - _callback(this, json); //potential memory leak, free it in your callbacks! + (*_callback)(json); //potential memory leak, free it in your callbacks! } return true; } diff --git a/backends/networking/curl/curljsonrequest.h b/backends/networking/curl/curljsonrequest.h index 56e7205512..1098638609 100644 --- a/backends/networking/curl/curljsonrequest.h +++ b/backends/networking/curl/curljsonrequest.h @@ -26,6 +26,10 @@ #include "backends/networking/curl/request.h" #include "common/memstream.h" +namespace Common { +class BaseCallback; +} + struct curl_slist; namespace Networking { @@ -43,7 +47,7 @@ class CurlJsonRequest : public Request { char *getPreparedContents(); public: - CurlJsonRequest(SimpleCallback cb, const char *url); + CurlJsonRequest(Common::BaseCallback *cb, const char *url); virtual ~CurlJsonRequest(); virtual bool handle(); diff --git a/backends/networking/curl/request.h b/backends/networking/curl/request.h index b9571075cb..860784f2a7 100644 --- a/backends/networking/curl/request.h +++ b/backends/networking/curl/request.h @@ -22,6 +22,7 @@ #ifndef BACKENDS_NETWORKING_CURL_REQUEST_H #define BACKENDS_NETWORKING_CURL_REQUEST_H +#include <common/callback.h> namespace Networking { @@ -34,7 +35,7 @@ protected: * That's the way Requests pass the result to the code which asked to create this request. */ - SimpleCallback _callback; + Common::BaseCallback* _callback; /** * Pointer, which could be set by Request creating code. It might be accessed @@ -44,7 +45,7 @@ protected: void *_pointer; public: - Request(SimpleCallback cb): _callback(cb) {}; + Request(Common::BaseCallback* cb): _callback(cb) {}; virtual ~Request() {}; /** |