Temporary fix for hybrid pkg installation
[platform/core/appfw/app-installers.git] / src / common / step / configuration / step_parse_manifest.h
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.
4
5 #ifndef COMMON_STEP_CONFIGURATION_STEP_PARSE_MANIFEST_H_
6 #define COMMON_STEP_CONFIGURATION_STEP_PARSE_MANIFEST_H_
7
8 #include <boost/filesystem.hpp>
9
10 #include <common/app_installer.h>
11 #include <common/installer_context.h>
12 #include <common/step/step.h>
13
14 #include <manifest_parser/utils/logging.h>
15 #include <tpk_manifest_handlers/privileges_handler.h>
16 #include <tpk_manifest_handlers/tpk_config_parser.h>
17 #include <tpk_manifest_handlers/ui_and_service_application_infos.h>
18
19 #include <memory>
20 #include <set>
21 #include <string>
22
23 namespace common_installer {
24 namespace configuration {
25
26 /**
27  * @brief The StepParseManifest class
28  *        Used to parse tpk manifest file and store information to context
29  *
30  * This step is parameterized according to:
31  *  - where to look for manifest file
32  *  - where to store information from manifest in context structure
33  *
34  * Different request mode will choose different ManifestLocation and
35  * StoreLocation for its purpose but main goal of this step parsing tpk
36  * manifest doesn't change.
37  */
38 class StepParseManifest : public common_installer::Step {
39  public:
40   enum class ManifestLocation {
41     PACKAGE,    // parse manifest file from unpacking diretory
42     INSTALLED,  // parse manfiest file from current package installation
43     RECOVERY    // parse manifest file from backup location or package location
44   };
45
46   enum class StoreLocation {
47     NORMAL,  // store in context as current application information (new)
48     BACKUP   // store in context as old version application information (update)
49   };
50
51   explicit StepParseManifest(common_installer::InstallerContext* context,
52       ManifestLocation manifest_location, StoreLocation store_location);
53
54   Status process() override;
55   Status clean() override { return Status::OK; }
56   Status undo() override { return Status::OK; }
57   Status precheck() override;
58
59  protected:
60   bool LocateConfigFile();
61   boost::filesystem::path path_;
62
63  private:
64   bool FillInstallationInfo(manifest_x* manifest);
65   bool FillPackageInfo(manifest_x* manifest);
66   bool FillAuthorInfo(manifest_x* manifest);
67   bool FillDescriptionInfo(manifest_x* manifest);
68   bool FillPrivileges(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
74   bool CheckFeatures();
75
76   template <typename T>
77       bool FillAppControl(application_x* manifest, const T& app_control_list);
78   template <typename T>
79       bool FillDataControl(application_x* manifest, const T& data_control_list);
80   template <typename T>
81       bool FillApplicationIconPaths(application_x* manifest,
82                                     const T& icons_info);
83   template <typename T>
84       bool FillLabel(application_x* manifest, const T& label_list);
85   template <typename T>
86       bool FillMetadata(application_x* manifest, const T& meta_data_list);
87   // FIXME: For hotfix, must be removed
88   template <typename T>
89       bool FillSupportSize(application_x* manifest, const T& support_size_list);
90   template <typename T>
91       bool FillCategories(application_x* manifest, const T& meta_data_list);
92   bool FillImage(application_x* app,
93                  const tpk::parse::ApplicationImagesInfo& label_list);
94   template <typename T>
95   bool FillBackgroundCategoryInfo(application_x* app,
96       const T& background_category_data_list);
97   template <typename T>
98   bool FillSplashScreen(application_x* app,
99       const T& splashscreen_list);
100   bool FillManifestX(manifest_x* manifest);
101
102   std::unique_ptr<tpk::parse::TPKConfigParser> parser_;
103   ManifestLocation manifest_location_;
104   StoreLocation store_location_;
105
106   STEP_NAME(ParseManifest)
107 };
108
109 }  // namespace configuration
110 }  // namespace common_installer
111
112 #endif  // COMMON_STEP_CONFIGURATION_STEP_PARSE_MANIFEST_H_