2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file InstallationContext.cpp
19 * @brief This is the implementation for the InstallerContext class.
22 #include "InstallationContext.h"
23 #include "SystemCheckStep.h"
24 #include "PackageCheckStep.h"
25 #include "ManifestXmlStep.h"
26 #include "LicenseStep.h"
27 #include "SignatureStep.h"
29 #include "UninstallStep.h"
30 #include "UnpackStep.h"
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Collection;
35 using namespace Tizen::Io;
36 using namespace Tizen::Security::Cert;
37 using namespace Tizen::App;
39 InstallationContext::InstallationContext(void)
42 ,__error(INSTALLER_ERROR_NONE)
43 ,__step(INSTALLER_STEP_NONE)
45 ,__state(INSTALLER_STATE_RUNNING)
51 ,__isHybridService(false)
52 ,__isVerificationMode(false)
54 ,__isAppSetting(false)
55 ,__operation(INSTALLER_OPERATION_INSTALL)
56 ,__storage(INSTALLATION_STORAGE_INTERNAL)
57 ,__rootCertType(ROOT_CERTIFICATE_NONE)
58 ,__pApp2ExtHandle(null)
59 ,__pPrivilegeList(null)
60 ,__pStringPrivilegeList(null)
61 ,__pContentDataList(null)
62 ,__pAuthorCertPath(null)
63 ,__pDistributorCertPath(null)
64 ,__pAuthorCertList(null)
65 ,__pDistributorCertList(null)
70 InstallationContext::~InstallationContext(void)
78 delete __pAuthorCertPath;
79 __pAuthorCertPath = null;
81 delete __pDistributorCertPath;
82 __pDistributorCertPath = null;
86 __pPrivilegeList->RemoveAll();
87 delete __pPrivilegeList;
88 __pPrivilegeList = null;
91 if (__pStringPrivilegeList)
93 __pStringPrivilegeList->RemoveAll(true);
94 delete __pStringPrivilegeList;
95 __pStringPrivilegeList = null;
100 __pAppDataList->RemoveAll();
101 delete __pAppDataList;
104 if (__pAuthorCertList)
106 __pAuthorCertList->RemoveAll();
107 delete __pAuthorCertList;
108 __pAuthorCertList = null;
111 if (__pDistributorCertList)
113 __pDistributorCertList->RemoveAll();
114 delete __pDistributorCertList;
115 __pDistributorCertList = null;
120 InstallationContext::Construct(void)
122 __pAppDataList = new (std::nothrow) ArrayListT<AppData*>;
123 TryReturn(__pAppDataList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pAppDataList is null");
125 __pAuthorCertList = new (std::nothrow) ArrayListT<String*>;
126 TryReturn(__pAuthorCertList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pAuthorCertList is null.");
128 __pDistributorCertList = new (std::nothrow) ArrayListT<String*>;
129 TryReturn(__pDistributorCertList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pDistributorCertList is null.");
131 return INSTALLER_ERROR_NONE;
135 InstallationContext::ChangeStep(InstallationStep step)
142 case INSTALLER_STEP_NONE:
145 case INSTALLER_STEP_INIT:
148 case INSTALLER_STEP_CHECK_SYSTEM:
149 __pStep = new (std::nothrow) SystemCheckStep();
150 TryReturn(__pStep, false, "SystemCheckStep is failed.");
153 case INSTALLER_STEP_CHECK_PACKAGE:
154 __pStep = new (std::nothrow) PackageCheckStep();
155 TryReturn(__pStep, false, "PackageCheckStep is failed.");
158 case INSTALLER_STEP_UNPACK:
159 __pStep = new (std::nothrow) UnpackStep();
160 TryReturn(__pStep, false, "UnpackStep is failed.");
163 case INSTALLER_STEP_PARSE_MANIFEST:
164 __pStep = new (std::nothrow) ManifestXmlStep();
165 TryReturn(__pStep, false, "ManifestXmlStep is failed.");
168 case INSTALLER_STEP_PARSE_SIGNATURE:
169 __pStep = new (std::nothrow) SignatureStep();
170 TryReturn(__pStep, false, "SignatureStep is failed.");
173 case INSTALLER_STEP_UNINSTALL:
174 __pStep = new (std::nothrow) UninstallStep();
175 TryReturn(__pStep, false, "UninstallStep is failed.");
178 case INSTALLER_STEP_LICENSE:
179 __pStep = new (std::nothrow) LicenseStep();
180 TryReturn(__pStep, false, "LicenseStep is failed.");
183 case INSTALLER_STEP_DRM:
184 __pStep = new (std::nothrow) DrmStep();
185 TryReturn(__pStep, false, "DrmStep is failed.");
188 case INSTALLER_STEP_RDS:
189 __pStep = new (std::nothrow) RdsStep();
190 TryReturn(__pStep, false, "DrmStep is failed.");
193 case INSTALLER_STEP_END:
205 InstallationContext::Run(void)
207 InstallerError error = INSTALLER_ERROR_NONE;
208 AppLog("InstallationContext::Run()");
213 InstallationContext::GetCurrentInstallationStep(void)
219 InstallationContext::SetCurrentInstallationStep(InstallationStep step)
225 InstallationContext::GetError(void)
231 InstallationContext::SetError(InstallerError installerError)
233 __error = installerError;
237 InstallationContext::GetState(void)
243 InstallationContext::SetState(InstallationState installationState)
245 __state = installationState;
249 InstallationContext::GetStep(void)
255 InstallationContext::SetInstallerOperation(InstallerOperation op)
261 InstallationContext::GetInstallerOperation(void) const
267 InstallationContext::IsContinue(void)
273 InstallationContext::SetContinue(bool cont)
279 InstallationContext::GetSignatureXmlPath(void)
283 path = __installDir + SIGNATURE1_XML_FILE;
289 InstallationContext::GetAuthorSignatureXmlPath(void)
293 path = __installDir + AUTHOR_SIGNATURE_XML_FILE;
299 InstallationContext::GetPrivilegeList(void) const
301 return __pPrivilegeList;
305 InstallationContext::SetPrivilegeList(ArrayList* privilegeList)
307 __pPrivilegeList = privilegeList;
311 InstallationContext::GetContentDataList(void) const
313 return __pContentDataList;
317 InstallationContext::SetContentDataList(ArrayList* pContentDataList)
319 __pContentDataList = pContentDataList;