Web app icon path change
[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 <manifest_handlers/widget_config_parser.h>
8
9 #include <common/pkgmgr_interface.h>
10 #include <common/step/step_configure.h>
11 #include <common/step/step_backup_manifest.h>
12 #include <common/step/step_copy.h>
13 #include <common/step/step_copy_backup.h>
14 #include <common/step/step_copy_storage_directories.h>
15 #include <common/step/step_delta_patch.h>
16 #include <common/step/step_fail.h>
17 #include <common/step/step_kill_apps.h>
18 #include <common/step/step_open_recovery_file.h>
19 #include <common/step/step_parse.h>
20 #include <common/step/step_privilege_compatibility.h>
21 #include <common/step/step_register_app.h>
22 #include <common/step/step_recover_application.h>
23 #include <common/step/step_recover_files.h>
24 #include <common/step/step_recover_manifest.h>
25 #include <common/step/step_recover_security.h>
26 #include <common/step/step_recover_storage_directories.h>
27 #include <common/step/step_remove_icons.h>
28 #include <common/step/step_remove_files.h>
29 #include <common/step/step_remove_temporary_directory.h>
30 #include <common/step/step_revoke_security.h>
31 #include <common/step/step_register_security.h>
32 #include <common/step/step_rollback_deinstallation_security.h>
33 #include <common/step/step_rollback_installation_security.h>
34 #include <common/step/step_old_manifest.h>
35 #include <common/step/step_check_signature.h>
36 #include <common/step/step_unregister_app.h>
37 #include <common/step/step_unzip.h>
38 #include <common/step/step_update_app.h>
39 #include <common/step/step_update_security.h>
40 #include <common/step/step_check_old_certificate.h>
41
42 #include "wgt/step/step_add_default_privileges.h"
43 #include "wgt/step/step_check_settings_level.h"
44 #include "wgt/step/step_check_wgt_background_category.h"
45 #include "wgt/step/step_create_symbolic_link.h"
46 #include "wgt/step/step_encrypt_resources.h"
47 #include "wgt/step/step_generate_xml.h"
48 #include "wgt/step/step_parse.h"
49 #include "wgt/step/step_parse_recovery.h"
50 #include "wgt/step/step_rds_modify.h"
51 #include "wgt/step/step_rds_parse.h"
52 #include "wgt/step/step_remove_encryption_data.h"
53 #include "wgt/step/step_wgt_backup_icons.h"
54 #include "wgt/step/step_wgt_copy_storage_directories.h"
55 #include "wgt/step/step_wgt_create_icons.h"
56 #include "wgt/step/step_wgt_create_storage_directories.h"
57 #include "wgt/step/step_wgt_recover_icons.h"
58 #include "wgt/step/step_wgt_resource_directory.h"
59
60 namespace ci = common_installer;
61
62 namespace wgt {
63
64 WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
65     : AppInstaller("wgt", pkgrmgr) {
66   /* treat the request */
67   switch (pkgmgr_->GetRequestType()) {
68     case ci::RequestType::Install : {
69       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
70       AddStep<ci::filesystem::StepUnzip>();
71       AddStep<wgt::parse::StepParse>(true);
72       AddStep<ci::security::StepCheckSignature>();
73       AddStep<ci::security::StepPrivilegeCompatibility>();
74       AddStep<wgt::security::StepCheckSettingsLevel>();
75       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
76       AddStep<wgt::encrypt::StepEncryptResources>();
77       AddStep<wgt::filesystem::StepWgtResourceDirectory>();
78       AddStep<ci::security::StepRollbackInstallationSecurity>();
79       AddStep<ci::filesystem::StepCopy>();
80       AddStep<wgt::filesystem::StepWgtCreateStorageDirectories>();
81       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
82       AddStep<wgt::filesystem::StepWgtCreateIcons>();
83       AddStep<wgt::pkgmgr::StepGenerateXml>();
84       AddStep<ci::pkgmgr::StepRegisterApplication>();
85       AddStep<ci::security::StepRegisterSecurity>();
86       break;
87     }
88     case ci::RequestType::Update: {
89       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
90       AddStep<ci::filesystem::StepUnzip>();
91       AddStep<wgt::parse::StepParse>(true);
92       AddStep<ci::security::StepCheckSignature>();
93       AddStep<ci::security::StepPrivilegeCompatibility>();
94       AddStep<wgt::security::StepCheckSettingsLevel>();
95       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
96       AddStep<ci::security::StepCheckOldCertificate>();
97       AddStep<wgt::filesystem::StepWgtResourceDirectory>();
98       AddStep<ci::backup::StepOldManifest>();
99       AddStep<ci::pkgmgr::StepKillApps>();
100       AddStep<ci::backup::StepBackupManifest>();
101       AddStep<wgt::backup::StepWgtBackupIcons>();
102       AddStep<ci::backup::StepCopyBackup>();
103       AddStep<wgt::filesystem::StepWgtCopyStorageDirectories>();
104       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
105       AddStep<wgt::filesystem::StepWgtCreateIcons>();
106       AddStep<ci::security::StepUpdateSecurity>();
107       AddStep<wgt::pkgmgr::StepGenerateXml>();
108       AddStep<ci::pkgmgr::StepUpdateApplication>();
109       break;
110     }
111     case ci::RequestType::Uninstall: {
112       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
113       AddStep<ci::parse::StepParse>();
114       AddStep<ci::pkgmgr::StepKillApps>();
115       AddStep<ci::backup::StepBackupManifest>();
116       AddStep<ci::pkgmgr::StepUnregisterApplication>();
117       AddStep<ci::security::StepRollbackDeinstallationSecurity>();
118       AddStep<ci::filesystem::StepRemoveFiles>();
119       AddStep<ci::filesystem::StepRemoveIcons>();
120       AddStep<wgt::encrypt::StepRemoveEncryptionData>();
121       AddStep<ci::security::StepRevokeSecurity>();
122       break;
123     }
124     case ci::RequestType::Reinstall: {
125       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
126       AddStep<wgt::parse::StepParse>(false);
127       AddStep<ci::pkgmgr::StepKillApps>();
128       AddStep<ci::backup::StepOldManifest>();
129       AddStep<wgt::rds::StepRDSParse>();
130       AddStep<wgt::rds::StepRDSModify>();
131       AddStep<ci::security::StepUpdateSecurity>();
132       break;
133     }
134     case ci::RequestType::Delta: {
135       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
136       AddStep<ci::filesystem::StepUnzip>();
137       // TODO(t.iwanek): manifest is parsed twice...
138       AddStep<wgt::parse::StepParse>(false);  // start file may not have changed
139       AddStep<ci::filesystem::StepDeltaPatch>("res/wgt/");
140       AddStep<wgt::parse::StepParse>(true);
141       AddStep<ci::security::StepCheckSignature>();
142       AddStep<ci::security::StepPrivilegeCompatibility>();
143       AddStep<wgt::security::StepCheckSettingsLevel>();
144       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
145       AddStep<ci::security::StepCheckOldCertificate>();
146       AddStep<wgt::filesystem::StepWgtResourceDirectory>();
147       AddStep<ci::backup::StepOldManifest>();
148       AddStep<ci::pkgmgr::StepKillApps>();
149       AddStep<ci::backup::StepBackupManifest>();
150       AddStep<wgt::backup::StepWgtBackupIcons>();
151       AddStep<ci::backup::StepCopyBackup>();
152       AddStep<wgt::filesystem::StepWgtCopyStorageDirectories>();
153       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
154       AddStep<wgt::filesystem::StepWgtCreateIcons>();
155       AddStep<ci::security::StepUpdateSecurity>();
156       AddStep<wgt::pkgmgr::StepGenerateXml>();
157       AddStep<ci::pkgmgr::StepUpdateApplication>();
158       break;
159     }
160     case ci::RequestType::Recovery: {
161       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
162       AddStep<ci::recovery::StepOpenRecoveryFile>();
163       AddStep<wgt::parse::StepParseRecovery>();
164       AddStep<ci::pkgmgr::StepRecoverApplication>();
165       AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
166       AddStep<wgt::filesystem::StepWgtRecoverIcons>();
167       AddStep<ci::filesystem::StepRecoverManifest>();
168       AddStep<ci::filesystem::StepRecoverStorageDirectories>();
169       AddStep<ci::filesystem::StepRecoverFiles>();
170       AddStep<ci::security::StepRecoverSecurity>();
171       break;
172     }
173     default: {
174       AddStep<ci::configuration::StepFail>();
175     }
176   }
177 }
178
179 }  // namespace wgt