mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-24 04:35:50 +01:00
profile_select: Port Service::Account::UUID to Common::UUID
This commit is contained in:
parent
1aa2b99a98
commit
851c01c45e
@ -3,6 +3,7 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "core/frontend/applets/profile_select.h"
|
#include "core/frontend/applets/profile_select.h"
|
||||||
|
#include "core/hle/service/acc/profile_manager.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
|
|
||||||
namespace Core::Frontend {
|
namespace Core::Frontend {
|
||||||
@ -10,9 +11,9 @@ namespace Core::Frontend {
|
|||||||
ProfileSelectApplet::~ProfileSelectApplet() = default;
|
ProfileSelectApplet::~ProfileSelectApplet() = default;
|
||||||
|
|
||||||
void DefaultProfileSelectApplet::SelectProfile(
|
void DefaultProfileSelectApplet::SelectProfile(
|
||||||
std::function<void(std::optional<Service::Account::UUID>)> callback) const {
|
std::function<void(std::optional<Common::UUID>)> callback) const {
|
||||||
Service::Account::ProfileManager manager;
|
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...");
|
LOG_INFO(Service_ACC, "called, selecting current user instead of prompting...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include "core/hle/service/acc/profile_manager.h"
|
#include "common/uuid.h"
|
||||||
|
|
||||||
namespace Core::Frontend {
|
namespace Core::Frontend {
|
||||||
|
|
||||||
@ -14,14 +14,12 @@ class ProfileSelectApplet {
|
|||||||
public:
|
public:
|
||||||
virtual ~ProfileSelectApplet();
|
virtual ~ProfileSelectApplet();
|
||||||
|
|
||||||
virtual void SelectProfile(
|
virtual void SelectProfile(std::function<void(std::optional<Common::UUID>)> callback) const = 0;
|
||||||
std::function<void(std::optional<Service::Account::UUID>)> callback) const = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DefaultProfileSelectApplet final : public ProfileSelectApplet {
|
class DefaultProfileSelectApplet final : public ProfileSelectApplet {
|
||||||
public:
|
public:
|
||||||
void SelectProfile(
|
void SelectProfile(std::function<void(std::optional<Common::UUID>)> callback) const override;
|
||||||
std::function<void(std::optional<Service::Account::UUID>)> callback) const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core::Frontend
|
} // namespace Core::Frontend
|
||||||
|
@ -56,16 +56,16 @@ void ProfileSelect::Execute() {
|
|||||||
frontend.SelectProfile([this](std::optional<Account::UUID> uuid) { SelectionComplete(uuid); });
|
frontend.SelectProfile([this](std::optional<Account::UUID> uuid) { SelectionComplete(uuid); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileSelect::SelectionComplete(std::optional<Account::UUID> uuid) {
|
void ProfileSelect::SelectionComplete(std::optional<Common::UUID> uuid) {
|
||||||
UserSelectionOutput output{};
|
UserSelectionOutput output{};
|
||||||
|
|
||||||
if (uuid.has_value() && uuid->uuid != Account::INVALID_UUID) {
|
if (uuid.has_value() && uuid->uuid != Common::INVALID_UUID) {
|
||||||
output.result = 0;
|
output.result = 0;
|
||||||
output.uuid_selected = uuid->uuid;
|
output.uuid_selected = uuid->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 = Account::INVALID_UUID;
|
output.uuid_selected = Common::INVALID_UUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 "core/hle/service/acc/profile_manager.h"
|
#include "common/uuid.h"
|
||||||
#include "core/hle/service/am/applets/applets.h"
|
#include "core/hle/service/am/applets/applets.h"
|
||||||
|
|
||||||
namespace Service::AM::Applets {
|
namespace Service::AM::Applets {
|
||||||
@ -38,7 +38,7 @@ public:
|
|||||||
void ExecuteInteractive() override;
|
void ExecuteInteractive() override;
|
||||||
void Execute() override;
|
void Execute() override;
|
||||||
|
|
||||||
void SelectionComplete(std::optional<Account::UUID> uuid);
|
void SelectionComplete(std::optional<Common::UUID> uuid);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Core::Frontend::ProfileSelectApplet& frontend;
|
const Core::Frontend::ProfileSelectApplet& frontend;
|
||||||
|
@ -174,7 +174,7 @@ MiiStoreData ConvertInfoToStoreData(const MiiInfo& info) {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& os,Source source) {
|
std::ostream& operator<<(std::ostream& os, Source source) {
|
||||||
os << SOURCE_NAMES.at(static_cast<std::size_t>(source));
|
os << SOURCE_NAMES.at(static_cast<std::size_t>(source));
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
@ -27,20 +27,20 @@ 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 FormatUserEntryText(const QString& username, Service::Account::UUID uuid) {
|
QString FormatUserEntryText(const QString& username, Common::UUID 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.FormatSwitch()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GetImagePath(Service::Account::UUID uuid) {
|
QString GetImagePath(Common::UUID uuid) {
|
||||||
const auto path = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) +
|
const auto path = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) +
|
||||||
"/system/save/8000000000000010/su/avators/" + uuid.FormatSwitch() + ".jpg";
|
"/system/save/8000000000000010/su/avators/" + uuid.FormatSwitch() + ".jpg";
|
||||||
return QString::fromStdString(path);
|
return QString::fromStdString(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap GetIcon(Service::Account::UUID uuid) {
|
QPixmap GetIcon(Common::UUID uuid) {
|
||||||
QPixmap icon{GetImagePath(uuid)};
|
QPixmap icon{GetImagePath(uuid)};
|
||||||
|
|
||||||
if (!icon) {
|
if (!icon) {
|
||||||
@ -154,12 +154,12 @@ QtProfileSelector::QtProfileSelector(GMainWindow& parent) {
|
|||||||
QtProfileSelector::~QtProfileSelector() = default;
|
QtProfileSelector::~QtProfileSelector() = default;
|
||||||
|
|
||||||
void QtProfileSelector::SelectProfile(
|
void QtProfileSelector::SelectProfile(
|
||||||
std::function<void(std::optional<Service::Account::UUID>)> callback) const {
|
std::function<void(std::optional<Common::UUID>)> callback) const {
|
||||||
this->callback = std::move(callback);
|
this->callback = std::move(callback);
|
||||||
emit MainWindowSelectProfile();
|
emit MainWindowSelectProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtProfileSelector::MainWindowFinishedSelection(std::optional<Service::Account::UUID> uuid) {
|
void QtProfileSelector::MainWindowFinishedSelection(std::optional<Common::UUID> uuid) {
|
||||||
// Acquire the HLE mutex
|
// Acquire the HLE mutex
|
||||||
std::lock_guard lock{HLE::g_hle_lock};
|
std::lock_guard lock{HLE::g_hle_lock};
|
||||||
callback(uuid);
|
callback(uuid);
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include "core/frontend/applets/profile_select.h"
|
#include "core/frontend/applets/profile_select.h"
|
||||||
|
#include "core/hle/service/acc/profile_manager.h"
|
||||||
|
|
||||||
class GMainWindow;
|
class GMainWindow;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
@ -60,14 +61,13 @@ public:
|
|||||||
explicit QtProfileSelector(GMainWindow& parent);
|
explicit QtProfileSelector(GMainWindow& parent);
|
||||||
~QtProfileSelector() override;
|
~QtProfileSelector() override;
|
||||||
|
|
||||||
void SelectProfile(
|
void SelectProfile(std::function<void(std::optional<Common::UUID>)> callback) const override;
|
||||||
std::function<void(std::optional<Service::Account::UUID>)> callback) const override;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void MainWindowSelectProfile() const;
|
void MainWindowSelectProfile() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void MainWindowFinishedSelection(std::optional<Service::Account::UUID> uuid);
|
void MainWindowFinishedSelection(std::optional<Common::UUID> uuid);
|
||||||
|
|
||||||
mutable std::function<void(std::optional<Service::Account::UUID>)> callback;
|
mutable std::function<void(std::optional<Common::UUID>)> callback;
|
||||||
};
|
};
|
||||||
|
@ -33,14 +33,13 @@ 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(Service::Account::UUID uuid) {
|
QString GetImagePath(Common::UUID uuid) {
|
||||||
const auto path = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) +
|
const auto path = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) +
|
||||||
"/system/save/8000000000000010/su/avators/" + uuid.FormatSwitch() + ".jpg";
|
"/system/save/8000000000000010/su/avators/" + uuid.FormatSwitch() + ".jpg";
|
||||||
return QString::fromStdString(path);
|
return QString::fromStdString(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GetAccountUsername(const Service::Account::ProfileManager& manager,
|
QString GetAccountUsername(const Service::Account::ProfileManager& manager, Common::UUID uuid) {
|
||||||
Service::Account::UUID uuid) {
|
|
||||||
Service::Account::ProfileBase profile;
|
Service::Account::ProfileBase profile;
|
||||||
if (!manager.GetProfileBase(uuid, profile)) {
|
if (!manager.GetProfileBase(uuid, profile)) {
|
||||||
return {};
|
return {};
|
||||||
@ -51,14 +50,14 @@ QString GetAccountUsername(const Service::Account::ProfileManager& manager,
|
|||||||
return QString::fromStdString(text);
|
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",
|
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.FormatSwitch()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap GetIcon(Service::Account::UUID uuid) {
|
QPixmap GetIcon(Common::UUID uuid) {
|
||||||
QPixmap icon{GetImagePath(uuid)};
|
QPixmap icon{GetImagePath(uuid)};
|
||||||
|
|
||||||
if (!icon) {
|
if (!icon) {
|
||||||
@ -190,7 +189,7 @@ void ConfigureProfileManager::AddUser() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto uuid = Service::Account::UUID::Generate();
|
const auto uuid = Common::UUID::Generate();
|
||||||
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)});
|
||||||
|
@ -104,7 +104,7 @@ signals:
|
|||||||
|
|
||||||
void ErrorDisplayFinished();
|
void ErrorDisplayFinished();
|
||||||
|
|
||||||
void ProfileSelectorFinishedSelection(std::optional<Service::Account::UUID> uuid);
|
void ProfileSelectorFinishedSelection(std::optional<Common::UUID> uuid);
|
||||||
void SoftwareKeyboardFinishedText(std::optional<std::u16string> text);
|
void SoftwareKeyboardFinishedText(std::optional<std::u16string> text);
|
||||||
void SoftwareKeyboardFinishedCheckDialog();
|
void SoftwareKeyboardFinishedCheckDialog();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user