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