ncm: GetContentAccessibilities, GetContentInfo*
This commit is contained in:
@@ -21,7 +21,7 @@ namespace ams::fs::impl {
|
||||
#define ADD_ENUM_CASE(v) case v: return #v
|
||||
|
||||
template<> const char *IdString::ToString<pkg1::KeyGeneration>(pkg1::KeyGeneration id) {
|
||||
static_assert(pkg1::KeyGeneration_Current == pkg1::KeyGeneration_14_0_0);
|
||||
static_assert(pkg1::KeyGeneration_Current == pkg1::KeyGeneration_15_0_0);
|
||||
switch (id) {
|
||||
using enum pkg1::KeyGeneration;
|
||||
case KeyGeneration_1_0_0: return "1.0.0-2.3.0";
|
||||
@@ -37,7 +37,8 @@ namespace ams::fs::impl {
|
||||
case KeyGeneration_9_1_0: return "9.1.0-12.0.3";
|
||||
case KeyGeneration_12_1_0: return "12.1.0";
|
||||
case KeyGeneration_13_0_0: return "13.0.0-13.2.1";
|
||||
case KeyGeneration_14_0_0: return "14.0.0-";
|
||||
case KeyGeneration_14_0_0: return "14.0.0-14.1.2";
|
||||
case KeyGeneration_15_0_0: return "15.0.0-";
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace ams::ncm {
|
||||
R_TRY(storage->GetSize(std::addressof(size), content_id));
|
||||
|
||||
/* Build. */
|
||||
R_TRY(this->BuildFromPackageContentMeta(package_meta.Get(), package_meta.GetSize(), ContentInfo::Make(content_id, size, ContentType::Meta)));
|
||||
R_TRY(this->BuildFromPackageContentMeta(package_meta.Get(), package_meta.GetSize(), ContentInfo::Make(content_id, size, ContentInfo::DefaultContentAttributes, ContentType::Meta)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace ams::ncm {
|
||||
R_UNLESS(content_id, ncm::ResultInvalidPackageFormat());
|
||||
|
||||
/* Build using the meta. */
|
||||
R_RETURN(this->BuildFromPackageContentMeta(package_meta.Get(), package_meta.GetSize(), ContentInfo::Make(*content_id, entry.file_size, ContentType::Meta)));
|
||||
R_RETURN(this->BuildFromPackageContentMeta(package_meta.Get(), package_meta.GetSize(), ContentInfo::Make(*content_id, entry.file_size, ContentInfo::DefaultContentAttributes, ContentType::Meta)));
|
||||
}));
|
||||
|
||||
/* Commit our changes. */
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
namespace ams::ncm {
|
||||
|
||||
Result ContentMetaDatabaseImpl::GetContentIdImpl(ContentId *out, const ContentMetaKey &key, ContentType type, util::optional<u8> id_offset) const {
|
||||
Result ContentMetaDatabaseImpl::GetContentInfoImpl(ContentInfo *out, const ContentMetaKey &key, ContentType type, util::optional<u8> id_offset) const {
|
||||
R_TRY(this->EnsureEnabled());
|
||||
|
||||
/* Find the meta key. */
|
||||
@@ -45,7 +45,7 @@ namespace ams::ncm {
|
||||
R_UNLESS(content_info != nullptr, ncm::ResultContentNotFound());
|
||||
|
||||
/* Save output. */
|
||||
*out = content_info->content_id;
|
||||
*out = *content_info;
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
@@ -481,4 +481,31 @@ namespace ams::ncm {
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ContentMetaDatabaseImpl::GetContentAccessibilities(sf::Out<u8> out_accessibilities, const ContentMetaKey &key) {
|
||||
R_TRY(this->EnsureEnabled());
|
||||
|
||||
/* Ensure this type of key is for an add-on content. */
|
||||
R_UNLESS(key.type == ContentMetaType::AddOnContent, ncm::ResultInvalidContentMetaKey());
|
||||
|
||||
/* 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_accessibilities.SetValue(reader.GetExtendedHeader<AddOnContentMetaExtendedHeader>()->content_accessibilities);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ContentMetaDatabaseImpl::GetContentInfoByType(sf::Out<ContentInfo> out_content_info, const ContentMetaKey &key, ContentType type) {
|
||||
R_RETURN(this->GetContentInfoImpl(out_content_info.GetPointer(), key, type, util::nullopt));
|
||||
}
|
||||
|
||||
Result ContentMetaDatabaseImpl::GetContentInfoByTypeAndIdOffset(sf::Out<ContentInfo> out_content_info, const ContentMetaKey &key, ContentType type, u8 id_offset) {
|
||||
R_RETURN(this->GetContentInfoImpl(out_content_info.GetPointer(), key, type, util::make_optional(id_offset)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,17 @@ namespace ams::ncm {
|
||||
ContentMetaDatabaseImpl(ContentMetaKeyValueStore *kvs) : ContentMetaDatabaseImplBase(kvs) { /* ... */ }
|
||||
private:
|
||||
/* Helpers. */
|
||||
Result GetContentIdImpl(ContentId *out, const ContentMetaKey &key, ContentType type, util::optional<u8> id_offset) const;
|
||||
Result GetContentInfoImpl(ContentInfo *out, const ContentMetaKey &key, ContentType type, util::optional<u8> id_offset) const;
|
||||
|
||||
Result GetContentIdImpl(ContentId *out, const ContentMetaKey &key, ContentType type, util::optional<u8> id_offset) const {
|
||||
/* Get the content info. */
|
||||
ContentInfo content_info;
|
||||
R_TRY(this->GetContentInfoImpl(std::addressof(content_info), key, type, id_offset));
|
||||
|
||||
/* Set the output id. */
|
||||
*out = content_info.GetId();
|
||||
R_SUCCEED();
|
||||
}
|
||||
public:
|
||||
/* Actual commands. */
|
||||
virtual Result Set(const ContentMetaKey &key, const sf::InBuffer &value) override;
|
||||
@@ -51,6 +61,9 @@ namespace ams::ncm {
|
||||
virtual Result GetContentIdByTypeAndIdOffset(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) override;
|
||||
virtual Result GetCount(sf::Out<u32> out_count) override;
|
||||
virtual Result GetOwnerApplicationId(sf::Out<ApplicationId> out_id, const ContentMetaKey &key) override;
|
||||
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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -77,6 +77,9 @@ namespace ams::ncm {
|
||||
virtual Result GetContentIdByTypeAndIdOffset(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) = 0;
|
||||
virtual Result GetCount(sf::Out<u32> out_count) = 0;
|
||||
virtual Result GetOwnerApplicationId(sf::Out<ApplicationId> out_id, const ContentMetaKey &key) = 0;
|
||||
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;
|
||||
};
|
||||
static_assert(ncm::IsIContentMetaDatabase<ContentMetaDatabaseImplBase>);
|
||||
|
||||
|
||||
@@ -790,7 +790,7 @@ namespace ams::ncm {
|
||||
R_TRY(tmp_buffer.Initialize(reader.CalculateConvertInstallContentMetaSize()));
|
||||
|
||||
/* Convert packaged content meta to install content meta. */
|
||||
reader.ConvertToInstallContentMeta(tmp_buffer.Get(), tmp_buffer.GetSize(), InstallContentInfo::Make(ContentInfo::Make(content_id, size, ContentType::Meta), meta_type));
|
||||
reader.ConvertToInstallContentMeta(tmp_buffer.Get(), tmp_buffer.GetSize(), InstallContentInfo::Make(ContentInfo::Make(content_id, size, ContentInfo::DefaultContentAttributes, ContentType::Meta), meta_type));
|
||||
|
||||
/* Push the content meta. */
|
||||
m_data->Push(tmp_buffer.Get(), tmp_buffer.GetSize());
|
||||
@@ -1028,7 +1028,7 @@ namespace ams::ncm {
|
||||
InstallContentInfo InstallTaskBase::MakeInstallContentInfoFrom(const InstallContentMetaInfo &info, const PlaceHolderId &placeholder_id, util::optional<bool> is_tmp) {
|
||||
return {
|
||||
.digest = info.digest,
|
||||
.info = ContentInfo::Make(info.content_id, info.content_size, ContentType::Meta, 0),
|
||||
.info = ContentInfo::Make(info.content_id, info.content_size, ContentInfo::DefaultContentAttributes, ContentType::Meta, 0),
|
||||
.placeholder_id = placeholder_id,
|
||||
.meta_type = info.key.type,
|
||||
.install_state = InstallState::Prepared,
|
||||
|
||||
@@ -168,6 +168,24 @@ namespace ams::ncm {
|
||||
AMS_UNUSED(out_id, key);
|
||||
AMS_ABORT();
|
||||
}
|
||||
|
||||
Result GetContentAccessibilities(sf::Out<u8> out_accessibilities, const ContentMetaKey &key) {
|
||||
/* TODO: libnx bindings */
|
||||
AMS_UNUSED(out_accessibilities, key);
|
||||
AMS_ABORT();
|
||||
}
|
||||
|
||||
Result GetContentInfoByType(sf::Out<ContentInfo> out_content_info, const ContentMetaKey &key, ContentType type) {
|
||||
/* TODO: libnx bindings */
|
||||
AMS_UNUSED(out_content_info, key, type);
|
||||
AMS_ABORT();
|
||||
}
|
||||
|
||||
Result GetContentInfoByTypeAndIdOffset(sf::Out<ContentInfo> out_content_info, const ContentMetaKey &key, ContentType type, u8 id_offset) {
|
||||
/* TODO: libnx bindings */
|
||||
AMS_UNUSED(out_content_info, key, type, id_offset);
|
||||
AMS_ABORT();
|
||||
}
|
||||
};
|
||||
static_assert(ncm::IsIContentMetaDatabase<RemoteContentMetaDatabaseImpl>);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user