2021-09-06 13:16:21 +02:00
|
|
|
// 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"
|
2021-09-29 05:42:50 +02:00
|
|
|
#include "core/hle/kernel/k_event.h"
|
2021-09-06 13:16:21 +02:00
|
|
|
#include "core/hle/service/acc/async_context.h"
|
|
|
|
|
|
|
|
namespace Service::Account {
|
2021-09-06 14:13:51 +02:00
|
|
|
IAsyncContext::IAsyncContext(Core::System& system_)
|
2021-09-29 05:42:50 +02:00
|
|
|
: ServiceFramework{system_, "IAsyncContext"}, service_context{system_, "IAsyncContext"} {
|
2021-09-06 13:16:21 +02:00
|
|
|
// clang-format off
|
2021-09-08 16:09:04 +02:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &IAsyncContext::GetSystemEvent, "GetSystemEvent"},
|
|
|
|
{1, &IAsyncContext::Cancel, "Cancel"},
|
|
|
|
{2, &IAsyncContext::HasDone, "HasDone"},
|
|
|
|
{3, &IAsyncContext::GetResult, "GetResult"},
|
|
|
|
};
|
2021-09-06 13:16:21 +02:00
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
2021-09-29 05:42:50 +02:00
|
|
|
|
|
|
|
completion_event = service_context.CreateEvent("IAsyncContext:CompletionEvent");
|
|
|
|
}
|
|
|
|
|
|
|
|
IAsyncContext::~IAsyncContext() {
|
|
|
|
service_context.CloseEvent(completion_event);
|
2021-09-06 13:16:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void IAsyncContext::GetSystemEvent(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_DEBUG(Service_ACC, "called");
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(ResultSuccess);
|
2021-09-29 05:42:50 +02:00
|
|
|
rb.PushCopyObjects(completion_event->GetReadableEvent());
|
2021-09-06 13:16:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
2021-09-08 16:10:52 +02:00
|
|
|
is_complete.store(IsComplete());
|
2021-09-06 13:16:21 +02:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(ResultSuccess);
|
2021-09-08 16:10:52 +02:00
|
|
|
rb.Push(is_complete.load());
|
2021-09-06 13:16:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void IAsyncContext::GetResult(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_DEBUG(Service_ACC, "called");
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(GetResult());
|
|
|
|
}
|
|
|
|
|
|
|
|
void IAsyncContext::MarkComplete() {
|
2021-09-08 16:10:52 +02:00
|
|
|
is_complete.store(true);
|
2021-09-29 05:42:50 +02:00
|
|
|
completion_event->GetWritableEvent().Signal();
|
2021-09-06 13:16:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Service::Account
|