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 <FApp_PackageInfoImpl.h>
34 using namespace Osp::Base;
35 using namespace Osp::Base::Collection;
36 using namespace Osp::Io;
37 using namespace Osp::Security::Cert;
38 using namespace Osp::App;
40 InstallationContext::InstallationContext(void)
43 ,__error(INSTALLER_ERROR_NONE)
44 ,__step(INSTALLER_STEP_NONE)
46 ,__state(INSTALLER_STATE_RUNNING)
50 ,__hybridService(false)
51 ,__verificationMode(false)
52 ,__operation(INSTALLER_OPERATION_INSTALL)
53 ,__storage(INSTALLATION_STORAGE_INTERNAL)
54 ,__pPrivilegeList(null)
56 ,__pContentInfoList(null)
57 ,__pAuthorCertPath(null)
58 ,__pDistributorCertPath(null)
59 ,__rootCertType(ROOT_CERTIFICATE_NONE)
60 ,__packageNameType(INSTALLER_PREFIX_TYPE_NONE)
61 ,__pApp2ExtHandle(null)
62 ,__pPackageInfoImpl(null)
66 InstallationContext::~InstallationContext(void)
74 delete __pAuthorCertPath;
75 __pAuthorCertPath = null;
77 delete __pDistributorCertPath;
78 __pDistributorCertPath = null;
82 __pPrivilegeList->RemoveAll();
83 delete __pPrivilegeList;
84 __pPrivilegeList = null;
89 __pLiveBoxList->RemoveAll();
90 delete __pLiveBoxList;
91 __pLiveBoxList = null;
96 InstallationContext::Construct(void)
98 __pPackageInfoImpl = new _PackageInfoImpl();
99 TryReturn(__pPackageInfoImpl, INSTALLER_ERROR_MEMORY, "[osp-installer] __pPackageInfoImpl is null.");
101 return INSTALLER_ERROR_NONE;
105 InstallationContext::ChangeStep(InstallationStep step)
112 case INSTALLER_STEP_NONE:
115 case INSTALLER_STEP_INIT:
118 case INSTALLER_STEP_CHECK_SYSTEM:
119 __pStep = new SystemCheckStep();
120 TryReturn(__pStep, false, "[osp-installer] SystemCheckStep is failed.");
123 case INSTALLER_STEP_CHECK_PACKAGE:
124 __pStep = new PackageCheckStep();
125 TryReturn(__pStep, false, "[osp-installer] PackageCheckStep is failed.");
128 case INSTALLER_STEP_UNPACK:
129 __pStep = new UnpackStep();
130 TryReturn(__pStep, false, "[osp-installer] UnpackStep is failed.");
133 case INSTALLER_STEP_PARSE_MANIFEST:
134 __pStep = new ManifestXmlStep();
135 TryReturn(__pStep, false, "[osp-installer] ManifestXmlStep is failed.");
138 case INSTALLER_STEP_PARSE_SIGNATURE:
139 __pStep = new SignatureStep();
140 TryReturn(__pStep, false, "[osp-installer] SignatureStep is failed.");
143 case INSTALLER_STEP_UNINSTALL:
144 __pStep = new UninstallStep();
145 TryReturn(__pStep, false, "[osp-installer] UninstallStep is failed.");
148 case INSTALLER_STEP_LICENSE:
149 __pStep = new LicenseStep();
150 TryReturn(__pStep, false, "[osp-installer] LicenseStep is failed.");
153 case INSTALLER_STEP_DRM:
154 __pStep = new DrmStep();
155 TryReturn(__pStep, false, "[osp-installer] DrmStep is failed.");
158 case INSTALLER_STEP_END:
170 InstallationContext::Run(void)
172 InstallerError error = INSTALLER_ERROR_NONE;
173 AppLogTag(OSP_INSTALLER, "InstallationContext::Run()");
178 InstallationContext::GetCurrentInstallationStep(void)
184 InstallationContext::SetCurrentInstallationStep(InstallationStep step)
190 InstallationContext::GetError(void)
196 InstallationContext::SetError(InstallerError installerError)
198 __error = installerError;
202 InstallationContext::GetState(void)
208 InstallationContext::SetState(InstallationState installationState)
210 __state = installationState;
214 InstallationContext::GetStep(void)
220 InstallationContext::SetInputPath(const Osp::Base::String& path)
226 InstallationContext::GetInputPath(void) const
232 InstallationContext::SetInstallerOperation(InstallerOperation op)
238 InstallationContext::GetInstallerOperation(void) const
244 InstallationContext::IsContinue(void)
250 InstallationContext::SetContinue(bool cont)
256 InstallationContext::IsPreloaded(void)
262 InstallationContext::SetPreloaded(bool preloaded)
264 __preloaded = preloaded;
268 InstallationContext::IsHybridService(void)
270 return __hybridService;
274 InstallationContext::SetHybridService(bool hybridService)
276 __hybridService = hybridService;
280 InstallationContext::IsVerificationMode(void)
282 return __verificationMode;
286 InstallationContext::SetVerificationMode(bool verificationMode)
288 __verificationMode = verificationMode;
292 InstallationContext::GetPackagePath(void) const
294 return __packagePath;
298 InstallationContext::SetPackagePath(const String& packagePath)
300 __packagePath = packagePath;
304 InstallationContext::GetLicensePath(void) const
306 return __licensePath;
310 InstallationContext::SetLicensePath(const String& licensePath)
312 __licensePath = licensePath;
316 InstallationContext::GetTemporaryDir(void) const
318 return __temporaryDir;
322 InstallationContext::SetTemporaryDir(const String& temporaryDir)
324 __temporaryDir = temporaryDir;
328 InstallationContext::GetInstallDir(void) const
334 InstallationContext::SetInstallDir(const String& installDir)
336 __installDir = installDir;
340 InstallationContext::GetWorkingDir(void) const
346 InstallationContext::SetWorkingDir(const String& workingDir)
348 __workingDir = workingDir;
352 InstallationContext::SetInstallationStorage(InstallationStorage storage)
357 InstallationContext::InstallationStorage
358 InstallationContext::GetInstallationStorage(void) const
364 InstallationContext::GetAppId(void) const
370 InstallationContext::SetAppId(const String& appId)
376 InstallationContext::GetAppVersion(void) const
382 InstallationContext::SetAppVersion(const String& appVersion)
384 __appVersion = appVersion;
388 InstallationContext::GetManifestXmlPath(void)
392 path = GetInstallDir() + PACKAGE_XML_FILE;
398 InstallationContext::GetSignatureXmlPath(void)
402 path = GetInstallDir() + SIGNATURE1_XML_FILE;
408 InstallationContext::GetAuthorSignatureXmlPath(void)
412 path = GetInstallDir() + AUTHOR_SIGNATURE_XML_FILE;
418 InstallationContext::GetPrivilegeList(void) const
420 return __pPrivilegeList;
424 InstallationContext::SetPrivilegeList(ArrayList* privilegeList)
426 __pPrivilegeList = privilegeList;
430 InstallationContext::GetLiveBoxList(void) const
432 return __pLiveBoxList;
436 InstallationContext::SetLiveBoxList(ArrayList* pLiveBoxList)
438 __pLiveBoxList = pLiveBoxList;
442 InstallationContext::GetContentInfoList(void) const
444 return __pContentInfoList;
448 InstallationContext::SetContentInfoList(ArrayList* pContentInfoList)
450 __pContentInfoList = pContentInfoList;
454 InstallationContext::GetAuthorCertPath(void) const
456 return __pAuthorCertPath;
460 InstallationContext::SetAuthorCertPath(X509CertificatePath* pAuthorCertPath)
462 __pAuthorCertPath = pAuthorCertPath;
466 InstallationContext::GetDistributorCertPath(void) const
468 return __pDistributorCertPath;
472 InstallationContext::SetDistributorCertPath(X509CertificatePath* pDistributorCertPath)
474 __pDistributorCertPath = pDistributorCertPath;
478 InstallationContext::GetRootCertType(void) const
480 return __rootCertType;
484 InstallationContext::SetRootCertType(RootCertificateType certType)
486 __rootCertType = certType;
490 InstallationContext::GetPackageNameType(void) const
492 return __packageNameType;
496 InstallationContext::SetPackageNameType(int type)
498 __packageNameType = type;
502 InstallationContext::GetApp2ExtHandle(void) const
504 return __pApp2ExtHandle;
508 InstallationContext::SetApp2ExtHandle(app2ext_handle* pHandle)
510 __pApp2ExtHandle = pHandle;
514 InstallationContext::GetPackageInfoImpl(void) const
516 return __pPackageInfoImpl;
519 LiveboxInfo::LiveboxInfo(void)
524 __pNameList = new (std::nothrow) HashMap;
525 TryReturn(__pNameList, , "[osp-installer] __pNameList is null.");
526 __pNameList->Construct();
528 __pSizeList = new (std::nothrow) ArrayList;
529 TryReturn(__pSizeList, , "[osp-installer] __pSizeList is null.");
530 __pSizeList->Construct();
533 LiveboxInfo::~LiveboxInfo(void)
535 __pNameList->RemoveAll(true);
538 __pSizeList->RemoveAll(true);
543 LiveboxInfo::SetUpdatePeriod(long long period)
545 __updatePeriod = period;
550 LiveboxInfo::GetUpdatePeriod(void) const
552 return __updatePeriod;
556 LiveboxInfo::SetPopupEnabled(const String& value)
558 __popupEnabled = value;
563 LiveboxInfo::GetPopupEnabled(void) const
565 return __popupEnabled;
569 LiveboxInfo::SetIcon(const String& icon)
576 LiveboxInfo::GetIcon(void) const
582 LiveboxInfo::AddName(const String& language, const String& name)
584 result r = E_SUCCESS;
586 r = __pNameList->Add(language, name);
592 LiveboxInfo::GetNameList(void) const
598 LiveboxInfo::AddSize(const String& size)
600 result r = E_SUCCESS;
602 r = __pSizeList->Add(size);
608 LiveboxInfo::GetSizeList(void) const
613 ContentInfo::ContentInfo(void)
616 __pNameList = new (std::nothrow) HashMap;
617 TryReturn(__pNameList, , "[osp-installer] __pNameList is null.");
618 __pNameList->Construct();
621 ContentInfo::~ContentInfo(void)
623 __pNameList->RemoveAll(true);
628 ContentInfo::SetContentId(const String& contentId)
630 __contentId = contentId;
635 ContentInfo::GetContentId(void) const
641 ContentInfo::SetIcon(const String& icon)
648 ContentInfo::GetIcon(void) const
654 ContentInfo::AddName(const String& language, const String& name)
656 result r = E_SUCCESS;
658 r = __pNameList->Add(language, name);
664 ContentInfo::GetNameList(void) const