mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Function name change, additional comments, code cleanup for remote disc streaming
This commit is contained in:
parent
ce7a93e24c
commit
ed046079a5
5 changed files with 55 additions and 50 deletions
|
@ -1088,16 +1088,17 @@ UI::EventReturn GameSettingsScreen::OnChangeMacAddress(UI::EventParams &e) {
|
|||
}
|
||||
|
||||
UI::EventReturn GameSettingsScreen::OnChangeRemoteISOSubdir(UI::EventParams &e) {
|
||||
//sanity checks
|
||||
//Conform to HTTP standards
|
||||
for (size_t i = 0; i < g_Config.sRemoteISOSubdir.length(); i++)
|
||||
{
|
||||
if (g_Config.sRemoteISOSubdir[i] == ' ') g_Config.sRemoteISOSubdir[i] = '+';
|
||||
if (g_Config.sRemoteISOSubdir[i] == '\\') g_Config.sRemoteISOSubdir[i] = '/';
|
||||
if (g_Config.sRemoteISOSubdir[i] == '?') {
|
||||
g_Config.sRemoteISOSubdir.erase(i); //truncate
|
||||
g_Config.sRemoteISOSubdir.erase(i); //truncate for safety
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Make sure it begins and ends with /
|
||||
if (g_Config.sRemoteISOSubdir[0] != '/')
|
||||
g_Config.sRemoteISOSubdir = "/" + g_Config.sRemoteISOSubdir;
|
||||
if (g_Config.sRemoteISOSubdir[g_Config.sRemoteISOSubdir.length() - 1] != '/')
|
||||
|
|
|
@ -198,52 +198,56 @@ static bool FindServer(std::string &resultHost, int &resultPort) {
|
|||
return true;
|
||||
}
|
||||
|
||||
if(!g_Config.bRemoteISOManual) {
|
||||
// Start by requesting a list of recent local ips for this network.
|
||||
if (http.Resolve(REPORT_HOSTNAME, REPORT_PORT)) {
|
||||
if (http.Connect()) {
|
||||
code = http.GET("/match/list", &result);
|
||||
http.Disconnect();
|
||||
}
|
||||
}
|
||||
//don't scan if in manual mode
|
||||
if (g_Config.bRemoteISOManual) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (code != 200 || scanCancelled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string json;
|
||||
result.TakeAll(&json);
|
||||
|
||||
JsonReader reader(json.c_str(), json.size());
|
||||
if (!reader.ok()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const json_value *entries = reader.root();
|
||||
if (!entries) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> servers;
|
||||
const json_value *entry = entries->first_child;
|
||||
while (entry) {
|
||||
const char *host = entry->getString("ip", "");
|
||||
int port = entry->getInt("p", 0);
|
||||
|
||||
char url[1024] = {};
|
||||
snprintf(url, sizeof(url), "http://%s:%d", host, port);
|
||||
servers.push_back(url);
|
||||
|
||||
if (http.Resolve(host, port) && http.Connect()) {
|
||||
http.Disconnect();
|
||||
resultHost = host;
|
||||
resultPort = port;
|
||||
return true;
|
||||
}
|
||||
|
||||
entry = entry->next_sibling;
|
||||
// Start by requesting a list of recent local ips for this network.
|
||||
if (http.Resolve(REPORT_HOSTNAME, REPORT_PORT)) {
|
||||
if (http.Connect()) {
|
||||
code = http.GET("/match/list", &result);
|
||||
http.Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if (code != 200 || scanCancelled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string json;
|
||||
result.TakeAll(&json);
|
||||
|
||||
JsonReader reader(json.c_str(), json.size());
|
||||
if (!reader.ok()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const json_value *entries = reader.root();
|
||||
if (!entries) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> servers;
|
||||
const json_value *entry = entries->first_child;
|
||||
while (entry) {
|
||||
const char *host = entry->getString("ip", "");
|
||||
int port = entry->getInt("p", 0);
|
||||
|
||||
char url[1024] = {};
|
||||
snprintf(url, sizeof(url), "http://%s:%d", host, port);
|
||||
servers.push_back(url);
|
||||
|
||||
if (http.Resolve(host, port) && http.Connect()) {
|
||||
http.Disconnect();
|
||||
resultHost = host;
|
||||
resultPort = port;
|
||||
return true;
|
||||
}
|
||||
|
||||
entry = entry->next_sibling;
|
||||
}
|
||||
|
||||
// None of the local IPs were reachable.
|
||||
return false;
|
||||
}
|
||||
|
@ -275,7 +279,7 @@ static bool LoadGameList(const std::string &host, int port, std::vector<std::str
|
|||
std::vector<std::string> items;
|
||||
result.TakeAll(&listing);
|
||||
|
||||
if (startsWith(responseHeaders[0],"Server: SuperDuperServer")) {
|
||||
if (startsWith(responseHeaders[0],"Server: PPSSPPServer") || startsWith(responseHeaders[0], "Server: SuperDuperServer")) {
|
||||
//ppsspp server
|
||||
SplitString(listing, '\n', items);
|
||||
for (const std::string &item : items) {
|
||||
|
@ -289,7 +293,7 @@ static bool LoadGameList(const std::string &host, int port, std::vector<std::str
|
|||
}
|
||||
} else {
|
||||
//other webserver
|
||||
FindQuotedStrings(listing, items);
|
||||
GetQuotedStrings(listing, items);
|
||||
for (const std::string &item : items) {
|
||||
|
||||
if (!endsWithNoCase(item, ".cso") && !endsWithNoCase(item, ".iso") && !endsWithNoCase(item, ".pbp")) {
|
||||
|
|
|
@ -279,7 +279,7 @@ void SplitString(const std::string& str, const char delim, std::vector<std::stri
|
|||
}
|
||||
}
|
||||
|
||||
void FindQuotedStrings(const std::string& str, std::vector<std::string>& output)
|
||||
void GetQuotedStrings(const std::string& str, std::vector<std::string>& output)
|
||||
{
|
||||
size_t next = 0;
|
||||
bool even = 0;
|
||||
|
|
|
@ -113,7 +113,7 @@ static bool TryParse(const std::string &str, N *const output)
|
|||
}
|
||||
void SplitString(const std::string& str, const char delim, std::vector<std::string>& output);
|
||||
|
||||
void FindQuotedStrings(const std::string& str, std::vector<std::string>& output);
|
||||
void GetQuotedStrings(const std::string& str, std::vector<std::string>& output);
|
||||
|
||||
std::string ReplaceAll(std::string input, const std::string& src, const std::string& dest);
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ void Request::WriteHttpResponseHeader(int status, int64_t size, const char *mime
|
|||
|
||||
net::OutputSink *buffer = Out();
|
||||
buffer->Printf("HTTP/1.0 %03d %s\r\n", status, statusStr);
|
||||
buffer->Push("Server: SuperDuperServer v0.1\r\n");
|
||||
buffer->Push("Server: PPSSPPServer v0.1\r\n");
|
||||
buffer->Printf("Content-Type: %s\r\n", mimeType ? mimeType : DEFAULT_MIME_TYPE);
|
||||
buffer->Push("Connection: close\r\n");
|
||||
if (size >= 0) {
|
||||
|
|
Loading…
Add table
Reference in a new issue