yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

boxcat: Implement events global field

This commit is contained in:
Zach Hilman 2019-06-20 20:31:17 -04:00
parent 2d410ddf4d
commit bcf1eafb8b
7 changed files with 44 additions and 31 deletions

2
externals/libzip vendored

@ -1 +1 @@
Subproject commit bebbb54c8e691f019415fcb852ef4d53ebbc5000 Subproject commit bd7a8103e96bc6d50164447f6b7b57bb786d8e2a

View File

@ -13,7 +13,7 @@ namespace Service::BCAT {
ProgressServiceBackend::ProgressServiceBackend(std::string event_name) : impl{} { ProgressServiceBackend::ProgressServiceBackend(std::string event_name) : impl{} {
auto& kernel{Core::System::GetInstance().Kernel()}; auto& kernel{Core::System::GetInstance().Kernel()};
event = Kernel::WritableEvent::CreateEventPair( event = Kernel::WritableEvent::CreateEventPair(
kernel, Kernel::ResetType::OneShot, "ProgressServiceBackend:UpdateEvent:" + event_name); kernel, Kernel::ResetType::Automatic, "ProgressServiceBackend:UpdateEvent:" + event_name);
} }
Kernel::SharedPtr<Kernel::ReadableEvent> ProgressServiceBackend::GetEvent() { Kernel::SharedPtr<Kernel::ReadableEvent> ProgressServiceBackend::GetEvent() {
@ -48,8 +48,10 @@ void ProgressServiceBackend::StartDownloadingFile(std::string_view dir_name,
impl.status = DeliveryCacheProgressImpl::Status::Downloading; impl.status = DeliveryCacheProgressImpl::Status::Downloading;
impl.current_downloaded_bytes = 0; impl.current_downloaded_bytes = 0;
impl.current_total_bytes = file_size; impl.current_total_bytes = file_size;
std::memcpy(impl.current_directory.data(), dir_name.data(), std::min(dir_name.size(), 0x31ull)); std::memcpy(impl.current_directory.data(), dir_name.data(),
std::memcpy(impl.current_file.data(), file_name.data(), std::min(file_name.size(), 0x31ull)); std::min<u64>(dir_name.size(), 0x31ull));
std::memcpy(impl.current_file.data(), file_name.data(),
std::min<u64>(file_name.size(), 0x31ull));
SignalUpdate(); SignalUpdate();
} }
@ -68,7 +70,8 @@ void ProgressServiceBackend::CommitDirectory(std::string_view dir_name) {
impl.current_file.fill(0); impl.current_file.fill(0);
impl.current_downloaded_bytes = 0; impl.current_downloaded_bytes = 0;
impl.current_total_bytes = 0; impl.current_total_bytes = 0;
std::memcpy(impl.current_directory.data(), dir_name.data(), std::min(dir_name.size(), 0x31ull)); std::memcpy(impl.current_directory.data(), dir_name.data(),
std::min<u64>(dir_name.size(), 0x31ull));
SignalUpdate(); SignalUpdate();
} }
@ -121,7 +124,7 @@ bool NullBackend::Clear(u64 title_id) {
void NullBackend::SetPassphrase(u64 title_id, const Passphrase& passphrase) { void NullBackend::SetPassphrase(u64 title_id, const Passphrase& passphrase) {
LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, passphrase = {}", title_id, LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, passphrase = {}", title_id,
Common::HexArrayToString(passphrase)); Common::HexToString(passphrase));
} }
std::optional<std::vector<u8>> NullBackend::GetLaunchParameter(TitleIDVersion title) { std::optional<std::vector<u8>> NullBackend::GetLaunchParameter(TitleIDVersion title) {

View File

@ -214,8 +214,7 @@ private:
std::vector<u8> bytes(file.GetSize()); std::vector<u8> bytes(file.GetSize());
file.ReadBytes(bytes.data(), bytes.size()); file.ReadBytes(bytes.data(), bytes.size());
const auto digest = DigestFile(bytes); const auto digest = DigestFile(bytes);
headers.insert( headers.insert({std::string("If-None-Match"), Common::HexToString(digest, false)});
{std::string("If-None-Match"), Common::HexArrayToString(digest, false)});
} }
} }
@ -402,7 +401,7 @@ bool Boxcat::Clear(u64 title_id) {
void Boxcat::SetPassphrase(u64 title_id, const Passphrase& passphrase) { void Boxcat::SetPassphrase(u64 title_id, const Passphrase& passphrase) {
LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, passphrase={}", title_id, LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, passphrase={}", title_id,
Common::HexArrayToString(passphrase)); Common::HexToString(passphrase));
} }
std::optional<std::vector<u8>> Boxcat::GetLaunchParameter(TitleIDVersion title) { std::optional<std::vector<u8>> Boxcat::GetLaunchParameter(TitleIDVersion title) {

View File

@ -195,7 +195,7 @@ private:
const auto passphrase_raw = ctx.ReadBuffer(); const auto passphrase_raw = ctx.ReadBuffer();
LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, passphrase={}", title_id, LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, passphrase={}", title_id,
Common::HexVectorToString(passphrase_raw)); Common::HexToString(passphrase_raw));
if (title_id == 0) { if (title_id == 0) {
LOG_ERROR(Service_BCAT, "Invalid title ID!"); LOG_ERROR(Service_BCAT, "Invalid title ID!");
@ -335,7 +335,7 @@ private:
rb.Push(ERROR_NO_OPEN_ENTITY); rb.Push(ERROR_NO_OPEN_ENTITY);
} }
size = std::min(current_file->GetSize() - offset, size); size = std::min<u64>(current_file->GetSize() - offset, size);
const auto buffer = current_file->ReadBytes(size, offset); const auto buffer = current_file->ReadBytes(size, offset);
ctx.WriteBuffer(buffer); ctx.WriteBuffer(buffer);
@ -437,7 +437,7 @@ private:
} }
const auto files = current_dir->GetFiles(); const auto files = current_dir->GetFiles();
write_size = std::min(write_size, files.size()); write_size = std::min<u64>(write_size, files.size());
std::vector<DeliveryCacheDirectoryEntry> entries(write_size); std::vector<DeliveryCacheDirectoryEntry> entries(write_size);
std::transform( std::transform(
files.begin(), files.begin() + write_size, entries.begin(), [](const auto& file) { files.begin(), files.begin() + write_size, entries.begin(), [](const auto& file) {
@ -519,7 +519,7 @@ private:
LOG_DEBUG(Service_BCAT, "called, size={:016X}", size); LOG_DEBUG(Service_BCAT, "called, size={:016X}", size);
size = std::min(size, entries.size() - next_read_index); size = std::min<u64>(size, entries.size() - next_read_index);
ctx.WriteBuffer(entries.data() + next_read_index, size * sizeof(DirectoryName)); ctx.WriteBuffer(entries.data() + next_read_index, size * sizeof(DirectoryName));
next_read_index += size; next_read_index += size;

View File

@ -526,9 +526,13 @@ void Config::ReadDebuggingValues() {
} }
void Config::ReadServiceValues() { void Config::ReadServiceValues() {
qt_config->beginGroup("Services"); qt_config->beginGroup(QStringLiteral("Services"));
Settings::values.bcat_backend = ReadSetting("bcat_backend", "boxcat").toString().toStdString(); Settings::values.bcat_backend =
Settings::values.bcat_boxcat_local = ReadSetting("bcat_boxcat_local", false).toBool(); ReadSetting(QStringLiteral("bcat_backend"), QStringLiteral("boxcat"))
.toString()
.toStdString();
Settings::values.bcat_boxcat_local =
ReadSetting(QStringLiteral("bcat_boxcat_local"), false).toBool();
qt_config->endGroup(); qt_config->endGroup();
} }
@ -973,9 +977,10 @@ void Config::SaveDebuggingValues() {
} }
void Config::SaveServiceValues() { void Config::SaveServiceValues() {
qt_config->beginGroup("Services"); qt_config->beginGroup(QStringLiteral("Services"));
WriteSetting("bcat_backend", QString::fromStdString(Settings::values.bcat_backend), "null"); WriteSetting(QStringLiteral("bcat_backend"),
WriteSetting("bcat_boxcat_local", Settings::values.bcat_boxcat_local, false); QString::fromStdString(Settings::values.bcat_backend), QStringLiteral("null"));
WriteSetting(QStringLiteral("bcat_boxcat_local"), Settings::values.bcat_boxcat_local, false);
qt_config->endGroup(); qt_config->endGroup();
} }

View File

@ -48,20 +48,20 @@ ConfigureService::ConfigureService(QWidget* parent)
connect(ui->bcat_source, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(ui->bcat_source, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ConfigureService::OnBCATImplChanged); &ConfigureService::OnBCATImplChanged);
this->setConfiguration(); this->SetConfiguration();
} }
ConfigureService::~ConfigureService() = default; ConfigureService::~ConfigureService() = default;
void ConfigureService::applyConfiguration() { void ConfigureService::ApplyConfiguration() {
Settings::values.bcat_backend = ui->bcat_source->currentText().toLower().toStdString(); Settings::values.bcat_backend = ui->bcat_source->currentText().toLower().toStdString();
} }
void ConfigureService::retranslateUi() { void ConfigureService::RetranslateUi() {
ui->retranslateUi(this); ui->retranslateUi(this);
} }
void ConfigureService::setConfiguration() { void ConfigureService::SetConfiguration() {
int index = ui->bcat_source->findData(QString::fromStdString(Settings::values.bcat_backend)); int index = ui->bcat_source->findData(QString::fromStdString(Settings::values.bcat_backend));
ui->bcat_source->setCurrentIndex(index == -1 ? 0 : index); ui->bcat_source->setCurrentIndex(index == -1 ? 0 : index);
} }
@ -73,13 +73,14 @@ std::pair<QString, QString> ConfigureService::BCATDownloadEvents() {
switch (res) { switch (res) {
case Service::BCAT::Boxcat::StatusResult::Offline: case Service::BCAT::Boxcat::StatusResult::Offline:
return {"", tr("The boxcat service is offline or you are not connected to the internet.")}; return {QStringLiteral(""),
tr("The boxcat service is offline or you are not connected to the internet.")};
case Service::BCAT::Boxcat::StatusResult::ParseError: case Service::BCAT::Boxcat::StatusResult::ParseError:
return {"", return {QStringLiteral(""),
tr("There was an error while processing the boxcat event data. Contact the yuzu " tr("There was an error while processing the boxcat event data. Contact the yuzu "
"developers.")}; "developers.")};
case Service::BCAT::Boxcat::StatusResult::BadClientVersion: case Service::BCAT::Boxcat::StatusResult::BadClientVersion:
return {"", return {QStringLiteral(""),
tr("The version of yuzu you are using is either too new or too old for the server. " tr("The version of yuzu you are using is either too new or too old for the server. "
"Try updating to the latest official release of yuzu.")}; "Try updating to the latest official release of yuzu.")};
} }
@ -90,9 +91,14 @@ std::pair<QString, QString> ConfigureService::BCATDownloadEvents() {
} }
QString out; QString out;
if (global.has_value()) {
out += QStringLiteral("%1<br>").arg(QString::fromStdString(*global));
}
for (const auto& [key, value] : map) { for (const auto& [key, value] : map) {
out += QStringLiteral("%1<b>%2</b><br>%3") out += QStringLiteral("%1<b>%2</b><br>%3")
.arg(out.isEmpty() ? "" : "<br>") .arg(out.isEmpty() ? QStringLiteral("") : QStringLiteral("<br>"))
.arg(QString::fromStdString(key)) .arg(QString::fromStdString(key))
.arg(FormatEventStatusString(value)); .arg(FormatEventStatusString(value));
} }
@ -104,7 +110,7 @@ void ConfigureService::OnBCATImplChanged() {
const auto boxcat = ui->bcat_source->currentText() == QStringLiteral("Boxcat"); const auto boxcat = ui->bcat_source->currentText() == QStringLiteral("Boxcat");
ui->bcat_empty_header->setHidden(!boxcat); ui->bcat_empty_header->setHidden(!boxcat);
ui->bcat_empty_label->setHidden(!boxcat); ui->bcat_empty_label->setHidden(!boxcat);
ui->bcat_empty_header->setText(""); ui->bcat_empty_header->setText(QStringLiteral(""));
ui->bcat_empty_label->setText(tr("Yuzu is retrieving the latest boxcat status...")); ui->bcat_empty_label->setText(tr("Yuzu is retrieving the latest boxcat status..."));
if (!boxcat) if (!boxcat)

View File

@ -19,11 +19,11 @@ public:
explicit ConfigureService(QWidget* parent = nullptr); explicit ConfigureService(QWidget* parent = nullptr);
~ConfigureService() override; ~ConfigureService() override;
void applyConfiguration(); void ApplyConfiguration();
void retranslateUi(); void RetranslateUi();
private: private:
void setConfiguration(); void SetConfiguration();
std::pair<QString, QString> BCATDownloadEvents(); std::pair<QString, QString> BCATDownloadEvents();
void OnBCATImplChanged(); void OnBCATImplChanged();