From 164faf19122809d7b82f3c7b1206b5f8611fca31 Mon Sep 17 00:00:00 2001 From: Duyoung Jang Date: Tue, 9 Oct 2012 20:14:35 +0900 Subject: [PATCH] Update to install Hybrid apps Change-Id: I9877e0110c66881db9563d08d6f54df81b64b8b4 --- inc/InstallerDefs.h | 2 +- src/Context/InstallationContext.cpp | 14 ++++- src/Context/InstallationContext.h | 5 +- src/Manager/ConfigurationManager.cpp | 108 ++++++++++++++++++++++++++++++----- src/Manager/ConfigurationManager.h | 1 + src/Manager/InstallerManager.cpp | 24 ++++++-- src/Manager/InstallerManager.h | 4 +- src/Manager/PermissionManager.cpp | 1 + src/Step/SignatureStep.h | 3 + src/Step/UninstallStep.cpp | 18 +++++- src/XmlHandler/ManifestGenerator.cpp | 16 +++--- 11 files changed, 161 insertions(+), 35 deletions(-) diff --git a/inc/InstallerDefs.h b/inc/InstallerDefs.h index ba24d5b..5f50fa7 100755 --- a/inc/InstallerDefs.h +++ b/inc/InstallerDefs.h @@ -70,7 +70,7 @@ #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/09/24" +#define OSP_INSTALLER_VERSION "osp-installer version = 2012/10/09" enum InstallationSetStep { diff --git a/src/Context/InstallationContext.cpp b/src/Context/InstallationContext.cpp index a940c68..7b34d70 100755 --- a/src/Context/InstallationContext.cpp +++ b/src/Context/InstallationContext.cpp @@ -46,7 +46,7 @@ InstallationContext::InstallationContext(void) ,__stepChanged(true) ,__continue(true) ,__preloaded(false) -,__webService(false) +,__hybridService(false) ,__operation(INSTALLER_OPERATION_INSTALL) ,__storage(INSTALLATION_STORAGE_INTERNAL) ,__pPrivilegeList(null) @@ -245,6 +245,18 @@ InstallationContext::SetPreloaded(bool preloaded) __preloaded = preloaded; } +bool +InstallationContext::IsHybridService(void) +{ + return __hybridService; +} + +void +InstallationContext::SetHybridService(bool hybridService) +{ + __hybridService = hybridService; +} + const String& InstallationContext::GetPackagePath(void) const { diff --git a/src/Context/InstallationContext.h b/src/Context/InstallationContext.h index 6898412..a030b4e 100755 --- a/src/Context/InstallationContext.h +++ b/src/Context/InstallationContext.h @@ -81,6 +81,9 @@ public: bool IsPreloaded(void); void SetPreloaded(bool preloaded); + bool IsHybridService(void); + void SetHybridService(bool hybridService); + const Osp::Base::String& GetPackagePath(void) const; void SetPackagePath(const Osp::Base::String& packagePath); @@ -129,7 +132,7 @@ private: bool __stepChanged; bool __continue; bool __preloaded; - bool __webService; + bool __hybridService; Osp::Base::String __inputPath; InstallerOperation __operation; diff --git a/src/Manager/ConfigurationManager.cpp b/src/Manager/ConfigurationManager.cpp index 4a21f1b..525b029 100755 --- a/src/Manager/ConfigurationManager.cpp +++ b/src/Manager/ConfigurationManager.cpp @@ -57,6 +57,7 @@ ConfigurationManager::CreateFile(InstallationContext* pContext) String xmlPath; char* pXmlPath = null; int err = 0; + bool hybridService = pContext->IsHybridService(); _PackageInfoImpl *pPackageInfoImpl = null; pPackageInfoImpl = pContext->GetPackageInfoImpl(); @@ -200,20 +201,29 @@ ConfigurationManager::CreateFile(InstallationContext* pContext) pXmlPath = _StringConverter::CopyToCharArrayN(xmlPath); TryCatch(pXmlPath != null, res = false, "[osp-installer] pXmlPath is null"); - pkgmgr_parser_parse_manifest_for_uninstallation(pXmlPath, null); - - CreateSystemXmlFile(pContext); + if (hybridService == true) + { + CreateHybridServiceDesktopFile(pContext); + } + else + { + pkgmgr_parser_parse_manifest_for_uninstallation(pXmlPath, null); + CreateSystemXmlFile(pContext); + } AppLogTag(OSP_INSTALLER, "START(sync)"); sync(); AppLogTag(OSP_INSTALLER, "END(sync)"); - AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_installation() START"); - if (pkgmgr_parser_parse_manifest_for_installation(pXmlPath, null) != 0) + if (hybridService == false) { - AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_installation() is failed.[%s]", pXmlPath); + AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_installation() START"); + if (pkgmgr_parser_parse_manifest_for_installation(pXmlPath, null) != 0) + { + AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_installation() is failed.[%s]", pXmlPath); + } + AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_installation() END"); } - AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_installation() END"); res = true; @@ -245,18 +255,26 @@ ConfigurationManager::RemoveFile(InstallationContext* pContext) pXmlPath = _StringConverter::CopyToCharArrayN(xmlPath); TryCatch(pXmlPath != null, , "[osp-installer] pXmlPath is null"); - AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_uninstallation() START"); - if (pkgmgr_parser_parse_manifest_for_uninstallation(pXmlPath, null) != 0) + if (pContext->IsHybridService() == true) { - AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_uninstallation() is failed.[%s]", pXmlPath); - } - AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_uninstallation() END"); + AppLogTag(OSP_INSTALLER, "Uninstallation for HybridService - skip"); - if (File::IsFileExist(xmlPath) == true) + } + else { - AppLogTag(OSP_INSTALLER, "removing xml filePath=[%ls]", xmlPath.GetPointer()); + AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_uninstallation() START"); + if (pkgmgr_parser_parse_manifest_for_uninstallation(pXmlPath, null) != 0) + { + AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_uninstallation() is failed.[%s]", pXmlPath); + } + AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_uninstallation() END"); + + if (File::IsFileExist(xmlPath) == true) + { + AppLogTag(OSP_INSTALLER, "removing xml filePath=[%ls]", xmlPath.GetPointer()); - InstallerUtil::Remove(xmlPath); + InstallerUtil::Remove(xmlPath); + } } pPackageInfoImpl = pContext->GetPackageInfoImpl(); @@ -306,6 +324,66 @@ ConfigurationManager::CreateSystemXmlFile(InstallationContext* pContext) } bool +ConfigurationManager::CreateHybridServiceDesktopFile(InstallationContext* pContext) +{ + AppLogTag(OSP_INSTALLER, "HybridServiceDesktopFile - START"); + + bool ret = true; + _PackageInfoImpl *pPackageInfoImpl = pContext->GetPackageInfoImpl(); + _PackageAppInfoImpl* pAppInfoImpl = null; + ArrayList* pAppList = null; + pAppList = pPackageInfoImpl->GetAppInfoList(); + + for (int i = 0 ; i < pAppList->GetCount(); i++) + { + pAppInfoImpl = dynamic_cast<_PackageAppInfoImpl*>(pAppList->GetAt(i)); + + if (pAppInfoImpl) + { + String name; + name.Format(1024, L"%ls", pPackageInfoImpl->GetAppName().GetPointer()); + + String binaryPath; + binaryPath.Format(1024, L"%ls%ls/%ls", pPackageInfoImpl->GetAppRootPath().GetPointer(), DIR_BIN, pAppInfoImpl->GetName().GetPointer()); + + String iconPath; + iconPath.Format(1024, L"%ls%ls/%ls", pPackageInfoImpl->GetAppRootPath().GetPointer(), DIR_ICONS, pAppInfoImpl->GetMainmenuIcon().GetPointer()); + + String version; + version.Format(1024, L"%ls", pPackageInfoImpl->GetAppVersion().GetPointer()); + + String desktop; + desktop.Format(1024, L"[Desktop Entry]\n" + "Name=%ls\n" + "Name[en_GB]=%ls\n" + "Type=Application\n" + "Exec=%ls\n" + "Icon=%ls\n" + "Version=%ls\n" + "NoDisplay=true\n" + "X-TIZEN-TaskManage=False\n" + "X-TIZEN-PackageType=tpk\n", + name.GetPointer(), name.GetPointer(), binaryPath.GetPointer(), iconPath.GetPointer(), version.GetPointer()); + + String desktopPath; + desktopPath.Format(1024, L"/opt/share/applications/%ls.desktop", pAppInfoImpl->GetPackageName().GetPointer()); + + if (File::IsFileExist(desktopPath) == true) + { + AppLogTag(OSP_INSTALLER, "removing desktop filePath=[%ls]", desktopPath.GetPointer()); + InstallerUtil::Remove(desktopPath); + } + + CreateInfoFile(desktopPath, &desktop); + } + } + + AppLogTag(OSP_INSTALLER, "HybridServiceDesktopFile - END"); + + return ret; +} + +bool ConfigurationManager::CreateInfoFile(const String& filePath, const String* pContext) { result r = E_SUCCESS; diff --git a/src/Manager/ConfigurationManager.h b/src/Manager/ConfigurationManager.h index 31b8995..d5e7dc9 100755 --- a/src/Manager/ConfigurationManager.h +++ b/src/Manager/ConfigurationManager.h @@ -47,6 +47,7 @@ public: private: bool CreateSystemXmlFile(InstallationContext* pContext); + bool CreateHybridServiceDesktopFile(InstallationContext* pContext); bool CreateInfoFile(const Osp::Base::String& filePath, const Osp::Base::String* pContext); bool FindPrivilege(InstallationContext* pContext, const Osp::Base::String& privilege) const; diff --git a/src/Manager/InstallerManager.cpp b/src/Manager/InstallerManager.cpp index fefc02d..1265522 100755 --- a/src/Manager/InstallerManager.cpp +++ b/src/Manager/InstallerManager.cpp @@ -71,7 +71,7 @@ InstallerManager::GetInstance() } InstallerError -InstallerManager::Construct(const String& path, InstallerType installerType, InstallerOperation operation, RequesterType requesterType) +InstallerManager::Construct(const String& path, InstallerType installerType, InstallerOperation operation, RequesterType requesterType, bool hybridService) { InstallerError error = INSTALLER_ERROR_NONE; @@ -88,6 +88,12 @@ InstallerManager::Construct(const String& path, InstallerType installerType, Ins __pContext->SetPreloaded(true); } + if (hybridService == true) + { + AppLogTag(OSP_INSTALLER, "Request to install HybridService app!"); + __pContext->SetHybridService(true); + } + __pInstaller = CreateInstaller(installerType); TryReturn(__pInstaller, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] __pInstaller is null."); @@ -299,13 +305,12 @@ InstallerManager::GetContext(void) } int -InstallerManager::Request(const String& path, InstallerOperation operation, RequesterType requesterType, String& appid, int& errorType) +InstallerManager::Request(const String& path, InstallerOperation operation, RequesterType requesterType, String& appid, int& errorType, bool hybridService) { InstallerType type = INSTALLER_TYPE_INSTALLER; InstallationContext* pContext = null; InstallerError error = INSTALLER_ERROR_NONE; InstallerManager* pInstallManager = null; - //bool isRunning = false; AppLogTag(OSP_INSTALLER, "------------------------------------------"); AppLogTag(OSP_INSTALLER, "InstallerManager::Request"); @@ -337,7 +342,7 @@ InstallerManager::Request(const String& path, InstallerOperation operation, Requ pInstallManager = InstallerManager::GetInstance(); TryCatch(pInstallManager, error = INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] pInstallManager is null."); - error = pInstallManager->Construct(path, type, operation, requesterType); + error = pInstallManager->Construct(path, type, operation, requesterType, hybridService); TryCatch(error == INSTALLER_ERROR_NONE, , "[osp-installer] pInstallManager->Construct() failed."); error = pInstallManager->Activate(); @@ -480,6 +485,7 @@ InstallerManager::RequestByCommand(int argc, char **argv) int errorType = -1; int result = 0; bool output = false; + bool hybridService = false; fprintf(stderr, "%s\n", OSP_INSTALLER_VERSION); AppLogTag(OSP_INSTALLER, "%s", OSP_INSTALLER_VERSION); @@ -495,6 +501,12 @@ InstallerManager::RequestByCommand(int argc, char **argv) ParseCommandArg(argc, argv, &mode, buf, &output); + if (output == true) + { + AppLogTag(OSP_INSTALLER, "HybridService is detected in ParseCommandArg()"); + hybridService = true; + } + switch (mode) { case INSTALLER_MODE_INSTALL: @@ -504,7 +516,7 @@ InstallerManager::RequestByCommand(int argc, char **argv) fprintf(stderr, " # directory = [%s]\n", buf); AppLogTag(OSP_INSTALLER, " # directory = [%s]", buf); - result = InstallerManager::Request(buf, INSTALLER_OPERATION_INSTALL, REQUESTER_TYPE_NORMAL, appId, errorType); + result = InstallerManager::Request(buf, INSTALLER_OPERATION_INSTALL, REQUESTER_TYPE_NORMAL, appId, errorType, hybridService); fprintf(stderr, " # appId = [%ls], error = [%d]\n", appId.GetPointer(), errorType); AppLogTag(OSP_INSTALLER, " # appId = [%ls], error = [%d]", appId.GetPointer(), errorType); @@ -530,7 +542,7 @@ InstallerManager::RequestByCommand(int argc, char **argv) fprintf(stderr, " # directory = [%s]\n", buf); AppLogTag(OSP_INSTALLER, " # directory = [%s]", buf); - result = Request(buf, INSTALLER_OPERATION_UNINSTALL, REQUESTER_TYPE_NORMAL, appId, errorType); + result = Request(buf, INSTALLER_OPERATION_UNINSTALL, REQUESTER_TYPE_NORMAL, appId, errorType, hybridService); fprintf(stderr, " # appId = [%ls], error = [%d]\n", appId.GetPointer(), errorType); AppLogTag(OSP_INSTALLER, " # appId = [%ls], error = [%d]", appId.GetPointer(), errorType); diff --git a/src/Manager/InstallerManager.h b/src/Manager/InstallerManager.h index 2b583bb..b00f8c6 100755 --- a/src/Manager/InstallerManager.h +++ b/src/Manager/InstallerManager.h @@ -38,13 +38,13 @@ class InstallerManager { public: InstallerManager(void); - InstallerError Construct(const Osp::Base::String& path, InstallerType installerType, InstallerOperation op, RequesterType requesterType); + InstallerError Construct(const Osp::Base::String& path, InstallerType installerType, InstallerOperation op, RequesterType requesterType, bool hybridService = false); virtual ~InstallerManager(void); static InstallerManager* GetInstance(void); void Release(void); - int Request(const Osp::Base::String& path, InstallerOperation op, RequesterType requesterType, Osp::Base::String& appid, int& errorType); + int Request(const Osp::Base::String& path, InstallerOperation op, RequesterType requesterType, Osp::Base::String& appid, int& errorType, bool hybridService = false); int RequestRecursiveDirectory(const Osp::Base::String& path, int& errorType); bool RemoveGarbage(const char* pDirectory); diff --git a/src/Manager/PermissionManager.cpp b/src/Manager/PermissionManager.cpp index c6728ea..8f25f68 100755 --- a/src/Manager/PermissionManager.cpp +++ b/src/Manager/PermissionManager.cpp @@ -410,6 +410,7 @@ PermissionManager::CreateSystemDirectory(InstallationContext* pContext, const Os TryReturn(pPackageInfoImpl, false, "[osp-installer] pPackageInfoImpl is null."); pAppList = pPackageInfoImpl->GetAppInfoList(); + TryReturn(pAppList, false, "[osp-installer] pAppList is null."); for (int i = 0 ; i < pAppList->GetCount(); i++) { diff --git a/src/Step/SignatureStep.h b/src/Step/SignatureStep.h index 25d912b..6cd743b 100755 --- a/src/Step/SignatureStep.h +++ b/src/Step/SignatureStep.h @@ -52,6 +52,9 @@ private: STATE_DONE }; + SignatureStep(const SignatureStep& value); + SignatureStep& operator =(const SignatureStep& source); + void GoNextState(void); InstallerError OnStateSignerCert(void); InstallerError OnStateCertChain(void); diff --git a/src/Step/UninstallStep.cpp b/src/Step/UninstallStep.cpp index 9d53904..bd1022a 100755 --- a/src/Step/UninstallStep.cpp +++ b/src/Step/UninstallStep.cpp @@ -118,6 +118,13 @@ UninstallStep::OnStateGetPackageInfo(void) InstallerError error = INSTALLER_ERROR_NONE; AppLogTag(OSP_INSTALLER, "UninstallStep::OnStateCheckAppRunning()"); + if (__pContext->IsHybridService() == true) + { + AppLogTag(OSP_INSTALLER, "Uninstallation for HybridService"); + __state = STATE_DELETE_DIR; + return error; + } + String appId; appId = __pContext->GetAppId(); @@ -191,7 +198,16 @@ UninstallStep::OnStateRemoveDir(void) AppLogTag(OSP_INSTALLER, "rootPath[%ls]", rootPath.GetPointer()); AppLogTag(OSP_INSTALLER, "Directory::Remove - START"); - InstallerUtil::Remove(rootPath); + + if (__pContext->IsHybridService() == true) + { + AppLogTag(OSP_INSTALLER, "Uninstallation for HybridService - skip Remove"); + + } + else + { + InstallerUtil::Remove(rootPath); + } _PackageAppInfoImpl* pAppInfoImpl = null; ArrayList* pAppList = null; diff --git a/src/XmlHandler/ManifestGenerator.cpp b/src/XmlHandler/ManifestGenerator.cpp index 1b5f422..4883b12 100755 --- a/src/XmlHandler/ManifestGenerator.cpp +++ b/src/XmlHandler/ManifestGenerator.cpp @@ -65,16 +65,16 @@ ManifestGenerator::Write() pPackageInfoImpl = __pContext->GetPackageInfoImpl(); TryReturn(pPackageInfoImpl, false, "[osp-installer] pPackageInfoImpl is null."); - if (preload == true) - { - xmlPath.Format(1024, DIR_RO_PACKAGE_SYSTEM_MANIFEST, __pContext->GetAppId().GetPointer()); - location = L"internal-only"; - } - else - { + //if (preload == true) + //{ + // xmlPath.Format(1024, DIR_RO_PACKAGE_SYSTEM_MANIFEST, __pContext->GetAppId().GetPointer()); + // location = L"internal-only"; + //} + //else + //{ xmlPath.Format(1024, DIR_RW_PACKAGE_SYSTEM_MANIFEST, __pContext->GetAppId().GetPointer()); location = L"auto"; - } + //} package = __pContext->GetAppId(); -- 2.7.4