From a599d8c8880c986ac7e6b3a2c01d39bbca00e2c4 Mon Sep 17 00:00:00 2001 From: Jihoon Chung Date: Thu, 6 Jun 2013 20:19:59 +0900 Subject: [PATCH] [Release] wrt-installer_0.1.74 Change-Id: I13d4ac931177c9368d45f60d55bb696d6bcf97c7 --- CMakeLists.txt | 6 + configuration/CMakeLists.txt | 2 + configuration/access.xsd | 29 ++ configuration/common.xsd | 79 ++++ configuration/config.xsd | 190 -------- configuration/its.xsd | 15 - configuration/local.xsd | 8 - configuration/packaging-configuration.xsd | 207 +++++++++ configuration/updates.xsd | 15 + .../{config.tizen.xsd => widgets.tizen.xsd} | 4 + configuration/widgets.xsd | 27 ++ configuration/xml.xsd | 4 +- etc/CMakeLists.txt | 2 +- packaging/wrt-installer.spec | 36 +- packaging/wrt-preinstall-widgets.service | 13 +- src/CMakeLists.txt | 6 +- src/commons/wrt_install_mode.h | 4 +- src/configuration_parser/parser_runner.cpp | 63 +++ src/configuration_parser/parser_runner.h | 2 + src/configuration_parser/widget_parser.cpp | 307 ++++++++++--- src/jobs/widget_install/job_widget_install.cpp | 240 +++------- src/jobs/widget_install/job_widget_install.h | 9 +- src/jobs/widget_install/manifest.cpp | 22 +- src/jobs/widget_install/manifest.h | 6 +- src/jobs/widget_install/task_certify.cpp | 16 +- src/jobs/widget_install/task_database.cpp | 40 -- src/jobs/widget_install/task_database.h | 1 - src/jobs/widget_install/task_encrypt_resource.cpp | 178 +++----- src/jobs/widget_install/task_file_manipulation.cpp | 28 +- src/jobs/widget_install/task_manifest_file.cpp | 139 +++--- src/jobs/widget_install/task_manifest_file.h | 3 +- src/jobs/widget_install/task_smack.cpp | 103 ++--- src/jobs/widget_install/task_update_files.cpp | 7 +- src/jobs/widget_install/task_widget_config.cpp | 56 +++ src/jobs/widget_install/task_widget_config.h | 1 + src/jobs/widget_install/widget_install_errors.h | 3 +- .../{task_unzip.cpp => widget_unzip.cpp} | 101 ++--- .../{task_unzip.h => widget_unzip.h} | 39 +- src/jobs/widget_uninstall/task_check.cpp | 4 - src/jobs/widget_uninstall/task_remove_files.cpp | 37 +- src/jobs/widget_uninstall/task_remove_files.h | 1 - src/logic/installer_controller.cpp | 8 - src/logic/installer_controller.h | 7 - src/logic/installer_logic.cpp | 25 -- src/logic/installer_logic.h | 3 - src/misc/widget_location.cpp | 7 + src/misc/widget_location.h | 1 + src/pkg-manager/backendlib.cpp | 10 +- src/wrt-installer/CMakeLists.txt | 2 + src/wrt-installer/wrt-installer.cpp | 485 ++++++++++++--------- src/wrt-installer/wrt-installer.h | 13 + src/wrt-installer/wrt_installer_api.cpp | 7 - tests/general/widgets/manifest.wgt | Bin 1615 -> 1168 bytes tests/general/widgets/nonroot.wgt | Bin 5855 -> 5460 bytes 54 files changed, 1426 insertions(+), 1195 deletions(-) create mode 100644 configuration/CMakeLists.txt create mode 100644 configuration/access.xsd create mode 100644 configuration/common.xsd delete mode 100644 configuration/config.xsd delete mode 100644 configuration/its.xsd delete mode 100644 configuration/local.xsd create mode 100644 configuration/packaging-configuration.xsd create mode 100644 configuration/updates.xsd rename configuration/{config.tizen.xsd => widgets.tizen.xsd} (96%) mode change 100644 => 100755 create mode 100644 configuration/widgets.xsd mode change 100644 => 100755 src/configuration_parser/widget_parser.cpp mode change 100644 => 100755 src/jobs/widget_install/manifest.cpp mode change 100644 => 100755 src/jobs/widget_install/manifest.h mode change 100644 => 100755 src/jobs/widget_install/task_manifest_file.cpp mode change 100644 => 100755 src/jobs/widget_install/task_widget_config.cpp mode change 100644 => 100755 src/jobs/widget_install/task_widget_config.h rename src/jobs/widget_install/{task_unzip.cpp => widget_unzip.cpp} (73%) rename src/jobs/widget_install/{task_unzip.h => widget_unzip.h} (57%) diff --git a/CMakeLists.txt b/CMakeLists.txt index b3933c5..666256f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,7 @@ 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) +OPTION(SCHEMA_VALIDATION_SUPPORT "Support for XML schema validation" OFF) ############################# compiler flags ################################## @@ -70,6 +71,10 @@ ENDIF(CSP_SUPPORT) IF(ALLOW_NAVIGATION_SUPPORT) ADD_DEFINITIONS("-DALLOW_NAVIGATION_ENABLED") ENDIF(ALLOW_NAVIGATION_SUPPORT) +IF(SCHEMA_VALIDATION_SUPPORT) + MESSAGE(STATUS "XML Schema validation of installed app enabled") + ADD_DEFINITIONS("-DSCHEMA_VALIDATION_ENABLED") +ENDIF(SCHEMA_VALIDATION_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 @@ -99,6 +104,7 @@ SET(TARGET_BACKEND_LIB "wgt") ############################# subdirectories ################################## ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(etc) +ADD_SUBDIRECTORY(configuration) IF(WITH_TESTS) ADD_SUBDIRECTORY(tests) diff --git a/configuration/CMakeLists.txt b/configuration/CMakeLists.txt new file mode 100644 index 0000000..380f512 --- /dev/null +++ b/configuration/CMakeLists.txt @@ -0,0 +1,2 @@ +FILE(GLOB XSD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.xsd") +INSTALL(FILES ${XSD_FILES} DESTINATION /usr/etc/wrt-installer/) diff --git a/configuration/access.xsd b/configuration/access.xsd new file mode 100644 index 0000000..36d2937 --- /dev/null +++ b/configuration/access.xsd @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + diff --git a/configuration/common.xsd b/configuration/common.xsd new file mode 100644 index 0000000..2ce2f7c --- /dev/null +++ b/configuration/common.xsd @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/configuration/config.xsd b/configuration/config.xsd deleted file mode 100644 index 0c83a1e..0000000 --- a/configuration/config.xsd +++ /dev/null @@ -1,190 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/configuration/its.xsd b/configuration/its.xsd deleted file mode 100644 index 49a2acd..0000000 --- a/configuration/its.xsd +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/configuration/local.xsd b/configuration/local.xsd deleted file mode 100644 index 59a9833..0000000 --- a/configuration/local.xsd +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/configuration/packaging-configuration.xsd b/configuration/packaging-configuration.xsd new file mode 100644 index 0000000..bb130eb --- /dev/null +++ b/configuration/packaging-configuration.xsd @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/configuration/updates.xsd b/configuration/updates.xsd new file mode 100644 index 0000000..6be386b --- /dev/null +++ b/configuration/updates.xsd @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/configuration/config.tizen.xsd b/configuration/widgets.tizen.xsd old mode 100644 new mode 100755 similarity index 96% rename from configuration/config.tizen.xsd rename to configuration/widgets.tizen.xsd index 3d0c175..238d216 --- a/configuration/config.tizen.xsd +++ b/configuration/widgets.tizen.xsd @@ -74,6 +74,9 @@ + + + @@ -147,6 +150,7 @@ + diff --git a/configuration/widgets.xsd b/configuration/widgets.xsd new file mode 100644 index 0000000..839fa03 --- /dev/null +++ b/configuration/widgets.xsd @@ -0,0 +1,27 @@ + + + + + + + + + + + + + diff --git a/configuration/xml.xsd b/configuration/xml.xsd index d9ed2aa..715330a 100644 --- a/configuration/xml.xsd +++ b/configuration/xml.xsd @@ -1,6 +1,4 @@ - - - + diff --git a/etc/CMakeLists.txt b/etc/CMakeLists.txt index 370d4af..c48caa4 100644 --- a/etc/CMakeLists.txt +++ b/etc/CMakeLists.txt @@ -1,3 +1,3 @@ SET(ETC_DIR ${PROJECT_SOURCE_DIR}/etc) -INSTALL(PROGRAMS ${ETC_DIR}/wrt_preinstall_widgets.sh DESTINATION /etc/rc.d/init.d) +INSTALL(PROGRAMS ${ETC_DIR}/wrt_preinstall_widgets.sh DESTINATION /usr/bin/) diff --git a/packaging/wrt-installer.spec b/packaging/wrt-installer.spec index 1c5229a..7a28830 100644 --- a/packaging/wrt-installer.spec +++ b/packaging/wrt-installer.spec @@ -1,13 +1,13 @@ -#git:framework/web/wrt-installer wrt-installer_0.1.58.3 +#git:framework/web/wrt-installer Name: wrt-installer Summary: Installer for tizen Webruntime -Version: 0.1.58.3 +Version: 0.1.74 Release: 1 Group: Development/Libraries License: Apache License, Version 2.0 URL: N/A Source0: %{name}-%{version}.tar.gz -Source100: wrt-preinstall-widgets.service +Source1: wrt-preinstall-widgets.service BuildRequires: cmake BuildRequires: edje-tools BuildRequires: pkgconfig(appsvc) @@ -41,10 +41,9 @@ BuildRequires: pkgconfig(capi-appfw-app-manager) BuildRequires: pkgconfig(app2sd) BuildRequires: pkgconfig(web-provider) BuildRequires: pkgconfig(libprivilege-control) -BuildRequires: pkgconfig(osp-appfw) -BuildRequires: osp-appfw-internal-devel BuildRequires: pkgconfig(libsmack) -Requires: osp-appfw +BuildRequires: libss-client-devel +Requires: libss-client Requires: osp-installer Requires: xmlsec1 @@ -76,15 +75,9 @@ mkdir -p %{buildroot}/usr/share/license cp LICENSE %{buildroot}/usr/share/license/%{name} %make_install -mkdir -p %{buildroot}%{_libdir}/systemd/user -install -m 644 %{SOURCE100} %{buildroot}%{_libdir}/systemd/user -mkdir -p %{buildroot}%{_libdir}/systemd/user/tizen-mobile-session.target.wants -ln -s ../wrt-preinstall-widgets.service %{buildroot}%{_libdir}/systemd/user/tizen-mobile-session.target.wants - -mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc3.d/ -mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc5.d/ -ln -s ../init.d/wrt_preinstall_widgets.sh %{buildroot}%{_sysconfdir}/rc.d/rc3.d/S48lwrt_preinstall_widgets.sh -ln -s ../init.d/wrt_preinstall_widgets.sh %{buildroot}%{_sysconfdir}/rc.d/rc5.d/S48lwrt_preinstall_widgets.sh +mkdir -p %{buildroot}%{_libdir}/systemd/system/tizen-runtime.target.wants +install -m 644 %{SOURCE1} %{buildroot}%{_libdir}/systemd/system/wrt-preinstall-widgets.service +ln -s ../wrt-preinstall-widgets.service %{buildroot}%{_libdir}/systemd/system/tizen-runtime.target.wants/wrt-preinstall-widgets.service %clean rm -rf %{buildroot} @@ -98,10 +91,6 @@ ln -sf /usr/bin/wrt-installer /usr/etc/package-manager/backend/wgt #for booting recovery mkdir -p /opt/share/widget/temp_info -[ -h /etc/rc.d/rc3.d/S48lwrt_preinstall_widgets.sh ] && rm /etc/rc.d/rc3.d/S48lwrt_preinstall_widgets.sh -[ -h /etc/rc.d/rc5.d/S48lwrt_preinstall_widgets.sh ] && rm /etc/rc.d/rc5.d/S48lwrt_preinstall_widgets.sh -ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc3.d/S48lwrt_preinstall_widgets.sh -ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc5.d/S48lwrt_preinstall_widgets.sh # for downloadable Application icons path mkdir -p /opt/share/icons/default/small @@ -111,13 +100,12 @@ mkdir -p /opt/share/icons/default/small %files %manifest wrt-installer.manifest %attr(755,root,root) %{_bindir}/wrt-installer -%attr(775,root,root) %{_initddir}/wrt_preinstall_widgets.sh -%{_sysconfdir}/rc.d/rc3.d/S48lwrt_preinstall_widgets.sh -%{_sysconfdir}/rc.d/rc5.d/S48lwrt_preinstall_widgets.sh +%attr(775,root,root) %{_bindir}/wrt_preinstall_widgets.sh /usr/etc/package-manager/backendlib/libwgt.so +%attr(644,root,root) /usr/etc/wrt-installer/*.xsd +%{_libdir}/systemd/system/tizen-runtime.target.wants/wrt-preinstall-widgets.service +%{_libdir}/systemd/system/wrt-preinstall-widgets.service %{_datadir}/license/%{name} -%{_libdir}/systemd/user/tizen-mobile-session.target.wants/wrt-preinstall-widgets.service -%{_libdir}/systemd/user/wrt-preinstall-widgets.service %if %{with_tests} %attr(755,root,root) %{_bindir}/wrt-installer-tests-* /opt/share/widget/tests/installer/widgets/* diff --git a/packaging/wrt-preinstall-widgets.service b/packaging/wrt-preinstall-widgets.service index 2bf8181..2a66867 100644 --- a/packaging/wrt-preinstall-widgets.service +++ b/packaging/wrt-preinstall-widgets.service @@ -1,8 +1,11 @@ [Unit] -Description=Installation of pre-installed widgets -ConditionPathExists=/opt/media/Downloads/.preinstallWidgets -After=xorg.target e17.service +Description=WRT Preinstall Widgets +After=tizen-system.target +Requires=tizen-system.target [Service] -Type=oneshot -ExecStart=/etc/init.d/wrt_preinstall_widgets.sh +Type=forking +ExecStart=/usr/bin/wrt_preinstall_widgets.sh + +[Install] +WantedBy=tizen-runtime.target diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8832baf..724787d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -62,7 +62,6 @@ SET(INSTALLER_SOURCES ${INSTALLER_JOBS}/widget_install/job_widget_install.cpp ${INSTALLER_JOBS}/widget_install/manifest.cpp ${INSTALLER_JOBS}/widget_install/task_commons.cpp - ${INSTALLER_JOBS}/widget_install/task_unzip.cpp ${INSTALLER_JOBS}/widget_install/task_widget_config.cpp ${INSTALLER_JOBS}/widget_install/task_database.cpp ${INSTALLER_JOBS}/widget_install/ace_registration.cpp @@ -82,6 +81,7 @@ SET(INSTALLER_SOURCES ${INSTALLER_JOBS}/widget_install/wac_security.cpp ${INSTALLER_JOBS}/widget_install/widget_update_info.cpp ${INSTALLER_JOBS}/widget_install/directory_api.cpp + ${INSTALLER_JOBS}/widget_install/widget_unzip.cpp ${INSTALLER_JOBS}/widget_uninstall/job_widget_uninstall.cpp ${INSTALLER_JOBS}/widget_uninstall/task_check.cpp ${INSTALLER_JOBS}/widget_uninstall/task_remove_files.cpp @@ -125,7 +125,6 @@ PKG_CHECK_MODULES(INSTALLER_STATIC_DEP pkgmgr-parser pkgmgr-info web-provider - osp-appfw libsmack REQUIRED ) @@ -147,7 +146,6 @@ PKG_CHECK_MODULES(SYS_INSTALLER_STATIC_DEP shortcut capi-appfw-app-manager app2sd - vconf libprivilege-control REQUIRED ) @@ -176,7 +174,7 @@ TARGET_LINK_LIBRARIES(${TARGET_INSTALLER_STATIC} ) #for encryption -TARGET_LINK_LIBRARIES(${TARGET_INSTALLER_STATIC} -L/usr/lib/osp -losp-appfw ) +TARGET_LINK_LIBRARIES(${TARGET_INSTALLER_STATIC} "-lss-client" ) ADD_SUBDIRECTORY(pkg-manager) ADD_SUBDIRECTORY(wrt-installer) diff --git a/src/commons/wrt_install_mode.h b/src/commons/wrt_install_mode.h index a545f9c..19a387e 100644 --- a/src/commons/wrt_install_mode.h +++ b/src/commons/wrt_install_mode.h @@ -61,7 +61,8 @@ class InstallMode location(lo), rootPath(root), extension(extensionType), - installTime(time) + installTime(time), + removable(true) {}; Command command; @@ -69,6 +70,7 @@ class InstallMode RootPath rootPath; ExtensionType extension; InstallTime installTime; + bool removable; }; #endif // WRT_INSTALL_MODE_H diff --git a/src/configuration_parser/parser_runner.cpp b/src/configuration_parser/parser_runner.cpp index cff02f7..cdc7caa 100644 --- a/src/configuration_parser/parser_runner.cpp +++ b/src/configuration_parser/parser_runner.cpp @@ -22,6 +22,8 @@ #include "parser_runner.h" #include "root_parser.h" +#include "stdio.h" + #include #include #include @@ -31,7 +33,63 @@ class ParserRunner::Impl { + static void logErrorLibxml2(void *, const char *msg, ...) + { + char buffer[300]; + va_list args; + va_start(args, msg); + vsnprintf(buffer, 300, msg, args); + va_end(args); + LogError(buffer); + } + + static void logWarningLibxml2(void *, const char *msg, ...) + { + char buffer[300]; + va_list args; + va_start(args, msg); + vsnprintf(buffer, 300, msg, args); + va_end(args); + LogWarning(buffer); + } + public: + bool Validate(const std::string& filename, const std::string& schema) + { + int ret = -1; + xmlSchemaParserCtxtPtr ctx; + xmlSchemaValidCtxtPtr vctx; + xmlSchemaPtr xschema; + ctx = xmlSchemaNewParserCtxt(schema.c_str()); + if (ctx == NULL) { + LogError("xmlSchemaNewParserCtxt() Failed"); + return false; + } + xschema = xmlSchemaParse(ctx); + if (xschema == NULL) { + LogError("xmlSchemaParse() Failed"); + return false; + } + vctx = xmlSchemaNewValidCtxt(xschema); + if (vctx == NULL) { + LogError("xmlSchemaNewValidCtxt() Failed"); + return false; + } + xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc)&logErrorLibxml2, (xmlSchemaValidityWarningFunc) &logWarningLibxml2, NULL); + ret = xmlSchemaValidateFile(vctx, filename.c_str(), 0); + if (ret == -1) { + LogError("xmlSchemaValidateFile() failed"); + return false; + } else if (ret == 0) { + LogError("Config is Valid"); + return true; + } else { + LogError("Config Validation Failed with error code " << ret); + return false; + } + return true; + } + void Parse(const std::string& filename, const ElementParserPtr& root) { @@ -385,6 +443,11 @@ ParserRunner::ParserRunner() : m_impl(new ParserRunner::Impl()) {} +bool ParserRunner::Validate(const std::string& filename, const std::string& schema) +{ + return m_impl->Validate(filename, schema); +} + void ParserRunner::Parse(const std::string& filename, ElementParserPtr root) { diff --git a/src/configuration_parser/parser_runner.h b/src/configuration_parser/parser_runner.h index 80a3208..c5c0714 100644 --- a/src/configuration_parser/parser_runner.h +++ b/src/configuration_parser/parser_runner.h @@ -30,6 +30,8 @@ class ParserRunner : private DPL::Noncopyable { public: + bool Validate(const std::string& filename, const std::string& schema); + void Parse(const std::string& filename, ElementParserPtr root); void Parse(DPL::AbstractInput *input, diff --git a/src/configuration_parser/widget_parser.cpp b/src/configuration_parser/widget_parser.cpp old mode 100644 new mode 100755 index 56127be..5a56c0f --- a/src/configuration_parser/widget_parser.cpp +++ b/src/configuration_parser/widget_parser.cpp @@ -43,6 +43,10 @@ #include #include #include +#include +#include +#include +#include using namespace WrtDB; @@ -566,7 +570,7 @@ class IconParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } IconParser(ConfigParserData& data) : ElementParser(), @@ -680,7 +684,7 @@ class ContentParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } ContentParser(ConfigParserData& data) : @@ -688,8 +692,10 @@ class ContentParser : public ElementParser m_data(data) {} - virtual void Accept(const Element& /*element*/) - {} + virtual void Accept(const Element& element) + { + m_namespace = element.ns; + } virtual void Accept(const Text& /*text*/) {} @@ -718,13 +724,17 @@ class ContentParser : public ElementParser virtual void Verify() { - if (m_data.startFileEncountered) { - LogWarning("This is not the first encountered " - "'content' element - ignoring."); - return; + if(!!m_data.startFile) + { + if(m_data.startFileNamespace == m_namespace + || m_namespace != ConfigurationNamespace::TizenWebAppNamespaceName) + { + return; + } + //else continue -> if previous item was not in tizen namespace } - m_data.startFileEncountered = true; + m_data.startFileNamespace = m_namespace; //we're consciously setting startFile even if m_src is null or invalid. //WidgetConfigurationManager will deal with this. @@ -745,6 +755,7 @@ class ContentParser : public ElementParser DPL::OptionalString m_type; DPL::OptionalString m_encoding; ConfigParserData& m_data; + DPL::String m_namespace; }; class PreferenceParser : public ElementParser @@ -753,7 +764,7 @@ class PreferenceParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const XmlAttribute& attribute) @@ -892,7 +903,7 @@ class SettingParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const Text& /*text*/) @@ -931,7 +942,7 @@ class AppControlParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const Text& /*text*/) @@ -977,7 +988,7 @@ class AppControlParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const Text& /*text*/) @@ -1023,7 +1034,7 @@ class AppControlParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const Text& /*text*/) @@ -1086,7 +1097,7 @@ class AppControlParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const Text& /*text*/) @@ -1149,7 +1160,7 @@ class AppControlParser : public ElementParser } else if (name == L"mime") { return DPL::MakeDelegate(this, &AppControlParser::OnMimeElement); } else { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } } @@ -1173,13 +1184,11 @@ class AppControlParser : public ElementParser virtual void Verify() { if (m_appControl.m_src == L"") { - LogWarning("service element must have src element"); - return; + ThrowMsg(Exception::ParseError, "service element must have src element"); } if (m_appControl.m_operation == L"") { - LogWarning("service element must have operation element"); - return; + ThrowMsg(Exception::ParseError, "service element must have operation element"); } m_data.appControlList.push_back(m_appControl); @@ -1222,13 +1231,12 @@ class ApplicationParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const Text& /*text*/) { if (m_properNamespace) { - LogDebug("text"); ThrowMsg(Exception::ParseError, "application element must be empty"); } } @@ -1240,13 +1248,11 @@ class ApplicationParser : public ElementParser { m_properNamespace = true; } - LogDebug("element"); } virtual void Accept(const XmlAttribute& attribute) { if (m_properNamespace) { - LogDebug("attribute"); if (attribute.name == L"id") { m_id = attribute.value; NormalizeAndTrimSpaceString(m_id); @@ -1278,6 +1284,8 @@ class ApplicationParser : public ElementParser m_properNamespace(false) {} + static const char* const REGEXP_ID; + private: void VerifyIdAndPackage() { @@ -1341,7 +1349,6 @@ class ApplicationParser : public ElementParser } static const char* const REGEXP_PACKAGE; - static const char* const REGEXP_ID; static const char* const REGEXP_VERSION; ConfigParserData& m_data; @@ -1361,7 +1368,7 @@ class SplashParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const XmlAttribute& attribute) @@ -1406,7 +1413,7 @@ class BackgroundParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const XmlAttribute& attribute) @@ -1450,7 +1457,7 @@ class PrivilegeParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const Text& /*text*/) @@ -1531,7 +1538,7 @@ class CategoryParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const XmlAttribute& attribute) @@ -1582,12 +1589,15 @@ class AppWidgetParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } - virtual void Accept(const XmlAttribute& /*attribute*/) - {} - + virtual void Accept(const XmlAttribute& attribute) + { + if (m_properNamespace) { + m_lang = attribute.lang; + } + } virtual void Accept(const Element& element) { if (element.ns == @@ -1606,7 +1616,14 @@ class AppWidgetParser : public ElementParser virtual void Verify() { - m_data.m_label = m_label; + if (m_label.empty()) { + ThrowMsg(Exception::ParseError, + "box-label element cannot be empty - ignoring"); + } + std::pair boxLabel; + boxLabel.first = m_lang; + boxLabel.second = m_label; + m_data.m_label.push_back(boxLabel); } BoxLabelParser(ConfigParserData::LiveboxInfo& data) : @@ -1616,6 +1633,7 @@ class AppWidgetParser : public ElementParser {} private: + DPL::String m_lang; DPL::String m_label; bool m_properNamespace; ConfigParserData::LiveboxInfo& m_data; @@ -1626,7 +1644,7 @@ class AppWidgetParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const XmlAttribute& attribute) @@ -1652,6 +1670,10 @@ class AppWidgetParser : public ElementParser virtual void Verify() { + if (m_icon.empty()) { + ThrowMsg(Exception::ParseError, + "src attribute of box-icon element is mandatory - ignoring"); + } m_data.m_icon = m_icon; } @@ -1674,7 +1696,7 @@ class AppWidgetParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const XmlAttribute& attribute) @@ -1704,6 +1726,11 @@ class AppWidgetParser : public ElementParser virtual void Verify() { + if(m_size.empty()) { + ThrowMsg(Exception::ParseError, + "size is mandatory - ignoring"); + } + std::pair boxSize; boxSize.first = m_size; boxSize.second = m_preview; @@ -1729,7 +1756,7 @@ class AppWidgetParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const XmlAttribute& attribute) @@ -1761,6 +1788,42 @@ class AppWidgetParser : public ElementParser virtual void Verify() { + if (m_src.empty()) { + ThrowMsg(Exception::ParseError, + "src attribute of pd element is mandatory - ignoring"); + } + + if (m_width.empty()) { + ThrowMsg(Exception::ParseError, + "width attribute of pd element is mandatory - ignoring"); + } + + if (m_height.empty()) { + ThrowMsg(Exception::ParseError, + "height attribute of pd element is mandatory - ignoring"); + } + + if (ConvertToInt(m_width).IsNull()) { + ThrowMsg(Exception::ParseError, + "width attribute of pd element cannot be converted to int - ignoring. value: " << m_width); + } + + + DPL::OptionalInt height = ConvertToInt(m_height); + + if (height.IsNull()) { + ThrowMsg(Exception::ParseError, + "height attribute of pd element cannot be converted to int - ignoring. value: " << m_height); + } + + if (*height < 1) { + m_height = L"1"; + LogDebug("height attribute of pd element shouldn't be less than 1. Changed to 1 from " << *height); + } else if (*height > 380){ + m_height = L"380"; + LogDebug("height attribute of pd element shouldn't be greater than 380. Changed to 380 from " << *height); + } + m_data.m_pdSrc = m_src; m_data.m_pdWidth = m_width; m_data.m_pdHeight = m_height; @@ -1775,6 +1838,23 @@ class AppWidgetParser : public ElementParser {} private: + DPL::OptionalInt ConvertToInt(const DPL::String& intAsString) + { + char * endptr; + std::string tempStr = DPL::ToUTF8String(intAsString); + const char * intAsString_c = tempStr.c_str(); + errno = 0; + long int intAsString_i = strtol(intAsString_c, &endptr, 10); + + if ((errno == ERANGE && (intAsString_i == LONG_MAX || intAsString_i == LONG_MIN)) + || intAsString_i > INT_MAX || intAsString_i < INT_MIN + || *endptr != '\0') { + return DPL::OptionalInt::Null; + } + + return static_cast(intAsString_i); + } + DPL::String m_src; DPL::String m_width; DPL::String m_height; @@ -1832,6 +1912,38 @@ class AppWidgetParser : public ElementParser virtual void Verify() { + if (m_box.m_boxSrc.empty()) { + ThrowMsg(Exception::ParseError, + "src attribute of box-content element is mandatory - ignoring"); + } + + if (!m_box.m_boxMouseEvent.empty() && + CheckIfNotTrueNorFalse(m_box.m_boxMouseEvent)) + { + ThrowMsg(Exception::ParseError, + "mouse-event attribute of box-content element should be true or false - ignoring"); + } + + if (!m_box.m_boxTouchEffect.empty() && + CheckIfNotTrueNorFalse(m_box.m_boxTouchEffect)) + { + ThrowMsg(Exception::ParseError, + "touch-effect attribute of box-content element should be true or false - ignoring"); + } + + if (m_box.m_boxMouseEvent.empty()) { + m_box.m_boxMouseEvent = L"false"; + } + + if (m_box.m_boxTouchEffect.empty()) { + m_box.m_boxTouchEffect = L"true"; + } + + if (m_box.m_boxSize.empty()) { + ThrowMsg(Exception::ParseError, + "box-size element of box-content element not found - ignoring"); + } + m_data.m_boxInfo = m_box; } @@ -1852,7 +1964,6 @@ class AppWidgetParser : public ElementParser } private: - DPL::String m_src; bool m_properNamespace; ConfigParserData::LiveboxInfo& m_data; ConfigParserData::LiveboxInfo::BoxContentInfo m_box; @@ -1868,7 +1979,7 @@ class AppWidgetParser : public ElementParser } else if (name == L"box-content") { return DPL::MakeDelegate(this, &AppWidgetParser::OnBoxContentElement); } else { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } } @@ -1903,6 +2014,77 @@ class AppWidgetParser : public ElementParser virtual void Verify() { + if (m_liveboxId.empty()) { + ThrowMsg(Exception::ParseError, + "app-widget element must have id attribute"); + } + else + { + pcrecpp::RE re(REGEXP_ID_STRING.c_str()); + if (!re.FullMatch(DPL::ToUTF8String(m_liveboxId))) + { + ThrowMsg(Exception::ParseError, + "invalid format of app-widget id attribute"); + } + } + + if (m_primary.empty()) + { + ThrowMsg(Exception::ParseError, + "app-widget element must have primary attribute"); + } else if (CheckIfNotTrueNorFalse(m_primary)) + { + ThrowMsg(Exception::ParseError, + "auto-launch attribute of app-widget element should be true or false - ignoring"); + } + + if (!m_autoLaunch.empty() && + CheckIfNotTrueNorFalse(m_autoLaunch)) + { + ThrowMsg(Exception::ParseError, + "auto-launch attribute of app-widget element should be true or false - ignoring"); + } + + if (!m_updatePeriod.empty()) + { + char * endptr; + errno = 0; + std::string tempStr = DPL::ToUTF8String(m_updatePeriod); + + //set standard locale to fix decimal point mark - '.' + std::string currentLocale = setlocale(LC_NUMERIC, NULL); + if (NULL == setlocale(LC_NUMERIC, "C")) + LogWarning("Failed to change locale to \"C\""); + double updatePeriod = strtod(tempStr.c_str(), &endptr); + + //go back to previous locale + if (NULL == setlocale(LC_NUMERIC, currentLocale.c_str())) + LogWarning("Failed to set previous locale"); + + if ((errno == ERANGE && (updatePeriod == -HUGE_VAL || updatePeriod == HUGE_VAL)) + || *endptr != '\0') { + ThrowMsg(Exception::ParseError, + "update-period attribute of app-widget element should be a number - ignoring. current value: " << m_updatePeriod); + } else if (updatePeriod < 1800.0) { + LogDebug("update-period attribute of app-widget element shouldn't be less than 1800.0 - changed to 1800 from value: " << m_updatePeriod); + m_updatePeriod = L"1800.0"; + } + } + + if (m_autoLaunch.empty()) { + m_autoLaunch = L"false"; + } + + if(m_livebox.m_label.empty()) { + ThrowMsg(Exception::ParseError, + "box-label element of app-widget element not found - ignoring"); + } + + if(!m_boxContentFound) { + ThrowMsg(Exception::ParseError, + "box-content element of app-widget element not found - ignoring"); + } + m_livebox.m_liveboxId = m_liveboxId; m_livebox.m_primary = m_primary; m_livebox.m_autoLaunch = m_autoLaunch; @@ -1915,13 +2097,15 @@ class AppWidgetParser : public ElementParser explicit AppWidgetParser(ConfigParserData& data) : ElementParser(), m_data(data), - m_properNamespace(false) + m_properNamespace(false), + m_boxContentFound(false) { m_livebox = ConfigParserData::LiveboxInfo(); } ElementParserPtr OnBoxLabelElement() { + return ElementParserPtr(new BoxLabelParser(m_livebox)); } @@ -1932,10 +2116,12 @@ class AppWidgetParser : public ElementParser ElementParserPtr OnBoxContentElement() { + m_boxContentFound = true; return ElementParserPtr(new BoxContentParser(m_livebox)); } private: + static std::string REGEXP_ID_STRING; ConfigParserData& m_data; ConfigParserData::LiveboxInfo m_livebox; DPL::String m_liveboxId; @@ -1944,8 +2130,16 @@ class AppWidgetParser : public ElementParser DPL::String m_updatePeriod; DPL::String m_type; bool m_properNamespace; + bool m_boxContentFound; + + static bool CheckIfNotTrueNorFalse(const DPL::String &stringToCheck) + { + return stringToCheck.compare(L"true") != 0 && stringToCheck.compare(L"false") != 0; + } }; +std::string AppWidgetParser::REGEXP_ID_STRING = std::string(ApplicationParser::REGEXP_ID) + "\\.[0-9A-Za-z]+"; + class AllowNavigationParser : public ElementParser { public: @@ -1958,7 +2152,7 @@ class AllowNavigationParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const Element& element) @@ -2029,7 +2223,7 @@ class CspParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } CspParser(ConfigParserData& data) : @@ -2074,7 +2268,7 @@ class CspReportOnlyParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } CspReportOnlyParser(ConfigParserData& data) : @@ -2126,7 +2320,7 @@ class AccountParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const Text& text) @@ -2184,7 +2378,7 @@ class AccountParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const Text& text) @@ -2236,7 +2430,7 @@ class AccountParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const Text& text) @@ -2283,7 +2477,7 @@ class AccountParser : public ElementParser } else if (name == L"capability") { return DPL::MakeDelegate(this, &AccountProviderParser::OnCapabilityElement); } else { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } } @@ -2296,11 +2490,7 @@ class AccountParser : public ElementParser virtual void Accept(const XmlAttribute& attribute) { if (attribute.name == L"multiple-accounts-support") { - if (attribute.value == L"") { - return; - } - - if (attribute.value == L"ture") { + if (attribute.value == L"true") { m_multiSupport = true; } } @@ -2345,7 +2535,7 @@ class AccountParser : public ElementParser if (name == L"account-provider") { return DPL::MakeDelegate(this, &AccountParser::OnProviderElement); } else { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } } @@ -2391,7 +2581,7 @@ class MetadataParser : public ElementParser virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, const DPL::String& /*name*/) { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } virtual void Accept(const XmlAttribute& attribute) @@ -2450,14 +2640,13 @@ class MetadataParser : public ElementParser ElementParser::ActionFunc WidgetParser::GetElementParser( const DPL::String& /*ns*/, - const DPL::String& - name) + const DPL::String& name) { FuncMap::const_iterator it = m_map.find(name); if (it != m_map.end()) { return it->second; } else { - return &IgnoringParser::Create; + return &IgnoringParser::Create; //ignore unknown according to w3c } } @@ -2666,11 +2855,11 @@ void WidgetParser::Accept(const XmlAttribute& attribute) if (!v.empty()) { unsigned char c = v.c_str()[0]; - if (c >= '0' && c <= '9') { + if (isdigit(c)) { int val = 0; for (size_t i = 0; i < v.size(); ++i) { c = v.c_str()[i]; - if (c >= '0' && c <= '9') { + if (isdigit(c)) { val *= 10; val += (c - '0'); } else { diff --git a/src/jobs/widget_install/job_widget_install.cpp b/src/jobs/widget_install/job_widget_install.cpp index 6245ed0..c10e6e8 100644 --- a/src/jobs/widget_install/job_widget_install.cpp +++ b/src/jobs/widget_install/job_widget_install.cpp @@ -67,13 +67,13 @@ #include #include #include -#include #include #include #include #include #include +#include using namespace WrtDB; using namespace Jobs::Exceptions; @@ -122,12 +122,15 @@ class InstallerTaskFail : void StepFail() { - if (m_result == ConfigureResult::Deferred) { - ThrowMsg(Jobs::WidgetInstall::Exceptions::Deferred, - "widget installation or update deferred!"); - } else if (m_result == ConfigureResult::Failed_InvalidConfig) { + if (m_result == ConfigureResult::Failed_InvalidConfig) { ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetConfigFileInvalid, "invalid config"); + } else if (m_result == ConfigureResult::Failed_OpenZipError) { + ThrowMsg(Jobs::WidgetInstall::Exceptions::OpenZipFailed, + "can't open wgt file"); + } else if (m_result == ConfigureResult::Failed_UnzipError) { + ThrowMsg(Jobs::WidgetInstall::Exceptions::ExtractFileFailed, + "can't extract wgt file"); } else if (m_result == ConfigureResult::Failed_LowerVersion) { ThrowMsg(Jobs::WidgetInstall::Exceptions::PackageLowerVersion, "package version is lower than installed version"); @@ -138,7 +141,7 @@ class InstallerTaskFail : ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError, "widget is running"); } else if (m_result == ConfigureResult::Failed_DrmError) { - ThrowMsg(Jobs::WidgetInstall::Exceptions::DRMFailed, + ThrowMsg(Jobs::WidgetInstall::Exceptions::DrmDecryptFailed, "drm failed"); } else if (m_result == ConfigureResult::Failed_NotSupportRDSUpdate) { ThrowMsg(Jobs::WidgetInstall::Exceptions::NotSupportRDSUpdate, @@ -167,7 +170,7 @@ JobWidgetInstall::JobWidgetInstall( m_exceptionCaught(Jobs::Exceptions::Success) { m_installerContext.mode = m_jobStruct.m_installMode; - ConfigureResult result = PrePareInstallation(widgetPath); + ConfigureResult result = prepareInstallation(widgetPath); if (result == ConfigureResult::Ok) { LogInfo("Configure installation succeeded"); @@ -175,16 +178,6 @@ JobWidgetInstall::JobWidgetInstall( AddTask(new TaskRecovery(m_installerContext)); - // Create installation tasks - if (m_installerContext.widgetConfig.packagingType != - WrtDB::PKG_TYPE_DIRECTORY_WEB_APP && - m_installerContext.widgetConfig.packagingType != - WrtDB::PKG_TYPE_HOSTED_WEB_APP && - !m_isDRM) - { - AddTask(new TaskUnzip(m_installerContext)); - } - AddTask(new TaskWidgetConfig(m_installerContext)); if (m_installerContext.widgetConfig.packagingType == WrtDB::PKG_TYPE_HOSTED_WEB_APP) @@ -218,15 +211,6 @@ JobWidgetInstall::JobWidgetInstall( AddTask(new TaskPrepareReinstall(m_installerContext)); } - if (m_installerContext.widgetConfig.packagingType != - WrtDB::PKG_TYPE_HOSTED_WEB_APP && - m_installerContext.widgetConfig.packagingType != - WrtDB::PKG_TYPE_DIRECTORY_WEB_APP && - !m_isDRM) - { - AddTask(new TaskUnzip(m_installerContext)); - } - AddTask(new TaskWidgetConfig(m_installerContext)); if (m_installerContext.widgetConfig.packagingType == @@ -261,23 +245,15 @@ JobWidgetInstall::JobWidgetInstall( // Any error in acecheck while update will break widget AddTask(new TaskSmack(m_installerContext)); AddTask(new TaskRemoveBackupFiles(m_installerContext)); - } else if (result == ConfigureResult::Deferred) { - // Installation is deferred - LogInfo("Configure installation deferred"); - - AddTask(new InstallerTaskFail(result)); - } else if (result >= ConfigureResult::Failed && - result <= ConfigureResult::Failed_NotSupportRDSUpdate) { + } else { // Installation is not allowed to proceed due to widget update policy LogWarning("Configure installation failed!"); AddTask(new InstallerTaskFail(result)); - } else { - Assert(false && "Invalid configure result!"); } } -ConfigureResult JobWidgetInstall::PrePareInstallation( +ConfigureResult JobWidgetInstall::prepareInstallation( const std::string &widgetPath) { ConfigureResult result; @@ -287,29 +263,28 @@ ConfigureResult JobWidgetInstall::PrePareInstallation( { std::string tempDir; if (m_installerContext.mode.extension == InstallMode::ExtensionType::DIR) { - std::ostringstream tempPathBuilder; - tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath(); - tempPathBuilder << WrtDB::GlobalConfig::GetTmpDirPath(); - tempPathBuilder << "/"; - tempPathBuilder << widgetPath; - tempDir = tempPathBuilder.str();; + if (m_installerContext.mode.command == + InstallMode::Command::REINSTALL) { + std::ostringstream tempPathBuilder; + tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath(); + tempPathBuilder << WrtDB::GlobalConfig::GetTmpDirPath(); + tempPathBuilder << "/"; + tempPathBuilder << widgetPath; + tempDir = tempPathBuilder.str();; + } else { + tempDir = widgetPath; + } } else { tempDir = Jobs::WidgetInstall::createTempPath( m_installerContext.mode.rootPath == InstallMode::RootPath::RO); - } - - m_isDRM = isDRMWidget(widgetPath); - if (true == m_isDRM) { - LogDebug("decrypt DRM widget"); - if (DecryptDRMWidget(widgetPath, tempDir)) { - LogDebug("Failed decrypt DRM widget"); - return ConfigureResult::Failed_DrmError; - } + WidgetUnzip wgtUnzip; + wgtUnzip.unzipWgtFile(widgetPath, tempDir); } LogDebug("widgetPath:" << widgetPath); + LogDebug("tempPath:" << tempDir); m_installerContext.widgetConfig.packagingType = checkPackageType(widgetPath, tempDir); @@ -317,7 +292,6 @@ ConfigureResult JobWidgetInstall::PrePareInstallation( widgetPath, tempDir, m_installerContext.widgetConfig.packagingType, - m_isDRM, m_installerContext.mode.command == InstallMode::Command::REINSTALL); LogDebug("widget packaging type : " << m_installerContext.widgetConfig.packagingType.pkgType); @@ -330,10 +304,20 @@ ConfigureResult JobWidgetInstall::PrePareInstallation( // Configure installation result = ConfigureInstallation(widgetPath, configData, tempDir); } + Catch(Exceptions::OpenZipFailed) + { + LogError("Failed to unzip for widget"); + result = ConfigureResult::Failed_OpenZipError; + } Catch(Exceptions::ExtractFileFailed) { - LogError("Failed to create temporary path for widget"); - result = ConfigureResult::Failed_InvalidConfig; + LogError("Failed to unzip for widget"); + result = ConfigureResult::Failed_UnzipError; + } + Catch(Exceptions::DrmDecryptFailed) + { + LogError("Failed to unzip for widget"); + result = ConfigureResult::Failed_DrmError; } return result; @@ -638,7 +622,6 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML( const std::string &widgetSource, const std::string &tempPath, WrtDB::PackagingType pkgType, - bool isDRM, bool isReinstall) { // Parse config @@ -676,78 +659,32 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML( configInfo, DPL::FromUTF32String(L"widget")))); } else { - if (!isDRM) { - std::unique_ptr zipFile( - new DPL::ZipInput(widgetSource)); - - std::unique_ptr configFile; - - // Open config.xml file - if (pkgType == PKG_TYPE_HYBRID_WEB_APP) { - configFile.reset(zipFile->OpenFile(WITH_OSP_XML)); - } else { - configFile.reset(zipFile->OpenFile(CONFIG_XML)); - } - - // Extract config - DPL::BinaryQueue buffer; - DPL::AbstractWaitableInputAdapter inputAdapter(configFile.get()); - DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer); - DPL::Copy(&inputAdapter, &outputAdapter); - parser.Parse(&buffer, - ElementParserPtr( - new RootParser(configInfo, - DPL:: - FromUTF32String( - L"widget")))); + std::string configFile; + if (pkgType == PKG_TYPE_HYBRID_WEB_APP) { + configFile = tempPath + "/" + WITH_OSP_XML; } else { - // DRM widget - std::string configFile; - if (pkgType == PKG_TYPE_HYBRID_WEB_APP) { - configFile = tempPath + "/" + WITH_OSP_XML; - } else { - configFile = tempPath + "/" + CONFIG_XML; - } - - parser.Parse(configFile, - ElementParserPtr( - new RootParser(configInfo, - DPL:: - FromUTF32String( - L"widget")))); + configFile = tempPath + "/" + CONFIG_XML; } + + parser.Parse(configFile, + ElementParserPtr( + new RootParser(configInfo, + DPL:: + FromUTF32String( + L"widget")))); } } - Catch(DPL::ZipInput::Exception::OpenFailed) - { - LogError("Failed to open widget package"); - return ConfigParserData(); - } - Catch(DPL::ZipInput::Exception::OpenFileFailed) - { - LogError("Failed to open config.xml file"); - return ConfigParserData(); - } - Catch(DPL::CopyFailed) - { - LogError("Failed to extract config.xml file"); - return ConfigParserData(); - } - Catch(DPL::FileInput::Exception::OpenFailed) - { - LogError("Failed to open config.xml file"); - return ConfigParserData(); - } Catch(ElementParser::Exception::ParseError) { LogError("Failed to parse config.xml file"); return ConfigParserData(); } - Catch(DPL::ZipInput::Exception::SeekFileFailed) + Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) { - LogError("Failed to seek widget archive - corrupted package?"); + LogError("Failed to find installed widget - give proper tizenId"); return ConfigParserData(); } + return configInfo; } @@ -956,60 +893,14 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType( return PKG_TYPE_HOSTED_WEB_APP; } - if (m_isDRM) { - std::string configFile = tempPath + "/" + CONFIG_XML; - if (WrtUtilFileExists(configFile)) { - return PKG_TYPE_NOMAL_WEB_APP; - } - - configFile = tempPath + "/" + WITH_OSP_XML; - if (WrtUtilFileExists(configFile)) { - return PKG_TYPE_HYBRID_WEB_APP; - } - } else { - std::unique_ptr zipFile; - - Try - { - // Open zip file - zipFile.reset(new DPL::ZipInput(widgetSource)); - } - Catch(DPL::ZipInput::Exception::OpenFailed) - { - LogDebug("Failed to open widget package"); - return PKG_TYPE_UNKNOWN; - } - Catch(DPL::ZipInput::Exception::SeekFileFailed) - { - LogError("Failed to seek widget package file"); - return PKG_TYPE_UNKNOWN; - } - - Try - { - // Open config.xml file in package root - std::unique_ptr configFile( - zipFile->OpenFile(CONFIG_XML)); - return PKG_TYPE_NOMAL_WEB_APP; - } - Catch(DPL::ZipInput::Exception::OpenFileFailed) - { - LogDebug("Could not find config.xml"); - } - - Try - { - // Open config.xml file in package root - std::unique_ptr configFile( - zipFile->OpenFile(WITH_OSP_XML)); + std::string configFile = tempPath + "/" + CONFIG_XML; + if (WrtUtilFileExists(configFile)) { + return PKG_TYPE_NOMAL_WEB_APP; + } - return PKG_TYPE_HYBRID_WEB_APP; - } - Catch(DPL::ZipInput::Exception::OpenFileFailed) - { - LogDebug("Could not find wgt/config.xml"); - return PKG_TYPE_UNKNOWN; - } + configFile = tempPath + "/" + WITH_OSP_XML; + if (WrtUtilFileExists(configFile)) { + return PKG_TYPE_HYBRID_WEB_APP; } return PKG_TYPE_UNKNOWN; @@ -1094,19 +985,6 @@ void JobWidgetInstall::setInstallLocationType( } } -bool JobWidgetInstall::isDRMWidget(std::string /*widgetPath*/) -{ - /* TODO */ - return false; -} - -bool JobWidgetInstall::DecryptDRMWidget(std::string /*widgetPath*/, - std::string /*destPath*/) -{ - /* TODO */ - return false; -} - bool JobWidgetInstall::checkSupportRDSUpdate(const WrtDB::ConfigParserData &configInfo) { diff --git a/src/jobs/widget_install/job_widget_install.h b/src/jobs/widget_install/job_widget_install.h index 7d5862d..1eebc7b 100644 --- a/src/jobs/widget_install/job_widget_install.h +++ b/src/jobs/widget_install/job_widget_install.h @@ -40,7 +40,6 @@ namespace WidgetInstall { enum class ConfigureResult { Ok, - Deferred, Updated, Failed, Failed_InvalidConfig, @@ -49,6 +48,8 @@ enum class ConfigureResult Failed_WidgetRunning, Failed_DrmError, Failed_NotSupportRDSUpdate, + Failed_OpenZipError, + Failed_UnzipError, }; class JobWidgetInstall : @@ -65,7 +66,6 @@ class JobWidgetInstall : std::string m_exceptionMessage; WidgetUpdateInfo m_widgetUpdateInfo; bool m_needEncryption; - bool m_isDRM; ConfigureResult ConfigureInstallation(const std::string &widgetSource, const WrtDB::ConfigParserData @@ -75,7 +75,6 @@ class JobWidgetInstall : const std::string &widgetSource, const std::string &tempPath, WrtDB::PackagingType pkgType, - bool isDRM, bool isReinstall); static WidgetUpdateInfo detectWidgetUpdate( const WrtDB::ConfigParserData &configInfo, @@ -91,9 +90,7 @@ class JobWidgetInstall : bool detectResourceEncryption(const WrtDB::ConfigParserData &configData); void setInstallLocationType(const WrtDB::ConfigParserData &configData); - bool isDRMWidget(std::string widgetPath); - bool DecryptDRMWidget(std::string widgetPath, std::string destPath); - ConfigureResult PrePareInstallation(const std::string &widgetPath); + ConfigureResult prepareInstallation(const std::string &widgetPath); bool validateTizenApplicationID(const WrtDB::TizenAppId &tizenAppId); bool validateTizenPackageID(const WrtDB::TizenPkgId &tizenPkgId); ConfigureResult checkWidgetUpdate(const WidgetUpdateInfo &update); diff --git a/src/jobs/widget_install/manifest.cpp b/src/jobs/widget_install/manifest.cpp old mode 100644 new mode 100755 index 15f381e..9688ee2 --- a/src/jobs/widget_install/manifest.cpp +++ b/src/jobs/widget_install/manifest.cpp @@ -367,11 +367,25 @@ void LiveBox::serialize(xmlTextWriterPtr writer) writeAttribute(writer, "nodisplay", "false"); if (!this->label.empty()) { - startElement(writer, "label"); - writeText(writer, this->label); - endElement(writer); + int defaultLabelChk = 0; + FOREACH(m, this->label) + { + std::pair boxLabel = *m; + startElement(writer, "label"); + if (!boxLabel.first.empty()) { + writeAttribute(writer, "xml:lang", boxLabel.first); + } else { + defaultLabelChk++; + } + writeText(writer, boxLabel.second); + endElement(writer); + } + if(!defaultLabelChk) { + startElement(writer, "label"); + writeText(writer, DPL::FromUTF8String("NO NAME")); + endElement(writer); + } } - if (!this->icon.empty()) { startElement(writer, "icon"); writeText(writer, this->icon); diff --git a/src/jobs/widget_install/manifest.h b/src/jobs/widget_install/manifest.h old mode 100644 new mode 100755 index cb7e6d6..30a849d --- a/src/jobs/widget_install/manifest.h +++ b/src/jobs/widget_install/manifest.h @@ -406,6 +406,7 @@ typedef UiApplication UiApplicationType; * @brief LiveBox element */ typedef std::list > boxSizeType; +typedef std::list > boxLabelType; struct BoxInfo { @@ -435,7 +436,7 @@ class LiveBox { this->updatePeriod = x; } - void setLabel(const NcnameType &x) + void setLabel(const boxLabelType &x) { this->label = x; } @@ -456,8 +457,9 @@ class LiveBox NcnameType autoLaunch; NcnameType updatePeriod; NcnameType timeout; - NcnameType label; + boxLabelType label; NcnameType icon; + NcnameType lang; BoxInfoType box; }; diff --git a/src/jobs/widget_install/task_certify.cpp b/src/jobs/widget_install/task_certify.cpp index edf9f1d..68189ac 100644 --- a/src/jobs/widget_install/task_certify.cpp +++ b/src/jobs/widget_install/task_certify.cpp @@ -265,7 +265,8 @@ void TaskCertify::stepSignature() "Certificate is REVOKED"); } - if (result == WrtSignatureValidator::SIGNATURE_INVALID) { + if (result == WrtSignatureValidator::SIGNATURE_INVALID && + iter->getFileNumber() <= 1) { LogWarning("Signature is INVALID"); // TODO change exception name ThrowMsg(Exceptions::SignatureInvalid, @@ -273,18 +274,13 @@ void TaskCertify::stepSignature() } if (data.isAuthorSignature()) { - if (result == WrtSignatureValidator::SIGNATURE_VERIFIED || - m_contextData.wacSecurity.isDistributorSigned()) - { + if (result == WrtSignatureValidator::SIGNATURE_VERIFIED ) { processAuthorSignature(data); - } else if (result == - WrtSignatureValidator::SIGNATURE_DISREGARD) - { - continue; } } else { - // now signature _must_ be verified - processDistributorSignature(data); + if (result != WrtSignatureValidator::SIGNATURE_INVALID) { + processDistributorSignature(data); + } } } Catch(ParserSchemaException::Base) { LogError("Error occured in ParserSchema."); diff --git a/src/jobs/widget_install/task_database.cpp b/src/jobs/widget_install/task_database.cpp index e9d1b6c..29fda9a 100644 --- a/src/jobs/widget_install/task_database.cpp +++ b/src/jobs/widget_install/task_database.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -43,7 +42,6 @@ #include #include #include -#include #include using namespace WrtDB; @@ -61,7 +59,6 @@ TaskDatabase::TaskDatabase(InstallerContext& context) : AddStep(&TaskDatabase::StepAceDBInsert); AddStep(&TaskDatabase::StepSecurityOriginDBInsert); AddStep(&TaskDatabase::StepRemoveExternalFiles); - AddStep(&TaskDatabase::StepCreateVconf); AddStep(&TaskDatabase::StepLiveboxDBInsert); AddAbortStep(&TaskDatabase::StepAbortDBInsert); @@ -249,43 +246,6 @@ void TaskDatabase::StepRemoveExternalFiles() } } -void TaskDatabase::StepCreateVconf() -{ - LogDebug("StepCreateVconf"); - std::map vconfData; - vconfData[ - WrtDB::VconfConfig::GetVconfKeyPopupUsage( - m_context.widgetConfig.tzAppid)] = WrtDB::SETTINGS_TYPE_ON; - vconfData[ - WrtDB::VconfConfig::GetVconfKeyGeolocationUsage( - m_context.widgetConfig.tzAppid)] = WrtDB::SETTINGS_TYPE_ON; - vconfData[ - WrtDB::VconfConfig::GetVconfKeyWebNotificationUsage( - m_context.widgetConfig.tzAppid)] = WrtDB::SETTINGS_TYPE_ON; - vconfData[ - WrtDB::VconfConfig::GetVconfKeyWebDatabaseUsage( - m_context.widgetConfig.tzAppid)] = WrtDB::SETTINGS_TYPE_ON; - vconfData[ - WrtDB::VconfConfig::GetVconfKeyMemorySavingMode( - m_context.widgetConfig.tzAppid)] = WrtDB::SETTINGS_TYPE_OFF; - - // vconftool -g 5000 set -t int initialize value - // Current installer should use vconftool for setting group ID - // In case of install application by pkgcmd, permission for others - // set to read-only - FOREACH(it, vconfData) { - std::ostringstream command; - command << "vconftool -g 5000 set -t int "; - command << (*it).first; - command << " \"" << static_cast((*it).second) << "\""; - int ret = system(command.str().c_str()); - if (-1 == ret) { - ThrowMsg(Exceptions::CreateVconfFailure, - "Failed to create vconf files"); - } - } -} - void TaskDatabase::StepAbortDBInsert() { LogWarning("[DB Update Task] Aborting... (DB Clean)"); diff --git a/src/jobs/widget_install/task_database.h b/src/jobs/widget_install/task_database.h index 88d99e9..e3e4951 100644 --- a/src/jobs/widget_install/task_database.h +++ b/src/jobs/widget_install/task_database.h @@ -50,7 +50,6 @@ class TaskDatabase : void StepAceDBInsert(); void StepSecurityOriginDBInsert(); void StepRemoveExternalFiles(); - void StepCreateVconf(); void StepLiveboxDBInsert(); void StepAbortDBInsert(); diff --git a/src/jobs/widget_install/task_encrypt_resource.cpp b/src/jobs/widget_install/task_encrypt_resource.cpp index 0b47580..e6838e5 100644 --- a/src/jobs/widget_install/task_encrypt_resource.cpp +++ b/src/jobs/widget_install/task_encrypt_resource.cpp @@ -40,8 +40,7 @@ #include #include #include -#include -#include +#include #include #include @@ -49,15 +48,9 @@ using namespace WrtDB; -extern "C" -{ - void InitWebAppInfo(const char* appId, const char* rootPath); -} - namespace { -const std::size_t ENCRYPTION_CHUNK_MAX_SIZE = 4096; // bytes +const std::size_t ENCRYPTION_CHUNK_MAX_SIZE = 8192; // bytes const std::size_t ENCRYPTION_DEC_CHUNK_SIZE = 4; // bytes -static bool initWebApp = false; std::set& getSupportedForEncryption() { @@ -168,60 +161,17 @@ void writeBytes(unsigned char* buffer, std::size_t count, FILE* stream) } while ((bytesWritten != bytesToWrite) && (EINTR == errno)); } -/* - * get encrypted string from trustzone -*/ -Tizen::Base::ByteBuffer* EncryptChunkByTrustZone( - Tizen::Base::ByteBuffer* appInfo, - const unsigned char *plainBuffer, - int pBufSize) +int ssmEncrypt(InstallMode::RootPath rootPath, std::string pkgId, const char* + inChunk, int inBytes, char** outChunk, int *outBytes) { - using namespace Tizen::Base; - if(!initWebApp) - { - char* pAppId = null; - pAppId = (char*)calloc(appInfo->GetRemaining()+1, 1); - memcpy(pAppId, appInfo->GetPointer(), appInfo->GetRemaining()); - InitWebAppInfo(pAppId, ""); - free (pAppId); - initWebApp = true; + if (rootPath == InstallMode::RootPath::RO) { + return ssm_encrypt_preloaded_application(inChunk, inBytes, + outChunk, outBytes); + } else { + return ssm_encrypt(pkgId.c_str(), pkgId.length(), + inChunk, inBytes, + outChunk, outBytes); } - - Tizen::Security::Crypto::_TrustZoneService* pInstance; - pInstance = Tizen::Security::Crypto::_TrustZoneService::GetInstance(); - - ByteBuffer pBuf; - pBuf.Construct(pBufSize); - const byte *pByte = reinterpret_cast(plainBuffer); - if (pBuf.SetArray(pByte, 0, pBufSize) != E_SUCCESS) { - LogDebug("Couldnot set pBuf"); - return NULL; - } - pBuf.Flip(); - - return pInstance->_TrustZoneService::EncryptN(*appInfo, pBuf); -} - -Tizen::Base::ByteBuffer* TEST_dec( - Tizen::Base::ByteBuffer* appInfo, - const unsigned char *plainBuffer, - int pBufSize) -{ - using namespace Tizen::Base; - - Tizen::Security::Crypto::_TrustZoneService* pInstance; - pInstance = Tizen::Security::Crypto::_TrustZoneService::GetInstance(); - - ByteBuffer pBuf; - pBuf.Construct(pBufSize); - const byte *pByte = reinterpret_cast(plainBuffer); - if (pBuf.SetArray(pByte, 0, pBufSize) != E_SUCCESS) { - LogDebug("Couldnot set pBuf"); - return NULL; - } - pBuf.Flip(); - - return pInstance->_TrustZoneService::DecryptN(*appInfo, pBuf); } } @@ -318,76 +268,62 @@ void TaskEncryptResource::EncryptFile(const std::string &fileName) return; } - DPL::ScopedFClose inFile(openFile(fileName, "r")); - DPL::ScopedFClose outFile(openFile(encFile, "w")); - - const std::size_t chunkSize = (fileSize > ENCRYPTION_CHUNK_MAX_SIZE - ? ENCRYPTION_CHUNK_MAX_SIZE : fileSize); + // If update installed preload web, should skip encryption. + if (!(m_context.mode.rootPath == InstallMode::RootPath::RO && + m_context.mode.installTime == InstallMode::InstallTime::PRELOAD + && m_context.mode.extension == InstallMode::ExtensionType::DIR)) { - std::unique_ptr inChunk(new unsigned char[chunkSize]); - std::unique_ptr outChunk; + DPL::ScopedFClose inFile(openFile(fileName, "r")); + DPL::ScopedFClose outFile(openFile(encFile, "w")); - std::size_t bytesRead = 0; - using namespace Tizen::Base; + const std::size_t chunkSize = (fileSize > ENCRYPTION_CHUNK_MAX_SIZE + ? ENCRYPTION_CHUNK_MAX_SIZE : fileSize); - std::string pkgid = - DPL::ToUTF8String(m_context.widgetConfig.tzAppid).c_str(); - const byte *b_pkgid = reinterpret_cast( - pkgid.c_str()); - ByteBuffer appInfo; - appInfo.Construct(pkgid.length()); + std::unique_ptr inChunk(new unsigned char[chunkSize]); + std::size_t bytesRead = 0; + /* TODO : pkgId should change to appId after wrt-client label changed. */ + std::string pkgId = DPL::ToUTF8String(m_context.widgetConfig.tzPkgid); - if (appInfo.SetArray(b_pkgid, 0, pkgid.length()) != E_SUCCESS) { - LogDebug("Couldnot set appInfo"); - return; - } - - appInfo.Flip(); - - do - { - bytesRead = readBytes(inChunk.get(), chunkSize, inFile.Get()); - if (0 != bytesRead) { - ByteBuffer *getBuffer = EncryptChunkByTrustZone( - &appInfo, - inChunk.get(), bytesRead); - if (getBuffer == NULL) { - ThrowMsg(Exceptions::EncryptionFailed, - "Encryption Failed using TrustZone"); + do + { + bytesRead = readBytes(inChunk.get(), chunkSize, inFile.Get()); + if (0 != bytesRead) { + int outDecSize = 0; + char *outChunk = NULL; + if (0 != ssmEncrypt(m_context.mode.rootPath, pkgId, + (char*)inChunk.get(), (int)bytesRead, + &outChunk, &outDecSize)) { + ThrowMsg(Exceptions::EncryptionFailed, + "Encryption Failed using TrustZone"); + } + + std::stringstream toString; + toString << outDecSize; + + writeBytes((unsigned char*)toString.str().c_str(), + sizeof(int), outFile.Get()); + writeBytes((unsigned char*)outChunk, outDecSize, outFile.Get()); + delete outChunk; } - int decBufSize = getBuffer->GetRemaining(); + inChunk.reset(new unsigned char[chunkSize]); - outChunk.reset(new unsigned char[decBufSize]); - memcpy(outChunk.get(), getBuffer->GetPointer(), getBuffer->GetRemaining()); - getBuffer->Reset(); + } while (0 == std::feof(inFile.Get())); - char writeSize[ENCRYPTION_DEC_CHUNK_SIZE]; - memset(writeSize, 0x00, ENCRYPTION_DEC_CHUNK_SIZE); - std::stringstream toString; - toString << decBufSize; - strncpy(writeSize, toString.str().c_str(), toString.str().length()); + outFile.Reset(); + inFile.Reset(); - writeBytes((unsigned char*)writeSize, - ENCRYPTION_DEC_CHUNK_SIZE, outFile.Get()); - writeBytes(outChunk.get(), decBufSize, outFile.Get()); + LogDebug("File encrypted successfully"); + LogDebug("Remove plain-text file: " << fileName); + if (0 != unlink(fileName.c_str())) + { + Throw(Exceptions::EncryptionFailed); } - } while (0 == std::feof(inFile.Get())); - - outFile.Reset(); - inFile.Reset(); - - LogDebug("File encrypted successfully"); - LogDebug("Remove plain-text file: " << fileName); - if (0 != unlink(fileName.c_str())) - { - Throw(Exceptions::EncryptionFailed); - } - - LogDebug("Rename encrypted file"); - if (0 != std::rename(encFile.c_str(), fileName.c_str())) - { - Throw(Exceptions::EncryptionFailed); + LogDebug("Rename encrypted file"); + if (0 != std::rename(encFile.c_str(), fileName.c_str())) + { + Throw(Exceptions::EncryptionFailed); + } } std::string realPath = fileName; diff --git a/src/jobs/widget_install/task_file_manipulation.cpp b/src/jobs/widget_install/task_file_manipulation.cpp index b365d9a..fa229cd 100644 --- a/src/jobs/widget_install/task_file_manipulation.cpp +++ b/src/jobs/widget_install/task_file_manipulation.cpp @@ -43,7 +43,7 @@ namespace { const mode_t PRIVATE_STORAGE_MODE = 0700; -const mode_t SHARE_MODE = 0705; +const mode_t SHARED_STORAGE_MODE = 0755; } using namespace WrtDB; @@ -99,12 +99,12 @@ bool _FolderCopy(std::string source, std::string dest) return true; } -void changeOwnerForDirectory(std::string storagePath) { +void changeOwnerForDirectory(std::string storagePath, mode_t mode) { if (euidaccess(storagePath.c_str(), F_OK) != 0) { - if (!WrtUtilMakeDir(storagePath, PRIVATE_STORAGE_MODE)) { - LogError("Failed to create directory for private storage"); + if (!WrtUtilMakeDir(storagePath, mode)) { + LogError("Failed to create directory : " << storagePath); ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed, - "Failed to create directory for private storage"); + "Failed to create directory : " << storagePath); } // '5000' is default uid, gid for applications. // So installed applications should be launched as process of uid @@ -118,7 +118,7 @@ void changeOwnerForDirectory(std::string storagePath) { "Chown to invaild user"); } } else if (euidaccess(storagePath.c_str(), W_OK | R_OK | X_OK) == 0) { - LogInfo("Private storage already exists."); + LogInfo(storagePath << " already exists."); // Even if private directory already is created, private dircetory // should change owner. if (chown(storagePath.c_str(), @@ -128,7 +128,7 @@ void changeOwnerForDirectory(std::string storagePath) { ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed, "Chown to invaild user"); } - if (chmod(storagePath.c_str(), PRIVATE_STORAGE_MODE) != 0) { + if (chmod(storagePath.c_str(), mode) != 0) { ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed, "chmod to 0700"); } @@ -216,7 +216,11 @@ void TaskFileManipulation::StepCreatePrivateStorageDir() "Error occurs copy private strage files"); } } - changeOwnerForDirectory(storagePath); + changeOwnerForDirectory(storagePath, PRIVATE_STORAGE_MODE); + + std::string tempStoragePath = m_context.locations->getPrivateTempStorageDir(); + LogDebug("Create temp private storage directory : " << tempStoragePath); + changeOwnerForDirectory(tempStoragePath, PRIVATE_STORAGE_MODE); } void TaskFileManipulation::StepRenamePath() @@ -287,7 +291,7 @@ void TaskFileManipulation::StepLinkForPreload() ThrowMsg(Exceptions::FileOperationFailed, "Symbolic link creating is not done."); } - changeOwnerForDirectory(dataDir); + changeOwnerForDirectory(dataDir, PRIVATE_STORAGE_MODE); } if (m_context.widgetConfig.packagingType != PKG_TYPE_HYBRID_WEB_APP) { @@ -431,8 +435,10 @@ void TaskFileManipulation::StepCreateSharedFolder() } } else { WrtUtilMakeDir(m_context.locations->getSharedResourceDir()); - WrtUtilMakeDir(m_context.locations->getSharedDataDir()); - WrtUtilMakeDir(m_context.locations->getSharedTrustedDir()); + changeOwnerForDirectory(m_context.locations->getSharedDataDir(), + SHARED_STORAGE_MODE); + changeOwnerForDirectory(m_context.locations->getSharedTrustedDir(), + SHARED_STORAGE_MODE); } } } //namespace WidgetInstall diff --git a/src/jobs/widget_install/task_manifest_file.cpp b/src/jobs/widget_install/task_manifest_file.cpp old mode 100644 new mode 100755 index 19d2ee4..d9cfeaa --- a/src/jobs/widget_install/task_manifest_file.cpp +++ b/src/jobs/widget_install/task_manifest_file.cpp @@ -59,8 +59,9 @@ using namespace WrtDB; namespace { typedef std::map LanguageTagMap; -const char* const ST_TRUE = "true"; -const char* const ST_NODISPLAY = "nodisplay"; +const char* const STR_TRUE = "true"; +const char* const STR_FALSE = "false"; +const char* const STR_NODISPLAY = "nodisplay"; LanguageTagMap getLanguageTagMap() { @@ -114,8 +115,7 @@ TaskManifestFile::TaskManifestFile(InstallerContext &inCont) : AddStep(&TaskManifestFile::stepCopyLiveboxFiles); AddStep(&TaskManifestFile::stepCreateExecFile); AddStep(&TaskManifestFile::stepGenerateManifest); - AddStep(&TaskManifestFile::stepParseUpgradedManifest); - AddStep(&TaskManifestFile::stepUpdateFinalize); + AddStep(&TaskManifestFile::stepParseManifest); AddAbortStep(&TaskManifestFile::stepAbortIconFiles); } else { @@ -124,7 +124,6 @@ TaskManifestFile::TaskManifestFile(InstallerContext &inCont) : AddStep(&TaskManifestFile::stepCreateExecFile); AddStep(&TaskManifestFile::stepGenerateManifest); AddStep(&TaskManifestFile::stepParseManifest); - AddStep(&TaskManifestFile::stepFinalize); AddAbortStep(&TaskManifestFile::stepAbortParseManifest); } @@ -152,8 +151,6 @@ void TaskManifestFile::stepCreateExecFile() if (error) LogPedantic("Failed to make a symbolic name for a file " << "[" << DPL::GetErrnoString(error) << "]"); - ThrowMsg(Exceptions::FileOperationFailed, - "Symbolic link creating is not done."); } // app-control widgets @@ -176,8 +173,6 @@ void TaskManifestFile::stepCreateExecFile() LogPedantic("Failed to make a symbolic name for a file " << "[" << DPL::GetErrnoString(error) << "]"); } - ThrowMsg(Exceptions::FileOperationFailed, - "Symbolic link creating is not done."); } } #else @@ -190,8 +185,6 @@ void TaskManifestFile::stepCreateExecFile() if (error) LogPedantic("Failed to make a symbolic name for a file " << "[" << DPL::GetErrnoString(error) << "]"); - ThrowMsg(Exceptions::FileOperationFailed, - "Symbolic link creating is not done."); } #endif m_context.job->UpdateProgress( @@ -430,12 +423,6 @@ void TaskManifestFile::stepAbortIconFiles() } } -void TaskManifestFile::stepUpdateFinalize() -{ - commitManifest(); - LogDebug("Finished Update Desktopfile"); -} - DPL::String TaskManifestFile::getIconTargetFilename( const DPL::String& languageTag) const { @@ -464,12 +451,6 @@ DPL::String TaskManifestFile::getIconTargetFilename( return filename.str(); } -void TaskManifestFile::stepFinalize() -{ - commitManifest(); - LogInfo("Finished ManifestFile step"); -} - void TaskManifestFile::saveLocalizedKey(std::ofstream &file, const DPL::String& key, const DPL::String& languageTag) @@ -585,6 +566,17 @@ void TaskManifestFile::stepGenerateManifest() writeManifest(manifest_file); + std::ostringstream destFile; + if (m_context.mode.rootPath == InstallMode::RootPath::RO) { + destFile << "/usr/share/packages" << "/"; //TODO constant with path + } else { + destFile << "/opt/share/packages" << "/"; //TODO constant with path + } + + destFile << DPL::ToUTF8String(manifest_name); + commit_manifest = destFile.str(); + LogDebug("Commiting manifest file : " << commit_manifest); + m_context.job->UpdateProgress( InstallerContext::INSTALL_CREATE_MANIFEST, "Widget Manifest Creation Finished"); @@ -592,61 +584,65 @@ void TaskManifestFile::stepGenerateManifest() void TaskManifestFile::stepParseManifest() { - int code = pkgmgr_parser_parse_manifest_for_installation( - DPL::ToUTF8String(manifest_file).c_str(), NULL); + int code = 0; - if (code != 0) { - LogError("Manifest parser error: " << code); - ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code); - } + char* updateTags[3] = {NULL, }; - m_context.job->UpdateProgress( - InstallerContext::INSTALL_CREATE_MANIFEST, - "Widget Manifest Parsing Finished"); - LogDebug("Manifest parsed"); -} + if (!m_context.mode.removable) { + updateTags[0] = "preload=false"; + updateTags[1] = "removable=false"; + updateTags[2] = NULL; -void TaskManifestFile::stepParseUpgradedManifest() -{ - if (m_context.widgetConfig.packagingType != - PKG_TYPE_HYBRID_WEB_APP) - { - int code = pkgmgr_parser_parse_manifest_for_upgrade( - DPL::ToUTF8String(manifest_file).c_str(), NULL); + } + + if (!access(commit_manifest.c_str(), F_OK) == 0) { + commitManifest(); + code = pkgmgr_parser_parse_manifest_for_installation( + commit_manifest.c_str(), (updateTags[0] == NULL) ? NULL : updateTags); if (code != 0) { LogError("Manifest parser error: " << code); ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code); } + } else { + if (m_context.widgetConfig.packagingType != + PKG_TYPE_HYBRID_WEB_APP) + { + commitManifest(); + code = pkgmgr_parser_parse_manifest_for_upgrade( + commit_manifest.c_str(), (updateTags[0] == NULL) ? NULL : updateTags); - m_context.job->UpdateProgress( - InstallerContext::INSTALL_CREATE_MANIFEST, - "Widget Manifest Parsing Finished"); - LogDebug("Manifest parsed"); + if (code != 0) { + LogError("Manifest parser error: " << code); + ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code); + } + + } } + + m_context.job->UpdateProgress( + InstallerContext::INSTALL_CREATE_MANIFEST, + "Widget Manifest Parsing Finished"); + LogDebug("Manifest parsed"); } void TaskManifestFile::commitManifest() { - LogDebug("Commiting manifest file : " << manifest_file); - std::ostringstream destFile; - if (m_context.mode.rootPath == InstallMode::RootPath::RO) { - destFile << "/usr/share/packages" << "/"; //TODO constant with path - } else { - destFile << "/opt/share/packages" << "/"; //TODO constant with path - } - destFile << DPL::ToUTF8String(manifest_name); - LogInfo("cp " << manifest_file << " " << destFile.str()); + if (!(m_context.mode.rootPath == InstallMode::RootPath::RO && + m_context.mode.installTime == InstallMode::InstallTime::PRELOAD + && m_context.mode.extension == InstallMode::ExtensionType::DIR)) { + LogInfo("cp " << manifest_file << " " << commit_manifest); - DPL::FileInput input(DPL::ToUTF8String(manifest_file)); - DPL::FileOutput output(destFile.str()); - DPL::Copy(&input, &output); - LogDebug("Manifest writen to: " << destFile.str()); + DPL::FileInput input(DPL::ToUTF8String(manifest_file)); + DPL::FileOutput output(commit_manifest); + DPL::Copy(&input, &output); + LogDebug("Manifest writen to: " << commit_manifest); - //removing temp file - unlink((DPL::ToUTF8String(manifest_file)).c_str()); - manifest_file = DPL::FromUTF8String(destFile.str().c_str()); + //removing temp file + unlink((DPL::ToUTF8String(manifest_file)).c_str()); + manifest_file = DPL::FromUTF8String(commit_manifest); + } } void TaskManifestFile::writeManifest(const DPL::String & path) @@ -943,8 +939,8 @@ void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp) { FOREACH(it, m_context.widgetConfig.configInfo.settingsList) { - if (!strcmp(DPL::ToUTF8String(it->m_name).c_str(), ST_NODISPLAY)) { - if (!strcmp(DPL::ToUTF8String(it->m_value).c_str(), ST_TRUE)) { + if (!strcmp(DPL::ToUTF8String(it->m_name).c_str(), STR_NODISPLAY)) { + if (!strcmp(DPL::ToUTF8String(it->m_value).c_str(), STR_TRUE)) { uiApp.setNodisplay(true); uiApp.setTaskmanage(false); } else { @@ -1079,8 +1075,21 @@ void TaskManifestFile::setLiveBoxInfo(Manifest& manifest) liveBox.setUpdatePeriod(ConfigInfo->m_updatePeriod); } - if (ConfigInfo->m_label != L"") { - liveBox.setLabel(ConfigInfo->m_label); + std::list > boxLabelList; + if (!ConfigInfo->m_label.empty()) { + FOREACH(im, ConfigInfo->m_label) { + std::pair boxSize; + Locale i = (*im).first; + // translate en -> en_US etc + DPL::OptionalString tag = getLangTag(i); + if (tag.IsNull()) { + tag = i; + } + boxSize.first = (*tag); + boxSize.second = (*im).second; + boxLabelList.push_back(boxSize); + } + liveBox.setLabel(boxLabelList); } DPL::String defaultLocale = diff --git a/src/jobs/widget_install/task_manifest_file.h b/src/jobs/widget_install/task_manifest_file.h index d4f1c90..efb1881 100644 --- a/src/jobs/widget_install/task_manifest_file.h +++ b/src/jobs/widget_install/task_manifest_file.h @@ -61,7 +61,6 @@ class TaskManifestFile : //TODO stepAbort //steps void stepCreateExecFile(); - void stepFinalize(); void stepCopyIconFiles(); void stepCopyLiveboxFiles(); void stepGenerateManifest(); @@ -72,7 +71,6 @@ class TaskManifestFile : //For widget update void stepBackupIconFiles(); - void stepUpdateFinalize(); void stepAbortIconFiles(); @@ -83,6 +81,7 @@ class TaskManifestFile : xmlTextWriterPtr writer; DPL::String manifest_name; DPL::String manifest_file; + std::string commit_manifest; //private methods diff --git a/src/jobs/widget_install/task_smack.cpp b/src/jobs/widget_install/task_smack.cpp index a007bf7..31ab408 100644 --- a/src/jobs/widget_install/task_smack.cpp +++ b/src/jobs/widget_install/task_smack.cpp @@ -93,9 +93,8 @@ void TaskSmack::StepSmackFolderLabeling() /* /opt/usr/apps/[pkgid] directory's label is "_" */ if (PC_OPERATION_SUCCESS != app_label_dir("_", m_context.locations->getPackageInstallationDir().c_str())) { - free(m_pkgId); - ThrowMsg(Exceptions::NotAllowed, "Instalation failure. " - "Add Label failure"); + LogWarning("Add label to " << + m_context.locations->getPackageInstallationDir()); } /* res directory */ @@ -103,83 +102,48 @@ void TaskSmack::StepSmackFolderLabeling() "/res"; if (PC_OPERATION_SUCCESS != app_label_dir(m_pkgId, resDir.c_str())) { - free(m_pkgId); - ThrowMsg(Exceptions::NotAllowed, "Instalation failure. " - "Add Label failure"); + LogWarning("Add label to " << resDir); } /* for prealod */ - if (m_context.mode.installTime == InstallMode::InstallTime::PRELOAD) + if (m_context.mode.installTime == InstallMode::InstallTime::PRELOAD && + m_context.mode.extension != InstallMode::ExtensionType::DIR) { if (PC_OPERATION_SUCCESS != app_label_dir("_", m_context.locations->getUserDataRootDir().c_str())) { - free(m_pkgId); - ThrowMsg(Exceptions::NotAllowed, "Instalation failure. " - "Add Label failure"); + LogWarning("Add label to " << m_context.locations->getUserDataRootDir()); } } /* data directory */ - if (PC_OPERATION_SUCCESS != app_label_dir(m_pkgId, - m_context.locations->getPrivateStorageDir().c_str())) { - free(m_pkgId); - ThrowMsg(Exceptions::NotAllowed, "Instalation failure. " - "Add Label failure"); + if (PC_OPERATION_SUCCESS != + app_label_dir(m_pkgId, + m_context.locations->getPrivateStorageDir().c_str())) + { + LogWarning("Add label to " << m_context.locations->getPrivateStorageDir()); + } + + /* tmp directory */ + if (PC_OPERATION_SUCCESS != + app_label_dir(m_pkgId, + m_context.locations->getPrivateTempStorageDir().c_str())) + { + LogWarning("Add label to " << m_context.locations->getPrivateTempStorageDir()); } /* bin directory */ if (PC_OPERATION_SUCCESS != app_label_dir(m_pkgId, m_context.locations->getBinaryDir().c_str())) { - free(m_pkgId); - ThrowMsg(Exceptions::NotAllowed, "Instalation failure. " - "Add Label failure"); + LogWarning("Add label to " << m_context.locations->getBinaryDir()); } if(!setLabelForSharedDir(m_pkgId)) { - ThrowMsg(Exceptions::NotAllowed, "Instalation failure. " - "Add Label failure"); + LogWarning("Add label to shared directory"); } free(m_pkgId); - /* TODO : set label at wrt-client - - std::string app = DPL::ToUTF8String(m_context.widgetConfig.tzAppid); - char* appId = NULL; - appId = (char*)calloc(1, app.length() + 1); - snprintf(appId, app.length() + 1, "%s", app.c_str()); - - if (0 != smack_lsetlabel(m_context.locations->getExecFile().c_str(), - appId, SMACK_LABEL_ACCESS)) { - free(m_pkgId); - free(appId); - ThrowMsg(Exceptions::NotAllowed, "Instalation failure. " - "Add ACESS Label for binary failure"); - } - - if (0 != smack_lsetlabel(m_context.locations->getExecFile().c_str(), - appId, SMACK_LABEL_EXEC)) { - free(m_pkgId); - free(appId); - ThrowMsg(Exceptions::NotAllowed, "Instalation failure. " - "Add EXEC Label for binary failure"); - } - - if (PC_OPERATION_SUCCESS != app_add_friend(m_pkgId, appId)) { - free(m_pkgId); - free(appId); - ThrowMsg(Exceptions::NotAllowed, "Instalation failure. " - "Add friend failure"); - } - - if (PC_OPERATION_SUCCESS != app_label_shared_dir(appId, m_pkgId, - m_context.locations->getBinaryDir().c_str())) { - free(m_pkgId); - free(appId); - ThrowMsg(Exceptions::NotAllowed, "Instalation failure. " - "Add Label failure"); - } - */ + /* TODO : set label at wrt-client */ #endif } @@ -188,7 +152,7 @@ void TaskSmack::StepSmackPrivilege() LogInfo("----------------> SMACK:\ Jobs::WidgetInstall::TaskSmack::SmackPrivilegeStep()"); #ifdef WRT_SMACK_ENABLED - /* TODO : + /* TODO : std::string id = DPL::ToUTF8String(m_context.widgetConfig.tzAppid); */ std::string id = DPL::ToUTF8String(m_context.widgetConfig.tzPkgid); @@ -199,24 +163,29 @@ void TaskSmack::StepSmackPrivilege() WrtDB::ConfigParserData::PrivilegeList privileges = m_context.widgetConfig.configInfo.privilegeList; - const char** perm_list = new const char*[privileges.size() + 1]; + char** perm_list = new char*[privileges.size() + 1]; int index = 0; FOREACH(it, privileges) { LogInfo("Permission : " << it->name); int length = DPL::ToUTF8String(it->name).length(); - char *priv = (char*) calloc(1, (sizeof(char) * length) + 1); + char *priv = new char[length + 1]; snprintf(priv, length + 1, "%s", - DPL::ToUTF8String(it->name).c_str()); + DPL::ToUTF8String(it->name).c_str()); perm_list[index++] = priv; } perm_list[index] = NULL; if (PC_OPERATION_SUCCESS != app_enable_permissions(appId, APP_TYPE_WGT, - perm_list, true)) { - LogError("failure in contructing smack rules based on perm_list"); + const_cast(perm_list), true)) { + LogWarning("failure in contructing smack rules based on perm_list"); } free(appId); + index = 0; + while (NULL != perm_list[index]) { + delete [] perm_list[index++]; + } + delete [] perm_list; m_context.job->UpdateProgress( InstallerContext::INSTALL_SMACK_ENABLE, @@ -230,7 +199,7 @@ void TaskSmack::StepRevokeForUpdate() Jobs::WidgetInstall::TaskSmack::StepRevokePrivilegeForUpdate()"); #ifdef WRT_SMACK_ENABLED if (PC_OPERATION_SUCCESS != app_revoke_permissions(m_pkgId)) { - LogError("failure in revoking smack permissions"); + LogWarning("failure in revoking smack permissions"); } #endif } @@ -249,11 +218,11 @@ void TaskSmack::StepAbortSmack() */ if (PC_OPERATION_SUCCESS != app_revoke_permissions(m_pkgId)) { - LogError("failure in revoking smack permissions"); + LogWarning("failure in revoking smack permissions"); } if (PC_OPERATION_SUCCESS != app_uninstall(m_pkgId)) { - LogError("failure in removing smack rules file"); + LogWarning("failure in removing smack rules file"); } free(m_pkgId); #endif diff --git a/src/jobs/widget_install/task_update_files.cpp b/src/jobs/widget_install/task_update_files.cpp index 12af068..1c41e5d 100644 --- a/src/jobs/widget_install/task_update_files.cpp +++ b/src/jobs/widget_install/task_update_files.cpp @@ -68,11 +68,14 @@ void TaskUpdateFiles::StepBackupDirectory() LogDebug("StepCreateBackupFolder"); std::string backPath = m_context.locations->getBackupDir(); - LogDebug("backup resource directory path : " << backPath); + LogDebug("Backup resource directory path : " << backPath); std::string pkgPath = m_context.locations->getPackageInstallationDir(); if (0 == access(backPath.c_str(), F_OK)) { - WrtUtilRemove(backPath); + if (!WrtUtilRemove(backPath)) { + ThrowMsg(Exceptions::RemovingFolderFailure, + "Error occurs during removing backup resource directory"); + } } LogDebug("copy : " << pkgPath << " to " << backPath); if ((rename(pkgPath.c_str(), backPath.c_str())) != 0) { diff --git a/src/jobs/widget_install/task_widget_config.cpp b/src/jobs/widget_install/task_widget_config.cpp old mode 100644 new mode 100755 index c5bbc5b..f77a8b7 --- a/src/jobs/widget_install/task_widget_config.cpp +++ b/src/jobs/widget_install/task_widget_config.cpp @@ -45,6 +45,9 @@ #include #include #include +#include +#include +#include namespace { // anonymous const DPL::String BR = DPL::FromUTF8String("
"); @@ -57,6 +60,8 @@ const char *const DEFAULT_LANGUAGE = "default"; const char *const WRT_WIDGET_CONFIG_FILE_NAME = "config.xml"; const std::string WINDGET_INSTALL_NETWORK_ACCESS = "network access"; + +const char WRT_WIDGETS_XML_SCHEMA[] = "/usr/etc/wrt-installer/widgets.xsd"; } namespace Jobs { @@ -511,6 +516,50 @@ void TaskWidgetConfig::StepVerifyFeatures() "Widget Config step2 Finished"); } +void TaskWidgetConfig::StepVerifyLivebox() +{ + using namespace WrtDB; + ConfigParserData &data = m_installContext.widgetConfig.configInfo; + ConfigParserData::LiveboxList liveBoxList = data.m_livebox; + + if (liveBoxList.size() <= 0) { + return; + } + + FOREACH (it, liveBoxList) { + std::string boxType; + + if ((**it).m_type.empty()) { + boxType = web_provider_livebox_get_default_type(); + } else { + boxType = DPL::ToUTF8String((**it).m_type); + } + + LogInfo("livebox type: " << boxType); + + boxSizeType boxSizeList = (**it).m_boxInfo.m_boxSize; + char** boxSize = static_cast( + malloc(sizeof(char*)* boxSizeList.size())); + + int boxSizeCnt = 0; + FOREACH (m, boxSizeList) { + boxSize[boxSizeCnt++] = strdup(DPL::ToUTF8String((*m).first).c_str()); + } + + bool chkSize = web_provider_plugin_check_supported_size( + boxType.c_str(), boxSize, boxSizeCnt); + + for(int i = 0; i < boxSizeCnt; i++) { + delete[] boxSize[i]; + } + + if(!chkSize) { + LogError("Invalid boxSize"); + ThrowMsg(Exceptions::WidgetConfigFileInvalid, "Invalid boxSize"); + } + } +} + bool TaskWidgetConfig::isFeatureAllowed(WrtDB::AppType appType, DPL::String featureName) { @@ -676,6 +725,13 @@ bool TaskWidgetConfig::parseConfigurationFileWidget( Try { ParserRunner parser; +#ifdef SCHEMA_VALIDATION_ENABLED + if(!parser.Validate(configFilePath, WRT_WIDGETS_XML_SCHEMA)) + { + LogError("Invalid configuration file - schema validation failed"); + return false; + } +#endif parser.Parse(configFilePath, ElementParserPtr(new RootParser( configInfo, diff --git a/src/jobs/widget_install/task_widget_config.h b/src/jobs/widget_install/task_widget_config.h old mode 100644 new mode 100755 index 6b500d3..785d7fc --- a/src/jobs/widget_install/task_widget_config.h +++ b/src/jobs/widget_install/task_widget_config.h @@ -81,6 +81,7 @@ class TaskWidgetConfig : void ProcessAppControlInfo(); void ProcessSecurityModel(); void StepVerifyFeatures(); + void StepVerifyLivebox(); void StepCheckMinVersionInfo(); template diff --git a/src/jobs/widget_install/widget_install_errors.h b/src/jobs/widget_install/widget_install_errors.h index eb1a25e..a76637f 100644 --- a/src/jobs/widget_install/widget_install_errors.h +++ b/src/jobs/widget_install/widget_install_errors.h @@ -67,9 +67,8 @@ DECLARE_JOB_EXCEPTION(Base, CertificateChainVerificationFailed, ErrorCertificate DECLARE_JOB_EXCEPTION(Base, CertificateExpired, ErrorCertificateExpired) DECLARE_JOB_EXCEPTION(Base, NotAllowed, ErrorFatalError) -DECLARE_JOB_EXCEPTION(Base, Deferred, ErrorFatalError) DECLARE_JOB_EXCEPTION(Base, WidgetRunningError, ErrorFatalError) -DECLARE_JOB_EXCEPTION(Base, DRMFailed, ErrorFatalError) +DECLARE_JOB_EXCEPTION(Base, DrmDecryptFailed, ErrorFatalError) DECLARE_JOB_EXCEPTION(Base, DatabaseFailure, ErrorFatalError) DECLARE_JOB_EXCEPTION(Base, RemovingFolderFailure, ErrorFatalError) DECLARE_JOB_EXCEPTION(Base, RemovingFileFailure, ErrorFatalError) diff --git a/src/jobs/widget_install/task_unzip.cpp b/src/jobs/widget_install/widget_unzip.cpp similarity index 73% rename from src/jobs/widget_install/task_unzip.cpp rename to src/jobs/widget_install/widget_unzip.cpp index 0ce18cf..bcf29e8 100644 --- a/src/jobs/widget_install/task_unzip.cpp +++ b/src/jobs/widget_install/widget_unzip.cpp @@ -14,12 +14,12 @@ * limitations under the License. */ /* - * @file task_unzip.cpp + * @file widget_unzip.cpp * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) * @version 1.0 - * @brief Implementation file for installer task unzip + * @brief Implementation file for installer widget unzip */ -#include +#include #include #include #include @@ -64,17 +64,7 @@ PathAndFilePair SplitFileAndPath(const std::string &filePath) namespace Jobs { namespace WidgetInstall { -TaskUnzip::TaskUnzip(InstallerContext &installerContext) : - DPL::TaskDecl(this), - m_installerContext(installerContext) -{ - // Install steps - AddStep(&TaskUnzip::StepUnzipPrepare); - AddStep(&TaskUnzip::StepUnzipProgress); - AddStep(&TaskUnzip::StepUnzipFinished); -} - -void TaskUnzip::ExtractFile(DPL::ZipInput::File *input, +void WidgetUnzip::ExtractFile(DPL::ZipInput::File *input, const std::string &destFileName) { Try @@ -94,38 +84,7 @@ void TaskUnzip::ExtractFile(DPL::ZipInput::File *input, } } -void TaskUnzip::StepUnzipPrepare() -{ - LogInfo("Prepare to unzip..."); - - Try - { - m_zip.reset(new DPL::ZipInput(m_installerContext.locations-> - getWidgetSource())); - LogInfo("Widget package comment: " << m_zip->GetGlobalComment()); - - // Widget package must not be empty - if (m_zip->empty()) { - ThrowMsg(Exceptions::ZipEmpty, - m_installerContext.locations->getWidgetSource()); - } - - // Set iterator to first file - m_zipIterator = m_zip->begin(); - } - Catch(DPL::ZipInput::Exception::OpenFailed) - { - ReThrowMsg(Exceptions::OpenZipFailed, - m_installerContext.locations->getWidgetSource()); - } - Catch(DPL::ZipInput::Exception::SeekFileFailed) - { - ThrowMsg(Exceptions::ExtractFileFailed, - "m_installerContext.locations->getWidgetSource()"); - } -} - -void TaskUnzip::StepUnzipProgress() +void WidgetUnzip::unzipProgress(const std::string &destination) { // Show file info LogInfo("Unzipping: '" << m_zipIterator->name << @@ -141,8 +100,7 @@ void TaskUnzip::StepUnzipProgress() if (fileName[fileName.size() - 1] == '/') { // This is path - std::string newPath = - m_installerContext.locations->getTemporaryPackageDir() + "/" + + std::string newPath = destination + "/" + fileName.substr(0, fileName.size() - 1); LogPedantic("Path to extract: " << newPath); @@ -150,9 +108,7 @@ void TaskUnzip::StepUnzipProgress() createTempPath(newPath); } else { // This is regular file - std::string fileExtractPath = - m_installerContext.locations->getTemporaryPackageDir() + "/" + - fileName; + std::string fileExtractPath = destination + "/" + fileName; LogPedantic("File to extract: " << fileExtractPath); @@ -185,21 +141,44 @@ void TaskUnzip::StepUnzipProgress() if (++m_zipIterator == m_zip->end()) { LogInfo("Unzip progress finished successfuly"); } else { - SwitchToStep(&TaskUnzip::StepUnzipProgress); + unzipProgress(destination); } - - m_installerContext.job->UpdateProgress( - InstallerContext::INSTALL_UNZIP_FILES, - "Unzip widget files to temporary directory"); } -void TaskUnzip::StepUnzipFinished() +void WidgetUnzip::unzipWgtFile(const std::string &source, const std::string &destination) { - // Unzip finished, close internal structures - m_zip.reset(); + LogInfo("Prepare to unzip..."); + + Try + { + m_zip.reset(new DPL::ZipInput(source)); + LogInfo("Widget package comment: " << m_zip->GetGlobalComment()); + + // Widget package must not be empty + if (m_zip->empty()) { + ThrowMsg(Exceptions::ZipEmpty, source); + } + + // Set iterator to first file + m_zipIterator = m_zip->begin(); + + unzipProgress(destination); - // Done - LogInfo("Unzip finished"); + // Unzip finished, close internal structures + m_zip.reset(); + + // Done + LogInfo("Unzip finished"); + } + Catch(DPL::ZipInput::Exception::OpenFailed) + { + ReThrowMsg(Exceptions::OpenZipFailed, source); + } + Catch(DPL::ZipInput::Exception::SeekFileFailed) + { + ThrowMsg(Exceptions::ExtractFileFailed, source); + } } + } //namespace WidgetInstall } //namespace Jobs diff --git a/src/jobs/widget_install/task_unzip.h b/src/jobs/widget_install/widget_unzip.h similarity index 57% rename from src/jobs/widget_install/task_unzip.h rename to src/jobs/widget_install/widget_unzip.h index 69ce606..4db5af7 100644 --- a/src/jobs/widget_install/task_unzip.h +++ b/src/jobs/widget_install/widget_unzip.h @@ -14,52 +14,37 @@ * limitations under the License. */ /* - * @file task_unzip.cpp + * @file widget_unzip.cpp * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) * @version 1.0 * @brief Implementation file for installer task unzip */ -#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_UNZIP_H -#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_UNZIP_H +#ifndef WIDGET_UNZIP_H +#define WIDGET_UNZIP_H #include -#include #include -#include -#include - -class InstallerContext; namespace Jobs { namespace WidgetInstall { -class TaskUnzip : - public DPL::TaskDecl +class WidgetUnzip { - private: - // Installation context - InstallerContext &m_installerContext; + public: + void unzipWgtFile(const std::string &source, const std::string &destination); + private: // Unzip state std::unique_ptr m_zip; DPL::ZipInput::const_iterator m_zipIterator; - WRTEncryptor::ResourceEncryptor *m_resEnc; - - void ExtractFile(DPL::ZipInput::File *input, - const std::string &destFileName); + void unzipProgress(const std::string &destination); + void ExtractFile(DPL::ZipInput::File *input, const std::string + &destFileName); - void EncryptionFile(const std::string &fileName); - - // Steps - void StepUnzipPrepare(); - void StepUnzipProgress(); - void StepUnzipFinished(); - - public: - TaskUnzip(InstallerContext &installerContext); }; + } //namespace WidgetInstall } //namespace Jobs -#endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_UNZIP_H +#endif // WIDGET_UNZIP_H diff --git a/src/jobs/widget_uninstall/task_check.cpp b/src/jobs/widget_uninstall/task_check.cpp index bb6a73b..abe6fd2 100644 --- a/src/jobs/widget_uninstall/task_check.cpp +++ b/src/jobs/widget_uninstall/task_check.cpp @@ -43,10 +43,6 @@ TaskCheck::~TaskCheck() void TaskCheck::StepUninstallPreCheck() { - LogInfo("Uninstall check for appid: " << m_context.tzAppid); - //check if deferred - //TODO if widget to be updated, then remove it from Deferred list? - bool isRunning = false; int ret = app_manager_is_running(m_context.tzAppid.c_str(), &isRunning); if (APP_MANAGER_ERROR_NONE != ret) { diff --git a/src/jobs/widget_uninstall/task_remove_files.cpp b/src/jobs/widget_uninstall/task_remove_files.cpp index 709b4a5..7404a74 100755 --- a/src/jobs/widget_uninstall/task_remove_files.cpp +++ b/src/jobs/widget_uninstall/task_remove_files.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -36,16 +35,11 @@ #include #include #include -#include namespace Jobs { namespace WidgetUninstall { using namespace WrtDB; -namespace { -const char * const VCONF_KEY_PREFIX = "file/private/"; -} - TaskRemoveFiles::TaskRemoveFiles(UninstallerContext& context) : DPL::TaskDecl(this), m_context(context) @@ -53,7 +47,6 @@ TaskRemoveFiles::TaskRemoveFiles(UninstallerContext& context) : AddStep(&TaskRemoveFiles::StepRemoveInstallationDirectory); AddStep(&TaskRemoveFiles::StepRemoveManifest); AddStep(&TaskRemoveFiles::StepRemoveExternalLocations); - AddStep(&TaskRemoveFiles::StepRemoveVconf); AddStep(&TaskRemoveFiles::StepRemoveFinished); } @@ -122,12 +115,18 @@ void TaskRemoveFiles::StepRemoveManifest() destFile << "/opt/share/packages" << "/"; //TODO constant with path } destFile << manifest_name.str(); - int ret1 = pkgmgr_parser_parse_manifest_for_uninstallation( - destFile.str().c_str(), NULL); - int ret2 = unlink(destFile.str().c_str()); - if (ret1 != 0) { - LogWarning("Manifest file failed to parse for uninstallation"); + std::string pre_manifest = "/usr/share/packages/" + manifest_name.str(); + + if (!(access(destFile.str().c_str(), F_OK) == 0 && + access(pre_manifest.c_str(), F_OK) == 0)) { + int ret1 = pkgmgr_parser_parse_manifest_for_uninstallation( + destFile.str().c_str(), NULL); + if (ret1 != 0) { + LogWarning("Manifest file failed to parse for uninstallation"); + } } + + int ret2 = unlink(destFile.str().c_str()); if (ret2 != 0) { LogWarning("No manifest file found: " << destFile.str()); } else { @@ -165,19 +164,5 @@ void TaskRemoveFiles::StepRemoveExternalLocations() dao.unregisterAllExternalLocations(); } } - -void TaskRemoveFiles::StepRemoveVconf() -{ - if (!m_context.removeAbnormal) { - std::string key = - WrtDB::VconfConfig::GetVconfKeyRootPath(DPL::FromUTF8String(m_context. - tzAppid)); - if (vconf_unset_recursive(key.c_str())) { - LogError("Fail to unset vconf file"); - } else { - LogDebug("vconf file is removed"); - } - } -} } //namespace WidgetUninstall } //namespace Jobs diff --git a/src/jobs/widget_uninstall/task_remove_files.h b/src/jobs/widget_uninstall/task_remove_files.h index 2ea7375..6959242 100644 --- a/src/jobs/widget_uninstall/task_remove_files.h +++ b/src/jobs/widget_uninstall/task_remove_files.h @@ -51,7 +51,6 @@ class TaskRemoveFiles : void StepRemoveDesktop(); void StepRemoveManifest(); void StepRemoveExternalLocations(); - void StepRemoveVconf(); public: explicit TaskRemoveFiles(UninstallerContext& context); diff --git a/src/logic/installer_controller.cpp b/src/logic/installer_controller.cpp index 5e65517..552dfae 100644 --- a/src/logic/installer_controller.cpp +++ b/src/logic/installer_controller.cpp @@ -68,14 +68,6 @@ void InstallerController::OnEventReceived( } void InstallerController::OnEventReceived( - const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent & - event) -{ - (void)event; - m_installerLogic.InstallDeferredWidgetPackages(); -} - -void InstallerController::OnEventReceived( const InstallerControllerEvents::InitializeEvent & /*event*/) { m_installerLogic.Initialize(); diff --git a/src/logic/installer_controller.h b/src/logic/installer_controller.h index ca4cc6b..3fa7964 100644 --- a/src/logic/installer_controller.h +++ b/src/logic/installer_controller.h @@ -63,8 +63,6 @@ DECLARE_GENERIC_EVENT_2(UninstallWidgetEvent, */ DECLARE_GENERIC_EVENT_1(NextStepEvent, Jobs::Job *) -DECLARE_GENERIC_EVENT_0(InstallDeferredWidgetPackagesEvent) - DECLARE_GENERIC_EVENT_0(InitializeEvent) DECLARE_GENERIC_EVENT_0(TerminateEvent) } // namespace InstallerEvents @@ -88,7 +86,6 @@ typedef DPL::TypeListDecl< InstallerControllerEvents::InstallPluginEvent, InstallerControllerEvents::UninstallWidgetEvent, InstallerControllerEvents::NextStepEvent, - InstallerControllerEvents::InstallDeferredWidgetPackagesEvent, InstallerControllerEvents::InitializeEvent, InstallerControllerEvents::TerminateEvent>::Type InstallerControllerEventsSet; @@ -121,10 +118,6 @@ class InstallerController : public DPL::Event::Controller< const InstallerControllerEvents::NextStepEvent &event); virtual void OnEventReceived( - const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent - &event); - - virtual void OnEventReceived( const InstallerControllerEvents::InitializeEvent &event); virtual void OnEventReceived( const InstallerControllerEvents::TerminateEvent &event); diff --git a/src/logic/installer_logic.cpp b/src/logic/installer_logic.cpp index aa9061c..10cda89 100644 --- a/src/logic/installer_logic.cpp +++ b/src/logic/installer_logic.cpp @@ -172,31 +172,6 @@ bool InstallerLogic::NextStep(Jobs::Job *job) } } -//TODO this should be moved somewhere...when it should take place? after widget -//is closing? -void InstallerLogic::InstallDeferredWidgetPackages() -{ - LogWarning("Not implemented"); - // LogInfo("Installing deferred widget packages..."); - // - // WidgetPackageList packages = - // GlobalDAO::GetDefferedWidgetPackageInstallationList(); - // - // LogInfo(packages.size() << " widget package(s) to install"); - // - // // Make a copy of widget packages to install, because some - // // widget packages may still fail because they are running - // m_packagesToInstall = packages; - // - // // Start processing - // InstallSingleDeferredPackage(); -} - -void InstallerLogic::InstallSingleDeferredPackage() -{ - LogWarning("Not implemented"); -} - void InstallerLogic::InstallWaitingPlugins() { PluginHandleSetPtr waitingPlugins; diff --git a/src/logic/installer_logic.h b/src/logic/installer_logic.h index 5072e39..496e967 100644 --- a/src/logic/installer_logic.h +++ b/src/logic/installer_logic.h @@ -30,9 +30,6 @@ class InstallerLogic typedef std::map JobsContainer; JobsContainer m_jobs; - void InstallDeferredWidgetPackages(); - void InstallSingleDeferredPackage(); - void ResetProgressPlugins(); void InstallWaitingPlugins(); bool resolvePluginDependencies(PluginHandle handle); diff --git a/src/misc/widget_location.cpp b/src/misc/widget_location.cpp index a2905aa..4c93057 100644 --- a/src/misc/widget_location.cpp +++ b/src/misc/widget_location.cpp @@ -173,6 +173,13 @@ std::string WidgetLocation::getPrivateStorageDir() const WrtDB::GlobalConfig::GetWidgetPrivateStoragePath(); } +std::string WidgetLocation::getPrivateTempStorageDir() const +{ + return getUserDataRootDir() + "/" + + WrtDB::GlobalConfig::GetWidgetPrivateTempStoragePath(); +} + + std::string WidgetLocation::getTemporaryPackageDir() const { return m_temp->getTempPath(); diff --git a/src/misc/widget_location.h b/src/misc/widget_location.h index ad73d80..2b44d4d 100644 --- a/src/misc/widget_location.h +++ b/src/misc/widget_location.h @@ -124,6 +124,7 @@ class WidgetLocation std::string getBackupPrivateDir() const; // /opt/apps/[pkg].backup/data std::string getUserDataRootDir() const; // /opt/usr/apps/[package] std::string getPrivateStorageDir() const; // /opt/usr/apps/[package]/data + std::string getPrivateTempStorageDir() const; // /opt/usr/apps/[package]/tmp std::string getSharedRootDir() const; // /opt/usr/apps/[package]/shared std::string getSharedResourceDir() const; // /opt/usr/apps/[package]/shared/res std::string getSharedDataDir() const; // /opt/usr/apps/[package]/shared/data diff --git a/src/pkg-manager/backendlib.cpp b/src/pkg-manager/backendlib.cpp index 3786026..48f98d4 100644 --- a/src/pkg-manager/backendlib.cpp +++ b/src/pkg-manager/backendlib.cpp @@ -327,7 +327,15 @@ char* getIconInfo(const std::string widgetPath, std::unique_ptr iconFile; - iconFile.reset(zipFile->OpenFile(icon_name)); + Try { + iconFile.reset(zipFile->OpenFile(icon_name)); + } + Catch(DPL::ZipInput::Exception::OpenFileFailed) + { + LogDebug("This web app is hybrid web app"); + std::string hybrid_icon = "res/wgt/" + icon_name; + iconFile.reset(zipFile->OpenFile(hybrid_icon)); + } DPL::BinaryQueue buffer; DPL::AbstractWaitableInputAdapter inputAdapter(iconFile.get()); diff --git a/src/wrt-installer/CMakeLists.txt b/src/wrt-installer/CMakeLists.txt index 7adda4d..3b94562 100644 --- a/src/wrt-installer/CMakeLists.txt +++ b/src/wrt-installer/CMakeLists.txt @@ -40,6 +40,8 @@ SET(WRT_INSTALLER_SOURCES PKG_CHECK_MODULES(WRT_INSTALLER_DEPS pkgmgr-installer libpcrecpp + pkgmgr-info + pkgmgr security-install REQUIRED) diff --git a/src/wrt-installer/wrt-installer.cpp b/src/wrt-installer/wrt-installer.cpp index 77457f5..4db1ad4 100644 --- a/src/wrt-installer/wrt-installer.cpp +++ b/src/wrt-installer/wrt-installer.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include @@ -77,6 +78,19 @@ struct PluginInstallerData void* wrtInstaller; std::string pluginPath; }; + +bool checkInitializeToPreload(std::string pkgid) +{ + std::string RoManifest = "/usr/share/packages/" + pkgid + ".xml"; + std::string RwManifest = "/opt/share/packages/" + pkgid + ".xml"; + + if (access(RwManifest.c_str(), F_OK) == 0 && + access(RoManifest.c_str(), F_OK) == 0) { + LogDebug("This web app need to down update"); + return true; + } + return false; +} } // namespace anonymous WrtInstaller::WrtInstaller(int argc, char **argv) : @@ -223,6 +237,17 @@ void WrtInstaller::OnCreate() return showHelpAndQuit(); } m_packagePath = it->second; + + it = m_CSCconfigurationMap.find( + CSCConfiguration::KEY_REMOVABLE); + if (it == m_CSCconfigurationMap.end()) { + return showHelpAndQuit(); + } + + m_installMode.removable = + (it->second.compare(CSCConfiguration::VALUE_FALSE) == 0) + ? false : true; + AddStep(&WrtInstaller::installStep); LogDebug("path = " << m_packagePath); } else if (it->second == CSCConfiguration::VALUE_UNINSTALL) { @@ -504,10 +529,20 @@ void WrtInstaller::uninstallPkgNameStep() { LogDebug("Uninstalling widget ..."); LogDebug("Package name : " << m_name); - wrt_uninstall_widget(m_name.c_str(), this, &staticWrtStatusCallback, - (m_installByPkgmgr) - ? &staticWrtUninstallProgressCallback : NULL, - pkgmgrSignalInterface); + + if (!checkInitializeToPreload(m_name)) { + wrt_uninstall_widget(m_name.c_str(), this, + &staticWrtStatusCallback, + (m_installByPkgmgr) + ? &staticWrtUninstallProgressCallback : NULL, + pkgmgrSignalInterface); + } else { + wrt_uninstall_widget(m_name.c_str(), this, + &staticWrtInitializeToPreloadCallback, + (m_installByPkgmgr) + ? &staticWrtUninstallProgressCallback : NULL, + pkgmgrSignalInterface); + } } void WrtInstaller::unistallWgtFileStep() @@ -624,6 +659,74 @@ void WrtInstaller::staticWrtInitCallback(WrtErrStatus status, } } +void WrtInstaller::staticWrtInitializeToPreloadCallback(std::string tizenId, WrtErrStatus + status, void* userdata) +{ + WrtInstaller *This = static_cast(userdata); + Assert(This); + + std::string printMsg = "uninstallation"; + + if (WRT_SUCCESS != status) { + // Failure + LogError("Step failed"); + This->m_returnStatus = 1; + + This->showErrorMsg(status, tizenId, printMsg); + + This->DPL::Event::ControllerEventHandler + ::PostEvent(WRTInstallerNS::QuitEvent()); + } else { + InstallMode mode; + mode.extension = InstallMode::ExtensionType::DIR; + mode.installTime = InstallMode::InstallTime::PRELOAD; + mode.rootPath = InstallMode::RootPath::RO; + std::string packagePath = + std::string(WrtDB::GlobalConfig::GetUserPreloadedWidgetPath()) + "/" + + This->m_name; + + wrt_install_widget(packagePath.c_str(), + This, &staticWrtInitPreloadStatusCallback, + NULL, + mode, + This->pkgmgrSignalInterface); + } +} + +void WrtInstaller::staticWrtInitPreloadStatusCallback(std::string tizenId, + WrtErrStatus status, + void* userdata) +{ + WrtInstaller *This = static_cast(userdata); + Assert(This); + + DPL::String resultMsg; + std::string printMsg = "initialization"; + + if (WRT_SUCCESS != status) { + // Failure + LogError("Step failed"); + This->m_returnStatus = 1; + + This->showErrorMsg(status, tizenId, printMsg); + + This->DPL::Event::ControllerEventHandler + ::PostEvent(WRTInstallerNS::QuitEvent()); + } else { + fprintf(stderr, + "## wrt-installer : %s %s was successful.\n", + tizenId.c_str(), + printMsg.c_str()); + LogDebug("Status succesfull"); + This->m_returnStatus = 0; + resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS); + + This->DPL::Event::ControllerEventHandler + ::PostEvent(WRTInstallerNS::NextStepEvent()); + } +} + void WrtInstaller::staticWrtStatusCallback(std::string tizenId, WrtErrStatus status, void* userdata) @@ -653,203 +756,7 @@ void WrtInstaller::staticWrtStatusCallback(std::string tizenId, This->DPL::Event::ControllerEventHandler ::PostEvent(WRTInstallerNS::QuitEvent()); - switch (status) { - case WRT_INSTALLER_ERROR_PACKAGE_NOT_FOUND: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - widget package does not exist\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_PACKAGE_INVALID: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - invalid widget package\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_PACKAGE_LOWER_VERSION: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - given" - " version is lower than existing version\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_MANIFEST_NOT_FOUND: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - manifest" - " file doesn't find in package.\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_MANIFEST_INVALID: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "invalid manifestx.xml\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_CONFIG_NOT_FOUND: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "config.xml does not exist\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_CONFIG_INVALID: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "invalid config.xml\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_SIGNATURE_NOT_FOUND: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "signature doesn't exist in package.\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_SIGNATURE_INVALID: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "invalid signature.\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_SIGNATURE_VERIFICATION_FAILED: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "signature verification failed.\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_ROOT_CERTIFICATE_NOT_FOUND: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "root certificate could not find.\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_CERTIFICATION_INVAID: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "invalid certification.\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_CERTIFICATE_CHAIN_VERIFICATION_FAILED: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "certificate chain verification failed.\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_CERTIFICATE_EXPIRED: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "certificate expired.\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_INVALID_PRIVILEGE: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "invalid privilege\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_PRIVILEGE_LEVEL_VIOLATION: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "privilege level violation\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_MENU_ICON_NOT_FOUND: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "menu icon could not find\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_FATAL_ERROR: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "fatal error\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_OUT_OF_STORAGE: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "out of storage\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_OUT_OF_MEMORY: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "out of memory\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_ARGUMENT_INVALID: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "invalid argument\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_PACKAGE_ALREADY_INSTALLED: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "package already installed\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_ACE_CHECK_FAILED: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "ace check failure\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_MANIFEST_CREATE_FAILED: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "to create manifest failed\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_ENCRYPTION_FAILED: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "encryption of resource failed\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_INSTALL_OSP_SERVCIE: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "installation of osp service failed\n", - tizenId.c_str(), printMsg.c_str()); - break; - - case WRT_INSTALLER_ERROR_UNINSTALLATION_FAILED: - This->m_returnStatus = 1; //this status is specific - fprintf(stderr, "## wrt-installer : %s %s has failed - " - "widget uninstallation failed\n", - tizenId.c_str(), printMsg.c_str()); - break; - - - case WRT_INSTALLER_ERROR_UNKNOWN: - fprintf(stderr,"## wrt-installer : %s %s has failed - unknown error\n", - tizenId.c_str(), printMsg.c_str()); - break; - - default: - break; - } + This->showErrorMsg(status, tizenId, printMsg); } else { fprintf(stderr, "## wrt-installer : %s %s was successful.\n", @@ -875,6 +782,182 @@ void WrtInstaller::staticWrtStatusCallback(std::string tizenId, } } +void WrtInstaller::showErrorMsg(WrtErrStatus status, std::string tizenId, + std::string printMsg) +{ + switch (status) { + case WRT_INSTALLER_ERROR_PACKAGE_NOT_FOUND: + fprintf(stderr, "## wrt-installer : %s %s has failed - widget package does not exist\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_PACKAGE_INVALID: + fprintf(stderr, "## wrt-installer : %s %s has failed - invalid widget package\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_PACKAGE_LOWER_VERSION: + fprintf(stderr, "## wrt-installer : %s %s has failed - given" + " version is lower than existing version\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_MANIFEST_NOT_FOUND: + fprintf(stderr, "## wrt-installer : %s %s has failed - manifest" + " file doesn't find in package.\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_MANIFEST_INVALID: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "invalid manifestx.xml\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_CONFIG_NOT_FOUND: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "config.xml does not exist\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_CONFIG_INVALID: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "invalid config.xml\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_SIGNATURE_NOT_FOUND: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "signature doesn't exist in package.\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_SIGNATURE_INVALID: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "invalid signature.\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_SIGNATURE_VERIFICATION_FAILED: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "signature verification failed.\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_ROOT_CERTIFICATE_NOT_FOUND: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "root certificate could not find.\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_CERTIFICATION_INVAID: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "invalid certification.\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_CERTIFICATE_CHAIN_VERIFICATION_FAILED: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "certificate chain verification failed.\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_CERTIFICATE_EXPIRED: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "certificate expired.\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_INVALID_PRIVILEGE: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "invalid privilege\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_PRIVILEGE_LEVEL_VIOLATION: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "privilege level violation\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_MENU_ICON_NOT_FOUND: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "menu icon could not find\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_FATAL_ERROR: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "fatal error\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_OUT_OF_STORAGE: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "out of storage\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_OUT_OF_MEMORY: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "out of memory\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_ARGUMENT_INVALID: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "invalid argument\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_PACKAGE_ALREADY_INSTALLED: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "package already installed\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_ACE_CHECK_FAILED: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "ace check failure\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_MANIFEST_CREATE_FAILED: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "to create manifest failed\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_ENCRYPTION_FAILED: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "encryption of resource failed\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_INSTALL_OSP_SERVCIE: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "installation of osp service failed\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_UNINSTALLATION_FAILED: + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "widget uninstallation failed\n", + tizenId.c_str(), printMsg.c_str()); + break; + + + case WRT_INSTALLER_ERROR_UNKNOWN: + fprintf(stderr,"## wrt-installer : %s %s has failed - unknown error\n", + tizenId.c_str(), printMsg.c_str()); + break; + + default: + break; + } + +} + void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status, void* userdata) { diff --git a/src/wrt-installer/wrt-installer.h b/src/wrt-installer/wrt-installer.h index 59bcc90..4405a07 100644 --- a/src/wrt-installer/wrt-installer.h +++ b/src/wrt-installer/wrt-installer.h @@ -44,8 +44,11 @@ typedef std::map dataMap; typedef std::pair dataPair; const char* const KEY_OP = "op"; const char* const KEY_PATH = "path"; +const char* const KEY_REMOVABLE = "removable"; const char* const VALUE_INSTALL = "install"; const char* const VALUE_UNINSTALL = "uninstall"; +const char* const VALUE_TRUE = "true"; +const char* const VALUE_FALSE = "false"; } enum ReturnValue @@ -117,9 +120,19 @@ class WrtInstaller : static void failResultCallback(void *data, Evas_Object *obj, void *event_info); + static void staticWrtInitializeToPreloadCallback(std::string tizenId, + WrtErrStatus status, + void* userdata); + + static void staticWrtInitPreloadStatusCallback(std::string tizenId, + WrtErrStatus status, + void* userdata); + void installNewPlugins(); bool popupsEnabled() const; CSCConfiguration::dataMap parseCSCConfiguration(std::string str); + void showErrorMsg(WrtErrStatus status, std::string tizenId, std::string + printMsg); // Private data std::shared_ptr pkgmgrSignalInterface; diff --git a/src/wrt-installer/wrt_installer_api.cpp b/src/wrt-installer/wrt_installer_api.cpp index 83b5172..ff19de7 100644 --- a/src/wrt-installer/wrt_installer_api.cpp +++ b/src/wrt-installer/wrt_installer_api.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -122,12 +121,6 @@ void wrt_installer_init(void *userdata, InstallerControllerEvents:: InitializeEvent()); - // Install deferred widget packages - CONTROLLER_POST_EVENT( - Logic::InstallerController, - InstallerControllerEvents:: - InstallDeferredWidgetPackagesEvent()); - if (callback) { LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK"); callback(WRT_SUCCESS, userdata); diff --git a/tests/general/widgets/manifest.wgt b/tests/general/widgets/manifest.wgt index 0977e5bd5287a86d01719dcdb50b3e3c499e23f1..e70d2af20db4266b7c530249cb55505635a97bdb 100644 GIT binary patch delta 596 zcmX@lGl8={z?+#xgn@y9gMrs~o0Hb7teBaM3=ET*85p=2WEhh3^U^ZY^(u06LPIzi zn6t{}1V#gKX$3a}Bg+e*A~3Nu*f(F;P+;%(@Sd9Ec@LWw-OY8>G8gc0<tD~^{6RR_?BMq|UGYW^>kno8xw83u z`TMv%Y1f_2XBRp#^`>3AvU&P+*0f{uG8gR-YBCT$f9dJk`8&A$-h4ddnSbr++jTW> ze3m+Rn6CtkX5csYQkAv0F~G zeP1iLc$0WA!Avq_C4NTBlc*H<(Wl7s{w!&QN;v__;)ed3 zWhvM{>dP+Lw)Y+Tq=~Oi9GHGz+gbezj+JuEk++XW?XSB0gQVF x24IvkG&F)($T7|eiE*^po_vT^i|H=o7E7>yAhmEWeJP3*B#0C%EwuVnTH2<4u=v!bf4+Yk|LX83&i(CpIOOeg$FDc!$)3 z5pi_apiWW6qa#mm-;MiIN|_o(!jVa6(c~)b?Ex4yRBUqY^~o|Pj7vp^f+F>4o@Y@VP_7e@W!NMKc9_pU`+_MoQ;3nL=_Rd5RJ^i_kxvdy zP@fntuOg-#6iS=mP*p^1jan*h8rox1rb_`2b)RUQNDxzryPlvUMy5{+EziuQn)dQ`MQe5ACp5yNuE>0jj&*u6NiT&#~>BS$Sg+onQOCk*w8j?(>HZ9-fb@_`=Sat7n(jcO1WS_pd+i{C08EB_6*SyFJ&j zYhw<7IQ`@0xmU&>y%s-r`=zCmYquSY{(Pz4wfU2yZ;Y3s%TIn)Tg<=xV)ROWjq~15 zch7WR{G)tyEUN9_n)y9H-@_MfbZ7Y4bN=GK_p@)EoZS3P;`EV;$3A`a&E<7_wk_ae zvFlGvUHjqnU*4Vl?$pM`Z*yDIAB^AIk~govb7N{ds;$3T&+Pu<%QL~ln;jg^ETqRy zQi-i)mPZjuGe0?6}|r0zmzgJ6cw3FiO+ diff --git a/tests/general/widgets/nonroot.wgt b/tests/general/widgets/nonroot.wgt index 6633b1a938d68c5894bdda718a3d0949b5b48e60..064dc46321bbf83a5f421f879972d7c5a40b860f 100644 GIT binary patch delta 547 zcmcbwdqt~0z?+#xgn@y9gJGi2HYdYtc1j713=H#_7#O%1WEhh3^U^ZY^(u06LPIzi zm>Wyy1eStu1vdjD%L`@(1~4%-$lCv~fxx}r+J5sKIINf2tX6Ri3E|;jY?X{WIZ;CB z_6pl$U3<=F*#=QtuJt1hWt8YOo7WJL>W zYrBk>c!$yPY17uNIhFa4kdGWQt|*fLMkNCS tFa{YK8bK`N2xNsuAZp}Ijuz8mTEaNFUCfLrj(PHaF)^-vAnhO<7yu9q*nj{4 delta 905 zcmZ`&OK%e~5KbD(p+^)rzyZsZ5ERv$LLU(A253Z!RESd2iX*aion5zH+qJ!9%O&E% ziCa#HE8-8pui(UiJNyt1*x3h_P`uj5c)t1O+nMptwO{MEh6k-n?S@+)1|N41Z+v=x zv(;$0d&TaBf{$s8^4a$$cy)ZVxBdV=>iH8I#l(Pw&^R#x-0pNBpiuz1;7SMsK`J5= zz;VWy4izCBf;U8IDtG`lPzP;5U@1%zz)c%EJ6XCu<=QJ)H3WIexb7PImRNjZjO=>e z+(JUd-UVcD1=!_toRVId+xO;H;fRP$Po=Smdjr9N69){@#-+D^;CmHf>L5iB&P*Z{ zAStFSfcPvoE166tNJU8FRA)R!l6kO*bXrEkm;HjqD|kv$Mnl3iS;#c~pXzCj zQ^^RZLi<9VD_3xEJG=w#bvh5hsL%lVLP=DnE#YNeY8zPhX=e)pt-=7hT_ky2w_#_x z1-&xF`V8TwMDmE_C^0F6z?@6lR4k=Ufn80#+&S*rcGbZ+42jlY^yJ0pc(9K!!zvA+ zQ5k`N6EhL&v@#{jV#;-4PHTotM%XMaR8=Rd)}PNr_ky7L5T+-4&+^^F`$x}FJ&zKH zr#QCi|2ZL0_>ZT fX}>l5)82;7