mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Show feedback when the compatibility is submitted.
This commit is contained in:
parent
45218be5e3
commit
42fd4aeb12
4 changed files with 73 additions and 6 deletions
|
@ -62,6 +62,8 @@ namespace Reporting
|
||||||
static bool everUnsupported = false;
|
static bool everUnsupported = false;
|
||||||
// Support is cached here to avoid checking it on every single request.
|
// Support is cached here to avoid checking it on every single request.
|
||||||
static bool currentSupported = false;
|
static bool currentSupported = false;
|
||||||
|
// Whether the most recent server request seemed successful.
|
||||||
|
static bool serverWorking = true;
|
||||||
|
|
||||||
enum class RequestType
|
enum class RequestType
|
||||||
{
|
{
|
||||||
|
@ -227,9 +229,10 @@ namespace Reporting
|
||||||
|
|
||||||
if (http.Resolve(serverHost, ServerPort())) {
|
if (http.Resolve(serverHost, ServerPort())) {
|
||||||
http.Connect();
|
http.Connect();
|
||||||
http.POST(uri, data, mimeType, output);
|
int result = http.POST(uri, data, mimeType, output);
|
||||||
http.Disconnect();
|
http.Disconnect();
|
||||||
return true;
|
|
||||||
|
return result >= 200 && result < 300;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -392,6 +395,7 @@ namespace Reporting
|
||||||
setCurrentThreadName("Report");
|
setCurrentThreadName("Report");
|
||||||
|
|
||||||
Payload &payload = payloadBuffer[pos];
|
Payload &payload = payloadBuffer[pos];
|
||||||
|
Buffer output;
|
||||||
|
|
||||||
MultipartFormDataEncoder postdata;
|
MultipartFormDataEncoder postdata;
|
||||||
AddSystemInfo(postdata);
|
AddSystemInfo(postdata);
|
||||||
|
@ -411,7 +415,8 @@ namespace Reporting
|
||||||
payload.string2.clear();
|
payload.string2.clear();
|
||||||
|
|
||||||
postdata.Finish();
|
postdata.Finish();
|
||||||
SendReportRequest("/report/message", postdata.ToString(), postdata.GetMimeType());
|
if (!SendReportRequest("/report/message", postdata.ToString(), postdata.GetMimeType()))
|
||||||
|
serverWorking = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RequestType::COMPAT:
|
case RequestType::COMPAT:
|
||||||
|
@ -427,7 +432,16 @@ namespace Reporting
|
||||||
payload.string2.clear();
|
payload.string2.clear();
|
||||||
|
|
||||||
postdata.Finish();
|
postdata.Finish();
|
||||||
SendReportRequest("/report/compat", postdata.ToString(), postdata.GetMimeType());
|
if (!SendReportRequest("/report/compat", postdata.ToString(), postdata.GetMimeType(), &output)) {
|
||||||
|
serverWorking = false;
|
||||||
|
} else {
|
||||||
|
char res = 0;
|
||||||
|
if (!output.empty()) {
|
||||||
|
output.Take(1, &res);
|
||||||
|
}
|
||||||
|
if (res == 0)
|
||||||
|
serverWorking = false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RequestType::NONE:
|
case RequestType::NONE:
|
||||||
|
@ -496,6 +510,20 @@ namespace Reporting
|
||||||
g_Config.sReportHost = "default";
|
g_Config.sReportHost = "default";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status GetStatus()
|
||||||
|
{
|
||||||
|
if (!serverWorking)
|
||||||
|
return Status::FAILING;
|
||||||
|
|
||||||
|
for (int pos = 0; pos < PAYLOAD_BUFFER_SIZE; ++pos)
|
||||||
|
{
|
||||||
|
if (payloadBuffer[pos].type != RequestType::NONE)
|
||||||
|
return Status::BUSY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status::WORKING;
|
||||||
|
}
|
||||||
|
|
||||||
int NextFreePos()
|
int NextFreePos()
|
||||||
{
|
{
|
||||||
int start = payloadBufferPos % PAYLOAD_BUFFER_SIZE;
|
int start = payloadBufferPos % PAYLOAD_BUFFER_SIZE;
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
// Official git repository and contact information can be found at
|
// Official git repository and contact information can be found at
|
||||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/Log.h"
|
#include "Common/Log.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -75,6 +77,15 @@ namespace Reporting
|
||||||
// Returns true if that identifier has not been logged yet.
|
// Returns true if that identifier has not been logged yet.
|
||||||
bool ShouldLogOnce(const char *identifier);
|
bool ShouldLogOnce(const char *identifier);
|
||||||
|
|
||||||
|
enum class Status {
|
||||||
|
WORKING,
|
||||||
|
BUSY,
|
||||||
|
FAILING,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Whether server requests appear to be working.
|
||||||
|
Status GetStatus();
|
||||||
|
|
||||||
// Return the currently active host (or blank if not active.)
|
// Return the currently active host (or blank if not active.)
|
||||||
std::string ServerHost();
|
std::string ServerHost();
|
||||||
|
|
||||||
|
|
|
@ -294,7 +294,7 @@ EventReturn ReportScreen::HandleBrowser(EventParams &e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ReportFinishScreen::ReportFinishScreen(const std::string &gamePath)
|
ReportFinishScreen::ReportFinishScreen(const std::string &gamePath)
|
||||||
: UIScreenWithGameBackground(gamePath) {
|
: UIScreenWithGameBackground(gamePath), resultNotice_(nullptr), setStatus_(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportFinishScreen::CreateViews() {
|
void ReportFinishScreen::CreateViews() {
|
||||||
|
@ -309,7 +309,7 @@ void ReportFinishScreen::CreateViews() {
|
||||||
LinearLayout *rightColumnItems = new LinearLayout(ORIENT_VERTICAL);
|
LinearLayout *rightColumnItems = new LinearLayout(ORIENT_VERTICAL);
|
||||||
|
|
||||||
leftColumnItems->Add(new TextView(rp->T("FeedbackThanks", "Thanks for your feedback."), new LinearLayoutParams(Margins(12, 5, 0, 5))));
|
leftColumnItems->Add(new TextView(rp->T("FeedbackThanks", "Thanks for your feedback."), new LinearLayoutParams(Margins(12, 5, 0, 5))));
|
||||||
leftColumnItems->Add(new TextView(rp->T("FeedbackDelayInfo", "Your data is being submitted in the background."), new LinearLayoutParams(Margins(12, 5, 0, 5))));
|
resultNotice_ = leftColumnItems->Add(new TextView(rp->T("FeedbackDelayInfo", "Your data is being submitted in the background."), new LinearLayoutParams(Margins(12, 5, 0, 5))));
|
||||||
|
|
||||||
rightColumnItems->SetSpacing(0.0f);
|
rightColumnItems->SetSpacing(0.0f);
|
||||||
rightColumnItems->Add(new Choice(rp->T("View Feedback")))->OnClick.Handle(this, &ReportFinishScreen::HandleViewFeedback);
|
rightColumnItems->Add(new Choice(rp->T("View Feedback")))->OnClick.Handle(this, &ReportFinishScreen::HandleViewFeedback);
|
||||||
|
@ -325,6 +325,30 @@ void ReportFinishScreen::CreateViews() {
|
||||||
rightColumn->Add(rightColumnItems);
|
rightColumn->Add(rightColumnItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReportFinishScreen::update(InputState &input) {
|
||||||
|
I18NCategory *rp = GetI18NCategory("Reporting");
|
||||||
|
|
||||||
|
if (!setStatus_) {
|
||||||
|
Reporting::Status status = Reporting::GetStatus();
|
||||||
|
switch (status) {
|
||||||
|
case Reporting::Status::WORKING:
|
||||||
|
resultNotice_->SetText(rp->T("FeedbackSubmitDone", "Your data has been submitted."));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Reporting::Status::FAILING:
|
||||||
|
resultNotice_->SetText(rp->T("FeedbackSubmitFail", "Could not submit data to server. Try updating PPSSPP."));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Reporting::Status::BUSY:
|
||||||
|
default:
|
||||||
|
// Can't update yet.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UIScreenWithGameBackground::update(input);
|
||||||
|
}
|
||||||
|
|
||||||
UI::EventReturn ReportFinishScreen::HandleViewFeedback(UI::EventParams &e) {
|
UI::EventReturn ReportFinishScreen::HandleViewFeedback(UI::EventParams &e) {
|
||||||
const std::string url = "http://" + Reporting::ServerHost() + "/game/" + Reporting::CurrentGameID();
|
const std::string url = "http://" + Reporting::ServerHost() + "/game/" + Reporting::CurrentGameID();
|
||||||
LaunchBrowser(url.c_str());
|
LaunchBrowser(url.c_str());
|
||||||
|
|
|
@ -55,7 +55,11 @@ public:
|
||||||
ReportFinishScreen(const std::string &gamePath);
|
ReportFinishScreen(const std::string &gamePath);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void update(InputState &input) override;
|
||||||
void CreateViews() override;
|
void CreateViews() override;
|
||||||
|
|
||||||
UI::EventReturn HandleViewFeedback(UI::EventParams &e);
|
UI::EventReturn HandleViewFeedback(UI::EventParams &e);
|
||||||
|
|
||||||
|
UI::TextView *resultNotice_;
|
||||||
|
bool setStatus_;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue