mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-03 08:08:39 -04:00
ncm: update for new 17.0.0 apis
This commit is contained in:
parent
ef9b111bbf
commit
c95741142e
31 changed files with 249 additions and 7 deletions
|
@ -26,6 +26,7 @@ namespace ams::ncm {
|
|||
.content_count = src.content_count,
|
||||
.content_meta_count = src.content_meta_count,
|
||||
.attributes = src.attributes,
|
||||
.platform = src.platform,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -42,6 +43,7 @@ namespace ams::ncm {
|
|||
.content_count = src.content_count,
|
||||
.content_meta_count = src.content_meta_count,
|
||||
.attributes = src.attributes,
|
||||
.platform = src.platform,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -518,4 +518,20 @@ namespace ams::ncm {
|
|||
R_RETURN(this->GetContentInfoImpl(out_content_info.GetPointer(), key, type, util::make_optional(id_offset)));
|
||||
}
|
||||
|
||||
Result ContentMetaDatabaseImpl::GetPlatform(sf::Out<ncm::ContentMetaPlatform> out, const ContentMetaKey &key) {
|
||||
R_TRY(this->EnsureEnabled());
|
||||
|
||||
/* Obtain the content meta for the key. */
|
||||
const void *meta;
|
||||
size_t meta_size;
|
||||
R_TRY(this->GetContentMetaPointer(&meta, &meta_size, key));
|
||||
|
||||
/* Create a reader. */
|
||||
ContentMetaReader reader(meta, meta_size);
|
||||
|
||||
/* Set the ouput value. */
|
||||
out.SetValue(reader.GetHeader()->platform);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ namespace ams::ncm {
|
|||
virtual Result GetContentAccessibilities(sf::Out<u8> out_accessibilities, const ContentMetaKey &key) override;
|
||||
virtual Result GetContentInfoByType(sf::Out<ContentInfo> out_content_info, const ContentMetaKey &key, ContentType type) override;
|
||||
virtual Result GetContentInfoByTypeAndIdOffset(sf::Out<ContentInfo> out_content_info, const ContentMetaKey &key, ContentType type, u8 id_offset) override;
|
||||
virtual Result GetPlatform(sf::Out<ncm::ContentMetaPlatform> out, const ContentMetaKey &key) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ namespace ams::ncm {
|
|||
virtual Result GetContentAccessibilities(sf::Out<u8> out_accessibilities, const ContentMetaKey &key) = 0;
|
||||
virtual Result GetContentInfoByType(sf::Out<ContentInfo> out_content_info, const ContentMetaKey &key, ContentType type) = 0;
|
||||
virtual Result GetContentInfoByTypeAndIdOffset(sf::Out<ContentInfo> out_content_info, const ContentMetaKey &key, ContentType type, u8 id_offset) = 0;
|
||||
virtual Result GetPlatform(sf::Out<ncm::ContentMetaPlatform> out, const ContentMetaKey &key) = 0;
|
||||
};
|
||||
static_assert(ncm::IsIContentMetaDatabase<ContentMetaDatabaseImplBase>);
|
||||
|
||||
|
|
|
@ -918,4 +918,19 @@ namespace ams::ncm {
|
|||
R_THROW(ncm::ResultInvalidOperation());
|
||||
}
|
||||
|
||||
Result ContentStorageImpl::GetProgramId(sf::Out<ncm::ProgramId> out, ContentId content_id, fs::ContentAttributes attr) {
|
||||
R_TRY(this->EnsureEnabled());
|
||||
|
||||
/* Get the path of the content. */
|
||||
Path path;
|
||||
R_TRY(this->GetPath(std::addressof(path), content_id));
|
||||
|
||||
/* Obtain the program id for the content. */
|
||||
ncm::ProgramId program_id;
|
||||
R_TRY(fs::GetProgramId(std::addressof(program_id), path.str, attr));
|
||||
|
||||
out.SetValue(program_id);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -105,6 +105,7 @@ namespace ams::ncm {
|
|||
virtual Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id, fs::ContentAttributes attr) override;
|
||||
virtual Result RegisterPath(const ContentId &content_id, const Path &path) override;
|
||||
virtual Result ClearRegisteredPath() override;
|
||||
virtual Result GetProgramId(sf::Out<ncm::ProgramId> out, ContentId content_id, fs::ContentAttributes attr) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ namespace ams::ncm {
|
|||
virtual Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id, fs::ContentAttributes attr) = 0;
|
||||
virtual Result RegisterPath(const ContentId &content_id, const Path &path) = 0;
|
||||
virtual Result ClearRegisteredPath() = 0;
|
||||
virtual Result GetProgramId(sf::Out<ncm::ProgramId> out, ContentId content_id, fs::ContentAttributes attr) = 0;
|
||||
|
||||
/* 16.0.0 Alignment change hacks. */
|
||||
Result CreatePlaceHolder_AtmosphereAlignmentFix(ContentId content_id, PlaceHolderId placeholder_id, s64 size) { R_RETURN(this->CreatePlaceHolder(placeholder_id, content_id, size)); }
|
||||
|
|
|
@ -224,4 +224,27 @@ namespace ams::ncm {
|
|||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result HostContentStorageImpl::GetProgramId(sf::Out<ncm::ProgramId> out, ContentId content_id, fs::ContentAttributes attr) {
|
||||
R_TRY(this->EnsureEnabled());
|
||||
|
||||
/* Get the content path. */
|
||||
Path path;
|
||||
R_TRY(m_registered_content->GetPath(std::addressof(path), content_id));
|
||||
|
||||
/* Check for correct extension. */
|
||||
const auto path_len = std::strlen(path.str);
|
||||
const char *extension = path.str + path_len - 1;
|
||||
if (*extension == '/') {
|
||||
--extension;
|
||||
}
|
||||
R_UNLESS(path_len >= 4 && std::memcmp(extension - 4, ".ncd", 4) == 0, ncm::ResultInvalidContentMetaDirectory());
|
||||
|
||||
/* Obtain the program id for the content. */
|
||||
ncm::ProgramId program_id;
|
||||
R_TRY(fs::GetProgramId(std::addressof(program_id), path.str, attr));
|
||||
|
||||
out.SetValue(program_id);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ namespace ams::ncm {
|
|||
Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id, fs::ContentAttributes attr);
|
||||
Result RegisterPath(const ContentId &content_id, const Path &path);
|
||||
Result ClearRegisteredPath();
|
||||
Result GetProgramId(sf::Out<ncm::ProgramId> out, ContentId content_id, fs::ContentAttributes attr);
|
||||
|
||||
/* 16.0.0 Alignment change hacks. */
|
||||
Result CreatePlaceHolder_AtmosphereAlignmentFix(ContentId content_id, PlaceHolderId placeholder_id, s64 size) { R_RETURN(this->CreatePlaceHolder(placeholder_id, content_id, size)); }
|
||||
|
|
|
@ -446,4 +446,21 @@ namespace ams::ncm {
|
|||
}));
|
||||
}
|
||||
|
||||
Result IntegratedContentMetaDatabaseImpl::GetPlatform(sf::Out<ncm::ContentMetaPlatform> out, const ContentMetaKey &key) {
|
||||
/* Lock ourselves. */
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
/* Check that we're enabled. */
|
||||
R_TRY(this->EnsureEnabled());
|
||||
|
||||
/* Check that our list has interfaces to check. */
|
||||
R_UNLESS(m_list.GetCount() > 0, ncm::ResultContentMetaNotFound());
|
||||
|
||||
/* Check each interface in turn. */
|
||||
R_RETURN(m_list.TryEach([&](const auto &data) {
|
||||
/* Try the current interface. */
|
||||
R_RETURN(data.interface->GetPlatform(out, key));
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -326,4 +326,31 @@ namespace ams::ncm {
|
|||
R_THROW(ncm::ResultInvalidOperation());
|
||||
}
|
||||
|
||||
Result IntegratedContentStorageImpl::GetProgramId(sf::Out<ncm::ProgramId> out, ContentId content_id, fs::ContentAttributes attr) {
|
||||
/* Lock ourselves. */
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
/* Check that we're enabled. */
|
||||
R_TRY(this->EnsureEnabled());
|
||||
|
||||
/* Check that our list has interfaces to check. */
|
||||
R_UNLESS(m_list.GetCount() > 0, ncm::ResultContentNotFound());
|
||||
|
||||
/* Check each interface in turn. */
|
||||
R_TRY(m_list.TryEach([&](const auto &data) {
|
||||
/* Check if the current interface has it. */
|
||||
bool has;
|
||||
R_TRY(data.interface->Has(std::addressof(has), content_id));
|
||||
|
||||
/* If it doesn't, continue on. */
|
||||
R_UNLESS(has, ncm::ResultContentNotFound());
|
||||
|
||||
|
||||
/* If it does, read the file. */
|
||||
R_RETURN(data.interface->GetProgramId(out, content_id, attr));
|
||||
}));
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -297,4 +297,19 @@ namespace ams::ncm {
|
|||
R_THROW(ncm::ResultInvalidOperation());
|
||||
}
|
||||
|
||||
Result ReadOnlyContentStorageImpl::GetProgramId(sf::Out<ncm::ProgramId> out, ContentId content_id, fs::ContentAttributes attr) {
|
||||
R_TRY(this->EnsureEnabled());
|
||||
|
||||
/* Get the path of the content. */
|
||||
Path path;
|
||||
R_TRY(this->GetPath(std::addressof(path), content_id));
|
||||
|
||||
/* Obtain the program id for the content. */
|
||||
ncm::ProgramId program_id;
|
||||
R_TRY(fs::GetProgramId(std::addressof(program_id), path.str, attr));
|
||||
|
||||
out.SetValue(program_id);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ namespace ams::ncm {
|
|||
virtual Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id, fs::ContentAttributes attr) override;
|
||||
virtual Result RegisterPath(const ContentId &content_id, const Path &path) override;
|
||||
virtual Result ClearRegisteredPath() override;
|
||||
virtual Result GetProgramId(sf::Out<ncm::ProgramId> out, ContentId content_id, fs::ContentAttributes attr) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -186,6 +186,11 @@ namespace ams::ncm {
|
|||
AMS_UNUSED(out_content_info, key, type, id_offset);
|
||||
AMS_ABORT();
|
||||
}
|
||||
|
||||
Result GetPlatform(sf::Out<ncm::ContentMetaPlatform> out, const ContentMetaKey &key) {
|
||||
static_assert(sizeof(ncm::ContentMetaPlatform) == sizeof(u8));
|
||||
R_RETURN(ncmContentMetaDatabaseGetPlatform(std::addressof(m_srv), reinterpret_cast<u8 *>(out.GetPointer()), Convert(key)));
|
||||
}
|
||||
};
|
||||
static_assert(ncm::IsIContentMetaDatabase<RemoteContentMetaDatabaseImpl>);
|
||||
#endif
|
||||
|
|
|
@ -219,6 +219,11 @@ namespace ams::ncm {
|
|||
R_RETURN(ncmContentStorageClearRegisteredPath(std::addressof(m_srv)));
|
||||
}
|
||||
|
||||
Result GetProgramId(sf::Out<ncm::ProgramId> out, ContentId content_id, fs::ContentAttributes attr) {
|
||||
static_assert(sizeof(ncm::ProgramId) == sizeof(u64));
|
||||
R_RETURN(ncmContentStorageGetProgramId(std::addressof(m_srv), reinterpret_cast<u64 *>(out.GetPointer()), Convert(content_id), Convert(attr)));
|
||||
}
|
||||
|
||||
/* 16.0.0 Alignment change hacks. */
|
||||
Result CreatePlaceHolder_AtmosphereAlignmentFix(ContentId content_id, PlaceHolderId placeholder_id, s64 size) { R_RETURN(this->CreatePlaceHolder(placeholder_id, content_id, size)); }
|
||||
Result Register_AtmosphereAlignmentFix(ContentId content_id, PlaceHolderId placeholder_id) { R_RETURN(this->Register(placeholder_id, content_id)); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue