diff --git a/CMakeLists.txt b/CMakeLists.txt index 9353a5155..b91e996f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index aa8b0d6f2..13b347d89 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -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) diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h index d05fc6bbc..730809413 100644 --- a/src/citra/default_ini.h +++ b/src/citra/default_ini.h @@ -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 = )"; diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index 3a61f9aa0..ea275f3d2 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -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 diff --git a/src/citra_qt/compatdb.cpp b/src/citra_qt/compatdb.cpp index fb0042b3c..d6712338c 100644 --- a/src/citra_qt/compatdb.cpp +++ b/src/citra_qt/compatdb.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); diff --git a/src/citra_qt/compatdb.h b/src/citra_qt/compatdb.h index 0a0f27cca..ca0dd11d6 100644 --- a/src/citra_qt/compatdb.h +++ b/src/citra_qt/compatdb.h @@ -21,7 +21,6 @@ public: private: std::unique_ptr ui; -private slots: void Submit(); void EnableNext(); }; diff --git a/src/citra_qt/configuration/configure_web.cpp b/src/citra_qt/configuration/configure_web.cpp index cf1daf76b..d74a5bafa 100644 --- a/src/citra_qt/configuration/configure_web.cpp +++ b/src/citra_qt/configuration/configure_web.cpp @@ -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("Sign up")); ui->web_token_info_link->setOpenExternalLinks(true); ui->web_token_info_link->setText( diff --git a/src/citra_qt/discord_impl.h b/src/citra_qt/discord_impl.h index e714ae6d9..067cf2e3d 100644 --- a/src/citra_qt/discord_impl.h +++ b/src/citra_qt/discord_impl.h @@ -11,7 +11,7 @@ namespace DiscordRPC { class DiscordImpl : public DiscordInterface { public: DiscordImpl(); - ~DiscordImpl(); + ~DiscordImpl() override; void Pause() override; void Update() override; diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 8d0856af1..669ced7f6 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -92,7 +92,7 @@ void GMainWindow::ShowTelemetryCallout() { } UISettings::values.callout_flags |= static_cast(CalloutFlag::Telemetry); - static const QString telemetry_message = + const QString telemetry_message = tr("Anonymous " "data is collected to help improve Citra. " "

Would you like to share your usage data with us?"); diff --git a/src/common/detached_tasks.h b/src/common/detached_tasks.h index eae27788d..5dd8fc27b 100644 --- a/src/common/detached_tasks.h +++ b/src/common/detached_tasks.h @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #pragma once + #include #include diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 1498ee343..2b9838a84 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -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) diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 015a837f7..94270dbfe 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -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 diff --git a/src/core/telemetry_session.h b/src/core/telemetry_session.h index 127b6fe5e..bcf206b1b 100644 --- a/src/core/telemetry_session.h +++ b/src/core/telemetry_session.h @@ -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 diff --git a/src/web_service/CMakeLists.txt b/src/web_service/CMakeLists.txt index fc311cb81..993ba9ac6 100644 --- a/src/web_service/CMakeLists.txt +++ b/src/web_service/CMakeLists.txt @@ -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) diff --git a/src/web_service/announce_room_json.cpp b/src/web_service/announce_room_json.cpp index 6a6512491..c0d543e73 100644 --- a/src/web_service/announce_room_json.cpp +++ b/src/web_service/announce_room_json.cpp @@ -3,10 +3,10 @@ // Refer to the license.txt file included. #include +#include #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 { diff --git a/src/web_service/json.h b/src/web_service/json.h deleted file mode 100644 index 88b31501e..000000000 --- a/src/web_service/json.h +++ /dev/null @@ -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() && __has_include() -# include -# define string_view experimental::string_view -# include -# undef string_view -#else -# include -#endif -// clang-format on diff --git a/src/web_service/telemetry_json.cpp b/src/web_service/telemetry_json.cpp index a0b7f9c4e..033ea1ea4 100644 --- a/src/web_service/telemetry_json.cpp +++ b/src/web_service/telemetry_json.cpp @@ -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 void TelemetryJson::Serialize(Telemetry::FieldType type, const std::string& name, T value) { sections[static_cast(type)][name] = value; diff --git a/src/web_service/telemetry_json.h b/src/web_service/telemetry_json.h index 4335ade59..42a15b6a4 100644 --- a/src/web_service/telemetry_json.h +++ b/src/web_service/telemetry_json.h @@ -6,9 +6,9 @@ #include #include +#include #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& field) override; void Visit(const Telemetry::Field& field) override; diff --git a/src/web_service/verify_login.cpp b/src/web_service/verify_login.cpp index 02e1b74f3..124aa3863 100644 --- a/src/web_service/verify_login.cpp +++ b/src/web_service/verify_login.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "web_service/json.h" +#include #include "web_service/verify_login.h" #include "web_service/web_backend.h" diff --git a/src/web_service/web_backend.cpp b/src/web_service/web_backend.cpp index 3c5d278e8..9b824e47d 100644 --- a/src/web_service/web_backend.cpp +++ b/src/web_service/web_backend.cpp @@ -6,19 +6,19 @@ #include #include #include +#include #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 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")); }; diff --git a/src/web_service/web_backend.h b/src/web_service/web_backend.h index 955b91c7a..6cdf35b48 100644 --- a/src/web_service/web_backend.h +++ b/src/web_service/web_backend.h @@ -8,7 +8,6 @@ #include #include #include -#include #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.