diff options
| -rw-r--r-- | src/core/hle/service/acc/profile_manager.cpp | 71 | ||||
| -rw-r--r-- | src/core/hle/service/acc/profile_manager.h | 18 | ||||
| -rw-r--r-- | src/core/hle/service/am/am.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_system.cpp | 8 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 2 |
5 files changed, 53 insertions, 48 deletions
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index 06f7d1b15..3cac1b4ff 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <random> | 5 | #include <random> |
| 6 | #include <boost/optional.hpp> | 6 | |
| 7 | #include "common/file_util.h" | 7 | #include "common/file_util.h" |
| 8 | #include "core/hle/service/acc/profile_manager.h" | 8 | #include "core/hle/service/acc/profile_manager.h" |
| 9 | #include "core/settings.h" | 9 | #include "core/settings.h" |
| @@ -58,11 +58,11 @@ ProfileManager::~ProfileManager() { | |||
| 58 | 58 | ||
| 59 | /// After a users creation it needs to be "registered" to the system. AddToProfiles handles the | 59 | /// After a users creation it needs to be "registered" to the system. AddToProfiles handles the |
| 60 | /// internal management of the users profiles | 60 | /// internal management of the users profiles |
| 61 | boost::optional<std::size_t> ProfileManager::AddToProfiles(const ProfileInfo& user) { | 61 | std::optional<std::size_t> ProfileManager::AddToProfiles(const ProfileInfo& profile) { |
| 62 | if (user_count >= MAX_USERS) { | 62 | if (user_count >= MAX_USERS) { |
| 63 | return boost::none; | 63 | return {}; |
| 64 | } | 64 | } |
| 65 | profiles[user_count] = user; | 65 | profiles[user_count] = profile; |
| 66 | return user_count++; | 66 | return user_count++; |
| 67 | } | 67 | } |
| 68 | 68 | ||
| @@ -81,7 +81,7 @@ bool ProfileManager::RemoveProfileAtIndex(std::size_t index) { | |||
| 81 | 81 | ||
| 82 | /// Helper function to register a user to the system | 82 | /// Helper function to register a user to the system |
| 83 | ResultCode ProfileManager::AddUser(const ProfileInfo& user) { | 83 | ResultCode ProfileManager::AddUser(const ProfileInfo& user) { |
| 84 | if (AddToProfiles(user) == boost::none) { | 84 | if (!AddToProfiles(user)) { |
| 85 | return ERROR_TOO_MANY_USERS; | 85 | return ERROR_TOO_MANY_USERS; |
| 86 | } | 86 | } |
| 87 | return RESULT_SUCCESS; | 87 | return RESULT_SUCCESS; |
| @@ -126,37 +126,40 @@ ResultCode ProfileManager::CreateNewUser(UUID uuid, const std::string& username) | |||
| 126 | return CreateNewUser(uuid, username_output); | 126 | return CreateNewUser(uuid, username_output); |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | boost::optional<UUID> ProfileManager::GetUser(std::size_t index) const { | 129 | std::optional<UUID> ProfileManager::GetUser(std::size_t index) const { |
| 130 | if (index >= MAX_USERS) | 130 | if (index >= MAX_USERS) { |
| 131 | return boost::none; | 131 | return {}; |
| 132 | } | ||
| 133 | |||
| 132 | return profiles[index].user_uuid; | 134 | return profiles[index].user_uuid; |
| 133 | } | 135 | } |
| 134 | 136 | ||
| 135 | /// Returns a users profile index based on their user id. | 137 | /// Returns a users profile index based on their user id. |
| 136 | boost::optional<std::size_t> ProfileManager::GetUserIndex(const UUID& uuid) const { | 138 | std::optional<std::size_t> ProfileManager::GetUserIndex(const UUID& uuid) const { |
| 137 | if (!uuid) { | 139 | if (!uuid) { |
| 138 | return boost::none; | 140 | return {}; |
| 139 | } | 141 | } |
| 140 | auto iter = std::find_if(profiles.begin(), profiles.end(), | 142 | |
| 141 | [&uuid](const ProfileInfo& p) { return p.user_uuid == uuid; }); | 143 | const auto iter = std::find_if(profiles.begin(), profiles.end(), |
| 144 | [&uuid](const ProfileInfo& p) { return p.user_uuid == uuid; }); | ||
| 142 | if (iter == profiles.end()) { | 145 | if (iter == profiles.end()) { |
| 143 | return boost::none; | 146 | return {}; |
| 144 | } | 147 | } |
| 148 | |||
| 145 | return static_cast<std::size_t>(std::distance(profiles.begin(), iter)); | 149 | return static_cast<std::size_t>(std::distance(profiles.begin(), iter)); |
| 146 | } | 150 | } |
| 147 | 151 | ||
| 148 | /// Returns a users profile index based on their profile | 152 | /// Returns a users profile index based on their profile |
| 149 | boost::optional<std::size_t> ProfileManager::GetUserIndex(const ProfileInfo& user) const { | 153 | std::optional<std::size_t> ProfileManager::GetUserIndex(const ProfileInfo& user) const { |
| 150 | return GetUserIndex(user.user_uuid); | 154 | return GetUserIndex(user.user_uuid); |
| 151 | } | 155 | } |
| 152 | 156 | ||
| 153 | /// Returns the data structure used by the switch when GetProfileBase is called on acc:* | 157 | /// Returns the data structure used by the switch when GetProfileBase is called on acc:* |
| 154 | bool ProfileManager::GetProfileBase(boost::optional<std::size_t> index, | 158 | bool ProfileManager::GetProfileBase(std::optional<std::size_t> index, ProfileBase& profile) const { |
| 155 | ProfileBase& profile) const { | 159 | if (!index || index >= MAX_USERS) { |
| 156 | if (index == boost::none || index >= MAX_USERS) { | ||
| 157 | return false; | 160 | return false; |
| 158 | } | 161 | } |
| 159 | const auto& prof_info = profiles[index.get()]; | 162 | const auto& prof_info = profiles[*index]; |
| 160 | profile.user_uuid = prof_info.user_uuid; | 163 | profile.user_uuid = prof_info.user_uuid; |
| 161 | profile.username = prof_info.username; | 164 | profile.username = prof_info.username; |
| 162 | profile.timestamp = prof_info.creation_time; | 165 | profile.timestamp = prof_info.creation_time; |
| @@ -165,7 +168,7 @@ bool ProfileManager::GetProfileBase(boost::optional<std::size_t> index, | |||
| 165 | 168 | ||
| 166 | /// Returns the data structure used by the switch when GetProfileBase is called on acc:* | 169 | /// Returns the data structure used by the switch when GetProfileBase is called on acc:* |
| 167 | bool ProfileManager::GetProfileBase(UUID uuid, ProfileBase& profile) const { | 170 | bool ProfileManager::GetProfileBase(UUID uuid, ProfileBase& profile) const { |
| 168 | auto idx = GetUserIndex(uuid); | 171 | const auto idx = GetUserIndex(uuid); |
| 169 | return GetProfileBase(idx, profile); | 172 | return GetProfileBase(idx, profile); |
| 170 | } | 173 | } |
| 171 | 174 | ||
| @@ -192,7 +195,7 @@ std::size_t ProfileManager::GetOpenUserCount() const { | |||
| 192 | 195 | ||
| 193 | /// Checks if a user id exists in our profile manager | 196 | /// Checks if a user id exists in our profile manager |
| 194 | bool ProfileManager::UserExists(UUID uuid) const { | 197 | bool ProfileManager::UserExists(UUID uuid) const { |
| 195 | return (GetUserIndex(uuid) != boost::none); | 198 | return GetUserIndex(uuid) != std::nullopt; |
| 196 | } | 199 | } |
| 197 | 200 | ||
| 198 | bool ProfileManager::UserExistsIndex(std::size_t index) const { | 201 | bool ProfileManager::UserExistsIndex(std::size_t index) const { |
| @@ -203,21 +206,23 @@ bool ProfileManager::UserExistsIndex(std::size_t index) const { | |||
| 203 | 206 | ||
| 204 | /// Opens a specific user | 207 | /// Opens a specific user |
| 205 | void ProfileManager::OpenUser(UUID uuid) { | 208 | void ProfileManager::OpenUser(UUID uuid) { |
| 206 | auto idx = GetUserIndex(uuid); | 209 | const auto idx = GetUserIndex(uuid); |
| 207 | if (idx == boost::none) { | 210 | if (!idx) { |
| 208 | return; | 211 | return; |
| 209 | } | 212 | } |
| 210 | profiles[idx.get()].is_open = true; | 213 | |
| 214 | profiles[*idx].is_open = true; | ||
| 211 | last_opened_user = uuid; | 215 | last_opened_user = uuid; |
| 212 | } | 216 | } |
| 213 | 217 | ||
| 214 | /// Closes a specific user | 218 | /// Closes a specific user |
| 215 | void ProfileManager::CloseUser(UUID uuid) { | 219 | void ProfileManager::CloseUser(UUID uuid) { |
| 216 | auto idx = GetUserIndex(uuid); | 220 | const auto idx = GetUserIndex(uuid); |
| 217 | if (idx == boost::none) { | 221 | if (!idx) { |
| 218 | return; | 222 | return; |
| 219 | } | 223 | } |
| 220 | profiles[idx.get()].is_open = false; | 224 | |
| 225 | profiles[*idx].is_open = false; | ||
| 221 | } | 226 | } |
| 222 | 227 | ||
| 223 | /// Gets all valid user ids on the system | 228 | /// Gets all valid user ids on the system |
| @@ -247,10 +252,10 @@ UUID ProfileManager::GetLastOpenedUser() const { | |||
| 247 | } | 252 | } |
| 248 | 253 | ||
| 249 | /// Return the users profile base and the unknown arbitary data. | 254 | /// Return the users profile base and the unknown arbitary data. |
| 250 | bool ProfileManager::GetProfileBaseAndData(boost::optional<std::size_t> index, ProfileBase& profile, | 255 | bool ProfileManager::GetProfileBaseAndData(std::optional<std::size_t> index, ProfileBase& profile, |
| 251 | ProfileData& data) const { | 256 | ProfileData& data) const { |
| 252 | if (GetProfileBase(index, profile)) { | 257 | if (GetProfileBase(index, profile)) { |
| 253 | data = profiles[index.get()].data; | 258 | data = profiles[*index].data; |
| 254 | return true; | 259 | return true; |
| 255 | } | 260 | } |
| 256 | return false; | 261 | return false; |
| @@ -259,7 +264,7 @@ bool ProfileManager::GetProfileBaseAndData(boost::optional<std::size_t> index, P | |||
| 259 | /// Return the users profile base and the unknown arbitary data. | 264 | /// Return the users profile base and the unknown arbitary data. |
| 260 | bool ProfileManager::GetProfileBaseAndData(UUID uuid, ProfileBase& profile, | 265 | bool ProfileManager::GetProfileBaseAndData(UUID uuid, ProfileBase& profile, |
| 261 | ProfileData& data) const { | 266 | ProfileData& data) const { |
| 262 | auto idx = GetUserIndex(uuid); | 267 | const auto idx = GetUserIndex(uuid); |
| 263 | return GetProfileBaseAndData(idx, profile, data); | 268 | return GetProfileBaseAndData(idx, profile, data); |
| 264 | } | 269 | } |
| 265 | 270 | ||
| @@ -277,8 +282,8 @@ bool ProfileManager::CanSystemRegisterUser() const { | |||
| 277 | } | 282 | } |
| 278 | 283 | ||
| 279 | bool ProfileManager::RemoveUser(UUID uuid) { | 284 | bool ProfileManager::RemoveUser(UUID uuid) { |
| 280 | auto index = GetUserIndex(uuid); | 285 | const auto index = GetUserIndex(uuid); |
| 281 | if (index == boost::none) { | 286 | if (!index) { |
| 282 | return false; | 287 | return false; |
| 283 | } | 288 | } |
| 284 | 289 | ||
| @@ -289,8 +294,8 @@ bool ProfileManager::RemoveUser(UUID uuid) { | |||
| 289 | } | 294 | } |
| 290 | 295 | ||
| 291 | bool ProfileManager::SetProfileBase(UUID uuid, const ProfileBase& profile_new) { | 296 | bool ProfileManager::SetProfileBase(UUID uuid, const ProfileBase& profile_new) { |
| 292 | auto index = GetUserIndex(uuid); | 297 | const auto index = GetUserIndex(uuid); |
| 293 | if (profile_new.user_uuid == UUID(INVALID_UUID) || index == boost::none) { | 298 | if (!index || profile_new.user_uuid == UUID(INVALID_UUID)) { |
| 294 | return false; | 299 | return false; |
| 295 | } | 300 | } |
| 296 | 301 | ||
diff --git a/src/core/hle/service/acc/profile_manager.h b/src/core/hle/service/acc/profile_manager.h index 235208d56..1cd2e51b2 100644 --- a/src/core/hle/service/acc/profile_manager.h +++ b/src/core/hle/service/acc/profile_manager.h | |||
| @@ -5,8 +5,8 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <optional> | ||
| 8 | 9 | ||
| 9 | #include "boost/optional.hpp" | ||
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "common/swap.h" | 11 | #include "common/swap.h" |
| 12 | #include "core/hle/result.h" | 12 | #include "core/hle/result.h" |
| @@ -96,13 +96,13 @@ public: | |||
| 96 | ResultCode AddUser(const ProfileInfo& user); | 96 | ResultCode AddUser(const ProfileInfo& user); |
| 97 | ResultCode CreateNewUser(UUID uuid, const ProfileUsername& username); | 97 | ResultCode CreateNewUser(UUID uuid, const ProfileUsername& username); |
| 98 | ResultCode CreateNewUser(UUID uuid, const std::string& username); | 98 | ResultCode CreateNewUser(UUID uuid, const std::string& username); |
| 99 | boost::optional<UUID> GetUser(std::size_t index) const; | 99 | std::optional<UUID> GetUser(std::size_t index) const; |
| 100 | boost::optional<std::size_t> GetUserIndex(const UUID& uuid) const; | 100 | std::optional<std::size_t> GetUserIndex(const UUID& uuid) const; |
| 101 | boost::optional<std::size_t> GetUserIndex(const ProfileInfo& user) const; | 101 | std::optional<std::size_t> GetUserIndex(const ProfileInfo& user) const; |
| 102 | bool GetProfileBase(boost::optional<std::size_t> index, ProfileBase& profile) const; | 102 | bool GetProfileBase(std::optional<std::size_t> index, ProfileBase& profile) const; |
| 103 | bool GetProfileBase(UUID uuid, ProfileBase& profile) const; | 103 | bool GetProfileBase(UUID uuid, ProfileBase& profile) const; |
| 104 | bool GetProfileBase(const ProfileInfo& user, ProfileBase& profile) const; | 104 | bool GetProfileBase(const ProfileInfo& user, ProfileBase& profile) const; |
| 105 | bool GetProfileBaseAndData(boost::optional<std::size_t> index, ProfileBase& profile, | 105 | bool GetProfileBaseAndData(std::optional<std::size_t> index, ProfileBase& profile, |
| 106 | ProfileData& data) const; | 106 | ProfileData& data) const; |
| 107 | bool GetProfileBaseAndData(UUID uuid, ProfileBase& profile, ProfileData& data) const; | 107 | bool GetProfileBaseAndData(UUID uuid, ProfileBase& profile, ProfileData& data) const; |
| 108 | bool GetProfileBaseAndData(const ProfileInfo& user, ProfileBase& profile, | 108 | bool GetProfileBaseAndData(const ProfileInfo& user, ProfileBase& profile, |
| @@ -120,16 +120,16 @@ public: | |||
| 120 | bool CanSystemRegisterUser() const; | 120 | bool CanSystemRegisterUser() const; |
| 121 | 121 | ||
| 122 | bool RemoveUser(UUID uuid); | 122 | bool RemoveUser(UUID uuid); |
| 123 | bool SetProfileBase(UUID uuid, const ProfileBase& profile); | 123 | bool SetProfileBase(UUID uuid, const ProfileBase& profile_new); |
| 124 | 124 | ||
| 125 | private: | 125 | private: |
| 126 | void ParseUserSaveFile(); | 126 | void ParseUserSaveFile(); |
| 127 | void WriteUserSaveFile(); | 127 | void WriteUserSaveFile(); |
| 128 | std::optional<std::size_t> AddToProfiles(const ProfileInfo& profile); | ||
| 129 | bool RemoveProfileAtIndex(std::size_t index); | ||
| 128 | 130 | ||
| 129 | std::array<ProfileInfo, MAX_USERS> profiles{}; | 131 | std::array<ProfileInfo, MAX_USERS> profiles{}; |
| 130 | std::size_t user_count = 0; | 132 | std::size_t user_count = 0; |
| 131 | boost::optional<std::size_t> AddToProfiles(const ProfileInfo& profile); | ||
| 132 | bool RemoveProfileAtIndex(std::size_t index); | ||
| 133 | UUID last_opened_user{INVALID_UUID}; | 133 | UUID last_opened_user{INVALID_UUID}; |
| 134 | }; | 134 | }; |
| 135 | 135 | ||
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 4ed66d817..59aafd616 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -743,7 +743,7 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) { | |||
| 743 | 743 | ||
| 744 | Account::ProfileManager profile_manager{}; | 744 | Account::ProfileManager profile_manager{}; |
| 745 | const auto uuid = profile_manager.GetUser(Settings::values.current_user); | 745 | const auto uuid = profile_manager.GetUser(Settings::values.current_user); |
| 746 | ASSERT(uuid != boost::none); | 746 | ASSERT(uuid != std::nullopt); |
| 747 | params.current_user = uuid->uuid; | 747 | params.current_user = uuid->uuid; |
| 748 | 748 | ||
| 749 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 749 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 83cc49dfc..0bc307e99 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp | |||
| @@ -153,7 +153,7 @@ void ConfigureSystem::UpdateCurrentUser() { | |||
| 153 | ui->pm_add->setEnabled(profile_manager->GetUserCount() < Service::Account::MAX_USERS); | 153 | ui->pm_add->setEnabled(profile_manager->GetUserCount() < Service::Account::MAX_USERS); |
| 154 | 154 | ||
| 155 | const auto& current_user = profile_manager->GetUser(Settings::values.current_user); | 155 | const auto& current_user = profile_manager->GetUser(Settings::values.current_user); |
| 156 | ASSERT(current_user != boost::none); | 156 | ASSERT(current_user != std::nullopt); |
| 157 | const auto username = GetAccountUsername(*current_user); | 157 | const auto username = GetAccountUsername(*current_user); |
| 158 | 158 | ||
| 159 | scene->clear(); | 159 | scene->clear(); |
| @@ -252,7 +252,7 @@ void ConfigureSystem::AddUser() { | |||
| 252 | void ConfigureSystem::RenameUser() { | 252 | void ConfigureSystem::RenameUser() { |
| 253 | const auto user = tree_view->currentIndex().row(); | 253 | const auto user = tree_view->currentIndex().row(); |
| 254 | const auto uuid = profile_manager->GetUser(user); | 254 | const auto uuid = profile_manager->GetUser(user); |
| 255 | ASSERT(uuid != boost::none); | 255 | ASSERT(uuid != std::nullopt); |
| 256 | const auto username = GetAccountUsername(*uuid); | 256 | const auto username = GetAccountUsername(*uuid); |
| 257 | 257 | ||
| 258 | Service::Account::ProfileBase profile; | 258 | Service::Account::ProfileBase profile; |
| @@ -292,7 +292,7 @@ void ConfigureSystem::RenameUser() { | |||
| 292 | void ConfigureSystem::DeleteUser() { | 292 | void ConfigureSystem::DeleteUser() { |
| 293 | const auto index = tree_view->currentIndex().row(); | 293 | const auto index = tree_view->currentIndex().row(); |
| 294 | const auto uuid = profile_manager->GetUser(index); | 294 | const auto uuid = profile_manager->GetUser(index); |
| 295 | ASSERT(uuid != boost::none); | 295 | ASSERT(uuid != std::nullopt); |
| 296 | const auto username = GetAccountUsername(*uuid); | 296 | const auto username = GetAccountUsername(*uuid); |
| 297 | 297 | ||
| 298 | const auto confirm = | 298 | const auto confirm = |
| @@ -320,7 +320,7 @@ void ConfigureSystem::DeleteUser() { | |||
| 320 | void ConfigureSystem::SetUserImage() { | 320 | void ConfigureSystem::SetUserImage() { |
| 321 | const auto index = tree_view->currentIndex().row(); | 321 | const auto index = tree_view->currentIndex().row(); |
| 322 | const auto uuid = profile_manager->GetUser(index); | 322 | const auto uuid = profile_manager->GetUser(index); |
| 323 | ASSERT(uuid != boost::none); | 323 | ASSERT(uuid != std::nullopt); |
| 324 | const auto username = GetAccountUsername(*uuid); | 324 | const auto username = GetAccountUsername(*uuid); |
| 325 | 325 | ||
| 326 | const auto file = QFileDialog::getOpenFileName(this, tr("Select User Image"), QString(), | 326 | const auto file = QFileDialog::getOpenFileName(this, tr("Select User Image"), QString(), |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 47f494841..55508b1e1 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -785,7 +785,7 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target | |||
| 785 | ASSERT(index != -1 && index < 8); | 785 | ASSERT(index != -1 && index < 8); |
| 786 | 786 | ||
| 787 | const auto user_id = manager.GetUser(index); | 787 | const auto user_id = manager.GetUser(index); |
| 788 | ASSERT(user_id != boost::none); | 788 | ASSERT(user_id != std::nullopt); |
| 789 | path = nand_dir + FileSys::SaveDataFactory::GetFullPath(FileSys::SaveDataSpaceId::NandUser, | 789 | path = nand_dir + FileSys::SaveDataFactory::GetFullPath(FileSys::SaveDataSpaceId::NandUser, |
| 790 | FileSys::SaveDataType::SaveData, | 790 | FileSys::SaveDataType::SaveData, |
| 791 | program_id, user_id->uuid, 0); | 791 | program_id, user_id->uuid, 0); |