Inital pass of account backend implementation
This commit verified working on puyo
This commit is contained in:
parent
03d7faf583
commit
75169c7570
|
@ -48,13 +48,6 @@ private:
|
||||||
LOG_INFO(Service_ACC, "called user_id={}", user_id.Format());
|
LOG_INFO(Service_ACC, "called user_id={}", user_id.Format());
|
||||||
ProfileBase profile_base{};
|
ProfileBase profile_base{};
|
||||||
std::array<u8, MAX_DATA> data{};
|
std::array<u8, MAX_DATA> data{};
|
||||||
/*if (Settings::values.username.size() > profile_base.username.size()) {
|
|
||||||
std::copy_n(Settings::values.username.begin(), profile_base.username.size(),
|
|
||||||
profile_base.username.begin());
|
|
||||||
} else {
|
|
||||||
std::copy(Settings::values.username.begin(), Settings::values.username.end(),
|
|
||||||
profile_base.username.begin());
|
|
||||||
}*/
|
|
||||||
if (profile_manager.GetProfileBaseAndData(user_id, profile_base, data)) {
|
if (profile_manager.GetProfileBaseAndData(user_id, profile_base, data)) {
|
||||||
ctx.WriteBuffer(data);
|
ctx.WriteBuffer(data);
|
||||||
IPC::ResponseBuilder rb{ctx, 16};
|
IPC::ResponseBuilder rb{ctx, 16};
|
||||||
|
@ -177,7 +170,9 @@ void Module::Interface::GetBaasAccountManagerForApplication(Kernel::HLERequestCo
|
||||||
}
|
}
|
||||||
|
|
||||||
Module::Interface::Interface(std::shared_ptr<Module> module, const char* name)
|
Module::Interface::Interface(std::shared_ptr<Module> module, const char* name)
|
||||||
: ServiceFramework(name), module(std::move(module)) {}
|
: ServiceFramework(name), module(std::move(module)) {
|
||||||
|
profile_manager = std::make_unique<ProfileManager>();
|
||||||
|
}
|
||||||
|
|
||||||
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
||||||
auto module = std::make_shared<Module>();
|
auto module = std::make_shared<Module>();
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include "core/settings.h"
|
||||||
#include "profile_manager.h"
|
#include "profile_manager.h"
|
||||||
|
|
||||||
namespace Service::Account {
|
namespace Service::Account {
|
||||||
|
@ -5,6 +6,10 @@ namespace Service::Account {
|
||||||
constexpr ResultCode ERROR_TOO_MANY_USERS(ErrorModule::Account, -1);
|
constexpr ResultCode ERROR_TOO_MANY_USERS(ErrorModule::Account, -1);
|
||||||
constexpr ResultCode ERROR_ARGUMENT_IS_NULL(ErrorModule::Account, 20);
|
constexpr ResultCode ERROR_ARGUMENT_IS_NULL(ErrorModule::Account, 20);
|
||||||
|
|
||||||
|
ProfileManager::ProfileManager() {
|
||||||
|
CreateNewUser(UUID{1, 0}, Settings::values.username);
|
||||||
|
}
|
||||||
|
|
||||||
size_t ProfileManager::AddToProfiles(const ProfileInfo& user) {
|
size_t ProfileManager::AddToProfiles(const ProfileInfo& user) {
|
||||||
if (user_count >= MAX_USERS) {
|
if (user_count >= MAX_USERS) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -39,14 +44,23 @@ ResultCode ProfileManager::CreateNewUser(UUID uuid, std::array<u8, 0x20> usernam
|
||||||
if (username[0] == 0x0)
|
if (username[0] == 0x0)
|
||||||
return ERROR_ARGUMENT_IS_NULL;
|
return ERROR_ARGUMENT_IS_NULL;
|
||||||
ProfileInfo prof_inf;
|
ProfileInfo prof_inf;
|
||||||
prof_inf.user_uuid = uuid;
|
prof_inf.user_uuid = std::move(uuid);
|
||||||
prof_inf.username = username;
|
prof_inf.username = std::move(username);
|
||||||
prof_inf.data = std::array<u8, MAX_DATA>();
|
prof_inf.data = std::array<u8, MAX_DATA>();
|
||||||
prof_inf.creation_time = 0x0;
|
prof_inf.creation_time = 0x0;
|
||||||
prof_inf.is_open = false;
|
prof_inf.is_open = false;
|
||||||
return AddUser(prof_inf);
|
return AddUser(prof_inf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResultCode ProfileManager::CreateNewUser(UUID uuid, std::string username) {
|
||||||
|
std::array<u8, 0x20> username_output;
|
||||||
|
if (username.size() > username_output.size())
|
||||||
|
std::copy_n(username.begin(), username_output.size(), username_output.begin());
|
||||||
|
else
|
||||||
|
std::copy(username.begin(), username.end(), username_output.begin());
|
||||||
|
return CreateNewUser(uuid, std::move(username_output));
|
||||||
|
}
|
||||||
|
|
||||||
size_t ProfileManager::GetUserIndex(UUID uuid) {
|
size_t ProfileManager::GetUserIndex(UUID uuid) {
|
||||||
if (!uuid)
|
if (!uuid)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -21,7 +21,7 @@ struct UUID {
|
||||||
uuid[1] = hi;
|
uuid[1] = hi;
|
||||||
};
|
};
|
||||||
operator bool() const {
|
operator bool() const {
|
||||||
return uuid[0] != 0x0 && uuid[1] != 0x0;
|
return uuid[0] != 0x0 || uuid[1] != 0x0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const UUID& rhs) {
|
bool operator==(const UUID& rhs) {
|
||||||
|
@ -76,9 +76,10 @@ static_assert(sizeof(ProfileBase) == 0x38, "ProfileBase is an invalid size");
|
||||||
/// objects
|
/// objects
|
||||||
class ProfileManager {
|
class ProfileManager {
|
||||||
public:
|
public:
|
||||||
ProfileManager() = default; // TODO(ogniK): Load from system save
|
ProfileManager(); // TODO(ogniK): Load from system save
|
||||||
ResultCode AddUser(ProfileInfo user);
|
ResultCode AddUser(ProfileInfo user);
|
||||||
ResultCode CreateNewUser(UUID uuid, std::array<u8, 0x20> username);
|
ResultCode CreateNewUser(UUID uuid, std::array<u8, 0x20> username);
|
||||||
|
ResultCode CreateNewUser(UUID uuid, std::string username);
|
||||||
size_t GetUserIndex(UUID uuid);
|
size_t GetUserIndex(UUID uuid);
|
||||||
size_t GetUserIndex(ProfileInfo user);
|
size_t GetUserIndex(ProfileInfo user);
|
||||||
bool GetProfileBase(size_t index, ProfileBase& profile);
|
bool GetProfileBase(size_t index, ProfileBase& profile);
|
||||||
|
|
Loading…
Reference in a new issue