1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache 2.0 license that can be
3 // found in the LICENSE file.
5 #ifndef COMMON_STEP_CONFIGURATION_STEP_PARSE_MANIFEST_H_
6 #define COMMON_STEP_CONFIGURATION_STEP_PARSE_MANIFEST_H_
8 #include <common/installer/app_installer.h>
9 #include <common/installer_context.h>
10 #include <common/step/step.h>
12 #include <manifest_parser/utils/logging.h>
13 #include <tpk_manifest_handlers/privileges_handler.h>
14 #include <tpk_manifest_handlers/tpk_config_parser.h>
15 #include <tpk_manifest_handlers/ui_and_service_application_infos.h>
22 namespace common_installer {
23 namespace configuration {
26 * @brief The StepParseManifest class
27 * Used to parse tpk manifest file and store information to context
29 * This step is parameterized according to:
30 * - where to look for manifest file
31 * - where to store information from manifest in context structure
33 * Different request mode will choose different ManifestLocation and
34 * StoreLocation for its purpose but main goal of this step parsing tpk
35 * manifest doesn't change.
37 class StepParseManifest : public common_installer::Step {
39 enum class ManifestLocation {
40 PACKAGE, // parse manifest file from unpacking diretory
41 INSTALLED, // parse manfiest file from current package installation
42 RECOVERY // parse manifest file from backup location or package location
45 enum class StoreLocation {
46 NORMAL, // store in context as current application information (new)
47 BACKUP // store in context as old version application information (update)
50 explicit StepParseManifest(common_installer::InstallerContext* context,
51 ManifestLocation manifest_location, StoreLocation store_location);
53 Status process() override;
54 Status clean() override { return Status::OK; }
55 Status undo() override { return Status::OK; }
56 Status precheck() override;
59 bool LocateConfigFile();
60 std::filesystem::path path_;
63 bool FillInstallationInfo(manifest_x* manifest);
64 bool FillPackageInfo(manifest_x* manifest);
65 bool FillAuthorInfo(manifest_x* manifest);
66 bool FillDescriptionInfo(manifest_x* manifest);
67 bool FillPrivileges(manifest_x* manifest);
68 bool FillProvidesAppDefinedPrivileges(manifest_x* manifest);
69 bool FillWidgetApplication(manifest_x* manifest);
70 bool FillServiceApplication(manifest_x* manifest);
71 bool FillUIApplication(manifest_x* manifest);
72 bool FillWatchApplication(manifest_x* manifest);
73 bool FillTrustAnchorInfo(manifest_x* manifest);
74 bool FillDependencyInfo(manifest_x* manifest);
75 bool FillComponentBasedApplicationInfo(manifest_x* manifest);
76 bool FillRobotApplicationInfo(manifest_x* manifest);
77 bool FillLightUserInfo(manifest_x* manifest);
78 int GetSupportModeVal(std::string support_mode);
80 void AppendSplashScreen(application_x* app, const std::string& src,
81 const std::string& type, const std::string& dpi,
82 const std::string& orientation, const std::string& indicatordisplay,
83 const std::string& operation, const std::string& color_depth);
84 void GetLegacySplashScreenFromMetadata(application_x* manifest,
85 const std::string& key, const std::string& val);
88 bool FillAppControl(application_x* manifest, const T& app_control_list);
90 bool FillDataControl(application_x* manifest, const T& data_control_list);
92 bool FillApplicationIconPaths(application_x* manifest,
95 bool FillLabel(application_x* manifest, const T& label_list);
97 bool FillMetadata(application_x* manifest, const T& meta_data_list);
99 bool FillCategories(application_x* manifest, const T& meta_data_list);
100 bool FillImage(application_x* app,
101 const tpk::parse::ApplicationImagesInfo& label_list);
102 template <typename T>
103 bool FillBackgroundCategoryInfo(application_x* app,
104 const T& background_category_data_list);
105 template <typename T>
106 bool FillSplashScreen(application_x* app,
107 const T& splashscreen_list);
108 template <typename T>
109 bool FillResControl(application_x* app, const T& res_control_list);
110 bool FillExtraInfo(manifest_x* manifest);
111 bool FillManifestX(manifest_x* manifest);
113 std::unique_ptr<tpk::parse::TPKConfigParser> parser_;
114 ManifestLocation manifest_location_;
115 StoreLocation store_location_;
117 STEP_NAME(ParseManifest)
120 } // namespace configuration
121 } // namespace common_installer
123 #endif // COMMON_STEP_CONFIGURATION_STEP_PARSE_MANIFEST_H_