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"
32 #include <FAppPkg_PackageInfoImpl.h>
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::Io;
37 using namespace Tizen::Security::Cert;
38 using namespace Tizen::App;
39 using namespace Tizen::App::Package;
41 InstallationContext::InstallationContext(void)
46 ,__error(INSTALLER_ERROR_NONE)
47 ,__step(INSTALLER_STEP_NONE)
49 ,__state(INSTALLER_STATE_RUNNING)
53 ,__hybridService(false)
54 ,__verificationMode(false)
55 ,__operation(INSTALLER_OPERATION_INSTALL)
56 ,__storage(INSTALLATION_STORAGE_INTERNAL)
57 ,__pPrivilegeList(null)
58 ,__pLiveboxDataList(null)
59 ,__pContentDataList(null)
60 ,__pAuthorCertPath(null)
61 ,__pDistributorCertPath(null)
62 ,__rootCertType(ROOT_CERTIFICATE_NONE)
63 ,__packageNameType(INSTALLER_PREFIX_TYPE_NONE)
64 ,__pApp2ExtHandle(null)
65 ,__pPackageInfoImpl(null)
69 InstallationContext::~InstallationContext(void)
77 delete __pAuthorCertPath;
78 __pAuthorCertPath = null;
80 delete __pDistributorCertPath;
81 __pDistributorCertPath = null;
85 __pPrivilegeList->RemoveAll();
86 delete __pPrivilegeList;
87 __pPrivilegeList = null;
90 if (__pLiveboxDataList)
92 __pLiveboxDataList->RemoveAll();
93 delete __pLiveboxDataList;
94 __pLiveboxDataList = null;
99 __pAppDataList->RemoveAll();
100 delete __pAppDataList;
105 InstallationContext::Construct(void)
107 __pPackageInfoImpl = new (std::nothrow) _PackageInfoImpl();
108 TryReturn(__pPackageInfoImpl, INSTALLER_ERROR_MEMORY, "[osp-installer] __pPackageInfoImpl is null.");
110 __pAppDataList = new (std::nothrow) ArrayListT<AppData*>;
111 TryReturn(__pAppDataList, INSTALLER_ERROR_MEMORY, "[osp-installer] __pAppDataList is null");
113 return INSTALLER_ERROR_NONE;
117 InstallationContext::ChangeStep(InstallationStep step)
124 case INSTALLER_STEP_NONE:
127 case INSTALLER_STEP_INIT:
130 case INSTALLER_STEP_CHECK_SYSTEM:
131 __pStep = new (std::nothrow) SystemCheckStep();
132 TryReturn(__pStep, false, "[osp-installer] SystemCheckStep is failed.");
135 case INSTALLER_STEP_CHECK_PACKAGE:
136 __pStep = new (std::nothrow) PackageCheckStep();
137 TryReturn(__pStep, false, "[osp-installer] PackageCheckStep is failed.");
140 case INSTALLER_STEP_UNPACK:
141 __pStep = new (std::nothrow) UnpackStep();
142 TryReturn(__pStep, false, "[osp-installer] UnpackStep is failed.");
145 case INSTALLER_STEP_PARSE_MANIFEST:
146 __pStep = new (std::nothrow) ManifestXmlStep();
147 TryReturn(__pStep, false, "[osp-installer] ManifestXmlStep is failed.");
150 case INSTALLER_STEP_PARSE_SIGNATURE:
151 __pStep = new (std::nothrow) SignatureStep();
152 TryReturn(__pStep, false, "[osp-installer] SignatureStep is failed.");
155 case INSTALLER_STEP_UNINSTALL:
156 __pStep = new (std::nothrow) UninstallStep();
157 TryReturn(__pStep, false, "[osp-installer] UninstallStep is failed.");
160 case INSTALLER_STEP_LICENSE:
161 __pStep = new (std::nothrow) LicenseStep();
162 TryReturn(__pStep, false, "[osp-installer] LicenseStep is failed.");
165 case INSTALLER_STEP_DRM:
166 __pStep = new (std::nothrow) DrmStep();
167 TryReturn(__pStep, false, "[osp-installer] DrmStep is failed.");
170 case INSTALLER_STEP_END:
182 InstallationContext::Run(void)
184 InstallerError error = INSTALLER_ERROR_NONE;
185 AppLogTag(OSP_INSTALLER, "InstallationContext::Run()");
190 InstallationContext::GetCurrentInstallationStep(void)
196 InstallationContext::SetCurrentInstallationStep(InstallationStep step)
202 InstallationContext::GetError(void)
208 InstallationContext::SetError(InstallerError installerError)
210 __error = installerError;
214 InstallationContext::GetState(void)
220 InstallationContext::SetState(InstallationState installationState)
222 __state = installationState;
226 InstallationContext::GetStep(void)
232 InstallationContext::SetInputPath(const Tizen::Base::String& path)
238 InstallationContext::GetInputPath(void) const
244 InstallationContext::SetInstallerOperation(InstallerOperation op)
250 InstallationContext::GetInstallerOperation(void) const
256 InstallationContext::IsContinue(void)
262 InstallationContext::SetContinue(bool cont)
268 InstallationContext::IsPreloaded(void)
274 InstallationContext::SetPreloaded(bool preloaded)
276 __preloaded = preloaded;
280 InstallationContext::IsHybridService(void)
282 return __hybridService;
286 InstallationContext::SetHybridService(bool hybridService)
288 __hybridService = hybridService;
292 InstallationContext::IsVerificationMode(void)
294 return __verificationMode;
298 InstallationContext::SetVerificationMode(bool verificationMode)
300 __verificationMode = verificationMode;
304 InstallationContext::GetPackagePath(void) const
306 return __packagePath;
310 InstallationContext::SetPackagePath(const String& packagePath)
312 __packagePath = packagePath;
316 InstallationContext::GetLicensePath(void) const
318 return __licensePath;
322 InstallationContext::SetLicensePath(const String& licensePath)
324 __licensePath = licensePath;
328 InstallationContext::GetTemporaryDir(void) const
330 return __temporaryDir;
334 InstallationContext::SetTemporaryDir(const String& temporaryDir)
336 __temporaryDir = temporaryDir;
340 InstallationContext::GetInstallDir(void) const
346 InstallationContext::SetInstallDir(const String& installDir)
348 __installDir = installDir;
352 InstallationContext::GetWorkingDir(void) const
358 InstallationContext::SetWorkingDir(const String& workingDir)
360 __workingDir = workingDir;
364 InstallationContext::SetInstallationStorage(InstallationStorage storage)
369 InstallationContext::InstallationStorage
370 InstallationContext::GetInstallationStorage(void) const
376 InstallationContext::GetId(void) const
382 InstallationContext::SetId(const PackageId& packageId)
384 __packageId = packageId;
388 InstallationContext::GetAppVersion(void) const
394 InstallationContext::SetAppVersion(const String& appVersion)
396 __appVersion = appVersion;
400 InstallationContext::GetManifestXmlPath(void)
404 path = GetInstallDir() + PACKAGE_XML_FILE;
410 InstallationContext::GetSignatureXmlPath(void)
414 path = GetInstallDir() + SIGNATURE1_XML_FILE;
420 InstallationContext::GetAuthorSignatureXmlPath(void)
424 path = GetInstallDir() + AUTHOR_SIGNATURE_XML_FILE;
430 InstallationContext::GetPrivilegeList(void) const
432 return __pPrivilegeList;
436 InstallationContext::SetPrivilegeList(ArrayList* privilegeList)
438 __pPrivilegeList = privilegeList;
442 InstallationContext::GetLiveboxDataList(void) const
444 return __pLiveboxDataList;
448 InstallationContext::SetLiveboxDataList(ArrayList* pLiveboxDataList)
450 __pLiveboxDataList = pLiveboxDataList;
454 InstallationContext::GetContentDataList(void) const
456 return __pContentDataList;
460 InstallationContext::SetContentDataList(ArrayList* pContentDataList)
462 __pContentDataList = pContentDataList;
466 InstallationContext::GetAuthorCertPath(void) const
468 return __pAuthorCertPath;
472 InstallationContext::SetAuthorCertPath(X509CertificatePath* pAuthorCertPath)
474 __pAuthorCertPath = pAuthorCertPath;
478 InstallationContext::GetDistributorCertPath(void) const
480 return __pDistributorCertPath;
484 InstallationContext::SetDistributorCertPath(X509CertificatePath* pDistributorCertPath)
486 __pDistributorCertPath = pDistributorCertPath;
490 InstallationContext::GetRootCertType(void) const
492 return __rootCertType;
496 InstallationContext::SetRootCertType(RootCertificateType certType)
498 __rootCertType = certType;
502 InstallationContext::GetPackageNameType(void) const
504 return __packageNameType;
508 InstallationContext::SetPackageNameType(int type)
510 __packageNameType = type;
514 InstallationContext::GetApp2ExtHandle(void) const
516 return __pApp2ExtHandle;
520 InstallationContext::SetApp2ExtHandle(app2ext_handle* pHandle)
522 __pApp2ExtHandle = pHandle;
526 InstallationContext::GetPackageInfoImpl(void) const
528 return __pPackageInfoImpl;