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/http/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  uint32 _lastEventPoll;
66 
67 
68  Common::U32String getSizeLabelText();
69  void refreshWidgets();
70 
71 public:
72  IntegrityDialog(Common::String endpoint, Common::String gameConfig);
73  ~IntegrityDialog();
74 
75 
80  bool progressUpdate(int bytesProcessed);
81 
82  void sendJSON();
83  void checksumResponseCallback(const Common::JSONValue *r);
84  void errorCallback(const Networking::ErrorResponse &error);
85 
87 
88  Common::Array<Common::StringArray> generateChecksums(Common::Path currentPath, Common::Array<Common::StringArray> &fileChecksums, Common::Path gamePath);
89  Common::JSONValue *generateJSONRequest(Common::Path gamePath, Common::String gameid, Common::String engineid, Common::String extra, Common::String platform, Common::String language);
90  void parseJSON(const Common::JSONValue *response);
91 
92  void open() override;
93  void close() override;
94  void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
95  void handleTickle() override;
96  void reflowLayout() override;
97 
98  void setError(Common::U32String &msg);
99 
100 private:
101  void setState(ProcessState state);
102 };
103 
104 } // End of namespace GUI
105 
106 #endif // GUI_INTEGRITY_DIALOG_H
Definition: str.h:59
Definition: request.h:73
Definition: array.h:52
bool progressUpdate(int bytesProcessed)
Definition: path.h:52
Definition: widget.h:206
Definition: widget.h:406
Definition: system.h:46
Definition: json.h:90
Definition: hashmap.h:85
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:234
Definition: object.h:40
Definition: integrity-dialog.h:52