1 /* 2014, Copyright © Intel Coporation, license APACHE-2.0, see LICENSE file */
2 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3 // Use of this source code is governed by a apache 2.0 license that can be
4 // found in the LICENSE file.
6 #ifndef COMMON_INSTALLER_CONTEXT_H_
7 #define COMMON_INSTALLER_CONTEXT_H_
9 #include <boost/filesystem/path.hpp>
11 #include <pkgmgr_parser.h>
14 #include <sys/types.h>
15 #include <vcore/Certificate.h>
22 #include "common/pkgmgr_interface.h"
23 #include "common/recovery_file.h"
24 #include "common/request.h"
25 #include "common/utils/property.h"
27 #include "manifest_info/account.h"
29 namespace common_installer {
31 // TODO(t.iwanek): this structure should be unified for manifest handlers of
32 // wgt and tpk packages
35 std::string extra_data;
36 std::string extra_key;
38 std::vector<std::pair<std::string, std::string>> labels;
41 using ShortcutListInfo = std::vector<ShortcutInfo>;
44 // TODO(p.sikorski): if that structure holds extra information not covered
45 // in manifest_x, maybe it should hold manifest_x as well?
47 * \brief Structure, that holds additional data retrieved from manifest
48 * and used during generation of platform manifest (for data that are not
49 * available within manifest_x structure
51 class ExtraManifestData {
54 ExtraManifestData() {}
56 Property<AccountInfo> account_info;
57 Property<ShortcutListInfo> shortcut_info;
61 * \brief Base class that is used within specific backends to keep additional
62 * information regarding package
66 /** virtual destructor */
67 virtual ~BackendData() { }
71 * \brief Class represents certificate information
73 class CertificateInfo {
75 /** author_id (using public key from author certificate) */
76 Property<std::string> author_id;
77 /** author_certificate */
78 Property<ValidationCore::CertificatePtr> author_certificate;
79 /** author_intermediate_certificate */
80 Property<ValidationCore::CertificatePtr> author_intermediate_certificate;
81 /** author_root_certificate */
82 Property<ValidationCore::CertificatePtr> author_root_certificate;
83 /** distributor_certificate */
84 Property<ValidationCore::CertificatePtr> distributor_certificate;
85 /** distributor_intermediate_certificate */
86 Property<ValidationCore::CertificatePtr> distributor_intermediate_certificate;
87 /** distributor_root_certificate */
88 Property<ValidationCore::CertificatePtr> distributor_root_certificate;
92 * \brief Class used for recovery situation.
93 * It holds pointer to RecoveryFile object.
97 /** default constructor */
103 * \param rf RecoveryFile object (pointer to object)
105 explicit RecoveryInfo(std::unique_ptr<recovery::RecoveryFile> rf)
106 : recovery_file(std::move(rf)) {
109 /** pointer to RecoveryFile */
110 std::unique_ptr<recovery::RecoveryFile> recovery_file;
114 * Enumeration for Privilege levels
116 enum class PrivilegeLevel : int {
124 * \brief Helper function. Checks (and compares) passed levels
126 * \param required_level level to compare
127 * \param allowed_level level to compare
129 * \return true, if required_level <= allowed_level
131 bool SatifiesPrivilegeLevel(PrivilegeLevel required_level,
132 PrivilegeLevel allowed_level);
135 * \brief translates privilege level to string
137 * \param level privilege level to translate
139 * \return translated level (to string)
141 const char* PrivilegeLevelToString(PrivilegeLevel level);
143 // TODO(p.sikorski@samsung.com) this class should be divided into:
144 // Base Context class
145 // CtxInstall class that inherits from Context
146 // CtxUninstall class that inherits from Context
147 // It is because Uninstallation does not need so many fields.
148 // similarly, installation may not need some of them
151 * \brief Holds data generated/used by Steps (e.g. pkgid retrieved from
152 * manifest parsing, path to unzipped package).
153 * ContextInstaller is owned by AppInstaller object. Steps holds
154 * “pointers” to ContextInstaller (pointer is initialized in Step
157 class InstallerContext {
166 * \brief package type (string representing name of backend)
168 Property<std::string> pkg_type;
171 * \brief In-memory representation of platform xml manifest file
172 * - contains all information needed by tizen application
173 * framework to handle package management (pkgid, icon,
174 * applications, appcontrol, privileges and more)
176 Property<manifest_x*> manifest_data;
178 /** Pkgmgr-parser plugins data */
179 Property<ExtraManifestData> manifest_plugins_data;
182 * \brief In-memory representation of platform xml manifest file
183 * - contains all already stored information needed by tizen
184 * application framework to handle package management (pkgid,
185 * icon, applications, appcontrol, privileges and more)
186 * - this field is set only for update installation
187 * (we need this information for rollback possibility)
189 Property<manifest_x*> old_manifest_data;
192 * \brief path to xml platform manifest which was generated according
193 * to maniest_data content */
194 Property<boost::filesystem::path> xml_path;
197 * \brief path to backup xml platform manifest which was generated
198 * according to old_maniest_data content (needed for rollback
201 Property<boost::filesystem::path> backup_xml_path;
204 * \brief path to final location of installed package in filesystem
206 Property<std::string> pkgid;
209 * \brief package directory path containing app data
211 Property<boost::filesystem::path> pkg_path;
214 * \brief file path used for installation or reinstallation process
216 Property<boost::filesystem::path> file_path;
219 * \brief tep file path used for TEP installation process
221 Property<boost::filesystem::path> tep_path;
224 * \brief boolean property that indicates tep file should be moved or not
226 Property<bool> is_tep_move;
229 * \brief path to temporary directory when package files are unpacked
230 * before coping them to final destination
232 Property<boost::filesystem::path> unpacked_dir_path;
235 * \brief uid of user which installation was triggered for
236 * (any normal or globaltizenapp)
241 * \brief root directory of installation of all packages for user
242 * (/home/${USER}/apps_rw/) or tizenglobalapp user (/usr/apps/)
244 Property<boost::filesystem::path> root_application_path;
247 * \brief "void*-like" structure to store backend specific
248 * information about installation process
250 Property<BackendData*> backend_data;
253 * \brief privilege/visibility level discovered from signature files
254 * - restricts package privileges
256 Property<PrivilegeLevel> privilege_level;
259 * \brief certificate information
261 Property<CertificateInfo> certificate_info;
264 * \brief information for recovery
266 Property<RecoveryInfo> recovery_info;
269 * \brief user type of request (GLOBAL/USER)
271 Property<RequestMode> request_mode;
274 * \brief request type received from pkgmgr_installer
276 Property<RequestType> request_type;
279 * \brief installation mode (ONLINE / OFFLINE)
281 Property<InstallationMode> installation_mode;
284 * \brief preload request received from pkgmgr_installer
286 Property<bool> is_preload_request;
289 } // namespace common_installer
291 #endif // COMMON_INSTALLER_CONTEXT_H_