summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/acc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/acc/acc.cpp69
-rw-r--r--src/core/hle/service/acc/async_context.cpp71
-rw-r--r--src/core/hle/service/acc/async_context.h40
-rw-r--r--src/core/hle/service/acc/profile_manager.cpp9
4 files changed, 164 insertions, 25 deletions
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp
index 882fc1492..689b36056 100644
--- a/src/core/hle/service/acc/acc.cpp
+++ b/src/core/hle/service/acc/acc.cpp
@@ -23,6 +23,7 @@
#include "core/hle/service/acc/acc_su.h"
#include "core/hle/service/acc/acc_u0.h"
#include "core/hle/service/acc/acc_u1.h"
+#include "core/hle/service/acc/async_context.h"
#include "core/hle/service/acc/errors.h"
#include "core/hle/service/acc/profile_manager.h"
#include "core/hle/service/glue/arp.h"
@@ -454,22 +455,6 @@ public:
: IProfileCommon{system_, "IProfileEditor", true, user_id_, profile_manager_} {}
};
-class IAsyncContext final : public ServiceFramework<IAsyncContext> {
-public:
- explicit IAsyncContext(Core::System& system_) : ServiceFramework{system_, "IAsyncContext"} {
- // clang-format off
- static const FunctionInfo functions[] = {
- {0, nullptr, "GetSystemEvent"},
- {1, nullptr, "Cancel"},
- {2, nullptr, "HasDone"},
- {3, nullptr, "GetResult"},
- };
- // clang-format on
-
- RegisterHandlers(functions);
- }
-};
-
class ISessionObject final : public ServiceFramework<ISessionObject> {
public:
explicit ISessionObject(Core::System& system_, Common::UUID)
@@ -504,16 +489,44 @@ public:
}
};
+class EnsureTokenIdCacheAsyncInterface final : public IAsyncContext {
+public:
+ explicit EnsureTokenIdCacheAsyncInterface(Core::System& system_) : IAsyncContext{system_} {
+ MarkComplete();
+ }
+ ~EnsureTokenIdCacheAsyncInterface() = default;
+
+ void LoadIdTokenCache(Kernel::HLERequestContext& ctx) {
+ LOG_WARNING(Service_ACC, "(STUBBED) called");
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(ResultSuccess);
+ }
+
+protected:
+ bool IsComplete() const override {
+ return true;
+ }
+
+ void Cancel() override {}
+
+ ResultCode GetResult() const override {
+ return ResultSuccess;
+ }
+};
+
class IManagerForApplication final : public ServiceFramework<IManagerForApplication> {
public:
explicit IManagerForApplication(Core::System& system_, Common::UUID user_id_)
- : ServiceFramework{system_, "IManagerForApplication"}, user_id{user_id_} {
+ : ServiceFramework{system_, "IManagerForApplication"},
+ ensure_token_id{std::make_shared<EnsureTokenIdCacheAsyncInterface>(system)},
+ user_id{user_id_} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &IManagerForApplication::CheckAvailability, "CheckAvailability"},
{1, &IManagerForApplication::GetAccountId, "GetAccountId"},
- {2, nullptr, "EnsureIdTokenCacheAsync"},
- {3, nullptr, "LoadIdTokenCache"},
+ {2, &IManagerForApplication::EnsureIdTokenCacheAsync, "EnsureIdTokenCacheAsync"},
+ {3, &IManagerForApplication::LoadIdTokenCache, "LoadIdTokenCache"},
{130, &IManagerForApplication::GetNintendoAccountUserResourceCacheForApplication, "GetNintendoAccountUserResourceCacheForApplication"},
{150, nullptr, "CreateAuthorizationRequest"},
{160, &IManagerForApplication::StoreOpenContext, "StoreOpenContext"},
@@ -540,6 +553,20 @@ private:
rb.PushRaw<u64>(user_id.GetNintendoID());
}
+ void EnsureIdTokenCacheAsync(Kernel::HLERequestContext& ctx) {
+ LOG_WARNING(Service_ACC, "(STUBBED) called");
+
+ IPC::ResponseBuilder rb{ctx, 2, 0, 1};
+ rb.Push(ResultSuccess);
+ rb.PushIpcInterface(ensure_token_id);
+ }
+
+ void LoadIdTokenCache(Kernel::HLERequestContext& ctx) {
+ LOG_WARNING(Service_ACC, "(STUBBED) called");
+
+ ensure_token_id->LoadIdTokenCache(ctx);
+ }
+
void GetNintendoAccountUserResourceCacheForApplication(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_ACC, "(STUBBED) called");
@@ -562,6 +589,7 @@ private:
rb.Push(ResultSuccess);
}
+ std::shared_ptr<EnsureTokenIdCacheAsyncInterface> ensure_token_id{};
Common::UUID user_id{Common::INVALID_UUID};
};
@@ -901,8 +929,7 @@ void Module::Interface::TrySelectUserWithoutInteraction(Kernel::HLERequestContex
}
const auto user_list = profile_manager->GetAllUsers();
- if (std::all_of(user_list.begin(), user_list.end(),
- [](const auto& user) { return user.uuid == Common::INVALID_UUID; })) {
+ if (std::ranges::all_of(user_list, [](const auto& user) { return user.IsInvalid(); })) {
rb.Push(ResultUnknown); // TODO(ogniK): Find the correct error code
rb.PushRaw<u128>(Common::INVALID_UUID);
return;
diff --git a/src/core/hle/service/acc/async_context.cpp b/src/core/hle/service/acc/async_context.cpp
new file mode 100644
index 000000000..a49dfdec7
--- /dev/null
+++ b/src/core/hle/service/acc/async_context.cpp
@@ -0,0 +1,71 @@
+// Copyright 2021 yuzu emulator team
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include "core/core.h"
+#include "core/hle/ipc_helpers.h"
+#include "core/hle/kernel/k_event.h"
+#include "core/hle/service/acc/async_context.h"
+
+namespace Service::Account {
+IAsyncContext::IAsyncContext(Core::System& system_)
+ : ServiceFramework{system_, "IAsyncContext"}, service_context{system_, "IAsyncContext"} {
+ // clang-format off
+ static const FunctionInfo functions[] = {
+ {0, &IAsyncContext::GetSystemEvent, "GetSystemEvent"},
+ {1, &IAsyncContext::Cancel, "Cancel"},
+ {2, &IAsyncContext::HasDone, "HasDone"},
+ {3, &IAsyncContext::GetResult, "GetResult"},
+ };
+ // clang-format on
+
+ RegisterHandlers(functions);
+
+ completion_event = service_context.CreateEvent("IAsyncContext:CompletionEvent");
+}
+
+IAsyncContext::~IAsyncContext() {
+ service_context.CloseEvent(completion_event);
+}
+
+void IAsyncContext::GetSystemEvent(Kernel::HLERequestContext& ctx) {
+ LOG_DEBUG(Service_ACC, "called");
+
+ IPC::ResponseBuilder rb{ctx, 2, 1};
+ rb.Push(ResultSuccess);
+ rb.PushCopyObjects(completion_event->GetReadableEvent());
+}
+
+void IAsyncContext::Cancel(Kernel::HLERequestContext& ctx) {
+ LOG_DEBUG(Service_ACC, "called");
+
+ Cancel();
+ MarkComplete();
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(ResultSuccess);
+}
+
+void IAsyncContext::HasDone(Kernel::HLERequestContext& ctx) {
+ LOG_DEBUG(Service_ACC, "called");
+
+ is_complete.store(IsComplete());
+
+ IPC::ResponseBuilder rb{ctx, 3};
+ rb.Push(ResultSuccess);
+ rb.Push(is_complete.load());
+}
+
+void IAsyncContext::GetResult(Kernel::HLERequestContext& ctx) {
+ LOG_DEBUG(Service_ACC, "called");
+
+ IPC::ResponseBuilder rb{ctx, 3};
+ rb.Push(GetResult());
+}
+
+void IAsyncContext::MarkComplete() {
+ is_complete.store(true);
+ completion_event->GetWritableEvent().Signal();
+}
+
+} // namespace Service::Account
diff --git a/src/core/hle/service/acc/async_context.h b/src/core/hle/service/acc/async_context.h
new file mode 100644
index 000000000..cc3a0a9fe
--- /dev/null
+++ b/src/core/hle/service/acc/async_context.h
@@ -0,0 +1,40 @@
+// Copyright 2021 yuzu emulator team
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <atomic>
+#include "core/hle/service/kernel_helpers.h"
+#include "core/hle/service/service.h"
+
+namespace Core {
+class System;
+}
+
+namespace Service::Account {
+
+class IAsyncContext : public ServiceFramework<IAsyncContext> {
+public:
+ explicit IAsyncContext(Core::System& system_);
+ ~IAsyncContext() override;
+
+ void GetSystemEvent(Kernel::HLERequestContext& ctx);
+ void Cancel(Kernel::HLERequestContext& ctx);
+ void HasDone(Kernel::HLERequestContext& ctx);
+ void GetResult(Kernel::HLERequestContext& ctx);
+
+protected:
+ virtual bool IsComplete() const = 0;
+ virtual void Cancel() = 0;
+ virtual ResultCode GetResult() const = 0;
+
+ void MarkComplete();
+
+ KernelHelpers::ServiceContext service_context;
+
+ std::atomic<bool> is_complete{false};
+ Kernel::KEvent* completion_event;
+};
+
+} // namespace Service::Account
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp
index 24a1c9157..568303ced 100644
--- a/src/core/hle/service/acc/profile_manager.cpp
+++ b/src/core/hle/service/acc/profile_manager.cpp
@@ -208,9 +208,10 @@ bool ProfileManager::UserExists(UUID uuid) const {
}
bool ProfileManager::UserExistsIndex(std::size_t index) const {
- if (index >= MAX_USERS)
+ if (index >= MAX_USERS) {
return false;
- return profiles[index].user_uuid.uuid != Common::INVALID_UUID;
+ }
+ return profiles[index].user_uuid.IsValid();
}
/// Opens a specific user
@@ -304,7 +305,7 @@ bool ProfileManager::RemoveUser(UUID uuid) {
bool ProfileManager::SetProfileBase(UUID uuid, const ProfileBase& profile_new) {
const auto index = GetUserIndex(uuid);
- if (!index || profile_new.user_uuid == UUID(Common::INVALID_UUID)) {
+ if (!index || profile_new.user_uuid.IsInvalid()) {
return false;
}
@@ -346,7 +347,7 @@ void ProfileManager::ParseUserSaveFile() {
}
for (const auto& user : data.users) {
- if (user.uuid == UUID(Common::INVALID_UUID)) {
+ if (user.uuid.IsInvalid()) {
continue;
}