From 851c01c45eac863359869ab82eea976cc365104d Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Thu, 10 Jan 2019 21:53:07 -0500 Subject: [PATCH] profile_select: Port Service::Account::UUID to Common::UUID --- src/core/frontend/applets/profile_select.cpp | 5 +++-- src/core/frontend/applets/profile_select.h | 8 +++----- src/core/hle/service/am/applets/profile_select.cpp | 6 +++--- src/core/hle/service/am/applets/profile_select.h | 4 ++-- src/core/hle/service/mii/mii_manager.cpp | 2 +- src/yuzu/applets/profile_select.cpp | 10 +++++----- src/yuzu/applets/profile_select.h | 8 ++++---- src/yuzu/configuration/configure_profile_manager.cpp | 11 +++++------ src/yuzu/main.h | 2 +- 9 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/core/frontend/applets/profile_select.cpp b/src/core/frontend/applets/profile_select.cpp index fbf5f2a9e..4df3574d2 100644 --- a/src/core/frontend/applets/profile_select.cpp +++ b/src/core/frontend/applets/profile_select.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include "core/frontend/applets/profile_select.h" +#include "core/hle/service/acc/profile_manager.h" #include "core/settings.h" namespace Core::Frontend { @@ -10,9 +11,9 @@ namespace Core::Frontend { ProfileSelectApplet::~ProfileSelectApplet() = default; void DefaultProfileSelectApplet::SelectProfile( - std::function)> callback) const { + std::function)> callback) const { Service::Account::ProfileManager manager; - callback(manager.GetUser(Settings::values.current_user).value_or(Service::Account::UUID{})); + callback(manager.GetUser(Settings::values.current_user).value_or(Common::UUID{})); LOG_INFO(Service_ACC, "called, selecting current user instead of prompting..."); } diff --git a/src/core/frontend/applets/profile_select.h b/src/core/frontend/applets/profile_select.h index fc8f7ae94..3506b9885 100644 --- a/src/core/frontend/applets/profile_select.h +++ b/src/core/frontend/applets/profile_select.h @@ -6,7 +6,7 @@ #include #include -#include "core/hle/service/acc/profile_manager.h" +#include "common/uuid.h" namespace Core::Frontend { @@ -14,14 +14,12 @@ class ProfileSelectApplet { public: virtual ~ProfileSelectApplet(); - virtual void SelectProfile( - std::function)> callback) const = 0; + virtual void SelectProfile(std::function)> callback) const = 0; }; class DefaultProfileSelectApplet final : public ProfileSelectApplet { public: - void SelectProfile( - std::function)> callback) const override; + void SelectProfile(std::function)> callback) const override; }; } // namespace Core::Frontend diff --git a/src/core/hle/service/am/applets/profile_select.cpp b/src/core/hle/service/am/applets/profile_select.cpp index d113bd2eb..3c184859d 100644 --- a/src/core/hle/service/am/applets/profile_select.cpp +++ b/src/core/hle/service/am/applets/profile_select.cpp @@ -56,16 +56,16 @@ void ProfileSelect::Execute() { frontend.SelectProfile([this](std::optional uuid) { SelectionComplete(uuid); }); } -void ProfileSelect::SelectionComplete(std::optional uuid) { +void ProfileSelect::SelectionComplete(std::optional uuid) { UserSelectionOutput output{}; - if (uuid.has_value() && uuid->uuid != Account::INVALID_UUID) { + if (uuid.has_value() && uuid->uuid != Common::INVALID_UUID) { output.result = 0; output.uuid_selected = uuid->uuid; } else { status = ERR_USER_CANCELLED_SELECTION; output.result = ERR_USER_CANCELLED_SELECTION.raw; - output.uuid_selected = Account::INVALID_UUID; + output.uuid_selected = Common::INVALID_UUID; } final_data = std::vector(sizeof(UserSelectionOutput)); diff --git a/src/core/hle/service/am/applets/profile_select.h b/src/core/hle/service/am/applets/profile_select.h index a2ac6cf50..f99630158 100644 --- a/src/core/hle/service/am/applets/profile_select.h +++ b/src/core/hle/service/am/applets/profile_select.h @@ -7,7 +7,7 @@ #include #include "common/common_funcs.h" -#include "core/hle/service/acc/profile_manager.h" +#include "common/uuid.h" #include "core/hle/service/am/applets/applets.h" namespace Service::AM::Applets { @@ -38,7 +38,7 @@ public: void ExecuteInteractive() override; void Execute() override; - void SelectionComplete(std::optional uuid); + void SelectionComplete(std::optional uuid); private: const Core::Frontend::ProfileSelectApplet& frontend; diff --git a/src/core/hle/service/mii/mii_manager.cpp b/src/core/hle/service/mii/mii_manager.cpp index 04fc2180b..a526e4440 100644 --- a/src/core/hle/service/mii/mii_manager.cpp +++ b/src/core/hle/service/mii/mii_manager.cpp @@ -174,7 +174,7 @@ MiiStoreData ConvertInfoToStoreData(const MiiInfo& info) { } // namespace -std::ostream& operator<<(std::ostream& os,Source source) { +std::ostream& operator<<(std::ostream& os, Source source) { os << SOURCE_NAMES.at(static_cast(source)); return os; } diff --git a/src/yuzu/applets/profile_select.cpp b/src/yuzu/applets/profile_select.cpp index 743b24d76..812b0142f 100644 --- a/src/yuzu/applets/profile_select.cpp +++ b/src/yuzu/applets/profile_select.cpp @@ -27,20 +27,20 @@ constexpr std::array backup_jpeg{ 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9, }; -QString FormatUserEntryText(const QString& username, Service::Account::UUID uuid) { +QString FormatUserEntryText(const QString& username, Common::UUID uuid) { return QtProfileSelectionDialog::tr( "%1\n%2", "%1 is the profile username, %2 is the formatted UUID (e.g. " "00112233-4455-6677-8899-AABBCCDDEEFF))") .arg(username, QString::fromStdString(uuid.FormatSwitch())); } -QString GetImagePath(Service::Account::UUID uuid) { +QString GetImagePath(Common::UUID uuid) { const auto path = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + "/system/save/8000000000000010/su/avators/" + uuid.FormatSwitch() + ".jpg"; return QString::fromStdString(path); } -QPixmap GetIcon(Service::Account::UUID uuid) { +QPixmap GetIcon(Common::UUID uuid) { QPixmap icon{GetImagePath(uuid)}; if (!icon) { @@ -154,12 +154,12 @@ QtProfileSelector::QtProfileSelector(GMainWindow& parent) { QtProfileSelector::~QtProfileSelector() = default; void QtProfileSelector::SelectProfile( - std::function)> callback) const { + std::function)> callback) const { this->callback = std::move(callback); emit MainWindowSelectProfile(); } -void QtProfileSelector::MainWindowFinishedSelection(std::optional uuid) { +void QtProfileSelector::MainWindowFinishedSelection(std::optional uuid) { // Acquire the HLE mutex std::lock_guard lock{HLE::g_hle_lock}; callback(uuid); diff --git a/src/yuzu/applets/profile_select.h b/src/yuzu/applets/profile_select.h index 1c2922e54..c5b90a78e 100644 --- a/src/yuzu/applets/profile_select.h +++ b/src/yuzu/applets/profile_select.h @@ -9,6 +9,7 @@ #include #include #include "core/frontend/applets/profile_select.h" +#include "core/hle/service/acc/profile_manager.h" class GMainWindow; class QDialogButtonBox; @@ -60,14 +61,13 @@ public: explicit QtProfileSelector(GMainWindow& parent); ~QtProfileSelector() override; - void SelectProfile( - std::function)> callback) const override; + void SelectProfile(std::function)> callback) const override; signals: void MainWindowSelectProfile() const; private: - void MainWindowFinishedSelection(std::optional uuid); + void MainWindowFinishedSelection(std::optional uuid); - mutable std::function)> callback; + mutable std::function)> callback; }; diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp index 41663e39a..10f8ba041 100644 --- a/src/yuzu/configuration/configure_profile_manager.cpp +++ b/src/yuzu/configuration/configure_profile_manager.cpp @@ -33,14 +33,13 @@ constexpr std::array backup_jpeg{ 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9, }; -QString GetImagePath(Service::Account::UUID uuid) { +QString GetImagePath(Common::UUID uuid) { const auto path = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + "/system/save/8000000000000010/su/avators/" + uuid.FormatSwitch() + ".jpg"; return QString::fromStdString(path); } -QString GetAccountUsername(const Service::Account::ProfileManager& manager, - Service::Account::UUID uuid) { +QString GetAccountUsername(const Service::Account::ProfileManager& manager, Common::UUID uuid) { Service::Account::ProfileBase profile; if (!manager.GetProfileBase(uuid, profile)) { return {}; @@ -51,14 +50,14 @@ QString GetAccountUsername(const Service::Account::ProfileManager& manager, return QString::fromStdString(text); } -QString FormatUserEntryText(const QString& username, Service::Account::UUID uuid) { +QString FormatUserEntryText(const QString& username, Common::UUID uuid) { return ConfigureProfileManager::tr("%1\n%2", "%1 is the profile username, %2 is the formatted UUID (e.g. " "00112233-4455-6677-8899-AABBCCDDEEFF))") .arg(username, QString::fromStdString(uuid.FormatSwitch())); } -QPixmap GetIcon(Service::Account::UUID uuid) { +QPixmap GetIcon(Common::UUID uuid) { QPixmap icon{GetImagePath(uuid)}; if (!icon) { @@ -190,7 +189,7 @@ void ConfigureProfileManager::AddUser() { return; } - const auto uuid = Service::Account::UUID::Generate(); + const auto uuid = Common::UUID::Generate(); profile_manager->CreateNewUser(uuid, username.toStdString()); item_model->appendRow(new QStandardItem{GetIcon(uuid), FormatUserEntryText(username, uuid)}); diff --git a/src/yuzu/main.h b/src/yuzu/main.h index fb2a193cb..c4566ed2c 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -104,7 +104,7 @@ signals: void ErrorDisplayFinished(); - void ProfileSelectorFinishedSelection(std::optional uuid); + void ProfileSelectorFinishedSelection(std::optional uuid); void SoftwareKeyboardFinishedText(std::optional text); void SoftwareKeyboardFinishedCheckDialog();