Move dispatch tables out of interface files

This commit is contained in:
Adubbz 2020-02-26 01:42:35 +11:00
parent b000168cfb
commit 78fe75acf4
7 changed files with 127 additions and 72 deletions

View file

@ -20,7 +20,7 @@
namespace ams::lr::impl {
Result LocationResolverManagerImpl::OpenLocationResolver(sf::Out<std::shared_ptr<ILocationResolver>> out, ncm::StorageId storage_id) {
Result LocationResolverManagerImpl::OpenLocationResolver(sf::Out<std::shared_ptr<ILocationResolverInterface>> 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<ILocationResolver> new_intf = *resolver;
std::shared_ptr<ILocationResolverInterface> new_intf = *resolver;
out.SetValue(std::move(new_intf));
return ResultSuccess();
}

View file

@ -19,7 +19,7 @@
#include <stratosphere.hpp>
#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<ncm::StorageId, std::shared_ptr<ILocationResolver>, 5> g_location_resolvers;
ncm::impl::BoundedMap<ncm::StorageId, std::shared_ptr<ILocationResolverInterface>, 5> g_location_resolvers;
std::shared_ptr<RegisteredLocationResolverInterface> g_registered_location_resolver = nullptr;
std::shared_ptr<AddOnContentLocationResolverInterface> g_add_on_content_location_resolver = nullptr;
os::Mutex g_mutex;
public:
/* Actual commands. */
virtual Result OpenLocationResolver(sf::Out<std::shared_ptr<ILocationResolver>> out, ncm::StorageId storage_id) override;
virtual Result OpenLocationResolver(sf::Out<std::shared_ptr<ILocationResolverInterface>> out, ncm::StorageId storage_id) override;
virtual Result OpenRegisteredLocationResolver(sf::Out<std::shared_ptr<RegisteredLocationResolverInterface>> out) override;
virtual Result RefreshLocationResolver(ncm::StorageId storage_id) override;
virtual Result OpenAddOnContentLocationResolver(sf::Out<std::shared_ptr<AddOnContentLocationResolverInterface>> 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),
};
};
}

View file

@ -18,13 +18,13 @@
#include <switch.h>
#include <stratosphere.hpp>
#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<ncm::IContentMetaDatabase> 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),
};
};

View file

@ -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),
};
};
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <switch.h>
#include <stratosphere.hpp>
#include "lr_i_location_resolver.hpp"
namespace ams::lr {
class ILocationResolverInterface : public ILocationResolver {
public:
virtual Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) = 0;
virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id) = 0;
virtual Result ResolveApplicationControlPath(sf::Out<Path> out, ncm::ProgramId id) = 0;
virtual Result ResolveApplicationHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) = 0;
virtual Result ResolveDataPath(sf::Out<Path> 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<Path> 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<ncm::ProgramId> &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<Path> 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),
};
};
}

View file

@ -19,7 +19,7 @@
#include <stratosphere.hpp>
#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<std::shared_ptr<ILocationResolver>> out, ncm::StorageId storage_id) = 0;
virtual Result OpenLocationResolver(sf::Out<std::shared_ptr<ILocationResolverInterface>> out, ncm::StorageId storage_id) = 0;
virtual Result OpenRegisteredLocationResolver(sf::Out<std::shared_ptr<RegisteredLocationResolverInterface>> out) = 0;
virtual Result RefreshLocationResolver(ncm::StorageId storage_id) = 0;
virtual Result OpenAddOnContentLocationResolver(sf::Out<std::shared_ptr<AddOnContentLocationResolverInterface>> 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),
};
};
}

View file

@ -22,7 +22,7 @@
namespace ams::lr {
class RedirectOnlyLocationResolverInterface : public ILocationResolver {
class RedirectOnlyLocationResolverInterface : public ILocationResolverInterface {
public:
~RedirectOnlyLocationResolverInterface();
public: