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