profile: Migrate to the new UUID implementation
This commit is contained in:
parent
d94dcaefa0
commit
dfe11d72e3
|
@ -11,10 +11,9 @@ namespace Core::Frontend {
|
||||||
ProfileSelectApplet::~ProfileSelectApplet() = default;
|
ProfileSelectApplet::~ProfileSelectApplet() = default;
|
||||||
|
|
||||||
void DefaultProfileSelectApplet::SelectProfile(
|
void DefaultProfileSelectApplet::SelectProfile(
|
||||||
std::function<void(std::optional<Common::UUID>)> callback) const {
|
std::function<void(std::optional<Common::NewUUID>)> callback) const {
|
||||||
Service::Account::ProfileManager manager;
|
Service::Account::ProfileManager manager;
|
||||||
callback(manager.GetUser(Settings::values.current_user.GetValue())
|
callback(manager.GetUser(Settings::values.current_user.GetValue()).value_or(Common::NewUUID{}));
|
||||||
.value_or(Common::UUID{Common::INVALID_UUID}));
|
|
||||||
LOG_INFO(Service_ACC, "called, selecting current user instead of prompting...");
|
LOG_INFO(Service_ACC, "called, selecting current user instead of prompting...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include "common/uuid.h"
|
#include "common/new_uuid.h"
|
||||||
|
|
||||||
namespace Core::Frontend {
|
namespace Core::Frontend {
|
||||||
|
|
||||||
|
@ -14,12 +14,13 @@ class ProfileSelectApplet {
|
||||||
public:
|
public:
|
||||||
virtual ~ProfileSelectApplet();
|
virtual ~ProfileSelectApplet();
|
||||||
|
|
||||||
virtual void SelectProfile(std::function<void(std::optional<Common::UUID>)> callback) const = 0;
|
virtual void SelectProfile(
|
||||||
|
std::function<void(std::optional<Common::NewUUID>)> callback) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DefaultProfileSelectApplet final : public ProfileSelectApplet {
|
class DefaultProfileSelectApplet final : public ProfileSelectApplet {
|
||||||
public:
|
public:
|
||||||
void SelectProfile(std::function<void(std::optional<Common::UUID>)> callback) const override;
|
void SelectProfile(std::function<void(std::optional<Common::NewUUID>)> callback) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core::Frontend
|
} // namespace Core::Frontend
|
||||||
|
|
|
@ -39,9 +39,9 @@ constexpr ResultCode ERR_FAILED_SAVE_DATA{ErrorModule::Account, 100};
|
||||||
// Thumbnails are hard coded to be at least this size
|
// Thumbnails are hard coded to be at least this size
|
||||||
constexpr std::size_t THUMBNAIL_SIZE = 0x24000;
|
constexpr std::size_t THUMBNAIL_SIZE = 0x24000;
|
||||||
|
|
||||||
static std::filesystem::path GetImagePath(Common::UUID uuid) {
|
static std::filesystem::path GetImagePath(const Common::NewUUID& uuid) {
|
||||||
return Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) /
|
return Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) /
|
||||||
fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormatSwitch());
|
fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString());
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr u32 SanitizeJPEGSize(std::size_t size) {
|
static constexpr u32 SanitizeJPEGSize(std::size_t size) {
|
||||||
|
@ -51,7 +51,7 @@ static constexpr u32 SanitizeJPEGSize(std::size_t size) {
|
||||||
|
|
||||||
class IManagerForSystemService final : public ServiceFramework<IManagerForSystemService> {
|
class IManagerForSystemService final : public ServiceFramework<IManagerForSystemService> {
|
||||||
public:
|
public:
|
||||||
explicit IManagerForSystemService(Core::System& system_, Common::UUID)
|
explicit IManagerForSystemService(Core::System& system_, Common::NewUUID)
|
||||||
: ServiceFramework{system_, "IManagerForSystemService"} {
|
: ServiceFramework{system_, "IManagerForSystemService"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
|
@ -87,7 +87,7 @@ public:
|
||||||
// 3.0.0+
|
// 3.0.0+
|
||||||
class IFloatingRegistrationRequest final : public ServiceFramework<IFloatingRegistrationRequest> {
|
class IFloatingRegistrationRequest final : public ServiceFramework<IFloatingRegistrationRequest> {
|
||||||
public:
|
public:
|
||||||
explicit IFloatingRegistrationRequest(Core::System& system_, Common::UUID)
|
explicit IFloatingRegistrationRequest(Core::System& system_, Common::NewUUID)
|
||||||
: ServiceFramework{system_, "IFloatingRegistrationRequest"} {
|
: ServiceFramework{system_, "IFloatingRegistrationRequest"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
|
@ -112,7 +112,7 @@ public:
|
||||||
|
|
||||||
class IAdministrator final : public ServiceFramework<IAdministrator> {
|
class IAdministrator final : public ServiceFramework<IAdministrator> {
|
||||||
public:
|
public:
|
||||||
explicit IAdministrator(Core::System& system_, Common::UUID)
|
explicit IAdministrator(Core::System& system_, Common::NewUUID)
|
||||||
: ServiceFramework{system_, "IAdministrator"} {
|
: ServiceFramework{system_, "IAdministrator"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
|
@ -170,7 +170,7 @@ public:
|
||||||
|
|
||||||
class IAuthorizationRequest final : public ServiceFramework<IAuthorizationRequest> {
|
class IAuthorizationRequest final : public ServiceFramework<IAuthorizationRequest> {
|
||||||
public:
|
public:
|
||||||
explicit IAuthorizationRequest(Core::System& system_, Common::UUID)
|
explicit IAuthorizationRequest(Core::System& system_, Common::NewUUID)
|
||||||
: ServiceFramework{system_, "IAuthorizationRequest"} {
|
: ServiceFramework{system_, "IAuthorizationRequest"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
|
@ -189,7 +189,7 @@ public:
|
||||||
|
|
||||||
class IOAuthProcedure final : public ServiceFramework<IOAuthProcedure> {
|
class IOAuthProcedure final : public ServiceFramework<IOAuthProcedure> {
|
||||||
public:
|
public:
|
||||||
explicit IOAuthProcedure(Core::System& system_, Common::UUID)
|
explicit IOAuthProcedure(Core::System& system_, Common::NewUUID)
|
||||||
: ServiceFramework{system_, "IOAuthProcedure"} {
|
: ServiceFramework{system_, "IOAuthProcedure"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
|
@ -208,7 +208,7 @@ public:
|
||||||
// 3.0.0+
|
// 3.0.0+
|
||||||
class IOAuthProcedureForExternalNsa final : public ServiceFramework<IOAuthProcedureForExternalNsa> {
|
class IOAuthProcedureForExternalNsa final : public ServiceFramework<IOAuthProcedureForExternalNsa> {
|
||||||
public:
|
public:
|
||||||
explicit IOAuthProcedureForExternalNsa(Core::System& system_, Common::UUID)
|
explicit IOAuthProcedureForExternalNsa(Core::System& system_, Common::NewUUID)
|
||||||
: ServiceFramework{system_, "IOAuthProcedureForExternalNsa"} {
|
: ServiceFramework{system_, "IOAuthProcedureForExternalNsa"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
|
@ -231,7 +231,7 @@ public:
|
||||||
class IOAuthProcedureForNintendoAccountLinkage final
|
class IOAuthProcedureForNintendoAccountLinkage final
|
||||||
: public ServiceFramework<IOAuthProcedureForNintendoAccountLinkage> {
|
: public ServiceFramework<IOAuthProcedureForNintendoAccountLinkage> {
|
||||||
public:
|
public:
|
||||||
explicit IOAuthProcedureForNintendoAccountLinkage(Core::System& system_, Common::UUID)
|
explicit IOAuthProcedureForNintendoAccountLinkage(Core::System& system_, Common::NewUUID)
|
||||||
: ServiceFramework{system_, "IOAuthProcedureForNintendoAccountLinkage"} {
|
: ServiceFramework{system_, "IOAuthProcedureForNintendoAccountLinkage"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
|
@ -252,7 +252,7 @@ public:
|
||||||
|
|
||||||
class INotifier final : public ServiceFramework<INotifier> {
|
class INotifier final : public ServiceFramework<INotifier> {
|
||||||
public:
|
public:
|
||||||
explicit INotifier(Core::System& system_, Common::UUID)
|
explicit INotifier(Core::System& system_, Common::NewUUID)
|
||||||
: ServiceFramework{system_, "INotifier"} {
|
: ServiceFramework{system_, "INotifier"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
|
@ -267,7 +267,7 @@ public:
|
||||||
class IProfileCommon : public ServiceFramework<IProfileCommon> {
|
class IProfileCommon : public ServiceFramework<IProfileCommon> {
|
||||||
public:
|
public:
|
||||||
explicit IProfileCommon(Core::System& system_, const char* name, bool editor_commands,
|
explicit IProfileCommon(Core::System& system_, const char* name, bool editor_commands,
|
||||||
Common::UUID user_id_, ProfileManager& profile_manager_)
|
Common::NewUUID user_id_, ProfileManager& profile_manager_)
|
||||||
: ServiceFramework{system_, name}, profile_manager{profile_manager_}, user_id{user_id_} {
|
: ServiceFramework{system_, name}, profile_manager{profile_manager_}, user_id{user_id_} {
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &IProfileCommon::Get, "Get"},
|
{0, &IProfileCommon::Get, "Get"},
|
||||||
|
@ -290,7 +290,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Get(Kernel::HLERequestContext& ctx) {
|
void Get(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.Format());
|
LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString());
|
||||||
ProfileBase profile_base{};
|
ProfileBase profile_base{};
|
||||||
ProfileData data{};
|
ProfileData data{};
|
||||||
if (profile_manager.GetProfileBaseAndData(user_id, profile_base, data)) {
|
if (profile_manager.GetProfileBaseAndData(user_id, profile_base, data)) {
|
||||||
|
@ -300,21 +300,21 @@ protected:
|
||||||
rb.PushRaw(profile_base);
|
rb.PushRaw(profile_base);
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR(Service_ACC, "Failed to get profile base and data for user=0x{}",
|
LOG_ERROR(Service_ACC, "Failed to get profile base and data for user=0x{}",
|
||||||
user_id.Format());
|
user_id.RawString());
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(ResultUnknown); // TODO(ogniK): Get actual error code
|
rb.Push(ResultUnknown); // TODO(ogniK): Get actual error code
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetBase(Kernel::HLERequestContext& ctx) {
|
void GetBase(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.Format());
|
LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString());
|
||||||
ProfileBase profile_base{};
|
ProfileBase profile_base{};
|
||||||
if (profile_manager.GetProfileBase(user_id, profile_base)) {
|
if (profile_manager.GetProfileBase(user_id, profile_base)) {
|
||||||
IPC::ResponseBuilder rb{ctx, 16};
|
IPC::ResponseBuilder rb{ctx, 16};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
rb.PushRaw(profile_base);
|
rb.PushRaw(profile_base);
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR(Service_ACC, "Failed to get profile base for user=0x{}", user_id.Format());
|
LOG_ERROR(Service_ACC, "Failed to get profile base for user=0x{}", user_id.RawString());
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(ResultUnknown); // TODO(ogniK): Get actual error code
|
rb.Push(ResultUnknown); // TODO(ogniK): Get actual error code
|
||||||
}
|
}
|
||||||
|
@ -373,7 +373,7 @@ protected:
|
||||||
LOG_DEBUG(Service_ACC, "called, username='{}', timestamp={:016X}, uuid=0x{}",
|
LOG_DEBUG(Service_ACC, "called, username='{}', timestamp={:016X}, uuid=0x{}",
|
||||||
Common::StringFromFixedZeroTerminatedBuffer(
|
Common::StringFromFixedZeroTerminatedBuffer(
|
||||||
reinterpret_cast<const char*>(base.username.data()), base.username.size()),
|
reinterpret_cast<const char*>(base.username.data()), base.username.size()),
|
||||||
base.timestamp, base.user_uuid.Format());
|
base.timestamp, base.user_uuid.RawString());
|
||||||
|
|
||||||
if (user_data.size() < sizeof(ProfileData)) {
|
if (user_data.size() < sizeof(ProfileData)) {
|
||||||
LOG_ERROR(Service_ACC, "ProfileData buffer too small!");
|
LOG_ERROR(Service_ACC, "ProfileData buffer too small!");
|
||||||
|
@ -406,7 +406,7 @@ protected:
|
||||||
LOG_DEBUG(Service_ACC, "called, username='{}', timestamp={:016X}, uuid=0x{}",
|
LOG_DEBUG(Service_ACC, "called, username='{}', timestamp={:016X}, uuid=0x{}",
|
||||||
Common::StringFromFixedZeroTerminatedBuffer(
|
Common::StringFromFixedZeroTerminatedBuffer(
|
||||||
reinterpret_cast<const char*>(base.username.data()), base.username.size()),
|
reinterpret_cast<const char*>(base.username.data()), base.username.size()),
|
||||||
base.timestamp, base.user_uuid.Format());
|
base.timestamp, base.user_uuid.RawString());
|
||||||
|
|
||||||
if (user_data.size() < sizeof(ProfileData)) {
|
if (user_data.size() < sizeof(ProfileData)) {
|
||||||
LOG_ERROR(Service_ACC, "ProfileData buffer too small!");
|
LOG_ERROR(Service_ACC, "ProfileData buffer too small!");
|
||||||
|
@ -435,26 +435,26 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileManager& profile_manager;
|
ProfileManager& profile_manager;
|
||||||
Common::UUID user_id{Common::INVALID_UUID}; ///< The user id this profile refers to.
|
Common::NewUUID user_id{}; ///< The user id this profile refers to.
|
||||||
};
|
};
|
||||||
|
|
||||||
class IProfile final : public IProfileCommon {
|
class IProfile final : public IProfileCommon {
|
||||||
public:
|
public:
|
||||||
explicit IProfile(Core::System& system_, Common::UUID user_id_,
|
explicit IProfile(Core::System& system_, Common::NewUUID user_id_,
|
||||||
ProfileManager& profile_manager_)
|
ProfileManager& profile_manager_)
|
||||||
: IProfileCommon{system_, "IProfile", false, user_id_, profile_manager_} {}
|
: IProfileCommon{system_, "IProfile", false, user_id_, profile_manager_} {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class IProfileEditor final : public IProfileCommon {
|
class IProfileEditor final : public IProfileCommon {
|
||||||
public:
|
public:
|
||||||
explicit IProfileEditor(Core::System& system_, Common::UUID user_id_,
|
explicit IProfileEditor(Core::System& system_, Common::NewUUID user_id_,
|
||||||
ProfileManager& profile_manager_)
|
ProfileManager& profile_manager_)
|
||||||
: IProfileCommon{system_, "IProfileEditor", true, user_id_, profile_manager_} {}
|
: IProfileCommon{system_, "IProfileEditor", true, user_id_, profile_manager_} {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ISessionObject final : public ServiceFramework<ISessionObject> {
|
class ISessionObject final : public ServiceFramework<ISessionObject> {
|
||||||
public:
|
public:
|
||||||
explicit ISessionObject(Core::System& system_, Common::UUID)
|
explicit ISessionObject(Core::System& system_, Common::NewUUID)
|
||||||
: ServiceFramework{system_, "ISessionObject"} {
|
: ServiceFramework{system_, "ISessionObject"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
|
@ -468,7 +468,7 @@ public:
|
||||||
|
|
||||||
class IGuestLoginRequest final : public ServiceFramework<IGuestLoginRequest> {
|
class IGuestLoginRequest final : public ServiceFramework<IGuestLoginRequest> {
|
||||||
public:
|
public:
|
||||||
explicit IGuestLoginRequest(Core::System& system_, Common::UUID)
|
explicit IGuestLoginRequest(Core::System& system_, Common::NewUUID)
|
||||||
: ServiceFramework{system_, "IGuestLoginRequest"} {
|
: ServiceFramework{system_, "IGuestLoginRequest"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
|
@ -514,7 +514,7 @@ protected:
|
||||||
|
|
||||||
class IManagerForApplication final : public ServiceFramework<IManagerForApplication> {
|
class IManagerForApplication final : public ServiceFramework<IManagerForApplication> {
|
||||||
public:
|
public:
|
||||||
explicit IManagerForApplication(Core::System& system_, Common::UUID user_id_)
|
explicit IManagerForApplication(Core::System& system_, Common::NewUUID user_id_)
|
||||||
: ServiceFramework{system_, "IManagerForApplication"},
|
: ServiceFramework{system_, "IManagerForApplication"},
|
||||||
ensure_token_id{std::make_shared<EnsureTokenIdCacheAsyncInterface>(system)},
|
ensure_token_id{std::make_shared<EnsureTokenIdCacheAsyncInterface>(system)},
|
||||||
user_id{user_id_} {
|
user_id{user_id_} {
|
||||||
|
@ -547,7 +547,7 @@ private:
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 4};
|
IPC::ResponseBuilder rb{ctx, 4};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
rb.PushRaw<u64>(user_id.GetNintendoID());
|
rb.PushRaw<u64>(user_id.Hash());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnsureIdTokenCacheAsync(Kernel::HLERequestContext& ctx) {
|
void EnsureIdTokenCacheAsync(Kernel::HLERequestContext& ctx) {
|
||||||
|
@ -577,7 +577,7 @@ private:
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 4};
|
IPC::ResponseBuilder rb{ctx, 4};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
rb.PushRaw<u64>(user_id.GetNintendoID());
|
rb.PushRaw<u64>(user_id.Hash());
|
||||||
}
|
}
|
||||||
|
|
||||||
void StoreOpenContext(Kernel::HLERequestContext& ctx) {
|
void StoreOpenContext(Kernel::HLERequestContext& ctx) {
|
||||||
|
@ -587,14 +587,14 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<EnsureTokenIdCacheAsyncInterface> ensure_token_id{};
|
std::shared_ptr<EnsureTokenIdCacheAsyncInterface> ensure_token_id{};
|
||||||
Common::UUID user_id{Common::INVALID_UUID};
|
Common::NewUUID user_id{};
|
||||||
};
|
};
|
||||||
|
|
||||||
// 6.0.0+
|
// 6.0.0+
|
||||||
class IAsyncNetworkServiceLicenseKindContext final
|
class IAsyncNetworkServiceLicenseKindContext final
|
||||||
: public ServiceFramework<IAsyncNetworkServiceLicenseKindContext> {
|
: public ServiceFramework<IAsyncNetworkServiceLicenseKindContext> {
|
||||||
public:
|
public:
|
||||||
explicit IAsyncNetworkServiceLicenseKindContext(Core::System& system_, Common::UUID)
|
explicit IAsyncNetworkServiceLicenseKindContext(Core::System& system_, Common::NewUUID)
|
||||||
: ServiceFramework{system_, "IAsyncNetworkServiceLicenseKindContext"} {
|
: ServiceFramework{system_, "IAsyncNetworkServiceLicenseKindContext"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
|
@ -614,7 +614,7 @@ public:
|
||||||
class IOAuthProcedureForUserRegistration final
|
class IOAuthProcedureForUserRegistration final
|
||||||
: public ServiceFramework<IOAuthProcedureForUserRegistration> {
|
: public ServiceFramework<IOAuthProcedureForUserRegistration> {
|
||||||
public:
|
public:
|
||||||
explicit IOAuthProcedureForUserRegistration(Core::System& system_, Common::UUID)
|
explicit IOAuthProcedureForUserRegistration(Core::System& system_, Common::NewUUID)
|
||||||
: ServiceFramework{system_, "IOAuthProcedureForUserRegistration"} {
|
: ServiceFramework{system_, "IOAuthProcedureForUserRegistration"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
|
@ -638,7 +638,8 @@ public:
|
||||||
|
|
||||||
class DAUTH_O final : public ServiceFramework<DAUTH_O> {
|
class DAUTH_O final : public ServiceFramework<DAUTH_O> {
|
||||||
public:
|
public:
|
||||||
explicit DAUTH_O(Core::System& system_, Common::UUID) : ServiceFramework{system_, "dauth:o"} {
|
explicit DAUTH_O(Core::System& system_, Common::NewUUID)
|
||||||
|
: ServiceFramework{system_, "dauth:o"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, nullptr, "EnsureAuthenticationTokenCacheAsync"},
|
{0, nullptr, "EnsureAuthenticationTokenCacheAsync"},
|
||||||
|
@ -662,7 +663,7 @@ public:
|
||||||
// 6.0.0+
|
// 6.0.0+
|
||||||
class IAsyncResult final : public ServiceFramework<IAsyncResult> {
|
class IAsyncResult final : public ServiceFramework<IAsyncResult> {
|
||||||
public:
|
public:
|
||||||
explicit IAsyncResult(Core::System& system_, Common::UUID)
|
explicit IAsyncResult(Core::System& system_, Common::NewUUID)
|
||||||
: ServiceFramework{system_, "IAsyncResult"} {
|
: ServiceFramework{system_, "IAsyncResult"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
|
@ -686,8 +687,8 @@ void Module::Interface::GetUserCount(Kernel::HLERequestContext& ctx) {
|
||||||
|
|
||||||
void Module::Interface::GetUserExistence(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::GetUserExistence(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
Common::UUID user_id = rp.PopRaw<Common::UUID>();
|
Common::NewUUID user_id = rp.PopRaw<Common::NewUUID>();
|
||||||
LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.Format());
|
LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString());
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
|
@ -712,13 +713,13 @@ void Module::Interface::GetLastOpenedUser(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_ACC, "called");
|
LOG_DEBUG(Service_ACC, "called");
|
||||||
IPC::ResponseBuilder rb{ctx, 6};
|
IPC::ResponseBuilder rb{ctx, 6};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
rb.PushRaw<Common::UUID>(profile_manager->GetLastOpenedUser());
|
rb.PushRaw<Common::NewUUID>(profile_manager->GetLastOpenedUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::Interface::GetProfile(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::GetProfile(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
Common::UUID user_id = rp.PopRaw<Common::UUID>();
|
Common::NewUUID user_id = rp.PopRaw<Common::NewUUID>();
|
||||||
LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.Format());
|
LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString());
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
|
@ -831,9 +832,9 @@ void Module::Interface::InitializeApplicationInfoV2(Kernel::HLERequestContext& c
|
||||||
|
|
||||||
void Module::Interface::GetProfileEditor(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::GetProfileEditor(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
Common::UUID user_id = rp.PopRaw<Common::UUID>();
|
Common::NewUUID user_id = rp.PopRaw<Common::NewUUID>();
|
||||||
|
|
||||||
LOG_DEBUG(Service_ACC, "called, user_id=0x{}", user_id.Format());
|
LOG_DEBUG(Service_ACC, "called, user_id=0x{}", user_id.RawString());
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
|
@ -873,9 +874,9 @@ void Module::Interface::ListOpenContextStoredUsers(Kernel::HLERequestContext& ct
|
||||||
|
|
||||||
void Module::Interface::StoreSaveDataThumbnailApplication(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::StoreSaveDataThumbnailApplication(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
const auto uuid = rp.PopRaw<Common::UUID>();
|
const auto uuid = rp.PopRaw<Common::NewUUID>();
|
||||||
|
|
||||||
LOG_WARNING(Service_ACC, "(STUBBED) called, uuid=0x{}", uuid.Format());
|
LOG_WARNING(Service_ACC, "(STUBBED) called, uuid=0x{}", uuid.RawString());
|
||||||
|
|
||||||
// TODO(ogniK): Check if application ID is zero on acc initialize. As we don't have a reliable
|
// TODO(ogniK): Check if application ID is zero on acc initialize. As we don't have a reliable
|
||||||
// way of confirming things like the TID, we're going to assume a non zero value for the time
|
// way of confirming things like the TID, we're going to assume a non zero value for the time
|
||||||
|
@ -886,15 +887,15 @@ void Module::Interface::StoreSaveDataThumbnailApplication(Kernel::HLERequestCont
|
||||||
|
|
||||||
void Module::Interface::StoreSaveDataThumbnailSystem(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::StoreSaveDataThumbnailSystem(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
const auto uuid = rp.PopRaw<Common::UUID>();
|
const auto uuid = rp.PopRaw<Common::NewUUID>();
|
||||||
const auto tid = rp.Pop<u64_le>();
|
const auto tid = rp.Pop<u64_le>();
|
||||||
|
|
||||||
LOG_WARNING(Service_ACC, "(STUBBED) called, uuid=0x{}, tid={:016X}", uuid.Format(), tid);
|
LOG_WARNING(Service_ACC, "(STUBBED) called, uuid=0x{}, tid={:016X}", uuid.RawString(), tid);
|
||||||
StoreSaveDataThumbnail(ctx, uuid, tid);
|
StoreSaveDataThumbnail(ctx, uuid, tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::Interface::StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx,
|
void Module::Interface::StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx,
|
||||||
const Common::UUID& uuid, const u64 tid) {
|
const Common::NewUUID& uuid, const u64 tid) {
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
|
||||||
if (tid == 0) {
|
if (tid == 0) {
|
||||||
|
@ -903,7 +904,7 @@ void Module::Interface::StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!uuid) {
|
if (uuid.IsInvalid()) {
|
||||||
LOG_ERROR(Service_ACC, "User ID is not valid!");
|
LOG_ERROR(Service_ACC, "User ID is not valid!");
|
||||||
rb.Push(ERR_INVALID_USER_ID);
|
rb.Push(ERR_INVALID_USER_ID);
|
||||||
return;
|
return;
|
||||||
|
@ -927,20 +928,20 @@ void Module::Interface::TrySelectUserWithoutInteraction(Kernel::HLERequestContex
|
||||||
IPC::ResponseBuilder rb{ctx, 6};
|
IPC::ResponseBuilder rb{ctx, 6};
|
||||||
if (profile_manager->GetUserCount() != 1) {
|
if (profile_manager->GetUserCount() != 1) {
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
rb.PushRaw<u128>(Common::INVALID_UUID);
|
rb.PushRaw(Common::InvalidUUID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto user_list = profile_manager->GetAllUsers();
|
const auto user_list = profile_manager->GetAllUsers();
|
||||||
if (std::ranges::all_of(user_list, [](const auto& user) { return user.IsInvalid(); })) {
|
if (std::ranges::all_of(user_list, [](const auto& user) { return user.IsInvalid(); })) {
|
||||||
rb.Push(ResultUnknown); // TODO(ogniK): Find the correct error code
|
rb.Push(ResultUnknown); // TODO(ogniK): Find the correct error code
|
||||||
rb.PushRaw<u128>(Common::INVALID_UUID);
|
rb.PushRaw(Common::InvalidUUID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select the first user we have
|
// Select the first user we have
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
rb.PushRaw<u128>(profile_manager->GetUser(0)->uuid);
|
rb.PushRaw(profile_manager->GetUser(0)->uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
Module::Interface::Interface(std::shared_ptr<Module> module_,
|
Module::Interface::Interface(std::shared_ptr<Module> module_,
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/uuid.h"
|
#include "common/new_uuid.h"
|
||||||
#include "core/hle/service/glue/glue_manager.h"
|
#include "core/hle/service/glue/glue_manager.h"
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ResultCode InitializeApplicationInfoBase();
|
ResultCode InitializeApplicationInfoBase();
|
||||||
void StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx, const Common::UUID& uuid,
|
void StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx, const Common::NewUUID& uuid,
|
||||||
const u64 tid);
|
const u64 tid);
|
||||||
|
|
||||||
enum class ApplicationType : u32_le {
|
enum class ApplicationType : u32_le {
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
namespace Service::Account {
|
namespace Service::Account {
|
||||||
|
|
||||||
namespace FS = Common::FS;
|
namespace FS = Common::FS;
|
||||||
using Common::UUID;
|
using Common::NewUUID;
|
||||||
|
|
||||||
struct UserRaw {
|
struct UserRaw {
|
||||||
UUID uuid{Common::INVALID_UUID};
|
NewUUID uuid{};
|
||||||
UUID uuid2{Common::INVALID_UUID};
|
NewUUID uuid2{};
|
||||||
u64 timestamp{};
|
u64 timestamp{};
|
||||||
ProfileUsername username{};
|
ProfileUsername username{};
|
||||||
ProfileData extra_data{};
|
ProfileData extra_data{};
|
||||||
|
@ -45,7 +45,7 @@ ProfileManager::ProfileManager() {
|
||||||
|
|
||||||
// Create an user if none are present
|
// Create an user if none are present
|
||||||
if (user_count == 0) {
|
if (user_count == 0) {
|
||||||
CreateNewUser(UUID::Generate(), "yuzu");
|
CreateNewUser(NewUUID::MakeRandom(), "yuzu");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto current =
|
auto current =
|
||||||
|
@ -97,11 +97,11 @@ ResultCode ProfileManager::AddUser(const ProfileInfo& user) {
|
||||||
|
|
||||||
/// Create a new user on the system. If the uuid of the user already exists, the user is not
|
/// Create a new user on the system. If the uuid of the user already exists, the user is not
|
||||||
/// created.
|
/// created.
|
||||||
ResultCode ProfileManager::CreateNewUser(UUID uuid, const ProfileUsername& username) {
|
ResultCode ProfileManager::CreateNewUser(NewUUID uuid, const ProfileUsername& username) {
|
||||||
if (user_count == MAX_USERS) {
|
if (user_count == MAX_USERS) {
|
||||||
return ERROR_TOO_MANY_USERS;
|
return ERROR_TOO_MANY_USERS;
|
||||||
}
|
}
|
||||||
if (!uuid) {
|
if (uuid.IsInvalid()) {
|
||||||
return ERROR_ARGUMENT_IS_NULL;
|
return ERROR_ARGUMENT_IS_NULL;
|
||||||
}
|
}
|
||||||
if (username[0] == 0x0) {
|
if (username[0] == 0x0) {
|
||||||
|
@ -124,7 +124,7 @@ ResultCode ProfileManager::CreateNewUser(UUID uuid, const ProfileUsername& usern
|
||||||
/// Creates a new user on the system. This function allows a much simpler method of registration
|
/// Creates a new user on the system. This function allows a much simpler method of registration
|
||||||
/// specifically by allowing an std::string for the username. This is required specifically since
|
/// specifically by allowing an std::string for the username. This is required specifically since
|
||||||
/// we're loading a string straight from the config
|
/// we're loading a string straight from the config
|
||||||
ResultCode ProfileManager::CreateNewUser(UUID uuid, const std::string& username) {
|
ResultCode ProfileManager::CreateNewUser(NewUUID uuid, const std::string& username) {
|
||||||
ProfileUsername username_output{};
|
ProfileUsername username_output{};
|
||||||
|
|
||||||
if (username.size() > username_output.size()) {
|
if (username.size() > username_output.size()) {
|
||||||
|
@ -135,7 +135,7 @@ ResultCode ProfileManager::CreateNewUser(UUID uuid, const std::string& username)
|
||||||
return CreateNewUser(uuid, username_output);
|
return CreateNewUser(uuid, username_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<UUID> ProfileManager::GetUser(std::size_t index) const {
|
std::optional<NewUUID> ProfileManager::GetUser(std::size_t index) const {
|
||||||
if (index >= MAX_USERS) {
|
if (index >= MAX_USERS) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
@ -144,8 +144,8 @@ std::optional<UUID> ProfileManager::GetUser(std::size_t index) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a users profile index based on their user id.
|
/// Returns a users profile index based on their user id.
|
||||||
std::optional<std::size_t> ProfileManager::GetUserIndex(const UUID& uuid) const {
|
std::optional<std::size_t> ProfileManager::GetUserIndex(const NewUUID& uuid) const {
|
||||||
if (!uuid) {
|
if (uuid.IsInvalid()) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ bool ProfileManager::GetProfileBase(std::optional<std::size_t> index, ProfileBas
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the data structure used by the switch when GetProfileBase is called on acc:*
|
/// Returns the data structure used by the switch when GetProfileBase is called on acc:*
|
||||||
bool ProfileManager::GetProfileBase(UUID uuid, ProfileBase& profile) const {
|
bool ProfileManager::GetProfileBase(NewUUID uuid, ProfileBase& profile) const {
|
||||||
const auto idx = GetUserIndex(uuid);
|
const auto idx = GetUserIndex(uuid);
|
||||||
return GetProfileBase(idx, profile);
|
return GetProfileBase(idx, profile);
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ std::size_t ProfileManager::GetOpenUserCount() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if a user id exists in our profile manager
|
/// Checks if a user id exists in our profile manager
|
||||||
bool ProfileManager::UserExists(UUID uuid) const {
|
bool ProfileManager::UserExists(NewUUID uuid) const {
|
||||||
return GetUserIndex(uuid).has_value();
|
return GetUserIndex(uuid).has_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ bool ProfileManager::UserExistsIndex(std::size_t index) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Opens a specific user
|
/// Opens a specific user
|
||||||
void ProfileManager::OpenUser(UUID uuid) {
|
void ProfileManager::OpenUser(NewUUID uuid) {
|
||||||
const auto idx = GetUserIndex(uuid);
|
const auto idx = GetUserIndex(uuid);
|
||||||
if (!idx) {
|
if (!idx) {
|
||||||
return;
|
return;
|
||||||
|
@ -226,7 +226,7 @@ void ProfileManager::OpenUser(UUID uuid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Closes a specific user
|
/// Closes a specific user
|
||||||
void ProfileManager::CloseUser(UUID uuid) {
|
void ProfileManager::CloseUser(NewUUID uuid) {
|
||||||
const auto idx = GetUserIndex(uuid);
|
const auto idx = GetUserIndex(uuid);
|
||||||
if (!idx) {
|
if (!idx) {
|
||||||
return;
|
return;
|
||||||
|
@ -250,14 +250,15 @@ UserIDArray ProfileManager::GetOpenUsers() const {
|
||||||
std::ranges::transform(profiles, output.begin(), [](const ProfileInfo& p) {
|
std::ranges::transform(profiles, output.begin(), [](const ProfileInfo& p) {
|
||||||
if (p.is_open)
|
if (p.is_open)
|
||||||
return p.user_uuid;
|
return p.user_uuid;
|
||||||
return UUID{Common::INVALID_UUID};
|
return Common::InvalidUUID;
|
||||||
});
|
});
|
||||||
std::stable_partition(output.begin(), output.end(), [](const UUID& uuid) { return uuid; });
|
std::stable_partition(output.begin(), output.end(),
|
||||||
|
[](const NewUUID& uuid) { return uuid.IsValid(); });
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the last user which was opened
|
/// Returns the last user which was opened
|
||||||
UUID ProfileManager::GetLastOpenedUser() const {
|
NewUUID ProfileManager::GetLastOpenedUser() const {
|
||||||
return last_opened_user;
|
return last_opened_user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +273,7 @@ bool ProfileManager::GetProfileBaseAndData(std::optional<std::size_t> index, Pro
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the users profile base and the unknown arbitary data.
|
/// Return the users profile base and the unknown arbitary data.
|
||||||
bool ProfileManager::GetProfileBaseAndData(UUID uuid, ProfileBase& profile,
|
bool ProfileManager::GetProfileBaseAndData(NewUUID uuid, ProfileBase& profile,
|
||||||
ProfileData& data) const {
|
ProfileData& data) const {
|
||||||
const auto idx = GetUserIndex(uuid);
|
const auto idx = GetUserIndex(uuid);
|
||||||
return GetProfileBaseAndData(idx, profile, data);
|
return GetProfileBaseAndData(idx, profile, data);
|
||||||
|
@ -291,7 +292,7 @@ bool ProfileManager::CanSystemRegisterUser() const {
|
||||||
// emulate qlaunch. Update this to dynamically change.
|
// emulate qlaunch. Update this to dynamically change.
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProfileManager::RemoveUser(UUID uuid) {
|
bool ProfileManager::RemoveUser(NewUUID uuid) {
|
||||||
const auto index = GetUserIndex(uuid);
|
const auto index = GetUserIndex(uuid);
|
||||||
if (!index) {
|
if (!index) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -299,11 +300,11 @@ bool ProfileManager::RemoveUser(UUID uuid) {
|
||||||
|
|
||||||
profiles[*index] = ProfileInfo{};
|
profiles[*index] = ProfileInfo{};
|
||||||
std::stable_partition(profiles.begin(), profiles.end(),
|
std::stable_partition(profiles.begin(), profiles.end(),
|
||||||
[](const ProfileInfo& profile) { return profile.user_uuid; });
|
[](const ProfileInfo& profile) { return profile.user_uuid.IsValid(); });
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProfileManager::SetProfileBase(UUID uuid, const ProfileBase& profile_new) {
|
bool ProfileManager::SetProfileBase(NewUUID uuid, const ProfileBase& profile_new) {
|
||||||
const auto index = GetUserIndex(uuid);
|
const auto index = GetUserIndex(uuid);
|
||||||
if (!index || profile_new.user_uuid.IsInvalid()) {
|
if (!index || profile_new.user_uuid.IsInvalid()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -317,7 +318,7 @@ bool ProfileManager::SetProfileBase(UUID uuid, const ProfileBase& profile_new) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProfileManager::SetProfileBaseAndData(Common::UUID uuid, const ProfileBase& profile_new,
|
bool ProfileManager::SetProfileBaseAndData(Common::NewUUID uuid, const ProfileBase& profile_new,
|
||||||
const ProfileData& data_new) {
|
const ProfileData& data_new) {
|
||||||
const auto index = GetUserIndex(uuid);
|
const auto index = GetUserIndex(uuid);
|
||||||
if (index.has_value() && SetProfileBase(uuid, profile_new)) {
|
if (index.has_value() && SetProfileBase(uuid, profile_new)) {
|
||||||
|
@ -335,14 +336,14 @@ void ProfileManager::ParseUserSaveFile() {
|
||||||
|
|
||||||
if (!save.IsOpen()) {
|
if (!save.IsOpen()) {
|
||||||
LOG_WARNING(Service_ACC, "Failed to load profile data from save data... Generating new "
|
LOG_WARNING(Service_ACC, "Failed to load profile data from save data... Generating new "
|
||||||
"user 'yuzu' with random UUID.");
|
"user 'yuzu' with random NewUUID.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileDataRaw data;
|
ProfileDataRaw data;
|
||||||
if (!save.ReadObject(data)) {
|
if (!save.ReadObject(data)) {
|
||||||
LOG_WARNING(Service_ACC, "profiles.dat is smaller than expected... Generating new user "
|
LOG_WARNING(Service_ACC, "profiles.dat is smaller than expected... Generating new user "
|
||||||
"'yuzu' with random UUID.");
|
"'yuzu' with random NewUUID.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +362,7 @@ void ProfileManager::ParseUserSaveFile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stable_partition(profiles.begin(), profiles.end(),
|
std::stable_partition(profiles.begin(), profiles.end(),
|
||||||
[](const ProfileInfo& profile) { return profile.user_uuid; });
|
[](const ProfileInfo& profile) { return profile.user_uuid.IsValid(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileManager::WriteUserSaveFile() {
|
void ProfileManager::WriteUserSaveFile() {
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "common/new_uuid.h"
|
||||||
#include "common/swap.h"
|
#include "common/swap.h"
|
||||||
#include "common/uuid.h"
|
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
|
|
||||||
namespace Service::Account {
|
namespace Service::Account {
|
||||||
|
@ -18,7 +18,7 @@ constexpr std::size_t MAX_USERS{8};
|
||||||
constexpr std::size_t profile_username_size{32};
|
constexpr std::size_t profile_username_size{32};
|
||||||
|
|
||||||
using ProfileUsername = std::array<u8, profile_username_size>;
|
using ProfileUsername = std::array<u8, profile_username_size>;
|
||||||
using UserIDArray = std::array<Common::UUID, MAX_USERS>;
|
using UserIDArray = std::array<Common::NewUUID, MAX_USERS>;
|
||||||
|
|
||||||
/// Contains extra data related to a user.
|
/// Contains extra data related to a user.
|
||||||
/// TODO: RE this structure
|
/// TODO: RE this structure
|
||||||
|
@ -35,7 +35,7 @@ static_assert(sizeof(ProfileData) == 0x80, "ProfileData structure has incorrect
|
||||||
/// This holds general information about a users profile. This is where we store all the information
|
/// This holds general information about a users profile. This is where we store all the information
|
||||||
/// based on a specific user
|
/// based on a specific user
|
||||||
struct ProfileInfo {
|
struct ProfileInfo {
|
||||||
Common::UUID user_uuid{Common::INVALID_UUID};
|
Common::NewUUID user_uuid{};
|
||||||
ProfileUsername username{};
|
ProfileUsername username{};
|
||||||
u64 creation_time{};
|
u64 creation_time{};
|
||||||
ProfileData data{}; // TODO(ognik): Work out what this is
|
ProfileData data{}; // TODO(ognik): Work out what this is
|
||||||
|
@ -43,13 +43,13 @@ struct ProfileInfo {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ProfileBase {
|
struct ProfileBase {
|
||||||
Common::UUID user_uuid;
|
Common::NewUUID user_uuid;
|
||||||
u64_le timestamp;
|
u64_le timestamp;
|
||||||
ProfileUsername username;
|
ProfileUsername username;
|
||||||
|
|
||||||
// Zero out all the fields to make the profile slot considered "Empty"
|
// Zero out all the fields to make the profile slot considered "Empty"
|
||||||
void Invalidate() {
|
void Invalidate() {
|
||||||
user_uuid.Invalidate();
|
user_uuid = {};
|
||||||
timestamp = 0;
|
timestamp = 0;
|
||||||
username.fill(0);
|
username.fill(0);
|
||||||
}
|
}
|
||||||
|
@ -65,34 +65,34 @@ public:
|
||||||
~ProfileManager();
|
~ProfileManager();
|
||||||
|
|
||||||
ResultCode AddUser(const ProfileInfo& user);
|
ResultCode AddUser(const ProfileInfo& user);
|
||||||
ResultCode CreateNewUser(Common::UUID uuid, const ProfileUsername& username);
|
ResultCode CreateNewUser(Common::NewUUID uuid, const ProfileUsername& username);
|
||||||
ResultCode CreateNewUser(Common::UUID uuid, const std::string& username);
|
ResultCode CreateNewUser(Common::NewUUID uuid, const std::string& username);
|
||||||
std::optional<Common::UUID> GetUser(std::size_t index) const;
|
std::optional<Common::NewUUID> GetUser(std::size_t index) const;
|
||||||
std::optional<std::size_t> GetUserIndex(const Common::UUID& uuid) const;
|
std::optional<std::size_t> GetUserIndex(const Common::NewUUID& uuid) const;
|
||||||
std::optional<std::size_t> GetUserIndex(const ProfileInfo& user) const;
|
std::optional<std::size_t> GetUserIndex(const ProfileInfo& user) const;
|
||||||
bool GetProfileBase(std::optional<std::size_t> index, ProfileBase& profile) const;
|
bool GetProfileBase(std::optional<std::size_t> index, ProfileBase& profile) const;
|
||||||
bool GetProfileBase(Common::UUID uuid, ProfileBase& profile) const;
|
bool GetProfileBase(Common::NewUUID uuid, ProfileBase& profile) const;
|
||||||
bool GetProfileBase(const ProfileInfo& user, ProfileBase& profile) const;
|
bool GetProfileBase(const ProfileInfo& user, ProfileBase& profile) const;
|
||||||
bool GetProfileBaseAndData(std::optional<std::size_t> index, ProfileBase& profile,
|
bool GetProfileBaseAndData(std::optional<std::size_t> index, ProfileBase& profile,
|
||||||
ProfileData& data) const;
|
ProfileData& data) const;
|
||||||
bool GetProfileBaseAndData(Common::UUID uuid, ProfileBase& profile, ProfileData& data) const;
|
bool GetProfileBaseAndData(Common::NewUUID uuid, ProfileBase& profile, ProfileData& data) const;
|
||||||
bool GetProfileBaseAndData(const ProfileInfo& user, ProfileBase& profile,
|
bool GetProfileBaseAndData(const ProfileInfo& user, ProfileBase& profile,
|
||||||
ProfileData& data) const;
|
ProfileData& data) const;
|
||||||
std::size_t GetUserCount() const;
|
std::size_t GetUserCount() const;
|
||||||
std::size_t GetOpenUserCount() const;
|
std::size_t GetOpenUserCount() const;
|
||||||
bool UserExists(Common::UUID uuid) const;
|
bool UserExists(Common::NewUUID uuid) const;
|
||||||
bool UserExistsIndex(std::size_t index) const;
|
bool UserExistsIndex(std::size_t index) const;
|
||||||
void OpenUser(Common::UUID uuid);
|
void OpenUser(Common::NewUUID uuid);
|
||||||
void CloseUser(Common::UUID uuid);
|
void CloseUser(Common::NewUUID uuid);
|
||||||
UserIDArray GetOpenUsers() const;
|
UserIDArray GetOpenUsers() const;
|
||||||
UserIDArray GetAllUsers() const;
|
UserIDArray GetAllUsers() const;
|
||||||
Common::UUID GetLastOpenedUser() const;
|
Common::NewUUID GetLastOpenedUser() const;
|
||||||
|
|
||||||
bool CanSystemRegisterUser() const;
|
bool CanSystemRegisterUser() const;
|
||||||
|
|
||||||
bool RemoveUser(Common::UUID uuid);
|
bool RemoveUser(Common::NewUUID uuid);
|
||||||
bool SetProfileBase(Common::UUID uuid, const ProfileBase& profile_new);
|
bool SetProfileBase(Common::NewUUID uuid, const ProfileBase& profile_new);
|
||||||
bool SetProfileBaseAndData(Common::UUID uuid, const ProfileBase& profile_new,
|
bool SetProfileBaseAndData(Common::NewUUID uuid, const ProfileBase& profile_new,
|
||||||
const ProfileData& data_new);
|
const ProfileData& data_new);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -103,7 +103,7 @@ private:
|
||||||
|
|
||||||
std::array<ProfileInfo, MAX_USERS> profiles{};
|
std::array<ProfileInfo, MAX_USERS> profiles{};
|
||||||
std::size_t user_count{};
|
std::size_t user_count{};
|
||||||
Common::UUID last_opened_user{Common::INVALID_UUID};
|
Common::NewUUID last_opened_user{};
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace Service::Account
|
}; // namespace Service::Account
|
||||||
|
|
|
@ -55,7 +55,7 @@ constexpr u32 LAUNCH_PARAMETER_ACCOUNT_PRESELECTED_USER_MAGIC = 0xC79497CA;
|
||||||
struct LaunchParameterAccountPreselectedUser {
|
struct LaunchParameterAccountPreselectedUser {
|
||||||
u32_le magic;
|
u32_le magic;
|
||||||
u32_le is_account_selected;
|
u32_le is_account_selected;
|
||||||
u128 current_user;
|
Common::NewUUID current_user;
|
||||||
INSERT_PADDING_BYTES(0x70);
|
INSERT_PADDING_BYTES(0x70);
|
||||||
};
|
};
|
||||||
static_assert(sizeof(LaunchParameterAccountPreselectedUser) == 0x88);
|
static_assert(sizeof(LaunchParameterAccountPreselectedUser) == 0x88);
|
||||||
|
@ -1453,8 +1453,8 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
|
||||||
|
|
||||||
Account::ProfileManager profile_manager{};
|
Account::ProfileManager profile_manager{};
|
||||||
const auto uuid = profile_manager.GetUser(static_cast<s32>(Settings::values.current_user));
|
const auto uuid = profile_manager.GetUser(static_cast<s32>(Settings::values.current_user));
|
||||||
ASSERT(uuid);
|
ASSERT(uuid.has_value() && uuid->IsValid());
|
||||||
params.current_user = uuid->uuid;
|
params.current_user = *uuid;
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
|
|
||||||
|
|
|
@ -54,19 +54,20 @@ void ProfileSelect::Execute() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
frontend.SelectProfile([this](std::optional<Common::UUID> uuid) { SelectionComplete(uuid); });
|
frontend.SelectProfile(
|
||||||
|
[this](std::optional<Common::NewUUID> uuid) { SelectionComplete(uuid); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileSelect::SelectionComplete(std::optional<Common::UUID> uuid) {
|
void ProfileSelect::SelectionComplete(std::optional<Common::NewUUID> uuid) {
|
||||||
UserSelectionOutput output{};
|
UserSelectionOutput output{};
|
||||||
|
|
||||||
if (uuid.has_value() && uuid->IsValid()) {
|
if (uuid.has_value() && uuid->IsValid()) {
|
||||||
output.result = 0;
|
output.result = 0;
|
||||||
output.uuid_selected = uuid->uuid;
|
output.uuid_selected = *uuid;
|
||||||
} else {
|
} else {
|
||||||
status = ERR_USER_CANCELLED_SELECTION;
|
status = ERR_USER_CANCELLED_SELECTION;
|
||||||
output.result = ERR_USER_CANCELLED_SELECTION.raw;
|
output.result = ERR_USER_CANCELLED_SELECTION.raw;
|
||||||
output.uuid_selected = Common::INVALID_UUID;
|
output.uuid_selected = Common::InvalidUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
final_data = std::vector<u8>(sizeof(UserSelectionOutput));
|
final_data = std::vector<u8>(sizeof(UserSelectionOutput));
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/uuid.h"
|
#include "common/new_uuid.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
#include "core/hle/service/am/applets/applets.h"
|
#include "core/hle/service/am/applets/applets.h"
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ static_assert(sizeof(UserSelectionConfig) == 0xA0, "UserSelectionConfig has inco
|
||||||
|
|
||||||
struct UserSelectionOutput {
|
struct UserSelectionOutput {
|
||||||
u64 result;
|
u64 result;
|
||||||
u128 uuid_selected;
|
Common::NewUUID uuid_selected;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(UserSelectionOutput) == 0x18, "UserSelectionOutput has incorrect size.");
|
static_assert(sizeof(UserSelectionOutput) == 0x18, "UserSelectionOutput has incorrect size.");
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public:
|
||||||
void ExecuteInteractive() override;
|
void ExecuteInteractive() override;
|
||||||
void Execute() override;
|
void Execute() override;
|
||||||
|
|
||||||
void SelectionComplete(std::optional<Common::UUID> uuid);
|
void SelectionComplete(std::optional<Common::NewUUID> uuid);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Core::Frontend::ProfileSelectApplet& frontend;
|
const Core::Frontend::ProfileSelectApplet& frontend;
|
||||||
|
|
|
@ -19,21 +19,21 @@
|
||||||
#include "yuzu/util/controller_navigation.h"
|
#include "yuzu/util/controller_navigation.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
QString FormatUserEntryText(const QString& username, Common::UUID uuid) {
|
QString FormatUserEntryText(const QString& username, Common::NewUUID uuid) {
|
||||||
return QtProfileSelectionDialog::tr(
|
return QtProfileSelectionDialog::tr(
|
||||||
"%1\n%2", "%1 is the profile username, %2 is the formatted UUID (e.g. "
|
"%1\n%2", "%1 is the profile username, %2 is the formatted UUID (e.g. "
|
||||||
"00112233-4455-6677-8899-AABBCCDDEEFF))")
|
"00112233-4455-6677-8899-AABBCCDDEEFF))")
|
||||||
.arg(username, QString::fromStdString(uuid.FormatSwitch()));
|
.arg(username, QString::fromStdString(uuid.FormattedString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GetImagePath(Common::UUID uuid) {
|
QString GetImagePath(Common::NewUUID uuid) {
|
||||||
const auto path =
|
const auto path =
|
||||||
Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) /
|
Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) /
|
||||||
fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormatSwitch());
|
fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString());
|
||||||
return QString::fromStdString(Common::FS::PathToUTF8String(path));
|
return QString::fromStdString(Common::FS::PathToUTF8String(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap GetIcon(Common::UUID uuid) {
|
QPixmap GetIcon(Common::NewUUID uuid) {
|
||||||
QPixmap icon{GetImagePath(uuid)};
|
QPixmap icon{GetImagePath(uuid)};
|
||||||
|
|
||||||
if (!icon) {
|
if (!icon) {
|
||||||
|
@ -163,11 +163,11 @@ QtProfileSelector::QtProfileSelector(GMainWindow& parent) {
|
||||||
QtProfileSelector::~QtProfileSelector() = default;
|
QtProfileSelector::~QtProfileSelector() = default;
|
||||||
|
|
||||||
void QtProfileSelector::SelectProfile(
|
void QtProfileSelector::SelectProfile(
|
||||||
std::function<void(std::optional<Common::UUID>)> callback_) const {
|
std::function<void(std::optional<Common::NewUUID>)> callback_) const {
|
||||||
callback = std::move(callback_);
|
callback = std::move(callback_);
|
||||||
emit MainWindowSelectProfile();
|
emit MainWindowSelectProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtProfileSelector::MainWindowFinishedSelection(std::optional<Common::UUID> uuid) {
|
void QtProfileSelector::MainWindowFinishedSelection(std::optional<Common::NewUUID> uuid) {
|
||||||
callback(uuid);
|
callback(uuid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,13 +66,14 @@ public:
|
||||||
explicit QtProfileSelector(GMainWindow& parent);
|
explicit QtProfileSelector(GMainWindow& parent);
|
||||||
~QtProfileSelector() override;
|
~QtProfileSelector() override;
|
||||||
|
|
||||||
void SelectProfile(std::function<void(std::optional<Common::UUID>)> callback_) const override;
|
void SelectProfile(
|
||||||
|
std::function<void(std::optional<Common::NewUUID>)> callback_) const override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void MainWindowSelectProfile() const;
|
void MainWindowSelectProfile() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void MainWindowFinishedSelection(std::optional<Common::UUID> uuid);
|
void MainWindowFinishedSelection(std::optional<Common::NewUUID> uuid);
|
||||||
|
|
||||||
mutable std::function<void(std::optional<Common::UUID>)> callback;
|
mutable std::function<void(std::optional<Common::NewUUID>)> callback;
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,14 +33,14 @@ constexpr std::array<u8, 107> backup_jpeg{
|
||||||
0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9,
|
0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9,
|
||||||
};
|
};
|
||||||
|
|
||||||
QString GetImagePath(Common::UUID uuid) {
|
QString GetImagePath(const Common::NewUUID& uuid) {
|
||||||
const auto path =
|
const auto path =
|
||||||
Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) /
|
Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) /
|
||||||
fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormatSwitch());
|
fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString());
|
||||||
return QString::fromStdString(Common::FS::PathToUTF8String(path));
|
return QString::fromStdString(Common::FS::PathToUTF8String(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GetAccountUsername(const Service::Account::ProfileManager& manager, Common::UUID uuid) {
|
QString GetAccountUsername(const Service::Account::ProfileManager& manager, Common::NewUUID uuid) {
|
||||||
Service::Account::ProfileBase profile{};
|
Service::Account::ProfileBase profile{};
|
||||||
if (!manager.GetProfileBase(uuid, profile)) {
|
if (!manager.GetProfileBase(uuid, profile)) {
|
||||||
return {};
|
return {};
|
||||||
|
@ -51,14 +51,14 @@ QString GetAccountUsername(const Service::Account::ProfileManager& manager, Comm
|
||||||
return QString::fromStdString(text);
|
return QString::fromStdString(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FormatUserEntryText(const QString& username, Common::UUID uuid) {
|
QString FormatUserEntryText(const QString& username, Common::NewUUID uuid) {
|
||||||
return ConfigureProfileManager::tr("%1\n%2",
|
return ConfigureProfileManager::tr("%1\n%2",
|
||||||
"%1 is the profile username, %2 is the formatted UUID (e.g. "
|
"%1 is the profile username, %2 is the formatted UUID (e.g. "
|
||||||
"00112233-4455-6677-8899-AABBCCDDEEFF))")
|
"00112233-4455-6677-8899-AABBCCDDEEFF))")
|
||||||
.arg(username, QString::fromStdString(uuid.FormatSwitch()));
|
.arg(username, QString::fromStdString(uuid.FormattedString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap GetIcon(Common::UUID uuid) {
|
QPixmap GetIcon(const Common::NewUUID& uuid) {
|
||||||
QPixmap icon{GetImagePath(uuid)};
|
QPixmap icon{GetImagePath(uuid)};
|
||||||
|
|
||||||
if (!icon) {
|
if (!icon) {
|
||||||
|
@ -200,7 +200,7 @@ void ConfigureProfileManager::AddUser() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto uuid = Common::UUID::Generate();
|
const auto uuid = Common::NewUUID::MakeRandom();
|
||||||
profile_manager->CreateNewUser(uuid, username.toStdString());
|
profile_manager->CreateNewUser(uuid, username.toStdString());
|
||||||
|
|
||||||
item_model->appendRow(new QStandardItem{GetIcon(uuid), FormatUserEntryText(username, uuid)});
|
item_model->appendRow(new QStandardItem{GetIcon(uuid), FormatUserEntryText(username, uuid)});
|
||||||
|
|
|
@ -1688,7 +1688,7 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target
|
||||||
|
|
||||||
const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath(
|
const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath(
|
||||||
*system, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData,
|
*system, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData,
|
||||||
program_id, user_id->uuid, 0);
|
program_id, user_id->AsU128(), 0);
|
||||||
|
|
||||||
path = Common::FS::ConcatPathSafe(nand_dir, user_save_data_path);
|
path = Common::FS::ConcatPathSafe(nand_dir, user_save_data_path);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -153,7 +153,7 @@ signals:
|
||||||
|
|
||||||
void ErrorDisplayFinished();
|
void ErrorDisplayFinished();
|
||||||
|
|
||||||
void ProfileSelectorFinishedSelection(std::optional<Common::UUID> uuid);
|
void ProfileSelectorFinishedSelection(std::optional<Common::NewUUID> uuid);
|
||||||
|
|
||||||
void SoftwareKeyboardSubmitNormalText(Service::AM::Applets::SwkbdResult result,
|
void SoftwareKeyboardSubmitNormalText(Service::AM::Applets::SwkbdResult result,
|
||||||
std::u16string submitted_text, bool confirmed);
|
std::u16string submitted_text, bool confirmed);
|
||||||
|
|
Loading…
Reference in a new issue