#define DIR_ICONS L"/icons"
#define DIR_LIB L"/lib"
#define DIR_SETTING L"/setting"
+#define DIR_CONTENTS L"/contents"
#define SLP_DIR_BIN L"/bin"
#define SLP_DIR_RES L"/res"
#define SLP_DIR_DATA L"/data"
#define SLP_APP_PATH L"/opt/apps"
+#define SLP_FONT_PATH L"/opt/share/fonts"
+
#define DIR_DESKTOP L"/opt/share/applications/%S.desktop"
#define PACKAGE_NAME_PREFIX_ORG L"org.tizen."
#define PACKAGE_NAME_RULE_ORG L"org.tizen.%ls#%s"
#define TYPE_INFO_FILE L"/info/type.info"
#define PACKAGE_XML_FILE L"/info/manifest.xml"
-#define SIGNATURE1_XML_FILE L"/signature1.xml"
-#define AUTHOR_SIGNATURE_XML_FILE L"/author-signature.xml"
+#define SIGNATURE1_XML_FILE L"/signature1.xml"
+#define AUTHOR_SIGNATURE_XML_FILE L"/author-signature.xml"
#define UISCALABILITY_INFO L"1 %ls %ls %ls"
#define DIR_MEMORYCARD_OSP_APPLICATIONS_TEMP L"/opt/storage/sdcard/apps/__@@osp_tmp@@__"
#define OSP_INSTALLER "osp-installer"
-#define OSP_INSTALLER_VERSION "osp-installer version = 2012/10/24"
+#define OSP_INSTALLER_VERSION "osp-installer version = 2012/10/29"
enum InstallationSetStep
{
,__storage(INSTALLATION_STORAGE_INTERNAL)
,__pPrivilegeList(null)
,__pLiveBoxList(null)
+,__pContentInfoList(null)
,__pAuthorCertPath(null)
,__pDistributorCertPath(null)
,__rootCertType(ROOT_CERTIFICATE_NONE)
__pLiveBoxList = pLiveBoxList;
}
+ArrayList*
+InstallationContext::GetContentInfoList(void) const
+{
+ return __pContentInfoList;
+}
+
+void
+InstallationContext::SetContentInfoList(ArrayList* pContentInfoList)
+{
+ __pContentInfoList = pContentInfoList;
+}
+
X509CertificatePath*
InstallationContext::GetAuthorCertPath(void) const
{
{
return __pSizeList;
}
+
+ContentInfo::ContentInfo(void)
+:__pNameList(null)
+{
+ __pNameList = new (std::nothrow) HashMap;
+ TryReturn(__pNameList, , "[osp-installer] __pNameList is null.");
+ __pNameList->Construct();
+}
+
+ContentInfo::~ContentInfo(void)
+{
+ __pNameList->RemoveAll(true);
+ delete __pNameList;
+}
+
+result
+ContentInfo::SetContentId(const String& contentId)
+{
+ __contentId = contentId;
+ return E_SUCCESS;
+}
+
+const String&
+ContentInfo::GetContentId(void) const
+{
+ return __contentId;
+}
+
+result
+ContentInfo::SetIcon(const String& icon)
+{
+ __icon = icon;
+ return E_SUCCESS;
+}
+
+const String&
+ContentInfo::GetIcon(void) const
+{
+ return __icon;
+}
+
+result
+ContentInfo::AddName(const String& language, const String& name)
+{
+ result r = E_SUCCESS;
+
+ r = __pNameList->Add(language, name);
+
+ return r;
+}
+
+HashMap*
+ContentInfo::GetNameList(void) const
+{
+ return __pNameList;
+}
+
Osp::Base::Collection::ArrayList* GetLiveBoxList(void) const;
void SetLiveBoxList(Osp::Base::Collection::ArrayList* pLiveBoxList);
+ Osp::Base::Collection::ArrayList* GetContentInfoList(void) const;
+ void SetContentInfoList(Osp::Base::Collection::ArrayList* pContentInfoList);
+
Osp::Security::Cert::X509CertificatePath* GetAuthorCertPath(void) const;
void SetAuthorCertPath(Osp::Security::Cert::X509CertificatePath* pAuthorCertPath);
Osp::Base::Collection::ArrayList* __pPrivilegeList;
Osp::Base::Collection::ArrayList* __pLiveBoxList;
+ Osp::Base::Collection::ArrayList* __pContentInfoList;
Osp::Security::Cert::X509CertificatePath* __pAuthorCertPath;
Osp::Security::Cert::X509CertificatePath* __pDistributorCertPath;
RootCertificateType __rootCertType;
}; // LiveboxInfo
+class ContentInfo
+ : public Osp::Base::Object
+{
+public:
+ ContentInfo(void);
+ virtual ~ContentInfo(void);
+
+ result SetContentId(const Osp::Base::String& contentId);
+ const Osp::Base::String& GetContentId(void) const;
+
+ result SetIcon(const Osp::Base::String& icon);
+ const Osp::Base::String& GetIcon(void) const;
+
+ result AddName(const Osp::Base::String& language, const Osp::Base::String& name);
+ Osp::Base::Collection::HashMap* GetNameList(void) const;
+
+private:
+ ContentInfo(const ContentInfo& value);
+ ContentInfo& operator =(const ContentInfo& source);
+
+ Osp::Base::String __icon;
+ Osp::Base::String __contentId;
+
+ Osp::Base::Collection::HashMap* __pNameList;
+
+}; // ContentInfo
+
#endif // _INSTALLATION_CONTEXT_H_
char* pXmlPath = null;
int err = 0;
bool hybridService = pContext->IsHybridService();
+ ArrayList* pContentInfoList = null;
_PackageInfoImpl *pPackageInfoImpl = null;
pPackageInfoImpl = pContext->GetPackageInfoImpl();
}
}
- int res = -1;
- res = chmod(pBinaryPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
- if (res != 0)
- {
- AppLogTag(OSP_INSTALLER, "Fail to set permission(755)[%s], res=%d.\n", pBinaryPath, res);
- }
- else
- {
- AppLogTag(OSP_INSTALLER, "Success to set permission(755)[%s], res=%d.\n", pBinaryPath, res);
- }
+ InstallerUtil::ChangeMode(pBinaryPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
delete[] pBinaryPath;
pBinaryPath = null;
}
}
+ pContentInfoList = pContext->GetContentInfoList();
+ if (pContentInfoList)
+ {
+ int contentCount = pContentInfoList->GetCount();
+ for (int i = 0 ; i < contentCount; i++)
+ {
+ ContentInfo* pContentInfo = static_cast<ContentInfo*>(pContentInfoList->GetAt(i));
+ if (pContentInfo)
+ {
+ String contentId = pContentInfo->GetContentId();
+ String oldPath = rootPath + DIR_CONTENTS + L"/" + contentId;
+
+ if (File::IsFileExist(SLP_FONT_PATH) == false)
+ {
+ Directory::Create(SLP_FONT_PATH, false);
+ InstallerUtil::ChangeMode(SLP_FONT_PATH, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+ }
+
+ String newPath = SLP_FONT_PATH;
+ newPath += L"/" + pContext->GetAppId();
+ Directory::Create(newPath, false);
+ InstallerUtil::ChangeMode(newPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+
+ newPath += L"/";
+ newPath += contentId;
+ InstallerUtil::CreateSymlink(oldPath, newPath);
+ }
+ }
+ }
+
//if (pContext->IsPreloaded() == true)
//{
// xmlPath.Format(1024, DIR_RO_PACKAGE_SYSTEM_MANIFEST, pContext->GetAppId().GetPointer());
{
}
-//bool
-//PermissionManager::ChangeOwner(const Osp::Base::String& filePath)
-//{
-// int res = -1;
-// char* pFilePath = null;
-//
-// pFilePath = _StringConverter::CopyToCharArrayN(filePath);
-// TryReturn(pFilePath, false, "[osp-installer] pFilePath is null");
-//
-// res = chown(pFilePath, APP_OWNER_ID, APP_GROUP_ID);
-// if (res != 0)
-// {
-// AppLogTag(OSP_INSTALLER, "Fail to change owner[%s], res=[%d]", pFilePath, res);
-// }
-//
-// delete[] pFilePath;
-//
-// return true;
-//}
-
bool
PermissionManager::ChangeHomeDirectoryOwner(const String& rootPath, int depth)
{
return true;
}
-//bool
-//PermissionManager::ChangeMode(const String& filePath, int mode)
-//{
-// int res = -1;
-// char* pFilePath = null;
-//
-// pFilePath = _StringConverter::CopyToCharArrayN(filePath);
-// TryReturn(pFilePath, false, "[osp-installer] pFilePath is null");
-//
-// res = chmod(pFilePath, mode);
-// if (res != 0)
-// {
-// AppLogTag(OSP_INSTALLER, "Fail to change mode, path=[%s], mode=[%o], res=[%d]", pFilePath, mode, res);
-// }
-//
-// delete[] pFilePath;
-//
-// return true;
-//}
-
bool
PermissionManager::SetDirectory(InstallationContext* pContext)
{
- char destPath[772] = {0};
- int res = -1;
- int err = 0;
+ result r = E_SUCCESS;
+
+ String destPath;
String appRootPath;
_PackageInfoImpl *pPackageInfoImpl = null;
FileAttributes attribute;
- result r = E_SUCCESS;
pPackageInfoImpl = pContext->GetPackageInfoImpl();
appRootPath = pPackageInfoImpl->GetAppRootPath();
- // set permission(755) to default folders(AppRootPath)
- sprintf(destPath, "%ls", appRootPath.GetPointer());
- r = File::GetAttributes(destPath, attribute);
- if (r == E_SUCCESS)
- {
- res = chmod(destPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
- if (res != 0)
- {
- AppLogTag(OSP_INSTALLER, "Fail to set permission(755)[%s], res=[%d].\n", destPath, res);
- }
- else
- {
- AppLogTag(OSP_INSTALLER, "Success to set permission(755)[%s], res=%d.\n", destPath, res);
- }
- }
+ // appRoot(rx for app)
+ InstallerUtil::ChangeOwner(appRootPath);
+ InstallerUtil::ChangeMode(appRootPath, S_IRUSR | S_IXUSR);
- // set permission(755) to default folders(BIN, INFO, DATA, RES)
- sprintf(destPath, "%ls%ls", appRootPath.GetPointer(), DIR_BIN);
- r = File::GetAttributes(destPath, attribute);
- if (r == E_SUCCESS)
- {
- res = chmod(destPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
- if (res)
- {
- AppLogTag(OSP_INSTALLER, "Fail to set permission(755)[%s], res=%d.\n", destPath, res);
- }
- else
- {
- AppLogTag(OSP_INSTALLER, "Success to set permission(755)[%s], res=%d.\n", destPath, res);
- }
- }
+ // appRoot/bin(no permission for app)
+ destPath = appRootPath + DIR_BIN;
+ InstallerUtil::ChangeDirectoryPermission(destPath, S_IRUSR | S_IXUSR);
- sprintf(destPath, "%ls%ls", appRootPath.GetPointer(), DIR_INFO);
- r = File::GetAttributes(destPath, attribute);
- if (r == E_SUCCESS)
- {
- res = chmod(destPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
- if (res != 0)
- {
- AppLogTag(OSP_INSTALLER, "Fail to set permission(755)[%s], res=%d.\n", destPath, res);
- }
- else
- {
- AppLogTag(OSP_INSTALLER, "Success to set permission(755)[%s], res=%d.\n", destPath, res);
- }
- }
+ // appRoot/info(rx for app)
+ destPath = appRootPath + DIR_INFO;
+ InstallerUtil::ChangeDirectoryPermission(destPath, S_IRUSR | S_IXUSR);
- sprintf(destPath, "%ls%ls", appRootPath.GetPointer(), DIR_RES);
- r = File::GetAttributes(destPath, attribute);
- if (r == E_SUCCESS)
- {
- ChangeHomeDirectoryOwner(destPath, 0);
- InstallerUtil::ChangeMode(destPath, S_IRUSR | S_IXUSR);
- }
+ // appRoot/res(rx for app)
+ destPath = appRootPath + DIR_RES;
+ InstallerUtil::ChangeDirectoryPermission(destPath, S_IRUSR | S_IXUSR);
- sprintf(destPath, "%ls%ls", appRootPath.GetPointer(), DIR_DATA);
- r = File::GetAttributes(destPath, attribute);
- if (r == E_SUCCESS)
- {
- res = chmod(destPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
- if (res != 0)
- {
- AppLogTag(OSP_INSTALLER, "Fail to set permission(755)[%s], res=%d.\n", destPath, res);
- }
- else
- {
- AppLogTag(OSP_INSTALLER, "Success to set permission(755)[%s], res=%d.\n", destPath, res);
- }
- }
+ // appRoot/lib(rwx for app)
+ destPath = appRootPath + DIR_LIB;
+ InstallerUtil::ChangeDirectoryPermission(destPath, S_IRUSR | S_IXUSR);
- sprintf(destPath, "%ls%ls", appRootPath.GetPointer(), DIR_LIB);
- r = File::GetAttributes(destPath, attribute);
- if (r == E_SUCCESS)
- {
- res = chmod(destPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
- if (res != 0)
- {
- AppLogTag(OSP_INSTALLER, "Fail to set permission(755)[%s], res=%d.\n", destPath, res);
- }
- else
- {
- AppLogTag(OSP_INSTALLER, "Success to set permission(755)[%s], res=%d.\n", destPath, res);
- }
- }
+ // appRoot/icons(rx for app)
+ destPath = appRootPath + DIR_ICONS;
+ InstallerUtil::ChangeDirectoryPermission(destPath, S_IRUSR | S_IXUSR);
- sprintf(destPath, "%ls%ls", appRootPath.GetPointer(), DIR_ICONS);
- r = File::GetAttributes(destPath, attribute);
- if (r == E_SUCCESS)
- {
- ChangeHomeDirectoryOwner(destPath, 0);
- InstallerUtil::ChangeMode(destPath, S_IRUSR | S_IWUSR | S_IXUSR);
- }
+ // appRoot/contents(rx for app)
+ destPath = appRootPath + DIR_CONTENTS;
+ InstallerUtil::ChangeDirectoryPermission(destPath, S_IRUSR | S_IXUSR);
- sprintf(destPath, "%ls%ls", appRootPath.GetPointer(), DIR_SETTING);
+ // appRoot/setting(rwx for app)
+ destPath = appRootPath + DIR_SETTING;
r = File::GetAttributes(destPath, attribute);
if (r == E_SUCCESS)
{
String appVersion = pPackageInfoImpl->GetAppVersion();
- char src[772] = {0};
- char dest[772] = {0};
-
- sprintf(src, "%s/%s.%ls.%s", destPath, "setting", appVersion.GetPointer(), "xml");
- sprintf(dest, "%s/%s", destPath, "setting.xml");
+ String srcPath;
+ String settingXmlPath;
- unlink(dest);
+ srcPath = destPath + L"/setting." + appVersion + L".xml";
+ settingXmlPath = destPath + L"/setting.xml";
- if (File::IsFileExist(src) == true)
- {
- err = symlink(src, dest);
- AppLogTag(OSP_INSTALLER, "[%s]->[%s]\n", dest, src);
- }
- else
- {
- AppLogTag(OSP_INSTALLER, "[%s] is not existed.\n", src);
- }
+ InstallerUtil::Remove(settingXmlPath);
+ InstallerUtil::CreateSymlink(srcPath, settingXmlPath);
- ChangeHomeDirectoryOwner(destPath, 0);
- InstallerUtil::ChangeMode(destPath, S_IRUSR | S_IWUSR | S_IXUSR);
+ InstallerUtil::ChangeDirectoryPermission(destPath, S_IRWXU);
}
- ApplyHomeDirectoryPolicy(appRootPath);
+ // appRoot/data(rwx for app)
+ destPath = appRootPath + DIR_DATA;
+ if (File::IsFileExist(destPath) == false)
+ {
+ r = Directory::Create(destPath, false);
+ TryReturn(!IsFailed(r), INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] Directory::Create() failed");
+ }
+ InstallerUtil::ChangeDirectoryPermission(destPath, S_IRWXU);
- String packageId = pContext->GetAppId();
+ String appId = pContext->GetAppId();
String apiVersion = pPackageInfoImpl->GetAppApiVersion();
- AppLogTag(OSP_INSTALLER, "Osp::Io > installed path: %ls, packageId: %ls, API version: %ls",
- appRootPath.GetPointer(), packageId.GetPointer(), apiVersion.GetPointer());
+ AppLogTag(OSP_INSTALLER, "Osp::Io > installed path: %ls, appId: %ls, API version: %ls",
+ appRootPath.GetPointer(), appId.GetPointer(), apiVersion.GetPointer());
if (apiVersion.CompareTo(L"3.0") < 0)
{
AppLogTag(OSP_INSTALLER, "Osp::Io > API version <= 2.0");
- if (_FileImpl::PrepareDataCaging(appRootPath, packageId) == false)
+ if (_FileImpl::PrepareDataCaging(appRootPath, appId) == false)
{
AppLogTag(OSP_INSTALLER, "Osp::Io > _FileImpl::PrepareDataCaging() failed");
return false;
{
AppLogTag(OSP_INSTALLER, "Osp::Io > API version >= 3.0");
- if (_FileImpl::CreateOspApplicationDirectories(appRootPath, packageId) == false)
+ if (_FileImpl::CreateOspApplicationDirectories(appRootPath, appId) == false)
{
AppLogTag(OSP_INSTALLER, "Osp::Io > _FileImpl::CreateOspApplicationDirectories() failed.");
return false;
}
}
+ // Create AppId.ExecutableName directory
+ // This will be removed.
CreateSystemDirectory(pContext, appRootPath);
return true;
bool
PermissionManager::SetFile(InstallationContext* pContext)
{
- char destPath[772] = {0};
- int res = -1;
+ String destPath;
_PackageInfoImpl *pPackageInfoImpl = null;
_PackageAppInfoImpl* pAppInfoImpl = null;
if (pAppInfoImpl)
{
// set permission(755) to bin file.
- sprintf(destPath, "%ls%ls/%ls", appRootPath.GetPointer(), DIR_BIN, (pAppInfoImpl->GetName()).GetPointer());
- strcat(destPath, ".exe");
- res = chmod(destPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
- if (res != 0)
- {
- AppLogTag(OSP_INSTALLER, "Fail to set permission(755)[%s], res=%d.\n", destPath, res);
- }
- else
- {
- AppLogTag(OSP_INSTALLER, "Success to set permission(755)[%s], res=%d.\n", destPath, res);
- }
+ // sprintf(destPath, "%ls%ls/%ls", appRootPath.GetPointer(), DIR_BIN, (pAppInfoImpl->GetName()).GetPointer());
+ // strcat(destPath, ".exe");
+ destPath = appRootPath + DIR_BIN + L"/" + pAppInfoImpl->GetName() + L".exe";
+ InstallerUtil::ChangeMode(destPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+ // res = chmod(destPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+// if (res != 0)
+// {
+// AppLogTag(OSP_INSTALLER, "Fail to set permission(755)[%s], res=%d.\n", destPath, res);
+// }
+// else
+// {
+// AppLogTag(OSP_INSTALLER, "Success to set permission(755)[%s], res=%d.\n", destPath, res);
+// }
}
}
_PackageInfoImpl *pPackageInfoImpl = null;
_PackageAppInfoImpl* pAppInfoImpl = null;
ArrayList* pAppList = null;
- int err = 0;
pPackageInfoImpl = pContext->GetPackageInfoImpl();
TryReturn(pPackageInfoImpl, false, "[osp-installer] pPackageInfoImpl is null.");
pAppInfoImpl = dynamic_cast<_PackageAppInfoImpl*>(pAppList->GetAt(i));
if (pAppInfoImpl)
{
- result r = E_SUCCESS;
- String packageName = pAppInfoImpl->GetPackageName();
- String destPath;
- String appRootPath;
- appRootPath = pPackageInfoImpl->GetAppRootPath();
- char src[772] = {0};
- char dest[772] = {0};
-
- destPath.Format(1024, L"%ls/%ls", SLP_APP_PATH, packageName.GetPointer());
-
- sprintf(src, "%ls", appRootPath.GetPointer());
- sprintf(dest, "%ls", destPath.GetPointer());
-
- unlink(dest);
-
- FileAttributes attr;
- r = File::GetAttributes(destPath, attr);
- if (r == E_SUCCESS)
- {
- InstallerUtil::Remove(destPath);
- AppLogTag(OSP_INSTALLER, "Directory is removed. [%ls]\n", destPath.GetPointer());
- }
-
- err = symlink(src, dest);
+ String destPath = SLP_APP_PATH;
+ destPath += L"/" + pAppInfoImpl->GetPackageName();
+
+ InstallerUtil::Remove(destPath);
+ InstallerUtil::CreateSymlink(pPackageInfoImpl->GetAppRootPath(), destPath);
}
}
bool
PermissionManager::SetSymLink(InstallationContext* pContext)
{
- char srcPath[772] = {0};
- char destPath[772] = {0};
- int err = 0;
- String appRootPath;
- _PackageInfoImpl *pPackageInfoImpl = null;
+ String oldPath;
+ String newPath;
- pPackageInfoImpl = pContext->GetPackageInfoImpl();
- appRootPath = pPackageInfoImpl->GetAppRootPath();
+ _PackageInfoImpl* pPackageInfoImpl = pContext->GetPackageInfoImpl();
+ String appRootPath = pPackageInfoImpl->GetAppRootPath();
- sprintf(srcPath, "%ls%ls", appRootPath.GetPointer(), DIR_RES);
- if (File::IsFileExist(srcPath) == true)
- {
- sprintf(destPath, "%ls%s", appRootPath.GetPointer(), "/Res");
- err = symlink("./res", destPath);
- }
+ oldPath = appRootPath + DIR_RES;
+ newPath = appRootPath + L"/Res";
+ InstallerUtil::CreateSymlink(oldPath, newPath);
- sprintf(srcPath, "%ls%ls", appRootPath.GetPointer(), DIR_DATA);
- if (File::IsFileExist(srcPath) == true)
- {
- sprintf(destPath, "%ls%s", appRootPath.GetPointer(), "/Home");
- err = symlink("./data", destPath);
- }
+ oldPath = appRootPath + DIR_DATA;
+ newPath = appRootPath + L"/Home";
+ InstallerUtil::CreateSymlink(oldPath, newPath);
- sprintf(srcPath, "%ls%s", appRootPath.GetPointer(), "/res/screen-size-normal");
- if (File::IsFileExist(srcPath) == true)
- {
- sprintf(destPath, "%ls%s", appRootPath.GetPointer(), "/Res/ScreenSize-Normal");
- err = symlink(srcPath, destPath);
- }
+ oldPath = appRootPath + DIR_RES + L"/screen-size-normal";
+ newPath = appRootPath + L"/Res/ScreenSize-Normal";
+ InstallerUtil::CreateSymlink(oldPath, newPath);
- sprintf(srcPath, "%ls%s", appRootPath.GetPointer(), "/res/screen-density-high");
- if (File::IsFileExist(srcPath) == true)
- {
- sprintf(destPath, "%ls%s", appRootPath.GetPointer(), "/Res/ScreenDensity-High");
- err = symlink(srcPath, destPath);
- }
+ oldPath = appRootPath + DIR_RES + L"screen-density-high";
+ newPath = appRootPath + L"/Res/ScreenDensity-High";
+ InstallerUtil::CreateSymlink(oldPath, newPath);
- sprintf(srcPath, "%ls%s", appRootPath.GetPointer(), "/res/screen-density-middle");
- if (File::IsFileExist(srcPath) == true)
- {
- sprintf(destPath, "%ls%s", appRootPath.GetPointer(), "/Res/ScreenDensity-Middle");
- err = symlink(srcPath, destPath);
- }
+ oldPath = appRootPath + DIR_RES + L"/screen-density-middle";
+ newPath = appRootPath + L"/Res/ScreenDensity-Middle";
+ InstallerUtil::CreateSymlink(oldPath, newPath);
- sprintf(srcPath, "%ls%s", appRootPath.GetPointer(), "/res/screen-density-low");
- if (File::IsFileExist(srcPath) == true)
- {
- sprintf(destPath, "%ls%s", appRootPath.GetPointer(), "/Res/ScreenDensity-Low");
- err = symlink(srcPath, destPath);
- }
+ oldPath = appRootPath + DIR_RES + L"/screen-density-low";
+ newPath = appRootPath + L"/Res/ScreenDensity-Low";
+ InstallerUtil::CreateSymlink(oldPath, newPath);
return true;
}
* @brief This is the implementation file for %ManifestStep class.
*/
+#include <unique_ptr.h>
+
#include <FIoFile.h>
#include <FBase_StringConverter.h>
InstallerError error = INSTALLER_ERROR_NONE;
bool ret = false;
- char *pFilepath = null;
+ // char *pFilepath = null;
_PackageInfoImpl *pPackageInfoImpl = null;
- File file;
- const int bufSize = 32*1024;
- char *p = new char[bufSize];
- memset(p, 0, sizeof(bufSize));
+ String manifestXmlPath;
+
+// File file;
+// const int bufSize = 32*1024;
+// char *p = new char[bufSize];
+// memset(p, 0, sizeof(bufSize));
result r = E_SUCCESS;
- int size = 0;
+// int size = 0;
- pFilepath = _StringConverter::CopyToCharArrayN(__pContext->GetManifestXmlPath());
+ // pFilepath = _StringConverter::CopyToCharArrayN(__pContext->GetManifestXmlPath());
+ manifestXmlPath = __pContext->GetManifestXmlPath();
- r = file.Construct(__pContext->GetManifestXmlPath(), L"r");
- if (r != E_SUCCESS)
- {
- fprintf(stderr, "OnStateManifestXml - file.Construct is failed. [%ls]\n", __pContext->GetManifestXmlPath().GetPointer());
- AppLogTag(OSP_INSTALLER, "OnStateManifestXml - file.Construct is failed. [%ls]\n", __pContext->GetManifestXmlPath().GetPointer());
- }
+// r = file.Construct(__pContext->GetManifestXmlPath(), L"r");
+// if (r != E_SUCCESS)
+// {
+// fprintf(stderr, "OnStateManifestXml - file.Construct is failed. [%ls]\n", __pContext->GetManifestXmlPath().GetPointer());
+// AppLogTag(OSP_INSTALLER, "OnStateManifestXml - file.Construct is failed. [%ls]\n", __pContext->GetManifestXmlPath().GetPointer());
+// }
FileAttributes attr;
- r = File::GetAttributes(__pContext->GetManifestXmlPath(), attr);
+ r = File::GetAttributes(manifestXmlPath, attr);
if (r != E_SUCCESS)
{
fprintf(stderr, "OnStateManifestXml - File::GetAttributes is failed. [%ls]\n", __pContext->GetManifestXmlPath().GetPointer());
AppLogTag(OSP_INSTALLER, "OnStateManifestXml - File::GetAttributes is failed. [%ls]\n", __pContext->GetManifestXmlPath().GetPointer());
}
- TryCatch(!IsFailed(r), error = INSTALLER_ERROR_INVALID_PACKAGE, "[osp-installer] File::GetAttributes() failed");
-
- size = file.Read(p, bufSize);
- if (size <= 0)
- {
- fprintf(stderr, "OnStateManifestXml - file.Read is failed. [%ls]\n", __pContext->GetManifestXmlPath().GetPointer());
- AppLogTag(OSP_INSTALLER, "OnStateManifestXml - file.Read is failed. [%ls]\n", __pContext->GetManifestXmlPath().GetPointer());
- }
-
- if (strstr(p, "<Apps>") != null)
- {
- AppLogTag(OSP_INSTALLER, "ManifestXmlStep::OnStateManifest() - new manifest!");
-
- ManifestHandler manifestHandler;
- manifestHandler.Construct(__pContext);
- ret = manifestHandler.Parse(pFilepath);
- if (ret == false)
- {
- fprintf(stderr, "OnStateManifestXml - manifestHandler.Parse is failed. [%s]\n", pFilepath);
- }
- TryCatch(ret == true, error = INSTALLER_ERROR_INVALID_MANIFEST, "[osp-installer] manifestHandler.Parse() failed");
-
- pPackageInfoImpl = __pContext->GetPackageInfoImpl();
- TryCatch(pPackageInfoImpl, error = INSTALLER_ERROR_INVALID_MANIFEST, "[osp-installer] pPackageInfoImpl is null");
- __pContext->SetAppId(pPackageInfoImpl->GetAppId());
- }
- else
+ TryReturn(!IsFailed(r), INSTALLER_ERROR_INVALID_PACKAGE, "[osp-installer] File::GetAttributes() failed");
+
+ std::unique_ptr<char[]> pFilepath(_StringConverter::CopyToCharArrayN(manifestXmlPath));
+ TryReturn(pFilepath, INSTALLER_ERROR_INVALID_PACKAGE, "[osp-installer] pFilepath is null");
+
+// size = file.Read(p, bufSize);
+// if (size <= 0)
+// {
+// fprintf(stderr, "OnStateManifestXml - file.Read is failed. [%ls]\n", __pContext->GetManifestXmlPath().GetPointer());
+// AppLogTag(OSP_INSTALLER, "OnStateManifestXml - file.Read is failed. [%ls]\n", __pContext->GetManifestXmlPath().GetPointer());
+// }
+
+// if (strstr(p, "<Apps>") != null)
+// {
+ AppLogTag(OSP_INSTALLER, "manifest file=(%ls)", manifestXmlPath.GetPointer());
+
+ ManifestHandler manifestHandler;
+ manifestHandler.Construct(__pContext);
+ ret = manifestHandler.Parse(pFilepath.get());
+ if (ret == false)
{
- fprintf(stderr, "ManifestXmlStep::OnStateManifestXml - old manifest!! \n");
- AppLogTag(OSP_INSTALLER, "ManifestXmlStep::OnStateManifest() - error(INSTALLER_ERROR_INVALID_MANIFEST)");
- error = INSTALLER_ERROR_INVALID_MANIFEST;
+ fprintf(stderr, "OnStateManifestXml - manifestHandler.Parse is failed. [%s]\n", pFilepath.get());
}
-
-CATCH:
- delete[] p;
+ TryReturn(ret == true, INSTALLER_ERROR_INVALID_MANIFEST, "[osp-installer] manifestHandler.Parse() failed");
+
+ pPackageInfoImpl = __pContext->GetPackageInfoImpl();
+ TryReturn(pPackageInfoImpl, error = INSTALLER_ERROR_INVALID_MANIFEST, "[osp-installer] pPackageInfoImpl is null");
+ __pContext->SetAppId(pPackageInfoImpl->GetAppId());
+// }
+// else
+// {
+// fprintf(stderr, "ManifestXmlStep::OnStateManifestXml - old manifest!! \n");
+// AppLogTag(OSP_INSTALLER, "ManifestXmlStep::OnStateManifest() - error(INSTALLER_ERROR_INVALID_MANIFEST)");
+// error = INSTALLER_ERROR_INVALID_MANIFEST;
+// }
+
+// CATCH:
+// delete[] p;
GoNextState();
- delete[] pFilepath;
+ // delete[] pFilepath;
return error;
}
bool
InstallerUtil::Remove(const Osp::Base::String& filePath)
{
- bool res = false;
- char* pFilePath = null;
- struct stat fileinfo;
- int err = 0;
+ int err = -1;
result r = E_SUCCESS;
+ struct stat fileinfo;
- pFilePath = _StringConverter::CopyToCharArrayN(filePath);
- TryCatch(pFilePath, r = GetLastResult(), "[osp-installer] pFilePath is null");
-
- err = lstat(pFilePath, &fileinfo);
- TryCatch(err >= 0, res = false, "[osp-installer] lstat() failed, pFilePath=%s", pFilePath);
+ std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
+ TryReturn(pFilePath, false, "[osp-installer] pFilePath is null");
+ err = lstat(pFilePath.get(), &fileinfo);
+ TryReturn(err >= 0, false, "[osp-installer] lstat() failed, filepath=%s", pFilePath.get());
if (S_ISLNK(fileinfo.st_mode))
{
- AppLogTag(OSP_INSTALLER, "remove symlink, pFilePath=%s", pFilePath);
- err = unlink(pFilePath);
- TryCatch(err >= 0, res = false, "[osp-installer] unlink() failed, pFilePath=%s", pFilePath);
+ AppLogTag(OSP_INSTALLER, "remove symlink, pFilePath=%s", pFilePath.get());
+ err = unlink(pFilePath.get());
+ TryReturn(err >= 0, false, "[osp-installer] unlink() failed, filepath=%s", pFilePath.get());
}
else if (S_ISDIR(fileinfo.st_mode))
{
AppLogTag(OSP_INSTALLER, "remove directory, filePath=%ls", filePath.GetPointer());
r = Directory::Remove(filePath, true);
- TryCatch(!IsFailed(r), res = false, "[osp-installer] Directory::Remove() failed, filePath=%ls", filePath.GetPointer());
+ TryReturn(!IsFailed(r), false, "[osp-installer] Directory::Remove() failed, filePath=%ls", filePath.GetPointer());
}
else
{
AppLogTag(OSP_INSTALLER, "remove file, filePath=%ls", filePath.GetPointer());
r = File::Remove(filePath);
- TryCatch(!IsFailed(r), res = false, "[osp-installer] File::Remove() failed, filePath=%ls", filePath.GetPointer());
+ TryReturn(!IsFailed(r), false, "[osp-installer] File::Remove() failed, filePath=%ls", filePath.GetPointer());
}
- res = true;
+ AppLogTag(OSP_INSTALLER, "[%ls] is removed.", filePath.GetPointer());
-CATCH:
- delete [] pFilePath;
- return res;
+ return true;
}
bool
InstallerUtil::CreateSymlink(const String& oldPath, const String& newPath)
{
int err = -1;
+ bool res = false;
+
+ res = File::IsFileExist(oldPath);
+ TryReturn(res == true, false, "[osp-installer] file not found, oldPath=(%ls).", oldPath.GetPointer());
std::unique_ptr<char[]> pOldPath(_StringConverter::CopyToCharArrayN(oldPath));
TryReturn(pOldPath, false, "[osp-installer] pOldPath is null");
}
bool
+InstallerUtil::ChangeDirectoryPermission(const String& filePath, int mode)
+{
+ result r = E_SUCCESS;
+
+ std::unique_ptr<Directory> pDir(new Directory);
+ TryReturn(pDir, false, "[osp-installer] pDir is null.");
+
+ r = pDir->Construct(filePath);
+ TryReturn(!IsFailed(r), false, "[osp-installer] pDir->Construct() failed, filePath=[%ls].", filePath.GetPointer());
+
+ std::unique_ptr<DirEnumerator> pDirEnum(pDir->ReadN());
+ TryReturn(pDirEnum, false, "[osp-installer] pDirEnum is null.");
+
+ while (pDirEnum->MoveNext() == E_SUCCESS)
+ {
+ DirEntry entry = pDirEnum->GetCurrentDirEntry();
+
+ String entryName = entry.GetName();
+ String entryDir = filePath;
+ entryDir += L"/";
+ entryDir += entryName;
+
+ if (entryName == L".")
+ {
+ InstallerUtil::ChangeOwner(entryDir);
+ InstallerUtil::ChangeMode(entryDir, mode);
+ continue;
+ }
+ else if (entryName == L"..")
+ {
+ continue;
+ }
+
+ if (entry.IsDirectory() == false)
+ {
+ InstallerUtil::ChangeOwner(entryDir);
+ InstallerUtil::ChangeMode(entryDir, mode);
+ }
+ else
+ {
+ ChangeDirectoryPermission(entryDir, mode);
+ InstallerUtil::ChangeMode(entryDir, mode);
+ }
+ }
+
+ return true;
+}
+
+bool
InstallerUtil::IsDrmFile(const Osp::Base::String& packagePath)
{
AppLogTag(OSP_INSTALLER, "IsDrmFile() called, packagePath=%ls", packagePath.GetPointer());
static bool CreateSymlink(const Osp::Base::String& oldPath, const Osp::Base::String& newPath);
static bool ChangeMode(const Osp::Base::String& filePath, int mode);
static bool ChangeOwner(const Osp::Base::String& filePath);
+ static bool ChangeDirectoryPermission(const Osp::Base::String& filePath, int mode);
static bool IsDrmFile(const Osp::Base::String& packagePath);
static bool DecryptPackage(const Osp::Base::String& packagePath);
__pWriter->EndElement();
}
}
+
+ return true;
}
:__pContext(null)
,__pPrivilegeList(null)
,__pLiveBoxList(null)
+,__pContentInfoList(null)
,__pPackageInfoImpl(null)
,__pPackageAppInfoImpl(null)
,__pAppControlInfoImpl(null)
,__pLaunchConditionImpl(null)
,__pNotificationImpl(null)
,__pLiveboxInfo(null)
+,__pContentInfo(null)
,__pDefaultIconType(null)
,__isDefaultMainmenu(false)
,__isDefaultSetting(false)
{
status = OnLiveBoxElement();
}
+ else if (strcasecmp(pName, "Contents") == 0)
+ {
+ status = OnContentsElement();
+ }
+ else if (strcasecmp(pName, "Content") == 0)
+ {
+ status = OnContentElement();
+ }
if (!status)
{
__isDefaultName = false;
AppLogTag(OSP_INSTALLER, "</%s>", pName);
}
-
else if (strcasecmp(pName, "AppControl") == 0)
{
__pPackageAppInfoImpl->AddAppControl(__pAppControlInfoImpl);
else if (strcasecmp(pName, "Apps") == 0)
{
AppLogTag(OSP_INSTALLER, "</%s>", pName);
- if (__isDefaultAppDetected == false)
- {
- fprintf(stderr, "__isDefaultAppDetected is false.\n");
- }
- TryReturn(__isDefaultAppDetected, false, "[osp-installer][Error] Default App is not detected...");
}
else if (strcasecmp(pName, "UiScalability") == 0)
{
__pLiveBoxList = null;
AppLogTag(OSP_INSTALLER, "</%s>", pName);
}
+ else if (strcasecmp(pName, "Contents") == 0)
+ {
+ __pContext->SetContentInfoList(__pContentInfoList);
+ __pContentInfoList = null;
+ AppLogTag(OSP_INSTALLER, "</%s>", pName);
+ }
else if (strcasecmp(pName, "LiveBox") == 0)
{
__pLiveBoxList->Add(*__pLiveboxInfo);
__pLiveboxInfo = null;
AppLogTag(OSP_INSTALLER, "</%s>", pName);
}
+ else if (strcasecmp(pName, "Content") == 0)
+ {
+ __pContentInfoList->Add(*__pContentInfo);
+ __pContentInfo = null;
+ AppLogTag(OSP_INSTALLER, "</%s>", pName);
+ }
+ else if (strcasecmp(pName, "Manifest") == 0)
+ {
+ if (__isDefaultAppDetected == false)
+ {
+ fprintf(stderr, "__isDefaultAppDetected is false.\n");
+ }
+ TryReturn(__isDefaultAppDetected, false, "[osp-installer][Error] Default App is not detected...");
+ AppLogTag(OSP_INSTALLER, "</%s>", pName);
+ }
if (!status)
{
}
bool
+ManifestHandler::OnContentsElement(void)
+{
+ __pContentInfoList = new ArrayList;
+ TryReturn(__pContentInfoList, false, "[osp-installer] __pContentInfoList is null");
+
+ AppLogTag(OSP_INSTALLER, "<Contents>");
+
+ return true;
+}
+
+bool
+ManifestHandler::OnContentElement(void)
+{
+ TryReturn(__pContentInfo == null, false, "[osp-installer] __pContentInfo is not null");
+
+ XmlAttribute *pAttr = null;
+ char *pDefault = null;
+
+ __pContentInfo = new ContentInfo;
+ TryReturn(__pContentInfo, false, "[osp-installer] __pLiveboxInfo is null");
+
+ pAttr = GetAttribute();
+ TryReturn(pAttr, true, "[osp-installer] pAttr is null");
+
+ char* pId = pAttr->Find("Id");
+ if (pId)
+ {
+ __pContentInfo->SetContentId(pId);
+ }
+
+ char* pEntryName = pAttr->Find("EntryName");
+ if (pEntryName)
+ {
+ __pContentInfo->SetContentId(pEntryName);
+ }
+
+ pDefault = pAttr->Find("Default");
+ if (pDefault)
+ {
+ if (strcasecmp(pDefault, "True") == 0)
+ {
+ __isDefaultAppDetected = true;
+ }
+ }
+
+ AppLogTag(OSP_INSTALLER, "<Content Id=\"%s\" EntryName=\"%s\">", pId, pEntryName);
+
+ return true;
+}
+
+bool
ManifestHandler::OnUiScalabilityElement(void)
{
XmlAttribute *pAttr = null;
ManifestHandler::OnTypeValue(const char *pCharacters)
{
__pPackageInfoImpl->SetAppType(pCharacters);
+
+ if (strcasecmp(pCharacters, "Contents") == 0)
+ {
+ __pPackageInfoImpl->SetAppApiVersion("3.0");
+ }
+
AppLogTag(OSP_INSTALLER, "<Type>%s</Type>", pCharacters);
return true;
TryReturn(__pLiveboxInfo, false, "[osp-installer] __pLiveboxInfo is null");
__pLiveboxInfo->SetIcon(icon);
}
+ else if (FindElement("Content") == true)
+ {
+ TryReturn(__pContentInfo, false, "[osp-installer] __pContentInfo is null");
+ __pContentInfo->SetIcon(icon);
+ }
else
{
if (strcasecmp(pAttrValue1, "MainMenu") == 0)
StringUtil::Utf8ToString(pCharacters, *pValue);
__pLiveboxInfo->AddName(*(new String(pAttrValue)), *pValue);
}
+ else if (FindElement("Content") == true)
+ {
+ TryReturn(__pContentInfo, false, "[osp-installer] __pContentInfo is null");
+
+ String* pValue = new String;
+ StringUtil::Utf8ToString(pCharacters, *pValue);
+ __pContentInfo->AddName(*(new String(pAttrValue)), *pValue);
+ }
else
{
if (strcasecmp(pAttrValue, "eng-GB") == 0 || strcasecmp(pAttrValue, "eng-US") == 0)
virtual bool OnStartElement(const char *pName);
virtual bool OnEndElement(const char *pName);
virtual bool OnCharacters(const char *pCharacters);
+
bool OnPrivilegesElement(void);
bool OnPrivilegesEndElement(void);
bool OnLiveBoxesElement(void);
bool OnLiveBoxElement(void);
+ bool OnContentsElement(void);
+ bool OnContentElement(void);
bool OnUiScalabilityElement(void);
bool OnUiThemeElement(void);
bool OnIconsElement(void);
InstallationContext* __pContext;
Osp::Base::Collection::ArrayList* __pPrivilegeList;
Osp::Base::Collection::ArrayList* __pLiveBoxList;
+ Osp::Base::Collection::ArrayList* __pContentInfoList;
Osp::App::_PackageInfoImpl* __pPackageInfoImpl;
Osp::App::_PackageAppInfoImpl* __pPackageAppInfoImpl;
Osp::App::_AppControlInfoImpl* __pAppControlInfoImpl;
Osp::App::_LaunchConditionInfoImpl* __pLaunchConditionImpl;
Osp::App::_NotificationInfoImpl* __pNotificationImpl;
LiveboxInfo* __pLiveboxInfo;
+ ContentInfo* __pContentInfo;
char* __pDefaultIconType;
bool __isDefaultMainmenu;