Add StepCreatePerUserStorageDirectories to installation step
[platform/core/appfw/wgt-backend.git] / src / hybrid / hybrid_installer.cc
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 #include "hybrid/hybrid_installer.h"
6
7 #include <common/step/step_check_signature.h>
8 #include <common/step/step_backup_icons.h>
9 #include <common/step/step_backup_manifest.h>
10 #include <common/step/step_configure.h>
11 #include <common/step/step_copy.h>
12 #include <common/step/step_copy_backup.h>
13 #include <common/step/step_copy_storage_directories.h>
14 #include <common/step/step_clear_data.h>
15 #include <common/step/step_create_icons.h>
16 #include <common/step/step_create_storage_directories.h>
17 #include <common/step/step_create_per_user_storage_directories.h>
18 #include <common/step/step_delta_patch.h>
19 #include <common/step/step_fail.h>
20 #include <common/step/step_kill_apps.h>
21 #include <common/step/step_parse_manifest.h>
22 #include <common/step/step_privilege_compatibility.h>
23 #include <common/step/step_register_app.h>
24 #include <common/step/step_register_security.h>
25 #include <common/step/step_remove_files.h>
26 #include <common/step/step_remove_icons.h>
27 #include <common/step/step_revoke_security.h>
28 #include <common/step/step_open_recovery_file.h>
29 #include <common/step/step_recover_application.h>
30 #include <common/step/step_recover_files.h>
31 #include <common/step/step_recover_icons.h>
32 #include <common/step/step_recover_manifest.h>
33 #include <common/step/step_recover_security.h>
34 #include <common/step/step_recover_storage_directories.h>
35 #include <common/step/step_remove_temporary_directory.h>
36 #include <common/step/step_rollback_deinstallation_security.h>
37 #include <common/step/step_rollback_installation_security.h>
38 #include <common/step/step_run_parser_plugins.h>
39 #include <common/step/step_unregister_app.h>
40 #include <common/step/step_unzip.h>
41 #include <common/step/step_update_app.h>
42 #include <common/step/step_update_security.h>
43 #include <common/step/step_remove_manifest.h>
44
45 #include <tpk/step/step_create_symbolic_link.h>
46 #include <tpk/step/step_tpk_patch_icons.h>
47
48 #include "hybrid/hybrid_backend_data.h"
49 #include "hybrid/step/step_encrypt_resources.h"
50 #include "hybrid/step/step_merge_tpk_config.h"
51 #include "hybrid/step/step_stash_tpk_config.h"
52 #include "hybrid/step/step_parse.h"
53 #include "wgt/step/step_check_settings_level.h"
54 #include "wgt/step/step_check_wgt_background_category.h"
55 #include "wgt/step/step_create_symbolic_link.h"
56 #include "wgt/step/step_generate_xml.h"
57 #include "wgt/step/step_parse_recovery.h"
58 #include "wgt/step/step_remove_encryption_data.h"
59 #include "wgt/step/step_wgt_patch_icons.h"
60 #include "wgt/step/step_wgt_patch_storage_directories.h"
61
62 namespace ci = common_installer;
63
64 namespace hybrid {
65
66 HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
67     : AppInstaller("wgt", pkgmgr) {
68   context_->backend_data.set(new HybridBackendData());
69
70   switch (pkgmgr_->GetRequestType()) {
71     case ci::RequestType::Install:
72       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
73       AddStep<ci::filesystem::StepUnzip>();
74       AddStep<ci::parse::StepParseManifest>(
75           ci::parse::StepParseManifest::ManifestLocation::PACKAGE,
76           ci::parse::StepParseManifest::StoreLocation::NORMAL);
77       AddStep<hybrid::parse::StepStashTpkConfig>();
78       AddStep<hybrid::parse::StepParse>(true);
79       AddStep<hybrid::parse::StepMergeTpkConfig>();
80       AddStep<ci::security::StepCheckSignature>();
81       AddStep<ci::security::StepPrivilegeCompatibility>();
82       AddStep<wgt::security::StepCheckSettingsLevel>();
83       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
84       AddStep<hybrid::encrypt::StepEncryptResources>();
85       AddStep<ci::security::StepRollbackInstallationSecurity>();
86       AddStep<ci::filesystem::StepCopy>();
87       AddStep<tpk::filesystem::StepTpkPatchIcons>();
88       AddStep<wgt::filesystem::StepWgtPatchIcons>();
89       AddStep<ci::filesystem::StepCreateIcons>();
90       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
91       AddStep<ci::filesystem::StepCreateStorageDirectories>();
92       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
93       AddStep<tpk::filesystem::StepCreateSymbolicLink>();
94       AddStep<wgt::pkgmgr::StepGenerateXml>();
95       AddStep<ci::pkgmgr::StepRunParserPlugin>(
96           ci::PluginsLauncher::ActionType::Install);
97       AddStep<ci::pkgmgr::StepRegisterApplication>();
98       AddStep<ci::security::StepRegisterSecurity>();
99       AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
100       break;
101     case ci::RequestType::Update:
102       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
103       AddStep<ci::filesystem::StepUnzip>();
104       AddStep<ci::parse::StepParseManifest>(
105           ci::parse::StepParseManifest::ManifestLocation::PACKAGE,
106           ci::parse::StepParseManifest::StoreLocation::NORMAL);
107       AddStep<hybrid::parse::StepStashTpkConfig>();
108       AddStep<hybrid::parse::StepParse>(true);
109       AddStep<hybrid::parse::StepMergeTpkConfig>();
110       AddStep<ci::security::StepCheckSignature>();
111       AddStep<ci::security::StepPrivilegeCompatibility>();
112       AddStep<wgt::security::StepCheckSettingsLevel>();
113       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
114       AddStep<hybrid::encrypt::StepEncryptResources>();
115       AddStep<ci::security::StepRollbackInstallationSecurity>();
116       AddStep<ci::parse::StepParseManifest>(
117           ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
118           ci::parse::StepParseManifest::StoreLocation::BACKUP);
119       AddStep<ci::pkgmgr::StepKillApps>();
120       AddStep<ci::backup::StepBackupManifest>();
121       AddStep<ci::backup::StepBackupIcons>();
122       AddStep<ci::backup::StepCopyBackup>();
123       AddStep<tpk::filesystem::StepTpkPatchIcons>();
124       AddStep<wgt::filesystem::StepWgtPatchIcons>();
125       AddStep<ci::filesystem::StepCreateIcons>();
126       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
127       AddStep<ci::filesystem::StepCopyStorageDirectories>();
128       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
129       AddStep<tpk::filesystem::StepCreateSymbolicLink>();
130       AddStep<ci::security::StepUpdateSecurity>();
131       AddStep<wgt::pkgmgr::StepGenerateXml>();
132       AddStep<ci::pkgmgr::StepUpdateApplication>();
133       AddStep<ci::pkgmgr::StepRunParserPlugin>(
134           ci::PluginsLauncher::ActionType::Upgrade);
135       break;
136     case ci::RequestType::Uninstall:
137       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
138       AddStep<ci::parse::StepParseManifest>(
139           ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
140           ci::parse::StepParseManifest::StoreLocation::NORMAL);
141       AddStep<ci::pkgmgr::StepRunParserPlugin>(
142           ci::PluginsLauncher::ActionType::Uninstall);
143       AddStep<ci::pkgmgr::StepKillApps>();
144       AddStep<ci::pkgmgr::StepUnregisterApplication>();
145       AddStep<ci::security::StepRollbackDeinstallationSecurity>();
146       AddStep<ci::filesystem::StepRemoveFiles>();
147       AddStep<ci::filesystem::StepRemoveIcons>();
148       AddStep<wgt::encrypt::StepRemoveEncryptionData>();
149       AddStep<ci::security::StepRevokeSecurity>();
150       AddStep<ci::pkgmgr::StepRemoveManifest>();
151       break;
152     case ci::RequestType::Reinstall:
153       // RDS is not supported for hybrid apps
154       AddStep<ci::configuration::StepFail>();
155       break;
156     case ci::RequestType::Delta:
157       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
158       AddStep<ci::filesystem::StepUnzip>();
159       AddStep<ci::parse::StepParseManifest>(
160           ci::parse::StepParseManifest::ManifestLocation::PACKAGE,
161           ci::parse::StepParseManifest::StoreLocation::NORMAL);
162       AddStep<ci::filesystem::StepDeltaPatch>();
163       AddStep<hybrid::parse::StepStashTpkConfig>();
164       AddStep<hybrid::parse::StepParse>(true);
165       AddStep<hybrid::parse::StepMergeTpkConfig>();
166       AddStep<ci::security::StepCheckSignature>();
167       AddStep<ci::security::StepPrivilegeCompatibility>();
168       AddStep<wgt::security::StepCheckSettingsLevel>();
169       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
170       AddStep<hybrid::encrypt::StepEncryptResources>();
171       AddStep<ci::security::StepRollbackInstallationSecurity>();
172       AddStep<ci::parse::StepParseManifest>(
173           ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
174           ci::parse::StepParseManifest::StoreLocation::BACKUP);
175       AddStep<ci::pkgmgr::StepKillApps>();
176       AddStep<ci::backup::StepBackupManifest>();
177       AddStep<ci::backup::StepBackupIcons>();
178       AddStep<ci::backup::StepCopyBackup>();
179       AddStep<tpk::filesystem::StepTpkPatchIcons>();
180       AddStep<wgt::filesystem::StepWgtPatchIcons>();
181       AddStep<ci::filesystem::StepCreateIcons>();
182       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
183       AddStep<ci::filesystem::StepCopyStorageDirectories>();
184       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
185       AddStep<tpk::filesystem::StepCreateSymbolicLink>();
186       AddStep<ci::security::StepUpdateSecurity>();
187       AddStep<wgt::pkgmgr::StepGenerateXml>();
188       AddStep<ci::pkgmgr::StepUpdateApplication>();
189       AddStep<ci::pkgmgr::StepRunParserPlugin>(
190           ci::PluginsLauncher::ActionType::Upgrade);
191       break;
192     case ci::RequestType::Recovery:
193       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
194       AddStep<ci::recovery::StepOpenRecoveryFile>();
195       AddStep<ci::parse::StepParseManifest>(
196           ci::parse::StepParseManifest::ManifestLocation::RECOVERY,
197           ci::parse::StepParseManifest::StoreLocation::NORMAL);
198       AddStep<hybrid::parse::StepStashTpkConfig>();
199       AddStep<wgt::parse::StepParseRecovery>();
200       AddStep<hybrid::parse::StepMergeTpkConfig>();
201       AddStep<ci::pkgmgr::StepRecoverApplication>();
202       AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
203       AddStep<ci::filesystem::StepRecoverIcons>();
204       AddStep<ci::filesystem::StepRecoverManifest>();
205       AddStep<ci::filesystem::StepRecoverStorageDirectories>();
206       AddStep<ci::filesystem::StepRecoverFiles>();
207       AddStep<ci::security::StepRecoverSecurity>();
208       break;
209     case ci::RequestType::Clear:
210       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
211       AddStep<ci::filesystem::StepClearData>();
212       break;
213     default:
214       AddStep<ci::configuration::StepFail>();
215       break;
216   }
217 }
218
219 }  // namespace hybrid
220