{{ message }}
Repository navigation
Expand file tree
/
Copy pathBugReport.cpp
More file actions
288 lines (263 loc) · 15.2 KB
/
Copy pathBugReport.cpp
File metadata and controls
288 lines (263 loc) · 15.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
/*
* GDevelop IDE
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the GNU General Public License version 3.
*/
#include "BugReport.h"
//(*InternalHeaders(BugReport)
#include <wx/artprov.h>
#include <wx/bitmap.h>
#include <wx/intl.h>
#include <wx/image.h>
#include <wx/string.h>
//*)
#include <wx/textfile.h>
#include "GDCore/CommonTools.h"
#include "GDCore/Tools/VersionWrapper.h"
#include <string>
#include <vector>
#include <iostream>
#include <wx/wfstream.h>
#include <wx/txtstrm.h>
#include <SFML/Network.hpp>
#include <wx/uri.h>
#include "GDCore/Tools/Log.h"
#include "GDCore/Tools/Localization.h"
using namespace std;
//(*IdInit(BugReport)
const long BugReport::ID_STATICBITMAP3 = wxNewId();
const long BugReport::ID_STATICTEXT2 = wxNewId();
const long BugReport::ID_STATICBITMAP4 = wxNewId();
const long BugReport::ID_STATICTEXT8 = wxNewId();
const long BugReport::ID_HYPERLINKCTRL1 = wxNewId();
const long BugReport::ID_BUTTON4 = wxNewId();
const long BugReport::ID_PANEL2 = wxNewId();
const long BugReport::ID_STATICTEXT3 = wxNewId();
const long BugReport::ID_TEXTCTRL1 = wxNewId();
const long BugReport::ID_STATICTEXT1 = wxNewId();
const long BugReport::ID_TEXTCTRL3 = wxNewId();
const long BugReport::ID_STATICTEXT6 = wxNewId();
const long BugReport::ID_BUTTON1 = wxNewId();
const long BugReport::ID_BUTTON5 = wxNewId();
const long BugReport::ID_PANEL3 = wxNewId();
const long BugReport::ID_STATICTEXT7 = wxNewId();
const long BugReport::ID_TEXTCTRL2 = wxNewId();
const long BugReport::ID_STATICTEXT4 = wxNewId();
const long BugReport::ID_BUTTON3 = wxNewId();
const long BugReport::ID_BUTTON2 = wxNewId();
const long BugReport::ID_PANEL4 = wxNewId();
const long BugReport::ID_NOTEBOOK1 = wxNewId();
//*)
BEGIN_EVENT_TABLE( BugReport, wxDialog )
//(*EventTable(BugReport)
//*)
END_EVENT_TABLE()
BugReport::BugReport( wxWindow* parent, const std::vector<gd::String> & openedFiles_ ) :
openedFiles(openedFiles_)
{
//(*Initialize(BugReport)
wxStaticBoxSizer* StaticBoxSizer2;
wxFlexGridSizer* FlexGridSizer4;
wxFlexGridSizer* FlexGridSizer10;
wxFlexGridSizer* FlexGridSizer3;
wxFlexGridSizer* FlexGridSizer5;
wxFlexGridSizer* FlexGridSizer9;
wxFlexGridSizer* FlexGridSizer2;
wxFlexGridSizer* FlexGridSizer7;
wxFlexGridSizer* FlexGridSizer8;
wxFlexGridSizer* FlexGridSizer12;
wxFlexGridSizer* FlexGridSizer1;
wxFlexGridSizer* FlexGridSizer11;
Create(parent, wxID_ANY, _("Something bad happened!"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("wxID_ANY"));
FlexGridSizer1 = new wxFlexGridSizer(0, 1, 0, 0);
FlexGridSizer1->AddGrowableCol(0);
FlexGridSizer1->AddGrowableRow(0);
Notebook1 = new wxNotebook(this, ID_NOTEBOOK1, wxDefaultPosition, wxDefaultSize, 0, _T("ID_NOTEBOOK1"));
Panel2 = new wxPanel(Notebook1, ID_PANEL2, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL2"));
FlexGridSizer3 = new wxFlexGridSizer(0, 1, 0, 0);
FlexGridSizer3->AddGrowableCol(0);
FlexGridSizer3->AddGrowableRow(0);
FlexGridSizer9 = new wxFlexGridSizer(0, 3, 0, 0);
StaticBitmap3 = new wxStaticBitmap(Panel2, ID_STATICBITMAP3, wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_INFORMATION")),wxART_OTHER), wxDefaultPosition, wxDefaultSize, wxNO_BORDER, _T("ID_STATICBITMAP3"));
FlexGridSizer9->Add(StaticBitmap3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticText2 = new wxStaticText(Panel2, ID_STATICTEXT2, _("It seems that GDevelop has closed abruptly after an\nerror. GDevelop should never freeze or crash whatever \nthe user make. You can help us correct the problem by filling\nthe error report."), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
FlexGridSizer9->Add(StaticText2, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer3->Add(FlexGridSizer9, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticBoxSizer2 = new wxStaticBoxSizer(wxHORIZONTAL, Panel2, _("Known bugs for this version of GDevelop"));
FlexGridSizer11 = new wxFlexGridSizer(0, 3, 0, 0);
FlexGridSizer11->AddGrowableCol(1);
FlexGridSizer11->AddGrowableRow(0);
StaticBitmap4 = new wxStaticBitmap(Panel2, ID_STATICBITMAP4, wxBitmap(wxImage(_T("res/internet32.png"))), wxDefaultPosition, wxDefaultSize, wxNO_BORDER, _T("ID_STATICBITMAP4"));
FlexGridSizer11->Add(StaticBitmap4, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer12 = new wxFlexGridSizer(0, 1, 0, 0);
StaticText8 = new wxStaticText(Panel2, ID_STATICTEXT8, _("You can visit a page on our website which can\ncontain known bugs for this version of GDevelop:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT8"));
FlexGridSizer12->Add(StaticText8, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
bugListBt = new wxHyperlinkCtrl(Panel2, ID_HYPERLINKCTRL1, _("View the known bugs for this version"), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_CONTEXTMENU|wxHL_ALIGN_CENTRE|wxNO_BORDER, _T("ID_HYPERLINKCTRL1"));
FlexGridSizer12->Add(bugListBt, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer11->Add(FlexGridSizer12, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
StaticBoxSizer2->Add(FlexGridSizer11, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
FlexGridSizer3->Add(StaticBoxSizer2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
Button1 = new wxButton(Panel2, ID_BUTTON4, _("Next"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON4"));
FlexGridSizer3->Add(Button1, 1, wxALL|wxALIGN_RIGHT|wxALIGN_BOTTOM, 5);
Panel2->SetSizer(FlexGridSizer3);
FlexGridSizer3->Fit(Panel2);
FlexGridSizer3->SetSizeHints(Panel2);
Panel3 = new wxPanel(Notebook1, ID_PANEL3, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL3"));
FlexGridSizer4 = new wxFlexGridSizer(0, 1, 0, 0);
FlexGridSizer4->AddGrowableCol(0);
FlexGridSizer4->AddGrowableRow(3);
StaticText3 = new wxStaticText(Panel3, ID_STATICTEXT3, _("To help us solve the problem, try to describe the error as precisely as\nyou can. Indicate if possible:\n-How did the error happened (Click on a button ...)\n-In which part of program (Scene editor, events editor...)"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT3"));
FlexGridSizer4->Add(StaticText3, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
UserReportEdit = new wxTextCtrl(Panel3, ID_TEXTCTRL1, wxEmptyString, wxDefaultPosition, wxSize(408,100), wxTE_MULTILINE, wxDefaultValidator, _T("ID_TEXTCTRL1"));
FlexGridSizer4->Add(UserReportEdit, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer2 = new wxFlexGridSizer(0, 1, 0, 0);
StaticText1 = new wxStaticText(Panel3, ID_STATICTEXT1, _("You can enter your email: (optional, so as to contact you if we need more information)"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
FlexGridSizer2->Add(StaticText1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
mailEdit = new wxTextCtrl(Panel3, ID_TEXTCTRL3, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL3"));
FlexGridSizer2->Add(mailEdit, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer4->Add(FlexGridSizer2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
FlexGridSizer7 = new wxFlexGridSizer(0, 3, 0, 0);
FlexGridSizer7->AddGrowableCol(1);
FlexGridSizer7->AddGrowableRow(0);
StaticText6 = new wxStaticText(Panel3, ID_STATICTEXT6, _("When you\'ve described the error, click on the button\nto automatically send the report.\n\nThanks!"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT6"));
FlexGridSizer7->Add(StaticText6, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
CreateRapportBt = new wxButton(Panel3, ID_BUTTON1, _("Send my report!"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
FlexGridSizer7->Add(CreateRapportBt, 1, wxALL|wxALIGN_TOP|wxALIGN_CENTER_HORIZONTAL, 5);
FlexGridSizer4->Add(FlexGridSizer7, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
Button2 = new wxButton(Panel3, ID_BUTTON5, _("Next"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON5"));
FlexGridSizer4->Add(Button2, 1, wxALL|wxALIGN_RIGHT|wxALIGN_BOTTOM, 5);
Panel3->SetSizer(FlexGridSizer4);
FlexGridSizer4->Fit(Panel3);
FlexGridSizer4->SetSizeHints(Panel3);
Panel4 = new wxPanel(Notebook1, ID_PANEL4, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL4"));
FlexGridSizer5 = new wxFlexGridSizer(0, 1, 0, 0);
FlexGridSizer5->AddGrowableCol(0);
FlexGridSizer5->AddGrowableRow(0);
FlexGridSizer10 = new wxFlexGridSizer(0, 1, 0, 0);
FlexGridSizer10->AddGrowableCol(0);
FlexGridSizer10->AddGrowableRow(1);
StaticText7 = new wxStaticText(Panel4, ID_STATICTEXT7, _("Here is a list of the projects opened during the last session:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT7"));
FlexGridSizer10->Add(StaticText7, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
openedFilesEdit = new wxTextCtrl(Panel4, ID_TEXTCTRL2, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY, wxDefaultValidator, _T("ID_TEXTCTRL2"));
FlexGridSizer10->Add(openedFilesEdit, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer5->Add(FlexGridSizer10, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
StaticText4 = new wxStaticText(Panel4, ID_STATICTEXT4, _("GDevelop may have made automatic backups of these projects. When you\'ll\nclose this window, the backups will be opened. If these backup are not corrupted,\nyou can save them over the original project files."), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT4"));
FlexGridSizer5->Add(StaticText4, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer8 = new wxFlexGridSizer(0, 3, 0, 0);
CloseNoOpenBt = new wxButton(Panel4, ID_BUTTON3, _("Close but don\'t open the autosave(s)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON3"));
FlexGridSizer8->Add(CloseNoOpenBt, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
CloseBt = new wxButton(Panel4, ID_BUTTON2, _("Close"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON2"));
FlexGridSizer8->Add(CloseBt, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer5->Add(FlexGridSizer8, 1, wxALL|wxALIGN_RIGHT|wxALIGN_BOTTOM, 0);
Panel4->SetSizer(FlexGridSizer5);
FlexGridSizer5->Fit(Panel4);
FlexGridSizer5->SetSizeHints(Panel4);
Notebook1->AddPage(Panel2, _("Oops..."), false);
Notebook1->AddPage(Panel3, _("Report the error"), false);
Notebook1->AddPage(Panel4, _("Load autosaves"), false);
FlexGridSizer1->Add(Notebook1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
SetSizer(FlexGridSizer1);
FlexGridSizer1->Fit(this);
FlexGridSizer1->SetSizeHints(this);
Center();
Connect(ID_BUTTON4,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&BugReport::OnButton1Click);
Connect(ID_TEXTCTRL1,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&BugReport::OnUserReportEditText);
Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&BugReport::OnCreateRapportBtClick);
Connect(ID_BUTTON5,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&BugReport::OnButton2Click);
Connect(ID_BUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&BugReport::OnCloseNoOpenBtClick);
Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&BugReport::OnCloseBtClick);
//*)
for (std::size_t i = 0; i < openedFiles.size(); ++i)
{
gd::String file = openedFiles[i];
if (!wxFileExists(file+".autosave"))
file += _(" (Autosave not found!)");
openedFilesEdit->AppendText(file+"\n");
}
if (openedFiles.empty()) {
Notebook1->RemovePage(2);
Button2->SetLabel(_("Close"));
}
CreateRapportBt->Disable();
bugListBt->SetURL(_("http://www.wiki.compilgames.net/doku.php/en/game_develop/knownbugs/gd")+gd::String::From(gd::VersionWrapper::Major())+gd::String::From(gd::VersionWrapper::Minor())+gd::String::From(gd::VersionWrapper::Build()));
}
BugReport::~BugReport()
{
//(*Destroy(BugReport)
//*)
}
void BugReport::OnCreateRapportBtClick( wxCommandEvent& event )
{
if (UserReportEdit->GetValue().Trim().IsEmpty() || UserReportEdit->GetValue().length() < 7)
return;
//On recherche le rapport d'erreur de GDevelop
string rapport;
if ( wxFileExists( "errordata.txt" ) )
{
wxFileInputStream input( "errordata.txt" );
if ( input.Ok() )
{
wxTextInputStream text( input );
while ( !input.Eof() )
{
rapport += text.ReadLine()+"\n";
}
}
}
if ( rapport == "" )
rapport = "No GDevelop error report";
wxString report;
report += "GD Error report:\n\n";
report += "V: " + gd::VersionWrapper::FullString()+"\n";
report += "OS: " + wxGetOsDescription()+"\n";
report += "Trace:\n";
report += rapport;
report += "(End)\n";
report += "User desc.:\n";
report += UserReportEdit->GetValue();
report += "(End)\n";
report += "User mail: "+mailEdit->GetValue()+"\n";
report.Replace("&", "%26");
wxString encodedReportURI = wxURI("www.compilgames.net/bugs/report.php?report="+report).BuildURI();
wxURI requestURI(encodedReportURI);
std::cout << "Sending report with these data:" << requestURI.GetQuery() << std::endl;
// Create request
sf::Http Http;
Http.setHost("http://www.compilgames.net");
sf::Http::Request request;
request.setMethod(sf::Http::Request::Post);
request.setField("Content-Type", "application/x-www-form-urlencoded");
request.setUri("/bugs/report.php");
request.setBody(gd::String(requestURI.GetQuery()).ToSfString());
// Send the request
sf::Http::Response response = Http.sendRequest(request, sf::seconds(5));
if (response.getStatus() != sf::Http::Response::Ok)
std::cout << "Unable to connect to the server for sending the report!" << std::endl;
else {
gd::LogMessage(_("Thanks for reporting the error!"));
CreateRapportBt->Disable();
}
}
void BugReport::OnCloseNoOpenBtClick(wxCommandEvent& event)
{
EndModal(0);
}
void BugReport::OnCloseBtClick(wxCommandEvent& event)
{
EndModal(1);
}
void BugReport::OnButton1Click(wxCommandEvent& event)
{
Notebook1->SetSelection(1);
}
void BugReport::OnButton2Click(wxCommandEvent& event)
{
if (openedFiles.empty())
EndModal(0);
else
Notebook1->SetSelection(2);
}
void BugReport::OnUserReportEditText(wxCommandEvent& event)
{
CreateRapportBt->Enable();
}
You can’t perform that action at this time.
