Stub ldn:u service

This commit is contained in:
Billy Laws 2022-10-16 17:55:04 +01:00
parent 77d76ed05a
commit 5b72be88c3
6 changed files with 133 additions and 0 deletions

View File

@ -335,6 +335,8 @@ add_library(skyline SHARED
${source_DIR}/skyline/services/pctl/IParentalControlService.cpp
${source_DIR}/skyline/services/lm/ILogService.cpp
${source_DIR}/skyline/services/lm/ILogger.cpp
${source_DIR}/skyline/services/ldn/IUserServiceCreator.cpp
${source_DIR}/skyline/services/ldn/IUserLocalCommunicationService.cpp
${source_DIR}/skyline/services/account/IAccountServiceForApplication.cpp
${source_DIR}/skyline/services/account/IManagerForApplication.cpp
${source_DIR}/skyline/services/account/IProfile.cpp

View File

@ -0,0 +1,35 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
#include "IUserLocalCommunicationService.h"
namespace skyline::service::ldn {
IUserLocalCommunicationService::IUserLocalCommunicationService(const DeviceState &state, ServiceManager &manager)
: BaseService(state, manager),
event{std::make_shared<type::KEvent>(state, false)} {}
Result IUserLocalCommunicationService::GetState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
static constexpr u32 StateNone{0x0};
response.Push<u32>(StateNone);
return {};
}
Result IUserLocalCommunicationService::AttachStateChangeEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
auto handle{state.process->InsertItem(event)};
Logger::Debug("LDN State Change Event Handle: 0x{:X}", handle);
response.copyHandles.push_back(handle);
return {};
}
Result IUserLocalCommunicationService::InitializeSystem(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
return result::DeviceDisabled;
}
Result IUserLocalCommunicationService::FinalizeSystem(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
return {};
}
Result IUserLocalCommunicationService::InitializeSystem2(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
return result::DeviceDisabled;
}
}

View File

@ -0,0 +1,57 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
#pragma once
#include <services/serviceman.h>
namespace skyline::service::ldn {
namespace result {
static constexpr Result DeviceDisabled{203, 22};
}
/**
* @brief IUserLocalCommunicationService is used by applications to manage LDN sessions
* @url https://switchbrew.org/wiki/LDN_services#IUserLocalCommunicationService
*/
class IUserLocalCommunicationService : public BaseService {
private:
std::shared_ptr<type::KEvent> event; //!< The KEvent that is signalled on state changes
public:
IUserLocalCommunicationService(const DeviceState &state, ServiceManager &manager);
/**
* @url https://switchbrew.org/wiki/LDN_services#GetState
*/
Result GetState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/**
* @url https://switchbrew.org/wiki/LDN_services#AttachStateChangeEvent
*/
Result AttachStateChangeEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/**
* @url https://switchbrew.org/wiki/LDN_services#InitializeSystem
*/
Result InitializeSystem(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/**
* @url https://switchbrew.org/wiki/LDN_services#FinalizeSystem
*/
Result FinalizeSystem(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/**
* @url https://switchbrew.org/wiki/LDN_services#InitializeSystem2
*/
Result InitializeSystem2(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
SERVICE_DECL(
SFUNC(0x0, IUserLocalCommunicationService, GetState),
SFUNC(0x64, IUserLocalCommunicationService, AttachStateChangeEvent),
SFUNC(0x190, IUserLocalCommunicationService, InitializeSystem),
SFUNC(0x191, IUserLocalCommunicationService, FinalizeSystem),
SFUNC(0x192, IUserLocalCommunicationService, InitializeSystem2),
)
};
}

View File

@ -0,0 +1,14 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
#include "IUserLocalCommunicationService.h"
#include "IUserServiceCreator.h"
namespace skyline::service::ldn {
IUserServiceCreator::IUserServiceCreator(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager) {}
Result IUserServiceCreator::CreateUserLocalCommunicationService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
manager.RegisterService(SRVREG(IUserLocalCommunicationService), session, response);
return {};
}
}

View File

@ -0,0 +1,23 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
#pragma once
#include <services/serviceman.h>
namespace skyline::service::ldn {
/**
* @brief IUserServiceCreator or ldn:u is used by applications to open a channel to manage LDN sessions
* @url https://switchbrew.org/wiki/LDN_services#CreateUserLocalCommunicationService
*/
class IUserServiceCreator : public BaseService {
public:
IUserServiceCreator(const DeviceState &state, ServiceManager &manager);
Result CreateUserLocalCommunicationService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
SERVICE_DECL(
SFUNC(0x0, IUserServiceCreator, CreateUserLocalCommunicationService)
)
};
}

View File

@ -34,6 +34,7 @@
#include "aocsrv/IAddOnContentManager.h"
#include "pctl/IParentalControlServiceFactory.h"
#include "lm/ILogService.h"
#include "ldn/IUserServiceCreator.h"
#include "account/IAccountServiceForApplication.h"
#include "friends/IServiceCreator.h"
#include "nfp/IUserManager.h"
@ -106,6 +107,7 @@ namespace skyline::service {
SERVICE_CASE(pctl::IParentalControlServiceFactory, "pctl:s")
SERVICE_CASE(pctl::IParentalControlServiceFactory, "pctl:r")
SERVICE_CASE(lm::ILogService, "lm")
SERVICE_CASE(ldn::IUserServiceCreator, "ldn:u")
SERVICE_CASE(account::IAccountServiceForApplication, "acc:u0")
SERVICE_CASE(friends::IServiceCreator, "friend:u")
SERVICE_CASE(nfp::IUserManager, "nfp:user")