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 PreloadedInstaller.cpp
19 * @brief This is the implementation file for %PreloadedInstaller class.
23 #include <FIoDirectory.h>
26 #include "PreloadedInstaller.h"
27 #include "InstallerUtil.h"
29 using namespace Tizen::Base;
30 using namespace Tizen::Io;
32 PreloadedInstaller::PreloadedInstaller(void)
36 PreloadedInstaller::~PreloadedInstaller(void)
41 PreloadedInstaller::GetNext(InstallationStep step)
43 return DirectoryInstaller::GetNext(step);
47 PreloadedInstaller::OnInit(void)
49 InstallationContext* pContext = GetContext();
50 String path = pContext->__inputPath;
52 String prefix(PATH_USR_APPS);
55 path.SubString(prefix.GetLength(), PACKAGE_ID_LENGTH, appId);
58 String versionFile = path + VERSION_INFO_FILE;
59 if (File::IsFileExist(versionFile) == true)
61 AppLog("install preloaded app again.")
62 pContext->__isUpdated = true;
65 String destRootPath(PATH_OPT_USR_APPS);
67 destRootPath += appId;
69 Directory::Create(destRootPath);
75 srcPath = path + DIR_SETTING;
76 destPath = destRootPath + DIR_SETTING;
77 InstallerUtil::CopyDirectory(srcPath, destPath);
80 srcPath = path + DIR_DATA;
81 destPath = destRootPath + DIR_DATA;
82 InstallerUtil::CopyDirectory(srcPath, destPath);
84 srcPath = path + DIR_INFO;
85 destPath = destRootPath + DIR_INFO;
86 InstallerUtil::CreateSymlink(srcPath, destPath);
88 srcPath = path + DIR_BIN;
89 destPath = destRootPath + DIR_BIN;
90 InstallerUtil::CreateSymlink(srcPath, destPath);
92 srcPath = path + DIR_RES;
93 destPath = destRootPath + DIR_RES;
94 InstallerUtil::CreateSymlink(srcPath, destPath);
96 srcPath = path + DIR_LIB;
97 destPath = destRootPath + DIR_LIB;
98 InstallerUtil::CreateSymlink(srcPath, destPath);
100 srcPath = path + DIR_SHARED;
101 destPath = destRootPath + DIR_SHARED;
102 if (File::IsFileExist(srcPath) == true)
104 InstallerUtil::CopyDirectory(srcPath, destPath);
108 Directory::Create(destPath);
113 if (File::IsFileExist(destPath) == false)
115 srcPath = path + DIR_ICONS;
116 InstallerUtil::CreateSymlink(srcPath, destPath);
119 pContext->__installDir = pContext->__inputPath;
120 if ((File::IsFileExist(pContext->GetSignatureXmlPath()) == true) &&
121 (File::IsFileExist(pContext->GetAuthorSignatureXmlPath()) == true))
123 srcPath = path + SIGNATURE1_XML_FILE;
124 destPath = destRootPath + SIGNATURE1_XML_FILE;
125 InstallerUtil::CreateSymlink(srcPath, destPath);
127 srcPath = path + AUTHOR_SIGNATURE_XML_FILE;
128 destPath = destRootPath + AUTHOR_SIGNATURE_XML_FILE;
129 InstallerUtil::CreateSymlink(srcPath, destPath);
131 AppLog("[VerifySignature] VerificationMode ON");
132 pContext->__isVerificationMode = true;
135 pContext->__installDir = destRootPath;
137 return DirectoryInstaller::OnInit();
141 PreloadedInstaller::OnRegister(void)
143 return DirectoryInstaller::OnRegister();
147 PreloadedInstaller::OnEnd(void)
149 return DirectoryInstaller::OnEnd();
153 PreloadedInstaller::OnError(void)
155 AppLog("PreloadedInstaller::OnError()");
156 return DirectoryInstaller::OnError();
160 PreloadedInstaller::OnRollback(void)
162 AppLog("PreloadedInstaller::OnRollback()");
163 return DirectoryInstaller::OnRollback();
167 PreloadedInstaller::OnUserCancel(void)
169 AppLog("PreloadedInstaller::OnUserCancel()");
170 return DirectoryInstaller::OnUserCancel();