diff options
| author | 2021-09-06 21:16:21 +1000 | |
|---|---|---|
| committer | 2021-09-06 21:16:21 +1000 | |
| commit | 4e2aa50cefd56f4bb119c9c6e6ab89afbb31351e (patch) | |
| tree | 0962f803f2826a1d6e3ae573309f4a84bd897950 /src/core/hle/service/acc | |
| parent | Merge pull request #6968 from bunnei/nvflinger-event (diff) | |
| download | yuzu-4e2aa50cefd56f4bb119c9c6e6ab89afbb31351e.tar.gz yuzu-4e2aa50cefd56f4bb119c9c6e6ab89afbb31351e.tar.xz yuzu-4e2aa50cefd56f4bb119c9c6e6ab89afbb31351e.zip | |
account: EnsureTokenIdCacheAsync
Closes #2547, #6946
Diffstat (limited to 'src/core/hle/service/acc')
| -rw-r--r-- | src/core/hle/service/acc/acc.cpp | 67 | ||||
| -rw-r--r-- | src/core/hle/service/acc/async_context.cpp | 68 | ||||
| -rw-r--r-- | src/core/hle/service/acc/async_context.h | 36 |
3 files changed, 152 insertions, 19 deletions
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 | ||
| 457 | class IAsyncContext final : public ServiceFramework<IAsyncContext> { | ||
| 458 | public: | ||
| 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 | |||
| 473 | class ISessionObject final : public ServiceFramework<ISessionObject> { | 458 | class ISessionObject final : public ServiceFramework<ISessionObject> { |
| 474 | public: | 459 | public: |
| 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 | ||
| 492 | class EnsureTokenIdCacheAsyncInterface final : public IAsyncContext { | ||
| 493 | public: | ||
| 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 | |||
| 506 | protected: | ||
| 507 | bool IsComplete() override { | ||
| 508 | return true; | ||
| 509 | } | ||
| 510 | |||
| 511 | void Cancel() override {} | ||
| 512 | |||
| 513 | ResultCode GetResult() override { | ||
| 514 | return ResultSuccess; | ||
| 515 | } | ||
| 516 | }; | ||
| 517 | |||
| 507 | class IManagerForApplication final : public ServiceFramework<IManagerForApplication> { | 518 | class IManagerForApplication final : public ServiceFramework<IManagerForApplication> { |
| 508 | public: | 519 | public: |
| 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 | ||
| 527 | private: | 540 | private: |
| @@ -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 | |||
| 9 | namespace Service::Account { | ||
| 10 | IAsyncContext::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 | |||
| 28 | void 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 | |||
| 36 | void 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 | |||
| 46 | void 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 | |||
| 56 | void IAsyncContext::GetResult(Kernel::HLERequestContext& ctx) { | ||
| 57 | LOG_DEBUG(Service_ACC, "called"); | ||
| 58 | |||
| 59 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 60 | rb.Push(GetResult()); | ||
| 61 | } | ||
| 62 | |||
| 63 | void 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 | |||
| 10 | namespace Core { | ||
| 11 | class System; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::Account { | ||
| 15 | |||
| 16 | class IAsyncContext : public ServiceFramework<IAsyncContext> { | ||
| 17 | public: | ||
| 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 | |||
| 25 | protected: | ||
| 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 | ||