verifying notification category privilege
[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
9 #include <common/step/backup/step_backup_icons.h>
10 #include <common/step/backup/step_backup_manifest.h>
11 #include <common/step/backup/step_copy_backup.h>
12 #include <common/step/configuration/step_configure.h>
13 #include <common/step/configuration/step_fail.h>
14 #include <common/step/configuration/step_parse_manifest.h>
15 #include <common/step/filesystem/step_clear_data.h>
16 #include <common/step/filesystem/step_copy.h>
17 #include <common/step/filesystem/step_copy_storage_directories.h>
18 #include <common/step/filesystem/step_copy_tep.h>
19 #include <common/step/filesystem/step_create_icons.h>
20 #include <common/step/filesystem/step_create_per_user_storage_directories.h>
21 #include <common/step/filesystem/step_create_storage_directories.h>
22 #include <common/step/filesystem/step_delta_patch.h>
23 #include <common/step/filesystem/step_recover_files.h>
24 #include <common/step/filesystem/step_recover_icons.h>
25 #include <common/step/filesystem/step_recover_manifest.h>
26 #include <common/step/filesystem/step_recover_storage_directories.h>
27 #include <common/step/filesystem/step_remove_files.h>
28 #include <common/step/filesystem/step_remove_icons.h>
29 #include <common/step/filesystem/step_remove_per_user_storage_directories.h>
30 #include <common/step/filesystem/step_remove_temporary_directory.h>
31 #include <common/step/filesystem/step_unzip.h>
32 #include <common/step/pkgmgr/step_check_blacklist.h>
33 #include <common/step/pkgmgr/step_check_removable.h>
34 #include <common/step/pkgmgr/step_kill_apps.h>
35 #include <common/step/pkgmgr/step_recover_application.h>
36 #include <common/step/pkgmgr/step_register_app.h>
37 #include <common/step/pkgmgr/step_remove_manifest.h>
38 #include <common/step/pkgmgr/step_run_parser_plugins.h>
39 #include <common/step/pkgmgr/step_unregister_app.h>
40 #include <common/step/pkgmgr/step_update_app.h>
41 #include <common/step/pkgmgr/step_update_tep.h>
42 #include <common/step/recovery/step_open_recovery_file.h>
43 #include <common/step/security/step_check_old_certificate.h>
44 #include <common/step/security/step_check_signature.h>
45 #include <common/step/security/step_privilege_compatibility.h>
46 #include <common/step/security/step_recover_security.h>
47 #include <common/step/security/step_register_security.h>
48 #include <common/step/security/step_revoke_security.h>
49 #include <common/step/security/step_rollback_deinstallation_security.h>
50 #include <common/step/security/step_rollback_installation_security.h>
51 #include <common/step/security/step_update_security.h>
52
53 #include <wgt_manifest_handlers/widget_config_parser.h>
54 #include <common/step/rds/step_rds_modify.h>
55 #include <common/step/rds/step_rds_parse.h>
56
57 #include "wgt/step/configuration/step_parse.h"
58 #include "wgt/step/configuration/step_parse_recovery.h"
59 #include "wgt/step/encryption/step_encrypt_resources.h"
60 #include "wgt/step/encryption/step_remove_encryption_data.h"
61 #include "wgt/step/filesystem/step_create_symbolic_link.h"
62 #include "wgt/step/filesystem/step_wgt_patch_icons.h"
63 #include "wgt/step/filesystem/step_wgt_patch_storage_directories.h"
64 #include "wgt/step/filesystem/step_wgt_resource_directory.h"
65 #include "wgt/step/pkgmgr/step_generate_xml.h"
66 #include "wgt/step/rds/step_wgt_rds_modify.h"
67 #include "wgt/step/security/step_add_default_privileges.h"
68 #include "wgt/step/security/step_check_settings_level.h"
69 #include "wgt/step/security/step_check_wgt_background_category.h"
70 #include "wgt/step/security/step_check_wgt_notification_category.h"
71
72 namespace ci = common_installer;
73
74 namespace wgt {
75
76 WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
77     : AppInstaller("wgt", pkgrmgr) {
78   context_->backend_data.set(new WgtBackendData());
79
80   /* treat the request */
81   switch (pkgmgr_->GetRequestType()) {
82     case ci::RequestType::Install : {
83       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
84       AddStep<ci::filesystem::StepUnzip>();
85       AddStep<wgt::configuration::StepParse>(true);
86       AddStep<ci::pkgmgr::StepCheckBlacklist>();
87       AddStep<ci::security::StepCheckSignature>();
88       AddStep<ci::security::StepPrivilegeCompatibility>();
89       AddStep<wgt::security::StepCheckSettingsLevel>();
90       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
91       AddStep<wgt::security::StepCheckWgtNotificationCategory>();
92       AddStep<wgt::encryption::StepEncryptResources>();
93       AddStep<wgt::filesystem::StepWgtResourceDirectory>();
94       AddStep<ci::security::StepRollbackInstallationSecurity>();
95       AddStep<ci::filesystem::StepCopy>();
96       AddStep<ci::filesystem::StepCopyTep>();
97       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
98       AddStep<ci::filesystem::StepCreateStorageDirectories>();
99       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
100       AddStep<wgt::filesystem::StepWgtPatchIcons>();
101       AddStep<ci::filesystem::StepCreateIcons>();
102       AddStep<wgt::pkgmgr::StepGenerateXml>();
103       AddStep<ci::pkgmgr::StepRegisterApplication>();
104       AddStep<ci::pkgmgr::StepRunParserPlugin>(
105           ci::Plugin::ActionType::Install);
106       AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
107       AddStep<ci::security::StepRegisterSecurity>();
108       break;
109     }
110     case ci::RequestType::Update: {
111       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
112       AddStep<ci::filesystem::StepUnzip>();
113       AddStep<wgt::configuration::StepParse>(true);
114       AddStep<ci::pkgmgr::StepCheckBlacklist>();
115       AddStep<ci::security::StepCheckSignature>();
116       AddStep<ci::security::StepPrivilegeCompatibility>();
117       AddStep<wgt::security::StepCheckSettingsLevel>();
118       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
119       AddStep<wgt::security::StepCheckWgtNotificationCategory>();
120       AddStep<ci::security::StepCheckOldCertificate>();
121       AddStep<wgt::filesystem::StepWgtResourceDirectory>();
122       AddStep<ci::configuration::StepParseManifest>(
123           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
124           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
125       AddStep<ci::pkgmgr::StepKillApps>();
126       AddStep<ci::backup::StepBackupManifest>();
127       AddStep<ci::backup::StepBackupIcons>();
128       AddStep<ci::backup::StepCopyBackup>();
129       AddStep<ci::filesystem::StepCopyTep>();
130       AddStep<ci::pkgmgr::StepUpdateTep>();
131       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
132       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
133       AddStep<wgt::filesystem::StepWgtPatchIcons>();
134       AddStep<ci::filesystem::StepCreateIcons>();
135       AddStep<ci::filesystem::StepCopyStorageDirectories>();
136       AddStep<ci::security::StepUpdateSecurity>();
137       AddStep<wgt::pkgmgr::StepGenerateXml>();
138       AddStep<ci::pkgmgr::StepRunParserPlugin>(
139           ci::Plugin::ActionType::Upgrade);
140       AddStep<ci::pkgmgr::StepUpdateApplication>();
141       break;
142     }
143     case ci::RequestType::Uninstall: {
144       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
145       AddStep<ci::pkgmgr::StepCheckRemovable>();
146       AddStep<ci::configuration::StepParseManifest>(
147           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
148           ci::configuration::StepParseManifest::StoreLocation::NORMAL);
149       AddStep<ci::pkgmgr::StepKillApps>();
150       AddStep<ci::pkgmgr::StepRunParserPlugin>(
151           ci::Plugin::ActionType::Uninstall);
152       AddStep<ci::filesystem::StepRemovePerUserStorageDirectories>();
153       AddStep<ci::pkgmgr::StepUnregisterApplication>();
154       AddStep<ci::security::StepRollbackDeinstallationSecurity>();
155       AddStep<ci::filesystem::StepRemoveFiles>();
156       AddStep<ci::filesystem::StepRemoveIcons>();
157       AddStep<wgt::encryption::StepRemoveEncryptionData>();
158       AddStep<ci::security::StepRevokeSecurity>();
159       AddStep<ci::pkgmgr::StepRemoveManifest>();
160       break;
161     }
162     case ci::RequestType::Reinstall: {
163       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
164       AddStep<wgt::configuration::StepParse>(false);
165       AddStep<ci::pkgmgr::StepKillApps>();
166       AddStep<ci::configuration::StepParseManifest>(
167           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
168           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
169       AddStep<ci::pkgmgr::StepCheckBlacklist>();
170       AddStep<ci::rds::StepRDSParse>();
171       AddStep<wgt::rds::StepWgtRDSModify>();
172       AddStep<ci::security::StepUpdateSecurity>();
173       break;
174     }
175     case ci::RequestType::Delta: {
176       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
177       AddStep<ci::filesystem::StepUnzip>();
178       // TODO(t.iwanek): manifest is parsed twice...
179       AddStep<wgt::configuration::StepParse>(false);
180       // start file may not have changed
181       AddStep<ci::filesystem::StepDeltaPatch>("res/wgt/");
182       AddStep<wgt::configuration::StepParse>(true);
183       AddStep<ci::pkgmgr::StepCheckBlacklist>();
184       AddStep<ci::security::StepCheckSignature>();
185       AddStep<ci::security::StepPrivilegeCompatibility>();
186       AddStep<wgt::security::StepCheckSettingsLevel>();
187       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
188       AddStep<wgt::security::StepCheckWgtNotificationCategory>();
189       AddStep<ci::security::StepCheckOldCertificate>();
190       AddStep<wgt::filesystem::StepWgtResourceDirectory>();
191       AddStep<ci::configuration::StepParseManifest>(
192           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
193           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
194       AddStep<ci::pkgmgr::StepKillApps>();
195       AddStep<ci::backup::StepBackupManifest>();
196       AddStep<ci::backup::StepBackupIcons>();
197       AddStep<ci::backup::StepCopyBackup>();
198       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
199       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
200       AddStep<wgt::filesystem::StepWgtPatchIcons>();
201       AddStep<ci::filesystem::StepCreateIcons>();
202       AddStep<ci::filesystem::StepCopyStorageDirectories>();
203       AddStep<ci::security::StepUpdateSecurity>();
204       AddStep<wgt::pkgmgr::StepGenerateXml>();
205       AddStep<ci::pkgmgr::StepRunParserPlugin>(
206           ci::Plugin::ActionType::Upgrade);
207       AddStep<ci::pkgmgr::StepUpdateApplication>();
208       break;
209     }
210     case ci::RequestType::Recovery: {
211       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
212       AddStep<ci::recovery::StepOpenRecoveryFile>();
213       AddStep<wgt::configuration::StepParseRecovery>();
214       AddStep<ci::pkgmgr::StepRecoverApplication>();
215       AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
216       AddStep<ci::filesystem::StepRecoverIcons>();
217       AddStep<ci::filesystem::StepRecoverManifest>();
218       AddStep<ci::filesystem::StepRecoverStorageDirectories>();
219       AddStep<ci::filesystem::StepRecoverFiles>();
220       AddStep<ci::security::StepRecoverSecurity>();
221       break;
222     }
223     case ci::RequestType::Clear: {
224       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
225       AddStep<ci::filesystem::StepClearData>();
226       break;
227     }
228     default: {
229       AddStep<ci::configuration::StepFail>();
230     }
231   }
232 }
233
234 }  // namespace wgt