From 22695c4febff5762c4c340e85b181cb25648aed0 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Tue, 31 May 2022 22:07:01 +0100 Subject: [PATCH] Stub nim services used for eShop communication We obviously don't need to implement these so add a simple set of stubs to satify games using them (mainly demos such as DQXII) --- app/CMakeLists.txt | 4 ++++ .../services/nim/IShopServiceAccessServer.cpp | 14 +++++++++++ .../services/nim/IShopServiceAccessServer.h | 23 +++++++++++++++++++ .../nim/IShopServiceAccessServerInterface.cpp | 14 +++++++++++ .../nim/IShopServiceAccessServerInterface.h | 23 +++++++++++++++++++ .../services/nim/IShopServiceAccessor.cpp | 14 +++++++++++ .../services/nim/IShopServiceAccessor.h | 23 +++++++++++++++++++ .../services/nim/IShopServiceAsync.cpp | 8 +++++++ .../skyline/services/nim/IShopServiceAsync.h | 17 ++++++++++++++ .../main/cpp/skyline/services/serviceman.cpp | 2 ++ 10 files changed, 142 insertions(+) create mode 100644 app/src/main/cpp/skyline/services/nim/IShopServiceAccessServer.cpp create mode 100644 app/src/main/cpp/skyline/services/nim/IShopServiceAccessServer.h create mode 100644 app/src/main/cpp/skyline/services/nim/IShopServiceAccessServerInterface.cpp create mode 100644 app/src/main/cpp/skyline/services/nim/IShopServiceAccessServerInterface.h create mode 100644 app/src/main/cpp/skyline/services/nim/IShopServiceAccessor.cpp create mode 100644 app/src/main/cpp/skyline/services/nim/IShopServiceAccessor.h create mode 100644 app/src/main/cpp/skyline/services/nim/IShopServiceAsync.cpp create mode 100644 app/src/main/cpp/skyline/services/nim/IShopServiceAsync.h diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index a9630666..c10db1cf 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -322,6 +322,10 @@ add_library(skyline SHARED ${source_DIR}/skyline/services/nifm/IGeneralService.cpp ${source_DIR}/skyline/services/nifm/IScanRequest.cpp ${source_DIR}/skyline/services/nifm/IRequest.cpp + ${source_DIR}/skyline/services/nim/IShopServiceAccessor.cpp + ${source_DIR}/skyline/services/nim/IShopServiceAccessServer.cpp + ${source_DIR}/skyline/services/nim/IShopServiceAccessServerInterface.cpp + ${source_DIR}/skyline/services/nim/IShopServiceAsync.cpp ${source_DIR}/skyline/services/socket/bsd/IClient.cpp ${source_DIR}/skyline/services/spl/IRandomInterface.cpp ${source_DIR}/skyline/services/ssl/ISslService.cpp diff --git a/app/src/main/cpp/skyline/services/nim/IShopServiceAccessServer.cpp b/app/src/main/cpp/skyline/services/nim/IShopServiceAccessServer.cpp new file mode 100644 index 00000000..d08c11ed --- /dev/null +++ b/app/src/main/cpp/skyline/services/nim/IShopServiceAccessServer.cpp @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) + +#include "IShopServiceAccessor.h" +#include "IShopServiceAccessServer.h" + +namespace skyline::service::nim { + IShopServiceAccessServer::IShopServiceAccessServer(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager) {} + + Result IShopServiceAccessServer::CreateAccessorInterface(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(SRVREG(IShopServiceAccessor), session, response); + return {}; + } +} diff --git a/app/src/main/cpp/skyline/services/nim/IShopServiceAccessServer.h b/app/src/main/cpp/skyline/services/nim/IShopServiceAccessServer.h new file mode 100644 index 00000000..065438f6 --- /dev/null +++ b/app/src/main/cpp/skyline/services/nim/IShopServiceAccessServer.h @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) + +#pragma once + +#include + +namespace skyline::service::nim { + /** + * @brief IShopServiceAccessServer is used by applications to interface with the Nintendo eShop + * @url https://switchbrew.org/wiki/NIM_services#IShopServiceAccessServer + */ + class IShopServiceAccessServer : public BaseService { + public: + IShopServiceAccessServer(const DeviceState &state, ServiceManager &manager); + + Result CreateAccessorInterface(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + SERVICE_DECL( + SFUNC(0x0, IShopServiceAccessServer, CreateAccessorInterface), + ) + }; +} diff --git a/app/src/main/cpp/skyline/services/nim/IShopServiceAccessServerInterface.cpp b/app/src/main/cpp/skyline/services/nim/IShopServiceAccessServerInterface.cpp new file mode 100644 index 00000000..d36ead8c --- /dev/null +++ b/app/src/main/cpp/skyline/services/nim/IShopServiceAccessServerInterface.cpp @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) + +#include "IShopServiceAccessServer.h" +#include "IShopServiceAccessServerInterface.h" + +namespace skyline::service::nim { + IShopServiceAccessServerInterface::IShopServiceAccessServerInterface(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager) {} + + Result IShopServiceAccessServerInterface::CreateServerInterface(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(SRVREG(IShopServiceAccessServer), session, response); + return {}; + } +} diff --git a/app/src/main/cpp/skyline/services/nim/IShopServiceAccessServerInterface.h b/app/src/main/cpp/skyline/services/nim/IShopServiceAccessServerInterface.h new file mode 100644 index 00000000..00dcc9f2 --- /dev/null +++ b/app/src/main/cpp/skyline/services/nim/IShopServiceAccessServerInterface.h @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) + +#pragma once + +#include + +namespace skyline::service::nim { + /** + * @brief IShopServiceAccessServerInterface or nim:eca is used by applications to open a channel to communicate with the Nintendo eShop + * @url https://switchbrew.org/wiki/NIM_services#nim:eca + */ + class IShopServiceAccessServerInterface : public BaseService { + public: + IShopServiceAccessServerInterface(const DeviceState &state, ServiceManager &manager); + + Result CreateServerInterface(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + SERVICE_DECL( + SFUNC(0x0, IShopServiceAccessServerInterface, CreateServerInterface) + ) + }; +} diff --git a/app/src/main/cpp/skyline/services/nim/IShopServiceAccessor.cpp b/app/src/main/cpp/skyline/services/nim/IShopServiceAccessor.cpp new file mode 100644 index 00000000..c3712bb7 --- /dev/null +++ b/app/src/main/cpp/skyline/services/nim/IShopServiceAccessor.cpp @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) + +#include "IShopServiceAsync.h" +#include "IShopServiceAccessor.h" + +namespace skyline::service::nim { + IShopServiceAccessor::IShopServiceAccessor(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager) {} + + Result IShopServiceAccessor::CreateAsyncInterface(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(SRVREG(IShopServiceAsync), session, response); + return {}; + } +} diff --git a/app/src/main/cpp/skyline/services/nim/IShopServiceAccessor.h b/app/src/main/cpp/skyline/services/nim/IShopServiceAccessor.h new file mode 100644 index 00000000..dfd80a8a --- /dev/null +++ b/app/src/main/cpp/skyline/services/nim/IShopServiceAccessor.h @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) + +#pragma once + +#include + +namespace skyline::service::nim { + /** + * @brief IShopServiceAccessor is used by applications to communicate with the Nintendo eShop + * @url https://switchbrew.org/wiki/NIM_services#IShopServiceAccessor + */ + class IShopServiceAccessor : public BaseService { + public: + IShopServiceAccessor(const DeviceState &state, ServiceManager &manager); + + Result CreateAsyncInterface(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + SERVICE_DECL( + SFUNC(0x0, IShopServiceAccessor, CreateAsyncInterface) + ) + }; +} diff --git a/app/src/main/cpp/skyline/services/nim/IShopServiceAsync.cpp b/app/src/main/cpp/skyline/services/nim/IShopServiceAsync.cpp new file mode 100644 index 00000000..5ba3f35c --- /dev/null +++ b/app/src/main/cpp/skyline/services/nim/IShopServiceAsync.cpp @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) + +#include "IShopServiceAsync.h" + +namespace skyline::service::nim { + IShopServiceAsync::IShopServiceAsync(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager) {} +} diff --git a/app/src/main/cpp/skyline/services/nim/IShopServiceAsync.h b/app/src/main/cpp/skyline/services/nim/IShopServiceAsync.h new file mode 100644 index 00000000..937fe943 --- /dev/null +++ b/app/src/main/cpp/skyline/services/nim/IShopServiceAsync.h @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) + +#pragma once + +#include + +namespace skyline::service::nim { + /** + * @brief IShopServiceAsync is used by applications to directly communicate with the Nintendo eShop + * @url https://switchbrew.org/wiki/NIM_services#IShopServiceAsync + */ + class IShopServiceAsync : public BaseService { + public: + IShopServiceAsync(const DeviceState &state, ServiceManager &manager); + }; +} diff --git a/app/src/main/cpp/skyline/services/serviceman.cpp b/app/src/main/cpp/skyline/services/serviceman.cpp index 92a2c24a..b9e5bc35 100644 --- a/app/src/main/cpp/skyline/services/serviceman.cpp +++ b/app/src/main/cpp/skyline/services/serviceman.cpp @@ -37,6 +37,7 @@ #include "friends/IServiceCreator.h" #include "nfp/IUserManager.h" #include "nifm/IStaticService.h" +#include "nim/IShopServiceAccessServerInterface.h" #include "socket/bsd/IClient.h" #include "spl/IRandomInterface.h" #include "ssl/ISslService.h" @@ -115,6 +116,7 @@ namespace skyline::service { SERVICE_CASE(bcat::IServiceCreator, "bcat:u") SERVICE_CASE(bt::IBluetoothUser, "bt") SERVICE_CASE(btm::IBtmUser, "btm:u") + SERVICE_CASE(nim::IShopServiceAccessServerInterface, "nim:eca") default: std::string_view nameString(span(reinterpret_cast(&name), sizeof(name)).as_string(true)); throw std::out_of_range(fmt::format("CreateService called with an unknown service name: {}", nameString));