mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-25 23:55:43 +01:00
service: mii: Migrate service to new interface
This commit is contained in:
parent
4526fdaf64
commit
c5e88c654e
@ -59,7 +59,7 @@ void MiiEdit::Initialize() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
manager = system.ServiceManager().GetService<Mii::MiiDBModule>("mii:e")->GetMiiManager();
|
manager = system.ServiceManager().GetService<Mii::IStaticService>("mii:e")->GetMiiManager();
|
||||||
if (manager == nullptr) {
|
if (manager == nullptr) {
|
||||||
manager = std::make_shared<Mii::MiiManager>();
|
manager = std::make_shared<Mii::MiiManager>();
|
||||||
}
|
}
|
||||||
|
@ -4,15 +4,18 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
#include "core/hle/service/cmif_serialization.h"
|
||||||
#include "core/hle/service/ipc_helpers.h"
|
#include "core/hle/service/ipc_helpers.h"
|
||||||
#include "core/hle/service/mii/mii.h"
|
#include "core/hle/service/mii/mii.h"
|
||||||
#include "core/hle/service/mii/mii_manager.h"
|
#include "core/hle/service/mii/mii_manager.h"
|
||||||
#include "core/hle/service/mii/mii_result.h"
|
#include "core/hle/service/mii/mii_result.h"
|
||||||
#include "core/hle/service/mii/types/char_info.h"
|
#include "core/hle/service/mii/types/char_info.h"
|
||||||
|
#include "core/hle/service/mii/types/raw_data.h"
|
||||||
#include "core/hle/service/mii/types/store_data.h"
|
#include "core/hle/service/mii/types/store_data.h"
|
||||||
#include "core/hle/service/mii/types/ver3_store_data.h"
|
#include "core/hle/service/mii/types/ver3_store_data.h"
|
||||||
#include "core/hle/service/server_manager.h"
|
#include "core/hle/service/server_manager.h"
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/set/system_settings_server.h"
|
||||||
|
#include "core/hle/service/sm/sm.h"
|
||||||
|
|
||||||
namespace Service::Mii {
|
namespace Service::Mii {
|
||||||
|
|
||||||
@ -24,549 +27,302 @@ public:
|
|||||||
is_system_} {
|
is_system_} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &IDatabaseService::IsUpdated, "IsUpdated"},
|
{0, D<&IDatabaseService::IsUpdated>, "IsUpdated"},
|
||||||
{1, &IDatabaseService::IsFullDatabase, "IsFullDatabase"},
|
{1, D<&IDatabaseService::IsFullDatabase>, "IsFullDatabase"},
|
||||||
{2, &IDatabaseService::GetCount, "GetCount"},
|
{2, D<&IDatabaseService::GetCount>, "GetCount"},
|
||||||
{3, &IDatabaseService::Get, "Get"},
|
{3, D<&IDatabaseService::Get>, "Get"},
|
||||||
{4, &IDatabaseService::Get1, "Get1"},
|
{4, D<&IDatabaseService::Get1>, "Get1"},
|
||||||
{5, &IDatabaseService::UpdateLatest, "UpdateLatest"},
|
{5, D<&IDatabaseService::UpdateLatest>, "UpdateLatest"},
|
||||||
{6, &IDatabaseService::BuildRandom, "BuildRandom"},
|
{6, D<&IDatabaseService::BuildRandom>, "BuildRandom"},
|
||||||
{7, &IDatabaseService::BuildDefault, "BuildDefault"},
|
{7, D<&IDatabaseService::BuildDefault>, "BuildDefault"},
|
||||||
{8, &IDatabaseService::Get2, "Get2"},
|
{8, D<&IDatabaseService::Get2>, "Get2"},
|
||||||
{9, &IDatabaseService::Get3, "Get3"},
|
{9, D<&IDatabaseService::Get3>, "Get3"},
|
||||||
{10, &IDatabaseService::UpdateLatest1, "UpdateLatest1"},
|
{10, D<&IDatabaseService::UpdateLatest1>, "UpdateLatest1"},
|
||||||
{11, &IDatabaseService::FindIndex, "FindIndex"},
|
{11, D<&IDatabaseService::FindIndex>, "FindIndex"},
|
||||||
{12, &IDatabaseService::Move, "Move"},
|
{12, D<&IDatabaseService::Move>, "Move"},
|
||||||
{13, &IDatabaseService::AddOrReplace, "AddOrReplace"},
|
{13, D<&IDatabaseService::AddOrReplace>, "AddOrReplace"},
|
||||||
{14, &IDatabaseService::Delete, "Delete"},
|
{14, D<&IDatabaseService::Delete>, "Delete"},
|
||||||
{15, &IDatabaseService::DestroyFile, "DestroyFile"},
|
{15, D<&IDatabaseService::DestroyFile>, "DestroyFile"},
|
||||||
{16, &IDatabaseService::DeleteFile, "DeleteFile"},
|
{16, D<&IDatabaseService::DeleteFile>, "DeleteFile"},
|
||||||
{17, &IDatabaseService::Format, "Format"},
|
{17, D<&IDatabaseService::Format>, "Format"},
|
||||||
{18, nullptr, "Import"},
|
{18, nullptr, "Import"},
|
||||||
{19, nullptr, "Export"},
|
{19, nullptr, "Export"},
|
||||||
{20, &IDatabaseService::IsBrokenDatabaseWithClearFlag, "IsBrokenDatabaseWithClearFlag"},
|
{20, D<&IDatabaseService::IsBrokenDatabaseWithClearFlag>, "IsBrokenDatabaseWithClearFlag"},
|
||||||
{21, &IDatabaseService::GetIndex, "GetIndex"},
|
{21, D<&IDatabaseService::GetIndex>, "GetIndex"},
|
||||||
{22, &IDatabaseService::SetInterfaceVersion, "SetInterfaceVersion"},
|
{22, D<&IDatabaseService::SetInterfaceVersion>, "SetInterfaceVersion"},
|
||||||
{23, &IDatabaseService::Convert, "Convert"},
|
{23, D<&IDatabaseService::Convert>, "Convert"},
|
||||||
{24, &IDatabaseService::ConvertCoreDataToCharInfo, "ConvertCoreDataToCharInfo"},
|
{24, D<&IDatabaseService::ConvertCoreDataToCharInfo>, "ConvertCoreDataToCharInfo"},
|
||||||
{25, &IDatabaseService::ConvertCharInfoToCoreData, "ConvertCharInfoToCoreData"},
|
{25, D<&IDatabaseService::ConvertCharInfoToCoreData>, "ConvertCharInfoToCoreData"},
|
||||||
{26, &IDatabaseService::Append, "Append"},
|
{26, D<&IDatabaseService::Append>, "Append"},
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
RegisterHandlers(functions);
|
RegisterHandlers(functions);
|
||||||
|
|
||||||
|
m_set_sys = system.ServiceManager().GetService<Service::Set::ISystemSettingsServer>(
|
||||||
|
"set:sys", true);
|
||||||
manager->Initialize(metadata);
|
manager->Initialize(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void IsUpdated(HLERequestContext& ctx) {
|
Result IsUpdated(Out<bool> out_is_updated, SourceFlag source_flag) {
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto source_flag{rp.PopRaw<SourceFlag>()};
|
|
||||||
|
|
||||||
LOG_DEBUG(Service_Mii, "called with source_flag={}", source_flag);
|
LOG_DEBUG(Service_Mii, "called with source_flag={}", source_flag);
|
||||||
|
|
||||||
const bool is_updated = manager->IsUpdated(metadata, source_flag);
|
*out_is_updated = manager->IsUpdated(metadata, source_flag);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
R_SUCCEED();
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.Push<u8>(is_updated);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IsFullDatabase(HLERequestContext& ctx) {
|
Result IsFullDatabase(Out<bool> out_is_full_database) {
|
||||||
LOG_DEBUG(Service_Mii, "called");
|
LOG_DEBUG(Service_Mii, "called");
|
||||||
|
|
||||||
const bool is_full_database = manager->IsFullDatabase();
|
*out_is_full_database = manager->IsFullDatabase();
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
R_SUCCEED();
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.Push<u8>(is_full_database);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetCount(HLERequestContext& ctx) {
|
Result GetCount(Out<u32> out_mii_count, SourceFlag source_flag) {
|
||||||
IPC::RequestParser rp{ctx};
|
*out_mii_count = manager->GetCount(metadata, source_flag);
|
||||||
const auto source_flag{rp.PopRaw<SourceFlag>()};
|
|
||||||
|
|
||||||
const u32 mii_count = manager->GetCount(metadata, source_flag);
|
LOG_DEBUG(Service_Mii, "called with source_flag={}, mii_count={}", source_flag,
|
||||||
|
*out_mii_count);
|
||||||
|
|
||||||
LOG_DEBUG(Service_Mii, "called with source_flag={}, mii_count={}", source_flag, mii_count);
|
R_SUCCEED();
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.Push(mii_count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Get(HLERequestContext& ctx) {
|
Result Get(Out<u32> out_mii_count, SourceFlag source_flag,
|
||||||
IPC::RequestParser rp{ctx};
|
OutArray<CharInfoElement, BufferAttr_HipcMapAlias> char_info_element_buffer) {
|
||||||
const auto source_flag{rp.PopRaw<SourceFlag>()};
|
const auto result =
|
||||||
const auto output_size{ctx.GetWriteBufferNumElements<CharInfoElement>()};
|
manager->Get(metadata, char_info_element_buffer, *out_mii_count, source_flag);
|
||||||
|
|
||||||
u32 mii_count{};
|
LOG_INFO(Service_Mii, "called with source_flag={}, mii_count={}", source_flag,
|
||||||
std::vector<CharInfoElement> char_info_elements(output_size);
|
*out_mii_count);
|
||||||
const auto result = manager->Get(metadata, char_info_elements, mii_count, source_flag);
|
|
||||||
|
|
||||||
if (mii_count != 0) {
|
R_RETURN(result);
|
||||||
ctx.WriteBuffer(char_info_elements);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called with source_flag={}, out_size={}, mii_count={}", source_flag,
|
|
||||||
output_size, mii_count);
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
|
||||||
rb.Push(result);
|
|
||||||
rb.Push(mii_count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Get1(HLERequestContext& ctx) {
|
Result Get1(Out<u32> out_mii_count, SourceFlag source_flag,
|
||||||
IPC::RequestParser rp{ctx};
|
OutArray<CharInfo, BufferAttr_HipcMapAlias> char_info_buffer) {
|
||||||
const auto source_flag{rp.PopRaw<SourceFlag>()};
|
const auto result = manager->Get(metadata, char_info_buffer, *out_mii_count, source_flag);
|
||||||
const auto output_size{ctx.GetWriteBufferNumElements<CharInfo>()};
|
|
||||||
|
|
||||||
u32 mii_count{};
|
LOG_INFO(Service_Mii, "called with source_flag={}, mii_count={}", source_flag,
|
||||||
std::vector<CharInfo> char_info(output_size);
|
*out_mii_count);
|
||||||
const auto result = manager->Get(metadata, char_info, mii_count, source_flag);
|
|
||||||
|
|
||||||
if (mii_count != 0) {
|
R_RETURN(result);
|
||||||
ctx.WriteBuffer(char_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called with source_flag={}, out_size={}, mii_count={}", source_flag,
|
|
||||||
output_size, mii_count);
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
|
||||||
rb.Push(result);
|
|
||||||
rb.Push(mii_count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateLatest(HLERequestContext& ctx) {
|
Result UpdateLatest(Out<CharInfo> out_char_info, CharInfo& char_info, SourceFlag source_flag) {
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto char_info{rp.PopRaw<CharInfo>()};
|
|
||||||
const auto source_flag{rp.PopRaw<SourceFlag>()};
|
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called with source_flag={}", source_flag);
|
LOG_INFO(Service_Mii, "called with source_flag={}", source_flag);
|
||||||
|
|
||||||
CharInfo new_char_info{};
|
R_RETURN(manager->UpdateLatest(metadata, *out_char_info, char_info, source_flag));
|
||||||
const auto result = manager->UpdateLatest(metadata, new_char_info, char_info, source_flag);
|
|
||||||
if (result.IsFailure()) {
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(result);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.PushRaw(new_char_info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildRandom(HLERequestContext& ctx) {
|
Result BuildRandom(Out<CharInfo> out_char_info, Age age, Gender gender, Race race) {
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto age{rp.PopRaw<Age>()};
|
|
||||||
const auto gender{rp.PopRaw<Gender>()};
|
|
||||||
const auto race{rp.PopRaw<Race>()};
|
|
||||||
|
|
||||||
LOG_DEBUG(Service_Mii, "called with age={}, gender={}, race={}", age, gender, race);
|
LOG_DEBUG(Service_Mii, "called with age={}, gender={}, race={}", age, gender, race);
|
||||||
|
|
||||||
if (age > Age::All) {
|
R_UNLESS(age <= Age::All, ResultInvalidArgument);
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
R_UNLESS(gender <= Gender::All, ResultInvalidArgument);
|
||||||
rb.Push(ResultInvalidArgument);
|
R_UNLESS(race <= Race::All, ResultInvalidArgument);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gender > Gender::All) {
|
manager->BuildRandom(*out_char_info, age, gender, race);
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(ResultInvalidArgument);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (race > Race::All) {
|
R_SUCCEED();
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(ResultInvalidArgument);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CharInfo char_info{};
|
|
||||||
manager->BuildRandom(char_info, age, gender, race);
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.PushRaw(char_info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildDefault(HLERequestContext& ctx) {
|
Result BuildDefault(Out<CharInfo> out_char_info, s32 index) {
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto index{rp.Pop<u32>()};
|
|
||||||
|
|
||||||
LOG_DEBUG(Service_Mii, "called with index={}", index);
|
LOG_DEBUG(Service_Mii, "called with index={}", index);
|
||||||
|
R_UNLESS(index < static_cast<s32>(RawData::DefaultMii.size()), ResultInvalidArgument);
|
||||||
|
|
||||||
if (index > 5) {
|
manager->BuildDefault(*out_char_info, index);
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(ResultInvalidArgument);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CharInfo char_info{};
|
R_SUCCEED();
|
||||||
manager->BuildDefault(char_info, index);
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.PushRaw(char_info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Get2(HLERequestContext& ctx) {
|
Result Get2(Out<u32> out_mii_count, SourceFlag source_flag,
|
||||||
IPC::RequestParser rp{ctx};
|
OutArray<StoreDataElement, BufferAttr_HipcMapAlias> store_data_element_buffer) {
|
||||||
const auto source_flag{rp.PopRaw<SourceFlag>()};
|
const auto result =
|
||||||
const auto output_size{ctx.GetWriteBufferNumElements<StoreDataElement>()};
|
manager->Get(metadata, store_data_element_buffer, *out_mii_count, source_flag);
|
||||||
|
|
||||||
u32 mii_count{};
|
LOG_INFO(Service_Mii, "called with source_flag={}, mii_count={}", source_flag,
|
||||||
std::vector<StoreDataElement> store_data_elements(output_size);
|
*out_mii_count);
|
||||||
const auto result = manager->Get(metadata, store_data_elements, mii_count, source_flag);
|
|
||||||
|
|
||||||
if (mii_count != 0) {
|
R_RETURN(result);
|
||||||
ctx.WriteBuffer(store_data_elements);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called with source_flag={}, out_size={}, mii_count={}", source_flag,
|
|
||||||
output_size, mii_count);
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
|
||||||
rb.Push(result);
|
|
||||||
rb.Push(mii_count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Get3(HLERequestContext& ctx) {
|
Result Get3(Out<u32> out_mii_count, SourceFlag source_flag,
|
||||||
IPC::RequestParser rp{ctx};
|
OutArray<StoreData, BufferAttr_HipcMapAlias> store_data_buffer) {
|
||||||
const auto source_flag{rp.PopRaw<SourceFlag>()};
|
const auto result = manager->Get(metadata, store_data_buffer, *out_mii_count, source_flag);
|
||||||
const auto output_size{ctx.GetWriteBufferNumElements<StoreData>()};
|
|
||||||
|
|
||||||
u32 mii_count{};
|
LOG_INFO(Service_Mii, "called with source_flag={}, mii_count={}", source_flag,
|
||||||
std::vector<StoreData> store_data(output_size);
|
*out_mii_count);
|
||||||
const auto result = manager->Get(metadata, store_data, mii_count, source_flag);
|
|
||||||
|
|
||||||
if (mii_count != 0) {
|
R_RETURN(result);
|
||||||
ctx.WriteBuffer(store_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called with source_flag={}, out_size={}, mii_count={}", source_flag,
|
|
||||||
output_size, mii_count);
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
|
||||||
rb.Push(result);
|
|
||||||
rb.Push(mii_count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateLatest1(HLERequestContext& ctx) {
|
Result UpdateLatest1(Out<StoreData> out_store_data, StoreData& store_data,
|
||||||
IPC::RequestParser rp{ctx};
|
SourceFlag source_flag) {
|
||||||
const auto store_data{rp.PopRaw<StoreData>()};
|
|
||||||
const auto source_flag{rp.PopRaw<SourceFlag>()};
|
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called with source_flag={}", source_flag);
|
LOG_INFO(Service_Mii, "called with source_flag={}", source_flag);
|
||||||
|
R_UNLESS(is_system, ResultPermissionDenied);
|
||||||
|
|
||||||
Result result = ResultSuccess;
|
R_RETURN(manager->UpdateLatest(metadata, *out_store_data, store_data, source_flag));
|
||||||
if (!is_system) {
|
|
||||||
result = ResultPermissionDenied;
|
|
||||||
}
|
|
||||||
|
|
||||||
StoreData new_store_data{};
|
|
||||||
if (result.IsSuccess()) {
|
|
||||||
result = manager->UpdateLatest(metadata, new_store_data, store_data, source_flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.IsFailure()) {
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(result);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(StoreData) / sizeof(u32)};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.PushRaw<StoreData>(new_store_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindIndex(HLERequestContext& ctx) {
|
Result FindIndex(Out<s32> out_index, Common::UUID create_id, bool is_special) {
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto create_id{rp.PopRaw<Common::UUID>()};
|
|
||||||
const auto is_special{rp.PopRaw<bool>()};
|
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called with create_id={}, is_special={}",
|
LOG_INFO(Service_Mii, "called with create_id={}, is_special={}",
|
||||||
create_id.FormattedString(), is_special);
|
create_id.FormattedString(), is_special);
|
||||||
|
|
||||||
const s32 index = manager->FindIndex(create_id, is_special);
|
*out_index = manager->FindIndex(create_id, is_special);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
R_SUCCEED();
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.Push(index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Move(HLERequestContext& ctx) {
|
Result Move(Common::UUID create_id, s32 new_index) {
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto create_id{rp.PopRaw<Common::UUID>()};
|
|
||||||
const auto new_index{rp.PopRaw<s32>()};
|
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called with create_id={}, new_index={}", create_id.FormattedString(),
|
LOG_INFO(Service_Mii, "called with create_id={}, new_index={}", create_id.FormattedString(),
|
||||||
new_index);
|
new_index);
|
||||||
|
R_UNLESS(is_system, ResultPermissionDenied);
|
||||||
|
|
||||||
Result result = ResultSuccess;
|
const u32 count = manager->GetCount(metadata, SourceFlag::Database);
|
||||||
if (!is_system) {
|
|
||||||
result = ResultPermissionDenied;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.IsSuccess()) {
|
R_UNLESS(new_index >= 0 && new_index < static_cast<s32>(count), ResultInvalidArgument);
|
||||||
const u32 count = manager->GetCount(metadata, SourceFlag::Database);
|
|
||||||
if (new_index < 0 || new_index >= static_cast<s32>(count)) {
|
|
||||||
result = ResultInvalidArgument;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.IsSuccess()) {
|
R_RETURN(manager->Move(metadata, new_index, create_id));
|
||||||
result = manager->Move(metadata, new_index, create_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddOrReplace(HLERequestContext& ctx) {
|
Result AddOrReplace(StoreData& store_data) {
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto store_data{rp.PopRaw<StoreData>()};
|
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called");
|
LOG_INFO(Service_Mii, "called");
|
||||||
|
R_UNLESS(is_system, ResultPermissionDenied);
|
||||||
|
|
||||||
Result result = ResultSuccess;
|
const auto result = manager->AddOrReplace(metadata, store_data);
|
||||||
|
|
||||||
if (!is_system) {
|
R_RETURN(result);
|
||||||
result = ResultPermissionDenied;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.IsSuccess()) {
|
|
||||||
result = manager->AddOrReplace(metadata, store_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Delete(HLERequestContext& ctx) {
|
Result Delete(Common::UUID create_id) {
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto create_id{rp.PopRaw<Common::UUID>()};
|
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called, create_id={}", create_id.FormattedString());
|
LOG_INFO(Service_Mii, "called, create_id={}", create_id.FormattedString());
|
||||||
|
R_UNLESS(is_system, ResultPermissionDenied);
|
||||||
|
|
||||||
Result result = ResultSuccess;
|
R_RETURN(manager->Delete(metadata, create_id));
|
||||||
|
|
||||||
if (!is_system) {
|
|
||||||
result = ResultPermissionDenied;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.IsSuccess()) {
|
|
||||||
result = manager->Delete(metadata, create_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyFile(HLERequestContext& ctx) {
|
Result DestroyFile() {
|
||||||
// This calls nn::settings::fwdbg::GetSettingsItemValue("is_db_test_mode_enabled");
|
bool is_db_test_mode_enabled{};
|
||||||
const bool is_db_test_mode_enabled = false;
|
m_set_sys->GetSettingsItemValue(is_db_test_mode_enabled, "mii", "is_db_test_mode_enabled");
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled);
|
LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled);
|
||||||
|
R_UNLESS(is_db_test_mode_enabled, ResultTestModeOnly);
|
||||||
|
|
||||||
Result result = ResultSuccess;
|
R_RETURN(manager->DestroyFile(metadata));
|
||||||
|
|
||||||
if (!is_db_test_mode_enabled) {
|
|
||||||
result = ResultTestModeOnly;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.IsSuccess()) {
|
|
||||||
result = manager->DestroyFile(metadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteFile(HLERequestContext& ctx) {
|
Result DeleteFile() {
|
||||||
// This calls nn::settings::fwdbg::GetSettingsItemValue("is_db_test_mode_enabled");
|
bool is_db_test_mode_enabled{};
|
||||||
const bool is_db_test_mode_enabled = false;
|
m_set_sys->GetSettingsItemValue(is_db_test_mode_enabled, "mii", "is_db_test_mode_enabled");
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled);
|
LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled);
|
||||||
|
R_UNLESS(is_db_test_mode_enabled, ResultTestModeOnly);
|
||||||
|
|
||||||
Result result = ResultSuccess;
|
R_RETURN(manager->DeleteFile());
|
||||||
|
|
||||||
if (!is_db_test_mode_enabled) {
|
|
||||||
result = ResultTestModeOnly;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.IsSuccess()) {
|
|
||||||
result = manager->DeleteFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Format(HLERequestContext& ctx) {
|
Result Format() {
|
||||||
// This calls nn::settings::fwdbg::GetSettingsItemValue("is_db_test_mode_enabled");
|
bool is_db_test_mode_enabled{};
|
||||||
const bool is_db_test_mode_enabled = false;
|
m_set_sys->GetSettingsItemValue(is_db_test_mode_enabled, "mii", "is_db_test_mode_enabled");
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled);
|
LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled);
|
||||||
|
R_UNLESS(is_db_test_mode_enabled, ResultTestModeOnly);
|
||||||
|
|
||||||
Result result = ResultSuccess;
|
R_RETURN(manager->Format(metadata));
|
||||||
|
|
||||||
if (!is_db_test_mode_enabled) {
|
|
||||||
result = ResultTestModeOnly;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.IsSuccess()) {
|
|
||||||
result = manager->Format(metadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IsBrokenDatabaseWithClearFlag(HLERequestContext& ctx) {
|
Result IsBrokenDatabaseWithClearFlag(Out<bool> out_is_broken_with_clear_flag) {
|
||||||
|
LOG_DEBUG(Service_Mii, "called");
|
||||||
|
R_UNLESS(is_system, ResultPermissionDenied);
|
||||||
|
|
||||||
|
*out_is_broken_with_clear_flag = manager->IsBrokenWithClearFlag(metadata);
|
||||||
|
|
||||||
|
R_SUCCEED();
|
||||||
|
}
|
||||||
|
|
||||||
|
Result GetIndex(Out<s32> out_index, CharInfo& char_info) {
|
||||||
LOG_DEBUG(Service_Mii, "called");
|
LOG_DEBUG(Service_Mii, "called");
|
||||||
|
|
||||||
bool is_broken_with_clear_flag = false;
|
R_RETURN(manager->GetIndex(metadata, char_info, *out_index));
|
||||||
Result result = ResultSuccess;
|
|
||||||
|
|
||||||
if (!is_system) {
|
|
||||||
result = ResultPermissionDenied;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.IsSuccess()) {
|
|
||||||
is_broken_with_clear_flag = manager->IsBrokenWithClearFlag(metadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
|
||||||
rb.Push(result);
|
|
||||||
rb.Push<u8>(is_broken_with_clear_flag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetIndex(HLERequestContext& ctx) {
|
Result SetInterfaceVersion(u32 interface_version) {
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto info{rp.PopRaw<CharInfo>()};
|
|
||||||
|
|
||||||
LOG_DEBUG(Service_Mii, "called");
|
|
||||||
|
|
||||||
s32 index{};
|
|
||||||
const auto result = manager->GetIndex(metadata, info, index);
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
|
||||||
rb.Push(result);
|
|
||||||
rb.Push(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetInterfaceVersion(HLERequestContext& ctx) {
|
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto interface_version{rp.PopRaw<u32>()};
|
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called, interface_version={:08X}", interface_version);
|
LOG_INFO(Service_Mii, "called, interface_version={:08X}", interface_version);
|
||||||
|
|
||||||
manager->SetInterfaceVersion(metadata, interface_version);
|
manager->SetInterfaceVersion(metadata, interface_version);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
R_SUCCEED();
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Convert(HLERequestContext& ctx) {
|
Result Convert(Out<CharInfo> out_char_info, Ver3StoreData& mii_v3) {
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto mii_v3{rp.PopRaw<Ver3StoreData>()};
|
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called");
|
LOG_INFO(Service_Mii, "called");
|
||||||
|
|
||||||
CharInfo char_info{};
|
R_RETURN(manager->ConvertV3ToCharInfo(*out_char_info, mii_v3));
|
||||||
const auto result = manager->ConvertV3ToCharInfo(char_info, mii_v3);
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)};
|
|
||||||
rb.Push(result);
|
|
||||||
rb.PushRaw<CharInfo>(char_info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvertCoreDataToCharInfo(HLERequestContext& ctx) {
|
Result ConvertCoreDataToCharInfo(Out<CharInfo> out_char_info, CoreData& core_data) {
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto core_data{rp.PopRaw<CoreData>()};
|
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called");
|
LOG_INFO(Service_Mii, "called");
|
||||||
|
|
||||||
CharInfo char_info{};
|
R_RETURN(manager->ConvertCoreDataToCharInfo(*out_char_info, core_data));
|
||||||
const auto result = manager->ConvertCoreDataToCharInfo(char_info, core_data);
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)};
|
|
||||||
rb.Push(result);
|
|
||||||
rb.PushRaw<CharInfo>(char_info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvertCharInfoToCoreData(HLERequestContext& ctx) {
|
Result ConvertCharInfoToCoreData(Out<CoreData> out_core_data, CharInfo& char_info) {
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto char_info{rp.PopRaw<CharInfo>()};
|
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called");
|
LOG_INFO(Service_Mii, "called");
|
||||||
|
|
||||||
CoreData core_data{};
|
R_RETURN(manager->ConvertCharInfoToCoreData(*out_core_data, char_info));
|
||||||
const auto result = manager->ConvertCharInfoToCoreData(core_data, char_info);
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(CoreData) / sizeof(u32)};
|
|
||||||
rb.Push(result);
|
|
||||||
rb.PushRaw<CoreData>(core_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Append(HLERequestContext& ctx) {
|
Result Append(CharInfo& char_info) {
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto char_info{rp.PopRaw<CharInfo>()};
|
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called");
|
LOG_INFO(Service_Mii, "called");
|
||||||
|
|
||||||
const auto result = manager->Append(metadata, char_info);
|
R_RETURN(manager->Append(metadata, char_info));
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<MiiManager> manager = nullptr;
|
std::shared_ptr<MiiManager> manager = nullptr;
|
||||||
DatabaseSessionMetadata metadata{};
|
DatabaseSessionMetadata metadata{};
|
||||||
bool is_system{};
|
bool is_system{};
|
||||||
|
|
||||||
|
std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
|
||||||
};
|
};
|
||||||
|
|
||||||
MiiDBModule::MiiDBModule(Core::System& system_, const char* name_,
|
IStaticService::IStaticService(Core::System& system_, const char* name_,
|
||||||
std::shared_ptr<MiiManager> mii_manager, bool is_system_)
|
std::shared_ptr<MiiManager> mii_manager, bool is_system_)
|
||||||
: ServiceFramework{system_, name_}, manager{mii_manager}, is_system{is_system_} {
|
: ServiceFramework{system_, name_}, manager{mii_manager}, is_system{is_system_} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &MiiDBModule::GetDatabaseService, "GetDatabaseService"},
|
{0, D<&IStaticService::GetDatabaseService>, "GetDatabaseService"},
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
RegisterHandlers(functions);
|
RegisterHandlers(functions);
|
||||||
|
|
||||||
if (manager == nullptr) {
|
|
||||||
manager = std::make_shared<MiiManager>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MiiDBModule::~MiiDBModule() = default;
|
IStaticService::~IStaticService() = default;
|
||||||
|
|
||||||
void MiiDBModule::GetDatabaseService(HLERequestContext& ctx) {
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.PushIpcInterface<IDatabaseService>(system, manager, is_system);
|
|
||||||
|
|
||||||
|
Result IStaticService::GetDatabaseService(
|
||||||
|
Out<SharedPointer<IDatabaseService>> out_database_service) {
|
||||||
LOG_DEBUG(Service_Mii, "called");
|
LOG_DEBUG(Service_Mii, "called");
|
||||||
|
|
||||||
|
*out_database_service = std::make_shared<IDatabaseService>(system, manager, is_system);
|
||||||
|
|
||||||
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<MiiManager> MiiDBModule::GetMiiManager() {
|
std::shared_ptr<MiiManager> IStaticService::GetMiiManager() {
|
||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
class MiiImg final : public ServiceFramework<MiiImg> {
|
class IImageDatabaseService final : public ServiceFramework<IImageDatabaseService> {
|
||||||
public:
|
public:
|
||||||
explicit MiiImg(Core::System& system_) : ServiceFramework{system_, "miiimg"} {
|
explicit IImageDatabaseService(Core::System& system_) : ServiceFramework{system_, "miiimg"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &MiiImg::Initialize, "Initialize"},
|
{0, D<&IImageDatabaseService::Initialize>, "Initialize"},
|
||||||
{10, nullptr, "Reload"},
|
{10, nullptr, "Reload"},
|
||||||
{11, &MiiImg::GetCount, "GetCount"},
|
{11, D<&IImageDatabaseService::GetCount>, "GetCount"},
|
||||||
{12, nullptr, "IsEmpty"},
|
{12, nullptr, "IsEmpty"},
|
||||||
{13, nullptr, "IsFull"},
|
{13, nullptr, "IsFull"},
|
||||||
{14, nullptr, "GetAttribute"},
|
{14, nullptr, "GetAttribute"},
|
||||||
@ -585,31 +341,30 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Initialize(HLERequestContext& ctx) {
|
Result Initialize() {
|
||||||
LOG_INFO(Service_Mii, "called");
|
LOG_INFO(Service_Mii, "called");
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
R_SUCCEED();
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetCount(HLERequestContext& ctx) {
|
Result GetCount(Out<u32> out_count) {
|
||||||
LOG_DEBUG(Service_Mii, "called");
|
LOG_DEBUG(Service_Mii, "called");
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
*out_count = 0;
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.Push(0);
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void LoopProcess(Core::System& system) {
|
void LoopProcess(Core::System& system) {
|
||||||
auto server_manager = std::make_unique<ServerManager>(system);
|
auto server_manager = std::make_unique<ServerManager>(system);
|
||||||
std::shared_ptr<MiiManager> manager = nullptr;
|
std::shared_ptr<MiiManager> manager = std::make_shared<MiiManager>();
|
||||||
|
|
||||||
server_manager->RegisterNamedService(
|
server_manager->RegisterNamedService(
|
||||||
"mii:e", std::make_shared<MiiDBModule>(system, "mii:e", manager, true));
|
"mii:e", std::make_shared<IStaticService>(system, "mii:e", manager, true));
|
||||||
server_manager->RegisterNamedService(
|
server_manager->RegisterNamedService(
|
||||||
"mii:u", std::make_shared<MiiDBModule>(system, "mii:u", manager, false));
|
"mii:u", std::make_shared<IStaticService>(system, "mii:u", manager, false));
|
||||||
server_manager->RegisterNamedService("miiimg", std::make_shared<MiiImg>(system));
|
server_manager->RegisterNamedService("miiimg", std::make_shared<IImageDatabaseService>(system));
|
||||||
ServerManager::RunServer(std::move(server_manager));
|
ServerManager::RunServer(std::move(server_manager));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/cmif_types.h"
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class System;
|
class System;
|
||||||
@ -11,19 +11,20 @@ class System;
|
|||||||
|
|
||||||
namespace Service::Mii {
|
namespace Service::Mii {
|
||||||
class MiiManager;
|
class MiiManager;
|
||||||
|
class IDatabaseService;
|
||||||
|
|
||||||
class MiiDBModule final : public ServiceFramework<MiiDBModule> {
|
class IStaticService final : public ServiceFramework<IStaticService> {
|
||||||
public:
|
public:
|
||||||
explicit MiiDBModule(Core::System& system_, const char* name_,
|
explicit IStaticService(Core::System& system_, const char* name_,
|
||||||
std::shared_ptr<MiiManager> mii_manager, bool is_system_);
|
std::shared_ptr<MiiManager> mii_manager, bool is_system_);
|
||||||
~MiiDBModule() override;
|
~IStaticService() override;
|
||||||
|
|
||||||
std::shared_ptr<MiiManager> GetMiiManager();
|
std::shared_ptr<MiiManager> GetMiiManager();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void GetDatabaseService(HLERequestContext& ctx);
|
Result GetDatabaseService(Out<SharedPointer<IDatabaseService>> out_database_service);
|
||||||
|
|
||||||
std::shared_ptr<MiiManager> manager = nullptr;
|
std::shared_ptr<MiiManager> manager{nullptr};
|
||||||
bool is_system{};
|
bool is_system{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -697,6 +697,9 @@ static Settings GetSettings() {
|
|||||||
ret["hid_debug"]["disabled_features_per_id"] = std::vector<u8>(0xa8);
|
ret["hid_debug"]["disabled_features_per_id"] = std::vector<u8>(0xa8);
|
||||||
ret["hid_debug"]["touch_firmware_auto_update_disabled"] = ToBytes(bool{false});
|
ret["hid_debug"]["touch_firmware_auto_update_disabled"] = ToBytes(bool{false});
|
||||||
|
|
||||||
|
// Mii
|
||||||
|
ret["mii"]["is_db_test_mode_enabled"] = ToBytes(bool{false});
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
ret["settings_debug"]["is_debug_mode_enabled"] = ToBytes(bool{false});
|
ret["settings_debug"]["is_debug_mode_enabled"] = ToBytes(bool{false});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user