From: Jihoon Chung Date: Thu, 3 Jan 2013 01:50:16 +0000 (+0900) Subject: [Release] wrt-installer_0.0.89 X-Git-Tag: accepted/tizen_2.1/20130425.023916~20^2~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d0b581548563b0b271382c1aedb900ff055cd42;p=framework%2Fweb%2Fwrt-installer.git [Release] wrt-installer_0.0.89 --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..306ad56 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*~ +\#*# +.#* \ No newline at end of file diff --git a/configuration/config.tizen.xsd b/configuration/config.tizen.xsd old mode 100644 new mode 100755 index a981896..46adddc --- a/configuration/config.tizen.xsd +++ b/configuration/config.tizen.xsd @@ -1,10 +1,10 @@ - - + + - @@ -38,6 +38,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -57,10 +93,101 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/configuration/config.xml b/configuration/config.xml old mode 100644 new mode 100755 index 4038a23..3e5dc15 --- a/configuration/config.xml +++ b/configuration/config.xml @@ -1,23 +1,23 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + hello @@ -32,4 +32,5 @@ + diff --git a/configuration/config.xsd b/configuration/config.xsd old mode 100644 new mode 100755 index 84d734d..07d19e8 --- a/configuration/config.xsd +++ b/configuration/config.xsd @@ -49,6 +49,11 @@ + + + + + @@ -68,10 +73,11 @@ + - + @@ -79,7 +85,7 @@ - + @@ -154,8 +160,6 @@ - - diff --git a/debian/changelog b/debian/changelog index e5a18b9..a9505da 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,178 @@ +wrt-installer (0.0.89) unstable; urgency=low + + * Throw error on no ElementParser + * Closed directory + * Apply vconf key path builder + * Add vconf creation for memory saving mode + + * Git : framework/web/wrt-installer + * Tag : wrt-installer_0.0.89 + + -- Jihoon Chung Wed, 02 Jan 2013 11:17:14 +0900 + +wrt-installer (0.0.88) unstable; urgency=low + + * Create/Remove vconf for security settings + * Remove required attribute and viewmode Change windowed to maximized + * auto-launch tag has been changed + * livebox configuration valuables has been modified + * For livebox configuration + + * Git : framework/web/wrt-installer + * Tag : wrt-installer_0.0.88 + + -- Jihoon Chung Fri, 28 Dec 2012 16:59:20 +0900 + +wrt-installer (0.0.86) unstable; urgency=low + + * Add installation to external location(sdcard) + * Remove installed directory and manifest file when installation failed after ace check + * Fixed directory installation using pkgcmd + * Fixed crash for external installation + + * Git : framework/web/wrt-installer + * Tag : wrt-installer_0.0.86 + + -- Soyoung Kim Wed, 26 Dec 2012 13:45:45 +0900 + +wrt-installer (0.0.85) unstable; urgency=low + + * Add category element at manifest and config.xml + + -- KEONGEUN Fri, 21 Dec 2012 16:48:54 +0900 + +wrt-installer (0.0.84) unstable; urgency=low + + * Fix for unhandled exception + * Dummy PkgmgrSignal for command line installation + * Support privilege database table + + * Git : framework/web/wrt-installer + * Tag : wrt-installer_0.0.84 + + -- Jihoon Chung Thu, 20 Dec 2012 08:49:25 +0900 + +wrt-installer (0.0.83) unstable; urgency=low + + * Handle unhandled exceptions in wrt-installer + * Support + + * Git : framework/web/wrt-installer + * Tag : wrt-installer_0.0.83 + + -- Jihoon Chung Fri, 14 Dec 2012 10:47:26 +0900 + +wrt-installer (0.0.82) unstable; urgency=low + + * Fixed build break + * [systemd] fix build error + * Directory install feature fix + * Update schema files + * [Prevent] Removed warning from Prevent. + * [Prevent] Removed warning from Prevent. + * Fixed package manager doesn't receive signal for widget update failed. + + * Git : framework/web/wrt-installer + * Tag : wrt-installer_0.0.82 + + -- Soyoung Kim Wed, 12 Dec 2012 15:50:01 +0900 + +wrt-installer (0.0.81) unstable; urgency=low + + * Merge branch 'systemd' + + * Git : framework/web/wrt-installer + * Tag : wrt-installer_0.0.81 + + -- Soyoung Kim Thu, 06 Dec 2012 14:02:20 +0900 + +wrt-installer (0.0.80) unstable; urgency=low + + * Distinguish between system headers and project headers. + * Add nodisplay setting + * arrangement of directory creation. + * add to create share directory + * Fixed nodisplay when other setting values exist. + + * Git : framework/web/wrt-installer + * Tag : wrt-installer_0.0.80 + + -- Soyoung Kim Wed, 05 Dec 2012 17:23:51 +0900 + +wrt-installer (0.0.79) unstable; urgency=low + + * Direcotry install feature added to wrt-installer + * [Prevent] Handle return value of regcomp. + * Removing unused merged code + * Pkgname (tizen id) - not null + * Platform version check during wgt installation - fixed + * Revert "Pkgname (tizen id) - not null" + * save installed path to db for preload widget + * Fixed certificate of authentication value to base64. + + * Git : framework/web/wrt-installer + * Tag : wrt-installer_0.0.79 + + -- Soyoung Kim Fri, 30 Nov 2012 21:44:41 +0900 + +wrt-installer (0.0.78) unstable; urgency=low + + * [Prevent] Handle fread return value. + * [Prevent] Handle return value from CertificateCollection::sort. + * remove temporary drm library and header files. + * [Installer] Clean up Flash Parser. + * Fixed can't remove preinstall widget during booting + + * Git : framework/web/wrt-installer + * Tag : wrt-installer_0.0.78 + + -- Soyoung Kim Tue, 27 Nov 2012 16:51:00 +0900 + +wrt-installer (0.0.77) unstable; urgency=low + + * Revert "Platform version check during wgt installation" + + * Git : framework/web/wrt-installer + * Tag : wrt-installer_0.0.77 + + -- Soyoung Kim Fri, 23 Nov 2012 21:19:17 +0900 + +wrt-installer (0.0.76) unstable; urgency=low + + * Filter output from wrt-installer needs for "expr match" to succeed + * Introduce systemd support + * Removed deprecated code + * Handle return value + * Platform version check during wgt installation + + * Git : framework/web/wrt-installer + * Tag : wrt-installer_0.0.76 + + -- Jihoon Chung Fri, 23 Nov 2012 12:01:17 +0900 + +wrt-installer (0.0.75) unstable; urgency=low + + * Fail to install package + * External file removal fix + * Removed GetFactoryWidget. + * Ace database fulfill implemented + * update drm library for temporary + + * Git : framework/web/wrt-installer + * Tag : wrt-installer_0.0.75 + + -- sy037.kim Mon, 19 Nov 2012 19:56:28 +0900 + +wrt-installer (0.0.74) unstable; urgency=low + + * Replace SignatureValidator. + * Fixed to set certi information + + * Git : framework/web/wrt-installer + * Tag : wrt-installer_0.0.74 + + -- Soyoung Kim Thu, 15 Nov 2012 16:46:02 +0900 + wrt-installer (0.0.73) unstable; urgency=low * WidgetHandle removal - part 4 diff --git a/etc/CMakeLists.txt b/etc/CMakeLists.txt index adccb68..370d4af 100644 --- a/etc/CMakeLists.txt +++ b/etc/CMakeLists.txt @@ -1,10 +1,3 @@ SET(ETC_DIR ${PROJECT_SOURCE_DIR}/etc) INSTALL(PROGRAMS ${ETC_DIR}/wrt_preinstall_widgets.sh DESTINATION /etc/rc.d/init.d) - -# Below Code is temporary. When DRM engine is provided it will be removed. -IF("${ARCH}" MATCHES "arm") - INSTALL(FILES ${ETC_DIR}/drm/armv7l/libdrm-service-core-intel.so.0.0.0 DESTINATION lib) -ELSE("${ARCH}" MATCHES "arm") - INSTALL(FILES ${ETC_DIR}/drm/ix86/libdrm-service-core-intel.so.0.0.0 DESTINATION lib) -ENDIF("${ARCH}" MATCHES "arm") diff --git a/etc/drm/armv7l/libdrm-service-core-intel.so b/etc/drm/armv7l/libdrm-service-core-intel.so deleted file mode 120000 index df92fda..0000000 --- a/etc/drm/armv7l/libdrm-service-core-intel.so +++ /dev/null @@ -1 +0,0 @@ -libdrm-service-core-intel.so.0 \ No newline at end of file diff --git a/etc/drm/armv7l/libdrm-service-core-intel.so.0 b/etc/drm/armv7l/libdrm-service-core-intel.so.0 deleted file mode 120000 index 4af898f..0000000 --- a/etc/drm/armv7l/libdrm-service-core-intel.so.0 +++ /dev/null @@ -1 +0,0 @@ -libdrm-service-core-intel.so.0.0.0 \ No newline at end of file diff --git a/etc/drm/armv7l/libdrm-service-core-intel.so.0.0.0 b/etc/drm/armv7l/libdrm-service-core-intel.so.0.0.0 deleted file mode 100755 index 68b76cf..0000000 Binary files a/etc/drm/armv7l/libdrm-service-core-intel.so.0.0.0 and /dev/null differ diff --git a/etc/drm/ix86/libdrm-service-core-intel.so b/etc/drm/ix86/libdrm-service-core-intel.so deleted file mode 120000 index df92fda..0000000 --- a/etc/drm/ix86/libdrm-service-core-intel.so +++ /dev/null @@ -1 +0,0 @@ -libdrm-service-core-intel.so.0 \ No newline at end of file diff --git a/etc/drm/ix86/libdrm-service-core-intel.so.0 b/etc/drm/ix86/libdrm-service-core-intel.so.0 deleted file mode 120000 index 4af898f..0000000 --- a/etc/drm/ix86/libdrm-service-core-intel.so.0 +++ /dev/null @@ -1 +0,0 @@ -libdrm-service-core-intel.so.0.0.0 \ No newline at end of file diff --git a/etc/drm/ix86/libdrm-service-core-intel.so.0.0.0 b/etc/drm/ix86/libdrm-service-core-intel.so.0.0.0 deleted file mode 100755 index d21a059..0000000 Binary files a/etc/drm/ix86/libdrm-service-core-intel.so.0.0.0 and /dev/null differ diff --git a/etc/wrt_preinstall_widgets.sh b/etc/wrt_preinstall_widgets.sh index 66c5515..9742d0d 100755 --- a/etc/wrt_preinstall_widgets.sh +++ b/etc/wrt_preinstall_widgets.sh @@ -23,8 +23,8 @@ install_widgets() { for list in $_wgt_list do echo "Install $list" - return_string=`wrt-installer -i $list` - if [ `expr match "$return_string" 'installed'` -gt 0 ]; then + return_string=`wrt-installer -il $list` + if [ "$return_string" != "${return_string/installed/}" ]; then echo "$list widget installation success" rm -rf $list else diff --git a/packaging/wrt-installer.spec b/packaging/wrt-installer.spec index 4fe6dc8..1e54895 100644 --- a/packaging/wrt-installer.spec +++ b/packaging/wrt-installer.spec @@ -1,12 +1,13 @@ -#git:framework/web/wrt-installer wrt-installer 0.0.73 +#git:framework/web/wrt-installer wrt-installer 0.0.89 Name: wrt-installer Summary: Installer for tizen Webruntime -Version: 0.0.73 +Version: 0.0.89 Release: 1 Group: Development/Libraries License: Apache License, Version 2.0 URL: N/A Source0: %{name}-%{version}.tar.gz +Source100: wrt-preinstall-widgets.service BuildRequires: cmake BuildRequires: edje-tools BuildRequires: pkgconfig(libxml-2.0) @@ -17,9 +18,8 @@ BuildRequires: pkgconfig(dpl-event-efl) BuildRequires: pkgconfig(dpl-utils-efl) BuildRequires: pkgconfig(dpl-wrt-dao-ro) BuildRequires: pkgconfig(dpl-wrt-dao-rw) -BuildRequires: pkgconfig(ecore-x) -BuildRequires: pkgconfig(security) BuildRequires: pkgconfig(security-install) +BuildRequires: pkgconfig(ecore-x) BuildRequires: pkgconfig(xmlsec1) BuildRequires: pkgconfig(libidn) BuildRequires: pkgconfig(libiri) @@ -35,11 +35,10 @@ BuildRequires: pkgconfig(tapi) BuildRequires: pkgconfig(shortcut) BuildRequires: pkgconfig(dpl-encryption) BuildRequires: pkgconfig(capi-appfw-app-manager) -BuildRequires: pkgconfig(drm-client) +BuildRequires: pkgconfig(drm-service-core-intel) +BuildRequires: pkgconfig(app2sd) Requires: xmlsec1 -Provides: libdrm-service-core-intel.so.0 - %description Description: Wrt Installer for Tizen apps and Wac apps @@ -47,12 +46,6 @@ Description: Wrt Installer for Tizen apps and Wac apps %setup -q %build -# for drm temporary code -%ifarch %{ix86} -BUILD_ARCH_=x86 -%else -BUILD_ARCH_=arm -%endif export LDFLAGS+="-Wl,--rpath=/usr/lib -Wl,--hash-style=both -Wl,--as-needed" LDFLAGS="$LDFLAGS" @@ -60,7 +53,6 @@ LDFLAGS="$LDFLAGS" cmake . -DCMAKE_INSTALL_PREFIX=/usr \ -DDPL_LOG=ON \ -DCMAKE_PACKAGE_VERSION=%{version} \ - -DARCH="$BUILD_ARCH_" \ -DCMAKE_BUILD_TYPE=%{?build_type:%build_type} make %{?jobs:-j%jobs} @@ -70,6 +62,16 @@ 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/S46lwrt_preinstall_widgets.sh +ln -s ../init.d/wrt_preinstall_widgets.sh %{buildroot}%{_sysconfdir}/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh + %clean rm -rf %{buildroot} @@ -81,18 +83,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/S46lwrt_preinstall_widgets.sh ] && rm /etc/rc.d/rc3.d/S46lwrt_preinstall_widgets.sh -[ -h /etc/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh ] && rm /etc/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh -ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc3.d/S46lwrt_preinstall_widgets.sh -ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh - -# for drm temporary code -mkdir -p /opt/var/drm/inteldrm -mkdir -p own 0:5000 /opt/var/drm/inteldrm -chmod 755 /opt/var/drm/inteldrm - -ln -s /usr/lib/libdrm-service-core-intel.so.0.0.0 /usr/lib/libdrm-service-core-intel.so.0 -ln -s /usr/lib/libdrm-service-core-intel.so.0 /usr/lib/libdrm-service-core-intel.so # for downloadable Application icons path mkdir -p /opt/share/icons/default/small @@ -100,9 +90,11 @@ mkdir -p /opt/share/icons/default/small %files %manifest wrt-installer.manifest %attr(755,root,root) %{_bindir}/wrt-installer -%attr(775,root,root) %{_initrddir}/wrt_preinstall_widgets.sh +%attr(775,root,root) %{_initddir}/wrt_preinstall_widgets.sh +%{_sysconfdir}/rc.d/rc3.d/S46lwrt_preinstall_widgets.sh +%{_sysconfdir}/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh %attr(644,root,root) %{_datadir}/edje/wrt/* /usr/etc/package-manager/backendlib/libwgt.so %{_datadir}/license/%{name} -# for drm temporary code -/usr/lib/*.so* +%{_libdir}/systemd/user/tizen-mobile-session.target.wants/wrt-preinstall-widgets.service +%{_libdir}/systemd/user/wrt-preinstall-widgets.service diff --git a/packaging/wrt-preinstall-widgets.service b/packaging/wrt-preinstall-widgets.service new file mode 100644 index 0000000..2bf8181 --- /dev/null +++ b/packaging/wrt-preinstall-widgets.service @@ -0,0 +1,8 @@ +[Unit] +Description=Installation of pre-installed widgets +ConditionPathExists=/opt/media/Downloads/.preinstallWidgets +After=xorg.target e17.service + +[Service] +Type=oneshot +ExecStart=/etc/init.d/wrt_preinstall_widgets.sh diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c9d8e96..6da67e5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -45,7 +45,6 @@ SET(INSTALLER_INCLUDES ${INSTALLER_SRC_DIR}/configuration_parser ${INSTALLER_SRC_DIR}/wrt-installer ${INSTALLER_SRC_DIR}/commons - ${INSTALLER_SRC_DIR}/commons/drm #this is temporary code for drm ${INSTALLER_SRC_DIR}/pkg-manager ) @@ -66,12 +65,12 @@ SET(INSTALLER_SOURCES ${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 ${INSTALLER_JOBS}/widget_install/task_file_manipulation.cpp ${INSTALLER_JOBS}/widget_install/task_smack.cpp ${INSTALLER_JOBS}/widget_install/task_ace_check.cpp ${INSTALLER_JOBS}/widget_install/task_manifest_file.cpp ${INSTALLER_JOBS}/widget_install/task_certify.cpp - ${INSTALLER_JOBS}/widget_install/task_private_storage.cpp ${INSTALLER_JOBS}/widget_install/task_prepare_files.cpp ${INSTALLER_JOBS}/widget_install/task_recovery.cpp ${INSTALLER_JOBS}/widget_install/task_install_ospsvc.cpp @@ -96,41 +95,57 @@ SET(INSTALLER_SOURCES ${INSTALLER_SRC_DIR}/misc/feature_logic.cpp ${INSTALLER_SRC_DIR}/misc/libxml_utils.cpp ${INSTALLER_SRC_DIR}/misc/widget_location.cpp + ${INSTALLER_SRC_DIR}/misc/widget_install_to_external.cpp ${INSTALLER_SRC_DIR}/pkg-manager/pkgmgr_signal.cpp ) +IF(LB_SUPPORT) + SET(INSTALLER_SOURCES + ${INSTALLER_SOURCES} + ) + MESSAGE(STATUS "adding definition -DLB_SUPPORT") + ADD_DEFINITIONS("-DLB_SUPPORT") +ENDIF(LB_SUPPORT) + MESSAGE(STATUS "add -DSEP_INSTALLER") ADD_DEFINITIONS("-DSEP_INSTALLER") PKG_CHECK_MODULES(INSTALLER_STATIC_DEP - libxml-2.0 - openssl dpl-efl - cert-svc-vcore - security-core dpl-event-efl dpl-utils-efl dpl-wrt-dao-ro dpl-wrt-dao-rw dpl-encryption + wrt-plugins-types + pkgmgr-installer + pkgmgr-parser + REQUIRED +) + +PKG_CHECK_MODULES(SYS_INSTALLER_STATIC_DEP + libxml-2.0 + openssl + cert-svc-vcore security-install ecore-x xmlsec1 libidn libiri libpcrecpp - wrt-plugins-types ail elementary - pkgmgr-installer - pkgmgr-parser tapi shortcut capi-appfw-app-manager - drm-client + drm-service-core-intel + app2sd + vconf REQUIRED - ) +) + +INCLUDE_DIRECTORIES( SYSTEM ${SYS_INSTALLER_STATIC_DEP_INCLUDE_DIRS}) INCLUDE_DIRECTORIES( ${INSTALLER_DEP_INCLUDES} @@ -144,24 +159,13 @@ ADD_LIBRARY(${TARGET_INSTALLER_STATIC} STATIC ADD_DEFINITIONS(${INSTALLER_STATIC_DEP_CFLAGS}) ADD_DEFINITIONS(${INSTALLER_STATIC_DEP_CFLAGS_OTHERS}) +ADD_DEFINITIONS(${SYS_INSTALLER_STATIC_DEP_CFLAGS}) +ADD_DEFINITIONS(${SYS_INSTALLER_STATIC_DEP_CFLAGS_OTHERS}) TARGET_LINK_LIBRARIES(${TARGET_INSTALLER_STATIC} ${INSTALLER_STATIC_DEP_LIBRARIES} "-ldl" + ${SYS_INSTALLER_STATIC_DEP_LIBRARIES} "-ldl" ) - -# Below Code is temporary. When DRM engine is provided it will be removed. -MESSAGE("ARCH ${ARCH}") -IF("${ARCH}" MATCHES "arm") - TARGET_LINK_LIBRARIES(${TARGET_INSTALLER_STATIC} - "-L${PROJECT_SOURCE_DIR}/etc/drm/armv7l -ldrm-service-core-intel" -Wl,--allow-shlib-undefine) -ELSE("${ARCH}" MATCHES "arm") - TARGET_LINK_LIBRARIES(${TARGET_INSTALLER_STATIC} - "-L${PROJECT_SOURCE_DIR}/etc/drm/ix86 -ldrm-service-core-intel" -Wl,--allow-shlib-undefine) -ENDIF("${ARCH}" MATCHES "arm") - -SET_TARGET_PROPERTIES(${TARGET_INSTALLER_STATIC} PROPERTIES - COMPILE_FLAGS -fPIC) - ADD_SUBDIRECTORY(pkg-manager) ADD_SUBDIRECTORY(wrt-installer) diff --git a/src/commons/drm/CPointerArray.h b/src/commons/drm/CPointerArray.h deleted file mode 100755 index 3e30e79..0000000 --- a/src/commons/drm/CPointerArray.h +++ /dev/null @@ -1,52 +0,0 @@ - -/******************************************************************************** -* Copyright ? 2004-2009 by INKA Entworks, Inc (www.inka.co.kr). * -* All rights reserved. * -* * -* No parts of this source code may be in any way copied, reproduced, modified * -* or distributed without the prior written consent of INKA Entworks, Inc. * -* CPointerArray.h: interface for the CPointerArray class. * -*********************************************************************************/ - -#ifndef __CPOINTERARRAY_H__ -#define __CPOINTERARRAY_H__ - - -#if !defined(AFX_CPOINTERARRAY_H__AB67E4BE_A233_4E3E_B257_9830D90326EE__INCLUDED_) -#define AFX_CPOINTERARRAY_H__AB67E4BE_A233_4E3E_B257_9830D90326EE__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -//#include "Shp.h" -#include "InkaTypes.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -class CPointerArray -{ -protected: - LPVOID* m_ppData; - int m_nMaxSize; - int m_nNumOfData; - -public: - CPointerArray(); - virtual ~CPointerArray(); - - int Add( LPVOID pData ); - int Remove( int nIndex ); - LPVOID Get( int nIndex ); - inline int GetCount() { return m_nNumOfData; } - inline void RemoveAll() { m_nNumOfData = 0; } -}; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif // !defined(AFX_CPOINTERARRAY_H__AB67E4BE_A233_4E3E_B257_9830D90326EE__INCLUDED_) -#endif /* __CPOINTERARRAY_H__ */ diff --git a/src/commons/drm/CXMLAttribute.h b/src/commons/drm/CXMLAttribute.h deleted file mode 100755 index dda8fe3..0000000 --- a/src/commons/drm/CXMLAttribute.h +++ /dev/null @@ -1,37 +0,0 @@ - -/******************************************************************************** -* Copyright ? 2004-2009 by INKA Entworks, Inc (www.inka.co.kr). * -* All rights reserved. * -* * -* No parts of this source code may be in any way copied, reproduced, modified * -* or distributed without the prior written consent of INKA Entworks, Inc. * -* CXMLAttribute.h: interface for the CXMLAttribute class. * -*********************************************************************************/ -//#include "Shp.h" -#include "InkaTypes.h" - -#if !defined(AFX_CXMLATTRIBUTE_H__2B925786_3613_47B0_B85D_CAF2053F46DB__INCLUDED_) -#define AFX_CXMLATTRIBUTE_H__2B925786_3613_47B0_B85D_CAF2053F46DB__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -class CXMLAttribute -{ -protected: - LPTSTR m_pszName; - LPTSTR m_pszValue; - -public: - CXMLAttribute(); - virtual ~CXMLAttribute(); - - int SetName( LPCTSTR pszName ); - int SetValue( LPCTSTR pszValue ); - - inline LPCTSTR GetName() { return m_pszName; } - inline LPCTSTR GetValue() { return m_pszValue; } -}; - -#endif // !defined(AFX_CXMLATTRIBUTE_H__2B925786_3613_47B0_B85D_CAF2053F46DB__INCLUDED_) diff --git a/src/commons/drm/CXMLElement.h b/src/commons/drm/CXMLElement.h deleted file mode 100755 index eb74a0c..0000000 --- a/src/commons/drm/CXMLElement.h +++ /dev/null @@ -1,57 +0,0 @@ - -/******************************************************************************** -* Copyright ? 2004-2009 by INKA Entworks, Inc (www.inka.co.kr). * -* All rights reserved. * -* * -* No parts of this source code may be in any way copied, reproduced, modified * -* or distributed without the prior written consent of INKA Entworks, Inc. * -* CXMLElement.h: interface for the CXMLElement class. * -*********************************************************************************/ - -#if !defined(AFX_CXMLELEMENT_H__B6A6A39B_1980_4A4F_B68B_E87B53A3EE9B__INCLUDED_) -#define AFX_CXMLELEMENT_H__B6A6A39B_1980_4A4F_B68B_E87B53A3EE9B__INCLUDED_ - -//#include "Shp.h" -#include "InkaTypes.h" -#include "CXMLAttribute.h" -#include "CPointerArray.h" - - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -class CXMLElement -{ -protected: - LPTSTR m_pszName; - LPTSTR m_pszValue; - - CPointerArray m_pChilds; - CPointerArray m_pAttributes; - - int _SearchNodes( CPointerArray* ppaChildNodes, CXMLElement* pCurrent, LPCTSTR pszTagName, va_list args ); - -public: - CXMLElement(); - virtual ~CXMLElement(); - - int SetName( LPCTSTR pszName ); - int SetValue( LPCTSTR pszValue ); - int AddAttribute( LPCTSTR pszName, LPCTSTR pszValue ); - - inline LPCTSTR GetName() { return m_pszName; } - inline LPCTSTR GetValue() { return m_pszValue; } - - int AddChild( CXMLElement* pChild ); - LPCTSTR GetAttribute( LPCTSTR pszName ); - - inline int GetChildCount() { return m_pChilds.GetCount(); } - inline int GetAttributeCount() { return m_pAttributes.GetCount(); } - inline CXMLElement* GetChild( int nIndex ) { return (CXMLElement*)m_pChilds.Get( nIndex ); } - inline CXMLAttribute* GetAttribute( int nIndex ) { return (CXMLAttribute*)m_pAttributes.Get( nIndex ); } - - int Find( CPointerArray* pSearchedChild, LPCTSTR pszChildName, ... ); -}; - -#endif // !defined(AFX_CXMLELEMENT_H__B6A6A39B_1980_4A4F_B68B_E87B53A3EE9B__INCLUDED_) diff --git a/src/commons/drm/CXMLFile.h b/src/commons/drm/CXMLFile.h deleted file mode 100755 index 0a3a2e2..0000000 --- a/src/commons/drm/CXMLFile.h +++ /dev/null @@ -1,54 +0,0 @@ - -/******************************************************************************** -* Copyright ? 2004-2009 by INKA Entworks, Inc (www.inka.co.kr). * -* All rights reserved. * -* * -* No parts of this source code may be in any way copied, reproduced, modified * -* or distributed without the prior written consent of INKA Entworks, Inc. * -* CXMLFile.h: interface for the CXMLFile class. * -*********************************************************************************/ - -#if !defined(AFX_CXMLFILE_H__21F76587_B9C8_4407_9C16_186F3D47ADE1__INCLUDED_) -#define AFX_CXMLFILE_H__21F76587_B9C8_4407_9C16_186F3D47ADE1__INCLUDED_ - -//#include "Shp.h" -#include "InkaTypes.h" -#include "CXMLElement.h" - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#ifndef IN - #define IN -#endif - -#ifndef OUT - #define OUT -#endif - -#define ELEMENT_QUEUE_MAX 2048 -class CXMLFile -{ -protected: - LPCTSTR m_pszXML; - CXMLElement* m_paElementQueue[ ELEMENT_QUEUE_MAX ]; - int m_nQueueIndex; - CXMLElement* m_pRoot; - - int _Parse(); - int _GetElementName( LPTSTR pszElementName ); - CXMLElement* _Pop(); - int _Push( CXMLElement* p ); - int _GetAttributeNameAndValue( LPTSTR pszName, LPTSTR pszValue ); - -public: - CXMLFile(); - virtual ~CXMLFile(); - - int LoadFromStream( LPCTSTR pszXML ); - int LoadFromFile( LPCTSTR pszFileName ); - inline CXMLElement* GetRoot() { return m_pRoot; } -}; - -#endif // !defined(AFX_CXMLFILE_H__21F76587_B9C8_4407_9C16_186F3D47ADE1__INCLUDED_) diff --git a/src/commons/drm/InkaTypes.h b/src/commons/drm/InkaTypes.h deleted file mode 100755 index d7a9291..0000000 --- a/src/commons/drm/InkaTypes.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SHP - * Copyright (c) 2000-2007 UMTS Software Lab, Mobile Communication Division, - * Telecommunication Network Business, Samsung Electronics, Inc. - * All rights reserved. - * - * This software is the confidential and proprietary information - * of Samsung Electronics, Inc. ("Confidential Information"). You - * shall not disclose such Confidential Information and shall use - * it only in accordance with the terms of the license agreement - * you entered into with Samsung Electronics. - */ - -/** - * @file InkaTypes.h - * @brief This file includes definitions of constants, - * enumerations, and datastructures for the Inka DRM service. -# @author Jihyun Lee(ezhyun.lee@samsung.com) -# @author Donghyun Yoo(marku.yoo@samsung.com) - * @version 1.0 - */ - -#ifndef INKA_DRM_TYPES_H -#define INKA_DRM_TYPES_H - -//#include "shp.h" -//#include "FileMgr.h" -#include -#include - -#define _T -#define IF_ERROR_GOTO( error ) if( FAILED( HRESULT_FROM_WIN32( error ) ) ) { nResult = ERRORMSG( error, NULL ); goto finish; } -#define IF_TRUE_GOTO( cond, error ) if( cond ) { nResult = -1; goto finish; } - -#if defined(_WIN32) || defined(_WIN64) - #define snprintf _snprintf - #define vsnprintf _vsnprintf - #define strcasecmp _stricmp - #define strncasecmp _strnicmp -#endif - -#ifndef _SHP_SIMUL -typedef void* LPVOID; -typedef const char* LPCTSTR; -typedef unsigned char* LPBYTE; -typedef char TCHAR; -typedef char* LPTSTR; -typedef LPTSTR LPSTR; -typedef LPCTSTR LPCTSTR; -typedef LPCTSTR LPCSTR; - -#define DWORD unsigned long -#define LPBYTE unsigned char* -#define BYTE unsigned char -#define UINT unsigned int -#define ULONG unsigned long -#define INT32 long -#define INT64 long long -#define TRUE 1 -#define FALSE 0 - - -typedef char CHAR; -typedef bool BOOL; - - -//typedef HFile HANDLE; -#define ERROR_INVALID_DATA 13L -#define ERROR_INSUFFICIENT_BUFFER 122L // dderror -//#define CopyMemory AcMemcpy -#define INVALID_HOBJ NULL - -#endif - - -#endif //INKA_DRM_TYPES_H diff --git a/src/commons/drm/IntelDrm_Core.h b/src/commons/drm/IntelDrm_Core.h deleted file mode 100755 index b8b4b48..0000000 --- a/src/commons/drm/IntelDrm_Core.h +++ /dev/null @@ -1,46 +0,0 @@ -//typedef char CHAR; -//typedef bool BOOL; - -typedef struct t_cek -{ - char *CID; // Content ID ¹öÆÛ Æ÷ÀÎÅÍ - char *CEK; // Content Encryption Key ¹öÆÛ Æ÷ÀÎÅÍ - char *EncryptionMethod; // CEK ¾Ë°í¸®Áò -}T_CEK; - -typedef struct t_dro -{ - char *CID; // Content ID ¹öÆÛ Æ÷ÀÎÅÍ - char *deviceId; // »ç¿ëÀÚ ½Äº° ¹ÙÀεù. IMEI, MIN °ª ¹ÙÀεù Á¦¾î - char *digestValue; // »ç¿ëÀÚ ½Äº° ¹ÙÀεù. IMEI, MIN °ª ¹ÙÀεù Á¦¾î - char *signedValue; // »ç¿ëÀÚ ½Äº° ¹ÙÀεù. IMEI, MIN °ª ¹ÙÀεù Á¦¾î - char *cert; // »ç¿ëÀÚ ½Äº° ¹ÙÀεù. IMEI, MIN °ª ¹ÙÀεù Á¦¾î - int Count; // »ç¿ë ȸ¼ö - char *CreatedTimestamp; // »ç¿ë °¡´É ½ÃÀÛ ÀϽà ¹öÆÛ Æ÷ÀÎÅÍ. GMT Ç¥±â - char *ExpiredTimeStamp; // »ç¿ë °¡´É ¸¸±â ÀϽà ¹öÆÛ Æ÷ÀÎÅÍ. GMT Ç¥±â - char *ExpirationDate; // ÃÖÃÊ »ç¿ë ÀÌÈÄ »ç¿ë °¡´É ½Ã°£. ½Ã°£ ´ÜÀ§ -}T_DRO; - -typedef struct t_dcf_file_header -{ - unsigned char Version; - unsigned char ContentTypeLen; - unsigned char ContentURILen; - char *ContentType; - char *ContentURI; - unsigned int HeadersLen; - unsigned int DataLen; - char *Headers; - unsigned int DataOffset; -}T_DCF_FILE_HEADER; - -// DRO Value size -#define APPID_SIZE 16 -#define CEK_SIZE 512 -#define ENCRYPTION_METHOD_SIZE 512 -#define DEVICEID_SIZE 256 -#define TIMESTAMP_SIZE 256 -#define DIGESTVALUE_SIZE 256 -#define SIGNATUREVALUE_SIZE 1024 -#define CERT_SIZE 1024 * 4 -#define AES_BLOCK_SIZE 16 diff --git a/src/commons/drm/drm-intel-crypto-util.h b/src/commons/drm/drm-intel-crypto-util.h deleted file mode 100755 index eacb1e5..0000000 --- a/src/commons/drm/drm-intel-crypto-util.h +++ /dev/null @@ -1,13 +0,0 @@ -#include "InkaTypes.h" -//#include "IntelDrm_Core.h" - -#include "stdlib.h" -#include "string.h" -#include "stdio.h" - -#define AES_BLOCK_SIZE 16 - -LPSTR Base64Encode(LPBYTE pbData, int nLength); -LPBYTE Base64Decode(LPCSTR pszString, int* pnLength); - -int decrypt_block(unsigned char *iv, unsigned char *cipherText, int cipherTextLen, unsigned char *cek, int cekLen, unsigned char *plainText); diff --git a/src/commons/drm/drm-intel-util.h b/src/commons/drm/drm-intel-util.h deleted file mode 100755 index 08bb2cd..0000000 --- a/src/commons/drm/drm-intel-util.h +++ /dev/null @@ -1,69 +0,0 @@ -#include "CPointerArray.h" -#include "CXMLAttribute.h" -#include "CXMLElement.h" -#include "CXMLFile.h" -#include "InkaTypes.h" -#include "IntelDrm_Core.h" -#include "drm-intel-crypto-util.h" - -#include "stdlib.h" -#include "string.h" -#include "stdio.h" - -/** - * An application can parse CEK XML Foramt. - * - * @param[in] pszXML Data String of the CEK information - * @param[out] t_cek parsing result to be saved - * @return This function returns 1 on success or 0 on failure. - * @remarks - * @see - * @since - */ -int parse_intel_cek(const char* pszXML, T_CEK* t_cek); - -/** - * An application can parse DRO XML Foramt. - * - * @param[in] pszXML Data String of the DRO information - * @param[out] t_cek parsing result to be saved - * @return This function returns 1 on success or 0 on failure. - * @remarks - * @see - * @since - */ -int parse_intel_dro(const char* pszXML, T_DRO* t_RO); - -int parse_intel_dro2(const char* pszXML, T_DRO* t_RO); - -/** - * An application can parse stored dro. - * - * @param[in] pFilepath file path of the internal dro - * @param[out] t_ro parsing result to be saved - * @return This function returns 1 on success or 0 on failure. - * @remarks - * @see - * @since - */ -int get_internal_dro(char *pFilepath, T_DRO* t_ro); - -/** - * An application can parse stored cek. - * - * @param[in] pFilepath file path of the internal cek - * @param[out] t_cek parsing result to be saved - * @return This function returns 1 on success or 0 on failure. - * @remarks - * @see - * @since - */ -int get_internal_cek(char *pFilepath, T_CEK* t_cek); - -int delete_internal_cek(char *pAppId); - -int get_dcf_header_info(char *pFilePath, T_DCF_FILE_HEADER *pTdcfHeader); - -bool get_Uintvar(unsigned int *nValue, FILE *pFile); - -int decrypt_package(char *pDcfPath, char *pDecryptedFilePath, unsigned char *pCEK, int cekLen, T_DCF_FILE_HEADER *t_dcf_header); diff --git a/src/commons/drm/drm-oem-intel.h b/src/commons/drm/drm-oem-intel.h deleted file mode 100755 index 80a9bb2..0000000 --- a/src/commons/drm/drm-oem-intel.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - * drm-intel - * - * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Sunggun Jung - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -/** -* @internal -* @defgroup DRM-INTEL drm-intel -* @{ -*/ -#include "drm-intel-util.h" -//#include "drm-intel-crypto-util.h" - -#include -#include -#include - -/** - * An application can install Intel DRM license(DRO). - * - * @param[in] pDroXML Data String of the Rights Request - * @param[in] droBufLen pDroXML Length - * @return This function returns 1 on success or 0 on failure. - * @remarks - * @see - * @since - */ -int drm_oem_intel_install_license(char *pDroXML, int droBufLen); - -/** - * An application can uninstall Intel DRM license(DRO). - * - * @param[in] pAppId App-id of the rigths which want to un-install - * @return This function returns 1 on success or 0 on failure. - * @remarks - * @see - * @since - */ -int drm_oem_intel_uninstall_license(char *pAppId); - -/** - * An application can install CEK(Contents Encryption Key). - * - * @param[in] pCekXML Data String of the Rights Request - * @param[in] cekBufLen pDroXML Length - * @return This function returns 1 on success or 0 on failure. - * @remarks - * @see - * @since - */ -int drm_oem_intel_install_cek(char *pCekXML, int cekBufLen); - -/** - * An application can get decrypted contents(Apps) which is encrypted - * - * @param[in] pDcfPath Intel DRM Package File Path - * @param[in] pDecryptedFile Decrypted File Path - * @return This function returns 1 on success or 0 on failure. - * @remarks - * @see - * @since - */ -int drm_oem_intel_decrypt_package(char *pDcfPath, char *pDecryptedFile); - -/** - * An application can get informations of rights (DRO). - * - * @param[in] pAppId App-id of the rights which want to know - * @param[out] pDro The rights information about the app-id - * @return This function can return any of the following codes - * DRM_INTEL_SUCCESS = 0 0) { + m_name = attribute.value; + } + } + } + + virtual void Accept(const Element& /*element*/) + { + } + + virtual void Accept(const Text& /*text*/) + { + } + + virtual void Verify() + { + if (m_name.IsNull()) { + LogWarning("name attribute of category element is mandatory - ignoring"); + return; + } + + if (m_data.categoryList.find(*m_name) == + m_data.categoryList.end()) { + m_data.categoryList.insert(*m_name); + } + } + + explicit CategoryParser(ConfigParserData& data) : + m_data(data) + { + } + + private: + DPL::OptionalString m_name; + ConfigParserData& m_data; +}; + +class LiveboxParser : public ElementParser +{ + public: + + struct BoxLabelParser : public ElementParser + { + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& /*name*/) + { + return &IgnoringParser::Create; + } + + virtual void Accept(const XmlAttribute& attribute) + { + } + + virtual void Accept(const Element& element) + { + if (element.ns == + ConfigurationNamespace::TizenWebAppNamespaceName) + { + m_properNamespace = true; + } + } + + virtual void Accept(const Text& text) + { + if(m_properNamespace) + m_label = text.value; + } + + virtual void Verify() + { + m_data.m_label = m_label; + } + + BoxLabelParser(ConfigParserData::LiveboxInfo& data) : + ElementParser(), + m_properNamespace(false), + m_data(data) + { + } + + private: + DPL::String m_label; + bool m_properNamespace; + ConfigParserData::LiveboxInfo& m_data; + }; + + struct BoxIconParser : public ElementParser + { + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& /*name*/) + { + return &IgnoringParser::Create; + } + + virtual void Accept(const XmlAttribute& attribute) + { + if(m_properNamespace) { + if (attribute.name == L"src") { + m_icon = attribute.value; + } + } + } + + virtual void Accept(const Element& element) + { + if (element.ns == + ConfigurationNamespace::TizenWebAppNamespaceName) + { + m_properNamespace = true; + } + } + + virtual void Accept(const Text& /*text*/) + { + } + + virtual void Verify() + { + m_data.m_icon = m_icon; + } + + explicit BoxIconParser(ConfigParserData::LiveboxInfo& data) : + ElementParser(), + m_properNamespace(false), + m_data(data) + { + } + + private: + DPL::String m_icon; + bool m_properNamespace; + ConfigParserData::LiveboxInfo& m_data; + }; + + struct BoxContentParser : public ElementParser + { + struct BoxSizeParser : public ElementParser + { + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& /*name*/) + { + return &IgnoringParser::Create; + } + + virtual void Accept(const XmlAttribute& attribute) + { + if(m_properNamespace) { + if (attribute.name == L"preview") { + m_preview = attribute.value; + } + } + } + + virtual void Accept(const Element& element) + { + if (element.ns == + ConfigurationNamespace::TizenWebAppNamespaceName) + { + m_properNamespace = true; + } + } + + virtual void Accept(const Text& text) + { + if(m_properNamespace) + m_size = text.value; + } + + virtual void Verify() + { + std::pair boxSize; + boxSize.first = m_size; + boxSize.second = m_preview; + m_data.m_boxSize.push_back(boxSize); + } + + explicit BoxSizeParser(ConfigParserData::LiveboxInfo::BoxContentInfo& data) : + ElementParser(), + m_data(data) + { + } + + private: + DPL::String m_size; + DPL::String m_preview; + bool m_properNamespace; + ConfigParserData::LiveboxInfo::BoxContentInfo& m_data; + }; + + struct PdParser : public ElementParser + { + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& name) + { + return &IgnoringParser::Create; + } + + virtual void Accept(const XmlAttribute& attribute) + { + if(m_properNamespace) { + if (attribute.name == L"src") { + m_src = attribute.value; + } else if (attribute.name == L"width") { + m_width = attribute.value; + } else if (attribute.name == L"height") { + m_height = attribute.value; + } + } + } + + virtual void Accept(const Element& element) + { + if (element.ns == + ConfigurationNamespace::TizenWebAppNamespaceName) + { + m_properNamespace = true; + } + } + + virtual void Accept(const Text& /*text*/) + { + } + + virtual void Verify() + { + m_data.m_pdSrc = m_src; + m_data.m_pdWidth = m_width; + m_data.m_pdHeight = m_height; + } + + explicit PdParser(ConfigParserData::LiveboxInfo::BoxContentInfo& data) : + ElementParser(), + m_properNamespace(false), + m_data(data) + { + } + + private: + DPL::String m_src; + DPL::String m_width; + DPL::String m_height; + + bool m_properNamespace; + ConfigParserData::LiveboxInfo::BoxContentInfo& m_data; + }; + + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& name) + { + if (name == L"box-size") { + return DPL::MakeDelegate(this, &LiveboxParser::BoxContentParser::OnBoxSizeElement); + } else if (name == L"pd") { + return DPL::MakeDelegate(this, &LiveboxParser::BoxContentParser::OnPdElement); + } else{ + ThrowMsg(Exception::ParseError, "No element parser for name: " << name); + } + } + + virtual void Accept(const XmlAttribute& attribute) + { + if (m_properNamespace) { + if (attribute.name == L"src") + m_box.m_boxSrc = attribute.value; + } + } + + virtual void Accept(const Element& element) + { + if (element.ns == + ConfigurationNamespace::TizenWebAppNamespaceName) + { + m_properNamespace = true; + } + } + + virtual void Accept(const Text& /*text*/) + { + } + + virtual void Verify() + { + m_data.m_boxInfo = m_box; + } + + explicit BoxContentParser(ConfigParserData::LiveboxInfo& data) : + ElementParser(), + m_properNamespace(false), + m_data(data) + { + } + + ElementParserPtr OnBoxSizeElement() + { + return ElementParserPtr(new BoxSizeParser(m_box)); + } + + ElementParserPtr OnPdElement() + { + return ElementParserPtr(new PdParser(m_box)); + } + + private: + DPL::String m_src; + bool m_properNamespace; + ConfigParserData::LiveboxInfo& m_data; + ConfigParserData::LiveboxInfo::BoxContentInfo m_box; + }; + + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& name) + { + if (name == L"box-label") { + return DPL::MakeDelegate(this, &LiveboxParser::OnBoxLabelElement); + } else if (name == L"box-icon") { + return DPL::MakeDelegate(this, &LiveboxParser::OnBoxIconElement); + } else if (name == L"box-content") { + return DPL::MakeDelegate(this, &LiveboxParser::OnBoxContentElement); + } else { + return &IgnoringParser::Create; + } + } + + virtual void Accept(const XmlAttribute& attribute) + { + if (m_properNamespace) { + if (attribute.name == L"id") { + m_liveboxId = attribute.value; + } else if (attribute.name == L"primary") { + m_primary = attribute.value; + } else if (attribute.name == L"auto-launch") { + m_autoLaunch = attribute.value; + } else if (attribute.name == L"update-period") { + m_updatePeriod = attribute.value; + } + } + } + + virtual void Accept(const Element& element) + { + if (element.ns == + ConfigurationNamespace::TizenWebAppNamespaceName) + { + m_properNamespace = true; + } + } + + virtual void Accept(const Text& /*text*/) + { + } + + virtual void Verify() + { + m_livebox.m_liveboxId = m_liveboxId; + m_livebox.m_primary = m_primary; + m_livebox.m_autoLaunch = m_autoLaunch; + m_livebox.m_updatePeriod = m_updatePeriod; + + m_data.m_livebox.push_back(m_livebox); + } + + explicit LiveboxParser(ConfigParserData& data) : + ElementParser(), + m_data(data), + m_properNamespace(false) + { + m_livebox = ConfigParserData::LiveboxInfo(); + } + + ElementParserPtr OnBoxLabelElement() + { + return ElementParserPtr(new BoxLabelParser(m_livebox)); + } + + ElementParserPtr OnBoxIconElement() + { + return ElementParserPtr(new BoxIconParser(m_livebox)); + } + + ElementParserPtr OnBoxContentElement() + { + return ElementParserPtr(new BoxContentParser(m_livebox)); + } + + private: + ConfigParserData& m_data; + ConfigParserData::LiveboxInfo m_livebox; + DPL::String m_liveboxId; + DPL::String m_primary; + DPL::String m_autoLaunch; + DPL::String m_updatePeriod; + bool m_properNamespace; + +}; + ElementParser::ActionFunc WidgetParser::GetElementParser(const DPL::String& /*ns*/, const DPL::String& name) { @@ -1412,14 +1852,21 @@ WidgetParser::WidgetParser(ConfigParserData& data) : DPL::MakeDelegate(this, &WidgetParser::OnFeatureElement); m_map[L"preference"] = DPL::MakeDelegate(this, &WidgetParser::OnPreferenceElement); - m_map[L"flash"] = DPL::MakeDelegate(this, &WidgetParser::OnFlashElement); m_map[L"link"] = DPL::MakeDelegate(this, &WidgetParser::OnLinkElement); m_map[L"setting"] = DPL::MakeDelegate(this, &WidgetParser::OnSettingElement); - m_map[L"appservice"] = DPL::MakeDelegate(this, &WidgetParser::OnServiceElement); + // TODO: appservice will be removed + m_map[L"appservice"] = DPL::MakeDelegate(this, &WidgetParser::OnAppControlElement); m_map[L"application"] = DPL::MakeDelegate(this, &WidgetParser::OnApplicationElement); m_map[L"splash"] = DPL::MakeDelegate(this, &WidgetParser::OnSplashElement); m_map[L"background"] = DPL::MakeDelegate(this, &WidgetParser::OnBackgroundElement); + m_map[L"privilege"] = DPL::MakeDelegate(this, &WidgetParser::OnPrivilegeElement); + m_map[L"appcontrol"] = DPL::MakeDelegate(this, + &WidgetParser::OnAppControlElement); + m_map[L"category"] = DPL::MakeDelegate(this, + &WidgetParser::OnCategoryElement); + m_map[L"livebox"] = DPL::MakeDelegate(this, &WidgetParser::OnLiveboxElement); + } ElementParserPtr WidgetParser::OnNameElement() @@ -1467,11 +1914,6 @@ ElementParserPtr WidgetParser::OnPreferenceElement() return ElementParserPtr(new PreferenceParser(m_data)); } -ElementParserPtr WidgetParser::OnFlashElement() -{ - return ElementParserPtr(new FlashParser(m_data)); -} - ElementParserPtr WidgetParser::OnLinkElement() { return ElementParserPtr(new LinkParser(m_data)); @@ -1482,11 +1924,6 @@ ElementParserPtr WidgetParser::OnSettingElement() return ElementParserPtr(new SettingParser(m_data)); } -ElementParserPtr WidgetParser::OnServiceElement() -{ - return ElementParserPtr(new ServiceParser(m_data)); -} - ElementParserPtr WidgetParser::OnApplicationElement() { return ElementParserPtr(new ApplicationParser(m_data)); @@ -1502,6 +1939,26 @@ ElementParserPtr WidgetParser::OnBackgroundElement() return ElementParserPtr(new BackgroundParser(m_data)); } +ElementParserPtr WidgetParser::OnPrivilegeElement() +{ + return ElementParserPtr(new PrivilegeParser(m_data)); +} + +ElementParserPtr WidgetParser::OnAppControlElement() +{ + return ElementParserPtr(new AppControlParser(m_data)); +} + +ElementParserPtr WidgetParser::OnCategoryElement() +{ + return ElementParserPtr(new CategoryParser(m_data)); +} + +ElementParserPtr WidgetParser::OnLiveboxElement() +{ + return ElementParserPtr(new LiveboxParser(m_data)); +} + void WidgetParser::Accept(const Element& element) { if (element.ns != ConfigurationNamespace::W3CWidgetNamespaceName && diff --git a/src/configuration_parser/widget_parser.h b/src/configuration_parser/widget_parser.h index 6ea2ffb..7670388 100755 --- a/src/configuration_parser/widget_parser.h +++ b/src/configuration_parser/widget_parser.h @@ -73,13 +73,15 @@ class WidgetParser : public ElementParser ElementParserPtr OnFeatureElement(); ElementParserPtr OnPreferenceElement(); ElementParserPtr OnAccessElement(); - ElementParserPtr OnFlashElement(); ElementParserPtr OnLinkElement(); ElementParserPtr OnSettingElement(); - ElementParserPtr OnServiceElement(); ElementParserPtr OnApplicationElement(); ElementParserPtr OnSplashElement(); ElementParserPtr OnBackgroundElement(); + ElementParserPtr OnPrivilegeElement(); + ElementParserPtr OnAppControlElement(); + ElementParserPtr OnCategoryElement(); + ElementParserPtr OnLiveboxElement(); virtual ActionFunc GetElementParser(const DPL::String& ns, const DPL::String& name); diff --git a/src/jobs/widget_install/ace_registration.cpp b/src/jobs/widget_install/ace_registration.cpp new file mode 100644 index 0000000..00165f1 --- /dev/null +++ b/src/jobs/widget_install/ace_registration.cpp @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file ace_registration.cpp + * @author Andrzej Surdej (a.surdej@gmail.com) + * @version 1.0 + * @brief Translate structures to ace api - implementation file + */ + +#include +#include +#include +#include + +namespace { + +char* toAceString(const DPL::OptionalString& os) +{ + if (!os.IsNull()) + return strdup(DPL::ToUTF8String(*os).c_str()); + else + return NULL; +} + +char* toAceString(const std::string& str) +{ + if (!str.empty()) + return strdup(str.c_str()); + else + return NULL; +} + +} //anonymous namespace + +namespace AceApi { + +bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle, + const WrtDB::WidgetRegisterInfo& widgetConfig, + const WrtDB::WidgetCertificateDataList& certList) +{ + LogDebug("Updating Ace database"); + struct widget_info wi; + DPL::OptionalString os; + + switch(widgetConfig.webAppType.appType) + { + case WrtDB::APP_TYPE_WAC20: + wi.type = WAC20; + break; + case WrtDB::APP_TYPE_TIZENWEBAPP: + wi.type = Tizen; + break; + default: + LogError("Unknown application type"); + return false; + } + + wi.id = toAceString(widgetConfig.configInfo.widget_id); + wi.version = toAceString(widgetConfig.configInfo.version); + wi.author = toAceString(widgetConfig.configInfo.authorName); + wi.shareHerf = strdup(widgetConfig.shareHref.c_str()); + LogDebug("Basic data converted. Certificates begin."); + + //one more element for NULL termination + LogDebug("Found: " << certList.size() << " certificates"); + ace_certificate_data** certData = new ace_certificate_data*[certList.size() + 1]; + certData[certList.size()] = NULL; // last element set to NULL + + int i = 0; + FOREACH(it, certList) + { + certData[i] = new ace_certificate_data; + switch (it->owner) { + case WrtDB::WidgetCertificateData::AUTHOR : + certData[i]->owner = AUTHOR; + break; + case WrtDB::WidgetCertificateData::DISTRIBUTOR : + certData[i]->owner = DISTRIBUTOR; + break; + default : + LogDebug("Unknown owner type of cert"); + certData[i]->owner = UNKNOWN; + } + switch (it->type) { + case WrtDB::WidgetCertificateData::ENDENTITY : + certData[i]->type = ENDENTITY; + break; + case WrtDB::WidgetCertificateData::ROOT : + certData[i]->type = ROOT; + break; + default : + LogError("Unknown type of cert"); + certData[i]->type = ENDENTITY; + } + certData[i]->chain_id = it->chainId; + + certData[i]->md5_fp = toAceString(it->strMD5Fingerprint); + certData[i]->sha1_fp = toAceString(it->strSHA1Fingerprint); + certData[i]->common_name = toAceString(DPL::ToUTF8String(it->strCommonName)); + ++i; + } + + LogDebug("Registerign widget in ace"); + ace_return_t retval = ACE_ACE_UNKNOWN_ERROR; + retval = ace_register_widget( + static_cast(widgetHandle), &wi, certData); + + //clean up - WidgetInfo + free(wi.author); + free(wi.id); + free(wi.shareHerf); + free(wi.version); + + //free cert list + i = 0; + while (certData[i] != NULL) { + free(certData[i]->common_name); + free(certData[i]->md5_fp); + free(certData[i]->sha1_fp); + delete certData[i]; + ++i; + } + delete[] certData; + return retval == ACE_OK; +} +} diff --git a/src/jobs/widget_install/ace_registration.h b/src/jobs/widget_install/ace_registration.h new file mode 100644 index 0000000..2f4a3b0 --- /dev/null +++ b/src/jobs/widget_install/ace_registration.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file ace_registration.h + * @author Andrzej Surdej (a.surdej@gmail.com) + * @version 1.0 + * @brief Translate structures to ace api - header file + */ +#ifndef WRT_SRC_INSTALLER_CORE_ACE_REGISTRATION_H_ +#define WRT_SRC_INSTALLER_CORE_ACE_REGISTRATION_H_ + +#include + +namespace AceApi { + +bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle, + const WrtDB::WidgetRegisterInfo& widgetConfig, + const WrtDB::WidgetCertificateDataList& certList); + +} + +#endif /* WRT_SRC_INSTALLER_CORE_ACE_REGISTRATION_H_ */ + diff --git a/src/jobs/widget_install/job_widget_install.cpp b/src/jobs/widget_install/job_widget_install.cpp index 5fd9f80..ad57eb7 100644 --- a/src/jobs/widget_install/job_widget_install.cpp +++ b/src/jobs/widget_install/job_widget_install.cpp @@ -21,6 +21,12 @@ * @brief Implementation file for main installer task */ #include +#include +#include +#include +#include +#include +#include #include #include @@ -30,9 +36,20 @@ #include #include #include -#include #include #include +#include +#include +#include +#include // TODO remove +#include + +#include +#include +#include +//#include +#include //temporary code + #include "root_parser.h" #include "widget_parser.h" #include "parser_runner.h" @@ -43,7 +60,6 @@ #include #include #include -#include #include #include #include @@ -54,25 +70,12 @@ #include #include #include + #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include // TODO remove -#include -#include -#include -#include -#include -#include //temporary code +#include using namespace WrtDB; @@ -83,10 +86,13 @@ const char * const WITH_OSP_XML = "res/wgt/config.xml"; //allowed: a-z, A-Z, 0-9 const char* REG_TIZENID_PATTERN = "^[a-zA-Z0-9]{10}$"; -const int MAX_TIZENID_LENGTH = 10; static const DPL::String SETTING_VALUE_ENCRYPTION = L"encryption"; static const DPL::String SETTING_VALUE_ENCRYPTION_ENABLE = L"enable"; +const DPL::String SETTING_VALUE_INSTALLTOEXT_NAME = + L"install-location-type"; +const DPL::String SETTING_VALUE_INSTALLTOEXT_PREPER_EXT = + L"prefer-external"; class InstallerTaskFail : public DPL::TaskDecl @@ -127,6 +133,22 @@ bool hasExtension(const std::string& filename, const std::string& extension) { } return (0 == filename.compare(fileLen-extLen, extLen, extension)); } + +bool checkTizenIdExist(const std::string& tizenId) { + std::string installPath = + std::string(GlobalConfig::GetUserInstalledWidgetPath()) + + "/" + tizenId; + std::string preinstallPath = + std::string(GlobalConfig::GetUserPreloadedWidgetPath()) + + "/" + tizenId; + + struct stat dirStat; + if ((stat(installPath.c_str(), &dirStat) == 0) && + (stat(preinstallPath.c_str(), &dirStat) == 0)) { + return true; + } + return false; +} } // namespace anonymous namespace Jobs { @@ -152,24 +174,28 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath, // Create installation tasks if (m_installerContext.widgetConfig.packagingType != - WrtDB::PKG_TYPE_HOSTED_WEB_APP || !m_isDRM) { + 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 ) { + if (m_installerContext.widgetConfig.packagingType == + WrtDB::PKG_TYPE_HOSTED_WEB_APP) + { AddTask(new TaskPrepareFiles(m_installerContext)); } AddTask(new TaskCertify(m_installerContext)); if (m_needEncryption) { AddTask(new TaskEncryptResource(m_installerContext)); } + AddTask(new TaskFileManipulation(m_installerContext)); // TODO: Update progress information for this task - AddTask(new TaskPrivateStorage(m_installerContext)); - //This is sort of quick solution, because ACE verdicts are based upon //data from DAO (DB). So AceCheck for now has to be AFTER DbUpdate //task. @@ -188,19 +214,28 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath, LogInfo("Configure installation updated"); LogInfo("Widget Update"); if (m_installerContext.widgetConfig.packagingType != - WrtDB::PKG_TYPE_HOSTED_WEB_APP || !m_isDRM) { + 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 == - WrtDB::PKG_TYPE_HOSTED_WEB_APP ) { + WrtDB::PKG_TYPE_HOSTED_WEB_APP) + { AddTask(new TaskPrepareFiles(m_installerContext)); } AddTask(new TaskCertify(m_installerContext)); - AddTask(new TaskUpdateFiles(m_installerContext)); + if (m_installerContext.widgetConfig.packagingType != + WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) + { + AddTask(new TaskUpdateFiles(m_installerContext)); + } /* TODO : To backup file, save md5 values */ AddTask(new TaskSmack(m_installerContext)); @@ -210,7 +245,11 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath, PKG_TYPE_HYBRID_WEB_APP) { AddTask(new TaskInstallOspsvc(m_installerContext)); } - AddTask(new TaskRemoveBackupFiles(m_installerContext)); + if (m_installerContext.widgetConfig.packagingType != + WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) + { + AddTask(new TaskRemoveBackupFiles(m_installerContext)); + } AddTask(new TaskPluginsCopy(m_installerContext)); AddTask(new TaskDatabase(m_installerContext)); AddTask(new TaskAceCheck(m_installerContext)); @@ -241,9 +280,10 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation( Try { - std::string tempDir = Jobs::WidgetInstall::createTempPath(); + std::string tempDir = + Jobs::WidgetInstall::createTempPath(m_jobStruct.m_preload); - bool m_isDRM = isDRMWidget(widgetPath); + m_isDRM = isDRMWidget(widgetPath); if (true == m_isDRM) { LogDebug("decrypt DRM widget"); if(DecryptDRMWidget(widgetPath, tempDir)) { @@ -256,12 +296,16 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation( m_installerContext.widgetConfig.packagingType = checkPackageType(widgetPath, tempDir); - ConfigParserData configData = getWidgetDataFromXML(widgetPath, tempDir, - m_installerContext.widgetConfig.packagingType, m_isDRM); + ConfigParserData configData = getWidgetDataFromXML( + widgetPath, + tempDir, + m_installerContext.widgetConfig.packagingType, + m_isDRM); LogDebug("widget packaging type : " << m_installerContext.widgetConfig.packagingType.pkgType); WidgetUpdateInfo update = detectWidgetUpdate(configData); m_needEncryption = detectResourceEncryption(configData); + setInstallLocationType(configData); // Configure installation result = ConfigureInstallation(widgetPath, configData, update, tempDir); @@ -275,31 +319,35 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation( return result; } -std::string JobWidgetInstall::generateTizenId() { - std::string allowed("0123456789" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz"); - std::string tizenId; - tizenId.resize(MAX_TIZENID_LENGTH); - for (int i = 0; i < MAX_TIZENID_LENGTH; ++i) { - tizenId[i] = allowed[rand() % allowed.length()]; - } - return tizenId; -} - bool JobWidgetInstall::setTizenId( - const WrtDB::ConfigParserData &configInfo, ConfigureResult result) + const WrtDB::ConfigParserData &configInfo, + const WidgetUpdateInfo &update, + bool preload) { + using namespace PackageManager; regex_t reg; - regcomp(®, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED); - struct stat dirStat; + if(regcomp(®, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED)!=0){ + LogDebug("Regcomp failed"); + } + + ConfigureResult result = checkWidgetUpdate(update); if(!!configInfo.tizenId) { LogDebug("Setting tizenId provided in config.xml: " << configInfo.tizenId); + // send start signal of pkgmgr + getInstallerStruct().pkgmgrInterface->setPkgname( + DPL::ToUTF8String(*(configInfo.tizenId))); + getInstallerStruct().pkgmgrInterface->sendSignal( + PKGMGR_START_KEY, + PKGMGR_START_INSTALL); + + if (result == ConfigureResult::Failed) { + return false; + } + if ((regexec(®, DPL::ToUTF8String(*(configInfo.tizenId)).c_str(), static_cast(0), NULL, 0) != REG_NOERROR) || - ((stat((std::string(GlobalConfig::GetUserInstalledWidgetPath()) + "/" - + DPL::ToUTF8String(*(configInfo.tizenId))).c_str(), &dirStat) == 0) - && result != ConfigureResult::Updated)) + (checkTizenIdExist(DPL::ToUTF8String(*(configInfo.tizenId))) && + result != ConfigureResult::Updated)) { //it is true when tizenId does not fit REG_TIZENID_PATTERN LogError("tizen_id provided but not proper."); @@ -309,33 +357,31 @@ bool JobWidgetInstall::setTizenId( m_installerContext.widgetConfig.pkgname = configInfo.tizenId; } else { - std::string tizenId = generateTizenId(); + WidgetPkgName tizenId = WidgetDAOReadOnly::generateTizenId(); // only for installation, not for update if (result == ConfigureResult::Ok) { //check if there is package with same name and if generate different name - std::string path = GlobalConfig::GetUserInstalledWidgetPath(); - path += "/"; - - std::ostringstream newPath; - newPath << path << tizenId; LogDebug("Checking if tizen id is unique"); while (true) { - if (stat(newPath.str().c_str(), &dirStat) == 0) { + if (checkTizenIdExist(DPL::ToUTF8String(tizenId))) { //path exist, chose another one - tizenId = generateTizenId(); - newPath.str(""); - newPath << path << tizenId; + tizenId = WidgetDAOReadOnly::generateTizenId(); continue; } break; } - m_installerContext.widgetConfig.pkgname = - DPL::FromUTF8String(tizenId); + m_installerContext.widgetConfig.pkgname = tizenId; } LogInfo("tizen_id name was generated by WRT: " << tizenId); + // send start signal of pkgmgr + getInstallerStruct().pkgmgrInterface->setPkgname(DPL::ToUTF8String( + *m_installerContext.widgetConfig.pkgname)); + getInstallerStruct().pkgmgrInterface->sendSignal( + PKGMGR_START_KEY, + PKGMGR_START_INSTALL); } regfree(®); @@ -344,18 +390,14 @@ bool JobWidgetInstall::setTizenId( return true; } -DPL::OptionalString JobWidgetInstall::getNewTizenId() const -{ - return m_installerContext.widgetConfig.pkgname; -} - void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath, const std::string& tempPath) { m_installerContext.locations = WidgetLocation(DPL::ToUTF8String(*m_installerContext.widgetConfig.pkgname), widgetPath, tempPath, - m_installerContext.widgetConfig.packagingType); + m_installerContext.widgetConfig.packagingType, + m_installerContext.locationType); LogInfo("widgetSource " << widgetPath); } @@ -366,6 +408,27 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation( const WidgetUpdateInfo &update, const std::string &tempPath) { + + if (!setTizenId(configData, update, m_jobStruct.m_preload)) { + return ConfigureResult::Failed; + } else { + LogInfo("Tizen Id: " << m_installerContext.widgetConfig.pkgname); + + configureWidgetLocation(widgetSource, tempPath); + } + + // Init installer context + m_installerContext.installStep = InstallerContext::INSTALL_START; + m_installerContext.job = this; + m_installerContext.existingWidgetInfo = update.existingWidgetInfo; + m_installerContext.widgetConfig.shareHref = std::string(); + + return ConfigureResult::Ok; +} + +JobWidgetInstall::ConfigureResult JobWidgetInstall::checkWidgetUpdate( + const WidgetUpdateInfo &update) +{ LogInfo( "Widget install/update: incoming guid = '" << update.incomingGUID << "'"); @@ -375,7 +438,6 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation( // Check policy WidgetUpdateMode::Type updateTypeCheckBit; - JobWidgetInstall::ConfigureResult ret = ConfigureResult::Ok; if (update.existingWidgetInfo.isExist == false) { LogInfo("Widget info does not exist"); @@ -412,7 +474,6 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation( } else { LogInfo( "Widget is already running. Policy is not update according to WAC"); - LogInfo("Installation aborted: " << widgetSource); return ConfigureResult::Failed; } @@ -426,39 +487,17 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation( updateTypeCheckBit = CalcWidgetUpdatePolicy(existingVersion, incomingVersion); // Calc proceed flag - if ((m_jobStruct.updateMode & updateTypeCheckBit) > 0) { + if ((m_jobStruct.updateMode & updateTypeCheckBit) > 0 || + m_jobStruct.updateMode == + WidgetUpdateMode::PolicyDirectoryForceInstall) + { LogInfo("Whether widget policy allow proceed ok"); - ret = ConfigureResult::Updated; + return ConfigureResult::Updated; } else return ConfigureResult::Failed; } - - if (!setTizenId(configData, ret)) { - return ConfigureResult::Failed; - } else { - using namespace PackageManager; - LogInfo("Tizen Id: " << m_installerContext.widgetConfig.pkgname); - - configureWidgetLocation(widgetSource, tempPath); - - // send start signal of pkgmgr - PkgmgrSignalSingleton::Instance().setPkgname( - DPL::ToUTF8String( - *m_installerContext.widgetConfig.pkgname)); - PkgmgrSignalSingleton::Instance().sendSignal( - PKGMGR_START_KEY, - PKGMGR_START_INSTALL); - } - - // Init installer context - m_installerContext.installStep = InstallerContext::INSTALL_START; - m_installerContext.job = this; - m_installerContext.existingWidgetInfo = update.existingWidgetInfo; - m_installerContext.widgetConfig.shareHref = std::string(); - - // Return result - return ret; + return ConfigureResult::Ok; } WidgetUpdateMode::Type JobWidgetInstall::CalcWidgetUpdatePolicy( @@ -512,6 +551,12 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML( new RootParser(configInfo, DPL::FromUTF32String( L"widget")))); + } else if (pkgType == PKG_TYPE_DIRECTORY_WEB_APP) { + parser.Parse(widgetSource + '/' + WITH_OSP_XML, + ElementParserPtr( + new RootParser( + configInfo, + DPL::FromUTF32String(L"widget")))); } else { if (!isDRM) { std::unique_ptr zipFile( @@ -578,6 +623,11 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML( LogError("Failed to parse config.xml file"); return ConfigParserData(); } + Catch(DPL::ZipInput::Exception::SeekFileFailed) + { + LogError("Failed to seek widget archive - corrupted package?"); + return ConfigParserData(); + } return configInfo; } @@ -635,7 +685,7 @@ void JobWidgetInstall::SendProgress() // send progress signal of pkgmgr std::ostringstream percent; percent << static_cast(GetProgressPercent()); - PkgmgrSignalSingleton::Instance().sendSignal( + getInstallerStruct().pkgmgrInterface->sendSignal( PKGMGR_PROGRESS_KEY, percent.str()); @@ -652,16 +702,26 @@ void JobWidgetInstall::SendFinishedSuccess() // TODO : sync should move to separate task. sync(); + + if (INSTALL_LOCATION_TYPE_EXTERNAL == m_installerContext.locationType) { + if (false == m_installerContext.existingWidgetInfo.isExist) { + WidgetInstallToExtSingleton::Instance().postInstallation(true); + } else { + WidgetInstallToExtSingleton::Instance().postUpgrade(true); + } + WidgetInstallToExtSingleton::Instance().deinitialize(); + } + // remove widget install information file unlink(m_installerContext.installInfo.c_str()); //inform widget info JobWidgetInstall::displayWidgetInfo(); - DPL::OptionalString tizenId = getNewTizenId(); + DPL::OptionalString & tizenId = m_installerContext.widgetConfig.pkgname; // send signal of pkgmgr - PkgmgrSignalSingleton::Instance().sendSignal( + getInstallerStruct().pkgmgrInterface->sendSignal( PKGMGR_END_KEY, PKGMGR_END_SUCCESS); @@ -678,12 +738,12 @@ void JobWidgetInstall::SendFinishedFailure() LogError("Error in installation step: " << m_exceptionCaught); LogError("Message: " << m_exceptionMessage); - DPL::OptionalString tizenId = getNewTizenId(); + DPL::OptionalString & tizenId = m_installerContext.widgetConfig.pkgname; LogDebug("Call widget install failure finishedCallback"); // send signal of pkgmgr - PkgmgrSignalSingleton::Instance().sendSignal( + getInstallerStruct().pkgmgrInterface->sendSignal( PKGMGR_END_KEY, PKGMGR_END_FAILURE); @@ -766,7 +826,12 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType( const std::string &widgetSource, const std::string &tempPath) { - // Check installation type (config.xml or widget.wgt) + // Check installation type (direcotory/ or config.xml or widget.wgt) + if (WidgetUpdateMode::PolicyDirectoryForceInstall == m_jobStruct.updateMode) + { + LogDebug("Install directly from directory"); + return PKG_TYPE_DIRECTORY_WEB_APP; + } if (hasExtension(widgetSource, XML_EXTENSION)) { LogInfo("Hosted app installation"); return PKG_TYPE_HOSTED_WEB_APP; @@ -796,6 +861,11 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType( 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 { @@ -840,6 +910,28 @@ bool JobWidgetInstall::detectResourceEncryption(const WrtDB::ConfigParserData &c return false; } +void JobWidgetInstall::setInstallLocationType(const + WrtDB::ConfigParserData &configData) +{ + m_installerContext.locationType = INSTALL_LOCATION_TYPE_NOMAL; + + if (true == m_jobStruct.m_preload) { + m_installerContext.locationType = + INSTALL_LOCATION_TYPE_PRELOAD; + } else { + FOREACH(it, configData.settingsList) + { + if (it->m_name == SETTING_VALUE_INSTALLTOEXT_NAME && + it->m_value == + SETTING_VALUE_INSTALLTOEXT_PREPER_EXT) { + LogDebug("This widget will be installed to sd card"); + m_installerContext.locationType = + INSTALL_LOCATION_TYPE_EXTERNAL; + } + } + } +} + bool JobWidgetInstall::isDRMWidget(std::string widgetPath) { /* TODO : @@ -862,7 +954,7 @@ bool JobWidgetInstall::isDRMWidget(std::string widgetPath) bool JobWidgetInstall::DecryptDRMWidget(std::string widgetPath, std::string destPath) { - /* TODO : + /* TODO : drm_trusted_sapps_decrypt_package_info_s package_info; strncpy(package_info.sadcf_filepath, widgetPath.c_str(), @@ -882,7 +974,7 @@ bool JobWidgetInstall::DecryptDRMWidget(std::string widgetPath, } */ if (drm_oem_intel_decrypt_package(const_cast(widgetPath.c_str()), - const_cast(destPath.c_str())) != 0) { + const_cast(destPath.c_str())) != 0) { return true; } else { return false; diff --git a/src/jobs/widget_install/job_widget_install.h b/src/jobs/widget_install/job_widget_install.h index fa39392..1f81498 100644 --- a/src/jobs/widget_install/job_widget_install.h +++ b/src/jobs/widget_install/job_widget_install.h @@ -72,7 +72,8 @@ class JobWidgetInstall : const OptionalWidgetVersion &existingVersion, const OptionalWidgetVersion &incomingVersion) const; bool setTizenId(const WrtDB::ConfigParserData &configInfo, - ConfigureResult result); + const WidgetUpdateInfo &update, + bool preload); void displayWidgetInfo(); void configureWidgetLocation(const std::string & widgetPath, const std::string &tempPath); @@ -81,10 +82,12 @@ class JobWidgetInstall : const std::string &widgetSource, const std::string &tempPath); bool detectResourceEncryption(const WrtDB::ConfigParserData &configData); - std::string generateTizenId(); + 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 checkWidgetUpdate(const WidgetUpdateInfo &update); public: /** @@ -93,8 +96,6 @@ class JobWidgetInstall : JobWidgetInstall(std::string const & widgetPath, const WidgetInstallationStruct &installerStruct); - DPL::OptionalString getNewTizenId() const; - //overrides void SendProgress(); void SendFinishedSuccess(); diff --git a/src/jobs/widget_install/manifest.cpp b/src/jobs/widget_install/manifest.cpp old mode 100644 new mode 100755 index f231d02..98adb96 --- a/src/jobs/widget_install/manifest.cpp +++ b/src/jobs/widget_install/manifest.cpp @@ -176,6 +176,7 @@ void Manifest::serialize(xmlTextWriterPtr writer) FOREACH(u, this->uiApplication) { u->serialize(writer); } FOREACH(i, this->imeApplication) { i->serialize(writer); } //FOREACH(f, this->font) { f->serialize(writer); } + FOREACH(l, this->livebox) { l->serialize(writer); } } endElement(writer); } @@ -210,7 +211,7 @@ void ServiceApplication::serialize(xmlTextWriterPtr writer) writeElementWithOneAttribute(writer, "icon", i->getString(), "xml:lang", i->getLang(), i->hasLang()); } - FOREACH(a, this->applicationService) + FOREACH(a, this->appControl) { a->serialize(writer); } @@ -242,10 +243,16 @@ void UiApplication::serialize(xmlTextWriterPtr writer) writeElementWithOneAttribute(writer, "icon", i->getString(), "xml:lang", i->getLang(), i->hasLang()); } - FOREACH(a, this->applicationService) + FOREACH(a, this->appControl) { a->serialize(writer); } + FOREACH(c, this->appCategory) + { + startElement(writer, "category"); + writeAttribute(writer, "name", *c); + endElement(writer); + } endElement(writer); } @@ -272,9 +279,9 @@ void ImeApplication::serialize(xmlTextWriterPtr writer) endElement(writer); } -void ApplicationService::serialize(xmlTextWriterPtr writer) +void AppControl::serialize(xmlTextWriterPtr writer) { - startElement(writer, "application-service"); + startElement(writer, "app-control"); FOREACH(o, this->operation) { startElement(writer, "operation"); @@ -296,5 +303,83 @@ void ApplicationService::serialize(xmlTextWriterPtr writer) endElement(writer); } +void LiveBox::serialize(xmlTextWriterPtr writer) +{ + startElement(writer, "livebox"); + if(!this->liveboxId.empty()) { + writeAttribute(writer, "appid", this->liveboxId); + } + + if(!this->primary.empty()) { + writeAttribute(writer, "primary", this->primary); + } + + if(!this->updatePeriod.empty()) { + writeAttribute(writer, "period", this->updatePeriod); + } + + writeAttribute(writer, "abi", "html"); + writeAttribute(writer, "network", "true"); + writeAttribute(writer, "nodisplay", "false"); + + if(!this->label.empty()) { + startElement(writer, "label"); + writeText(writer, this->label); + endElement(writer); + } + + if(!this->icon.empty()) { + startElement(writer, "icon"); + writeText(writer, this->icon); + endElement(writer); + } + + if(!this->autoLaunch.empty()) { + startElement(writer, "launch"); + writeText(writer, this->autoLaunch); + endElement(writer); + } + + if(!this->box.boxSrc.empty() && !this->box.boxSize.empty()) + { + startElement(writer, "box"); + writeAttribute(writer, "type", "buffer"); + + FOREACH(m, this->box.boxSize) + { + std::pair boxSize = *m; + startElement(writer, "size"); + if(!boxSize.second.empty()) + writeAttribute(writer, "preview", boxSize.second); + writeText(writer, boxSize.first); + endElement(writer); + } + + startElement(writer, "script"); + writeAttribute(writer, "src", this->box.boxSrc); + endElement(writer); + + endElement(writer); + + if(!this->box.pdSrc.empty() && ! this->box.pdWidth.empty() && ! this->box.pdHeight.empty()) { + startElement(writer, "pd"); + writeAttribute(writer, "type", "buffer"); + + startElement(writer, "size"); + DPL::String pdSize = this->box.pdWidth+DPL::String(L"x")+this->box.pdHeight; + writeText(writer, pdSize); + endElement(writer); + + startElement(writer, "script"); + writeAttribute(writer, "src", this->box.pdSrc); + endElement(writer); + + endElement(writer); + } + } + + endElement(writer); +} + } //namespace Jobs } //namespace WidgetInstall diff --git a/src/jobs/widget_install/manifest.h b/src/jobs/widget_install/manifest.h old mode 100644 new mode 100755 index 84894dd..ac469d2 --- a/src/jobs/widget_install/manifest.h +++ b/src/jobs/widget_install/manifest.h @@ -61,6 +61,7 @@ typedef StringWithLang LabelType, IconType, DescriptionType; typedef DPL::String NcnameType, NmtokenType, AnySimpleType, LangType; typedef DPL::String OperationType, MimeType, UriType, TypeType, PackageType; typedef DPL::OptionalString InstallLocationType, CategoriesType; +typedef DPL::String AppCategoryType; /** * xmllib2 wrappers @@ -103,10 +104,10 @@ typedef Author AuthorType; /** * @brief application-service element */ -class ApplicationService +class AppControl { public: - ApplicationService() {} + AppControl() {} void addOperation(const OperationType &x) { this->operation.push_back(x); } void addUri(const UriType &x) { this->uri.push_back(x); } void addMime(const MimeType &x) { this->mime.push_back(x); } @@ -117,7 +118,7 @@ private: std::list mime; //attr name AnySimpleType }; -typedef ApplicationService ApplicationServiceType; +typedef AppControl AppControlType; /** * @brief ime-application element @@ -160,9 +161,9 @@ public: void setType(const TypeType &x) { this->type = x; } void addLabel(const LabelType &x) { this->label.push_back(x); } void addIcon(const IconType &x) { this->icon.push_back(x); } - void addApplicationService(const ApplicationServiceType &x) + void addAppControl(const AppControlType &x) { - this->applicationService.push_back(x); + this->appControl.push_back(x); } void serialize(xmlTextWriterPtr writer); private: @@ -173,7 +174,7 @@ private: TypeType type; std::list label; //attr name AnySimpleType std::list icon; //attr name AnySimpleType - std::list applicationService; //attr name AnySimpleType + std::list appControl; //attr name AnySimpleType }; typedef ServiceApplication ServiceApplicationType; @@ -195,9 +196,13 @@ public: void setCategories(const NcnameType &x) { this->categories = x; } void addLabel(const LabelType &x) { this->label.push_back(x); } void addIcon(const IconType &x) { this->icon.push_back(x); } - void addApplicationService(const ApplicationServiceType &x) + void addAppControl(const AppControlType &x) { - this->applicationService.push_back(x); + this->appControl.push_back(x); + } + void addAppCategory(const AppCategoryType &x) + { + this->appCategory.push_back(x); } void serialize(xmlTextWriterPtr writer); private: @@ -211,12 +216,56 @@ private: CategoriesType categories; std::list label; std::list icon; - std::list applicationService; + std::list appControl; + std::list appCategory; }; typedef UiApplication UiApplicationType; /** + * @brief LiveBox element + */ +typedef std::list> boxSizeType; + + +struct BoxInfo +{ + NcnameType boxSrc; + boxSizeType boxSize; + NcnameType pdSrc; + NcnameType pdWidth; + NcnameType pdHeight; +}; +typedef BoxInfo BoxInfoType; + +class LiveBox +{ +public: + LiveBox() { } + void setLiveboxId(const NcnameType &x) { this->liveboxId = x; } + void setPrimary(const NcnameType &x) { this->primary = x; } + void setAutoLaunch(const NcnameType &x) { this->autoLaunch = x; } + void setUpdatePeriod(const NcnameType &x) { this->updatePeriod = x; } + void setLabel(const NcnameType &x) { this->label = x; } + void setIcon(const NcnameType &x) { this->icon = x; } + void setBox(const BoxInfoType &x) { this->box = x; } + + void serialize(xmlTextWriterPtr writer); + +private: + NcnameType liveboxId; + NcnameType primary; + NcnameType autoLaunch; + NcnameType updatePeriod; + NcnameType timeout; + NcnameType label; + NcnameType icon; + BoxInfoType box; +}; + +typedef LiveBox LiveBoxInfo; + +/** * @brief manifest element * * Manifest xml file representation. @@ -257,6 +306,11 @@ public: } // void addFont(const FontType &x) { this->font.push_back(x); } + void addLivebox(const LiveBoxInfo &x) + { + this->livebox.push_back(x); + } + void setInstallLocation(const InstallLocationType &x) { this->installLocation = x; @@ -275,6 +329,7 @@ private: std::list uiApplication; std::list imeApplication; // std::list font; + std::list livebox; InstallLocationType installLocation; NcnameType package; PackageType type; diff --git a/src/jobs/widget_install/task_certificates.cpp b/src/jobs/widget_install/task_certificates.cpp index a302b64..4e41048 100755 --- a/src/jobs/widget_install/task_certificates.cpp +++ b/src/jobs/widget_install/task_certificates.cpp @@ -83,49 +83,74 @@ void TaskCertificates::SetCertiInfo(CertificateSource source) FOREACH(it, certificateChainList) { - LogDebug("Insert certinfo to pkgmgr db"); + LogDebug("Insert certinfo to pkgmgr structure"); ValidationCore::CertificateCollection chain; if (false == chain.load(*it)) { LogError("Chain is broken"); + ThrowMsg(Exceptions::SetCertificateInfoFailed, + "Failed to Installer Save Certinfo"); } - chain.sort(); + if (!chain.sort()){ + LogError("Chain failed at sorting"); + } ValidationCore::CertificateList list = chain.getCertificateList(); - FOREACH(certIt, list) { - ValidationCore::Crypto::Hash::SHA1 sha1; - sha1.Append((*certIt)->getDER()); - sha1.Finish(); - std::string sha1String = sha1.ToBase64String(); - - if ((*certIt)->isRootCert()) { - if (source == SIGNATURE_DISTRIBUTOR) { - LogDebug("Set SIGNATURE_DISTRIBUTOR "); - if((pkgmgr_installer_set_cert_value( - m_pkgHandle, - PM_SET_DISTRIBUTOR_ROOT_CERT, - const_cast(sha1String.c_str()))) < 0) { - LogError("pkgmgrInstallerSetCertValue fail"); - ThrowMsg(Exceptions::SetCertificateInfoFailed, - "Failed to Set CertValue"); + pkgmgr_instcert_type instCertType; + + if (source == SIGNATURE_DISTRIBUTOR) { + std::string + Name(DPL::ToUTF8String(*(*certIt)->getOrganizationName())); + size_t found = Name.find("Tizen"); + + if (found != std::string::npos) { + LogDebug("Set SIGNATURE_DISTRIBUTOR"); + if ((*certIt)->isRootCert()) { + instCertType = PM_SET_DISTRIBUTOR_ROOT_CERT; + } else { + if ((*certIt)->isCA()) { + instCertType = PM_SET_DISTRIBUTOR_INTERMEDIATE_CERT; + } else { + instCertType = PM_SET_DISTRIBUTOR_SIGNER_CERT; + } + } + } else { + LogDebug("Set SIGNATURE_DISTRIBUTOR2"); + if ((*certIt)->isRootCert()) { + instCertType = PM_SET_DISTRIBUTOR2_ROOT_CERT; + } else { + if ((*certIt)->isCA()) { + instCertType = PM_SET_DISTRIBUTOR2_INTERMEDIATE_CERT; + } else { + instCertType = PM_SET_DISTRIBUTOR2_SIGNER_CERT; + } } } - else { - LogDebug("set SIGNATURE_AUTHOR"); - if((pkgmgr_installer_set_cert_value( - m_pkgHandle, - PM_SET_AUTHOR_ROOT_CERT, - const_cast(sha1String.c_str()))) < 0) { - LogError("pkgmgrInstallerSetCertValue fail"); - ThrowMsg(Exceptions::SetCertificateInfoFailed, - "Failed to Installer Set CertValue"); + } else { + LogDebug("set SIGNATURE_AUTHOR"); + if ((*certIt)->isRootCert()) { + instCertType = PM_SET_AUTHOR_ROOT_CERT; + } else { + if ((*certIt)->isCA()) { + instCertType = PM_SET_AUTHOR_INTERMEDIATE_CERT; + } else { + instCertType = PM_SET_AUTHOR_SIGNER_CERT; } } } + LogDebug("cert type : " << instCertType); + if((pkgmgr_installer_set_cert_value( + m_pkgHandle, + instCertType, + const_cast(((*certIt)->getBase64()).c_str()))) < 0) { + LogError("pkgmgrInstallerSetCertValue fail"); + ThrowMsg(Exceptions::SetCertificateInfoFailed, + "Failed to Set CertValue"); + } } } } diff --git a/src/jobs/widget_install/task_certify.cpp b/src/jobs/widget_install/task_certify.cpp index 532c206..40a17cd 100755 --- a/src/jobs/widget_install/task_certify.cpp +++ b/src/jobs/widget_install/task_certify.cpp @@ -37,9 +37,10 @@ #include #include "wac_widget_id.h" +#include #include #include -#include +#include #include #include #include @@ -83,11 +84,11 @@ WidgetCertificateData toWidgetCertificateData(const SignatureData &data, result.strCommonName = *certificate->getCommonName(); result.strMD5Fingerprint = std::string("md5 ") + - SignatureValidator::FingerprintToColonHex( + Certificate::FingerprintToColonHex( certificate->getFingerprint(Certificate::FINGERPRINT_MD5)); result.strSHA1Fingerprint = std::string("sha-1 ") + - SignatureValidator::FingerprintToColonHex( + Certificate::FingerprintToColonHex( certificate->getFingerprint(Certificate::FINGERPRINT_SHA1)); return result; @@ -101,10 +102,7 @@ TaskCertify::TaskCertify(InstallerContext &inCont) : m_contextData(inCont), WidgetInstallPopup(inCont) { - /* This is temporary comment for certi error - After security-server, cert-svc release, should remove comment AddStep(&TaskCertify::stepSignature); - */ // Block until fixed popup issues if (!GlobalSettings::PopupsTestModeEnabled() @@ -131,7 +129,9 @@ void TaskCertify::processDistributorSignature(const SignatureData &data, CertificateCollection collection; collection.load(data.getCertList()); - collection.sort(); + Assert(collection.sort() && + "Certificate collection can't sort"); + Assert(collection.isChain() && "Certificate collection is not able to create chain. " "It is not possible to verify this signature."); @@ -186,7 +186,7 @@ void TaskCertify::processAuthorSignature(const SignatureData &data) void TaskCertify::stepSignature() { - LogInfo("enter"); + LogInfo("================ Step: <> ENTER ==============="); std::string widgetPath = m_contextData.locations->getTemporaryRootDir() + "/"; @@ -199,7 +199,7 @@ void TaskCertify::stepSignature() } SignatureFileInfoSet::reverse_iterator iter = signatureFiles.rbegin(); - LogInfo("No of signatures: " << signatureFiles.size()); + LogInfo("Number of signatures: " << signatureFiles.size()); bool firstDistributorSignature = true; bool testCertificate = false; @@ -216,19 +216,28 @@ void TaskCertify::stepSignature() xml.initialize(data, GlobalConfig::GetSignatureXmlSchema()); xml.read(data); - SignatureValidator validator(!GlobalSettings::OCSPTestModeEnabled(), - !GlobalSettings::CrlTestModeEnabled(), - complianceMode); - SignatureValidator::Result result = + WrtSignatureValidator::AppType appType = WrtSignatureValidator::WAC20; + + if (m_installContext.widgetConfig.webAppType == APP_TYPE_TIZENWEBAPP) { + appType = WrtSignatureValidator::TIZEN; + } + + WrtSignatureValidator validator( + appType, + !GlobalSettings::OCSPTestModeEnabled(), + !GlobalSettings::CrlTestModeEnabled(), + complianceMode); + + WrtSignatureValidator::Result result = validator.check(data, widgetPath); - if (result == SignatureValidator::SIGNATURE_REVOKED) { + if (result == WrtSignatureValidator::SIGNATURE_REVOKED) { LogWarning("Certificate is REVOKED"); ThrowMsg(Exceptions::InvalidPackage, "Certificate is REVOKED"); } - if (result == SignatureValidator::SIGNATURE_INVALID) { + if (result == WrtSignatureValidator::SIGNATURE_INVALID) { LogWarning("Signature is INVALID"); // TODO change exception name ThrowMsg(Exceptions::InvalidPackage, @@ -236,15 +245,15 @@ void TaskCertify::stepSignature() } if (data.isAuthorSignature()) { - if (result == SignatureValidator::SIGNATURE_VERIFIED || + if (result == WrtSignatureValidator::SIGNATURE_VERIFIED || m_contextData.wacSecurity.isDistributorSigned()) { processAuthorSignature(data); - } else if (result == SignatureValidator::SIGNATURE_DISREGARD) { + } else if (result == WrtSignatureValidator::SIGNATURE_DISREGARD) { continue; } } else { - if (result == SignatureValidator::SIGNATURE_DISREGARD) { + if (result == WrtSignatureValidator::SIGNATURE_DISREGARD) { continue; } // now signature _must_ be verified @@ -300,7 +309,7 @@ void TaskCertify::stepSignature() LogInfo("No signature files has been found."); } - LogInfo("================ Step: <> DONE ================"); + LogInfo("================ Step: <> DONE ================"); m_contextData.job->UpdateProgress( InstallerContext::INSTALL_DIGSIG_CHECK, diff --git a/src/jobs/widget_install/task_commons.cpp b/src/jobs/widget_install/task_commons.cpp index 10c73e8..fea9ea1 100644 --- a/src/jobs/widget_install/task_commons.cpp +++ b/src/jobs/widget_install/task_commons.cpp @@ -43,14 +43,19 @@ const mode_t TEMPORARY_PATH_MODE = 0775; } // namespace -std::string createTempPath() +std::string createTempPath(bool preload) { LogInfo("Step: Creating temporary path"); // Temporary path std::ostringstream tempPathBuilder; - tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath(); + if (preload) { + tempPathBuilder << WrtDB::GlobalConfig::GetUserPreloadedWidgetPath(); + } else { + tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath(); + } + tempPathBuilder << WrtDB::GlobalConfig::GetTmpDirPath(); tempPathBuilder << "/"; tempPathBuilder << TEMPORARY_PATH_POSTFIX; tempPathBuilder << "_"; diff --git a/src/jobs/widget_install/task_commons.h b/src/jobs/widget_install/task_commons.h index dbb41eb..5193c3d 100644 --- a/src/jobs/widget_install/task_commons.h +++ b/src/jobs/widget_install/task_commons.h @@ -29,7 +29,8 @@ namespace WidgetInstall { //TODO make directory like jobs common? -std::string createTempPath(); +std::string createTempPath(bool preload = false); +std::string createTempPath(bool preload); void createTempPath(const std::string& path); diff --git a/src/jobs/widget_install/task_database.cpp b/src/jobs/widget_install/task_database.cpp index f861c85..696a962 100644 --- a/src/jobs/widget_install/task_database.cpp +++ b/src/jobs/widget_install/task_database.cpp @@ -26,31 +26,41 @@ #include #include #include -//#include #include +#include #include #include #include #include -//#include #include #include +#include +#include +#include +#include +#include using namespace WrtDB; namespace Jobs { namespace WidgetInstall { + TaskDatabase::TaskDatabase(InstallerContext& context) : DPL::TaskDecl(this), - m_context(context) + m_context(context), + m_handleToRemove(INVALID_WIDGET_HANDLE), + m_handle(INVALID_WIDGET_HANDLE) { AddStep(&TaskDatabase::StepRegisterExternalFiles); - AddStep(&TaskDatabase::StepDBInsert); + AddStep(&TaskDatabase::StepWrtDBInsert); + AddStep(&TaskDatabase::StepAceDBInsert); + AddStep(&TaskDatabase::StepRemoveExternalFiles); + AddStep(&TaskDatabase::StepCreateVconf); AddAbortStep(&TaskDatabase::StepAbortDBInsert); } -void TaskDatabase::StepDBInsert() +void TaskDatabase::StepWrtDBInsert() { Try { @@ -59,11 +69,15 @@ void TaskDatabase::StepDBInsert() if (m_context.existingWidgetInfo.isExist) //update { + m_handleToRemove = WidgetDAOReadOnly::getHandle( + m_context.locations->getPkgname()); LogInfo("Registering widget... (update)"); WidgetDAO::registerOrUpdateWidget( m_context.locations->getPkgname(), m_context.widgetConfig, m_context.wacSecurity); + m_handle = WidgetDAOReadOnly::getHandle( + m_context.locations->getPkgname()); } else //new installation { @@ -72,6 +86,8 @@ void TaskDatabase::StepDBInsert() m_context.locations->getPkgname(), m_context.widgetConfig, m_context.wacSecurity); + m_handle = WidgetDAOReadOnly::getHandle( + m_context.locations->getPkgname()); } FOREACH (cap, m_context.staticPermittedDevCaps) { @@ -91,6 +107,27 @@ void TaskDatabase::StepDBInsert() LogError("Database failure!"); ReThrowMsg(Exceptions::InsertNewWidgetFailed, "Database failure!"); } +} + +void TaskDatabase::StepAceDBInsert() +{ + LogDebug("Inserting Ace database entry. New handle: " << m_handle); + if (INVALID_WIDGET_HANDLE != m_handleToRemove) { + LogDebug("Removing old insallation. Handle: " << m_handleToRemove); + if (ACE_OK != ace_unregister_widget( + static_cast(m_handleToRemove))) + { + LogWarning("Error while removing ace entry for previous insallation"); + }; + } + + if(!AceApi::registerAceWidget(m_handle, m_context.widgetConfig, + m_context.wacSecurity.getCertificateList())) + { + LogError("ace database insert failed"); + ThrowMsg(Exceptions::NotAllowed, "Update failure. ace_register_widget failed"); + } + LogDebug("Ace data inserted"); m_context.job->UpdateProgress( InstallerContext::INSTALL_NEW_DB_INSERT, @@ -104,28 +141,11 @@ void TaskDatabase::StepRegisterExternalFiles() { WidgetDAO dao(m_context.locations->getPkgname()); WrtDB::ExternalLocationList externalLocationsDB = dao.getWidgetExternalLocations(); - LogDebug("Removing external files:"); FOREACH(file, externalLocationsDB) { if(std::find(externalLocationsUpdate.begin(), externalLocationsUpdate.end(), *file) == externalLocationsUpdate.end()) { - if(WrtUtilFileExists(*file)) - { - LogDebug(" -> " << *file); - remove(file->c_str()); - } - else if(WrtUtilDirExists(*file)) - { - LogDebug(" -> " << *file); - if(!WrtUtilRemove(*file)){ - ThrowMsg(Exceptions::RemovingFolderFailure, - "Failed to remove external directory"); - } - } - else - { - LogWarning(" -> " << *file << "(no such a path)"); - } + m_externalLocationsToRemove.push_back(*file); } } } @@ -135,23 +155,97 @@ void TaskDatabase::StepRegisterExternalFiles() LogDebug(" -> " << *file); } - //set external lcoations to be registered + //set external locations to be registered m_context.widgetConfig.externalLocations = externalLocationsUpdate; } +void TaskDatabase::StepRemoveExternalFiles() +{ + if(!m_externalLocationsToRemove.empty()) + { + LogDebug("Removing external files:"); + } + + FOREACH(file, m_externalLocationsToRemove) + { + if(WrtUtilFileExists(*file)) + { + LogDebug(" -> " << *file); + remove(file->c_str()); + } + else if(WrtUtilDirExists(*file)) + { + LogDebug(" -> " << *file); + if(!WrtUtilRemove(*file)){ + ThrowMsg(Exceptions::RemovingFolderFailure, + "Failed to remove external directory"); + } + } + else + { + LogWarning(" -> " << *file << "(no such a path)"); + } + } +} + +void TaskDatabase::StepCreateVconf() +{ + LogDebug("StepCreateVconf"); + std::string popupUsageKey = + WrtDB::VconfConfig::GetVconfKeyPopupUsage( + m_context.locations->getPkgname()); + std::string geolocationUsageKey = + WrtDB::VconfConfig::GetVconfKeyGeolocationUsage( + m_context.locations->getPkgname()); + std::string webNotificationUsageKey = + WrtDB::VconfConfig::GetVconfKeyWebNotificationUsage( + m_context.locations->getPkgname()); + std::string webDatabaseUsageKey = + WrtDB::VconfConfig::GetVconfKeyWebDatabaseUsage( + m_context.locations->getPkgname()); + std::string filesystemUsageKey = + WrtDB::VconfConfig::GetVconfKeyFilesystemUsage( + m_context.locations->getPkgname()); + std::string memorySavingModeKey = + WrtDB::VconfConfig::GetVconfKeyMemorySavingMode( + m_context.locations->getPkgname()); + + vconf_set_int(popupUsageKey.c_str(), + static_cast(WrtDB::SETTINGS_TYPE_ON)); + // prevent permission error + vconf_unset(popupUsageKey.c_str()); + vconf_set_int(popupUsageKey.c_str(), + static_cast(WrtDB::SETTINGS_TYPE_ON)); + vconf_set_int(geolocationUsageKey.c_str(), + static_cast(WrtDB::SETTINGS_TYPE_ON)); + vconf_set_int(webNotificationUsageKey.c_str(), + static_cast(WrtDB::SETTINGS_TYPE_ON)); + vconf_set_int(webDatabaseUsageKey.c_str(), + static_cast(WrtDB::SETTINGS_TYPE_ON)); + vconf_set_int(filesystemUsageKey.c_str(), + static_cast(WrtDB::SETTINGS_TYPE_ON)); + vconf_set_int(memorySavingModeKey.c_str(), + static_cast(WrtDB::SETTINGS_TYPE_OFF)); +} + void TaskDatabase::StepAbortDBInsert() { LogWarning("[DB Update Task] Aborting... (DB Clean)"); Try { WidgetDAO::unregisterWidget(m_context.locations->getPkgname()); - LogDebug("Cleaning DB successful!"); } Catch(DPL::DB::SqlConnection::Exception::Base) { LogError("Failed to handle StepAbortDBClean!"); } + + ace_unregister_widget(static_cast(m_handle)); + // Remove also old one. If it was already updated nothing wrong will happen, + // but if not old widget will be removed. + if (INVALID_WIDGET_HANDLE != m_handleToRemove) + ace_unregister_widget(static_cast(m_handle)); } } //namespace WidgetInstall diff --git a/src/jobs/widget_install/task_database.h b/src/jobs/widget_install/task_database.h index ce01985..f2098bc 100644 --- a/src/jobs/widget_install/task_database.h +++ b/src/jobs/widget_install/task_database.h @@ -24,6 +24,9 @@ #define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_DATABASE_H #include +#include + +#include class InstallerContext; @@ -34,9 +37,18 @@ class TaskDatabase: { private: InstallerContext& m_context; + WrtDB::ExternalLocationList m_externalLocationsToRemove; + + //TODO: temporary needed until security-server start to use pkgName instead + //of widget handle + WrtDB::DbWidgetHandle m_handleToRemove; + WrtDB::DbWidgetHandle m_handle; - void StepDBInsert(); void StepRegisterExternalFiles(); + void StepWrtDBInsert(); + void StepAceDBInsert(); + void StepRemoveExternalFiles(); + void StepCreateVconf(); void StepAbortDBInsert(); diff --git a/src/jobs/widget_install/task_db_update.cpp b/src/jobs/widget_install/task_db_update.cpp deleted file mode 100644 index 5b02a95..0000000 --- a/src/jobs/widget_install/task_db_update.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file task_db_update.cpp - * @author Lukasz Wrzosek(l.wrzosek@samsung.com) - * @version 1.0 - * @brief Implementation file for installer task database updating - */ -//#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace WrtDB; - -namespace Jobs { -namespace WidgetInstall { -TaskDbUpdate::TaskDbUpdate(InstallerContext& context) : - DPL::TaskDecl(this), - m_context(context) -{ - AddStep(&TaskDbUpdate::StepDbUpdate); - - AddAbortStep(&TaskDbUpdate::StepAbortDBUpdate); -} - -void TaskDbUpdate::StepDbUpdate() -{ - Try - { - // If there is existing model, remove its database data - if (true == m_context.existingWidgetInfo.isExist) { - WidgetHandle old = m_context.existingWidgetInfo.existingHandle; - LogInfo("Unregistering widget...: " << old); - WidgetDAO::unregisterWidget(old); - LogInfo("Widget unregistered"); - } - - /* Set install Time */ - time(&m_context.widgetConfig.installedTime); - - LogInfo("Registering widget..."); - - WidgetDAO::registerWidget( - *(m_context.widgetHandle), - m_context.widgetConfig, - m_context.wacSecurity); - - FOREACH (cap, m_context.staticPermittedDevCaps) { - LogInfo("staticPermittedDevCaps : " << cap->first - << " smack status: " << cap->second); - } - - Assert(!!m_context.widgetConfig.pkgname - && "pkgName should be initialized"); - - WrtDB::WidgetDAO widgetDao(*m_context.widgetHandle); - widgetDao.setPkgName(m_context.widgetConfig.pkgname); - - LogInfo("Widget registered"); - } - Catch(WidgetDAO::Exception::DatabaseError) - { - LogWarning("Database failure!"); - ReThrowMsg(Exceptions::DatabaseFailure, "Database failure!"); - } - Catch(DPL::DB::SqlConnection::Exception::Base) - { - LogDebug("Database failure!"); - ReThrowMsg(Exceptions::DatabaseFailure, "Database failure!"); - } - - m_context.job->UpdateProgress( - InstallerContext::INSTALL_DB_UPDATE, - "Widget DB UPDATE Finished"); -} - -void TaskDbUpdate::StepAbortDBUpdate() -{ - LogWarning("[DB Update Task] Aborting... (DB Clean)"); - Assert(!!m_context.widgetHandle); - Try - { - WidgetDAO::unregisterWidget(*m_context.widgetHandle); - - LogDebug("Cleaning DB successful!"); - } - Catch(DPL::DB::SqlConnection::Exception::Base) - { - //TODO What should happen here? - LogError("Failed to handle StepAbortDBClean!"); - // ReThrowMsg(Exceptions::DbStepFailed, "Failed to handle StepAbortDBClean!"); - } -} - -} //namespace WidgetInstall -} //namespace Jobs diff --git a/src/jobs/widget_install/task_db_update.h b/src/jobs/widget_install/task_db_update.h deleted file mode 100644 index 3f76680..0000000 --- a/src/jobs/widget_install/task_db_update.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file task_db_update.h - * @author Lukasz Wrzosek(l.wrzosek@samsung.com) - * @version 1.0 - * @brief Header file for installer task database updating - */ -#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_DB_UPDATE_H -#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_DB_UPDATE_H - -#include - -class InstallerContext; - -namespace Jobs { -namespace WidgetInstall { -class TaskDbUpdate : - public DPL::TaskDecl -{ - private: - InstallerContext& m_context; - - void StepDbUpdate(); - - void StepAbortDBUpdate(); - - public: - TaskDbUpdate(InstallerContext& context); -}; -} //namespace WidgetInstall -} //namespace Jobs - -#endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_DB_UPDATE_H diff --git a/src/jobs/widget_install/task_encrypt_resource.cpp b/src/jobs/widget_install/task_encrypt_resource.cpp index 9b0bdb4..2ea97ee 100644 --- a/src/jobs/widget_install/task_encrypt_resource.cpp +++ b/src/jobs/widget_install/task_encrypt_resource.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include @@ -161,17 +163,24 @@ void TaskEncryptResource::EncryptFile(const std::string &fileName) memset(readBuf, 0, fileSize); memset(outEncBuf, 0, blockSize); - fread(readBuf, sizeof(unsigned char), fileSize, resFp); - fclose(resFp); + ret = fread(readBuf, sizeof(unsigned char), fileSize, resFp); + if (ret!=fileSize){ + LogError("Failed to read ecryption buffer with error: " << strerror(errno) ); + fclose(resFp); + return; + } m_resEnc->EncryptChunk(readBuf, outEncBuf, fileSize); FILE* encFp = fopen(encFile.c_str(), "w"); if (NULL == encFp) { LogError("Failed to open ecryption file"); + fclose(resFp); return; } fwrite(outEncBuf, sizeof(unsigned char), blockSize, encFp); + + fclose(resFp); fclose(encFp); LogDebug("Success to encrypt file"); diff --git a/src/jobs/widget_install/task_file_manipulation.cpp b/src/jobs/widget_install/task_file_manipulation.cpp index ae02d73..a41239e 100644 --- a/src/jobs/widget_install/task_file_manipulation.cpp +++ b/src/jobs/widget_install/task_file_manipulation.cpp @@ -20,6 +20,7 @@ * @brief Implementation file for installer task database updating */ #include +#include #include #include #include @@ -28,20 +29,93 @@ #include #include #include +#include #include +#include +#include + +#define WEBAPP_DEFAULT_UID 5000 +#define WEBAPP_DEFAULT_GID 5000 + +namespace { +const mode_t PRIVATE_STORAGE_MODE = 0700; +const mode_t SHARE_MODE = 0705; +} using namespace WrtDB; +namespace { +const char* GLIST_RES_DIR = "res"; +const char* GLIST_BIN_DIR = "bin"; + +bool _FolderCopy(std::string source, std::string dest) +{ + DIR* dir = opendir(source.c_str()); + if (NULL == dir) { + return false; + } + + struct dirent* dEntry = NULL; + do { + struct stat statInfo; + if (dEntry = readdir(dir)) { + std::string fileName = dEntry->d_name; + std::string fullName = source + "/" + fileName; + + if (stat(fullName.c_str(), &statInfo) != 0) { + return false; + } + + if (S_ISDIR(statInfo.st_mode)) { + if(("." == fileName) || (".." == fileName)) { + continue; + } + std::string destFolder = dest + "/" + fileName; + WrtUtilMakeDir(destFolder); + + if (!_FolderCopy(fullName, destFolder)) { + return false; + } + } + + std::string destFile = dest + "/" + fileName; + std::ifstream infile(fullName); + std::ofstream outfile(destFile); + outfile << infile.rdbuf(); + outfile.close(); + infile.close(); + } + } while(dEntry); + closedir(dir); + return true; +} +} + namespace Jobs { namespace WidgetInstall { TaskFileManipulation::TaskFileManipulation(InstallerContext& context) : DPL::TaskDecl(this), m_context(context) { - AddStep(&TaskFileManipulation::StepCreateDirs); - AddStep(&TaskFileManipulation::StepRenamePath); + if (INSTALL_LOCATION_TYPE_EXTERNAL != + m_context.locationType) { + AddStep(&TaskFileManipulation::StepCreateDirs); + AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir); + AddStep(&TaskFileManipulation::StepCreateShareDir); + if (m_context.widgetConfig.packagingType != + WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) + { + AddStep(&TaskFileManipulation::StepRenamePath); + AddAbortStep(&TaskFileManipulation::StepAbortRenamePath); + } + } else { + AddStep(&TaskFileManipulation::StepPrepareExternalDir); + AddStep(&TaskFileManipulation::StepInstallToExternal); + AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir); + AddStep(&TaskFileManipulation::StepCreateShareDir); - AddAbortStep(&TaskFileManipulation::StepAbortRenamePath); + AddAbortStep(&TaskFileManipulation::StepAbortCreateExternalDir); + } } void TaskFileManipulation::StepCreateDirs() @@ -74,6 +148,91 @@ void TaskFileManipulation::StepCreateDirs() "Widget Directory Created"); } +void TaskFileManipulation::StepCreatePrivateStorageDir() +{ + std::string storagePath = m_context.locations->getPrivateStorageDir(); + + if (euidaccess(storagePath.c_str(), F_OK) != 0) { + if(!WrtUtilMakeDir(storagePath, PRIVATE_STORAGE_MODE)){ + LogError("Failed to create directory for private storage"); + ThrowMsg(Exceptions::InternalError, + "Failed to create directory for private storage"); + } + // '5000' is default uid, gid for applications. + // So installed applications should be launched as process of uid '5000'. + // the process can access private directory 'data' of itself. + if(chown(storagePath.c_str(), + WEBAPP_DEFAULT_UID, + WEBAPP_DEFAULT_GID) != 0) + { + ThrowMsg(Exceptions::InternalError, + "Chown to invaild user"); + } + } else if (euidaccess(storagePath.c_str(), W_OK | R_OK | X_OK) == 0) { + LogInfo("Private storage already exists."); + // Even if private directory already is created, private dircetory + // should change owner. + if(chown(storagePath.c_str(), + WEBAPP_DEFAULT_UID, + WEBAPP_DEFAULT_GID) != 0) + { + ThrowMsg(Exceptions::InternalError, + "Chown to invaild user"); + } + if(chmod(storagePath.c_str(), PRIVATE_STORAGE_MODE) != 0) { + ThrowMsg(Exceptions::InternalError, + "chmod to 0700"); + } + + } else { + ThrowMsg(Exceptions::InternalError, + "No access to private storage."); + } +} + +void TaskFileManipulation::StepCreateShareDir() +{ + std::string sharePath = m_context.locations->getShareDir(); + + if (euidaccess(sharePath.c_str(), F_OK) != 0) { + if(!WrtUtilMakeDir(sharePath, SHARE_MODE)){ + LogError("Failed to create directory for share"); + ThrowMsg(Exceptions::InternalError, + "Failed to create directory for share"); + } + // '5000' is default uid, gid for applications. + // So installed applications should be launched as process of uid '5000'. + // the process can access private directory 'data' of itself. + if(chown(sharePath.c_str(), + WEBAPP_DEFAULT_UID, + WEBAPP_DEFAULT_GID) != 0) + { + ThrowMsg(Exceptions::InternalError, + "Chown to invaild user"); + } + } else if (euidaccess(sharePath.c_str(), W_OK | R_OK | X_OK) == 0) { + LogInfo("Share directory already exists."); + // Even if share directory already is created, share dircetory + // should change owner. + if(chown(sharePath.c_str(), + WEBAPP_DEFAULT_UID, + WEBAPP_DEFAULT_GID) != 0) + { + ThrowMsg(Exceptions::InternalError, + "Chown to invaild user"); + } + if(chmod(sharePath.c_str(), SHARE_MODE) != 0) { + ThrowMsg(Exceptions::InternalError, + "chmod to 0700"); + } + + } else { + ThrowMsg(Exceptions::InternalError, + "No access to private storage."); + } + +} + void TaskFileManipulation::StepRenamePath() { std::string instDir; @@ -98,7 +257,6 @@ void TaskFileManipulation::StepRenamePath() ThrowMsg(Exceptions::UnknownError, "Error occurs during renaming widget folder"); } - m_context.job->UpdateProgress( InstallerContext::INSTALL_RENAME_PATH, "Widget Rename path Finished"); @@ -108,21 +266,90 @@ void TaskFileManipulation::StepAbortRenamePath() { LogDebug("[Rename Widget Path] Aborting.... (Rename path)"); std::string widgetPath; - if (m_context.widgetConfig.packagingType == PKG_TYPE_HYBRID_WEB_APP) { + if (m_context.widgetConfig.packagingType != PKG_TYPE_HYBRID_WEB_APP) { widgetPath = m_context.locations->getPackageInstallationDir(); - } else { - widgetPath = m_context.locations->getSourceDir(); + if (!WrtUtilRemove(widgetPath)) { + ThrowMsg(Exceptions::RemovingFolderFailure, + "Error occurs during removing existing folder"); + } } - struct stat fileInfo; - if (stat(widgetPath.c_str(), &fileInfo) != 0) { - LogError("Failed to get widget file path : " << widgetPath); - return; + LogDebug("Rename widget path sucessful!"); +} + +void TaskFileManipulation::StepPrepareExternalDir() +{ + LogDebug("Step prepare to install in exernal directory"); + Try { + std::string pkgname = + DPL::ToUTF8String(*m_context.widgetConfig.pkgname); + + WidgetInstallToExtSingleton::Instance().initialize(pkgname); + + size_t totalSize = + Utils::getFolderSize(m_context.locations->getTemporaryPackageDir()); + + int folderSize = (int)(totalSize / (1024 * 1024)) + 1; + + GList *list = NULL; + app2ext_dir_details* dirDetail = NULL; + + std::string dirNames[2] = {GLIST_RES_DIR, GLIST_BIN_DIR}; + + for (int i = 0; i < 2; i++) { + dirDetail = (app2ext_dir_details*) calloc(1, + sizeof(app2ext_dir_details)); + if (NULL == dirDetail) { + ThrowMsg(Exceptions::ErrorExternalInstallingFailure, "error in app2ext"); + } + dirDetail->name = strdup(dirNames[i].c_str()); + dirDetail->type = APP2EXT_DIR_RO; + list = g_list_append(list, dirDetail); + } + + if (false == m_context.existingWidgetInfo.isExist) { + WidgetInstallToExtSingleton::Instance().preInstallation(list, + folderSize); + } else { + WidgetInstallToExtSingleton::Instance().preUpgrade(list, + folderSize); + } + free(dirDetail); + g_list_free(list); + } + Catch (WidgetInstallToExt::Exception::ErrorInstallToExt) + { + ReThrowMsg(Exceptions::ErrorExternalInstallingFailure, "Error during \ + create external folder "); } +} - if (!(rename(widgetPath.c_str(), m_context.locations->getTemporaryPackageDir().c_str()) == 0)) { - LogError("Failed to rename"); +void TaskFileManipulation::StepInstallToExternal() +{ + LogDebug("StepInstallExternal"); + if (!WrtUtilMakeDir(m_context.locations->getSourceDir())) { + ThrowMsg(Exceptions::ErrorExternalInstallingFailure, "To make src \ + directory failed"); } - LogDebug("Rename widget path sucessful!"); + + LogDebug("Resource move to external storage " << + m_context.locations->getSourceDir()); + if (!_FolderCopy(m_context.locations->getTemporaryPackageDir(), + m_context.locations->getSourceDir())) + { + ThrowMsg(Exceptions::UnknownError, + "Error occurs during renaming widget folder"); + } +} + +void TaskFileManipulation::StepAbortCreateExternalDir() +{ + LogError("Abort StepAbortCreateExternalDir"); + if (false == m_context.existingWidgetInfo.isExist) { + WidgetInstallToExtSingleton::Instance().postInstallation(false); + } else { + WidgetInstallToExtSingleton::Instance().postUpgrade(false); + } + WidgetInstallToExtSingleton::Instance().deinitialize(); } } //namespace WidgetInstall } //namespace Jobs diff --git a/src/jobs/widget_install/task_file_manipulation.h b/src/jobs/widget_install/task_file_manipulation.h index 162dbbf..e3f615e 100644 --- a/src/jobs/widget_install/task_file_manipulation.h +++ b/src/jobs/widget_install/task_file_manipulation.h @@ -23,6 +23,7 @@ #define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_FILE_MANIPULATION_UPDATE_H #include +#include class InstallerContext; @@ -31,14 +32,23 @@ namespace WidgetInstall { class TaskFileManipulation : public DPL::TaskDecl { - private: InstallerContext& m_context; + app2ext_handle *m_extHandle; + // install internal location void StepCreateDirs(); void StepRenamePath(); + void StepCreatePrivateStorageDir(); + void StepCreateShareDir(); void StepAbortRenamePath(); + // install external location + void StepPrepareExternalDir(); + void StepInstallToExternal(); + void StepFinishExternalInstallation(); + void StepAbortCreateExternalDir(); + public: TaskFileManipulation(InstallerContext& context); }; 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 3acb023..908109a --- a/src/jobs/widget_install/task_manifest_file.cpp +++ b/src/jobs/widget_install/task_manifest_file.cpp @@ -56,6 +56,9 @@ using namespace WrtDB; namespace { typedef std::map LanguageTagMap; +const char* const ST_TRUE = "true"; +const char* const ST_NODISPLAY = "nodisplay"; + LanguageTagMap getLanguageTagMap() { LanguageTagMap map; @@ -107,6 +110,8 @@ TaskManifestFile::TaskManifestFile(InstallerContext &inCont) : AddStep(&TaskManifestFile::stepGenerateManifest); AddStep(&TaskManifestFile::stepParseManifest); AddStep(&TaskManifestFile::stepFinalize); + + AddAbortStep(&TaskManifestFile::stepAbortParseManifest); } else { // for widget update. AddStep(&TaskManifestFile::stepBackupIconFiles); @@ -545,6 +550,8 @@ void TaskManifestFile::writeManifest(const DPL::String & path) setWidgetManifest(manifest); setWidgetOtherInfo(uiApp); setAppServiceInfo(uiApp); + setAppCategory(uiApp); + setLiveBoxInfo(manifest); manifest.addUiApplication(uiApp); manifest.generate(path); @@ -727,7 +734,17 @@ void TaskManifestFile::setWidgetManifest(Manifest & manifest) void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp) { - uiApp.setNodisplay(false); + 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)) { + uiApp.setNodisplay(true); + } + else { + uiApp.setNodisplay(false); + } + } + } //TODO //There is no "X-TIZEN-PackageType=wgt" //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" << DPL::ToUTF8String(*widgetID).c_str() @@ -746,19 +763,138 @@ void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp) // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image; FOREACH(it, appServiceList) { - ApplicationService appService; + AppControl appControl; if (!it->m_operation.empty()) { - appService.addOperation(it->m_operation); //TODO: encapsulation? + appControl.addOperation(it->m_operation); //TODO: encapsulation? } if (!it->m_scheme.empty()) { - appService.addUri(it->m_scheme); + appControl.addUri(it->m_scheme); } if (!it->m_mime.empty()) { - appService.addMime(it->m_mime); + appControl.addMime(it->m_mime); + } + uiApp.addAppControl(appControl); + } +} + +void TaskManifestFile::setAppCategory(UiApplication &uiApp) +{ + WrtDB::ConfigParserData::CategoryList categoryList = + m_context.widgetConfig.configInfo.categoryList; + + if (categoryList.empty()) { + LogInfo("Widget doesn't contain application category"); + return; + } + FOREACH(it, categoryList) { + if (!(*it).empty()) { + uiApp.addAppCategory(*it); } - uiApp.addApplicationService(appService); } } +void TaskManifestFile::stepAbortParseManifest() +{ + LogError("[Parse Manifest] Abroting...."); + + int code = pkgmgr_parser_parse_manifest_for_uninstallation( + DPL::ToUTF8String(manifest_file).c_str(), NULL); + + if (0 != code) + { + LogWarning("Manifest parser error: " << code); + ThrowMsg(ManifestParsingError, "Parser returncode: " << code); + } + int ret = unlink(DPL::ToUTF8String(manifest_file).c_str()); + if (0 != ret) + { + LogWarning("No manifest file found: " << manifest_file); + } +} + +void TaskManifestFile::setLiveBoxInfo(Manifest& manifest) +{ + FOREACH(it, m_context.widgetConfig.configInfo.m_livebox) { + LogInfo("setLiveBoxInfo"); + LiveBoxInfo liveBox; + DPL::Optional ConfigInfo = *it; + DPL::String pkgname = *m_context.widgetConfig.pkgname; + size_t found; + + if(ConfigInfo->m_liveboxId != L"") { + found = ConfigInfo->m_liveboxId.find_first_of(L"."); + if(found != std::string::npos) { + if(0 == ConfigInfo->m_liveboxId.compare(0, found, pkgname)) + liveBox.setLiveboxId(ConfigInfo->m_liveboxId); + else { + DPL::String liveboxId = + pkgname+DPL::String(L".")+ConfigInfo->m_liveboxId; + liveBox.setLiveboxId(liveboxId); + } + } else { + DPL::String liveboxId = + pkgname+DPL::String(L".")+ConfigInfo->m_liveboxId; + liveBox.setLiveboxId(liveboxId); + } + } + + if(ConfigInfo->m_primary != L"") + liveBox.setPrimary(ConfigInfo->m_primary); + + if(ConfigInfo->m_autoLaunch == L"true") + liveBox.setAutoLaunch(pkgname); + + if(ConfigInfo->m_updatePeriod != L"") + liveBox.setUpdatePeriod(ConfigInfo->m_updatePeriod); + + if(ConfigInfo->m_label != L"") + liveBox.setLabel(ConfigInfo->m_label); + + DPL::String defaultLocale + = DPL::FromUTF8String(m_context.locations->getPackageInstallationDir()) + + DPL::String(L"/res/wgt/"); + + if(ConfigInfo->m_icon!=L"") { + liveBox.setIcon(defaultLocale+ConfigInfo->m_icon); + } + + if (ConfigInfo->m_boxInfo.m_boxSrc.empty() || ConfigInfo->m_boxInfo.m_boxSize.empty()) { + LogInfo("Widget doesn't contain box"); + return; + } else { + BoxInfoType box; + if (!ConfigInfo->m_boxInfo.m_boxSrc.empty()) { + if((0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 4, L"http")) + || (0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 5, L"https"))) + box.boxSrc = ConfigInfo->m_boxInfo.m_boxSrc; + else + box.boxSrc = defaultLocale + ConfigInfo->m_boxInfo.m_boxSrc; + } + + std::list> BoxSizeList + = ConfigInfo->m_boxInfo.m_boxSize; + FOREACH(im, BoxSizeList) { + std::pair boxSize = *im; + if(!boxSize.second.empty()) + boxSize.second = defaultLocale + boxSize.second; + box.boxSize.push_back(boxSize); + } + + if (!ConfigInfo->m_boxInfo.m_pdSrc.empty() + && !ConfigInfo->m_boxInfo.m_pdWidth.empty() + && !ConfigInfo->m_boxInfo.m_pdHeight.empty()) { + box.pdSrc = defaultLocale + ConfigInfo->m_boxInfo.m_pdSrc; + box.pdWidth = ConfigInfo->m_boxInfo.m_pdWidth; + box.pdHeight = ConfigInfo->m_boxInfo.m_pdHeight; + } + + liveBox.setBox(box); + } + + manifest.addLivebox(liveBox); + } + +} + } //namespace WidgetInstall } //namespace Jobs diff --git a/src/jobs/widget_install/task_manifest_file.h b/src/jobs/widget_install/task_manifest_file.h old mode 100644 new mode 100755 index 86edffe..191bc49 --- a/src/jobs/widget_install/task_manifest_file.h +++ b/src/jobs/widget_install/task_manifest_file.h @@ -68,6 +68,8 @@ class TaskManifestFile : void stepParseManifest(); void stepParseUpgradedManifest(); + void stepAbortParseManifest(); + //For widget update void stepBackupIconFiles(); void stepUpdateFinalize(); @@ -93,6 +95,8 @@ class TaskManifestFile : void setWidgetManifest(Manifest & manifest); void setWidgetOtherInfo(UiApplication & uiApp); void setAppServiceInfo(UiApplication & uiApp); + void setAppCategory(UiApplication & uiApp); + void setLiveBoxInfo(Manifest& manifest); void generateWidgetName(Manifest & manifest, UiApplication &uiApp, const DPL::OptionalString& tag, DPL::OptionalString name, bool & defaultNameSaved); void generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag, const DPL::String& language, bool & defaultIconSaved); diff --git a/src/jobs/widget_install/task_new_db_insert.cpp b/src/jobs/widget_install/task_new_db_insert.cpp deleted file mode 100644 index 38e9d92..0000000 --- a/src/jobs/widget_install/task_new_db_insert.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file task_new_db_insert.cpp - * @author Lukasz Wrzosek(l.wrzosek@samsung.com) - * @author Soyoung kim(sy037.kim@samsung.com) - * @version 1.0 - * @brief Implementation file for installer task database updating for widget update - */ -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include -#include -//#include -#include -#include - -using namespace WrtDB; - -namespace Jobs { -namespace WidgetInstall { -TaskNewDbInsert::TaskNewDbInsert(InstallerContext& context) : - DPL::TaskDecl(this), - m_context(context) -{ - AddStep(&TaskNewDbInsert::StepDBInsert); - - AddAbortStep(&TaskNewDbInsert::StepAbortDBInsert); -} - -void TaskNewDbInsert::StepDBInsert() -{ - Try - { - /* Set install Time */ - time(&m_context.widgetConfig.installedTime); - - LogInfo("Registering widget..."); - - WidgetDAO::registerWidget( - *(m_context.widgetHandle), - m_context.widgetConfig, - m_context.wacSecurity); - - FOREACH (cap, m_context.staticPermittedDevCaps) { - LogInfo("staticPermittedDevCaps : " << cap->first - << " smack status: " << cap->second); - } - - Assert(!!m_context.widgetConfig.pkgname - && "pkgName should be initialized"); - - WrtDB::WidgetDAO widgetDao(*m_context.widgetHandle); - widgetDao.setPkgName(m_context.widgetConfig.pkgname); - - LogInfo("Widget registered"); - } - Catch(WidgetDAO::Exception::DatabaseError) - { - LogWarning("Database failure!"); - ReThrowMsg(Exceptions::InsertNewWidgetFailed, "Database failure!"); - } - Catch(DPL::DB::SqlConnection::Exception::Base) - { - LogDebug("Database failure!"); - ReThrowMsg(Exceptions::InsertNewWidgetFailed, "Database failure!"); - } - - m_context.job->UpdateProgress( - InstallerContext::INSTALL_NEW_DB_INSERT, - "New Widget DB UPDATE Finished"); -} - -void TaskNewDbInsert::StepAbortDBInsert() -{ - LogWarning("[DB Update Task] Aborting... (DB Clean)"); - Assert(!!m_context.widgetHandle); - Try - { - WidgetDAO::unregisterWidget(*m_context.widgetHandle); - - LogDebug("Cleaning DB successful!"); - } - Catch(DPL::DB::SqlConnection::Exception::Base) - { - LogError("Failed to handle StepAbortDBClean!"); - } -} - -} //namespace WidgetInstall -} //namespace Jobs diff --git a/src/jobs/widget_install/task_new_db_insert.h b/src/jobs/widget_install/task_new_db_insert.h deleted file mode 100644 index 13290d4..0000000 --- a/src/jobs/widget_install/task_new_db_insert.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file task_new_db_insert.h - * @author Lukasz Wrzosek(l.wrzosek@samsung.com) - * @author Soyoung kim(sy037.kim@samsung.com) - * @version 1.0 - * @brief Header file for installer task database updating for widget update - */ -#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_NEW_DB_INSERT_H -#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_NEW_DB_INSERT_H - -#include - -class InstallerContext; - -namespace Jobs { -namespace WidgetInstall { -class TaskNewDbInsert: - public DPL::TaskDecl -{ - private: - InstallerContext& m_context; - - void StepDBInsert(); - - void StepAbortDBInsert(); - - public: - TaskNewDbInsert(InstallerContext& context); -}; -} //namespace WidgetInstall -} //namespace Jobs - -#endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_NEW_DB_INSERT_H diff --git a/src/jobs/widget_install/task_private_storage.cpp b/src/jobs/widget_install/task_private_storage.cpp deleted file mode 100644 index 8d9934f..0000000 --- a/src/jobs/widget_install/task_private_storage.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file installer_task_private_storage.cpp - * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com) - * @version 1.0 - * @brief Implementation file for installer task private storage. - */ -#include "task_private_storage.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#define WEBAPP_DEFAULT_UID 5000 -#define WEBAPP_DEFAULT_GID 5000 - -namespace { -const mode_t PRIVATE_STORAGE_MODE = 0700; -} - -namespace Jobs { -namespace WidgetInstall { -TaskPrivateStorage::TaskPrivateStorage(InstallerContext& context) : - DPL::TaskDecl(this), - m_context(context) -{ - AddStep(&TaskPrivateStorage::StepCreateDirectory); -} - -void TaskPrivateStorage::StepCreateDirectory() -{ - using namespace WrtDB; - - LogInfo("Step: Creating private storage directory."); - - m_context.installStep = - InstallerContext::INSTALL_CREATE_PRIVATE_STORAGE; - - std::ostringstream widgetPath; - DPL::OptionalString pkgname = m_context.widgetConfig.pkgname; - if(!pkgname.IsNull()) { - widgetPath << m_context.locations->getPackageInstallationDir() << "/"; - } else { - ThrowMsg(Exceptions::InternalError, "No Package name exists."); - } - - if (euidaccess(widgetPath.str().c_str(), W_OK | X_OK) != 0) { - ThrowMsg(Exceptions::InternalError, DPL::GetErrnoString()); - } - - std::ostringstream storagePath; - storagePath << widgetPath.str().c_str() - << GlobalConfig::GetWidgetPrivateStoragePath(); - - if (euidaccess(storagePath.str().c_str(), F_OK) != 0) { - if(!WrtUtilMakeDir(storagePath.str(), PRIVATE_STORAGE_MODE)){ - LogError("Failed to create directory for private storage"); - ThrowMsg(Exceptions::InternalError, - "Failed to create directory for private storage"); - } - // '5000' is default uid, gid for applications. - // So installed applications should be launched as process of uid '5000'. - // the process can access private directory 'data' of itself. - if(chown(storagePath.str().c_str(), - WEBAPP_DEFAULT_UID, - WEBAPP_DEFAULT_GID) != 0) - { - ThrowMsg(Exceptions::InternalError, - "Chown to invaild user"); - } - } else if (euidaccess(storagePath.str().c_str(), W_OK | R_OK | X_OK) == 0) { - LogInfo("Private storage already exists."); - // Even if private directory already is created, private dircetory - // should change owner. - if(chown(storagePath.str().c_str(), - WEBAPP_DEFAULT_UID, - WEBAPP_DEFAULT_GID) != 0) - { - ThrowMsg(Exceptions::InternalError, - "Chown to invaild user"); - } - if(chmod(storagePath.str().c_str(), PRIVATE_STORAGE_MODE) != 0) { - ThrowMsg(Exceptions::InternalError, - "chmod to 0700"); - } - - } else { - ThrowMsg(Exceptions::InternalError, - "No access to private storage."); - } - - m_context.job->UpdateProgress( - InstallerContext::INSTALL_CREATE_PRIVATE_STORAGE, - "Private storage created." - ); -} -} //namespace WidgetInstall -} //namespace Jobs diff --git a/src/jobs/widget_install/task_recovery.cpp b/src/jobs/widget_install/task_recovery.cpp index 1b922db..bd844ae 100644 --- a/src/jobs/widget_install/task_recovery.cpp +++ b/src/jobs/widget_install/task_recovery.cpp @@ -72,10 +72,6 @@ void TaskRecovery::StepCreateCheckFile() m_context.installInfo = infoPath.str(); LogDebug("Create file : " << m_context.installInfo); - m_context.job->UpdateProgress( - InstallerContext::INSTALL_LINK_DEPENDS_DIRECTORY, - "depends directory linked." - ); } else { ThrowMsg(Exceptions::InternalError, "Fail to create file for recovery."); } diff --git a/src/jobs/widget_install/task_unzip.cpp b/src/jobs/widget_install/task_unzip.cpp index b19bc19..fb084f6 100644 --- a/src/jobs/widget_install/task_unzip.cpp +++ b/src/jobs/widget_install/task_unzip.cpp @@ -116,6 +116,10 @@ void TaskUnzip::StepUnzipPrepare() { ReThrowMsg(Exceptions::OpenZipFailed, m_installerContext.locations->getWidgetSource()); } + Catch(DPL::ZipInput::Exception::SeekFileFailed) + { + ThrowMsg(Exceptions::ExtractFileFailed,"m_installerContext.locations->getWidgetSource()"); + } } void TaskUnzip::StepUnzipProgress() diff --git a/src/jobs/widget_install/task_widget_config.cpp b/src/jobs/widget_install/task_widget_config.cpp index 8423144..bf5301a 100644 --- a/src/jobs/widget_install/task_widget_config.cpp +++ b/src/jobs/widget_install/task_widget_config.cpp @@ -80,13 +80,14 @@ TaskWidgetConfig::TaskWidgetConfig(InstallerContext& installContext) : AddStep(&TaskWidgetConfig::ProcessLocalizedStartFiles); AddStep(&TaskWidgetConfig::ProcessBackgroundPageFile); AddStep(&TaskWidgetConfig::ProcessLocalizedIcons); + AddStep(&TaskWidgetConfig::ProcessWidgetInstalledPath); AddStep(&TaskWidgetConfig::StepVerifyFeatures); + AddStep(&TaskWidgetConfig::StepCheckMinVersionInfo); if (!GlobalSettings::TestModeEnabled() && !m_installContext.m_quiet) { AddStep(&TaskWidgetConfig::StepCancelWidgetInstallationAfterVerifyFeatures); AddStep(&TaskWidgetConfig::StepShowWidgetInfo); AddStep(&TaskWidgetConfig::StepCancelWidgetInstallation); - AddStep(&TaskWidgetConfig::StepCheckMinVersionInfo); AddStep(&TaskWidgetConfig::StepCancelWidgetInstallationAfterMinVersion); AddStep(&TaskWidgetConfig::StepDeletePopupWin); } @@ -261,9 +262,9 @@ void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path, if (m_installContext.widgetConfig.webAppType == APP_TYPE_TIZENWEBAPP) { - const char *startPath = - DPL::ToUTF8String(startFileData.path).c_str(); - if (strstr(startPath, "http") == startPath) { + std::string startPath = DPL::ToUTF8String(startFileData.path); + + if (strstr(startPath.c_str(), "http") == startPath.c_str()) { WidgetRegisterInfo::StartFileProperties startFileProperties; if (!!type) { @@ -363,6 +364,13 @@ void TaskWidgetConfig::ProcessIcon(const WrtDB::ConfigParserData::Icon& icon) } } +void TaskWidgetConfig::ProcessWidgetInstalledPath() +{ + LogDebug("ProcessWidgetInstalledPath"); + m_installContext.widgetConfig.widgetInstalledPath = + DPL::FromUTF8String(m_installContext.locations->getPackageInstallationDir()); +} + void TaskWidgetConfig::StepCancelWidgetInstallationAfterVerifyFeatures() { LogDebug("StepCancelWidgetInstallationAfterVerifyFeatures"); @@ -426,8 +434,18 @@ void TaskWidgetConfig::StepCheckMinVersionInfo() if (!isMinVersionCompatible( m_installContext.widgetConfig.webAppType.appType, m_installContext.widgetConfig.minVersion)) { - std::string label = WIDGET_NOT_COMPATIBLE + QUESTION; - createInstallPopup(PopupType::WIDGET_MIN_VERSION, label); + if(!GlobalSettings::TestModeEnabled() && !m_installContext.m_quiet) + { + LogDebug("Platform version to low - launching"); + std::string label = WIDGET_NOT_COMPATIBLE + QUESTION; + createInstallPopup(PopupType::WIDGET_MIN_VERSION, label); + } + else + { + LogError("Platform version lower than required -> cancelling installation"); + ThrowMsg(Exceptions::NotAllowed, + "Platform version does not meet requirements"); + } } m_installContext.job->UpdateProgress( @@ -550,7 +568,9 @@ bool TaskWidgetConfig::isFeatureAllowed(WrtDB::AppType appType, LogInfo("FetureName = [" << featureName << "]"); AppType featureType = APP_TYPE_UNKNOWN; - const char* feature = DPL::ToUTF8String(featureName).c_str(); + std::string featureStr = DPL::ToUTF8String(featureName); + const char* feature = featureStr.c_str(); + // check prefix of feature name if (strstr(feature, PluginsPrefix::TIZENPluginsPrefix) == feature) { // Tizen WebApp feature @@ -629,13 +649,15 @@ bool TaskWidgetConfig::isMinVersionCompatible(WrtDB::AppType appType, if (!parseVersionString(version, majorSupported, minorSupported, microSupported)) { - LogWarning("Invalid format of WAC version string."); + LogWarning("Invalid format of platform version string."); return true; } if (majorWidget > majorSupported || - minorWidget > minorSupported || - microWidget > microSupported) { + (majorWidget == majorSupported && minorWidget > minorSupported) || + (majorWidget == majorSupported && minorWidget == minorSupported + && microWidget > microSupported)) + { LogInfo("Platform doesn't support this widget."); return false; } diff --git a/src/jobs/widget_install/task_widget_config.h b/src/jobs/widget_install/task_widget_config.h index 740af5f..2b0b7dc 100755 --- a/src/jobs/widget_install/task_widget_config.h +++ b/src/jobs/widget_install/task_widget_config.h @@ -78,6 +78,7 @@ class TaskWidgetConfig : void ProcessBackgroundPageFile(); void ProcessLocalizedIcons(); void ProcessIcon(const WrtDB::ConfigParserData::Icon& icon); + void ProcessWidgetInstalledPath(); void StepVerifyFeatures(); void StepShowWidgetInfo(); void StepCheckMinVersionInfo(); diff --git a/src/jobs/widget_install/wac_security.cpp b/src/jobs/widget_install/wac_security.cpp index 4f81120..6dafd02 100644 --- a/src/jobs/widget_install/wac_security.cpp +++ b/src/jobs/widget_install/wac_security.cpp @@ -27,13 +27,6 @@ namespace Jobs { namespace WidgetInstall { void WacSecurity::getCertificateChainList( - WrtDB::CertificateChainList& list) const -{ - FOREACH(certIter, mCertificateChainList) - list.push_back(certIter->toBase64String()); -} - -void WacSecurity::getCertificateChainList( WrtDB::CertificateChainList& list, WrtDB::CertificateSource source) const { diff --git a/src/jobs/widget_install/wac_security.h b/src/jobs/widget_install/wac_security.h index e899ad8..a2095da 100644 --- a/src/jobs/widget_install/wac_security.h +++ b/src/jobs/widget_install/wac_security.h @@ -53,9 +53,6 @@ class WacSecurity : public WrtDB::IWacSecurity virtual bool isWacSigned() const { return mWacSigned; } virtual void getCertificateChainList( - WrtDB::CertificateChainList& list) const; - - virtual void getCertificateChainList( WrtDB::CertificateChainList& list, WrtDB::CertificateSource source) const; diff --git a/src/jobs/widget_install/widget_install_context.h b/src/jobs/widget_install/widget_install_context.h index 4fa010b..284cc1b 100755 --- a/src/jobs/widget_install/widget_install_context.h +++ b/src/jobs/widget_install/widget_install_context.h @@ -65,8 +65,6 @@ struct InstallerContext INSTALL_BACKUP_EXEC, /* For Update */ INSTALL_NEW_DB_INSERT, /* For Update */ - INSTALL_CREATE_PRIVATE_STORAGE, - INSTALL_LINK_DEPENDS_DIRECTORY, INSTALL_ACE_PREPARE, INSTALL_ACE_CHECK, INSTALL_SMACK_ENABLE, @@ -104,6 +102,7 @@ struct InstallerContext RequestedDevCapsMap staticPermittedDevCaps; std::string installInfo; /// bool m_quiet; + InstallLocationType locationType; }; #endif // INSTALLER_CONTEXT_H diff --git a/src/jobs/widget_install/widget_install_errors.h b/src/jobs/widget_install/widget_install_errors.h index 78480c2..109caff 100644 --- a/src/jobs/widget_install/widget_install_errors.h +++ b/src/jobs/widget_install/widget_install_errors.h @@ -47,8 +47,10 @@ enum Type ErrorDeferred, ///< Widget installation was deferred and will be continued when possible ErrorDatabaseFailure, ///< Failure in database ErrorRemovingFolderFailure, ///< Failure in removing existing widget folder + ErrorCreateVconfFailure, ///< Failure in creating vconf ErrorInstallOspServcie, ///< Failure in installing osp service ErrorUpdateWidget, ///< Failure in widget update. + ErrorInstallToExt, ///< Failure in install to sdcard ErrorUnknown ///< Temporary error. Try to not use this. }; @@ -80,9 +82,12 @@ DECLARE_JOB_EXCEPTION(Base, AlreadyInstalled, ErrorAlreadyInstalled) DECLARE_JOB_EXCEPTION(Base, UnknownError, ErrorUnknown) DECLARE_JOB_EXCEPTION(Base, DatabaseFailure, ErrorDatabaseFailure) DECLARE_JOB_EXCEPTION(Base, RemovingFolderFailure, ErrorRemovingFolderFailure) +DECLARE_JOB_EXCEPTION(Base, CreateVconfFailure, ErrorCreateVconfFailure) DECLARE_JOB_EXCEPTION(Base, CopyIconFailed, ErrorUnknown) +DECLARE_JOB_EXCEPTION(Base, ErrorExternalInstallingFailure, ErrorInstallToExt) + // Installation osp service DECLARE_JOB_EXCEPTION(Base, RequestInstallOspsvc, ErrorInstallOspServcie) DECLARE_JOB_EXCEPTION(Base, InstallOspsvcFailed, ErrorInstallOspServcie) diff --git a/src/jobs/widget_install/widget_installer_struct.h b/src/jobs/widget_install/widget_installer_struct.h index 2c7e3c8..2a655c8 100755 --- a/src/jobs/widget_install/widget_installer_struct.h +++ b/src/jobs/widget_install/widget_installer_struct.h @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include //Widget Installer typedefs @@ -71,7 +73,8 @@ enum Type ExistingVersionEqual | ExistingVersionNewer, - PolicyForceInstall = PolicyAlwaysInstall + PolicyForceInstall = PolicyAlwaysInstall, + PolicyDirectoryForceInstall }; inline Type operator | (const Type &a, @@ -100,10 +103,13 @@ struct WidgetInstallationStruct : public WidgetInstallCallbackBase { WidgetUpdateMode::Type updateMode; bool m_quiet; + bool m_preload; + std::shared_ptr pkgmgrInterface; // It must be empty-constructible as a parameter of generic event WidgetInstallationStruct() : updateMode(WidgetUpdateMode::Zero), - m_quiet(true) + m_quiet(true), + m_preload(false) { } @@ -111,10 +117,15 @@ struct WidgetInstallationStruct : public WidgetInstallCallbackBase InstallerProgressCallback progress, void *param, WidgetUpdateMode::Type mode, - bool quiet) : + bool quiet, + bool preload, + std::shared_ptr _pkgmgrInterface + ) : WidgetInstallCallbackBase(finished, progress, param), updateMode(mode), - m_quiet(quiet) + m_quiet(quiet), + m_preload(preload), + pkgmgrInterface(_pkgmgrInterface) { } }; diff --git a/src/jobs/widget_install/widget_unzip.cpp b/src/jobs/widget_install/widget_unzip.cpp deleted file mode 100644 index b8d0b98..0000000 --- a/src/jobs/widget_install/widget_unzip.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file widget_unzip.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief Implementation file for installer task unzip - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace WrtDB; - -namespace { -struct PathAndFilePair -{ - std::string path; - std::string file; - - PathAndFilePair(const std::string &p, - const std::string &f) : - path(p), - file(f) - { - } -}; - -PathAndFilePair SplitFileAndPath(const std::string &filePath) -{ - std::string::size_type position = filePath.rfind('/'); - - // Is this only a file without a path ? - if (position == std::string::npos) { - return PathAndFilePair(std::string(), filePath); - } - - // This is full file-path pair - return PathAndFilePair(filePath.substr(0, - position), - filePath.substr(position + 1)); -} -} - -namespace Jobs { -namespace WidgetInstall { -WidgetUnzip::WidgetUnzip(std::string source, std::string path) : - m_source(source), - m_destPath(path) -{ - LogDebug("WidgetUnzip"); -} - -void WidgetUnzip::ExtractFile(DPL::ZipInput::File *input, - const std::string &destFileName) -{ - Try - { - DPL::AbstractWaitableInputAdapter inputAdapter(input); - DPL::FileOutput output(destFileName); - - DPL::Copy(&inputAdapter, &output); - } - Catch(DPL::FileOutput::Exception::OpenFailed) - { - ReThrowMsg(Exceptions::ExtractFileFailed, destFileName); - } - Catch(DPL::CopyFailed) - { - ReThrowMsg(Exceptions::ExtractFileFailed, destFileName); - } -} - -void WidgetUnzip::UnzipWidget() -{ - UnzipPrepare(); - UnzipProgress(); -} - -void WidgetUnzip::UnzipPrepare() -{ - LogInfo("Prepare to unzip..."); - - Try - { - m_zip.reset(new DPL::ZipInput(m_source)); - LogInfo("Widget package comment: " << m_zip->GetGlobalComment()); - - // Widget package must not be empty - if (m_zip->empty()) { - ThrowMsg(Exceptions::ZipEmpty, m_source); - } - - // Set iterator to first file - m_zipIterator = m_zip->begin(); - } - Catch(DPL::ZipInput::Exception::OpenFailed) - { - ReThrowMsg(Exceptions::OpenZipFailed, m_source); - } -} - -void WidgetUnzip::UnzipProgress() -{ - - // Show file info - LogInfo("Unzipping: '" << m_zipIterator->name << - "', Comment: '" << m_zipIterator->comment << - "', Compressed size: " << m_zipIterator->compressedSize << - ", Uncompressed size: " << m_zipIterator->uncompressedSize); - - - // Normalize file paths - // FIXME: Implement checking for invalid characters - - // Extract file or path - std::string fileName = m_zipIterator->name; - - if (fileName[fileName.size() - 1] == '/') { - // This is path - std::string newPath = m_destPath + "/" + - fileName.substr(0, fileName.size() - 1); - LogPedantic("Path to extract: " << newPath); - - // Create path in case of it is empty - createTempPath(newPath); - } else { - // This is regular file - std::string fileExtractPath = m_destPath + "/" + fileName; - - LogPedantic("File to extract: " << fileExtractPath); - - // Split into pat & file pair - PathAndFilePair pathAndFile = SplitFileAndPath(fileExtractPath); - - LogPedantic("Path and file: " << - pathAndFile.path << - " : " << pathAndFile.file); - - // First, ensure that path exists - createTempPath(pathAndFile.path); - - Try - { - // Open file - std::unique_ptr file( - m_zip->OpenFile(fileName)); - - // Extract single file - ExtractFile(file.get(), fileExtractPath); - } - Catch(DPL::ZipInput::Exception::OpenFileFailed) - { - ThrowMsg(Exceptions::ExtractFileFailed, fileName); - } - } - - // Check whether there are more files to extract - if (++m_zipIterator == m_zip->end()) { - LogInfo("Unzip progress finished successfuly"); - m_zip.reset(); - } else { - UnzipProgress(); - } -} - -void WidgetUnzip::UnzipDRMWidget() -{ - LogDebug("Decrypt drm widget"); - drm_trusted_sapps_decrypt_package_info_s package_info; - - strncpy(package_info.sadcf_filepath, m_source.c_str(), - sizeof(package_info.sadcf_filepath)); - strncpy(package_info.decrypt_filepath, m_destPath.c_str(), - sizeof(package_info.decrypt_filepath)); - - drm_trusted_request_type_e requestType = - DRM_TRUSTED_REQ_TYPE_SAPPS_DECRYPT_PACKAGE; - - int ret = drm_trusted_handle_request(requestType, - (void *)&package_info, NULL); - if (DRM_TRUSTED_RETURN_SUCCESS != ret) { - LogDebug("Failed unzip drm widget"); - ThrowMsg(Exceptions::ExtractFileFailed, m_destPath); - } -} -} //namespace WidgetInstall -} //namespace Jobs diff --git a/src/jobs/widget_install/widget_unzip.h b/src/jobs/widget_install/widget_unzip.h deleted file mode 100644 index 7c7b4ca..0000000 --- a/src/jobs/widget_install/widget_unzip.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @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_WIDGET_UNZIP_H -#define INSTALLER_CORE_JOS_WIDGET_INSTALL_WIDGET_UNZIP_H - -#include -#include - -#include - -class InstallerContext; - -namespace Jobs { -namespace WidgetInstall { -class WidgetUnzip -{ - private: - // Installation context - std::string m_source; - std::string m_destPath; - - // Unzip state - std::unique_ptr m_zip; - DPL::ZipInput::const_iterator m_zipIterator; - - void ExtractFile(DPL::ZipInput::File *input, - const std::string &destFileName); - - void UnzipPrepare(); - void UnzipProgress(); - - public: - WidgetUnzip(std::string m_source, std::string m_destPath); - void UnzipWidget(); - void UnzipDRMWidget(); -}; -} //namespace WidgetInstall -} //namespace Jobs - -#endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_WIDGET_UNZIP_H diff --git a/src/jobs/widget_uninstall/job_widget_uninstall.cpp b/src/jobs/widget_uninstall/job_widget_uninstall.cpp index 392106f..e6153ff 100644 --- a/src/jobs/widget_uninstall/job_widget_uninstall.cpp +++ b/src/jobs/widget_uninstall/job_widget_uninstall.cpp @@ -23,6 +23,7 @@ #include #include #include +#include using namespace WrtDB; @@ -66,6 +67,7 @@ JobWidgetUninstall::JobWidgetUninstall(const std::string & widgetPkgName, m_context.uninstallStep = UninstallerContext::UNINSTALL_START; m_context.job = this; m_context.pkgname = widgetPkgName; + m_context.isExternalWidget = getExternalWidgetFlag(); Try { @@ -85,8 +87,8 @@ JobWidgetUninstall::JobWidgetUninstall(const std::string & widgetPkgName, AddTask(new TaskDeleteCertificates(m_context)); // send start signal of pkgmgr - if (PkgmgrSignalSingleton::Instance().setPkgname(m_context.pkgname)) { - PkgmgrSignalSingleton::Instance().sendSignal( + if (getInstallerStruct().pkgmgrInterface->setPkgname(m_context.pkgname)) { + getInstallerStruct().pkgmgrInterface->sendSignal( PKGMGR_START_KEY, PKGMGR_START_UNINSTALL); } @@ -121,7 +123,7 @@ void JobWidgetUninstall::SendProgress() // send progress signal of pkgmgr std::ostringstream percent; percent << static_cast(GetProgressPercent()); - PkgmgrSignalSingleton::Instance().sendSignal( + getInstallerStruct().pkgmgrInterface->sendSignal( PKGMGR_PROGRESS_KEY, percent.str()); @@ -137,7 +139,7 @@ void JobWidgetUninstall::SendFinishedSuccess() { using namespace PackageManager; // send signal of pkgmgr - PkgmgrSignalSingleton::Instance().sendSignal( + getInstallerStruct().pkgmgrInterface->sendSignal( PKGMGR_END_KEY, PKGMGR_END_SUCCESS); @@ -153,7 +155,7 @@ void JobWidgetUninstall::SendFinishedFailure() LogError("Message: " << m_exceptionMessage); // send signal of pkgmgr - PkgmgrSignalSingleton::Instance().sendSignal( + getInstallerStruct().pkgmgrInterface->sendSignal( PKGMGR_END_KEY, PKGMGR_END_FAILURE); @@ -168,5 +170,17 @@ void JobWidgetUninstall::SaveExceptionData(const Jobs::JobExceptionBase &e) m_exceptionCaught = static_cast(e.getParam()); m_exceptionMessage = e.GetMessage(); } + +bool JobWidgetUninstall::getExternalWidgetFlag() const +{ + + LogDebug("Get external widget"); + if (APP2EXT_SD_CARD == app2ext_get_app_location(m_context.pkgname.c_str())) { + LogDebug("This widget is in external stroage"); + return true; + } + return false; +} + } //namespace WidgetUninstall } //namespace Jobs diff --git a/src/jobs/widget_uninstall/job_widget_uninstall.h b/src/jobs/widget_uninstall/job_widget_uninstall.h index 98cd62c..80c188c 100644 --- a/src/jobs/widget_uninstall/job_widget_uninstall.h +++ b/src/jobs/widget_uninstall/job_widget_uninstall.h @@ -55,6 +55,7 @@ class JobWidgetUninstall : std::string getRemovedTizenId() const; bool getRemoveStartedFlag() const; bool getRemoveFinishedFlag() const; + bool getExternalWidgetFlag() const; void SendProgress(); void SendFinishedSuccess(); diff --git a/src/jobs/widget_uninstall/task_db_update.cpp b/src/jobs/widget_uninstall/task_db_update.cpp index b18feb0..d3f2c93 100644 --- a/src/jobs/widget_uninstall/task_db_update.cpp +++ b/src/jobs/widget_uninstall/task_db_update.cpp @@ -23,8 +23,11 @@ #include #include #include +#include +#include #include +#include using namespace WrtDB; @@ -45,6 +48,9 @@ void TaskDbUpdate::StepDbUpdate() { Try { + //TODO: widget handle should not be used any more + ace_unregister_widget(static_cast( + WidgetDAOReadOnly::getHandle(m_context.locations->getPkgname()))); WidgetDAO::unregisterWidget(m_context.locations->getPkgname()); LogDebug("Unregistered widget successfully!"); diff --git a/src/jobs/widget_uninstall/task_remove_files.cpp b/src/jobs/widget_uninstall/task_remove_files.cpp index 2dfe92e..d7c3157 100644 --- a/src/jobs/widget_uninstall/task_remove_files.cpp +++ b/src/jobs/widget_uninstall/task_remove_files.cpp @@ -25,24 +25,38 @@ #include #include #include +#include #include #include #include #include +#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) { - AddStep(&TaskRemoveFiles::StepRemoveInstallationDirectory); + if (!m_context.isExternalWidget) { + AddStep(&TaskRemoveFiles::StepRemoveInstallationDirectory); + } else { + AddStep(&TaskRemoveFiles::StepRemoveExternalWidget); + } //AddStep(&TaskRemoveFiles::StepRemoveDesktop); AddStep(&TaskRemoveFiles::StepRemoveManifest); AddStep(&TaskRemoveFiles::StepRemoveExternalLocations); + AddStep(&TaskRemoveFiles::StepRemoveVconf); AddStep(&TaskRemoveFiles::StepRemoveFinished); } @@ -60,6 +74,10 @@ void TaskRemoveFiles::StepRemoveInstallationDirectory() if(!WrtUtilRemove(widgetDir)){ LogWarning("Removing widget installation directory failed"); } + std::string dataDir = m_context.locations->getUserDataRootDir(); + if(!WrtUtilRemove(dataDir)){ + LogWarning(dataDir + " is already removed"); + } m_context.job->UpdateProgress( UninstallerContext::UNINSTALL_REMOVE_WIDGETDIR, "Widget INstallation Directory Removal Finished"); @@ -138,7 +156,10 @@ void TaskRemoveFiles::StepRemoveExternalLocations() if(WrtUtilFileExists(*path)) { LogDebug(" -> " << *path); - remove(path->c_str()); + int ret = remove(path->c_str()); + if (ret != 0) { + LogError("Failed to remove the file: " << path->c_str() << " with error: " << strerror(errno)); + } } else if(WrtUtilDirExists(*path)) { @@ -155,5 +176,30 @@ void TaskRemoveFiles::StepRemoveExternalLocations() dao.unregisterAllExternalLocations(); } +void TaskRemoveFiles::StepRemoveVconf() +{ + std::string key = + WrtDB::VconfConfig::GetVconfKeyRootPath( + m_context.locations->getPkgname()); + if(vconf_unset_recursive(key.c_str())) { + LogError("Fail to unset vconf file"); + } else { + LogDebug("vconf file is removed"); + } +} + +void TaskRemoveFiles::StepRemoveExternalWidget() +{ + Try { + WidgetInstallToExtSingleton::Instance().initialize(m_context.pkgname); + WidgetInstallToExtSingleton::Instance().uninstallation(); + WidgetInstallToExtSingleton::Instance().deinitialize(); + } + Catch (WidgetInstallToExt::Exception::ErrorInstallToExt) + { + Throw(Jobs::WidgetUninstall::TaskRemoveFiles::Exception::RemoveFilesFailed); + } +} + } //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 6959242..0336443 100644 --- a/src/jobs/widget_uninstall/task_remove_files.h +++ b/src/jobs/widget_uninstall/task_remove_files.h @@ -51,6 +51,8 @@ class TaskRemoveFiles : void StepRemoveDesktop(); void StepRemoveManifest(); void StepRemoveExternalLocations(); + void StepRemoveVconf(); + void StepRemoveExternalWidget(); public: explicit TaskRemoveFiles(UninstallerContext& context); diff --git a/src/jobs/widget_uninstall/uninstaller_context.h b/src/jobs/widget_uninstall/uninstaller_context.h index 1aeb086..caedcb7 100644 --- a/src/jobs/widget_uninstall/uninstaller_context.h +++ b/src/jobs/widget_uninstall/uninstaller_context.h @@ -60,6 +60,7 @@ struct UninstallerContext UninstallStep uninstallStep; ///< current step of installation Jobs::WidgetUninstall::JobWidgetUninstall *job; std::string pkgname; + bool isExternalWidget; }; #endif // WRT_SRC_INSTALLER_CORE_UNINSTALLER_TASKS_UNINSTALLER_CONTEXT_H_ diff --git a/src/jobs/widget_uninstall/widget_uninstaller_struct.h b/src/jobs/widget_uninstall/widget_uninstaller_struct.h index 4388164..ce2d4cc 100644 --- a/src/jobs/widget_uninstall/widget_uninstaller_struct.h +++ b/src/jobs/widget_uninstall/widget_uninstaller_struct.h @@ -29,6 +29,8 @@ #include #include #include +#include +#include //Widget Uninstaller typedefs typedef void (*UninstallerFinishedCallback)( @@ -44,6 +46,26 @@ typedef void (*UninstallerProgressCallback)( //UninstallationStruct typedef Jobs::JobCallbacksBase -WidgetUninstallationStruct; +WidgetUninstallCallbackBase; + +struct WidgetUninstallationStruct : public WidgetUninstallCallbackBase +{ + std::shared_ptr pkgmgrInterface; + + // It must be empty-constructible as a parameter of generic event + WidgetUninstallationStruct() + { + } + + WidgetUninstallationStruct(UninstallerFinishedCallback finished, + UninstallerProgressCallback progress, + void *param, + std::shared_ptr _pkgmgrInterface + ) : + WidgetUninstallCallbackBase(finished, progress, param), + pkgmgrInterface(_pkgmgrInterface) + { + } +}; #endif // WRT_SRC_INSTALLER_CORE_UNINSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_ diff --git a/src/logic/installer_controller.h b/src/logic/installer_controller.h index 938e7ee..55c68fe 100644 --- a/src/logic/installer_controller.h +++ b/src/logic/installer_controller.h @@ -52,7 +52,7 @@ DECLARE_GENERIC_EVENT_2(InstallPluginEvent, std::string, PluginInstallerStruct) /** * @brief Event for inicietig widget uninstallation. * - * WidgetHandler is used to point witch widget shuld be uninstalled + * tizen id is used to point witch widget shuld be uninstalled */ DECLARE_GENERIC_EVENT_2(UninstallWidgetEvent, std::string, diff --git a/src/misc/widget_install_to_external.cpp b/src/misc/widget_install_to_external.cpp new file mode 100644 index 0000000..3751d60 --- /dev/null +++ b/src/misc/widget_install_to_external.cpp @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * @file widget_install_to_external.cpp + * @author Soyoung Kim (sy037.kim@smasung.com) + */ +#include "widget_install_to_external.h" + +#include +#include +#include + +IMPLEMENT_SAFE_SINGLETON(WidgetInstallToExt) + +WidgetInstallToExt::WidgetInstallToExt() : + m_handle(NULL), + m_appId("") +{ +} + +WidgetInstallToExt::~WidgetInstallToExt() +{ +} + +void WidgetInstallToExt::initialize(std::string appId) +{ + LogDebug("WidgetInstallToExt::initialize()"); + m_appId = appId; + + m_handle = app2ext_init(APP2EXT_SD_CARD); + if (NULL == m_handle) { + ThrowMsg(Exception::ErrorInstallToExt, "initialize failed"); + } +} + +void WidgetInstallToExt::deinitialize() +{ + LogDebug("WidgetInstallToExt::deinitialize()"); + if (NULL != m_handle) { + if ( 0 < app2ext_deinit(m_handle)) { + ThrowMsg(Exception::ErrorInstallToExt, "app2ext deinitialize \ + failed"); + } + } +} + +void WidgetInstallToExt::preInstallation(GList *dirList, int dSize) +{ + LogDebug("WidgetInstallToExt::preInstallation()"); + Assert(m_handle); + + int ret = m_handle->interface.pre_install(m_appId.c_str(), dirList, dSize); + + if (APP2EXT_SUCCESS == ret ) { + LogDebug("App2Ext pre install success"); + } else { + postInstallation(false); + ThrowMsg(Exception::ErrorInstallToExt, "pre-install failed"); + } +} + +void WidgetInstallToExt::postInstallation(bool status) +{ + LogDebug("WidgetInstallToExt::postInstallation()"); + Assert(m_handle); + + if (status) { + m_handle->interface.post_install(m_appId.c_str(), + APP2EXT_STATUS_SUCCESS); + } else { + m_handle->interface.post_install(m_appId.c_str(), + APP2EXT_STATUS_FAILED); + } +} + +void WidgetInstallToExt::preUpgrade(GList *dirList, int dSize) +{ + LogDebug("WidgetInstallToExt::preUpgrade()"); + Assert(m_handle); + + int ret = m_handle->interface.pre_upgrade(m_appId.c_str(), dirList, dSize); + if (APP2EXT_SUCCESS == ret ) { + LogDebug("App2Ext pre-upgrade success"); + } else { + postUpgrade(false); + ThrowMsg(Exception::ErrorInstallToExt, "pre-upgrade failed"); + } +} + +void WidgetInstallToExt::postUpgrade(bool status) +{ + LogDebug("WidgetInstallToExt::postUpgrade()"); + Assert(m_handle); + + if (status) { + m_handle->interface.post_upgrade(m_appId.c_str(), + APP2EXT_STATUS_SUCCESS); + } else { + m_handle->interface.post_upgrade(m_appId.c_str(), + APP2EXT_STATUS_FAILED); + } +} + +void WidgetInstallToExt::uninstallation() +{ + LogDebug("WidgetInstallToExt::uninstallation()"); + + Assert(m_handle); + + int ret = m_handle->interface.pre_uninstall(m_appId.c_str()); + if (APP2EXT_SUCCESS == ret ) { + if (APP2EXT_SUCCESS == + m_handle->interface.post_uninstall(m_appId.c_str())) { + LogDebug("App2Ext pre-uninstall success"); + } else { + ThrowMsg(Exception::ErrorInstallToExt, "post-uninstall failed"); + } + } else { + ThrowMsg(Exception::ErrorInstallToExt, "pre-uninstall failed"); + } +} diff --git a/src/misc/widget_install_to_external.h b/src/misc/widget_install_to_external.h new file mode 100644 index 0000000..9f71906 --- /dev/null +++ b/src/misc/widget_install_to_external.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * @file widget_install_to_external.h + * @author Soyoung Kim (sy037.kim@smasung.com) + */ +#ifndef WRT_INSTALLER_SRC_MISC_WIDGET_INSTALL_TO_EXTERNAL_H +#define WRT_INSTALLER_SRC_MISC_WIDGET_INSTALL_TO_EXTERNAL_H + +#include +#include +#include +#include + + +class WidgetInstallToExt +{ +public: + class Exception + { + public: + DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) + DECLARE_EXCEPTION_TYPE(Base, ErrorInstallToExt) + }; + + void initialize(std::string appId); + void deinitialize(); + void preInstallation(GList* dirList, int dSize); + void postInstallation(bool status); + void preUpgrade(GList* dirList, int dSize); + void postUpgrade(bool status); + void uninstallation(); + +private: + app2ext_handle *m_handle; + std::string m_appId; + + WidgetInstallToExt(); + ~WidgetInstallToExt(); + + friend class DPL::Singleton; +}; + +typedef DPL::Singleton WidgetInstallToExtSingleton; + +#endif // WRT_INSTALLER_SRC_MISC_WIDGET_INSTALL_TO_EXTERNAL_H diff --git a/src/misc/widget_location.cpp b/src/misc/widget_location.cpp index b899bec..35a8026 100644 --- a/src/misc/widget_location.cpp +++ b/src/misc/widget_location.cpp @@ -42,7 +42,9 @@ WidgetLocation::DirectoryDeletor::DirectoryDeletor(std::string tempPath) WidgetLocation::DirectoryDeletor::~DirectoryDeletor() { LogDebug("Removing widget installation temporary directory: " << m_dirpath.c_str()); - WrtUtilRemove(m_dirpath); + if(!WrtUtilRemove(m_dirpath)){ + LogError("Fail at removing directory: " << m_dirpath.c_str()); + } } std::string WidgetLocation::DirectoryDeletor::getTempPath() const @@ -65,47 +67,58 @@ WidgetLocation::~WidgetLocation() WidgetLocation::WidgetLocation(const std::string & widgetname, std::string sourcePath, - WrtDB::PackagingType t): + WrtDB::PackagingType t, + InstallLocationType locationType): m_pkgname(widgetname), m_widgetSource(sourcePath), m_type(t), m_temp(new WidgetLocation::DirectoryDeletor()) { + if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) { + m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath(); + } else { + m_installedPath += WrtDB::GlobalConfig::GetUserInstalledWidgetPath(); + } } WidgetLocation::WidgetLocation(const std::string & widgetname, std::string sourcePath, std::string dirPath, - WrtDB::PackagingType t): + WrtDB::PackagingType t, + InstallLocationType locationType): m_pkgname(widgetname), m_widgetSource(sourcePath), m_type(t), m_temp(new WidgetLocation::DirectoryDeletor(dirPath)) { + if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) { + m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath(); + } else { + m_installedPath += WrtDB::GlobalConfig::GetUserInstalledWidgetPath(); + } } // TODO cache all these paths std::string WidgetLocation::getInstallationDir() const { - return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()); + return m_installedPath; } std::string WidgetLocation::getPackageInstallationDir() const { - return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/" - + m_pkgname; + return m_installedPath + "/" + m_pkgname; } std::string WidgetLocation::getSourceDir() const { - return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/" + return m_installedPath + "/" + m_pkgname + WrtDB::GlobalConfig::GetWidgetSrcPath(); } std::string WidgetLocation::getBinaryDir() const { - return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/" + return m_installedPath + "/" + m_pkgname + WrtDB::GlobalConfig::GetUserWidgetExecPath(); } @@ -134,6 +147,24 @@ std::string WidgetLocation::getBackupExecFile() const return getBackupBinaryDir() + "/" + m_pkgname; } +std::string WidgetLocation::getUserDataRootDir() const +{ + return std::string(WrtDB::GlobalConfig::GetWidgetUserDataPath()) + + "/" + m_pkgname; +} + +std::string WidgetLocation::getPrivateStorageDir() const +{ + return getUserDataRootDir() + "/" + + WrtDB::GlobalConfig::GetWidgetPrivateStoragePath(); +} + +std::string WidgetLocation::getShareDir() const +{ + return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/" + + m_pkgname + "/" + WrtDB::GlobalConfig::GetWidgetSharePath(); +} + std::string WidgetLocation::getTemporaryPackageDir() const { return m_temp->getTempPath(); @@ -141,6 +172,9 @@ std::string WidgetLocation::getTemporaryPackageDir() const std::string WidgetLocation::getTemporaryRootDir() const { + if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) { + return getWidgetSource(); + } if(m_type == WrtDB::PKG_TYPE_HYBRID_WEB_APP) { return getTemporaryPackageDir() + WrtDB::GlobalConfig::GetWidgetSrcPath(); @@ -153,7 +187,7 @@ std::string WidgetLocation::getTemporaryRootDir() const std::string WidgetLocation::getConfigurationDir() const { - if(m_type == WrtDB::PKG_TYPE_HOSTED_WEB_APP) + if(m_type == WrtDB::PKG_TYPE_HOSTED_WEB_APP) { std::string path = "."; int index = m_widgetSource.find_last_of("\\/"); @@ -163,7 +197,10 @@ std::string WidgetLocation::getConfigurationDir() const } return path; } - else + else if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) + { + return getWidgetSource() + WrtDB::GlobalConfig::GetWidgetSrcPath(); + } else { return getTemporaryRootDir(); } diff --git a/src/misc/widget_location.h b/src/misc/widget_location.h index ab9fa29..e04c3dd 100644 --- a/src/misc/widget_location.h +++ b/src/misc/widget_location.h @@ -25,6 +25,7 @@ #include #include +#include /** * @brief The WidgetLocation class @@ -36,6 +37,7 @@ * * /opt/apps/[package_name] * \_____________ /data + * \_____________ /share * \_____________ /bin * \_____________ /bin/[id_of_installed_package] * \_____________ /res/wgt/ @@ -91,15 +93,20 @@ public: * In destruction removes temporary directory */ WidgetLocation(const std::string & widgetname, std::string sourcePath, - WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP); + WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP, + InstallLocationType ltype = + INSTALL_LOCATION_TYPE_NOMAL); WidgetLocation(const std::string & widgetname, std::string sourcePath, std::string dirPath, - WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP); + WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP, + InstallLocationType ltype = + INSTALL_LOCATION_TYPE_NOMAL); + ~WidgetLocation(); // Installed paths - std::string getInstallationDir() const; // /opt/apps + std::string getInstallationDir() const; // /opt/apps or /usr/apps std::string getPackageInstallationDir() const; // /opt/apps/[package] std::string getSourceDir() const; // /opt/apps/[package]/res/wgt std::string getBinaryDir() const; // /opt/apps/[package]/bin @@ -108,6 +115,9 @@ public: std::string getBackupSourceDir() const; // /opt/apps/[package]/backup/res/wgt std::string getBackupBinaryDir() const; // /opt/apps/[package]/backup/bin std::string getBackupExecFile() const; // /opt/apps/[package]/backup/bin/[package] + std::string getUserDataRootDir() const; // /opt/usr/apps/[package] + std::string getPrivateStorageDir() const; // /opt/usr/apps/[package]/data + std::string getShareDir() const; // /opt/usr/apps/[package]/share // Temporary paths /** @@ -185,6 +195,7 @@ private: WrtDB::PackagingType m_type; std::shared_ptr m_temp; //directory WrtDB::ExternalLocationList m_externals; + std::string m_installedPath; }; #endif // WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H diff --git a/src/pkg-manager/pkgmgr_signal.cpp b/src/pkg-manager/pkgmgr_signal.cpp index 13b32b5..4b48b83 100644 --- a/src/pkg-manager/pkgmgr_signal.cpp +++ b/src/pkg-manager/pkgmgr_signal.cpp @@ -19,12 +19,10 @@ * @brief */ -#include #include #include #include -IMPLEMENT_SAFE_SINGLETON(PackageManager::PkgmgrSignal) namespace PackageManager { @@ -95,7 +93,7 @@ bool PkgmgrSignal::deinitialize() return true; } -bool PkgmgrSignal::setPkgname(std::string name) +bool PkgmgrSignal::setPkgname(const std::string& name) { if (!m_initialized) { @@ -115,7 +113,7 @@ bool PkgmgrSignal::setPkgname(std::string name) return true; } -bool PkgmgrSignal::sendSignal(std::string key, std::string value) const +bool PkgmgrSignal::sendSignal(const std::string& key, const std::string& value) const { if (!m_initialized) { diff --git a/src/pkg-manager/pkgmgr_signal.h b/src/pkg-manager/pkgmgr_signal.h index 6c4e043..a939c50 100644 --- a/src/pkg-manager/pkgmgr_signal.h +++ b/src/pkg-manager/pkgmgr_signal.h @@ -15,14 +15,15 @@ */ /* * @author Yunchan Cho (yunchan.cho@samsung.com) - * @version 0.1 + * @author Jan Olszak (j.olszak@samsung.com) + * @version 0.2 * @brief */ #ifndef WRT_PKGMGR_SIGNAL_H_ #define WRT_PKGMGR_SINGAL_H_ -#include +#include #include namespace PackageManager{ @@ -38,17 +39,20 @@ namespace PackageManager{ typedef pkgmgr_installer* PkgmgrHandle; -class PkgmgrSignal +class PkgmgrSignal: public IPkgmgrSignal { public: bool initialize(int argc, char* argv[]); bool deinitialize(); - bool setPkgname(std::string name); - bool sendSignal(std::string key, std::string value) const; + bool setPkgname(const std::string& name); + bool sendSignal(const std::string& key, const std::string& value) const; std::string getPkgname() const; int getRequestedType() const; bool isNoPopupRequired() const; + PkgmgrSignal(); + virtual ~PkgmgrSignal(); + private: bool m_initialized; PkgmgrHandle m_handle; @@ -56,15 +60,7 @@ class PkgmgrSignal std::string m_pkgname; bool m_noPopup; int m_reqType; - - PkgmgrSignal(); - ~PkgmgrSignal(); - - friend class DPL::Singleton; }; - -typedef DPL::Singleton PkgmgrSignalSingleton; - } // PackageManager #endif // WRT_PKGMGR_SIGNAL_H_ diff --git a/src/pkg-manager/pkgmgr_signal_dummy.h b/src/pkg-manager/pkgmgr_signal_dummy.h new file mode 100644 index 0000000..f8862ee --- /dev/null +++ b/src/pkg-manager/pkgmgr_signal_dummy.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * @author Jan Olszak (j.olszak@samsung.com) + * @version 0.1 + * @brief Dummy version of PkgmgrSignal. + */ + +#ifndef WRT_PKGMGR_SIGNAL_DUMMY_H_ +#define WRT_PKGMGR_SIGNAL_DUMMY_H_ + +#include + +namespace PackageManager { + +class PkgmgrSignalDummy: public IPkgmgrSignal +{ +public: + PkgmgrSignalDummy() + { + } + + virtual ~PkgmgrSignalDummy() + { + } + bool setPkgname(const std::string& name) + { + return false; + } + + bool sendSignal(const std::string& key, const std::string& value) const + { + return false; + } + + std::string getPkgname() const + { + return ""; + } +}; + +} // PkgmgrSignalDummy + +#endif // WRT_PKGMGR_SIGNAL_DUMMY_H_ diff --git a/src/jobs/widget_install/task_private_storage.h b/src/pkg-manager/pkgmgr_signal_interface.h similarity index 50% rename from src/jobs/widget_install/task_private_storage.h rename to src/pkg-manager/pkgmgr_signal_interface.h index e919f6b..187efb5 100644 --- a/src/jobs/widget_install/task_private_storage.h +++ b/src/pkg-manager/pkgmgr_signal_interface.h @@ -13,33 +13,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @file task_private_storage.h - * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com) - * @version 1.0 - * @brief Header file for installer task private storage. +/* + * @author Jan Olszak (j.olszak@samsung.com) + * @version 0.1 + * @brief Interface for PkgmgrSignal. */ -#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_PRIVATESTORAGE_H -#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_PRIVATESTORAGE_H -#include +#ifndef WRT_PKGMGR_SIGNAL_INTERFACE_H_ +#define WRT_PKGMGR_SIGNAL_INTERFACE_H_ -class InstallerContext; +#include +namespace PackageManager { -namespace Jobs { -namespace WidgetInstall { -class TaskPrivateStorage : public DPL::TaskDecl +class IPkgmgrSignal { - public: - explicit TaskPrivateStorage(InstallerContext& context); - - private: - void StepCreateDirectory(); - - private: - InstallerContext& m_context; +public: + virtual bool setPkgname(const std::string& name) = 0; + virtual bool sendSignal(const std::string& key, const std::string& value) const = 0; + virtual std::string getPkgname() const = 0; + virtual ~IPkgmgrSignal(){}; }; -} //namespace WidgetInstall -} //namespace Jobs -#endif +} // IPkgmgrSignal + +#endif // WRT_PKGMGR_SIGNAL_INTERFACE_H_ diff --git a/src/wrt-installer/wrt_installer.cpp b/src/wrt-installer/wrt_installer.cpp index 354cb5a..425d655 100644 --- a/src/wrt-installer/wrt_installer.cpp +++ b/src/wrt-installer/wrt_installer.cpp @@ -49,7 +49,8 @@ #include #include #include -#include + + #define NOFILE_CNT_FOR_INSTALLER 9999 @@ -89,7 +90,8 @@ WrtInstaller::WrtInstaller(int argc, char **argv) : m_installByPkgmgr(false), m_quiet(true), m_popup(NULL), - m_startupPluginInstallation(false) + m_startupPluginInstallation(false), + m_preloadWidget(false) { Touch(); LogDebug("App Created"); @@ -113,6 +115,12 @@ void WrtInstaller::OnCreate() std::string arg = m_argv[0]; + pkgmgrSignalInterface = std::static_pointer_cast( + std::shared_ptr( + new PackageManager::PkgmgrSignalDummy() + ) + ); + if (arg.empty()) { return showHelpAndQuit(); } @@ -147,8 +155,17 @@ void WrtInstaller::OnCreate() return showHelpAndQuit(); } + struct stat info; + if (-1 != stat(m_argv[2], &info) && S_ISDIR(info.st_mode)) { + LogInfo("Installing package directly from directory"); + m_installPolicy = WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL; + } + else + { + LogInfo("Installing from regular location"); + m_installPolicy = WRT_WIM_POLICY_WAC; + } m_packagePath = m_argv[2]; - m_installPolicy = WRT_WIM_POLICY_WAC; AddStep(&WrtInstaller::installStep); } else if (arg == "-if" || arg == "--install-force") { if (m_argc != 3) { @@ -158,6 +175,15 @@ void WrtInstaller::OnCreate() m_packagePath = m_argv[2]; m_installPolicy = WRT_WIM_POLICY_FORCE_INSTALL; AddStep(&WrtInstaller::installStep); + } else if (arg == "-il" || arg == "--install-preload") { + if (m_argc != 3) { + return showHelpAndQuit(); + } + + m_packagePath = m_argv[2]; + m_preloadWidget = true; + m_installPolicy = WRT_WIM_POLICY_WAC; + AddStep(&WrtInstaller::installStep); } else if (arg == "-un" || arg == "--uninstall-name") { if (m_argc != 3) { return showHelpAndQuit(); @@ -184,16 +210,31 @@ void WrtInstaller::OnCreate() using namespace PackageManager; m_installByPkgmgr = true; - PkgmgrSignalSingleton::Instance().initialize(m_argc, m_argv); - m_quiet = PkgmgrSignalSingleton::Instance().isNoPopupRequired(); + auto pkgmgrSignal = std::shared_ptr( + new PackageManager::PkgmgrSignal() + ); + + pkgmgrSignal->initialize(m_argc, m_argv); + m_quiet = pkgmgrSignal->isNoPopupRequired(); LogDebug("backend m_quiet"<getRequestedType(); + pkgmgrSignalInterface = + std::static_pointer_cast(pkgmgrSignal); switch (reqType) { case PKGMGR_REQ_INSTALL: m_packagePath = m_argv[4]; - m_installPolicy = WRT_WIM_POLICY_WAC; + struct stat info; + if (-1 != stat(m_argv[4], &info) && S_ISDIR(info.st_mode)) { + LogInfo("Installing package directly from directory"); + m_installPolicy = WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL; + } + else + { + LogInfo("Installing from regular location"); + m_installPolicy = WRT_WIM_POLICY_WAC; + } AddStep(&WrtInstaller::installStep); break; case PKGMGR_REQ_UNINSTALL: @@ -324,7 +365,9 @@ void WrtInstaller::installStep() (!m_quiet || m_installByPkgmgr) ? &staticWrtInstallProgressCallback : NULL, m_installPolicy, - m_quiet); + m_quiet, + m_preloadWidget, + pkgmgrSignalInterface); } void WrtInstaller::installPluginsStep() @@ -405,7 +448,8 @@ void WrtInstaller::uninstallPkgNameStep() LogDebug("Package name : " << m_name); wrt_uninstall_widget(m_name.c_str(), this, &staticWrtStatusCallback, (!m_quiet || m_installByPkgmgr) - ? &staticWrtUninstallProgressCallback : NULL); + ? &staticWrtUninstallProgressCallback : NULL, + pkgmgrSignalInterface); } void WrtInstaller::uninstallGuidStep() @@ -416,7 +460,8 @@ void WrtInstaller::uninstallGuidStep() if (status == WRT_SUCCESS) { LogDebug("Guid : " << m_name); wrt_uninstall_widget(pkgname.c_str(), this, &staticWrtStatusCallback, - !m_quiet ? &staticWrtUninstallProgressCallback : NULL); + !m_quiet ? &staticWrtUninstallProgressCallback : NULL, + pkgmgrSignalInterface); } else { printf("failed: can not uninstall widget\n"); LogError("Fail to uninstalling widget... "); @@ -463,7 +508,8 @@ void WrtInstaller::unistallWgtFileStep() if (status == WRT_SUCCESS) { LogDebug("Pkgname from packagePath : " << pkgname); wrt_uninstall_widget(pkgname.c_str(), this, &staticWrtStatusCallback, - !m_quiet ? &staticWrtUninstallProgressCallback : NULL); + !m_quiet ? &staticWrtUninstallProgressCallback : NULL, + pkgmgrSignalInterface); } else { LogError("Fail to uninstalling widget... "); m_returnStatus = -1; @@ -906,44 +952,48 @@ bool WrtInstaller::popupsEnabled() const int main(int argc, char *argv[]) { - // Output on stdout will be flushed after every newline character, - // even if it is redirected to a pipe. This is useful for running - // from a script and parsing output. - // (Standard behavior of stdlib is to use full buffering when - // redirected to a pipe, which means even after an end of line - // the output may not be flushed). - setlinebuf(stdout); - - // Check and re-set the file open limitation - struct rlimit rlim; - if (getrlimit(RLIMIT_NOFILE, &rlim) != -1) { - LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")" ); - LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")" ); - - if (rlim.rlim_cur < NOFILE_CNT_FOR_INSTALLER) { - rlim.rlim_cur = NOFILE_CNT_FOR_INSTALLER; - rlim.rlim_max = NOFILE_CNT_FOR_INSTALLER; - if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) { - LogError("setrlimit is fail!!"); + UNHANDLED_EXCEPTION_HANDLER_BEGIN + { + // Output on stdout will be flushed after every newline character, + // even if it is redirected to a pipe. This is useful for running + // from a script and parsing output. + // (Standard behavior of stdlib is to use full buffering when + // redirected to a pipe, which means even after an end of line + // the output may not be flushed). + setlinebuf(stdout); + + // Check and re-set the file open limitation + struct rlimit rlim; + if (getrlimit(RLIMIT_NOFILE, &rlim) != -1) { + LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")" ); + LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")" ); + + if (rlim.rlim_cur < NOFILE_CNT_FOR_INSTALLER) { + rlim.rlim_cur = NOFILE_CNT_FOR_INSTALLER; + rlim.rlim_max = NOFILE_CNT_FOR_INSTALLER; + if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) { + LogError("setrlimit is fail!!"); + } } + } else { + LogError("getrlimit is fail!!"); } - } else { - LogError("getrlimit is fail!!"); - } - // set evas backend type for emulator - // popup isn't showed in the emulator, - // if backend isn't set to SW backend - if (GlobalSettings::IsEmulator()) { - if (setenv("ELM_ENGINE", "x11", 1)) { - LogDebug("Enable backend"); + // set evas backend type for emulator + // popup isn't showed in the emulator, + // if backend isn't set to SW backend + if (GlobalSettings::IsEmulator()) { + if (setenv("ELM_ENGINE", "x11", 1)) { + LogDebug("Enable backend"); + } } - } - WrtInstaller app(argc, argv); - int ret = app.Exec(); - LogDebug("App returned: " << ret); - ret = app.getReturnStatus(); - LogDebug("WrtInstaller returned: " << ret); - return ret; + WrtInstaller app(argc, argv); + int ret = app.Exec(); + LogDebug("App returned: " << ret); + ret = app.getReturnStatus(); + LogDebug("WrtInstaller returned: " << ret); + return ret; + } + UNHANDLED_EXCEPTION_HANDLER_END } diff --git a/src/wrt-installer/wrt_installer.h b/src/wrt-installer/wrt_installer.h index d6e2315..723236f 100644 --- a/src/wrt-installer/wrt_installer.h +++ b/src/wrt-installer/wrt_installer.h @@ -31,7 +31,11 @@ #include #include #include -#include + +#include +#include +#include +#include namespace WRTInstallerNS { //anonymous DECLARE_GENERIC_EVENT_0(QuitEvent) @@ -134,6 +138,7 @@ class WrtInstaller : bool popupsEnabled() const; // Private data + std::shared_ptr pkgmgrSignalInterface; wrt_widget_install_mode_e m_installPolicy; std::string m_bundleValue; std::string m_packagePath; @@ -149,6 +154,7 @@ class WrtInstaller : bool m_startupPluginInstallation; std::string m_webAppConfig; std::string m_webAppIcon; + bool m_preloadWidget; typedef std::list PluginPathList; DPL::Optional m_pluginsPaths; diff --git a/src/wrt-installer/wrt_installer_api.cpp b/src/wrt-installer/wrt_installer_api.cpp index 21fcc72..d643991 100755 --- a/src/wrt-installer/wrt_installer_api.cpp +++ b/src/wrt-installer/wrt_installer_api.cpp @@ -62,8 +62,10 @@ extern "C" inline WidgetUpdateMode::Type translateWidgetUpdateMode( wrt_widget_update_mode_t updateMode) { - WidgetUpdateMode::Type result = WidgetUpdateMode::Zero; + if (updateMode == WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL) + return WidgetUpdateMode::PolicyDirectoryForceInstall; + WidgetUpdateMode::Type result = WidgetUpdateMode::Zero; if (updateMode & WRT_WIM_NOT_INSTALLED) { result = result | WidgetUpdateMode::NotInstalled; } @@ -136,17 +138,17 @@ extern "C" "> does not exist."); } - if_ok &= (checkPath(GlobalConfig::GetFactoryInstalledWidgetPath())); + if_ok &= (checkPath(GlobalConfig::GetUserInstalledWidgetPath())); if (!if_ok) { LogError( - "Path <" << GlobalConfig::GetFactoryInstalledWidgetPath() << + "Path <" << GlobalConfig::GetUserInstalledWidgetPath() << "> does not exist."); } - if_ok &= (checkPath(GlobalConfig::GetUserInstalledWidgetPath())); + if_ok &= (checkPath(GlobalConfig::GetUserPreloadedWidgetPath())); if (!if_ok) { LogError( - "Path <" << GlobalConfig::GetUserInstalledWidgetPath() << + "Path <" << GlobalConfig::GetUserPreloadedWidgetPath() << "> does not exist."); } return if_ok; @@ -321,7 +323,10 @@ extern "C" WrtInstallerStatusCallback status_cb, WrtProgressCallback progress_cb, wrt_widget_update_mode_t update_mode, - bool quiet) + bool quiet, + bool preload, + std::shared_ptr pkgmgrInterface + ) { UNHANDLED_EXCEPTION_HANDLER_BEGIN { @@ -336,7 +341,9 @@ extern "C" new InstallerCallbacksTranslate::StatusCallbackStruct( userdata, status_cb, progress_cb), translateWidgetUpdateMode(update_mode), - quiet))); + quiet, + preload, + pkgmgrInterface))); } UNHANDLED_EXCEPTION_HANDLER_END } @@ -344,7 +351,8 @@ extern "C" EXPORT_API void wrt_uninstall_widget(const char * const pkg_name, void* userdata, WrtInstallerStatusCallback status_cb, - WrtProgressCallback progress_cb) + WrtProgressCallback progress_cb, + std::shared_ptr pkgmgrSignalInterface) { UNHANDLED_EXCEPTION_HANDLER_BEGIN { @@ -352,14 +360,18 @@ extern "C" LogInfo("[WRT-API] UNINSTALL WIDGET: " << widgetPkgName); // Post uninstallation event CONTROLLER_POST_EVENT( - Logic::InstallerController, - InstallerControllerEvents::UninstallWidgetEvent( - widgetPkgName, - WidgetUninstallationStruct( - InstallerCallbacksTranslate::uninstallFinishedCallback, - InstallerCallbacksTranslate::installProgressCallback, - new InstallerCallbacksTranslate::StatusCallbackStruct( - userdata, status_cb, progress_cb)))); + Logic::InstallerController, + InstallerControllerEvents::UninstallWidgetEvent( + widgetPkgName, + WidgetUninstallationStruct( + InstallerCallbacksTranslate::uninstallFinishedCallback, + InstallerCallbacksTranslate::installProgressCallback, + new InstallerCallbacksTranslate::StatusCallbackStruct( + userdata, status_cb, progress_cb), + pkgmgrSignalInterface + ) + ) + ); } UNHANDLED_EXCEPTION_HANDLER_END } diff --git a/src/wrt-installer/wrt_installer_api.h b/src/wrt-installer/wrt_installer_api.h index cd83c5b..6f2bea6 100755 --- a/src/wrt-installer/wrt_installer_api.h +++ b/src/wrt-installer/wrt_installer_api.h @@ -33,6 +33,8 @@ #include #include #include +#include +#include #ifdef __cplusplus extern "C" { @@ -151,7 +153,10 @@ typedef enum wrt_widget_install_mode_e /* Force install policy */ - WRT_WIM_POLICY_FORCE_INSTALL = WRT_WIM_POLICY_ALWAYS_INSTALL + WRT_WIM_POLICY_FORCE_INSTALL = WRT_WIM_POLICY_ALWAYS_INSTALL, + /* Installation from directory - forced update + */ + WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL } wrt_widget_update_mode_t; int wrt_installer_init(void *userdata, @@ -196,7 +201,9 @@ void wrt_installer_shutdown(void); * void *user_parameter, * WrtInstallerStatusCallback status_callback, * WrtProgressCallback progress_callback, - * wrt_widget_update_mode_t update_mode); + * wrt_widget_update_mode_t update_mode, + * bool quiet, + * bool preload); * * @brief Installs widget from given path * @@ -213,6 +220,8 @@ void wrt_installer_shutdown(void); * If you don't want to get progress data, this * should be NULL * @param [in] install_mode Installation mode + * @param [in] quiet quiet mode + * @param [in] preload preload widget install * @return Nothing (status returned in callback). * * Sample code: @@ -221,7 +230,9 @@ void wrt_installer_shutdown(void); * NULL, * install_cb, * progress_cb, - * WRT_WIM_POLICY_WAC); + * WRT_WIM_POLICY_WAC, + * false, + * false); * @endcode * * @see wrt_installer_uninstall_widget @@ -231,7 +242,10 @@ void wrt_install_widget(const char *path, WrtInstallerStatusCallback status_callback, WrtProgressCallback progress_callback, wrt_widget_update_mode_t update_mode, - bool quiet); + bool quiet, + bool preload, + std::shared_ptr pkgmgrInterface + ); /** * @fn void wrt_installer_uninstall_widget (const char * const pkg_name, @@ -264,7 +278,8 @@ void wrt_install_widget(const char *path, void wrt_uninstall_widget (const char * const pkg_name, void* userdata, WrtInstallerStatusCallback status_cb, - WrtProgressCallback progress_cb); + WrtProgressCallback progress_cb, + std::shared_ptr pkgmgrSignalInterface); /** * @fn void wrt_install_plugin(const char *pluginDirectory,