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