mirror of https://github.com/xemu-project/xemu.git
ui: Add report submission error reporting
This commit is contained in:
parent
d0df082322
commit
37ef9f5856
|
@ -944,6 +944,8 @@ public:
|
|||
CompatibilityReport report;
|
||||
bool dirty;
|
||||
bool is_open;
|
||||
bool is_xbe_identified;
|
||||
bool did_send, send_result;
|
||||
std::string serialized_report;
|
||||
|
||||
CompatibilityReporter()
|
||||
|
@ -967,6 +969,8 @@ public:
|
|||
report.os_version = xemu_get_os_info();
|
||||
report.cpu = get_cpu_info();
|
||||
dirty = true;
|
||||
is_xbe_identified = false;
|
||||
did_send = send_result = false;
|
||||
}
|
||||
|
||||
~CompatibilityReporter()
|
||||
|
@ -991,11 +995,19 @@ public:
|
|||
report.gl_version = (const char *)glGetString(GL_VERSION);
|
||||
report.gl_shading_language_version = (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION);
|
||||
struct xbe *xbe = xemu_get_xbe_info();
|
||||
if (xbe != NULL) {
|
||||
is_xbe_identified = xbe != NULL;
|
||||
if (is_xbe_identified) {
|
||||
report.SetXbeData(xbe);
|
||||
} else {
|
||||
// FIXME: Show message if XBE could not be identified
|
||||
}
|
||||
did_send = send_result = false;
|
||||
}
|
||||
|
||||
if (!is_xbe_identified) {
|
||||
ImGui::TextWrapped(
|
||||
"An XBE could not be identified. Please launch an official "
|
||||
"Xbox title to submit a compatibility report.");
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui::TextWrapped(
|
||||
|
@ -1073,11 +1085,25 @@ public:
|
|||
|
||||
ImGui::Columns(1);
|
||||
|
||||
ImGui::Dummy(ImVec2(0, 5*g_ui_scale));
|
||||
ImGui::Separator();
|
||||
ImGui::Dummy(ImVec2(0, 5*g_ui_scale));
|
||||
|
||||
if (did_send) {
|
||||
if (send_result) {
|
||||
ImGui::Text("Sent! Thanks.");
|
||||
} else {
|
||||
ImGui::Text("Error: %s (%d)", report.GetResultMessage().c_str(), report.GetResultCode());
|
||||
}
|
||||
ImGui::SameLine();
|
||||
}
|
||||
|
||||
ImGui::SetCursorPosX(ImGui::GetWindowWidth()-(120+10)*g_ui_scale);
|
||||
|
||||
ImGui::SetItemDefaultFocus();
|
||||
if (ImGui::Button("Send", ImVec2(120*g_ui_scale, 0))) {
|
||||
report.Send();
|
||||
did_send = true;
|
||||
send_result = report.Send();
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
|
|
|
@ -38,13 +38,11 @@ const std::string &CompatibilityReport::GetSerializedReport()
|
|||
return serialized;
|
||||
}
|
||||
|
||||
void CompatibilityReport::Send()
|
||||
bool CompatibilityReport::Send()
|
||||
{
|
||||
// Serialize the report
|
||||
const std::string &s = GetSerializedReport();
|
||||
|
||||
fprintf(stderr, "%s\n", s.c_str());
|
||||
|
||||
httplib::SSLClient cli("127.0.0.1", 443);
|
||||
// httplib::SSLClient cli("reports.xemu.app", 443);
|
||||
|
||||
|
@ -63,10 +61,36 @@ void CompatibilityReport::Send()
|
|||
}
|
||||
#endif
|
||||
#endif
|
||||
return;
|
||||
|
||||
result_code = -1;
|
||||
result_msg = "Failed to connect";
|
||||
return false;
|
||||
}
|
||||
|
||||
fprintf(stderr, "%d\n", res->status);
|
||||
result_code = res->status;
|
||||
|
||||
switch(res->status) {
|
||||
case 200:
|
||||
result_msg = "Ok";
|
||||
return true;
|
||||
|
||||
case 400:
|
||||
case 411:
|
||||
result_msg = "Invalid request";
|
||||
return false;
|
||||
|
||||
case 403:
|
||||
result_msg = "Invalid token";
|
||||
return false;
|
||||
|
||||
case 413:
|
||||
result_msg = "Report too long";
|
||||
return false;
|
||||
|
||||
default:
|
||||
result_msg = "Unknown error occured";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void CompatibilityReport::SetXbeData(struct xbe *xbe)
|
||||
|
|
|
@ -45,12 +45,17 @@ public:
|
|||
std::string compat_comments;
|
||||
std::string xbe_headers;
|
||||
|
||||
private:
|
||||
std::string serialized;
|
||||
int result_code;
|
||||
std::string result_msg;
|
||||
|
||||
public:
|
||||
CompatibilityReport();
|
||||
~CompatibilityReport();
|
||||
void Send();
|
||||
bool Send();
|
||||
int GetResultCode() { return result_code; }
|
||||
std::string &GetResultMessage() { return result_msg; }
|
||||
const std::string &GetSerializedReport();
|
||||
void SetXbeData(struct xbe *xbe);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue