Added GetOpenUserCount
This commit is contained in:
parent
662218e997
commit
b8e70faa2d
3 changed files with 14 additions and 3 deletions
|
@ -158,8 +158,9 @@ void Module::Interface::ListAllUsers(Kernel::HLERequestContext& ctx) {
|
||||||
void Module::Interface::ListOpenUsers(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::ListOpenUsers(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_INFO(Service_ACC, "called");
|
LOG_INFO(Service_ACC, "called");
|
||||||
ctx.WriteBuffer(profile_manager->GetOpenUsers());
|
ctx.WriteBuffer(profile_manager->GetOpenUsers());
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
rb.Push<u32>(static_cast<u32>(profile_manager->GetOpenUserCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::Interface::GetLastOpenedUser(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::GetLastOpenedUser(Kernel::HLERequestContext& ctx) {
|
||||||
|
|
|
@ -118,6 +118,11 @@ size_t ProfileManager::GetUserCount() const {
|
||||||
return user_count;
|
return user_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t ProfileManager::GetOpenUserCount() const {
|
||||||
|
return std::count_if(profiles.begin(), profiles.end(),
|
||||||
|
[](const ProfileInfo& p) { return p.is_open; });
|
||||||
|
}
|
||||||
|
|
||||||
bool ProfileManager::UserExists(UUID uuid) const {
|
bool ProfileManager::UserExists(UUID uuid) const {
|
||||||
return (GetUserIndex(uuid) != std::numeric_limits<size_t>::max());
|
return (GetUserIndex(uuid) != std::numeric_limits<size_t>::max());
|
||||||
}
|
}
|
||||||
|
@ -148,8 +153,12 @@ std::array<UUID, MAX_USERS> ProfileManager::GetAllUsers() const {
|
||||||
|
|
||||||
std::array<UUID, MAX_USERS> ProfileManager::GetOpenUsers() const {
|
std::array<UUID, MAX_USERS> ProfileManager::GetOpenUsers() const {
|
||||||
std::array<UUID, MAX_USERS> output;
|
std::array<UUID, MAX_USERS> output;
|
||||||
std::copy_if(profiles.begin(), profiles.end(), output.begin(),
|
std::transform(profiles.begin(), profiles.end(), output.begin(), [](const ProfileInfo& p) {
|
||||||
[](const ProfileInfo& p) { return p.is_open; });
|
if (p.is_open)
|
||||||
|
return p.user_uuid;
|
||||||
|
return UUID{};
|
||||||
|
});
|
||||||
|
std::stable_partition(output.begin(), output.end(), [](const UUID& uuid) { return uuid; });
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,7 @@ public:
|
||||||
bool GetProfileBaseAndData(ProfileInfo user, ProfileBase& profile,
|
bool GetProfileBaseAndData(ProfileInfo user, ProfileBase& profile,
|
||||||
std::array<u8, MAX_DATA>& data);
|
std::array<u8, MAX_DATA>& data);
|
||||||
size_t GetUserCount() const;
|
size_t GetUserCount() const;
|
||||||
|
size_t GetOpenUserCount() const;
|
||||||
bool UserExists(UUID uuid) const;
|
bool UserExists(UUID uuid) const;
|
||||||
void OpenUser(UUID uuid);
|
void OpenUser(UUID uuid);
|
||||||
void CloseUser(UUID uuid);
|
void CloseUser(UUID uuid);
|
||||||
|
|
Loading…
Reference in a new issue