Revert "hoc-clk: add live vdd2, live boost clock and basic pwm dimming"

This reverts commit 15b7df8ef1.
This commit is contained in:
souldbminersmwc
2025-11-09 16:14:52 -05:00
parent 22ec140738
commit 21a3f953d7
3804 changed files with 435 additions and 570162 deletions

View File

@@ -1,193 +0,0 @@
/*
* Copyright (c) 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/>.
*/
#include <stratosphere.hpp>
#include "lr_add_on_content_location_resolver_impl.hpp"
namespace ams::lr {
namespace {
constexpr const lr::Path EmptyPath = {};
template<size_t N>
Result ResolveAddOnContentPathImpl(Path *out, RedirectionAttributes *out_attr, const RegisteredStorages<ncm::DataId, N> &storages, ncm::DataId id) {
/* Find a storage that contains the given program id. */
ncm::StorageId storage_id = ncm::StorageId::None;
R_UNLESS(storages.Find(std::addressof(storage_id), id), lr::ResultAddOnContentNotFound());
/* Obtain a content meta database for the storage id. */
ncm::ContentMetaDatabase content_meta_database;
R_TRY(ncm::OpenContentMetaDatabase(std::addressof(content_meta_database), storage_id));
/* Find the latest data content info for the given program id. */
ncm::ContentInfo data_content_info;
R_TRY(content_meta_database.GetLatestData(std::addressof(data_content_info), id));
/* Obtain a content storage for the storage id. */
ncm::ContentStorage content_storage;
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), storage_id));
/* Get the path of the data content. */
static_assert(sizeof(lr::Path) == sizeof(ncm::Path));
content_storage.GetPath(reinterpret_cast<ncm::Path *>(out), data_content_info.GetId());
/* Get the redirection attributes. */
*out_attr = RedirectionAttributes::Make(data_content_info.GetContentAttributes());
R_SUCCEED();
}
}
Result AddOnContentLocationResolverImpl::ResolveAddOnContentPath(Path *out, RedirectionAttributes *out_attr, ncm::DataId id) {
/* Try to resolve using our registered storages. */
if (const auto result = ResolveAddOnContentPathImpl(out, out_attr, m_registered_storages, id); R_SUCCEEDED(result) || !lr::ResultAddOnContentNotFound::Includes(result)) {
R_RETURN(result);
}
/* If we failed to find the add-on content by storage, we should check if there's a registered path. */
auto * const found = m_registered_paths.Find(id);
R_UNLESS(found != nullptr, lr::ResultAddOnContentNotFound());
/* Set the output path. */
*out = found->redir_path.path;
*out_attr = found->redir_path.attributes;
R_SUCCEED();
}
Result AddOnContentLocationResolverImpl::ResolveAddOnContentPath(sf::Out<Path> out, ncm::DataId id) {
RedirectionAttributes attr;
R_RETURN(this->ResolveAddOnContentPath(out.GetPointer(), std::addressof(attr), id));
}
Result AddOnContentLocationResolverImpl::RegisterAddOnContentStorageDeprecated(ncm::DataId id, ncm::StorageId storage_id) {
/* Register storage for the given program id. 2.0.0-8.1.0 did not require an owner application id. */
R_UNLESS(m_registered_storages.Register(id, storage_id, ncm::InvalidApplicationId), lr::ResultTooManyRegisteredPaths());
R_SUCCEED();
}
Result AddOnContentLocationResolverImpl::RegisterAddOnContentStorage(ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id) {
/* Register storage for the given program id and owner application. */
R_UNLESS(m_registered_storages.Register(id, storage_id, application_id), lr::ResultTooManyRegisteredPaths());
R_SUCCEED();
}
Result AddOnContentLocationResolverImpl::UnregisterAllAddOnContentPath() {
m_registered_storages.Clear();
m_registered_paths.RemoveAll();
m_registered_other_paths.RemoveAll();
R_SUCCEED();
}
Result AddOnContentLocationResolverImpl::RefreshApplicationAddOnContent(const sf::InArray<ncm::ApplicationId> &ids) {
/* Clear all registered storages excluding the provided program ids. */
m_registered_storages.ClearExcluding(reinterpret_cast<const ncm::ProgramId *>(ids.GetPointer()), ids.GetSize());
auto ShouldRefresh = [&ids](const ncm::DataId &, const OwnedPath &owned_path) {
for (size_t i = 0; i < ids.GetSize(); ++i) {
if (owned_path.owner_id == ids[i]) {
return false;
}
}
return true;
};
m_registered_paths.RemoveIf(ShouldRefresh);
m_registered_other_paths.RemoveIf(ShouldRefresh);
R_SUCCEED();
}
Result AddOnContentLocationResolverImpl::UnregisterApplicationAddOnContent(ncm::ApplicationId id) {
/* Remove entries belonging to the provided application. */
m_registered_storages.UnregisterOwnerProgram(id);
auto ShouldRefresh = [&id](const ncm::DataId &, const OwnedPath &owned_path) {
return owned_path.owner_id == id;
};
m_registered_paths.RemoveIf(ShouldRefresh);
m_registered_other_paths.RemoveIf(ShouldRefresh);
R_SUCCEED();
}
Result AddOnContentLocationResolverImpl::GetRegisteredAddOnContentPaths(Path *out, RedirectionAttributes *out_attr, Path *out2, RedirectionAttributes *out_attr2, ncm::DataId id) {
/* Find a registered path. */
auto * const found = m_registered_paths.Find(id);
if (found == nullptr) {
/* We have no registered path, so perform a normal resolution. */
R_TRY(ResolveAddOnContentPathImpl(out, out_attr, m_registered_storages, id));
/* Clear the second output path. */
*out2 = {};
*out_attr2 = {};
R_SUCCEED();
}
/* Set the output path. */
*out = found->redir_path.path;
*out_attr = found->redir_path.attributes;
/* If we have a second path, set it to output. */
if (auto * const found2 = m_registered_other_paths.Find(id); found2 != nullptr) {
*out2 = found2->redir_path.path;
*out_attr2 = found2->redir_path.attributes;
} else {
*out2 = {};
*out_attr2 = {};
}
R_SUCCEED();
}
Result AddOnContentLocationResolverImpl::GetRegisteredAddOnContentPaths(sf::Out<PathByMapAlias> out, sf::Out<PathByMapAlias> out2, ncm::DataId id) {
RedirectionAttributes attr, attr2;
R_RETURN(this->GetRegisteredAddOnContentPaths(out.GetPointer(), std::addressof(attr), out2.GetPointer(), std::addressof(attr2), id));
}
Result AddOnContentLocationResolverImpl::RegisterAddOnContentPath(ncm::DataId id, ncm::ApplicationId application_id, const lr::PathByMapAlias &path) {
R_RETURN(this->RegisterAddOnContentPaths(id, application_id, path, DefaultRedirectionAttributes, EmptyPath, DefaultRedirectionAttributes));
}
Result AddOnContentLocationResolverImpl::RegisterAddOnContentPaths(ncm::DataId id, ncm::ApplicationId application_id, const lr::PathByMapAlias &path, const lr::PathByMapAlias &path2) {
R_RETURN(this->RegisterAddOnContentPaths(id, application_id, path, DefaultRedirectionAttributes, path2, DefaultRedirectionAttributes));
}
Result AddOnContentLocationResolverImpl::RegisterAddOnContentPaths(ncm::DataId id, ncm::ApplicationId application_id, const Path &path, const RedirectionAttributes &attr, const Path &path2, const RedirectionAttributes &attr2) {
/* Check that it's possible for us to register the path. */
/* NOTE: This check is technically incorrect, if the id is already registered. */
R_UNLESS(!m_registered_paths.IsFull(), lr::ResultTooManyRegisteredPaths());
/* Check that the input path isn't empty. */
R_UNLESS(path.str[0] != '\x00', lr::ResultInvalidPath());
/* Insert the path. */
m_registered_paths.InsertOrAssign(id, OwnedPath{ { path, attr }, application_id });
/* If we have a second path, insert it. */
if (path2.str[0] != '\x00') {
m_registered_other_paths.InsertOrAssign(id, OwnedPath { { path2, attr2 }, application_id });
} else {
m_registered_other_paths.Remove(id);
}
R_SUCCEED();
}
}

View File

@@ -1,66 +0,0 @@
/*
* Copyright (c) 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 <stratosphere.hpp>
#include "lr_location_redirector.hpp"
#include "lr_registered_data.hpp"
namespace ams::lr {
class AddOnContentLocationResolverImpl {
private:
struct OwnedPath {
RedirectionPath redir_path;
ncm::ApplicationId owner_id;
};
private:
/* Storage for RegisteredData entries by data id. */
RegisteredStorages<ncm::DataId, 0x800> m_registered_storages;
ncm::BoundedMap<ncm::DataId, OwnedPath, 8> m_registered_paths;
ncm::BoundedMap<ncm::DataId, OwnedPath, 8> m_registered_other_paths;
private:
static ALWAYS_INLINE size_t GetStorageCapacity() {
const auto version = hos::GetVersion();
if (version >= hos::Version_12_0_0) {
return 0x8;
} else if (version >= hos::Version_9_0_0) {
return 0x2;
} else {
return 0x800;
}
}
public:
AddOnContentLocationResolverImpl() : m_registered_storages(GetStorageCapacity()), m_registered_paths{}, m_registered_other_paths{} { /* ... */ }
/* Actual commands. */
Result ResolveAddOnContentPath(sf::Out<Path> out, ncm::DataId id);
Result RegisterAddOnContentStorageDeprecated(ncm::DataId id, ncm::StorageId storage_id);
Result RegisterAddOnContentStorage(ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id);
Result UnregisterAllAddOnContentPath();
Result RefreshApplicationAddOnContent(const sf::InArray<ncm::ApplicationId> &ids);
Result UnregisterApplicationAddOnContent(ncm::ApplicationId id);
Result GetRegisteredAddOnContentPaths(sf::Out<PathByMapAlias> out, sf::Out<PathByMapAlias> out2, ncm::DataId id);
Result RegisterAddOnContentPath(ncm::DataId id, ncm::ApplicationId application_id, const PathByMapAlias &path);
Result RegisterAddOnContentPaths(ncm::DataId id, ncm::ApplicationId application_id, const PathByMapAlias &path, const PathByMapAlias &path2);
private:
Result ResolveAddOnContentPath(Path *out, RedirectionAttributes *out_attr, ncm::DataId id);
Result GetRegisteredAddOnContentPaths(Path *out, RedirectionAttributes *out_attr, Path *out2, RedirectionAttributes *out_attr2, ncm::DataId id);
Result RegisterAddOnContentPaths(ncm::DataId id, ncm::ApplicationId application_id, const Path &path, const RedirectionAttributes &attr, const Path &path2, const RedirectionAttributes &attr2);
};
static_assert(lr::IsIAddOnContentLocationResolver<AddOnContentLocationResolverImpl>);
}

View File

@@ -1,65 +0,0 @@
/*
* Copyright (c) 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/>.
*/
#include <stratosphere.hpp>
#include "lr_location_resolver_manager_factory.hpp"
namespace ams::lr {
namespace {
constinit sf::SharedPointer<ILocationResolverManager> g_location_resolver_manager;
}
void Initialize() {
AMS_ASSERT(g_location_resolver_manager == nullptr);
g_location_resolver_manager = GetLocationResolverManagerService();
}
void Finalize() {
AMS_ASSERT(g_location_resolver_manager != nullptr);
g_location_resolver_manager = nullptr;
}
Result OpenLocationResolver(LocationResolver *out, ncm::StorageId storage_id) {
sf::SharedPointer<lr::ILocationResolver> lr;
R_TRY(g_location_resolver_manager->OpenLocationResolver(std::addressof(lr), storage_id));
*out = LocationResolver(std::move(lr));
R_SUCCEED();
}
Result OpenRegisteredLocationResolver(RegisteredLocationResolver *out) {
sf::SharedPointer<lr::IRegisteredLocationResolver> lr;
R_TRY(g_location_resolver_manager->OpenRegisteredLocationResolver(std::addressof(lr)));
*out = RegisteredLocationResolver(std::move(lr));
R_SUCCEED();
}
Result OpenAddOnContentLocationResolver(AddOnContentLocationResolver *out) {
sf::SharedPointer<lr::IAddOnContentLocationResolver> lr;
R_TRY(g_location_resolver_manager->OpenAddOnContentLocationResolver(std::addressof(lr)));
*out = AddOnContentLocationResolver(std::move(lr));
R_SUCCEED();
}
Result RefreshLocationResolver(ncm::StorageId storage_id) {
R_RETURN(g_location_resolver_manager->RefreshLocationResolver(storage_id));
}
}

View File

@@ -1,221 +0,0 @@
/*
* Copyright (c) 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/>.
*/
#include <stratosphere.hpp>
#include "lr_content_location_resolver_impl.hpp"
namespace ams::lr {
ContentLocationResolverImpl::~ContentLocationResolverImpl() {
this->ClearRedirections();
}
/* Helper function. */
void ContentLocationResolverImpl::GetContentStoragePath(Path *out, ncm::ContentId content_id) {
static_assert(sizeof(lr::Path) == sizeof(ncm::Path));
m_content_storage.GetPath(reinterpret_cast<ncm::Path *>(out), content_id);
}
Result ContentLocationResolverImpl::ResolveProgramPath(Path *out, RedirectionAttributes *out_attr, ncm::ProgramId id) {
/* Use a redirection if present. */
R_SUCCEED_IF(m_program_redirector.FindRedirection(out, out_attr, id));
/* If we're not enabled, we can't resolve a program. */
R_UNLESS(m_enabled, lr::ResultProgramNotFound())
/* Find the latest program content for the program id. */
ncm::ContentInfo program_content_info;
R_TRY_CATCH(m_content_meta_database.GetLatestProgram(std::addressof(program_content_info), id)) {
R_CONVERT(ncm::ResultContentMetaNotFound, lr::ResultProgramNotFound())
} R_END_TRY_CATCH;
/* Obtain the content path and attributes. */
this->GetContentStoragePath(out, program_content_info.GetId());
*out_attr = RedirectionAttributes::Make(program_content_info.GetContentAttributes());
R_SUCCEED();
}
Result ContentLocationResolverImpl::ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) {
RedirectionAttributes attr;
R_RETURN(this->ResolveProgramPath(out.GetPointer(), std::addressof(attr), id));
}
Result ContentLocationResolverImpl::RedirectProgramPath(const Path &path, ncm::ProgramId id) {
m_program_redirector.SetRedirection(id, path, DefaultRedirectionAttributes);
R_SUCCEED();
}
Result ContentLocationResolverImpl::ResolveApplicationControlPath(sf::Out<Path> out, ncm::ProgramId id) {
RedirectionAttributes attr;
R_UNLESS(m_app_control_redirector.FindRedirection(out.GetPointer(), std::addressof(attr), id), lr::ResultControlNotFound());
R_SUCCEED();
}
Result ContentLocationResolverImpl::ResolveApplicationHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) {
RedirectionAttributes attr;
R_UNLESS(m_html_docs_redirector.FindRedirection(out.GetPointer(), std::addressof(attr), id), lr::ResultHtmlDocumentNotFound());
R_SUCCEED();
}
Result ContentLocationResolverImpl::ResolveDataPath(sf::Out<Path> out, ncm::DataId id) {
/* If we're not enabled, we can't resolve data. */
R_UNLESS(m_enabled, lr::ResultDataNotFound())
/* Find the latest data content info for the program id. */
ncm::ContentInfo data_content_info;
R_TRY(m_content_meta_database.GetLatestData(std::addressof(data_content_info), id));
/* Obtain the content path. */
this->GetContentStoragePath(out.GetPointer(), data_content_info.GetId());
R_SUCCEED();
}
Result ContentLocationResolverImpl::RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) {
m_app_control_redirector.SetRedirection(id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result ContentLocationResolverImpl::RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
m_app_control_redirector.SetRedirection(id, owner_id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result ContentLocationResolverImpl::RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) {
m_html_docs_redirector.SetRedirection(id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result ContentLocationResolverImpl::RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
m_html_docs_redirector.SetRedirection(id, owner_id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result ContentLocationResolverImpl::ResolveApplicationLegalInformationPath(sf::Out<Path> out, ncm::ProgramId id) {
RedirectionAttributes attr;
R_UNLESS(m_legal_info_redirector.FindRedirection(out.GetPointer(), std::addressof(attr), id), lr::ResultLegalInformationNotFound());
R_SUCCEED();
}
Result ContentLocationResolverImpl::RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) {
m_legal_info_redirector.SetRedirection(id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result ContentLocationResolverImpl::RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
m_legal_info_redirector.SetRedirection(id, owner_id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result ContentLocationResolverImpl::Refresh() {
/* Obtain content meta database and content storage objects for this resolver's storage. */
ncm::ContentMetaDatabase meta_db;
ncm::ContentStorage storage;
R_TRY(ncm::OpenContentMetaDatabase(std::addressof(meta_db), m_storage_id));
R_TRY(ncm::OpenContentStorage(std::addressof(storage), m_storage_id));
/* Store the acquired objects. */
m_content_meta_database = std::move(meta_db);
m_content_storage = std::move(storage);
/* Remove any existing redirections. */
this->ClearRedirections();
R_SUCCEED();
}
Result ContentLocationResolverImpl::RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) {
m_program_redirector.SetRedirection(id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result ContentLocationResolverImpl::RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
m_program_redirector.SetRedirection(id, owner_id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result ContentLocationResolverImpl::ClearApplicationRedirectionDeprecated() {
this->ClearRedirections(RedirectionFlags_Application);
R_SUCCEED();
}
Result ContentLocationResolverImpl::ClearApplicationRedirection(const sf::InArray<ncm::ProgramId> &excluding_ids) {
this->ClearRedirections(excluding_ids.GetPointer(), excluding_ids.GetSize());
R_SUCCEED();
}
Result ContentLocationResolverImpl::EraseProgramRedirection(ncm::ProgramId id) {
m_program_redirector.EraseRedirection(id);
R_SUCCEED();
}
Result ContentLocationResolverImpl::EraseApplicationControlRedirection(ncm::ProgramId id) {
m_app_control_redirector.EraseRedirection(id);
R_SUCCEED();
}
Result ContentLocationResolverImpl::EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) {
m_html_docs_redirector.EraseRedirection(id);
R_SUCCEED();
}
Result ContentLocationResolverImpl::EraseApplicationLegalInformationRedirection(ncm::ProgramId id) {
m_legal_info_redirector.EraseRedirection(id);
R_SUCCEED();
}
Result ContentLocationResolverImpl::ResolveProgramPathForDebug(sf::Out<Path> out, ncm::ProgramId id) {
/* Use a redirection if present. */
RedirectionAttributes attr;
R_SUCCEED_IF(m_debug_program_redirector.FindRedirection(out.GetPointer(), std::addressof(attr), id));
/* If we're not enabled, we can't resolve a program. */
R_UNLESS(m_enabled, lr::ResultDebugProgramNotFound())
/* Otherwise find the path for the program id. */
R_TRY_CATCH(this->ResolveProgramPath(out.GetPointer(), std::addressof(attr), id)) {
R_CONVERT(lr::ResultProgramNotFound, lr::ResultDebugProgramNotFound())
} R_END_TRY_CATCH;
R_SUCCEED();
}
Result ContentLocationResolverImpl::RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) {
m_debug_program_redirector.SetRedirection(id, path, DefaultRedirectionAttributes);
R_SUCCEED();
}
Result ContentLocationResolverImpl::RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) {
m_debug_program_redirector.SetRedirection(id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result ContentLocationResolverImpl::RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
m_debug_program_redirector.SetRedirection(id, owner_id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result ContentLocationResolverImpl::EraseProgramRedirectionForDebug(ncm::ProgramId id) {
m_debug_program_redirector.EraseRedirection(id);
R_SUCCEED();
}
Result ContentLocationResolverImpl::Disable() {
m_enabled = false;
R_SUCCEED();
}
}

View File

@@ -1,71 +0,0 @@
/*
* Copyright (c) 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 "lr_location_resolver_impl_base.hpp"
#include "lr_location_redirector.hpp"
namespace ams::lr {
class ContentLocationResolverImpl : public LocationResolverImplBase {
private:
ncm::StorageId m_storage_id;
bool m_enabled;
/* Objects for this storage type. */
ncm::ContentMetaDatabase m_content_meta_database;
ncm::ContentStorage m_content_storage;
public:
ContentLocationResolverImpl(ncm::StorageId storage_id, bool enabled) : m_storage_id(storage_id), m_enabled(enabled), m_content_meta_database(), m_content_storage() { /* ... */ }
~ContentLocationResolverImpl();
private:
/* Helper functions. */
void GetContentStoragePath(Path *out, ncm::ContentId content_id);
Result ResolveProgramPath(Path *out, RedirectionAttributes *out_attr, ncm::ProgramId id);
public:
/* Actual commands. */
Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id);
Result RedirectProgramPath(const Path &path, ncm::ProgramId id);
Result ResolveApplicationControlPath(sf::Out<Path> out, ncm::ProgramId id);
Result ResolveApplicationHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id);
Result ResolveDataPath(sf::Out<Path> out, ncm::DataId id);
Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result ResolveApplicationLegalInformationPath(sf::Out<Path> out, ncm::ProgramId id);
Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result Refresh();
Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result ClearApplicationRedirectionDeprecated();
Result ClearApplicationRedirection(const sf::InArray<ncm::ProgramId> &excluding_ids);
Result EraseProgramRedirection(ncm::ProgramId id);
Result EraseApplicationControlRedirection(ncm::ProgramId id);
Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id);
Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id);
Result ResolveProgramPathForDebug(sf::Out<Path> out, ncm::ProgramId id);
Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id);
Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result EraseProgramRedirectionForDebug(ncm::ProgramId id);
Result Disable();
};
static_assert(lr::IsILocationResolver<ContentLocationResolverImpl>);
}

View File

@@ -1,125 +0,0 @@
/*
* Copyright (c) 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/>.
*/
#include <stratosphere.hpp>
#include "lr_location_redirector.hpp"
namespace ams::lr {
class LocationRedirector::Redirection : public util::IntrusiveListBaseNode<Redirection> {
NON_COPYABLE(Redirection);
NON_MOVEABLE(Redirection);
private:
ncm::ProgramId m_program_id;
ncm::ProgramId m_owner_id;
Path m_path;
RedirectionAttributes m_attr;
u32 m_flags;
public:
Redirection(ncm::ProgramId program_id, ncm::ProgramId owner_id, const Path &path, const RedirectionAttributes &attr, u32 flags) :
m_program_id(program_id), m_owner_id(owner_id), m_path(path), m_attr(attr), m_flags(flags) { /* ... */ }
ncm::ProgramId GetProgramId() const {
return m_program_id;
}
ncm::ProgramId GetOwnerProgramId() const {
return m_owner_id;
}
void GetPath(Path *out) const {
*out = m_path;
}
void GetAttributes(RedirectionAttributes *out) const {
*out = m_attr;
}
u32 GetFlags() const {
return m_flags;
}
void SetFlags(u32 flags) {
m_flags = flags;
}
};
bool LocationRedirector::FindRedirection(Path *out, RedirectionAttributes *out_attr, ncm::ProgramId program_id) const {
/* Obtain the path of a matching redirection. */
for (const auto &redirection : m_redirection_list) {
if (redirection.GetProgramId() == program_id) {
redirection.GetPath(out);
redirection.GetAttributes(out_attr);
return true;
}
}
return false;
}
void LocationRedirector::SetRedirection(ncm::ProgramId program_id, const Path &path, const RedirectionAttributes &attr, u32 flags) {
this->SetRedirection(program_id, ncm::InvalidProgramId, path, attr, flags);
}
void LocationRedirector::SetRedirection(ncm::ProgramId program_id, ncm::ProgramId owner_id, const Path &path, const RedirectionAttributes &attr, u32 flags) {
/* Remove any existing redirections for this program id. */
this->EraseRedirection(program_id);
/* Insert a new redirection into the list. */
m_redirection_list.push_back(*(new Redirection(program_id, owner_id, path, attr, flags)));
}
void LocationRedirector::EraseRedirection(ncm::ProgramId program_id) {
/* Remove any redirections with a matching program id. */
for (auto it = m_redirection_list.begin(); it != m_redirection_list.end(); /* ... */) {
if (it->GetProgramId() == program_id) {
auto *redirection = std::addressof(*it);
it = m_redirection_list.erase(it);
delete redirection;
break;
} else {
++it;
}
}
}
void LocationRedirector::ClearRedirections(u32 flags) {
/* Remove any redirections with matching flags. */
for (auto it = m_redirection_list.begin(); it != m_redirection_list.end(); /* ... */) {
if ((it->GetFlags() & flags) == flags) {
auto *redirection = std::addressof(*it);
it = m_redirection_list.erase(it);
delete redirection;
} else {
++it;
}
}
}
void LocationRedirector::ClearRedirectionsExcludingOwners(const ncm::ProgramId *excluding_ids, size_t num_ids) {
for (auto it = m_redirection_list.begin(); it != m_redirection_list.end();) {
/* Skip removal if the redirection has an excluded owner program id. */
if (this->IsExcluded(it->GetOwnerProgramId(), excluding_ids, num_ids)) {
it++;
continue;
}
/* Remove the redirection. */
auto *redirection = std::addressof(*it);
it = m_redirection_list.erase(it);
delete redirection;
}
}
}

View File

@@ -1,80 +0,0 @@
/*
* Copyright (c) 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 <stratosphere.hpp>
namespace ams::lr {
enum RedirectionFlags {
RedirectionFlags_None = (0 << 0),
RedirectionFlags_Application = (1 << 0),
};
/* TODO: Do any of these unknown fields exist? */
struct RedirectionAttributes {
fs::ContentAttributes content_attributes;
u8 unknown[0xF];
static constexpr ALWAYS_INLINE RedirectionAttributes Make(fs::ContentAttributes attr) {
return { attr, };
}
};
static_assert(util::is_pod<RedirectionAttributes>::value);
static_assert(sizeof(RedirectionAttributes) == 0x10);
constexpr inline const RedirectionAttributes DefaultRedirectionAttributes = RedirectionAttributes::Make(fs::ContentAttributes_None);
struct RedirectionPath {
Path path;
RedirectionAttributes attributes;
};
static_assert(util::is_pod<RedirectionPath>::value);
static_assert(sizeof(RedirectionPath) == 0x310);
class LocationRedirector {
NON_COPYABLE(LocationRedirector);
NON_MOVEABLE(LocationRedirector);
private:
class Redirection;
private:
using RedirectionList = ams::util::IntrusiveListBaseTraits<Redirection>::ListType;
private:
RedirectionList m_redirection_list;
public:
LocationRedirector() : m_redirection_list() { /* ... */ }
~LocationRedirector() { this->ClearRedirections(); }
/* API. */
bool FindRedirection(Path *out, RedirectionAttributes *out_attr, ncm::ProgramId program_id) const;
void SetRedirection(ncm::ProgramId program_id, const Path &path, const RedirectionAttributes &attr, u32 flags = RedirectionFlags_None);
void SetRedirection(ncm::ProgramId program_id, ncm::ProgramId owner_id, const Path &path, const RedirectionAttributes &attr, u32 flags = RedirectionFlags_None);
void EraseRedirection(ncm::ProgramId program_id);
void ClearRedirections(u32 flags = RedirectionFlags_None);
void ClearRedirectionsExcludingOwners(const ncm::ProgramId *excluding_ids, size_t num_ids);
private:
inline bool IsExcluded(const ncm::ProgramId id, const ncm::ProgramId *excluding_ids, size_t num_ids) const {
for (size_t i = 0; i < num_ids; i++) {
if (id == excluding_ids[i]) {
return true;
}
}
return false;
}
};
}

View File

@@ -1,54 +0,0 @@
/*
* Copyright (c) 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 <stratosphere.hpp>
#include "lr_location_redirector.hpp"
namespace ams::lr {
class LocationResolverImplBase {
NON_COPYABLE(LocationResolverImplBase);
NON_MOVEABLE(LocationResolverImplBase);
protected:
/* Location redirectors. */
LocationRedirector m_program_redirector;
LocationRedirector m_debug_program_redirector;
LocationRedirector m_app_control_redirector;
LocationRedirector m_html_docs_redirector;
LocationRedirector m_legal_info_redirector;
protected:
LocationResolverImplBase() : m_program_redirector(), m_debug_program_redirector(), m_app_control_redirector(), m_html_docs_redirector(), m_legal_info_redirector() { /* ... */ }
protected:
/* Helper functions. */
void ClearRedirections(u32 flags = RedirectionFlags_None) {
m_program_redirector.ClearRedirections(flags);
m_debug_program_redirector.ClearRedirections(flags);
m_app_control_redirector.ClearRedirections(flags);
m_html_docs_redirector.ClearRedirections(flags);
m_legal_info_redirector.ClearRedirections(flags);
}
void ClearRedirections(const ncm::ProgramId *excluding_ids, size_t num_ids) {
m_program_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids);
m_debug_program_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids);
m_app_control_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids);
m_html_docs_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids);
m_legal_info_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids);
}
};
}

View File

@@ -1,40 +0,0 @@
/*
* Copyright (c) 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/>.
*/
#include <stratosphere.hpp>
#include <stratosphere/lr/lr_location_resolver_manager_impl.hpp>
#include "lr_remote_location_resolver_manager_impl.hpp"
namespace ams::lr {
namespace {
class StaticAllocatorInitializer {
public:
StaticAllocatorInitializer() {
LocationResolverManagerAllocator::Initialize(lmem::CreateOption_None);
}
} g_static_allocator_initializer;
}
sf::SharedPointer<ILocationResolverManager> GetLocationResolverManagerService() {
#if defined(ATMOSPHERE_OS_HORIZON)
return LocationResolverManagerFactory::CreateSharedEmplaced<ILocationResolverManager, RemoteLocationResolverManagerImpl>();
#else
return LocationResolverManagerFactory::CreateSharedEmplaced<ILocationResolverManager, LocationResolverManagerImpl>();
#endif
}
}

View File

@@ -1,29 +0,0 @@
/*
* Copyright (c) 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 <stratosphere.hpp>
namespace ams::lr {
struct LocationResolverManagerAllocatorTag;
using LocationResolverManagerAllocator = sf::ExpHeapStaticAllocator<1_KB, LocationResolverManagerAllocatorTag>;
using LocationResolverManagerFactory = sf::ObjectFactory<typename LocationResolverManagerAllocator::Policy>;
sf::SharedPointer<ILocationResolverManager> GetLocationResolverManagerService();
}

View File

@@ -1,145 +0,0 @@
/*
* Copyright (c) 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/>.
*/
#include <stratosphere.hpp>
#include <stratosphere/lr/lr_location_resolver_manager_impl.hpp>
#include "lr_content_location_resolver_impl.hpp"
#include "lr_redirect_only_location_resolver_impl.hpp"
#include "lr_add_on_content_location_resolver_impl.hpp"
#include "lr_registered_location_resolver_impl.hpp"
namespace ams::lr {
namespace {
using ContentLocationResolverFactory = sf::ObjectFactory<sf::StdAllocationPolicy<std::allocator>>;
using RedirectOnlyLocationResolverFactory = sf::ObjectFactory<sf::StdAllocationPolicy<std::allocator>>;
bool IsAcceptableStorageId(ncm::StorageId storage_id) {
if (ncm::IsInstallableStorage(storage_id)) {
return storage_id != ncm::StorageId::Any;
} else {
return storage_id == ncm::StorageId::Host || storage_id == ncm::StorageId::GameCard;
}
}
}
Result LocationResolverManagerImpl::OpenLocationResolver(sf::Out<sf::SharedPointer<ILocationResolver>> out, ncm::StorageId storage_id) {
std::scoped_lock lk(m_mutex);
/* Find an existing resolver. */
auto resolver = m_location_resolvers.Find(storage_id);
/* No existing resolver is present, create one. */
if (!resolver) {
if (storage_id == ncm::StorageId::Host) {
AMS_ABORT_UNLESS(m_location_resolvers.Insert(storage_id, RedirectOnlyLocationResolverFactory::CreateSharedEmplaced<ILocationResolver, RedirectOnlyLocationResolverImpl>()));
} else {
/* Get enabled. */
auto *enabled = m_location_resolvers_enabled.Find(storage_id);
/* Create the resolver. */
auto content_resolver = ContentLocationResolverFactory::CreateSharedEmplaced<ILocationResolver, ContentLocationResolverImpl>(storage_id, enabled != nullptr ? *enabled : m_default_enabled);
R_TRY(content_resolver->Refresh());
AMS_ABORT_UNLESS(m_location_resolvers.Insert(storage_id, std::move(content_resolver)));
}
/* Acquire the newly-created resolver. */
resolver = m_location_resolvers.Find(storage_id);
}
/* Copy the output interface. */
*out = *resolver;
R_SUCCEED();
}
Result LocationResolverManagerImpl::OpenRegisteredLocationResolver(sf::Out<sf::SharedPointer<IRegisteredLocationResolver>> out) {
std::scoped_lock lk(m_mutex);
/* No existing resolver is present, create one. */
if (!m_registered_location_resolver) {
m_registered_location_resolver = ContentLocationResolverFactory::CreateSharedEmplaced<IRegisteredLocationResolver, RegisteredLocationResolverImpl>();
}
/* Copy the output interface. */
*out = m_registered_location_resolver;
R_SUCCEED();
}
Result LocationResolverManagerImpl::RefreshLocationResolver(ncm::StorageId storage_id) {
std::scoped_lock lk(m_mutex);
/* Attempt to find an existing resolver. */
auto resolver = m_location_resolvers.Find(storage_id);
R_UNLESS(resolver, lr::ResultUnknownStorageId());
/* Refresh the resolver. */
if (storage_id != ncm::StorageId::Host) {
(*resolver)->Refresh();
}
R_SUCCEED();
}
Result LocationResolverManagerImpl::OpenAddOnContentLocationResolver(sf::Out<sf::SharedPointer<IAddOnContentLocationResolver>> out) {
std::scoped_lock lk(m_mutex);
/* No existing resolver is present, create one. */
if (!m_add_on_content_location_resolver) {
m_add_on_content_location_resolver = ContentLocationResolverFactory::CreateSharedEmplaced<IAddOnContentLocationResolver, AddOnContentLocationResolverImpl>();
}
/* Copy the output interface. */
*out = m_add_on_content_location_resolver;
R_SUCCEED();
}
Result LocationResolverManagerImpl::SetEnabled(const sf::InMapAliasArray<ncm::StorageId> &storages) {
std::scoped_lock lk(m_mutex);
/* If we're setting enabled, we're no longer enabled by default. */
m_default_enabled = false;
/* Create entries for each storage. */
for (size_t i = 0; i < storages.GetSize(); ++i) {
/* Get the storage id. */
const auto storage_id = storages[i];
/* Check that the storage id is acceptable. */
R_UNLESS(IsAcceptableStorageId(storage_id), lr::ResultUnknownStorageId());
/* Set the storage id as enabled. */
AMS_ABORT_UNLESS(m_location_resolvers_enabled.InsertOrAssign(storage_id, true));
}
/* Disable any open storages which shouldn't be enabled. */
m_location_resolvers.ForEach([&](ncm::StorageId storage_id, sf::SharedPointer<ILocationResolver> &resolver) -> void {
/* Check if the storage id is contained in the input array. */
for (size_t i = 0; i < storages.GetSize(); ++i) {
if (storages[i] == storage_id) {
/* The storage is enabled, so we can return. */
return;
}
}
/* The storage isn't enabled, so disable it. */
R_ABORT_UNLESS(resolver->Disable());
});
R_SUCCEED();
}
}

View File

@@ -1,170 +0,0 @@
/*
* Copyright (c) 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/>.
*/
#include <stratosphere.hpp>
#include "lr_redirect_only_location_resolver_impl.hpp"
namespace ams::lr {
RedirectOnlyLocationResolverImpl::~RedirectOnlyLocationResolverImpl() {
/* Ensure entries are deallocated */
this->ClearRedirections();
}
Result RedirectOnlyLocationResolverImpl::ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) {
RedirectionAttributes attr;
R_UNLESS(m_program_redirector.FindRedirection(out.GetPointer(), std::addressof(attr), id), lr::ResultProgramNotFound());
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::RedirectProgramPath(const Path &path, ncm::ProgramId id) {
m_program_redirector.SetRedirection(id, path, DefaultRedirectionAttributes);
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::ResolveApplicationControlPath(sf::Out<Path> out, ncm::ProgramId id) {
RedirectionAttributes attr;
R_UNLESS(m_app_control_redirector.FindRedirection(out.GetPointer(), std::addressof(attr), id), lr::ResultControlNotFound());
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::ResolveApplicationHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) {
RedirectionAttributes attr;
R_UNLESS(m_html_docs_redirector.FindRedirection(out.GetPointer(), std::addressof(attr), id), lr::ResultHtmlDocumentNotFound());
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::ResolveDataPath(sf::Out<Path> out, ncm::DataId id) {
AMS_UNUSED(out, id);
R_THROW(lr::ResultDataNotFound());
}
Result RedirectOnlyLocationResolverImpl::RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) {
m_app_control_redirector.SetRedirection(id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
m_app_control_redirector.SetRedirection(id, owner_id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) {
m_html_docs_redirector.SetRedirection(id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
m_html_docs_redirector.SetRedirection(id, owner_id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::ResolveApplicationLegalInformationPath(sf::Out<Path> out, ncm::ProgramId id) {
RedirectionAttributes attr;
R_UNLESS(m_legal_info_redirector.FindRedirection(out.GetPointer(), std::addressof(attr), id), lr::ResultLegalInformationNotFound());
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) {
m_legal_info_redirector.SetRedirection(id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
m_legal_info_redirector.SetRedirection(id, owner_id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::Refresh() {
this->ClearRedirections();
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) {
m_program_redirector.SetRedirection(id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
m_program_redirector.SetRedirection(id, owner_id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::ClearApplicationRedirectionDeprecated() {
this->ClearRedirections(RedirectionFlags_Application);
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::ClearApplicationRedirection(const sf::InArray<ncm::ProgramId> &excluding_ids) {
this->ClearRedirections(excluding_ids.GetPointer(), excluding_ids.GetSize());
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::EraseProgramRedirection(ncm::ProgramId id) {
m_program_redirector.EraseRedirection(id);
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::EraseApplicationControlRedirection(ncm::ProgramId id) {
m_app_control_redirector.EraseRedirection(id);
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) {
m_html_docs_redirector.EraseRedirection(id);
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::EraseApplicationLegalInformationRedirection(ncm::ProgramId id) {
m_legal_info_redirector.EraseRedirection(id);
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::ResolveProgramPathForDebug(sf::Out<Path> out, ncm::ProgramId id) {
/* If a debug program redirection is present, use it. */
RedirectionAttributes attr;
R_SUCCEED_IF(m_debug_program_redirector.FindRedirection(out.GetPointer(), std::addressof(attr), id));
/* Otherwise, try to find a normal program redirection. */
R_UNLESS(m_program_redirector.FindRedirection(out.GetPointer(), std::addressof(attr), id), lr::ResultDebugProgramNotFound());
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) {
m_debug_program_redirector.SetRedirection(id, path, DefaultRedirectionAttributes);
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) {
m_debug_program_redirector.SetRedirection(id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
m_debug_program_redirector.SetRedirection(id, owner_id, path, DefaultRedirectionAttributes, RedirectionFlags_Application);
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::EraseProgramRedirectionForDebug(ncm::ProgramId id) {
m_debug_program_redirector.EraseRedirection(id);
R_SUCCEED();
}
Result RedirectOnlyLocationResolverImpl::Disable() {
R_SUCCEED();
}
}

View File

@@ -1,57 +0,0 @@
/*
* Copyright (c) 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 "lr_location_resolver_impl_base.hpp"
namespace ams::lr {
class RedirectOnlyLocationResolverImpl : public LocationResolverImplBase {
public:
~RedirectOnlyLocationResolverImpl();
public:
/* Actual commands. */
Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id);
Result RedirectProgramPath(const Path &path, ncm::ProgramId id);
Result ResolveApplicationControlPath(sf::Out<Path> out, ncm::ProgramId id);
Result ResolveApplicationHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id);
Result ResolveDataPath(sf::Out<Path> out, ncm::DataId id);
Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result ResolveApplicationLegalInformationPath(sf::Out<Path> out, ncm::ProgramId id);
Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result Refresh();
Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result ClearApplicationRedirectionDeprecated();
Result ClearApplicationRedirection(const sf::InArray<ncm::ProgramId> &excluding_ids);
Result EraseProgramRedirection(ncm::ProgramId id);
Result EraseApplicationControlRedirection(ncm::ProgramId id);
Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id);
Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id);
Result ResolveProgramPathForDebug(sf::Out<Path> out, ncm::ProgramId id);
Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id);
Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result EraseProgramRedirectionForDebug(ncm::ProgramId id);
Result Disable();
};
static_assert(lr::IsILocationResolver<RedirectOnlyLocationResolverImpl>);
}

View File

@@ -1,146 +0,0 @@
/*
* Copyright (c) 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 <stratosphere/lr/lr_types.hpp>
#include "lr_location_redirector.hpp"
namespace ams::lr {
template<typename Key, typename Value, size_t NumEntries>
class RegisteredData {
NON_COPYABLE(RegisteredData);
NON_MOVEABLE(RegisteredData);
private:
struct Entry {
Value value;
ncm::ProgramId owner_id;
Key key;
bool is_valid;
};
private:
Entry m_entries[NumEntries];
size_t m_capacity;
private:
inline bool IsExcluded(const ncm::ProgramId id, const ncm::ProgramId *excluding_ids, size_t num_ids) const {
/* Try to find program id in exclusions. */
for (size_t i = 0; i < num_ids; i++) {
if (id == excluding_ids[i]) {
return true;
}
}
return false;
}
inline void RegisterImpl(size_t i, const Key &key, const Value &value, const ncm::ProgramId owner_id) {
/* Populate entry. */
Entry &entry = m_entries[i];
entry.key = key;
entry.value = value;
entry.owner_id = owner_id;
entry.is_valid = true;
}
public:
RegisteredData(size_t capacity = NumEntries) : m_capacity(capacity) {
this->Clear();
}
bool Register(const Key &key, const Value &value, const ncm::ProgramId owner_id) {
/* Try to find an existing value. */
for (size_t i = 0; i < this->GetCapacity(); i++) {
Entry &entry = m_entries[i];
if (entry.is_valid && entry.key == key) {
this->RegisterImpl(i, key, value, owner_id);
return true;
}
}
/* We didn't find an existing entry, so try to create a new one. */
for (size_t i = 0; i < this->GetCapacity(); i++) {
Entry &entry = m_entries[i];
if (!entry.is_valid) {
this->RegisterImpl(i, key, value, owner_id);
return true;
}
}
return false;
}
void Unregister(const Key &key) {
/* Invalidate entries with a matching key. */
for (size_t i = 0; i < this->GetCapacity(); i++) {
Entry &entry = m_entries[i];
if (entry.is_valid && entry.key == key) {
entry.is_valid = false;
}
}
}
void UnregisterOwnerProgram(ncm::ProgramId owner_id) {
/* Invalidate entries with a matching owner id. */
for (size_t i = 0; i < this->GetCapacity(); i++) {
Entry &entry = m_entries[i];
if (entry.owner_id == owner_id) {
entry.is_valid = false;
}
}
}
bool Find(Value *out, const Key &key) const {
/* Locate a matching entry. */
for (size_t i = 0; i < this->GetCapacity(); i++) {
const Entry &entry = m_entries[i];
if (entry.is_valid && entry.key == key) {
*out = entry.value;
return true;
}
}
return false;
}
void Clear() {
/* Invalidate all entries. */
for (size_t i = 0; i < this->GetCapacity(); i++) {
m_entries[i].is_valid = false;
}
}
void ClearExcluding(const ncm::ProgramId *ids, size_t num_ids) {
/* Invalidate all entries unless excluded. */
for (size_t i = 0; i < this->GetCapacity(); i++) {
Entry &entry = m_entries[i];
if (!this->IsExcluded(entry.owner_id, ids, num_ids)) {
entry.is_valid = false;
}
}
}
size_t GetCapacity() const {
return m_capacity;
}
};
template<typename Key, size_t NumEntries>
using RegisteredLocations = RegisteredData<Key, RedirectionPath, NumEntries>;
template<typename Key, size_t NumEntries>
using RegisteredStorages = RegisteredData<Key, ncm::StorageId, NumEntries>;
}

View File

@@ -1,158 +0,0 @@
/*
* Copyright (c) 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/>.
*/
#include <stratosphere.hpp>
#include "lr_registered_location_resolver_impl.hpp"
namespace ams::lr {
namespace {
template<size_t N>
bool ResolvePath(Path *out, const LocationRedirector &redirector, const RegisteredLocations<ncm::ProgramId, N> &locations, ncm::ProgramId id) {
/* Attempt to use a redirection if present. */
RedirectionAttributes attr;
if (!redirector.FindRedirection(out, std::addressof(attr), id)) {
/* Otherwise try and use a registered location. */
RedirectionPath redir_path;
if (!locations.Find(std::addressof(redir_path), id)) {
return false;
}
/* Set the output path. */
*out = redir_path.path;
}
return true;
}
template<size_t N>
void RegisterPath(RegisteredLocations<ncm::ProgramId, N> &locations, ncm::ProgramId id, const Path& path, ncm::ProgramId owner_id) {
/* Create a redirection path. */
const RedirectionPath redir_path = { path, DefaultRedirectionAttributes };
/* If we register successfully, we're good. */
if (locations.Register(id, redir_path, owner_id)) {
return;
}
/* Otherwise, clear and register (this should always succeed). */
locations.Clear();
locations.Register(id, redir_path, owner_id);
}
}
RegisteredLocationResolverImpl::~RegisteredLocationResolverImpl() {
/* Ensure entries are deallocated */
this->ClearRedirections();
}
/* Helper function. */
void RegisteredLocationResolverImpl::ClearRedirections(u32 flags) {
m_html_docs_redirector.ClearRedirections(flags);
m_program_redirector.ClearRedirections(flags);
}
Result RegisteredLocationResolverImpl::RefreshImpl(const ncm::ProgramId *excluding_ids, size_t num_ids) {
/* On < 9.0.0, exclusion lists were not supported yet, so simply clear and return. */
if (hos::GetVersion() < hos::Version_9_0_0) {
this->ClearRedirections();
R_SUCCEED();
}
if (num_ids) {
/* If we have exclusion lists, explicitly clear our locations. */
m_registered_program_locations.ClearExcluding(excluding_ids, num_ids);
m_registered_html_docs_locations.ClearExcluding(excluding_ids, num_ids);
} else {
/* If we don't, just perform a general clear (as pre 9.0.0 did). */
this->ClearRedirections();
}
/* Clear redirectors using exclusion lists. */
m_program_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids);
m_html_docs_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids);
R_SUCCEED();
}
Result RegisteredLocationResolverImpl::ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) {
R_UNLESS(ResolvePath(out.GetPointer(), m_program_redirector, m_registered_program_locations, id), lr::ResultProgramNotFound());
R_SUCCEED();
}
Result RegisteredLocationResolverImpl::RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id) {
RegisterPath(m_registered_program_locations, id, path, ncm::InvalidProgramId);
R_SUCCEED();
}
Result RegisteredLocationResolverImpl::RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
RegisterPath(m_registered_program_locations, id, path, owner_id);
R_SUCCEED();
}
Result RegisteredLocationResolverImpl::UnregisterProgramPath(ncm::ProgramId id) {
m_registered_program_locations.Unregister(id);
R_SUCCEED();
}
Result RegisteredLocationResolverImpl::RedirectProgramPathDeprecated(const Path &path, ncm::ProgramId id) {
m_program_redirector.SetRedirection(id, path, DefaultRedirectionAttributes);
R_SUCCEED();
}
Result RegisteredLocationResolverImpl::RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
m_program_redirector.SetRedirection(id, owner_id, path, DefaultRedirectionAttributes);
R_SUCCEED();
}
Result RegisteredLocationResolverImpl::ResolveHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) {
R_UNLESS(ResolvePath(out.GetPointer(), m_html_docs_redirector, m_registered_html_docs_locations, id), lr::ResultHtmlDocumentNotFound());
R_SUCCEED();
}
Result RegisteredLocationResolverImpl::RegisterHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) {
RegisterPath(m_registered_html_docs_locations, id, path, ncm::InvalidProgramId);
R_SUCCEED();
}
Result RegisteredLocationResolverImpl::RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
RegisterPath(m_registered_html_docs_locations, id, path, owner_id);
R_SUCCEED();
}
Result RegisteredLocationResolverImpl::UnregisterHtmlDocumentPath(ncm::ProgramId id) {
m_registered_html_docs_locations.Unregister(id);
R_SUCCEED();
}
Result RegisteredLocationResolverImpl::RedirectHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) {
m_html_docs_redirector.SetRedirection(id, path, DefaultRedirectionAttributes);
R_SUCCEED();
}
Result RegisteredLocationResolverImpl::RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
m_html_docs_redirector.SetRedirection(id, owner_id, path, DefaultRedirectionAttributes);
R_SUCCEED();
}
Result RegisteredLocationResolverImpl::Refresh() {
R_RETURN(this->RefreshImpl(nullptr, 0));
}
Result RegisteredLocationResolverImpl::RefreshExcluding(const sf::InArray<ncm::ProgramId> &ids) {
R_RETURN(this->RefreshImpl(ids.GetPointer(), ids.GetSize()));
}
}

View File

@@ -1,69 +0,0 @@
/*
* Copyright (c) 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 <stratosphere.hpp>
#include "lr_location_redirector.hpp"
#include "lr_registered_data.hpp"
namespace ams::lr {
class RegisteredLocationResolverImpl {
private:
static constexpr size_t MaxRegisteredLocationsDeprecated = 0x10;
static constexpr size_t MaxRegisteredLocations = 0x20;
static_assert(MaxRegisteredLocations >= MaxRegisteredLocationsDeprecated);
private:
static ALWAYS_INLINE size_t GetMaxRegisteredLocations() {
if (hos::GetVersion() >= hos::Version_9_0_0) {
return MaxRegisteredLocations;
} else {
return MaxRegisteredLocationsDeprecated;
}
}
private:
/* Redirection and registered location storage. */
LocationRedirector m_program_redirector;
RegisteredLocations<ncm::ProgramId, MaxRegisteredLocations> m_registered_program_locations;
LocationRedirector m_html_docs_redirector;
RegisteredLocations<ncm::ProgramId, MaxRegisteredLocations> m_registered_html_docs_locations;
private:
/* Helper functions. */
void ClearRedirections(u32 flags = RedirectionFlags_None);
Result RefreshImpl(const ncm::ProgramId *excluding_ids, size_t num_ids);
public:
RegisteredLocationResolverImpl() : m_program_redirector(), m_registered_program_locations(GetMaxRegisteredLocations()), m_html_docs_redirector(), m_registered_html_docs_locations(GetMaxRegisteredLocations()) { /* ... */ }
~RegisteredLocationResolverImpl();
public:
/* Actual commands. */
Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id);
Result RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id);
Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result UnregisterProgramPath(ncm::ProgramId id);
Result RedirectProgramPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result ResolveHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id);
Result RegisterHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id);
Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result UnregisterHtmlDocumentPath(ncm::ProgramId id);
Result RedirectHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result Refresh();
Result RefreshExcluding(const sf::InArray<ncm::ProgramId> &ids);
};
static_assert(lr::IsIRegisteredLocationResolver<RegisteredLocationResolverImpl>);
}

View File

@@ -1,166 +0,0 @@
/*
* Copyright (c) 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 <stratosphere.hpp>
namespace ams::lr {
#if defined(ATMOSPHERE_OS_HORIZON)
class RemoteLocationResolverImpl {
private:
::LrLocationResolver m_srv;
public:
RemoteLocationResolverImpl(::LrLocationResolver &l) : m_srv(l) { /* ... */ }
~RemoteLocationResolverImpl() { ::serviceClose(std::addressof(m_srv.s)); }
public:
/* Actual commands. */
Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) {
R_RETURN(::lrLrResolveProgramPath(std::addressof(m_srv), id.value, out->str));
}
Result RedirectProgramPath(const Path &path, ncm::ProgramId id) {
R_RETURN(::lrLrRedirectProgramPath(std::addressof(m_srv), id.value, path.str));
}
Result ResolveApplicationControlPath(sf::Out<Path> out, ncm::ProgramId id) {
R_RETURN(::lrLrResolveApplicationControlPath(std::addressof(m_srv), id.value, out->str));
}
Result ResolveApplicationHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) {
R_RETURN(::lrLrResolveApplicationHtmlDocumentPath(std::addressof(m_srv), id.value, out->str));
}
Result ResolveDataPath(sf::Out<Path> out, ncm::DataId id) {
R_RETURN(::lrLrResolveDataPath(std::addressof(m_srv), id.value, out->str));
}
Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) {
R_RETURN(::lrLrRedirectApplicationControlPath(std::addressof(m_srv), id.value, 0, path.str));
}
Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
R_RETURN(::lrLrRedirectApplicationControlPath(std::addressof(m_srv), id.value, owner_id.value, path.str));
}
Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) {
R_RETURN(::lrLrRedirectApplicationHtmlDocumentPath(std::addressof(m_srv), id.value, 0, path.str));
}
Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
R_RETURN(::lrLrRedirectApplicationHtmlDocumentPath(std::addressof(m_srv), id.value, owner_id.value, path.str));
}
Result ResolveApplicationLegalInformationPath(sf::Out<Path> out, ncm::ProgramId id) {
R_RETURN(::lrLrResolveApplicationLegalInformationPath(std::addressof(m_srv), id.value, out->str));
}
Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) {
R_RETURN(::lrLrRedirectApplicationLegalInformationPath(std::addressof(m_srv), id.value, 0, path.str));
}
Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
R_RETURN(::lrLrRedirectApplicationLegalInformationPath(std::addressof(m_srv), id.value, owner_id.value, path.str));
}
Result Refresh() {
R_RETURN(::lrLrRefresh(std::addressof(m_srv)));
}
Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_UNUSED(path, id);
AMS_ABORT();
}
Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
/* TODO: libnx bindings */
AMS_UNUSED(path, id, owner_id);
AMS_ABORT();
}
Result ClearApplicationRedirectionDeprecated() {
/* TODO: libnx bindings */
AMS_ABORT();
}
Result ClearApplicationRedirection(const sf::InArray<ncm::ProgramId> &excluding_ids) {
/* TODO: libnx bindings */
AMS_UNUSED(excluding_ids);
AMS_ABORT();
}
Result EraseProgramRedirection(ncm::ProgramId id) {
R_RETURN(::lrLrEraseProgramRedirection(std::addressof(m_srv), id.value));
}
Result EraseApplicationControlRedirection(ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_UNUSED(id);
AMS_ABORT();
}
Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_UNUSED(id);
AMS_ABORT();
}
Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_UNUSED(id);
AMS_ABORT();
}
Result ResolveProgramPathForDebug(sf::Out<Path> out, ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_UNUSED(out, id);
AMS_ABORT();
}
Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_UNUSED(path, id);
AMS_ABORT();
}
Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_UNUSED(path, id);
AMS_ABORT();
}
Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
/* TODO: libnx bindings */
AMS_UNUSED(path, id, owner_id);
AMS_ABORT();
}
Result EraseProgramRedirectionForDebug(ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_UNUSED(id);
AMS_ABORT();
}
Result Disable() {
/* TODO: libnx bindings */
AMS_ABORT();
}
};
static_assert(lr::IsILocationResolver<RemoteLocationResolverImpl>);
#endif
}

View File

@@ -1,66 +0,0 @@
/*
* Copyright (c) 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 <stratosphere.hpp>
#include "lr_location_resolver_manager_factory.hpp"
#include "lr_remote_location_resolver_impl.hpp"
#include "lr_remote_registered_location_resolver_impl.hpp"
namespace ams::lr {
#if defined(ATMOSPHERE_OS_HORIZON)
class RemoteLocationResolverManagerImpl {
public:
RemoteLocationResolverManagerImpl() { R_ABORT_UNLESS(::lrInitialize()); }
~RemoteLocationResolverManagerImpl() { ::lrExit(); }
public:
/* Actual commands. */
Result OpenLocationResolver(sf::Out<sf::SharedPointer<ILocationResolver>> out, ncm::StorageId storage_id) {
LrLocationResolver lr;
R_TRY(::lrOpenLocationResolver(static_cast<::NcmStorageId>(storage_id), std::addressof(lr)));
*out = LocationResolverManagerFactory::CreateSharedEmplaced<ILocationResolver, RemoteLocationResolverImpl>(lr);
R_SUCCEED();
}
Result OpenRegisteredLocationResolver(sf::Out<sf::SharedPointer<IRegisteredLocationResolver>> out) {
LrRegisteredLocationResolver lr;
R_TRY(::lrOpenRegisteredLocationResolver(std::addressof(lr)));
*out = LocationResolverManagerFactory::CreateSharedEmplaced<IRegisteredLocationResolver, RemoteRegisteredLocationResolverImpl>(lr);
R_SUCCEED();
}
Result RefreshLocationResolver(ncm::StorageId storage_id) {
AMS_UNUSED(storage_id);
AMS_ABORT("TODO: libnx binding");
}
Result OpenAddOnContentLocationResolver(sf::Out<sf::SharedPointer<IAddOnContentLocationResolver>> out) {
AMS_UNUSED(out);
AMS_ABORT("TODO: libnx binding");
}
Result SetEnabled(const sf::InMapAliasArray<ncm::StorageId> &storages) {
AMS_UNUSED(storages);
AMS_ABORT("TODO: libnx binding");
}
};
static_assert(lr::IsILocationResolverManager<RemoteLocationResolverManagerImpl>);
#endif
}

View File

@@ -1,116 +0,0 @@
/*
* Copyright (c) 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 <stratosphere.hpp>
namespace ams::lr {
#if defined(ATMOSPHERE_OS_HORIZON)
class RemoteRegisteredLocationResolverImpl {
private:
::LrRegisteredLocationResolver m_srv;
public:
RemoteRegisteredLocationResolverImpl(::LrRegisteredLocationResolver &l) : m_srv(l) { /* ... */ }
~RemoteRegisteredLocationResolverImpl() { ::serviceClose(std::addressof(m_srv.s)); }
public:
/* Actual commands. */
Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) {
R_RETURN(::lrRegLrResolveProgramPath(std::addressof(m_srv), id.value, out->str));
}
Result RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_UNUSED(path, id);
AMS_ABORT();
}
Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
/* TODO: libnx bindings */
AMS_UNUSED(path, id, owner_id);
AMS_ABORT();
}
Result UnregisterProgramPath(ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_UNUSED(id);
AMS_ABORT();
}
Result RedirectProgramPathDeprecated(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_UNUSED(path, id);
AMS_ABORT();
}
Result RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
/* TODO: libnx bindings */
AMS_UNUSED(path, id, owner_id);
AMS_ABORT();
}
Result ResolveHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_UNUSED(out, id);
AMS_ABORT();
}
Result RegisterHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_UNUSED(path, id);
AMS_ABORT();
}
Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
/* TODO: libnx bindings */
AMS_UNUSED(path, id, owner_id);
AMS_ABORT();
}
Result UnregisterHtmlDocumentPath(ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_UNUSED(id);
AMS_ABORT();
}
Result RedirectHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_UNUSED(path, id);
AMS_ABORT();
}
Result RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
/* TODO: libnx bindings */
AMS_UNUSED(path, id, owner_id);
AMS_ABORT();
}
Result Refresh() {
/* TODO: libnx bindings */
AMS_ABORT();
}
Result RefreshExcluding(const sf::InArray<ncm::ProgramId> &ids) {
/* TODO: libnx bindings */
AMS_UNUSED(ids);
AMS_ABORT();
}
};
static_assert(lr::IsIRegisteredLocationResolver<RemoteRegisteredLocationResolverImpl>);
#endif
}