sf: finish conversion of libstrat to new definitions

This commit is contained in:
Michael Scire 2020-07-06 19:41:04 -07:00
parent 379bddf6d1
commit dd432f33e8
40 changed files with 498 additions and 413 deletions

View File

@ -127,23 +127,21 @@ namespace ams::sf::cmif {
} }
}; };
template<typename T> template<typename T> requires sf::IsServiceObject<T>
struct ServiceDispatchTraits { struct ServiceDispatchTraits {
static_assert(std::is_base_of<sf::IServiceObject, T>::value, "ServiceObjects must derive from sf::IServiceObject");
using ProcessHandlerType = decltype(ServiceDispatchMeta::ProcessHandler); using ProcessHandlerType = decltype(ServiceDispatchMeta::ProcessHandler);
static constexpr inline auto DispatchTable = T::template s_CmifServiceDispatchTable<T>; static constexpr inline auto DispatchTable = T::template s_CmifServiceDispatchTable<T>;
using DispatchTableType = decltype(DispatchTable); using DispatchTableType = decltype(DispatchTable);
static constexpr ProcessHandlerType ProcessHandlerImpl = ServiceObjectTraits<T>::IsMitmServiceObject ? (&impl::ServiceDispatchTableBase::ProcessMessageForMitm<DispatchTableType>) static constexpr ProcessHandlerType ProcessHandlerImpl = sf::IsMitmServiceObject<T> ? (&impl::ServiceDispatchTableBase::ProcessMessageForMitm<DispatchTableType>)
: (&impl::ServiceDispatchTableBase::ProcessMessage<DispatchTableType>); : (&impl::ServiceDispatchTableBase::ProcessMessage<DispatchTableType>);
static constexpr inline ServiceDispatchMeta Meta{&DispatchTable, ProcessHandlerImpl}; static constexpr inline ServiceDispatchMeta Meta{&DispatchTable, ProcessHandlerImpl};
}; };
template<typename T> template<typename T>
NX_CONSTEXPR const ServiceDispatchMeta *GetServiceDispatchMeta() { constexpr ALWAYS_INLINE const ServiceDispatchMeta *GetServiceDispatchMeta() {
return &ServiceDispatchTraits<T>::Meta; return &ServiceDispatchTraits<T>::Meta;
} }

View File

@ -69,12 +69,12 @@ namespace ams::sf::hipc {
virtual void CreateSessionObjectHolder(cmif::ServiceObjectHolder *out_obj, std::shared_ptr<::Service> *out_fsrv) const = 0; virtual void CreateSessionObjectHolder(cmif::ServiceObjectHolder *out_obj, std::shared_ptr<::Service> *out_fsrv) const = 0;
}; };
template<typename ServiceImpl, auto MakeShared = std::make_shared<ServiceImpl>> template<typename Interface, auto MakeShared>
class Server : public ServerBase { class Server : public ServerBase {
NON_COPYABLE(Server); NON_COPYABLE(Server);
NON_MOVEABLE(Server); NON_MOVEABLE(Server);
private: private:
static constexpr bool IsMitmServer = ServiceObjectTraits<ServiceImpl>::IsMitmServiceObject; static constexpr bool IsMitmServer = sf::IsMitmServiceObject<Interface>;
public: public:
Server(Handle ph, sm::ServiceName sn, bool m, cmif::ServiceObjectHolder &&sh) : ServerBase(ph, sn, m, std::forward<cmif::ServiceObjectHolder>(sh)) { Server(Handle ph, sm::ServiceName sn, bool m, cmif::ServiceObjectHolder &&sh) : ServerBase(ph, sn, m, std::forward<cmif::ServiceObjectHolder>(sh)) {
/* ... */ /* ... */
@ -145,14 +145,14 @@ namespace ams::sf::hipc {
void ProcessDeferredSessions(); void ProcessDeferredSessions();
template<typename ServiceImpl, auto MakeShared = std::make_shared<ServiceImpl>> template<typename Interface, auto MakeShared>
void RegisterServerImpl(Handle port_handle, sm::ServiceName service_name, bool managed, cmif::ServiceObjectHolder &&static_holder) { void RegisterServerImpl(Handle port_handle, sm::ServiceName service_name, bool managed, cmif::ServiceObjectHolder &&static_holder) {
/* Allocate server memory. */ /* Allocate server memory. */
auto *server = this->AllocateServer(); auto *server = this->AllocateServer();
AMS_ABORT_UNLESS(server != nullptr); AMS_ABORT_UNLESS(server != nullptr);
new (server) Server<ServiceImpl, MakeShared>(port_handle, service_name, managed, std::forward<cmif::ServiceObjectHolder>(static_holder)); new (server) Server<Interface, MakeShared>(port_handle, service_name, managed, std::forward<cmif::ServiceObjectHolder>(static_holder));
if constexpr (!ServiceObjectTraits<ServiceImpl>::IsMitmServiceObject) { if constexpr (!sf::IsMitmServiceObject<Interface>) {
/* Non-mitm server. */ /* Non-mitm server. */
os::SetWaitableHolderUserData(server, static_cast<uintptr_t>(UserDataTag::Server)); os::SetWaitableHolderUserData(server, static_cast<uintptr_t>(UserDataTag::Server));
} else { } else {
@ -163,9 +163,9 @@ namespace ams::sf::hipc {
os::LinkWaitableHolder(std::addressof(this->waitable_manager), server); os::LinkWaitableHolder(std::addressof(this->waitable_manager), server);
} }
template<typename ServiceImpl> template<typename Interface, typename ServiceImpl>
static constexpr inline std::shared_ptr<ServiceImpl> MakeSharedMitm(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &client_info) { static constexpr inline std::shared_ptr<Service> MakeSharedMitm(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &client_info) {
return std::make_shared<ServiceImpl>(std::forward<std::shared_ptr<::Service>>(s), client_info); return sf::MakeShared<Interface, ServiceImpl>(std::forward<std::shared_ptr<::Service>>(s), client_info);
} }
Result InstallMitmServerImpl(Handle *out_port_handle, sm::ServiceName service_name, MitmQueryFunction query_func); Result InstallMitmServerImpl(Handle *out_port_handle, sm::ServiceName service_name, MitmQueryFunction query_func);
@ -187,21 +187,18 @@ namespace ams::sf::hipc {
os::InitializeWaitableManager(std::addressof(this->waitlist)); os::InitializeWaitableManager(std::addressof(this->waitlist));
} }
template<typename ServiceImpl, auto MakeShared = std::make_shared<ServiceImpl>> template<typename Interface, typename ServiceImpl, auto MakeShared = sf::MakeShared<Interface, ServiceImpl>> requires (sf::IsServiceObject<Interface> && !sf::IsMitmServiceObject<Interface>)
void RegisterServer(Handle port_handle, std::shared_ptr<ServiceImpl> static_object = nullptr) { void RegisterServer(Handle port_handle, std::shared_ptr<Interface> static_object = nullptr) {
static_assert(!ServiceObjectTraits<ServiceImpl>::IsMitmServiceObject, "RegisterServer requires non-mitm object. Use RegisterMitmServer instead.");
/* Register server. */ /* Register server. */
cmif::ServiceObjectHolder static_holder; cmif::ServiceObjectHolder static_holder;
if (static_object != nullptr) { if (static_object != nullptr) {
static_holder = cmif::ServiceObjectHolder(std::move(static_object)); static_holder = cmif::ServiceObjectHolder(std::move(static_object));
} }
this->RegisterServerImpl<ServiceImpl, MakeShared>(port_handle, sm::InvalidServiceName, false, std::move(static_holder)); this->RegisterServerImpl<Interface, MakeShared>(port_handle, sm::InvalidServiceName, false, std::move(static_holder));
} }
template<typename ServiceImpl, auto MakeShared = std::make_shared<ServiceImpl>> template<typename Interface, typename ServiceImpl, auto MakeShared = sf::MakeShared<Interface, ServiceImpl>> requires (sf::IsServiceObject<Interface> && !sf::IsMitmServiceObject<Interface>)
Result RegisterServer(sm::ServiceName service_name, size_t max_sessions, std::shared_ptr<ServiceImpl> static_object = nullptr) { Result RegisterServer(sm::ServiceName service_name, size_t max_sessions, std::shared_ptr<Interface> static_object = nullptr) {
static_assert(!ServiceObjectTraits<ServiceImpl>::IsMitmServiceObject, "RegisterServer requires non-mitm object. Use RegisterMitmServer instead.");
/* Register service. */ /* Register service. */
Handle port_handle; Handle port_handle;
R_TRY(sm::RegisterService(&port_handle, service_name, max_sessions, false)); R_TRY(sm::RegisterService(&port_handle, service_name, max_sessions, false));
@ -211,19 +208,17 @@ namespace ams::sf::hipc {
if (static_object != nullptr) { if (static_object != nullptr) {
static_holder = cmif::ServiceObjectHolder(std::move(static_object)); static_holder = cmif::ServiceObjectHolder(std::move(static_object));
} }
this->RegisterServerImpl<ServiceImpl, MakeShared>(port_handle, service_name, true, std::move(static_holder)); this->RegisterServerImpl<Interface, MakeShared>(port_handle, service_name, true, std::move(static_holder));
return ResultSuccess(); return ResultSuccess();
} }
template<typename ServiceImpl, auto MakeShared = MakeSharedMitm<ServiceImpl>> template<typename Interface, typename ServiceImpl, auto MakeShared = MakeSharedMitm<Interface, ServiceImpl>> requires (sf::IsMitmServiceObject<Interface>)
Result RegisterMitmServer(sm::ServiceName service_name) { Result RegisterMitmServer(sm::ServiceName service_name) {
static_assert(ServiceObjectTraits<ServiceImpl>::IsMitmServiceObject, "RegisterMitmServer requires mitm object. Use RegisterServer instead.");
/* Install mitm service. */ /* Install mitm service. */
Handle port_handle; Handle port_handle;
R_TRY(this->InstallMitmServerImpl(&port_handle, service_name, &ServiceImpl::ShouldMitm)); R_TRY(this->InstallMitmServerImpl(&port_handle, service_name, &ServiceImpl::ShouldMitm));
this->RegisterServerImpl<ServiceImpl, MakeShared>(port_handle, service_name, true, cmif::ServiceObjectHolder()); this->RegisterServerImpl<Interface, MakeShared>(port_handle, service_name, true, cmif::ServiceObjectHolder());
return ResultSuccess(); return ResultSuccess();
} }

View File

@ -126,13 +126,21 @@ namespace ams::sf::impl {
return this->impl.NAME(std::forward<Arguments>(args)...); \ return this->impl.NAME(std::forward<Arguments>(args)...); \
} }
#define AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_IMPL_PTR(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
template<typename ...Arguments> \
requires (std::same_as<std::tuple<Arguments...>, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> && \
std::same_as<RETURN, decltype(impl->NAME(std::declval<Arguments>()...))>) \
RETURN NAME (Arguments &&... args) { \
return this->impl->NAME(std::forward<Arguments>(args)...); \
}
#define AMS_SF_IMPL_DEFINE_INTERFACE_IMPL_FUNCTION_POINTER_HOLDER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \ #define AMS_SF_IMPL_DEFINE_INTERFACE_IMPL_FUNCTION_POINTER_HOLDER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
template<typename A> struct NAME##FunctionPointerHolder; \ template<typename A> struct NAME##FunctionPointerHolder; \
\ \
template<typename ...Arguments> \ template<typename ...Arguments> \
requires std::same_as<std::tuple<Arguments...>, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> \ requires std::same_as<std::tuple<Arguments...>, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> \
struct NAME##FunctionPointerHolder<std::tuple<Arguments...>> { \ struct NAME##FunctionPointerHolder<std::tuple<Arguments...>> { \
static constexpr auto Value = static_cast<AMS_SF_IMPL_FUNCTION_POINTER_TYPE(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX)>(&ImplHolder::NAME##Invoker<Arguments...>); \ static constexpr auto Value = static_cast<AMS_SF_IMPL_FUNCTION_POINTER_TYPE(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX)>(&NAME##Invoker<Arguments...>); \
}; };
#define AMS_SF_IMPL_DEFINE_INTERFACE_SERVICE_COMMAND_META_HOLDER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \ #define AMS_SF_IMPL_DEFINE_INTERFACE_SERVICE_COMMAND_META_HOLDER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
@ -185,6 +193,8 @@ namespace ams::sf::impl {
{ \ { \
/* ... */ \ /* ... */ \
} \ } \
ALWAYS_INLINE T &GetImpl() { return this->impl; } \
ALWAYS_INLINE const T &GetImpl() const { return this->impl; } \
private: \ private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_INVOKER) \ CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_INVOKER) \
public: \ public: \
@ -198,6 +208,29 @@ namespace ams::sf::impl {
}; \ }; \
static_assert(Is##CLASSNAME<ImplHolder>); \ static_assert(Is##CLASSNAME<ImplHolder>); \
\ \
class ImplPointer : public S { \
private: \
T *impl; \
public: \
constexpr ImplPointer(T *t) \
: S(std::addressof(CommandPointerTableImpl)), impl(t) \
{ \
/* ... */ \
} \
ALWAYS_INLINE T &GetImpl() { return *this->impl; } \
ALWAYS_INLINE const T &GetImpl() const { return *this->impl; } \
private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_INVOKER) \
public: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_IMPL_PTR) \
private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_IMPL_FUNCTION_POINTER_HOLDER) \
public: \
static constexpr CommandPointerTable CommandPointerTableImpl = { \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_COMMAND_POINTER_TABLE_MEMBER) \
}; \
}; \
static_assert(Is##CLASSNAME<ImplHolder>); \
}; \ }; \
private: \ private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_SERVICE_COMMAND_META_HOLDER) \ CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_SERVICE_COMMAND_META_HOLDER) \
@ -205,6 +238,9 @@ namespace ams::sf::impl {
template<typename T> requires (!std::same_as<CLASSNAME, T>&& Is##CLASSNAME<T>) \ template<typename T> requires (!std::same_as<CLASSNAME, T>&& Is##CLASSNAME<T>) \
using ImplHolder = typename ImplGenerator<CLASSNAME, T>::ImplHolder; \ using ImplHolder = typename ImplGenerator<CLASSNAME, T>::ImplHolder; \
\ \
template<typename T> requires (!std::same_as<CLASSNAME, T>&& Is##CLASSNAME<T>) \
using ImplPointer = typename ImplGenerator<CLASSNAME, T>::ImplPointer; \
\
AMS_SF_CMIF_IMPL_DEFINE_SERVICE_DISPATCH_TABLE { \ AMS_SF_CMIF_IMPL_DEFINE_SERVICE_DISPATCH_TABLE { \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_CMIF_SERVICE_COMMAND_META_TABLE_ENTRY) \ CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_CMIF_SERVICE_COMMAND_META_TABLE_ENTRY) \
}; \ }; \

View File

@ -25,6 +25,9 @@ namespace ams::sf {
virtual ~IServiceObject() { /* ... */ } virtual ~IServiceObject() { /* ... */ }
}; };
template<typename T>
concept IsServiceObject = std::derived_from<T, IServiceObject>;
class IMitmServiceObject : public IServiceObject { class IMitmServiceObject : public IServiceObject {
protected: protected:
std::shared_ptr<::Service> forward_service; std::shared_ptr<::Service> forward_service;
@ -37,26 +40,25 @@ namespace ams::sf {
static bool ShouldMitm(os::ProcessId process_id, ncm::ProgramId program_id); static bool ShouldMitm(os::ProcessId process_id, ncm::ProgramId program_id);
}; };
template<typename T>
concept IsMitmServiceObject = IsServiceObject<T> && std::derived_from<T, IMitmServiceObject>;
/* Utility. */ /* Utility. */
#define AMS_SF_MITM_SERVICE_OBJECT_CTOR(cls) cls(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &c) : ::ams::sf::IMitmServiceObject(std::forward<std::shared_ptr<::Service>>(s), c) #define AMS_SF_MITM_SERVICE_OBJECT_CTOR(cls) cls(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &c) : ::ams::sf::IMitmServiceObject(std::forward<std::shared_ptr<::Service>>(s), c)
template<typename T> template<typename Interface, typename Impl, typename... Arguments> requires std::constructible_from<Impl, Arguments...>
struct ServiceObjectTraits { constexpr ALWAYS_INLINE std::shared_ptr<typename Interface::ImplHolder<Impl>> MakeShared(Arguments &&... args) {
static_assert(std::is_base_of<ams::sf::IServiceObject, T>::value, "ServiceObjectTraits requires ServiceObject"); return std::make_shared<typename Interface::ImplHolder<Impl>>(std::forward<Arguments>(args)...);
static constexpr bool IsMitmServiceObject = std::is_base_of<IMitmServiceObject, T>::value;
struct SharedPointerHelper {
static constexpr void EmptyDelete(T *) { /* Empty deleter, for fake shared pointer. */ }
static constexpr std::shared_ptr<T> GetEmptyDeleteSharedPointer(T *srv_obj) {
return std::shared_ptr<T>(srv_obj, EmptyDelete);
} }
}; template<typename Interface, typename Impl>
}; constexpr ALWAYS_INLINE std::shared_ptr<typename Interface::ImplPointer<Impl>> GetSharedPointerTo(Impl *impl) {
return std::make_shared<typename Interface::ImplPointer<Impl>>(impl);
}
template<typename Interface, typename Impl>
constexpr ALWAYS_INLINE std::shared_ptr<typename Interface::ImplPointer<Impl>> GetSharedPointerTo(Impl &impl) {
return GetSharedPointerTo<Interface, Impl>(std::addressof(impl));
}
} }

View File

@ -24,7 +24,7 @@ namespace ams::capsrv::server {
this->server_manager_holder.emplace(); this->server_manager_holder.emplace();
/* Register the service. */ /* Register the service. */
R_ABORT_UNLESS(this->server_manager_holder->RegisterServer<Service>(ServiceName, MaxSessions, sf::ServiceObjectTraits<Service>::SharedPointerHelper::GetEmptyDeleteSharedPointer(std::addressof(*this->service_holder)))); R_ABORT_UNLESS((this->server_manager_holder->RegisterServer<Interface, Service>(ServiceName, MaxSessions, sf::GetSharedPointerTo<Interface>(*this->service_holder))));
/* Initialize the idle event, we're idle initially. */ /* Initialize the idle event, we're idle initially. */
os::InitializeEvent(std::addressof(this->idle_event), true, os::EventClearMode_ManualClear); os::InitializeEvent(std::addressof(this->idle_event), true, os::EventClearMode_ManualClear);

View File

@ -26,6 +26,7 @@ namespace ams::capsrv::server {
static constexpr inline size_t MaxSessions = 2; static constexpr inline size_t MaxSessions = 2;
static constexpr inline sm::ServiceName ServiceName = sm::ServiceName::Encode("caps:dc"); static constexpr inline sm::ServiceName ServiceName = sm::ServiceName::Encode("caps:dc");
using Interface = IDecoderControlService;
using Service = DecoderControlService; using Service = DecoderControlService;
using ServerOptions = sf::hipc::DefaultServerManagerOptions; using ServerOptions = sf::hipc::DefaultServerManagerOptions;
using ServerManager = sf::hipc::ServerManager<NumServers, ServerOptions, MaxSessions>; using ServerManager = sf::hipc::ServerManager<NumServers, ServerOptions, MaxSessions>;

View File

@ -18,17 +18,15 @@
namespace ams::capsrv::server { namespace ams::capsrv::server {
class DecoderControlService final : public sf::IServiceObject { #define AMS_CAPSRV_DECODER_CONTROL_SERVICE_INTERFACE_INFO(C, H) \
protected: AMS_SF_METHOD_INFO(C, H, 3001, Result, DecodeJpeg, (const sf::OutNonSecureBuffer &out, const sf::InBuffer &in, u32 width, u32 height, const ScreenShotDecodeOption &option))
enum class CommandId {
DecodeJpeg = 3001, AMS_SF_DEFINE_INTERFACE(IDecoderControlService, AMS_CAPSRV_DECODER_CONTROL_SERVICE_INTERFACE_INFO)
};
class DecoderControlService final {
public: public:
/* Actual commands. */ Result DecodeJpeg(const sf::OutNonSecureBuffer &out, const sf::InBuffer &in, u32 width, u32 height, const ScreenShotDecodeOption &option);
virtual Result DecodeJpeg(const sf::OutNonSecureBuffer &out, const sf::InBuffer &in, u32 width, u32 height, const ScreenShotDecodeOption &option);
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MAKE_SERVICE_COMMAND_META(DecodeJpeg)
};
}; };
static_assert(IsIDecoderControlService<DecoderControlService>);
} }

View File

@ -20,19 +20,20 @@ namespace ams::erpt::srv {
class Attachment; class Attachment;
class AttachmentImpl final : public erpt::sf::IAttachment { class AttachmentImpl final {
private: private:
Attachment *attachment; Attachment *attachment;
public: public:
AttachmentImpl(); AttachmentImpl();
~AttachmentImpl(); ~AttachmentImpl();
public: public:
virtual Result Open(const AttachmentId &attachment_id) override final; Result Open(const AttachmentId &attachment_id);
virtual Result Read(ams::sf::Out<u32> out_count, const ams::sf::OutBuffer &out_buffer) override final; Result Read(ams::sf::Out<u32> out_count, const ams::sf::OutBuffer &out_buffer);
virtual Result SetFlags(AttachmentFlagSet flags) override final; Result SetFlags(AttachmentFlagSet flags);
virtual Result GetFlags(ams::sf::Out<AttachmentFlagSet> out) override final; Result GetFlags(ams::sf::Out<AttachmentFlagSet> out);
virtual Result Close() override final; Result Close();
virtual Result GetSize(ams::sf::Out<s64> out) override final; Result GetSize(ams::sf::Out<s64> out);
}; };
static_assert(erpt::sf::IsIAttachment<AttachmentImpl>);
} }

View File

@ -18,19 +18,20 @@
namespace ams::erpt::srv { namespace ams::erpt::srv {
class ContextImpl final : public erpt::sf::IContext { class ContextImpl final {
public: public:
virtual Result SubmitContext(const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer) override final; Result SubmitContext(const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer);
virtual Result CreateReport(ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer, const ams::sf::InBuffer &meta_buffer) override final; Result CreateReport(ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer, const ams::sf::InBuffer &meta_buffer);
virtual Result SetInitialLaunchSettingsCompletionTime(const time::SteadyClockTimePoint &time_point) override final; Result SetInitialLaunchSettingsCompletionTime(const time::SteadyClockTimePoint &time_point);
virtual Result ClearInitialLaunchSettingsCompletionTime() override final; Result ClearInitialLaunchSettingsCompletionTime();
virtual Result UpdatePowerOnTime() override final; Result UpdatePowerOnTime();
virtual Result UpdateAwakeTime() override final; Result UpdateAwakeTime();
virtual Result SubmitMultipleCategoryContext(const MultipleCategoryContextEntry &ctx_entry, const ams::sf::InBuffer &str_buffer) override final; Result SubmitMultipleCategoryContext(const MultipleCategoryContextEntry &ctx_entry, const ams::sf::InBuffer &str_buffer);
virtual Result UpdateApplicationLaunchTime() override final; Result UpdateApplicationLaunchTime();
virtual Result ClearApplicationLaunchTime() override final; Result ClearApplicationLaunchTime();
virtual Result SubmitAttachment(ams::sf::Out<AttachmentId> out, const ams::sf::InBuffer &attachment_name, const ams::sf::InBuffer &attachment_data) override final; Result SubmitAttachment(ams::sf::Out<AttachmentId> out, const ams::sf::InBuffer &attachment_name, const ams::sf::InBuffer &attachment_data);
virtual Result CreateReportWithAttachments(ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer, const ams::sf::InBuffer &attachment_ids_buffer) override final; Result CreateReportWithAttachments(ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer, const ams::sf::InBuffer &attachment_ids_buffer);
}; };
static_assert(erpt::sf::IsIContext<ContextImpl>);
} }

View File

@ -18,7 +18,7 @@
namespace ams::erpt::srv { namespace ams::erpt::srv {
class ManagerImpl final : public erpt::sf::IManager, public util::IntrusiveListBaseNode<ManagerImpl> { class ManagerImpl final : public util::IntrusiveListBaseNode<ManagerImpl> {
private: private:
os::SystemEvent system_event; os::SystemEvent system_event;
public: public:
@ -29,12 +29,13 @@ namespace ams::erpt::srv {
public: public:
static Result NotifyAll(); static Result NotifyAll();
public: public:
virtual Result GetReportList(const ams::sf::OutBuffer &out_list, ReportType type_filter) override final; Result GetReportList(const ams::sf::OutBuffer &out_list, ReportType type_filter);
virtual Result GetEvent(ams::sf::OutCopyHandle out) override final; Result GetEvent(ams::sf::OutCopyHandle out);
virtual Result CleanupReports() override final; Result CleanupReports();
virtual Result DeleteReport(const ReportId &report_id) override final; Result DeleteReport(const ReportId &report_id);
virtual Result GetStorageUsageStatistics(ams::sf::Out<StorageUsageStatistics> out) override final; Result GetStorageUsageStatistics(ams::sf::Out<StorageUsageStatistics> out);
virtual Result GetAttachmentList(const ams::sf::OutBuffer &out_buf, const ReportId &report_id) override final; Result GetAttachmentList(const ams::sf::OutBuffer &out_buf, const ReportId &report_id);
}; };
static_assert(erpt::sf::IsIManager<ManagerImpl>);
} }

View File

@ -20,19 +20,20 @@ namespace ams::erpt::srv {
class Report; class Report;
class ReportImpl final : public erpt::sf::IReport { class ReportImpl final {
private: private:
Report *report; Report *report;
public: public:
ReportImpl(); ReportImpl();
~ReportImpl(); ~ReportImpl();
public: public:
virtual Result Open(const ReportId &report_id) override final; Result Open(const ReportId &report_id);
virtual Result Read(ams::sf::Out<u32> out_count, const ams::sf::OutBuffer &out_buffer) override final; Result Read(ams::sf::Out<u32> out_count, const ams::sf::OutBuffer &out_buffer);
virtual Result SetFlags(ReportFlagSet flags) override final; Result SetFlags(ReportFlagSet flags);
virtual Result GetFlags(ams::sf::Out<ReportFlagSet> out) override final; Result GetFlags(ams::sf::Out<ReportFlagSet> out);
virtual Result Close() override final; Result Close();
virtual Result GetSize(ams::sf::Out<s64> out) override final; Result GetSize(ams::sf::Out<s64> out);
}; };
static_assert(erpt::sf::IsIReport<ReportImpl>);
} }

View File

@ -42,7 +42,7 @@ namespace ams::erpt::srv {
class ErrorReportServiceManager : public ams::sf::hipc::ServerManager<ErrorReportNumServers, ErrorReportServerOptions, ErrorReportMaxSessions> { class ErrorReportServiceManager : public ams::sf::hipc::ServerManager<ErrorReportNumServers, ErrorReportServerOptions, ErrorReportMaxSessions> {
private: private:
os::ThreadType thread; os::ThreadType thread;
std::shared_ptr<erpt::srv::ContextImpl> context_session_object; std::shared_ptr<erpt::sf::IContext> context_session_object;
private: private:
static void ThreadFunction(void *_this) { static void ThreadFunction(void *_this) {
reinterpret_cast<ErrorReportServiceManager *>(_this)->SetupAndLoopProcess(); reinterpret_cast<ErrorReportServiceManager *>(_this)->SetupAndLoopProcess();
@ -51,14 +51,14 @@ namespace ams::erpt::srv {
void SetupAndLoopProcess(); void SetupAndLoopProcess();
public: public:
ErrorReportServiceManager(erpt::srv::ContextImpl *c) ErrorReportServiceManager(erpt::srv::ContextImpl *c)
: context_session_object(ams::sf::ServiceObjectTraits<erpt::srv::ContextImpl>::SharedPointerHelper::GetEmptyDeleteSharedPointer(c)) : context_session_object(ams::sf::GetSharedPointerTo<erpt::sf::IContext, erpt::srv::ContextImpl>(c))
{ {
/* ... */ /* ... */
} }
Result Initialize() { Result Initialize() {
R_ABORT_UNLESS(this->RegisterServer<erpt::srv::ContextImpl>(ErrorReportContextServiceName, ErrorReportContextSessions, this->context_session_object)); R_ABORT_UNLESS((this->RegisterServer<erpt::sf::IContext, erpt::srv::ContextImpl>(ErrorReportContextServiceName, ErrorReportContextSessions, this->context_session_object)));
R_ABORT_UNLESS(this->RegisterServer<erpt::srv::SessionImpl>(ErrorReportReportServiceName, ErrorReportReportSessions)); R_ABORT_UNLESS((this->RegisterServer<erpt::sf::ISession, erpt::srv::SessionImpl>(ErrorReportReportServiceName, ErrorReportReportSessions)));
this->ResumeProcessing(); this->ResumeProcessing();
@ -117,7 +117,7 @@ namespace ams::erpt::srv {
} }
} }
erpt::srv::ContextImpl g_context_object; constinit erpt::srv::ContextImpl g_context_object;
ErrorReportServiceManager g_erpt_server_manager(std::addressof(g_context_object)); ErrorReportServiceManager g_erpt_server_manager(std::addressof(g_context_object));
} }

View File

@ -21,9 +21,15 @@
namespace ams::erpt::srv { namespace ams::erpt::srv {
Result SessionImpl::OpenReport(ams::sf::Out<std::shared_ptr<erpt::sf::IReport>> out) { namespace {
/* Create an interface. */
auto intf = std::shared_ptr<ReportImpl>(new (std::nothrow) ReportImpl); template<typename Interface, typename Impl>
ALWAYS_INLINE Result OpenInterface(ams::sf::Out<std::shared_ptr<Interface>> &out) {
/* Define holder type. */
using Holder = typename Interface::ImplHolder<Impl>;
/* Create an interface holder. */
auto intf = std::shared_ptr<Holder>(new (std::nothrow) Holder);
R_UNLESS(intf != nullptr, erpt::ResultOutOfMemory()); R_UNLESS(intf != nullptr, erpt::ResultOutOfMemory());
/* Return it. */ /* Return it. */
@ -31,24 +37,18 @@ namespace ams::erpt::srv {
return ResultSuccess(); return ResultSuccess();
} }
}
Result SessionImpl::OpenReport(ams::sf::Out<std::shared_ptr<erpt::sf::IReport>> out) {
return OpenInterface<erpt::sf::IReport, ReportImpl>(out);
}
Result SessionImpl::OpenManager(ams::sf::Out<std::shared_ptr<erpt::sf::IManager>> out) { Result SessionImpl::OpenManager(ams::sf::Out<std::shared_ptr<erpt::sf::IManager>> out) {
/* Create an interface. */ return OpenInterface<erpt::sf::IManager, ManagerImpl>(out);
auto intf = std::shared_ptr<ManagerImpl>(new (std::nothrow) ManagerImpl);
R_UNLESS(intf != nullptr, erpt::ResultOutOfMemory());
/* Return it. */
out.SetValue(std::move(intf));
return ResultSuccess();
} }
Result SessionImpl::OpenAttachment(ams::sf::Out<std::shared_ptr<erpt::sf::IAttachment>> out) { Result SessionImpl::OpenAttachment(ams::sf::Out<std::shared_ptr<erpt::sf::IAttachment>> out) {
/* Create an interface. */ return OpenInterface<erpt::sf::IAttachment, AttachmentImpl>(out);
auto intf = std::shared_ptr<AttachmentImpl>(new (std::nothrow) AttachmentImpl);
R_UNLESS(intf != nullptr, erpt::ResultOutOfMemory());
/* Return it. */
out.SetValue(std::move(intf));
return ResultSuccess();
} }
} }

View File

@ -18,11 +18,12 @@
namespace ams::erpt::srv { namespace ams::erpt::srv {
class SessionImpl final : public erpt::sf::ISession { class SessionImpl final {
public: public:
virtual Result OpenReport(ams::sf::Out<std::shared_ptr<erpt::sf::IReport>> out) override final; Result OpenReport(ams::sf::Out<std::shared_ptr<erpt::sf::IReport>> out);
virtual Result OpenManager(ams::sf::Out<std::shared_ptr<erpt::sf::IManager>> out) override final; Result OpenManager(ams::sf::Out<std::shared_ptr<erpt::sf::IManager>> out);
virtual Result OpenAttachment(ams::sf::Out<std::shared_ptr<erpt::sf::IAttachment>> out) override final; Result OpenAttachment(ams::sf::Out<std::shared_ptr<erpt::sf::IAttachment>> out);
}; };
static_assert(erpt::sf::IsISession<SessionImpl>);
} }

View File

@ -254,7 +254,7 @@ namespace ams::fssrv::impl {
/* TODO: N creates an nn::fssystem::AsynchronousAccessFile here. */ /* TODO: N creates an nn::fssystem::AsynchronousAccessFile here. */
std::shared_ptr<FileSystemInterfaceAdapter> shared_this = this->shared_from_this(); std::shared_ptr<FileSystemInterfaceAdapter> shared_this = this->shared_from_this();
std::shared_ptr<fssrv::sf::IFile> file_intf = std::make_shared<fssrv::sf::IFile::ImplHolder<FileInterfaceAdapter>>(std::move(file), std::move(shared_this), std::move(open_count_semaphore)); auto file_intf = ams::sf::MakeShared<fssrv::sf::IFile, FileInterfaceAdapter>(std::move(file), std::move(shared_this), std::move(open_count_semaphore));
R_UNLESS(file_intf != nullptr, fs::ResultAllocationFailureInFileSystemInterfaceAdapter()); R_UNLESS(file_intf != nullptr, fs::ResultAllocationFailureInFileSystemInterfaceAdapter());
out.SetValue(std::move(file_intf), target_object_id); out.SetValue(std::move(file_intf), target_object_id);
@ -281,7 +281,7 @@ namespace ams::fssrv::impl {
const auto target_object_id = dir->GetDomainObjectId(); const auto target_object_id = dir->GetDomainObjectId();
std::shared_ptr<FileSystemInterfaceAdapter> shared_this = this->shared_from_this(); std::shared_ptr<FileSystemInterfaceAdapter> shared_this = this->shared_from_this();
std::shared_ptr<fssrv::sf::IDirectory> dir_intf = std::make_shared<fssrv::sf::IDirectory::ImplHolder<DirectoryInterfaceAdapter>>(std::move(dir), std::move(shared_this), std::move(open_count_semaphore)); auto dir_intf = ams::sf::MakeShared<fssrv::sf::IDirectory, DirectoryInterfaceAdapter>(std::move(dir), std::move(shared_this), std::move(open_count_semaphore));
R_UNLESS(dir_intf != nullptr, fs::ResultAllocationFailureInFileSystemInterfaceAdapter()); R_UNLESS(dir_intf != nullptr, fs::ResultAllocationFailureInFileSystemInterfaceAdapter());
out.SetValue(std::move(dir_intf), target_object_id); out.SetValue(std::move(dir_intf), target_object_id);

View File

@ -21,7 +21,7 @@
namespace ams::lr { namespace ams::lr {
class AddOnContentLocationResolverImpl : public IAddOnContentLocationResolver { class AddOnContentLocationResolverImpl {
private: private:
/* Storage for RegisteredData entries by data id. */ /* Storage for RegisteredData entries by data id. */
RegisteredStorages<ncm::DataId, 0x800> registered_storages; RegisteredStorages<ncm::DataId, 0x800> registered_storages;
@ -29,12 +29,13 @@ namespace ams::lr {
AddOnContentLocationResolverImpl() : registered_storages(hos::GetVersion() < hos::Version_9_0_0 ? 0x800 : 0x2) { /* ... */ } AddOnContentLocationResolverImpl() : registered_storages(hos::GetVersion() < hos::Version_9_0_0 ? 0x800 : 0x2) { /* ... */ }
/* Actual commands. */ /* Actual commands. */
virtual Result ResolveAddOnContentPath(sf::Out<Path> out, ncm::DataId id) override; Result ResolveAddOnContentPath(sf::Out<Path> out, ncm::DataId id);
virtual Result RegisterAddOnContentStorageDeprecated(ncm::DataId id, ncm::StorageId storage_id) override; Result RegisterAddOnContentStorageDeprecated(ncm::DataId id, ncm::StorageId storage_id);
virtual Result RegisterAddOnContentStorage(ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id) override; Result RegisterAddOnContentStorage(ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id);
virtual Result UnregisterAllAddOnContentPath() override; Result UnregisterAllAddOnContentPath();
virtual Result RefreshApplicationAddOnContent(const sf::InArray<ncm::ApplicationId> &ids) override; Result RefreshApplicationAddOnContent(const sf::InArray<ncm::ApplicationId> &ids);
virtual Result UnregisterApplicationAddOnContent(ncm::ApplicationId id) override; Result UnregisterApplicationAddOnContent(ncm::ApplicationId id);
}; };
static_assert(lr::IsIAddOnContentLocationResolver<AddOnContentLocationResolverImpl>);
} }

View File

@ -42,7 +42,7 @@ namespace ams::lr {
LrLocationResolver lr; LrLocationResolver lr;
R_TRY(lrOpenLocationResolver(static_cast<NcmStorageId>(storage_id), std::addressof(lr))); R_TRY(lrOpenLocationResolver(static_cast<NcmStorageId>(storage_id), std::addressof(lr)));
*out = LocationResolver(std::make_shared<RemoteLocationResolverImpl>(lr)); *out = LocationResolver(sf::MakeShared<ILocationResolver, RemoteLocationResolverImpl>(lr));
return ResultSuccess(); return ResultSuccess();
} }
@ -50,7 +50,7 @@ namespace ams::lr {
LrRegisteredLocationResolver lr; LrRegisteredLocationResolver lr;
R_TRY(lrOpenRegisteredLocationResolver(std::addressof(lr))); R_TRY(lrOpenRegisteredLocationResolver(std::addressof(lr)));
*out = RegisteredLocationResolver(std::make_shared<RemoteRegisteredLocationResolverImpl>(lr)); *out = RegisteredLocationResolver(sf::MakeShared<IRegisteredLocationResolver, RemoteRegisteredLocationResolverImpl>(lr));
return ResultSuccess(); return ResultSuccess();
} }

View File

@ -35,32 +35,33 @@ namespace ams::lr {
void GetContentStoragePath(Path *out, ncm::ContentId content_id); void GetContentStoragePath(Path *out, ncm::ContentId content_id);
public: public:
/* Actual commands. */ /* Actual commands. */
virtual Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) override; Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id);
virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id) override; Result RedirectProgramPath(const Path &path, ncm::ProgramId id);
virtual Result ResolveApplicationControlPath(sf::Out<Path> out, ncm::ProgramId id) override; Result ResolveApplicationControlPath(sf::Out<Path> out, ncm::ProgramId id);
virtual Result ResolveApplicationHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) override; Result ResolveApplicationHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id);
virtual Result ResolveDataPath(sf::Out<Path> out, ncm::DataId id) override; Result ResolveDataPath(sf::Out<Path> out, ncm::DataId id);
virtual Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) override; Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id);
virtual Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
virtual Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override; Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id);
virtual Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
virtual Result ResolveApplicationLegalInformationPath(sf::Out<Path> out, ncm::ProgramId id) override; Result ResolveApplicationLegalInformationPath(sf::Out<Path> out, ncm::ProgramId id);
virtual Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) override; Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id);
virtual Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
virtual Result Refresh() override; Result Refresh();
virtual Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) override; Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id);
virtual Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
virtual Result ClearApplicationRedirectionDeprecated() override; Result ClearApplicationRedirectionDeprecated();
virtual Result ClearApplicationRedirection(const sf::InArray<ncm::ProgramId> &excluding_ids) override; Result ClearApplicationRedirection(const sf::InArray<ncm::ProgramId> &excluding_ids);
virtual Result EraseProgramRedirection(ncm::ProgramId id) override; Result EraseProgramRedirection(ncm::ProgramId id);
virtual Result EraseApplicationControlRedirection(ncm::ProgramId id) override; Result EraseApplicationControlRedirection(ncm::ProgramId id);
virtual Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) override; Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id);
virtual Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id) override; Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id);
virtual Result ResolveProgramPathForDebug(sf::Out<Path> out, ncm::ProgramId id) override; Result ResolveProgramPathForDebug(sf::Out<Path> out, ncm::ProgramId id);
virtual Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) override; Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id);
virtual Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) override; Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id);
virtual Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
virtual Result EraseProgramRedirectionForDebug(ncm::ProgramId id) override; Result EraseProgramRedirectionForDebug(ncm::ProgramId id);
}; };
static_assert(lr::IsILocationResolver<ContentLocationResolverImpl>);
} }

View File

@ -20,7 +20,7 @@
namespace ams::lr { namespace ams::lr {
class LocationResolverImplBase : public ILocationResolver { class LocationResolverImplBase {
NON_COPYABLE(LocationResolverImplBase); NON_COPYABLE(LocationResolverImplBase);
NON_MOVEABLE(LocationResolverImplBase); NON_MOVEABLE(LocationResolverImplBase);
protected: protected:

View File

@ -30,10 +30,10 @@ namespace ams::lr {
/* No existing resolver is present, create one. */ /* No existing resolver is present, create one. */
if (!resolver) { if (!resolver) {
if (storage_id == ncm::StorageId::Host) { if (storage_id == ncm::StorageId::Host) {
AMS_ABORT_UNLESS(this->location_resolvers.Insert(storage_id, std::make_shared<RedirectOnlyLocationResolverImpl>())); AMS_ABORT_UNLESS(this->location_resolvers.Insert(storage_id, sf::MakeShared<ILocationResolver, RedirectOnlyLocationResolverImpl>()));
} else { } else {
auto content_resolver = std::make_shared<ContentLocationResolverImpl>(storage_id); auto content_resolver = sf::MakeShared<ILocationResolver, ContentLocationResolverImpl>(storage_id);
R_TRY(content_resolver->Refresh()); R_TRY(content_resolver->GetImpl().Refresh());
AMS_ABORT_UNLESS(this->location_resolvers.Insert(storage_id, std::move(content_resolver))); AMS_ABORT_UNLESS(this->location_resolvers.Insert(storage_id, std::move(content_resolver)));
} }
@ -51,7 +51,7 @@ namespace ams::lr {
/* No existing resolver is present, create one. */ /* No existing resolver is present, create one. */
if (!this->registered_location_resolver) { if (!this->registered_location_resolver) {
this->registered_location_resolver = std::make_shared<RegisteredLocationResolverImpl>(); this->registered_location_resolver = sf::MakeShared<IRegisteredLocationResolver, RegisteredLocationResolverImpl>();
} }
/* Copy the output interface. */ /* Copy the output interface. */
@ -79,7 +79,7 @@ namespace ams::lr {
/* No existing resolver is present, create one. */ /* No existing resolver is present, create one. */
if (!this->add_on_content_location_resolver) { if (!this->add_on_content_location_resolver) {
this->add_on_content_location_resolver = std::make_shared<AddOnContentLocationResolverImpl>(); this->add_on_content_location_resolver = sf::MakeShared<IAddOnContentLocationResolver, AddOnContentLocationResolverImpl>();
} }
/* Copy the output interface. */ /* Copy the output interface. */

View File

@ -24,32 +24,33 @@ namespace ams::lr {
~RedirectOnlyLocationResolverImpl(); ~RedirectOnlyLocationResolverImpl();
public: public:
/* Actual commands. */ /* Actual commands. */
virtual Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) override; Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id);
virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id) override; Result RedirectProgramPath(const Path &path, ncm::ProgramId id);
virtual Result ResolveApplicationControlPath(sf::Out<Path> out, ncm::ProgramId id) override; Result ResolveApplicationControlPath(sf::Out<Path> out, ncm::ProgramId id);
virtual Result ResolveApplicationHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) override; Result ResolveApplicationHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id);
virtual Result ResolveDataPath(sf::Out<Path> out, ncm::DataId id) override; Result ResolveDataPath(sf::Out<Path> out, ncm::DataId id);
virtual Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) override; Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id);
virtual Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
virtual Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override; Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id);
virtual Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
virtual Result ResolveApplicationLegalInformationPath(sf::Out<Path> out, ncm::ProgramId id) override; Result ResolveApplicationLegalInformationPath(sf::Out<Path> out, ncm::ProgramId id);
virtual Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) override; Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id);
virtual Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
virtual Result Refresh() override; Result Refresh();
virtual Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) override; Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id);
virtual Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
virtual Result ClearApplicationRedirectionDeprecated() override; Result ClearApplicationRedirectionDeprecated();
virtual Result ClearApplicationRedirection(const sf::InArray<ncm::ProgramId> &excluding_ids) override; Result ClearApplicationRedirection(const sf::InArray<ncm::ProgramId> &excluding_ids);
virtual Result EraseProgramRedirection(ncm::ProgramId id) override; Result EraseProgramRedirection(ncm::ProgramId id);
virtual Result EraseApplicationControlRedirection(ncm::ProgramId id) override; Result EraseApplicationControlRedirection(ncm::ProgramId id);
virtual Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) override; Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id);
virtual Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id) override; Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id);
virtual Result ResolveProgramPathForDebug(sf::Out<Path> out, ncm::ProgramId id) override; Result ResolveProgramPathForDebug(sf::Out<Path> out, ncm::ProgramId id);
virtual Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) override; Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id);
virtual Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) override; Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id);
virtual Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
virtual Result EraseProgramRedirectionForDebug(ncm::ProgramId id) override; Result EraseProgramRedirectionForDebug(ncm::ProgramId id);
}; };
static_assert(lr::IsILocationResolver<RedirectOnlyLocationResolverImpl>);
} }

View File

@ -21,7 +21,7 @@
namespace ams::lr { namespace ams::lr {
class RegisteredLocationResolverImpl : public IRegisteredLocationResolver { class RegisteredLocationResolverImpl {
private: private:
static constexpr size_t MaxRegisteredLocationsDeprecated = 0x10; static constexpr size_t MaxRegisteredLocationsDeprecated = 0x10;
static constexpr size_t MaxRegisteredLocations = 0x20; static constexpr size_t MaxRegisteredLocations = 0x20;
@ -49,20 +49,21 @@ namespace ams::lr {
~RegisteredLocationResolverImpl(); ~RegisteredLocationResolverImpl();
public: public:
/* Actual commands. */ /* Actual commands. */
virtual Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) override; Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id);
virtual Result RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id) override; Result RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id);
virtual Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
virtual Result UnregisterProgramPath(ncm::ProgramId id) override; Result UnregisterProgramPath(ncm::ProgramId id);
virtual Result RedirectProgramPathDeprecated(const Path &path, ncm::ProgramId id) override; Result RedirectProgramPathDeprecated(const Path &path, ncm::ProgramId id);
virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; Result RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
virtual Result ResolveHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) override; Result ResolveHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id);
virtual Result RegisterHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override; Result RegisterHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id);
virtual Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
virtual Result UnregisterHtmlDocumentPath(ncm::ProgramId id) override; Result UnregisterHtmlDocumentPath(ncm::ProgramId id);
virtual Result RedirectHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override; Result RedirectHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id);
virtual Result RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; Result RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
virtual Result Refresh() override; Result Refresh();
virtual Result RefreshExcluding(const sf::InArray<ncm::ProgramId> &ids) override; Result RefreshExcluding(const sf::InArray<ncm::ProgramId> &ids);
}; };
static_assert(lr::IsIRegisteredLocationResolver<RegisteredLocationResolverImpl>);
} }

View File

@ -18,7 +18,7 @@
namespace ams::lr { namespace ams::lr {
class RemoteLocationResolverImpl : public ILocationResolver { class RemoteLocationResolverImpl {
private: private:
::LrLocationResolver srv; ::LrLocationResolver srv;
public: public:
@ -27,121 +27,122 @@ namespace ams::lr {
~RemoteLocationResolverImpl() { ::serviceClose(&srv.s); } ~RemoteLocationResolverImpl() { ::serviceClose(&srv.s); }
public: public:
/* Actual commands. */ /* Actual commands. */
virtual Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) override { Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) {
return lrLrResolveProgramPath(std::addressof(this->srv), id.value, out->str); return ::lrLrResolveProgramPath(std::addressof(this->srv), id.value, out->str);
} }
virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id) override { Result RedirectProgramPath(const Path &path, ncm::ProgramId id) {
return lrLrRedirectProgramPath(std::addressof(this->srv), id.value, path.str); return ::lrLrRedirectProgramPath(std::addressof(this->srv), id.value, path.str);
} }
virtual Result ResolveApplicationControlPath(sf::Out<Path> out, ncm::ProgramId id) override { Result ResolveApplicationControlPath(sf::Out<Path> out, ncm::ProgramId id) {
return lrLrResolveApplicationControlPath(std::addressof(this->srv), id.value, out->str); return ::lrLrResolveApplicationControlPath(std::addressof(this->srv), id.value, out->str);
} }
virtual Result ResolveApplicationHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) override { Result ResolveApplicationHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) {
return lrLrResolveApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, out->str); return ::lrLrResolveApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, out->str);
} }
virtual Result ResolveDataPath(sf::Out<Path> out, ncm::DataId id) override { Result ResolveDataPath(sf::Out<Path> out, ncm::DataId id) {
return lrLrResolveDataPath(std::addressof(this->srv), id.value, out->str); return ::lrLrResolveDataPath(std::addressof(this->srv), id.value, out->str);
} }
virtual Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) override { Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) {
return lrLrRedirectApplicationControlPath(std::addressof(this->srv), id.value, 0, path.str); return ::lrLrRedirectApplicationControlPath(std::addressof(this->srv), id.value, 0, path.str);
} }
virtual Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override { Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
return lrLrRedirectApplicationControlPath(std::addressof(this->srv), id.value, owner_id.value, path.str); return ::lrLrRedirectApplicationControlPath(std::addressof(this->srv), id.value, owner_id.value, path.str);
} }
virtual Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override { Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) {
return lrLrRedirectApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, 0, path.str); return ::lrLrRedirectApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, 0, path.str);
} }
virtual Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override { Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
return lrLrRedirectApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, owner_id.value, path.str); return ::lrLrRedirectApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, owner_id.value, path.str);
} }
virtual Result ResolveApplicationLegalInformationPath(sf::Out<Path> out, ncm::ProgramId id) override { Result ResolveApplicationLegalInformationPath(sf::Out<Path> out, ncm::ProgramId id) {
return lrLrResolveApplicationLegalInformationPath(std::addressof(this->srv), id.value, out->str); return ::lrLrResolveApplicationLegalInformationPath(std::addressof(this->srv), id.value, out->str);
} }
virtual Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) override { Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) {
return lrLrRedirectApplicationLegalInformationPath(std::addressof(this->srv), id.value, 0, path.str); return ::lrLrRedirectApplicationLegalInformationPath(std::addressof(this->srv), id.value, 0, path.str);
} }
virtual Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override { Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
return lrLrRedirectApplicationLegalInformationPath(std::addressof(this->srv), id.value, owner_id.value, path.str); return ::lrLrRedirectApplicationLegalInformationPath(std::addressof(this->srv), id.value, owner_id.value, path.str);
} }
virtual Result Refresh() override { Result Refresh() {
return lrLrRefresh(std::addressof(this->srv)); return ::lrLrRefresh(std::addressof(this->srv));
} }
virtual Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) override { Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override { Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result ClearApplicationRedirectionDeprecated() override { Result ClearApplicationRedirectionDeprecated() {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result ClearApplicationRedirection(const sf::InArray<ncm::ProgramId> &excluding_ids) override { Result ClearApplicationRedirection(const sf::InArray<ncm::ProgramId> &excluding_ids) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result EraseProgramRedirection(ncm::ProgramId id) override { Result EraseProgramRedirection(ncm::ProgramId id) {
return lrLrEraseProgramRedirection(std::addressof(this->srv), id.value); return ::lrLrEraseProgramRedirection(std::addressof(this->srv), id.value);
} }
virtual Result EraseApplicationControlRedirection(ncm::ProgramId id) override { Result EraseApplicationControlRedirection(ncm::ProgramId id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) override { Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id) override { Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result ResolveProgramPathForDebug(sf::Out<Path> out, ncm::ProgramId id) override { Result ResolveProgramPathForDebug(sf::Out<Path> out, ncm::ProgramId id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) override { Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) override { Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override { Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result EraseProgramRedirectionForDebug(ncm::ProgramId id) override { Result EraseProgramRedirectionForDebug(ncm::ProgramId id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
}; };
static_assert(lr::IsILocationResolver<RemoteLocationResolverImpl>);
} }

View File

@ -19,7 +19,7 @@
namespace ams::lr { namespace ams::lr {
class RemoteRegisteredLocationResolverImpl : public IRegisteredLocationResolver { class RemoteRegisteredLocationResolverImpl {
private: private:
::LrRegisteredLocationResolver srv; ::LrRegisteredLocationResolver srv;
public: public:
@ -28,74 +28,75 @@ namespace ams::lr {
~RemoteRegisteredLocationResolverImpl() { ::serviceClose(&srv.s); } ~RemoteRegisteredLocationResolverImpl() { ::serviceClose(&srv.s); }
public: public:
/* Actual commands. */ /* Actual commands. */
virtual Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) override { Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) {
return lrRegLrResolveProgramPath(std::addressof(this->srv), static_cast<u64>(id), out->str); return ::lrRegLrResolveProgramPath(std::addressof(this->srv), static_cast<u64>(id), out->str);
} }
virtual Result RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id) override { Result RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override { Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result UnregisterProgramPath(ncm::ProgramId id) override { Result UnregisterProgramPath(ncm::ProgramId id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result RedirectProgramPathDeprecated(const Path &path, ncm::ProgramId id) override { Result RedirectProgramPathDeprecated(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override { Result RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result ResolveHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) override { Result ResolveHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result RegisterHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override { Result RegisterHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override { Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result UnregisterHtmlDocumentPath(ncm::ProgramId id) override { Result UnregisterHtmlDocumentPath(ncm::ProgramId id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result RedirectHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override { Result RedirectHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override { Result RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result Refresh() override { Result Refresh() {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result RefreshExcluding(const sf::InArray<ncm::ProgramId> &ids) override { Result RefreshExcluding(const sf::InArray<ncm::ProgramId> &ids) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
}; };
static_assert(lr::IsIRegisteredLocationResolver<RemoteRegisteredLocationResolverImpl>);
} }

View File

@ -27,7 +27,7 @@ namespace ams::ncm {
void Initialize() { void Initialize() {
AMS_ASSERT(g_content_manager == nullptr); AMS_ASSERT(g_content_manager == nullptr);
R_ABORT_UNLESS(ncmInitialize()); R_ABORT_UNLESS(ncmInitialize());
g_content_manager = std::make_shared<RemoteContentManagerImpl>(); g_content_manager = sf::MakeShared<IContentManager, RemoteContentManagerImpl>();
} }
void Finalize() { void Finalize() {

View File

@ -553,23 +553,23 @@ namespace ams::ncm {
if (storage_id == StorageId::GameCard) { if (storage_id == StorageId::GameCard) {
/* Game card content storage is read only. */ /* Game card content storage is read only. */
auto content_storage = std::make_shared<ReadOnlyContentStorageImpl>(); auto content_storage = sf::MakeShared<IContentStorage, ReadOnlyContentStorageImpl>();
R_TRY(content_storage->Initialize(root->path, MakeFlatContentFilePath)); R_TRY(content_storage->GetImpl().Initialize(root->path, MakeFlatContentFilePath));
root->content_storage = std::move(content_storage); root->content_storage = std::move(content_storage);
} else { } else {
/* Create a content storage. */ /* Create a content storage. */
auto content_storage = std::make_shared<ContentStorageImpl>(); auto content_storage = sf::MakeShared<IContentStorage, ContentStorageImpl>();
/* Initialize content storage with an appropriate path function. */ /* Initialize content storage with an appropriate path function. */
switch (storage_id) { switch (storage_id) {
case StorageId::BuiltInSystem: case StorageId::BuiltInSystem:
R_TRY(content_storage->Initialize(root->path, MakeFlatContentFilePath, MakeFlatPlaceHolderFilePath, false, std::addressof(this->rights_id_cache))); R_TRY(content_storage->GetImpl().Initialize(root->path, MakeFlatContentFilePath, MakeFlatPlaceHolderFilePath, false, std::addressof(this->rights_id_cache)));
break; break;
case StorageId::SdCard: case StorageId::SdCard:
R_TRY(content_storage->Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, true, std::addressof(this->rights_id_cache))); R_TRY(content_storage->GetImpl().Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, true, std::addressof(this->rights_id_cache)));
break; break;
default: default:
R_TRY(content_storage->Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, false, std::addressof(this->rights_id_cache))); R_TRY(content_storage->GetImpl().Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, false, std::addressof(this->rights_id_cache)));
break; break;
} }
@ -617,7 +617,7 @@ namespace ams::ncm {
R_TRY(root->kvs->Initialize(root->max_content_metas, root->memory_resource)); R_TRY(root->kvs->Initialize(root->max_content_metas, root->memory_resource));
/* Create an on memory content meta database for game cards. */ /* Create an on memory content meta database for game cards. */
root->content_meta_database = std::make_shared<OnMemoryContentMetaDatabaseImpl>(std::addressof(*root->kvs)); root->content_meta_database = sf::MakeShared<IContentMetaDatabase, OnMemoryContentMetaDatabaseImpl>(std::addressof(*root->kvs));
} else { } else {
/* Mount save data for this root. */ /* Mount save data for this root. */
R_TRY(fs::MountSystemSaveData(root->mount_name, root->info.space_id, root->info.id)); R_TRY(fs::MountSystemSaveData(root->mount_name, root->info.space_id, root->info.id));
@ -630,7 +630,7 @@ namespace ams::ncm {
R_TRY(root->kvs->Load()); R_TRY(root->kvs->Load());
/* Create the content meta database. */ /* Create the content meta database. */
root->content_meta_database = std::make_shared<ContentMetaDatabaseImpl>(std::addressof(*root->kvs), root->mount_name); root->content_meta_database = sf::MakeShared<IContentMetaDatabase, ContentMetaDatabaseImpl>(std::addressof(*root->kvs), root->mount_name);
mount_guard.Cancel(); mount_guard.Cancel();
} }

View File

@ -18,7 +18,7 @@
namespace ams::ncm { namespace ams::ncm {
class ContentMetaDatabaseImplBase : public IContentMetaDatabase { class ContentMetaDatabaseImplBase {
NON_COPYABLE(ContentMetaDatabaseImplBase); NON_COPYABLE(ContentMetaDatabaseImplBase);
NON_MOVEABLE(ContentMetaDatabaseImplBase); NON_MOVEABLE(ContentMetaDatabaseImplBase);
protected: protected:
@ -52,6 +52,32 @@ namespace ams::ncm {
R_TRY(this->GetContentMetaSize(out_size, key)); R_TRY(this->GetContentMetaSize(out_size, key));
return this->kvs->GetValuePointer(reinterpret_cast<const ContentMetaHeader **>(out_value_ptr), key); return this->kvs->GetValuePointer(reinterpret_cast<const ContentMetaHeader **>(out_value_ptr), key);
} }
public:
/* Actual commands. */
virtual Result Set(const ContentMetaKey &key, sf::InBuffer value) = 0;
virtual Result Get(sf::Out<u64> out_size, const ContentMetaKey &key, sf::OutBuffer out_value) = 0;
virtual Result Remove(const ContentMetaKey &key) = 0;
virtual Result GetContentIdByType(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type) = 0;
virtual Result ListContentInfo(sf::Out<s32> out_entries_written, const sf::OutArray<ContentInfo> &out_info, const ContentMetaKey &key, s32 offset) = 0;
virtual Result List(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaKey> &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) = 0;
virtual Result GetLatestContentMetaKey(sf::Out<ContentMetaKey> out_key, u64 id) = 0;
virtual Result ListApplication(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ApplicationContentMetaKey> &out_keys, ContentMetaType meta_type) = 0;
virtual Result Has(sf::Out<bool> out, const ContentMetaKey &key) = 0;
virtual Result HasAll(sf::Out<bool> out, const sf::InArray<ContentMetaKey> &keys) = 0;
virtual Result GetSize(sf::Out<u64> out_size, const ContentMetaKey &key) = 0;
virtual Result GetRequiredSystemVersion(sf::Out<u32> out_version, const ContentMetaKey &key) = 0;
virtual Result GetPatchId(sf::Out<PatchId> out_patch_id, const ContentMetaKey &key) = 0;
virtual Result DisableForcibly() = 0;
virtual Result LookupOrphanContent(const sf::OutArray<bool> &out_orphaned, const sf::InArray<ContentId> &content_ids) = 0;
virtual Result Commit() = 0;
virtual Result HasContent(sf::Out<bool> out, const ContentMetaKey &key, const ContentId &content_id) = 0;
virtual Result ListContentMetaInfo(sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaInfo> &out_meta_info, const ContentMetaKey &key, s32 offset) = 0;
virtual Result GetAttributes(sf::Out<u8> out_attributes, const ContentMetaKey &key) = 0;
virtual Result GetRequiredApplicationVersion(sf::Out<u32> out_version, const ContentMetaKey &key) = 0;
virtual Result GetContentIdByTypeAndIdOffset(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) = 0;
virtual Result GetCount(sf::Out<u32> out_count) = 0;
virtual Result GetOwnerApplicationId(sf::Out<ApplicationId> out_id, const ContentMetaKey &key) = 0;
}; };
static_assert(ncm::IsIContentMetaDatabase<ContentMetaDatabaseImplBase>);
} }

View File

@ -18,7 +18,7 @@
namespace ams::ncm { namespace ams::ncm {
class ContentStorageImplBase : public IContentStorage { class ContentStorageImplBase {
NON_COPYABLE(ContentStorageImplBase); NON_COPYABLE(ContentStorageImplBase);
NON_MOVEABLE(ContentStorageImplBase); NON_MOVEABLE(ContentStorageImplBase);
protected: protected:
@ -43,6 +43,39 @@ namespace ams::ncm {
} }
return ResultSuccess(); return ResultSuccess();
} }
public:
/* Actual commands. */
virtual Result GeneratePlaceHolderId(sf::Out<PlaceHolderId> out) = 0;
virtual Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) = 0;
virtual Result DeletePlaceHolder(PlaceHolderId placeholder_id) = 0;
virtual Result HasPlaceHolder(sf::Out<bool> out, PlaceHolderId placeholder_id) = 0;
virtual Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, sf::InBuffer data) = 0;
virtual Result Register(PlaceHolderId placeholder_id, ContentId content_id) = 0;
virtual Result Delete(ContentId content_id) = 0;
virtual Result Has(sf::Out<bool> out, ContentId content_id) = 0;
virtual Result GetPath(sf::Out<Path> out, ContentId content_id) = 0;
virtual Result GetPlaceHolderPath(sf::Out<Path> out, PlaceHolderId placeholder_id) = 0;
virtual Result CleanupAllPlaceHolder() = 0;
virtual Result ListPlaceHolder(sf::Out<s32> out_count, const sf::OutArray<PlaceHolderId> &out_buf) = 0;
virtual Result GetContentCount(sf::Out<s32> out_count) = 0;
virtual Result ListContentId(sf::Out<s32> out_count, const sf::OutArray<ContentId> &out_buf, s32 start_offset) = 0;
virtual Result GetSizeFromContentId(sf::Out<s64> out_size, ContentId content_id) = 0;
virtual Result DisableForcibly() = 0;
virtual Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) = 0;
virtual Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) = 0;
virtual Result ReadContentIdFile(sf::OutBuffer buf, ContentId content_id, s64 offset) = 0;
virtual Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, PlaceHolderId placeholder_id) = 0;
virtual Result GetRightsIdFromPlaceHolderId(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id) = 0;
virtual Result GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) = 0;
virtual Result GetRightsIdFromContentId(sf::Out<ncm::RightsId> out_rights_id, ContentId content_id) = 0;
virtual Result WriteContentForDebug(ContentId content_id, s64 offset, sf::InBuffer data) = 0;
virtual Result GetFreeSpaceSize(sf::Out<s64> out_size) = 0;
virtual Result GetTotalSpaceSize(sf::Out<s64> out_size) = 0;
virtual Result FlushPlaceHolder() = 0;
virtual Result GetSizeFromPlaceHolderId(sf::Out<s64> out, PlaceHolderId placeholder_id) = 0;
virtual Result RepairInvalidFileAttribute() = 0;
virtual Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) = 0;
}; };
static_assert(ncm::IsIContentStorage<ContentStorageImplBase>);
} }

View File

@ -20,80 +20,81 @@
namespace ams::ncm { namespace ams::ncm {
class RemoteContentManagerImpl final : public IContentManager { class RemoteContentManagerImpl final {
public: public:
RemoteContentManagerImpl() { /* ... */ } RemoteContentManagerImpl() { /* ... */ }
~RemoteContentManagerImpl() { /* ... */ } ~RemoteContentManagerImpl() { /* ... */ }
public: public:
virtual Result CreateContentStorage(StorageId storage_id) override { Result CreateContentStorage(StorageId storage_id) {
return ::ncmCreateContentStorage(static_cast<NcmStorageId>(storage_id)); return ::ncmCreateContentStorage(static_cast<NcmStorageId>(storage_id));
} }
virtual Result CreateContentMetaDatabase(StorageId storage_id) override { Result CreateContentMetaDatabase(StorageId storage_id) {
return ::ncmCreateContentMetaDatabase(static_cast<NcmStorageId>(storage_id)); return ::ncmCreateContentMetaDatabase(static_cast<NcmStorageId>(storage_id));
} }
virtual Result VerifyContentStorage(StorageId storage_id) override { Result VerifyContentStorage(StorageId storage_id) {
return ::ncmVerifyContentStorage(static_cast<NcmStorageId>(storage_id)); return ::ncmVerifyContentStorage(static_cast<NcmStorageId>(storage_id));
} }
virtual Result VerifyContentMetaDatabase(StorageId storage_id) override { Result VerifyContentMetaDatabase(StorageId storage_id) {
return ::ncmVerifyContentMetaDatabase(static_cast<NcmStorageId>(storage_id)); return ::ncmVerifyContentMetaDatabase(static_cast<NcmStorageId>(storage_id));
} }
virtual Result OpenContentStorage(sf::Out<std::shared_ptr<IContentStorage>> out, StorageId storage_id) override { Result OpenContentStorage(sf::Out<std::shared_ptr<IContentStorage>> out, StorageId storage_id) {
NcmContentStorage cs; NcmContentStorage cs;
R_TRY(::ncmOpenContentStorage(std::addressof(cs), static_cast<NcmStorageId>(storage_id))); R_TRY(::ncmOpenContentStorage(std::addressof(cs), static_cast<NcmStorageId>(storage_id)));
out.SetValue(std::make_shared<RemoteContentStorageImpl>(cs)); out.SetValue(sf::MakeShared<IContentStorage, RemoteContentStorageImpl>(cs));
return ResultSuccess(); return ResultSuccess();
} }
virtual Result OpenContentMetaDatabase(sf::Out<std::shared_ptr<IContentMetaDatabase>> out, StorageId storage_id) override { Result OpenContentMetaDatabase(sf::Out<std::shared_ptr<IContentMetaDatabase>> out, StorageId storage_id) {
NcmContentMetaDatabase db; NcmContentMetaDatabase db;
R_TRY(::ncmOpenContentMetaDatabase(std::addressof(db), static_cast<NcmStorageId>(storage_id))); R_TRY(::ncmOpenContentMetaDatabase(std::addressof(db), static_cast<NcmStorageId>(storage_id)));
out.SetValue(std::make_shared<RemoteContentMetaDatabaseImpl>(db)); out.SetValue(sf::MakeShared<IContentMetaDatabase, RemoteContentMetaDatabaseImpl>(db));
return ResultSuccess(); return ResultSuccess();
} }
virtual Result CloseContentStorageForcibly(StorageId storage_id) override { Result CloseContentStorageForcibly(StorageId storage_id) {
return ::ncmCloseContentStorageForcibly(static_cast<NcmStorageId>(storage_id)); return ::ncmCloseContentStorageForcibly(static_cast<NcmStorageId>(storage_id));
} }
virtual Result CloseContentMetaDatabaseForcibly(StorageId storage_id) override { Result CloseContentMetaDatabaseForcibly(StorageId storage_id) {
return ::ncmCloseContentMetaDatabaseForcibly(static_cast<NcmStorageId>(storage_id)); return ::ncmCloseContentMetaDatabaseForcibly(static_cast<NcmStorageId>(storage_id));
} }
virtual Result CleanupContentMetaDatabase(StorageId storage_id) override { Result CleanupContentMetaDatabase(StorageId storage_id) {
return ::ncmCleanupContentMetaDatabase(static_cast<NcmStorageId>(storage_id)); return ::ncmCleanupContentMetaDatabase(static_cast<NcmStorageId>(storage_id));
} }
virtual Result ActivateContentStorage(StorageId storage_id) override { Result ActivateContentStorage(StorageId storage_id) {
return ::ncmActivateContentStorage(static_cast<NcmStorageId>(storage_id)); return ::ncmActivateContentStorage(static_cast<NcmStorageId>(storage_id));
} }
virtual Result InactivateContentStorage(StorageId storage_id) override { Result InactivateContentStorage(StorageId storage_id) {
return ::ncmInactivateContentStorage(static_cast<NcmStorageId>(storage_id)); return ::ncmInactivateContentStorage(static_cast<NcmStorageId>(storage_id));
} }
virtual Result ActivateContentMetaDatabase(StorageId storage_id) override { Result ActivateContentMetaDatabase(StorageId storage_id) {
return ::ncmActivateContentMetaDatabase(static_cast<NcmStorageId>(storage_id)); return ::ncmActivateContentMetaDatabase(static_cast<NcmStorageId>(storage_id));
} }
virtual Result InactivateContentMetaDatabase(StorageId storage_id) override { Result InactivateContentMetaDatabase(StorageId storage_id) {
return ::ncmInactivateContentMetaDatabase(static_cast<NcmStorageId>(storage_id)); return ::ncmInactivateContentMetaDatabase(static_cast<NcmStorageId>(storage_id));
} }
virtual Result InvalidateRightsIdCache() override { Result InvalidateRightsIdCache() {
return ::ncmInvalidateRightsIdCache(); return ::ncmInvalidateRightsIdCache();
} }
virtual Result GetMemoryReport(sf::Out<MemoryReport> out) override { Result GetMemoryReport(sf::Out<MemoryReport> out) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
}; };
static_assert(ncm::IsIContentManager<RemoteContentManagerImpl>);
} }

View File

@ -18,7 +18,7 @@
namespace ams::ncm { namespace ams::ncm {
class RemoteContentMetaDatabaseImpl final : public IContentMetaDatabase { class RemoteContentMetaDatabaseImpl final {
private: private:
::NcmContentMetaDatabase srv; ::NcmContentMetaDatabase srv;
public: public:
@ -71,101 +71,101 @@ namespace ams::ncm {
return reinterpret_cast<const ::NcmContentId *>(std::addressof(c)); return reinterpret_cast<const ::NcmContentId *>(std::addressof(c));
} }
public: public:
virtual Result Set(const ContentMetaKey &key, sf::InBuffer value) override { Result Set(const ContentMetaKey &key, sf::InBuffer value) {
return ncmContentMetaDatabaseSet(std::addressof(this->srv), Convert(key), value.GetPointer(), value.GetSize()); return ncmContentMetaDatabaseSet(std::addressof(this->srv), Convert(key), value.GetPointer(), value.GetSize());
} }
virtual Result Get(sf::Out<u64> out_size, const ContentMetaKey &key, sf::OutBuffer out_value) override { Result Get(sf::Out<u64> out_size, const ContentMetaKey &key, sf::OutBuffer out_value) {
return ncmContentMetaDatabaseGet(std::addressof(this->srv), Convert(key), out_size.GetPointer(), out_value.GetPointer(), out_value.GetSize()); return ncmContentMetaDatabaseGet(std::addressof(this->srv), Convert(key), out_size.GetPointer(), out_value.GetPointer(), out_value.GetSize());
} }
virtual Result Remove(const ContentMetaKey &key) override { Result Remove(const ContentMetaKey &key) {
return ncmContentMetaDatabaseRemove(std::addressof(this->srv), Convert(key)); return ncmContentMetaDatabaseRemove(std::addressof(this->srv), Convert(key));
} }
virtual Result GetContentIdByType(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type) override { Result GetContentIdByType(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type) {
return ncmContentMetaDatabaseGetContentIdByType(std::addressof(this->srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type)); return ncmContentMetaDatabaseGetContentIdByType(std::addressof(this->srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type));
} }
virtual Result ListContentInfo(sf::Out<s32> out_entries_written, const sf::OutArray<ContentInfo> &out_info, const ContentMetaKey &key, s32 offset) override { Result ListContentInfo(sf::Out<s32> out_entries_written, const sf::OutArray<ContentInfo> &out_info, const ContentMetaKey &key, s32 offset) {
return ncmContentMetaDatabaseListContentInfo(std::addressof(this->srv), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), Convert(key), offset); return ncmContentMetaDatabaseListContentInfo(std::addressof(this->srv), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), Convert(key), offset);
} }
virtual Result List(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaKey> &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) override { Result List(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaKey> &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) {
return ncmContentMetaDatabaseList(std::addressof(this->srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), static_cast<::NcmContentMetaType>(meta_type), application_id.value, min, max, static_cast<::NcmContentInstallType>(install_type)); return ncmContentMetaDatabaseList(std::addressof(this->srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), static_cast<::NcmContentMetaType>(meta_type), application_id.value, min, max, static_cast<::NcmContentInstallType>(install_type));
} }
virtual Result GetLatestContentMetaKey(sf::Out<ContentMetaKey> out_key, u64 id) override { Result GetLatestContentMetaKey(sf::Out<ContentMetaKey> out_key, u64 id) {
return ncmContentMetaDatabaseGetLatestContentMetaKey(std::addressof(this->srv), Convert(out_key.GetPointer()), static_cast<u64>(id)); return ncmContentMetaDatabaseGetLatestContentMetaKey(std::addressof(this->srv), Convert(out_key.GetPointer()), static_cast<u64>(id));
} }
virtual Result ListApplication(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ApplicationContentMetaKey> &out_keys, ContentMetaType meta_type) override { Result ListApplication(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ApplicationContentMetaKey> &out_keys, ContentMetaType meta_type) {
return ncmContentMetaDatabaseListApplication(std::addressof(this->srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_keys.GetPointer()), out_keys.GetSize(), static_cast<::NcmContentMetaType>(meta_type)); return ncmContentMetaDatabaseListApplication(std::addressof(this->srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_keys.GetPointer()), out_keys.GetSize(), static_cast<::NcmContentMetaType>(meta_type));
} }
virtual Result Has(sf::Out<bool> out, const ContentMetaKey &key) override { Result Has(sf::Out<bool> out, const ContentMetaKey &key) {
return ncmContentMetaDatabaseHas(std::addressof(this->srv), out.GetPointer(), Convert(key)); return ncmContentMetaDatabaseHas(std::addressof(this->srv), out.GetPointer(), Convert(key));
} }
virtual Result HasAll(sf::Out<bool> out, const sf::InArray<ContentMetaKey> &keys) override { Result HasAll(sf::Out<bool> out, const sf::InArray<ContentMetaKey> &keys) {
return ncmContentMetaDatabaseHasAll(std::addressof(this->srv), out.GetPointer(), Convert(keys.GetPointer()), keys.GetSize()); return ncmContentMetaDatabaseHasAll(std::addressof(this->srv), out.GetPointer(), Convert(keys.GetPointer()), keys.GetSize());
} }
virtual Result GetSize(sf::Out<u64> out_size, const ContentMetaKey &key) override { Result GetSize(sf::Out<u64> out_size, const ContentMetaKey &key) {
return ncmContentMetaDatabaseGetSize(std::addressof(this->srv), out_size.GetPointer(), Convert(key)); return ncmContentMetaDatabaseGetSize(std::addressof(this->srv), out_size.GetPointer(), Convert(key));
} }
virtual Result GetRequiredSystemVersion(sf::Out<u32> out_version, const ContentMetaKey &key) override { Result GetRequiredSystemVersion(sf::Out<u32> out_version, const ContentMetaKey &key) {
return ncmContentMetaDatabaseGetRequiredSystemVersion(std::addressof(this->srv), out_version.GetPointer(), Convert(key)); return ncmContentMetaDatabaseGetRequiredSystemVersion(std::addressof(this->srv), out_version.GetPointer(), Convert(key));
} }
virtual Result GetPatchId(sf::Out<PatchId> out_patch_id, const ContentMetaKey &key) override { Result GetPatchId(sf::Out<PatchId> out_patch_id, const ContentMetaKey &key) {
return ncmContentMetaDatabaseGetPatchId(std::addressof(this->srv), reinterpret_cast<u64 *>(out_patch_id.GetPointer()), Convert(key)); return ncmContentMetaDatabaseGetPatchId(std::addressof(this->srv), reinterpret_cast<u64 *>(out_patch_id.GetPointer()), Convert(key));
} }
virtual Result DisableForcibly() override { Result DisableForcibly() {
return ncmContentMetaDatabaseDisableForcibly(std::addressof(this->srv)); return ncmContentMetaDatabaseDisableForcibly(std::addressof(this->srv));
} }
virtual Result LookupOrphanContent(const sf::OutArray<bool> &out_orphaned, const sf::InArray<ContentId> &content_ids) override { Result LookupOrphanContent(const sf::OutArray<bool> &out_orphaned, const sf::InArray<ContentId> &content_ids) {
return ncmContentMetaDatabaseLookupOrphanContent(std::addressof(this->srv), out_orphaned.GetPointer(), Convert(content_ids.GetPointer()), std::min(out_orphaned.GetSize(), content_ids.GetSize())); return ncmContentMetaDatabaseLookupOrphanContent(std::addressof(this->srv), out_orphaned.GetPointer(), Convert(content_ids.GetPointer()), std::min(out_orphaned.GetSize(), content_ids.GetSize()));
} }
virtual Result Commit() override { Result Commit() {
return ncmContentMetaDatabaseCommit(std::addressof(this->srv)); return ncmContentMetaDatabaseCommit(std::addressof(this->srv));
} }
virtual Result HasContent(sf::Out<bool> out, const ContentMetaKey &key, const ContentId &content_id) override { Result HasContent(sf::Out<bool> out, const ContentMetaKey &key, const ContentId &content_id) {
return ncmContentMetaDatabaseHasContent(std::addressof(this->srv), out.GetPointer(), Convert(key), Convert(content_id)); return ncmContentMetaDatabaseHasContent(std::addressof(this->srv), out.GetPointer(), Convert(key), Convert(content_id));
} }
virtual Result ListContentMetaInfo(sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaInfo> &out_meta_info, const ContentMetaKey &key, s32 offset) override { Result ListContentMetaInfo(sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaInfo> &out_meta_info, const ContentMetaKey &key, s32 offset) {
return ncmContentMetaDatabaseListContentMetaInfo(std::addressof(this->srv), out_entries_written.GetPointer(), out_meta_info.GetPointer(), out_meta_info.GetSize(), Convert(key), offset); return ncmContentMetaDatabaseListContentMetaInfo(std::addressof(this->srv), out_entries_written.GetPointer(), out_meta_info.GetPointer(), out_meta_info.GetSize(), Convert(key), offset);
} }
virtual Result GetAttributes(sf::Out<u8> out_attributes, const ContentMetaKey &key) override { Result GetAttributes(sf::Out<u8> out_attributes, const ContentMetaKey &key) {
static_assert(sizeof(ContentMetaAttribute) == sizeof(u8)); static_assert(sizeof(ContentMetaAttribute) == sizeof(u8));
return ncmContentMetaDatabaseGetAttributes(std::addressof(this->srv), Convert(key), out_attributes.GetPointer()); return ncmContentMetaDatabaseGetAttributes(std::addressof(this->srv), Convert(key), out_attributes.GetPointer());
} }
virtual Result GetRequiredApplicationVersion(sf::Out<u32> out_version, const ContentMetaKey &key) override { Result GetRequiredApplicationVersion(sf::Out<u32> out_version, const ContentMetaKey &key) {
return ncmContentMetaDatabaseGetRequiredApplicationVersion(std::addressof(this->srv), out_version.GetPointer(), Convert(key)); return ncmContentMetaDatabaseGetRequiredApplicationVersion(std::addressof(this->srv), out_version.GetPointer(), Convert(key));
} }
virtual Result GetContentIdByTypeAndIdOffset(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) override { Result GetContentIdByTypeAndIdOffset(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) {
return ncmContentMetaDatabaseGetContentIdByTypeAndIdOffset(std::addressof(this->srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type), id_offset); return ncmContentMetaDatabaseGetContentIdByTypeAndIdOffset(std::addressof(this->srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type), id_offset);
} }
virtual Result GetCount(sf::Out<u32> out_count) override { Result GetCount(sf::Out<u32> out_count) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result GetOwnerApplicationId(sf::Out<ApplicationId> out_id, const ContentMetaKey &key) override { Result GetOwnerApplicationId(sf::Out<ApplicationId> out_id, const ContentMetaKey &key) {
/* TODO: libnx bindings */ /* TODO: libnx bindings */
AMS_ABORT(); AMS_ABORT();
} }
}; };
static_assert(ncm::IsIContentMetaDatabase<RemoteContentMetaDatabaseImpl>);
} }

View File

@ -18,7 +18,7 @@
namespace ams::ncm { namespace ams::ncm {
class RemoteContentStorageImpl final : public IContentStorage { class RemoteContentStorageImpl final {
private: private:
::NcmContentStorage srv; ::NcmContentStorage srv;
public: public:
@ -46,85 +46,85 @@ namespace ams::ncm {
return reinterpret_cast<::NcmContentId *>(std::addressof(c)); return reinterpret_cast<::NcmContentId *>(std::addressof(c));
} }
public: public:
virtual Result GeneratePlaceHolderId(sf::Out<PlaceHolderId> out) override { Result GeneratePlaceHolderId(sf::Out<PlaceHolderId> out) {
return ncmContentStorageGeneratePlaceHolderId(std::addressof(this->srv), Convert(out.GetPointer())); return ncmContentStorageGeneratePlaceHolderId(std::addressof(this->srv), Convert(out.GetPointer()));
} }
virtual Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) override { Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) {
static_assert(alignof(ContentId) < alignof(PlaceHolderId)); static_assert(alignof(ContentId) < alignof(PlaceHolderId));
return ncmContentStorageCreatePlaceHolder(std::addressof(this->srv), Convert(content_id), Convert(placeholder_id), size); return ncmContentStorageCreatePlaceHolder(std::addressof(this->srv), Convert(content_id), Convert(placeholder_id), size);
} }
virtual Result DeletePlaceHolder(PlaceHolderId placeholder_id) override { Result DeletePlaceHolder(PlaceHolderId placeholder_id) {
return ncmContentStorageDeletePlaceHolder(std::addressof(this->srv), Convert(placeholder_id)); return ncmContentStorageDeletePlaceHolder(std::addressof(this->srv), Convert(placeholder_id));
} }
virtual Result HasPlaceHolder(sf::Out<bool> out, PlaceHolderId placeholder_id) override { Result HasPlaceHolder(sf::Out<bool> out, PlaceHolderId placeholder_id) {
return ncmContentStorageHasPlaceHolder(std::addressof(this->srv), out.GetPointer(), Convert(placeholder_id)); return ncmContentStorageHasPlaceHolder(std::addressof(this->srv), out.GetPointer(), Convert(placeholder_id));
} }
virtual Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, sf::InBuffer data) override { Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, sf::InBuffer data) {
return ncmContentStorageWritePlaceHolder(std::addressof(this->srv), Convert(placeholder_id), offset, data.GetPointer(), data.GetSize()); return ncmContentStorageWritePlaceHolder(std::addressof(this->srv), Convert(placeholder_id), offset, data.GetPointer(), data.GetSize());
} }
virtual Result Register(PlaceHolderId placeholder_id, ContentId content_id) override { Result Register(PlaceHolderId placeholder_id, ContentId content_id) {
static_assert(alignof(ContentId) < alignof(PlaceHolderId)); static_assert(alignof(ContentId) < alignof(PlaceHolderId));
return ncmContentStorageRegister(std::addressof(this->srv), Convert(content_id), Convert(placeholder_id)); return ncmContentStorageRegister(std::addressof(this->srv), Convert(content_id), Convert(placeholder_id));
} }
virtual Result Delete(ContentId content_id) override { Result Delete(ContentId content_id) {
return ncmContentStorageDelete(std::addressof(this->srv), Convert(content_id)); return ncmContentStorageDelete(std::addressof(this->srv), Convert(content_id));
} }
virtual Result Has(sf::Out<bool> out, ContentId content_id) override { Result Has(sf::Out<bool> out, ContentId content_id) {
return ncmContentStorageHas(std::addressof(this->srv), out.GetPointer(), Convert(content_id)); return ncmContentStorageHas(std::addressof(this->srv), out.GetPointer(), Convert(content_id));
} }
virtual Result GetPath(sf::Out<Path> out, ContentId content_id) override { Result GetPath(sf::Out<Path> out, ContentId content_id) {
return ncmContentStorageGetPath(std::addressof(this->srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(content_id)); return ncmContentStorageGetPath(std::addressof(this->srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(content_id));
} }
virtual Result GetPlaceHolderPath(sf::Out<Path> out, PlaceHolderId placeholder_id) override { Result GetPlaceHolderPath(sf::Out<Path> out, PlaceHolderId placeholder_id) {
return ncmContentStorageGetPlaceHolderPath(std::addressof(this->srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(placeholder_id)); return ncmContentStorageGetPlaceHolderPath(std::addressof(this->srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(placeholder_id));
} }
virtual Result CleanupAllPlaceHolder() override { Result CleanupAllPlaceHolder() {
return ncmContentStorageCleanupAllPlaceHolder(std::addressof(this->srv)); return ncmContentStorageCleanupAllPlaceHolder(std::addressof(this->srv));
} }
virtual Result ListPlaceHolder(sf::Out<s32> out_count, const sf::OutArray<PlaceHolderId> &out_buf) override { Result ListPlaceHolder(sf::Out<s32> out_count, const sf::OutArray<PlaceHolderId> &out_buf) {
return ncmContentStorageListPlaceHolder(std::addressof(this->srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer()); return ncmContentStorageListPlaceHolder(std::addressof(this->srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer());
} }
virtual Result GetContentCount(sf::Out<s32> out_count) override { Result GetContentCount(sf::Out<s32> out_count) {
return ncmContentStorageGetContentCount(std::addressof(this->srv), out_count.GetPointer()); return ncmContentStorageGetContentCount(std::addressof(this->srv), out_count.GetPointer());
} }
virtual Result ListContentId(sf::Out<s32> out_count, const sf::OutArray<ContentId> &out_buf, s32 offset) override { Result ListContentId(sf::Out<s32> out_count, const sf::OutArray<ContentId> &out_buf, s32 offset) {
return ncmContentStorageListContentId(std::addressof(this->srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer(), offset); return ncmContentStorageListContentId(std::addressof(this->srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer(), offset);
} }
virtual Result GetSizeFromContentId(sf::Out<s64> out_size, ContentId content_id) override { Result GetSizeFromContentId(sf::Out<s64> out_size, ContentId content_id) {
return ncmContentStorageGetSizeFromContentId(std::addressof(this->srv), out_size.GetPointer(), Convert(content_id)); return ncmContentStorageGetSizeFromContentId(std::addressof(this->srv), out_size.GetPointer(), Convert(content_id));
} }
virtual Result DisableForcibly() override { Result DisableForcibly() {
return ncmContentStorageDisableForcibly(std::addressof(this->srv)); return ncmContentStorageDisableForcibly(std::addressof(this->srv));
} }
virtual Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) override { Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) {
return ncmContentStorageRevertToPlaceHolder(std::addressof(this->srv), Convert(placeholder_id), Convert(old_content_id), Convert(new_content_id)); return ncmContentStorageRevertToPlaceHolder(std::addressof(this->srv), Convert(placeholder_id), Convert(old_content_id), Convert(new_content_id));
} }
virtual Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) override { Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) {
return ncmContentStorageSetPlaceHolderSize(std::addressof(this->srv), Convert(placeholder_id), size); return ncmContentStorageSetPlaceHolderSize(std::addressof(this->srv), Convert(placeholder_id), size);
} }
virtual Result ReadContentIdFile(sf::OutBuffer buf, ContentId content_id, s64 offset) override { Result ReadContentIdFile(sf::OutBuffer buf, ContentId content_id, s64 offset) {
return ncmContentStorageReadContentIdFile(std::addressof(this->srv), buf.GetPointer(), buf.GetSize(), Convert(content_id), offset); return ncmContentStorageReadContentIdFile(std::addressof(this->srv), buf.GetPointer(), buf.GetSize(), Convert(content_id), offset);
} }
virtual Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, PlaceHolderId placeholder_id) override { Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, PlaceHolderId placeholder_id) {
::NcmRightsId rights_id; ::NcmRightsId rights_id;
R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(this->srv), std::addressof(rights_id), Convert(placeholder_id))); R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(this->srv), std::addressof(rights_id), Convert(placeholder_id)));
@ -133,7 +133,7 @@ namespace ams::ncm {
return ResultSuccess(); return ResultSuccess();
} }
virtual Result GetRightsIdFromPlaceHolderId(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id) override { Result GetRightsIdFromPlaceHolderId(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id) {
::NcmRightsId rights_id; ::NcmRightsId rights_id;
R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(this->srv), std::addressof(rights_id), Convert(placeholder_id))); R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(this->srv), std::addressof(rights_id), Convert(placeholder_id)));
@ -142,7 +142,7 @@ namespace ams::ncm {
return ResultSuccess(); return ResultSuccess();
} }
virtual Result GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) override { Result GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) {
::NcmRightsId rights_id; ::NcmRightsId rights_id;
R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(this->srv), std::addressof(rights_id), Convert(content_id))); R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(this->srv), std::addressof(rights_id), Convert(content_id)));
@ -151,7 +151,7 @@ namespace ams::ncm {
return ResultSuccess(); return ResultSuccess();
} }
virtual Result GetRightsIdFromContentId(sf::Out<ncm::RightsId> out_rights_id, ContentId content_id) override { Result GetRightsIdFromContentId(sf::Out<ncm::RightsId> out_rights_id, ContentId content_id) {
::NcmRightsId rights_id; ::NcmRightsId rights_id;
R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(this->srv), std::addressof(rights_id), Convert(content_id))); R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(this->srv), std::addressof(rights_id), Convert(content_id)));
@ -160,35 +160,36 @@ namespace ams::ncm {
return ResultSuccess(); return ResultSuccess();
} }
virtual Result WriteContentForDebug(ContentId content_id, s64 offset, sf::InBuffer data) override { Result WriteContentForDebug(ContentId content_id, s64 offset, sf::InBuffer data) {
return ncmContentStorageWriteContentForDebug(std::addressof(this->srv), Convert(content_id), offset, data.GetPointer(), data.GetSize()); return ncmContentStorageWriteContentForDebug(std::addressof(this->srv), Convert(content_id), offset, data.GetPointer(), data.GetSize());
} }
virtual Result GetFreeSpaceSize(sf::Out<s64> out_size) override { Result GetFreeSpaceSize(sf::Out<s64> out_size) {
return ncmContentStorageGetFreeSpaceSize(std::addressof(this->srv), out_size.GetPointer()); return ncmContentStorageGetFreeSpaceSize(std::addressof(this->srv), out_size.GetPointer());
} }
virtual Result GetTotalSpaceSize(sf::Out<s64> out_size) override { Result GetTotalSpaceSize(sf::Out<s64> out_size) {
return ncmContentStorageGetTotalSpaceSize(std::addressof(this->srv), out_size.GetPointer()); return ncmContentStorageGetTotalSpaceSize(std::addressof(this->srv), out_size.GetPointer());
} }
virtual Result FlushPlaceHolder() override { Result FlushPlaceHolder() {
return ncmContentStorageFlushPlaceHolder(std::addressof(this->srv)); return ncmContentStorageFlushPlaceHolder(std::addressof(this->srv));
} }
virtual Result GetSizeFromPlaceHolderId(sf::Out<s64> out_size, PlaceHolderId placeholder_id) override { Result GetSizeFromPlaceHolderId(sf::Out<s64> out_size, PlaceHolderId placeholder_id) {
return ncmContentStorageGetSizeFromPlaceHolderId(std::addressof(this->srv), out_size.GetPointer(), Convert(placeholder_id)); return ncmContentStorageGetSizeFromPlaceHolderId(std::addressof(this->srv), out_size.GetPointer(), Convert(placeholder_id));
} }
virtual Result RepairInvalidFileAttribute() override { Result RepairInvalidFileAttribute() {
return ncmContentStorageRepairInvalidFileAttribute(std::addressof(this->srv)); return ncmContentStorageRepairInvalidFileAttribute(std::addressof(this->srv));
} }
virtual Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) override { Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) {
static_assert(sizeof(::NcmRightsId) == sizeof(ncm::RightsId)); static_assert(sizeof(::NcmRightsId) == sizeof(ncm::RightsId));
::NcmRightsId *out = reinterpret_cast<::NcmRightsId *>(out_rights_id.GetPointer()); ::NcmRightsId *out = reinterpret_cast<::NcmRightsId *>(out_rights_id.GetPointer());
return ncmContentStorageGetRightsIdFromPlaceHolderIdWithCache(std::addressof(this->srv), out, Convert(placeholder_id), Convert(cache_content_id)); return ncmContentStorageGetRightsIdFromPlaceHolderIdWithCache(std::addressof(this->srv), out, Convert(placeholder_id), Convert(cache_content_id));
} }
}; };
static_assert(ncm::IsIContentStorage<RemoteContentStorageImpl>);
} }

View File

@ -18,28 +18,29 @@
namespace ams::pgl { namespace ams::pgl {
class RemoteEventObserver final : public pgl::sf::IEventObserver { class RemoteEventObserver final {
NON_COPYABLE(RemoteEventObserver); NON_COPYABLE(RemoteEventObserver);
NON_MOVEABLE(RemoteEventObserver); NON_MOVEABLE(RemoteEventObserver);
private: private:
::PglEventObserver observer; ::PglEventObserver observer;
public: public:
constexpr RemoteEventObserver(const ::PglEventObserver &o) : observer(o) { /* ... */ } constexpr RemoteEventObserver(const ::PglEventObserver &o) : observer(o) { /* ... */ }
virtual ~RemoteEventObserver() override { ~RemoteEventObserver() {
::pglEventObserverClose(std::addressof(this->observer)); ::pglEventObserverClose(std::addressof(this->observer));
} }
virtual Result GetProcessEventHandle(ams::sf::OutCopyHandle out) override { Result GetProcessEventHandle(ams::sf::OutCopyHandle out) {
::Event ev; ::Event ev;
R_TRY(::pglEventObserverGetProcessEvent(std::addressof(this->observer), std::addressof(ev))); R_TRY(::pglEventObserverGetProcessEvent(std::addressof(this->observer), std::addressof(ev)));
out.SetValue(ev.revent); out.SetValue(ev.revent);
return ResultSuccess(); return ResultSuccess();
} }
virtual Result GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out) override { Result GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out) {
static_assert(sizeof(*out.GetPointer()) == sizeof(::PmProcessEventInfo)); static_assert(sizeof(*out.GetPointer()) == sizeof(::PmProcessEventInfo));
return ::pglEventObserverGetProcessEventInfo(std::addressof(this->observer), reinterpret_cast<::PmProcessEventInfo *>(out.GetPointer())); return ::pglEventObserverGetProcessEventInfo(std::addressof(this->observer), reinterpret_cast<::PmProcessEventInfo *>(out.GetPointer()));
} }
}; };
static_assert(pgl::sf::IsIEventObserver<RemoteEventObserver>);
} }

View File

@ -79,7 +79,7 @@ namespace ams::pgl {
::PglEventObserver obs; ::PglEventObserver obs;
R_TRY(::pglGetEventObserver(std::addressof(obs))); R_TRY(::pglGetEventObserver(std::addressof(obs)));
auto remote_observer = std::make_shared<RemoteEventObserver>(obs); auto remote_observer = ams::sf::MakeShared<pgl::sf::IEventObserver, RemoteEventObserver>(obs);
AMS_ABORT_UNLESS(remote_observer != nullptr); AMS_ABORT_UNLESS(remote_observer != nullptr);
*out = pgl::EventObserver(remote_observer); *out = pgl::EventObserver(remote_observer);

View File

@ -66,13 +66,13 @@ namespace ams::pgl::srv {
this->event.Signal(); this->event.Signal();
} }
Result EventObserverInterface::GetProcessEventHandle(ams::sf::OutCopyHandle out) { Result ShellEventObserver::GetProcessEventHandle(ams::sf::OutCopyHandle out) {
out.SetValue(GetReference(this->observer).GetEvent().GetReadableHandle()); out.SetValue(this->GetEvent().GetReadableHandle());
return ResultSuccess(); return ResultSuccess();
} }
Result EventObserverInterface::GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out) { Result ShellEventObserver::GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out) {
return GetReference(this->observer).PopEventInfo(out.GetPointer()); return this->PopEventInfo(out.GetPointer());
} }
} }

View File

@ -56,23 +56,10 @@ namespace ams::pgl::srv {
Result PopEventInfo(pm::ProcessEventInfo *out); Result PopEventInfo(pm::ProcessEventInfo *out);
virtual void Notify(const pm::ProcessEventInfo &info) override final; virtual void Notify(const pm::ProcessEventInfo &info) override final;
Result GetProcessEventHandle(ams::sf::OutCopyHandle out);
Result GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out);
}; };
static_assert(pgl::sf::IsIEventObserver<ShellEventObserver>);
class EventObserverInterface final : public pgl::sf::IEventObserver {
private:
TYPED_STORAGE(ShellEventObserver) observer;
public:
EventObserverInterface() {
std::memset(std::addressof(this->observer), 0, sizeof(this->observer));
new (GetPointer(this->observer)) ShellEventObserver;
}
~EventObserverInterface() {
GetReference(this->observer).~ShellEventObserver();
}
public:
virtual Result GetProcessEventHandle(ams::sf::OutCopyHandle out) override final;
virtual Result GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out) override final;
};
} }

View File

@ -69,20 +69,22 @@ namespace ams::pgl::srv {
} }
Result ShellInterface::GetShellEventObserver(ams::sf::Out<std::shared_ptr<pgl::sf::IEventObserver>> out) { Result ShellInterface::GetShellEventObserver(ams::sf::Out<std::shared_ptr<pgl::sf::IEventObserver>> out) {
using Interface = typename pgl::sf::IEventObserver::ImplHolder<ShellEventObserver>;
/* Allocate a new interface. */ /* Allocate a new interface. */
auto *observer_memory = this->memory_resource->Allocate(sizeof(EventObserverInterface), alignof(EventObserverInterface)); auto *observer_memory = this->memory_resource->Allocate(sizeof(Interface), alignof(Interface));
AMS_ABORT_UNLESS(observer_memory != nullptr); AMS_ABORT_UNLESS(observer_memory != nullptr);
/* Create the interface object. */ /* Create the interface object. */
new (observer_memory) EventObserverInterface; new (observer_memory) Interface;
/* Set the output. */ /* Set the output. */
out.SetValue(std::shared_ptr<EventObserverInterface>(reinterpret_cast<EventObserverInterface *>(observer_memory), [&](EventObserverInterface *obj) { out.SetValue(std::shared_ptr<pgl::sf::IEventObserver>(reinterpret_cast<Interface *>(observer_memory), [&](Interface *obj) {
/* Destroy the object. */ /* Destroy the object. */
obj->~EventObserverInterface(); obj->~Interface();
/* Custom deleter: use the memory resource to free. */ /* Custom deleter: use the memory resource to free. */
this->memory_resource->Deallocate(obj, sizeof(EventObserverInterface), alignof(EventObserverInterface)); this->memory_resource->Deallocate(obj, sizeof(Interface), alignof(Interface));
})); }));
return ResultSuccess(); return ResultSuccess();
} }

View File

@ -34,7 +34,7 @@ namespace ams::psc {
::PscPmModule module; ::PscPmModule module;
R_TRY(::pscmGetPmModule(std::addressof(module), static_cast<::PscPmModuleId>(mid), reinterpret_cast<const u16 *>(dependencies), dependency_count, clear_mode == os::EventClearMode_AutoClear)); R_TRY(::pscmGetPmModule(std::addressof(module), static_cast<::PscPmModuleId>(mid), reinterpret_cast<const u16 *>(dependencies), dependency_count, clear_mode == os::EventClearMode_AutoClear));
this->intf = std::make_shared<RemotePmModule>(module); this->intf = ams::sf::MakeShared<psc::sf::IPmModule, RemotePmModule>(module);
this->system_event.AttachReadableHandle(module.event.revent, false, clear_mode); this->system_event.AttachReadableHandle(module.event.revent, false, clear_mode);
this->initialized = true; this->initialized = true;
return ResultSuccess(); return ResultSuccess();

View File

@ -18,41 +18,42 @@
namespace ams::psc { namespace ams::psc {
class RemotePmModule final : public psc::sf::IPmModule { class RemotePmModule final {
NON_COPYABLE(RemotePmModule); NON_COPYABLE(RemotePmModule);
NON_MOVEABLE(RemotePmModule); NON_MOVEABLE(RemotePmModule);
private: private:
::PscPmModule module; ::PscPmModule module;
public: public:
constexpr RemotePmModule(const ::PscPmModule &m) : module(m) { /* ... */ } constexpr RemotePmModule(const ::PscPmModule &m) : module(m) { /* ... */ }
virtual ~RemotePmModule() override { ~RemotePmModule() {
::pscPmModuleClose(std::addressof(this->module)); ::pscPmModuleClose(std::addressof(this->module));
} }
virtual Result Initialize(ams::sf::OutCopyHandle out, psc::PmModuleId module_id, const ams::sf::InBuffer &child_list) override final { Result Initialize(ams::sf::OutCopyHandle out, psc::PmModuleId module_id, const ams::sf::InBuffer &child_list) {
/* NOTE: This functionality is already implemented by the libnx command we use to instantiate the PscPmModule. */ /* NOTE: This functionality is already implemented by the libnx command we use to instantiate the PscPmModule. */
AMS_ABORT(); AMS_ABORT();
} }
virtual Result GetRequest(ams::sf::Out<PmState> out_state, ams::sf::Out<PmFlagSet> out_flags) override final { Result GetRequest(ams::sf::Out<PmState> out_state, ams::sf::Out<PmFlagSet> out_flags) {
static_assert(sizeof(PmState) == sizeof(::PscPmState)); static_assert(sizeof(PmState) == sizeof(::PscPmState));
static_assert(sizeof(PmFlagSet) == sizeof(u32)); static_assert(sizeof(PmFlagSet) == sizeof(u32));
return ::pscPmModuleGetRequest(std::addressof(this->module), reinterpret_cast<::PscPmState *>(out_state.GetPointer()), reinterpret_cast<u32 *>(out_flags.GetPointer())); return ::pscPmModuleGetRequest(std::addressof(this->module), reinterpret_cast<::PscPmState *>(out_state.GetPointer()), reinterpret_cast<u32 *>(out_flags.GetPointer()));
} }
virtual Result Acknowledge() override final { Result Acknowledge() {
/* NOTE: libnx does not separate acknowledge/acknowledgeEx. */ /* NOTE: libnx does not separate acknowledge/acknowledgeEx. */
return ::pscPmModuleAcknowledge(std::addressof(this->module), static_cast<::PscPmState>(0)); return ::pscPmModuleAcknowledge(std::addressof(this->module), static_cast<::PscPmState>(0));
} }
virtual Result Finalize() override final { Result Finalize() {
return ::pscPmModuleFinalize(std::addressof(this->module)); return ::pscPmModuleFinalize(std::addressof(this->module));
} }
virtual Result AcknowledgeEx(PmState state) override final { Result AcknowledgeEx(PmState state) {
static_assert(sizeof(state) == sizeof(::PscPmState)); static_assert(sizeof(state) == sizeof(::PscPmState));
return ::pscPmModuleAcknowledge(std::addressof(this->module), static_cast<::PscPmState>(state)); return ::pscPmModuleAcknowledge(std::addressof(this->module), static_cast<::PscPmState>(state));
} }
}; };
static_assert(psc::sf::IsIPmModule<RemotePmModule>);
} }

View File

@ -20,11 +20,13 @@ namespace ams::sf::hipc::impl {
namespace { namespace {
class MitmQueryService : public IServiceObject { #define AMS_SF_HIPC_IMPL_I_MITM_QUERY_SERVICE_INTERFACE_INFO(C, H) \
private: AMS_SF_METHOD_INFO(C, H, 65000, void, ShouldMitm, (sf::Out<bool> out, const sm::MitmProcessInfo &client_info))
enum class CommandId {
ShouldMitm = 65000, AMS_SF_DEFINE_INTERFACE(IMitmQueryService, AMS_SF_HIPC_IMPL_I_MITM_QUERY_SERVICE_INTERFACE_INFO)
};
class MitmQueryService {
private: private:
ServerManagerBase::MitmQueryFunction query_function; ServerManagerBase::MitmQueryFunction query_function;
public: public:
@ -33,11 +35,8 @@ namespace ams::sf::hipc::impl {
void ShouldMitm(sf::Out<bool> out, const sm::MitmProcessInfo &client_info) { void ShouldMitm(sf::Out<bool> out, const sm::MitmProcessInfo &client_info) {
out.SetValue(this->query_function(client_info)); out.SetValue(this->query_function(client_info));
} }
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MAKE_SERVICE_COMMAND_META(ShouldMitm),
};
}; };
static_assert(IsIMitmQueryService<MitmQueryService>);
/* Globals. */ /* Globals. */
os::Mutex g_query_server_lock(false); os::Mutex g_query_server_lock(false);
@ -66,7 +65,7 @@ namespace ams::sf::hipc::impl {
g_constructed_server = true; g_constructed_server = true;
} }
R_ABORT_UNLESS(GetPointer(g_query_server_storage)->RegisterSession(query_handle, cmif::ServiceObjectHolder(std::make_shared<MitmQueryService>(query_func)))); R_ABORT_UNLESS(GetPointer(g_query_server_storage)->RegisterSession(query_handle, cmif::ServiceObjectHolder(sf::MakeShared<IMitmQueryService, MitmQueryService>(query_func))));
if (AMS_UNLIKELY(!g_registered_any)) { if (AMS_UNLIKELY(!g_registered_any)) {
R_ABORT_UNLESS(os::CreateThread(std::addressof(g_query_server_process_thread), &QueryServerProcessThreadMain, GetPointer(g_query_server_storage), g_server_process_thread_stack, sizeof(g_server_process_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(mitm_sf, QueryServerProcessThread))); R_ABORT_UNLESS(os::CreateThread(std::addressof(g_query_server_process_thread), &QueryServerProcessThreadMain, GetPointer(g_query_server_storage), g_server_process_thread_stack, sizeof(g_server_process_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(mitm_sf, QueryServerProcessThread)));

View File

@ -19,15 +19,16 @@ namespace ams::sf::hipc {
namespace impl { namespace impl {
class HipcManager : public IServiceObject { #define AMS_SF_HIPC_IMPL_I_HIPC_MANAGER_INTERFACE_INFO(C, H) \
private: AMS_SF_METHOD_INFO(C, H, 0, Result, ConvertCurrentObjectToDomain, (ams::sf::Out<ams::sf::cmif::DomainObjectId> out)) \
enum class CommandId { AMS_SF_METHOD_INFO(C, H, 1, Result, CopyFromCurrentDomain, (ams::sf::OutMoveHandle out, ams::sf::cmif::DomainObjectId object_id)) \
ConvertCurrentObjectToDomain = 0, AMS_SF_METHOD_INFO(C, H, 2, Result, CloneCurrentObject, (ams::sf::OutMoveHandle out)) \
CopyFromCurrentDomain = 1, AMS_SF_METHOD_INFO(C, H, 3, void, QueryPointerBufferSize, (ams::sf::Out<u16> out)) \
CloneCurrentObject = 2, AMS_SF_METHOD_INFO(C, H, 4, Result, CloneCurrentObjectEx, (ams::sf::OutMoveHandle out, u32 tag))
QueryPointerBufferSize = 3,
CloneCurrentObjectEx = 4, AMS_SF_DEFINE_INTERFACE(IHipcManager, AMS_SF_HIPC_IMPL_I_HIPC_MANAGER_INTERFACE_INFO)
};
class HipcManager final {
private: private:
ServerDomainSessionManager *manager; ServerDomainSessionManager *manager;
ServerSession *session; ServerSession *session;
@ -150,16 +151,8 @@ namespace ams::sf::hipc {
Result CloneCurrentObjectEx(sf::OutMoveHandle out, u32 tag) { Result CloneCurrentObjectEx(sf::OutMoveHandle out, u32 tag) {
return this->CloneCurrentObjectImpl(out.GetHandlePointer(), this->manager->GetSessionManagerByTag(tag)); return this->CloneCurrentObjectImpl(out.GetHandlePointer(), this->manager->GetSessionManagerByTag(tag));
} }
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MAKE_SERVICE_COMMAND_META(ConvertCurrentObjectToDomain),
MAKE_SERVICE_COMMAND_META(CopyFromCurrentDomain),
MAKE_SERVICE_COMMAND_META(CloneCurrentObject),
MAKE_SERVICE_COMMAND_META(QueryPointerBufferSize),
MAKE_SERVICE_COMMAND_META(CloneCurrentObjectEx),
};
}; };
static_assert(IsIHipcManager<HipcManager>);
} }
@ -168,7 +161,7 @@ namespace ams::sf::hipc {
/* Note: This is safe, as no additional references to the hipc manager can ever be stored. */ /* Note: This is safe, as no additional references to the hipc manager can ever be stored. */
/* The shared pointer to stack object is definitely gross, though. */ /* The shared pointer to stack object is definitely gross, though. */
impl::HipcManager hipc_manager(this, session); impl::HipcManager hipc_manager(this, session);
return this->DispatchRequest(cmif::ServiceObjectHolder(std::move(ServiceObjectTraits<impl::HipcManager>::SharedPointerHelper::GetEmptyDeleteSharedPointer(&hipc_manager))), session, in_message, out_message); return this->DispatchRequest(cmif::ServiceObjectHolder(sf::GetSharedPointerTo<impl::IHipcManager>(hipc_manager)), session, in_message, out_message);
} }
} }