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 <pkgmgr_parser.h>
12 #include <sys/types.h>
13 #include <vcore/Certificate.h>
21 #include "common/external_mount.h"
22 #include "common/external_storage.h"
23 #include "common/pkgmgr_interface.h"
24 #include "common/recovery_file.h"
25 #include "common/utils/pkgmgr_query.h"
26 #include "common/utils/property.h"
27 #include "common/utils/request.h"
29 #include "manifest_info/account.h"
30 #include "manifest_info/ime_info.h"
32 namespace common_installer {
36 std::string extra_data;
37 std::string extra_key;
39 std::vector<std::pair<std::string, std::string>> labels;
42 using ShortcutListInfo = std::vector<ShortcutInfo>;
45 * \brief Structure, that holds additional data retrieved from manifest
46 * and used during generation of platform manifest (for data that are not
47 * available within manifest_x structure
49 class ExtraManifestData {
52 ExtraManifestData() {}
54 Property<AccountInfo> account_info;
55 Property<ShortcutListInfo> shortcut_info;
56 Property<ImeInfo> ime_info;
60 * \brief Base class that is used within specific backends to keep additional
61 * information regarding package
65 /** virtual destructor */
66 virtual ~BackendData() { }
70 * \brief Class represents certificate information
72 class CertificateInfo {
74 /** author_id (using public key from author certificate) */
75 Property<std::string> author_id;
76 /** author_certificate */
77 Property<ValidationCore::CertificatePtr> auth_cert;
78 /** author_intermediate_certificate */
79 Property<ValidationCore::CertificatePtr> auth_im_cert;
80 /** author_root_certificate */
81 Property<ValidationCore::CertificatePtr> auth_root_cert;
82 /** distributor_certificate */
83 Property<ValidationCore::CertificatePtr> dist_cert;
84 /** distributor_intermediate_certificate */
85 Property<ValidationCore::CertificatePtr> dist_im_cert;
86 /** distributor_root_certificate */
87 Property<ValidationCore::CertificatePtr> dist_root_cert;
88 /** distributor2_certificate */
89 Property<ValidationCore::CertificatePtr> dist2_cert;
90 /** distributor2_intermediate_certificate */
91 Property<ValidationCore::CertificatePtr>
93 /** distributor2_root_certificate */
94 Property<ValidationCore::CertificatePtr> dist2_root_cert;
98 * \brief Class used for recovery situation.
99 * It holds pointer to RecoveryFile object.
103 /** default constructor */
104 RecoveryInfo() : cleanup(false) { }
109 * \param rf RecoveryFile object (pointer to object)
111 explicit RecoveryInfo(std::unique_ptr<recovery::RecoveryFile> rf)
112 : recovery_file(std::move(rf)), cleanup(false) {
118 * \param path path of recovery file to be created
119 * \param recovery_cleanup path of recovery file to be created
121 explicit RecoveryInfo(const std::filesystem::path& path,
122 bool recovery_cleanup = false)
123 : filepath(path), cleanup(recovery_cleanup) {
126 /** pointer to RecoveryFile */
127 std::unique_ptr<recovery::RecoveryFile> recovery_file;
129 /** path of recovery file to be created */
130 std::filesystem::path filepath;
132 /** cleanup flag delivered by global recovery file */
137 * Enumeration for Privilege levels
139 enum class PrivilegeLevel : int {
147 * Enumeration for Storage types
149 enum class Storage : int {
156 * Enumeration for move types
158 enum class MoveType : int {
166 * \brief Helper function. Checks (and compares) passed levels
168 * \param required_level level to compare
169 * \param allowed_level level to compare
171 * \return true, if required_level <= allowed_level
173 bool SatifiesPrivilegeLevel(PrivilegeLevel required_level,
174 PrivilegeLevel allowed_level);
177 * \brief translates privilege level to string
179 * \param level privilege level to translate
181 * \return translated level (to string)
183 const char* PrivilegeLevelToString(PrivilegeLevel level);
186 * \brief Holds data generated/used by Steps (e.g. pkgid retrieved from
187 * manifest parsing, path to unzipped package).
188 * ContextInstaller is owned by AppInstaller object. Steps holds
189 * “pointers” to ContextInstaller (pointer is initialized in Step
192 class InstallerContext {
201 * \brief Returns package directory path containing app data
203 inline std::filesystem::path GetPkgPath() const {
204 return root_application_path.get() / pkgid.get();
208 * \brief path to final location of installed package in filesystem
210 Property<std::string> pkgid;
213 * \brief package type (string representing name of backend)
215 Property<std::string> pkg_type;
218 * \brief In-memory representation of platform xml manifest file
219 * - contains all information needed by tizen application
220 * framework to handle package management (pkgid, icon,
221 * applications, appcontrol, privileges and more)
223 Property<manifest_x*> manifest_data;
225 /** Pkgmgr-parser plugins data */
226 Property<ExtraManifestData> manifest_plugins_data;
229 * \brief In-memory representation of platform xml manifest file
230 * - contains all already stored information needed by tizen
231 * application framework to handle package management (pkgid,
232 * icon, applications, appcontrol, privileges and more)
233 * - this field is set only for update installation
234 * (we need this information for rollback possibility)
236 Property<manifest_x*> old_manifest_data;
239 * \brief path to xml platform manifest which was generated according
240 * to maniest_data content */
241 Property<std::filesystem::path> xml_path;
244 * \brief path to backup xml platform manifest which was generated
245 * according to old_maniest_data content (needed for rollback
248 Property<std::filesystem::path> backup_xml_path;
251 * \brief file path used for installation or reinstallation process
253 Property<std::filesystem::path> file_path;
256 * \brief tep file path used for TEP installation process
258 Property<std::filesystem::path> tep_path;
261 * \brief boolean property that indicates tep file should be moved or not
263 Property<bool> is_tep_move;
266 * \brief boolean property that indicates request is external move or not
268 Property<bool> is_move_to_external;
271 * \brief property that indicates move type
273 Property<MoveType> move_type;
276 * \brief path to temporary directory when package files are unpacked
277 * before coping them to final destination
279 Property<std::filesystem::path> unpacked_dir_path;
282 * \brief uid of user which installation was triggered for
283 * (any normal or globaltizenapp)
288 * \brief root directory of installation of all packages for user
289 * (${TZ_USER_HOME}/${USER}/apps_rw/) or
290 * tizenglobalapp user (${TZ_SYS_RO_APP} or ${TZ_SYS_RW_APP})
292 Property<std::filesystem::path> root_application_path;
295 * \brief "void*-like" structure to store backend specific
296 * information about installation process
298 Property<BackendData*> backend_data;
301 * \brief privilege/visibility level discovered from signature files
302 * - restricts package privileges
304 Property<PrivilegeLevel> privilege_level;
307 * \brief certificate information
309 Property<CertificateInfo> certificate_info;
312 * \brief information for recovery
314 Property<RecoveryInfo> recovery_info;
317 * \brief user type of request (GLOBAL/USER)
319 Property<RequestMode> request_mode;
322 * \brief request type received from pkgmgr_installer
324 Property<RequestType> request_type;
327 * \brief installation mode (ONLINE / OFFLINE)
329 Property<InstallationMode> installation_mode;
332 * \brief readonly request received from pkgmgr_installer
334 Property<bool> is_readonly_package;
337 * \brief preload-rw request received from pkgmgr_installer
339 Property<bool> is_preload_rw_package;
342 * \brief force-remove flag received from pkgmgr_installer
344 Property<bool> force_remove;
347 * \brief no-remove flag received from pkgmgr_installer
349 Property<bool> no_remove;
352 * \brief keep-rwdata flag received from pkgmgr_installer
354 Property<bool> keep_rwdata;
357 * \brief partial-rw flag received from pkgmgr_installer
359 Property<bool> partial_rw;
362 * \brief Describes force clean behaviour from db data. It set to ture,
363 * the uninstallation will be done to the end of steps.
365 Property<bool> force_clean_from_db;
368 * \brief Describes behaviour for security manager. It set to true, this will
369 * force to generates n-to-n rules for package's apps.
370 * This will be used for hybrid apps.
372 Property<bool> cross_app_rules;
375 * \brief boolean property that indicates the request is for debugging or not.
377 Property<bool> debug_mode;
380 * \brief boolean property that indicates
381 * the request is for skip optimization or not.
383 Property<bool> skip_optimization;
386 * \brief Property of vector of files to add
388 Property<std::vector<std::string>> files_to_add;
391 * \brief Property of vector of files to modify
393 Property<std::vector<std::string>> files_to_modify;
396 * \brief Property of vector of files to delete
398 Property<std::vector<std::string>> files_to_delete;
401 * @brief External Storage object if installing in external
403 std::unique_ptr<ExternalStorage> external_storage;
406 * @brief External package mount object if delta update with external
408 std::unique_ptr<ExternalMount> external_mount;
411 * @brief skip-check-reference flag received from pkgmgr_installer
413 Property<bool> skip_check_reference;
416 * @brief Storage where package to be installed
418 Property<Storage> storage;
421 * @brief Index of current request
426 * @brief Property of vector of plugin execution information
427 * (needed for rollback operations)
429 Property<std::vector<PkgQueryInterface::PluginInfo>> backup_plugin_info;
432 } // namespace common_installer
434 #endif // COMMON_INSTALLER_CONTEXT_H_