From 49b41267bd5f173571993f006cb60f1bf6a60851 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Thu, 2 Jun 2016 14:58:32 +0200 Subject: [PATCH 01/16] STEP_NAME marco Adding marco to print name of step that failed in AppInstaller class Following must be submitted together: - https://review.tizen.org/gerrit/72827 - https://review.tizen.org/gerrit/72828 - https://review.tizen.org/gerrit/72829 Change-Id: I88056f428cc88ceb1a0c375103f4acc410314abe --- src/hybrid/step/configuration/step_merge_tpk_config.h | 2 +- src/hybrid/step/configuration/step_stash_tpk_config.h | 2 +- src/hybrid/step/encryption/step_encrypt_resources.h | 2 +- src/unit_tests/smoke_test_helper.cc | 2 ++ src/wgt/step/configuration/step_parse.h | 2 +- src/wgt/step/configuration/step_parse_recovery.h | 2 +- src/wgt/step/encryption/step_encrypt_resources.h | 2 +- src/wgt/step/encryption/step_remove_encryption_data.h | 2 +- src/wgt/step/filesystem/step_copy_preview_icons.h | 2 +- src/wgt/step/filesystem/step_create_symbolic_link.h | 2 +- src/wgt/step/filesystem/step_wgt_patch_icons.h | 2 +- src/wgt/step/filesystem/step_wgt_patch_storage_directories.h | 2 +- src/wgt/step/filesystem/step_wgt_prepare_package_directory.h | 2 +- src/wgt/step/filesystem/step_wgt_resource_directory.h | 2 +- src/wgt/step/filesystem/step_wgt_update_package_directory.h | 2 +- src/wgt/step/pkgmgr/step_generate_xml.h | 2 +- src/wgt/step/rds/step_wgt_rds_modify.h | 2 ++ src/wgt/step/security/step_add_default_privileges.h | 2 +- src/wgt/step/security/step_check_settings_level.h | 2 +- src/wgt/step/security/step_check_wgt_ime_privilege.h | 2 +- src/wgt/step/security/step_check_wgt_notification_category.h | 2 ++ src/wgt/step/security/step_direct_manifest_check_signature.h | 2 +- 22 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/hybrid/step/configuration/step_merge_tpk_config.h b/src/hybrid/step/configuration/step_merge_tpk_config.h index 0414abe..2171d59 100644 --- a/src/hybrid/step/configuration/step_merge_tpk_config.h +++ b/src/hybrid/step/configuration/step_merge_tpk_config.h @@ -25,7 +25,7 @@ class StepMergeTpkConfig : public common_installer::Step { Status undo() override { return Status::OK; } Status precheck() override { return Status::OK; } - SCOPE_LOG_TAG(MergeTpkConfig) + STEP_NAME(MergeTpkConfig) }; } // namespace configuration diff --git a/src/hybrid/step/configuration/step_stash_tpk_config.h b/src/hybrid/step/configuration/step_stash_tpk_config.h index 7cc889c..2ac4716 100644 --- a/src/hybrid/step/configuration/step_stash_tpk_config.h +++ b/src/hybrid/step/configuration/step_stash_tpk_config.h @@ -25,7 +25,7 @@ class StepStashTpkConfig : public common_installer::Step { Status undo() override { return Status::OK; } Status precheck() override { return Status::OK; } - SCOPE_LOG_TAG(StashTpkConfig) + STEP_NAME(StashTpkConfig) }; } // namespace configuration diff --git a/src/hybrid/step/encryption/step_encrypt_resources.h b/src/hybrid/step/encryption/step_encrypt_resources.h index ec66852..88b0f5b 100644 --- a/src/hybrid/step/encryption/step_encrypt_resources.h +++ b/src/hybrid/step/encryption/step_encrypt_resources.h @@ -24,7 +24,7 @@ class StepEncryptResources : public wgt::encryption::StepEncryptResources { private: void SetEncryptionRoot() override; - SCOPE_LOG_TAG(EncryptResources) + STEP_NAME(EncryptResources) }; } // namespace encryption diff --git a/src/unit_tests/smoke_test_helper.cc b/src/unit_tests/smoke_test_helper.cc index c3988d6..0d37d1c 100644 --- a/src/unit_tests/smoke_test_helper.cc +++ b/src/unit_tests/smoke_test_helper.cc @@ -23,6 +23,8 @@ class StepCrash : public ci::Step { ci::Step::Status clean() override { return ci::Step::Status::OK; } ci::Step::Status undo() override { return ci::Step::Status::OK; } ci::Step::Status precheck() override { return ci::Step::Status::OK; } + + STEP_NAME(Crash) }; } // namespace diff --git a/src/wgt/step/configuration/step_parse.h b/src/wgt/step/configuration/step_parse.h index 4a41978..eb7e7fa 100644 --- a/src/wgt/step/configuration/step_parse.h +++ b/src/wgt/step/configuration/step_parse.h @@ -74,7 +74,7 @@ class StepParse : public common_installer::Step { ConfigLocation config_location_; bool check_start_file_; - SCOPE_LOG_TAG(Parse) + STEP_NAME(Parse) }; } // namespace configuration diff --git a/src/wgt/step/configuration/step_parse_recovery.h b/src/wgt/step/configuration/step_parse_recovery.h index bc30019..5af4ce3 100644 --- a/src/wgt/step/configuration/step_parse_recovery.h +++ b/src/wgt/step/configuration/step_parse_recovery.h @@ -47,7 +47,7 @@ class StepParseRecovery : public StepParse { */ Status precheck() override; - SCOPE_LOG_TAG(ParseRecovery) + STEP_NAME(ParseRecovery) }; } // namespace configuration diff --git a/src/wgt/step/encryption/step_encrypt_resources.h b/src/wgt/step/encryption/step_encrypt_resources.h index 628b0e9..27e4d02 100644 --- a/src/wgt/step/encryption/step_encrypt_resources.h +++ b/src/wgt/step/encryption/step_encrypt_resources.h @@ -63,7 +63,7 @@ class StepEncryptResources : public common_installer::Step { bool EncryptFile(const boost::filesystem::path &src); bool ToBeEncrypted(const boost::filesystem::path &file); WgtBackendData* backend_data_; - SCOPE_LOG_TAG(EncryptResources) + STEP_NAME(EncryptResources) }; } // namespace encryption diff --git a/src/wgt/step/encryption/step_remove_encryption_data.h b/src/wgt/step/encryption/step_remove_encryption_data.h index f372e39..0fe8d67 100644 --- a/src/wgt/step/encryption/step_remove_encryption_data.h +++ b/src/wgt/step/encryption/step_remove_encryption_data.h @@ -31,7 +31,7 @@ class StepRemoveEncryptionData : public common_installer::Step { Status undo() override { return Status::OK; } Status precheck() override { return Status::OK; } - SCOPE_LOG_TAG(RemoveEncryptionData) + STEP_NAME(RemoveEncryptionData) }; } // namespace encryption } // namespace wgt diff --git a/src/wgt/step/filesystem/step_copy_preview_icons.h b/src/wgt/step/filesystem/step_copy_preview_icons.h index ee9c525..5a51d83 100644 --- a/src/wgt/step/filesystem/step_copy_preview_icons.h +++ b/src/wgt/step/filesystem/step_copy_preview_icons.h @@ -26,7 +26,7 @@ class StepCopyPreviewIcons : public common_installer::Step { Status undo() override { return Status::OK; } Status precheck() override { return Status::OK; } - SCOPE_LOG_TAG(CopyPreviewIcons) + STEP_NAME(CopyPreviewIcons) }; } // namespace filesystem diff --git a/src/wgt/step/filesystem/step_create_symbolic_link.h b/src/wgt/step/filesystem/step_create_symbolic_link.h index dbe650b..43b3ddb 100644 --- a/src/wgt/step/filesystem/step_create_symbolic_link.h +++ b/src/wgt/step/filesystem/step_create_symbolic_link.h @@ -56,7 +56,7 @@ class StepCreateSymbolicLink : public common_installer::Step { bool CreateSymlinksForApps(); bool CreateSymlinksForAppWidgets(); - SCOPE_LOG_TAG(SymbolicLink) + STEP_NAME(SymbolicLink) }; } // namespace filesystem diff --git a/src/wgt/step/filesystem/step_wgt_patch_icons.h b/src/wgt/step/filesystem/step_wgt_patch_icons.h index d4ff8fb..1f478a5 100644 --- a/src/wgt/step/filesystem/step_wgt_patch_icons.h +++ b/src/wgt/step/filesystem/step_wgt_patch_icons.h @@ -28,7 +28,7 @@ class StepWgtPatchIcons : public common_installer::Step { Status clean() override { return Status::OK; } Status precheck() override { return Status::OK; } - SCOPE_LOG_TAG(WgtPatchIcons) + STEP_NAME(WgtPatchIcons) }; } // namespace filesystem diff --git a/src/wgt/step/filesystem/step_wgt_patch_storage_directories.h b/src/wgt/step/filesystem/step_wgt_patch_storage_directories.h index c3a61e9..f4ab56f 100644 --- a/src/wgt/step/filesystem/step_wgt_patch_storage_directories.h +++ b/src/wgt/step/filesystem/step_wgt_patch_storage_directories.h @@ -30,7 +30,7 @@ class StepWgtPatchStorageDirectories : bool ShareDirFor3x(); bool CreatePrivateTmpDir(); - SCOPE_LOG_TAG(PatchWgtStorageDirectories) + STEP_NAME(PatchWgtStorageDirectories) }; } // namespace filesystem diff --git a/src/wgt/step/filesystem/step_wgt_prepare_package_directory.h b/src/wgt/step/filesystem/step_wgt_prepare_package_directory.h index 6d35f30..dd98d4c 100644 --- a/src/wgt/step/filesystem/step_wgt_prepare_package_directory.h +++ b/src/wgt/step/filesystem/step_wgt_prepare_package_directory.h @@ -36,7 +36,7 @@ class StepWgtPreparePackageDirectory : public common_installer::Step { private: Status CreateSymlinkToMountPoint(); - SCOPE_LOG_TAG(WgtPreparePackageDirectory) + STEP_NAME(WgtPreparePackageDirectory) }; } // namespace filesystem diff --git a/src/wgt/step/filesystem/step_wgt_resource_directory.h b/src/wgt/step/filesystem/step_wgt_resource_directory.h index 7fa9a4c..f5437fd 100644 --- a/src/wgt/step/filesystem/step_wgt_resource_directory.h +++ b/src/wgt/step/filesystem/step_wgt_resource_directory.h @@ -53,7 +53,7 @@ class StepWgtResourceDirectory : public common_installer::Step { */ Status precheck() override { return Status::OK; } - SCOPE_LOG_TAG(CreateWgtResourceDirectory) + STEP_NAME(CreateWgtResourceDirectory) }; } // namespace filesystem diff --git a/src/wgt/step/filesystem/step_wgt_update_package_directory.h b/src/wgt/step/filesystem/step_wgt_update_package_directory.h index aa15c02..b8aefbb 100644 --- a/src/wgt/step/filesystem/step_wgt_update_package_directory.h +++ b/src/wgt/step/filesystem/step_wgt_update_package_directory.h @@ -24,7 +24,7 @@ class StepWgtUpdatePackageDirectory : public StepWgtPreparePackageDirectory { Status CreateBackupOfDirectories(); Status RecoverBackupOfDirectories(); - SCOPE_LOG_TAG(WgtUpdatePackageDirectory) + STEP_NAME(WgtUpdatePackageDirectory) }; } // namespace filesystem diff --git a/src/wgt/step/pkgmgr/step_generate_xml.h b/src/wgt/step/pkgmgr/step_generate_xml.h index 00b82e6..a00b9d3 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.h +++ b/src/wgt/step/pkgmgr/step_generate_xml.h @@ -37,7 +37,7 @@ class StepGenerateXml : public common_installer::Step { xmlTextWriterPtr writer, AppCompType type); - SCOPE_LOG_TAG(GenerateXML) + STEP_NAME(GenerateXML) }; } // namespace pkgmgr diff --git a/src/wgt/step/rds/step_wgt_rds_modify.h b/src/wgt/step/rds/step_wgt_rds_modify.h index 67f9d28..2812b5a 100644 --- a/src/wgt/step/rds/step_wgt_rds_modify.h +++ b/src/wgt/step/rds/step_wgt_rds_modify.h @@ -31,6 +31,8 @@ class StepWgtRDSModify : public common_installer::rds::StepRDSModify { * \return std::string */ std::string GetAppPath() override; + + STEP_NAME(WgtRDSModify) }; } // namespace rds diff --git a/src/wgt/step/security/step_add_default_privileges.h b/src/wgt/step/security/step_add_default_privileges.h index b7759a9..84c7bca 100644 --- a/src/wgt/step/security/step_add_default_privileges.h +++ b/src/wgt/step/security/step_add_default_privileges.h @@ -50,7 +50,7 @@ class StepAddDefaultPrivileges : public common_installer::Step { */ Status precheck() override; - SCOPE_LOG_TAG(AddDefaultPrivileges) + STEP_NAME(AddDefaultPrivileges) }; } // namespace security diff --git a/src/wgt/step/security/step_check_settings_level.h b/src/wgt/step/security/step_check_settings_level.h index 3dfd8ac..adc7337 100644 --- a/src/wgt/step/security/step_check_settings_level.h +++ b/src/wgt/step/security/step_check_settings_level.h @@ -50,7 +50,7 @@ class StepCheckSettingsLevel : public common_installer::Step { */ Status precheck() override { return Status::OK; } - SCOPE_LOG_TAG(CheckSettingsLevel) + STEP_NAME(CheckSettingsLevel) }; } // namespace security diff --git a/src/wgt/step/security/step_check_wgt_ime_privilege.h b/src/wgt/step/security/step_check_wgt_ime_privilege.h index d5595db..04f49c8 100644 --- a/src/wgt/step/security/step_check_wgt_ime_privilege.h +++ b/src/wgt/step/security/step_check_wgt_ime_privilege.h @@ -31,7 +31,7 @@ class StepCheckWgtImePrivilege : Status CheckImePrivilege() const; - SCOPE_LOG_TAG(CheckWgtImePrivilege) + STEP_NAME(CheckWgtImePrivilege) }; } // namespace security } // namespace wgt diff --git a/src/wgt/step/security/step_check_wgt_notification_category.h b/src/wgt/step/security/step_check_wgt_notification_category.h index 738a6ea..842b531 100644 --- a/src/wgt/step/security/step_check_wgt_notification_category.h +++ b/src/wgt/step/security/step_check_wgt_notification_category.h @@ -24,6 +24,8 @@ class StepCheckWgtNotificationCategory : Status clean() override { return Status::OK; } Status undo() override { return Status::OK; } Status precheck() override { return Status::OK; } + + STEP_NAME(CheckWgtNotificationCategory) }; } // namespace security } // namespace wgt diff --git a/src/wgt/step/security/step_direct_manifest_check_signature.h b/src/wgt/step/security/step_direct_manifest_check_signature.h index a24d910..a56a998 100644 --- a/src/wgt/step/security/step_direct_manifest_check_signature.h +++ b/src/wgt/step/security/step_direct_manifest_check_signature.h @@ -19,7 +19,7 @@ class StepDirectManifestCheckSignature private: boost::filesystem::path GetSignatureRoot() const override; - SCOPE_LOG_TAG(StepDirectManifestCheckSignature) + STEP_NAME(StepDirectManifestCheckSignature) }; } // namespace security -- 2.7.4 From 70f5b6d15f222869221b012499e40ebda3ac7f4b Mon Sep 17 00:00:00 2001 From: Piotr Ganicz Date: Wed, 25 May 2016 14:43:38 +0200 Subject: [PATCH 02/16] Refactoring of StepGenerateXml This patch provides refactoring for StepGenerateXml::process() method into smaller pieces. Change-Id: I3889f127bb4344a79cd18fb2875d6983a9ab20a7 --- src/wgt/step/pkgmgr/step_generate_xml.cc | 105 ++++++++++++++++++++++--------- src/wgt/step/pkgmgr/step_generate_xml.h | 13 ++++ 2 files changed, 87 insertions(+), 31 deletions(-) diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc index 6bf7403..724203d 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.cc +++ b/src/wgt/step/pkgmgr/step_generate_xml.cc @@ -243,6 +243,13 @@ common_installer::Step::Status StepGenerateXml::GenerateApplicationCommonXml( return Step::Status::OK; } +common_installer::Step::Status StepGenerateXml::undo() { + bs::error_code error; + if (bf::exists(context_->xml_path.get())) + bf::remove_all(context_->xml_path.get(), error); + return Status::OK; +} + common_installer::Step::Status StepGenerateXml::precheck() { if (!context_->manifest_data.get()) { LOG(ERROR) << "manifest_data attribute is empty"; @@ -278,7 +285,6 @@ common_installer::Step::Status StepGenerateXml::process() { } xmlTextWriterPtr writer; - writer = xmlNewTextWriterFilename(context_->xml_path.get().c_str(), 0); if (!writer) { LOG(ERROR) << "Failed to create new file"; @@ -286,12 +292,52 @@ common_installer::Step::Status StepGenerateXml::process() { } xmlTextWriterStartDocument(writer, nullptr, nullptr, nullptr); - xmlTextWriterSetIndent(writer, 1); - // add manifest Element + Status status = GenerateManifestElement(writer); + if (status != Status::OK) { + return status; + } + + xmlTextWriterEndDocument(writer); + xmlFreeTextWriter(writer); + + if (pkgmgr_parser_check_manifest_validation( + context_->xml_path.get().c_str()) != 0) { + LOG(ERROR) << "Manifest is not valid"; + return Step::Status::MANIFEST_ERROR; + } + + LOG(DEBUG) << "Successfully create manifest xml " + << context_->xml_path.get(); + return Status::OK; +} + +common_installer::Step::Status StepGenerateXml::GenerateManifestElement( + xmlTextWriterPtr writer) { xmlTextWriterStartElement(writer, BAD_CAST "manifest"); + GenerateManifestElementAttributes(writer); + GenerateLangLabels(writer); + GenerateAuthor(writer); + GenerateDescription(writer); + Status status = GenerateApplications(writer); + if (status != Status::OK) { + return status; + } + GeneratePrivilege(writer); + GenerateAccount(writer); + GenerateIme(writer); + GenerateProfiles(writer); + GenerateShortcuts(writer); + GenerateWidget(writer); + + xmlTextWriterEndElement(writer); + return Status::OK; +} + +void StepGenerateXml::GenerateManifestElementAttributes( + xmlTextWriterPtr writer) { xmlTextWriterWriteAttribute(writer, BAD_CAST "xmlns", BAD_CAST "http://tizen.org/ns/packages"); xmlTextWriterWriteAttribute(writer, BAD_CAST "package", @@ -304,7 +350,9 @@ common_installer::Step::Status StepGenerateXml::process() { BAD_CAST context_->manifest_data.get()->api_version); xmlTextWriterWriteAttribute(writer, BAD_CAST "nodisplay-setting", BAD_CAST context_->manifest_data.get()->nodisplay_setting); +} +void StepGenerateXml::GenerateLangLabels(xmlTextWriterPtr writer) { for (label_x* label : GListRange(context_->manifest_data.get()->label)) { xmlTextWriterStartElement(writer, BAD_CAST "label"); @@ -315,7 +363,9 @@ common_installer::Step::Status StepGenerateXml::process() { xmlTextWriterWriteString(writer, BAD_CAST label->name); xmlTextWriterEndElement(writer); } +} +void StepGenerateXml::GenerateAuthor(xmlTextWriterPtr writer) { for (author_x* author : GListRange(context_->manifest_data.get()->author)) { xmlTextWriterStartElement(writer, BAD_CAST "author"); @@ -330,7 +380,9 @@ common_installer::Step::Status StepGenerateXml::process() { xmlTextWriterWriteString(writer, BAD_CAST author->text); xmlTextWriterEndElement(writer); } +} +void StepGenerateXml::GenerateDescription(xmlTextWriterPtr writer) { for (description_x* description : GListRange(context_->manifest_data.get()->description)) { xmlTextWriterStartElement(writer, BAD_CAST "description"); @@ -341,8 +393,10 @@ common_installer::Step::Status StepGenerateXml::process() { xmlTextWriterWriteString(writer, BAD_CAST description->text); xmlTextWriterEndElement(writer); } +} - // add application +common_installer::Step::Status StepGenerateXml::GenerateApplications( + xmlTextWriterPtr writer) { for (application_x* app : GListRange(context_->manifest_data.get()->application)) { AppCompType type; @@ -366,12 +420,11 @@ common_installer::Step::Status StepGenerateXml::process() { GenerateApplicationCommonXml(app, writer, type); xmlTextWriterEndElement(writer); } + return Status::OK; +} - const auto &ime = context_->manifest_plugins_data.get().ime_info.get(); - const auto ime_uuid = ime.uuid(); - - // add privilege element - if (context_->manifest_data.get()->privileges) { +void StepGenerateXml::GeneratePrivilege(xmlTextWriterPtr writer) { + if (context_->manifest_data.get()->privileges) { xmlTextWriterStartElement(writer, BAD_CAST "privileges"); for (const char* priv : GListRange(context_->manifest_data.get()->privileges)) { @@ -381,7 +434,9 @@ common_installer::Step::Status StepGenerateXml::process() { xmlTextWriterEndElement(writer); } +} +void StepGenerateXml::GenerateAccount(xmlTextWriterPtr writer) { const auto& accounts = context_->manifest_plugins_data.get().account_info.get().accounts(); if (!accounts.empty()) { @@ -431,7 +486,11 @@ common_installer::Step::Status StepGenerateXml::process() { } xmlTextWriterEndElement(writer); } +} +void StepGenerateXml::GenerateIme(xmlTextWriterPtr writer) { + const auto &ime = context_->manifest_plugins_data.get().ime_info.get(); + const auto ime_uuid = ime.uuid(); if (!ime_uuid.empty()) { xmlTextWriterStartElement(writer, BAD_CAST "ime"); @@ -461,7 +520,9 @@ common_installer::Step::Status StepGenerateXml::process() { xmlTextWriterEndElement(writer); } +} +void StepGenerateXml::GenerateProfiles(xmlTextWriterPtr writer) { for (const char* profile : GListRange(context_->manifest_data.get()->deviceprofile)) { xmlTextWriterStartElement(writer, BAD_CAST "profile"); @@ -469,7 +530,9 @@ common_installer::Step::Status StepGenerateXml::process() { BAD_CAST profile); xmlTextWriterEndElement(writer); } +} +void StepGenerateXml::GenerateShortcuts(xmlTextWriterPtr writer) { const auto& shortcuts = context_->manifest_plugins_data.get().shortcut_info.get(); if (!shortcuts.empty()) { @@ -502,7 +565,9 @@ common_installer::Step::Status StepGenerateXml::process() { } xmlTextWriterEndElement(writer); } +} +void StepGenerateXml::GenerateWidget(xmlTextWriterPtr writer) { WgtBackendData* backend_data = static_cast(context_->backend_data.get()); bf::path widget_content_path = context_->pkg_path.get() / kResWgt; @@ -573,28 +638,6 @@ common_installer::Step::Status StepGenerateXml::process() { xmlTextWriterEndElement(writer); } - - xmlTextWriterEndElement(writer); - - xmlTextWriterEndDocument(writer); - xmlFreeTextWriter(writer); - - if (pkgmgr_parser_check_manifest_validation( - context_->xml_path.get().c_str()) != 0) { - LOG(ERROR) << "Manifest is not valid"; - return Step::Status::MANIFEST_ERROR; - } - - LOG(DEBUG) << "Successfully create manifest xml " - << context_->xml_path.get(); - return Status::OK; -} - -common_installer::Step::Status StepGenerateXml::undo() { - bs::error_code error; - if (bf::exists(context_->xml_path.get())) - bf::remove_all(context_->xml_path.get(), error); - return Status::OK; } } // namespace pkgmgr diff --git a/src/wgt/step/pkgmgr/step_generate_xml.h b/src/wgt/step/pkgmgr/step_generate_xml.h index a00b9d3..f4be3a7 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.h +++ b/src/wgt/step/pkgmgr/step_generate_xml.h @@ -37,6 +37,19 @@ class StepGenerateXml : public common_installer::Step { xmlTextWriterPtr writer, AppCompType type); + Step::Status GenerateManifestElement(xmlTextWriterPtr writer); + void GenerateManifestElementAttributes(xmlTextWriterPtr writer); + void GenerateLangLabels(xmlTextWriterPtr writer); + void GenerateAuthor(xmlTextWriterPtr writer); + void GenerateDescription(xmlTextWriterPtr writer); + Step::Status GenerateApplications(xmlTextWriterPtr writer); + void GeneratePrivilege(xmlTextWriterPtr writer); + void GenerateAccount(xmlTextWriterPtr writer); + void GenerateIme(xmlTextWriterPtr writer); + void GenerateProfiles(xmlTextWriterPtr writer); + void GenerateShortcuts(xmlTextWriterPtr writer); + void GenerateWidget(xmlTextWriterPtr writer); + STEP_NAME(GenerateXML) }; -- 2.7.4 From ffed32d0f9f28668c0409507c5b71cc606cd8348 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Wed, 1 Jun 2016 13:29:06 +0200 Subject: [PATCH 03/16] Fix generating widget-application item This commit is based on: - https://review.tizen.org/gerrit/71796 The way it is changed is: - widget information is gathered in manifest_x structure and backend data because data that is created by StepParse is inserted into database directly according to past changes (even we add widget information to generated manifest it is not read). - icon path is full path for widget-application (same as for ui-application) to handle icon backup, copying and pkgmgr expectations. - is changed to defined in manifest.xsd.in in pkgmgr-info repository. Requires: - https://review.tizen.org/gerrit/71798 - https://review.tizen.org/gerrit/72573 Change-Id: I2c980ae205f29fb70928aba58d8d3458d88a9c90 --- src/wgt/step/configuration/step_parse.cc | 82 ++++++++++--- src/wgt/step/configuration/step_parse.h | 1 + .../step/filesystem/step_create_symbolic_link.cc | 23 +--- .../step/filesystem/step_create_symbolic_link.h | 1 - src/wgt/step/pkgmgr/step_generate_xml.cc | 128 ++++++++------------- src/wgt/step/pkgmgr/step_generate_xml.h | 1 - 6 files changed, 115 insertions(+), 121 deletions(-) diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index ad485ca..ee937d2 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -84,6 +84,17 @@ void SetApplicationXDefaults(application_x* application) { application->ui_gadget = strdup("false"); } +template +void AppendLabel(T* root, const std::string& label, + const std::string& locale) { + label_x* label_item = reinterpret_cast(calloc(1, sizeof(label_x))); + label_item->name = strdup(label.c_str()); + label_item->text = strdup(label.c_str()); + label_item->lang = !locale.empty() ? + strdup(locale.c_str()) : strdup(DEFAULT_LOCALE); + root->label = g_list_append(root->label, label_item); +} + } // namespace namespace wgt { @@ -182,12 +193,7 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) { } for (auto& item : wgt_info->name_set()) { - label_x* label = reinterpret_cast(calloc(1, sizeof(label_x))); - label->name = strdup(item.second.c_str()); - label->text = strdup(item.second.c_str()); - label->lang = !item.first.empty() ? - strdup(item.first.c_str()) : strdup(DEFAULT_LOCALE); - manifest->label = g_list_append(manifest->label, label); + AppendLabel(manifest, item.second, item.first); } manifest->type = strdup("wgt"); @@ -199,12 +205,7 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) { for (auto& item : wgt_info->name_set()) { application_x* app = reinterpret_cast(manifest->application->data); - label_x* label = reinterpret_cast(calloc(1, sizeof(label_x))); - label->name = strdup(item.second.c_str()); - label->text = strdup(item.second.c_str()); - label->lang = !item.first.empty() ? - strdup(item.first.c_str()) : strdup(DEFAULT_LOCALE); - app->label = g_list_append(app->label, label); + AppendLabel(app, item.second, item.first); } author_x* author = reinterpret_cast(calloc(1, sizeof(author_x))); @@ -337,12 +338,7 @@ bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) { application->package = strdup(manifest->package); for (auto& pair : service_info.names()) { - label_x* label = reinterpret_cast(calloc(1, sizeof(label_x))); - label->lang = !pair.first.empty() ? - strdup(pair.first.c_str()) : strdup(DEFAULT_LOCALE); - label->name = strdup(pair.second.c_str()); - label->text = strdup(pair.second.c_str()); - application->label = g_list_append(application->label, label); + AppendLabel(application, pair.second, pair.first); } if (!service_info.icon().empty()) { @@ -373,6 +369,51 @@ bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) { return true; } +bool StepParse::FillWidgetApplicationInfo(manifest_x* manifest) { + std::shared_ptr appwidget_info = + std::static_pointer_cast( + parser_->GetManifestData( + wgt::application_widget_keys::kTizenAppWidgetFullKey)); + if (!appwidget_info) + return true; + for (auto& app_widget : appwidget_info->app_widgets()) { + application_x* application = reinterpret_cast + (calloc(1, sizeof(application_x))); + application->component_type = strdup("widgetapp"); + application->mainapp = strdup("false"); + application->multiple = strdup("false"); + application->appid = strdup(app_widget.id.c_str()); + application->exec = + strdup((context_->root_application_path.get() / manifest->package + / "bin" / application->appid).c_str()); + application->type = strdup("webapp"); + application->nodisplay = strdup("false"); + application->taskmanage = strdup("false"); + SetApplicationXDefaults(application); + application->ambient_support = strdup("false"); + application->package = strdup(manifest->package); + + if (!app_widget.label.default_value.empty()) { + AppendLabel(application, app_widget.label.default_value, std::string()); + } + + for (auto& pair : app_widget.label.lang_value_map) { + AppendLabel(application, pair.second, pair.first); + } + + if (!app_widget.icon_src.empty()) { + icon_x* icon = reinterpret_cast(calloc(1, sizeof(icon_x))); + icon->text = strdup(app_widget.icon_src.c_str()); + icon->lang = strdup(DEFAULT_LOCALE); + application->icon = g_list_append(application->icon, icon); + } + + manifest->application = g_list_append(manifest->application, application); + } + return true; +} + + bool StepParse::FillBackgroundCategoryInfo(manifest_x* manifest) { auto manifest_data = parser_->GetManifestData( app_keys::kTizenBackgroundCategoryKey); @@ -459,6 +500,7 @@ bool StepParse::FillMetadata(manifest_x* manifest) { } bool StepParse::FillAppWidget() { + // This is needed to store preview icons which are not saved into manifest_x WgtBackendData* backend_data = static_cast(context_->backend_data.get()); @@ -533,9 +575,11 @@ bool StepParse::FillManifestX(manifest_x* manifest) { // TODO(t.iwanek): fix adding ui application element // for now adding application service is added here because rest of code // assumes that there is one application at manifest->application - // so this must execute last + // so this must execute last. Don't move it above any item if (!FillServiceApplicationInfo(manifest)) return false; + if (!FillWidgetApplicationInfo(manifest)) + return false; if (!FillBackgroundCategoryInfo(manifest)) return false; if (!FillExtraManifestInfo(manifest)) diff --git a/src/wgt/step/configuration/step_parse.h b/src/wgt/step/configuration/step_parse.h index eb7e7fa..e7b9357 100644 --- a/src/wgt/step/configuration/step_parse.h +++ b/src/wgt/step/configuration/step_parse.h @@ -59,6 +59,7 @@ class StepParse : public common_installer::Step { bool FillWidgetInfo(manifest_x* manifest); bool FillMainApplicationInfo(manifest_x* manifest); bool FillServiceApplicationInfo(manifest_x* manifest); + bool FillWidgetApplicationInfo(manifest_x* manifest); bool FillAppControl(manifest_x* manifest); bool FillPrivileges(manifest_x* manifest); bool FillCategories(manifest_x* manifest); diff --git a/src/wgt/step/filesystem/step_create_symbolic_link.cc b/src/wgt/step/filesystem/step_create_symbolic_link.cc index b23fcae..bc94fe2 100644 --- a/src/wgt/step/filesystem/step_create_symbolic_link.cc +++ b/src/wgt/step/filesystem/step_create_symbolic_link.cc @@ -17,8 +17,6 @@ #include #include -#include "wgt/wgt_backend_data.h" - namespace bf = boost::filesystem; namespace bs = boost::system; @@ -49,6 +47,8 @@ bool StepCreateSymbolicLink::CreateSymlinksForApps() { bf::create_symlink(bf::path(WRT_LAUNCHER), exec_path, error); } else if (strcmp(app->component_type, "watchapp") == 0) { bf::create_symlink(bf::path(WRT_LAUNCHER), exec_path, error); + } else if (strcmp(app->component_type, "widgetapp") == 0) { + bf::create_symlink(kWidgetClientBinaryPath, exec_path, error); } else { bf::create_symlink(kWrtServiceBinaryPath, exec_path, error); } @@ -61,31 +61,12 @@ bool StepCreateSymbolicLink::CreateSymlinksForApps() { return true; } -bool StepCreateSymbolicLink::CreateSymlinksForAppWidgets() { - WgtBackendData* backend_data = - static_cast(context_->backend_data.get()); - for (auto& appwidget : backend_data->appwidgets.get().app_widgets()) { - bf::path exec_path = context_->pkg_path.get() / "bin" / appwidget.id; - bs::error_code error; - bf::create_symlink(kWidgetClientBinaryPath, exec_path, error); - if (error) { - LOG(ERROR) << "Failed to create symlink for app widget: " - << appwidget.id; - return false; - } - } - return true; -} - common_installer::Step::Status StepCreateSymbolicLink::process() { assert(context_->manifest_data.get()); if (!CreateSymlinksForApps()) return Status::APP_DIR_ERROR; - if (!CreateSymlinksForAppWidgets()) - return Status::APP_DIR_ERROR; - LOG(DEBUG) << "Symlinks created successfully"; return Status::OK; } diff --git a/src/wgt/step/filesystem/step_create_symbolic_link.h b/src/wgt/step/filesystem/step_create_symbolic_link.h index 43b3ddb..048c759 100644 --- a/src/wgt/step/filesystem/step_create_symbolic_link.h +++ b/src/wgt/step/filesystem/step_create_symbolic_link.h @@ -54,7 +54,6 @@ class StepCreateSymbolicLink : public common_installer::Step { private: bool CreateSymlinksForApps(); - bool CreateSymlinksForAppWidgets(); STEP_NAME(SymbolicLink) }; diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc index 724203d..1148642 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.cc +++ b/src/wgt/step/pkgmgr/step_generate_xml.cc @@ -84,18 +84,54 @@ void WriteServiceApplicationAttributes( BAD_CAST app->taskmanage); } -void WriteWidgetApplicationAttributes( - xmlTextWriterPtr writer, application_x *app) { +bool WriteWidgetApplicationAttributesAndElements( + xmlTextWriterPtr writer, application_x *app, + const wgt::parse::AppWidgetInfo& widget_info, + const bf::path& shared_path) { if (app->nodisplay) xmlTextWriterWriteAttribute(writer, BAD_CAST "nodisplay", BAD_CAST app->nodisplay); if (app->multiple) xmlTextWriterWriteAttribute(writer, BAD_CAST "multiple", BAD_CAST app->multiple); + + // Generate attributes and elements not covered in manifest.xsd + auto& appwidgets = widget_info.app_widgets(); + const auto& appwidget = std::find_if(appwidgets.begin(), appwidgets.end(), + [app](const wgt::parse::AppWidget& widget) { + return widget.id == app->appid; + }); + if (appwidget == appwidgets.end()) { + LOG(ERROR) << "Failed to generate appwidget extra elements"; + return false; + } + + xmlTextWriterWriteAttribute(writer, BAD_CAST "main", + BAD_CAST (appwidget->primary ? "true" : "false")); // NOLINT + xmlTextWriterWriteAttribute(writer, BAD_CAST "update-period", BAD_CAST "0"); + + for (auto& size : appwidget->content_size) { + xmlTextWriterStartElement(writer, BAD_CAST "support-size"); + + std::string type = wgt::parse::AppWidgetSizeTypeToString(size.type); + if (!size.preview.empty()) { + std::string icon_name = shared_path.string() + "/" + appwidget->id + "." + type + "." + "preview" + + bf::path(size.preview).extension().string(); + xmlTextWriterWriteAttribute(writer, BAD_CAST "preview", + BAD_CAST icon_name.c_str()); // NOLINT + } + + xmlTextWriterWriteAttribute(writer, BAD_CAST "frame", + BAD_CAST "true"); + xmlTextWriterWriteString(writer, + BAD_CAST type.c_str()); + xmlTextWriterEndElement(writer); + } + return true; } void WriteWatchApplicationAttributes( - xmlTextWriterPtr writer, application_x *app) { + xmlTextWriterPtr writer, application_x* app) { if (app->ambient_support) xmlTextWriterWriteAttribute(writer, BAD_CAST "ambient-support", BAD_CAST app->ambient_support); @@ -132,7 +168,11 @@ common_installer::Step::Status StepGenerateXml::GenerateApplicationCommonXml( WriteServiceApplicationAttributes(writer, app); break; case AppCompType::WIDGETAPP: - WriteWidgetApplicationAttributes(writer, app); + if (!WriteWidgetApplicationAttributesAndElements(writer, app, + static_cast( + context_->backend_data.get())->appwidgets.get(), + context_->pkg_path.get() / "shared" / "res")) + return Status::MANIFEST_ERROR; break; case AppCompType::WATCHAPP: WriteWatchApplicationAttributes(writer, app); @@ -330,7 +370,6 @@ common_installer::Step::Status StepGenerateXml::GenerateManifestElement( GenerateIme(writer); GenerateProfiles(writer); GenerateShortcuts(writer); - GenerateWidget(writer); xmlTextWriterEndElement(writer); return Status::OK; @@ -417,7 +456,11 @@ common_installer::Step::Status StepGenerateXml::GenerateApplications( xmlFreeTextWriter(writer); return Status::ERROR; } - GenerateApplicationCommonXml(app, writer, type); + Status status = GenerateApplicationCommonXml(app, writer, type); + if (status != Status::OK) { + xmlFreeTextWriter(writer); + return status; + } xmlTextWriterEndElement(writer); } return Status::OK; @@ -567,78 +610,5 @@ void StepGenerateXml::GenerateShortcuts(xmlTextWriterPtr writer) { } } -void StepGenerateXml::GenerateWidget(xmlTextWriterPtr writer) { - WgtBackendData* backend_data = - static_cast(context_->backend_data.get()); - bf::path widget_content_path = context_->pkg_path.get() / kResWgt; - for (auto& appwidget : backend_data->appwidgets.get().app_widgets()) { - xmlTextWriterStartElement(writer, BAD_CAST "widget"); - xmlTextWriterWriteAttribute(writer, BAD_CAST "appid", - BAD_CAST appwidget.id.c_str()); - xmlTextWriterWriteAttribute(writer, BAD_CAST "primary", - BAD_CAST (appwidget.primary ? "true" : "false")); // NOLINT - xmlTextWriterWriteAttribute(writer, BAD_CAST "abi", - BAD_CAST "html"); - xmlTextWriterWriteAttribute(writer, BAD_CAST "network", - BAD_CAST "true"); - xmlTextWriterWriteAttribute(writer, BAD_CAST "nodisplay", - BAD_CAST "false"); - - if (!appwidget.label.default_value.empty()) { - xmlTextWriterStartElement(writer, BAD_CAST "label"); - xmlTextWriterWriteString(writer, - BAD_CAST appwidget.label.default_value.c_str()); - xmlTextWriterEndElement(writer); - } - for (auto& pair : appwidget.label.lang_value_map) { - xmlTextWriterStartElement(writer, BAD_CAST "label"); - xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang", - BAD_CAST pair.first.c_str()); - xmlTextWriterWriteString(writer, BAD_CAST pair.second.c_str()); - xmlTextWriterEndElement(writer); - } - - if (!appwidget.icon_src.empty()) { - xmlTextWriterStartElement(writer, BAD_CAST "icon"); - xmlTextWriterWriteString(writer, BAD_CAST appwidget.icon_src.c_str()); - xmlTextWriterEndElement(writer); - } - - xmlTextWriterStartElement(writer, BAD_CAST "box"); - xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST "buffer"); - xmlTextWriterWriteAttribute(writer, BAD_CAST "mouse_event", - BAD_CAST (appwidget.content_mouse_event ? "true" : "false")); // NOLINT - xmlTextWriterWriteAttribute(writer, BAD_CAST "touch_effect", - BAD_CAST (appwidget.content_touch_effect ? "true" : "false")); // NOLINT - xmlTextWriterStartElement(writer, BAD_CAST "script"); - bf::path src = widget_content_path / appwidget.content_src; - xmlTextWriterWriteAttribute(writer, BAD_CAST "src", - BAD_CAST src.c_str()); - xmlTextWriterEndElement(writer); - for (auto& size : appwidget.content_size) { - xmlTextWriterStartElement(writer, BAD_CAST "size"); - - std::string type = wgt::parse::AppWidgetSizeTypeToString(size.type); - if (!size.preview.empty()) { - std::string icon_name = appwidget.id + "." + type + "." + "preview" + - bf::path(size.preview).extension().string(); - bf::path preview_icon = - context_->pkg_path.get() / kSharedRes / icon_name; - xmlTextWriterWriteAttribute(writer, BAD_CAST "preview", - BAD_CAST preview_icon.c_str()); // NOLINT - } - - xmlTextWriterWriteAttribute(writer, BAD_CAST "need_frame", - BAD_CAST "true"); - xmlTextWriterWriteString(writer, - BAD_CAST type.c_str()); - xmlTextWriterEndElement(writer); - } - xmlTextWriterEndElement(writer); - - xmlTextWriterEndElement(writer); - } -} - } // namespace pkgmgr } // namespace wgt diff --git a/src/wgt/step/pkgmgr/step_generate_xml.h b/src/wgt/step/pkgmgr/step_generate_xml.h index f4be3a7..5dbb706 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.h +++ b/src/wgt/step/pkgmgr/step_generate_xml.h @@ -48,7 +48,6 @@ class StepGenerateXml : public common_installer::Step { void GenerateIme(xmlTextWriterPtr writer); void GenerateProfiles(xmlTextWriterPtr writer); void GenerateShortcuts(xmlTextWriterPtr writer); - void GenerateWidget(xmlTextWriterPtr writer); STEP_NAME(GenerateXML) }; -- 2.7.4 From 761a13058814f05500026601bbe67dcfd7aa8987 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Mon, 13 Jun 2016 15:51:02 +0900 Subject: [PATCH 04/16] set label to prevent execution by non-system application. Change-Id: I12e682b56fa142919ef1d6941d995b7874cab130 Signed-off-by: jongmyeongko --- packaging/wgt-backend.manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.manifest b/packaging/wgt-backend.manifest index 55125da..85f79f1 100644 --- a/packaging/wgt-backend.manifest +++ b/packaging/wgt-backend.manifest @@ -3,6 +3,6 @@ - + -- 2.7.4 From c487e4bf613524114db57876f33790a7a0b66a3d Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Mon, 13 Jun 2016 16:45:48 +0900 Subject: [PATCH 05/16] Add StepCheckRestriction Added at install, uninstall, reinstall, mount install. Change-Id: I85ff7e43ac8b9033654b116b436a0db04953572f Signed-off-by: Sangyoon Jang --- src/hybrid/hybrid_installer.cc | 4 ++++ src/wgt/wgt_installer.cc | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index c1765cc..b54c8e5 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -94,6 +95,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep( wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, true); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -167,6 +169,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) break; case ci::RequestType::Uninstall: AddStep(pkgmgr_); + AddStep(); AddStep(); AddStep( ci::configuration::StepParseManifest::ManifestLocation::INSTALLED, @@ -264,6 +267,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep( wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, true); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index 13176b2..11b7c9b 100644 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -95,6 +96,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep( wgt::configuration::StepParse::ConfigLocation::PACKAGE, true); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -163,6 +165,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) } case ci::RequestType::Uninstall: { AddStep(pkgmgr_); + AddStep(); AddStep(); AddStep( ci::configuration::StepParseManifest::ManifestLocation::INSTALLED, @@ -186,6 +189,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(pkgmgr_); AddStep( wgt::configuration::StepParse::ConfigLocation::PACKAGE, false); + AddStep(); AddStep(); AddStep(); AddStep( @@ -269,6 +273,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep( wgt::configuration::StepParse::ConfigLocation::PACKAGE, true); + AddStep(); AddStep(); AddStep(); AddStep(); -- 2.7.4 From 487c97263f921ed473549f6c6022827e50ff33f1 Mon Sep 17 00:00:00 2001 From: JongHeon Choi Date: Thu, 9 Jun 2016 11:30:12 +0900 Subject: [PATCH 06/16] Change the binary name.(widget-client => web-widget-runtime) Change-Id: If3da83217bd4e3739079689697a56b5454b714e0 --- src/wgt/step/filesystem/step_create_symbolic_link.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wgt/step/filesystem/step_create_symbolic_link.cc b/src/wgt/step/filesystem/step_create_symbolic_link.cc index bc94fe2..cbdbb7f 100644 --- a/src/wgt/step/filesystem/step_create_symbolic_link.cc +++ b/src/wgt/step/filesystem/step_create_symbolic_link.cc @@ -23,7 +23,7 @@ namespace bs = boost::system; namespace { const char kWrtServiceBinaryPath[] = "/usr/bin/wrt-service"; -const char kWidgetClientBinaryPath[] = "/usr/bin/widget-client"; +const char kWebWidgetRuntimeBinaryPath[] = "/usr/bin/web-widget-runtime"; } // namespace @@ -48,7 +48,7 @@ bool StepCreateSymbolicLink::CreateSymlinksForApps() { } else if (strcmp(app->component_type, "watchapp") == 0) { bf::create_symlink(bf::path(WRT_LAUNCHER), exec_path, error); } else if (strcmp(app->component_type, "widgetapp") == 0) { - bf::create_symlink(kWidgetClientBinaryPath, exec_path, error); + bf::create_symlink(kWebWidgetRuntimeBinaryPath, exec_path, error); } else { bf::create_symlink(kWrtServiceBinaryPath, exec_path, error); } -- 2.7.4 From 810e4243029550e4861625943e8bd949023097b8 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Thu, 16 Jun 2016 20:39:59 +0900 Subject: [PATCH 07/16] apply PIE option Change-Id: I7d3271747ff9be58b0f8a46637a8282000c59b3c Signed-off-by: jongmyeongko --- CMakeLists.txt | 23 ++++++++++++----------- src/hybrid/CMakeLists.txt | 1 + src/unit_tests/CMakeLists.txt | 6 +++--- src/wgt/CMakeLists.txt | 1 + src/wgt_backend/CMakeLists.txt | 2 ++ 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08858fa..20eafb2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,13 +13,18 @@ IF(NOT CMAKE_BUILD_TYPE) ENDIF(NOT CMAKE_BUILD_TYPE) # Compiler flags -SET(CMAKE_C_FLAGS_PROFILING "-O2") -SET(CMAKE_CXX_FLAGS_PROFILING "-O2 -std=c++11") -SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") -SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -std=c++11 -g") -SET(CMAKE_C_FLAGS_RELEASE "-O2 -g") -SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -std=c++11 -g") -SET(CMAKE_CXX_FLAGS_CCOV "-O0 -std=c++11 -g --coverage") +SET(EXTRA_FLAGS "-Wall -Wextra") +SET(CMAKE_C_FLAGS_PROFILING "-O2 ${EXTRA_FLAGS}") +SET(CMAKE_CXX_FLAGS_PROFILING "-O2 -std=c++11 ${EXTRA_FLAGS}") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g ${EXTRA_FLAGS}") +SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -std=c++11 -g ${EXTRA_FLAGS}") +SET(CMAKE_C_FLAGS_RELEASE "-O2 -g ${EXTRA_FLAGS}") +SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -std=c++11 -g ${EXTRA_FLAGS}") +SET(CMAKE_CXX_FLAGS_CCOV "-O0 -std=c++11 -g --coverage ${EXTRA_FLAGS}") + +# Linker flags +SET(EXTRA_LINKER_FLAGS "-Wl,--as-needed") +SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EXTRA_LINKER_FLAGS}") # Targets SET(TARGET_LIBNAME_WGT "wgt-installer") @@ -30,10 +35,6 @@ SET(TARGET_SMOKE_TEST "smoke-test") SET(TARGET_SMOKE_TEST_HELPER "smoke-test-helper") SET(TARGET_MANIFEST_TEST "manifest-test") -ADD_DEFINITIONS("-Wall") -ADD_DEFINITIONS("-Wextra") -ADD_DEFINITIONS("-fPIE") -ADD_DEFINITIONS("-fPIC") ADD_DEFINITIONS("-DPROJECT_TAG=\"WGT_BACKEND\"") SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/") diff --git a/src/hybrid/CMakeLists.txt b/src/hybrid/CMakeLists.txt index 72cc3d2..ccc7f4a 100644 --- a/src/hybrid/CMakeLists.txt +++ b/src/hybrid/CMakeLists.txt @@ -16,3 +16,4 @@ APPLY_PKG_CONFIG(${TARGET_LIBNAME_HYBRID} PUBLIC # Target - in-package deps TARGET_LINK_LIBRARIES(${TARGET_LIBNAME_HYBRID} PRIVATE ${TARGET_LIBNAME_WGT}) +SET_TARGET_PROPERTIES(${TARGET_LIBNAME_HYBRID} PROPERTIES COMPILE_FLAGS "-fPIC") diff --git a/src/unit_tests/CMakeLists.txt b/src/unit_tests/CMakeLists.txt index 7222f1e..3947045 100644 --- a/src/unit_tests/CMakeLists.txt +++ b/src/unit_tests/CMakeLists.txt @@ -29,9 +29,9 @@ APPLY_PKG_CONFIG(${TARGET_MANIFEST_TEST} PUBLIC # FindGTest module do not sets all needed libraries in GTEST_LIBRARIES and # GTest main libraries is still missing, so additional linking of # GTEST_MAIN_LIBRARIES is needed. -target_link_libraries(${TARGET_SMOKE_TEST} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_LIBNAME_HYBRID} ${GTEST_MAIN_LIBRARIES}) -target_link_libraries(${TARGET_SMOKE_TEST_HELPER} PRIVATE ${TARGET_LIBNAME_WGT}) -target_link_libraries(${TARGET_MANIFEST_TEST} PRIVATE ${TARGET_LIBNAME_WGT} ${GTEST_MAIN_LIBRARIES}) +TARGET_LINK_LIBRARIES(${TARGET_SMOKE_TEST} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_LIBNAME_HYBRID} ${GTEST_MAIN_LIBRARIES}) +TARGET_LINK_LIBRARIES(${TARGET_SMOKE_TEST_HELPER} PRIVATE ${TARGET_LIBNAME_WGT}) +TARGET_LINK_LIBRARIES(${TARGET_MANIFEST_TEST} PRIVATE ${TARGET_LIBNAME_WGT} ${GTEST_MAIN_LIBRARIES}) INSTALL(TARGETS ${TARGET_SMOKE_TEST} DESTINATION ${BINDIR}/${DESTINATION_DIR}) INSTALL(TARGETS ${TARGET_SMOKE_TEST_HELPER} DESTINATION ${BINDIR}/${DESTINATION_DIR}) diff --git a/src/wgt/CMakeLists.txt b/src/wgt/CMakeLists.txt index ea51011..f45acc5 100644 --- a/src/wgt/CMakeLists.txt +++ b/src/wgt/CMakeLists.txt @@ -42,3 +42,4 @@ APPLY_PKG_CONFIG(${TARGET_LIBNAME_WGT} PUBLIC ENCRYPTION_DEPS Boost ) +SET_TARGET_PROPERTIES(${TARGET_LIBNAME_WGT} PROPERTIES COMPILE_FLAGS "-fPIC") diff --git a/src/wgt_backend/CMakeLists.txt b/src/wgt_backend/CMakeLists.txt index 54f886e..79807f6 100644 --- a/src/wgt_backend/CMakeLists.txt +++ b/src/wgt_backend/CMakeLists.txt @@ -6,6 +6,8 @@ TARGET_INCLUDE_DIRECTORIES(${TARGET_WGT_BACKEND} PUBLIC "${CMAKE_CURRENT_SOURCE_ # Target - in-package deps TARGET_LINK_LIBRARIES(${TARGET_WGT_BACKEND} PRIVATE ${TARGET_LIBNAME_WGT}) TARGET_LINK_LIBRARIES(${TARGET_WGT_BACKEND} PRIVATE ${TARGET_LIBNAME_HYBRID}) +SET_TARGET_PROPERTIES(${TARGET_WGT_BACKEND} PROPERTIES COMPILE_FLAGS ${CFLAGS} "-fPIE") +SET_TARGET_PROPERTIES(${TARGET_WGT_BACKEND} PROPERTIES LINK_FLAGS "-pie") # Install INSTALL(TARGETS ${TARGET_WGT_BACKEND} DESTINATION ${BINDIR}) -- 2.7.4 From e4076b741c3091c2bdebf422dbed000e2b4e59f2 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Fri, 10 Jun 2016 12:58:58 +0200 Subject: [PATCH 08/16] Implement move request for wgt-backend Check success of commands to verify: wgt-backend -i ${package} wgt-backend -m ${pkgid} -t 1 wgt-backend -m ${pkgid} -t 2 Change-Id: I72ef419c1b4c5f99b3477265a7549a53c5efa838 --- src/wgt/step/configuration/step_parse.cc | 1 + src/wgt/wgt_installer.cc | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index ee937d2..51c86ca 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -200,6 +200,7 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) { manifest->appsetting = strdup("false"); manifest->nodisplay_setting = strdup("false"); manifest->preload = strdup("false"); + manifest->installed_storage = strdup("installed_internal"); // For wgt package use the long name for (auto& item : wgt_info->name_set()) { diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index 11b7c9b..bfa2b4e 100644 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -377,6 +378,16 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); break; } + case ci::RequestType::Move: { + AddStep(pkgmgr_); + AddStep( + ci::configuration::StepParseManifest::ManifestLocation::INSTALLED, + ci::configuration::StepParseManifest::StoreLocation::NORMAL); + AddStep(); + AddStep(); + AddStep(); + break; + } default: { AddStep(); } -- 2.7.4 From 97105afe0264304db009f68f0e10333db77217af Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Mon, 13 Jun 2016 15:39:43 +0200 Subject: [PATCH 09/16] New use of tep steps For internal installation tep is removed with files removal. For external installation tep file must be removed from sd card. Requires: - https://review.tizen.org/gerrit/#/c/74068/ Submit together: - https://review.tizen.org/gerrit/#/c/74068/ - https://review.tizen.org/gerrit/#/c/74293/ - https://review.tizen.org/gerrit/#/c/74294/ Change-Id: I2457b1918d5cb8450c8d1f3f93d42bec77f65d5f --- src/hybrid/hybrid_installer.cc | 11 ++++++----- src/wgt/wgt_installer.cc | 12 +++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index b54c8e5..9b8be50 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -31,7 +31,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -44,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -151,8 +152,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); - AddStep(); - AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -181,6 +181,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -221,6 +222,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -323,8 +325,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); - AddStep(); - AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index bfa2b4e..7abd4e2 100644 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -33,8 +33,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -47,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -149,8 +150,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); - AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -178,6 +178,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -199,6 +200,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); break; @@ -232,6 +234,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -323,8 +326,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); - AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); -- 2.7.4 From e82d90ac3087342e09f4dc5d81167aebb32c5119 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Wed, 25 May 2016 12:39:18 +0200 Subject: [PATCH 10/16] Fix StepParse for tizen:service icon According to 782d65d706b0bc46e12a2e041a9331893c788f6c icon path should be always set with full path. To verify: - install widget with tag and check shared/res/ for icons there should be one per tizen:service and one for widget itself. Change-Id: I58d61c447b88a70de34faabaff81c07133f4cfe4 --- src/wgt/step/configuration/step_parse.cc | 4 +++- src/wgt/step/filesystem/step_wgt_patch_icons.cc | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index 51c86ca..5e1a677 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -343,8 +343,10 @@ bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) { } if (!service_info.icon().empty()) { + bf::path icon_path = context_->root_application_path.get() + / manifest->package / "res" / "wgt" / service_info.icon(); icon_x* icon = reinterpret_cast(calloc(1, sizeof(icon_x))); - icon->text = strdup(service_info.icon().c_str()); + icon->text = strdup(icon_path.c_str()); icon->lang = strdup(DEFAULT_LOCALE); application->icon = g_list_append(application->icon, icon); } diff --git a/src/wgt/step/filesystem/step_wgt_patch_icons.cc b/src/wgt/step/filesystem/step_wgt_patch_icons.cc index d9a1827..5bcb229 100644 --- a/src/wgt/step/filesystem/step_wgt_patch_icons.cc +++ b/src/wgt/step/filesystem/step_wgt_patch_icons.cc @@ -13,10 +13,6 @@ namespace bf = boost::filesystem; namespace bs = boost::system; namespace ci = common_installer; -namespace { -const char kResWgt[] = "res/wgt"; -} // namespace - namespace wgt { namespace filesystem { -- 2.7.4 From c32ebaf7ea6c7b4e1593327e7b6bd3a156a32d10 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Wed, 22 Jun 2016 17:52:03 +0900 Subject: [PATCH 11/16] grant User label to wgt-backend Change-Id: I301c4e2c990a7c3aab377cf9435bb194d8d40868 Signed-off-by: jongmyeongko --- packaging/wgt-backend.manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.manifest b/packaging/wgt-backend.manifest index 85f79f1..18893ce 100644 --- a/packaging/wgt-backend.manifest +++ b/packaging/wgt-backend.manifest @@ -3,6 +3,6 @@ - + -- 2.7.4 From 6099c6684c9f61ffae80084671e6a023a41df03d Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Mon, 13 Jun 2016 16:06:10 +0200 Subject: [PATCH 12/16] Rename backup_paths.h to paths.h Submit together: - https://review.tizen.org/gerrit/74296 - https://review.tizen.org/gerrit/74297 - https://review.tizen.org/gerrit/74298 Change-Id: I9b679eebc05951df0e9c706c1495bf54a376fb9e --- src/unit_tests/smoke_test.cc | 2 +- src/wgt/step/configuration/step_parse.cc | 2 +- src/wgt/step/configuration/step_parse_recovery.cc | 2 +- src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc | 2 +- src/wgt/step/filesystem/step_wgt_update_package_directory.cc | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/unit_tests/smoke_test.cc b/src/unit_tests/smoke_test.cc index 3ab430b..f150590 100644 --- a/src/unit_tests/smoke_test.cc +++ b/src/unit_tests/smoke_test.cc @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index 5e1a677..24c359b 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/wgt/step/configuration/step_parse_recovery.cc b/src/wgt/step/configuration/step_parse_recovery.cc index c01cb41..8ff406d 100644 --- a/src/wgt/step/configuration/step_parse_recovery.cc +++ b/src/wgt/step/configuration/step_parse_recovery.cc @@ -4,7 +4,7 @@ #include "wgt/step/configuration/step_parse_recovery.h" -#include +#include #include namespace { diff --git a/src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc b/src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc index fc4907b..a4e1d6a 100644 --- a/src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc +++ b/src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc @@ -8,7 +8,7 @@ #include #include -#include +#include #include namespace bf = boost::filesystem; diff --git a/src/wgt/step/filesystem/step_wgt_update_package_directory.cc b/src/wgt/step/filesystem/step_wgt_update_package_directory.cc index 0aadad5..17e07d9 100644 --- a/src/wgt/step/filesystem/step_wgt_update_package_directory.cc +++ b/src/wgt/step/filesystem/step_wgt_update_package_directory.cc @@ -8,7 +8,7 @@ #include #include -#include +#include #include namespace bf = boost::filesystem; -- 2.7.4 From 5a036ff4525f485ee44cbc53e05452508a9cbe15 Mon Sep 17 00:00:00 2001 From: Piotr Ganicz Date: Tue, 21 Jun 2016 10:50:51 +0200 Subject: [PATCH 13/16] Refactoring StepParse Change-Id: Ib396f828909c4c114c82876b504c37bdb682a128 --- src/wgt/step/configuration/step_parse.cc | 134 +++++++++++++++---------------- src/wgt/step/configuration/step_parse.h | 11 ++- 2 files changed, 74 insertions(+), 71 deletions(-) diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index 24c359b..602df3f 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -82,6 +82,7 @@ void SetApplicationXDefaults(application_x* application) { application->submode = strdup("false"); application->support_disable = strdup("false"); application->ui_gadget = strdup("false"); + application->multiple = strdup("false"); } template @@ -94,7 +95,6 @@ void AppendLabel(T* root, const std::string& label, strdup(locale.c_str()) : strdup(DEFAULT_LOCALE); root->label = g_list_append(root->label, label_item); } - } // namespace namespace wgt { @@ -146,16 +146,16 @@ bool StepParse::FillInstallationInfo(manifest_x* manifest) { } bool StepParse::FillIconPaths(manifest_x* manifest) { - std::shared_ptr app_info = - std::static_pointer_cast( - parser_->GetManifestData(app_keys::kTizenApplicationKey)); + auto app_info = + GetManifestDataForKey( + app_keys::kTizenApplicationKey); if (!app_info) { LOG(ERROR) << "Application info manifest data has not been found."; return false; } - std::shared_ptr icons_info = - std::static_pointer_cast( - parser_->GetManifestData(app_keys::kIconsKey)); + auto icons_info = + GetManifestDataForKey( + app_keys::kIconsKey); if (icons_info.get()) { for (auto& application_icon : icons_info->icons()) { icon_x* icon = reinterpret_cast (calloc(1, sizeof(icon_x))); @@ -170,9 +170,10 @@ bool StepParse::FillIconPaths(manifest_x* manifest) { } bool StepParse::FillWidgetInfo(manifest_x* manifest) { - std::shared_ptr wgt_info = - std::static_pointer_cast( - parser_->GetManifestData(app_keys::kWidgetKey)); + auto wgt_info = + GetManifestDataForKey( + app_keys::kWidgetKey); + if (!wgt_info.get()) { LOG(ERROR) << "Widget info manifest data has not been found."; return false; @@ -203,9 +204,9 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) { manifest->installed_storage = strdup("installed_internal"); // For wgt package use the long name + application_x* app = + reinterpret_cast(manifest->application->data); for (auto& item : wgt_info->name_set()) { - application_x* app = - reinterpret_cast(manifest->application->data); AppendLabel(app, item.second, item.first); } @@ -219,10 +220,9 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) { author->lang = strdup(DEFAULT_LOCALE); manifest->author = g_list_append(manifest->author, author); - std::shared_ptr settings_info = - std::static_pointer_cast( - parser_->GetManifestData( - wgt::application_widget_keys::kTizenSettingKey)); + auto settings_info = + GetManifestDataForKey( + wgt::application_widget_keys::kTizenSettingKey); if (settings_info) { switch (settings_info->install_location()) { case wgt::parse::SettingInfo::InstallLocation::AUTO: { @@ -246,18 +246,19 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) { } bool StepParse::FillMainApplicationInfo(manifest_x* manifest) { - std::shared_ptr app_info = - std::static_pointer_cast( - parser_->GetManifestData(app_keys::kTizenApplicationKey)); + auto app_info = + GetManifestDataForKey( + app_keys::kTizenApplicationKey); if (!app_info) { LOG(ERROR) << "Application info manifest data has not been found."; return false; } bool has_watch_catergory = false; bool has_ime = false; - std::shared_ptr category_info = - std::static_pointer_cast( - parser_->GetManifestData(app_keys::kTizenCategoryKey)); + auto category_info = + GetManifestDataForKey( + app_keys::kTizenCategoryKey); + if (category_info) { has_watch_catergory = std::find_if(category_info->categories.begin(), category_info->categories.end(), @@ -277,7 +278,6 @@ bool StepParse::FillMainApplicationInfo(manifest_x* manifest) { application->component_type = has_watch_catergory ? strdup("watchapp") : strdup("uiapp"); application->mainapp = strdup("true"); - application->multiple = strdup("false"); application->appid = strdup(app_info->id().c_str()); application->nodisplay = has_ime ? strdup("true") : strdup("false"); application->taskmanage = has_ime ? strdup("false") : strdup("true"); @@ -304,7 +304,8 @@ bool StepParse::FillMainApplicationInfo(manifest_x* manifest) { app_icon->lang = strdup(icon->lang); application->icon = g_list_append(application->icon, app_icon); } - manifest->application = g_list_append(manifest->application, application); + // guarantees that the main app will be at the begining of the list + manifest->application = g_list_insert(manifest->application, application, 0); manifest->package = strdup(app_info->package().c_str()); manifest->mainapp_id = strdup(app_info->id().c_str()); @@ -312,9 +313,9 @@ bool StepParse::FillMainApplicationInfo(manifest_x* manifest) { } bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) { - std::shared_ptr service_list = - std::static_pointer_cast( - parser_->GetManifestData(app_keys::kTizenServiceKey)); + auto service_list = + GetManifestDataForKey( + app_keys::kTizenServiceKey); if (!service_list) return true; for (auto& service_info : service_list->services) { @@ -322,7 +323,6 @@ bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) { (calloc(1, sizeof(application_x))); application->component_type = strdup("svcapp"); application->mainapp = strdup("false"); - application->multiple = strdup("false"); application->appid = strdup(service_info.id().c_str()); application->exec = strdup((context_->root_application_path.get() / manifest->package @@ -373,10 +373,9 @@ bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) { } bool StepParse::FillWidgetApplicationInfo(manifest_x* manifest) { - std::shared_ptr appwidget_info = - std::static_pointer_cast( - parser_->GetManifestData( - wgt::application_widget_keys::kTizenAppWidgetFullKey)); + auto appwidget_info = + GetManifestDataForKey( + wgt::application_widget_keys::kTizenAppWidgetFullKey); if (!appwidget_info) return true; for (auto& app_widget : appwidget_info->app_widgets()) { @@ -384,7 +383,6 @@ bool StepParse::FillWidgetApplicationInfo(manifest_x* manifest) { (calloc(1, sizeof(application_x))); application->component_type = strdup("widgetapp"); application->mainapp = strdup("false"); - application->multiple = strdup("false"); application->appid = strdup(app_widget.id.c_str()); application->exec = strdup((context_->root_application_path.get() / manifest->package @@ -439,9 +437,9 @@ bool StepParse::FillBackgroundCategoryInfo(manifest_x* manifest) { } bool StepParse::FillAppControl(manifest_x* manifest) { - std::shared_ptr app_info_list = - std::static_pointer_cast( - parser_->GetManifestData(app_keys::kTizenApplicationAppControlsKey)); + auto app_info_list = + GetManifestDataForKey( + app_keys::kTizenApplicationAppControlsKey); application_x* app = reinterpret_cast(manifest->application->data); @@ -459,9 +457,9 @@ bool StepParse::FillAppControl(manifest_x* manifest) { } bool StepParse::FillPrivileges(manifest_x* manifest) { - std::shared_ptr perm_info = - std::static_pointer_cast( - parser_->GetManifestData(app_keys::kTizenPermissionsKey)); + auto perm_info = + GetManifestDataForKey( + app_keys::kTizenPermissionsKey); std::set privileges; if (perm_info) privileges = ExtractPrivileges(perm_info); @@ -474,9 +472,9 @@ bool StepParse::FillPrivileges(manifest_x* manifest) { } bool StepParse::FillCategories(manifest_x* manifest) { - std::shared_ptr category_info = - std::static_pointer_cast( - parser_->GetManifestData(app_keys::kTizenCategoryKey)); + auto category_info = + GetManifestDataForKey( + app_keys::kTizenCategoryKey); if (!category_info) return true; @@ -490,9 +488,9 @@ bool StepParse::FillCategories(manifest_x* manifest) { } bool StepParse::FillMetadata(manifest_x* manifest) { - std::shared_ptr meta_info = - std::static_pointer_cast( - parser_->GetManifestData(app_keys::kTizenMetaDataKey)); + auto meta_info = + GetManifestDataForKey( + app_keys::kTizenMetaDataKey); if (!meta_info) return true; @@ -507,19 +505,18 @@ bool StepParse::FillAppWidget() { WgtBackendData* backend_data = static_cast(context_->backend_data.get()); - std::shared_ptr appwidget_info = - std::static_pointer_cast( - parser_->GetManifestData( - wgt::application_widget_keys::kTizenAppWidgetFullKey)); + auto appwidget_info = + GetManifestDataForKey( + wgt::application_widget_keys::kTizenAppWidgetFullKey); if (appwidget_info) backend_data->appwidgets.set(*appwidget_info); return true; } bool StepParse::FillAccounts(manifest_x* manifest) { - std::shared_ptr account_info = - std::static_pointer_cast( - parser_->GetManifestData(app_keys::kAccountKey)); + auto account_info = + GetManifestDataForKey( + app_keys::kAccountKey); if (!account_info) return true; common_installer::AccountInfo info; @@ -538,8 +535,9 @@ bool StepParse::FillAccounts(manifest_x* manifest) { } bool StepParse::FillImeInfo() { - const auto ime_info = std::static_pointer_cast( - parser_->GetManifestData(app_keys::kTizenImeKey)); + auto ime_info = + GetManifestDataForKey( + app_keys::kAccountKey); if (!ime_info) return true; @@ -645,14 +643,12 @@ common_installer::Step::Status StepParse::process() { } // Copy data from ManifestData to InstallerContext - std::shared_ptr info = - std::static_pointer_cast( - parser_->GetManifestData( - wgt::application_widget_keys::kTizenApplicationKey)); - std::shared_ptr wgt_info = - std::static_pointer_cast( - parser_->GetManifestData( - wgt::application_widget_keys::kTizenWidgetKey)); + auto info = + GetManifestDataForKey( + wgt::application_widget_keys::kTizenApplicationKey); + auto wgt_info = + GetManifestDataForKey( + wgt::application_widget_keys::kTizenWidgetKey); std::string name; const auto& name_set = wgt_info->name_set(); @@ -681,10 +677,9 @@ common_installer::Step::Status StepParse::process() { context_->recovery_info.get().recovery_file->WriteAndCommitFileContent(); } - std::shared_ptr perm_info = - std::static_pointer_cast( - parser_->GetManifestData( - wgt::application_widget_keys::kTizenPermissionsKey)); + auto perm_info = + GetManifestDataForKey( + wgt::application_widget_keys::kTizenPermissionsKey); parser::PermissionSet permissions; if (perm_info) permissions = perm_info->GetAPIPermissions(); @@ -692,10 +687,9 @@ common_installer::Step::Status StepParse::process() { WgtBackendData* backend_data = static_cast(context_->backend_data.get()); - std::shared_ptr settings_info = - std::static_pointer_cast( - parser_->GetManifestData( - wgt::application_widget_keys::kTizenSettingKey)); + auto settings_info = + GetManifestDataForKey( + wgt::application_widget_keys::kTizenSettingKey); if (settings_info) backend_data->settings.set(*settings_info); diff --git a/src/wgt/step/configuration/step_parse.h b/src/wgt/step/configuration/step_parse.h index e7b9357..69015fc 100644 --- a/src/wgt/step/configuration/step_parse.h +++ b/src/wgt/step/configuration/step_parse.h @@ -1,7 +1,6 @@ // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved // Use of this source code is governed by a apache 2.0 license that can be // found in the LICENSE file. - #ifndef WGT_STEP_CONFIGURATION_STEP_PARSE_H_ #define WGT_STEP_CONFIGURATION_STEP_PARSE_H_ @@ -15,6 +14,8 @@ #include #include +#include +#include #include #include #include @@ -75,6 +76,14 @@ class StepParse : public common_installer::Step { ConfigLocation config_location_; bool check_start_file_; + template + std::shared_ptr GetManifestDataForKey(const std::string& key) { + assert(!key.empty()); + static_assert(std::is_base_of::value, + "Type is not base of parser::ManifestData"); + return std::static_pointer_cast(parser_->GetManifestData(key)); + } + STEP_NAME(Parse) }; -- 2.7.4 From da54fd639e7284dd641e5a67579ca2836ade0591 Mon Sep 17 00:00:00 2001 From: Piotr Ganicz Date: Wed, 22 Jun 2016 09:51:31 +0200 Subject: [PATCH 14/16] Fix for update-period Change-Id: Ic8adec0d7bd7aa14a3b5e054aaed67d5cb1d849c --- src/wgt/step/pkgmgr/step_generate_xml.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc index 1148642..1173a85 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.cc +++ b/src/wgt/step/pkgmgr/step_generate_xml.cc @@ -108,7 +108,11 @@ bool WriteWidgetApplicationAttributesAndElements( xmlTextWriterWriteAttribute(writer, BAD_CAST "main", BAD_CAST (appwidget->primary ? "true" : "false")); // NOLINT - xmlTextWriterWriteAttribute(writer, BAD_CAST "update-period", BAD_CAST "0"); + if (!appwidget->update_period.empty()) { + xmlTextWriterWriteAttribute(writer, BAD_CAST "update-period", BAD_CAST + std::to_string(static_cast( + appwidget->update_period.front())).c_str()); + } for (auto& size : appwidget->content_size) { xmlTextWriterStartElement(writer, BAD_CAST "support-size"); @@ -297,7 +301,8 @@ common_installer::Step::Status StepGenerateXml::precheck() { } if (context_->pkgid.get().empty()) { LOG(ERROR) << "pkgid attribute is empty"; - return Step::Status::PACKAGE_NOT_FOUND; } + return Step::Status::PACKAGE_NOT_FOUND; + } if (!context_->manifest_data.get()->application) { LOG(ERROR) << "No application in package"; -- 2.7.4 From 6bbd3f9ddc27487d54bc2441d8cfba9d8bef2345 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Thu, 16 Jun 2016 14:57:58 +0200 Subject: [PATCH 15/16] Split API in pkgmgr_registration.h Submit together: - https://review.tizen.org/gerrit/75107 - https://review.tizen.org/gerrit/75108 - https://review.tizen.org/gerrit/75109 Change-Id: I259d3aac621443e7985fc2d5aa87e99d5a7bd959 --- src/unit_tests/smoke_test.cc | 6 +++--- src/wgt/wgt_app_query_interface.cc | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/unit_tests/smoke_test.cc b/src/unit_tests/smoke_test.cc index f150590..56dfb15 100644 --- a/src/unit_tests/smoke_test.cc +++ b/src/unit_tests/smoke_test.cc @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -217,13 +217,13 @@ void PackageCheckCleanup(const std::string& pkgid, void ValidatePackage(const std::string& pkgid, const std::vector& appids) { - ASSERT_TRUE(ci::IsPackageInstalled(pkgid, ci::GetRequestMode())); + ASSERT_TRUE(ci::QueryIsPackageInstalled(pkgid, ci::GetRequestMode())); ValidatePackageFS(pkgid, appids); } void CheckPackageNonExistance(const std::string& pkgid, const std::vector& appids) { - ASSERT_FALSE(ci::IsPackageInstalled(pkgid, ci::GetRequestMode())); + ASSERT_FALSE(ci::QueryIsPackageInstalled(pkgid, ci::GetRequestMode())); PackageCheckCleanup(pkgid, appids); } diff --git a/src/wgt/wgt_app_query_interface.cc b/src/wgt/wgt_app_query_interface.cc index e4245cc..912c861 100644 --- a/src/wgt/wgt_app_query_interface.cc +++ b/src/wgt/wgt_app_query_interface.cc @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include @@ -107,21 +107,21 @@ bool WgtAppQueryInterface::IsAppInstalledByArgv(int argc, char** argv) { return false; // argument from commandline is package id - if (ci::IsPackageInstalled(arg, ci::GetRequestMode())) + if (ci::QueryIsPackageInstalled(arg, ci::GetRequestMode())) return true; // argument from commandline is path to file std::string pkg_id = GetPkgIdFromPath(arg); if (pkg_id.empty()) return false; - return ci::IsPackageInstalled(pkg_id, ci::GetRequestMode()); + return ci::QueryIsPackageInstalled(pkg_id, ci::GetRequestMode()); } bool WgtAppQueryInterface::IsHybridApplication(int argc, char** argv) { std::string arg = GetInstallationRequestInfo(argc, argv); if (arg.find("apps_rw/recovery-") != std::string::npos) arg = ReadPkgidFromRecovery(arg); - if (ci::IsPackageInstalled(arg, ci::GetRequestMode())) { + if (ci::QueryIsPackageInstalled(arg, ci::GetRequestMode())) { bf::path package_directory(ci::GetRootAppPath(false)); if (bf::exists(package_directory / arg / kTizenManifestLocation) && bf::exists(package_directory / arg / kHybridConfigLocation)) -- 2.7.4 From 70f676c0d426d55dc0dc7201f83e7c4e9aac1c06 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szulakiewicz Date: Wed, 22 Jun 2016 14:29:06 +0200 Subject: [PATCH 16/16] Add 'multiple-accounts-support' attribute for false values Change-Id: I16f212ec25689115c890f5688cdd7f8657cbebda --- src/wgt/step/pkgmgr/step_generate_xml.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc index 1173a85..8e92818 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.cc +++ b/src/wgt/step/pkgmgr/step_generate_xml.cc @@ -504,6 +504,10 @@ void StepGenerateXml::GenerateAccount(xmlTextWriterPtr writer) { xmlTextWriterWriteAttribute(writer, BAD_CAST "multiple-accounts-support", BAD_CAST "true"); + else + xmlTextWriterWriteAttribute(writer, + BAD_CAST "multiple-accounts-support", + BAD_CAST "false"); for (auto& icon_pair : account.icon_paths) { xmlTextWriterStartElement(writer, BAD_CAST "icon"); if (icon_pair.first == "AccountSmall") -- 2.7.4