ScummVM API documentation
integrity-dialog.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 GUI_INTEGRITY_DIALOG_H
23 #define GUI_INTEGRITY_DIALOG_H
24 
25 #include "backends/networking/curl/postrequest.h"
26 
27 #include "common/array.h"
28 #include "common/formats/json.h"
29 #include "common/str.h"
30 
31 #include "gui/dialog.h"
32 #include "gui/widget.h"
33 #include "gui/widgets/list.h"
34 
35 namespace GUI {
36 
37 enum {
38  OK = 0,
39  MISSING = 1,
40  CHECKSUM_MISMATCH = 2,
41  SIZE_MISMATCH = 3,
42  UNKNOWN = 4
43 };
44 
45 enum ProcessState {
46  kChecksumStateNone,
47  kChecksumStateCalculating,
48  kChecksumComplete,
49  kResponseReceived
50 };
51 
52 class IntegrityDialog : public Dialog, public CommandSender {
53  StaticTextWidget *_warningText;
54  ListWidget *_resultsText;
55 
56  StaticTextWidget *_statusText;
57  StaticTextWidget *_errorText;
58  StaticTextWidget *_percentLabel;
59  StaticTextWidget *_calcSizeLabel;
60  SliderWidget *_progressBar;
61  ButtonWidget *_cancelButton;
62  ButtonWidget *_copyEmailButton;
63 
64  bool _close;
65 
66  Common::U32String getSizeLabelText();
67  void refreshWidgets();
68 
69 public:
70  IntegrityDialog(Common::String endpoint, Common::String gameConfig);
71  ~IntegrityDialog();
72 
73  void sendJSON();
74  void checksumResponseCallback(const Common::JSONValue *r);
75  void errorCallback(const Networking::ErrorResponse &error);
76 
77  void calculateTotalSize(Common::Path gamePath);
78 
80  Common::JSONValue *generateJSONRequest(Common::Path gamePath, Common::String gameid, Common::String engineid, Common::String extra, Common::String platform, Common::String language);
81  void parseJSON(const Common::JSONValue *response);
82 
83  void open() override;
84  void close() override;
85  void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
86  void handleTickle() override;
87  void reflowLayout() override;
88 
89  void setError(Common::U32String &msg);
90 
91 private:
92  void setState(ProcessState state);
93 };
94 
95 } // End of namespace GUI
96 
97 #endif // GUI_INTEGRITY_DIALOG_H
Definition: str.h:59
Definition: request.h:73
Definition: array.h:52
Definition: path.h:52
Definition: widget.h:205
Definition: widget.h:404
Definition: system.h:46
Definition: json.h:90
Definition: ustr.h:57
Definition: list.h:51
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: dialog.h:49
Definition: widget.h:232
Definition: object.h:40
Definition: integrity-dialog.h:52