chore: make yuzu REUSE compliant
[REUSE] is a specification that aims at making file copyright
information consistent, so that it can be both human and machine
readable. It basically requires that all files have a header containing
copyright and licensing information. When this isn't possible, like
when dealing with binary assets, generated files or embedded third-party
dependencies, it is permitted to insert copyright information in the
`.reuse/dep5` file.
Oh, and it also requires that all the licenses used in the project are
present in the `LICENSES` folder, that's why the diff is so huge.
This can be done automatically with `reuse download --all`.
The `reuse` tool also contains a handy subcommand that analyzes the
project and tells whether or not the project is (still) compliant,
`reuse lint`.
Following REUSE has a few advantages over the current approach:
- Copyright information is easy to access for users / downstream
- Files like `dist/license.md` do not need to exist anymore, as
`.reuse/dep5` is used instead
- `reuse lint` makes it easy to ensure that copyright information of
files like binary assets / images is always accurate and up to date
To add copyright information of files that didn't have it I looked up
who committed what and when, for each file. As yuzu contributors do not
have to sign a CLA or similar I couldn't assume that copyright ownership
was of the "yuzu Emulator Project", so I used the name and/or email of
the commit author instead.
[REUSE]: https://reuse.software
Follow-up to 01cf05bc75b1e47beb08937439f3ed9339e7b254
2022-05-15 01:06:02 +01:00
|
|
|
// SPDX-FileCopyrightText: 2017 Citra Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-09-16 19:05:51 +01:00
|
|
|
|
2020-05-08 22:09:29 +01:00
|
|
|
#include <nlohmann/json.hpp>
|
2018-09-16 19:05:51 +01:00
|
|
|
#include "common/detached_tasks.h"
|
|
|
|
#include "web_service/telemetry_json.h"
|
|
|
|
#include "web_service/web_backend.h"
|
2020-08-23 00:23:22 +01:00
|
|
|
#include "web_service/web_result.h"
|
2018-09-16 19:05:51 +01:00
|
|
|
|
|
|
|
namespace WebService {
|
|
|
|
|
2020-08-18 19:21:50 +01:00
|
|
|
namespace Telemetry = Common::Telemetry;
|
|
|
|
|
2018-10-11 02:04:19 +01:00
|
|
|
struct TelemetryJson::Impl {
|
2022-05-27 00:57:11 +01:00
|
|
|
Impl(std::string host_, std::string username_, std::string token_)
|
|
|
|
: host{std::move(host_)}, username{std::move(username_)}, token{std::move(token_)} {}
|
2018-09-17 16:16:01 +01:00
|
|
|
|
2018-10-11 02:04:19 +01:00
|
|
|
nlohmann::json& TopSection() {
|
|
|
|
return sections[static_cast<u8>(Telemetry::FieldType::None)];
|
|
|
|
}
|
2018-09-16 19:05:51 +01:00
|
|
|
|
2018-10-11 02:04:19 +01:00
|
|
|
const nlohmann::json& TopSection() const {
|
|
|
|
return sections[static_cast<u8>(Telemetry::FieldType::None)];
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
void Serialize(Telemetry::FieldType type, const std::string& name, T value) {
|
|
|
|
sections[static_cast<u8>(type)][name] = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SerializeSection(Telemetry::FieldType type, const std::string& name) {
|
|
|
|
TopSection()[name] = sections[static_cast<unsigned>(type)];
|
|
|
|
}
|
|
|
|
|
|
|
|
nlohmann::json output;
|
|
|
|
std::array<nlohmann::json, 7> sections;
|
|
|
|
std::string host;
|
|
|
|
std::string username;
|
|
|
|
std::string token;
|
|
|
|
};
|
|
|
|
|
|
|
|
TelemetryJson::TelemetryJson(std::string host, std::string username, std::string token)
|
|
|
|
: impl{std::make_unique<Impl>(std::move(host), std::move(username), std::move(token))} {}
|
|
|
|
TelemetryJson::~TelemetryJson() = default;
|
2018-09-16 19:05:51 +01:00
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<bool>& field) {
|
2018-10-11 02:04:19 +01:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 19:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<double>& field) {
|
2018-10-11 02:04:19 +01:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 19:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<float>& field) {
|
2018-10-11 02:04:19 +01:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 19:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<u8>& field) {
|
2018-10-11 02:04:19 +01:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 19:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<u16>& field) {
|
2018-10-11 02:04:19 +01:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 19:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<u32>& field) {
|
2018-10-11 02:04:19 +01:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 19:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<u64>& field) {
|
2018-10-11 02:04:19 +01:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 19:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<s8>& field) {
|
2018-10-11 02:04:19 +01:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 19:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<s16>& field) {
|
2018-10-11 02:04:19 +01:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 19:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<s32>& field) {
|
2018-10-11 02:04:19 +01:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 19:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<s64>& field) {
|
2018-10-11 02:04:19 +01:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 19:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<std::string>& field) {
|
2018-10-11 02:04:19 +01:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 19:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<const char*>& field) {
|
2018-10-11 02:04:19 +01:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), std::string(field.GetValue()));
|
2018-09-16 19:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<std::chrono::microseconds>& field) {
|
2018-10-11 02:04:19 +01:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue().count());
|
2018-09-16 19:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Complete() {
|
2018-10-11 02:04:19 +01:00
|
|
|
impl->SerializeSection(Telemetry::FieldType::App, "App");
|
|
|
|
impl->SerializeSection(Telemetry::FieldType::Session, "Session");
|
|
|
|
impl->SerializeSection(Telemetry::FieldType::Performance, "Performance");
|
|
|
|
impl->SerializeSection(Telemetry::FieldType::UserConfig, "UserConfig");
|
|
|
|
impl->SerializeSection(Telemetry::FieldType::UserSystem, "UserSystem");
|
|
|
|
|
|
|
|
auto content = impl->TopSection().dump();
|
2018-09-16 19:05:51 +01:00
|
|
|
// Send the telemetry async but don't handle the errors since they were written to the log
|
2018-10-26 15:21:45 +01:00
|
|
|
Common::DetachedTasks::AddTask([host{impl->host}, content]() {
|
|
|
|
Client{host, "", ""}.PostJson("/telemetry", content, true);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TelemetryJson::SubmitTestcase() {
|
|
|
|
impl->SerializeSection(Telemetry::FieldType::App, "App");
|
|
|
|
impl->SerializeSection(Telemetry::FieldType::Session, "Session");
|
|
|
|
impl->SerializeSection(Telemetry::FieldType::UserFeedback, "UserFeedback");
|
|
|
|
impl->SerializeSection(Telemetry::FieldType::UserSystem, "UserSystem");
|
2020-01-21 19:38:36 +00:00
|
|
|
impl->SerializeSection(Telemetry::FieldType::UserConfig, "UserConfig");
|
2018-10-26 15:21:45 +01:00
|
|
|
|
|
|
|
auto content = impl->TopSection().dump();
|
|
|
|
Client client(impl->host, impl->username, impl->token);
|
|
|
|
auto value = client.PostJson("/gamedb/testcase", content, false);
|
|
|
|
|
2020-08-23 00:23:22 +01:00
|
|
|
return value.result_code == WebResult::Code::Success;
|
2018-09-16 19:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace WebService
|