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 ,__privilegeLevel(PRIVILEGE_LEVEL_PUBLIC)
59 ,__pApp2ExtHandle(null)
60 ,__pPrivilegeList(null)
61 ,__pStringPrivilegeList(null)
62 ,__pContentDataList(null)
63 ,__pAuthorCertPath(null)
64 ,__pDistributorCertPath(null)
65 ,__pAuthorCertList(null)
66 ,__pDistributorCertList(null)
71 InstallationContext::~InstallationContext(void)
79 delete __pAuthorCertPath;
80 __pAuthorCertPath = null;
82 delete __pDistributorCertPath;
83 __pDistributorCertPath = null;
87 __pPrivilegeList->RemoveAll();
88 delete __pPrivilegeList;
89 __pPrivilegeList = null;
92 if (__pStringPrivilegeList)
94 __pStringPrivilegeList->RemoveAll(true);
95 delete __pStringPrivilegeList;
96 __pStringPrivilegeList = null;
101 __pAppDataList->RemoveAll();
102 delete __pAppDataList;
105 if (__pAuthorCertList)
107 __pAuthorCertList->RemoveAll();
108 delete __pAuthorCertList;
109 __pAuthorCertList = null;
112 if (__pDistributorCertList)
114 __pDistributorCertList->RemoveAll();
115 delete __pDistributorCertList;
116 __pDistributorCertList = null;
121 InstallationContext::Construct(void)
123 __pAppDataList = new (std::nothrow) ArrayListT<AppData*>;
124 TryReturn(__pAppDataList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pAppDataList is null");
126 __pAuthorCertList = new (std::nothrow) ArrayListT<String*>;
127 TryReturn(__pAuthorCertList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pAuthorCertList is null.");
129 __pDistributorCertList = new (std::nothrow) ArrayListT<String*>;
130 TryReturn(__pDistributorCertList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pDistributorCertList is null.");
132 return INSTALLER_ERROR_NONE;
136 InstallationContext::ChangeStep(InstallationStep step)
143 case INSTALLER_STEP_NONE:
146 case INSTALLER_STEP_INIT:
149 case INSTALLER_STEP_CHECK_SYSTEM:
150 __pStep = new (std::nothrow) SystemCheckStep();
151 TryReturn(__pStep, false, "SystemCheckStep is failed.");
154 case INSTALLER_STEP_CHECK_PACKAGE:
155 __pStep = new (std::nothrow) PackageCheckStep();
156 TryReturn(__pStep, false, "PackageCheckStep is failed.");
159 case INSTALLER_STEP_UNPACK:
160 __pStep = new (std::nothrow) UnpackStep();
161 TryReturn(__pStep, false, "UnpackStep is failed.");
164 case INSTALLER_STEP_PARSE_MANIFEST:
165 __pStep = new (std::nothrow) ManifestXmlStep();
166 TryReturn(__pStep, false, "ManifestXmlStep is failed.");
169 case INSTALLER_STEP_PARSE_SIGNATURE:
170 __pStep = new (std::nothrow) SignatureStep();
171 TryReturn(__pStep, false, "SignatureStep is failed.");
174 case INSTALLER_STEP_UNINSTALL:
175 __pStep = new (std::nothrow) UninstallStep();
176 TryReturn(__pStep, false, "UninstallStep is failed.");
179 case INSTALLER_STEP_LICENSE:
180 __pStep = new (std::nothrow) LicenseStep();
181 TryReturn(__pStep, false, "LicenseStep is failed.");
184 case INSTALLER_STEP_DRM:
185 __pStep = new (std::nothrow) DrmStep();
186 TryReturn(__pStep, false, "DrmStep is failed.");
189 case INSTALLER_STEP_RDS:
190 __pStep = new (std::nothrow) RdsStep();
191 TryReturn(__pStep, false, "DrmStep is failed.");
194 case INSTALLER_STEP_END:
206 InstallationContext::Run(void)
208 InstallerError error = INSTALLER_ERROR_NONE;
209 AppLog("InstallationContext::Run()");
214 InstallationContext::GetCurrentInstallationStep(void)
220 InstallationContext::SetCurrentInstallationStep(InstallationStep step)
226 InstallationContext::GetError(void)
232 InstallationContext::SetError(InstallerError installerError)
234 __error = installerError;
238 InstallationContext::GetState(void)
244 InstallationContext::SetState(InstallationState installationState)
246 __state = installationState;
250 InstallationContext::GetStep(void)
256 InstallationContext::SetInstallerOperation(InstallerOperation op)
262 InstallationContext::GetInstallerOperation(void) const
268 InstallationContext::IsContinue(void)
274 InstallationContext::SetContinue(bool cont)
280 InstallationContext::GetSignatureXmlPath(void)
284 path = __installDir + SIGNATURE1_XML_FILE;
290 InstallationContext::GetAuthorSignatureXmlPath(void)
294 path = __installDir + AUTHOR_SIGNATURE_XML_FILE;
300 InstallationContext::GetPrivilegeList(void) const
302 return __pPrivilegeList;
306 InstallationContext::SetPrivilegeList(ArrayList* privilegeList)
308 __pPrivilegeList = privilegeList;
312 InstallationContext::GetContentDataList(void) const
314 return __pContentDataList;
318 InstallationContext::SetContentDataList(ArrayList* pContentDataList)
320 __pContentDataList = pContentDataList;