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