From c7b504b2506c5718e1611c2258b3e345363e0a8c Mon Sep 17 00:00:00 2001 From: Jihoon Chung Date: Tue, 30 Apr 2013 12:07:40 +0900 Subject: [PATCH] [Release] wrt-installer_0.1.47 --- CMakeLists.txt | 23 +++--- packaging/wrt-installer.spec | 4 +- src/configuration_parser/widget_parser.cpp | 90 ++++++++++++++++++++++ src/configuration_parser/widget_parser.h | 1 + src/jobs/widget_install/task_database.cpp | 28 +++---- src/jobs/widget_install/task_file_manipulation.cpp | 6 ++ src/jobs/widget_install/task_smack.cpp | 7 ++ src/jobs/widget_install/task_smack.h | 1 + src/jobs/widget_install/task_widget_config.cpp | 41 ++++++++++ src/jobs/widget_install/task_widget_config.h | 1 + src/jobs/widget_uninstall/job_widget_uninstall.cpp | 5 +- src/jobs/widget_uninstall/task_remove_files.cpp | 7 +- src/jobs/widget_uninstall/uninstaller_context.h | 1 + src/wrt-installer/wrt-installer.cpp | 4 +- 14 files changed, 179 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b9bb8b9..a548f68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,13 +34,12 @@ ENDIF(NOT CMAKE_BUILD_TYPE) ############################# compilation defines ############################# - -#csp from .xml parsing enabled -OPTION(CSP_SUPPORT "Support for csp policy" OFF) - -IF(CSP_SUPPORT) - ADD_DEFINITIONS("-DCSP_ENABLED") -ENDIF(CSP_SUPPORT) +OPTION(DPL_LOG "DPL logs status" ON) +OPTION(WITH_TESTS "Build tests" OFF) +OPTION(MULTIPROCESS_SERVICE_SUPPORT "Process per service" OFF) +OPTION(MULTIPROCESS_SERVICE_SUPPORT_INLINE "Process per service - inline mode support" OFF) +OPTION(CSP_SUPPORT "Support for csp policy" ON) +OPTION(ALLOW_NAVIGATION_SUPPORT "Support for allow-navigation" ON) ############################# compiler flags ################################## @@ -52,10 +51,6 @@ SET(CMAKE_C_FLAGS_RELEASE "-O2 -g") SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -std=c++0x -g") SET(CMAKE_CXX_FLAGS_CCOV "-O0 -std=c++0x -g --coverage") -OPTION(DPL_LOG "DPL logs status" ON) -OPTION(WITH_TESTS "Build tests" OFF) -OPTION(MULTIPROCESS_SERVICE_SUPPORT "Process per service" OFF) -OPTION(MULTIPROCESS_SERVICE_SUPPORT_INLINE "Process per service - inline mode support" OFF) IF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling") MESSAGE(STATUS "Logging enabled for DPL") ADD_DEFINITIONS("-DDPL_LOGS_ENABLED") @@ -69,6 +64,12 @@ IF(MULTIPROCESS_SERVICE_SUPPORT) ADD_DEFINITIONS("-DMULTIPROCESS_SERVICE_SUPPORT_INLINE") ENDIF(MULTIPROCESS_SERVICE_SUPPORT_INLINE) ENDIF(MULTIPROCESS_SERVICE_SUPPORT) +IF(CSP_SUPPORT) + ADD_DEFINITIONS("-DCSP_ENABLED") +ENDIF(CSP_SUPPORT) +IF(ALLOW_NAVIGATION_SUPPORT) + ADD_DEFINITIONS("-DALLOW_NAVIGATION_ENABLED") +ENDIF(CSP_SUPPORT) # If supported for the target machine, emit position-independent code,suitable # for dynamic linking and avoiding any limit on the size of the global offset diff --git a/packaging/wrt-installer.spec b/packaging/wrt-installer.spec index f0815c0..54d113f 100644 --- a/packaging/wrt-installer.spec +++ b/packaging/wrt-installer.spec @@ -1,7 +1,7 @@ -#git:framework/web/wrt-installer wrt-installer 0.1.41 +#git:framework/web/wrt-installer wrt-installer 0.1.47 Name: wrt-installer Summary: Installer for tizen Webruntime -Version: 0.1.41 +Version: 0.1.47 Release: 1 Group: Development/Libraries License: Apache License, Version 2.0 diff --git a/src/configuration_parser/widget_parser.cpp b/src/configuration_parser/widget_parser.cpp index da4e1b9..289e30d 100644 --- a/src/configuration_parser/widget_parser.cpp +++ b/src/configuration_parser/widget_parser.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -1740,6 +1741,8 @@ class AppWidgetParser : public ElementParser m_width = attribute.value; } else if (attribute.name == L"height") { m_height = attribute.value; + } else if (attribute.name == L"fast-open") { + m_fastOpen= attribute.value; } } } @@ -1761,6 +1764,7 @@ class AppWidgetParser : public ElementParser m_data.m_pdSrc = m_src; m_data.m_pdWidth = m_width; m_data.m_pdHeight = m_height; + m_data.m_pdFastOpen = m_fastOpen; } explicit PdParser( @@ -1774,6 +1778,7 @@ class AppWidgetParser : public ElementParser DPL::String m_src; DPL::String m_width; DPL::String m_height; + DPL::String m_fastOpen; bool m_properNamespace; ConfigParserData::LiveboxInfo::BoxContentInfo& m_data; @@ -1941,6 +1946,82 @@ class AppWidgetParser : public ElementParser bool m_properNamespace; }; +class AllowNavigationParser : public ElementParser +{ + public: + AllowNavigationParser(ConfigParserData& data) : + ElementParser(), + m_data(data), + m_properNamespace(false) + {} + + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& /*name*/) + { + return &IgnoringParser::Create; + } + + virtual void Accept(const Element& element) + { + if (element.ns == ConfigurationNamespace::TizenWebAppNamespaceName) { + m_properNamespace = true; + } + } + + virtual void Accept(const Text& text) + { + if (m_properNamespace) { + m_origin = text.value; + } + } + + virtual void Accept(const XmlAttribute& /*attribute*/) + { + } + + virtual void Verify() + { + if (m_origin.IsNull()) { + LogWarning("data is empty"); + return; + } + + char* data = strdup(DPL::ToUTF8String(*m_origin).c_str()); + char* ptr = strtok(data," "); + while (ptr != NULL) { + std::string origin = ptr; + ptr = strtok(NULL," "); + if(origin == "*") { + ConfigParserData::AllowNavigationInfo info(L"*", L"*"); + m_data.allowNavigationInfoList.push_back(info); + continue; + } + + DPL::ScopedPtr iri(iri_parse(origin.c_str())); + if (!iri->host || strlen(iri->host) == 0) { + // input origin should has schem and host + // in case of file scheme path is filled + // "http://" + LogWarning("input origin isn't verified"); + continue; + } + DPL::String scheme = L"*"; + if (iri->scheme && strlen(iri->scheme) != 0) { + scheme = DPL::FromUTF8String(iri->scheme); + } + ConfigParserData::AllowNavigationInfo info( + scheme, + DPL::FromUTF8String(iri->host)); + m_data.allowNavigationInfoList.push_back(info); + } + } + + private: + DPL::OptionalString m_origin; + ConfigParserData& m_data; + bool m_properNamespace; +}; + class CspParser : public ElementParser { public: @@ -2361,6 +2442,10 @@ WidgetParser::WidgetParser(ConfigParserData& data) : &WidgetParser:: OnCspReportOnlyElement); #endif +#ifdef ALLOW_NAVIGATION_ENABLED + m_map[L"allow-navigation"] = + DPL::MakeDelegate(this, &WidgetParser::OnAllowNavigationElement); +#endif m_map[L"account"] = DPL::MakeDelegate(this, &WidgetParser::OnAccountElement); } @@ -2459,6 +2544,11 @@ ElementParserPtr WidgetParser::OnCspReportOnlyElement() return ElementParserPtr(new CspReportOnlyParser(m_data)); } +ElementParserPtr WidgetParser::OnAllowNavigationElement() +{ + return ElementParserPtr(new AllowNavigationParser(m_data)); +} + ElementParserPtr WidgetParser::OnAccountElement() { return ElementParserPtr(new AccountParser(m_data)); diff --git a/src/configuration_parser/widget_parser.h b/src/configuration_parser/widget_parser.h index 883a5fc..c1147c9 100644 --- a/src/configuration_parser/widget_parser.h +++ b/src/configuration_parser/widget_parser.h @@ -83,6 +83,7 @@ class WidgetParser : public ElementParser ElementParserPtr OnAppWidgetElement(); ElementParserPtr OnCspElement(); ElementParserPtr OnCspReportOnlyElement(); + ElementParserPtr OnAllowNavigationElement(); ElementParserPtr OnAccountElement(); virtual ActionFunc GetElementParser(const DPL::String& ns, diff --git a/src/jobs/widget_install/task_database.cpp b/src/jobs/widget_install/task_database.cpp index bf49632..0258359 100644 --- a/src/jobs/widget_install/task_database.cpp +++ b/src/jobs/widget_install/task_database.cpp @@ -304,12 +304,13 @@ void TaskDatabase::StepLiveboxDBInsert() std::string tizenId = DPL::ToUTF8String(m_context.widgetConfig.tzAppid); + // insert specific information to web livebox db for (auto it = m_context.widgetConfig.configInfo.m_livebox.begin(); it != m_context.widgetConfig.configInfo.m_livebox.end(); ++it) { std::string boxId = DPL::ToUTF8String((**it).m_liveboxId); std::string boxType; - if ((**it).m_type == L"") { + if ((**it).m_type.empty()) { boxType = web_provider_livebox_get_default_type(); } else { boxType = DPL::ToUTF8String((**it).m_type); @@ -317,29 +318,18 @@ void TaskDatabase::StepLiveboxDBInsert() LogInfo("livebox id: " << boxId); LogInfo("livebox type: " << boxType); - int autoLaunch; - if ((**it).m_autoLaunch == L"true") { - autoLaunch = 1; - } else { - autoLaunch = 0; - } + int autoLaunch = (**it).m_autoLaunch == L"true" ? 1 : 0; LogInfo("livebox auto-launch: " << autoLaunch); - int mouseEvent; - if ((**it).m_boxInfo.m_boxMouseEvent == L"true") { - mouseEvent = 1; - } else { - mouseEvent = 0; - } + int mouseEvent = (**it).m_boxInfo.m_boxMouseEvent == L"true" ? 1 : 0; LogInfo("livebox mouse-event: " << mouseEvent); - int ret = - web_provider_livebox_insert_box_info( - boxId.c_str(), tizenId.c_str(), boxType.c_str(), autoLaunch, mouseEvent); + int pdFastOpen = (**it).m_boxInfo.m_pdFastOpen == L"true" ? 1 : 0; + LogInfo("livebox pd fast-open: " << pdFastOpen); - if (ret < 0) { - LogDebug("failed to set type of livebox: " << boxId); - } + web_provider_livebox_insert_box_info( + boxId.c_str(), tizenId.c_str(), boxType.c_str(), + autoLaunch, mouseEvent, pdFastOpen); } } } //namespace WidgetInstall diff --git a/src/jobs/widget_install/task_file_manipulation.cpp b/src/jobs/widget_install/task_file_manipulation.cpp index a07944d..4e25780 100644 --- a/src/jobs/widget_install/task_file_manipulation.cpp +++ b/src/jobs/widget_install/task_file_manipulation.cpp @@ -309,6 +309,12 @@ void TaskFileManipulation::StepAbortRenamePath() ThrowMsg(Exceptions::RemovingFolderFailure, "Error occurs during removing existing folder"); } + // Remove user data directory if preload web app. + std::string userData = m_context.locations->getUserDataRootDir(); + if (0 == access(userData.c_str(), F_OK)) { + WrtUtilRemove(userData); + } + } LogDebug("Rename widget path sucessful!"); } diff --git a/src/jobs/widget_install/task_smack.cpp b/src/jobs/widget_install/task_smack.cpp index a9c285a..a5624a9 100644 --- a/src/jobs/widget_install/task_smack.cpp +++ b/src/jobs/widget_install/task_smack.cpp @@ -47,6 +47,7 @@ TaskSmack::TaskSmack(InstallerContext& context) : AddStep(&TaskSmack::SmackFolderLabelingStep); AddStep(&TaskSmack::SmackPrivilegeStep); AddStep(&TaskSmack::SmackTemporaryStep); + AddStep(&TaskSmack::SetEndofInstallation); } void TaskSmack::SmackFolderLabelingStep() @@ -174,5 +175,11 @@ void TaskSmack::SmackTemporaryStep() #endif } +void TaskSmack::SetEndofInstallation() +{ + m_context.job->UpdateProgress( + InstallerContext::INSTALL_END, + "End installation"); +} } //namespace WidgetInstall } //namespace Jobs diff --git a/src/jobs/widget_install/task_smack.h b/src/jobs/widget_install/task_smack.h index b602819..4b09f19 100644 --- a/src/jobs/widget_install/task_smack.h +++ b/src/jobs/widget_install/task_smack.h @@ -39,6 +39,7 @@ class TaskSmack : void SmackFolderLabelingStep(); void SmackPrivilegeStep(); void SmackTemporaryStep(); + void SetEndofInstallation(); public: TaskSmack(InstallerContext& context); diff --git a/src/jobs/widget_install/task_widget_config.cpp b/src/jobs/widget_install/task_widget_config.cpp index ac99419..c5bbc5b 100644 --- a/src/jobs/widget_install/task_widget_config.cpp +++ b/src/jobs/widget_install/task_widget_config.cpp @@ -78,6 +78,7 @@ TaskWidgetConfig::TaskWidgetConfig(InstallerContext& installContext) : AddStep(&TaskWidgetConfig::ProcessLocalizedIcons); AddStep(&TaskWidgetConfig::ProcessWidgetInstalledPath); AddStep(&TaskWidgetConfig::ProcessAppControlInfo); + AddStep(&TaskWidgetConfig::ProcessSecurityModel); AddStep(&TaskWidgetConfig::StepVerifyFeatures); AddStep(&TaskWidgetConfig::StepCheckMinVersionInfo); } @@ -408,6 +409,46 @@ void TaskWidgetConfig::ProcessAppControlInfo() } } +void TaskWidgetConfig::ProcessSecurityModel() +{ + bool isSecurityModelV1 = false; + bool isSecurityModelV2 = false; + WrtDB::ConfigParserData &data = m_installContext.widgetConfig.configInfo; + + // WARP is V1 + if (!data.accessInfoSet.empty()) { + isSecurityModelV1 = true; + } + + // CSP is V2 + if (!data.cspPolicy.IsNull() || !data.cspPolicyReportOnly.IsNull()) { + isSecurityModelV2 = true; + } + + // allow-navigation is V2 + if (!data.allowNavigationInfoList.empty()) { + isSecurityModelV2 = true; + } + + if (isSecurityModelV1 && isSecurityModelV2) { + LogError("Security model is conflict"); + ThrowMsg(Exceptions::NotAllowed, "Security model is conflict"); + } else if (isSecurityModelV1) { + data.securityModelVersion = + WrtDB::ConfigParserData::SecurityModelVersion::SECURITY_MODEL_V1; + } else if (isSecurityModelV2) { + data.securityModelVersion = + WrtDB::ConfigParserData::SecurityModelVersion::SECURITY_MODEL_V2; + } else { + data.securityModelVersion = + WrtDB::ConfigParserData::SecurityModelVersion::SECURITY_MODEL_V1; + } + + m_installContext.job->UpdateProgress( + InstallerContext::INSTALL_WIDGET_CONFIG2, + "Finished process security model"); +} + void TaskWidgetConfig::StepCheckMinVersionInfo() { if (!isMinVersionCompatible( diff --git a/src/jobs/widget_install/task_widget_config.h b/src/jobs/widget_install/task_widget_config.h index b267257..6b500d3 100644 --- a/src/jobs/widget_install/task_widget_config.h +++ b/src/jobs/widget_install/task_widget_config.h @@ -79,6 +79,7 @@ class TaskWidgetConfig : void ProcessIcon(const WrtDB::ConfigParserData::Icon& icon); void ProcessWidgetInstalledPath(); void ProcessAppControlInfo(); + void ProcessSecurityModel(); void StepVerifyFeatures(); void StepCheckMinVersionInfo(); diff --git a/src/jobs/widget_uninstall/job_widget_uninstall.cpp b/src/jobs/widget_uninstall/job_widget_uninstall.cpp index 322d66c..986ee29 100644 --- a/src/jobs/widget_uninstall/job_widget_uninstall.cpp +++ b/src/jobs/widget_uninstall/job_widget_uninstall.cpp @@ -105,6 +105,8 @@ JobWidgetUninstall::JobWidgetUninstall( m_context.tzPkgid = DPL::ToUTF8String(dao.getTizenPkgId()); m_context.locations = WidgetLocation(m_context.tzPkgid); m_context.locations->registerAppid(m_context.tzAppid); + m_context.installedPath = + DPL::ToUTF8String(*dao.getWidgetInstalledPath()); LogInfo("Widget model exists. App id : " << m_context.tzAppid); @@ -171,8 +173,7 @@ WidgetStatus JobWidgetUninstall::getWidgetStatus(const std::string &id) if (0 == installPath.compare(0, PRELOAD_INSTALLED_PATH.length(), PRELOAD_INSTALLED_PATH)) { - LogError("This widget is prealoaded. So it cann't be removed"); - return WidgetStatus::PREALOAD; + LogDebug("This widget is prealoded."); } } Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) { LogDebug("package id : " << pkgId); diff --git a/src/jobs/widget_uninstall/task_remove_files.cpp b/src/jobs/widget_uninstall/task_remove_files.cpp index 47ae2ff..2cd9538 100644 --- a/src/jobs/widget_uninstall/task_remove_files.cpp +++ b/src/jobs/widget_uninstall/task_remove_files.cpp @@ -69,10 +69,9 @@ void TaskRemoveFiles::StepRemoveInstallationDirectory() { LogDebug("Removing directory"); m_context.removeStarted = true; - std::string widgetDir = - m_context.locations->getPackageInstallationDir(); - if (!WrtUtilRemove(widgetDir)) { - LogError("Removing widget installation directory failed"); + if (!WrtUtilRemove(m_context.installedPath)) { + LogError("Removing widget installation directory failed : " << + m_context.installedPath); } std::string dataDir = m_context.locations->getUserDataRootDir(); if (!WrtUtilRemove(dataDir)) { diff --git a/src/jobs/widget_uninstall/uninstaller_context.h b/src/jobs/widget_uninstall/uninstaller_context.h index f705b78..f3eb7c1 100644 --- a/src/jobs/widget_uninstall/uninstaller_context.h +++ b/src/jobs/widget_uninstall/uninstaller_context.h @@ -62,6 +62,7 @@ struct UninstallerContext std::string tzAppid; std::string tzPkgid; bool removeAbnormal; + std::string installedPath; }; #endif // WRT_SRC_INSTALLER_CORE_UNINSTALLER_TASKS_UNINSTALLER_CONTEXT_H_ diff --git a/src/wrt-installer/wrt-installer.cpp b/src/wrt-installer/wrt-installer.cpp index a61a96a..58db8f4 100644 --- a/src/wrt-installer/wrt-installer.cpp +++ b/src/wrt-installer/wrt-installer.cpp @@ -1001,14 +1001,14 @@ CSCConfiguration::dataMap WrtInstaller::parseCSCConfiguration( const char* ptr = strtok(buf,":"); while (ptr != NULL) { std::string string = ptr; + ptr = strtok (NULL, ":"); size_t pos = string.find('='); if (pos == std::string::npos) { continue; } result.insert( CSCConfiguration::dataPair(string.substr(0, pos), - string.substr(pos+1))); - ptr = strtok (NULL, ":"); + string.substr(pos+1))); } return result; } -- 2.7.4