summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chloe Marcec2021-09-06 21:16:21 +1000
committerGravatar Chloe Marcec2021-09-06 21:16:21 +1000
commit4e2aa50cefd56f4bb119c9c6e6ab89afbb31351e (patch)
tree0962f803f2826a1d6e3ae573309f4a84bd897950
parentMerge pull request #6968 from bunnei/nvflinger-event (diff)
downloadyuzu-4e2aa50cefd56f4bb119c9c6e6ab89afbb31351e.tar.gz
yuzu-4e2aa50cefd56f4bb119c9c6e6ab89afbb31351e.tar.xz
yuzu-4e2aa50cefd56f4bb119c9c6e6ab89afbb31351e.zip
account: EnsureTokenIdCacheAsync
Closes #2547, #6946
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/hle/service/acc/acc.cpp67
-rw-r--r--src/core/hle/service/acc/async_context.cpp68
-rw-r--r--src/core/hle/service/acc/async_context.h36
4 files changed, 154 insertions, 19 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 87d47e2e5..7140d0db8 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -263,6 +263,8 @@ add_library(core STATIC
263 hle/service/acc/acc_u0.h 263 hle/service/acc/acc_u0.h
264 hle/service/acc/acc_u1.cpp 264 hle/service/acc/acc_u1.cpp
265 hle/service/acc/acc_u1.h 265 hle/service/acc/acc_u1.h
266 hle/service/acc/async_context.cpp
267 hle/service/acc/async_context.h
266 hle/service/acc/errors.h 268 hle/service/acc/errors.h
267 hle/service/acc/profile_manager.cpp 269 hle/service/acc/profile_manager.cpp
268 hle/service/acc/profile_manager.h 270 hle/service/acc/profile_manager.h
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp
index 882fc1492..1db054257 100644
--- a/src/core/hle/service/acc/acc.cpp
+++ b/src/core/hle/service/acc/acc.cpp
@@ -23,6 +23,7 @@
23#include "core/hle/service/acc/acc_su.h" 23#include "core/hle/service/acc/acc_su.h"
24#include "core/hle/service/acc/acc_u0.h" 24#include "core/hle/service/acc/acc_u0.h"
25#include "core/hle/service/acc/acc_u1.h" 25#include "core/hle/service/acc/acc_u1.h"
26#include "core/hle/service/acc/async_context.h"
26#include "core/hle/service/acc/errors.h" 27#include "core/hle/service/acc/errors.h"
27#include "core/hle/service/acc/profile_manager.h" 28#include "core/hle/service/acc/profile_manager.h"
28#include "core/hle/service/glue/arp.h" 29#include "core/hle/service/glue/arp.h"
@@ -454,22 +455,6 @@ public:
454 : IProfileCommon{system_, "IProfileEditor", true, user_id_, profile_manager_} {} 455 : IProfileCommon{system_, "IProfileEditor", true, user_id_, profile_manager_} {}
455}; 456};
456 457
457class IAsyncContext final : public ServiceFramework<IAsyncContext> {
458public:
459 explicit IAsyncContext(Core::System& system_) : ServiceFramework{system_, "IAsyncContext"} {
460 // clang-format off
461 static const FunctionInfo functions[] = {
462 {0, nullptr, "GetSystemEvent"},
463 {1, nullptr, "Cancel"},
464 {2, nullptr, "HasDone"},
465 {3, nullptr, "GetResult"},
466 };
467 // clang-format on
468
469 RegisterHandlers(functions);
470 }
471};
472
473class ISessionObject final : public ServiceFramework<ISessionObject> { 458class ISessionObject final : public ServiceFramework<ISessionObject> {
474public: 459public:
475 explicit ISessionObject(Core::System& system_, Common::UUID) 460 explicit ISessionObject(Core::System& system_, Common::UUID)
@@ -504,16 +489,42 @@ public:
504 } 489 }
505}; 490};
506 491
492class EnsureTokenIdCacheAsyncInterface final : public IAsyncContext {
493public:
494 explicit EnsureTokenIdCacheAsyncInterface(Core::System& system_) : IAsyncContext(system_) {
495 MarkComplete();
496 }
497 ~EnsureTokenIdCacheAsyncInterface() = default;
498
499 void LoadIdTokenCache(Kernel::HLERequestContext& ctx) {
500 LOG_WARNING(Service_ACC, "(STUBBED) called");
501
502 IPC::ResponseBuilder rb{ctx, 2};
503 rb.Push(ResultSuccess);
504 }
505
506protected:
507 bool IsComplete() override {
508 return true;
509 }
510
511 void Cancel() override {}
512
513 ResultCode GetResult() override {
514 return ResultSuccess;
515 }
516};
517
507class IManagerForApplication final : public ServiceFramework<IManagerForApplication> { 518class IManagerForApplication final : public ServiceFramework<IManagerForApplication> {
508public: 519public:
509 explicit IManagerForApplication(Core::System& system_, Common::UUID user_id_) 520 explicit IManagerForApplication(Core::System& system_, Common::UUID user_id_)
510 : ServiceFramework{system_, "IManagerForApplication"}, user_id{user_id_} { 521 : ServiceFramework{system_, "IManagerForApplication"}, user_id{user_id_}, system(system_) {
511 // clang-format off 522 // clang-format off
512 static const FunctionInfo functions[] = { 523 static const FunctionInfo functions[] = {
513 {0, &IManagerForApplication::CheckAvailability, "CheckAvailability"}, 524 {0, &IManagerForApplication::CheckAvailability, "CheckAvailability"},
514 {1, &IManagerForApplication::GetAccountId, "GetAccountId"}, 525 {1, &IManagerForApplication::GetAccountId, "GetAccountId"},
515 {2, nullptr, "EnsureIdTokenCacheAsync"}, 526 {2, &IManagerForApplication::EnsureIdTokenCacheAsync, "EnsureIdTokenCacheAsync"},
516 {3, nullptr, "LoadIdTokenCache"}, 527 {3, &IManagerForApplication::LoadIdTokenCache, "LoadIdTokenCache"},
517 {130, &IManagerForApplication::GetNintendoAccountUserResourceCacheForApplication, "GetNintendoAccountUserResourceCacheForApplication"}, 528 {130, &IManagerForApplication::GetNintendoAccountUserResourceCacheForApplication, "GetNintendoAccountUserResourceCacheForApplication"},
518 {150, nullptr, "CreateAuthorizationRequest"}, 529 {150, nullptr, "CreateAuthorizationRequest"},
519 {160, &IManagerForApplication::StoreOpenContext, "StoreOpenContext"}, 530 {160, &IManagerForApplication::StoreOpenContext, "StoreOpenContext"},
@@ -522,6 +533,8 @@ public:
522 // clang-format on 533 // clang-format on
523 534
524 RegisterHandlers(functions); 535 RegisterHandlers(functions);
536
537 ensure_token_id = std::make_shared<EnsureTokenIdCacheAsyncInterface>(system);
525 } 538 }
526 539
527private: 540private:
@@ -540,6 +553,20 @@ private:
540 rb.PushRaw<u64>(user_id.GetNintendoID()); 553 rb.PushRaw<u64>(user_id.GetNintendoID());
541 } 554 }
542 555
556 void EnsureIdTokenCacheAsync(Kernel::HLERequestContext& ctx) {
557 LOG_WARNING(Service_ACC, "(STUBBED) called");
558
559 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
560 rb.Push(ResultSuccess);
561 rb.PushIpcInterface(ensure_token_id);
562 }
563
564 void LoadIdTokenCache(Kernel::HLERequestContext& ctx) {
565 LOG_WARNING(Service_ACC, "(STUBBED) called");
566
567 ensure_token_id->LoadIdTokenCache(ctx);
568 }
569
543 void GetNintendoAccountUserResourceCacheForApplication(Kernel::HLERequestContext& ctx) { 570 void GetNintendoAccountUserResourceCacheForApplication(Kernel::HLERequestContext& ctx) {
544 LOG_WARNING(Service_ACC, "(STUBBED) called"); 571 LOG_WARNING(Service_ACC, "(STUBBED) called");
545 572
@@ -562,7 +589,9 @@ private:
562 rb.Push(ResultSuccess); 589 rb.Push(ResultSuccess);
563 } 590 }
564 591
592 std::shared_ptr<EnsureTokenIdCacheAsyncInterface> ensure_token_id{};
565 Common::UUID user_id{Common::INVALID_UUID}; 593 Common::UUID user_id{Common::INVALID_UUID};
594 Core::System& system;
566}; 595};
567 596
568// 6.0.0+ 597// 6.0.0+
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..a58429090
--- /dev/null
+++ b/src/core/hle/service/acc/async_context.cpp
@@ -0,0 +1,68 @@
1// Copyright 2021 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "core/core.h"
6#include "core/hle/ipc_helpers.h"
7#include "core/hle/service/acc/async_context.h"
8
9namespace Service::Account {
10IAsyncContext::IAsyncContext(Core::System& system)
11 : ServiceFramework{system, "IAsyncContext"}, compeletion_event{system.Kernel()} {
12
13 Kernel::KAutoObject::Create(std::addressof(compeletion_event));
14 compeletion_event.Initialize("IAsyncContext:CompletionEvent");
15
16 // clang-format off
17 static const FunctionInfo functions[] = {
18 {0, &IAsyncContext::GetSystemEvent, "GetSystemEvent"},
19 {1, &IAsyncContext::Cancel, "Cancel"},
20 {2, &IAsyncContext::HasDone, "HasDone"},
21 {3, &IAsyncContext::GetResult, "GetResult"},
22 };
23 // clang-format on
24
25 RegisterHandlers(functions);
26}
27
28void IAsyncContext::GetSystemEvent(Kernel::HLERequestContext& ctx) {
29 LOG_DEBUG(Service_ACC, "called");
30
31 IPC::ResponseBuilder rb{ctx, 2, 1};
32 rb.Push(ResultSuccess);
33 rb.PushCopyObjects(compeletion_event.GetReadableEvent());
34}
35
36void IAsyncContext::Cancel(Kernel::HLERequestContext& ctx) {
37 LOG_DEBUG(Service_ACC, "called");
38
39 Cancel();
40 MarkComplete();
41
42 IPC::ResponseBuilder rb{ctx, 2};
43 rb.Push(ResultSuccess);
44}
45
46void IAsyncContext::HasDone(Kernel::HLERequestContext& ctx) {
47 LOG_DEBUG(Service_ACC, "called");
48
49 is_complete = IsComplete();
50
51 IPC::ResponseBuilder rb{ctx, 3};
52 rb.Push(ResultSuccess);
53 rb.Push(is_complete);
54}
55
56void IAsyncContext::GetResult(Kernel::HLERequestContext& ctx) {
57 LOG_DEBUG(Service_ACC, "called");
58
59 IPC::ResponseBuilder rb{ctx, 3};
60 rb.Push(GetResult());
61}
62
63void IAsyncContext::MarkComplete() {
64 is_complete = true;
65 compeletion_event.GetWritableEvent().Signal();
66}
67
68} // 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..2453a79f5
--- /dev/null
+++ b/src/core/hle/service/acc/async_context.h
@@ -0,0 +1,36 @@
1// Copyright 2021 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "core/hle/kernel/k_event.h"
8#include "core/hle/service/service.h"
9
10namespace Core {
11class System;
12}
13
14namespace Service::Account {
15
16class IAsyncContext : public ServiceFramework<IAsyncContext> {
17public:
18 explicit IAsyncContext(Core::System& system_);
19
20 void GetSystemEvent(Kernel::HLERequestContext& ctx);
21 void Cancel(Kernel::HLERequestContext& ctx);
22 void HasDone(Kernel::HLERequestContext& ctx);
23 void GetResult(Kernel::HLERequestContext& ctx);
24
25protected:
26 virtual bool IsComplete() = 0;
27 virtual void Cancel() = 0;
28 virtual ResultCode GetResult() = 0;
29
30 void MarkComplete();
31
32 bool is_complete{false};
33 Kernel::KEvent compeletion_event;
34};
35
36} // namespace Service::Account