Atmosphere/stratosphere/ncm/source/lr_registeredlocationresolver.hpp
2019-12-10 13:26:13 +11:00

94 lines
5.4 KiB
C++

/*
* Copyright (c) 2019 Adubbz
*
* 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 "impl/lr_redirection.hpp"
#include "impl/lr_registered_data.hpp"
namespace ams::lr {
class RegisteredLocationResolverInterface final : public sf::IServiceObject {
private:
static constexpr size_t MaxRegisteredLocations = 0x20;
protected:
enum class CommandId {
ResolveProgramPath = 0,
RegisterProgramPathDeprecated = 1,
RegisterProgramPath = 1,
UnregisterProgramPath = 2,
RedirectProgramPathDeprecated = 3,
RedirectProgramPath = 3,
ResolveHtmlDocumentPath = 4,
RegisterHtmlDocumentPathDeprecated = 5,
RegisterHtmlDocumentPath = 5,
UnregisterHtmlDocumentPath = 6,
RedirectHtmlDocumentPathDeprecated = 7,
RedirectHtmlDocumentPath = 7,
Refresh = 8,
RefreshExcluding = 9,
};
private:
impl::LocationRedirector program_redirector;
impl::RegisteredLocations<ncm::ProgramId, MaxRegisteredLocations> registered_program_locations;
impl::LocationRedirector html_docs_redirector;
impl::RegisteredLocations<ncm::ProgramId, MaxRegisteredLocations> registered_html_docs_locations;
private:
void ClearRedirections(u32 flags = impl::RedirectionFlags_None);
void RegisterPath(const Path& path, impl::RegisteredLocations<ncm::ProgramId, MaxRegisteredLocations>* locations, ncm::ProgramId tid, ncm::ProgramId owner_tid);
bool ResolvePath(Path* out, impl::LocationRedirector* redirector, impl::RegisteredLocations<ncm::ProgramId, MaxRegisteredLocations>* locations, ncm::ProgramId tid);
Result RefreshImpl(const ncm::ProgramId* excluding_tids, size_t num_tids);
public:
RegisteredLocationResolverInterface() : registered_program_locations(hos::GetVersion() < hos::Version_900 ? 0x10 : MaxRegisteredLocations), registered_html_docs_locations(hos::GetVersion() < hos::Version_900 ? 0x10 : MaxRegisteredLocations) { /* ... */ }
~RegisteredLocationResolverInterface();
Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId tid);
Result RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId tid);
Result RegisterProgramPath(const Path &path, ncm::ProgramId tid, ncm::ProgramId owner_tid);
Result UnregisterProgramPath(ncm::ProgramId tid);
Result RedirectProgramPathDeprecated(const Path &path, ncm::ProgramId tid);
Result RedirectProgramPath(const Path &path, ncm::ProgramId tid, ncm::ProgramId owner_tid);
Result ResolveHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId tid);
Result RegisterHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId tid);
Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId tid, ncm::ProgramId owner_tid);
Result UnregisterHtmlDocumentPath(ncm::ProgramId tid);
Result RedirectHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId tid);
Result RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId tid, ncm::ProgramId owner_tid);
Result Refresh();
Result RefreshExcluding(const sf::InArray<ncm::ProgramId> &tids);
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MAKE_SERVICE_COMMAND_META(ResolveProgramPath),
MAKE_SERVICE_COMMAND_META(RegisterProgramPathDeprecated, hos::Version_100, hos::Version_810),
MAKE_SERVICE_COMMAND_META(RegisterProgramPath, hos::Version_900),
MAKE_SERVICE_COMMAND_META(UnregisterProgramPath),
MAKE_SERVICE_COMMAND_META(RedirectProgramPathDeprecated, hos::Version_100, hos::Version_810),
MAKE_SERVICE_COMMAND_META(RedirectProgramPath, hos::Version_900),
MAKE_SERVICE_COMMAND_META(ResolveHtmlDocumentPath, hos::Version_200),
MAKE_SERVICE_COMMAND_META(RegisterHtmlDocumentPathDeprecated, hos::Version_200, hos::Version_810),
MAKE_SERVICE_COMMAND_META(RegisterHtmlDocumentPath, hos::Version_900),
MAKE_SERVICE_COMMAND_META(UnregisterHtmlDocumentPath, hos::Version_200),
MAKE_SERVICE_COMMAND_META(RedirectHtmlDocumentPathDeprecated, hos::Version_200, hos::Version_810),
MAKE_SERVICE_COMMAND_META(RedirectHtmlDocumentPathDeprecated, hos::Version_900),
MAKE_SERVICE_COMMAND_META(Refresh, hos::Version_700),
MAKE_SERVICE_COMMAND_META(RefreshExcluding, hos::Version_900),
};
};
}