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