mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-26 05:45:40 +01:00
bcat: Add backend class to generify the functions of BCAT
Provides the most abstract simplified functions of BCAT as functions. Also includes a NullBackend class which is just a no-op.
This commit is contained in:
parent
647992e666
commit
2c0b75a744
47
src/core/hle/service/bcat/backend/backend.cpp
Normal file
47
src/core/hle/service/bcat/backend/backend.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright 2019 yuzu emulator team
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "common/hex_util.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/hle/service/bcat/backend/backend.h"
|
||||
|
||||
namespace Service::BCAT {
|
||||
|
||||
Backend::Backend(DirectoryGetter getter) : dir_getter(std::move(getter)) {}
|
||||
|
||||
Backend::~Backend() = default;
|
||||
|
||||
NullBackend::NullBackend(const DirectoryGetter& getter) : Backend(std::move(getter)) {}
|
||||
|
||||
NullBackend::~NullBackend() = default;
|
||||
|
||||
bool NullBackend::Synchronize(TitleIDVersion title, CompletionCallback callback) {
|
||||
LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, build_id={:016X}", title.title_id,
|
||||
title.build_id);
|
||||
|
||||
callback(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NullBackend::SynchronizeDirectory(TitleIDVersion title, std::string name,
|
||||
CompletionCallback callback) {
|
||||
LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, build_id={:016X}, name={}", title.title_id,
|
||||
title.build_id, name);
|
||||
|
||||
callback(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NullBackend::Clear(u64 title_id) {
|
||||
LOG_DEBUG(Service_BCAT, "called, title_id={:016X}");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void NullBackend::SetPassphrase(u64 title_id, const Passphrase& passphrase) {
|
||||
LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, passphrase = {}", title_id,
|
||||
Common::HexArrayToString(passphrase));
|
||||
}
|
||||
|
||||
} // namespace Service::BCAT
|
53
src/core/hle/service/bcat/backend/backend.h
Normal file
53
src/core/hle/service/bcat/backend/backend.h
Normal file
@ -0,0 +1,53 @@
|
||||
// Copyright 2019 yuzu emulator team
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include "common/common_types.h"
|
||||
#include "core/file_sys/vfs_types.h"
|
||||
|
||||
namespace Service::BCAT {
|
||||
|
||||
using CompletionCallback = std::function<void(bool)>;
|
||||
using DirectoryGetter = std::function<FileSys::VirtualDir(u64)>;
|
||||
using Passphrase = std::array<u8, 0x20>;
|
||||
|
||||
struct TitleIDVersion {
|
||||
u64 title_id;
|
||||
u64 build_id;
|
||||
};
|
||||
|
||||
class Backend {
|
||||
public:
|
||||
explicit Backend(DirectoryGetter getter);
|
||||
virtual ~Backend();
|
||||
|
||||
virtual bool Synchronize(TitleIDVersion title, CompletionCallback callback) = 0;
|
||||
virtual bool SynchronizeDirectory(TitleIDVersion title, std::string name,
|
||||
CompletionCallback callback) = 0;
|
||||
|
||||
virtual bool Clear(u64 title_id) = 0;
|
||||
|
||||
virtual void SetPassphrase(u64 title_id, const Passphrase& passphrase) = 0;
|
||||
|
||||
protected:
|
||||
DirectoryGetter dir_getter;
|
||||
};
|
||||
|
||||
class NullBackend : public Backend {
|
||||
public:
|
||||
explicit NullBackend(const DirectoryGetter& getter);
|
||||
~NullBackend() override;
|
||||
|
||||
bool Synchronize(TitleIDVersion title, CompletionCallback callback) override;
|
||||
bool SynchronizeDirectory(TitleIDVersion title, std::string name,
|
||||
CompletionCallback callback) override;
|
||||
|
||||
bool Clear(u64 title_id) override;
|
||||
|
||||
void SetPassphrase(u64 title_id, const Passphrase& passphrase) override;
|
||||
};
|
||||
|
||||
} // namespace Service::BCAT
|
Loading…
Reference in New Issue
Block a user