citra-emu
/
citra
Archived
1
0
Fork 0

web_service: Unify links for web service endpoints

This commit is contained in:
fearlessTobi 2018-08-26 01:45:11 +02:00
parent ae6007bf9d
commit 0d6b1d161b
6 changed files with 15 additions and 41 deletions

View File

@ -229,13 +229,8 @@ void Config::ReadValues() {
// Web Service
Settings::values.enable_telemetry =
sdl2_config->GetBoolean("WebService", "enable_telemetry", true);
Settings::values.telemetry_endpoint_url = sdl2_config->Get(
"WebService", "telemetry_endpoint_url", "https://services.citra-emu.org/api/telemetry");
Settings::values.verify_endpoint_url = sdl2_config->Get(
"WebService", "verify_endpoint_url", "https://services.citra-emu.org/api/profile");
Settings::values.announce_multiplayer_room_endpoint_url =
sdl2_config->Get("WebService", "announce_multiplayer_room_endpoint_url",
"https://services.citra-emu.org/api/multiplayer/rooms");
Settings::values.web_services_endpoint_url =
sdl2_config->Get("WebService", "web_services_endpoint_url", "https://api.citra-emu.org");
Settings::values.citra_username = sdl2_config->Get("WebService", "citra_username", "");
Settings::values.citra_token = sdl2_config->Get("WebService", "citra_token", "");
}

View File

@ -245,12 +245,8 @@ gdbstub_port=24689
# Whether or not to enable telemetry
# 0: No, 1 (default): Yes
enable_telemetry =
# Endpoint URL for submitting telemetry data
telemetry_endpoint_url = https://services.citra-emu.org/api/telemetry
# Endpoint URL to verify the username and token
verify_endpoint_url = https://services.citra-emu.org/api/profile
# Endpoint URL for announcing public rooms
announce_multiplayer_room_endpoint_url = https://services.citra-emu.org/api/multiplayer/rooms
# Endpoint URL for web services
web_services_endpoint_url = https://api.citra-emu.org
# Username and token for Citra Web Service
# See https://services.citra-emu.org/ for more info
citra_username =

View File

@ -191,17 +191,8 @@ void Config::ReadValues() {
qt_config->beginGroup("WebService");
Settings::values.enable_telemetry = ReadSetting("enable_telemetry", true).toBool();
Settings::values.telemetry_endpoint_url =
ReadSetting("telemetry_endpoint_url", "https://services.citra-emu.org/api/telemetry")
.toString()
.toStdString();
Settings::values.verify_endpoint_url =
ReadSetting("verify_endpoint_url", "https://services.citra-emu.org/api/profile")
.toString()
.toStdString();
Settings::values.announce_multiplayer_room_endpoint_url =
ReadSetting("announce_multiplayer_room_endpoint_url",
"https://services.citra-emu.org/api/multiplayer/rooms")
Settings::values.web_services_endpoint_url =
ReadSetting("web_services_endpoint_url", "https://api.citra-emu.org")
.toString()
.toStdString();
Settings::values.citra_username = ReadSetting("citra_username").toString().toStdString();
@ -435,16 +426,9 @@ void Config::SaveValues() {
qt_config->beginGroup("WebService");
WriteSetting("enable_telemetry", Settings::values.enable_telemetry, true);
WriteSetting("telemetry_endpoint_url",
QString::fromStdString(Settings::values.telemetry_endpoint_url),
"https://services.citra-emu.org/api/telemetry");
WriteSetting("verify_endpoint_url",
QString::fromStdString(Settings::values.verify_endpoint_url),
"https://services.citra-emu.org/api/profile");
WriteSetting("announce_multiplayer_room_endpoint_url",
QString::fromStdString(Settings::values.announce_multiplayer_room_endpoint_url),
"https://services.citra-emu.org/"
"api/multiplayer/rooms");
WriteSetting("web_services_endpoint_url",
QString::fromStdString(Settings::values.web_services_endpoint_url),
"https://api.citra-emu.org");
WriteSetting("citra_username", QString::fromStdString(Settings::values.citra_username));
WriteSetting("citra_token", QString::fromStdString(Settings::values.citra_token));
qt_config->endGroup();

View File

@ -22,7 +22,7 @@ static constexpr std::chrono::seconds announce_time_interval(15);
AnnounceMultiplayerSession::AnnounceMultiplayerSession() {
#ifdef ENABLE_WEB_SERVICE
backend = std::make_unique<WebService::RoomJson>(
Settings::values.announce_multiplayer_room_endpoint_url, Settings::values.citra_username,
Settings::values.web_services_endpoint_url + "/lobby", Settings::values.citra_username,
Settings::values.citra_token);
#else
backend = std::make_unique<AnnounceMultiplayerRoom::NullBackend>();

View File

@ -165,9 +165,7 @@ struct Values {
// WebService
bool enable_telemetry;
std::string telemetry_endpoint_url;
std::string verify_endpoint_url;
std::string announce_multiplayer_room_endpoint_url;
std::string web_services_endpoint_url;
std::string citra_username;
std::string citra_token;
} extern values;

View File

@ -82,7 +82,8 @@ u64 RegenerateTelemetryId() {
std::future<bool> VerifyLogin(std::string username, std::string token, std::function<void()> func) {
#ifdef ENABLE_WEB_SERVICE
return WebService::VerifyLogin(username, token, Settings::values.verify_endpoint_url, func);
return WebService::VerifyLogin(username, token,
Settings::values.web_services_endpoint_url + "/profile", func);
#else
return std::async(std::launch::async, [func{std::move(func)}]() {
func();
@ -95,8 +96,8 @@ TelemetrySession::TelemetrySession() {
#ifdef ENABLE_WEB_SERVICE
if (Settings::values.enable_telemetry) {
backend = std::make_unique<WebService::TelemetryJson>(
Settings::values.telemetry_endpoint_url, Settings::values.citra_username,
Settings::values.citra_token);
Settings::values.web_services_endpoint_url + "/telemetry",
Settings::values.citra_username, Settings::values.citra_token);
} else {
backend = std::make_unique<Telemetry::NullVisitor>();
}