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(true)
54 ,__isAppSetting(false)
56 ,__isUninstallable(false)
57 ,__operation(INSTALLER_OPERATION_INSTALL)
58 ,__storage(INSTALLATION_STORAGE_NONE)
59 ,__rootCertType(ROOT_CERTIFICATE_NONE)
60 ,__privilegeLevel(PRIVILEGE_LEVEL_PUBLIC)
61 ,__pApp2ExtHandle(null)
62 ,__pPrivilegeList(null)
63 ,__pStringPrivilegeList(null)
64 ,__pContentDataList(null)
65 ,__pAuthorCertList(null)
66 ,__pDistributorCertList(null)
67 ,__pDistributorCertList2(null)
69 ,__pPkgmgrInstaller(null)
73 InstallationContext::~InstallationContext(void)
83 __pPrivilegeList->RemoveAll();
84 delete __pPrivilegeList;
85 __pPrivilegeList = null;
88 if (__pStringPrivilegeList)
90 __pStringPrivilegeList->RemoveAll(true);
91 delete __pStringPrivilegeList;
92 __pStringPrivilegeList = null;
97 __pAppDataList->RemoveAll();
98 delete __pAppDataList;
101 if (__pAuthorCertList)
103 __pAuthorCertList->RemoveAll();
104 delete __pAuthorCertList;
105 __pAuthorCertList = null;
108 if (__pDistributorCertList)
110 __pDistributorCertList->RemoveAll();
111 delete __pDistributorCertList;
112 __pDistributorCertList = null;
115 if (__pDistributorCertList2)
117 __pDistributorCertList2->RemoveAll();
118 delete __pDistributorCertList2;
119 __pDistributorCertList2 = null;
124 InstallationContext::Construct(void)
126 __pAppDataList = new (std::nothrow) ArrayListT<AppData*>;
127 TryReturn(__pAppDataList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pAppDataList is null");
129 __pAuthorCertList = new (std::nothrow) ArrayListT<String*>;
130 TryReturn(__pAuthorCertList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pAuthorCertList is null.");
132 __pDistributorCertList = new (std::nothrow) ArrayListT<String*>;
133 TryReturn(__pDistributorCertList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pDistributorCertList is null.");
135 __pDistributorCertList2 = new (std::nothrow) ArrayListT<String*>;
136 TryReturn(__pDistributorCertList2, INSTALLER_ERROR_OUT_OF_MEMORY, "__pDistributorCertList2 is null.");
138 return INSTALLER_ERROR_NONE;
142 InstallationContext::ChangeStep(InstallationStep step)
149 case INSTALLER_STEP_NONE:
152 case INSTALLER_STEP_INIT:
155 case INSTALLER_STEP_CHECK_SYSTEM:
156 __pStep = new (std::nothrow) SystemCheckStep();
157 TryReturn(__pStep, false, "SystemCheckStep is failed.");
160 case INSTALLER_STEP_CHECK_PACKAGE:
161 __pStep = new (std::nothrow) PackageCheckStep();
162 TryReturn(__pStep, false, "PackageCheckStep is failed.");
165 case INSTALLER_STEP_UNPACK:
166 __pStep = new (std::nothrow) UnpackStep();
167 TryReturn(__pStep, false, "UnpackStep is failed.");
170 case INSTALLER_STEP_PARSE_MANIFEST:
171 __pStep = new (std::nothrow) ManifestXmlStep();
172 TryReturn(__pStep, false, "ManifestXmlStep is failed.");
175 case INSTALLER_STEP_PARSE_SIGNATURE:
176 __pStep = new (std::nothrow) SignatureStep();
177 TryReturn(__pStep, false, "SignatureStep is failed.");
180 case INSTALLER_STEP_UNINSTALL:
181 __pStep = new (std::nothrow) UninstallStep();
182 TryReturn(__pStep, false, "UninstallStep is failed.");
185 case INSTALLER_STEP_LICENSE:
186 __pStep = new (std::nothrow) LicenseStep();
187 TryReturn(__pStep, false, "LicenseStep is failed.");
190 case INSTALLER_STEP_DRM:
191 __pStep = new (std::nothrow) DrmStep();
192 TryReturn(__pStep, false, "DrmStep is failed.");
195 case INSTALLER_STEP_RDS:
196 __pStep = new (std::nothrow) RdsStep();
197 TryReturn(__pStep, false, "DrmStep is failed.");
200 case INSTALLER_STEP_END:
212 InstallationContext::Run(void)
214 InstallerError error = INSTALLER_ERROR_NONE;
215 AppLog("InstallationContext::Run()");
220 InstallationContext::GetCurrentInstallationStep(void)
226 InstallationContext::SetCurrentInstallationStep(InstallationStep step)
232 InstallationContext::GetError(void)
238 InstallationContext::SetError(InstallerError installerError)
240 __error = installerError;
244 InstallationContext::GetState(void)
250 InstallationContext::SetState(InstallationState installationState)
252 __state = installationState;
256 InstallationContext::GetStep(void)
262 InstallationContext::SetInstallerOperation(InstallerOperation op)
268 InstallationContext::GetInstallerOperation(void) const
274 InstallationContext::IsContinue(void)
280 InstallationContext::SetContinue(bool cont)
286 InstallationContext::GetSignatureXmlPath(void)
290 path = __installDir + SIGNATURE1_XML_FILE;
296 InstallationContext::GetAuthorSignatureXmlPath(void)
300 path = __installDir + AUTHOR_SIGNATURE_XML_FILE;
306 InstallationContext::GetPrivilegeList(void) const
308 return __pPrivilegeList;
312 InstallationContext::SetPrivilegeList(ArrayList* privilegeList)
314 __pPrivilegeList = privilegeList;
318 InstallationContext::GetContentDataList(void) const
320 return __pContentDataList;
324 InstallationContext::SetContentDataList(ArrayList* pContentDataList)
326 __pContentDataList = pContentDataList;