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