2020-03-08 08:06:23 +00:00
|
|
|
/*
|
2021-10-04 19:59:10 +00:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2020-03-08 08:06:23 +00:00
|
|
|
*
|
|
|
|
* 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 <stratosphere/lr/lr_i_registered_location_resolver.hpp>
|
|
|
|
|
|
|
|
namespace ams::lr {
|
|
|
|
|
|
|
|
class RegisteredLocationResolver {
|
|
|
|
NON_COPYABLE(RegisteredLocationResolver);
|
|
|
|
private:
|
2021-10-10 07:14:06 +00:00
|
|
|
sf::SharedPointer<IRegisteredLocationResolver> m_interface;
|
2020-03-08 08:06:23 +00:00
|
|
|
public:
|
2022-03-22 21:02:14 +00:00
|
|
|
RegisteredLocationResolver() : m_interface(nullptr) { /* ... */ }
|
2021-10-10 07:14:06 +00:00
|
|
|
explicit RegisteredLocationResolver(sf::SharedPointer<IRegisteredLocationResolver> intf) : m_interface(intf) { /* ... */ }
|
2020-03-08 08:06:23 +00:00
|
|
|
|
|
|
|
RegisteredLocationResolver(RegisteredLocationResolver &&rhs) {
|
2021-10-10 07:14:06 +00:00
|
|
|
m_interface = std::move(rhs.m_interface);
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RegisteredLocationResolver &operator=(RegisteredLocationResolver &&rhs) {
|
|
|
|
RegisteredLocationResolver(std::move(rhs)).Swap(*this);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Swap(RegisteredLocationResolver &rhs) {
|
2021-10-10 07:14:06 +00:00
|
|
|
std::swap(m_interface, rhs.m_interface);
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
public:
|
|
|
|
/* Actual commands. */
|
|
|
|
Result ResolveProgramPath(Path *out, ncm::ProgramId id) {
|
2022-03-06 20:08:20 +00:00
|
|
|
AMS_ASSERT(m_interface != nullptr);
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(m_interface->ResolveProgramPath(out, id));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
|
2022-03-06 20:08:20 +00:00
|
|
|
AMS_ASSERT(m_interface != nullptr);
|
2020-04-14 05:19:44 +00:00
|
|
|
if (hos::GetVersion() >= hos::Version_9_0_0) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(m_interface->RegisterProgramPath(path, id, owner_id));
|
2020-03-08 08:06:23 +00:00
|
|
|
} else {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(m_interface->RegisterProgramPathDeprecated(path, id));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Result UnregisterProgramPath(ncm::ProgramId id) {
|
2022-03-06 20:08:20 +00:00
|
|
|
AMS_ASSERT(m_interface != nullptr);
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(m_interface->UnregisterProgramPath(id));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
|
2022-03-06 20:08:20 +00:00
|
|
|
AMS_ASSERT(m_interface != nullptr);
|
2020-04-14 05:19:44 +00:00
|
|
|
if (hos::GetVersion() >= hos::Version_9_0_0) {
|
2021-10-10 07:14:06 +00:00
|
|
|
R_ABORT_UNLESS(m_interface->RedirectProgramPath(path, id, owner_id));
|
2020-03-08 08:06:23 +00:00
|
|
|
} else {
|
2021-10-10 07:14:06 +00:00
|
|
|
R_ABORT_UNLESS(m_interface->RedirectProgramPathDeprecated(path, id));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Result ResolveHtmlDocumentPath(Path *out, ncm::ProgramId id) {
|
2022-03-06 20:08:20 +00:00
|
|
|
AMS_ASSERT(m_interface != nullptr);
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(m_interface->ResolveHtmlDocumentPath(out, id));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
|
2022-03-06 20:08:20 +00:00
|
|
|
AMS_ASSERT(m_interface != nullptr);
|
2020-04-14 05:19:44 +00:00
|
|
|
if (hos::GetVersion() >= hos::Version_9_0_0) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(m_interface->RegisterHtmlDocumentPath(path, id, owner_id));
|
2020-03-08 08:06:23 +00:00
|
|
|
} else {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(m_interface->RegisterHtmlDocumentPathDeprecated(path, id));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Result UnregisterHtmlDocumentPath(ncm::ProgramId id) {
|
2022-03-06 20:08:20 +00:00
|
|
|
AMS_ASSERT(m_interface != nullptr);
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(m_interface->UnregisterHtmlDocumentPath(id));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
|
2022-03-06 20:08:20 +00:00
|
|
|
AMS_ASSERT(m_interface != nullptr);
|
2020-04-14 05:19:44 +00:00
|
|
|
if (hos::GetVersion() >= hos::Version_9_0_0) {
|
2021-10-10 07:14:06 +00:00
|
|
|
R_ABORT_UNLESS(m_interface->RedirectHtmlDocumentPath(path, id, owner_id));
|
2020-03-08 08:06:23 +00:00
|
|
|
} else {
|
2021-10-10 07:14:06 +00:00
|
|
|
R_ABORT_UNLESS(m_interface->RedirectHtmlDocumentPathDeprecated(path, id));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Result Refresh() {
|
2022-03-06 20:08:20 +00:00
|
|
|
AMS_ASSERT(m_interface != nullptr);
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(m_interface->Refresh());
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result RefreshExcluding(const ncm::ProgramId *excluding_ids, size_t num_ids) {
|
2022-03-06 20:08:20 +00:00
|
|
|
AMS_ASSERT(m_interface != nullptr);
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(m_interface->RefreshExcluding(sf::InArray<ncm::ProgramId>(excluding_ids, num_ids)));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|