From 78fe75acf4bb2a936eefc172841e75159f49b0a0 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Wed, 26 Feb 2020 01:42:35 +1100 Subject: [PATCH] Move dispatch tables out of interface files --- .../lr_location_resolver_manager_impl.cpp | 4 +- .../lr_location_resolver_manager_impl.hpp | 13 ++- .../source/lr_content_location_resolver.hpp | 56 ++++++------- .../ncm/source/lr_i_location_resolver.hpp | 29 ------- .../lr_i_location_resolver_interface.hpp | 84 +++++++++++++++++++ .../source/lr_i_location_resolver_manager.hpp | 11 +-- .../lr_redirect_only_location_resolver.hpp | 2 +- 7 files changed, 127 insertions(+), 72 deletions(-) create mode 100644 stratosphere/ncm/source/lr_i_location_resolver_interface.hpp diff --git a/stratosphere/ncm/source/impl/lr_location_resolver_manager_impl.cpp b/stratosphere/ncm/source/impl/lr_location_resolver_manager_impl.cpp index 70cea04cb..cbc70d823 100644 --- a/stratosphere/ncm/source/impl/lr_location_resolver_manager_impl.cpp +++ b/stratosphere/ncm/source/impl/lr_location_resolver_manager_impl.cpp @@ -20,7 +20,7 @@ namespace ams::lr::impl { - Result LocationResolverManagerImpl::OpenLocationResolver(sf::Out> out, ncm::StorageId storage_id) { + Result LocationResolverManagerImpl::OpenLocationResolver(sf::Out> out, ncm::StorageId storage_id) { std::scoped_lock lk(g_mutex); auto resolver = g_location_resolvers.Find(storage_id); @@ -35,7 +35,7 @@ namespace ams::lr::impl { resolver = g_location_resolvers.Find(storage_id); } - std::shared_ptr new_intf = *resolver; + std::shared_ptr new_intf = *resolver; out.SetValue(std::move(new_intf)); return ResultSuccess(); } diff --git a/stratosphere/ncm/source/impl/lr_location_resolver_manager_impl.hpp b/stratosphere/ncm/source/impl/lr_location_resolver_manager_impl.hpp index 17c838c6a..e188400f8 100644 --- a/stratosphere/ncm/source/impl/lr_location_resolver_manager_impl.hpp +++ b/stratosphere/ncm/source/impl/lr_location_resolver_manager_impl.hpp @@ -19,7 +19,7 @@ #include #include "../lr_add_on_content_location_resolver.hpp" -#include "../lr_i_location_resolver.hpp" +#include "../lr_i_location_resolver_interface.hpp" #include "../lr_i_location_resolver_manager.hpp" #include "../lr_registered_location_resolver.hpp" #include "ncm_bounded_map.hpp" @@ -28,16 +28,23 @@ namespace ams::lr::impl { class LocationResolverManagerImpl final : public ILocationResolverManager { private: - ncm::impl::BoundedMap, 5> g_location_resolvers; + ncm::impl::BoundedMap, 5> g_location_resolvers; std::shared_ptr g_registered_location_resolver = nullptr; std::shared_ptr g_add_on_content_location_resolver = nullptr; os::Mutex g_mutex; public: /* Actual commands. */ - virtual Result OpenLocationResolver(sf::Out> out, ncm::StorageId storage_id) override; + virtual Result OpenLocationResolver(sf::Out> out, ncm::StorageId storage_id) override; virtual Result OpenRegisteredLocationResolver(sf::Out> out) override; virtual Result RefreshLocationResolver(ncm::StorageId storage_id) override; virtual Result OpenAddOnContentLocationResolver(sf::Out> out) override; + public: + DEFINE_SERVICE_DISPATCH_TABLE { + MAKE_SERVICE_COMMAND_META(OpenLocationResolver), + MAKE_SERVICE_COMMAND_META(OpenRegisteredLocationResolver), + MAKE_SERVICE_COMMAND_META(RefreshLocationResolver), + MAKE_SERVICE_COMMAND_META(OpenAddOnContentLocationResolver, hos::Version_200), + }; }; } diff --git a/stratosphere/ncm/source/lr_content_location_resolver.hpp b/stratosphere/ncm/source/lr_content_location_resolver.hpp index 3ff4ed9bf..6f19cc85c 100644 --- a/stratosphere/ncm/source/lr_content_location_resolver.hpp +++ b/stratosphere/ncm/source/lr_content_location_resolver.hpp @@ -18,13 +18,13 @@ #include #include -#include "lr_i_location_resolver.hpp" +#include "lr_i_location_resolver_interface.hpp" #include "ncm_i_content_meta_database.hpp" #include "ncm_i_content_storage.hpp" namespace ams::lr { - class ContentLocationResolverInterface : public ILocationResolver { + class ContentLocationResolverInterface : public ILocationResolverInterface { private: ncm::StorageId storage_id; std::shared_ptr content_meta_database; @@ -64,32 +64,32 @@ namespace ams::lr { virtual Result EraseProgramRedirectionForDebug(ncm::ProgramId id) override; public: DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, ResolveProgramPath), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, RedirectProgramPath), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, ResolveApplicationControlPath), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, ResolveApplicationHtmlDocumentPath), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, ResolveDataPath), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, RedirectApplicationControlPathDeprecated, hos::Version_100, hos::Version_810), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, RedirectApplicationControlPath, hos::Version_900), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, RedirectApplicationHtmlDocumentPathDeprecated, hos::Version_100, hos::Version_810), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, RedirectApplicationHtmlDocumentPath, hos::Version_900), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, ResolveApplicationLegalInformationPath), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, RedirectApplicationLegalInformationPathDeprecated, hos::Version_100, hos::Version_810), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, RedirectApplicationLegalInformationPath, hos::Version_900), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, Refresh), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, RedirectApplicationProgramPathDeprecated, hos::Version_500, hos::Version_810), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, RedirectApplicationProgramPath, hos::Version_900), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, ClearApplicationRedirectionDeprecated, hos::Version_500, hos::Version_810), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, ClearApplicationRedirection, hos::Version_900), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, EraseProgramRedirection, hos::Version_500), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, EraseApplicationControlRedirection, hos::Version_500), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, EraseApplicationHtmlDocumentRedirection, hos::Version_500), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, EraseApplicationLegalInformationRedirection, hos::Version_500), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, ResolveProgramPathForDebug, hos::Version_700), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, RedirectProgramPathForDebug, hos::Version_700), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, RedirectApplicationProgramPathForDebugDeprecated, hos::Version_700, hos::Version_810), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, RedirectApplicationProgramPathForDebug, hos::Version_900), - MAKE_SERVICE_COMMAND_META(ContentLocationResolverInterface, EraseProgramRedirectionForDebug, hos::Version_700), + MAKE_SERVICE_COMMAND_META(ResolveProgramPath), + MAKE_SERVICE_COMMAND_META(RedirectProgramPath), + MAKE_SERVICE_COMMAND_META(ResolveApplicationControlPath), + MAKE_SERVICE_COMMAND_META(ResolveApplicationHtmlDocumentPath), + MAKE_SERVICE_COMMAND_META(ResolveDataPath), + MAKE_SERVICE_COMMAND_META(RedirectApplicationControlPathDeprecated, hos::Version_100, hos::Version_810), + MAKE_SERVICE_COMMAND_META(RedirectApplicationControlPath, hos::Version_900), + MAKE_SERVICE_COMMAND_META(RedirectApplicationHtmlDocumentPathDeprecated, hos::Version_100, hos::Version_810), + MAKE_SERVICE_COMMAND_META(RedirectApplicationHtmlDocumentPath, hos::Version_900), + MAKE_SERVICE_COMMAND_META(ResolveApplicationLegalInformationPath), + MAKE_SERVICE_COMMAND_META(RedirectApplicationLegalInformationPathDeprecated, hos::Version_100, hos::Version_810), + MAKE_SERVICE_COMMAND_META(RedirectApplicationLegalInformationPath, hos::Version_900), + MAKE_SERVICE_COMMAND_META(Refresh), + MAKE_SERVICE_COMMAND_META(RedirectApplicationProgramPathDeprecated, hos::Version_500, hos::Version_810), + MAKE_SERVICE_COMMAND_META(RedirectApplicationProgramPath, hos::Version_900), + MAKE_SERVICE_COMMAND_META(ClearApplicationRedirectionDeprecated, hos::Version_500, hos::Version_810), + MAKE_SERVICE_COMMAND_META(ClearApplicationRedirection, hos::Version_900), + MAKE_SERVICE_COMMAND_META(EraseProgramRedirection, hos::Version_500), + MAKE_SERVICE_COMMAND_META(EraseApplicationControlRedirection, hos::Version_500), + MAKE_SERVICE_COMMAND_META(EraseApplicationHtmlDocumentRedirection, hos::Version_500), + MAKE_SERVICE_COMMAND_META(EraseApplicationLegalInformationRedirection, hos::Version_500), + MAKE_SERVICE_COMMAND_META(ResolveProgramPathForDebug, hos::Version_700), + MAKE_SERVICE_COMMAND_META(RedirectProgramPathForDebug, hos::Version_700), + MAKE_SERVICE_COMMAND_META(RedirectApplicationProgramPathForDebugDeprecated, hos::Version_700, hos::Version_810), + MAKE_SERVICE_COMMAND_META(RedirectApplicationProgramPathForDebug, hos::Version_900), + MAKE_SERVICE_COMMAND_META(EraseProgramRedirectionForDebug, hos::Version_700), }; }; diff --git a/stratosphere/ncm/source/lr_i_location_resolver.hpp b/stratosphere/ncm/source/lr_i_location_resolver.hpp index 63a59dfc4..437dbc43f 100644 --- a/stratosphere/ncm/source/lr_i_location_resolver.hpp +++ b/stratosphere/ncm/source/lr_i_location_resolver.hpp @@ -105,35 +105,6 @@ namespace ams::lr { virtual Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) = 0; virtual Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) = 0; virtual Result EraseProgramRedirectionForDebug(ncm::ProgramId id) = 0; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(ResolveProgramPath), - MAKE_SERVICE_COMMAND_META(RedirectProgramPath), - MAKE_SERVICE_COMMAND_META(ResolveApplicationControlPath), - MAKE_SERVICE_COMMAND_META(ResolveApplicationHtmlDocumentPath), - MAKE_SERVICE_COMMAND_META(ResolveDataPath), - MAKE_SERVICE_COMMAND_META(RedirectApplicationControlPathDeprecated, hos::Version_100, hos::Version_810), - MAKE_SERVICE_COMMAND_META(RedirectApplicationControlPath, hos::Version_900), - MAKE_SERVICE_COMMAND_META(RedirectApplicationHtmlDocumentPathDeprecated, hos::Version_100, hos::Version_810), - MAKE_SERVICE_COMMAND_META(RedirectApplicationHtmlDocumentPath, hos::Version_900), - MAKE_SERVICE_COMMAND_META(ResolveApplicationLegalInformationPath), - MAKE_SERVICE_COMMAND_META(RedirectApplicationLegalInformationPathDeprecated, hos::Version_100, hos::Version_810), - MAKE_SERVICE_COMMAND_META(RedirectApplicationLegalInformationPath, hos::Version_900), - MAKE_SERVICE_COMMAND_META(Refresh), - MAKE_SERVICE_COMMAND_META(RedirectApplicationProgramPathDeprecated, hos::Version_500, hos::Version_810), - MAKE_SERVICE_COMMAND_META(RedirectApplicationProgramPath, hos::Version_900), - MAKE_SERVICE_COMMAND_META(ClearApplicationRedirectionDeprecated, hos::Version_500, hos::Version_810), - MAKE_SERVICE_COMMAND_META(ClearApplicationRedirection, hos::Version_900), - MAKE_SERVICE_COMMAND_META(EraseProgramRedirection, hos::Version_500), - MAKE_SERVICE_COMMAND_META(EraseApplicationControlRedirection, hos::Version_500), - MAKE_SERVICE_COMMAND_META(EraseApplicationHtmlDocumentRedirection, hos::Version_500), - MAKE_SERVICE_COMMAND_META(EraseApplicationLegalInformationRedirection, hos::Version_500), - MAKE_SERVICE_COMMAND_META(ResolveProgramPathForDebug, hos::Version_700), - MAKE_SERVICE_COMMAND_META(RedirectProgramPathForDebug, hos::Version_700), - MAKE_SERVICE_COMMAND_META(RedirectApplicationProgramPathForDebugDeprecated, hos::Version_700, hos::Version_810), - MAKE_SERVICE_COMMAND_META(RedirectApplicationProgramPathForDebug, hos::Version_900), - MAKE_SERVICE_COMMAND_META(EraseProgramRedirectionForDebug, hos::Version_700), - }; }; } diff --git a/stratosphere/ncm/source/lr_i_location_resolver_interface.hpp b/stratosphere/ncm/source/lr_i_location_resolver_interface.hpp new file mode 100644 index 000000000..cf8231f9a --- /dev/null +++ b/stratosphere/ncm/source/lr_i_location_resolver_interface.hpp @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2019-2020 Adubbz, Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once +#include +#include + +#include "lr_i_location_resolver.hpp" + +namespace ams::lr { + + class ILocationResolverInterface : public ILocationResolver { + public: + virtual Result ResolveProgramPath(sf::Out out, ncm::ProgramId id) = 0; + virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id) = 0; + virtual Result ResolveApplicationControlPath(sf::Out out, ncm::ProgramId id) = 0; + virtual Result ResolveApplicationHtmlDocumentPath(sf::Out out, ncm::ProgramId id) = 0; + virtual Result ResolveDataPath(sf::Out out, ncm::ProgramId id) = 0; + virtual Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) = 0; + virtual Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) = 0; + virtual Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) = 0; + virtual Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) = 0; + virtual Result ResolveApplicationLegalInformationPath(sf::Out out, ncm::ProgramId id) = 0; + virtual Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) = 0; + virtual Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) = 0; + virtual Result Refresh() = 0; + virtual Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) = 0; + virtual Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) = 0; + virtual Result ClearApplicationRedirectionDeprecated() = 0; + virtual Result ClearApplicationRedirection(const sf::InArray &excluding_ids) = 0; + virtual Result EraseProgramRedirection(ncm::ProgramId id) = 0; + virtual Result EraseApplicationControlRedirection(ncm::ProgramId id) = 0; + virtual Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) = 0; + virtual Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id) = 0; + virtual Result ResolveProgramPathForDebug(sf::Out out, ncm::ProgramId id) = 0; + virtual Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) = 0; + virtual Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) = 0; + virtual Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) = 0; + virtual Result EraseProgramRedirectionForDebug(ncm::ProgramId id) = 0; + public: + DEFINE_SERVICE_DISPATCH_TABLE { + MAKE_SERVICE_COMMAND_META(ResolveProgramPath), + MAKE_SERVICE_COMMAND_META(RedirectProgramPath), + MAKE_SERVICE_COMMAND_META(ResolveApplicationControlPath), + MAKE_SERVICE_COMMAND_META(ResolveApplicationHtmlDocumentPath), + MAKE_SERVICE_COMMAND_META(ResolveDataPath), + MAKE_SERVICE_COMMAND_META(RedirectApplicationControlPathDeprecated, hos::Version_100, hos::Version_810), + MAKE_SERVICE_COMMAND_META(RedirectApplicationControlPath, hos::Version_900), + MAKE_SERVICE_COMMAND_META(RedirectApplicationHtmlDocumentPathDeprecated, hos::Version_100, hos::Version_810), + MAKE_SERVICE_COMMAND_META(RedirectApplicationHtmlDocumentPath, hos::Version_900), + MAKE_SERVICE_COMMAND_META(ResolveApplicationLegalInformationPath), + MAKE_SERVICE_COMMAND_META(RedirectApplicationLegalInformationPathDeprecated, hos::Version_100, hos::Version_810), + MAKE_SERVICE_COMMAND_META(RedirectApplicationLegalInformationPath, hos::Version_900), + MAKE_SERVICE_COMMAND_META(Refresh), + MAKE_SERVICE_COMMAND_META(RedirectApplicationProgramPathDeprecated, hos::Version_500, hos::Version_810), + MAKE_SERVICE_COMMAND_META(RedirectApplicationProgramPath, hos::Version_900), + MAKE_SERVICE_COMMAND_META(ClearApplicationRedirectionDeprecated, hos::Version_500, hos::Version_810), + MAKE_SERVICE_COMMAND_META(ClearApplicationRedirection, hos::Version_900), + MAKE_SERVICE_COMMAND_META(EraseProgramRedirection, hos::Version_500), + MAKE_SERVICE_COMMAND_META(EraseApplicationControlRedirection, hos::Version_500), + MAKE_SERVICE_COMMAND_META(EraseApplicationHtmlDocumentRedirection, hos::Version_500), + MAKE_SERVICE_COMMAND_META(EraseApplicationLegalInformationRedirection, hos::Version_500), + MAKE_SERVICE_COMMAND_META(ResolveProgramPathForDebug, hos::Version_700), + MAKE_SERVICE_COMMAND_META(RedirectProgramPathForDebug, hos::Version_700), + MAKE_SERVICE_COMMAND_META(RedirectApplicationProgramPathForDebugDeprecated, hos::Version_700, hos::Version_810), + MAKE_SERVICE_COMMAND_META(RedirectApplicationProgramPathForDebug, hos::Version_900), + MAKE_SERVICE_COMMAND_META(EraseProgramRedirectionForDebug, hos::Version_700), + }; + }; + +} \ No newline at end of file diff --git a/stratosphere/ncm/source/lr_i_location_resolver_manager.hpp b/stratosphere/ncm/source/lr_i_location_resolver_manager.hpp index 7db086710..549e42a3b 100644 --- a/stratosphere/ncm/source/lr_i_location_resolver_manager.hpp +++ b/stratosphere/ncm/source/lr_i_location_resolver_manager.hpp @@ -19,7 +19,7 @@ #include #include "lr_add_on_content_location_resolver.hpp" -#include "lr_i_location_resolver.hpp" +#include "lr_i_location_resolver_interface.hpp" #include "lr_registered_location_resolver.hpp" namespace ams::lr { @@ -34,17 +34,10 @@ namespace ams::lr { }; public: /* Actual commands. */ - virtual Result OpenLocationResolver(sf::Out> out, ncm::StorageId storage_id) = 0; + virtual Result OpenLocationResolver(sf::Out> out, ncm::StorageId storage_id) = 0; virtual Result OpenRegisteredLocationResolver(sf::Out> out) = 0; virtual Result RefreshLocationResolver(ncm::StorageId storage_id) = 0; virtual Result OpenAddOnContentLocationResolver(sf::Out> out) = 0; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(OpenLocationResolver), - MAKE_SERVICE_COMMAND_META(OpenRegisteredLocationResolver), - MAKE_SERVICE_COMMAND_META(RefreshLocationResolver), - MAKE_SERVICE_COMMAND_META(OpenAddOnContentLocationResolver, hos::Version_200), - }; }; } diff --git a/stratosphere/ncm/source/lr_redirect_only_location_resolver.hpp b/stratosphere/ncm/source/lr_redirect_only_location_resolver.hpp index 0650dbc74..a4d298672 100644 --- a/stratosphere/ncm/source/lr_redirect_only_location_resolver.hpp +++ b/stratosphere/ncm/source/lr_redirect_only_location_resolver.hpp @@ -22,7 +22,7 @@ namespace ams::lr { - class RedirectOnlyLocationResolverInterface : public ILocationResolver { + class RedirectOnlyLocationResolverInterface : public ILocationResolverInterface { public: ~RedirectOnlyLocationResolverInterface(); public: