mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-15 03:50:06 +00:00
Merge pull request #4315 from FearlessTobi/port-1332
WebService: Backport review comments from yuzu-emu/yuzu#1332
This commit is contained in:
commit
11729eafe1
@ -255,13 +255,6 @@ if (ENABLE_QT)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (ENABLE_WEB_SERVICE)
|
||||
add_definitions(-DENABLE_WEB_SERVICE)
|
||||
endif()
|
||||
if (CITRA_ENABLE_COMPATIBILITY_REPORTING)
|
||||
add_definitions(-DCITRA_ENABLE_COMPATIBILITY_REPORTING)
|
||||
endif()
|
||||
|
||||
if (ENABLE_SCRIPTING)
|
||||
add_definitions(-DENABLE_SCRIPTING)
|
||||
endif()
|
||||
|
8
externals/CMakeLists.txt
vendored
8
externals/CMakeLists.txt
vendored
@ -71,19 +71,19 @@ endif()
|
||||
|
||||
# DiscordRPC
|
||||
if (USE_DISCORD_PRESENCE)
|
||||
add_subdirectory(discord-rpc)
|
||||
add_subdirectory(discord-rpc EXCLUDE_FROM_ALL)
|
||||
target_include_directories(discord-rpc INTERFACE ./discord-rpc/include)
|
||||
endif()
|
||||
|
||||
if (ENABLE_WEB_SERVICE)
|
||||
# LibreSSL
|
||||
set(LIBRESSL_SKIP_INSTALL ON CACHE BOOL "")
|
||||
add_definitions(-DHAVE_INET_NTOP)
|
||||
add_subdirectory(libressl)
|
||||
add_subdirectory(libressl EXCLUDE_FROM_ALL)
|
||||
target_include_directories(ssl INTERFACE ./libressl/include)
|
||||
target_compile_definitions(ssl PRIVATE -DHAVE_INET_NTOP)
|
||||
|
||||
# lurlparser
|
||||
add_subdirectory(lurlparser)
|
||||
add_subdirectory(lurlparser EXCLUDE_FROM_ALL)
|
||||
|
||||
# httplib
|
||||
add_library(httplib INTERFACE)
|
||||
|
@ -248,7 +248,7 @@ enable_telemetry =
|
||||
# URL for Web API
|
||||
web_api_url = https://api.citra-emu.org
|
||||
# Username and token for Citra Web Service
|
||||
# See https://services.citra-emu.org/ for more info
|
||||
# See https://profile.citra-emu.org/ for more info
|
||||
citra_username =
|
||||
citra_token =
|
||||
)";
|
||||
|
@ -208,6 +208,10 @@ target_link_libraries(citra-qt PRIVATE audio_core common core input_common netwo
|
||||
target_link_libraries(citra-qt PRIVATE Boost::boost glad nihstro-headers Qt5::OpenGL Qt5::Widgets Qt5::Multimedia)
|
||||
target_link_libraries(citra-qt PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads)
|
||||
|
||||
if (CITRA_ENABLE_COMPATIBILITY_REPORTING)
|
||||
add_definitions(-DCITRA_ENABLE_COMPATIBILITY_REPORTING)
|
||||
endif()
|
||||
|
||||
if (USE_DISCORD_PRESENCE)
|
||||
target_sources(citra-qt PUBLIC
|
||||
discord_impl.cpp
|
||||
|
@ -25,7 +25,11 @@ CompatDB::CompatDB(QWidget* parent)
|
||||
|
||||
CompatDB::~CompatDB() = default;
|
||||
|
||||
enum class CompatDBPage { Intro = 0, Selection = 1, Final = 2 };
|
||||
enum class CompatDBPage {
|
||||
Intro = 0,
|
||||
Selection = 1,
|
||||
Final = 2,
|
||||
};
|
||||
|
||||
void CompatDB::Submit() {
|
||||
QButtonGroup* compatibility = new QButtonGroup(this);
|
||||
|
@ -21,7 +21,6 @@ public:
|
||||
private:
|
||||
std::unique_ptr<Ui::CompatDB> ui;
|
||||
|
||||
private slots:
|
||||
void Submit();
|
||||
void EnableNext();
|
||||
};
|
||||
|
@ -25,7 +25,7 @@ ConfigureWeb::ConfigureWeb(QWidget* parent)
|
||||
this->setConfiguration();
|
||||
}
|
||||
|
||||
ConfigureWeb::~ConfigureWeb() {}
|
||||
ConfigureWeb::~ConfigureWeb() = default;
|
||||
|
||||
void ConfigureWeb::setConfiguration() {
|
||||
ui->web_credentials_disclaimer->setWordWrap(true);
|
||||
@ -38,7 +38,7 @@ void ConfigureWeb::setConfiguration() {
|
||||
|
||||
ui->web_signup_link->setOpenExternalLinks(true);
|
||||
ui->web_signup_link->setText(
|
||||
tr("<a href='https://services.citra-emu.org/'><span style=\"text-decoration: underline; "
|
||||
tr("<a href='https://profile.citra-emu.org/'><span style=\"text-decoration: underline; "
|
||||
"color:#039be5;\">Sign up</span></a>"));
|
||||
ui->web_token_info_link->setOpenExternalLinks(true);
|
||||
ui->web_token_info_link->setText(
|
||||
|
@ -11,7 +11,7 @@ namespace DiscordRPC {
|
||||
class DiscordImpl : public DiscordInterface {
|
||||
public:
|
||||
DiscordImpl();
|
||||
~DiscordImpl();
|
||||
~DiscordImpl() override;
|
||||
|
||||
void Pause() override;
|
||||
void Update() override;
|
||||
|
@ -92,7 +92,7 @@ void GMainWindow::ShowTelemetryCallout() {
|
||||
}
|
||||
|
||||
UISettings::values.callout_flags |= static_cast<uint32_t>(CalloutFlag::Telemetry);
|
||||
static const QString telemetry_message =
|
||||
const QString telemetry_message =
|
||||
tr("<a href='https://citra-emu.org/entry/telemetry-and-why-thats-a-good-thing/'>Anonymous "
|
||||
"data is collected</a> to help improve Citra. "
|
||||
"<br/><br/>Would you like to share your usage data with us?");
|
||||
|
@ -3,6 +3,7 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <condition_variable>
|
||||
#include <functional>
|
||||
|
||||
|
@ -445,7 +445,8 @@ create_target_directory_groups(core)
|
||||
target_link_libraries(core PUBLIC common PRIVATE audio_core network video_core)
|
||||
target_link_libraries(core PUBLIC Boost::boost PRIVATE cryptopp fmt open_source_archives)
|
||||
if (ENABLE_WEB_SERVICE)
|
||||
target_link_libraries(core PUBLIC json-headers web_service)
|
||||
target_compile_definitions(core PRIVATE -DENABLE_WEB_SERVICE)
|
||||
target_link_libraries(core PRIVATE json-headers web_service)
|
||||
endif()
|
||||
|
||||
if (ARCHITECTURE_x86_64)
|
||||
|
@ -82,7 +82,7 @@ u64 RegenerateTelemetryId() {
|
||||
return new_telemetry_id;
|
||||
}
|
||||
|
||||
bool VerifyLogin(std::string username, std::string token) {
|
||||
bool VerifyLogin(const std::string& username, const std::string& token) {
|
||||
#ifdef ENABLE_WEB_SERVICE
|
||||
return WebService::VerifyLogin(Settings::values.web_api_url, username, token);
|
||||
#else
|
||||
|
@ -56,6 +56,6 @@ u64 RegenerateTelemetryId();
|
||||
* @param func A function that gets exectued when the verification is finished
|
||||
* @returns Future with bool indicating whether the verification succeeded
|
||||
*/
|
||||
bool VerifyLogin(std::string username, std::string token);
|
||||
bool VerifyLogin(const std::string& username, const std::string& token);
|
||||
|
||||
} // namespace Core
|
||||
|
@ -14,5 +14,5 @@ create_target_directory_groups(web_service)
|
||||
get_directory_property(OPENSSL_LIBS
|
||||
DIRECTORY ${CMAKE_SOURCE_DIR}/externals/libressl
|
||||
DEFINITION OPENSSL_LIBS)
|
||||
add_definitions(-DCPPHTTPLIB_OPENSSL_SUPPORT)
|
||||
target_link_libraries(web_service PUBLIC common json-headers ${OPENSSL_LIBS} httplib lurlparser)
|
||||
target_compile_definitions(web_service PRIVATE -DCPPHTTPLIB_OPENSSL_SUPPORT)
|
||||
target_link_libraries(web_service PRIVATE common json-headers ${OPENSSL_LIBS} httplib lurlparser)
|
||||
|
@ -3,10 +3,10 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <future>
|
||||
#include <json.hpp>
|
||||
#include "common/detached_tasks.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "web_service/announce_room_json.h"
|
||||
#include "web_service/json.h"
|
||||
#include "web_service/web_backend.h"
|
||||
|
||||
namespace AnnounceMultiplayerRoom {
|
||||
|
@ -1,18 +0,0 @@
|
||||
// Copyright 2018 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
// This hack is needed to support json.hpp on platforms where the C++17 stdlib
|
||||
// lacks std::string_view. See https://github.com/nlohmann/json/issues/735.
|
||||
// clang-format off
|
||||
#if !__has_include(<string_view>) && __has_include(<experimental/string_view>)
|
||||
# include <experimental/string_view>
|
||||
# define string_view experimental::string_view
|
||||
# include <json.hpp>
|
||||
# undef string_view
|
||||
#else
|
||||
# include <json.hpp>
|
||||
#endif
|
||||
// clang-format on
|
@ -10,6 +10,11 @@
|
||||
|
||||
namespace WebService {
|
||||
|
||||
TelemetryJson::TelemetryJson(const std::string& host, const std::string& username,
|
||||
const std::string& token)
|
||||
: host(std::move(host)), username(std::move(username)), token(std::move(token)) {}
|
||||
TelemetryJson::~TelemetryJson() = default;
|
||||
|
||||
template <class T>
|
||||
void TelemetryJson::Serialize(Telemetry::FieldType type, const std::string& name, T value) {
|
||||
sections[static_cast<u8>(type)][name] = value;
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <json.hpp>
|
||||
#include "common/announce_multiplayer_room.h"
|
||||
#include "common/telemetry.h"
|
||||
#include "web_service/json.h"
|
||||
|
||||
namespace WebService {
|
||||
|
||||
@ -18,9 +18,8 @@ namespace WebService {
|
||||
*/
|
||||
class TelemetryJson : public Telemetry::VisitorInterface {
|
||||
public:
|
||||
TelemetryJson(const std::string& host, const std::string& username, const std::string& token)
|
||||
: host(host), username(username), token(token) {}
|
||||
~TelemetryJson() = default;
|
||||
TelemetryJson(const std::string& host, const std::string& username, const std::string& token);
|
||||
~TelemetryJson();
|
||||
|
||||
void Visit(const Telemetry::Field<bool>& field) override;
|
||||
void Visit(const Telemetry::Field<double>& field) override;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "web_service/json.h"
|
||||
#include <json.hpp>
|
||||
#include "web_service/verify_login.h"
|
||||
#include "web_service/web_backend.h"
|
||||
|
||||
|
@ -6,19 +6,19 @@
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <LUrlParser.h>
|
||||
#include <httplib.h>
|
||||
#include "common/announce_multiplayer_room.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/settings.h"
|
||||
#include "web_service/web_backend.h"
|
||||
|
||||
namespace WebService {
|
||||
|
||||
static constexpr char API_VERSION[]{"1"};
|
||||
constexpr std::array<const char, 1> API_VERSION{'1'};
|
||||
|
||||
constexpr int HTTP_PORT = 80;
|
||||
constexpr int HTTPS_PORT = 443;
|
||||
|
||||
constexpr int TIMEOUT_SECONDS = 30;
|
||||
constexpr std::size_t TIMEOUT_SECONDS = 30;
|
||||
|
||||
Client::JWTCache Client::jwt_cache{};
|
||||
|
||||
@ -30,6 +30,8 @@ Client::Client(const std::string& host, const std::string& username, const std::
|
||||
}
|
||||
}
|
||||
|
||||
Client::~Client() = default;
|
||||
|
||||
Common::WebResult Client::GenericJson(const std::string& method, const std::string& path,
|
||||
const std::string& data, const std::string& jwt,
|
||||
const std::string& username, const std::string& token) {
|
||||
@ -70,7 +72,7 @@ Common::WebResult Client::GenericJson(const std::string& method, const std::stri
|
||||
};
|
||||
}
|
||||
|
||||
params.emplace(std::string("api-version"), std::string(API_VERSION));
|
||||
params.emplace(std::string("api-version"), std::string(API_VERSION.begin(), API_VERSION.end()));
|
||||
if (method != "GET") {
|
||||
params.emplace(std::string("Content-Type"), std::string("application/json"));
|
||||
};
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <httplib.h>
|
||||
#include "common/announce_multiplayer_room.h"
|
||||
#include "common/common_types.h"
|
||||
|
||||
@ -21,6 +20,7 @@ namespace WebService {
|
||||
class Client {
|
||||
public:
|
||||
Client(const std::string& host, const std::string& username, const std::string& token);
|
||||
~Client();
|
||||
|
||||
/**
|
||||
* Posts JSON to the specified path.
|
||||
|
Loading…
Reference in New Issue
Block a user