From: jongmyeongko Date: Tue, 18 Jul 2017 14:23:43 +0000 (+0900) Subject: Add appdefined privilege feature X-Git-Tag: accepted/tizen/4.0/unified/20170816.010534~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b5872bf1f65bb6f48d6f070e9b3e7389a03208ae;p=platform%2Fcore%2Fappfw%2Fwgt-backend.git Add appdefined privilege feature Requires: https://review.tizen.org/gerrit/#/c/136932/ https://review.tizen.org/gerrit/#/c/139373/ Change-Id: I185d5fe866b686152616cc20df79e80d8dbb7ea6 Signed-off-by: jongmyeongko --- diff --git a/src/hybrid/step/configuration/step_merge_tpk_privileges.cc b/src/hybrid/step/configuration/step_merge_tpk_privileges.cc index 48f13f5..631189e 100644 --- a/src/hybrid/step/configuration/step_merge_tpk_privileges.cc +++ b/src/hybrid/step/configuration/step_merge_tpk_privileges.cc @@ -21,6 +21,16 @@ common_installer::Step::Status StepMergeTpkPrivileges::process() { g_list_concat(wgt_data->privileges, tpk_data->privileges); tpk_data->privileges = nullptr; + wgt_data->appdefined_privileges = + g_list_concat(wgt_data->appdefined_privileges, + tpk_data->appdefined_privileges); + tpk_data->appdefined_privileges = nullptr; + + wgt_data->provides_appdefined_privileges = + g_list_concat(wgt_data->provides_appdefined_privileges, + tpk_data->provides_appdefined_privileges); + tpk_data->provides_appdefined_privileges = nullptr; + return Status::OK; } diff --git a/src/hybrid/step/pkgmgr/step_generate_xml.cc b/src/hybrid/step/pkgmgr/step_generate_xml.cc index 2004179..00e4e5d 100644 --- a/src/hybrid/step/pkgmgr/step_generate_xml.cc +++ b/src/hybrid/step/pkgmgr/step_generate_xml.cc @@ -33,6 +33,7 @@ const std::vector kBlackListNodes = { {"description"}, {"profile"}, {"privileges"}, + {"provides-appdefined-privileges"}, }; const std::vector kNeedMergeNodes = { {"manifest"}, diff --git a/src/unit_tests/manifest_test.cc b/src/unit_tests/manifest_test.cc index 009cf44..90c9ed6 100644 --- a/src/unit_tests/manifest_test.cc +++ b/src/unit_tests/manifest_test.cc @@ -218,6 +218,210 @@ TEST_F(ManifestTest, PrivilegeElement_MissingName) { ASSERT_FALSE(runner.Run()); } +TEST_F(ManifestTest, AppDefinedPrivilegeElement_Invalid_NotURI) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, AppDefinedPrivilegeElement_Invalid_NoPKGID) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, AppDefinedPrivilegeElement_Invalid_OverLength) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, AppDefinedPrivilegeElement_ValidName) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + std::vector priv_vec; + for (appdefined_privilege_x* priv : + GListRange(m->appdefined_privileges)) { + priv_vec.push_back(priv->value); + } + ASSERT_FALSE(priv_vec.empty()); + const char* expected_name = "http://package0id/appdefined/test.read"; + ASSERT_CSTR_EQ(priv_vec[0].c_str(), expected_name); +} + +TEST_F(ManifestTest, AppDefinedPrivilegeElement_ManyElements) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + std::vector priv_vec; + for (appdefined_privilege_x* priv : + GListRange(m->appdefined_privileges)) { + priv_vec.push_back(priv->value); + } + ASSERT_EQ(priv_vec.size(), 2); + const char* first_priv = "http://package0id/appdefined/test.read"; + ASSERT_CSTR_EQ(priv_vec[0].c_str(), first_priv); + const char* second_priv = "http://package0id/appdefined/test.write"; + ASSERT_CSTR_EQ(priv_vec[1].c_str(), second_priv); +} + +TEST_F(ManifestTest, AppDefinedPrivilegeElement_WithLicenseValidName) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + std::vector priv_vec; + std::vector license_vec; + for (appdefined_privilege_x* priv : + GListRange(m->appdefined_privileges)) { + priv_vec.push_back(priv->value); + license_vec.push_back(priv->license); + } + ASSERT_FALSE(priv_vec.empty()); + const char* expected_name = "http://package0id/appdefined/test.read"; + ASSERT_CSTR_EQ(priv_vec[0].c_str(), expected_name); + ASSERT_FALSE(license_vec.empty()); + bf::path path(m->root_path); + path /= "res/cert"; + ASSERT_CSTR_EQ(license_vec[0].c_str(), path.c_str()); +} + +TEST_F(ManifestTest, AppDefinedPrivilegeElement_WithLicenseManyElements) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + std::vector priv_vec; + std::vector license_vec; + for (appdefined_privilege_x* priv : + GListRange(m->appdefined_privileges)) { + priv_vec.push_back(priv->value); + license_vec.push_back(priv->license); + } + ASSERT_EQ(priv_vec.size(), 2); + const char* first_priv = "http://package0id/appdefined/test.read"; + ASSERT_CSTR_EQ(priv_vec[0].c_str(), first_priv); + const char* second_priv = "http://package0id/appdefined/test.write"; + ASSERT_CSTR_EQ(priv_vec[1].c_str(), second_priv); + ASSERT_EQ(license_vec.size(), 2); + bf::path path(m->root_path); + path /= "res/cert"; + ASSERT_CSTR_EQ(license_vec[0].c_str(), path.c_str()); + ASSERT_CSTR_EQ(license_vec[1].c_str(), path.c_str()); +} + +TEST_F(ManifestTest, AppDefinedPrivilegeElement_InvalidName) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, AppDefinedPrivilegeElement_MissingName) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, ProvidesAppDefinedPrivilegeElement_Invalid_NotURI) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, ProvidesAppDefinedPrivilegeElement_Invalid_NoPKGID) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, ProvidesAppDefinedPrivilegeElement_Invalid_OverLength) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, ProvidesAppDefinedPrivilegeElement_ValidName) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + std::vector priv_vec; + for (appdefined_privilege_x* priv : GListRange( + m->provides_appdefined_privileges)) { + priv_vec.push_back(priv->value); + } + ASSERT_FALSE(priv_vec.empty()); + const char* expected_name = "http://package0id/appdefined/test.read"; + ASSERT_CSTR_EQ(priv_vec[0].c_str(), expected_name); +} + +TEST_F(ManifestTest, ProvidesAppDefinedPrivilegeElement_ManyElements) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + std::vector priv_vec; + for (appdefined_privilege_x* priv : GListRange( + m->provides_appdefined_privileges)) { + priv_vec.push_back(priv->value); + } + ASSERT_EQ(priv_vec.size(), 2); + const char* first_priv = "http://package0id/appdefined/test.read"; + ASSERT_CSTR_EQ(priv_vec[0].c_str(), first_priv); + const char* second_priv = "http://package0id/appdefined/test.write"; + ASSERT_CSTR_EQ(priv_vec[1].c_str(), second_priv); +} + +TEST_F(ManifestTest, ProvidesAppDefinedPrivilegeElement_WithLicenseValidName) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + std::vector priv_vec; + std::vector license_vec; + for (appdefined_privilege_x* priv : GListRange( + m->provides_appdefined_privileges)) { + priv_vec.push_back(priv->value); + license_vec.push_back(priv->license); + } + ASSERT_FALSE(priv_vec.empty()); + const char* expected_name = "http://package0id/appdefined/test.read"; + ASSERT_CSTR_EQ(priv_vec[0].c_str(), expected_name); + ASSERT_FALSE(license_vec.empty()); + bf::path path(m->root_path); + path /= "res/cert"; + ASSERT_CSTR_EQ(license_vec[0].c_str(), path.c_str()); +} + +TEST_F(ManifestTest, + ProvidesAppDefinedPrivilegeElement_WithLicenseManyElements) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + std::vector priv_vec; + std::vector license_vec; + for (appdefined_privilege_x* priv : GListRange( + m->provides_appdefined_privileges)) { + priv_vec.push_back(priv->value); + license_vec.push_back(priv->license); + } + ASSERT_EQ(priv_vec.size(), 2); + const char* first_priv = "http://package0id/appdefined/test.read"; + ASSERT_CSTR_EQ(priv_vec[0].c_str(), first_priv); + const char* second_priv = "http://package0id/appdefined/test.write"; + ASSERT_CSTR_EQ(priv_vec[1].c_str(), second_priv); + ASSERT_EQ(license_vec.size(), 2); + bf::path path(m->root_path); + path /= "res/cert"; + ASSERT_CSTR_EQ(license_vec[0].c_str(), path.c_str()); + ASSERT_CSTR_EQ(license_vec[1].c_str(), path.c_str()); +} + +TEST_F(ManifestTest, ProvidesAppDefinedPrivilegeElement_InvalidName) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, ProvidesAppDefinedPrivilegeElement_MissingName) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} TEST_F(ManifestTest, AppControlElement_Valid) { StepParseRunner runner(GetMyName()); diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_InvalidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_InvalidName/config.xml new file mode 100644 index 0000000..d5aaa70 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_InvalidName/config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml new file mode 100644 index 0000000..4cb239b --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_NoURI/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_NoURI/config.xml new file mode 100644 index 0000000..d824f8d --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_NoURI/config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_OverLength/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_OverLength/config.xml new file mode 100644 index 0000000..79a8bec --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_OverLength/config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_ManyElements/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_ManyElements/config.xml new file mode 100644 index 0000000..97cdcc1 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_ManyElements/config.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_MissingName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_MissingName/config.xml new file mode 100644 index 0000000..3dc4f44 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_MissingName/config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_ValidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_ValidName/config.xml new file mode 100644 index 0000000..00611d1 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_ValidName/config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_WithLicenseManyElements/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_WithLicenseManyElements/config.xml new file mode 100644 index 0000000..270313a --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_WithLicenseManyElements/config.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_WithLicenseValidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_WithLicenseValidName/config.xml new file mode 100644 index 0000000..536dca6 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_WithLicenseValidName/config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_InvalidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_InvalidName/config.xml new file mode 100644 index 0000000..78ca65a --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_InvalidName/config.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml new file mode 100644 index 0000000..748f827 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoURI/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoURI/config.xml new file mode 100644 index 0000000..68e32f7 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoURI/config.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_OverLength/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_OverLength/config.xml new file mode 100644 index 0000000..201ebd7 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_OverLength/config.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ManyElements/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ManyElements/config.xml new file mode 100644 index 0000000..f01fb27 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ManyElements/config.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_MissingName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_MissingName/config.xml new file mode 100644 index 0000000..bb84800 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_MissingName/config.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ValidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ValidName/config.xml new file mode 100644 index 0000000..613eae7 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ValidName/config.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseManyElements/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseManyElements/config.xml new file mode 100644 index 0000000..297cbdf --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseManyElements/config.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseValidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseValidName/config.xml new file mode 100644 index 0000000..7d85238 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseValidName/config.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index 1844dec..f1825e2 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -545,6 +546,68 @@ bool StepParse::FillPrivileges(manifest_x* manifest) { return true; } +bool StepParse::FillAppDefinedPrivileges(manifest_x* manifest) { + auto priv_info = + GetManifestDataForKey( + app_keys::kTizenAppDefinedPrivilegeKey); + if (!priv_info) + return true; + + const auto& privileges = priv_info->GetAppDefinedPrivilegeList(); + for (auto& priv : privileges) { + appdefined_privilege_x* privilege = + reinterpret_cast(calloc(1, + sizeof(appdefined_privilege_x))); + if (privilege == nullptr) { + LOG(ERROR) << "Memory alloc failure"; + return false; + } + privilege->value = strdup(priv.privilege.c_str()); + privilege->type = strdup(common_installer::kWebPrivilegeType); + if (!priv.license.empty()) { + if (bf::path(priv.license).is_absolute()) + privilege->license = strdup(priv.license.c_str()); + else + privilege->license = strdup((context_->root_application_path.get() + / manifest->package / priv.license).c_str()); + } + manifest->appdefined_privileges = + g_list_append(manifest->appdefined_privileges, privilege); + } + return true; +} + +bool StepParse::FillProvidesAppDefinedPrivileges(manifest_x* manifest) { + auto priv_info = + GetManifestDataForKey( + app_keys::kTizenProvidesAppDefinedPrivilegesKey); + if (!priv_info) + return true; + + const auto& privileges = priv_info->GetAppDefinedPrivilegeList(); + for (auto& priv : privileges) { + appdefined_privilege_x* privilege = + reinterpret_cast(calloc(1, + sizeof(appdefined_privilege_x))); + if (privilege == nullptr) { + LOG(ERROR) << "Memory alloc failure"; + return false; + } + privilege->value = strdup(priv.privilege.c_str()); + privilege->type = strdup(common_installer::kWebPrivilegeType); + if (!priv.license.empty()) { + if (bf::path(priv.license).is_absolute()) + privilege->license = strdup(priv.license.c_str()); + else + privilege->license = strdup((context_->root_application_path.get() + / manifest->package / priv.license).c_str()); + } + manifest->provides_appdefined_privileges = + g_list_append(manifest->provides_appdefined_privileges, privilege); + } + return true; +} + bool StepParse::FillCategories(manifest_x* manifest) { auto category_info = GetManifestDataForKey( @@ -642,6 +705,10 @@ bool StepParse::FillManifestX(manifest_x* manifest) { return false; if (!FillPrivileges(manifest)) return false; + if (!FillAppDefinedPrivileges(manifest)) + return false; + if (!FillProvidesAppDefinedPrivileges(manifest)) + return false; if (!FillAppControl(manifest)) return false; if (!FillCategories(manifest)) diff --git a/src/wgt/step/configuration/step_parse.h b/src/wgt/step/configuration/step_parse.h index d2a42dc..10e5f9e 100644 --- a/src/wgt/step/configuration/step_parse.h +++ b/src/wgt/step/configuration/step_parse.h @@ -63,6 +63,8 @@ class StepParse : public common_installer::Step { bool FillWidgetApplicationInfo(manifest_x* manifest); bool FillAppControl(manifest_x* manifest); bool FillPrivileges(manifest_x* manifest); + bool FillAppDefinedPrivileges(manifest_x* manifest); + bool FillProvidesAppDefinedPrivileges(manifest_x* manifest); bool FillCategories(manifest_x* manifest); bool FillMetadata(manifest_x* manifest); bool FillExtraManifestInfo(manifest_x* manifest); diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc index 370d403..ab05829 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.cc +++ b/src/wgt/step/pkgmgr/step_generate_xml.cc @@ -386,6 +386,7 @@ common_installer::Step::Status StepGenerateXml::GenerateManifestElement( return status; } GeneratePrivilege(writer); + GenerateProvidesAppDefinedPrivilege(writer); GenerateAccount(writer); GenerateIme(writer); GenerateProfiles(writer); @@ -505,7 +506,36 @@ void StepGenerateXml::GeneratePrivilege(xmlTextWriterPtr writer) { xmlTextWriterWriteString(writer, BAD_CAST priv->value); xmlTextWriterEndElement(writer); } + if (context_->manifest_data.get()->appdefined_privileges) { + for (appdefined_privilege_x* priv : GListRange( + context_->manifest_data.get()->appdefined_privileges)) { + xmlTextWriterStartElement(writer, BAD_CAST "appdefined-privilege"); + xmlTextWriterWriteAttribute(writer, BAD_CAST "license", + BAD_CAST priv->license); + xmlTextWriterWriteAttribute(writer, BAD_CAST "type", + BAD_CAST priv->type); + xmlTextWriterWriteString(writer, BAD_CAST priv->value); + xmlTextWriterEndElement(writer); + } + } + xmlTextWriterEndElement(writer); + } +} +void StepGenerateXml::GenerateProvidesAppDefinedPrivilege( + xmlTextWriterPtr writer) { + if (context_->manifest_data.get()->provides_appdefined_privileges) { + xmlTextWriterStartElement(writer, BAD_CAST "provides-appdefined-privileges"); + for (appdefined_privilege_x* priv : GListRange( + context_->manifest_data.get()->provides_appdefined_privileges)) { + xmlTextWriterStartElement(writer, BAD_CAST "appdefined-privilege"); + xmlTextWriterWriteAttribute(writer, BAD_CAST "license", + BAD_CAST priv->license); + xmlTextWriterWriteAttribute(writer, BAD_CAST "type", + BAD_CAST priv->type); + xmlTextWriterWriteString(writer, BAD_CAST priv->value); + xmlTextWriterEndElement(writer); + } xmlTextWriterEndElement(writer); } } diff --git a/src/wgt/step/pkgmgr/step_generate_xml.h b/src/wgt/step/pkgmgr/step_generate_xml.h index 5dbb706..5bb7f89 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.h +++ b/src/wgt/step/pkgmgr/step_generate_xml.h @@ -44,6 +44,7 @@ class StepGenerateXml : public common_installer::Step { void GenerateDescription(xmlTextWriterPtr writer); Step::Status GenerateApplications(xmlTextWriterPtr writer); void GeneratePrivilege(xmlTextWriterPtr writer); + void GenerateProvidesAppDefinedPrivilege(xmlTextWriterPtr writer); void GenerateAccount(xmlTextWriterPtr writer); void GenerateIme(xmlTextWriterPtr writer); void GenerateProfiles(xmlTextWriterPtr writer);