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 FillLightUserInfo(manifest_x* manifest);
77 int GetSupportModeVal(std::string support_mode);
79 void AppendSplashScreen(application_x* app, const std::string& src,
80 const std::string& type, const std::string& dpi,
81 const std::string& orientation, const std::string& indicatordisplay,
82 const std::string& operation, const std::string& color_depth);
83 void GetLegacySplashScreenFromMetadata(application_x* manifest,
84 const std::string& key, const std::string& val);
87 bool FillAppControl(application_x* manifest, const T& app_control_list);
89 bool FillDataControl(application_x* manifest, const T& data_control_list);
91 bool FillApplicationIconPaths(application_x* manifest,
94 bool FillLabel(application_x* manifest, const T& label_list);
96 bool FillMetadata(application_x* manifest, const T& meta_data_list);
98 bool FillCategories(application_x* manifest, const T& meta_data_list);
99 bool FillImage(application_x* app,
100 const tpk::parse::ApplicationImagesInfo& label_list);
101 template <typename T>
102 bool FillBackgroundCategoryInfo(application_x* app,
103 const T& background_category_data_list);
104 template <typename T>
105 bool FillSplashScreen(application_x* app,
106 const T& splashscreen_list);
107 template <typename T>
108 bool FillResControl(application_x* app, const T& res_control_list);
109 bool FillExtraInfo(manifest_x* manifest);
110 bool FillManifestX(manifest_x* manifest);
112 std::unique_ptr<tpk::parse::TPKConfigParser> parser_;
113 ManifestLocation manifest_location_;
114 StoreLocation store_location_;
116 STEP_NAME(ParseManifest)
119 } // namespace configuration
120 } // namespace common_installer
122 #endif // COMMON_STEP_CONFIGURATION_STEP_PARSE_MANIFEST_H_