From 7c2e9a6596c8b6c5d366c3eaaf926ad7db406486 Mon Sep 17 00:00:00 2001 From: Narr the Reg Date: Thu, 8 Feb 2024 16:58:44 -0600 Subject: service: bcat: Migrate and refractor service to new IPC --- src/core/hle/service/bcat/backend/backend.cpp | 30 +++++++-------- src/core/hle/service/bcat/backend/backend.h | 54 +++++---------------------- 2 files changed, 24 insertions(+), 60 deletions(-) (limited to 'src/core/hle/service/bcat/backend') diff --git a/src/core/hle/service/bcat/backend/backend.cpp b/src/core/hle/service/bcat/backend/backend.cpp index 847f76987..1993493a9 100644 --- a/src/core/hle/service/bcat/backend/backend.cpp +++ b/src/core/hle/service/bcat/backend/backend.cpp @@ -33,18 +33,18 @@ void ProgressServiceBackend::SetTotalSize(u64 size) { } void ProgressServiceBackend::StartConnecting() { - impl.status = DeliveryCacheProgressImpl::Status::Connecting; + impl.status = DeliveryCacheProgressStatus::Connecting; SignalUpdate(); } void ProgressServiceBackend::StartProcessingDataList() { - impl.status = DeliveryCacheProgressImpl::Status::ProcessingDataList; + impl.status = DeliveryCacheProgressStatus::ProcessingDataList; SignalUpdate(); } void ProgressServiceBackend::StartDownloadingFile(std::string_view dir_name, std::string_view file_name, u64 file_size) { - impl.status = DeliveryCacheProgressImpl::Status::Downloading; + impl.status = DeliveryCacheProgressStatus::Downloading; impl.current_downloaded_bytes = 0; impl.current_total_bytes = file_size; std::memcpy(impl.current_directory.data(), dir_name.data(), @@ -65,7 +65,7 @@ void ProgressServiceBackend::FinishDownloadingFile() { } void ProgressServiceBackend::CommitDirectory(std::string_view dir_name) { - impl.status = DeliveryCacheProgressImpl::Status::Committing; + impl.status = DeliveryCacheProgressStatus::Committing; impl.current_file.fill(0); impl.current_downloaded_bytes = 0; impl.current_total_bytes = 0; @@ -76,7 +76,7 @@ void ProgressServiceBackend::CommitDirectory(std::string_view dir_name) { void ProgressServiceBackend::FinishDownload(Result result) { impl.total_downloaded_bytes = impl.total_bytes; - impl.status = DeliveryCacheProgressImpl::Status::Done; + impl.status = DeliveryCacheProgressStatus::Done; impl.result = result; SignalUpdate(); } @@ -85,15 +85,15 @@ void ProgressServiceBackend::SignalUpdate() { update_event->Signal(); } -Backend::Backend(DirectoryGetter getter) : dir_getter(std::move(getter)) {} +BcatBackend::BcatBackend(DirectoryGetter getter) : dir_getter(std::move(getter)) {} -Backend::~Backend() = default; +BcatBackend::~BcatBackend() = default; -NullBackend::NullBackend(DirectoryGetter getter) : Backend(std::move(getter)) {} +NullBcatBackend::NullBcatBackend(DirectoryGetter getter) : BcatBackend(std::move(getter)) {} -NullBackend::~NullBackend() = default; +NullBcatBackend::~NullBcatBackend() = default; -bool NullBackend::Synchronize(TitleIDVersion title, ProgressServiceBackend& progress) { +bool NullBcatBackend::Synchronize(TitleIDVersion title, ProgressServiceBackend& progress) { LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, build_id={:016X}", title.title_id, title.build_id); @@ -101,8 +101,8 @@ bool NullBackend::Synchronize(TitleIDVersion title, ProgressServiceBackend& prog return true; } -bool NullBackend::SynchronizeDirectory(TitleIDVersion title, std::string name, - ProgressServiceBackend& progress) { +bool NullBcatBackend::SynchronizeDirectory(TitleIDVersion title, std::string name, + ProgressServiceBackend& progress) { LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, build_id={:016X}, name={}", title.title_id, title.build_id, name); @@ -110,18 +110,18 @@ bool NullBackend::SynchronizeDirectory(TitleIDVersion title, std::string name, return true; } -bool NullBackend::Clear(u64 title_id) { +bool NullBcatBackend::Clear(u64 title_id) { LOG_DEBUG(Service_BCAT, "called, title_id={:016X}", title_id); return true; } -void NullBackend::SetPassphrase(u64 title_id, const Passphrase& passphrase) { +void NullBcatBackend::SetPassphrase(u64 title_id, const Passphrase& passphrase) { LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, passphrase={}", title_id, Common::HexToString(passphrase)); } -std::optional> NullBackend::GetLaunchParameter(TitleIDVersion title) { +std::optional> NullBcatBackend::GetLaunchParameter(TitleIDVersion title) { LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, build_id={:016X}", title.title_id, title.build_id); return std::nullopt; diff --git a/src/core/hle/service/bcat/backend/backend.h b/src/core/hle/service/bcat/backend/backend.h index aa36d29d5..3680f6c9c 100644 --- a/src/core/hle/service/bcat/backend/backend.h +++ b/src/core/hle/service/bcat/backend/backend.h @@ -10,6 +10,7 @@ #include "common/common_types.h" #include "core/file_sys/vfs/vfs_types.h" #include "core/hle/result.h" +#include "core/hle/service/bcat/bcat_types.h" #include "core/hle/service/kernel_helpers.h" namespace Core { @@ -24,44 +25,6 @@ class KReadableEvent; namespace Service::BCAT { -struct DeliveryCacheProgressImpl; - -using DirectoryGetter = std::function; -using Passphrase = std::array; - -struct TitleIDVersion { - u64 title_id; - u64 build_id; -}; - -using DirectoryName = std::array; -using FileName = std::array; - -struct DeliveryCacheProgressImpl { - enum class Status : s32 { - None = 0x0, - Queued = 0x1, - Connecting = 0x2, - ProcessingDataList = 0x3, - Downloading = 0x4, - Committing = 0x5, - Done = 0x9, - }; - - Status status; - Result result = ResultSuccess; - DirectoryName current_directory; - FileName current_file; - s64 current_downloaded_bytes; ///< Bytes downloaded on current file. - s64 current_total_bytes; ///< Bytes total on current file. - s64 total_downloaded_bytes; ///< Bytes downloaded on overall download. - s64 total_bytes; ///< Bytes total on overall download. - INSERT_PADDING_BYTES( - 0x198); ///< Appears to be unused in official code, possibly reserved for future use. -}; -static_assert(sizeof(DeliveryCacheProgressImpl) == 0x200, - "DeliveryCacheProgressImpl has incorrect size."); - // A class to manage the signalling to the game about BCAT download progress. // Some of this class is implemented in module.cpp to avoid exposing the implementation structure. class ProgressServiceBackend { @@ -107,10 +70,10 @@ private: }; // A class representing an abstract backend for BCAT functionality. -class Backend { +class BcatBackend { public: - explicit Backend(DirectoryGetter getter); - virtual ~Backend(); + explicit BcatBackend(DirectoryGetter getter); + virtual ~BcatBackend(); // Called when the backend is needed to synchronize the data for the game with title ID and // version in title. A ProgressServiceBackend object is provided to alert the application of @@ -135,10 +98,10 @@ protected: }; // A backend of BCAT that provides no operation. -class NullBackend : public Backend { +class NullBcatBackend : public BcatBackend { public: - explicit NullBackend(DirectoryGetter getter); - ~NullBackend() override; + explicit NullBcatBackend(DirectoryGetter getter); + ~NullBcatBackend() override; bool Synchronize(TitleIDVersion title, ProgressServiceBackend& progress) override; bool SynchronizeDirectory(TitleIDVersion title, std::string name, @@ -151,6 +114,7 @@ public: std::optional> GetLaunchParameter(TitleIDVersion title) override; }; -std::unique_ptr CreateBackendFromSettings(Core::System& system, DirectoryGetter getter); +std::unique_ptr CreateBackendFromSettings(Core::System& system, + DirectoryGetter getter); } // namespace Service::BCAT -- cgit v1.2.3