0a88baf816e664e3bff26614464d238368030dcf
[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 #include "wgt/step/step_wgt_remove_manifest.h"
59
60 namespace ci = common_installer;
61
62 namespace hybrid {
63
64 HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
65     : AppInstaller("wgt", pkgmgr) {
66   context_->backend_data.set(new HybridBackendData());
67
68   switch (pkgmgr_->GetRequestType()) {
69     case ci::RequestType::Install:
70       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
71       AddStep<ci::filesystem::StepUnzip>();
72       AddStep<ci::parse::StepParseManifest>(
73           ci::parse::StepParseManifest::ManifestLocation::PACKAGE,
74           ci::parse::StepParseManifest::StoreLocation::NORMAL);
75       AddStep<hybrid::parse::StepStashTpkConfig>();
76       AddStep<hybrid::parse::StepParse>(true);
77       AddStep<hybrid::parse::StepMergeTpkConfig>();
78       AddStep<ci::security::StepCheckSignature>();
79       AddStep<ci::security::StepPrivilegeCompatibility>();
80       AddStep<wgt::security::StepCheckSettingsLevel>();
81       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
82       AddStep<hybrid::encrypt::StepEncryptResources>();
83       AddStep<ci::security::StepRollbackInstallationSecurity>();
84       AddStep<ci::filesystem::StepCopy>();
85       AddStep<tpk::filesystem::StepTpkPatchIcons>();
86       AddStep<wgt::filesystem::StepWgtPatchIcons>();
87       AddStep<ci::filesystem::StepCreateIcons>();
88       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
89       AddStep<ci::filesystem::StepCreateStorageDirectories>();
90       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
91       AddStep<tpk::filesystem::StepCreateSymbolicLink>();
92       AddStep<wgt::pkgmgr::StepGenerateXml>();
93       AddStep<ci::pkgmgr::StepRegisterApplication>();
94       AddStep<ci::security::StepRegisterSecurity>();
95       break;
96     case ci::RequestType::Update:
97       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
98       AddStep<ci::filesystem::StepUnzip>();
99       AddStep<ci::parse::StepParseManifest>(
100           ci::parse::StepParseManifest::ManifestLocation::PACKAGE,
101           ci::parse::StepParseManifest::StoreLocation::NORMAL);
102       AddStep<hybrid::parse::StepStashTpkConfig>();
103       AddStep<hybrid::parse::StepParse>(true);
104       AddStep<hybrid::parse::StepMergeTpkConfig>();
105       AddStep<ci::security::StepCheckSignature>();
106       AddStep<ci::security::StepPrivilegeCompatibility>();
107       AddStep<wgt::security::StepCheckSettingsLevel>();
108       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
109       AddStep<hybrid::encrypt::StepEncryptResources>();
110       AddStep<ci::security::StepRollbackInstallationSecurity>();
111       AddStep<ci::parse::StepParseManifest>(
112           ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
113           ci::parse::StepParseManifest::StoreLocation::BACKUP);
114       AddStep<ci::pkgmgr::StepKillApps>();
115       AddStep<ci::backup::StepBackupManifest>();
116       AddStep<ci::backup::StepBackupIcons>();
117       AddStep<ci::backup::StepCopyBackup>();
118       AddStep<tpk::filesystem::StepTpkPatchIcons>();
119       AddStep<wgt::filesystem::StepWgtPatchIcons>();
120       AddStep<ci::filesystem::StepCreateIcons>();
121       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
122       AddStep<ci::filesystem::StepCopyStorageDirectories>();
123       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
124       AddStep<tpk::filesystem::StepCreateSymbolicLink>();
125       AddStep<ci::security::StepUpdateSecurity>();
126       AddStep<wgt::pkgmgr::StepGenerateXml>();
127       AddStep<ci::pkgmgr::StepUpdateApplication>();
128       break;
129     case ci::RequestType::Uninstall:
130       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
131       // TODO(t.iwanek): this parses both configuration files
132       // tpk and wgt, removing pkgmgr-parser should change this code
133       // that it will still support parsing both files
134       AddStep<ci::parse::StepParseManifest>(
135           ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
136           ci::parse::StepParseManifest::StoreLocation::NORMAL);
137       AddStep<ci::pkgmgr::StepKillApps>();
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       AddStep<wgt::pkgmgr::StepRemoveManifest>();
145       break;
146     case ci::RequestType::Reinstall:
147       // RDS is not supported for hybrid apps
148       AddStep<ci::configuration::StepFail>();
149       break;
150     case ci::RequestType::Delta:
151       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
152       AddStep<ci::filesystem::StepUnzip>();
153       AddStep<ci::parse::StepParseManifest>(
154           ci::parse::StepParseManifest::ManifestLocation::PACKAGE,
155           ci::parse::StepParseManifest::StoreLocation::NORMAL);
156       AddStep<hybrid::parse::StepStashTpkConfig>();
157       // TODO(t.iwanek): manifest is parsed twice...
158       AddStep<hybrid::parse::StepParse>(false);
159       AddStep<hybrid::parse::StepMergeTpkConfig>();
160       AddStep<ci::filesystem::StepDeltaPatch>();
161       AddStep<wgt::parse::StepParse>(true);
162       AddStep<ci::security::StepCheckSignature>();
163       AddStep<ci::security::StepPrivilegeCompatibility>();
164       AddStep<wgt::security::StepCheckSettingsLevel>();
165       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
166       AddStep<hybrid::encrypt::StepEncryptResources>();
167       AddStep<ci::security::StepRollbackInstallationSecurity>();
168       AddStep<ci::parse::StepParseManifest>(
169           ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
170           ci::parse::StepParseManifest::StoreLocation::BACKUP);
171       AddStep<ci::pkgmgr::StepKillApps>();
172       AddStep<ci::backup::StepBackupManifest>();
173       AddStep<ci::backup::StepBackupIcons>();
174       AddStep<ci::backup::StepCopyBackup>();
175       AddStep<tpk::filesystem::StepTpkPatchIcons>();
176       AddStep<wgt::filesystem::StepWgtPatchIcons>();
177       AddStep<ci::filesystem::StepCreateIcons>();
178       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
179       AddStep<ci::filesystem::StepCopyStorageDirectories>();
180       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
181       AddStep<tpk::filesystem::StepCreateSymbolicLink>();
182       AddStep<ci::security::StepUpdateSecurity>();
183       AddStep<wgt::pkgmgr::StepGenerateXml>();
184       AddStep<ci::pkgmgr::StepUpdateApplication>();
185       break;
186     case ci::RequestType::Recovery:
187       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
188       AddStep<ci::recovery::StepOpenRecoveryFile>();
189       AddStep<ci::parse::StepParseManifest>(
190           ci::parse::StepParseManifest::ManifestLocation::RECOVERY,
191           ci::parse::StepParseManifest::StoreLocation::NORMAL);
192       AddStep<hybrid::parse::StepStashTpkConfig>();
193       AddStep<wgt::parse::StepParseRecovery>();
194       AddStep<hybrid::parse::StepMergeTpkConfig>();
195       AddStep<ci::pkgmgr::StepRecoverApplication>();
196       AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
197       AddStep<ci::filesystem::StepRecoverIcons>();
198       AddStep<ci::filesystem::StepRecoverManifest>();
199       AddStep<ci::filesystem::StepRecoverStorageDirectories>();
200       AddStep<ci::filesystem::StepRecoverFiles>();
201       AddStep<ci::security::StepRecoverSecurity>();
202       break;
203     case ci::RequestType::Clear:
204       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
205       AddStep<ci::filesystem::StepClearData>();
206       break;
207     default:
208       AddStep<ci::configuration::StepFail>();
209       break;
210   }
211 }
212
213 }  // namespace hybrid
214