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.hpp>
|
|
|
|
#include "ncm_remote_content_storage_impl.hpp"
|
|
|
|
#include "ncm_remote_content_meta_database_impl.hpp"
|
|
|
|
|
|
|
|
namespace ams::ncm {
|
|
|
|
|
2022-03-06 20:08:20 +00:00
|
|
|
#if defined(ATMOSPHERE_OS_HORIZON)
|
2021-01-17 15:55:32 +00:00
|
|
|
class RemoteContentManagerImpl {
|
|
|
|
private:
|
|
|
|
/* TODO: sf::ProxyObjectAllocator */
|
|
|
|
using ObjectFactory = sf::ObjectFactory<sf::StdAllocationPolicy<std::allocator>>;
|
2020-03-08 08:06:23 +00:00
|
|
|
public:
|
2022-03-06 20:08:20 +00:00
|
|
|
RemoteContentManagerImpl() { R_ABORT_UNLESS(::ncmInitialize()); }
|
2020-03-08 08:06:23 +00:00
|
|
|
|
2022-03-06 20:08:20 +00:00
|
|
|
~RemoteContentManagerImpl() { ::ncmExit(); }
|
2020-03-08 08:06:23 +00:00
|
|
|
public:
|
2020-07-08 00:07:23 +00:00
|
|
|
Result CreateContentStorage(StorageId storage_id) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(::ncmCreateContentStorage(static_cast<NcmStorageId>(storage_id)));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 00:07:23 +00:00
|
|
|
Result CreateContentMetaDatabase(StorageId storage_id) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(::ncmCreateContentMetaDatabase(static_cast<NcmStorageId>(storage_id)));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 00:07:23 +00:00
|
|
|
Result VerifyContentStorage(StorageId storage_id) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(::ncmVerifyContentStorage(static_cast<NcmStorageId>(storage_id)));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 00:07:23 +00:00
|
|
|
Result VerifyContentMetaDatabase(StorageId storage_id) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(::ncmVerifyContentMetaDatabase(static_cast<NcmStorageId>(storage_id)));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
2021-01-17 15:55:32 +00:00
|
|
|
Result OpenContentStorage(sf::Out<sf::SharedPointer<IContentStorage>> out, StorageId storage_id) {
|
2020-03-08 08:06:23 +00:00
|
|
|
NcmContentStorage cs;
|
|
|
|
R_TRY(::ncmOpenContentStorage(std::addressof(cs), static_cast<NcmStorageId>(storage_id)));
|
|
|
|
|
2021-01-17 15:55:32 +00:00
|
|
|
out.SetValue(ObjectFactory::CreateSharedEmplaced<IContentStorage, RemoteContentStorageImpl>(cs));
|
2022-03-26 07:14:36 +00:00
|
|
|
R_SUCCEED();
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
2021-01-17 15:55:32 +00:00
|
|
|
Result OpenContentMetaDatabase(sf::Out<sf::SharedPointer<IContentMetaDatabase>> out, StorageId storage_id) {
|
2020-03-08 08:06:23 +00:00
|
|
|
NcmContentMetaDatabase db;
|
|
|
|
R_TRY(::ncmOpenContentMetaDatabase(std::addressof(db), static_cast<NcmStorageId>(storage_id)));
|
|
|
|
|
2021-01-17 15:55:32 +00:00
|
|
|
out.SetValue(ObjectFactory::CreateSharedEmplaced<IContentMetaDatabase, RemoteContentMetaDatabaseImpl>(db));
|
2022-03-26 07:14:36 +00:00
|
|
|
R_SUCCEED();
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 00:07:23 +00:00
|
|
|
Result CloseContentStorageForcibly(StorageId storage_id) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(::ncmCloseContentStorageForcibly(static_cast<NcmStorageId>(storage_id)));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 00:07:23 +00:00
|
|
|
Result CloseContentMetaDatabaseForcibly(StorageId storage_id) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(::ncmCloseContentMetaDatabaseForcibly(static_cast<NcmStorageId>(storage_id)));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 00:07:23 +00:00
|
|
|
Result CleanupContentMetaDatabase(StorageId storage_id) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(::ncmCleanupContentMetaDatabase(static_cast<NcmStorageId>(storage_id)));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 00:07:23 +00:00
|
|
|
Result ActivateContentStorage(StorageId storage_id) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(::ncmActivateContentStorage(static_cast<NcmStorageId>(storage_id)));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 00:07:23 +00:00
|
|
|
Result InactivateContentStorage(StorageId storage_id) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(::ncmInactivateContentStorage(static_cast<NcmStorageId>(storage_id)));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 00:07:23 +00:00
|
|
|
Result ActivateContentMetaDatabase(StorageId storage_id) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(::ncmActivateContentMetaDatabase(static_cast<NcmStorageId>(storage_id)));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 00:07:23 +00:00
|
|
|
Result InactivateContentMetaDatabase(StorageId storage_id) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(::ncmInactivateContentMetaDatabase(static_cast<NcmStorageId>(storage_id)));
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 00:07:23 +00:00
|
|
|
Result InvalidateRightsIdCache() {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(::ncmInvalidateRightsIdCache());
|
2020-03-08 08:06:23 +00:00
|
|
|
}
|
2020-04-14 17:11:51 +00:00
|
|
|
|
2020-07-08 00:07:23 +00:00
|
|
|
Result GetMemoryReport(sf::Out<MemoryReport> out) {
|
2020-04-14 17:11:51 +00:00
|
|
|
/* TODO: libnx bindings */
|
2021-10-06 22:20:48 +00:00
|
|
|
AMS_UNUSED(out);
|
2020-04-14 17:11:51 +00:00
|
|
|
AMS_ABORT();
|
|
|
|
}
|
2023-02-21 23:06:21 +00:00
|
|
|
|
|
|
|
Result ActivateFsContentStorage(fs::ContentStorageId fs_content_storage_id) {
|
|
|
|
R_RETURN(::ncmActivateFsContentStorage(static_cast<::FsContentStorageId>(util::ToUnderlying(fs_content_storage_id))));
|
|
|
|
}
|
2020-03-08 08:06:23 +00:00
|
|
|
};
|
2020-07-08 00:07:23 +00:00
|
|
|
static_assert(ncm::IsIContentManager<RemoteContentManagerImpl>);
|
2022-03-06 20:08:20 +00:00
|
|
|
#endif
|
2020-03-08 08:06:23 +00:00
|
|
|
|
|
|
|
}
|