1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by a apache 2.0 license that can be
3 // found in the LICENSE file.
4 #ifndef WGT_STEP_CONFIGURATION_STEP_PARSE_H_
5 #define WGT_STEP_CONFIGURATION_STEP_PARSE_H_
7 #include <boost/filesystem.hpp>
9 #include <common/app_installer.h>
10 #include <common/installer_context.h>
11 #include <common/step/step.h>
13 #include <manifest_parser/utils/logging.h>
14 #include <wgt_manifest_handlers/permissions_handler.h>
15 #include <wgt_manifest_handlers/widget_config_parser.h>
17 #include <type_traits>
24 namespace configuration {
27 * \brief This step parse config.xml configuration file of widget
29 class StepParse : public common_installer::Step {
31 enum class ConfigLocation {
32 PACKAGE, // parse config file from unpacking diretory
33 INSTALLED, // parse config file from current package installation
34 RECOVERY, // parse config file from backup location or package location
35 RESOURCE_WGT // parse config file from unpacking subdiretory "res/wgt"
38 explicit StepParse(common_installer::InstallerContext* context,
39 ConfigLocation config_location, bool check_start_file);
41 Status process() override;
42 Status clean() override { return Status::OK; }
43 Status undo() override { return Status::OK; }
44 Status precheck() override { return Status::OK; }
47 virtual bool LocateConfigFile();
48 bool Check(const boost::filesystem::path& widget_path);
50 boost::filesystem::path widget_path_;
53 std::set<std::string> ExtractPrivileges(
54 std::shared_ptr<const wgt::parse::PermissionsInfo> perm_info) const;
56 std::string GetPackageVersion(const std::string& manifest_version);
58 bool FillInstallationInfo(manifest_x* manifest);
59 bool FillIconPaths(manifest_x* manifest);
60 bool FillWidgetInfo(manifest_x* manifest);
61 bool FillMainApplicationInfo(manifest_x* manifest);
62 bool FillServiceApplicationInfo(manifest_x* manifest);
63 bool FillWidgetApplicationInfo(manifest_x* manifest);
64 bool FillAppControl(manifest_x* manifest);
65 bool FillPrivileges(manifest_x* manifest);
66 bool FillAppDefinedPrivileges(manifest_x* manifest);
67 bool FillProvidesAppDefinedPrivileges(manifest_x* manifest);
68 bool FillCategories(manifest_x* manifest);
69 bool FillMetadata(manifest_x* manifest);
70 bool FillExtraManifestInfo(manifest_x* manifest);
71 bool FillAccounts(manifest_x* manifest);
74 bool FillBackgroundCategoryInfo(manifest_x* manifest);
75 bool FillAdditionalApplications(manifest_x* manifest);
76 bool FillManifestX(manifest_x* manifest);
77 bool FillTrustAnchorInfo(manifest_x* manifest);
79 std::unique_ptr<wgt::parse::WidgetConfigParser> parser_;
80 ConfigLocation config_location_;
81 bool check_start_file_;
84 std::shared_ptr<const T> GetManifestDataForKey(const std::string& key) {
86 static_assert(std::is_base_of<parser::ManifestData, T>::value,
87 "Type is not base of parser::ManifestData");
88 return std::static_pointer_cast<const T>(parser_->GetManifestData(key));
94 } // namespace configuration
97 #endif // WGT_STEP_CONFIGURATION_STEP_PARSE_H_