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 PackageCheckStep.cpp
19 * @brief This is the implementation file for %PackageCheckStep class.
23 #include <FIoDirectory.h>
25 #include "InstallationContext.h"
26 #include "PackageCheckStep.h"
27 #include "InstallerUtil.h"
29 using namespace Osp::Base;
30 using namespace Osp::Base::Utility;
31 using namespace Osp::Io;
33 PackageCheckStep::PackageCheckStep(void)
34 :__state(STATE_PACKAGE_CHECK)
39 PackageCheckStep::~PackageCheckStep(void)
44 PackageCheckStep::Run(InstallationContext* pContext)
46 InstallerError error = INSTALLER_ERROR_NONE;
47 AppLogTag(OSP_INSTALLER, "------------------------------------------");
48 AppLogTag(OSP_INSTALLER, " PackageCheckStep - START");
49 AppLogTag(OSP_INSTALLER, "------------------------------------------");
51 __pContext = pContext;
57 case STATE_PACKAGE_CHECK:
58 AppLogTag(OSP_INSTALLER, "[STATE_PACKAGE_CHECK]");
59 error = OnStatePackageCheck();
63 AppLogTag(OSP_INSTALLER, "[STATE_DONE]");
64 error = OnStateDone();
71 if (error != INSTALLER_ERROR_NONE)
73 fprintf(stderr, "PackageCheckStep::Run - ErrorType [%d]\n", error);
77 if (__state > STATE_DONE)
79 AppLogTag(OSP_INSTALLER, "------------------------------------------");
80 AppLogTag(OSP_INSTALLER, " PackageCheckStep - END");
81 AppLogTag(OSP_INSTALLER, "------------------------------------------");
90 PackageCheckStep::GoNextState(void)
96 PackageCheckStep::OnStatePackageCheck(void)
98 InstallerError error = INSTALLER_ERROR_NONE;
101 if (__pContext->GetInstallationStorage() == InstallationContext::INSTALLATION_STORAGE_INTERNAL)
103 tempDir = DIR_OSP_APPLICATIONS_TEMP;
107 tempDir = DIR_MEMORYCARD_OSP_APPLICATIONS_TEMP;
110 __pContext->SetTemporaryDir(tempDir);
111 __pContext->SetInstallDir(tempDir);
113 if (File::IsFileExist(DIR_OSP_APPLICATIONS_TEMP) == false)
115 result r = E_SUCCESS;
116 r = Directory::Create(DIR_OSP_APPLICATIONS_TEMP, false);
117 TryReturn(!IsFailed(r), INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] Directory::Create() failed");
120 String packagePath = __pContext->GetPackagePath();
121 if (InstallerUtil::IsDrmFile(packagePath) == true)
124 res = InstallerUtil::DecryptPackage(packagePath);
125 TryReturn(res == true, INSTALLER_ERROR_DRM, "[osp-installer] InstallerUtil::DecryptPackage() failed");
128 FileUnzipper unzipper;
129 unzipper.Construct(packagePath);
131 AppLogTag(OSP_INSTALLER, "UnzipTo(manifest.xml) - START");
132 unzipper.UnzipTo(tempDir, L"info/manifest.xml");
133 unzipper.UnzipTo(tempDir, L"signature1.xml");
134 unzipper.UnzipTo(tempDir, L"author-signature.xml");
135 AppLogTag(OSP_INSTALLER, "UnzipTo(manifest.xml) - END");
137 if ((File::IsFileExist(__pContext->GetSignatureXmlPath()) == true) &&
138 (File::IsFileExist(__pContext->GetAuthorSignatureXmlPath()) == true))
140 AppLogTag(OSP_INSTALLER, "[VerifySignature] VerificationMode ON");
141 __pContext->SetVerificationMode(true);
149 PackageCheckStep::OnStateDone(void)
151 InstallerError error = INSTALLER_ERROR_NONE;