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 DirectoryInstaller.cpp
19 * @brief This is the implementation file for %DirectoryInstaller class.
23 #include <FIoDirectory.h>
24 #include <FIo_FileImpl.h>
26 #include "DirectoryInstaller.h"
27 #include "InstallerUtil.h"
29 using namespace Tizen::Base;
30 using namespace Tizen::Io;
32 DirectoryInstaller::DirectoryInstaller(void)
36 DirectoryInstaller::~DirectoryInstaller(void)
41 DirectoryInstaller::GetNext(InstallationStep step)
43 if (step == INSTALLER_STEP_NONE)
45 return INSTALLER_STEP_INIT;
47 else if (step == INSTALLER_STEP_INIT)
49 return INSTALLER_STEP_PARSE_MANIFEST;
51 else if (step == INSTALLER_STEP_PARSE_MANIFEST)
53 return INSTALLER_STEP_CHECK_SYSTEM;
55 else if (step == INSTALLER_STEP_CHECK_SYSTEM)
57 return INSTALLER_STEP_PARSE_SIGNATURE;
59 else if (step == INSTALLER_STEP_PARSE_SIGNATURE)
61 return INSTALLER_STEP_END;
65 step = (InstallationStep)(step + 1);
71 DirectoryInstaller::OnInit(void)
73 InstallationContext* pContext = GetContext();
75 if ((File::IsFileExist(pContext->GetSignatureXmlPath()) == true) &&
76 (File::IsFileExist(pContext->GetAuthorSignatureXmlPath()) == true))
78 AppLog("[VerifySignature] VerificationMode ON");
79 pContext->__isVerificationMode = true;
82 String installPath = pContext->__installDir;
84 String newInstallPath;
85 InstallerUtil::CreateSymlinkForAppDirectory(installPath, newInstallPath);
86 pContext->__installDir = newInstallPath;
87 pContext->__rootPath = newInstallPath;
89 // remove in /info/*.info files
92 AppLog("installation path = [%ls]", newInstallPath.GetPointer());
94 return Installer::OnInit();
98 DirectoryInstaller::OnRegister(void)
100 AppLog("DirectoryInstaller::OnRegister()");
101 return Installer::OnRegister();
105 DirectoryInstaller::OnEnd(void)
107 AppLog("DirectoryInstaller::OnEnd()");
108 return Installer::OnEnd();
112 DirectoryInstaller::OnError(void)
114 AppLog("DirectoryInstaller::OnError()");
115 return Installer::OnError();
119 DirectoryInstaller::OnRollback(void)
121 AppLog("DirectoryInstaller::OnRollback()");
122 return Installer::OnRollback();
126 DirectoryInstaller::OnUserCancel(void)
128 AppLog("DirectoryInstaller::OnUserCancel()");
129 return Installer::OnUserCancel();
133 DirectoryInstaller::RemoveInfoFiles(void)
135 Directory* pDir = null;
136 DirEnumerator* pDirEnum = null;
137 result r = E_SUCCESS;
141 InstallationContext* pContext = null;
143 pContext = GetContext();
144 TryCatch(pContext, res = false, "pContext is null");
146 path = pContext->__rootPath + DIR_INFO;
148 pDir = new (std::nothrow) Directory; // Allocate %Directory instance
149 TryCatch(pDir, res = false, "pDir is null");
151 r = pDir->Construct(path);
152 TryCatch(!IsFailed(r), res = false, "pDir->Construct() failed, path = [%ls]", path.GetPointer());
154 pDirEnum = pDir->ReadN();
155 TryCatch(pDirEnum, res = false, "pDirEnum is null");
157 while (pDirEnum->MoveNext() == E_SUCCESS)
159 DirEntry entry = pDirEnum->GetCurrentDirEntry();
161 String entryName = entry.GetName();
162 String entryDir = path;
164 entryDir += entryName;
166 if (entryName == L"." || entryName == L"..")
172 if ((_FileImpl::GetFileExtension(entryDir) == FILE_EXT_INFO) ||
173 (entry.IsDirectory() == true))
175 AppLog("Request to delete info file = [%ls]", entryDir.GetPointer());
176 InstallerUtil::Remove(entryDir);