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