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-14 19:06:02 -05:00
|
|
|
// SPDX-FileCopyrightText: 2017 Citra Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-09-16 13:05:51 -05:00
|
|
|
|
2020-05-08 16:09:29 -05:00
|
|
|
#include <nlohmann/json.hpp>
|
2018-09-16 13:05:51 -05:00
|
|
|
#include "common/detached_tasks.h"
|
|
|
|
#include "web_service/telemetry_json.h"
|
|
|
|
#include "web_service/web_backend.h"
|
2020-08-22 18:23:22 -05:00
|
|
|
#include "web_service/web_result.h"
|
2018-09-16 13:05:51 -05:00
|
|
|
|
|
|
|
namespace WebService {
|
|
|
|
|
2020-08-18 13:21:50 -05:00
|
|
|
namespace Telemetry = Common::Telemetry;
|
|
|
|
|
2018-10-10 20:04:19 -05:00
|
|
|
struct TelemetryJson::Impl {
|
2022-05-26 18:57:11 -05: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 10:16:01 -05:00
|
|
|
|
2018-10-10 20:04:19 -05:00
|
|
|
nlohmann::json& TopSection() {
|
|
|
|
return sections[static_cast<u8>(Telemetry::FieldType::None)];
|
|
|
|
}
|
2018-09-16 13:05:51 -05:00
|
|
|
|
2018-10-10 20:04:19 -05: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 13:05:51 -05:00
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<bool>& field) {
|
2018-10-10 20:04:19 -05:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 13:05:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<double>& field) {
|
2018-10-10 20:04:19 -05:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 13:05:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<float>& field) {
|
2018-10-10 20:04:19 -05:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 13:05:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<u8>& field) {
|
2018-10-10 20:04:19 -05:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 13:05:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<u16>& field) {
|
2018-10-10 20:04:19 -05:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 13:05:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<u32>& field) {
|
2018-10-10 20:04:19 -05:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 13:05:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<u64>& field) {
|
2018-10-10 20:04:19 -05:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 13:05:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<s8>& field) {
|
2018-10-10 20:04:19 -05:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 13:05:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<s16>& field) {
|
2018-10-10 20:04:19 -05:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 13:05:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<s32>& field) {
|
2018-10-10 20:04:19 -05:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 13:05:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<s64>& field) {
|
2018-10-10 20:04:19 -05:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 13:05:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<std::string>& field) {
|
2018-10-10 20:04:19 -05:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
|
2018-09-16 13:05:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<const char*>& field) {
|
2018-10-10 20:04:19 -05:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), std::string(field.GetValue()));
|
2018-09-16 13:05:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Visit(const Telemetry::Field<std::chrono::microseconds>& field) {
|
2018-10-10 20:04:19 -05:00
|
|
|
impl->Serialize(field.GetType(), field.GetName(), field.GetValue().count());
|
2018-09-16 13:05:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void TelemetryJson::Complete() {
|
2018-10-10 20:04:19 -05: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 13:05:51 -05:00
|
|
|
// Send the telemetry async but don't handle the errors since they were written to the log
|
2018-10-26 09:21:45 -05: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 13:38:36 -06:00
|
|
|
impl->SerializeSection(Telemetry::FieldType::UserConfig, "UserConfig");
|
2018-10-26 09:21:45 -05:00
|
|
|
|
|
|
|
auto content = impl->TopSection().dump();
|
|
|
|
Client client(impl->host, impl->username, impl->token);
|
|
|
|
auto value = client.PostJson("/gamedb/testcase", content, false);
|
|
|
|
|
2020-08-22 18:23:22 -05:00
|
|
|
return value.result_code == WebResult::Code::Success;
|
2018-09-16 13:05:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace WebService
|