ScummVM API documentation
connectcloudhandler.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef BACKENDS_NETWORKING_SDL_NET_CONNECTCLOUDHANDLER_H
23 #define BACKENDS_NETWORKING_SDL_NET_CONNECTCLOUDHANDLER_H
24 
25 #include "backends/networking/sdl_net/handlers/basehandler.h"
26 #include "backends/networking/sdl_net/client.h"
27 #include "backends/networking/curl/request.h"
28 #include "common/memstream.h"
29 
30 namespace Networking {
31 
33  void handleError(Client &client, const Common::String &message) const;
34  void setJsonResponseHandler(Client &client, const Common::String &type, const Common::String &message) const;
35 
36  Networking::ErrorCallback _storageConnectionCallback;
37 
38 public:
40  ~ConnectCloudHandler() override;
41 
42  void handle(Client &client) override;
43  bool minimalModeSupported() override { return true; }
44 
45  void setStorageConnectionCallback(Networking::ErrorCallback cb) { _storageConnectionCallback = cb; }
46  void storageConnected(const Networking::ErrorResponse& response) const;
47 };
48 
50  const ConnectCloudHandler *_cloudHandler;
51  Common::MemoryWriteStreamDynamic _clientContent;
52  Client *_client;
53  static const int32 SUSPICIOUS_CONTENT_SIZE = 640 * 1024; // 640K ought to be enough for anybody
54 
55  void respond(Client &client, const Common::String &response, long responseCode = 200) const;
56  void respondWithJson(Client &client, bool error, const Common::String &message, long responseCode = 200) const;
57  void handleError(Client &client, const Common::String &message, long responseCode) const;
58  void handleSuccess(Client &client, const Common::String &message) const;
59  void storageConnectionCallback(const Networking::ErrorResponse &response);
60 
61 public:
63  ~ConnectCloudClientHandler() override;
64 
65  void handle(Client *client) override;
66 };
67 
68 } // End of namespace Networking
69 
70 #endif
Definition: connectcloudhandler.h:32
Definition: client.h:75
Definition: str.h:59
Definition: scummvmcloud.h:31
Definition: request.h:73
Definition: memstream.h:194
Definition: basehandler.h:29
Definition: connectcloudhandler.h:49
Definition: callback.h:49
Definition: client.h:49
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1