From 702622b8f1eaa1b297a27a305ac56faeadf542d7 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Wed, 10 Oct 2018 21:49:20 -0400 Subject: profile_manager: Load user icons, names, and UUIDs from system save --- src/core/hle/service/acc/acc.cpp | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'src/core/hle/service/acc/acc.cpp') diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 0149ea8b3..cee309cb1 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include #include #include "common/common_paths.h" #include "common/common_types.h" @@ -33,9 +34,9 @@ struct UserData { }; static_assert(sizeof(UserData) == 0x80, "UserData structure has incorrect size"); -static std::string GetImagePath(const std::string& username) { - return FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "users" + DIR_SEP + username + - ".jpg"; +static std::string GetImagePath(UUID uuid) { + return FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + + "/system/save/8000000000000010/su/avators/" + uuid.FormatSwitch() + ".jpg"; } class IProfile final : public ServiceFramework { @@ -49,15 +50,6 @@ public: {11, &IProfile::LoadImage, "LoadImage"}, }; RegisterHandlers(functions); - - ProfileBase profile_base{}; - if (profile_manager.GetProfileBase(user_id, profile_base)) { - image = std::make_unique( - GetImagePath(Common::StringFromFixedZeroTerminatedBuffer( - reinterpret_cast(profile_base.username.data()), - profile_base.username.size())), - "rb"); - } } private: @@ -111,13 +103,15 @@ private: IPC::ResponseBuilder rb{ctx, 3}; rb.Push(RESULT_SUCCESS); - if (image == nullptr) { + const FileUtil::IOFile image(GetImagePath(user_id), "rb"); + + if (!image.IsOpen()) { ctx.WriteBuffer(backup_jpeg); rb.Push(backup_jpeg_size); } else { - const auto size = std::min(image->GetSize(), MAX_JPEG_IMAGE_SIZE); + const auto size = std::min(image.GetSize(), MAX_JPEG_IMAGE_SIZE); std::vector buffer(size); - image->ReadBytes(buffer.data(), buffer.size()); + image.ReadBytes(buffer.data(), buffer.size()); ctx.WriteBuffer(buffer.data(), buffer.size()); rb.Push(buffer.size()); @@ -130,15 +124,16 @@ private: IPC::ResponseBuilder rb{ctx, 3}; rb.Push(RESULT_SUCCESS); - if (image == nullptr) + const FileUtil::IOFile image(GetImagePath(user_id), "rb"); + + if (!image.IsOpen()) rb.Push(backup_jpeg_size); else - rb.Push(std::min(image->GetSize(), MAX_JPEG_IMAGE_SIZE)); + rb.Push(std::min(image.GetSize(), MAX_JPEG_IMAGE_SIZE)); } const ProfileManager& profile_manager; UUID user_id; ///< The user id this profile refers to. - std::unique_ptr image = nullptr; }; class IManagerForApplication final : public ServiceFramework { -- cgit v1.2.3