summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/Context/InstallationContext.cpp13
-rwxr-xr-xsrc/Context/InstallationContext.h6
-rwxr-xr-xsrc/Installer/Installer.cpp15
-rwxr-xr-xsrc/Manager/ConfigurationManager.cpp47
-rwxr-xr-xsrc/Manager/ConfigurationManager.h3
-rwxr-xr-xsrc/Step/UninstallStep.cpp31
-rwxr-xr-xsrc/Step/UnpackStep.cpp168
-rwxr-xr-x[-rw-r--r--]src/Step/UnpackStep.h9
-rwxr-xr-xsrc/XmlHandler/ManifestHandler.cpp20
-rwxr-xr-xsrc/XmlHandler/ManifestHandler.h1
10 files changed, 302 insertions, 11 deletions
diff --git a/src/Context/InstallationContext.cpp b/src/Context/InstallationContext.cpp
index c7ee5d6..6b00330 100755
--- a/src/Context/InstallationContext.cpp
+++ b/src/Context/InstallationContext.cpp
@@ -57,6 +57,7 @@ InstallationContext::InstallationContext(void)
,__pDistributorCertPath(null)
,__rootCertType(ROOT_CERTIFICATE_NONE)
,__packageNameType(INSTALLER_PREFIX_TYPE_NONE)
+,__pApp2ExtHandle(null)
,__pPackageInfoImpl(null)
{
}
@@ -484,6 +485,18 @@ InstallationContext::SetPackageNameType(int type)
__packageNameType = type;
}
+app2ext_handle*
+InstallationContext::GetApp2ExtHandle(void) const
+{
+ return __pApp2ExtHandle;
+}
+
+void
+InstallationContext::SetApp2ExtHandle(app2ext_handle* pHandle)
+{
+ __pApp2ExtHandle = pHandle;
+}
+
_PackageInfoImpl*
InstallationContext::GetPackageInfoImpl(void) const
{
diff --git a/src/Context/InstallationContext.h b/src/Context/InstallationContext.h
index f423eb7..3315496 100755
--- a/src/Context/InstallationContext.h
+++ b/src/Context/InstallationContext.h
@@ -23,6 +23,8 @@
#ifndef _INSTALLATION_CONTEXT_H_
#define _INSTALLATION_CONTEXT_H_
+#include <app2ext_interface.h>
+
#include <FAppPackageInfo.h>
#include <FSecCertX509CertificatePath.h>
@@ -131,6 +133,9 @@ public:
int GetPackageNameType(void) const;
void SetPackageNameType(int type);
+ app2ext_handle* GetApp2ExtHandle(void) const;
+ void SetApp2ExtHandle(app2ext_handle* pHandle);
+
Osp::App::_PackageInfoImpl* GetPackageInfoImpl(void) const;
private:
@@ -169,6 +174,7 @@ private:
RootCertificateType __rootCertType;
int __packageNameType;
+ app2ext_handle* __pApp2ExtHandle;
Osp::App::_PackageInfoImpl* __pPackageInfoImpl;
diff --git a/src/Installer/Installer.cpp b/src/Installer/Installer.cpp
index 94b76b4..9790b29 100755
--- a/src/Installer/Installer.cpp
+++ b/src/Installer/Installer.cpp
@@ -152,11 +152,13 @@ Installer::OnEnd(void)
configurationManager.CreateFile(pContext);
configurationManager.UnregisterCertInfo(pContext);
configurationManager.RegisterCertInfo(pContext);
+ configurationManager.PostInstall(pContext, false);
}
else if (operation == INSTALLER_OPERATION_UNINSTALL)
{
configurationManager.RemoveFile(pContext);
configurationManager.UnregisterCertInfo(pContext);
+ configurationManager.PostUninstall(pContext);
}
AppLogTag(OSP_INSTALLER, "Installer::OnEnd() - END");
@@ -169,6 +171,19 @@ InstallerError
Installer::OnError(void)
{
AppLogTag(OSP_INSTALLER, "Installer::OnError()");
+
+ InstallerOperation operation = __pContext->GetInstallerOperation();
+ ConfigurationManager configurationManager;
+
+ if (operation == INSTALLER_OPERATION_INSTALL)
+ {
+ configurationManager.PostInstall(__pContext, true);
+ }
+ else
+ {
+ configurationManager.PostUninstall(__pContext);
+ }
+
return INSTALLER_ERROR_NONE;
}
diff --git a/src/Manager/ConfigurationManager.cpp b/src/Manager/ConfigurationManager.cpp
index 866d0b4..0782600 100755
--- a/src/Manager/ConfigurationManager.cpp
+++ b/src/Manager/ConfigurationManager.cpp
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <unique_ptr.h>
#include <pkgmgr_parser.h>
#include <pkgmgr_installer.h>
@@ -504,6 +505,52 @@ CATCH:
}
bool
+ConfigurationManager::PostInstall(InstallationContext* pContext, bool error) const
+{
+ app2ext_handle* pHandle = pContext->GetApp2ExtHandle();
+ if (pHandle)
+ {
+ String appId = pContext->GetAppId();
+ std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
+ TryReturn(pAppId, false, "[osp-installer] pAppId is null");
+
+ if (error == true)
+ {
+ pHandle->interface.post_install(pAppId.get(), APP2EXT_STATUS_FAILED);
+ AppLogTag(OSP_INSTALLER, "[app2sd] post_install(%s, APP2EXT_STATUS_FAILED)", pAppId.get());
+ }
+ else
+ {
+ pHandle->interface.post_install(pAppId.get(), APP2EXT_STATUS_SUCCESS);
+ AppLogTag(OSP_INSTALLER, "[app2sd] post_install(%s, APP2EXT_STATUS_SUCCESS)", pAppId.get());
+ }
+
+ app2ext_deinit(pHandle);
+ }
+
+ return true;
+}
+
+bool
+ConfigurationManager::PostUninstall(InstallationContext* pContext) const
+{
+ app2ext_handle* pHandle = pContext->GetApp2ExtHandle();
+ if (pHandle)
+ {
+ String appId = pContext->GetAppId();
+ std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
+ TryReturn(pAppId, false, "[osp-installer] pAppId is null");
+
+ pHandle->interface.post_uninstall(pAppId.get());
+ AppLogTag(OSP_INSTALLER, "[app2sd] post_uninstall(%s)", pAppId.get());
+
+ app2ext_deinit(pHandle);
+ }
+
+ return true;
+}
+
+bool
ConfigurationManager::CreateSystemXmlFile(InstallationContext* pContext)
{
AppLogTag(OSP_INSTALLER, "------------------------------------------");
diff --git a/src/Manager/ConfigurationManager.h b/src/Manager/ConfigurationManager.h
index e68f8ed..cac1b7d 100755
--- a/src/Manager/ConfigurationManager.h
+++ b/src/Manager/ConfigurationManager.h
@@ -48,6 +48,9 @@ public:
bool RegisterCertInfo(InstallationContext* pContext) const;
bool UnregisterCertInfo(InstallationContext* pContext) const;
+ bool PostInstall(InstallationContext* pContext, bool error) const;
+ bool PostUninstall(InstallationContext* pContext) const;
+
private:
bool CreateSystemXmlFile(InstallationContext* pContext);
bool CreateHybridServiceDesktopFile(InstallationContext* pContext);
diff --git a/src/Step/UninstallStep.cpp b/src/Step/UninstallStep.cpp
index 06162fb..ca55db7 100755
--- a/src/Step/UninstallStep.cpp
+++ b/src/Step/UninstallStep.cpp
@@ -19,8 +19,11 @@
* @brief This is the implementation file for %UninstallStep class.
*/
+#include <unique_ptr.h>
+
#include <FIoDirectory.h>
#include <FIo_FileImpl.h>
+#include <FBase_StringConverter.h>
#include <FApp_PackageManagerImpl.h>
#include <FApp_PackageInfoImpl.h>
#include <FApp_AppInfoImpl.h>
@@ -120,6 +123,13 @@ InstallerError
UninstallStep::OnStateGetPackageInfo(void)
{
InstallerError error = INSTALLER_ERROR_NONE;
+ String appId = __pContext->GetAppId();
+
+ _PackageInfoImpl* pPackageInfoImpl = __pContext->GetPackageInfoImpl();
+ TryReturn(pPackageInfoImpl, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] pPackageInfoImpl is null");
+
+ AppLogTag(OSP_INSTALLER, "appId = %S", appId.GetPointer());
+ pPackageInfoImpl->Construct(appId);
if (__pContext->IsHybridService() == true)
{
@@ -128,15 +138,24 @@ UninstallStep::OnStateGetPackageInfo(void)
return error;
}
- String appId;
- appId = __pContext->GetAppId();
+ if (pPackageInfoImpl->GetAppStorageType() == PACKAGE_STORAGE_TYPE_EXTERNAL)
+ {
+ int res = 0;
+ app2ext_handle* pHandle = null;
- AppLogTag(OSP_INSTALLER, "appId = %S", appId.GetPointer());
+ std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
+ TryReturn(pAppId, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] pAppId is null");
- _PackageInfoImpl* pPackageInfoImpl = __pContext->GetPackageInfoImpl();
- TryReturn(pPackageInfoImpl, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] pPackageInfoImpl is null");
+ pHandle = app2ext_init(APP2EXT_SD_CARD);
+ TryReturn(pHandle, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] app2ext_init() failed");
- pPackageInfoImpl->Construct(appId);
+ res = pHandle->interface.pre_uninstall(pAppId.get());
+ TryReturn(res == 0, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] pHandle->interface.pre_uninstall() failed [%d]", res);
+
+ __pContext->SetApp2ExtHandle(pHandle);
+
+ AppLogTag(OSP_INSTALLER, "[app2sd] pre_uninstall(%s)", pAppId.get());
+ }
ArrayList* pList = pPackageInfoImpl->GetAppInfoListN();
TryReturn(pList, INSTALLER_ERROR_DATABASE, "[osp-installer] pList is null.");
diff --git a/src/Step/UnpackStep.cpp b/src/Step/UnpackStep.cpp
index 53ad2da..e9ea41a 100755
--- a/src/Step/UnpackStep.cpp
+++ b/src/Step/UnpackStep.cpp
@@ -19,17 +19,21 @@
* @brief This is the implementation file for %UnpackStep class.
*/
+#include <unique_ptr.h>
+
#include <FIoFile.h>
#include <FIoDirectory.h>
#include <FBaseResult.h>
#include <FBaseUtilFileUnzipper.h>
#include <FApp_PackageInfoImpl.h>
+#include <FBase_StringConverter.h>
#include "InstallationContext.h"
#include "UnpackStep.h"
#include "InstallerUtil.h"
using namespace Osp::Base;
+using namespace Osp::Base::Collection;
using namespace Osp::Base::Utility;
using namespace Osp::App;
using namespace Osp::Io;
@@ -37,11 +41,30 @@ using namespace Osp::Io;
UnpackStep::UnpackStep(void)
:__state(STATE_UNZIP)
,__pContext(null)
+,__pDirectoryList(null)
+,__uncompressedSize(0)
{
}
UnpackStep::~UnpackStep(void)
{
+ if (__pDirectoryList)
+ {
+ GList* pList = null;
+ app2ext_dir_details* pDirDetails = null;
+
+ pList = g_list_first(__pDirectoryList);
+ while (pList)
+ {
+ pDirDetails = (app2ext_dir_details*)pList->data;
+ if (pDirDetails && pDirDetails->name)
+ {
+ free(pDirDetails->name);
+ }
+ pList = g_list_next(pList);
+ }
+ g_list_free(__pDirectoryList);
+ }
}
InstallerError
@@ -116,6 +139,8 @@ UnpackStep::OnUnzip(void)
{
InstallerError error = INSTALLER_ERROR_NONE;
_PackageInfoImpl *pPackageInfoImpl = null;
+ String newInstallPath;
+ app2ext_handle* pHandle = null;
String installPath;
installPath = PATH_OPT_USR_APPS;
@@ -128,14 +153,39 @@ UnpackStep::OnUnzip(void)
installPath += __pContext->GetAppId();
+ result r = E_SUCCESS;
+ FileUnzipper unzipper;
+ r = unzipper.Construct(__pContext->GetPackagePath());
+ TryReturn(!IsFailed(r), INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] unzipper.Construct() failed");
+
+ if (__pContext->GetInstallationStorage() == InstallationContext::INSTALLATION_STORAGE_EXTERNAL)
+ {
+ int res = 0;
+ String appId = __pContext->GetAppId();
+
+ std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
+ TryReturn(pAppId, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] pAppId is null");
+
+ GetUncompressedInfo(unzipper);
+ TryReturn((__pDirectoryList && (__uncompressedSize > 0)), INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] GetUncompressedInfo() failed");
+
+ pHandle = app2ext_init(APP2EXT_SD_CARD);
+ TryReturn(pHandle, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] app2ext_init() failed");
+
+ __pContext->SetApp2ExtHandle(pHandle);
+
+ res = pHandle->interface.pre_install(pAppId.get(), __pDirectoryList, __uncompressedSize);
+ TryReturn(res == 0, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] pHandle->interface.pre_install() failed [%d]", res);
+
+ AppLogTag(OSP_INSTALLER, "[app2sd] pre_install(%s)", pAppId.get());
+ }
+
if (File::IsFileExist(installPath) == false)
{
- result r = E_SUCCESS;
r = Directory::Create(installPath, false);
TryReturn(!IsFailed(r), INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] Directory::Create() failed, installPath=%ls", installPath.GetPointer());
}
- String newInstallPath;
InstallerUtil::CreateSymlinkForAppDirectory(installPath, newInstallPath);
__pContext->SetInstallDir(newInstallPath);
@@ -143,8 +193,6 @@ UnpackStep::OnUnzip(void)
pPackageInfoImpl->SetAppRootPath(newInstallPath);
AppLogTag(OSP_INSTALLER, "UnzipTo - START");
- FileUnzipper unzipper;
- unzipper.Construct(__pContext->GetPackagePath());
unzipper.UnzipTo(newInstallPath);
AppLogTag(OSP_INSTALLER, "UnzipTo - END");
@@ -197,3 +245,115 @@ UnpackStep::CreateDefaultDir(void)
return true;
}
+
+bool
+UnpackStep::GetUncompressedInfo(const FileUnzipper& unzipper)
+{
+ result r = E_SUCCESS;
+ unsigned long totalSize = 0;
+ String directory;
+ String entryName;
+ ArrayList directoryList;
+ int entryCount = unzipper.GetEntryCount();
+
+ directoryList.Construct();
+
+ for(int i = 0; i < entryCount; i++)
+ {
+ int indexOf = 0;
+ int startIndex = 0;
+ unsigned long uncompressedSize = 0;
+ ZipEntry zipEntry;
+
+ unzipper.GetEntry(i, zipEntry);
+ entryName = zipEntry.GetName();
+
+ while((r = entryName.IndexOf(L'/', startIndex, indexOf)) == E_SUCCESS)
+ {
+ String* pCurDirectory = new String;
+ TryReturn(pCurDirectory, false, "[osp-installer] pCurDirectory is null.");
+
+ entryName.SubString(0, indexOf, *pCurDirectory);
+
+ if (directoryList.Contains(*pCurDirectory) == false)
+ {
+ if (startIndex == 0)
+ {
+ AddDirectory(*pCurDirectory);
+ }
+
+ AppLogTag(OSP_INSTALLER, "Folder[%ls], Size[%d]", pCurDirectory->GetPointer(), BLOCK_SIZE);
+ totalSize += BLOCK_SIZE;
+
+ directoryList.Add(*pCurDirectory);
+ }
+
+ startIndex = indexOf + 1;
+ }
+
+ if (zipEntry.IsDirectory() == false)
+ {
+ uncompressedSize = zipEntry.GetUncompressedSize();
+
+ int blockCount = uncompressedSize / BLOCK_SIZE;
+
+ if ((blockCount == 0) && (uncompressedSize != 0))
+ {
+ uncompressedSize = BLOCK_SIZE;
+ }
+ else
+ {
+ int mod = uncompressedSize % BLOCK_SIZE;
+ if (mod != 0)
+ {
+ blockCount++;
+ }
+ uncompressedSize = (BLOCK_SIZE * blockCount);
+ }
+
+ totalSize += uncompressedSize;
+ AppLogTag(OSP_INSTALLER, " -File[%ls], UncompressedSize[%u]", entryName.GetPointer(), uncompressedSize);
+ }
+ }
+
+ directoryList.RemoveAll(true);
+ __uncompressedSize = (int)(totalSize / (1024 * 1024)) + 1;
+
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+ AppLogTag(OSP_INSTALLER, "TotalSize = [%u]B", totalSize);
+ AppLogTag(OSP_INSTALLER, "TotalSize = [%d]MB", __uncompressedSize);
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+
+
+ return true;
+}
+
+bool
+UnpackStep::AddDirectory(const String& rootDirectory)
+{
+ int length = 0;
+ app2ext_dir_details* pDirDetails = null;
+
+ pDirDetails = (app2ext_dir_details*) calloc(1, sizeof(app2ext_dir_details));
+ TryReturn(pDirDetails, false, "[osp-installer] pDirDetails is null");
+
+ length = rootDirectory.GetLength();
+ pDirDetails->name = (char*) calloc(1, (sizeof(char) * length) + 1);
+ snprintf(pDirDetails->name, length + 1, "%ls", rootDirectory.GetPointer());
+
+ if ((rootDirectory == L"bin") || (rootDirectory == L"res") || (rootDirectory == L"icons"))
+ {
+ pDirDetails->type = APP2EXT_DIR_RO;
+ }
+ else
+ {
+ pDirDetails->type = APP2EXT_DIR_RW;
+ }
+
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+ AppLogTag(OSP_INSTALLER, "# Root Directory = [%s], Type = [%d]", pDirDetails->name, pDirDetails->type);
+
+ __pDirectoryList = g_list_append(__pDirectoryList, pDirDetails);
+
+ return true;
+}
diff --git a/src/Step/UnpackStep.h b/src/Step/UnpackStep.h
index d67d7fd..c4209cc 100644..100755
--- a/src/Step/UnpackStep.h
+++ b/src/Step/UnpackStep.h
@@ -23,6 +23,10 @@
#ifndef _UNPACK_STEP_H_
#define _UNPACK_STEP_H_
+#include <glib.h>
+
+#include <FBaseUtilFileUnzipper.h>
+
#include "IInstallationStep.h"
/**
@@ -60,11 +64,14 @@ private:
InstallerError OnStateDone(void);
bool CreateDefaultDir(void);
- bool Unzip(const Osp::Base::String& srcZipFile, const Osp::Base::String& desDirPath);
+ bool GetUncompressedInfo(const Osp::Base::Utility::FileUnzipper& unzipper);
+ bool AddDirectory(const Osp::Base::String& directory);
private:
int __state;
InstallationContext* __pContext;
+ GList* __pDirectoryList;
+ int __uncompressedSize;
}; // UnpackStep
diff --git a/src/XmlHandler/ManifestHandler.cpp b/src/XmlHandler/ManifestHandler.cpp
index 628d3bc..c7a8503 100755
--- a/src/XmlHandler/ManifestHandler.cpp
+++ b/src/XmlHandler/ManifestHandler.cpp
@@ -367,6 +367,10 @@ ManifestHandler::OnCharacters(const char *pCharacters)
{
status = OnSizeValue(pCharacters);
}
+ else if (strcasecmp(pName, "InstallationLocation") == 0)
+ {
+ status = OnInstallationLocationValue(pCharacters);
+ }
if (!status)
{
@@ -983,6 +987,22 @@ ManifestHandler::OnSizeValue(const char *pCharacters)
}
bool
+ManifestHandler::OnInstallationLocationValue(const char *pCharacters)
+{
+ AppLogTag(OSP_INSTALLER, "<InstallationLocation>%s</InstallationLocation>", pCharacters);
+
+ if ((strcasecmp(pCharacters, "UserPreferred") == 0) &&
+ (File::IsFileExist(DIR_MEMORYCARD_INSTALLATION) == true))
+ {
+ AppLogTag(OSP_INSTALLER, "INSTALLATION_STORAGE = [EXTERNAL]");
+ __pContext->SetInstallationStorage(InstallationContext::INSTALLATION_STORAGE_EXTERNAL);
+ __pPackageInfoImpl->SetAppStorageType(PACKAGE_STORAGE_TYPE_EXTERNAL);
+ }
+
+ return true;
+}
+
+bool
ManifestHandler::OnAppControlElement(void)
{
XmlAttribute *pAttr = null;
diff --git a/src/XmlHandler/ManifestHandler.h b/src/XmlHandler/ManifestHandler.h
index 59ab3c2..1024d73 100755
--- a/src/XmlHandler/ManifestHandler.h
+++ b/src/XmlHandler/ManifestHandler.h
@@ -80,6 +80,7 @@ private:
bool OnConditionValue(const char *pCharacters);
bool OnNotificationValue(const char *pCharacters);
bool OnSizeValue(const char *pCharacters);
+ bool OnInstallationLocationValue(const char *pCharacters);
bool OnAppControlElement(void);
bool OnCapabilityElement(void);