merge with master
authorJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:21:52 +0000 (01:21 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:21:52 +0000 (01:21 +0900)
159 files changed:
CMakeLists.txt
configuration/config.tizen.xsd [changed mode: 0644->0755]
debian/changelog
etc/wrt_preinstall_widgets.sh
packaging/wrt-installer.spec
src/CMakeLists.txt
src/commons/wrt_common_types.h
src/commons/wrt_error.h
src/configuration_parser/WidgetConfigurationManager.cpp [deleted file]
src/configuration_parser/WidgetConfigurationManager.h [deleted file]
src/configuration_parser/deny_all_parser.cpp
src/configuration_parser/deny_all_parser.h
src/configuration_parser/element_parser.h
src/configuration_parser/ignoring_parser.cpp
src/configuration_parser/ignoring_parser.h
src/configuration_parser/libiriwrapper.cpp
src/configuration_parser/libiriwrapper.h
src/configuration_parser/parser_runner.cpp
src/configuration_parser/parser_runner.h
src/configuration_parser/root_parser.h
src/configuration_parser/widget_parser.cpp [changed mode: 0755->0644]
src/configuration_parser/widget_parser.h [changed mode: 0755->0644]
src/jobs/job.cpp
src/jobs/job.h
src/jobs/job_base.h
src/jobs/job_exception_base.h
src/jobs/plugin_install/job_plugin_install.cpp
src/jobs/plugin_install/job_plugin_install.h
src/jobs/plugin_install/plugin_install_task.cpp
src/jobs/plugin_install/plugin_installer_errors.h
src/jobs/plugin_install/plugin_metafile_reader.cpp
src/jobs/plugin_install/plugin_objects.cpp
src/jobs/plugin_install/plugin_objects.h
src/jobs/widget_install/ace_registration.cpp
src/jobs/widget_install/ace_registration.h
src/jobs/widget_install/job_widget_install.cpp
src/jobs/widget_install/job_widget_install.h
src/jobs/widget_install/languages.def
src/jobs/widget_install/manifest.cpp [changed mode: 0755->0644]
src/jobs/widget_install/manifest.h [changed mode: 0755->0644]
src/jobs/widget_install/task_ace_check.cpp
src/jobs/widget_install/task_certificates.cpp
src/jobs/widget_install/task_certificates.h [changed mode: 0755->0644]
src/jobs/widget_install/task_certify.cpp [changed mode: 0755->0644]
src/jobs/widget_install/task_certify.h [changed mode: 0755->0644]
src/jobs/widget_install/task_commons.cpp
src/jobs/widget_install/task_commons.h
src/jobs/widget_install/task_database.cpp
src/jobs/widget_install/task_database.h
src/jobs/widget_install/task_encrypt_resource.cpp
src/jobs/widget_install/task_encrypt_resource.h
src/jobs/widget_install/task_file_manipulation.cpp
src/jobs/widget_install/task_file_manipulation.h
src/jobs/widget_install/task_install_ospsvc.cpp
src/jobs/widget_install/task_install_ospsvc.h
src/jobs/widget_install/task_manifest_file.cpp
src/jobs/widget_install/task_manifest_file.h [changed mode: 0755->0644]
src/jobs/widget_install/task_plugins_copy.cpp
src/jobs/widget_install/task_plugins_copy.h
src/jobs/widget_install/task_prepare_files.cpp
src/jobs/widget_install/task_prepare_files.h
src/jobs/widget_install/task_recovery.cpp
src/jobs/widget_install/task_recovery.h
src/jobs/widget_install/task_remove_backup.cpp
src/jobs/widget_install/task_remove_backup.h
src/jobs/widget_install/task_smack.cpp
src/jobs/widget_install/task_smack.h
src/jobs/widget_install/task_unzip.cpp
src/jobs/widget_install/task_unzip.h
src/jobs/widget_install/task_update_files.cpp
src/jobs/widget_install/task_widget_config.cpp
src/jobs/widget_install/task_widget_config.h [changed mode: 0755->0644]
src/jobs/widget_install/view_mode.h
src/jobs/widget_install/wac_security.cpp
src/jobs/widget_install/wac_security.h
src/jobs/widget_install/widget_install_context.h [changed mode: 0755->0644]
src/jobs/widget_install/widget_install_errors.h
src/jobs/widget_install/widget_install_popup.cpp [changed mode: 0755->0644]
src/jobs/widget_install/widget_install_popup.h [changed mode: 0755->0644]
src/jobs/widget_install/widget_installer_struct.h [changed mode: 0755->0644]
src/jobs/widget_install/widget_update_info.cpp
src/jobs/widget_install/widget_update_info.h
src/jobs/widget_uninstall/job_widget_uninstall.cpp
src/jobs/widget_uninstall/job_widget_uninstall.h
src/jobs/widget_uninstall/task_check.cpp
src/jobs/widget_uninstall/task_db_update.cpp
src/jobs/widget_uninstall/task_db_update.h
src/jobs/widget_uninstall/task_delete_certificates.cpp [changed mode: 0755->0644]
src/jobs/widget_uninstall/task_delete_certificates.h
src/jobs/widget_uninstall/task_remove_custom_handlers.cpp
src/jobs/widget_uninstall/task_remove_custom_handlers.h
src/jobs/widget_uninstall/task_remove_files.cpp
src/jobs/widget_uninstall/task_smack.cpp
src/jobs/widget_uninstall/task_smack.h
src/jobs/widget_uninstall/task_uninstall_ospsvc.cpp
src/jobs/widget_uninstall/uninstaller_context.h
src/jobs/widget_uninstall/widget_uninstall_errors.h
src/jobs/widget_uninstall/widget_uninstaller_struct.h
src/logic/installer_controller.cpp
src/logic/installer_controller.h
src/logic/installer_logic.cpp
src/logic/installer_logic.h
src/misc/feature_logic.cpp
src/misc/feature_logic.h
src/misc/libxml_utils.cpp
src/misc/libxml_utils.h
src/misc/wac_widget_id.cpp
src/misc/widget_install_to_external.cpp
src/misc/widget_install_to_external.h
src/misc/widget_location.cpp
src/misc/widget_location.h
src/pkg-manager/CMakeLists.txt
src/pkg-manager/backendlib.cpp
src/pkg-manager/pkgmgr_signal.cpp
src/pkg-manager/pkgmgr_signal.h
src/pkg-manager/pkgmgr_signal_dummy.h
src/pkg-manager/pkgmgr_signal_interface.h
src/wrt-installer/CMakeLists.txt
src/wrt-installer/installer_callbacks_translate.cpp
src/wrt-installer/installer_callbacks_translate.h
src/wrt-installer/installer_main_thread.cpp [changed mode: 0755->0644]
src/wrt-installer/installer_main_thread.h [changed mode: 0755->0644]
src/wrt-installer/language_subtag_rst_tree.cpp
src/wrt-installer/option_parser.cpp
src/wrt-installer/option_parser.h
src/wrt-installer/plugin_utils.cpp
src/wrt-installer/plugin_utils.h [changed mode: 0755->0644]
src/wrt-installer/wrt_installer.cpp
src/wrt-installer/wrt_installer.h
src/wrt-installer/wrt_installer_api.cpp
src/wrt-installer/wrt_installer_api.h [changed mode: 0755->0644]
src/wrt-installer/wrt_type.h [changed mode: 0755->0644]
tests/CMakeLists.txt [new file with mode: 0644]
tests/general/BackgroundPageTests.cpp [new file with mode: 0644]
tests/general/CMakeLists.txt [new file with mode: 0644]
tests/general/InstallerWrapper.cpp [new file with mode: 0644]
tests/general/InstallerWrapper.h [new file with mode: 0644]
tests/general/ManifestFile.cpp [new file with mode: 0644]
tests/general/ManifestFile.h [new file with mode: 0644]
tests/general/ManifestTests.cpp [new file with mode: 0644]
tests/general/NPluginsInstallTests.cpp [new file with mode: 0644]
tests/general/NonRootUserTests.cpp [new file with mode: 0644]
tests/general/ParsingTizenAppserviceTests.cpp [new file with mode: 0644]
tests/general/TestInit.cpp [new file with mode: 0644]
tests/general/widgets/appservice_dispos.wgt [new file with mode: 0644]
tests/general/widgets/bg-00-with_bg.wgt [new file with mode: 0644]
tests/general/widgets/bg-01-missing_file.wgt [new file with mode: 0644]
tests/general/widgets/bg-02-without_bg.wgt [new file with mode: 0644]
tests/general/widgets/inst_nplug_1.wgt [new file with mode: 0644]
tests/general/widgets/inst_nplug_2.wgt [new file with mode: 0644]
tests/general/widgets/inst_nplug_3.wgt [new file with mode: 0644]
tests/general/widgets/inst_nplug_4.wgt [new file with mode: 0644]
tests/general/widgets/manifest.wgt [new file with mode: 0644]
tests/general/widgets/nonroot.wgt [new file with mode: 0644]
tests/general/widgets/tizen_appservice_disposition/config.xml [new file with mode: 0755]
tests/general/widgets/tizen_appservice_disposition/icon.png [new file with mode: 0755]
tests/general/widgets/tizen_appservice_disposition/index.htm [new file with mode: 0755]
uncrustify.cfg [new file with mode: 0644]
uncrustify.sh [new file with mode: 0755]

index f85fa56..78004ae 100644 (file)
@@ -34,7 +34,13 @@ ENDIF(NOT CMAKE_BUILD_TYPE)
 
 ############################# compilation defines #############################
 
-# EMPTY
+
+#csp from .xml parsing enabled
+OPTION(CSP_SUPPORT "Support for csp policy" ON)
+
+IF(CSP_SUPPORT)
+    ADD_DEFINITIONS("-DCSP_ENABLED")
+ENDIF(CSP_SUPPORT)
 
 ############################# compiler flags ##################################
 
@@ -47,12 +53,14 @@ SET(CMAKE_CXX_FLAGS_RELEASE    "-O2 -std=c++0x -g")
 SET(CMAKE_CXX_FLAGS_CCOV       "-O0 -std=c++0x -g --coverage")
 
 OPTION(DPL_LOG "DPL logs status" ON)
+OPTION(WITH_TESTS "Build tests" OFF)
 IF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
     MESSAGE(STATUS "Logging enabled for DPL")
     ADD_DEFINITIONS("-DDPL_LOGS_ENABLED")
 ELSE(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
     MESSAGE(STATUS "Logging disabled for DPL")
 ENDIF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
+MESSAGE(STATUS "WITH_TESTS: " ${WITH_TESTS})
 
 # If supported for the target machine, emit position-independent code,suitable
 # for dynamic linking and avoiding any limit on the size of the global offset
@@ -96,3 +104,7 @@ INSTALL(FILES   ${PROJECT_SOURCE_DIR}/data/widget_install_popup.edj
 ############################# subdirectories ##################################
 ADD_SUBDIRECTORY(src)
 ADD_SUBDIRECTORY(etc)
+
+IF(WITH_TESTS)
+    ADD_SUBDIRECTORY(tests)
+ENDIF(WITH_TESTS)
old mode 100644 (file)
new mode 100755 (executable)
index 4bc46ea..99e8ecf
     <xs:restriction base="xs:anyURI"/>
 </xs:simpleType>
 
-<xs:simpleType name="applicationIdType">
+<xs:simpleType name="PackageType">
     <xs:restriction base="xs:string">
         <xs:pattern value="[0-9a-zA-Z]{10}"/>
     </xs:restriction>
 </xs:simpleType>
 
+<xs:simpleType name="applicationIdType">
+    <xs:restriction base="xs:string">
+        <xs:pattern value="[0-9a-zA-Z]{10}.[0-9a-zA-Z]{1,}"/>
+    </xs:restriction>
+</xs:simpleType>
+
 <xs:simpleType name="screenOrientationType">
     <xs:restriction base="xs:token">
         <xs:enumeration value="portrait"/>
@@ -69,6 +75,7 @@
 <xs:element name="application">
     <xs:complexType>
         <xs:attribute name="id" type="tizen:applicationIdType" use="required"/>
+        <xs:attribute name="package" type="tizen:PackageType" use="required"/>
         <xs:attribute name="required_version" type="xs:float" use="required"/>
     </xs:complexType>
 </xs:element>
 
 <xs:element name="operation">
     <xs:complexType>
-        <xs:attribute name="name" use="required"/>
+        <xs:attribute name="name" type="tizen:appserviceOperationType" use="required"/>
     </xs:complexType>
 </xs:element>
 
     </xs:complexType>
 </xs:element>
 
-<xs:element name="box-label" type="xs:string"/>
+<xs:element name="box-label"> 
+    <xs:complexType mixed="true"> 
+    </xs:complexType> 
+</xs:element>
 
 <xs:element name="box-icon">
     <xs:complexType>
index 856ba17..5866ad9 100644 (file)
@@ -1,8 +1,166 @@
-wrt-installer (0.0.94.1) unstable; urgency=low
+wrt-installer (0.1.12) unstable; urgency=low
+
+  * Fixed pkgmgr signal request by menuscreen
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Mon, 11 Mar 2013 22:48:50 +0900
+
+wrt-installer (0.1.11) unstable; urgency=low
+
+  * remove encryption api dependency from wrt-commons
+  * move booting script location(wrt_preinstall_widgets.sh)
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Mon, 11 Mar 2013 20:26:56 +0900
+
+wrt-installer (0.1.10) unstable; urgency=low
+
+  * Change encryption API.
+  * fixed installation failed when w3c widget without min-version attribute in
+   config.xml.
+  * pkgmgr signal id changed.
+  * Fixed check exist directory.
+  * check certificate during update
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Fri, 08 Mar 2013 18:54:57 +0900
+
+wrt-installer (0.1.9) unstable; urgency=low
+
+  * Installer errors handling clean up
+  * Installer tests sources modification
+  * Content-Security-Policy-Report-Only xml tag support
+  * Remove web storage & filesystem usage code
+  * Fix App-control Supports : Some parser related app-control was changed
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 07 Mar 2013 09:11:07 +0900
+
+wrt-installer (0.1.8) unstable; urgency=low
+
+  * Release
+
+ -- Leerang Song <leerang.song@samsung.com>  Thu, 28 Feb 2013 11:13:19 +0900
+
+wrt-installer (0.1.7) unstable; urgency=low
+
+  * Removing warnings reported by cppcheck tool.
+  * Removing compilation warnings in wrt-installer repo
+  * Fixed language tag map for pkg labels
+
+ -- Leerang Song <leerang.song@samsung.com>  Wed, 27 Feb 2013 15:53:56 +0900
+
+wrt-installer (0.1.6) unstable; urgency=low
+
+  * code clean up - src/configuration_parser/WidgetConfigurationManager
+  * Implement tizen privilege for w3c API
+  * Fixed can't uninstall using pkgid from pkgcmd
+  * Fixed required version issue
+  * Renaming tests binaries
+  * Move installer test suites to installer repository
+
+ -- leerang Song <leerang.song@samsung.com>  Fri, 22 Feb 2013 15:35:49 +0900
+
+wrt-installer (0.1.5) unstable; urgency=low
+
+  * REG_NOERROR value is not defined for function regexec.
+  * Fixed skip to validate a signature
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Thu, 14 Feb 2013 19:17:48 +0900
+
+wrt-installer (0.1.4) unstable; urgency=low
+
+  * Fixed uninstallation using pkgid and installation without pkgid in config.xml
+  * Source code formating unification
+  * Support for GCC 4.7
+  * File encryption method reading whole files into a dynamic stack buffer.
+  * Fixed icon name
+  * Fixed update signal
+  * Fixed to update progress enum
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.1.4
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Fri, 08 Feb 2013 18:34:29 +0900
+
+wrt-installer (0.1.3) unstable; urgency=low
+
+  * Signature path bug fix when install by directory mode.
+  * Fixed if there is no pkgid, widget installation failed.
+  * Fix prevent issue
+  * CSP policy parsing support.
+  * remove share directory
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.1.3
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Wed, 06 Feb 2013 19:35:55 +0900
+
+wrt-installer (0.1.2) unstable; urgency=low
+
+  * Fixed name has special characters
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.1.2
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Fri, 01 Feb 2013 16:53:19 +0900
+
+wrt-installer (0.1.1) unstable; urgency=low
+
+  * Add mouse-event of <tizen:box-content> and type of <tizen:livebox> 
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.1.1
+
+ -- Yunchan Cho <yunchan.cho@samsung.com>  Wed, 30 Jan 2013 17:41:01 +0900
+
+wrt-installer (0.1.0) unstable; urgency=low
+
+  * Fixed appid included space during installation
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Wed, 30 Jan 2013 14:01:41 +0900
+
+wrt-installer (0.0.99) unstable; urgency=low
 
   * Fixed to send progress signal during RDS update.
+  * Fixed widget name has special character.
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Tue, 29 Jan 2013 22:14:13 +0900
+
+wrt-installer (0.0.98) unstable; urgency=low
+
+  * Change pkgname to appid for docomo request. PART1
+  * Change pkgname to appid for docomo request. PART2
+  * Change pkgname to appid for docomo request. PART3
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.98
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Mon, 28 Jan 2013 17:47:38 +0900
+
+wrt-installer (0.0.97) unstable; urgency=low
+
+  * Revert "Change pkgname to appid for docomo request."
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com>  Fri, 25 Jan 2013 22:38:17 +0900
+
+wrt-installer (0.0.96) unstable; urgency=low
+
+  * Change pkgname to appid for docomo request. PART2
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.96
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Thu, 24 Jan 2013 21:14:47 +0900
+
+wrt-installer (0.0.95) unstable; urgency=low
+
+  * change schema type of livebox
+  * Patch for semaphore deadlock bug while plugins installation.
+  * Fixed preinstall for plugin
+  * Change pkgname to appid for docomo request. PART1
+  * Fixed app-control element type
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.95
 
- -- Soyoung Kim <sy037.kim@samsung.com>  Tue, 29 Jan 2013 16:02:14 +0900
+ -- Soyoung Kim <sy037.kim@samsung.com>  Thu, 24 Jan 2013 16:00:35 +0900
 
 wrt-installer (0.0.94) unstable; urgency=low
 
index 2d7b9d5..218015d 100755 (executable)
@@ -14,7 +14,7 @@
 #    limitations under the License.
 #
 
-_working_dir="/opt/media/Downloads/.preinstallWidgets"
+_working_dir="/opt/usr/media/Downloads/.preinstallWidgets"
 _widget_temp="/opt/share/widget/*";
 
 install_widgets() {
@@ -23,8 +23,8 @@ install_widgets() {
        for list in $_wgt_list
        do
                echo "Install $list"
-               return_string=`wrt-installer -il $list`
-        if [ "$return_string" != "${return_string/installed/}" ]; then
+               return_string=`wrt-installer -il $list 2>&1 | grep -v plugin`
+        if [ "$return_string" != "${return_string/successful/}" ]; then
             echo "$list widget installation success"
             rm -rf $list
         else
@@ -69,13 +69,13 @@ else
 fi
 }
 
+#Plugin installation is temporary code for window SDK
+/usr/bin/wrt-installer -p
+
 if [ ! -d $_working_dir ]; then
        echo "There is no preinstall widget directory - $_working_dir"
     restore_widget
        exit 1
 fi
 
-#Plugin installation is temporary code for window SDK
-/usr/bin/wrt-installer -p
-
 install_widgets
index 1b2f14c..a749efc 100644 (file)
@@ -1,7 +1,7 @@
-#git:framework/web/wrt-installer wrt-installer 0.0.94.1
+#git:framework/web/wrt-installer wrt-installer 0.1.12
 Name:       wrt-installer
 Summary:    Installer for tizen Webruntime
-Version:    0.0.94.1
+Version:    0.1.12
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
@@ -38,6 +38,11 @@ BuildRequires:  pkgconfig(dpl-encryption)
 BuildRequires:  pkgconfig(capi-appfw-app-manager)
 BuildRequires:  pkgconfig(drm-service-core-intel)
 BuildRequires:  pkgconfig(app2sd)
+BuildRequires:  pkgconfig(web-provider-svc)
+BuildRequires:  pkgconfig(libprivilege-control)
+BuildRequires:  pkgconfig(osp-appfw)
+BuildRequires:  osp-appfw-internal-devel
+Requires: osp-appfw
 Requires: xmlsec1
 
 %description
@@ -46,6 +51,11 @@ Description: Wrt Installer for Tizen apps and Wac apps
 %prep
 %setup -q
 
+%define with_tests 0
+%if "%{WITH_TESTS}" == "ON" || "%{WITH_TESTS}" == "Y" || "%{WITH_TESTS}" == "YES" || "%{WITH_TESTS}" == "TRUE" || "%{WITH_TESTS}" == "1"
+    %define with_tests 1
+%endif
+
 %build
 
 export LDFLAGS+="-Wl,--rpath=/usr/lib -Wl,--hash-style=both -Wl,--as-needed"
@@ -54,7 +64,8 @@ LDFLAGS="$LDFLAGS"
 cmake . -DCMAKE_INSTALL_PREFIX=/usr \
         -DDPL_LOG=ON \
         -DCMAKE_PACKAGE_VERSION=%{version} \
-        -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}
+        -DCMAKE_BUILD_TYPE=%{?build_type:%build_type} \
+        %{?WITH_TESTS:-DWITH_TESTS=%WITH_TESTS}
 make %{?jobs:-j%jobs}
 
 %install
@@ -70,8 +81,8 @@ ln -s ../wrt-preinstall-widgets.service %{buildroot}%{_libdir}/systemd/user/tize
 
 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
+ln -s ../init.d/wrt_preinstall_widgets.sh %{buildroot}%{_sysconfdir}/rc.d/rc3.d/S48lwrt_preinstall_widgets.sh
+ln -s ../init.d/wrt_preinstall_widgets.sh %{buildroot}%{_sysconfdir}/rc.d/rc5.d/S48lwrt_preinstall_widgets.sh
 
 %clean
 rm -rf %{buildroot}
@@ -84,6 +95,10 @@ ln -sf /usr/bin/wrt-installer /usr/etc/package-manager/backend/wgt
 
 #for booting recovery
 mkdir -p /opt/share/widget/temp_info
+[ -h /etc/rc.d/rc3.d/S48lwrt_preinstall_widgets.sh ] && rm /etc/rc.d/rc3.d/S48lwrt_preinstall_widgets.sh
+[ -h /etc/rc.d/rc5.d/S48lwrt_preinstall_widgets.sh ] && rm /etc/rc.d/rc5.d/S48lwrt_preinstall_widgets.sh
+ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc3.d/S48lwrt_preinstall_widgets.sh
+ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc5.d/S48lwrt_preinstall_widgets.sh
 
 # for downloadable Application icons path
 mkdir -p /opt/share/icons/default/small
@@ -92,10 +107,14 @@ mkdir -p /opt/share/icons/default/small
 %manifest wrt-installer.manifest
 %attr(755,root,root) %{_bindir}/wrt-installer
 %attr(775,root,root) %{_initddir}/wrt_preinstall_widgets.sh
-%{_sysconfdir}/rc.d/rc3.d/S46lwrt_preinstall_widgets.sh
-%{_sysconfdir}/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh
+%{_sysconfdir}/rc.d/rc3.d/S48lwrt_preinstall_widgets.sh
+%{_sysconfdir}/rc.d/rc5.d/S48lwrt_preinstall_widgets.sh
 %attr(644,root,root) %{_datadir}/edje/wrt/*
 /usr/etc/package-manager/backendlib/libwgt.so
 %{_datadir}/license/%{name}
 %{_libdir}/systemd/user/tizen-mobile-session.target.wants/wrt-preinstall-widgets.service
 %{_libdir}/systemd/user/wrt-preinstall-widgets.service
+%if %{with_tests}
+    %attr(755,root,root) %{_bindir}/wrt-installer-tests-*
+    /opt/share/widget/tests/installer/widgets/*
+%endif
index c07dbab..67b1189 100644 (file)
@@ -119,10 +119,12 @@ PKG_CHECK_MODULES(INSTALLER_STATIC_DEP
     dpl-wrt-dao-ro
     dpl-wrt-dao-rw
     wrt-commons-custom-handler-dao-rw
-    dpl-encryption
+    wrt-commons-security-origin-dao
     wrt-plugins-types
     pkgmgr-installer
     pkgmgr-parser
+    web-provider-svc
+    osp-appfw
     REQUIRED
 )
 
@@ -154,6 +156,7 @@ INCLUDE_DIRECTORIES(
     ${INSTALLER_DEP_INCLUDES}
     ${INSTALLER_INCLUDES}
     ${INSTALLER_STATIC_DEP_INCLUDE_DIRS}
+    ${OSP_APPFW_INCLUDES}
     )
 
 ADD_LIBRARY(${TARGET_INSTALLER_STATIC} STATIC
@@ -170,5 +173,8 @@ TARGET_LINK_LIBRARIES(${TARGET_INSTALLER_STATIC}
     ${SYS_INSTALLER_STATIC_DEP_LIBRARIES} "-ldl"
     )
 
+#for encryption
+TARGET_LINK_LIBRARIES(${TARGET_INSTALLER_STATIC} -L/usr/lib/osp -losp-appfw )
+
 ADD_SUBDIRECTORY(pkg-manager)
 ADD_SUBDIRECTORY(wrt-installer)
index 4fe586f..f888c85 100644 (file)
@@ -26,8 +26,8 @@
 #include <dpl/wrt-dao-ro/common_dao_types.h>
 
 /**
-* Widget version is optional
-*/
+ * Widget version is optional
+ */
 typedef DPL::Optional<WidgetVersion> OptionalWidgetVersion;
 
 /* Define db type */
index 22599f3..ae4f2de 100644 (file)
@@ -126,7 +126,8 @@ enum Type
     AlreadyRunning,         ///< Widget is already running
     AlreadyStopped,         ///< Widget is already stopped
     InvalidLanguage,        ///< Widget is invalid in current locales
-    StillAuthorizing,       ///< Widget is still autorizing and has not yet finished it
+    StillAuthorizing,       ///< Widget is still autorizing and has not yet
+                            // finished it
     EarlyKilled,            ///< Widget was early killed during launch
     AccessDenied,           ///< Access denied from ACE
     CertificateRevoked,     ///< Some certificate was revoked.
diff --git a/src/configuration_parser/WidgetConfigurationManager.cpp b/src/configuration_parser/WidgetConfigurationManager.cpp
deleted file mode 100644 (file)
index 94a7c54..0000000
+++ /dev/null
@@ -1,230 +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        WidgetConfigurationManager.cpp
- * @author      Piotr Fatyga (p.fatyga@samsung.com)
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     0.1
- * @brief
- */
-#include "WidgetConfigurationManager.h"
-#include <dirent.h>
-#include <dpl/wrt-dao-ro/global_config.h>
-#include "root_parser.h"
-#include "parser_runner.h"
-#include "widget_parser.h"
-#include <wrt_error.h>
-#include <dpl/utils/mime_type_utils.h>
-#include <dpl/localization/w3c_file_localization.h>
-#include <dpl/utils/wrt_utility.h>
-#include <dpl/singleton_impl.h>
-IMPLEMENT_SINGLETON(WidgetConfigurationManager)
-
-//TODO Rewrite this as steps/tasks
-namespace // anonymous
-{
-const char *const DEFAULT_LANGUAGE = "default";
-const size_t MAX_WIDGET_PATH_SIZE = 1024;
-
-//#define WRT_WIDGET_DEFAULT_ICON_WIDTH 80
-//#define WRT_WIDGET_DEFAULT_ICON_HEIGHT 80
-
-//#define WRT_WIDGET_CONFIG_BASE_LOCALE "locales"
-const char *const WRT_WIDGET_CONFIG_FILE_NAME = "config.xml";
-}
-
-bool WidgetConfigurationManager::locateAndParseConfigurationFile(
-        const std::string& _currentPath,
-        WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
-        const std::string& baseFolder,
-        int* pErrCode)
-{
-    using namespace WrtDB;
-
-    if (!pErrCode) {
-        return false;
-    }
-
-    ConfigParserData& configInfo = pWidgetConfigInfo.configInfo;
-
-    // check if this installation from browser, or not.
-    size_t pos = _currentPath.rfind("/");
-    std::ostringstream infoPath;
-    infoPath << _currentPath.substr(pos+1);
-
-    ParserRunner parser;
-    std::string language = "";
-
-    if (infoPath.str() != WRT_WIDGET_CONFIG_FILE_NAME) {
-        // in case of general installation using wgt archive
-        //TODO: use DPL::String in the caller to this function too.
-        DPL::String currentPath = DPL::FromUTF8String(_currentPath);
-
-        if (currentPath.empty() || baseFolder.empty()) {
-            *pErrCode = WRT_ERR_INVALID_ARG;
-            return false;
-        }
-
-        //TODO: rewrite this madness
-        char cfgAbsPath[MAX_WIDGET_PATH_SIZE + 1] = { 0 };
-        DIR* dir = NULL;
-        struct dirent* ptr = NULL;
-
-        dir = opendir(_currentPath.c_str());
-        if (dir == NULL) {
-            *pErrCode = WRT_ERR_UNKNOWN;
-            return false;
-        }
-
-        //TODO why don't we use fopen here
-        bool has_config_xml = false;
-        errno = 0;
-        while ((ptr = readdir(dir)) != NULL) { //Find configuration file, based on its name
-            if (ptr->d_type == DT_REG) {
-                if (!strcmp(ptr->d_name, WRT_WIDGET_CONFIG_FILE_NAME)) {
-                    _WrtUtilSetAbsolutePath(cfgAbsPath,
-                                            _currentPath.c_str(), ptr->d_name);
-                    //Parse widget configuration file
-                    LogDebug("Found config: " << cfgAbsPath);
-
-                    Try
-                    {
-                        parser.Parse(cfgAbsPath, ElementParserPtr(new
-                                                                  RootParser<
-                                                                      WidgetParser>(
-                                                                      configInfo,
-                                                                      DPL
-                                                                          ::
-                                                                          FromUTF32String(
-                                                                          L"widget"))));
-                    }
-                    Catch(ElementParser::Exception::Base)
-                    {
-                        LogDebug("Invalid widget configuration file!");
-                        //                    _rethrown_exception.Dump();
-                        *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
-                        closedir(dir);
-                        return false;
-                    }
-
-                    //
-                    //                WidgetConfigurationParser & parser = WidgetConfigurationParserSingleton::Instance();
-                    //                if (!parser.parseConfigurationFile(cfgAbsPath, configInfo, baseFolder.c_str(), pWidgetConfigInfo.signature_type)) {
-                    //                    LogDebug("Invalid widget configuration file!");
-                    //                    *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
-                    //                    closedir(dir);
-                    //                    return false;
-                    //                }
-
-                    has_config_xml = true;
-                    break;
-                }
-            }
-        }
-        closedir(dir);
-
-        //We must have config.xml so leaveing if we doesn't
-        if (!has_config_xml) {
-            LogDebug("Invalid archive");
-            *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
-            return false;
-        }
-    } else {
-        // in case of browser installation
-        Try
-        {
-            parser.Parse(_currentPath, ElementParserPtr(new
-                                                      RootParser<
-                                                          WidgetParser>(
-                                                          configInfo,
-                                                          DPL::FromUTF32String(
-                                                              L"widget"))));
-        }
-        Catch(ElementParser::Exception::Base)
-        {
-            LogDebug("Invalid widget configuration file!");
-            //                    _rethrown_exception.Dump();
-            *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
-            return false;
-        }
-    }
-
-
-    char *tmp_language;
-    if (!_WrtUtilStringToLower(baseFolder.c_str(), &tmp_language)) {
-        *pErrCode = WRT_ERR_UNKNOWN;
-        return false;
-    }
-
-    if (!tmp_language) {
-        *pErrCode = WRT_ERR_UNKNOWN;
-        return false;
-    }
-    language = tmp_language;
-    free(tmp_language);
-
-    if (!!configInfo.widget_id) {
-        if (!pWidgetConfigInfo.guid) {
-            pWidgetConfigInfo.guid = configInfo.widget_id;
-        } else {
-            if (pWidgetConfigInfo.guid != configInfo.widget_id) {
-                *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
-                LogDebug("Invalid archive");
-                return false;
-            }
-        }
-    }
-
-    if (!!configInfo.tizenId) {
-        if (pWidgetConfigInfo.pkgName != *configInfo.tizenId) {
-            *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
-            LogDebug("Invalid archive - Tizen ID not same error");
-            return false;
-        }
-    }
-
-    if (!!configInfo.version) {
-        if (!pWidgetConfigInfo.version) {
-            pWidgetConfigInfo.version = configInfo.version;
-        } else {
-            if (pWidgetConfigInfo.version != configInfo.version) {
-                *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
-                LogDebug("Invalid archive");
-                return false;
-            }
-        }
-    }
-
-    if (!!configInfo.minVersionRequired) {
-        pWidgetConfigInfo.minVersion = configInfo.minVersionRequired;
-    } else if (!!configInfo.tizenMinVersionRequired) {
-        pWidgetConfigInfo.minVersion = configInfo.tizenMinVersionRequired;
-    }
-
-    return true;
-}
-
-void WidgetConfigurationManager::processFile(const std::string& path,
-        WrtDB::WidgetRegisterInfo &widgetConfiguration)
-{
-    int pErrCode;
-
-    if (!locateAndParseConfigurationFile(path, widgetConfiguration,
-                                         DEFAULT_LANGUAGE, &pErrCode)) {
-        LogWarning("Widget archive: Failed while parsing config file");
-        ThrowMsg(Exception::ProcessFailed, path);
-    }
-}
diff --git a/src/configuration_parser/WidgetConfigurationManager.h b/src/configuration_parser/WidgetConfigurationManager.h
deleted file mode 100644 (file)
index 84ad2f7..0000000
+++ /dev/null
@@ -1,65 +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        WidgetConfigurationManager.h
- * @author      Piotr Fatyga (p.fatyga@samsung.com)
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     0.1
- * @brief
- */
-#ifndef _WIDGETCONFIGURATIONMANAGER_H
-#define _WIDGETCONFIGURATIONMANAGER_H
-
-#include <dpl/singleton.h>
-#include <dpl/string.h>
-#include <dpl/optional.h>
-#include <dpl/wrt-dao-ro/config_parser_data.h>
-#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
-#include <list>
-
-class WidgetConfigurationManager
-{
-  public:
-    class Exception
-    {
-      public:
-        DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
-        DECLARE_EXCEPTION_TYPE(Base, ProcessFailed)
-    };
-
-    /**
-     * This method is used to process the config.xml of widget, get
-     * the corresponding configuration to pWidgetConfigInfo
-     *
-     * @param[in] path Specified the widget archive file path (absolute path).
-     * @return         Configuration information of  widget
-     */
-    void processFile(const std::string& path,
-                     WrtDB::WidgetRegisterInfo &wConfig);
-
-  private:
-    typedef std::list<std::pair<DPL::String, DPL::String> > StringPairList;
-
-    bool locateAndParseConfigurationFile(const std::string& currentPath,
-            WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
-            const std::string& baseFolder,
-            int* pErrCode);
-};
-
-typedef DPL::Singleton<WidgetConfigurationManager>
-WidgetConfigurationManagerSingleton;
-
-#endif // _WIDGETCONFIGURATIONMANAGER_H
index cffa56a..e807d5e 100644 (file)
@@ -17,8 +17,7 @@
 #include <dpl/assert.h>
 
 DenyAllParser::DenyAllParser() : ElementParser()
-{
-}
+{}
 
 ElementParserPtr DenyAllParser::Create()
 {
@@ -26,7 +25,7 @@ ElementParserPtr DenyAllParser::Create()
 }
 
 ElementParser::ActionFunc DenyAllParser::GetElementParser(const DPL::String& /*ns*/,
-        const DPL::String& /*name*/)
+                                                          const DPL::String& /*name*/)
 {
     ThrowMsg(Exception::ParseError, "There must not be any subelement");
 }
index 2d45707..d9dfe56 100644 (file)
@@ -31,10 +31,9 @@ struct DenyAllParser : public ElementParser
     virtual void Accept(const XmlAttribute& /*attribute*/);
     virtual void Accept(const Text& /*text*/);
     virtual void Verify()
-    {
-    }
+    {}
     virtual ActionFunc GetElementParser(const DPL::String& ns,
-            const DPL::String& name);
+                                        const DPL::String& name);
 
     DenyAllParser();
 };
index 4751672..a44f94a 100644 (file)
@@ -79,15 +79,13 @@ class ElementParser : public std::enable_shared_from_this<ElementParser>
     virtual void Accept(const Text&) = 0;
     virtual void Verify() = 0;
     virtual ActionFunc GetElementParser(const DPL::String &ns,
-            const DPL::String &name) = 0;
+                                        const DPL::String &name) = 0;
     virtual ~ElementParser()
-    {
-    }
+    {}
 
   protected:
     ElementParser()
-    {
-    }
+    {}
 };
 
 #endif // ELEMENT_PARSER_H_
index 9fc90a0..29520d5 100644 (file)
@@ -24,8 +24,7 @@
 #include <memory>
 
 IgnoringParser::IgnoringParser() : ElementParser()
-{
-}
+{}
 
 ElementParserPtr IgnoringParser::Create()
 {
@@ -38,23 +37,19 @@ ElementParserPtr IgnoringParser::Reuse()
 }
 
 ElementParser::ActionFunc IgnoringParser::GetElementParser(const DPL::String& /*ns*/,
-        const DPL::String& /*name*/)
+                                                           const DPL::String& /*name*/)
 {
     return DPL::MakeDelegate(this, &IgnoringParser::Reuse);
 }
 
 void IgnoringParser::Accept(const Element& /*element*/)
-{
-}
+{}
 
 void IgnoringParser::Accept(const Text& /*text*/)
-{
-}
+{}
 
 void IgnoringParser::Accept(const XmlAttribute& /*attribute*/)
-{
-}
+{}
 
 void IgnoringParser::Verify()
-{
-}
+{}
index 9f1f6d5..b14f1ad 100644 (file)
@@ -28,7 +28,7 @@ struct IgnoringParser : public ElementParser
 {
     static ElementParserPtr Create();
     virtual ActionFunc GetElementParser(const DPL::String& ns,
-            const DPL::String& name);
+                                        const DPL::String& name);
     virtual void Accept(const Element&);
     virtual void Accept(const Text&);
     virtual void Accept(const XmlAttribute&);
index f429344..6d8de2a 100644 (file)
@@ -27,8 +27,7 @@
 
 namespace LibIri {
 Wrapper::Wrapper(const char* aIri) : m_Iri(iri_parse(aIri))
-{
-}
+{}
 Wrapper::~Wrapper()
 {
     iri_destroy(m_Iri);
@@ -52,10 +51,10 @@ bool Wrapper::Validate()
 }
 
 std::ostream & operator<<(std::ostream& a_stream,
-        const Wrapper& a_wrapper)
+                          const Wrapper& a_wrapper)
 {
     iri_t& iri = *a_wrapper.m_Iri;
-#define PRINT_FIELD(field) "] " # field " [" << (iri.field ? iri.field : "null")
+#define PRINT_FIELD(field) "] " #field " [" << (iri.field ? iri.field : "null")
     a_stream <<
     " display [" << (iri.display ? iri.display : "null") <<
     PRINT_FIELD(scheme) <<
index 1029059..b0b3e86 100644 (file)
@@ -39,7 +39,7 @@ struct Wrapper
 };
 
 std::ostream & operator<<(std::ostream& a_stream,
-        const Wrapper& a_wrapper);
+                          const Wrapper& a_wrapper);
 } //namespace LibIri
 
 #endif // _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_LIBIRIWRAPPER_H_
index 6de0c0d..cff02f7 100644 (file)
@@ -33,14 +33,14 @@ class ParserRunner::Impl
 {
   public:
     void Parse(const std::string& filename,
-            const ElementParserPtr& root)
+               const ElementParserPtr& root)
     {
         DPL::FileInput input(filename);
         Parse(&input, root);
     }
 
     void Parse (DPL::AbstractInput *input,
-            const ElementParserPtr& root)
+                const ElementParserPtr& root)
     {
         Try
         {
@@ -123,8 +123,7 @@ class ParserRunner::Impl
     Impl() :
         m_reader(NULL),
         m_parsingError(false)
-    {
-    }
+    {}
 
     ~Impl()
     {
@@ -136,24 +135,24 @@ class ParserRunner::Impl
 
   private:
     static void xmlTextReaderErrorHandler(void* arg,
-            const char* msg,
-            xmlParserSeverities /* severity */,
-            xmlTextReaderLocatorPtr /* locator */)
+                                          const char* msg,
+                                          xmlParserSeverities /* severity */,
+                                          xmlTextReaderLocatorPtr /* locator */)
     {
         ParserRunner::Impl* impl = static_cast<ParserRunner::Impl*>(arg);
         impl->ErrorHandler(DPL::FromASCIIString(msg));
     }
 
     static void xmlTextReaderStructuredErrorHandler(void* arg,
-            xmlErrorPtr error)
+                                                    xmlErrorPtr error)
     {
         ParserRunner::Impl* impl = static_cast<ParserRunner::Impl*>(arg);
         impl->StructuredErrorHandler(error);
     }
 
     static int XMLCALL IoRead(void *context,
-            char *buffer,
-            int len)
+                              char *buffer,
+                              int len)
     {
         DPL::AbstractInput *input = static_cast<DPL::AbstractInput *>(context);
         DPL::BinaryQueueAutoPtr data = input->Read(static_cast<size_t>(len));
@@ -384,17 +383,16 @@ class ParserRunner::Impl
 
 ParserRunner::ParserRunner() :
     m_impl(new ParserRunner::Impl())
-{
-}
+{}
 
 void ParserRunner::Parse(const std::string& filename,
-        ElementParserPtr root)
+                         ElementParserPtr root)
 {
     m_impl->Parse(filename, root);
 }
 
 void ParserRunner::Parse(DPL::AbstractInput *input,
-        ElementParserPtr root)
+                         ElementParserPtr root)
 {
     m_impl->Parse(input, root);
 }
index 1176165..80a3208 100644 (file)
@@ -31,9 +31,9 @@ class ParserRunner : private DPL::Noncopyable
 {
   public:
     void Parse(const std::string& filename,
-            ElementParserPtr root);
+               ElementParserPtr root);
     void Parse(DPL::AbstractInput *input,
-            ElementParserPtr root);
+               ElementParserPtr root);
 
     ParserRunner();
     ~ParserRunner();
index 3f4a86b..df7ea6a 100644 (file)
@@ -31,7 +31,7 @@ class RootParser : public ElementParser
   public:
     typedef typename ta_Parser::Data Data;
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& name)
+                                        const DPL::String& name)
     {
         if (name == m_tag) {
             return DPL::MakeDelegate(this,
@@ -43,15 +43,13 @@ class RootParser : public ElementParser
     }
 
     RootParser(Data data,
-            const DPL::String& tag) :
+               const DPL::String& tag) :
         m_data(data),
         m_tag(tag)
-    {
-    }
+    {}
 
     virtual ~RootParser()
-    {
-    }
+    {}
 
     virtual void Accept(const Element& /*element*/)
     {
old mode 100755 (executable)
new mode 100644 (file)
index d740ac3..3b0a0ec
@@ -13,7 +13,7 @@
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
  */
- /**
+/**
  * This file  have been implemented in compliance with  W3C WARP SPEC.
  * but there are some patent issue between  W3C WARP SPEC and APPLE.
  * so if you want to use this file, refer to the README file in root directory
@@ -68,7 +68,7 @@ Direction ParseDirAttribute(const XmlAttribute& attribute)
 }
 
 void UpdateTextWithDirectionMark(Direction direction,
-        DPL::String* text)
+                                 DPL::String* text)
 {
     Assert(text);
     switch (direction) {
@@ -88,6 +88,7 @@ void UpdateTextWithDirectionMark(Direction direction,
         break;
     default:
         Assert(false);
+        break;
     }
 }
 } // namespace Unicode
@@ -96,14 +97,13 @@ class InnerElementsParser : public ElementParser
 {
   public:
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& /*name*/)
+                                        const DPL::String& /*name*/)
     {
         return DPL::MakeDelegate(this, &InnerElementsParser::Other);
     }
 
     virtual void Accept(const Element& /*element*/)
-    {
-    }
+    {}
 
     virtual void Accept(const Text& text)
     {
@@ -133,8 +133,7 @@ class InnerElementsParser : public ElementParser
     InnerElementsParser(ElementParserPtr parent) :
         m_parentParser(parent),
         m_textDirection(Unicode::EMPTY)
-    {
-    }
+    {}
 
     ElementParserPtr Other()
     {
@@ -153,7 +152,7 @@ class NameParser : public ElementParser
 {
   public:
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& /*name*/)
+                                        const DPL::String& /*name*/)
     {
         return DPL::MakeDelegate(this, &NameParser::Other);
     }
@@ -203,11 +202,10 @@ class NameParser : public ElementParser
     }
 
     NameParser(Unicode::Direction direction,
-            ConfigParserData& data) :
+               ConfigParserData& data) :
         m_data(data),
         m_textDirection(direction)
-    {
-    }
+    {}
 
     ElementParserPtr Other()
     {
@@ -235,7 +233,7 @@ class AccessParser : public ElementParser
     };
 
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& /*name*/)
+                                        const DPL::String& /*name*/)
     {
         return DPL::MakeDelegate(this, &AccessParser::Other);
     }
@@ -251,8 +249,7 @@ class AccessParser : public ElementParser
     }
 
     virtual void Accept(const Text& /*text*/)
-    {
-    }
+    {}
 
     void AcceptWac(const XmlAttribute& attribute)
     {
@@ -279,6 +276,7 @@ class AccessParser : public ElementParser
             break;
         default:
             LogError("Error in Access tag - unknown standard.");
+            break;
         }
     }
 
@@ -297,7 +295,7 @@ class AccessParser : public ElementParser
 
         ConfigParserData::AccessInfo accessInfo(m_strIRIOrigin,
                                                 m_bSubDomainAccess);
-        std::pair <ConfigParserData::AccessInfoSet::iterator, bool> ret =
+        //std::pair <ConfigParserData::AccessInfoSet::iterator, bool> ret =
             m_data.accessInfoSet.insert(accessInfo);
     }
 
@@ -309,6 +307,7 @@ class AccessParser : public ElementParser
             break;
         default:
             LogError("Error in Access tag - unknown standard.");
+            break;
         }
     }
 
@@ -318,8 +317,7 @@ class AccessParser : public ElementParser
         m_standardType(STANDARD_TYPE_NONE),
         m_network(false),
         m_data(data)
-    {
-    }
+    {}
 
     ElementParserPtr Other()
     {
@@ -339,7 +337,7 @@ class DescriptionParser : public ElementParser
 {
   public:
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& /*name*/)
+                                        const DPL::String& /*name*/)
     {
         return DPL::MakeDelegate(this, &DescriptionParser::Other);
     }
@@ -386,13 +384,12 @@ class DescriptionParser : public ElementParser
     }
 
     DescriptionParser(Unicode::Direction direction,
-            ConfigParserData& data) :
+                      ConfigParserData& data) :
         m_data(data),
         m_lang(),
         m_description(),
         m_textDirection(direction)
-    {
-    }
+    {}
 
   private:
     ConfigParserData& m_data;
@@ -405,17 +402,16 @@ class AuthorParser : public ElementParser
 {
   public:
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& /*name*/)
+                                        const DPL::String& /*name*/)
     {
         return DPL::MakeDelegate(this, &AuthorParser::Other);
     }
 
     AuthorParser(Unicode::Direction direction,
-            ConfigParserData& data) :
+                 ConfigParserData& data) :
         m_data(data),
         m_textDirection(direction)
-    {
-    }
+    {}
 
     virtual void Accept(const Element& /*element*/)
     {
@@ -482,18 +478,17 @@ class LicenseParser : public ElementParser
 {
   public:
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& /*name*/)
+                                        const DPL::String& /*name*/)
     {
         return DPL::MakeDelegate(this, &LicenseParser::Other);
     }
 
     LicenseParser(Unicode::Direction direction,
-            ConfigParserData& data) :
+                  ConfigParserData& data) :
         m_data(data),
         m_ignore(true),
         m_textDirection(direction)
-    {
-    }
+    {}
 
     virtual void Accept(const Element& element)
     {
@@ -561,19 +556,17 @@ class IconParser : public ElementParser
 
   public:
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& /*name*/)
+                                        const DPL::String& /*name*/)
     {
         return &IgnoringParser::Create;
     }
 
     IconParser(ConfigParserData& data) : ElementParser(),
         m_data(data)
-    {
-    }
+    {}
 
     virtual void Accept(const Element& /*element*/)
-    {
-    }
+    {}
 
     virtual void Accept(const XmlAttribute& attribute)
     {
@@ -635,7 +628,8 @@ class IconParser : public ElementParser
                 strtol(DPL::ToUTF8String(value).c_str(), &reterr, 10);
             if (errno != 0 ||
                 std::string(reterr) == DPL::ToUTF8String(value) ||
-                valueInt <= 0) {
+                valueInt <= 0)
+            {
                 return DPL::OptionalInt::Null;
             } else {
                 return valueInt;
@@ -645,7 +639,8 @@ class IconParser : public ElementParser
     }
 
     /**
-     * @brief delocalizePath removes locales folder from relative path if neccessary
+     * @brief delocalizePath removes locales folder from relative path if
+     * neccessary
      * @param source source string
      *
      * @throw BadSrcError if string is bad value of src attribute
@@ -659,15 +654,11 @@ class IconParser : public ElementParser
 
         DPL::String result = source;
 
-        if(source.substr(0,index) == localeFolder)
-        {
-            size_t pos = result.find_first_of('/',index);
-            if(pos != std::string::npos && pos + 1 < source.size())
-            {
-                result = result.substr(pos + 1,source.size());
-            }
-            else
-            {
+        if (source.substr(0, index) == localeFolder) {
+            size_t pos = result.find_first_of('/', index);
+            if (pos != std::string::npos && pos + 1 < source.size()) {
+                result = result.substr(pos + 1, source.size());
+            } else {
                 Throw(BadSrcError);
             }
         }
@@ -679,7 +670,7 @@ class ContentParser : public ElementParser
 {
   public:
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& /*name*/)
+                                        const DPL::String& /*name*/)
     {
         return &IgnoringParser::Create;
     }
@@ -687,16 +678,13 @@ class ContentParser : public ElementParser
     ContentParser(ConfigParserData& data) :
         ElementParser(),
         m_data(data)
-    {
-    }
+    {}
 
     virtual void Accept(const Element& /*element*/)
-    {
-    }
+    {}
 
     virtual void Accept(const Text& /*text*/)
-    {
-    }
+    {}
 
     virtual void Accept(const XmlAttribute& attribute)
     {
@@ -756,7 +744,7 @@ class FeatureParser : public ElementParser
     struct ParamParser : public ElementParser
     {
         virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-                const DPL::String& /*name*/)
+                                            const DPL::String& /*name*/)
         {
             return &IgnoringParser::Create;
         }
@@ -773,8 +761,7 @@ class FeatureParser : public ElementParser
         }
 
         virtual void Accept(const Element& /*element*/)
-        {
-        }
+        {}
 
         virtual void Accept(const Text& /*text*/)
         {
@@ -801,8 +788,7 @@ class FeatureParser : public ElementParser
         ParamParser(ConfigParserData::Feature& data) :
             ElementParser(),
             m_data(data)
-        {
-        }
+        {}
 
       private:
         DPL::OptionalString m_name;
@@ -811,7 +797,7 @@ class FeatureParser : public ElementParser
     };
 
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& name)
+                                        const DPL::String& name)
     {
         if (name == L"param") {
             return DPL::MakeDelegate(this, &FeatureParser::OnParamElement);
@@ -821,12 +807,10 @@ class FeatureParser : public ElementParser
     }
 
     virtual void Accept(const Text& /*text*/)
-    {
-    }
+    {}
 
     virtual void Accept(const Element& /*element*/)
-    {
-    }
+    {}
 
     virtual void Accept(const XmlAttribute& attribute)
     {
@@ -848,7 +832,8 @@ class FeatureParser : public ElementParser
         if (m_feature.name != L"") {
             if (iri.Validate()) {
                 if (m_data.featuresList.find(m_feature) ==
-                    m_data.featuresList.end()) {
+                    m_data.featuresList.end())
+                {
                     m_data.featuresList.insert(m_feature);
                 } else {
                     LogDebug("Ignoring feature with name" <<
@@ -872,8 +857,7 @@ class FeatureParser : public ElementParser
         ElementParser(),
         m_data(data),
         m_feature(L"")
-    {
-    }
+    {}
 
   private:
     ConfigParserData& m_data;
@@ -884,7 +868,7 @@ class PreferenceParser : public ElementParser
 {
   public:
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& /*name*/)
+                                        const DPL::String& /*name*/)
     {
         return &IgnoringParser::Create;
     }
@@ -905,8 +889,7 @@ class PreferenceParser : public ElementParser
     }
 
     virtual void Accept(const Element& /*element*/)
-    {
-    }
+    {}
 
     virtual void Accept(const Text& /*text*/)
     {
@@ -924,7 +907,8 @@ class PreferenceParser : public ElementParser
         ConfigParserData::Preference preference(*m_name, m_required);
         preference.value = m_value;
         if (m_data.preferencesList.find(preference) ==
-            m_data.preferencesList.end()) {
+            m_data.preferencesList.end())
+        {
             m_data.preferencesList.insert(preference);
         }
     }
@@ -933,8 +917,7 @@ class PreferenceParser : public ElementParser
         ElementParser(),
         m_required(false),
         m_data(data)
-    {
-    }
+    {}
 
   private:
     DPL::OptionalString m_name;
@@ -947,7 +930,7 @@ class LinkParser : public ElementParser
 {
   public:
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& /*name*/)
+                                        const DPL::String& /*name*/)
     {
         return &DenyAllParser::Create;
     }
@@ -961,8 +944,9 @@ class LinkParser : public ElementParser
                     ThrowMsg(Exception::ParseError,
                              "rel attribute must have describedby value");
                 }
-            } else if (attribute.name == L"type") {
-            } else if (attribute.name == L"href") {
+            } else if (attribute.name == L"type") {} else if (attribute.name ==
+                                                              L"href")
+            {
                 LogDebug("here is href");
                 m_href = attribute.value;
             } else {
@@ -1011,8 +995,7 @@ class LinkParser : public ElementParser
         m_properNamespace(false),
         m_data(data),
         m_href(DPL::OptionalString::Null)
-    {
-    }
+    {}
 
   private:
     bool m_properNamespace;
@@ -1024,18 +1007,16 @@ class SettingParser : public ElementParser
 {
   public:
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& /*name*/)
+                                        const DPL::String& /*name*/)
     {
         return &IgnoringParser::Create;
     }
 
     virtual void Accept(const Text& /*text*/)
-    {
-    }
+    {}
 
     virtual void Accept(const Element& /*element*/)
-    {
-    }
+    {}
 
     virtual void Accept(const XmlAttribute& attribute)
     {
@@ -1045,15 +1026,13 @@ class SettingParser : public ElementParser
     }
 
     virtual void Verify()
-    {
-    }
+    {}
 
     SettingParser(ConfigParserData& data) :
         ElementParser(),
         m_data(data),
         m_setting(L"", L"")
-    {
-    }
+    {}
 
   private:
     ConfigParserData& m_data;
@@ -1079,6 +1058,10 @@ class AppServiceParser : public ElementParser
             m_scheme = attribute.value;
         } else if (attribute.name == L"mime") {
             m_mime = attribute.value;
+        } else if (attribute.name == L"disposition") {
+            if (attribute.value == L"inline")
+                m_disposition =
+                    ConfigParserData::ServiceInfo::Disposition::INLINE;
         }
     }
 
@@ -1087,7 +1070,7 @@ class AppServiceParser : public ElementParser
         LogWarning("namespace for app service = " << element.ns);
         if (element.ns == ConfigurationNamespace::W3CWidgetNamespaceName) {
             ThrowMsg(Exception::ParseError,
-                "Wrong xml namespace for widget element");
+                     "Wrong xml namespace for widget element");
         }
     }
 
@@ -1110,37 +1093,47 @@ class AppServiceParser : public ElementParser
         NormalizeString(m_scheme);
         NormalizeString(m_mime);
 
+        // exception
+        DPL::String ignoreUri(L"file");
+
+        if (!m_scheme.IsNull() && *m_scheme == ignoreUri)
+        {
+            LogInfo("exception : '" << *m_scheme << "' scheme will be ignored.");
+            m_scheme = DPL::OptionalString::Null;
+        }
+
         // verify duplicate element
         DPL::String wildString(L"*/*");
         DPL::String nullString(L"");
         ConfigParserData::ServiceInfo serviceInfo(
-            m_src.IsNull()       ? nullString:*m_src,
-            m_operation.IsNull() ? nullString:*m_operation,
-            m_scheme.IsNull()    ? nullString:*m_scheme,
-            m_mime.IsNull()      ? nullString:*m_mime);
+            m_src.IsNull() ? nullString : *m_src,
+            m_operation.IsNull() ? nullString : *m_operation,
+            m_scheme.IsNull() ? nullString : *m_scheme,
+            m_mime.IsNull() ? nullString : *m_mime,
+            m_disposition);
 
         FOREACH(iterator, m_data.appServiceList) {
             if (iterator->m_operation == serviceInfo.m_operation &&
                 // check scheme
                 (iterator->m_scheme == serviceInfo.m_scheme ||
-                // check input scheme is "*/*" case
-                (iterator->m_scheme == wildString &&
-                 serviceInfo.m_scheme != nullString) ||
-                // check iterator scheme is "*/*" case
-                (serviceInfo.m_scheme == wildString &&
-                 iterator->m_scheme != nullString)) &&
+                 // check input scheme is "*/*" case
+                 (iterator->m_scheme == wildString &&
+                  serviceInfo.m_scheme != nullString) ||
+                 // check iterator scheme is "*/*" case
+                 (serviceInfo.m_scheme == wildString &&
+                  iterator->m_scheme != nullString)) &&
 
                 (iterator->m_mime == serviceInfo.m_mime ||
-                // check input mime is "*/*" case
-                (iterator->m_mime == wildString &&
-                 serviceInfo.m_mime != nullString) ||
-                // check iterator mime is "*/*" case
-                (serviceInfo.m_mime == wildString &&
-                 iterator->m_mime != nullString)))
+                 // check input mime is "*/*" case
+                 (iterator->m_mime == wildString &&
+                  serviceInfo.m_mime != nullString) ||
+                 // check iterator mime is "*/*" case
+                 (serviceInfo.m_mime == wildString &&
+                  iterator->m_mime != nullString)))
             {
                 ThrowMsg(Exception::ParseError,
-                    "service operation is duplicated " +
-                    DPL::ToUTF8String(*m_operation));
+                         "service operation is duplicated " +
+                         DPL::ToUTF8String(*m_operation));
             }
         }
         m_data.appServiceList.push_back(serviceInfo);
@@ -1152,262 +1145,259 @@ class AppServiceParser : public ElementParser
         m_operation(DPL::OptionalString::Null),
         m_scheme(DPL::OptionalString::Null),
         m_mime(DPL::OptionalString::Null),
+        m_disposition(ConfigParserData::ServiceInfo::Disposition::WINDOW),
         m_data(data)
-    {
-    }
+    {}
 
   private:
     DPL::OptionalString m_src;
     DPL::OptionalString m_operation;
     DPL::OptionalString m_scheme;
     DPL::OptionalString m_mime;
+    ConfigParserData::ServiceInfo::Disposition m_disposition;
     ConfigParserData& m_data;
 };
 
 class AppControlParser : public ElementParser
 {
   public:
-     struct SourceParser : public ElementParser
-     {
-         public:
-             virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-                     const DPL::String& /*name*/)
-             {
-                 return &IgnoringParser::Create;
-             }
-
-             virtual void Accept(const Text& /*text*/)
-             {
-             }
-
-             virtual void Accept(const Element& /*element*/)
-             {
-             }
-
-             virtual void Accept(const XmlAttribute& attribute)
-             {
-                 if (attribute.name == L"name") {
-                     if (attribute.value.size() > 0) {
-                         m_value = attribute.value;
-                         NormalizeString(m_value);
-                     }
-                 }
-             }
-
-             virtual void Verify()
-             {
-                 if (m_value.IsNull() || *m_value== L"") {
-                     return;
-                 }
-
-                 m_data.m_src = *m_value;
-             }
-
-             SourceParser(ConfigParserData::AppControlInfo& data) :
-                 ElementParser(),
-                 m_properNamespace(false),
-                 m_data(data)
-         {
-         }
-
-         private:
-             bool m_properNamespace;
-             DPL::OptionalString m_value;
-             ConfigParserData::AppControlInfo& m_data;
-     };
-
-     struct OperationParser : public ElementParser
-     {
-         public:
-             virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-                     const DPL::String& /*name*/)
-             {
-                 return &IgnoringParser::Create;
-             }
-
-             virtual void Accept(const Text& /*text*/)
-             {
-             }
-
-             virtual void Accept(const Element& /*element*/)
-             {
-             }
-
-             virtual void Accept(const XmlAttribute& attribute)
-             {
-                 if (attribute.name == L"name") {
-                     if (attribute.value.size() > 0) {
-                         m_value = attribute.value;
-                         NormalizeString(m_value);
-                     }
-                 }
-             }
-
-             virtual void Verify()
-             {
-                 if (m_value.IsNull() || *m_value== L"") {
-                     return;
-                 }
-
-                 m_data.m_operation = *m_value;
-             }
-
-             OperationParser(ConfigParserData::AppControlInfo& data) :
-                 ElementParser(),
-                 m_properNamespace(false),
-                 m_data(data)
-         {
-         }
-
-         private:
-             bool m_properNamespace;
-             DPL::OptionalString m_value;
-             ConfigParserData::AppControlInfo& m_data;
-     };
-
-     struct UriParser : public ElementParser
-     {
-         public:
-             virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-                     const DPL::String& /*name*/)
-             {
-                 return &IgnoringParser::Create;
-             }
-
-             virtual void Accept(const Text& /*text*/)
-             {
-             }
-
-             virtual void Accept(const Element& /*element*/)
-             {
-             }
-
-             virtual void Accept(const XmlAttribute& attribute)
-             {
-                 if (attribute.name == L"name") {
-                     if (attribute.value.size() > 0) {
-                         m_value = attribute.value;
-                         NormalizeString(m_value);
-                     }
-                 }
-             }
-
-             virtual void Verify()
-             {
-                 if (m_value.IsNull() || *m_value == L"") {
-                     return;
-                 }
-
-                 DPL::String wildString(L"*/*");
-                 if ((m_data.m_uriList.find(wildString) ==
-                             m_data.m_uriList.end())
-                         && (m_data.m_uriList.find(*m_value) ==
-                             m_data.m_uriList.end())) {                   
-                         
-                     m_data.m_uriList.insert(*m_value);
-                 } else {
-                     LogDebug("Ignoring uri with name" <<
-                             DPL::ToUTF8String(*m_value));
-                 }
-             }
-
-             UriParser(ConfigParserData::AppControlInfo& data) :
-                 ElementParser(),
-                 m_properNamespace(false),
-                 m_data(data)
-         {
-         }
-
-         private:
-             bool m_properNamespace;
-             DPL::OptionalString m_value;
-             ConfigParserData::AppControlInfo& m_data;
-     };
-
-     struct MimeParser : public ElementParser
-     {
-         public:
-             virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-                     const DPL::String& /*name*/)
-             {
-                 return &IgnoringParser::Create;
-             }
-
-             virtual void Accept(const Text& /*text*/)
-             {
-             }
-
-             virtual void Accept(const Element& /*element*/)
-             {
-             }
-
-             virtual void Accept(const XmlAttribute& attribute)
-             {
-                 if (attribute.name == L"name") {
-                     if (attribute.value.size() > 0) {
-                         m_value = attribute.value;
-                         NormalizeString(m_value);
-                     }
-                 }
-             }
-
-             virtual void Verify()
-             {
-                 if (m_value.IsNull() || *m_value == L"") {
-                     return;
-                 }
-
-                 DPL::String wildString(L"*/*");
-                 if ((m_data.m_mimeList.find(wildString) ==
-                             m_data.m_mimeList.end())
-                         && (m_data.m_mimeList.find(*m_value) ==
-                             m_data.m_mimeList.end())) {                   
-                     m_data.m_mimeList.insert(*m_value);
-                 } else {
-                     LogDebug("Ignoring mime with name" <<
-                             DPL::ToUTF8String(*m_value));
-                 }
-             }
-
-             MimeParser(ConfigParserData::AppControlInfo& data) :
-                 ElementParser(),
-                 m_properNamespace(false),
-                 m_data(data)
-         {
-         }
-
-         private:
-             bool m_properNamespace;
-             DPL::OptionalString m_value;
-             ConfigParserData::AppControlInfo& m_data;
-     };
-     
+    struct SourceParser : public ElementParser
+    {
+      public:
+        virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+                                            const DPL::String& /*name*/)
+        {
+            return &IgnoringParser::Create;
+        }
+
+        virtual void Accept(const Text& /*text*/)
+        {}
+
+        virtual void Accept(const Element& /*element*/)
+        {}
+
+        virtual void Accept(const XmlAttribute& attribute)
+        {
+            if (attribute.name == L"name") {
+                if (attribute.value.size() > 0) {
+                    m_value = attribute.value;
+                    NormalizeString(m_value);
+                }
+            }
+        }
+
+        virtual void Verify()
+        {
+            if (m_value.IsNull() || *m_value == L"") {
+                return;
+            }
+
+            m_data.m_src = *m_value;
+        }
+
+        SourceParser(ConfigParserData::AppControlInfo& data) :
+            ElementParser(),
+            m_properNamespace(false),
+            m_data(data)
+        {}
+
+      private:
+        bool m_properNamespace;
+        DPL::OptionalString m_value;
+        ConfigParserData::AppControlInfo& m_data;
+    };
+
+    struct OperationParser : public ElementParser
+    {
+      public:
+        virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+                                            const DPL::String& /*name*/)
+        {
+            return &IgnoringParser::Create;
+        }
+
+        virtual void Accept(const Text& /*text*/)
+        {}
+
+        virtual void Accept(const Element& /*element*/)
+        {}
+
+        virtual void Accept(const XmlAttribute& attribute)
+        {
+            if (attribute.name == L"name") {
+                if (attribute.value.size() > 0) {
+                    m_value = attribute.value;
+                    NormalizeString(m_value);
+                }
+            }
+        }
+
+        virtual void Verify()
+        {
+            if (m_value.IsNull() || *m_value == L"") {
+                return;
+            }
+
+            m_data.m_operation = *m_value;
+        }
+
+        OperationParser(ConfigParserData::AppControlInfo& data) :
+            ElementParser(),
+            m_properNamespace(false),
+            m_data(data)
+        {}
+
+      private:
+        bool m_properNamespace;
+        DPL::OptionalString m_value;
+        ConfigParserData::AppControlInfo& m_data;
+    };
+
+    struct UriParser : public ElementParser
+    {
+      public:
+        virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+                                            const DPL::String& /*name*/)
+        {
+            return &IgnoringParser::Create;
+        }
+
+        virtual void Accept(const Text& /*text*/)
+        {}
+
+        virtual void Accept(const Element& /*element*/)
+        {}
+
+        virtual void Accept(const XmlAttribute& attribute)
+        {
+            if (attribute.name == L"name") {
+                if (attribute.value.size() > 0) {
+                    m_value = attribute.value;
+                    NormalizeString(m_value);
+                }
+            }
+        }
+
+        virtual void Verify()
+        {
+            // exception
+            DPL::String ignoreUri(L"file");
+
+            if (!m_value.IsNull() && *m_value == ignoreUri)
+            {
+                LogInfo("exception : '" << *m_value << "' scheme will be ignored.");
+                m_value = DPL::OptionalString::Null;
+            }
+
+            if (m_value.IsNull() || *m_value == L"") {
+                return;
+            }
+
+            DPL::String wildString(L"*/*");
+            if ((m_data.m_uriList.find(wildString) == m_data.m_uriList.end())
+                && (m_data.m_uriList.find(*m_value) == m_data.m_uriList.end()))
+            {
+                m_data.m_uriList.insert(*m_value);
+            } else {
+                LogDebug("Ignoring uri with name" <<
+                         DPL::ToUTF8String(*m_value));
+            }
+        }
+
+        UriParser(ConfigParserData::AppControlInfo& data) :
+            ElementParser(),
+            m_properNamespace(false),
+            m_data(data)
+        {}
+
+      private:
+        bool m_properNamespace;
+        DPL::OptionalString m_value;
+        ConfigParserData::AppControlInfo& m_data;
+    };
+
+    struct MimeParser : public ElementParser
+    {
+      public:
+        virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+                                            const DPL::String& /*name*/)
+        {
+            return &IgnoringParser::Create;
+        }
+
+        virtual void Accept(const Text& /*text*/)
+        {}
+
+        virtual void Accept(const Element& /*element*/)
+        {}
+
+        virtual void Accept(const XmlAttribute& attribute)
+        {
+            if (attribute.name == L"name") {
+                if (attribute.value.size() > 0) {
+                    m_value = attribute.value;
+                    NormalizeString(m_value);
+                }
+            }
+        }
+
+        virtual void Verify()
+        {
+            if (m_value.IsNull() || *m_value == L"") {
+                return;
+            }
+
+            DPL::String wildString(L"*/*");
+            if ((m_data.m_mimeList.find(wildString) ==
+                 m_data.m_mimeList.end())
+                && (m_data.m_mimeList.find(*m_value) ==
+                    m_data.m_mimeList.end()))
+            {
+                m_data.m_mimeList.insert(*m_value);
+            } else {
+                LogDebug("Ignoring mime with name" <<
+                         DPL::ToUTF8String(*m_value));
+            }
+        }
+
+        MimeParser(ConfigParserData::AppControlInfo& data) :
+            ElementParser(),
+            m_properNamespace(false),
+            m_data(data)
+        {}
+
+      private:
+        bool m_properNamespace;
+        DPL::OptionalString m_value;
+        ConfigParserData::AppControlInfo& m_data;
+    };
+
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& name)
+                                        const DPL::String& name)
     {
         if (name == L"src") {
             return DPL::MakeDelegate(this, &AppControlParser::OnSourceElement);
         } else if (name == L"operation") {
-            return DPL::MakeDelegate(this, &AppControlParser::OnOperationElement);
+            return DPL::MakeDelegate(this,
+                                     &AppControlParser::OnOperationElement);
         } else if (name == L"uri") {
             return DPL::MakeDelegate(this, &AppControlParser::OnUriElement);
-        }  else if (name == L"mime") {
+        } else if (name == L"mime") {
             return DPL::MakeDelegate(this, &AppControlParser::OnMimeElement);
         } else {
             return &IgnoringParser::Create;
         }
     }
 
-    virtual void Accept(const XmlAttribute& attribute)
-    {
-    }
+    virtual void Accept(const XmlAttribute& /*attribute*/)
+    {}
 
     virtual void Accept(const Element& element)
     {
         LogWarning("namespace for app service = " << element.ns);
         if (element.ns == ConfigurationNamespace::W3CWidgetNamespaceName) {
             ThrowMsg(Exception::ParseError,
-                "Wrong xml namespace for widget element");
+                     "Wrong xml namespace for widget element");
         }
     }
 
@@ -1418,26 +1408,16 @@ class AppControlParser : public ElementParser
 
     virtual void Verify()
     {
-        if (m_appControl.m_src == L""){
+        if (m_appControl.m_src == L"") {
             LogWarning("service element must have src element");
             return;
         }
 
-        if (m_appControl.m_operation == L""){
+        if (m_appControl.m_operation == L"") {
             LogWarning("service element must have operation element");
             return;
         }
 
-        FOREACH(iterator, m_data.appControlList) {
-            if (iterator->m_src == m_appControl.m_src &&
-                    iterator->m_operation == m_appControl.m_operation )
-            {
-                ThrowMsg(Exception::ParseError,
-                    "app control element is duplicated " +
-                    DPL::ToUTF8String(m_appControl.m_src) + ", " +
-                    DPL::ToUTF8String(m_appControl.m_operation));
-            }
-        }
         m_data.appControlList.push_back(m_appControl);
     }
 
@@ -1460,13 +1440,12 @@ class AppControlParser : public ElementParser
     {
         return ElementParserPtr(new MimeParser(m_appControl));
     }
-    
+
     AppControlParser(ConfigParserData& data) :
         ElementParser(),
         m_data(data),
         m_appControl(L"")
-    {
-    }
+    {}
 
   private:
     ConfigParserData& m_data;
@@ -1477,12 +1456,12 @@ class ApplicationParser : public ElementParser
 {
   public:
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& /*name*/)
+                                        const DPL::String& /*name*/)
     {
         return &IgnoringParser::Create;
     }
 
-    virtual void Accept(const Text& text)
+    virtual void Accept(const Text& /*text*/)
     {
         if (m_properNamespace) {
             LogDebug("text");
@@ -1506,6 +1485,9 @@ class ApplicationParser : public ElementParser
             LogDebug("attribute");
             if (attribute.name == L"id") {
                 m_id = attribute.value;
+                NormalizeAndTrimSpaceString(m_id);
+            } else if (attribute.name == L"package") {
+                m_package = attribute.value;
             } else if (attribute.name == L"required_version") {
                 m_version = attribute.value;
                 NormalizeString(m_version);
@@ -1520,18 +1502,22 @@ class ApplicationParser : public ElementParser
 
     virtual void Verify()
     {
-        if(!m_id) {
+        if (!m_id) {
             ThrowMsg(Exception::ParseError,
                      "application element must have id attribute");
         }
 
-        if(!m_version) {
+        if (!!m_package) {
+            m_data.tizenPkgId = m_package;
+        }
+
+        if (!m_version) {
             ThrowMsg(Exception::ParseError,
                      "application element must have required_version attribute");
         }
 
         //TODO check if id and version format is right
-        m_data.tizenId = m_id;
+        m_data.tizenAppId = m_id;
         m_data.tizenMinVersionRequired = m_version;
     }
 
@@ -1541,12 +1527,12 @@ class ApplicationParser : public ElementParser
         m_id(DPL::OptionalString::Null),
         m_version(DPL::OptionalString::Null),
         m_properNamespace(false)
-    {
-    }
+    {}
 
   private:
     ConfigParserData& m_data;
     DPL::OptionalString m_id;
+    DPL::OptionalString m_package;
     DPL::OptionalString m_version;
     bool m_properNamespace;
 };
@@ -1569,18 +1555,17 @@ class SplashParser : public ElementParser
         }
     }
 
-    virtual void Accept(const Element& element)
-    {
-    }
+    virtual void Accept(const Element& /*element*/)
+    {}
 
     virtual void Accept(const Text& /*text*/)
-    {
-    }
+    {}
 
     virtual void Verify()
     {
         if (m_src.IsNull()) {
-            LogWarning("src attribute of splash element is mandatory - ignoring");
+            LogWarning(
+                "src attribute of splash element is mandatory - ignoring");
             return;
         }
 
@@ -1590,8 +1575,7 @@ class SplashParser : public ElementParser
     SplashParser(ConfigParserData& data) :
         ElementParser(),
         m_data(data)
-    {
-    }
+    {}
 
   private:
     DPL::OptionalString m_src;
@@ -1617,17 +1601,16 @@ class BackgroundParser : public ElementParser
     }
 
     virtual void Accept(const Element& /*element*/)
-    {
-    }
+    {}
 
     virtual void Accept(const Text& /*text*/)
-    {
-    }
+    {}
 
     virtual void Verify()
     {
         if (m_src.IsNull()) {
-            LogWarning("src attribute of background element is mandatory - ignoring");
+            LogWarning(
+                "src attribute of background element is mandatory - ignoring");
             return;
         }
 
@@ -1636,8 +1619,7 @@ class BackgroundParser : public ElementParser
 
     explicit BackgroundParser(ConfigParserData& data) :
         m_data(data)
-    {
-    }
+    {}
 
   private:
     DPL::OptionalString m_src;
@@ -1648,14 +1630,13 @@ class PrivilegeParser : public ElementParser
 {
   public:
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& name)
+                                        const DPL::String& /*name*/)
     {
         return &IgnoringParser::Create;
     }
 
     virtual void Accept(const Text& /*text*/)
-    {
-    }
+    {}
 
     virtual void Accept(const Element& element)
     {
@@ -1685,7 +1666,8 @@ class PrivilegeParser : public ElementParser
         if (m_feature.name != L"") {
             if (iri.Validate()) {
                 if (m_data.featuresList.find(m_feature) ==
-                    m_data.featuresList.end()) {
+                    m_data.featuresList.end())
+                {
                     m_data.featuresList.insert(m_feature);
                 } else {
                     LogDebug("Ignoring feature with name" <<
@@ -1700,7 +1682,8 @@ class PrivilegeParser : public ElementParser
         if (m_privilege.name != L"") {
             if (iriPrivilege.Validate()) {
                 if (m_data.privilegeList.find(m_privilege) ==
-                    m_data.privilegeList.end()) {
+                    m_data.privilegeList.end())
+                {
                     m_data.privilegeList.insert(m_privilege);
                 } else {
                     LogDebug("Ignoring privilege with name" <<
@@ -1716,8 +1699,7 @@ class PrivilegeParser : public ElementParser
         m_feature(L""),
         m_privilege(L""),
         m_properNamespace(false)
-    {
-    }
+    {}
 
   private:
     ConfigParserData& m_data;
@@ -1745,30 +1727,29 @@ class CategoryParser : public ElementParser
     }
 
     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");
+            LogWarning(
+                "name attribute of category element is mandatory - ignoring");
             return;
         }
 
         if (m_data.categoryList.find(*m_name) ==
-            m_data.categoryList.end()) {
+            m_data.categoryList.end())
+        {
             m_data.categoryList.insert(*m_name);
         }
     }
 
     explicit CategoryParser(ConfigParserData& data) :
         m_data(data)
-    {
-    }
+    {}
 
   private:
     DPL::OptionalString m_name;
@@ -1777,24 +1758,23 @@ class CategoryParser : public ElementParser
 
 class LiveboxParser : public ElementParser
 {
-    public:
+  public:
 
     struct BoxLabelParser : public ElementParser
     {
         virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-                const DPL::String& /*name*/)
+                                            const DPL::String& /*name*/)
         {
             return &IgnoringParser::Create;
         }
 
-        virtual void Accept(const XmlAttribute& attribute)
-        {
-        }
+        virtual void Accept(const XmlAttribute& /*attribute*/)
+        {}
 
         virtual void Accept(const Element& element)
         {
             if (element.ns ==
-                    ConfigurationNamespace::TizenWebAppNamespaceName)
+                ConfigurationNamespace::TizenWebAppNamespaceName)
             {
                 m_properNamespace = true;
             }
@@ -1802,8 +1782,9 @@ class LiveboxParser : public ElementParser
 
         virtual void Accept(const Text& text)
         {
-            if(m_properNamespace)
+            if (m_properNamespace) {
                 m_label = text.value;
+            }
         }
 
         virtual void Verify()
@@ -1815,10 +1796,9 @@ class LiveboxParser : public ElementParser
             ElementParser(),
             m_properNamespace(false),
             m_data(data)
-        {
-        }
+        {}
 
-        private:
+      private:
         DPL::String m_label;
         bool m_properNamespace;
         ConfigParserData::LiveboxInfo& m_data;
@@ -1827,14 +1807,14 @@ class LiveboxParser : public ElementParser
     struct BoxIconParser : public ElementParser
     {
         virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-                const DPL::String& /*name*/)
+                                            const DPL::String& /*name*/)
         {
             return &IgnoringParser::Create;
         }
 
         virtual void Accept(const XmlAttribute& attribute)
         {
-            if(m_properNamespace) {
+            if (m_properNamespace) {
                 if (attribute.name == L"src") {
                     m_icon = attribute.value;
                 }
@@ -1844,15 +1824,14 @@ class LiveboxParser : public ElementParser
         virtual void Accept(const Element& element)
         {
             if (element.ns ==
-                    ConfigurationNamespace::TizenWebAppNamespaceName)
+                ConfigurationNamespace::TizenWebAppNamespaceName)
             {
                 m_properNamespace = true;
             }
         }
 
         virtual void Accept(const Text& /*text*/)
-        {
-        }
+        {}
 
         virtual void Verify()
         {
@@ -1863,10 +1842,9 @@ class LiveboxParser : public ElementParser
             ElementParser(),
             m_properNamespace(false),
             m_data(data)
-        {
-        }
+        {}
 
-        private:
+      private:
         DPL::String m_icon;
         bool m_properNamespace;
         ConfigParserData::LiveboxInfo& m_data;
@@ -1877,14 +1855,14 @@ class LiveboxParser : public ElementParser
         struct BoxSizeParser : public ElementParser
         {
             virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-                    const DPL::String& /*name*/)
+                                                const DPL::String& /*name*/)
             {
                 return &IgnoringParser::Create;
             }
 
             virtual void Accept(const XmlAttribute& attribute)
             {
-                if(m_properNamespace) {
+                if (m_properNamespace) {
                     if (attribute.name == L"preview") {
                         m_preview = attribute.value;
                     }
@@ -1894,7 +1872,7 @@ class LiveboxParser : public ElementParser
             virtual void Accept(const Element& element)
             {
                 if (element.ns ==
-                        ConfigurationNamespace::TizenWebAppNamespaceName)
+                    ConfigurationNamespace::TizenWebAppNamespaceName)
                 {
                     m_properNamespace = true;
                 }
@@ -1902,8 +1880,9 @@ class LiveboxParser : public ElementParser
 
             virtual void Accept(const Text& text)
             {
-                if(m_properNamespace)
+                if (m_properNamespace) {
                     m_size = text.value;
+                }
             }
 
             virtual void Verify()
@@ -1914,13 +1893,14 @@ class LiveboxParser : public ElementParser
                 m_data.m_boxSize.push_back(boxSize);
             }
 
-            explicit BoxSizeParser(ConfigParserData::LiveboxInfo::BoxContentInfo& data) :
+            explicit BoxSizeParser(
+                ConfigParserData::LiveboxInfo::BoxContentInfo& data) :
                 ElementParser(),
+                m_properNamespace(false),
                 m_data(data)
-            {
-            }
+            {}
 
-            private:
+          private:
             DPL::String m_size;
             DPL::String m_preview;
             bool m_properNamespace;
@@ -1930,14 +1910,14 @@ class LiveboxParser : public ElementParser
         struct PdParser : public ElementParser
         {
             virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-                    const DPL::String& name)
+                                                const DPL::String& /*name*/)
             {
                 return &IgnoringParser::Create;
             }
 
             virtual void Accept(const XmlAttribute& attribute)
             {
-                if(m_properNamespace) {
+                if (m_properNamespace) {
                     if (attribute.name == L"src") {
                         m_src = attribute.value;
                     } else if (attribute.name == L"width") {
@@ -1951,15 +1931,14 @@ class LiveboxParser : public ElementParser
             virtual void Accept(const Element& element)
             {
                 if (element.ns ==
-                        ConfigurationNamespace::TizenWebAppNamespaceName)
+                    ConfigurationNamespace::TizenWebAppNamespaceName)
                 {
                     m_properNamespace = true;
                 }
             }
 
             virtual void Accept(const Text& /*text*/)
-            {
-            }
+            {}
 
             virtual void Verify()
             {
@@ -1968,14 +1947,14 @@ class LiveboxParser : public ElementParser
                 m_data.m_pdHeight = m_height;
             }
 
-            explicit PdParser(ConfigParserData::LiveboxInfo::BoxContentInfo& data) :
+            explicit PdParser(
+                ConfigParserData::LiveboxInfo::BoxContentInfo& data) :
                 ElementParser(),
                 m_properNamespace(false),
                 m_data(data)
-            {
-            }
+            {}
 
-            private:
+          private:
             DPL::String m_src;
             DPL::String m_width;
             DPL::String m_height;
@@ -1985,37 +1964,47 @@ class LiveboxParser : public ElementParser
         };
 
         virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-                const DPL::String& name)
+                                            const DPL::String& name)
         {
             if (name == L"box-size") {
-                return DPL::MakeDelegate(this, &LiveboxParser::BoxContentParser::OnBoxSizeElement);
+                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);
+                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")
+                if (attribute.name == L"src") {
                     m_box.m_boxSrc = attribute.value;
+                }
+                if (attribute.name == L"mouse-event") {
+                    m_box.m_boxMouseEvent = attribute.value;
+                }
             }
         }
 
         virtual void Accept(const Element& element)
         {
             if (element.ns ==
-                    ConfigurationNamespace::TizenWebAppNamespaceName)
+                ConfigurationNamespace::TizenWebAppNamespaceName)
             {
                 m_properNamespace = true;
             }
         }
 
         virtual void Accept(const Text& /*text*/)
-        {
-        }
+        {}
 
         virtual void Verify()
         {
@@ -2026,8 +2015,7 @@ class LiveboxParser : public ElementParser
             ElementParser(),
             m_properNamespace(false),
             m_data(data)
-        {
-        }
+        {}
 
         ElementParserPtr OnBoxSizeElement()
         {
@@ -2039,7 +2027,7 @@ class LiveboxParser : public ElementParser
             return ElementParserPtr(new PdParser(m_box));
         }
 
-        private:
+      private:
         DPL::String m_src;
         bool m_properNamespace;
         ConfigParserData::LiveboxInfo& m_data;
@@ -2047,13 +2035,13 @@ class LiveboxParser : public ElementParser
     };
 
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& name)
+                                        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") {
+        } else if (name == L"box-content") {
             return DPL::MakeDelegate(this, &LiveboxParser::OnBoxContentElement);
         } else {
             return &IgnoringParser::Create;
@@ -2071,6 +2059,8 @@ class LiveboxParser : public ElementParser
                 m_autoLaunch = attribute.value;
             } else if (attribute.name == L"update-period") {
                 m_updatePeriod = attribute.value;
+            } else if (attribute.name == L"type") {
+                m_type = attribute.value;
             }
         }
     }
@@ -2078,15 +2068,14 @@ class LiveboxParser : public ElementParser
     virtual void Accept(const Element& element)
     {
         if (element.ns ==
-                ConfigurationNamespace::TizenWebAppNamespaceName)
+            ConfigurationNamespace::TizenWebAppNamespaceName)
         {
             m_properNamespace = true;
         }
     }
 
     virtual void Accept(const Text& /*text*/)
-    {
-    }
+    {}
 
     virtual void Verify()
     {
@@ -2094,6 +2083,7 @@ class LiveboxParser : public ElementParser
         m_livebox.m_primary = m_primary;
         m_livebox.m_autoLaunch = m_autoLaunch;
         m_livebox.m_updatePeriod = m_updatePeriod;
+        m_livebox.m_type = m_type;
 
         m_data.m_livebox.push_back(m_livebox);
     }
@@ -2128,13 +2118,104 @@ class LiveboxParser : public ElementParser
     DPL::String m_primary;
     DPL::String m_autoLaunch;
     DPL::String m_updatePeriod;
+    DPL::String m_type;
     bool m_properNamespace;
+};
+
+class CspParser : public ElementParser
+{
+  public:
+    virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+                                        const DPL::String& /*name*/)
+    {
+        return &IgnoringParser::Create;
+    }
+
+    CspParser(ConfigParserData& data) :
+        ElementParser(),
+        m_data(data),
+        m_properNamespace(false)
+    {}
+
+    virtual void Accept(const Element& element)
+    {
+        if (element.ns == ConfigurationNamespace::TizenWebAppNamespaceName) {
+            m_properNamespace = true;
+        }
+    }
+
+    virtual void Accept(const XmlAttribute& /*attribute*/)
+    {}
+
+    virtual void Accept(const Text& text)
+    {
+        if (m_properNamespace) {
+            m_policy = text.value;
+        }
+    }
+
+    virtual void Verify()
+    {
+        if (!m_policy.IsNull()) {
+            m_data.cspPolicy = *m_policy;
+        }
+    }
 
+  private:
+    ConfigParserData& m_data;
+    bool m_properNamespace;
+    DPL::OptionalString m_policy;
 };
 
+class CspReportOnlyParser : public ElementParser
+{
+  public:
+    virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+                                        const DPL::String& /*name*/)
+    {
+        return &IgnoringParser::Create;
+    }
 
-ElementParser::ActionFunc WidgetParser::GetElementParser(const DPL::String& /*ns*/,
-        const DPL::String& name)
+    CspReportOnlyParser(ConfigParserData& data) :
+        ElementParser(),
+        m_data(data),
+        m_properNamespace(false)
+    {}
+
+    virtual void Accept(const Element& element)
+    {
+        if (element.ns == ConfigurationNamespace::TizenWebAppNamespaceName) {
+            m_properNamespace = true;
+        }
+    }
+
+    virtual void Accept(const XmlAttribute& /*attribute*/)
+    {}
+
+    virtual void Accept(const Text& text)
+    {
+        if (m_properNamespace) {
+            m_policy = text.value;
+        }
+    }
+
+    virtual void Verify()
+    {
+        if (!m_policy.IsNull()) {
+            m_data.cspPolicyReportOnly = *m_policy;
+        }
+    }
+
+  private:
+    ConfigParserData& m_data;
+    bool m_properNamespace;
+    DPL::OptionalString m_policy;
+};
+
+ElementParser::ActionFunc WidgetParser::GetElementParser(
+    const DPL::String& /*ns*/,
+    const DPL::String&
+    name)
 {
     FuncMap::const_iterator it = m_map.find(name);
     if (it != m_map.end()) {
@@ -2166,17 +2247,34 @@ WidgetParser::WidgetParser(ConfigParserData& data) :
     m_map[L"setting"] =
         DPL::MakeDelegate(this, &WidgetParser::OnSettingElement);
     // TODO: appservice will be removed
-    m_map[L"appservice"] = DPL::MakeDelegate(this, &WidgetParser::OnAppServiceElement);
-    m_map[L"application"] = DPL::MakeDelegate(this, &WidgetParser::OnApplicationElement);
+    m_map[L"appservice"] = DPL::MakeDelegate(this,
+                                             &WidgetParser::OnAppServiceElement);
+    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"app-control"] = DPL::MakeDelegate(this,
-            &WidgetParser::OnAppControlElement);
+    m_map[L"background"] = DPL::MakeDelegate(this,
+                                             &WidgetParser::OnBackgroundElement);
+    m_map[L"privilege"] = DPL::MakeDelegate(this,
+                                            &WidgetParser::OnPrivilegeElement);
+    m_map[L"app-control"] = DPL::MakeDelegate(
+            this,
+            &WidgetParser::
+                OnAppControlElement);
     m_map[L"category"] = DPL::MakeDelegate(this,
-            &WidgetParser::OnCategoryElement);
+                                           &WidgetParser::OnCategoryElement);
     m_map[L"livebox"] = DPL::MakeDelegate(this, &WidgetParser::OnLiveboxElement);
-
+#ifdef CSP_ENABLED
+    m_map[L"Content-Security-Policy"] = DPL::MakeDelegate(
+            this,
+            &WidgetParser::
+                OnCspElement);
+    m_map[L"Content-Security-Policy-Report-Only"] = DPL::MakeDelegate(
+            this,
+            &WidgetParser::
+                OnCspReportOnlyElement);
+#endif
 }
 
 ElementParserPtr WidgetParser::OnNameElement()
@@ -2274,6 +2372,16 @@ ElementParserPtr WidgetParser::OnLiveboxElement()
     return ElementParserPtr(new LiveboxParser(m_data));
 }
 
+ElementParserPtr WidgetParser::OnCspElement()
+{
+    return ElementParserPtr(new CspParser(m_data));
+}
+
+ElementParserPtr WidgetParser::OnCspReportOnlyElement()
+{
+    return ElementParserPtr(new CspReportOnlyParser(m_data));
+}
+
 void WidgetParser::Accept(const Element& element)
 {
     if (element.ns != ConfigurationNamespace::W3CWidgetNamespaceName &&
@@ -2364,26 +2472,27 @@ void WidgetParser::Accept(const XmlAttribute& attribute)
             m_defaultlocale = attribute.value;
             NormalizeString(m_defaultlocale);
             if (!LanguageSubtagRstTreeSingleton::Instance().ValidateLanguageTag(
-                    DPL::ToUTF8String(*m_defaultlocale))) {
+                    DPL::ToUTF8String(*m_defaultlocale)))
+            {
                 LogWarning("Language tag: " <<
                            m_defaultlocale << " is not valid");
                 m_defaultlocale = DPL::OptionalString::Null;
-            }
-            else
+            } else {
                 LogDebug("Default Locale Found " << m_defaultlocale);
+            }
         } else {
             LogWarning("Ignoring subsequent default locale");
         }
 
-    //Any other value consider as a namespace definition
+        //Any other value consider as a namespace definition
     } else if (attribute.name == L"xmlns" || attribute.prefix == L"xmlns") {
         LogInfo("Namespace domain: " << attribute.name);
         LogInfo("Namespace value: " << attribute.value);
         m_nameSpaces[attribute.name] = attribute.value;
     } else {
         LogError("Unknown attirbute: namespace=" << attribute.ns <<
-                ", name=" << attribute.name <<
-                ", value=" << attribute.value);
+                 ", name=" << attribute.name <<
+                 ", value=" << attribute.value);
     }
 }
 
@@ -2392,7 +2501,8 @@ void WidgetParser::Verify()
     FOREACH(mode, m_windowModes) {
         if (L"windowed" == *mode || L"floating" == *mode ||
             L"fullscreen" == *mode || L"maximized" == *mode ||
-            L"minimized" == *mode) {
+            L"minimized" == *mode)
+        {
             m_data.windowModes.insert(*mode);
         }
     }
old mode 100755 (executable)
new mode 100644 (file)
index 82b406c..c8c1a2b
@@ -13,7 +13,7 @@
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
  */
- /**
+/**
  * This file  have been implemented in compliance with  W3C WARP SPEC.
  * but there are some patent issue between  W3C WARP SPEC and APPLE.
  * so if you want to use this file, refer to the README file in root directory
@@ -83,9 +83,11 @@ class WidgetParser : public ElementParser
     ElementParserPtr OnAppControlElement();
     ElementParserPtr OnCategoryElement();
     ElementParserPtr OnLiveboxElement();
+    ElementParserPtr OnCspElement();
+    ElementParserPtr OnCspReportOnlyElement();
 
     virtual ActionFunc GetElementParser(const DPL::String& ns,
-            const DPL::String& name);
+                                        const DPL::String& name);
 
     virtual void Accept(const Element&);
     virtual void Accept(const Text&);
index 64903b2..335ab76 100644 (file)
 
 namespace Jobs {
 Job::Job(InstallationType installType) :
+    m_handle(0),
     m_installationType(installType),
     m_UndoType(false),
     m_paused(false)
-{
-}
+{}
 
 InstallationType Job::GetInstallationType() const
 {
@@ -88,18 +88,17 @@ JobHandle Job::GetJobHandle() const
 }
 
 void Job::SendProgress()
-{
-}
+{}
 
 void Job::SendFinishedSuccess()
-{
-}
+{}
 
 void Job::SendFinishedFailure()
-{
-}
+{}
+
+void Job::SendProgressIconPath(const std::string &/*path*/)
+{}
 
 void Job::SaveExceptionData(const Jobs::JobExceptionBase&)
-{
-}
+{}
 } //namespace Jobs
index 877a966..1050cbc 100644 (file)
@@ -54,8 +54,10 @@ class Job :
     virtual void SendProgress();
     virtual void SendFinishedSuccess();
     virtual void SendFinishedFailure();
+    virtual void SendProgressIconPath(const std::string &path);
 
     virtual void SaveExceptionData(const Jobs::JobExceptionBase&);
+
   private:
     JobHandle m_handle;
     InstallationType m_installationType;
index 86e1746..c2ed1d8 100644 (file)
@@ -34,8 +34,7 @@ class JobProgressBase
   public:
     JobProgressBase() : m_progressFlag(false),
         m_progresPercent(0.0)
-    {
-    }
+    {}
 
     void SetProgressFlag(bool flag)
     {
@@ -57,7 +56,7 @@ class JobProgressBase
     }
 
     void UpdateProgress(T_InstallationStep step,
-            ProgressDescription const &description)
+                        ProgressDescription const &description)
     {
         m_progresPercent =
             ((static_cast<ProgressPercent>(step) + 1.0) /
@@ -72,13 +71,13 @@ class JobContextBase
   public:
     JobContextBase(const T_JobStruct& jobStruct) :
         m_jobStruct(jobStruct)
-    {
-    }
+    {}
 
     T_JobStruct getInstallerStruct() const
     {
         return m_jobStruct;
-    }                                                                  //TODO RENAME
+    }                                                                  //TODO
+                                                                       // RENAME
 
   protected:
     T_JobStruct m_jobStruct;
@@ -96,17 +95,15 @@ struct JobCallbacksBase
         finishedCallback(0),
         progressCallback(0),
         userParam(0)
-    {
-    }
+    {}
 
     JobCallbacksBase(T_finishedCb finished,
-            T_progressCb progress,
-            void *param) :
+                     T_progressCb progress,
+                     void *param) :
         finishedCallback(finished),
         progressCallback(progress),
         userParam(param)
-    {
-    }
+    {}
 };
 } //namespace Jobs
 
index 3f12a2d..9612bc2 100644 (file)
               const char *function,                                          \
               int line,                                                      \
               const std::string & message = std::string()) :                                                                  \
-                      Base(path, function, line, message)                              \
-              {                                                                    \
-                  m_className = # Class;                                            \
-                  m_param = Param;                                                   \
-              }                                                                    \
+            Base(path, function, line, message)                              \
+        {                                                                    \
+            m_className = #Class;                                            \
+            m_param = Param;                                                   \
+        }                                                                    \
                                                                              \
-              Class(const char *path,                                              \
-                    const char *function,                                          \
-                    int line,                                                      \
-                    const Exception &reason,                                       \
-                    const std::string & message = std::string()) :                                                                  \
-                            Base(path, function, line, reason, message)                      \
-                    {                                                                    \
-                        m_className = # Class;                                            \
-                        m_param = Param;                                                   \
-                    }                                                                    \
+        Class(const char *path,                                              \
+              const char *function,                                          \
+              int line,                                                      \
+              const Exception &reason,                                       \
+              const std::string & message = std::string()) :                                                                  \
+            Base(path, function, line, reason, message)                      \
+        {                                                                    \
+            m_className = #Class;                                            \
+            m_param = Param;                                                   \
+        }                                                                    \
                                                                              \
-                    virtual int getParam() const                                         \
+        virtual int getParam() const                                         \
         {                                                                    \
             return m_param;                                                  \
         }                                                                    \
               const char *function,                                          \
               int line,                                                      \
               const std::string & message = std::string()) :                                                                  \
-                      Base(path, function, line, message)                              \
-              {                                                                    \
-                  m_className = # Class;                                            \
-                  m_param = Param;                                                   \
-              }                                                                    \
+            Base(path, function, line, message)                              \
+        {                                                                    \
+            m_className = #Class;                                            \
+            m_param = Param;                                                   \
+        }                                                                    \
                                                                              \
-              Class(const char *path,                                              \
-                    const char *function,                                          \
-                    int line,                                                      \
-                    const Exception &reason,                                       \
-                    const std::string & message = std::string()) :                                                                  \
-                            Base(path, function, line, reason, message)                      \
-                    {                                                                    \
-                        m_className = # Class;                                            \
-                        m_param = Param;                                                   \
-                    }                                                                    \
+        Class(const char *path,                                              \
+              const char *function,                                          \
+              int line,                                                      \
+              const Exception &reason,                                       \
+              const std::string & message = std::string()) :                                                                  \
+            Base(path, function, line, reason, message)                      \
+        {                                                                    \
+            m_className = #Class;                                            \
+            m_param = Param;                                                   \
+        }                                                                    \
                                                                              \
-                    virtual int getParam() const                                         \
+        virtual int getParam() const                                         \
         {                                                                    \
             return m_param;                                                  \
         }                                                                    \
index 8bf52ff..ac1642f 100644 (file)
@@ -29,7 +29,8 @@
 namespace Jobs {
 namespace PluginInstall {
 JobPluginInstall::JobPluginInstall(std::string const &pluginPath,
-        const PluginInstallerStruct &installerStruct) :
+                                   const PluginInstallerStruct &installerStruct)
+    :
     Job(PluginInstallation),
     JobContextBase<PluginInstallerStruct>(installerStruct)
 {
@@ -52,7 +53,8 @@ void JobPluginInstall::SendProgress()
     if (GetProgressFlag() && getInstallerStruct().progressCallback != NULL) {
         LogDebug("Call Plugin install progressCallback");
         getInstallerStruct().progressCallback(getInstallerStruct().userParam,
-                GetProgressPercent(), GetProgressDescription());
+                                              GetProgressPercent(),
+                                              GetProgressDescription());
     }
 }
 
@@ -65,11 +67,11 @@ void JobPluginInstall::SendFinishedSuccess()
     {
         LogDebug("Call Plugin install success finishedCallback");
         getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
-                Exceptions::Success);
+                                              Exceptions::Success);
     } else {
         LogDebug("Call Plugin install waiting finishedCallback");
         getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
-                Exceptions::InstallationWaiting);
+                                              Exceptions::InstallationWaiting);
 
         LogInfo("Installation: " << getFilePath() <<
                 " NOT possible");
@@ -83,7 +85,7 @@ void JobPluginInstall::SendFinishedFailure()
 
     LogDebug("Call Plugin install failure finishedCallback");
     getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
-            m_exceptionCaught);
+                                          m_exceptionCaught);
 }
 
 void JobPluginInstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
index a7fde44..46af82a 100644 (file)
@@ -48,7 +48,7 @@ class JobPluginInstall :
      * @brief Automaticaly sets installation process
      */
     JobPluginInstall(std::string const &pluginPath,
-            const PluginInstallerStruct &installerStruct);
+                     const PluginInstallerStruct &installerStruct);
 
     WrtDB::DbPluginHandle getNewPluginHandle() const
     {
@@ -67,6 +67,7 @@ class JobPluginInstall :
     void SendFinishedSuccess();
     void SendFinishedFailure();
     void SaveExceptionData(const Jobs::JobExceptionBase &e);
+
   private:
     //TODO move somewhere this attribute
     //(as it is in all Jobs...)
index 57d3c0c..2eccd38 100644 (file)
@@ -53,7 +53,7 @@ const std::string DIRECTORY_SEPARATOR = std::string("/");
         PluginInstallerContext::step, desc);
 
 #define DISABLE_IF_PLUGIN_WITHOUT_LIB()        \
-    if(m_pluginInfo.m_libraryName.empty()) \
+    if (m_pluginInfo.m_libraryName.empty()) \
     {                                          \
         LogWarning("Plugin without library."); \
         return;                                \
@@ -61,10 +61,10 @@ const std::string DIRECTORY_SEPARATOR = std::string("/");
 
 namespace Jobs {
 namespace PluginInstall {
-
 PluginInstallTask::PluginInstallTask(PluginInstallerContext *inCont) :
     DPL::TaskDecl<PluginInstallTask>(this),
     m_context(inCont),
+    m_pluginHandle(0),
     m_dataFromConfigXML(true)
 {
     AddStep(&PluginInstallTask::stepCheckPluginPath);
@@ -81,8 +81,7 @@ PluginInstallTask::PluginInstallTask(PluginInstallerContext *inCont) :
 }
 
 PluginInstallTask::~PluginInstallTask()
-{
-}
+{}
 
 void PluginInstallTask::stepCheckPluginPath()
 {
@@ -128,7 +127,7 @@ void PluginInstallTask::stepParseConfigFile()
         FOREACH(it, m_pluginInfo.m_featureContainer)
         {
             LogDebug("Parsed feature : " << it->m_name);
-            FOREACH (devCap, it->m_deviceCapabilities) {
+            FOREACH(devCap, it->m_deviceCapabilities) {
                 LogDebug("  |  DevCap : " << *devCap);
             }
         }
@@ -145,25 +144,22 @@ void PluginInstallTask::stepParseConfigFile()
 
 void PluginInstallTask::stepFindPluginLibrary()
 {
-    if (m_dataFromConfigXML)
-    {
+    if (m_dataFromConfigXML) {
         return;
     }
     LogDebug("Plugin installation: step find plugin library");
     std::string pluginPath = m_context->pluginFilePath;
     size_t indexpos = pluginPath.find_last_of('/');
 
-    if (std::string::npos == indexpos)
-    {
+    if (std::string::npos == indexpos) {
         indexpos = 0;
-    }
-    else
-    {
+    } else {
         indexpos += 1;  // move after '/'
     }
 
     std::string libName = pluginPath.substr(indexpos);
-    libName = GlobalConfig::GetPluginPrefix() + libName + GlobalConfig::GetPluginSuffix();
+    libName = GlobalConfig::GetPluginPrefix() + libName +
+        GlobalConfig::GetPluginSuffix();
     LogDebug("Plugin .so: " << libName);
     m_pluginInfo.m_libraryName = libName;
 }
@@ -190,10 +186,10 @@ void PluginInstallTask::stepLoadPluginLibrary()
     LogDebug("Loading plugin: " << filename);
 
     void *dlHandle = dlopen(filename.c_str(), RTLD_NOW);
-    if (dlHandle == NULL ) {
+    if (dlHandle == NULL) {
         LogError(
-                "Failed to load plugin: " << filename <<
-                ". Reason: " << dlerror());
+            "Failed to load plugin: " << filename <<
+            ". Reason: " << dlerror());
         ThrowMsg(Exceptions::PluginLibraryError, "Library error");
     }
 
@@ -202,14 +198,14 @@ void PluginInstallTask::stepLoadPluginLibrary()
 
     getWidgetEntityMapProcPtr =
         reinterpret_cast<get_widget_entity_map_proc *>(dlsym(dlHandle,
-                    PLUGIN_GET_CLASS_MAP_PROC_NAME));
+                                                             PLUGIN_GET_CLASS_MAP_PROC_NAME));
 
     if (getWidgetEntityMapProcPtr) {
         rawEntityList = (*getWidgetEntityMapProcPtr)();
     } else {
         rawEntityList =
             static_cast<const js_entity_definition_t *>(dlsym(dlHandle,
-                        PLUGIN_CLASS_MAP_NAME));
+                                                              PLUGIN_CLASS_MAP_NAME));
     }
 
     if (rawEntityList == NULL) {
@@ -218,14 +214,12 @@ void PluginInstallTask::stepLoadPluginLibrary()
         ThrowMsg(Exceptions::PluginLibraryError, "Library error");
     }
 
-    if (!m_dataFromConfigXML)
-    {
+    if (!m_dataFromConfigXML) {
         on_widget_init_proc *onWidgetInitProc =
             reinterpret_cast<on_widget_init_proc *>(
                 dlsym(dlHandle, PLUGIN_WIDGET_INIT_PROC_NAME));
 
-        if (NULL == onWidgetInitProc)
-        {
+        if (NULL == onWidgetInitProc) {
             dlclose(dlHandle);
             LogError("Failed to read onWidgetInit symbol" << filename);
             ThrowMsg(Exceptions::PluginLibraryError, "Library error");
@@ -246,25 +240,24 @@ void PluginInstallTask::stepLoadPluginLibrary()
 
         LogDebug("Getting mapping from features to device capabilities");
 
-        for (size_t i = 0; i < devcapMapping->featuresCount; ++i)
-        {
+        for (size_t i = 0; i < devcapMapping->featuresCount; ++i) {
             PluginMetafileData::Feature feature;
             feature.m_name = devcapMapping->features[i].feature_name;
 
             LogDebug("Feature: " << feature.m_name);
 
             const devcaps_t* dc =
-                mappingInterface.dcGetter(devcapMapping,
-                                          devcapMapping->features[i].feature_name);
+                mappingInterface.dcGetter(
+                    devcapMapping,
+                    devcapMapping->features[i].
+                        feature_name);
 
             LogDebug("device=cap: " << dc);
 
-            if (dc)
-            {
+            if (dc) {
                 LogDebug("devcaps count: " << dc->devCapsCount);
 
-                for (size_t j = 0; j < dc->devCapsCount; ++j)
-                {
+                for (size_t j = 0; j < dc->devCapsCount; ++j) {
                     LogDebug("devcap: " << dc->deviceCaps[j]);
                     feature.m_deviceCapabilities.insert(dc->deviceCaps[j]);
                 }
@@ -284,14 +277,14 @@ void PluginInstallTask::stepLoadPluginLibrary()
     LogInfo("#####");
 
     while (rawEntityListIterator->parent_name != NULL &&
-            rawEntityListIterator->object_name != NULL)
+           rawEntityListIterator->object_name != NULL)
     {
         LogInfo("#####     [" << rawEntityListIterator->object_name << "]: ");
         LogInfo("#####     Parent: " << rawEntityListIterator->parent_name);
         LogInfo("#####");
 
         m_libraryObjects->addObjects(rawEntityListIterator->parent_name,
-                rawEntityListIterator->object_name);
+                                     rawEntityListIterator->object_name);
 
         ++rawEntityListIterator;
     }
@@ -367,10 +360,11 @@ void PluginInstallTask::stepResolvePluginDependencies()
     LogInfo("Plugin installation: step resolve dependencies ");
 
     //DISABLE_IF_PLUGIN_WITHOUT_LIB
-    if(m_pluginInfo.m_libraryName.empty())
-    {
-        PluginDAO::setPluginInstallationStatus(m_pluginHandle,
-                                           PluginDAO::INSTALLATION_COMPLETED);
+    if (m_pluginInfo.m_libraryName.empty()) {
+        PluginDAO::setPluginInstallationStatus(
+            m_pluginHandle,
+            PluginDAO::
+                INSTALLATION_COMPLETED);
         //Installation completed
         m_context->pluginHandle = m_pluginHandle;
         m_context->installationCompleted = true;
index 35f0353..16ad13f 100644 (file)
@@ -35,9 +35,9 @@ enum Type
 {
     Success,                    ///< Success
 
-    WrongPluginPath,            ///< ?
-    MetafileError,              ///< ?
-    AlreadyInstalled,           ///< ?
+    WrongPluginPath,            ///< Wrong plugin path
+    MetafileError,              ///< Metafile parse error
+    AlreadyInstalled,           ///< Plugin already installed
     LoadingLibraryError,        ///< Loading library by dlopen failed.
                                 /// It may be caused by missing symbols
     InstallationWaiting,         /// Installation failed due to dependencies
@@ -55,5 +55,6 @@ DECLARE_JOB_EXCEPTION(Base, UnknownError, Unknown)
 } //namespace
 } //namespace
 
-#endif /* WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_INSTALLER_ERRORS_H_ */
+#endif
+//WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_INSTALLER_ERRORS_H_
 
index ac500e8..b65c2e3 100644 (file)
@@ -57,8 +57,7 @@ PluginMetafileReader::PluginMetafileReader() : m_parserSchema(this)
 }
 
 void PluginMetafileReader::blankFunction(PluginMetafileData & /* data */)
-{
-}
+{}
 
 void PluginMetafileReader::tokenEndLibraryName(PluginMetafileData &data)
 {
index 71e9131..2747f8b 100644 (file)
@@ -35,7 +35,8 @@ std::string normalizeName(const std::string& objectName)
     }
 
     if (!objectName.compare(0, GLOBAL_OBJECT_NAME.size(),
-                            GLOBAL_OBJECT_NAME)) {
+                            GLOBAL_OBJECT_NAME))
+    {
         return objectName;
     }
 
@@ -44,7 +45,7 @@ std::string normalizeName(const std::string& objectName)
 }
 
 std::string normalizeName(const std::string& objectName,
-        const std::string& parentName)
+                          const std::string& parentName)
 {
     if (objectName.empty() || parentName.empty()) {
         LogError("Normalize name, name size or parent name size is 0");
@@ -76,7 +77,7 @@ PluginObjects::ObjectsPtr PluginObjects::getDependentObjects() const
 }
 
 void PluginObjects::addObjects(const std::string& parentName,
-        const std::string& name)
+                               const std::string& name)
 {
     addImplementedObject(normalizeName(name, parentName));
     addDependentObject(normalizeName(parentName));
index 4a8ab14..0b27a14 100644 (file)
@@ -43,7 +43,7 @@ class PluginObjects : public WrtDB::PluginObjectsDAO
 
     //add object declaration
     void addObjects(const std::string& parentName,
-            const std::string& name);
+                    const std::string& name);
 
     //check if library implemements object given as name
     bool hasObject(const std::string& name) const;
index 00165f1..e2077ef 100644 (file)
 #include <ace_api_install.h>
 
 namespace {
-
 char* toAceString(const DPL::OptionalString& os)
 {
-    if (!os.IsNull())
+    if (!os.IsNull()) {
         return strdup(DPL::ToUTF8String(*os).c_str());
-    else
+    } else {
         return NULL;
+    }
 }
 
 char* toAceString(const std::string& str)
 {
-    if (!str.empty())
+    if (!str.empty()) {
         return strdup(str.c_str());
-    else
+    } else {
         return NULL;
+    }
 }
-
 } //anonymous namespace
 
 namespace AceApi {
-
 bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle,
-                               const WrtDB::WidgetRegisterInfo& widgetConfig,
-                               const WrtDB::WidgetCertificateDataList& certList)
+                       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;
+    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);
@@ -76,7 +74,8 @@ bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle,
 
     //one more element for NULL termination
     LogDebug("Found: " << certList.size() << " certificates");
-    ace_certificate_data** certData = new ace_certificate_data*[certList.size() + 1];
+    ace_certificate_data** certData = new ace_certificate_data *
+        [certList.size() + 1];
     certData[certList.size()] = NULL; // last element set to NULL
 
     int i = 0;
@@ -84,39 +83,41 @@ bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle,
     {
         certData[i] = new ace_certificate_data;
         switch (it->owner) {
-        case WrtDB::WidgetCertificateData::AUTHOR :
+        case WrtDB::WidgetCertificateData::AUTHOR:
             certData[i]->owner = AUTHOR;
             break;
-        case WrtDB::WidgetCertificateData::DISTRIBUTOR :
+        case WrtDB::WidgetCertificateData::DISTRIBUTOR:
             certData[i]->owner = DISTRIBUTOR;
             break;
-        default :
+        default:
             LogDebug("Unknown owner type of cert");
             certData[i]->owner = UNKNOWN;
+            break;
         }
         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;
+        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;
+            break;
         }
         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));
+        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<ace_widget_handle_t>(widgetHandle), &wi, certData);
+    ace_return_t retval = ace_register_widget(
+            static_cast<ace_widget_handle_t>(widgetHandle), &wi, certData);
 
     //clean up - WidgetInfo
     free(wi.author);
index 2f4a3b0..a9e0577 100644 (file)
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 
 namespace AceApi {
-
 bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle,
                        const WrtDB::WidgetRegisterInfo& widgetConfig,
                        const WrtDB::WidgetCertificateDataList& certList);
-
 }
 
-#endif /* WRT_SRC_INSTALLER_CORE_ACE_REGISTRATION_H_ */
+#endif  /* WRT_SRC_INSTALLER_CORE_ACE_REGISTRATION_H_ */
 
index 5b5148b..cd810fb 100644 (file)
@@ -41,6 +41,7 @@
 #include <dpl/wrt-dao-ro/common_dao_types.h>
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-ro/config_parser_data.h>
 #include <dpl/wrt-dao-rw/global_dao.h> // TODO remove
 #include <dpl/localization/w3c_file_localization.h>
 
@@ -85,7 +86,9 @@ const char * const CONFIG_XML = "config.xml";
 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 char* REG_TIZENID_PATTERN = "^[a-zA-Z0-9]{10}.{1,}$";
+const char* REG_NAME_PATTERN = "^[a-zA-Z0-9._-]{1,}$";
+const size_t PACKAGE_ID_LENGTH = 10;
 
 static const DPL::String SETTING_VALUE_ENCRYPTION = L"encryption";
 static const DPL::String SETTING_VALUE_ENCRYPTION_ENABLE = L"enable";
@@ -122,29 +125,32 @@ class InstallerTaskFail :
 
 const std::string XML_EXTENSION = ".xml";
 
-bool hasExtension(const std::string& filename, const std::string& extension) {
-    LogDebug("Looking for extension " << extension << " in: "  << filename);
+bool hasExtension(const std::string& filename, const std::string& extension)
+{
+    LogDebug("Looking for extension " << extension << " in: " << filename);
     size_t fileLen = filename.length();
     size_t extLen = extension.length();
     if (fileLen < extLen) {
         LogError("Filename " << filename << " is shorter than extension "
-                 << extension);
+                             << extension);
         return false;
     }
-    return (0 == filename.compare(fileLen-extLen, extLen, extension));
+    return (0 == filename.compare(fileLen - extLen, extLen, extension));
 }
 
-bool checkTizenIdExist(const std::string& tizenId) {
+bool checkTizenPkgIdExist(const std::string& tizenPkgId)
+{
     std::string installPath =
         std::string(GlobalConfig::GetUserInstalledWidgetPath()) +
-        "/" + tizenId;
+        "/" + tizenPkgId;
     std::string preinstallPath =
         std::string(GlobalConfig::GetUserPreloadedWidgetPath()) +
-        "/" + tizenId;
+        "/" + tizenPkgId;
 
     struct stat dirStat;
-    if ((stat(installPath.c_str(), &dirStat) == 0) &&
-            (stat(preinstallPath.c_str(), &dirStat) == 0)) {
+    if ((stat(installPath.c_str(), &dirStat) == 0) ||
+        (stat(preinstallPath.c_str(), &dirStat) == 0))
+    {
         return true;
     }
     return false;
@@ -153,39 +159,37 @@ bool checkTizenIdExist(const std::string& tizenId) {
 
 namespace Jobs {
 namespace WidgetInstall {
-JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
-        const WidgetInstallationStruct &installerStruct) :
+JobWidgetInstall::JobWidgetInstall(
+    std::string const &widgetPath,
+    const WidgetInstallationStruct &
+    installerStruct) :
     Job(Installation),
     JobContextBase<WidgetInstallationStruct>(installerStruct),
     m_exceptionCaught(Exceptions::Success)
 {
-    struct timeval tv;
-    gettimeofday(&tv, NULL);
-    srand(time(NULL) + tv.tv_usec);
-
     m_installerContext.m_quiet = m_jobStruct.m_quiet;
 
     ConfigureResult result = PrePareInstallation(widgetPath);
-    m_installerContext.job->SetProgressFlag(true);
 
     if (result == ConfigureResult::Ok) {
         LogInfo("Configure installation succeeded");
+        m_installerContext.job->SetProgressFlag(true);
 
         AddTask(new TaskRecovery(m_installerContext));
 
         // Create installation tasks
         if (m_installerContext.widgetConfig.packagingType !=
-                WrtDB::PKG_TYPE_DIRECTORY_WEB_APP &&
+            WrtDB::PKG_TYPE_DIRECTORY_WEB_APP &&
             m_installerContext.widgetConfig.packagingType !=
-                WrtDB::PKG_TYPE_HOSTED_WEB_APP &&
+            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));
         }
@@ -205,7 +209,8 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
         AddTask(new TaskManifestFile(m_installerContext));
         AddTask(new TaskCertificates(m_installerContext));
         if (m_installerContext.widgetConfig.packagingType ==
-                PKG_TYPE_HYBRID_WEB_APP) {
+            PKG_TYPE_HYBRID_WEB_APP)
+        {
             AddTask(new TaskInstallOspsvc(m_installerContext));
         }
         AddTask(new TaskPluginsCopy(m_installerContext));
@@ -214,10 +219,11 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
     } else if (result == ConfigureResult::Updated) {
         LogInfo("Configure installation updated");
         LogInfo("Widget Update");
+        m_installerContext.job->SetProgressFlag(true);
         if (m_installerContext.widgetConfig.packagingType !=
-                WrtDB::PKG_TYPE_HOSTED_WEB_APP &&
+            WrtDB::PKG_TYPE_HOSTED_WEB_APP &&
             m_installerContext.widgetConfig.packagingType !=
-                WrtDB::PKG_TYPE_DIRECTORY_WEB_APP &&
+            WrtDB::PKG_TYPE_DIRECTORY_WEB_APP &&
             !m_isDRM)
         {
             AddTask(new TaskUnzip(m_installerContext));
@@ -226,7 +232,7 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
         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));
         }
@@ -243,7 +249,8 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
 
         AddTask(new TaskManifestFile(m_installerContext));
         if (m_installerContext.widgetConfig.packagingType ==
-                PKG_TYPE_HYBRID_WEB_APP) {
+            PKG_TYPE_HYBRID_WEB_APP)
+        {
             AddTask(new TaskInstallOspsvc(m_installerContext));
         }
         if (m_installerContext.widgetConfig.packagingType !=
@@ -257,7 +264,6 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
         //TODO: remove widgetHandle from this task and move before database task
         // by now widget handle is needed in ace check
         // Any error in acecheck while update will break widget
-
     } else if (result == ConfigureResult::Deferred) {
         // Installation is deferred
         LogInfo("Configure installation deferred");
@@ -274,7 +280,7 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
 }
 
 JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation(
-        const std::string &widgetPath)
+    const std::string &widgetPath)
 {
     ConfigureResult result;
     m_needEncryption = false;
@@ -287,7 +293,7 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation(
         m_isDRM = isDRMWidget(widgetPath);
         if (true == m_isDRM) {
             LogDebug("decrypt DRM widget");
-            if(DecryptDRMWidget(widgetPath, tempDir)) {
+            if (DecryptDRMWidget(widgetPath, tempDir)) {
                 LogDebug("Failed decrypt DRM widget");
                 return ConfigureResult::Failed;
             }
@@ -298,12 +304,12 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation(
         m_installerContext.widgetConfig.packagingType =
             checkPackageType(widgetPath, tempDir);
         ConfigParserData configData = getWidgetDataFromXML(
-            widgetPath,
-            tempDir,
-            m_installerContext.widgetConfig.packagingType,
-            m_isDRM);
+                widgetPath,
+                tempDir,
+                m_installerContext.widgetConfig.packagingType,
+                m_isDRM);
         LogDebug("widget packaging type : " <<
-                m_installerContext.widgetConfig.packagingType.pkgType);
+                 m_installerContext.widgetConfig.packagingType.pkgType);
 
         setTizenId(configData);
         setApplicationType(configData);
@@ -323,44 +329,106 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation(
 }
 
 void JobWidgetInstall::setTizenId(
-        const WrtDB::ConfigParserData &configInfo)
+    const WrtDB::ConfigParserData &configInfo)
 {
+    bool shouldMakeAppid = false;
     using namespace PackageManager;
+    if (!!configInfo.tizenAppId) {
+        LogDebug("Setting tizenAppId provided in config.xml: " <<
+                 configInfo.tizenAppId);
 
-    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);
-
-        m_installerContext.widgetConfig.pkgName = *configInfo.tizenId;
+        m_installerContext.widgetConfig.tzAppid = *configInfo.tizenAppId;
+        //check package id.
+        if (!!configInfo.tizenPkgId) {
+            LogDebug("Setting tizenPkgId provided in config.xml: " <<
+                     configInfo.tizenPkgId);
 
+            m_installerContext.widgetConfig.tzPkgid = *configInfo.tizenPkgId;
+        } else {
+            DPL::String appid = *configInfo.tizenAppId;
+            if (appid.length() > PACKAGE_ID_LENGTH) {
+                m_installerContext.widgetConfig.tzPkgid =
+                    appid.substr(0, PACKAGE_ID_LENGTH);
+            } else {
+                //old version appid only has 10byte random character is able to install for a while.
+                //this case appid equal pkgid.
+                m_installerContext.widgetConfig.tzPkgid =
+                    *configInfo.tizenAppId;
+                shouldMakeAppid = true;
+            }
+        }
     } else {
-        WidgetPkgName tizenId = WidgetDAOReadOnly::generateTizenId();
-        LogDebug("Checking if tizen id is unique");
+        shouldMakeAppid = true;
+        TizenPkgId pkgId = WidgetDAOReadOnly::generatePkgId();
+        LogDebug("Checking if pkg id is unique");
         while (true) {
-            if (checkTizenIdExist(DPL::ToUTF8String(tizenId))) {
+            if (checkTizenPkgIdExist(DPL::ToUTF8String(pkgId))) {
                 //path exist, chose another one
-                tizenId = WidgetDAOReadOnly::generateTizenId();
+                pkgId = WidgetDAOReadOnly::generatePkgId();
                 continue;
             }
             break;
         }
+        m_installerContext.widgetConfig.tzPkgid = pkgId;
+        LogInfo("tizen_id name was generated by WRT: " <<
+                m_installerContext.widgetConfig.tzPkgid);
+    }
+
+    if (shouldMakeAppid == true) {
+        DPL::OptionalString name;
+        DPL::OptionalString defaultLocale = configInfo.defaultlocale;
+
+        FOREACH(localizedData, configInfo.localizedDataSet)
+        {
+            Locale i = localizedData->first;
+            if (!!defaultLocale) {
+                if (defaultLocale == i) {
+                    name = localizedData->second.name;
+                    break;
+                }
+            } else {
+                name = localizedData->second.name;
+                break;
+            }
+        }
+        regex_t regx;
+        if (regcomp(&regx, REG_NAME_PATTERN, REG_NOSUB | REG_EXTENDED) != 0) {
+            LogDebug("Regcomp failed");
+        }
 
-        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);
+        LogDebug("Name : " << name);
+        if (!name || (regexec(&regx, DPL::ToUTF8String(*name).c_str(),
+                              static_cast<size_t>(0), NULL, 0) != REG_NOERROR))
+        {
+            // TODO : generate name move to wrt-commons
+            std::string allowedString("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+            std::ostringstream genName;
+            struct timeval tv;
+            gettimeofday(&tv, NULL);
+            unsigned int seed = time(NULL) + tv.tv_usec;
+
+            genName << "_" << allowedString[rand_r(&seed) % allowedString.length()];
+            name = DPL::FromUTF8String(genName.str());
+            LogDebug("name was generated by WRT");
+        }
+        regfree(&regx);
+        LogDebug("Name : " << name);
+        std::ostringstream genid;
+        genid << m_installerContext.widgetConfig.tzPkgid << "." << name;
+        LogDebug("tizen appid was generated by WRT : " << genid.str());
+
+        DPL::OptionalString appid = DPL::FromUTF8String(genid.str());
+        NormalizeAndTrimSpaceString(appid);
+        m_installerContext.widgetConfig.tzAppid = *appid;
     }
 
-    LogInfo("Tizen Id : " << m_installerContext.widgetConfig.pkgName);
+    // send start signal of pkgmgr
+    getInstallerStruct().pkgmgrInterface->setPkgname(DPL::ToUTF8String(
+                                                         m_installerContext.
+                                                             widgetConfig.
+                                                             tzAppid));
+    LogInfo("Tizen App Id : " << m_installerContext.widgetConfig.tzAppid);
+    LogInfo("Tizen Pkg Id : " << m_installerContext.widgetConfig.tzPkgid);
     LogInfo("W3C Widget GUID : " << m_installerContext.widgetConfig.guid);
 }
 
@@ -368,38 +436,48 @@ 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.locationType);
+        WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig.
+                                             tzPkgid),
+                       widgetPath, tempPath,
+                       m_installerContext.widgetConfig.packagingType,
+                       m_installerContext.locationType);
+    m_installerContext.locations->registerAppid(
+        DPL::ToUTF8String(m_installerContext.widgetConfig.tzAppid));
 
     LogInfo("widgetSource " << widgetPath);
 }
 
 JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
-        const std::string &widgetSource,
-        const WrtDB::ConfigParserData &configData,
-        const std::string &tempPath)
+    const std::string &widgetSource,
+    const WrtDB::ConfigParserData &configData,
+    const std::string &tempPath)
 {
-    WidgetUpdateInfo update = detectWidgetUpdate(configData,
-            m_installerContext.widgetConfig.webAppType,
-            m_installerContext.widgetConfig.pkgName);
+    WidgetUpdateInfo update = detectWidgetUpdate(
+            configData,
+            m_installerContext.
+                widgetConfig.webAppType,
+            m_installerContext.
+                widgetConfig.tzAppid);
     ConfigureResult result = checkWidgetUpdate(update);
 
     // Validate tizenId
     regex_t reg;
-    if(regcomp(&reg, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED)!=0){
+    if (regcomp(&reg, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED) != 0) {
         LogDebug("Regcomp failed");
     }
 
     if ((regexec(&reg,
-                    DPL::ToUTF8String(m_installerContext.widgetConfig.pkgName).c_str(),
-                    static_cast<size_t>(0), NULL, 0) != REG_NOERROR) ||
-            (checkTizenIdExist(DPL::ToUTF8String(m_installerContext.widgetConfig.pkgName)) &&
-             result != ConfigureResult::Updated))
+                 DPL::ToUTF8String(m_installerContext.widgetConfig.tzAppid).
+                     c_str(),
+                     static_cast<size_t>(0), NULL, 0) == REG_NOMATCH) ||
+        (checkTizenPkgIdExist(DPL::ToUTF8String(m_installerContext.widgetConfig
+                                                    .tzPkgid)) &&
+         result != ConfigureResult::Updated))
     {
         //it is true when tizenId does not fit REG_TIZENID_PATTERN
-        LogError("tizen_id provided but not proper.");
+        LogError("tizen_id provided but not proper or pkgId directory exists");
+        //TODO(t.iwanek): appId is unique, what about installation of
+        // abcdefghij.test1 and abcdefghij.test2?
         regfree(&reg);
         return ConfigureResult::Failed;
     }
@@ -417,7 +495,7 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
 }
 
 JobWidgetInstall::ConfigureResult JobWidgetInstall::checkWidgetUpdate(
-        const WidgetUpdateInfo &update)
+    const WidgetUpdateInfo &update)
 {
     LogInfo(
         "Widget install/update: incoming guid = '" <<
@@ -432,18 +510,27 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::checkWidgetUpdate(
     if (update.existingWidgetInfo.isExist == false) {
         LogInfo("Widget info does not exist");
         updateTypeCheckBit = WidgetUpdateMode::NotInstalled;
+
+        getInstallerStruct().pkgmgrInterface->sendSignal(
+                PKGMGR_START_KEY,
+                PKGMGR_START_INSTALL);
+
     } else {
-        LogInfo("Widget info exists. PkgName: " <<
-                update.existingWidgetInfo.pkgname);
+        LogInfo("Widget info exists. appid: " <<
+                update.existingWidgetInfo.tzAppid);
 
-        WidgetPkgName pkgname = update.existingWidgetInfo.pkgname;
+        getInstallerStruct().pkgmgrInterface->sendSignal(
+                PKGMGR_START_KEY,
+                PKGMGR_START_UPDATE);
 
-        LogInfo("Widget model exists. package name: " << pkgname);
+        TizenAppId tzAppid = update.existingWidgetInfo.tzAppid;
+
+        LogInfo("Widget model exists. tizen app id: " << tzAppid);
 
         // Check running state
-        int retval = APP_MANAGER_ERROR_NONE;
         bool isRunning = false;
-        retval = app_manager_is_running(DPL::ToUTF8String(pkgname).c_str(), &isRunning);
+        int retval = app_manager_is_running(DPL::ToUTF8String(
+                                            tzAppid).c_str(), &isRunning);
         if (APP_MANAGER_ERROR_NONE != retval) {
             LogError("Fail to get running state");
             return ConfigureResult::Failed;
@@ -464,7 +551,7 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::checkWidgetUpdate(
             }
         }
 
-        m_installerContext.widgetConfig.pkgName = pkgname;
+        m_installerContext.widgetConfig.tzAppid = tzAppid;
         OptionalWidgetVersion existingVersion;
         existingVersion = update.existingWidgetInfo.existingVersion;
         OptionalWidgetVersion incomingVersion = update.incomingVersion;
@@ -474,20 +561,20 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::checkWidgetUpdate(
         // Calc proceed flag
         if ((m_jobStruct.updateMode & updateTypeCheckBit) > 0 ||
             m_jobStruct.updateMode ==
-                WidgetUpdateMode::PolicyDirectoryForceInstall)
+            WidgetUpdateMode::PolicyDirectoryForceInstall)
         {
             LogInfo("Whether widget policy allow proceed ok");
             return ConfigureResult::Updated;
-        }
-        else
+        } else {
             return ConfigureResult::Failed;
+        }
     }
     return ConfigureResult::Ok;
 }
 
 WidgetUpdateMode::Type JobWidgetInstall::CalcWidgetUpdatePolicy(
-        const OptionalWidgetVersion &existingVersion,
-        const OptionalWidgetVersion &incomingVersion) const
+    const OptionalWidgetVersion &existingVersion,
+    const OptionalWidgetVersion &incomingVersion) const
 {
     // Widget is installed, check versions
     if (!existingVersion && !incomingVersion) {
@@ -519,10 +606,10 @@ WidgetUpdateMode::Type JobWidgetInstall::CalcWidgetUpdatePolicy(
 }
 
 ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
-        const std::string &widgetSource,
-        const std::string &tempPath,
-        WrtDB::PackagingType pkgType,
-        bool isDRM)
+    const std::string &widgetSource,
+    const std::string &tempPath,
+    WrtDB::PackagingType pkgType,
+    bool isDRM)
 {
     // Parse config
     ParserRunner parser;
@@ -532,20 +619,20 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
     {
         if (pkgType == PKG_TYPE_HOSTED_WEB_APP) {
             parser.Parse(widgetSource,
-                    ElementParserPtr(
-                        new RootParser<WidgetParser>(configInfo,
-                            DPL::FromUTF32String(
-                                L"widget"))));
+                         ElementParserPtr(
+                             new RootParser<WidgetParser>(configInfo,
+                                                          DPL::FromUTF32String(
+                                                              L"widget"))));
         } else if (pkgType == PKG_TYPE_DIRECTORY_WEB_APP) {
             parser.Parse(widgetSource + '/' + WITH_OSP_XML,
                          ElementParserPtr(
                              new RootParser<WidgetParser>(
-                             configInfo,
-                             DPL::FromUTF32String(L"widget"))));
+                                 configInfo,
+                                 DPL::FromUTF32String(L"widget"))));
         } else {
             if (!isDRM) {
                 std::unique_ptr<DPL::ZipInput> zipFile(
-                        new DPL::ZipInput(widgetSource));
+                    new DPL::ZipInput(widgetSource));
 
                 std::unique_ptr<DPL::ZipInput::File> configFile;
 
@@ -562,10 +649,11 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
                 DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
                 DPL::Copy(&inputAdapter, &outputAdapter);
                 parser.Parse(&buffer,
-                        ElementParserPtr(
-                            new RootParser<WidgetParser>(configInfo,
-                                DPL::FromUTF32String(
-                                    L"widget"))));
+                             ElementParserPtr(
+                                 new RootParser<WidgetParser>(configInfo,
+                                                              DPL::
+                                                                  FromUTF32String(
+                                                                  L"widget"))));
             } else {
                 // DRM widget
                 std::string configFile;
@@ -576,10 +664,11 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
                 }
 
                 parser.Parse(configFile,
-                        ElementParserPtr(
-                            new RootParser<WidgetParser>(configInfo,
-                                DPL::FromUTF32String(
-                                    L"widget"))));
+                             ElementParserPtr(
+                                 new RootParser<WidgetParser>(configInfo,
+                                                              DPL::
+                                                                  FromUTF32String(
+                                                                  L"widget"))));
             }
         }
     }
@@ -617,9 +706,9 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
 }
 
 WidgetUpdateInfo JobWidgetInstall::detectWidgetUpdate(
-        const ConfigParserData &configInfo,
-        const WrtDB::WidgetType appType,
-        const WrtDB::WidgetPkgName &tizenId)
+    const ConfigParserData &configInfo,
+    const WrtDB::WidgetType appType,
+    const WrtDB::TizenAppId &tizenId)
 {
     LogInfo("Checking up widget package for config.xml...");
 
@@ -650,18 +739,18 @@ WidgetUpdateInfo JobWidgetInstall::detectWidgetUpdate(
             // Search widget handle by GUID
             WidgetDAOReadOnly dao(widgetGUID);
             return WidgetUpdateInfo(
-                    widgetGUID,
-                    widgetVersion,
-                    WidgetUpdateInfo::ExistingWidgetInfo(
-                        dao.getPkgName(), dao.getVersion()));
+                       widgetGUID,
+                       widgetVersion,
+                       WidgetUpdateInfo::ExistingWidgetInfo(
+                           dao.getTzAppId(), dao.getVersion()));
         }
         Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
         {
             // GUID isn't installed
             return WidgetUpdateInfo(
-                    widgetGUID,
-                    widgetVersion,
-                    WidgetUpdateInfo::ExistingWidgetInfo());
+                       widgetGUID,
+                       widgetVersion,
+                       WidgetUpdateInfo::ExistingWidgetInfo());
         }
     } else {
         Try
@@ -669,20 +758,19 @@ WidgetUpdateInfo JobWidgetInstall::detectWidgetUpdate(
             // Search widget handle by appId
             WidgetDAOReadOnly dao(tizenId);
             return WidgetUpdateInfo(
-                    widgetGUID,
-                    widgetVersion,
-                    WidgetUpdateInfo::ExistingWidgetInfo(
-                        dao.getPkgName(), dao.getVersion()));
+                       widgetGUID,
+                       widgetVersion,
+                       WidgetUpdateInfo::ExistingWidgetInfo(
+                           dao.getTzAppId(), dao.getVersion()));
         }
         Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
         {
             // GUID isn't installed
             return WidgetUpdateInfo(
-                    widgetGUID,
-                    widgetVersion,
-                    WidgetUpdateInfo::ExistingWidgetInfo());
+                       widgetGUID,
+                       widgetVersion,
+                       WidgetUpdateInfo::ExistingWidgetInfo());
         }
-
     }
 }
 
@@ -695,12 +783,27 @@ void JobWidgetInstall::SendProgress()
             std::ostringstream percent;
             percent << static_cast<int>(GetProgressPercent());
             getInstallerStruct().pkgmgrInterface->sendSignal(
-                        PKGMGR_PROGRESS_KEY,
-                        percent.str());
+                PKGMGR_PROGRESS_KEY,
+                percent.str());
 
             LogDebug("Call widget install progressCallbak");
-            getInstallerStruct().progressCallback(getInstallerStruct().userParam,
-                    GetProgressPercent(),GetProgressDescription());
+            getInstallerStruct().progressCallback(
+                getInstallerStruct().userParam,
+                GetProgressPercent(),
+                GetProgressDescription());
+        }
+    }
+}
+
+void JobWidgetInstall::SendProgressIconPath(const std::string &path)
+{
+    using namespace PackageManager;
+    if (GetProgressFlag() != false) {
+        if (getInstallerStruct().progressCallback != NULL) {
+            // send progress signal of pkgmgr
+            getInstallerStruct().pkgmgrInterface->sendSignal(
+                PKGMGR_ICON_PATH,
+                path);
         }
     }
 }
@@ -711,7 +814,6 @@ 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);
@@ -727,16 +829,17 @@ void JobWidgetInstall::SendFinishedSuccess()
     //inform widget info
     JobWidgetInstall::displayWidgetInfo();
 
-    WidgetPkgName& tizenId = m_installerContext.widgetConfig.pkgName;
+    TizenAppId& tizenId = m_installerContext.widgetConfig.tzAppid;
 
     // send signal of pkgmgr
     getInstallerStruct().pkgmgrInterface->sendSignal(
-                PKGMGR_END_KEY,
-                PKGMGR_END_SUCCESS);
+        PKGMGR_END_KEY,
+        PKGMGR_END_SUCCESS);
 
     LogDebug("Call widget install successfinishedCallback");
     getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
-            DPL::ToUTF8String(tizenId), Exceptions::Success);
+                                          DPL::ToUTF8String(
+                                              tizenId), Exceptions::Success);
 }
 
 void JobWidgetInstall::SendFinishedFailure()
@@ -747,17 +850,18 @@ void JobWidgetInstall::SendFinishedFailure()
 
     LogError("Error in installation step: " << m_exceptionCaught);
     LogError("Message: " << m_exceptionMessage);
-    WidgetPkgName & tizenId = m_installerContext.widgetConfig.pkgName;
+    TizenAppId & tizenId = m_installerContext.widgetConfig.tzAppid;
 
     LogDebug("Call widget install failure finishedCallback");
 
     // send signal of pkgmgr
     getInstallerStruct().pkgmgrInterface->sendSignal(
-                PKGMGR_END_KEY,
-                PKGMGR_END_FAILURE);
+        PKGMGR_END_KEY,
+        PKGMGR_END_FAILURE);
 
     getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
-            DPL::ToUTF8String(tizenId), m_exceptionCaught);
+                                          DPL::ToUTF8String(
+                                              tizenId), m_exceptionCaught);
 }
 
 void JobWidgetInstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
@@ -768,38 +872,39 @@ void JobWidgetInstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
 
 void JobWidgetInstall::displayWidgetInfo()
 {
-    WidgetDAOReadOnly dao(m_installerContext.locations->getPkgname());
+    WidgetDAOReadOnly dao(m_installerContext.widgetConfig.tzAppid);
 
     std::ostringstream out;
     WidgetLocalizedInfo localizedInfo =
-        W3CFileLocalization::getLocalizedInfo(dao.getPkgName());
+        W3CFileLocalization::getLocalizedInfo(dao.getTzAppId());
 
     out << std::endl <<
-        "===================================== INSTALLED WIDGET INFO ========="\
-        "============================";
+    "===================================== INSTALLED WIDGET INFO =========" \
+    "============================";
     out << std::endl << "Name:                        " << localizedInfo.name;
-    out << std::endl << "PkgName:                     " << dao.getPkgName();
+    out << std::endl << "AppId:                     " << dao.getTzAppId();
     WidgetSize size = dao.getPreferredSize();
     out << std::endl << "Width:                       " << size.width;
     out << std::endl << "Height:                      " << size.height;
     out << std::endl << "Start File:                  " <<
-        W3CFileLocalization::getStartFile(dao.getPkgName());
+    W3CFileLocalization::getStartFile(dao.getTzAppId());
     out << std::endl << "Version:                     " << dao.getVersion();
     out << std::endl << "Licence:                     " <<
-        localizedInfo.license;
+    localizedInfo.license;
     out << std::endl << "Licence Href:                " <<
-        localizedInfo.licenseHref;
+    localizedInfo.licenseHref;
     out << std::endl << "Description:                 " <<
-        localizedInfo.description;
+    localizedInfo.description;
     out << std::endl << "Widget Id:                   " << dao.getGUID();
     out << std::endl << "Widget recognized:           " << dao.isRecognized();
     out << std::endl << "Widget wac signed:           " << dao.isWacSigned();
     out << std::endl << "Widget distributor signed:   " <<
-        dao.isDistributorSigned();
+    dao.isDistributorSigned();
     out << std::endl << "Widget trusted:              " << dao.isTrusted();
 
-    OptionalWidgetIcon icon = W3CFileLocalization::getIcon(dao.getPkgName());
-    DPL::OptionalString iconSrc = !!icon ? icon->src : DPL::OptionalString::Null;
+    OptionalWidgetIcon icon = W3CFileLocalization::getIcon(dao.getTzAppId());
+    DPL::OptionalString iconSrc =
+        !!icon ? icon->src : DPL::OptionalString::Null;
     out << std::endl << "Icon:                        " << iconSrc;
 
     out << std::endl << "Preferences:";
@@ -808,9 +913,9 @@ void JobWidgetInstall::displayWidgetInfo()
         FOREACH(it, list)
         {
             out << std::endl << "  Key:                       " <<
-                it->key_name;
+            it->key_name;
             out << std::endl << "      Readonly:              " <<
-                it->readonly;
+            it->readonly;
         }
     }
 
@@ -831,11 +936,12 @@ void JobWidgetInstall::displayWidgetInfo()
 }
 
 WrtDB::PackagingType JobWidgetInstall::checkPackageType(
-        const std::string &widgetSource,
-        const std::string &tempPath)
+    const std::string &widgetSource,
+    const std::string &tempPath)
 {
     // Check installation type (direcotory/ or config.xml or widget.wgt)
-    if (WidgetUpdateMode::PolicyDirectoryForceInstall == m_jobStruct.updateMode)
+    if (WidgetUpdateMode::PolicyDirectoryForceInstall ==
+        m_jobStruct.updateMode)
     {
         LogDebug("Install directly from directory");
         return PKG_TYPE_DIRECTORY_WEB_APP;
@@ -862,7 +968,6 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType(
         {
             // Open zip file
             zipFile.reset(new DPL::ZipInput(widgetSource));
-
         }
         Catch(DPL::ZipInput::Exception::OpenFailed)
         {
@@ -879,7 +984,7 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType(
         {
             // Open config.xml file in package root
             std::unique_ptr<DPL::ZipInput::File> configFile(
-                    zipFile->OpenFile(CONFIG_XML));
+                zipFile->OpenFile(CONFIG_XML));
             return PKG_TYPE_NOMAL_WEB_APP;
         }
         Catch(DPL::ZipInput::Exception::OpenFileFailed)
@@ -891,7 +996,7 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType(
         {
             // Open config.xml file in package root
             std::unique_ptr<DPL::ZipInput::File> configFile(
-                    zipFile->OpenFile(WITH_OSP_XML));
+                zipFile->OpenFile(WITH_OSP_XML));
 
             return PKG_TYPE_HYBRID_WEB_APP;
         }
@@ -906,9 +1011,8 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType(
 }
 
 void JobWidgetInstall::setApplicationType(
-        const WrtDB::ConfigParserData &configInfo)
+    const WrtDB::ConfigParserData &configInfo)
 {
-
     FOREACH(iterator, configInfo.nameSpaces) {
         LogInfo("namespace = [" << *iterator << "]");
         AppType currentAppType = APP_TYPE_UNKNOWN;
@@ -923,15 +1027,18 @@ void JobWidgetInstall::setApplicationType(
         {
             currentAppType = APP_TYPE_WAC20;
         } else if (*iterator ==
-                ConfigurationNamespace::TizenWebAppNamespaceName) {
+                   ConfigurationNamespace::TizenWebAppNamespaceName)
+        {
             currentAppType = APP_TYPE_TIZENWEBAPP;
         }
 
         if (m_installerContext.widgetConfig.webAppType ==
-                APP_TYPE_UNKNOWN) {
+            APP_TYPE_UNKNOWN)
+        {
             m_installerContext.widgetConfig.webAppType = currentAppType;
         } else if (m_installerContext.widgetConfig.webAppType ==
-                currentAppType) {
+                   currentAppType)
+        {
             continue;
         } else {
             ThrowMsg(Exceptions::WidgetConfigFileInvalid,
@@ -945,15 +1052,18 @@ void JobWidgetInstall::setApplicationType(
     }
 
     LogInfo("type = [" <<
-            m_installerContext.widgetConfig.webAppType.getApptypeToString() << "]");
+            m_installerContext.widgetConfig.webAppType.getApptypeToString() <<
+            "]");
 }
 
-bool JobWidgetInstall::detectResourceEncryption(const WrtDB::ConfigParserData &configData)
+bool JobWidgetInstall::detectResourceEncryption(
+    const WrtDB::ConfigParserData &configData)
 {
     FOREACH(it, configData.settingsList)
     {
         if (it->m_name == SETTING_VALUE_ENCRYPTION &&
-                it->m_value == SETTING_VALUE_ENCRYPTION_ENABLE) {
+            it->m_value == SETTING_VALUE_ENCRYPTION_ENABLE)
+        {
             LogDebug("resource need encryption");
             return true;
         }
@@ -961,8 +1071,10 @@ bool JobWidgetInstall::detectResourceEncryption(const WrtDB::ConfigParserData &c
     return false;
 }
 
-void JobWidgetInstall::setInstallLocationType(const
-        WrtDB::ConfigParserData &configData)
+void JobWidgetInstall::setInstallLocationType(
+    const
+    WrtDB::ConfigParserData &
+    configData)
 {
     m_installerContext.locationType = INSTALL_LOCATION_TYPE_NOMAL;
 
@@ -973,8 +1085,9 @@ void JobWidgetInstall::setInstallLocationType(const
         FOREACH(it, configData.settingsList)
         {
             if (it->m_name == SETTING_VALUE_INSTALLTOEXT_NAME &&
-                    it->m_value ==
-                    SETTING_VALUE_INSTALLTOEXT_PREPER_EXT) {
+                it->m_value ==
+                SETTING_VALUE_INSTALLTOEXT_PREPER_EXT)
+            {
                 LogDebug("This widget will be installed to sd card");
                 m_installerContext.locationType =
                     INSTALL_LOCATION_TYPE_EXTERNAL;
@@ -986,16 +1099,16 @@ void JobWidgetInstall::setInstallLocationType(const
 bool JobWidgetInstall::isDRMWidget(std::string widgetPath)
 {
     /* TODO :
-    drm_bool_type_e is_drm_file = DRM_UNKNOWN;
-    int ret = -1;
-
-    ret = drm_is_drm_file(widgetPath.c_str(), &is_drm_file);
-    if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file) {
-    */
+     * drm_bool_type_e is_drm_file = DRM_UNKNOWN;
+     * int ret = -1;
+     *
+     * ret = drm_is_drm_file(widgetPath.c_str(), &is_drm_file);
+     * if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file) {
+     */
 
     /* blow code temporary code for drm. */
     int ret = drm_oem_intel_isDrmFile(const_cast<char*>(widgetPath.c_str()));
-    if ( 1 == ret) {
+    if (1 == ret) {
         return true;
     } else {
         return false;
@@ -1003,34 +1116,34 @@ bool JobWidgetInstall::isDRMWidget(std::string widgetPath)
 }
 
 bool JobWidgetInstall::DecryptDRMWidget(std::string widgetPath,
-        std::string destPath)
+                                        std::string destPath)
 {
     /* TODO :
-    drm_trusted_sapps_decrypt_package_info_s package_info;
-
-    strncpy(package_info.sadcf_filepath, widgetPath.c_str(),
-            sizeof(package_info.sadcf_filepath));
-    strncpy(package_info.decrypt_filepath, 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) {
-        return true;
-    } else {
-        return false;
-    }
-    */
+     * drm_trusted_sapps_decrypt_package_info_s package_info;
+     *
+     * strncpy(package_info.sadcf_filepath, widgetPath.c_str(),
+     *      sizeof(package_info.sadcf_filepath));
+     * strncpy(package_info.decrypt_filepath, 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) {
+     *  return true;
+     * } else {
+     *  return false;
+     * }
+     */
     if (drm_oem_intel_decrypt_package(const_cast<char*>(widgetPath.c_str()),
-                const_cast<char*>(destPath.c_str())) != 0) {
+                                      const_cast<char*>(destPath.c_str())) != 0)
+    {
         return true;
     } else {
         return false;
     }
 }
-
 } //namespace WidgetInstall
 } //namespace Jobs
index 6066c26..b323cc3 100644 (file)
@@ -48,8 +48,8 @@ class JobWidgetInstall :
     Exceptions::Type m_exceptionCaught;
     std::string m_exceptionMessage;
     WidgetUpdateInfo m_widgetUpdateInfo;
-    bool    m_needEncryption;
-    bool    m_isDRM;
+    bool m_needEncryption;
+    bool m_isDRM;
 
     enum class ConfigureResult
     {
@@ -61,28 +61,28 @@ class JobWidgetInstall :
                                           &configData,
                                           const std::string &tempPath);
     static WrtDB::ConfigParserData getWidgetDataFromXML(
-            const std::string &widgetSource,
-            const std::string &tempPath,
-            WrtDB::PackagingType pkgType,
-            bool isDRM);
+        const std::string &widgetSource,
+        const std::string &tempPath,
+        WrtDB::PackagingType pkgType,
+        bool isDRM);
     static WidgetUpdateInfo detectWidgetUpdate(
-            const WrtDB::ConfigParserData &configInfo,
-            const WrtDB::WidgetType appType,
-            const WrtDB::WidgetPkgName &tizenId);
+        const WrtDB::ConfigParserData &configInfo,
+        const WrtDB::WidgetType appType,
+        const WrtDB::TizenAppId &tizenId);
     WidgetUpdateMode::Type CalcWidgetUpdatePolicy(
-            const OptionalWidgetVersion &existingVersion,
-            const OptionalWidgetVersion &incomingVersion) const;
+        const OptionalWidgetVersion &existingVersion,
+        const OptionalWidgetVersion &incomingVersion) const;
     void setTizenId(const WrtDB::ConfigParserData &configInfo);
     void displayWidgetInfo();
     void configureWidgetLocation(const std::string & widgetPath,
                                  const std::string &tempPath);
 
     WrtDB::PackagingType checkPackageType(
-            const std::string &widgetSource,
-            const std::string &tempPath);
+        const std::string &widgetSource,
+        const std::string &tempPath);
     bool detectResourceEncryption(const WrtDB::ConfigParserData &configData);
     void setInstallLocationType(const WrtDB::ConfigParserData
-            &configData);
+                                &configData);
     bool isDRMWidget(std::string widgetPath);
     bool DecryptDRMWidget(std::string widgetPath, std::string destPath);
     ConfigureResult PrePareInstallation(const std::string &widgetPath);
@@ -94,12 +94,13 @@ class JobWidgetInstall :
      * @brief Automaticaly sets installation process
      */
     JobWidgetInstall(std::string const & widgetPath,
-            const WidgetInstallationStruct &installerStruct);
+                     const WidgetInstallationStruct &installerStruct);
 
     //overrides
     void SendProgress();
     void SendFinishedSuccess();
     void SendFinishedFailure();
+    void SendProgressIconPath(const std::string &path);
     void SaveExceptionData(const Jobs::JobExceptionBase&);
 };
 } //namespace WidgetInstall
index e26443f..e9439b6 100644 (file)
@@ -1,15 +1,15 @@
-ADD(de, de_DE)
-ADD(el, el_GR)
-ADD(en, en_US)
-ADD(es, es_ES)
-ADD(fr, fr_FR)
-ADD(it, it_IT)
-ADD(ja, ja_JP)
-ADD(ko, ko_KR)
-ADD(nl, nl_NL)
-ADD(pt, pt_PT)
-ADD(ru, ru_RU)
-ADD(tr, tr_TR)
-ADD(zh, zh_CN)
-ADD(zh, zh_HK)
-ADD(zh, zh_TW)
+ADD(de, de-de)
+ADD(el, el-gr)
+ADD(en, en-us)
+ADD(es, es-es)
+ADD(fr, fr-fr)
+ADD(it, it-it)
+ADD(ja, ja-jp)
+ADD(ko, ko-kr)
+ADD(nl, nl-nl)
+ADD(pt, pt-pt)
+ADD(ru, ru-ru)
+ADD(tr, tr-tr)
+ADD(zh, zh-cn)
+ADD(zh, zh-hk)
+ADD(zh, zh-tw)
old mode 100755 (executable)
new mode 100644 (file)
index 98adb96..f11c954
 
 namespace Jobs {
 namespace WidgetInstall {
-
 void writeElement(xmlTextWriterPtr writer, const char * name, DPL::String body)
 {
     int state = xmlTextWriterWriteElement(writer, BAD_CAST name,
-            BAD_CAST DPL::ToUTF8String(body).c_str());
-    if (state < 0)
-    {
+                                          BAD_CAST DPL::ToUTF8String(
+                                              body).c_str());
+    if (state < 0) {
         ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteElement failed");
     }
 }
@@ -39,9 +38,8 @@ void writeElement(xmlTextWriterPtr writer, const char * name, DPL::String body)
 void writeText(xmlTextWriterPtr writer, DPL::String text)
 {
     int state = xmlTextWriterWriteString(writer,
-            BAD_CAST DPL::ToUTF8String(text).c_str());
-    if (state < 0)
-    {
+                                         BAD_CAST DPL::ToUTF8String(text).c_str());
+    if (state < 0) {
         ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteText failed");
     }
 }
@@ -49,15 +47,17 @@ void writeText(xmlTextWriterPtr writer, DPL::String text)
 void writeElement(xmlTextWriterPtr writer, const char * name, const char * body)
 {
     int state = xmlTextWriterWriteElement(writer, BAD_CAST name, BAD_CAST body);
-    if (state < 0)
-    {
+    if (state < 0) {
         ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteElement failed");
     }
 }
 
-void writeElementWithOneAttribute(xmlTextWriterPtr writer, const char * name,
-        DPL::String body, const char * nameAttr, DPL::String bodyAttr,
-        bool condition = true)
+void writeElementWithOneAttribute(xmlTextWriterPtr writer,
+                                  const char * name,
+                                  DPL::String body,
+                                  const char * nameAttr,
+                                  DPL::String bodyAttr,
+                                  bool condition = true)
 {
     startElement(writer, name);
     writeAttribute(writer, nameAttr, bodyAttr, condition);
@@ -68,8 +68,7 @@ void writeElementWithOneAttribute(xmlTextWriterPtr writer, const char * name,
 void startElement(xmlTextWriterPtr writer, const char * name)
 {
     int state = xmlTextWriterStartElement(writer, BAD_CAST name);
-    if (state < 0)
-    {
+    if (state < 0) {
         ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterStartElement failed");
     }
 }
@@ -77,34 +76,42 @@ void startElement(xmlTextWriterPtr writer, const char * name)
 void endElement(xmlTextWriterPtr writer)
 {
     int state = xmlTextWriterEndElement(writer);
-    if (state < 0)
-    {
+    if (state < 0) {
         ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterEndElement failed");
     }
 }
 
-void writeAttribute(xmlTextWriterPtr writer, const char * name, DPL::String body,
-        bool condition = true)
+void writeAttribute(xmlTextWriterPtr writer,
+                    const char * name,
+                    DPL::String body,
+                    bool condition = true)
 {
-    if (!condition)
+    if (!condition) {
         return;
+    }
     int state = xmlTextWriterWriteAttribute(writer, BAD_CAST name,
-            BAD_CAST DPL::ToUTF8String(body).c_str());
-    if (state < 0)
-    {
-        ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteAttribute failed");
+                                            BAD_CAST DPL::ToUTF8String(
+                                                body).c_str());
+    if (state < 0) {
+        ThrowMsg(LibxmlUtils::Libxml2Error,
+                 "xmlTextWriterWriteAttribute failed");
     }
 }
 
-void writeAttribute(xmlTextWriterPtr writer, const char * name, const char * body,
-        bool condition = true)
+void writeAttribute(xmlTextWriterPtr writer,
+                    const char * name,
+                    const char * body,
+                    bool condition = true)
 {
-    if (!condition)
+    if (!condition) {
         return;
-    int state = xmlTextWriterWriteAttribute(writer, BAD_CAST name, BAD_CAST body);
-    if (state < 0)
-    {
-        ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteAttribute failed");
+    }
+    int state = xmlTextWriterWriteAttribute(writer,
+                                            BAD_CAST name,
+                                            BAD_CAST body);
+    if (state < 0) {
+        ThrowMsg(LibxmlUtils::Libxml2Error,
+                 "xmlTextWriterWriteAttribute failed");
     }
 }
 
@@ -112,28 +119,28 @@ void Manifest::generate(DPL::String filename)
 {
     xmlTextWriterPtr writer;
     int state;
-    writer = xmlNewTextWriterFilename(DPL::ToUTF8String(filename).c_str(), 0); //compression set to 0
-    if (writer == NULL)
+
+    //compression set to 0
+    writer = xmlNewTextWriterFilename(DPL::ToUTF8String(filename).c_str(), 0);
+
+    if (writer == NULL) {
         ThrowMsg(LibxmlUtils::Libxml2Error, "xmlNewTextWriterFilename failed");
-    state = xmlTextWriterSetIndent (writer, 1);
-    if (state < 0)
-    {
+    }
+    state = xmlTextWriterSetIndent(writer, 1);
+    if (state < 0) {
         ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterSetIndent failed");
     }
 
     state = xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL);
-    if (state < 0)
-    {
+    if (state < 0) {
         ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterStartDocument failed");
     }
     this->serialize(writer);
     state = xmlTextWriterEndDocument(writer);
-    if (state < 0)
-    {
+    if (state < 0) {
         ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterEndDocument failed");
     }
-    if (writer != NULL)
-    {
+    if (writer != NULL) {
         xmlFreeTextWriter(writer);
         writer = NULL;
     }
@@ -147,19 +154,20 @@ void Manifest::serialize(xmlTextWriterPtr writer)
         writeAttribute(writer, "package", this->package);
         writeAttribute(writer, "type", this->type);
         writeAttribute(writer, "version", this->version);
-        if (!this->installLocation.IsNull())
+        if (!this->installLocation.IsNull()) {
             writeAttribute(writer, "install-location", (*this->installLocation),
-                    (*this->installLocation).empty());
+                           (*this->installLocation).empty());
+        }
 
         FOREACH(l, this->label)
         {
             writeElementWithOneAttribute(writer, "label", l->getString(),
-                    "xml:lang", l->getLang(), l->hasLang());
+                                         "xml:lang", l->getLang(), l->hasLang());
         }
         FOREACH(i, this->icon)
         {
             writeElementWithOneAttribute(writer, "icon", i->getString(),
-                    "xml:lang", i->getLang(), i->hasLang());
+                                         "xml:lang", i->getLang(), i->hasLang());
         }
         FOREACH(a, this->author)
         {
@@ -168,15 +176,23 @@ void Manifest::serialize(xmlTextWriterPtr writer)
         FOREACH(d, this->description)
         {
             writeElementWithOneAttribute(writer, "description", d->getString(),
-                    "xml:lang", d->getLang(), d->hasLang());
+                                         "xml:lang", d->getLang(), d->hasLang());
         }
         //FOREACH(c, this->compatibility) { c->serialize(writer); }
         //FOREACH(d, this->deviceProfile) { d->serialize(writer); }
-        FOREACH(s, this->serviceApplication) { s->serialize(writer); }
-        FOREACH(u, this->uiApplication) { u->serialize(writer); }
-        FOREACH(i, this->imeApplication) { i->serialize(writer); }
+        FOREACH(s, this->serviceApplication) {
+            s->serialize(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); }
+        FOREACH(l, this->livebox) {
+            l->serialize(writer);
+        }
     }
     endElement(writer);
 }
@@ -195,21 +211,24 @@ void ServiceApplication::serialize(xmlTextWriterPtr writer)
 {
     startElement(writer, "service-application");
     writeAttribute(writer, "appid", this->appid);
-    writeAttribute(writer, "auto-restart", (!this->autoRestart.IsNull() &&
-            (*this->autoRestart)) ? "true" : "false");
+    writeAttribute(writer, "auto-restart",
+                   (!this->autoRestart.IsNull() &&
+                    (*this->autoRestart)) ? "true" :
+                   "false");
     writeAttribute(writer, "exec", this->exec);
     writeAttribute(writer, "on-boot", (!this->onBoot.IsNull() &&
-            (*this->onBoot)) ? "true" : "false");
+                                       (*this->onBoot)) ? "true" : "false");
     writeAttribute(writer, "type", this->type);
     FOREACH(l, this->label)
     {
-        writeElementWithOneAttribute(writer, "label", l->getString(), "xml:lang",
-                l->getLang(), l->hasLang());
+        writeElementWithOneAttribute(writer, "label",
+                                     l->getString(), "xml:lang",
+                                     l->getLang(), l->hasLang());
     }
     FOREACH(i, this->icon)
     {
         writeElementWithOneAttribute(writer, "icon", i->getString(), "xml:lang",
-                i->getLang(), i->hasLang());
+                                     i->getLang(), i->hasLang());
     }
     FOREACH(a, this->appControl)
     {
@@ -223,25 +242,34 @@ void UiApplication::serialize(xmlTextWriterPtr writer)
     startElement(writer, "ui-application");
     writeAttribute(writer, "appid", this->appid);
     writeAttribute(writer, "exec", this->exec);
-    if (!this->multiple.IsNull())
+    if (!this->multiple.IsNull()) {
         writeAttribute(writer, "multiple", (*this->multiple) ? "true" : "false");
-    if (!this->nodisplay.IsNull())
-        writeAttribute(writer, "nodisplay", (*this->nodisplay) ? "true" : "false");
-    if (!this->taskmanage.IsNull())
-        writeAttribute(writer, "taskmanage", (*this->taskmanage) ? "true" : "false");
+    }
+    if (!this->nodisplay.IsNull()) {
+        writeAttribute(writer,
+                       "nodisplay",
+                       (*this->nodisplay) ? "true" : "false");
+    }
+    if (!this->taskmanage.IsNull()) {
+        writeAttribute(writer,
+                       "taskmanage",
+                       (*this->taskmanage) ? "true" : "false");
+    }
     writeAttribute(writer, "type", this->type);
     writeAttribute(writer, "extraid", this->extraid);
-    if (!this->categories.IsNull())
+    if (!this->categories.IsNull()) {
         writeAttribute(writer, "categories", (*this->categories));
+    }
     FOREACH(l, this->label)
     {
-        writeElementWithOneAttribute(writer, "label", l->getString(), "xml:lang",
-                l->getLang(), l->hasLang());
+        writeElementWithOneAttribute(writer, "label",
+                                     l->getString(), "xml:lang",
+                                     l->getLang(), l->hasLang());
     }
     FOREACH(i, this->icon)
     {
         writeElementWithOneAttribute(writer, "icon", i->getString(), "xml:lang",
-                i->getLang(), i->hasLang());
+                                     i->getLang(), i->hasLang());
     }
     FOREACH(a, this->appControl)
     {
@@ -261,20 +289,25 @@ void ImeApplication::serialize(xmlTextWriterPtr writer)
     startElement(writer, "ime-application");
     writeAttribute(writer, "appid", this->appid);
     writeAttribute(writer, "exec", this->exec);
-    if (!this->multiple.IsNull())
+    if (!this->multiple.IsNull()) {
         writeAttribute(writer, "multiple", (*this->multiple) ? "true" : "false");
-    if (!this->nodisplay.IsNull())
-        writeAttribute(writer, "nodisplay", (*this->nodisplay) ? "true" : "false");
+    }
+    if (!this->nodisplay.IsNull()) {
+        writeAttribute(writer,
+                       "nodisplay",
+                       (*this->nodisplay) ? "true" : "false");
+    }
     writeAttribute(writer, "type", this->type);
     FOREACH(l, this->label)
     {
-        writeElementWithOneAttribute(writer, "label", l->getString(), "xml:lang",
-                l->getLang(), l->hasLang());
+        writeElementWithOneAttribute(writer, "label",
+                                     l->getString(), "xml:lang",
+                                     l->getLang(), l->hasLang());
     }
     FOREACH(i, this->icon)
     {
         writeElementWithOneAttribute(writer, "icon", i->getString(), "xml:lang",
-                i->getLang(), i->hasLang());
+                                     i->getLang(), i->hasLang());
     }
     endElement(writer);
 }
@@ -306,15 +339,15 @@ void AppControl::serialize(xmlTextWriterPtr writer)
 void LiveBox::serialize(xmlTextWriterPtr writer)
 {
     startElement(writer, "livebox");
-    if(!this->liveboxId.empty()) {
+    if (!this->liveboxId.empty()) {
         writeAttribute(writer, "appid", this->liveboxId);
     }
 
-    if(!this->primary.empty()) {
+    if (!this->primary.empty()) {
         writeAttribute(writer, "primary", this->primary);
     }
 
-    if(!this->updatePeriod.empty()) {
+    if (!this->updatePeriod.empty()) {
         writeAttribute(writer, "period", this->updatePeriod);
     }
 
@@ -322,35 +355,39 @@ void LiveBox::serialize(xmlTextWriterPtr writer)
     writeAttribute(writer, "network", "true");
     writeAttribute(writer, "nodisplay", "false");
 
-    if(!this->label.empty()) {
+    if (!this->label.empty()) {
         startElement(writer, "label");
         writeText(writer, this->label);
         endElement(writer);
     }
 
-    if(!this->icon.empty()) {
+    if (!this->icon.empty()) {
         startElement(writer, "icon");
         writeText(writer, this->icon);
         endElement(writer);
     }
 
-    if(!this->autoLaunch.empty()) {
+    if (!this->autoLaunch.empty()) {
         startElement(writer, "launch");
         writeText(writer, this->autoLaunch);
         endElement(writer);
     }
 
-    if(!this->box.boxSrc.empty() && !this->box.boxSize.empty())
+    if (!this->box.boxSrc.empty() &&
+        !this->box.boxMouseEvent.empty() &&
+        !this->box.boxSize.empty())
     {
         startElement(writer, "box");
         writeAttribute(writer, "type", "buffer");
+        writeAttribute(writer, "mouse_event", this->box.boxMouseEvent);
 
         FOREACH(m, this->box.boxSize)
         {
             std::pair<DPL::String, DPL::String> boxSize = *m;
             startElement(writer, "size");
-            if(!boxSize.second.empty())
+            if (!boxSize.second.empty()) {
                 writeAttribute(writer, "preview", boxSize.second);
+            }
             writeText(writer, boxSize.first);
             endElement(writer);
         }
@@ -361,12 +398,16 @@ void LiveBox::serialize(xmlTextWriterPtr writer)
 
         endElement(writer);
 
-        if(!this->box.pdSrc.empty() && ! this->box.pdWidth.empty() && ! this->box.pdHeight.empty()) {
+        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;
+            DPL::String pdSize = this->box.pdWidth + DPL::String(L"x") +
+                this->box.pdHeight;
             writeText(writer, pdSize);
             endElement(writer);
 
@@ -380,6 +421,5 @@ void LiveBox::serialize(xmlTextWriterPtr writer)
 
     endElement(writer);
 }
-
 } //namespace Jobs
 } //namespace WidgetInstall
old mode 100755 (executable)
new mode 100644 (file)
index ac469d2..d2b3917
 
 namespace Jobs {
 namespace WidgetInstall {
-
 /**
  * @brief string with optional language attribute
  */
 class StringWithLang
 {
-public:
+  public:
     StringWithLang() { }
-    StringWithLang(DPL::String s): string(s) { }
-    StringWithLang(DPL::String s, DPL::String l): string(s), lang(l) { }
-    DPL::String getString() { return this->string; }
-    DPL::String getLang() { return this->lang; }
-    bool hasLang() { return !this->lang.empty(); }
-private:
+    StringWithLang(DPL::String s) : string(s) { }
+    StringWithLang(DPL::String s, DPL::String l) : string(s), lang(l) { }
+    DPL::String getString()
+    {
+        return this->string;
+    }
+    DPL::String getLang()
+    {
+        return this->lang;
+    }
+    bool hasLang()
+    {
+        return !this->lang.empty();
+    }
+
+  private:
     DPL::String string;
     DPL::String lang;
 };
@@ -55,7 +64,8 @@ typedef StringWithLang LabelType, IconType, DescriptionType;
 /**
  * These types are basicaly strings but they should allow usage of different
  * range of characters or words (details in XML spec.).
- * For simplicity DPL::Strings are used, although this can lead to XML validation
+ * For simplicity DPL::Strings are used, although this can lead to XML
+ * validation
  * errors (related to usage of not allowed characters in given places).
  */
 typedef DPL::String NcnameType, NmtokenType, AnySimpleType, LangType;
@@ -69,30 +79,34 @@ typedef DPL::String AppCategoryType;
 void writeElement(xmlTextWriterPtr writer, const char * name, DPL::String body);
 void writeText(xmlTextWriterPtr writer, DPL::String text);
 void writeElement(xmlTextWriterPtr writer, const char * name, const char * body);
-void writeElementWithOneAttribute(xmlTextWriterPtr writer, const char * name,
-        const char * body, const char * nameAttr, DPL::String bodyAttr,
-        bool condition = true);
+void writeElementWithOneAttribute(xmlTextWriterPtr writer,
+                                  const char * name,
+                                  const char * body,
+                                  const char * nameAttr,
+                                  DPL::String bodyAttr,
+                                  bool condition = true);
 void startElement(xmlTextWriterPtr writer, const char * name);
 void endElement(xmlTextWriterPtr writer);
 void writeAttribute(xmlTextWriterPtr writer, const char * name,
-        DPL::String body, bool condition);
+                    DPL::String body, bool condition);
 void writeAttribute(xmlTextWriterPtr writer, const char * name,
-        const char * body, bool condition);
+                    const char * body, bool condition);
 
 /**
  * @brief author element
  */
 class Author
 {
-public:
+  public:
     Author() {}
     Author(AnySimpleType e,
-            NcnameType h,
-            LangType l,
-            DPL::String b)
-        email(e), href(h), lang(l), body(b) {}
+           NcnameType h,
+           LangType l,
+           DPL::String b) :
+        email(e), href(h), lang(l), body(b) {}
     void serialize(xmlTextWriterPtr writer);
-private:
+
+  private:
     AnySimpleType email;
     NcnameType href;
     LangType lang;
@@ -106,13 +120,23 @@ typedef Author AuthorType;
  */
 class AppControl
 {
-public:
+  public:
     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); }
+    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);
+    }
     void serialize(xmlTextWriterPtr writer);
-private:
+
+  private:
     std::list<OperationType> operation; //attr name AnySimpleType
     std::list<UriType> uri; //attr name AnySimpleType
     std::list<MimeType> mime; //attr name AnySimpleType
@@ -125,17 +149,39 @@ typedef AppControl AppControlType;
  */
 class ImeApplication
 {
-public:
+  public:
     ImeApplication() {}
-    void setAppid(const NcnameType &x) { this->appid = x; }
-    void setExec(const NcnameType &x) { this->exec = x; }
-    void setMultiple(bool x) { this->multiple = x; }
-    void setNodisplay(bool x) { this->nodisplay = x; }
-    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 setAppid(const NcnameType &x)
+    {
+        this->appid = x;
+    }
+    void setExec(const NcnameType &x)
+    {
+        this->exec = x;
+    }
+    void setMultiple(bool x)
+    {
+        this->multiple = x;
+    }
+    void setNodisplay(bool x)
+    {
+        this->nodisplay = x;
+    }
+    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 serialize(xmlTextWriterPtr writer);
-private:
+
+  private:
     NcnameType appid;
     NcnameType exec;
     DPL::OptionalBool multiple;
@@ -152,21 +198,43 @@ typedef ImeApplication ImeApplicationType;
  */
 class ServiceApplication
 {
-public:
+  public:
     ServiceApplication() {}
-    void setAppid(const NcnameType &x) { this->appid = x; }
-    void setAutoRestart(bool x) { this->autoRestart = x; }
-    void setExec(const AnySimpleType &x) { this->exec = x; }
-    void setOnBoot(bool x) { this->onBoot = x; }
-    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 setAppid(const NcnameType &x)
+    {
+        this->appid = x;
+    }
+    void setAutoRestart(bool x)
+    {
+        this->autoRestart = x;
+    }
+    void setExec(const AnySimpleType &x)
+    {
+        this->exec = x;
+    }
+    void setOnBoot(bool x)
+    {
+        this->onBoot = x;
+    }
+    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 addAppControl(const AppControlType &x)
     {
         this->appControl.push_back(x);
     }
     void serialize(xmlTextWriterPtr writer);
-private:
+
+  private:
     NcnameType appid;
     DPL::OptionalBool autoRestart;
     AnySimpleType exec;
@@ -184,18 +252,48 @@ typedef ServiceApplication ServiceApplicationType;
  */
 class UiApplication
 {
-public:
+  public:
     UiApplication() {}
-    void setAppid(const NcnameType &x) { this->appid = x; }
-    void setExtraid(const NcnameType &x) { this->extraid = x; }
-    void setExec(const AnySimpleType &x) { this->exec = x; }
-    void setMultiple(bool x) { this->multiple = x; }
-    void setNodisplay(bool x) { this->nodisplay = x; }
-    void setTaskmanage(bool x) { this->taskmanage = x; }
-    void setType(const TypeType &x) { this->type = x; }
-    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 setAppid(const NcnameType &x)
+    {
+        this->appid = x;
+    }
+    void setExtraid(const NcnameType &x)
+    {
+        this->extraid = x;
+    }
+    void setExec(const AnySimpleType &x)
+    {
+        this->exec = x;
+    }
+    void setMultiple(bool x)
+    {
+        this->multiple = x;
+    }
+    void setNodisplay(bool x)
+    {
+        this->nodisplay = x;
+    }
+    void setTaskmanage(bool x)
+    {
+        this->taskmanage = x;
+    }
+    void setType(const TypeType &x)
+    {
+        this->type = x;
+    }
+    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 addAppControl(const AppControlType &x)
     {
         this->appControl.push_back(x);
@@ -205,7 +303,8 @@ public:
         this->appCategory.push_back(x);
     }
     void serialize(xmlTextWriterPtr writer);
-private:
+
+  private:
     NcnameType appid;
     NcnameType extraid;
     AnySimpleType exec;
@@ -225,12 +324,12 @@ typedef UiApplication UiApplicationType;
 /**
  * @brief LiveBox element
  */
-typedef std::list<std::pair<DPL::String, DPL::String>> boxSizeType;
-
+typedef std::list<std::pair<DPL::String, DPL::String> > boxSizeType;
 
 struct BoxInfo
 {
     NcnameType boxSrc;
+    NcnameType boxMouseEvent;
     boxSizeType boxSize;
     NcnameType pdSrc;
     NcnameType pdWidth;
@@ -240,19 +339,40 @@ typedef BoxInfo BoxInfoType;
 
 class LiveBox
 {
-public:
+  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 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:
+  private:
     NcnameType liveboxId;
     NcnameType primary;
     NcnameType autoLaunch;
@@ -272,26 +392,35 @@ typedef LiveBox LiveBoxInfo;
  */
 class Manifest
 {
-public:
+  public:
     Manifest() {}
     void serialize(xmlTextWriterPtr writer);
     void generate(DPL::String filename);
 
-    void addLabel(const LabelType &x) { this->label.push_back(x); }
-    void addIcon(const IconType &x) { this->icon.push_back(x); }
-    void addAuthor(const AuthorType &x) { this->author.push_back(x); };
+    void addLabel(const LabelType &x)
+    {
+        this->label.push_back(x);
+    }
+    void addIcon(const IconType &x)
+    {
+        this->icon.push_back(x);
+    }
+    void addAuthor(const AuthorType &x)
+    {
+        this->author.push_back(x);
+    }
     void addDescription(const DescriptionType &x)
     {
         this->description.push_back(x);
     }
-//    void addCompatibility(const CompatibilityType &x)
-//    {
-//        this->compatibility.push_back(x);
-//    }
-//    void addDeviceProfile(const DeviceProfileType &x)
-//    {
-//        this->deviceProfile.push_back(x);
-//    }
+    //    void addCompatibility(const CompatibilityType &x)
+    //    {
+    //        this->compatibility.push_back(x);
+    //    }
+    //    void addDeviceProfile(const DeviceProfileType &x)
+    //    {
+    //        this->deviceProfile.push_back(x);
+    //    }
     void addServiceApplication(const ServiceApplicationType &x)
     {
         this->serviceApplication.push_back(x);
@@ -304,7 +433,7 @@ public:
     {
         this->imeApplication.push_back(x);
     }
-//    void addFont(const FontType &x) { this->font.push_back(x); }
+    //    void addFont(const FontType &x) { this->font.push_back(x); }
 
     void addLivebox(const LiveBoxInfo &x)
     {
@@ -315,27 +444,36 @@ public:
     {
         this->installLocation = x;
     }
-    void setPackage(const NcnameType &x) { this->package = x; }
-    void setType(const PackageType &x) { this->type = x; }
-    void setVersion(const NmtokenType &x) { this->version = x; }
-private:
+    void setPackage(const NcnameType &x)
+    {
+        this->package = x;
+    }
+    void setType(const PackageType &x)
+    {
+        this->type = x;
+    }
+    void setVersion(const NmtokenType &x)
+    {
+        this->version = x;
+    }
+
+  private:
     std::list<LabelType> label;
     std::list<IconType> icon;
     std::list<AuthorType> author;
     std::list<DescriptionType> description;
-//    std::list<CompatibilityType> compatibility;
-//    std::list<DeviceProfileType> deviceProfile;
+    //    std::list<CompatibilityType> compatibility;
+    //    std::list<DeviceProfileType> deviceProfile;
     std::list<ServiceApplicationType> serviceApplication;
     std::list<UiApplicationType> uiApplication;
     std::list<ImeApplicationType> imeApplication;
-//    std::list<FontType> font;
+    //    std::list<FontType> font;
     std::list<LiveBoxInfo> livebox;
     InstallLocationType installLocation;
     NcnameType package;
     PackageType type;
     NmtokenType version;
 };
-
 } //namespace Jobs
 } //namespace WidgetInstall
 
index 7436f4b..2697a9c 100644 (file)
@@ -38,7 +38,6 @@
 
 namespace Jobs {
 namespace WidgetInstall {
-
 TaskAceCheck::TaskAceCheck(InstallerContext& context) :
     DPL::TaskDecl<TaskAceCheck>(this),
     m_context(context)
@@ -52,7 +51,7 @@ TaskAceCheck::TaskAceCheck(InstallerContext& context) :
 void TaskAceCheck::StepPrepareForAce()
 {
     m_context.featureLogic =
-        FeatureLogicPtr(new FeatureLogic(m_context.locations->getPkgname()));
+        FeatureLogicPtr(new FeatureLogic(m_context.widgetConfig.tzAppid));
     m_context.job->UpdateProgress(
         InstallerContext::INSTALL_ACE_PREPARE,
         "Widget Access Control Check Prepared");
@@ -60,7 +59,7 @@ void TaskAceCheck::StepPrepareForAce()
 
 void TaskAceCheck::StepAceCheck()
 {
-    WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
+    WrtDB::WidgetDAO dao(m_context.widgetConfig.tzAppid);
     LogInfo("StepAceCheck!");
     // This widget does not use any device cap
     if (m_context.featureLogic->isDone()) {
@@ -75,27 +74,31 @@ void TaskAceCheck::StepAceCheck()
 
     std::string devCapStr = DPL::ToUTF8String(deviceCap);
     ace_policy_result_t policyResult = ACE_DENY;
+
+    //TODO: remove dao.getHandle()
     ace_return_t ret = ace_get_policy_result(
             const_cast<const ace_resource_t>(devCapStr.c_str()),
-            dao.getHandle(),                         //TODO: remove dao.getHandle()
+            dao.getHandle(),
             &policyResult);
     if (ACE_OK != ret) {
         ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
-                 "ACE check failure");
+                                         "ACE check failure");
     }
 
     LogInfo("PolicyResult is : " << static_cast<int>(policyResult));
     m_context.staticPermittedDevCaps.insert(std::make_pair(deviceCap,
-            policyResult == ACE_PERMIT));
+                                                           policyResult ==
+                                                           ACE_PERMIT));
 
     m_context.featureLogic->setAceResponse(policyResult != ACE_DENY);
 }
 
 void TaskAceCheck::StepProcessAceResponse()
 {
-    WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
+    WrtDB::WidgetDAO dao(m_context.widgetConfig.tzAppid);
     if (m_context.widgetConfig.packagingType ==
-            WrtDB::PKG_TYPE_HOSTED_WEB_APP) {
+        WrtDB::PKG_TYPE_HOSTED_WEB_APP)
+    {
         return;
     }
 
@@ -109,9 +112,9 @@ void TaskAceCheck::StepProcessAceResponse()
         std::vector<std::string> devCaps;
         std::vector<bool> devCapsSmack;
         // Saving static dev cap permissions
-        FOREACH (cap, m_context.staticPermittedDevCaps) {
+        FOREACH(cap, m_context.staticPermittedDevCaps) {
             LogInfo("staticPermittedDevCaps : " << cap->first
-                    << " smack: " << cap->second);
+                                                << " smack: " << cap->second);
             std::string devCapStr = DPL::ToUTF8String(cap->first);
             devCaps.push_back(devCapStr);
             devCapsSmack.push_back(cap->second);
@@ -122,21 +125,22 @@ void TaskAceCheck::StepProcessAceResponse()
 
         for (unsigned int i = 0; i < devCaps.size(); ++i) {
             list.items[i].device_capability =
-                    const_cast<const ace_resource_t>(devCaps[i].c_str());
+                const_cast<const ace_resource_t>(devCaps[i].c_str());
             list.items[i].smack_granted =
-                    devCapsSmack[i] ? ACE_TRUE : ACE_FALSE;
+                devCapsSmack[i] ? ACE_TRUE : ACE_FALSE;
         }
-        ace_return_t ret = ace_set_requested_dev_caps(dao.getHandle(),   //TODO: remove dao.getHandle()
+        //TODO: remove dao.getHandle()
+        ace_return_t ret = ace_set_requested_dev_caps(dao.getHandle(),
                                                       &list);
         if (ACE_OK != ret) {
             ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
-                     "ACE failure");
+                                             "ACE failure");
         }
-        delete [] list.items;
+        delete[] list.items;
 
         std::set<std::string> acceptedFeature;
         auto it = m_context.featureLogic->resultBegin();
-        for (;it != m_context.featureLogic->resultEnd(); ++it) {
+        for (; it != m_context.featureLogic->resultEnd(); ++it) {
             if (!(it->rejected)) {
                 acceptedFeature.insert(DPL::ToUTF8String(it->name));
             }
@@ -145,22 +149,24 @@ void TaskAceCheck::StepProcessAceResponse()
         featureList.count = acceptedFeature.size();
         featureList.items = new ace_string_t[featureList.count];
 
-        size_t i=0;
+        size_t i = 0;
         for (std::set<std::string>::const_iterator iter = acceptedFeature.begin();
-                iter != acceptedFeature.end(); ++iter) {
+             iter != acceptedFeature.end(); ++iter)
+        {
             LogDebug("Accepted feature item: " << iter->c_str());
             featureList.items[i] = const_cast<char *>(iter->c_str());
             i++;
         }
 
-        ret = ace_set_accepted_feature(dao.getHandle(), &featureList); //TODO: remove dao.getHandle()
+        //TODO: remove dao.getHandle()
+        ret = ace_set_accepted_feature(dao.getHandle(), &featureList);
 
-        delete [] featureList.items;
+        delete[] featureList.items;
 
         if (ACE_OK != ret) {
             LogError("Error in ace_set_feature");
             ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
-              "ace_set_feature failure.");
+                                             "ace_set_feature failure.");
         }
         return;
     }
@@ -175,16 +181,20 @@ void TaskAceCheck::StepCheckAceResponse()
     LogInfo("Checking ACE response");
     if (m_context.featureLogic->isRejected()) {
         LogError("Installation failure. Some devCap was not accepted by ACE.");
-        ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
+        ThrowMsg(
+            Exceptions::NotAllowed,
+            "Instalation failure. "
             "Some deviceCap was not accepted by ACE.");
     }
     LogInfo("Updating \"feature reject status\" in database!");
     auto it = m_context.featureLogic->resultBegin();
     auto end = m_context.featureLogic->resultEnd();
-    for(;it != end; ++it){
-        LogInfo("  |-  Feature: " << it->name << " has reject status: " << it->rejected);
+    for (; it != end; ++it) {
+        LogInfo(
+            "  |-  Feature: " << it->name << " has reject status: " <<
+            it->rejected);
         if (it->rejected) {
-            WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
+            WrtDB::WidgetDAO dao(m_context.widgetConfig.tzAppid);
             dao.updateFeatureRejectStatus(*it);
         }
     }
@@ -194,6 +204,5 @@ void TaskAceCheck::StepCheckAceResponse()
         InstallerContext::INSTALL_ACE_CHECK,
         "Widget Access Control Check Finished");
 }
-
 } //namespace WidgetInstall
 } //namespace Jobs
index 92fc86f..04247fa 100644 (file)
@@ -37,10 +37,10 @@ using namespace WrtDB;
 
 namespace Jobs {
 namespace WidgetInstall {
-
 TaskCertificates::TaskCertificates(InstallerContext& context) :
     DPL::TaskDecl<TaskCertificates>(this),
-    m_context(context)
+    m_context(context),
+    m_pkgHandle(NULL)
 {
     AddStep(&TaskCertificates::StepSetCertiInfo);
     AddAbortStep(&TaskCertificates::StepAbortCertiInfo);
@@ -53,19 +53,20 @@ void TaskCertificates::StepSetCertiInfo()
     if (pkgmgr_installer_create_certinfo_set_handle(&m_pkgHandle) < 0) {
         LogError("pkgmgrInstallerCreateCertinfoSetHandle fail");
         ThrowMsg(Exceptions::SetCertificateInfoFailed,
-                "Failed to create certificate handle");
+                 "Failed to create certificate handle");
     }
 
     SetCertiInfo(SIGNATURE_AUTHOR);
     SetCertiInfo(SIGNATURE_DISTRIBUTOR);
 
     if ((pkgmgr_installer_save_certinfo(
-                    const_cast<char*>(DPL::ToUTF8String(
-                            m_context.widgetConfig.pkgName).c_str()),
-                    m_pkgHandle)) < 0) {
+             const_cast<char*>(DPL::ToUTF8String(
+                                   m_context.widgetConfig.tzPkgid).c_str()),
+             m_pkgHandle)) < 0)
+    {
         LogError("pkgmgrInstallerSaveCertinfo fail");
         ThrowMsg(Exceptions::SetCertificateInfoFailed,
-                "Failed to Installer Save Certinfo");
+                 "Failed to Installer Save Certinfo");
     } else {
         LogDebug("Succeed to save Certinfo");
     }
@@ -73,6 +74,10 @@ void TaskCertificates::StepSetCertiInfo()
     if (pkgmgr_installer_destroy_certinfo_set_handle(m_pkgHandle) < 0) {
         LogError("pkgmgrInstallerDestroyCertinfoSetHandle fail");
     }
+
+    m_context.job->UpdateProgress(
+            InstallerContext::INSTALL_SET_CERTINFO,
+            "Save certinfo to pkgmgr");
 }
 
 void TaskCertificates::SetCertiInfo(CertificateSource source)
@@ -89,22 +94,22 @@ void TaskCertificates::SetCertiInfo(CertificateSource source)
         if (false == chain.load(*it)) {
             LogError("Chain is broken");
             ThrowMsg(Exceptions::SetCertificateInfoFailed,
-                    "Failed to Installer Save Certinfo");
+                     "Failed to Installer Save Certinfo");
         }
 
-        if (!chain.sort()){
+        if (!chain.sort()) {
             LogError("Chain failed at sorting");
         }
 
         ValidationCore::CertificateList list = chain.getCertificateList();
 
-        FOREACH(certIt, list) 
+        FOREACH(certIt, list)
         {
             pkgmgr_instcert_type instCertType;
 
             if (source == SIGNATURE_DISTRIBUTOR) {
                 std::string
-                    Name(DPL::ToUTF8String(*(*certIt)->getOrganizationName()));
+                Name(DPL::ToUTF8String(*(*certIt)->getOrganizationName()));
                 size_t found = Name.find("Tizen");
 
                 if (found != std::string::npos) {
@@ -124,7 +129,8 @@ void TaskCertificates::SetCertiInfo(CertificateSource source)
                         instCertType = PM_SET_DISTRIBUTOR2_ROOT_CERT;
                     } else {
                         if ((*certIt)->isCA()) {
-                            instCertType = PM_SET_DISTRIBUTOR2_INTERMEDIATE_CERT;
+                            instCertType =
+                                PM_SET_DISTRIBUTOR2_INTERMEDIATE_CERT;
                         } else {
                             instCertType = PM_SET_DISTRIBUTOR2_SIGNER_CERT;
                         }
@@ -143,13 +149,14 @@ void TaskCertificates::SetCertiInfo(CertificateSource source)
                 }
             }
             LogDebug("cert type : " << instCertType);
-            if((pkgmgr_installer_set_cert_value(
-                            m_pkgHandle,
-                            instCertType,
-                            const_cast<char*>(((*certIt)->getBase64()).c_str()))) < 0) {
+            if ((pkgmgr_installer_set_cert_value(
+                     m_pkgHandle,
+                     instCertType,
+                     const_cast<char*>(((*certIt)->getBase64()).c_str()))) < 0)
+            {
                 LogError("pkgmgrInstallerSetCertValue fail");
                 ThrowMsg(Exceptions::SetCertificateInfoFailed,
-                        "Failed to Set CertValue");
+                         "Failed to Set CertValue");
             }
         }
     }
@@ -158,11 +165,12 @@ void TaskCertificates::SetCertiInfo(CertificateSource source)
 void TaskCertificates::StepAbortCertiInfo()
 {
     if ((pkgmgr_installer_delete_certinfo(
-                    const_cast<char*>(DPL::ToUTF8String(
-                            m_context.widgetConfig.pkgName).c_str()))) < 0) {
+             const_cast<char*>(DPL::ToUTF8String(
+                                   m_context.widgetConfig.tzPkgid).c_str()))) <
+        0)
+    {
         LogError("pkgmgr_installer_delete_certinfo fail");
     }
 }
-
 } //namespace WidgetInstall
 } //namespace Jobs
old mode 100755 (executable)
new mode 100644 (file)
index 8a377d6..e689cee
@@ -34,7 +34,7 @@ class InstallerContext;
 
 namespace Jobs {
 namespace WidgetInstall {
-class TaskCertificates:
+class TaskCertificates :
     public DPL::TaskDecl<TaskCertificates>,
     public DPL::Event::ICDelegateSupport<TaskCertificates>
 {
old mode 100755 (executable)
new mode 100644 (file)
index 40a17cd..cd38d74
@@ -33,7 +33,6 @@
 #include <widget_install/widget_install_errors.h>
 #include <widget_install/widget_install_context.h>
 #include <dpl/log/log.h>
-#include <wrt_error.h>
 #include <dpl/wrt-dao-ro/global_config.h>
 #include "wac_widget_id.h"
 
@@ -54,8 +53,8 @@ using namespace WrtDB;
 namespace {
 const std::string LABEL_NEW_LINE = "<br>";
 const std::string LABEL_NEW_LINE_2 = "<br><br>";
-const std::string UNTRUSTED_WIDGET ="It is an Untrusted Widget";
-const char *QUESTION ="Do you wanto to install?";
+const std::string UNTRUSTED_WIDGET = "It is an Untrusted Widget";
+const char *QUESTION = "Do you wanto to install?";
 
 WidgetCertificateData toWidgetCertificateData(const SignatureData &data,
                                               bool root)
@@ -79,7 +78,7 @@ WidgetCertificateData toWidgetCertificateData(const SignatureData &data,
     }
 
     Assert(certificate && !certificate->getCommonName().IsNull() &&
-            "CommonName is Null");
+           "CommonName is Null");
 
     result.strCommonName = *certificate->getCommonName();
 
@@ -93,20 +92,53 @@ WidgetCertificateData toWidgetCertificateData(const SignatureData &data,
 
     return result;
 }
+
+CertificatePtr getOldAuthorSignerCertificate(DPL::String appid)
+{
+    WidgetDAOReadOnly dao(appid);
+    CertificateChainList chainList = dao.getWidgetCertificate(SIGNATURE_AUTHOR);
+
+    FOREACH(it, chainList)
+    {
+        ValidationCore::CertificateCollection chain;
+        if (false == chain.load(*it)) {
+            LogError("Chain is broken");
+        }
+
+        if (!chain.sort()) {
+            LogError("Chain failed at sorting");
+        }
+
+        ValidationCore::CertificateList list = chain.getCertificateList();
+
+        FOREACH(cert, list)
+        {
+            if (!(*cert)->isRootCert() && !(*cert)->isCA()) {
+                return *cert;
+            }
+        }
+    }
+    return CertificatePtr(NULL);
+}
 } // namespace anonymous
 
 namespace Jobs {
 namespace WidgetInstall {
 TaskCertify::TaskCertify(InstallerContext &inCont) :
     DPL::TaskDecl<TaskCertify>(this),
-    m_contextData(inCont),
-    WidgetInstallPopup(inCont)
+    WidgetInstallPopup(inCont),
+    m_contextData(inCont)
 {
     AddStep(&TaskCertify::stepSignature);
+    // certi comparison determines whether the update.
+    if (true == m_contextData.existingWidgetInfo.isExist) {
+        AddStep(&TaskCertify::stepVerifyUpdate);
+    }
 
     // Block until fixed popup issues
     if (!GlobalSettings::PopupsTestModeEnabled()
-            && !m_installContext.m_quiet && !isTizenWebApp()) {
+        && !m_installContext.m_quiet && !isTizenWebApp())
+    {
         AddStep(&TaskCertify::stepWarningPopup);
         AddStep(&TaskCertify::stepWarningPopupAnswer);
         AddStep(&TaskCertify::stepAuthorInfoPopup);
@@ -130,14 +162,14 @@ void TaskCertify::processDistributorSignature(const SignatureData &data,
     CertificateCollection collection;
     collection.load(data.getCertList());
     Assert(collection.sort() &&
-            "Certificate collection can't 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.");
 
     m_contextData.wacSecurity.getCertificateChainListRef().push_back(
-            collection);
+        collection);
 
     if (first) {
         m_contextData.wacSecurity.getCertificateListRef().push_back(
@@ -152,8 +184,9 @@ void TaskCertify::processAuthorSignature(const SignatureData &data)
     using namespace ValidationCore;
     LogInfo("DNS Identity match!");
     // this signature is verified or widget is distributor signed
-    m_contextData.wacSecurity.getAuthorCertificatePtr() =
-        data.getEndEntityCertificatePtr();
+    m_contextData.wacSecurity.setAuthorCertificatePtr(data.getEndEntityCertificatePtr());
+    CertificatePtr test = m_contextData.wacSecurity.getAuthorCertificatePtr();
+
     m_contextData.wacSecurity.getCertificateListRef().push_back(
         toWidgetCertificateData(data, true));
     m_contextData.wacSecurity.getCertificateListRef().push_back(
@@ -174,7 +207,7 @@ void TaskCertify::processAuthorSignature(const SignatureData &data)
            "It is not possible to verify this signature.");
 
     m_contextData.wacSecurity.getAuthorsCertificateChainListRef().push_back(
-            collection);
+        collection);
 
     FOREACH(it, dnsIdentity){
         if (widgetId.matchHost(*it)) {
@@ -188,7 +221,8 @@ void TaskCertify::stepSignature()
 {
     LogInfo("================ Step: <<Signature>> ENTER ===============");
 
-    std::string widgetPath = m_contextData.locations->getTemporaryRootDir() + "/";
+    std::string widgetPath = m_contextData.locations->getTemporaryRootDir() +
+        "/";
 
     SignatureFileInfoSet signatureFiles;
     SignatureFinder signatureFinder(widgetPath);
@@ -216,20 +250,34 @@ void TaskCertify::stepSignature()
             xml.initialize(data, GlobalConfig::GetSignatureXmlSchema());
             xml.read(data);
 
-            WrtSignatureValidator::AppType appType = WrtSignatureValidator::WAC20;
+            WrtSignatureValidator::AppType appType =
+                WrtSignatureValidator::WAC20;
 
-            if (m_installContext.widgetConfig.webAppType == APP_TYPE_TIZENWEBAPP) {
+            if (m_installContext.widgetConfig.webAppType ==
+                APP_TYPE_TIZENWEBAPP)
+            {
                 appType = WrtSignatureValidator::TIZEN;
             }
 
+            WrtSignatureValidator::Result result;
+
             WrtSignatureValidator validator(
-                appType,
-                !GlobalSettings::OCSPTestModeEnabled(),
-                !GlobalSettings::CrlTestModeEnabled(),
-                complianceMode);
+                    appType,
+                    !GlobalSettings::
+                    OCSPTestModeEnabled(),
+                    !GlobalSettings::
+                    CrlTestModeEnabled(),
+                    complianceMode);
 
-            WrtSignatureValidator::Result result =
-                validator.check(data, widgetPath);
+            result = validator.check(data, widgetPath);
+
+            if (m_contextData.widgetConfig.packagingType
+                == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
+            {
+                // In directory installation mode, the validation is skipped.
+
+                result = WrtSignatureValidator::SIGNATURE_VERIFIED;
+            }
 
             if (result == WrtSignatureValidator::SIGNATURE_REVOKED) {
                 LogWarning("Certificate is REVOKED");
@@ -249,7 +297,9 @@ void TaskCertify::stepSignature()
                     m_contextData.wacSecurity.isDistributorSigned())
                 {
                     processAuthorSignature(data);
-                } else if (result == WrtSignatureValidator::SIGNATURE_DISREGARD) {
+                } else if (result ==
+                           WrtSignatureValidator::SIGNATURE_DISREGARD)
+                {
                     continue;
                 }
             } else {
@@ -266,8 +316,7 @@ void TaskCertify::stepSignature()
             std::string realMEID;
             TapiHandle *tapiHandle = tel_init(NULL);
             char *meid = tel_get_misc_me_sn_sync(tapiHandle);
-            if (meid)
-            {
+            if (meid) {
                 realMEID = meid;
                 free(meid);
             }
@@ -319,11 +368,11 @@ void TaskCertify::stepSignature()
 void TaskCertify::createInstallPopup(PopupType type, const std::string &label)
 {
     m_contextData.job->Pause();
-    if(m_popup)
+    if (m_popup) {
         destroyPopup();
+    }
     bool ret = createPopup();
-    if(ret)
-    {
+    if (ret) {
         loadPopup(type, label);
         showPopup();
     }
@@ -404,9 +453,9 @@ std::string TaskCertify::createAuthorWidgetInfo() const
 void TaskCertify::stepAuthorInfoPopup()
 {
     LogInfo("Step:: <<Author Popup Information>>");
-        std::string label
-            = createAuthorWidgetInfo() + LABEL_NEW_LINE_2 + QUESTION;
-        createInstallPopup(PopupType::WIDGET_AUTHOR_INFO, label);
+    std::string label
+        = createAuthorWidgetInfo() + LABEL_NEW_LINE_2 + QUESTION;
+    createInstallPopup(PopupType::WIDGET_AUTHOR_INFO, label);
 }
 
 void TaskCertify::stepFinalize()
@@ -418,12 +467,11 @@ void TaskCertify::stepFinalize()
         "Widget Certification Check Finished");
 }
 
-
 void TaskCertify::stepWarningPopupAnswer()
 {
     LogInfo("Step: <<Warning Popup Answer>>");
     if (false == m_contextData.wacSecurity.isDistributorSigned() &&
-            WRT_POPUP_BUTTON_CANCEL == m_installCancel)
+        WRT_POPUP_BUTTON_CANCEL == m_installCancel)
     {
         LogWarning("User does not agreed to install unsigned widgets!");
         m_installCancel = WRT_POPUP_BUTTON;
@@ -435,7 +483,7 @@ void TaskCertify::stepWarningPopupAnswer()
 void TaskCertify::stepAuthorInfoPopupAnswer()
 {
     LogInfo("Step: <<Author Info Popup Answer>>");
-    if ( WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
+    if (WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
         LogWarning("User does not agreed to install widget!");
         m_installCancel = WRT_POPUP_BUTTON;
         destroyPopup();
@@ -447,11 +495,47 @@ bool TaskCertify::isTizenWebApp() const
 {
     bool ret = FALSE;
     if (m_installContext.widgetConfig.webAppType.appType
-            == WrtDB::AppType::APP_TYPE_TIZENWEBAPP)
+        == WrtDB::AppType::APP_TYPE_TIZENWEBAPP)
+    {
         ret = TRUE;
+    }
 
     return ret;
 }
+
+void TaskCertify::stepVerifyUpdate()
+{
+    LogInfo("Step: <<Check Update>>");
+    CertificatePtr newCertificate =
+        m_contextData.wacSecurity.getAuthorCertificatePtr();
+    CertificatePtr oldCertificate =
+        getOldAuthorSignerCertificate(m_installContext.widgetConfig.tzAppid);
+
+    if (!!newCertificate && !!oldCertificate) {
+        if (0 != newCertificate->getBase64().compare(oldCertificate->getBase64())) {
+            LogDebug("old widget's author signer certificate : " <<
+                    oldCertificate->getBase64());
+            LogDebug("new widget's author signer certificate : " <<
+                    newCertificate->getBase64());
+            ThrowMsg(Exceptions::InvalidPackage,
+                    "Author signer certificates doesn't match \
+                    between old widget and installing widget");
+        }
+    } else {
+        if (NULL == newCertificate.Get() )
+            LogDebug("@@@@ new certificate nul");
+
+        if (NULL == oldCertificate.Get() )
+            LogDebug("@@@@ old certificate nul");
+
+        if (!(NULL == newCertificate.Get() && NULL == oldCertificate.Get())) {
+        LogDebug("@@@@");
+            ThrowMsg(Exceptions::InvalidPackage,
+                    "Author signer certificates doesn't match \
+                    between old widget and installing widget");
+        }
+    }
+}
 } //namespace WidgetInstall
 } //namespace Jobs
 
old mode 100755 (executable)
new mode 100644 (file)
index e6ca9ac..315a500
@@ -51,6 +51,7 @@ class TaskCertify :
 
     //steps
     void stepSignature();
+    void stepVerifyUpdate();
     void stepWarningPopup();
     void stepAuthorInfoPopup();
     void stepWarningPopupAnswer();
@@ -60,13 +61,12 @@ class TaskCertify :
     void createInstallPopup(PopupType type, const std::string &label);
 
     void processDistributorSignature(const ValidationCore::SignatureData &data,
-            bool first);
+                                     bool first);
     void processAuthorSignature(const ValidationCore::SignatureData &data);
 
     std::string createAuthorWidgetInfo() const;
 
     bool isTizenWebApp() const;
-
 };
 } //namespace WidgetInstall
 } //namespace Jobs
index fea9ea1..ff1006a 100644 (file)
 
 namespace Jobs {
 namespace WidgetInstall {
-
 namespace {
-
 const char * const TEMPORARY_PATH_POSTFIX = "temp";
 const mode_t TEMPORARY_PATH_MODE = 0775;
-
 } // namespace
 
-
 std::string createTempPath(bool preload)
 {
     LogInfo("Step: Creating temporary path");
 
-   // Temporary path
-   std::ostringstream tempPathBuilder;
-
-   if (preload) {
-       tempPathBuilder << WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
-   } else {
-       tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
-   }
-   tempPathBuilder << WrtDB::GlobalConfig::GetTmpDirPath();
-   tempPathBuilder << "/";
-   tempPathBuilder << TEMPORARY_PATH_POSTFIX;
-   tempPathBuilder << "_";
-
-   timeval tv;
-   gettimeofday(&tv, NULL);
-   tempPathBuilder <<
-   (static_cast<unsigned long long>(tv.tv_sec) * 1000000ULL +
-    static_cast<unsigned long long>(tv.tv_usec));
-
-   std::string tempPath = tempPathBuilder.str();
-
-   // Remove old path if any
-   struct stat fileInfo;
-
-   if (stat(tempPath.c_str(), &fileInfo) == 0) {
-       if(!WrtUtilRemove(tempPath)){
-           ThrowMsg(Exceptions::RemovingFolderFailure,
-                    "Failed to to remove temporary directory");
-       }
-   }
-   // Create new path
-   if(!WrtUtilMakeDir(tempPath, TEMPORARY_PATH_MODE)){
-       ThrowMsg(Exceptions::InternalError, "Failed to create temporary directory");
-   }
-
-   return tempPath;
+    // Temporary path
+    std::ostringstream tempPathBuilder;
+
+    if (preload) {
+        tempPathBuilder << WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
+    } else {
+        tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
+    }
+    tempPathBuilder << WrtDB::GlobalConfig::GetTmpDirPath();
+    tempPathBuilder << "/";
+    tempPathBuilder << TEMPORARY_PATH_POSTFIX;
+    tempPathBuilder << "_";
+
+    timeval tv;
+    gettimeofday(&tv, NULL);
+    tempPathBuilder <<
+    (static_cast<unsigned long long>(tv.tv_sec) * 1000000ULL +
+     static_cast<unsigned long long>(tv.tv_usec));
+
+    std::string tempPath = tempPathBuilder.str();
+
+    // Remove old path if any
+    struct stat fileInfo;
+
+    if (stat(tempPath.c_str(), &fileInfo) == 0) {
+        if (!WrtUtilRemove(tempPath)) {
+            ThrowMsg(Exceptions::RemovingFolderFailure,
+                     "Failed to to remove temporary directory");
+        }
+    }
+    // Create new path
+    if (!WrtUtilMakeDir(tempPath, TEMPORARY_PATH_MODE)) {
+        ThrowMsg(Exceptions::InternalError,
+                 "Failed to create temporary directory");
+    }
+
+    return tempPath;
 }
 
 void createTempPath(const std::string& path)
 {
-   if(!WrtUtilMakeDir(path, TEMPORARY_PATH_MODE)){
-       ThrowMsg(Exceptions::InternalError, "Failed to create temporary directory");
-   }
+    if (!WrtUtilMakeDir(path, TEMPORARY_PATH_MODE)) {
+        ThrowMsg(Exceptions::InternalError,
+                 "Failed to create temporary directory");
+    }
 }
-
 } // WidgetInstall
 } // Jobs
index 5193c3d..6a2f223 100644 (file)
 
 namespace Jobs {
 namespace WidgetInstall {
-
 //TODO make directory like jobs common?
 
 std::string createTempPath(bool preload = false);
 std::string createTempPath(bool preload);
 
 void createTempPath(const std::string& path);
-
 } // WidgetInstall
 } // Jobs
 
-
 #endif /* INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_COMMONS_H_ */
index 78c06ef..874bad8 100644 (file)
  * @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
+ * @brief   Implementation file for installer task database updating for widget
+ * update
  */
+#include <unistd.h>
 #include <time.h>
 #include <sys/stat.h>
 #include <widget_install/task_database.h>
 #include <widget_install/job_widget_install.h>
 #include <widget_install/widget_install_errors.h>
 #include <widget_install/widget_install_context.h>
+#include <web-provider-info.h>
 #include <dpl/wrt-dao-rw/widget_dao.h>
 #include <dpl/wrt-dao-ro/vconf_config.h>
 #include <dpl/foreach.h>
 #include <dpl/utils/wrt_utility.h>
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
+#include <wrt-commons/security-origin-dao/security_origin_dao.h>
 #include <string>
 #include <sstream>
 #include <ace_api_install.h>
@@ -45,7 +49,6 @@ using namespace WrtDB;
 
 namespace Jobs {
 namespace WidgetInstall {
-
 TaskDatabase::TaskDatabase(InstallerContext& context) :
     DPL::TaskDecl<TaskDatabase>(this),
     m_context(context),
@@ -55,8 +58,10 @@ TaskDatabase::TaskDatabase(InstallerContext& context) :
     AddStep(&TaskDatabase::StepRegisterExternalFiles);
     AddStep(&TaskDatabase::StepWrtDBInsert);
     AddStep(&TaskDatabase::StepAceDBInsert);
+    AddStep(&TaskDatabase::StepSecurityOriginDBInsert);
     AddStep(&TaskDatabase::StepRemoveExternalFiles);
     AddStep(&TaskDatabase::StepCreateVconf);
+    AddStep(&TaskDatabase::StepLiveboxDBInsert);
 
     AddAbortStep(&TaskDatabase::StepAbortDBInsert);
 }
@@ -68,40 +73,41 @@ void TaskDatabase::StepWrtDBInsert()
         /* Set install Time */
         time(&m_context.widgetConfig.installedTime);
 
-        if (m_context.existingWidgetInfo.isExist) //update
-        {
+        if (m_context.existingWidgetInfo.isExist) { //update
             LogInfo("Registering widget... (update)");
             Try
             {
                 m_handleToRemove = WidgetDAOReadOnly::getHandle(
-                    m_context.locations->getPkgname());
+                        m_context.widgetConfig.tzAppid);
             }
             Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
             {
-                LogError("Given tizenId not found for update installation (Same GUID?)");
-                ThrowMsg(Exceptions::InvalidPackage, "Given tizenId not found for update installation");
+                LogError(
+                    "Given tizenId not found for update installation (Same GUID?)");
+                ThrowMsg(Exceptions::InvalidPackage,
+                         "Given tizenId not found for update installation");
             }
             WidgetDAO::registerOrUpdateWidget(
-                    m_context.locations->getPkgname(),
-                    m_context.widgetConfig,
-                    m_context.wacSecurity);
+                m_context.widgetConfig.tzAppid,
+                m_context.widgetConfig,
+                m_context.wacSecurity);
             m_handle = WidgetDAOReadOnly::getHandle(
-                m_context.locations->getPkgname());
-        }
-        else //new installation
-        {
+                    m_context.widgetConfig.tzAppid);
+        } else { //new installation
             LogInfo("Registering widget...");
             WidgetDAO::registerWidget(
-                    m_context.locations->getPkgname(),
-                    m_context.widgetConfig,
-                    m_context.wacSecurity);
+                m_context.widgetConfig.tzAppid,
+                m_context.widgetConfig,
+                m_context.wacSecurity);
             m_handle = WidgetDAOReadOnly::getHandle(
-                m_context.locations->getPkgname());
+                    m_context.widgetConfig.tzAppid);
         }
 
-        FOREACH (cap, m_context.staticPermittedDevCaps) {
-            LogInfo("staticPermittedDevCaps : " << cap->first
-                    << " smack status: " << cap->second);
+        FOREACH(cap, m_context.staticPermittedDevCaps) {
+            LogInfo(
+                "staticPermittedDevCaps : " << cap->first
+                                            << " smack status: " <<
+                cap->second);
         }
 
         LogInfo("Widget registered");
@@ -126,17 +132,36 @@ void TaskDatabase::StepAceDBInsert()
         if (ACE_OK != ace_unregister_widget(
                 static_cast<ace_widget_handle_t>(m_handleToRemove)))
         {
-            LogWarning("Error while removing ace entry for previous insallation");
-        };
+            LogWarning(
+                "Error while removing ace entry for previous insallation");
+        }
     }
 
-    if(!AceApi::registerAceWidget(m_handle, m_context.widgetConfig,
-                                  m_context.wacSecurity.getCertificateList()))
+    if (!AceApi::registerAceWidget(m_handle, m_context.widgetConfig,
+                                   m_context.wacSecurity.getCertificateList()))
     {
         LogError("ace database insert failed");
-        ThrowMsg(Exceptions::UpdateFailed, "Update failure. ace_register_widget failed");
+        ThrowMsg(Exceptions::UpdateFailed,
+                 "Update failure. ace_register_widget failed");
     }
     LogDebug("Ace data inserted");
+}
+
+void TaskDatabase::StepSecurityOriginDBInsert()
+{
+    LogDebug("Create Security origin database");
+    // automatically create security origin database
+    using namespace SecurityOriginDB;
+    SecurityOriginDAO dao(m_context.locations->getPkgId());
+
+    // Checking privilege list for setting security origin exception data
+    FOREACH(it, m_context.widgetConfig.configInfo.privilegeList) {
+        std::map<std::string, Feature>::const_iterator result =
+            g_W3CPrivilegeTextMap.find(DPL::ToUTF8String(it->name));
+        if (result != g_W3CPrivilegeTextMap.end()) {
+            dao.setPrivilegeSecurityOriginData(result->second);
+        }
+    }
 
     m_context.job->UpdateProgress(
         InstallerContext::INSTALL_NEW_DB_INSERT,
@@ -145,16 +170,19 @@ void TaskDatabase::StepAceDBInsert()
 
 void TaskDatabase::StepRegisterExternalFiles()
 {
-    WrtDB::ExternalLocationList externalLocationsUpdate = m_context.locations->listExternalLocations();
-    if (m_context.existingWidgetInfo.isExist) //update
-    {
+    WrtDB::ExternalLocationList externalLocationsUpdate =
+        m_context.locations->listExternalLocations();
+    if (m_context.existingWidgetInfo.isExist) { //update
         Try
         {
-            WidgetDAO dao(m_context.locations->getPkgname());
-            WrtDB::ExternalLocationList externalLocationsDB = dao.getWidgetExternalLocations();
+            WidgetDAO dao(m_context.widgetConfig.tzAppid);
+            WrtDB::ExternalLocationList externalLocationsDB =
+                dao.getWidgetExternalLocations();
             FOREACH(file, externalLocationsDB)
             {
-                if(std::find(externalLocationsUpdate.begin(), externalLocationsUpdate.end(), *file) == externalLocationsUpdate.end())
+                if (std::find(externalLocationsUpdate.begin(),
+                              externalLocationsUpdate.end(),
+                              *file) == externalLocationsUpdate.end())
                 {
                     m_externalLocationsToRemove.push_back(*file);
                 }
@@ -162,8 +190,10 @@ void TaskDatabase::StepRegisterExternalFiles()
         }
         Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
         {
-            LogError("Given tizenId not found for update installation (Same GUID?)");
-            ThrowMsg(Exceptions::UpdateFailed, "Given tizenId not found for update installation");
+            LogError(
+                "Given tizenId not found for update installation (Same GUID?)");
+            ThrowMsg(Exceptions::UpdateFailed,
+                     "Given tizenId not found for update installation");
         }
     }
     LogDebug("Registering external files:");
@@ -178,28 +208,25 @@ void TaskDatabase::StepRegisterExternalFiles()
 
 void TaskDatabase::StepRemoveExternalFiles()
 {
-    if(!m_externalLocationsToRemove.empty())
-    {
+    if (!m_externalLocationsToRemove.empty()) {
         LogDebug("Removing external files:");
     }
 
     FOREACH(file, m_externalLocationsToRemove)
     {
-        if(WrtUtilFileExists(*file))
-        {
+        if (WrtUtilFileExists(*file)) {
             LogDebug("  -> " << *file);
-            remove(file->c_str());
-        }
-        else if(WrtUtilDirExists(*file))
-        {
+            if (-1 == TEMP_FAILURE_RETRY(remove(file->c_str()))) {
+                ThrowMsg(Exceptions::RemovingFileFailure,
+                         "Failed to remove external file");
+            }
+        } else if (WrtUtilDirExists(*file)) {
             LogDebug("  -> " << *file);
-            if(!WrtUtilRemove(*file)){
+            if (!WrtUtilRemove(*file)) {
                 ThrowMsg(Exceptions::RemovingFolderFailure,
-                        "Failed to remove external directory");
+                         "Failed to remove external directory");
             }
-        }
-        else
-        {
+        } else {
             LogWarning("  -> " << *file << "(no such a path)");
         }
     }
@@ -211,22 +238,16 @@ void TaskDatabase::StepCreateVconf()
     std::map<std::string, WrtDB::SettingsType> vconfData;
     vconfData[
         WrtDB::VconfConfig::GetVconfKeyPopupUsage(
-            m_context.locations->getPkgname())] = WrtDB::SETTINGS_TYPE_ON;
+            m_context.widgetConfig.tzAppid)] = WrtDB::SETTINGS_TYPE_ON;
     vconfData[
         WrtDB::VconfConfig::GetVconfKeyGeolocationUsage(
-            m_context.locations->getPkgname())] = WrtDB::SETTINGS_TYPE_ON;
+            m_context.widgetConfig.tzAppid)] = WrtDB::SETTINGS_TYPE_ON;
     vconfData[
         WrtDB::VconfConfig::GetVconfKeyWebNotificationUsage(
-            m_context.locations->getPkgname())] = WrtDB::SETTINGS_TYPE_ON;
-    vconfData[
-        WrtDB::VconfConfig::GetVconfKeyWebDatabaseUsage(
-            m_context.locations->getPkgname())] = WrtDB::SETTINGS_TYPE_ON;
-    vconfData[
-        WrtDB::VconfConfig::GetVconfKeyFilesystemUsage(
-            m_context.locations->getPkgname())] = WrtDB::SETTINGS_TYPE_ON;
+            m_context.widgetConfig.tzAppid)] = WrtDB::SETTINGS_TYPE_ON;
     vconfData[
         WrtDB::VconfConfig::GetVconfKeyMemorySavingMode(
-            m_context.locations->getPkgname())] = WrtDB::SETTINGS_TYPE_OFF;
+            m_context.widgetConfig.tzAppid)] = WrtDB::SETTINGS_TYPE_OFF;
 
     // vconftool -g 5000 set -t int <path> initialize value
     // Current installer should use vconftool for setting group ID
@@ -239,7 +260,8 @@ void TaskDatabase::StepCreateVconf()
         command << " \"" << static_cast<int>((*it).second) << "\"";
         int ret = system(command.str().c_str());
         if (-1 == ret) {
-            ThrowMsg(Exceptions::CreateVconfFailure, "Failed to create vconf files");
+            ThrowMsg(Exceptions::CreateVconfFailure,
+                     "Failed to create vconf files");
         }
     }
 }
@@ -249,7 +271,7 @@ void TaskDatabase::StepAbortDBInsert()
     LogWarning("[DB Update Task] Aborting... (DB Clean)");
     Try
     {
-        WidgetDAO::unregisterWidget(m_context.locations->getPkgname());
+        WidgetDAO::unregisterWidget(m_context.widgetConfig.tzAppid);
         LogDebug("Cleaning DB successful!");
     }
     Catch(DPL::DB::SqlConnection::Exception::Base)
@@ -260,9 +282,40 @@ void TaskDatabase::StepAbortDBInsert()
     ace_unregister_widget(static_cast<ace_widget_handle_t>(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)
+    if (INVALID_WIDGET_HANDLE != m_handleToRemove) {
         ace_unregister_widget(static_cast<ace_widget_handle_t>(m_handle));
+    }
 }
 
+void TaskDatabase::StepLiveboxDBInsert()
+{
+    if (m_context.widgetConfig.configInfo.m_livebox.size() <= 0) {
+        return;
+    }
+
+    std::string tizenId = DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
+
+    for (auto it = m_context.widgetConfig.configInfo.m_livebox.begin();
+         it != m_context.widgetConfig.configInfo.m_livebox.end(); ++it)
+    {
+        std::string boxId = DPL::ToUTF8String((**it).m_liveboxId);
+        std::string boxType;
+        if ((**it).m_type == L"") {
+            boxType = web_provider_info_get_default_type();
+        } else {
+            boxType = DPL::ToUTF8String((**it).m_type);
+        }
+        LogInfo("livebox id: " << boxId);
+        LogInfo("livebox type: " << boxType);
+
+        int ret =
+            web_provider_info_insert_box_type(
+                boxId.c_str(), tizenId.c_str(), boxType.c_str());
+
+        if (ret < 0) {
+            LogDebug("failed to set type of livebox: " << boxId);
+        }
+    }
+}
 } //namespace WidgetInstall
 } //namespace Jobs
index f2098bc..3e0beba 100644 (file)
@@ -32,7 +32,7 @@ class InstallerContext;
 
 namespace Jobs {
 namespace WidgetInstall {
-class TaskDatabase:
+class TaskDatabase :
     public DPL::TaskDecl<TaskDatabase>
 {
   private:
@@ -47,8 +47,10 @@ class TaskDatabase:
     void StepRegisterExternalFiles();
     void StepWrtDBInsert();
     void StepAceDBInsert();
+    void StepSecurityOriginDBInsert();
     void StepRemoveExternalFiles();
     void StepCreateVconf();
+    void StepLiveboxDBInsert();
 
     void StepAbortDBInsert();
 
index 71752e5..3de2de7 100644 (file)
 #undef __USE_FILE_OFFSET64
 
 #include <unistd.h>
-#include <string>
 #include <sys/stat.h>
 #include <fts.h>
 #include <string.h>
 #include <errno.h>
+#include <cstdio>
+
+#include <memory>
 
 #include <dpl/log/log.h>
 #include <dpl/errno_string.h>
 #include <dpl/foreach.h>
+#include <dpl/scoped_fclose.h>
 #include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/string.h>
+#include <FBaseByteBuffer.h>
+#include <security/FSecCrypto_TrustZoneService.h>
 
 #include <widget_install/job_widget_install.h>
 #include <widget_install/widget_install_context.h>
 #include <widget_install/widget_install_errors.h>
 
 using namespace WrtDB;
-using namespace WRTEncryptor;
 
 namespace {
+const std::size_t ENCRYPTION_CHUNK_MAX_SIZE = 1008; // bytes
+
 std::set<std::string>& getSupportedForEncryption()
 {
     static std::set<std::string> encryptSet;
@@ -63,6 +70,117 @@ bool isSupportedForEncryption(const std::string &file)
     }
     return false;
 }
+
+/**
+ * Opens a file.
+ *
+ * @param path Path to a file.
+ * @param mode Mode.
+ * @return Stream handle.
+ * @throw ExtractFileFailed If error (other than EINTR) occurs.
+ */
+FILE* openFile(const std::string& path, const std::string& mode)
+{
+    FILE* result = NULL;
+
+    do
+    {
+        result = fopen(path.c_str(), mode.c_str());
+    } while ((NULL == result) && (EINTR == errno));
+
+    if (NULL == result)
+    {
+        ThrowMsg(Jobs::WidgetInstall::Exceptions::InternalError,
+                 "Could not open file " << path);
+    }
+
+    return result;
+}
+
+/**
+ * Reads bytes from a stream.
+ *
+ * @param buffer Buffer to read the bytes into.
+ * @param count Number of bytes to read.
+ * @param stream Stream to read from.
+ * @return Number of bytes read
+ * @throw ExtractFileFailed If error (other than EINTR) occurs.
+ */
+std::size_t readBytes(unsigned char* buffer, std::size_t count, FILE* stream)
+{
+    std::size_t result = std::fread(buffer,
+                                    sizeof(unsigned char),
+                                    count,
+                                    stream);
+
+    if (result != count)
+    {
+        int error = errno;
+        if (0 != std::ferror(stream))
+        {
+            if (EINTR != error)
+            {
+                ThrowMsg(Jobs::WidgetInstall::Exceptions::InternalError,
+                         "Error while reading data" <<
+                         " [" << DPL::GetErrnoString(error) << "]");
+            }
+        }
+    }
+
+    return result;
+}
+
+/**
+ * Writes bytes to a stream.
+ *
+ * @param buffer Data to write.
+ * @param count Number of bytes.
+ * @param stream Stream to write to.
+ * @throw ExtractFileFailed If error (other than EINTR) occurs.
+ */
+void writeBytes(unsigned char* buffer, std::size_t count, FILE* stream)
+{
+    std::size_t bytesWritten = 0;
+    std::size_t bytesToWrite = 0;
+    do
+    {
+        bytesToWrite = count - bytesWritten;
+        bytesWritten = std::fwrite(buffer + bytesWritten,
+                                   sizeof(unsigned char),
+                                   count - bytesWritten,
+                                   stream);
+        if ((bytesWritten != bytesToWrite) && (EINTR != errno))
+        {
+            int error = errno;
+            ThrowMsg(Jobs::WidgetInstall::Exceptions::InternalError,
+                     "Error while writing data" <<
+                     " [" << DPL::GetErrnoString(error) << "]");
+        }
+    } while ((bytesWritten != bytesToWrite) && (EINTR == errno));
+}
+
+/*
+ * get encrypted string from trustzone
+*/
+Tizen::Base::ByteBuffer* EncryptChunkByTrustZone(
+        Tizen::Base::ByteBuffer* appInfo,
+        const unsigned char *plainBuffer,
+        int pBufSize)
+{
+    using namespace Tizen::Base;
+
+    Tizen::Security::Crypto::_TrustZoneService* pInstance;
+    pInstance = Tizen::Security::Crypto::_TrustZoneService::GetInstance();
+
+    ByteBuffer pBuf;
+    pBuf.Construct(pBufSize);
+    const byte *pByte = reinterpret_cast<const byte*>(plainBuffer);
+    pBuf.SetArray(pByte, 0, pBufSize);
+    pBuf.Flip();
+
+    ByteBuffer* getBuffer = pInstance->_TrustZoneService::EncryptN(*appInfo, pBuf);
+    return getBuffer;
+}
 }
 
 namespace Jobs {
@@ -77,135 +195,158 @@ TaskEncryptResource::TaskEncryptResource(InstallerContext& context) :
 void TaskEncryptResource::StepEncryptResource()
 {
     LogDebug("Step Encrypt resource");
-    m_resEnc = new ResourceEncryptor;
-    m_resEnc->CreateEncryptionKey(DPL::ToUTF8String(m_context.
-                widgetConfig.pkgName));
 
     EncryptDirectory(m_context.locations->getTemporaryRootDir());
+    m_context.job->UpdateProgress(
+            InstallerContext::INSTALL_ECRYPTION_FILES,
+            "Ecrypt resource files");
 }
 
 void TaskEncryptResource::EncryptDirectory(std::string path)
 {
     FTS *fts;
     FTSENT *ftsent;
-    char * const paths[] = {const_cast<char * const>(path.c_str()), NULL};
+    char * const paths[] = { const_cast<char * const>(path.c_str()), NULL };
 
-    if ((fts = fts_open(paths, FTS_PHYSICAL|FTS_NOCHDIR, NULL)) == NULL) {
+    if ((fts = fts_open(paths, FTS_PHYSICAL | FTS_NOCHDIR, NULL)) == NULL) {
         //ERROR
         int error = errno;
         LogWarning(__PRETTY_FUNCTION__ << ": fts_open failed with error: "
-                << strerror(error));
+                                       << strerror(error));
         ThrowMsg(Exceptions::InternalError, "Error reading directory: "
-                << path);
+                 << path);
     }
 
     while ((ftsent = fts_read(fts)) != NULL) {
         switch (ftsent->fts_info) {
-            case FTS_DP:
-            case FTS_DC:
-            case FTS_D:
-            case FTS_DEFAULT:
-            case FTS_SLNONE:
-                //directories, non-regular files, dangling symbolic links
-                break;
-            case FTS_F:
-            case FTS_NSOK:
-            case FTS_SL:
-                //regular files and other objects that can be counted
-                if (isSupportedForEncryption(ftsent->fts_path)) {
-                    EncryptFile(ftsent->fts_path);
-                }
-                break;
-            case FTS_NS:
-            case FTS_DOT:
-            case FTS_DNR:
-            case FTS_ERR:
-            default:
-                LogWarning(__PRETTY_FUNCTION__
-                        << ": traversal failed on file: "
-                        << ftsent->fts_path
-                        << " with error: "
-                        << strerror(ftsent->fts_errno));
-                ThrowMsg(Exceptions::InternalError, "Error reading file");
+        case FTS_DP:
+        case FTS_DC:
+        case FTS_D:
+        case FTS_DEFAULT:
+        case FTS_SLNONE:
+            //directories, non-regular files, dangling symbolic links
+            break;
+        case FTS_F:
+        case FTS_NSOK:
+        case FTS_SL:
+            //regular files and other objects that can be counted
+            if (isSupportedForEncryption(ftsent->fts_path)) {
+                EncryptFile(ftsent->fts_path);
+            }
+            break;
+        case FTS_NS:
+        case FTS_DOT:
+        case FTS_DNR:
+        case FTS_ERR:
+        default:
+            LogWarning(__PRETTY_FUNCTION__
+                       << ": traversal failed on file: "
+                       << ftsent->fts_path
+                       << " with error: "
+                       << strerror(ftsent->fts_errno));
+            ThrowMsg(Exceptions::InternalError, "Error reading file");
+            break;
         }
     }
 
     if (fts_close(fts) == -1) {
         int error = errno;
         LogWarning(__PRETTY_FUNCTION__ << ": fts_close failed with error: "
-                << strerror(error));
+                                       << strerror(error));
     }
 }
 
 void TaskEncryptResource::EncryptFile(const std::string &fileName)
 {
-    Try
+    try
     {
-        LogDebug("Need to ecnrypt file Name " << fileName);
+        LogDebug("Encrypt file: " << fileName);
         std::string encFile = fileName + ".enc";
 
-        struct stat buf;
-        int ret = stat(fileName.c_str(), &buf);
-        if(ret == 0) {
-            size_t fileSize = buf.st_size;
+        struct stat info;
+        memset(&info, 0, sizeof(info));
+        if (stat(fileName.c_str(), &info) != 0)
+        {
+            int error = errno;
+            ThrowMsg(Exceptions::InternalError,
+                     "Could not access file " << fileName <<
+                     "[" << DPL::GetErrnoString(error) << "]");
+        }
+        const std::size_t fileSize = info.st_size;
 
-            FILE* resFp = fopen(fileName.c_str(), "r");
-            if ( NULL == resFp) {
-                LogError("Couldnot open file : " << fileName);
-                return;
-            }
+        DPL::ScopedFClose inFile(openFile(fileName, "r"));
+        DPL::ScopedFClose outFile(openFile(encFile, "w"));
 
-            int blockSize = m_resEnc->GetBlockSize(fileSize);
-            LogDebug("Get block size : " << blockSize);
+        const std::size_t chunkSize = (fileSize > ENCRYPTION_CHUNK_MAX_SIZE
+                ? ENCRYPTION_CHUNK_MAX_SIZE : fileSize);
 
-            unsigned char readBuf[fileSize];
-            unsigned char outEncBuf[blockSize];
-            memset(readBuf, 0, fileSize);
-            memset(outEncBuf, 0, blockSize);
+        std::unique_ptr<unsigned char[]> inChunk(new unsigned char[chunkSize]);
+        std::unique_ptr<unsigned char[]> outChunk;
 
-            ret = fread(readBuf, sizeof(unsigned char), fileSize, resFp);
-            if (ret!=fileSize){
-                LogError("Failed to read ecryption buffer with error: " << strerror(errno) );
-                fclose(resFp);
-               return;
-            }
+        std::size_t bytesRead = 0;
+        using namespace Tizen::Base;
 
-            m_resEnc->EncryptChunk(readBuf, outEncBuf, fileSize);
+        std::string pkgid =
+            DPL::ToUTF8String(m_context.widgetConfig.tzAppid).c_str();
+        const byte *b_pkgid = reinterpret_cast<const byte*>(
+                    pkgid.c_str());
+        ByteBuffer appInfo;
+        appInfo.Construct(pkgid.length());
+        appInfo.SetArray(b_pkgid, 0, pkgid.length());
+        appInfo.Flip();
 
-            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);
+        do
+        {
+            bytesRead = readBytes(inChunk.get(), chunkSize, inFile.Get());
+            if (0 != bytesRead) {
 
-            fclose(resFp);
-            fclose(encFp);
+                ByteBuffer *getBuffer = EncryptChunkByTrustZone(
+                        &appInfo,
+                        inChunk.get(), bytesRead);
+                int decBufSize = getBuffer->GetRemaining();
 
-            LogDebug("Success to encrypt file");
-            LogDebug("Remove unecrypted file : " << fileName);
+                outChunk.reset(new unsigned char[decBufSize]);
+                memcpy(outChunk.get(), getBuffer->GetPointer(), getBuffer->GetRemaining());
+                getBuffer->Reset();
 
-            unlink(fileName.c_str());
-            if ((rename(encFile.c_str(), fileName.c_str())) != 0) {
-                ThrowMsg(Exceptions::ExtractFileFailed, fileName);
+                writeBytes(outChunk.get(), decBufSize, outFile.Get());
             }
 
-            std::string realPath = fileName;
-            realPath.replace(0, m_context.locations->getTemporaryRootDir().length(),
-                    m_context.locations->getSourceDir());
+        } while (0 == std::feof(inFile.Get()));
+
+        LogDebug("File encrypted successfully");
 
-            WrtDB::EncryptedFileInfo info;
-            info.fileName = DPL::FromUTF8String(realPath);
-            info.fileSize = fileSize;
+        outFile.Reset();
+        inFile.Reset();
 
-            m_context.widgetConfig.encryptedFiles.insert(info);
+        LogDebug("Remove plain-text file: " << fileName);
+        if (0 != unlink(fileName.c_str()))
+        {
+            Throw(Exceptions::InternalError);
         }
+
+        LogDebug("Rename encrypted file");
+        if (0 != std::rename(encFile.c_str(), fileName.c_str()))
+        {
+            Throw(Exceptions::InternalError);
+        }
+
+        std::string realPath = fileName;
+        realPath.replace(0,
+                         m_context.locations->getTemporaryRootDir().length(),
+                         m_context.locations->getSourceDir());
+
+        WrtDB::EncryptedFileInfo fileInfo;
+        fileInfo.fileName = DPL::FromUTF8String(realPath);
+        fileInfo.fileSize = fileSize;
+
+        m_context.widgetConfig.encryptedFiles.insert(fileInfo);
     }
-    Catch(ResourceEncryptor::Exception::Base)
+    Catch (Exceptions::InternalError)
     {
         ReThrowMsg(Exceptions::ExtractFileFailed, fileName);
     }
 }
+
 } //namespace WidgetInstall
 } //namespace Jobs
index de37640..9c95696 100644 (file)
 #include <dpl/task.h>
 #include <string>
 
-#include <dpl/encryption/resource_encryption.h>
-
 class InstallerContext;
 
 namespace Jobs {
 namespace WidgetInstall {
-
 class TaskEncryptResource : public DPL::TaskDecl<TaskEncryptResource>
 {
-private:
+  private:
     // Installation context
     InstallerContext &m_context;
     std::string tempInstalledPath;
@@ -44,12 +41,9 @@ private:
     void EncryptDirectory(std::string path);
     void EncryptFile(const std::string &fileName);
 
-    WRTEncryptor::ResourceEncryptor *m_resEnc;
-
   public:
     explicit TaskEncryptResource(InstallerContext &installerContext);
 };
-
 } // namespace WidgetInstall
 } // namespace Jobs
 #endif /* SRC_JOBS_WIDGET_INSTALL_TASK_ENCRYPT_RESOURCE_H_ */
index 8306799..db50d6b 100644 (file)
@@ -19,6 +19,7 @@
  * @version 1.0
  * @brief   Implementation file for installer task database updating
  */
+#include <unistd.h>
 #include <sys/stat.h>
 #include <dirent.h>
 #include <widget_install/task_file_manipulation.h>
@@ -55,11 +56,15 @@ bool _FolderCopy(std::string source, std::string dest)
         return false;
     }
 
-    struct dirent* dEntry = NULL;
+    struct dirent dEntry;
+    struct dirent *dEntryResult;
+    int return_code;
+
     do {
         struct stat statInfo;
-        if (dEntry = readdir(dir)) {
-            std::string fileName = dEntry->d_name;
+        return_code = readdir_r(dir, &dEntry, &dEntryResult);
+        if (dEntryResult != NULL && return_code == 0) {
+            std::string fileName = dEntry.d_name;
             std::string fullName = source + "/" + fileName;
 
             if (stat(fullName.c_str(), &statInfo) != 0) {
@@ -68,7 +73,7 @@ bool _FolderCopy(std::string source, std::string dest)
             }
 
             if (S_ISDIR(statInfo.st_mode)) {
-                if(("." == fileName) || (".." == fileName)) {
+                if (("." == fileName) || (".." == fileName)) {
                     continue;
                 }
                 std::string destFolder = dest + "/" + fileName;
@@ -87,7 +92,7 @@ bool _FolderCopy(std::string source, std::string dest)
             outfile.close();
             infile.close();
         }
-    } while(dEntry);
+    } while (dEntryResult != NULL && return_code == 0);
     closedir(dir);
     return true;
 }
@@ -97,15 +102,16 @@ namespace Jobs {
 namespace WidgetInstall {
 TaskFileManipulation::TaskFileManipulation(InstallerContext& context) :
     DPL::TaskDecl<TaskFileManipulation>(this),
-    m_context(context)
+    m_context(context),
+    m_extHandle(NULL)
 {
     if (INSTALL_LOCATION_TYPE_EXTERNAL !=
-            m_context.locationType) {
+        m_context.locationType)
+    {
         AddStep(&TaskFileManipulation::StepCreateDirs);
         AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir);
-        AddStep(&TaskFileManipulation::StepCreateShareDir);
         if (m_context.widgetConfig.packagingType !=
-                WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
+            WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
         {
             AddStep(&TaskFileManipulation::StepRenamePath);
             AddAbortStep(&TaskFileManipulation::StepAbortRenamePath);
@@ -114,7 +120,6 @@ TaskFileManipulation::TaskFileManipulation(InstallerContext& context) :
         AddStep(&TaskFileManipulation::StepPrepareExternalDir);
         AddStep(&TaskFileManipulation::StepInstallToExternal);
         AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir);
-        AddStep(&TaskFileManipulation::StepCreateShareDir);
 
         AddAbortStep(&TaskFileManipulation::StepAbortCreateExternalDir);
     }
@@ -151,86 +156,43 @@ void TaskFileManipulation::StepCreatePrivateStorageDir()
     std::string storagePath = m_context.locations->getPrivateStorageDir();
 
     if (euidaccess(storagePath.c_str(), F_OK) != 0) {
-        if(!WrtUtilMakeDir(storagePath, PRIVATE_STORAGE_MODE)){
+        if (!WrtUtilMakeDir(storagePath, PRIVATE_STORAGE_MODE)) {
             LogError("Failed to create directory for private storage");
             ThrowMsg(Exceptions::InternalError,
-                    "Failed to create directory for private storage");
+                     "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'.
+        // 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)
+        if (chown(storagePath.c_str(),
+                  WEBAPP_DEFAULT_UID,
+                  WEBAPP_DEFAULT_GID) != 0)
         {
             ThrowMsg(Exceptions::InternalError,
-                 "Chown to invaild user");
+                     "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)
+        if (chown(storagePath.c_str(),
+                  WEBAPP_DEFAULT_UID,
+                  WEBAPP_DEFAULT_GID) != 0)
         {
             ThrowMsg(Exceptions::InternalError,
-                 "Chown to invaild user");
+                     "Chown to invaild user");
         }
-        if(chmod(storagePath.c_str(), PRIVATE_STORAGE_MODE) != 0) {
+        if (chmod(storagePath.c_str(), PRIVATE_STORAGE_MODE) != 0) {
             ThrowMsg(Exceptions::InternalError,
-                 "chmod to 0700");
+                     "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;
@@ -244,12 +206,14 @@ void TaskFileManipulation::StepRenamePath()
     LogDebug("Copy file from temp directory to " << instDir);
     if (!WrtUtilRemove(instDir)) {
         ThrowMsg(Exceptions::RemovingFolderFailure,
-                "Error occurs during removing existing folder");
+                 "Error occurs during removing existing folder");
     }
 
-    if (!(rename(m_context.locations->getTemporaryPackageDir().c_str(), instDir.c_str()) == 0)) {
+    if (!(rename(m_context.locations->getTemporaryPackageDir().c_str(),
+                 instDir.c_str()) == 0))
+    {
         ThrowMsg(Exceptions::UnknownError,
-                "Error occurs during renaming widget folder");
+                 "Error occurs during renaming widget folder");
     }
     m_context.job->UpdateProgress(
         InstallerContext::INSTALL_RENAME_PATH,
@@ -264,7 +228,7 @@ void TaskFileManipulation::StepAbortRenamePath()
         widgetPath = m_context.locations->getPackageInstallationDir();
         if (!WrtUtilRemove(widgetPath)) {
             ThrowMsg(Exceptions::RemovingFolderFailure,
-                    "Error occurs during removing existing folder");
+                     "Error occurs during removing existing folder");
         }
     }
     LogDebug("Rename widget path sucessful!");
@@ -274,10 +238,10 @@ void TaskFileManipulation::StepPrepareExternalDir()
 {
     LogDebug("Step prepare to install in exernal directory");
     Try {
-        std::string pkgname =
-            DPL::ToUTF8String(*m_context.widgetConfig.pkgname);
+        std::string appid =
+            DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
 
-        WidgetInstallToExtSingleton::Instance().initialize(pkgname);
+        WidgetInstallToExtSingleton::Instance().initialize(appid);
 
         size_t totalSize =
             Utils::getFolderSize(m_context.locations->getTemporaryPackageDir());
@@ -287,13 +251,15 @@ void TaskFileManipulation::StepPrepareExternalDir()
         GList *list = NULL;
         app2ext_dir_details* dirDetail = NULL;
 
-        std::string dirNames[2] = {GLIST_RES_DIR, GLIST_BIN_DIR};
+        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));
+                                                      sizeof(
+                                                          app2ext_dir_details));
             if (NULL == dirDetail) {
-                ThrowMsg(Exceptions::ErrorExternalInstallingFailure, "error in app2ext");
+                ThrowMsg(Exceptions::ErrorExternalInstallingFailure,
+                         "error in app2ext");
             }
             dirDetail->name = strdup(dirNames[i].c_str());
             dirDetail->type = APP2EXT_DIR_RO;
@@ -302,17 +268,18 @@ void TaskFileManipulation::StepPrepareExternalDir()
 
         if (false == m_context.existingWidgetInfo.isExist) {
             WidgetInstallToExtSingleton::Instance().preInstallation(list,
-                    folderSize);
+                                                                    folderSize);
         } else {
             WidgetInstallToExtSingleton::Instance().preUpgrade(list,
-                    folderSize);
+                                                               folderSize);
         }
         free(dirDetail);
         g_list_free(list);
     }
-    Catch (WidgetInstallToExt::Exception::ErrorInstallToExt)
+    Catch(WidgetInstallToExt::Exception::ErrorInstallToExt)
     {
-        ReThrowMsg(Exceptions::ErrorExternalInstallingFailure, "Error during \
+        ReThrowMsg(Exceptions::ErrorExternalInstallingFailure,
+                   "Error during \
                 create external folder ");
     }
 }
@@ -321,17 +288,18 @@ void TaskFileManipulation::StepInstallToExternal()
 {
     LogDebug("StepInstallExternal");
     if (!WrtUtilMakeDir(m_context.locations->getSourceDir())) {
-        ThrowMsg(Exceptions::ErrorExternalInstallingFailure, "To make src \
+        ThrowMsg(Exceptions::ErrorExternalInstallingFailure,
+                 "To make src \
                 directory failed");
     }
 
     LogDebug("Resource move to external storage " <<
-            m_context.locations->getSourceDir());
+             m_context.locations->getSourceDir());
     if (!_FolderCopy(m_context.locations->getTemporaryPackageDir(),
-                m_context.locations->getSourceDir()))
+                     m_context.locations->getSourceDir()))
     {
         ThrowMsg(Exceptions::UnknownError,
-                "Error occurs during renaming widget folder");
+                 "Error occurs during renaming widget folder");
     }
 }
 
index e3f615e..bce099f 100644 (file)
@@ -39,7 +39,6 @@ class TaskFileManipulation :
     void StepCreateDirs();
     void StepRenamePath();
     void StepCreatePrivateStorageDir();
-    void StepCreateShareDir();
 
     void StepAbortRenamePath();
 
index 150f60f..7909c26 100644 (file)
@@ -55,7 +55,8 @@ void TaskInstallOspsvc::StepInstallOspService()
     LogInfo("Step: installation for osp service");
 
     std::ostringstream commStr;
-    commStr << OSP_INSTALL_STR << BashUtils::escape_arg(m_context.locations->getPackageInstallationDir());
+    commStr << OSP_INSTALL_STR << BashUtils::escape_arg(
+        m_context.locations->getPackageInstallationDir());
     //commStr << " 2>&1";
     LogDebug("osp install command : " << commStr.str());
 
@@ -64,15 +65,25 @@ void TaskInstallOspsvc::StepInstallOspService()
     fd = popen(commStr.str().c_str(), "r");
     if (NULL == fd) {
         LogError("Failed to installtion osp service");
-        ThrowMsg(Exceptions::InstallOspsvcFailed, "Error occurs during\
+        ThrowMsg(Exceptions::InstallOspsvcFailed,
+                 "Error occurs during\
+                install osp service");
+    }
+
+    if (fgets(readBuf, MAX_BUF_SIZE, fd) == NULL)
+    {
+        LogError("Failed to installtion osp service.\
+                Inability of reading file.");
+        ThrowMsg(Exceptions::InstallOspsvcFailed,
+                "Error occurs during\
                 install osp service");
     }
-    fgets(readBuf, MAX_BUF_SIZE, fd);
     LogDebug("return value : " << readBuf);
 
     int result = atoi(readBuf);
     if (0 != result) {
-        ThrowMsg(Exceptions::InstallOspsvcFailed, "Error occurs during\
+        ThrowMsg(Exceptions::InstallOspsvcFailed,
+                 "Error occurs during\
                 install osp service");
     }
 
index 29d6d80..445bfb4 100644 (file)
@@ -29,10 +29,9 @@ class InstallerContext;
 
 namespace Jobs {
 namespace WidgetInstall {
-
 class TaskInstallOspsvc : public DPL::TaskDecl<TaskInstallOspsvc>
 {
-private:
+  private:
     // Installation context
     InstallerContext &m_context;
 
@@ -42,14 +41,13 @@ private:
 
     // return callback
     static int StatusCallback(
-            int req_id, const char *pkg_type, const char *pkg_name,
-            const char *key, const char *val, const void *pmsg,
-            void *priv_data);
+        int req_id, const char *pkg_type, const char *pkg_name,
+        const char *key, const char *val, const void *pmsg,
+        void *priv_data);
 
   public:
     explicit TaskInstallOspsvc(InstallerContext &installerContext);
 };
-
 } // namespace WidgetInstall
 } // namespace Jobs
 #endif /* SRC_JOBS_WIDGET_INSTALL_TASK_INSTALL_OSPSVC_H_ */
index b34b13c..135b252 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 //SYSTEM INCLUDES
+#include <unistd.h>
 #include <string>
 #include <dpl/assert.h>
 #include <dirent.h>
@@ -63,7 +64,7 @@ LanguageTagMap getLanguageTagMap()
 {
     LanguageTagMap map;
 
-#define ADD(tag, l_tag) map.insert(std::make_pair(L ## # tag, L ## # l_tag));
+#define ADD(tag, l_tag) map.insert(std::make_pair(L###tag, L###l_tag));
 #include "languages.def"
 #undef ADD
 
@@ -97,12 +98,12 @@ DPL::OptionalString getLangTag(const DPL::String& tag)
 
 namespace Jobs {
 namespace WidgetInstall {
-
 const char * TaskManifestFile::encoding = "UTF-8";
 
 TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
     DPL::TaskDecl<TaskManifestFile>(this),
-    m_context(inCont)
+    m_context(inCont),
+    writer(NULL)
 {
     if (false == m_context.existingWidgetInfo.isExist) {
         AddStep(&TaskManifestFile::stepCopyIconFiles);
@@ -113,7 +114,7 @@ TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
 
         AddAbortStep(&TaskManifestFile::stepAbortParseManifest);
     } else {
-    // for widget update.
+        // for widget update.
         AddStep(&TaskManifestFile::stepBackupIconFiles);
         AddStep(&TaskManifestFile::stepCopyIconFiles);
         AddStep(&TaskManifestFile::stepGenerateManifest);
@@ -125,8 +126,7 @@ TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
 }
 
 TaskManifestFile::~TaskManifestFile()
-{
-}
+{}
 
 void TaskManifestFile::stepCreateExecFile()
 {
@@ -134,11 +134,20 @@ void TaskManifestFile::stepCreateExecFile()
     std::string clientExeStr = GlobalConfig::GetWrtClientExec();
 
     LogInfo("link -s " << clientExeStr << " " << exec);
-    symlink(clientExeStr.c_str(), exec.c_str());
 
+    errno = 0;
+    if (symlink(clientExeStr.c_str(), exec.c_str()) !=  0)
+    {
+        int error = errno;
+        if(error)
+            LogPedantic("Failed to make a symbolic name for a file "
+                    << "[" <<  DPL::GetErrnoString(error) << "]");
+        ThrowMsg(Exceptions::InstallationFailed,
+                "Symbolic link creating is not done.");
+    }
     m_context.job->UpdateProgress(
-        InstallerContext::INSTALL_CREATE_EXECFILE,
-        "Widget execfile creation Finished");
+            InstallerContext::INSTALL_CREATE_EXECFILE,
+            "Widget execfile creation Finished");
 }
 
 void TaskManifestFile::stepCopyIconFiles()
@@ -149,27 +158,32 @@ void TaskManifestFile::stepCopyIconFiles()
     //which there is at least one icon in widget for, icon file is copied.
     //Coping prioritize last positions when coping. If there is several icons
     //with given locale, the one, that will be copied, will be icon
-    //which is declared by <icon> tag later than the others in config.xml of widget
+    //which is declared by <icon> tag later than the others in config.xml of
+    // widget
 
     std::vector<Locale> generatedLocales;
 
-    WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = m_context.widgetConfig.localizationData.icons;
+    WrtDB::WidgetRegisterInfo::LocalizedIconList & icons =
+        m_context.widgetConfig.localizationData.icons;
 
-    //reversed: last <icon> has highest priority to be copied if it has given locale (TODO: why was that working that way?)
-    for(WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator icon = icons.rbegin(); icon != icons.rend(); icon++)
+    //reversed: last <icon> has highest priority to be copied if it has given
+    // locale (TODO: why was that working that way?)
+    for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
+         icon = icons.rbegin();
+         icon != icons.rend();
+         ++icon)
     {
         FOREACH(locale, icon->availableLocales)
         {
             DPL::String src = icon->src;
             LogDebug("Icon for locale: " << *locale << "is : " << src);
 
-            if(std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end())
+            if (std::find(generatedLocales.begin(), generatedLocales.end(),
+                          *locale) != generatedLocales.end())
             {
                 LogDebug("Skipping - has that locale");
                 continue;
-            }
-            else
-            {
+            } else {
                 generatedLocales.push_back(*locale);
             }
 
@@ -187,10 +201,11 @@ void TaskManifestFile::stepCopyIconFiles()
             targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
             targetFile << getIconTargetFilename(*locale);
 
-
             if (m_context.widgetConfig.packagingType ==
-                    WrtDB::PKG_TYPE_HOSTED_WEB_APP) {
-                m_context.locations->setIconTargetFilenameForLocale(targetFile.str());
+                WrtDB::PKG_TYPE_HOSTED_WEB_APP)
+            {
+                m_context.locations->setIconTargetFilenameForLocale(
+                    targetFile.str());
             }
 
             LogDebug("Copying icon: " << sourceFile.str() <<
@@ -208,27 +223,30 @@ void TaskManifestFile::stepCopyIconFiles()
             Catch(DPL::FileInput::Exception::Base)
             {
                 // Error while opening or closing source file
-                //ReThrowMsg(InstallerException::CopyIconFailed, sourceFile.str());
+                //ReThrowMsg(InstallerException::CopyIconFailed,
+                // sourceFile.str());
                 LogError(
-                    "Copying widget's icon failed. Widget's icon will not be"\
+                    "Copying widget's icon failed. Widget's icon will not be" \
                     "available from Main Screen");
             }
 
             Catch(DPL::FileOutput::Exception::Base)
             {
                 // Error while opening or closing target file
-                //ReThrowMsg(InstallerException::CopyIconFailed, targetFile.str());
+                //ReThrowMsg(InstallerException::CopyIconFailed,
+                // targetFile.str());
                 LogError(
-                    "Copying widget's icon failed. Widget's icon will not be"\
+                    "Copying widget's icon failed. Widget's icon will not be" \
                     "available from Main Screen");
             }
 
             Catch(DPL::CopyFailed)
             {
                 // Error while copying
-                //ReThrowMsg(InstallerException::CopyIconFailed, targetFile.str());
+                //ReThrowMsg(InstallerException::CopyIconFailed,
+                // targetFile.str());
                 LogError(
-                    "Copying widget's icon failed. Widget's icon will not be"\
+                    "Copying widget's icon failed. Widget's icon will not be" \
                     "available from Main Screen");
             }
         }
@@ -286,18 +304,18 @@ void TaskManifestFile::stepAbortIconFiles()
         Catch(DPL::FileInput::Exception::Base)
         {
             LogError("Restoration icon File Failed." << backup_file.str()
-                    << " to " << res_file.str());
+                                                     << " to " << res_file.str());
         }
 
         Catch(DPL::FileOutput::Exception::Base)
         {
             LogError("Restoration icon File Failed." << backup_file.str()
-                    << " to " << res_file.str());
+                                                     << " to " << res_file.str());
         }
         Catch(DPL::CopyFailed)
         {
             LogError("Restoration icon File Failed." << backup_file.str()
-                    << " to " << res_file.str());
+                                                     << " to " << res_file.str());
         }
     }
 }
@@ -309,20 +327,23 @@ void TaskManifestFile::stepUpdateFinalize()
 }
 
 DPL::String TaskManifestFile::getIconTargetFilename(
-        const DPL::String& languageTag) const
+    const DPL::String& languageTag) const
 {
     DPL::OStringStream filename;
-    WidgetPkgName pkgname = m_context.widgetConfig.pkgName;
+    TizenAppId appid = m_context.widgetConfig.tzAppid;
 
-    filename << DPL::ToUTF8String(pkgname).c_str();
+    filename << DPL::ToUTF8String(appid).c_str();
 
     if (!languageTag.empty()) {
-        DPL::OptionalString tag = getLangTag(languageTag); // translate en -> en_US etc
-        if (tag.IsNull()) { tag = languageTag; }
+        DPL::OptionalString tag = getLangTag(languageTag); // translate en ->
+                                                           // en_US etc
+        if (tag.IsNull()) {
+            tag = languageTag;
+        }
         DPL::String locale =
             LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
 
-       if(locale.empty()) {
+        if (locale.empty()) {
             filename << L"." << languageTag;
         } else {
             filename << L"." << locale;
@@ -339,13 +360,12 @@ void TaskManifestFile::stepFinalize()
     LogInfo("Finished ManifestFile step");
 }
 
-
 void TaskManifestFile::saveLocalizedKey(std::ofstream &file,
-        const DPL::String& key,
-        const DPL::String& languageTag)
+                                        const DPL::String& key,
+                                        const DPL::String& languageTag)
 {
     DPL::String locale =
-            LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag);
+        LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag);
 
     file << key;
     if (!locale.empty()) {
@@ -357,26 +377,26 @@ void TaskManifestFile::saveLocalizedKey(std::ofstream &file,
 void TaskManifestFile::updateAilInfo()
 {
     // Update ail for desktop
-    std::string cfgPkgname =
-        DPL::ToUTF8String(m_context.widgetConfig.pkgName);
-    const char* pkgname = cfgPkgname.c_str();
+    std::string cfgAppid =
+        DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
+    const char* appid = cfgAppid.c_str();
 
-    LogDebug("Update ail desktop : " << pkgname );
+    LogDebug("Update ail desktop : " << appid);
     ail_appinfo_h ai = NULL;
     ail_error_e ret;
 
-    ret = ail_package_get_appinfo(pkgname, &ai);
+    ret = ail_get_appinfo(appid, &ai);
     if (ai) {
-        ail_package_destroy_appinfo(ai);
+        ail_destroy_appinfo(ai);
     }
 
     if (AIL_ERROR_NO_DATA == ret) {
-        if (ail_desktop_add(pkgname) < 0) {
-            LogWarning("Failed to add ail desktop : " << pkgname);
+        if (ail_desktop_add(appid) < 0) {
+            LogWarning("Failed to add ail desktop : " << appid);
         }
     } else if (AIL_ERROR_OK == ret) {
-        if (ail_desktop_update(pkgname) < 0) {
-            LogWarning("Failed to update ail desktop : " << pkgname);
+        if (ail_desktop_update(appid) < 0) {
+            LogWarning("Failed to update ail desktop : " << appid);
         }
     }
 }
@@ -393,12 +413,13 @@ void TaskManifestFile::backupIconFiles()
 
     std::list<std::string> fileList;
     getFileList(GlobalConfig::GetUserWidgetDesktopIconPath(), fileList);
-    std::string pkgname = DPL::ToUTF8String(m_context.widgetConfig.pkgName);
+    std::string appid = DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
 
     FOREACH(it, fileList)
     {
-        if (0 == (strncmp((*it).c_str(), pkgname.c_str(),
-                        strlen(pkgname.c_str())))) {
+        if (0 == (strncmp((*it).c_str(), appid.c_str(),
+                          strlen(appid.c_str()))))
+        {
             std::ostringstream icon_file, backup_icon;
             icon_file << GlobalConfig::GetUserWidgetDesktopIconPath();
             icon_file << "/" << (*it);
@@ -406,7 +427,7 @@ void TaskManifestFile::backupIconFiles()
             backup_icon << b_icon_dir.str() << "/" << (*it);
 
             LogDebug("Backup icon file " << icon_file.str() << " to " <<
-                    backup_icon.str());
+                     backup_icon.str());
             Try
             {
                 DPL::FileInput input(icon_file.str());
@@ -435,7 +456,7 @@ void TaskManifestFile::backupIconFiles()
 }
 
 void TaskManifestFile::getFileList(const char* path,
-        std::list<std::string> &list)
+                                   std::list<std::string> &list)
 {
     DIR* dir = opendir(path);
     if (!dir) {
@@ -443,27 +464,37 @@ void TaskManifestFile::getFileList(const char* path,
         ThrowMsg(Exceptions::InternalError, path);
     }
 
-    struct dirent* d_ent;
-    do {
-        if ((d_ent = readdir(dir))) {
-            if(strcmp(d_ent->d_name, ".") == 0 ||
-                    strcmp(d_ent->d_name, "..") == 0) {
-                continue;
-            }
-            std::string file_name = d_ent->d_name;
-            list.push_back(file_name);
+    struct dirent entry;
+    struct dirent *result;
+    int return_code;
+    errno = 0;
+    for (return_code = readdir_r(dir, &entry, &result);
+            result != NULL && return_code == 0;
+            return_code = readdir_r(dir, &entry, &result))
+    {
+        if (strcmp(entry.d_name, ".") == 0 ||
+            strcmp(entry.d_name, "..") == 0)
+        {
+            continue;
         }
-    }while(d_ent);
+        std::string file_name = entry.d_name;
+        list.push_back(file_name);
+    }
+
+    if (return_code != 0 || errno != 0) {
+        LogError("readdir_r() failed with " << DPL::GetErrnoString());
+    }
+
     if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
         LogError("Failed to close dir: " << path << " with error: "
-                << DPL::GetErrnoString());
+                                         << DPL::GetErrnoString());
     }
 }
 
 void TaskManifestFile::stepGenerateManifest()
 {
-    WidgetPkgName pkgname = m_context.widgetConfig.pkgName;
-    manifest_name = pkgname + L".xml";
+    TizenPkgId pkgid = m_context.widgetConfig.tzPkgid;
+    manifest_name = pkgid + L".xml";
     manifest_file += L"/tmp/" + manifest_name;
 
     //libxml - init and check
@@ -481,13 +512,13 @@ void TaskManifestFile::stepParseManifest()
     int code = pkgmgr_parser_parse_manifest_for_installation(
             DPL::ToUTF8String(manifest_file).c_str(), NULL);
 
-    if(code != 0)
-    {
+    if (code != 0) {
         LogError("Manifest parser error: " << code);
         ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
     }
 
-    // TODO : It will be removed. AIL update is temporary code request by pkgmgr team.
+    // TODO : It will be removed. AIL update is temporary code request by pkgmgr
+    // team.
     updateAilInfo();
 
     m_context.job->UpdateProgress(
@@ -501,13 +532,13 @@ void TaskManifestFile::stepParseUpgradedManifest()
     int code = pkgmgr_parser_parse_manifest_for_upgrade(
             DPL::ToUTF8String(manifest_file).c_str(), NULL);
 
-    if(code != 0)
-    {
+    if (code != 0) {
         LogError("Manifest parser error: " << code);
         ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
     }
 
-    // TODO : It will be removed. AIL update is temporary code request by pkgmgr team.
+    // TODO : It will be removed. AIL update is temporary code request by pkgmgr
+    // team.
     updateAilInfo();
 
     m_context.job->UpdateProgress(
@@ -565,43 +596,45 @@ void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp)
 {
     bool defaultNameSaved = false;
 
-    DPL::OptionalString defaultLocale = m_context.widgetConfig.configInfo.defaultlocale;
-    std::pair<DPL::String, WrtDB::ConfigParserData::LocalizedData> defaultLocalizedData;
+    DPL::OptionalString defaultLocale =
+        m_context.widgetConfig.configInfo.defaultlocale;
+    std::pair<DPL::String,
+              WrtDB::ConfigParserData::LocalizedData> defaultLocalizedData;
     //labels
     FOREACH(localizedData, m_context.widgetConfig.configInfo.localizedDataSet)
     {
         Locale i = localizedData->first;
         DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
-        if (tag.IsNull())
-        {
+        if (tag.IsNull()) {
             tag = i;
         }
         DPL::OptionalString name = localizedData->second.name;
         generateWidgetName(manifest, uiApp, tag, name, defaultNameSaved);
 
         //store default locale localized data
-        if(!!defaultLocale && defaultLocale == i)
-        {
+        if (!!defaultLocale && defaultLocale == i) {
             defaultLocalizedData = *localizedData;
         }
     }
 
-    if (!!defaultLocale && !defaultNameSaved)
-    {
+    if (!!defaultLocale && !defaultNameSaved) {
         DPL::OptionalString name = defaultLocalizedData.second.name;
-        generateWidgetName(manifest, uiApp, DPL::OptionalString::Null, name, defaultNameSaved);
+        generateWidgetName(manifest,
+                           uiApp,
+                           DPL::OptionalString::Null,
+                           name,
+                           defaultNameSaved);
     }
     //appid
-    WidgetPkgName pkgname = m_context.widgetConfig.pkgName;
-    uiApp.setAppid(pkgname);
-
+    TizenAppId appid = m_context.widgetConfig.tzAppid;
+    uiApp.setAppid(appid);
 
     //extraid
-    if(!!m_context.widgetConfig.guid) {
+    if (!!m_context.widgetConfig.guid) {
         uiApp.setExtraid(*m_context.widgetConfig.guid);
     } else {
-        if(!pkgname.empty()) {
-            uiApp.setExtraid(DPL::String(L"http://") + pkgname);
+        if (!appid.empty()) {
+            uiApp.setExtraid(DPL::String(L"http://") + appid);
         }
     }
 
@@ -610,25 +643,24 @@ void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp)
     manifest.setType(L"wgt");
 }
 
-void TaskManifestFile::generateWidgetName(Manifest & manifest, UiApplication &uiApp, const DPL::OptionalString& tag, DPL::OptionalString name, bool & defaultNameSaved)
+void TaskManifestFile::generateWidgetName(Manifest & manifest,
+                                          UiApplication &uiApp,
+                                          const DPL::OptionalString& tag,
+                                          DPL::OptionalString name,
+                                          bool & defaultNameSaved)
 {
     if (!!name) {
-        if (!!tag)
-        {
+        if (!!tag) {
             DPL::String locale =
-                    LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
+                LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
 
             if (!locale.empty()) {
-                uiApp.addLabel(LabelType(*name,*tag));
-            }
-            else
-            {
+                uiApp.addLabel(LabelType(*name, *tag));
+            } else {
                 uiApp.addLabel(LabelType(*name));
                 manifest.addLabel(LabelType(*name));
             }
-        }
-        else
-        {
+        } else {
             defaultNameSaved = true;
             uiApp.addLabel(LabelType(*name));
             manifest.addLabel(LabelType(*name));
@@ -642,108 +674,115 @@ void TaskManifestFile::setWidgetIcons(UiApplication & uiApp)
     //changes.
     bool defaultIconSaved = false;
 
-    DPL::OptionalString defaultLocale = m_context.widgetConfig.configInfo.defaultlocale;
+    DPL::OptionalString defaultLocale =
+        m_context.widgetConfig.configInfo.defaultlocale;
 
     std::vector<Locale> generatedLocales;
-    WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = m_context.widgetConfig.localizationData.icons;
-
-    //reversed: last <icon> has highest priority to be writen to manifest if it has given locale (TODO: why was that working that way?)
-    for(WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator icon = icons.rbegin(); icon != icons.rend(); icon++)
+    WrtDB::WidgetRegisterInfo::LocalizedIconList & icons =
+        m_context.widgetConfig.localizationData.icons;
+
+    //reversed: last <icon> has highest priority to be writen to manifest if it
+    // has given locale (TODO: why was that working that way?)
+    for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
+         icon = icons.rbegin();
+         icon != icons.rend();
+         ++icon)
     {
         FOREACH(locale, icon->availableLocales)
         {
-            if(std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end())
+            if (std::find(generatedLocales.begin(), generatedLocales.end(),
+                          *locale) != generatedLocales.end())
             {
                 LogDebug("Skipping - has that locale - already in manifest");
                 continue;
-            }
-            else
-            {
+            } else {
                 generatedLocales.push_back(*locale);
             }
 
-            DPL::OptionalString tag = getLangTag(*locale); // translate en -> en_US etc
-            if (tag.IsNull()) { tag = *locale; }
+            DPL::OptionalString tag = getLangTag(*locale); // translate en ->
+                                                           // en_US etc
+            if (tag.IsNull()) {
+                tag = *locale;
+            }
 
             generateWidgetIcon(uiApp, tag, *locale, defaultIconSaved);
         }
     }
-    if (!!defaultLocale && !defaultIconSaved)
-    {
+    if (!!defaultLocale && !defaultIconSaved) {
         generateWidgetIcon(uiApp, DPL::OptionalString::Null,
                            DPL::String(),
                            defaultIconSaved);
     }
 }
 
-void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag,
-        const DPL::String& language, bool & defaultIconSaved)
+void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp,
+                                          const DPL::OptionalString& tag,
+                                          const DPL::String& language,
+                                          bool & defaultIconSaved)
 {
     DPL::String locale;
-    if (!!tag)
-    {
+    if (!!tag) {
         locale = LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
-    }
-    else
-    {
+    } else {
         defaultIconSaved = true;
     }
 
     DPL::String iconText;
     iconText += getIconTargetFilename(language);
 
-    if(!locale.empty())
-    {
+    if (!locale.empty()) {
         uiApp.addIcon(IconType(iconText, locale));
-    }
-    else
-    {
+    } else {
         uiApp.addIcon(IconType(iconText));
     }
+    std::ostringstream iconPath;
+    iconPath << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
+    iconPath << getIconTargetFilename(locale);
+     m_context.job->SendProgressIconPath(iconPath.str());
 }
 
 void TaskManifestFile::setWidgetManifest(Manifest & manifest)
 {
-    manifest.setPackage(m_context.widgetConfig.pkgName);
+    manifest.setPackage(m_context.widgetConfig.tzPkgid);
 
-    if(!!m_context.widgetConfig.version)
-    {
+    if (!!m_context.widgetConfig.version) {
         manifest.setVersion(*m_context.widgetConfig.version);
     }
     DPL::String email = (!!m_context.widgetConfig.configInfo.authorEmail ?
-                            *m_context.widgetConfig.configInfo.authorEmail : L"");
+                         *m_context.widgetConfig.configInfo.authorEmail : L"");
     DPL::String href = (!!m_context.widgetConfig.configInfo.authorHref ?
-                            *m_context.widgetConfig.configInfo.authorHref : L"");
+                        *m_context.widgetConfig.configInfo.authorHref : L"");
     DPL::String name = (!!m_context.widgetConfig.configInfo.authorName ?
-                            *m_context.widgetConfig.configInfo.authorName : L"");
-    manifest.addAuthor(Author(email,href,L"",name));
+                        *m_context.widgetConfig.configInfo.authorName : L"");
+    manifest.addAuthor(Author(email, href, L"", name));
 }
 
 void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp)
 {
     FOREACH(it, m_context.widgetConfig.configInfo.settingsList)
     {
-         if(!strcmp(DPL::ToUTF8String(it->m_name).c_str(), ST_NODISPLAY)) {
-             if(!strcmp(DPL::ToUTF8String(it->m_value).c_str(), ST_TRUE)) {
+        if (!strcmp(DPL::ToUTF8String(it->m_name).c_str(), ST_NODISPLAY)) {
+            if (!strcmp(DPL::ToUTF8String(it->m_value).c_str(), ST_TRUE)) {
                 uiApp.setNodisplay(true);
                 uiApp.setTaskmanage(false);
-             }
-             else {
+            } else {
                 uiApp.setNodisplay(false);
                 uiApp.setTaskmanage(true);
             }
-         }
-     }
+        }
+    }
     //TODO
     //There is no "X-TIZEN-PackageType=wgt"
-    //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" << DPL::ToUTF8String(*widgetID).c_str()
+    //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" <<
+    // DPL::ToUTF8String(*widgetID).c_str()
     //There is no Comment in pkgmgr "Comment=Widget application"
     //that were in desktop file
 }
 
 void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp)
 {
-    WrtDB::ConfigParserData::ServiceInfoList appServiceList = m_context.widgetConfig.configInfo.appServiceList;
+    WrtDB::ConfigParserData::ServiceInfoList appServiceList =
+        m_context.widgetConfig.configInfo.appServiceList;
 
     if (appServiceList.empty()) {
         LogInfo("Widget doesn't contain application service");
@@ -819,14 +858,12 @@ void TaskManifestFile::stepAbortParseManifest()
     int code = pkgmgr_parser_parse_manifest_for_uninstallation(
             DPL::ToUTF8String(manifest_file).c_str(), NULL);
 
-    if (0 != code)
-    {
+    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)
-    {
+    if (0 != ret) {
         LogWarning("No manifest file found: " << manifest_file);
     }
 }
@@ -837,83 +874,96 @@ void TaskManifestFile::setLiveBoxInfo(Manifest& manifest)
         LogInfo("setLiveBoxInfo");
         LiveBoxInfo liveBox;
         DPL::Optional<WrtDB::ConfigParserData::LiveboxInfo> ConfigInfo = *it;
-        DPL::String pkgname = m_context.widgetConfig.pkgName;
-        size_t found;
+        DPL::String appid = m_context.widgetConfig.tzAppid;
 
-        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))
+        if (ConfigInfo->m_liveboxId != L"") {
+            size_t found = ConfigInfo->m_liveboxId.find_last_of(L".");
+            if (found != std::string::npos) {
+                if (0 == ConfigInfo->m_liveboxId.compare(0, found, appid)) {
                     liveBox.setLiveboxId(ConfigInfo->m_liveboxId);
-                else {
+                else {
                     DPL::String liveboxId =
-                        pkgname+DPL::String(L".")+ConfigInfo->m_liveboxId;
+                        appid + DPL::String(L".") + ConfigInfo->m_liveboxId;
                     liveBox.setLiveboxId(liveboxId);
                 }
             } else {
                 DPL::String liveboxId =
-                    pkgname+DPL::String(L".")+ConfigInfo->m_liveboxId;
+                    appid + DPL::String(L".") + ConfigInfo->m_liveboxId;
                 liveBox.setLiveboxId(liveboxId);
             }
         }
 
-        if(ConfigInfo->m_primary != L"")
+        if (ConfigInfo->m_primary != L"") {
             liveBox.setPrimary(ConfigInfo->m_primary);
+        }
 
-        if(ConfigInfo->m_autoLaunch == L"true")
-            liveBox.setAutoLaunch(pkgname);
+        if (ConfigInfo->m_autoLaunch == L"true") {
+            liveBox.setAutoLaunch(appid);
+        }
 
-        if(ConfigInfo->m_updatePeriod != L"")
+        if (ConfigInfo->m_updatePeriod != L"") {
             liveBox.setUpdatePeriod(ConfigInfo->m_updatePeriod);
+        }
 
-        if(ConfigInfo->m_label != L"")
+        if (ConfigInfo->m_label != L"") {
             liveBox.setLabel(ConfigInfo->m_label);
+        }
 
         DPL::String defaultLocale
-            = DPL::FromUTF8String(m_context.locations->getPackageInstallationDir())
-            + DPL::String(L"/res/wgt/");
+            = 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_icon != L"") {
+            liveBox.setIcon(defaultLocale + ConfigInfo->m_icon);
         }
 
-        if (ConfigInfo->m_boxInfo.m_boxSrc.empty() || ConfigInfo->m_boxInfo.m_boxSize.empty()) {
+        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")))
+                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
+                } else {
                     box.boxSrc = defaultLocale + ConfigInfo->m_boxInfo.m_boxSrc;
+                }
             }
 
-            std::list<std::pair<DPL::String,DPL::String>> BoxSizeList
+            if (ConfigInfo->m_boxInfo.m_boxMouseEvent == L"true") {
+                box.boxMouseEvent = ConfigInfo->m_boxInfo.m_boxMouseEvent;
+            } else {
+                box.boxMouseEvent = L"false";
+            }
+
+            std::list<std::pair<DPL::String, DPL::String> > BoxSizeList
                 = ConfigInfo->m_boxInfo.m_boxSize;
             FOREACH(im, BoxSizeList) {
                 std::pair<DPL::String, DPL::String> boxSize = *im;
-                if(!boxSize.second.empty())
+                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()) {
+                && !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
old mode 100755 (executable)
new mode 100644 (file)
index ec9e12b..de18c42
@@ -38,7 +38,6 @@
 
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 
-
 class InstallerContext;
 
 namespace Jobs {
@@ -77,7 +76,8 @@ class TaskManifestFile :
     void stepAbortIconFiles();
 
     //private data
-    std::list<std::string> icon_list; //TODO: this should be registered as external files
+    std::list<std::string> icon_list; //TODO: this should be registered as
+                                      // external files
     std::ostringstream backup_dir;
     xmlTextWriterPtr writer;
     DPL::String manifest_name;
@@ -100,8 +100,15 @@ class TaskManifestFile :
     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);
+    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);
 
     //for widget update
     void backupIconFiles();
@@ -109,11 +116,10 @@ class TaskManifestFile :
     DPL::String getIconTargetFilename(const DPL::String& languageTag) const;
 
     static void saveLocalizedKey(std::ofstream &file,
-            const DPL::String& key,
-            const DPL::String& languageTag);
+                                 const DPL::String& key,
+                                 const DPL::String& languageTag);
 
     static const char * encoding;
-
 };
 } //namespace WidgetInstall
 } //namespace Jobs
index 528f12e..bf295ea 100644 (file)
  * @brief   Copying plugins delivered in widget package.
  */
 
+#include <unistd.h>
 #include "task_plugins_copy.h"
 #include <dpl/log/log.h>
 #include <dpl/string.h>
 #include <dpl/utils/wrt_utility.h>
 #include <dpl/errno_string.h>
+#include <widget_install/job_widget_install.h>
 #include <widget_install_context.h>
 #include <widget_install/widget_install_errors.h>
 #include <dpl/exception.h>
@@ -45,14 +47,13 @@ const std::string plugins_dir = "i586";
 #endif
 
 namespace {
-    const std::string PackagePluginsDir = "/plugins/";
-    const std::string InstallationPluginsDir = "/data/.netscape/plugins/";
-    const mode_t InstallationPluginsDirMode = 0755;
+const std::string PackagePluginsDir = "/plugins/";
+const std::string InstallationPluginsDir = "/data/.netscape/plugins/";
+const mode_t InstallationPluginsDirMode = 0755;
 }
 
 namespace Jobs {
 namespace WidgetInstall {
-
 TaskPluginsCopy::TaskPluginsCopy(InstallerContext& context) :
     DPL::TaskDecl<TaskPluginsCopy>(this),
     m_context(context)
@@ -63,9 +64,9 @@ TaskPluginsCopy::TaskPluginsCopy(InstallerContext& context) :
     AddStep(&TaskPluginsCopy::StepCopyingFinished);
     LogDebug("Widget plugins copy task ended");
     m_npsource = m_context.locations->getSourceDir() + PackagePluginsDir
-            + plugins_dir;
+        + plugins_dir;
     m_npdestination = m_context.locations->getPackageInstallationDir()
-            + InstallationPluginsDir;
+        + InstallationPluginsDir;
 }
 
 void TaskPluginsCopy::StepFindPlugins()
@@ -73,74 +74,92 @@ void TaskPluginsCopy::StepFindPlugins()
     LogDebug("Starting plugins finding step");
     /* Check whether plugins directory for actual architecture exists
      * (plugins for other architectures are omitted even they exists). */
-    if(!WrtUtilDirExists(m_npsource)) {
-        LogDebug("Plugins directory (" <<m_npsource
-                <<") does not exists - skipping copy step");
+    if (!WrtUtilDirExists(m_npsource)) {
+        LogDebug(
+            "Plugins directory (" << m_npsource
+                                  <<
+            ") does not exists - skipping copy step");
         SwitchToStep(&TaskPluginsCopy::StepCopyingFinished);
         return;
     }
 
     /* Find all .so files and store their names in list */
     DIR *dir;
-    struct dirent *entry;
     struct stat st;
     LogDebug("Opening plugins directory");
     dir = opendir(m_npsource.c_str());
-    if(dir == NULL) {
+    if (dir == NULL) {
         LogError("Unable to open plugins directory");
         ThrowMsg(Exceptions::InternalError, "Unable to read plugins directory");
     }
     std::string tempname;
+    struct dirent entry;
+    struct dirent *result;
+    int return_code;
+    errno = 0;
     const std::string ext(".so");
     /* Listing directory and checking entries found inside */
-    while ((entry = readdir(dir)) != NULL){
-        tempname = m_npsource + "/" + entry->d_name;
-        if(lstat(tempname.c_str(), &st) != 0) {
-            LogWarning("Failed to call \"lstat\" (errno:" <<errno
-                    <<") on entry - skipping");
+    for (return_code = readdir_r(dir, &entry, &result);
+                result != NULL && return_code == 0;
+                return_code = readdir_r(dir, &entry, &result))
+    {
+        tempname = m_npsource + "/" + entry.d_name;
+        if (lstat(tempname.c_str(), &st) != 0) {
+            LogWarning(
+                "Failed to call \"lstat\" (errno:" << errno
+                                                   <<
+                ") on entry - skipping");
             continue;
         }
         /* Directories other than "." and ".." should not be found*/
-        if(S_ISDIR(st.st_mode)){
-            if(strncmp(entry->d_name, "..", 2)!=0
-                        && strncmp(entry->d_name, ".", 1)!=0) {
+        if (S_ISDIR(st.st_mode)) {
+            if (strncmp(entry.d_name, "..", 2) != 0
+                && strncmp(entry.d_name, ".", 1) != 0)
+            {
                 LogError("Directory detected instead of plugin file: "
-                        << entry->d_name);
+                         << entry.d_name);
                 /* Subdirectories inside plugins/ARCH are not supported */
                 if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
-                    LogError("Failed to close dir: " << m_npsource
-                            << " with error: " << DPL::GetErrnoString());
+                    LogError(
+                        "Failed to close dir: " << m_npsource
+                                                << " with error: " <<
+                        DPL::GetErrnoString());
                 }
-                ThrowMsg(Exceptions::PluginsSubdirectory,
-                        "Subdirectories inside plugins directory are not supported");
-            }
-            else {
+                ThrowMsg(
+                    Exceptions::PluginsSubdirectory,
+                    "Subdirectories inside plugins directory are not supported");
+            else {
                 continue;
             }
         }
 
-        tempname = std::string(entry->d_name);
+        tempname = std::string(entry.d_name);
         /* Check whether file extension is ".so" */
-        if(tempname.compare(tempname.size()-ext.size(), ext.size(), ext) == 0) {
+        if (tempname.compare(tempname.size() - ext.size(), ext.size(),
+                             ext) == 0)
+        {
             /* Plugin file found */
-            LogDebug("Plugin file found: " <<tempname);
+            LogDebug("Plugin file found: " << tempname);
             m_nplugins.push_back(tempname);
-        }
-        else {
+        } else {
             /* Non-.so file found in plugins directory- skipping */
-            LogWarning("Non-plugin file found: " <<tempname);
+            LogWarning("Non-plugin file found: " << tempname);
         }
     }
+    if (return_code != 0 || errno != 0) {
+        LogError("readdir_r() failed with " << DPL::GetErrnoString());
+    }
+    errno = 0;
     if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
         LogError("Failed to close dir: " << m_npsource << " with error: "
-                << DPL::GetErrnoString());
+                                         << DPL::GetErrnoString());
     }
     /* If no .so files found (list is empty) abort taks*/
-    if(m_nplugins.empty()) {
+    if (m_nplugins.empty()) {
         LogError("No valid plugin files found");
         ThrowMsg(Exceptions::EmptyPluginsDirectory, "No valid plugin found");
     }
-    LogDebug("Number of detected plugins: " <<m_nplugins.size());
+    LogDebug("Number of detected plugins: " << m_nplugins.size());
     LogDebug("Plugins finding step ended");
 }
 
@@ -152,22 +171,24 @@ void TaskPluginsCopy::StepCopyPlugins()
 
     /* Create new directory for plugins (data/.netscape/plugins/) */
     LogDebug("Creating destination plugin directory");
-    if(!WrtUtilMakeDir(m_npdestination, InstallationPluginsDirMode)){
+    if (!WrtUtilMakeDir(m_npdestination, InstallationPluginsDirMode)) {
         LogError("Failed to create directory for plugins");
-        ThrowMsg(Exceptions::InternalError, "Failed to create directory for plugins");
+        ThrowMsg(Exceptions::InternalError,
+                 "Failed to create directory for plugins");
     }
 
-    LogDebug("Copying plugins to: " <<m_npdestination);
+    LogDebug("Copying plugins to: " << m_npdestination);
     /* Copy plugins from widget package into
      * .netscape/plugins in widget's target directory */
-    for(std::list<std::string>::const_iterator it = m_nplugins.begin();
-            it != m_nplugins.end(); it++) {
+    for (std::list<std::string>::const_iterator it = m_nplugins.begin();
+         it != m_nplugins.end(); ++it)
+    {
         LogDebug("Copying plugin file: " << (*it));
         source = m_npsource + "/" + (*it);
         destination = m_npdestination + (*it);
-        if(rename(source.c_str(), destination.c_str()) != 0) {
-            LogError("Failed to move " <<source <<" to " <<destination);
-            LogError("(errno: " <<errno <<")");
+        if (rename(source.c_str(), destination.c_str()) != 0) {
+            LogError("Failed to move " << source << " to " << destination);
+            LogError("(errno: " << errno << ")");
             ThrowMsg(Exceptions::InternalError, "Failed to copy plugin file");
         }
     }
@@ -179,17 +200,21 @@ void TaskPluginsCopy::StepCopyPlugins()
     LogDebug("Removing unnecessary directory: " << source);
     /* Remove source directory with plugins (possibly for multiple
      * architectures). */
-    if(!WrtUtilRemove(source)){
+    if (!WrtUtilRemove(source)) {
         LogError("Failed to plugins source remove directory");
-        ThrowMsg(Exceptions::InternalError, "Failed to plugins source remove directory");
+        ThrowMsg(Exceptions::InternalError,
+                 "Failed to plugins source remove directory");
     }
     LogDebug("Plugins copying step ended");
+
+    m_context.job->UpdateProgress(
+            InstallerContext::INSTALL_PLUGINS_COPY,
+            "Plugins copy");
 }
 
 void TaskPluginsCopy::StepCopyingFinished()
 {
     LogDebug("Plugins copy task finished");
 }
-
 } //namespace WidgetInstall
 } //namespace Jobs
index 3f3a205..2c9efdd 100644 (file)
@@ -34,9 +34,10 @@ namespace Jobs {
 namespace WidgetInstall {
 class TaskPluginsCopy : public DPL::TaskDecl<TaskPluginsCopy>
 {
-public:
+  public:
     TaskPluginsCopy(InstallerContext &context);
-private:
+
+  private:
     /* Widget installer context */
     InstallerContext &m_context;
     /* Path to plugins directory in unpacked widget*/
index 9395094..1838887 100644 (file)
@@ -35,7 +35,6 @@
 
 namespace Jobs {
 namespace WidgetInstall {
-
 TaskPrepareFiles::TaskPrepareFiles(InstallerContext &installerContext) :
     DPL::TaskDecl<TaskPrepareFiles>(this),
     m_installerContext(installerContext)
@@ -46,17 +45,19 @@ TaskPrepareFiles::TaskPrepareFiles(InstallerContext &installerContext) :
 
 void TaskPrepareFiles::CopyFile(const std::string& source)
 {
-    if(source.empty()) {
+    if (source.empty()) {
         LogWarning("No source file specified");
         return;
     }
 
     std::string filename = source;
-    size_t last = source.find_last_of( "\\/" );
-    if(last != std::string::npos) {
-        filename = source.substr( last+1 );
+    size_t last = source.find_last_of("\\/");
+    if (last != std::string::npos) {
+        filename = source.substr(last + 1);
     }
-    std::string target = m_installerContext.locations->getTemporaryPackageDir() + '/' + filename;
+    std::string target =
+        m_installerContext.locations->getTemporaryPackageDir() + '/' +
+        filename;
     LogDebug("source " << source);
     LogDebug("target " << target);
 
@@ -90,10 +91,14 @@ void TaskPrepareFiles::StepCopyFiles()
 {
     CopyFile(m_installerContext.locations->getWidgetSource());
 
-    size_t last = m_installerContext.locations->getWidgetSource().find_last_of("\\/");
+    size_t last = m_installerContext.locations->getWidgetSource().find_last_of(
+            "\\/");
     std::string sourceDir = "";
     if (last != std::string::npos) {
-        sourceDir = m_installerContext.locations->getWidgetSource().substr(0,last+1);
+        sourceDir = m_installerContext.locations->getWidgetSource().substr(
+                0,
+                last
+                + 1);
     }
 
     LogDebug("Icons copy...");
@@ -104,6 +109,5 @@ void TaskPrepareFiles::StepCopyFiles()
         CopyFile(os.str());
     }
 }
-
 } // namespace WidgetInstall
 } // namespace Jobs
index 7db10cf..dd217a5 100644 (file)
@@ -29,10 +29,9 @@ class InstallerContext;
 
 namespace Jobs {
 namespace WidgetInstall {
-
 class TaskPrepareFiles : public DPL::TaskDecl<TaskPrepareFiles>
 {
-private:
+  private:
     // Installation context
     InstallerContext &m_installerContext;
 
@@ -44,7 +43,6 @@ private:
   public:
     explicit TaskPrepareFiles(InstallerContext &installerContext);
 };
-
 } // namespace WidgetInstall
 } // namespace Jobs
 #endif /* SRC_JOBS_WIDGET_INSTALL_TASK_PREPARE_FILES_H_ */
index 7daba5e..c6a5e9b 100644 (file)
@@ -58,16 +58,16 @@ void TaskRecovery::StepCreateCheckFile()
     std::ostringstream infoPath;
     infoPath << GlobalConfig::GetTempInstallInfoPath();
     infoPath << "/";
-    infoPath << m_context.locations->getWidgetSource().substr(pos+1);
+    infoPath << m_context.locations->getWidgetSource().substr(pos + 1);
 
     FILE *temp = fopen(infoPath.str().c_str(), "w+");
     if (temp != NULL) {
         fputs(m_context.locations->getWidgetSource().c_str(), temp);
-        if (-1 == fsync(temp->_fileno)) {
-            fclose(temp);
+        int ret = fsync(temp->_fileno);
+        fclose(temp);
+        if (-1 == ret) {
             ThrowMsg(Exceptions::InternalError, "Fail to fsync for recovery.");
         }
-        fclose(temp);
 
         m_context.installInfo = infoPath.str();
 
index 5a5fd54..120c1aa 100644 (file)
@@ -29,10 +29,9 @@ class InstallerContext;
 
 namespace Jobs {
 namespace WidgetInstall {
-
 class TaskRecovery : public DPL::TaskDecl<TaskRecovery>
 {
-private:
+  private:
     // Installation context
     InstallerContext &m_context;
 
@@ -41,7 +40,6 @@ private:
   public:
     explicit TaskRecovery(InstallerContext &installerContext);
 };
-
 } // namespace WidgetInstall
 } // namespace Jobs
 #endif /* SRC_JOBS_WIDGET_INSTALL_TASK_RECOVERY_FILES_H_ */
index bcf7317..8841739 100644 (file)
@@ -70,6 +70,5 @@ void TaskRemoveBackupFiles::StepRemoveBackupFiles()
         InstallerContext::INSTALL_REMOVE_BACKUP_FILE,
         "Backup widget file delete Finished");
 }
-
 } //namespace WidgetInstall
 } //namespace Jobs
index b12cec7..d269435 100644 (file)
@@ -28,7 +28,7 @@ class InstallerContext;
 
 namespace Jobs {
 namespace WidgetInstall {
-class TaskRemoveBackupFiles:
+class TaskRemoveBackupFiles :
     public DPL::TaskDecl<TaskRemoveBackupFiles>
 {
   private:
index b468d3b..75d0fc8 100644 (file)
@@ -48,17 +48,18 @@ void TaskSmack::Step()
     FOREACH(it, m_context.staticPermittedDevCaps) {
         if (it->second) {
             std::string utf8 = DPL::ToUTF8String(it->first);
-            if (it != m_context.staticPermittedDevCaps.begin())
+            if (it != m_context.staticPermittedDevCaps.begin()) {
                 devcaps << ",";
+            }
             devcaps << utf8;
         }
     }
-    WidgetPkgName pkgName = m_context.widgetConfig.pkgName;
+    TizenAppId tzAppid = m_context.widgetConfig.tzAppid;
     int result = handle_access_control_conf_forWAC(
-                     DPL::ToUTF8String(pkgName).c_str(),
-                     devcaps.str().c_str(),
-                     OPERATION_INSTALL);
-    Assert(result==PC_OPERATION_SUCCESS && "access control setup failed");
+            DPL::ToUTF8String(tzAppid).c_str(),
+            devcaps.str().c_str(),
+            OPERATION_INSTALL);
+    Assert(result == PC_OPERATION_SUCCESS && "access control setup failed");
     m_context.job->UpdateProgress(
         UninstallerContext::INSTALL_SMACK_ENABLE,
         "Widget SMACK Enabled");
index 8d87e04..ce05d29 100644 (file)
@@ -29,7 +29,7 @@ class InstallerContext;
 
 namespace Jobs {
 namespace WidgetInstall {
-class TaskSmack:
+class TaskSmack :
     public DPL::TaskDecl<TaskSmack>,
     public DPL::Event::ICDelegateSupport<TaskSmack>
 {
index fb084f6..0ce18cf 100644 (file)
@@ -40,11 +40,10 @@ struct PathAndFilePair
     std::string file;
 
     PathAndFilePair(const std::string &p,
-            const std::string &f) :
+                    const std::string &f) :
         path(p),
         file(f)
-    {
-    }
+    {}
 };
 
 PathAndFilePair SplitFileAndPath(const std::string &filePath)
@@ -76,7 +75,7 @@ TaskUnzip::TaskUnzip(InstallerContext &installerContext) :
 }
 
 void TaskUnzip::ExtractFile(DPL::ZipInput::File *input,
-        const std::string &destFileName)
+                            const std::string &destFileName)
 {
     Try
     {
@@ -101,12 +100,14 @@ void TaskUnzip::StepUnzipPrepare()
 
     Try
     {
-        m_zip.reset(new DPL::ZipInput(m_installerContext.locations->getWidgetSource()));
+        m_zip.reset(new DPL::ZipInput(m_installerContext.locations->
+                                          getWidgetSource()));
         LogInfo("Widget package comment: " << m_zip->GetGlobalComment());
 
         // Widget package must not be empty
         if (m_zip->empty()) {
-            ThrowMsg(Exceptions::ZipEmpty, m_installerContext.locations->getWidgetSource());
+            ThrowMsg(Exceptions::ZipEmpty,
+                     m_installerContext.locations->getWidgetSource());
         }
 
         // Set iterator to first file
@@ -114,11 +115,13 @@ void TaskUnzip::StepUnzipPrepare()
     }
     Catch(DPL::ZipInput::Exception::OpenFailed)
     {
-        ReThrowMsg(Exceptions::OpenZipFailed, m_installerContext.locations->getWidgetSource());
+        ReThrowMsg(Exceptions::OpenZipFailed,
+                   m_installerContext.locations->getWidgetSource());
     }
     Catch(DPL::ZipInput::Exception::SeekFileFailed)
     {
-        ThrowMsg(Exceptions::ExtractFileFailed,"m_installerContext.locations->getWidgetSource()");
+        ThrowMsg(Exceptions::ExtractFileFailed,
+                 "m_installerContext.locations->getWidgetSource()");
     }
 }
 
@@ -138,7 +141,8 @@ void TaskUnzip::StepUnzipProgress()
 
     if (fileName[fileName.size() - 1] == '/') {
         // This is path
-        std::string newPath = m_installerContext.locations->getTemporaryPackageDir() + "/" +
+        std::string newPath =
+            m_installerContext.locations->getTemporaryPackageDir() + "/" +
             fileName.substr(0, fileName.size() - 1);
         LogPedantic("Path to extract: " << newPath);
 
@@ -147,7 +151,8 @@ void TaskUnzip::StepUnzipProgress()
     } else {
         // This is regular file
         std::string fileExtractPath =
-            m_installerContext.locations->getTemporaryPackageDir() + "/" + fileName;
+            m_installerContext.locations->getTemporaryPackageDir() + "/" +
+            fileName;
 
         LogPedantic("File to extract: " << fileExtractPath);
 
@@ -196,6 +201,5 @@ void TaskUnzip::StepUnzipFinished()
     // Done
     LogInfo("Unzip finished");
 }
-
 } //namespace WidgetInstall
 } //namespace Jobs
index 3962297..69ce606 100644 (file)
@@ -47,7 +47,7 @@ class TaskUnzip :
     WRTEncryptor::ResourceEncryptor *m_resEnc;
 
     void ExtractFile(DPL::ZipInput::File *input,
-            const std::string &destFileName);
+                     const std::string &destFileName);
 
     void EncryptionFile(const std::string &fileName);
 
index 30589a9..76ff014 100644 (file)
@@ -20,6 +20,7 @@
  * @brief   Implementation file for installer task update files
  */
 
+#include <unistd.h>
 #include <utility>
 #include <vector>
 #include <string>
@@ -44,7 +45,6 @@
 using namespace WrtDB;
 
 namespace {
-
 inline const char* GetWidgetBackupDirPath()
 {
     return "backup";
@@ -53,7 +53,6 @@ inline const char* GetWidgetBackupDirPath()
 
 namespace Jobs {
 namespace WidgetInstall {
-
 TaskUpdateFiles::TaskUpdateFiles(InstallerContext& context) :
     DPL::TaskDecl<TaskUpdateFiles>(this),
     m_context(context)
@@ -70,19 +69,22 @@ TaskUpdateFiles::TaskUpdateFiles(InstallerContext& context) :
 void TaskUpdateFiles::StepCreateBackupFolder()
 {
     LogDebug("StepCreateBackupFolder");
-    std::ostringstream backDirPath;
 
     std::string srcBuPath = m_context.locations->getBackupSourceDir();
     LogDebug("backup resource directory path : " << srcBuPath);
-    if(!WrtUtilMakeDir(srcBuPath)) {
-        ThrowMsg(Exceptions::BackupFailed, "Error occurs during create \
+    if (!WrtUtilMakeDir(srcBuPath)) {
+        ThrowMsg(
+            Exceptions::BackupFailed,
+            "Error occurs during create \
                 backup directory.");
     }
 
     std::string binBuPath = m_context.locations->getBackupBinaryDir();
     LogDebug("backup execution directory path : " << binBuPath);
-    if(!WrtUtilMakeDir(binBuPath)) {
-        ThrowMsg(Exceptions::BackupFailed, "Error occurs during create backup \
+    if (!WrtUtilMakeDir(binBuPath)) {
+        ThrowMsg(
+            Exceptions::BackupFailed,
+            "Error occurs during create backup \
                 directory.");
     }
 
@@ -92,41 +94,50 @@ void TaskUpdateFiles::StepCreateBackupFolder()
 }
 
 void TaskUpdateFiles::ReadDirList(std::string dirPath, ExistFileList &list,
-        size_t subLen)
+                                  size_t subLen)
 {
     DIR* pkgDir = opendir(dirPath.c_str());
     if (!pkgDir) {
         LogError("Package directory " << dirPath << " doesn't exist");
-        ThrowMsg(Exceptions::InternalError, "Error occurs during read \
+        ThrowMsg(Exceptions::InternalError,
+                 "Error occurs during read \
                 directory");
     }
 
-    struct dirent* dirent;
     struct stat statInfo;
-    do {
-        if ((dirent = readdir(pkgDir))) {
-            std::string dirName = dirent->d_name;
-            std::string absFileName = dirPath + "/" + dirName;
-            if (stat(absFileName.c_str(), &statInfo) != 0) {
-                ThrowMsg(Exceptions::InternalError, "Error occurs read file");
-            }
+    struct dirent dirent;
+    struct dirent *result;
+    int return_code;
+    errno = 0;
+    for (return_code = readdir_r(pkgDir, &dirent, &result);
+            result != NULL && return_code == 0;
+            return_code = readdir_r(pkgDir, &dirent, &result))
+    {
+        std::string dirName = dirent.d_name;
+        std::string absFileName = dirPath + "/" + dirName;
+        if (stat(absFileName.c_str(), &statInfo) != 0) {
+            ThrowMsg(Exceptions::InternalError, "Error occurs read file");
+        }
 
-            if (S_ISDIR(statInfo.st_mode)) {
-                if(strcmp(dirent->d_name, ".") == 0 || strcmp(dirent->d_name,
-                            "..") == 0) {
-                    continue;
-                }
-                ReadDirList(absFileName, list, subLen);
+        if (S_ISDIR(statInfo.st_mode)) {
+            if (strcmp(dirent.d_name, ".") == 0 || strcmp(dirent.d_name,
+                                                           "..") == 0)
+            {
+                continue;
             }
-
-            list.insert(absFileName.substr(subLen));
+            ReadDirList(absFileName, list, subLen);
         }
+
+        list.insert(absFileName.substr(subLen));
+    }
+    if (return_code != 0 || errno != 0) {
+        LogError("readdir_r() failed with " << DPL::GetErrnoString());
     }
-    while(dirent);
+    errno = 0;
     //closing the directory
     if (-1 == TEMP_FAILURE_RETRY(closedir(pkgDir))) {
         LogError("Failed to close dir: " << dirPath << " with error: "
-                << DPL::GetErrnoString());
+                                         << DPL::GetErrnoString());
     }
 }
 
@@ -138,21 +149,21 @@ void TaskUpdateFiles::StepResourceFilesBackup()
     ExistFileList tempList;
 
     std::string pkgSrc = m_context.locations->getSourceDir();
-    ReadDirList(pkgSrc, resList, strlen(pkgSrc.c_str())+1);
-
+    ReadDirList(pkgSrc, resList, strlen(pkgSrc.c_str()) + 1);
 
     std::string tempSrc = m_context.locations->getTemporaryPackageDir();
-    ReadDirList(tempSrc, tempList, strlen(tempSrc.c_str())+1);
+    ReadDirList(tempSrc, tempList, strlen(tempSrc.c_str()) + 1);
 
     FOREACH(it, tempList) {
         std::set<std::string>::iterator res;
         res = resList.find(*it);
         std::string resFile = pkgSrc + "/" + (*it);
-        std::string newFile = tempSrc + "/" +(*it);
+        std::string newFile = tempSrc + "/" + (*it);
 
         if (res != resList.end()) {
-            std::string backupFile = m_context.locations->getBackupSourceDir() +
-                    "/"+ (*it);
+            std::string backupFile =
+                m_context.locations->getBackupSourceDir() +
+                "/" + (*it);
 
             struct stat sInfo;
             if (stat(resFile.c_str(), &sInfo) != 0) {
@@ -161,20 +172,27 @@ void TaskUpdateFiles::StepResourceFilesBackup()
 
             if (S_ISDIR(sInfo.st_mode)) {
                 LogDebug(resFile << " is a directory. so create a folder : " <<
-                        backupFile);
+                         backupFile);
                 WrtUtilMakeDir(backupFile);
             } else {
                 if ((rename(resFile.c_str(), backupFile.c_str())) != 0) {
-                    LogError("Failed to rename " << resFile << " to " << backupFile);
-                    ThrowMsg(Exceptions::BackupFailed, "Error occurs during \
+                    LogError(
+                        "Failed to rename " << resFile << " to " <<
+                        backupFile);
+                    ThrowMsg(
+                        Exceptions::BackupFailed,
+                        "Error occurs during \
                             rename file");
                 }
 
                 LogDebug("backup : " << resFile << " to " << backupFile);
 
                 if ((rename(newFile.c_str(), resFile.c_str())) != 0) {
-                    LogError("Failed to rename " << newFile << " to " << resFile);
-                    ThrowMsg(Exceptions::BackupFailed, "Error occurs during \
+                    LogError(
+                        "Failed to rename " << newFile << " to " << resFile);
+                    ThrowMsg(
+                        Exceptions::BackupFailed,
+                        "Error occurs during \
                             rename file");
                 }
                 LogDebug("copy : " << newFile << " to " << resFile);
@@ -183,7 +201,9 @@ void TaskUpdateFiles::StepResourceFilesBackup()
         } else {
             if ((rename(newFile.c_str(), resFile.c_str())) != 0) {
                 LogError("Failed to rename " << newFile << " to " << resFile);
-                ThrowMsg(Exceptions::BackupFailed, "Error occurs during \
+                ThrowMsg(
+                    Exceptions::BackupFailed,
+                    "Error occurs during \
                         rename file");
             }
             LogDebug("only copy : " << newFile << " to " << resFile);
@@ -196,7 +216,9 @@ void TaskUpdateFiles::StepResourceFilesBackup()
             std::string backFile = tempSrc + "/" + (*remain);
             if ((rename(pkgFile.c_str(), backFile.c_str())) != 0) {
                 LogError("Failed to backup : " << pkgFile << " to " << backFile);
-                ThrowMsg(Exceptions::BackupFailed, "Error occurs during \
+                ThrowMsg(
+                    Exceptions::BackupFailed,
+                    "Error occurs during \
                         rename file");
             }
             LogDebug("only backup : " << pkgFile << " to " << backFile);
@@ -214,13 +236,14 @@ void TaskUpdateFiles::StepExecFileBackup()
 
     LogDebug(" source : " << execFile);
 
-    std::string tempSource= m_context.locations->getBackupExecFile();
+    std::string tempSource = m_context.locations->getBackupExecFile();
     LogDebug(" source : " << tempSource);
 
     if ((rename(execFile.c_str(), tempSource.c_str())) != 0) {
         LogError("Failed to rename " << execFile << " to " <<
-                tempSource);
-        ThrowMsg(Exceptions::BackupFailed, "Error occurs during \
+                 tempSource);
+        ThrowMsg(Exceptions::BackupFailed,
+                 "Error occurs during \
                 rename file");
     }
     LogDebug("Backup : " << execFile << " to " << tempSource);
@@ -228,8 +251,17 @@ void TaskUpdateFiles::StepExecFileBackup()
     std::string clientPath = GlobalConfig::GetWrtClientExec();
 
     LogInfo("link -s " << clientPath << " " << execFile);
-    symlink(clientPath.c_str(), execFile.c_str());
 
+    errno = 0;
+    if( symlink(clientPath.c_str(), execFile.c_str()) != 0 )
+    {
+        int error = errno;
+        if(error)
+            LogPedantic("Failed to make a symbolic name for a file "
+                    << "[" <<  DPL::GetErrnoString(error) << "]");
+        ThrowMsg(Exceptions::BackupFailed,
+                "Error occurs during rename file");
+    }
     m_context.job->UpdateProgress(
         InstallerContext::INSTALL_BACKUP_EXEC,
         "Backup execution file for update");
@@ -243,7 +275,7 @@ void TaskUpdateFiles::StepAbortResourceFilesBackup()
 
     LogDebug("Backup Folder " << srcBuPath << " to " << srcPath);
 
-    if(!WrtUtilRemove(srcPath)) {
+    if (!WrtUtilRemove(srcPath)) {
         LogError("Failed to remove " << srcPath);
     }
 
@@ -257,7 +289,7 @@ void TaskUpdateFiles::StepAbortExecFileBackup()
     LogDebug("StepAbortExecFileBackup");
     std::string binPath = m_context.locations->getBinaryDir();
 
-    if(!WrtUtilRemove(binPath)) {
+    if (!WrtUtilRemove(binPath)) {
         LogError("Failed to remove " << binPath);
     }
 
@@ -275,10 +307,9 @@ void TaskUpdateFiles::StepAbortCreateBackupFolder()
     path << m_context.locations->getBackupDir();
     LogDebug("Remove backup directory : " << path.str());
 
-    if(!WrtUtilRemove(path.str())) {
+    if (!WrtUtilRemove(path.str())) {
         LogError("Failed to remove " << path);
     }
 }
-
 } //namespace WidgetInstall
 } //namespace Jobs
index 54a8f31..b53bb25 100644 (file)
 #include <widget_install/widget_install_context.h>
 #include <widget_install/widget_install_errors.h>
 #include <widget_parser.h>
-#include <wrt_error.h>
-
 
 namespace { // anonymous
 const DPL::String BR = DPL::FromUTF8String("<br>");
 const std::string WIDGET_NOT_COMPATIBLE = "This widget is "
-        "not compatible with WRT.<br><br>";
+                                          "not compatible with WRT.<br><br>";
 const std::string QUESTION = "Do you want to install it anyway?";
 
 const char *const DEFAULT_LANGUAGE = "default";
@@ -60,11 +58,10 @@ const char *const WRT_WIDGET_CONFIG_FILE_NAME = "config.xml";
 const std::string WINDGET_INSTALL_NETWORK_ACCESS = "network access";
 }
 
-
 namespace Jobs {
 namespace WidgetInstall {
 void InstallerTaskWidgetPopupData::PopupData::addWidgetInfo(
-        const DPL::String &info)
+    const DPL::String &info)
 {
     widgetInfo = info;
 }
@@ -73,7 +70,6 @@ TaskWidgetConfig::TaskWidgetConfig(InstallerContext& installContext) :
     DPL::TaskDecl<TaskWidgetConfig>(this),
     WidgetInstallPopup(installContext),
     m_installContext(installContext)
-
 {
     AddStep(&TaskWidgetConfig::StepProcessConfigurationFile);
     AddStep(&TaskWidgetConfig::ReadLocaleFolders);
@@ -85,7 +81,9 @@ TaskWidgetConfig::TaskWidgetConfig(InstallerContext& installContext) :
     AddStep(&TaskWidgetConfig::StepCheckMinVersionInfo);
 
     if (!GlobalSettings::TestModeEnabled() && !m_installContext.m_quiet) {
-        AddStep(&TaskWidgetConfig::StepCancelWidgetInstallationAfterVerifyFeatures);
+        AddStep(
+            &TaskWidgetConfig::
+                StepCancelWidgetInstallationAfterVerifyFeatures);
         AddStep(&TaskWidgetConfig::StepShowWidgetInfo);
         AddStep(&TaskWidgetConfig::StepCancelWidgetInstallation);
         AddStep(&TaskWidgetConfig::StepCancelWidgetInstallationAfterMinVersion);
@@ -119,45 +117,50 @@ void TaskWidgetConfig::ReadLocaleFolders()
     //Adding default locale
     m_localeFolders.insert(L"");
 
-    std::string localePath = m_installContext.locations->getConfigurationDir() + "/locales";
+    std::string localePath =
+        m_installContext.locations->getConfigurationDir() + "/locales";
     DIR* localeDir = opendir(localePath.c_str());
     if (!localeDir) {
         LogDebug("No /locales directory in the widget package.");
         return;
     }
 
-    struct dirent* dirent;
+
+
     struct stat statStruct;
-    do {
-        errno = 0;
-        if ((dirent = readdir(localeDir))) {
-            DPL::String dirName = DPL::FromUTF8String(dirent->d_name);
-            std::string absoluteDirName = localePath + "/";
-            absoluteDirName += dirent->d_name;
-
-            if (stat(absoluteDirName.c_str(), &statStruct) != 0) {
-                LogError("stat() failed with " << DPL::GetErrnoString());
-                continue;
-            }
+    struct dirent dirent;
+    struct dirent *result;
+    int return_code;
+    errno = 0;
+    for (return_code = readdir_r(localeDir, &dirent, &result);
+            result != NULL && return_code == 0;
+            return_code = readdir_r(localeDir, &dirent, &result))
+    {
+        DPL::String dirName = DPL::FromUTF8String(dirent.d_name);
+        std::string absoluteDirName = localePath + "/";
+        absoluteDirName += dirent.d_name;
 
-            if (S_ISDIR(statStruct.st_mode)) {
-                //Yes, we ignore current, parent & hidden directories
-                if (dirName[0] != L'.') {
-                    LogDebug("Adding locale directory \"" << dirName << "\"");
-                    m_localeFolders.insert(dirName);
-                }
+        if (stat(absoluteDirName.c_str(), &statStruct) != 0) {
+            LogError("stat() failed with " << DPL::GetErrnoString());
+            continue;
+        }
+
+        if (S_ISDIR(statStruct.st_mode)) {
+            //Yes, we ignore current, parent & hidden directories
+            if (dirName[0] != L'.') {
+                LogDebug("Adding locale directory \"" << dirName << "\"");
+                m_localeFolders.insert(dirName);
             }
         }
     }
-    while (dirent);
 
-    if (errno != 0) {
-        LogError("readdir() failed with " << DPL::GetErrnoString());
+    if (return_code != 0 || errno != 0) {
+        LogError("readdir_r() failed with " << DPL::GetErrnoString());
     }
 
     if (-1 == TEMP_FAILURE_RETRY(closedir(localeDir))) {
         LogError("Failed to close dir: " << localePath << " with error: "
-                << DPL::GetErrnoString());
+                                         << DPL::GetErrnoString());
     }
 }
 
@@ -175,7 +178,8 @@ void TaskWidgetConfig::ProcessLocalizedStartFiles()
     ProcessStartFile(S(L"index.svg"), S(L"image/svg+xml"));
     ProcessStartFile(S(L"index.xhtml"), S(L"application/xhtml+xml"));
     ProcessStartFile(S(L"index.xht"), S(L"application/xhtml+xml"));
-    // TODO: (l.wrzosek) we need better check if in current locales widget is valid.
+    // TODO: (l.wrzosek) we need better check if in current locales widget is
+    // valid.
     FOREACH(it, m_installContext.widgetConfig.localizationData.startFiles) {
         if (it->propertiesForLocales.size() > 0) {
             return;
@@ -186,9 +190,9 @@ void TaskWidgetConfig::ProcessLocalizedStartFiles()
 }
 
 void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path,
-        const DPL::OptionalString& type,
-        const DPL::OptionalString& encoding,
-        bool typeForcedInConfig)
+                                        const DPL::OptionalString& type,
+                                        const DPL::OptionalString& encoding,
+                                        bool typeForcedInConfig)
 {
     using namespace WrtDB;
 
@@ -204,7 +208,8 @@ void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path,
 
             DPL::String relativePath = pathPrefix + *path;
             DPL::String absolutePath = DPL::FromUTF8String(
-                    m_installContext.locations->getConfigurationDir()) + L"/" + relativePath;
+                    m_installContext.locations->getConfigurationDir()) + L"/" +
+                relativePath;
 
             // get property data from packaged app
             if (WrtUtilFileExists(DPL::ToUTF8String(absolutePath))) {
@@ -225,7 +230,7 @@ void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path,
                     } else {
                         MimeTypeUtils::MimeAttributes attributes =
                             MimeTypeUtils::getMimeAttributes(
-                            startFileProperties.type);
+                                startFileProperties.type);
                         if (attributes.count(L"charset") > 0) {
                             startFileProperties.encoding =
                                 attributes[L"charset"];
@@ -250,11 +255,14 @@ void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path,
                 // set property data for hosted start url
                 // Hosted start url only support TIZEN WebApp
                 if (m_installContext.widgetConfig.webAppType ==
-                        APP_TYPE_TIZENWEBAPP)
+                    APP_TYPE_TIZENWEBAPP)
                 {
-                    std::string startPath =  DPL::ToUTF8String(startFileData.path);
+                    std::string startPath = DPL::ToUTF8String(
+                            startFileData.path);
 
-                    if (strstr(startPath.c_str(), "http") == startPath.c_str()) {
+                    if (strstr(startPath.c_str(),
+                               "http") == startPath.c_str())
+                    {
                         WidgetRegisterInfo::StartFileProperties
                             startFileProperties;
                         if (!!type) {
@@ -280,12 +288,12 @@ void TaskWidgetConfig::ProcessBackgroundPageFile()
     if (!!m_installContext.widgetConfig.configInfo.backgroundPage) {
         // check whether file exists
         DPL::String backgroundPagePath = DPL::FromUTF8String(
-            m_installContext.locations->getConfigurationDir()) + L"/" +
+                m_installContext.locations->getConfigurationDir()) + L"/" +
             *m_installContext.widgetConfig.configInfo.backgroundPage;
         //if no then cancel installation
         if (!WrtUtilFileExists(DPL::ToUTF8String(backgroundPagePath))) {
             ThrowMsg(Exceptions::WidgetConfigFileInvalid,
-                    L"Given background page file not found in archive");
+                     L"Given background page file not found in archive");
         }
     }
 }
@@ -310,7 +318,8 @@ void TaskWidgetConfig::ProcessIcon(const WrtDB::ConfigParserData::Icon& icon)
     LogInfo("enter");
     bool isAnyIconValid = false;
     //In case a default filename is passed as custom filename in config.xml, we
-    //need to keep a set of already processed filenames to avoid icon duplication
+    //need to keep a set of already processed filenames to avoid icon
+    // duplication
     //in database.
 
     using namespace WrtDB;
@@ -331,7 +340,8 @@ void TaskWidgetConfig::ProcessIcon(const WrtDB::ConfigParserData::Icon& icon)
 
         DPL::String relativePath = pathPrefix + icon.src;
         DPL::String absolutePath = DPL::FromUTF8String(
-                m_installContext.locations->getConfigurationDir()) + L"/" + relativePath;
+                m_installContext.locations->getConfigurationDir()) + L"/" +
+            relativePath;
 
         if (WrtUtilFileExists(DPL::ToUTF8String(absolutePath))) {
             DPL::String type = MimeTypeUtils::identifyFileMimeType(absolutePath);
@@ -345,8 +355,7 @@ void TaskWidgetConfig::ProcessIcon(const WrtDB::ConfigParserData::Icon& icon)
         }
     }
 
-    if(isAnyIconValid)
-    {
+    if (isAnyIconValid) {
         WidgetRegisterInfo::LocalizedIcon localizedIcon(icon,
                                                         localesAvailableForIcon);
         m_installContext.widgetConfig.localizationData.icons.push_back(
@@ -358,7 +367,8 @@ void TaskWidgetConfig::ProcessWidgetInstalledPath()
 {
     LogDebug("ProcessWidgetInstalledPath");
     m_installContext.widgetConfig.widgetInstalledPath =
-        DPL::FromUTF8String(m_installContext.locations->getPackageInstallationDir());
+        DPL::FromUTF8String(
+            m_installContext.locations->getPackageInstallationDir());
 }
 
 void TaskWidgetConfig::StepCancelWidgetInstallationAfterVerifyFeatures()
@@ -389,16 +399,17 @@ void TaskWidgetConfig::StepCancelWidgetInstallationAfterMinVersion()
     }
 }
 
-void TaskWidgetConfig::createInstallPopup(PopupType type, const std::string &label)
+void TaskWidgetConfig::createInstallPopup(PopupType type,
+                                          const std::string &label)
 {
     m_installContext.job->Pause();
-    if (m_popup)
+    if (m_popup) {
         destroyPopup();
+    }
 
     bool ret = createPopup();
-    if (ret)
-    {
-        loadPopup( type, label);
+    if (ret) {
+        loadPopup(type, label);
         showPopup();
     }
 }
@@ -411,8 +422,8 @@ void TaskWidgetConfig::StepDeletePopupWin()
 void TaskWidgetConfig::StepShowWidgetInfo()
 {
     if (!m_popupData.widgetInfo.empty()) {
-            std::string label = DPL::ToUTF8String(m_popupData.widgetInfo);
-            createInstallPopup(PopupType::WIDGET_FEATURE_INFO, label);
+        std::string label = DPL::ToUTF8String(m_popupData.widgetInfo);
+        createInstallPopup(PopupType::WIDGET_FEATURE_INFO, label);
         m_installContext.job->UpdateProgress(
             InstallerContext::INSTALL_WIDGET_CONFIG2,
             "Show Widget Info Finished");
@@ -422,25 +433,24 @@ void TaskWidgetConfig::StepShowWidgetInfo()
 void TaskWidgetConfig::StepCheckMinVersionInfo()
 {
     if (!isMinVersionCompatible(
-                m_installContext.widgetConfig.webAppType.appType,
-                m_installContext.widgetConfig.minVersion)) {
-        if(!GlobalSettings::TestModeEnabled() && !m_installContext.m_quiet)
-        {
+            m_installContext.widgetConfig.webAppType.appType,
+            m_installContext.widgetConfig.minVersion))
+    {
+        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");
+        } else {
+            LogError(
+                "Platform version lower than required -> cancelling installation");
             ThrowMsg(Exceptions::NotAllowed,
-                    "Platform version does not meet requirements");
+                     "Platform version does not meet requirements");
         }
     }
 
     m_installContext.job->UpdateProgress(
-            InstallerContext::INSTALL_WIDGET_CONFIG2,
-            "Check MinVersion Finished");
+        InstallerContext::INSTALL_WIDGET_CONFIG2,
+        "Check MinVersion Finished");
 }
 
 void TaskWidgetConfig::StepVerifyFeatures()
@@ -464,12 +474,14 @@ void TaskWidgetConfig::StepVerifyFeatures()
             ThrowMsg(
                 Exceptions::WidgetConfigFileInvalid,
                 "This app type [" <<
-                m_installContext.widgetConfig.webAppType.getApptypeToString() <<
+                m_installContext.widgetConfig.webAppType.getApptypeToString()
+                                  <<
                 "] cannot be allowed to use [" <<
                 DPL::ToUTF8String(it->name) + "] feature");
         }
         if (!WrtDB::FeatureDAOReadOnly::isFeatureInstalled(
-                DPL::ToUTF8String(it->name))) {
+                DPL::ToUTF8String(it->name)))
+        {
             LogWarning("Feature not found. Checking if required :[" <<
                        DPL::ToUTF8String(it->name) << "]");
 
@@ -480,11 +492,13 @@ void TaskWidgetConfig::StepVerifyFeatures()
                  * supported.
                  */
                 std::ostringstream os;
-                os << "Widget cannot be installed, required feature is missing:["
-                    << DPL::ToUTF8String(it->name) << "]";
+                os <<
+                "Widget cannot be installed, required feature is missing:["
+                   << DPL::ToUTF8String(it->name) << "]";
                 if (!GlobalSettings::TestModeEnabled() && !isTizenWebApp()) {
                     std::string label = os.str();
-                    createInstallPopup(PopupType::WIDGET_WRONG_FEATURE_INFO, label);
+                    createInstallPopup(PopupType::WIDGET_WRONG_FEATURE_INFO,
+                                       label);
                 }
                 ThrowMsg(Exceptions::WidgetConfigFileInvalid, os.str());
             }
@@ -494,7 +508,7 @@ void TaskWidgetConfig::StepVerifyFeatures()
             featureInfo += DPL::ToUTF8String(BR);
         }
     }
-    if(!data.accessInfoSet.empty()) {
+    if (!data.accessInfoSet.empty()) {
         featureInfo += WINDGET_INSTALL_NETWORK_ACCESS;
         featureInfo += DPL::ToUTF8String(BR);
     }
@@ -544,7 +558,9 @@ bool TaskWidgetConfig::isFeatureAllowed(WrtDB::AppType appType,
 }
 
 bool TaskWidgetConfig::parseVersionString(const std::string &version,
-        long &majorVersion, long &minorVersion, long &microVersion) const
+                                          long &majorVersion,
+                                          long &minorVersion,
+                                          long &microVersion) const
 {
     std::istringstream inputString(version);
     inputString >> majorVersion;
@@ -566,22 +582,28 @@ bool TaskWidgetConfig::parseVersionString(const std::string &version,
     return true;
 }
 
-bool TaskWidgetConfig::isMinVersionCompatible(WrtDB::AppType appType,
-        const DPL::OptionalString &widgetVersion) const
+bool TaskWidgetConfig::isMinVersionCompatible(
+    WrtDB::AppType appType,
+    const DPL::OptionalString &
+    widgetVersion) const
 {
-    if (widgetVersion.IsNull() || (*widgetVersion).empty())
-    {
-        LogWarning("minVersion attribute is empty. WRT assumes platform "
-                "supports this widget.");
-        return true;
+    if (widgetVersion.IsNull() || (*widgetVersion).empty()) {
+        if (appType == WrtDB::AppType::APP_TYPE_TIZENWEBAPP) {
+            return false;
+        } else {
+            LogWarning("minVersion attribute is empty. WRT assumes platform "
+                    "supports this widget.");
+            return true;
+        }
     }
 
     //Parse widget version
     long majorWidget = 0, minorWidget = 0, microWidget = 0;
     if (!parseVersionString(DPL::ToUTF8String(*widgetVersion), majorWidget,
-            minorWidget, microWidget)) {
+                            minorWidget, microWidget))
+    {
         LogWarning("Invalid format of widget version string.");
-        return true;
+        return false;
     }
 
     //Parse supported version
@@ -597,15 +619,16 @@ bool TaskWidgetConfig::isMinVersionCompatible(WrtDB::AppType appType,
     }
 
     if (!parseVersionString(version,
-                majorSupported, minorSupported, microSupported)) {
+                            majorSupported, minorSupported, microSupported))
+    {
         LogWarning("Invalid format of platform version string.");
         return true;
     }
 
     if (majorWidget > majorSupported ||
-            (majorWidget == majorSupported && minorWidget > minorSupported) ||
-            (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;
@@ -617,55 +640,64 @@ bool TaskWidgetConfig::isTizenWebApp() const
 {
     bool ret = FALSE;
     if (m_installContext.widgetConfig.webAppType.appType
-            == WrtDB::AppType::APP_TYPE_TIZENWEBAPP)
+        == WrtDB::AppType::APP_TYPE_TIZENWEBAPP)
+    {
         ret = TRUE;
+    }
 
     return ret;
 }
 
-bool TaskWidgetConfig::parseConfigurationFileBrowser(WrtDB::ConfigParserData& configInfo,
-                                    const std::string& _currentPath, int* pErrCode)
+bool TaskWidgetConfig::parseConfigurationFileBrowser(
+    WrtDB::ConfigParserData& configInfo,
+    const std::string& _currentPath)
 {
     ParserRunner parser;
     Try
     {
         parser.Parse(_currentPath, ElementParserPtr(new
-                                                  RootParser<
-                                                      WidgetParser>(
-                                                      configInfo,
-                                                      DPL::FromUTF32String(
-                                                          L"widget"))));
+                                                    RootParser<
+                                                        WidgetParser>(
+                                                        configInfo,
+                                                        DPL::FromUTF32String(
+                                                            L"widget"))));
     }
     Catch(ElementParser::Exception::Base)
     {
         LogError("Invalid widget configuration file!");
-        *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
         return false;
     }
     return true;
 }
 
-bool TaskWidgetConfig::parseConfigurationFileWidget(WrtDB::ConfigParserData& configInfo,
-                                    const std::string& _currentPath, int* pErrCode)
+bool TaskWidgetConfig::parseConfigurationFileWidget(
+    WrtDB::ConfigParserData& configInfo,
+    const std::string& _currentPath)
 {
     ParserRunner parser;
 
     //TODO: rewrite this madness
     std::string cfgAbsPath;
     DIR* dir = NULL;
-    struct dirent* ptr = NULL;
 
     dir = opendir(_currentPath.c_str());
     if (dir == NULL) {
-        *pErrCode = WRT_ERR_UNKNOWN;
         return false;
     }
     bool has_config_xml = false;
+    struct dirent ptr;
+    struct dirent *result;
+    int return_code;
     errno = 0;
-    while ((ptr = readdir(dir)) != NULL) { //Find configuration file, based on its name
-        if (ptr->d_type == DT_REG) {
-            if (!strcmp(ptr->d_name, WRT_WIDGET_CONFIG_FILE_NAME)) {
-                std::string dName(ptr->d_name);
+
+    //Find configuration file, based on its name
+    for (return_code = readdir_r(dir, &ptr, &result);
+                result != NULL && return_code == 0;
+                return_code = readdir_r(dir, &ptr, &result))
+    {
+        if (ptr.d_type == DT_REG) {
+            if (!strcmp(ptr.d_name, WRT_WIDGET_CONFIG_FILE_NAME)) {
+                std::string dName(ptr.d_name);
                 WrtUtilJoinPaths(cfgAbsPath, _currentPath, dName);
 
                 //Parse widget configuration file
@@ -685,11 +717,11 @@ bool TaskWidgetConfig::parseConfigurationFileWidget(WrtDB::ConfigParserData& con
                 Catch(ElementParser::Exception::Base)
                 {
                     LogError("Invalid widget configuration file!");
-                    //                    _rethrown_exception.Dump();
-                    *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
                     if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
-                        LogError("Failed to close dir: " << _currentPath << " with error: "
-                                << DPL::GetErrnoString());
+                        LogError(
+                            "Failed to close dir: " << _currentPath <<
+                            " with error: "
+                                                    << DPL::GetErrnoString());
                     }
                     return false;
                 }
@@ -699,67 +731,63 @@ bool TaskWidgetConfig::parseConfigurationFileWidget(WrtDB::ConfigParserData& con
             }
         }
     }
+    if (errno != 0) {
+        LogError("readdir_r() failed with " << DPL::GetErrnoString());
+    }
+    errno = 0;
     if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
         LogError("Failed to close dir: " << _currentPath << " with error: "
-                << DPL::GetErrnoString());
+                                         << DPL::GetErrnoString());
     }
 
     //We must have config.xml so leaveing if we doesn't
     if (!has_config_xml) {
         LogError("Invalid archive");
-        *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
         return false;
     }
     return true;
 }
 
 bool TaskWidgetConfig::locateAndParseConfigurationFile(
-        const std::string& _currentPath,
-        WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
-        const std::string& baseFolder,
-        int* pErrCode)
+    const std::string& _currentPath,
+    WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
+    const std::string& baseFolder)
 {
     using namespace WrtDB;
 
-    if (!pErrCode) {
-        return false;
-    }
-
     ConfigParserData& configInfo = pWidgetConfigInfo.configInfo;
 
     // check if this installation from browser, or not.
     size_t pos = _currentPath.rfind("/");
     std::ostringstream infoPath;
-    infoPath << _currentPath.substr(pos+1);
+    infoPath << _currentPath.substr(pos + 1);
 
     if (infoPath.str() != WRT_WIDGET_CONFIG_FILE_NAME) {
         if (_currentPath.empty() || baseFolder.empty()) {
-            *pErrCode = WRT_ERR_INVALID_ARG;
             return false;
         }
         // in case of general installation using wgt archive
-        if(!parseConfigurationFileWidget(configInfo, _currentPath, pErrCode))
+        if (!parseConfigurationFileWidget(configInfo, _currentPath))
         {
             return false;
         }
     } else {
         // in case of browser installation
-        if(!parseConfigurationFileBrowser(configInfo, _currentPath, pErrCode))
+        if (!parseConfigurationFileBrowser(configInfo, _currentPath))
         {
             return false;
         }
     }
 
-    if(!fillWidgetConfig(pWidgetConfigInfo, configInfo))
-    {
-        *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
+    if (!fillWidgetConfig(pWidgetConfigInfo, configInfo)) {
         return false;
     }
     return true;
 }
 
-bool TaskWidgetConfig::fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
-                                        WrtDB::ConfigParserData& configInfo)
+bool TaskWidgetConfig::fillWidgetConfig(
+    WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
+    WrtDB::ConfigParserData& configInfo)
 {
     if (!!configInfo.widget_id) {
         if (!pWidgetConfigInfo.guid) {
@@ -771,11 +799,19 @@ bool TaskWidgetConfig::fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfig
             }
         }
     }
-    if (!!configInfo.tizenId) {
-       if (pWidgetConfigInfo.pkgName != *configInfo.tizenId) {
-           LogError("Invalid archive - Tizen ID not same error");
-           return false;
-       }
+    if (!!configInfo.tizenAppId) {
+        if (DPL::ToUTF8String(pWidgetConfigInfo.tzAppid).compare(
+                DPL::ToUTF8String(*configInfo.tizenAppId)) < 0)
+        {
+            LogError("Invalid archive - Tizen App ID not same error");
+            return false;
+        }
+    }
+    if (!!configInfo.tizenPkgId) {
+        if (pWidgetConfigInfo.tzPkgid != *configInfo.tizenPkgId) {
+            LogError("Invalid archive - Tizen Pkg ID not same error");
+            return false;
+        }
     }
     if (!!configInfo.version) {
         if (!pWidgetConfigInfo.version) {
@@ -795,17 +831,17 @@ bool TaskWidgetConfig::fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfig
     return true;
 }
 
-void TaskWidgetConfig::processFile(const std::string& path,
-        WrtDB::WidgetRegisterInfo &widgetConfiguration)
+void TaskWidgetConfig::processFile(
+    const std::string& path,
+    WrtDB::WidgetRegisterInfo &
+    widgetConfiguration)
 {
-    int pErrCode;
-
     if (!locateAndParseConfigurationFile(path, widgetConfiguration,
-                                         DEFAULT_LANGUAGE, &pErrCode)) {
+                                         DEFAULT_LANGUAGE))
+    {
         LogWarning("Widget archive: Failed while parsing config file");
         ThrowMsg(Exception::ConfigParseFailed, path);
     }
 }
-
 } //namespace WidgetInstall
 } //namespace Jobs
old mode 100755 (executable)
new mode 100644 (file)
index 9b44559..fdaf1e9
@@ -33,7 +33,6 @@
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <dpl/wrt-dao-ro/global_config.h>
 
-#include <wrt_error.h>
 #include <wrt_common_types.h>
 #include <widget_install/widget_install_popup.h>
 
@@ -71,10 +70,12 @@ class TaskWidgetConfig :
     void StepProcessConfigurationFile();
     void ReadLocaleFolders();
     void ProcessLocalizedStartFiles();
-    void ProcessStartFile(const DPL::OptionalString& path,
-            const DPL::OptionalString& type,
-            const DPL::OptionalString& encoding = DPL::OptionalString::Null,
-            bool typeForcedInConfig = false);
+    void ProcessStartFile(
+        const DPL::OptionalString& path,
+        const DPL::OptionalString& type,
+        const DPL::OptionalString& encoding =
+            DPL::OptionalString::Null,
+        bool typeForcedInConfig = false);
     void ProcessBackgroundPageFile();
     void ProcessLocalizedIcons();
     void ProcessIcon(const WrtDB::ConfigParserData::Icon& icon);
@@ -93,17 +94,17 @@ class TaskWidgetConfig :
     void createInstallPopup(PopupType type, const std::string &label);
     DPL::String createAuthorWidgetInfo() const;
     bool isFeatureAllowed(
-            WrtDB::AppType appType, DPL::String featureName);
+        WrtDB::AppType appType, DPL::String featureName);
     bool isMinVersionCompatible(
-            WrtDB::AppType appType,
-            const DPL::OptionalString &widgetVersion) const;
+        WrtDB::AppType appType,
+        const DPL::OptionalString &widgetVersion) const;
     /**
      * @brief Parses version string in format "major.minor.micro anything"
      * Returns false if format is invalid
      */
     bool isTizenWebApp() const;
     bool parseVersionString(const std::string &version, long &majorVersion,
-            long &minorVersion, long &microVersion) const;
+                            long &minorVersion, long &microVersion) const;
     /**
      * This method is used to process the config.xml of widget, get
      * the corresponding configuration to pWidgetConfigInfo
@@ -114,16 +115,18 @@ class TaskWidgetConfig :
     void processFile(const std::string& path,
                      WrtDB::WidgetRegisterInfo &wConfig);
 
-    bool locateAndParseConfigurationFile(const std::string& currentPath,
-            WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
-            const std::string& baseFolder,
-            int* pErrCode);
+    bool locateAndParseConfigurationFile(
+        const std::string& currentPath,
+        WrtDB::WidgetRegisterInfo&
+        pWidgetConfigInfo,
+        const std::string& baseFolder);
     bool parseConfigurationFileBrowser(WrtDB::ConfigParserData& configInfo,
-                                    const std::string& _currentPath, int* pErrCode);
+                                       const std::string& _currentPath);
     bool parseConfigurationFileWidget(WrtDB::ConfigParserData& configInfo,
-                                    const std::string& _currentPath, int* pErrCode);
+                                      const std::string& _currentPath);
     bool fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
-                                    WrtDB::ConfigParserData& configInfo);
+                          WrtDB::ConfigParserData& configInfo);
+
   public:
     TaskWidgetConfig(InstallerContext& installTaskContext);
 };
index 6054388..a4acc39 100644 (file)
@@ -24,7 +24,6 @@
 
 namespace Jobs {
 namespace WidgetInstall {
-
 enum ViewMode
 {
     WINDOWED = 0,
@@ -33,7 +32,6 @@ enum ViewMode
     MAXIMIZED,
     MINIMIZED
 };
-
 } // WidgetInstall
 } // Jobs
 
index 6dafd02..447a99f 100644 (file)
 
 namespace Jobs {
 namespace WidgetInstall {
-
 void WacSecurity::getCertificateChainList(
-        WrtDB::CertificateChainList& list,
-        WrtDB::CertificateSource source) const
+    WrtDB::CertificateChainList& list,
+    WrtDB::CertificateSource source) const
 {
-    if (source == WrtDB::CertificateSource::SIGNATURE_DISTRIBUTOR){
+    if (source == WrtDB::CertificateSource::SIGNATURE_DISTRIBUTOR) {
         FOREACH(certIter, mCertificateChainList)
-            list.push_back(certIter->toBase64String());
+        list.push_back(certIter->toBase64String());
     } else {
         FOREACH(certIter, mAuthorsCertificateChainList)
-            list.push_back(certIter->toBase64String());
+        list.push_back(certIter->toBase64String());
     }
 }
-
 } // namespace WidgetInstall
 } // namespace Jobs
index a2095da..d343fd9 100644 (file)
@@ -29,7 +29,6 @@
 
 namespace Jobs {
 namespace WidgetInstall {
-
 class WacSecurity : public WrtDB::IWacSecurity
 {
   public:
@@ -37,8 +36,7 @@ class WacSecurity : public WrtDB::IWacSecurity
         mRecognized(false),
         mDistributorSigned(false),
         mWacSigned(false)
-    {
-    }
+    {}
 
     // from IWacSecurity
     virtual const WrtDB::WidgetCertificateDataList& getCertificateList() const
@@ -46,30 +44,53 @@ class WacSecurity : public WrtDB::IWacSecurity
         return mCertificateList;
     }
 
-    virtual bool isRecognized() const { return mRecognized; }
+    virtual bool isRecognized() const
+    {
+        return mRecognized;
+    }
 
-    virtual bool isDistributorSigned() const { return mDistributorSigned; }
+    virtual bool isDistributorSigned() const
+    {
+        return mDistributorSigned;
+    }
 
-    virtual bool isWacSigned() const { return mWacSigned; }
+    virtual bool isWacSigned() const
+    {
+        return mWacSigned;
+    }
 
     virtual void getCertificateChainList(
-            WrtDB::CertificateChainList& list,
-            WrtDB::CertificateSource source) const;
+        WrtDB::CertificateChainList& list,
+        WrtDB::CertificateSource source) const;
 
-    void setRecognized(bool recognized) { mRecognized = recognized; }
+    void setRecognized(bool recognized)
+    {
+        mRecognized = recognized;
+    }
     void setDistributorSigned(bool distributorSigned)
     {
         mDistributorSigned = distributorSigned;
     }
-    void setWacSigned(bool wacSigned) { mWacSigned = wacSigned; }
+    void setWacSigned(bool wacSigned)
+    {
+        mWacSigned = wacSigned;
+    }
+    void setAuthorCertificatePtr(ValidationCore::CertificatePtr certPtr)
+    {
+        mAuthorCertificate = certPtr;
+    }
 
-    ValidationCore::CertificatePtr getAuthorCertificatePtr() const { return mAuthorCertificate;}
+    ValidationCore::CertificatePtr getAuthorCertificatePtr() const
+    {
+        return mAuthorCertificate;
+    }
     ValidationCore::CertificateCollectionList& getCertificateChainListRef()
     {
         return mCertificateChainList;
     }
 
-    ValidationCore::CertificateCollectionList& getAuthorsCertificateChainListRef()
+    ValidationCore::CertificateCollectionList&
+    getAuthorsCertificateChainListRef()
     {
         return mAuthorsCertificateChainList;
     }
@@ -98,7 +119,6 @@ class WacSecurity : public WrtDB::IWacSecurity
     // This authors certificates are used by tizen
     ValidationCore::CertificateCollectionList mAuthorsCertificateChainList;
 };
-
 } // namespace WidgetInstall
 } // namespace Jobs
 
old mode 100755 (executable)
new mode 100644 (file)
index 284cc1b..affe621
@@ -47,38 +47,32 @@ struct InstallerContext
     {
         INSTALL_START = 0,
         INSTALL_CHECK_FILE,
-        INSTALL_CREATE_TEMPDIR,
         INSTALL_UNZIP_FILES,
         INSTALL_WIDGET_CONFIG1,
         INSTALL_WIDGET_CONFIG2,
-        INSTALL_WIDGET_CONFIG3,
-        INSTALL_WIDGET_CONFIG4,
-        INSTALL_WIDGET_CONFIG5,
         INSTALL_DIGSIG_CHECK,
         INSTALL_CERT_CHECK,
-        INSTALL_DB_UPDATE,
+        INSTALL_ECRYPTION_FILES,
         INSTALL_DIR_CREATE,
         INSTALL_RENAME_PATH,
 
-        INSTALL_CREATE_BACKUP_DIR = INSTALL_DB_UPDATE, /* For Update */
+        INSTALL_CREATE_BACKUP_DIR,                     /* For Update */
         INSTALL_BACKUP_RES_FILES,                      /* For Update */
         INSTALL_BACKUP_EXEC,                           /* For Update */
-        INSTALL_NEW_DB_INSERT,                         /* For Update */
 
-        INSTALL_ACE_PREPARE,
-        INSTALL_ACE_CHECK,
         INSTALL_SMACK_ENABLE,
         INSTALL_BACKUP_ICONFILE,                         /* For Update */
         INSTALL_COPY_ICONFILE,
         INSTALL_CREATE_EXECFILE,
         INSTALL_CREATE_MANIFEST,
-        INSTALL_CREATE_DESKTOP,
         INSTALL_CREATE_SHORTCUT,
+        INSTALL_SET_CERTINFO,
         INSTALL_INSTALL_OSPSVC,
-
-        INSTALL_UPDATE_DESKTOP = INSTALL_CREATE_DESKTOP, /* For Update */
-        INSTALL_DELETE_OLD_DB,                           /* For Update */
         INSTALL_REMOVE_BACKUP_FILE,
+        INSTALL_PLUGINS_COPY,
+        INSTALL_NEW_DB_INSERT,
+        INSTALL_ACE_PREPARE,
+        INSTALL_ACE_CHECK,
 
         INSTALL_END
     } InstallStep;
@@ -86,19 +80,20 @@ struct InstallerContext
     // Installation state variables
     WrtDB::WidgetRegisterInfo widgetConfig;      ///< WidgetConfigInfo
     DPL::Optional<WidgetLocation> locations;
-    Jobs::WidgetInstall::WacSecurity wacSecurity;///< Widget Domain information.
+    Jobs::WidgetInstall::WacSecurity wacSecurity; ///< Widget Domain
+                                                  // information.
     InstallStep installStep;              ///< current step of installation
     Jobs::WidgetInstall::JobWidgetInstall *job;
-        ///< pointer of instance of JobWidgetInstall
+    ///< pointer of instance of JobWidgetInstall
     WidgetUpdateInfo::ExistingWidgetInfo existingWidgetInfo;
-        ///< Whether this is an update or normal installation
+    ///< Whether this is an update or normal installation
     Jobs::WidgetInstall::FeatureLogicPtr featureLogic;
     /** List of dev-caps that are requested in widget config file.
-    * Additional flag tells whether dev cap gets "static" permission
-    * (will always have PERMIT from ACE Policy). They will therefore receive
-    * static SMACK permission. (They may be forbidden because
-    * of ACE User Settings, but for now we do not protect this
-    * case with SMACK). */
+     * Additional flag tells whether dev cap gets "static" permission
+     * (will always have PERMIT from ACE Policy). They will therefore receive
+     * static SMACK permission. (They may be forbidden because
+     * of ACE User Settings, but for now we do not protect this
+     * case with SMACK). */
     RequestedDevCapsMap staticPermittedDevCaps;
     std::string installInfo;            ///<For recovery>
     bool m_quiet;
index b3bf040..79e8407 100644 (file)
@@ -35,18 +35,19 @@ enum Type
 {
     Success,                         ///< Success
 
-    ErrorInvalidWidgetPackage,       ///< ?
-    ErrorWidgetDoesNotExist,         ///< ?
+    ErrorInvalidWidgetPackage,       ///< invalid widget package
+    ErrorWidgetDoesNotExist,         ///< given tizenAppId is invalid, no app
     ErrorAreadyUninstalling,         ///< Widget is already being uninstalled
-    ErrorOutOfDiskSpace,             ///< ?
     ErrorInvalidPackage,             ///< Widget signature is invalid.
-    ErrorAlreadyInstalled,           ///< ?
-    ErrorInternal,                   ///< ?
-    ErrorNotAllowed,                 ///< Widget installation or update not allowed
+    ErrorInternal,                   ///< Internal error due to inconsistency
+    ErrorNotAllowed,                 ///< Widget installation or update not
+                                     // allowed
                                      ///< because violation of policy ocurred
-    ErrorDeferred,                   ///< Widget installation was deferred and will be continued when possible
+    ErrorDeferred,                   ///< Widget installation was deferred and
+                                     // will be continued when possible
     ErrorDatabaseFailure,            ///< Failure in database
-    ErrorRemovingFolderFailure,      ///< Failure in removing existing widget folder
+    ErrorRemovingFolderFailure,      ///< Failure in removing existing widget
+                                     // folder
     ErrorCreateVconfFailure,         ///< Failure in creating vconf
     ErrorInstallOspServcie,          ///< Failure in installing osp service
     ErrorUpdateWidget,               ///< Failure in widget update.
@@ -59,16 +60,11 @@ DECLARE_JOB_EXCEPTION_BASE(JobExceptionBase, Base, ErrorUnknown)
 // PREPARE
 DECLARE_JOB_EXCEPTION(Base, NotAllowed, ErrorNotAllowed)
 DECLARE_JOB_EXCEPTION(Base, Deferred, ErrorDeferred)
-DECLARE_JOB_EXCEPTION(Base, InvalidWidgetUrl, ErrorInvalidWidgetPackage)
 
 //UNZIP
 DECLARE_JOB_EXCEPTION(Base, OpenZipFailed, ErrorInvalidWidgetPackage)
-DECLARE_JOB_EXCEPTION(Base, GetZipGlobalInfoFailed, ErrorInvalidWidgetPackage)
 DECLARE_JOB_EXCEPTION(Base, ZipEmpty, ErrorInvalidWidgetPackage)
-DECLARE_JOB_EXCEPTION(Base, GetZippedFileInfoFailed, ErrorInvalidWidgetPackage)
-DECLARE_JOB_EXCEPTION(Base, ZippedFileVersionTooNew, ErrorInvalidWidgetPackage)
 DECLARE_JOB_EXCEPTION(Base, ExtractFileFailed, ErrorInvalidWidgetPackage)
-DECLARE_JOB_EXCEPTION(Base, OutOfDiskSpace, ErrorOutOfDiskSpace)
 DECLARE_JOB_EXCEPTION(Base, InternalError, ErrorInternal)
 
 //CERTIFY
@@ -76,12 +72,11 @@ DECLARE_JOB_EXCEPTION(Base, InvalidPackage, ErrorInvalidPackage)
 
 //WCONFIG
 DECLARE_JOB_EXCEPTION(Base, WidgetConfigFileInvalid, ErrorInvalidWidgetPackage)
-DECLARE_JOB_EXCEPTION(Base, NotInstalled, ErrorInvalidWidgetPackage)
 DECLARE_JOB_EXCEPTION(Base, InstallationFailed, ErrorInvalidWidgetPackage)
-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, RemovingFileFailure, ErrorRemovingFolderFailure)
 DECLARE_JOB_EXCEPTION(Base, CreateVconfFailure, ErrorCreateVconfFailure)
 
 DECLARE_JOB_EXCEPTION(Base, CopyIconFailed, ErrorUnknown)
@@ -89,7 +84,6 @@ 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)
 //UPDATE
 DECLARE_JOB_EXCEPTION(Base, BackupFailed, ErrorUpdateWidget)
@@ -104,7 +98,6 @@ DECLARE_JOB_EXCEPTION(Base, EmptyPluginsDirectory, ErrorInvalidWidgetPackage)
 DECLARE_JOB_EXCEPTION(Base, PluginsSubdirectory, ErrorInvalidWidgetPackage)
 
 DECLARE_JOB_EXCEPTION(Base, SetCertificateInfoFailed, ErrorUnknown)
-
 } //namespace
 } //namespace
 } //namespace
old mode 100755 (executable)
new mode 100644 (file)
index 34c3fa1..bfb6b9f
 #include <widget_install_popup.h>
 
 namespace {
-const char * const EDJFILE ="/usr/share/edje/wrt/widget_install_popup.edj";
+const char * const EDJFILE = "/usr/share/edje/wrt/widget_install_popup.edj";
 const char * const EDJGROUP = "widget_install_popup";
-const char * const TITLE_TEXT  ="title,text";
-const char * const name ="WidgetInstallPopup";
+const char * const TITLE_TEXT "title,text";
+const char * const name = "WidgetInstallPopup";
 const char * const FEATURE_TITLE = "Widget Feature Info";
 const char * const INFO_TITLE = "Widget Info";
 const char * const INSTALLATION_FAILURE = "Installation failure";
-const char * const INFO_LEFT_BUTTON ="OK";
+const char * const INFO_LEFT_BUTTON = "OK";
 const char * const INFO_RIGHT_BUTTON = "CANCEL ";
 const char * const WARNING_TITLE = "Widget Warning";
 const char * const WARNING_LEFT_BUTTON = "YES";
 const char * const WARNING_RIGHT_BUTTON = "NO";
-const char * const QUESTION ="Widget use Device API below. <br>Do you want to install?";
+const char * const QUESTION =
+    "Widget use Device API below. <br>Do you want to install?";
 }
 
 namespace Jobs {
@@ -61,8 +62,7 @@ bool WidgetInstallPopup::addWin(const char *name)
 {
     int w, h;
     m_win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
-    if(!m_win)
-    {
+    if (!m_win) {
         LogError("addWin failed");
         return false;
     }
@@ -80,40 +80,42 @@ bool WidgetInstallPopup::addWin(const char *name)
 bool WidgetInstallPopup::addPopup()
 {
     m_popup = elm_popup_add(m_win);
-    if(!m_popup)
+    if (!m_popup) {
         return false;
+    }
 
     evas_object_size_hint_align_set(m_popup, EVAS_HINT_FILL, EVAS_HINT_FILL);
-    evas_object_size_hint_weight_set(m_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    evas_object_size_hint_weight_set(m_popup,
+                                     EVAS_HINT_EXPAND,
+                                     EVAS_HINT_EXPAND);
     return true;
 }
 
 void WidgetInstallPopup::addTitle(PopupType type)
 {
     switch (type) {
-    case PopupType::WIDGET_FEATURE_INFO :
+    case PopupType::WIDGET_FEATURE_INFO:
         elm_object_part_text_set(m_popup, TITLE_TEXT, FEATURE_TITLE);
-    break;
-    case PopupType::WIDGET_AUTHOR_INFO :
+        break;
+    case PopupType::WIDGET_AUTHOR_INFO:
         elm_object_part_text_set(m_popup, TITLE_TEXT, INFO_TITLE);
-    break;
-    case PopupType::WIDGET_MIN_VERSION :
-    case PopupType::WIDGET_UNRECOGNIZED :
+        break;
+    case PopupType::WIDGET_MIN_VERSION:
+    case PopupType::WIDGET_UNRECOGNIZED:
         elm_object_part_text_set(m_popup, TITLE_TEXT, WARNING_TITLE);
-    break;
-    case PopupType::WIDGET_WRONG_FEATURE_INFO :
+        break;
+    case PopupType::WIDGET_WRONG_FEATURE_INFO:
         elm_object_part_text_set(m_popup, TITLE_TEXT, INSTALLATION_FAILURE);
-    break;
-    default :
-    break;
-}
+        break;
+    default:
+        break;
+    }
 }
 
 void WidgetInstallPopup::addScrollLabel(const std::string &str)
 {
     Evas_Object *ly = elm_layout_add(m_popup);
-    if (!ly)
-    {
+    if (!ly) {
         LogError(" install popup layout add failed");
         return;
     }
@@ -124,95 +126,111 @@ void WidgetInstallPopup::addScrollLabel(const std::string &str)
     elm_object_content_set(m_popup, ly);
 
     Evas_Object *question_label = elm_label_add(m_popup);
-    if(!question_label)
+    if (!question_label) {
         return;
-    evas_object_size_hint_align_set(question_label, EVAS_HINT_FILL, EVAS_HINT_FILL);
-    evas_object_size_hint_weight_set(question_label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    }
+    evas_object_size_hint_align_set(question_label,
+                                    EVAS_HINT_FILL,
+                                    EVAS_HINT_FILL);
+    evas_object_size_hint_weight_set(question_label,
+                                     EVAS_HINT_EXPAND,
+                                     EVAS_HINT_EXPAND);
     evas_object_show(question_label);
     elm_object_text_set(question_label, QUESTION);
     elm_object_part_content_set(ly, "elm.swallow.label", question_label);
 
     Evas_Object *scroller = elm_scroller_add(m_popup);
-    if(!scroller)
+    if (!scroller) {
         return;
+    }
     evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
-    evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    evas_object_size_hint_weight_set(scroller,
+                                     EVAS_HINT_EXPAND,
+                                     EVAS_HINT_EXPAND);
     elm_scroller_bounce_set(scroller, EINA_TRUE, EINA_TRUE);
-    elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_AUTO);
+    elm_scroller_policy_set(scroller,
+                            ELM_SCROLLER_POLICY_AUTO,
+                            ELM_SCROLLER_POLICY_AUTO);
 
     elm_object_part_content_set(ly, "elm.swallow.scroller", scroller);
     evas_object_show(scroller);
 
     Evas_Object *feature_label = elm_label_add(m_popup);
-    if(!feature_label)
+    if (!feature_label) {
         return;
-    evas_object_size_hint_align_set(feature_label, EVAS_HINT_FILL, EVAS_HINT_FILL);
-    evas_object_size_hint_weight_set(feature_label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    }
+    evas_object_size_hint_align_set(feature_label,
+                                    EVAS_HINT_FILL,
+                                    EVAS_HINT_FILL);
+    evas_object_size_hint_weight_set(feature_label,
+                                     EVAS_HINT_EXPAND,
+                                     EVAS_HINT_EXPAND);
     evas_object_show(feature_label);
     elm_object_text_set(feature_label, str.c_str());
     elm_object_content_set(scroller, feature_label);
 }
 
-void WidgetInstallPopup::addContent(PopupType  type, const std::string &str)
+void WidgetInstallPopup::addContent(PopupType type, const std::string &str)
 {
     switch (type) {
-    case PopupType::WIDGET_FEATURE_INFO :
+    case PopupType::WIDGET_FEATURE_INFO:
         addScrollLabel(str);
-    break;
-    default :
+        break;
+    default:
         elm_object_part_text_set(m_popup, "default", str.c_str());
-    break;
+        break;
     }
 }
 
-void WidgetInstallPopup::addButton(PopupType  type)
+void WidgetInstallPopup::addButton(PopupType type)
 {
     Evas_Object *lbutton = elm_button_add(m_popup);
     Evas_Object *rbutton = elm_button_add(m_popup);
-    if(!lbutton || !rbutton)
+    if (!lbutton || !rbutton) {
         return;
+    }
 
     switch (type) {
-        case PopupType::WIDGET_WRONG_FEATURE_INFO :
-            elm_object_text_set(lbutton, INFO_LEFT_BUTTON);
-            elm_object_part_content_set(m_popup, "button1", lbutton);
-            evas_object_smart_callback_add(lbutton,
-                    "clicked",
-                    userCancelCallback,
-                    this);
-            return;
-        case PopupType::WIDGET_FEATURE_INFO :
-            elm_object_text_set(lbutton, INFO_LEFT_BUTTON);
-            elm_object_text_set(rbutton, INFO_RIGHT_BUTTON);
-            break;
-        default :
-            elm_object_text_set(lbutton, WARNING_LEFT_BUTTON);
-            elm_object_text_set(rbutton, WARNING_RIGHT_BUTTON);
-            break;
+    case PopupType::WIDGET_WRONG_FEATURE_INFO:
+        elm_object_text_set(lbutton, INFO_LEFT_BUTTON);
+        elm_object_part_content_set(m_popup, "button1", lbutton);
+        evas_object_smart_callback_add(lbutton,
+                                       "clicked",
+                                       userCancelCallback,
+                                       this);
+        return;
+    case PopupType::WIDGET_FEATURE_INFO:
+        elm_object_text_set(lbutton, INFO_LEFT_BUTTON);
+        elm_object_text_set(rbutton, INFO_RIGHT_BUTTON);
+        break;
+    default:
+        elm_object_text_set(lbutton, WARNING_LEFT_BUTTON);
+        elm_object_text_set(rbutton, WARNING_RIGHT_BUTTON);
+        break;
     }
 
     elm_object_part_content_set(m_popup, "button1", lbutton);
     evas_object_smart_callback_add(lbutton,
-            "clicked",
-            userPermitCallback,
-            this);
+                                   "clicked",
+                                   userPermitCallback,
+                                   this);
     elm_object_part_content_set(m_popup, "button2", rbutton);
     evas_object_smart_callback_add(rbutton,
-            "clicked",
-            userCancelCallback,
-            this);
+                                   "clicked",
+                                   userCancelCallback,
+                                   this);
 }
 
 bool WidgetInstallPopup::createPopup()
 {
     bool ret = addWin(name);
-    if(!ret)
+    if (!ret) {
         return false;
+    }
     evas_object_show(m_win);
 
     ret = addPopup();
-    if(!ret)
-    {
+    if (!ret) {
         evas_object_del(m_win);
         m_win = NULL;
         return false;
@@ -223,11 +241,11 @@ bool WidgetInstallPopup::createPopup()
 
 void WidgetInstallPopup::destroyPopup()
 {
-    if(m_win) {
-           evas_object_del(m_win);
-           m_win = NULL;
-           m_popup = NULL;
-       }
+    if (m_win) {
+        evas_object_del(m_win);
+        m_win = NULL;
+        m_popup = NULL;
+    }
 }
 
 void WidgetInstallPopup::loadPopup(PopupType type, const std::string &label)
@@ -243,8 +261,8 @@ void WidgetInstallPopup::showPopup()
 }
 
 void WidgetInstallPopup::userPermitCallback(void * data,
-        Evas_Object */*obj*/,
-        void */*event_info*/)
+                                            Evas_Object */*obj*/,
+                                            void */*event_info*/)
 {
     WidgetInstallPopup *This = static_cast<WidgetInstallPopup *>(data);
     This->m_installCancel = WRT_POPUP_BUTTON_OK;
@@ -252,8 +270,8 @@ void WidgetInstallPopup::userPermitCallback(void * data,
 }
 
 void WidgetInstallPopup::userCancelCallback(void *data,
-        Evas_Object */*obj*/,
-        void */*event_info*/)
+                                            Evas_Object */*obj*/,
+                                            void */*event_info*/)
 {
     WidgetInstallPopup *This = static_cast<WidgetInstallPopup *>(data);
     This->m_installCancel = WRT_POPUP_BUTTON_CANCEL;
@@ -262,4 +280,3 @@ void WidgetInstallPopup::userCancelCallback(void *data,
 }
 }
 
-
old mode 100755 (executable)
new mode 100644 (file)
index d2859f7..bbbe851
 #include <Ecore_X.h>
 #include <Elementary.h>
 
-
 class InstallerContext;
 
 namespace Jobs {
 namespace WidgetInstall {
-
 enum PopupType {
     WIDGET_INSTALL_POPUP = 0,
     WIDGET_FEATURE_INFO,  //sp-2390
@@ -49,36 +47,35 @@ enum InfoPopupButton
     WRT_POPUP_BUTTON_CANCEL
 };
 
-
 class WidgetInstallPopup
 {
-    public :
-      explicit WidgetInstallPopup(InstallerContext &installContext);
-      virtual ~WidgetInstallPopup();
+  public:
+    explicit WidgetInstallPopup(InstallerContext &installContext);
+    virtual ~WidgetInstallPopup();
 
-      bool createPopup();
-      void destroyPopup();
-      void loadPopup(PopupType type, const std::string &label);
-      void showPopup();
-      bool addWin(const char *name);
-      bool addPopup();
-      void addTitle(PopupType type);
-      void addScrollLabel(const std::string &str);
-      void addContent(PopupType  type, const std::string &str);
-      void addButton(PopupType type);
+    bool createPopup();
+    void destroyPopup();
+    void loadPopup(PopupType type, const std::string &label);
+    void showPopup();
+    bool addWin(const char *name);
+    bool addPopup();
+    void addTitle(PopupType type);
+    void addScrollLabel(const std::string &str);
+    void addContent(PopupType type, const std::string &str);
+    void addButton(PopupType type);
 
-      static void userPermitCallback(void *data,
-      Evas_Object *obj,
-      void *event_info);
-      static void userCancelCallback(void *data,
-      Evas_Object *obj,
-      void *event_info);
+    static void userPermitCallback(void *data,
+                                   Evas_Object *obj,
+                                   void *event_info);
+    static void userCancelCallback(void *data,
+                                   Evas_Object *obj,
+                                   void *event_info);
 
-  protected :
-      Evas_Object *m_win;
-      Evas_Object *m_popup;
-      InstallerContext &m_installContext;
-      int m_installCancel;
+  protected:
+    Evas_Object *m_win;
+    Evas_Object *m_popup;
+    InstallerContext &m_installContext;
+    int m_installCancel;
 };
 }
 }
old mode 100755 (executable)
new mode 100644 (file)
index 2a655c8..797aa2d
@@ -51,13 +51,13 @@ enum Type
     Zero = 0,
 
     // Bits
-    NotInstalled          = 1 << 0,
+    NotInstalled = 1 << 0,
     IncomingVersionNotStd = 1 << 1,
     ExistingVersionNotStd = 1 << 2,
-    BothVersionsNotStd    = 1 << 3,
-    ExistingVersionOlder  = 1 << 4,
-    ExistingVersionEqual  = 1 << 5,
-    ExistingVersionNewer  = 1 << 6,
+    BothVersionsNotStd = 1 << 3,
+    ExistingVersionOlder = 1 << 4,
+    ExistingVersionEqual = 1 << 5,
+    ExistingVersionNewer = 1 << 6,
 
     // Policies
     PolicyNeverUpdate = NotInstalled,
@@ -78,14 +78,14 @@ enum Type
 };
 
 inline Type operator | (const Type &a,
-        const Type &b)
+                        const Type &b)
 {
     return static_cast<Type>(static_cast<unsigned long>(a) |
                              static_cast<unsigned long>(b));
 }
 
 inline Type operator & (const Type &a,
-        const Type &b)
+                        const Type &b)
 {
     return static_cast<Type>(static_cast<unsigned long>(a) &
                              static_cast<unsigned long>(b));
@@ -108,26 +108,26 @@ struct WidgetInstallationStruct : public WidgetInstallCallbackBase
 
     // It must be empty-constructible as a parameter of generic event
     WidgetInstallationStruct() : updateMode(WidgetUpdateMode::Zero),
-                                m_quiet(true),
-                                m_preload(false)
-    {
-    }
-
-    WidgetInstallationStruct(InstallerFinishedCallback finished,
-            InstallerProgressCallback progress,
-            void *param,
-            WidgetUpdateMode::Type mode,
-            bool quiet,
-            bool preload,
-            std::shared_ptr<PackageManager::IPkgmgrSignal> _pkgmgrInterface
-            ) :
+        m_quiet(true),
+        m_preload(false)
+    {}
+
+    WidgetInstallationStruct(
+        InstallerFinishedCallback finished,
+        InstallerProgressCallback progress,
+        void *param,
+        WidgetUpdateMode::Type mode,
+        bool quiet,
+        bool preload,
+        std::shared_ptr<PackageManager::IPkgmgrSignal>
+        _pkgmgrInterface
+        ) :
         WidgetInstallCallbackBase(finished, progress, param),
         updateMode(mode),
         m_quiet(quiet),
         m_preload(preload),
         pkgmgrInterface(_pkgmgrInterface)
-    {
-    }
+    {}
 };
 
 #endif // WRT_SRC_INSTALLER_CORE_INSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_
index 3e93084..de35936 100644 (file)
 
 WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo() :
     isExist(false)
-{
-}
+{}
 
 WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo(
-    const WrtDB::WidgetPkgName & name,
+    const WrtDB::TizenAppId & appid,
     const DPL::Optional<WidgetVersion> &version) :
-    pkgname(name),
+    tzAppid(appid),
     isExist(true),
     existingVersion(version)
-{
-}
+{}
 
 WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo(
-    const WrtDB::WidgetPkgName & name,
+    const WrtDB::TizenAppId & appid,
     const DPL::Optional<DPL::String> &version) :
-    pkgname(name),
+    tzAppid(appid),
     isExist(true)
 {
     if (!!version) {
@@ -49,8 +47,7 @@ WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo(
 
 WidgetUpdateInfo::WidgetUpdateInfo() :
     existingWidgetInfo()
-{
-}
+{}
 
 WidgetUpdateInfo::WidgetUpdateInfo(
     const DPL::Optional<WrtDB::WidgetGUID> &guid,
@@ -59,5 +56,4 @@ WidgetUpdateInfo::WidgetUpdateInfo(
     incomingGUID(guid),
     incomingVersion(version),
     existingWidgetInfo(widgetInfo)
-{
-}
+{}
index 9f10cb3..858fa25 100644 (file)
@@ -34,14 +34,14 @@ struct WidgetUpdateInfo
 {
     struct ExistingWidgetInfo
     {
-        WrtDB::WidgetPkgName pkgname;
+        WrtDB::TizenAppId tzAppid;
         bool isExist;
         DPL::Optional<WidgetVersion> existingVersion;
 
         ExistingWidgetInfo();
-        ExistingWidgetInfo(const WrtDB::WidgetPkgName & name,
+        ExistingWidgetInfo(const WrtDB::TizenAppId & tzAppid,
                            const DPL::Optional<WidgetVersion> &version);
-        ExistingWidgetInfo(const WrtDB::WidgetPkgName & name,
+        ExistingWidgetInfo(const WrtDB::TizenAppId & tzAppid,
                            const DPL::Optional<DPL::String> &version);
     };
 
index 3cb8d82..b28b9e9 100644 (file)
@@ -14,6 +14,7 @@
  *    limitations under the License.
  */
 
+#include <regex.h>
 #include <widget_uninstall/job_widget_uninstall.h>
 #include <widget_uninstall/widget_uninstall_errors.h>
 #include <widget_uninstall/task_check.h>
@@ -29,6 +30,7 @@
 using namespace WrtDB;
 
 namespace { //anonymous
+const char* REG_TIZEN_PKGID_PATTERN = "^[a-zA-Z0-9]{10}$";
 class UninstallerTaskFail :
     public DPL::TaskDecl<UninstallerTaskFail>
 {
@@ -37,9 +39,9 @@ class UninstallerTaskFail :
 
     void StepFail()
     {
-        if(m_uninstalled) {
+        if (m_uninstalled) {
             ThrowMsg(Jobs::WidgetUninstall::Exceptions::WidgetNotExist,
-                    "Widget does not exist");
+                     "Widget does not exist");
         } else {
             Throw(Jobs::WidgetUninstall::Exceptions::Base);
         }
@@ -57,8 +59,10 @@ class UninstallerTaskFail :
 
 namespace Jobs {
 namespace WidgetUninstall {
-JobWidgetUninstall::JobWidgetUninstall(const std::string & widgetPkgName,
-        const WidgetUninstallationStruct &uninstallerStruct) :
+JobWidgetUninstall::JobWidgetUninstall(
+    const std::string & tizenAppId,
+    const WidgetUninstallationStruct &
+    uninstallerStruct) :
     Job(Uninstallation),
     JobContextBase<WidgetUninstallationStruct>(uninstallerStruct)
 {
@@ -67,15 +71,31 @@ JobWidgetUninstall::JobWidgetUninstall(const std::string & widgetPkgName,
     m_context.removeFinished = false;
     m_context.uninstallStep = UninstallerContext::UNINSTALL_START;
     m_context.job = this;
-    m_context.pkgname = widgetPkgName;
     m_context.isExternalWidget = getExternalWidgetFlag();
 
     Try
     {
-        WrtDB::WidgetDAOReadOnly dao(DPL::FromUTF8String(widgetPkgName));
-        m_context.locations = WidgetLocation(m_context.pkgname);
+        regex_t regx;
+        if(regcomp(&regx, REG_TIZEN_PKGID_PATTERN, REG_NOSUB | REG_EXTENDED)!=0){
+            LogDebug("Regcomp failed");
+        }
+
+        if ((regexec(&regx, tizenAppId.c_str(),
+                        static_cast<size_t>(0), NULL, 0) == REG_NOERROR)) {
+            TizenAppId appid =
+                WrtDB::WidgetDAOReadOnly::getTzAppId(
+                        DPL::FromUTF8String(tizenAppId));
+            LogDebug("Get appid from pkgid : " << appid);
+            m_context.tzAppid = DPL::ToUTF8String(appid);
+        } else {
+            m_context.tzAppid = tizenAppId;
+        }
+        WrtDB::WidgetDAOReadOnly dao(DPL::FromUTF8String(m_context.tzAppid));
+        m_context.tzPkgid = DPL::ToUTF8String(dao.getTizenPkgId());
+        m_context.locations = WidgetLocation(m_context.tzPkgid);
+        m_context.locations->registerAppid(m_context.tzAppid);
 
-        LogInfo("Widget model exists. Pkg name: " << m_context.pkgname);
+        LogInfo("Widget model exists. App id : " << m_context.tzAppid);
 
         AddTask(new TaskSmack(m_context));
         AddTask(new TaskCheck(m_context));
@@ -89,21 +109,22 @@ JobWidgetUninstall::JobWidgetUninstall(const std::string & widgetPkgName,
         AddTask(new TaskDeleteCertificates(m_context));
 
         // send start signal of pkgmgr
-        if (getInstallerStruct().pkgmgrInterface->setPkgname(m_context.pkgname)) {
+        if (getInstallerStruct().pkgmgrInterface->setPkgname(m_context.tzAppid))
+        {
             getInstallerStruct().pkgmgrInterface->sendSignal(
-                    PKGMGR_START_KEY,
-                    PKGMGR_START_UNINSTALL);
+                PKGMGR_START_KEY,
+                PKGMGR_START_UNINSTALL);
         }
-    } Catch (WidgetDAOReadOnly::Exception::WidgetNotExist) {
+    } Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) {
         AddTask(new UninstallerTaskFail(true));
-    } Catch (WidgetDAOReadOnly::Exception::Base) {
+    } Catch(WidgetDAOReadOnly::Exception::Base) {
         AddTask(new UninstallerTaskFail(false));
     }
 }
 
 std::string JobWidgetUninstall::getRemovedTizenId() const
 {
-    return m_context.pkgname;
+    return m_context.tzAppid;
 }
 
 bool JobWidgetUninstall::getRemoveStartedFlag() const
@@ -120,19 +141,20 @@ void JobWidgetUninstall::SendProgress()
 {
     using namespace PackageManager;
     if (!getRemoveStartedFlag() ||
-        (getRemoveStartedFlag() && getRemoveFinishedFlag())) {
+        (getRemoveStartedFlag() && getRemoveFinishedFlag()))
+    {
         if (NULL != getInstallerStruct().progressCallback) {
             // send progress signal of pkgmgr
             std::ostringstream percent;
             percent << static_cast<int>(GetProgressPercent());
             getInstallerStruct().pkgmgrInterface->sendSignal(
-                        PKGMGR_PROGRESS_KEY,
-                        percent.str());
+                PKGMGR_PROGRESS_KEY,
+                percent.str());
 
             LogDebug("Call widget uninstall progressCallback");
             getInstallerStruct().progressCallback(
-                    getInstallerStruct().userParam,
-                    GetProgressPercent(), GetProgressDescription());
+                getInstallerStruct().userParam,
+                GetProgressPercent(), GetProgressDescription());
         }
     }
 }
@@ -142,12 +164,13 @@ void JobWidgetUninstall::SendFinishedSuccess()
     using namespace PackageManager;
     // send signal of pkgmgr
     getInstallerStruct().pkgmgrInterface->sendSignal(
-                PKGMGR_END_KEY,
-                PKGMGR_END_SUCCESS);
+        PKGMGR_END_KEY,
+        PKGMGR_END_SUCCESS);
 
     LogDebug("Call widget uninstall success finishedCallback");
     getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
-            getRemovedTizenId(),Exceptions::Success);
+                                          getRemovedTizenId(),
+                                          Exceptions::Success);
 }
 
 void JobWidgetUninstall::SendFinishedFailure()
@@ -158,12 +181,13 @@ void JobWidgetUninstall::SendFinishedFailure()
 
     // send signal of pkgmgr
     getInstallerStruct().pkgmgrInterface->sendSignal(
-                PKGMGR_END_KEY,
-                PKGMGR_END_FAILURE);
+        PKGMGR_END_KEY,
+        PKGMGR_END_FAILURE);
 
     LogDebug("Call widget uninstall failure finishedCallback");
     getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
-            getRemovedTizenId(), m_exceptionCaught); //TODO
+                                          getRemovedTizenId(),
+                                          m_exceptionCaught); //TODO
     LogDebug("[JobWidgetUninstall] Asynchronous failure callback status sent");
 }
 
@@ -175,14 +199,14 @@ void JobWidgetUninstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
 
 bool JobWidgetUninstall::getExternalWidgetFlag() const
 {
-
     LogDebug("Get external widget");
-    if (APP2EXT_SD_CARD == app2ext_get_app_location(m_context.pkgname.c_str())) {
+    if (APP2EXT_SD_CARD ==
+        app2ext_get_app_location(m_context.tzAppid.c_str()))
+    {
         LogDebug("This widget is in external stroage");
         return true;
     }
     return false;
 }
-
 } //namespace WidgetUninstall
 } //namespace Jobs
index 80c188c..a76444e 100644 (file)
@@ -47,10 +47,10 @@ class JobWidgetUninstall :
     /**
      * @brief Uninstaller must to know which widget to uninstall.
      *
-     * @param[in] WrtDB::WidgetPkgName widgetPkgName - widget to uninstall
+     * @param[in] WrtDB::TizenAppId tzAppId - widget to uninstall
      */
-    JobWidgetUninstall(const std::string &widgetPkgName,
-            const WidgetUninstallationStruct& uninstallerStruct);
+    JobWidgetUninstall(const std::string &tizenAppId,
+                       const WidgetUninstallationStruct& uninstallerStruct);
 
     std::string getRemovedTizenId() const;
     bool getRemoveStartedFlag() const;
index 8670ac5..1a1f62b 100644 (file)
@@ -38,18 +38,16 @@ TaskCheck::TaskCheck(UninstallerContext& context) :
 }
 
 TaskCheck::~TaskCheck()
-{
-}
+{}
 
 void TaskCheck::StepUninstallPreCheck()
 {
-    LogInfo("Uninstall check for pkgname: " << m_context.locations->getPkgname());
+    LogInfo("Uninstall check for appid: " << m_context.tzAppid);
     //check if deferred
     //TODO if widget to be updated, then remove it from Deferred list?
 
-    int ret = APP_MANAGER_ERROR_NONE;
     bool isRunning = false;
-    ret = app_manager_is_running(m_context.pkgname.c_str(), &isRunning);
+    int ret = app_manager_is_running(m_context.tzAppid.c_str(), &isRunning);
     if (APP_MANAGER_ERROR_NONE != ret) {
         LogError("Fail to get running state");
         ThrowMsg(Exceptions::PlatformAPIFailure,
@@ -64,10 +62,9 @@ void TaskCheck::StepUninstallPreCheck()
         //TODO or defer uninstall?
     }
 
-    LogInfo("Widget Can be uninstalled. Pkgname : " << m_context.locations->getPkgname());
+    LogInfo("Widget Can be uninstalled. Pkgname : " << m_context.tzAppid);
     m_context.job->UpdateProgress(UninstallerContext::UNINSTALL_PRECHECK,
                                   "Uninstall pre-checking Finished");
 }
-
 } //namespace WidgetUninstall
 } //namespace Jobs
index d3f2c93..0418ce8 100644 (file)
  * @brief   Implementation file for uninstaller task database updating
  */
 
+#include <web-provider-info.h>
 #include <widget_uninstall/task_db_update.h>
 #include <widget_uninstall/job_widget_uninstall.h>
 #include <widget_uninstall/widget_uninstall_errors.h>
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <ace_api_install.h>
-
 #include <dpl/assert.h>
 #include <ace-common/ace_api_common.h>
 
@@ -38,11 +38,11 @@ TaskDbUpdate::TaskDbUpdate(UninstallerContext& context) :
     m_context(context)
 {
     AddStep(&TaskDbUpdate::StepDbUpdate);
+    AddStep(&TaskDbUpdate::StepLiveboxDBDelete);
 }
 
 TaskDbUpdate::~TaskDbUpdate()
-{
-}
+{}
 
 void TaskDbUpdate::StepDbUpdate()
 {
@@ -50,8 +50,11 @@ void TaskDbUpdate::StepDbUpdate()
     {
         //TODO: widget handle should not be used any more
         ace_unregister_widget(static_cast<ace_widget_handle_t>(
-            WidgetDAOReadOnly::getHandle(m_context.locations->getPkgname())));
-        WidgetDAO::unregisterWidget(m_context.locations->getPkgname());
+                                  WidgetDAOReadOnly::getHandle(DPL::
+                                                                   FromUTF8String(
+                                                                   m_context.
+                                                                       tzAppid))));
+        WidgetDAO::unregisterWidget(DPL::FromUTF8String(m_context.tzAppid));
 
         LogDebug("Unregistered widget successfully!");
     }
@@ -66,5 +69,17 @@ void TaskDbUpdate::StepDbUpdate()
         UninstallerContext::UNINSTALL_DB_UPDATE,
         "Widget DB Update Finished");
 }
+
+void TaskDbUpdate::StepLiveboxDBDelete()
+{
+    int ret =
+        web_provider_info_delete_by_app_id(m_context.tzAppid.c_str());
+
+    if (ret < 0) {
+        LogDebug("failed to delete box info");
+    } else {
+        LogInfo("delete box info: " << m_context.tzAppid);
+    }
+}
 } //namespace WidgetUninstall
 } //namespace Jobs
index 93c4ff2..1f34b00 100644 (file)
@@ -46,6 +46,7 @@ class TaskDbUpdate :
 
   private:
     void StepDbUpdate();
+    void StepLiveboxDBDelete();
 
   public:
     TaskDbUpdate(UninstallerContext& context);
old mode 100755 (executable)
new mode 100644 (file)
index d656c39..cb9b7e9
@@ -38,16 +38,13 @@ TaskDeleteCertificates::TaskDeleteCertificates(
 }
 
 TaskDeleteCertificates::~TaskDeleteCertificates()
-{
-}
+{}
 
 void TaskDeleteCertificates::StepDeleteCertificates()
 {
-    pkgmgr_instcertinfo_h handle;
-
     if ((pkgmgr_installer_delete_certinfo(
-                    const_cast<char*>((
-                            m_context.pkgname).c_str()))) < 0) {
+             const_cast<char*>((m_context.tzAppid).c_str()))) < 0)
+    {
         LogError("pkgmgr_installer_delete_certinfo fail");
     }
 }
index 94efa67..b7b513b 100644 (file)
@@ -46,4 +46,5 @@ class TaskDeleteCertificates :
 } //namespace WidgetUninstall
 } //namespace Jobs
 
-#endif // WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_DELETE_CERTIFICATES_H_
+#endif
+// WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_DELETE_CERTIFICATES_H_
index 5c020a9..3717d62 100644 (file)
@@ -30,7 +30,8 @@
 
 namespace Jobs {
 namespace WidgetUninstall {
-TaskRemoveCustomHandlers::TaskRemoveCustomHandlers(UninstallerContext& context) :
+TaskRemoveCustomHandlers::TaskRemoveCustomHandlers(UninstallerContext& context)
+    :
     DPL::TaskDecl<TaskRemoveCustomHandlers>(this),
     m_context(context)
 {
@@ -40,16 +41,15 @@ TaskRemoveCustomHandlers::TaskRemoveCustomHandlers(UninstallerContext& context)
 void TaskRemoveCustomHandlers::Step()
 {
     LogDebug("Removing widget from appsvc");
-    int result = appsvc_unset_defapp(m_context.pkgname.c_str());
+    int result = appsvc_unset_defapp(m_context.tzAppid.c_str());
     LogDebug("Result: " << result);
 
     CustomHandlerDB::Interface::attachDatabaseRW();
     CustomHandlerDB::CustomHandlerDAO handlersDao(
-            DPL::FromASCIIString(m_context.pkgname));
+        DPL::FromASCIIString(m_context.tzAppid));
     handlersDao.removeWidgetProtocolHandlers();
     handlersDao.removeWidgetContentHandlers();
     CustomHandlerDB::Interface::detachDatabase();
 }
-
 } //namespace WidgetUninstall
 } //namespace Jobs
index c0812c1..48d0d92 100644 (file)
@@ -28,7 +28,7 @@ class UninstallerContext;
 
 namespace Jobs {
 namespace WidgetUninstall {
-class TaskRemoveCustomHandlers:
+class TaskRemoveCustomHandlers :
     public DPL::TaskDecl<TaskRemoveCustomHandlers>
 {
   private:
index d7c3157..ac26deb 100644 (file)
@@ -20,6 +20,7 @@
  * @brief   Implementation file for uninstaller task for removing widget files
  */
 
+#include <unistd.h>
 #include <widget_uninstall/task_remove_files.h>
 #include <widget_uninstall/job_widget_uninstall.h>
 #include <widget_uninstall/uninstaller_context.h>
@@ -37,7 +38,6 @@
 
 namespace Jobs {
 namespace WidgetUninstall {
-
 using namespace WrtDB;
 
 namespace {
@@ -61,8 +61,7 @@ TaskRemoveFiles::TaskRemoveFiles(UninstallerContext& context) :
 }
 
 TaskRemoveFiles::~TaskRemoveFiles()
-{
-}
+{}
 
 void TaskRemoveFiles::StepRemoveInstallationDirectory()
 {
@@ -71,11 +70,11 @@ void TaskRemoveFiles::StepRemoveInstallationDirectory()
     m_context.removeStarted = true;
     std::string widgetDir =
         m_context.locations->getPackageInstallationDir();
-    if(!WrtUtilRemove(widgetDir)){
+    if (!WrtUtilRemove(widgetDir)) {
         LogWarning("Removing widget installation directory failed");
     }
     std::string dataDir = m_context.locations->getUserDataRootDir();
-    if(!WrtUtilRemove(dataDir)){
+    if (!WrtUtilRemove(dataDir)) {
         LogWarning(dataDir + " is already removed");
     }
     m_context.job->UpdateProgress(
@@ -97,23 +96,23 @@ void TaskRemoveFiles::StepRemoveDesktop()
     std::ostringstream desktopFile;
 
     desktopFile << GlobalConfig::GetUserWidgetDesktopPath() << "/";
-    desktopFile << m_context.pkgname << ".desktop";
+    desktopFile << m_context.tzAppid << ".desktop";
 
     unlink(desktopFile.str().c_str());
 
     ail_appinfo_h ai = NULL;
     ail_error_e ret;
 
-    const char* package = m_context.pkgname.c_str();
+    const char* package = m_context.tzAppid.c_str();
     LogDebug("ail delete : " << package);
 
-    ret = ail_package_get_appinfo(package, &ai);
+    ret = ail_get_appinfo(package, &ai);
     if (ai) {
-        ail_package_destroy_appinfo(ai);
+        ail_destroy_appinfo(ai);
     }
 
     if (AIL_ERROR_OK == ret) {
-        if ( 0 > ail_desktop_remove(package)) {
+        if (0 > ail_desktop_remove(package)) {
             LogWarning("Failed to remove ail information : " << package);
         }
     }
@@ -126,50 +125,46 @@ void TaskRemoveFiles::StepRemoveDesktop()
 void TaskRemoveFiles::StepRemoveManifest()
 {
     std::ostringstream manifest_name;
-    manifest_name << m_context.pkgname << ".xml";
+    manifest_name << m_context.tzPkgid << ".xml";
     std::ostringstream destFile;
     destFile << "/opt/share/packages" << "/"; //TODO constant with path
     destFile << manifest_name.str();
-    int ret1 = pkgmgr_parser_parse_manifest_for_uninstallation(destFile.str().c_str(), NULL);
+    int ret1 = pkgmgr_parser_parse_manifest_for_uninstallation(
+            destFile.str().c_str(), NULL);
     int ret2 = unlink(destFile.str().c_str());
-    if(ret1 != 0)
-    {
+    if (ret1 != 0) {
         LogWarning("Manifest file failed to parse for uninstallation");
     }
-    if(ret2 != 0)
-    {
+    if (ret2 != 0) {
         LogWarning("No manifest file found: " << destFile.str());
-    }
-    else
-    {
+    } else {
         LogDebug("Manifest file removed: " << destFile.str());
     }
 }
 
 void TaskRemoveFiles::StepRemoveExternalLocations()
 {
-    WidgetDAO dao(m_context.locations->getPkgname());
+    WidgetDAO dao(DPL::FromUTF8String(m_context.tzAppid));
     LogDebug("Removing external locations:");
     WrtDB::ExternalLocationList externalPaths = dao.getWidgetExternalLocations();
     FOREACH(path, externalPaths)
     {
-        if(WrtUtilFileExists(*path))
-        {
+        if (WrtUtilFileExists(*path)) {
             LogDebug("  -> " << *path);
             int ret = remove(path->c_str());
             if (ret != 0) {
-                LogError("Failed to remove the file: " << path->c_str() << " with error: " << strerror(errno));
+                LogError(
+                    "Failed to remove the file: " << path->c_str() <<
+                    " with error: " << strerror(errno));
             }
-        }
-        else if(WrtUtilDirExists(*path))
-        {
+        } else if (WrtUtilDirExists(*path)) {
             LogDebug("  -> " << *path);
-            if(!WrtUtilRemove(*path)){
-                Throw(Jobs::WidgetUninstall::TaskRemoveFiles::Exception::RemoveFilesFailed);
+            if (!WrtUtilRemove(*path)) {
+                Throw(
+                    Jobs::WidgetUninstall::TaskRemoveFiles::Exception::
+                        RemoveFilesFailed);
             }
-        }
-        else
-        {
+        } else {
             LogWarning("  -> " << *path << "(no such a path)");
         }
     }
@@ -179,9 +174,9 @@ void TaskRemoveFiles::StepRemoveExternalLocations()
 void TaskRemoveFiles::StepRemoveVconf()
 {
     std::string key =
-        WrtDB::VconfConfig::GetVconfKeyRootPath(
-            m_context.locations->getPkgname());
-    if(vconf_unset_recursive(key.c_str())) {
+        WrtDB::VconfConfig::GetVconfKeyRootPath(DPL::FromUTF8String(m_context.
+                                                                        tzAppid));
+    if (vconf_unset_recursive(key.c_str())) {
         LogError("Fail to unset vconf file");
     } else {
         LogDebug("vconf file is removed");
@@ -191,15 +186,16 @@ void TaskRemoveFiles::StepRemoveVconf()
 void TaskRemoveFiles::StepRemoveExternalWidget()
 {
     Try {
-        WidgetInstallToExtSingleton::Instance().initialize(m_context.pkgname);
+        WidgetInstallToExtSingleton::Instance().initialize(m_context.tzPkgid);
         WidgetInstallToExtSingleton::Instance().uninstallation();
         WidgetInstallToExtSingleton::Instance().deinitialize();
     }
-    Catch (WidgetInstallToExt::Exception::ErrorInstallToExt)
+    Catch(WidgetInstallToExt::Exception::ErrorInstallToExt)
     {
-        Throw(Jobs::WidgetUninstall::TaskRemoveFiles::Exception::RemoveFilesFailed);
+        Throw(
+            Jobs::WidgetUninstall::TaskRemoveFiles::Exception::
+                RemoveFilesFailed);
     }
 }
-
 } //namespace WidgetUninstall
 } //namespace Jobs
index 23d2df6..7074dd6 100644 (file)
@@ -39,19 +39,19 @@ TaskSmack::TaskSmack(UninstallerContext& context) :
 
 void TaskSmack::Step()
 {
-    LogInfo("------------------------> SMACK: Jobs::WidgetUninstall::TaskSmack::Step()");
+    LogInfo(
+        "------------------------> SMACK: Jobs::WidgetUninstall::TaskSmack::Step()");
 #ifdef WRT_SMACK_ENABLED
     try {
-      WrtDB::WidgetDAOReadOnly dao(m_context.locations->getPkgname());
-      WidgetPkgName pkgName = dao.getPkgName();
-      const char *devCap = "";
-      int result = handle_access_control_conf_forWAC(
-                       DPL::ToUTF8String(pkgName).c_str(),
-                       NULL,
-                       OPERATION_UNINSTALL);
-      Assert(result==PC_OPERATION_SUCCESS && "access control setup failed");
+        WrtDB::WidgetDAOReadOnly dao(m_context.widgetConfig.tzAppid);
+        TizenAppId tzAppid = dao.getTizenAppId();
+        int result = handle_access_control_conf_forWAC(
+                DPL::ToUTF8String(tzAppid).c_str(),
+                NULL,
+                OPERATION_UNINSTALL);
+        Assert(result == PC_OPERATION_SUCCESS && "access control setup failed");
     } catch (WrtDB::WidgetDAOReadOnly::Exception) {
-      Assert(false && "can't access widget data");
+        Assert(false && "can't access widget data");
     }
 
     m_context.job->UpdateProgress(
@@ -59,6 +59,5 @@ void TaskSmack::Step()
         "Widget SMACK Enabled");
 #endif
 }
-
 } //namespace WidgetUninstall
 } //namespace Jobs
index 35a0355..f9fcda4 100644 (file)
@@ -28,7 +28,7 @@ class UninstallerContext;
 
 namespace Jobs {
 namespace WidgetUninstall {
-class TaskSmack:
+class TaskSmack :
     public DPL::TaskDecl<TaskSmack>
 {
   private:
index 187d958..572b130 100644 (file)
@@ -45,15 +45,14 @@ TaskUninstallOspsvc::TaskUninstallOspsvc(UninstallerContext& context) :
 }
 
 TaskUninstallOspsvc::~TaskUninstallOspsvc()
-{
-}
+{}
 
 void TaskUninstallOspsvc::StepUninstallOspsvc()
 {
     LogInfo("Step : Uninstall Osp service ");
 
     std::ostringstream commStr;
-    commStr << OSP_INSTALL_STR << BashUtils::escape_arg(m_context.pkgname);
+    commStr << OSP_INSTALL_STR << BashUtils::escape_arg(m_context.tzPkgid);
     LogDebug("osp uninstall command : " << commStr.str());
 
     char readBuf[MAX_BUF_SIZE];
@@ -61,24 +60,33 @@ void TaskUninstallOspsvc::StepUninstallOspsvc()
     fd = popen(commStr.str().c_str(), "r");
     if (NULL == fd) {
         LogError("Failed to uninstalltion osp service");
-        ThrowMsg(Exceptions::UninstallOspSvcFailed, "Error occurs during\
+        ThrowMsg(Exceptions::UninstallOspSvcFailed,
+                 "Error occurs during\
+                uninstall osp service");
+    }
+
+    if(fgets(readBuf, MAX_BUF_SIZE, fd) == NULL)
+    {
+        LogError("Failed to uninstalltion osp service\
+                        Inability of reading file.");
+        ThrowMsg(Exceptions::UninstallOspSvcFailed,
+                "Error occurs during\
                 uninstall osp service");
     }
-    fgets( readBuf, MAX_BUF_SIZE, fd);
     LogDebug("return value : " << readBuf);
 
     int result = atoi(readBuf);
     if (0 != result) {
-        ThrowMsg(Exceptions::UninstallOspSvcFailed, "Error occurs during\
+        ThrowMsg(Exceptions::UninstallOspSvcFailed,
+                 "Error occurs during\
                 install osp service");
     }
 
     pclose(fd);
-    
-    LogInfo("Widget Can be uninstalled. Pkgname : " << m_context.pkgname);
+
+    LogInfo("Widget Can be uninstalled. Pkgname : " << m_context.tzPkgid);
     m_context.job->UpdateProgress(UninstallerContext::UNINSTALL_REMOVE_OSPSVC,
                                   "Uninstall OSP service finished");
 }
-
 } //namespace WidgetUninstall
 } //namespace Jobs
index caedcb7..67f15eb 100644 (file)
@@ -59,7 +59,8 @@ struct UninstallerContext
 
     UninstallStep uninstallStep;       ///< current step of installation
     Jobs::WidgetUninstall::JobWidgetUninstall *job;
-    std::string pkgname;
+    std::string tzAppid;
+    std::string tzPkgid;
     bool isExternalWidget;
 };
 
index f08d33d..81de95d 100644 (file)
@@ -47,7 +47,6 @@ DECLARE_JOB_EXCEPTION(Base, AlreadyUninstalling, ErrorAlreadyUninstalling)
 DECLARE_JOB_EXCEPTION(Base, WidgetNotExist, ErrorWidgetDoesNotExist)
 DECLARE_JOB_EXCEPTION(Base, UninstallOspSvcFailed, ErrorUninstallOspSvcFailed)
 DECLARE_JOB_EXCEPTION(Base, PlatformAPIFailure, ErrorPlatformAPI)
-
 } //namespace
 } //namespace
 } //namespace
index ce2d4cc..83714a9 100644 (file)
@@ -48,24 +48,23 @@ typedef Jobs::JobCallbacksBase<UninstallerFinishedCallback,
                                UninstallerProgressCallback>
 WidgetUninstallCallbackBase;
 
-
 struct WidgetUninstallationStruct : public WidgetUninstallCallbackBase
 {
     std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrInterface;
 
     // It must be empty-constructible as a parameter of generic event
     WidgetUninstallationStruct()
-    {
-    }
+    {}
 
-    WidgetUninstallationStruct(UninstallerFinishedCallback finished,
-            UninstallerProgressCallback progress,
-            void *param,
-            std::shared_ptr<PackageManager::IPkgmgrSignal> _pkgmgrInterface
-            ) :
+    WidgetUninstallationStruct(
+        UninstallerFinishedCallback finished,
+        UninstallerProgressCallback progress,
+        void *param,
+        std::shared_ptr<PackageManager::IPkgmgrSignal>
+        _pkgmgrInterface
+        ) :
         WidgetUninstallCallbackBase(finished, progress, param),
         pkgmgrInterface(_pkgmgrInterface)
-    {
-    }
+    {}
 };
 #endif // WRT_SRC_INSTALLER_CORE_UNINSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_
index 8995d33..5e65517 100644 (file)
 
 IMPLEMENT_SINGLETON(Logic::InstallerController)
 
-namespace Logic
-{
-
+namespace Logic {
 InstallerController::InstallerController()
-{
-}
+{}
 
 void InstallerController::OnEventReceived(
-        const InstallerControllerEvents::InstallWidgetEvent &event)
+    const InstallerControllerEvents::InstallWidgetEvent &event)
 {
     std::string fileName = event.GetArg0();
     WidgetInstallationStruct installerStruct = event.GetArg1();
@@ -35,7 +32,7 @@ void InstallerController::OnEventReceived(
 }
 
 void InstallerController::OnEventReceived(
-        const InstallerControllerEvents::InstallPluginEvent &event)
+    const InstallerControllerEvents::InstallPluginEvent &event)
 {
     std::string dirName = event.GetArg0();
     PluginInstallerStruct installerStruct = event.GetArg1();
@@ -43,7 +40,7 @@ void InstallerController::OnEventReceived(
 }
 
 void InstallerController::OnEventReceived(
-        const InstallerControllerEvents::UninstallWidgetEvent &event)
+    const InstallerControllerEvents::UninstallWidgetEvent &event)
 {
     std::string widgetPkgName = event.GetArg0();
     WidgetUninstallationStruct uninstallerStruct = event.GetArg1();
@@ -54,13 +51,13 @@ Eina_Bool InstallerController::AddNextStep(void *data)
 {
     Jobs::Job* model = static_cast<Jobs::Job *>(data);
     CONTROLLER_POST_EVENT(InstallerController,
-            InstallerControllerEvents::NextStepEvent(model));
+                          InstallerControllerEvents::NextStepEvent(model));
 
     return ECORE_CALLBACK_CANCEL;
 }
 
 void InstallerController::OnEventReceived(
-        const InstallerControllerEvents::NextStepEvent &event)
+    const InstallerControllerEvents::NextStepEvent &event)
 {
     Jobs::Job* model = event.GetArg0();
     Assert(model != NULL);
@@ -71,24 +68,23 @@ void InstallerController::OnEventReceived(
 }
 
 void InstallerController::OnEventReceived(
-        const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent &
-        event)
+    const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent &
+    event)
 {
     (void)event;
     m_installerLogic.InstallDeferredWidgetPackages();
 }
 
 void InstallerController::OnEventReceived(
-        const InstallerControllerEvents::InitializeEvent & /*event*/)
+    const InstallerControllerEvents::InitializeEvent & /*event*/)
 {
     m_installerLogic.Initialize();
 }
 
 void InstallerController::OnEventReceived(
-        const InstallerControllerEvents::TerminateEvent & /*event*/)
+    const InstallerControllerEvents::TerminateEvent & /*event*/)
 {
     m_installerLogic.Terminate();
 }
-
 } //Logic
 
index 55c68fe..ca4cc6b 100644 (file)
@@ -38,8 +38,8 @@ namespace InstallerControllerEvents {
  * This event holds std::string witch should be path to widget package
  */
 DECLARE_GENERIC_EVENT_2(InstallWidgetEvent,
-                        std::string,
-                        WidgetInstallationStruct)                                  // (zipFileName, installerStruct)
+                        std::string,              // zipFileName
+                        WidgetInstallationStruct) // installerStruct
 
 /**
  * @brief Event for iniciating plugin instalation process.
@@ -67,12 +67,9 @@ DECLARE_GENERIC_EVENT_0(InstallDeferredWidgetPackagesEvent)
 
 DECLARE_GENERIC_EVENT_0(InitializeEvent)
 DECLARE_GENERIC_EVENT_0(TerminateEvent)
-
 } // namespace InstallerEvents
 
-
 namespace Logic {
-
 /**
  * @brief Controls Widget installation
  *
@@ -96,40 +93,41 @@ typedef DPL::TypeListDecl<
     InstallerControllerEvents::TerminateEvent>::Type
 InstallerControllerEventsSet;
 
-class InstallerController : public DPL::Event::Controller<InstallerControllerEventsSet>
+class InstallerController : public DPL::Event::Controller<
+        InstallerControllerEventsSet>
 {
   protected:
     /**
      * @brief Executed on InstallWidgetEvent received.
      */
     virtual void OnEventReceived(
-            const InstallerControllerEvents::InstallWidgetEvent &event);
+        const InstallerControllerEvents::InstallWidgetEvent &event);
 
     /**
      * @brief Executed on InstallPluginEvent received.
      */
     virtual void OnEventReceived(
-            const InstallerControllerEvents::InstallPluginEvent &event);
+        const InstallerControllerEvents::InstallPluginEvent &event);
 
     /**
      * @brief Executed on UninstallWidgetEvent received.
      */
     virtual void OnEventReceived(
-            const InstallerControllerEvents::UninstallWidgetEvent &event);
+        const InstallerControllerEvents::UninstallWidgetEvent &event);
     /**
      * @brief Executed on NextStepEvent received.
      */
     virtual void OnEventReceived(
-            const InstallerControllerEvents::NextStepEvent &event);
+        const InstallerControllerEvents::NextStepEvent &event);
 
     virtual void OnEventReceived(
-            const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent
-            &event);
+        const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent
+        &event);
 
     virtual void OnEventReceived(
-            const InstallerControllerEvents::InitializeEvent &event);
+        const InstallerControllerEvents::InitializeEvent &event);
     virtual void OnEventReceived(
-            const InstallerControllerEvents::TerminateEvent &event);
+        const InstallerControllerEvents::TerminateEvent &event);
 
   private:
     // Embedded logic
@@ -143,7 +141,6 @@ class InstallerController : public DPL::Event::Controller<InstallerControllerEve
 };
 
 typedef DPL::Singleton<InstallerController> InstallerControllerSingleton;
-
 }
 
 #endif // INSTALLER_CONTROLLER_H
index 2cd734e..f4b202e 100644 (file)
 using namespace WrtDB;
 
 namespace Logic {
-
 InstallerLogic::InstallerLogic() :
     m_NextHandle(0)
-{
-}
+{}
 
 InstallerLogic::~InstallerLogic()
 {
@@ -72,8 +70,10 @@ Jobs::JobHandle InstallerLogic::AddAndStartJob(Jobs::Job *job)
 
 //InstallWidget, UninstallWidget InstallPlugin method are almost the same
 // But each Job has different constructor, so creating new Job is specific
-Jobs::JobHandle InstallerLogic::InstallWidget(const std::string & widgetPath,
-        const WidgetInstallationStruct &installerStruct)
+Jobs::JobHandle InstallerLogic::InstallWidget(
+    const std::string & widgetPath,
+    const WidgetInstallationStruct &
+    installerStruct)
 {
     LogDebug("New Widget Installation:");
 
@@ -83,8 +83,10 @@ Jobs::JobHandle InstallerLogic::InstallWidget(const std::string & widgetPath,
     return AddAndStartJob(job);
 }
 
-Jobs::JobHandle InstallerLogic::UninstallWidget(const std::string & widgetPkgName,
-        const WidgetUninstallationStruct &uninstallerStruct)
+Jobs::JobHandle InstallerLogic::UninstallWidget(
+    const std::string & widgetPkgName,
+    const
+    WidgetUninstallationStruct &uninstallerStruct)
 {
     LogDebug("New Widget Uninstallation");
 
@@ -95,8 +97,10 @@ Jobs::JobHandle InstallerLogic::UninstallWidget(const std::string & widgetPkgNam
     return AddAndStartJob(job);
 }
 
-Jobs::JobHandle InstallerLogic::InstallPlugin(std::string const & pluginPath,
-        const PluginInstallerStruct &installerStruct)
+Jobs::JobHandle InstallerLogic::InstallPlugin(
+    std::string const & pluginPath,
+    const PluginInstallerStruct &
+    installerStruct)
 {
     LogDebug("New Plugin Installation");
 
@@ -148,8 +152,7 @@ bool InstallerLogic::NextStep(Jobs::Job *job)
         delete job;
 
         return false;
-    }
-    catch (Jobs::JobExceptionBase &exc) {
+    } catch (Jobs::JobExceptionBase &exc) {
         //start revert job
         LogInfo("Exception occured: " << exc.getParam() <<
                 ". Reverting job...");
@@ -176,7 +179,8 @@ void InstallerLogic::InstallDeferredWidgetPackages()
     LogWarning("Not implemented");
     //    LogInfo("Installing deferred widget packages...");
     //
-    //    WidgetPackageList packages = GlobalDAO::GetDefferedWidgetPackageInstallationList();
+    //    WidgetPackageList packages =
+    // GlobalDAO::GetDefferedWidgetPackageInstallationList();
     //
     //    LogInfo(packages.size() << " widget package(s) to install");
     //
@@ -206,8 +210,10 @@ void InstallerLogic::InstallSingleDeferredPackage()
     //
     //    // Post installation
     //    CONTROLLER_POST_EVENT(
-    //        InstallerController, InstallerControllerEvents::InstallWidgetEvent(
-    //            DPL::ToUTF8String(widgetPackage).c_str(), WidgetInstallationStruct(
+    //        InstallerController,
+    // InstallerControllerEvents::InstallWidgetEvent(
+    //            DPL::ToUTF8String(widgetPackage).c_str(),
+    // WidgetInstallationStruct(
     //                    &DummyInstallCallback, &DummyProgressCallback, NULL,
     //                        WidgetUpdateMode::PolicyWac)));
 }
@@ -258,7 +264,8 @@ bool InstallerLogic::resolvePluginDependencies(PluginHandle handle)
             PluginDAO::getPluginHandleForImplementedObject(*requiredObject);
 
         if (depHandle ==
-            Jobs::PluginInstall::JobPluginInstall::INVALID_HANDLE) {
+            Jobs::PluginInstall::JobPluginInstall::INVALID_HANDLE)
+        {
             LogError("Library implementing: " <<
                      *requiredObject << " NOT FOUND");
 
@@ -274,6 +281,5 @@ bool InstallerLogic::resolvePluginDependencies(PluginHandle handle)
 
     return true;
 }
-
 }
 
index 479313e..5072e39 100644 (file)
@@ -25,7 +25,6 @@
 #include <job.h>
 
 namespace Logic {
-
 class InstallerLogic
 {
     typedef std::map<Jobs::JobHandle, Jobs::Job*> JobsContainer;
@@ -44,6 +43,7 @@ class InstallerLogic
         return m_NextHandle++;
     }
     Jobs::JobHandle AddAndStartJob(Jobs::Job *job);
+
   public:
     virtual ~InstallerLogic();
 
@@ -51,14 +51,18 @@ class InstallerLogic
 
     void Terminate();
 
-    Jobs::JobHandle InstallWidget(const std::string & widgetPath,
-            const WidgetInstallationStruct &installerStruct);
+    Jobs::JobHandle InstallWidget(
+        const std::string & widgetPath,
+        const WidgetInstallationStruct &
+        installerStruct);
 
-    Jobs::JobHandle UninstallWidget(const std::string & widgetPkgName,
-            const WidgetUninstallationStruct &uninstallerStruct);
+    Jobs::JobHandle UninstallWidget(
+        const std::string & widgetPkgName,
+        const WidgetUninstallationStruct &
+        uninstallerStruct);
 
     Jobs::JobHandle InstallPlugin(std::string const & pluginPath,
-            const PluginInstallerStruct &installerStruct);
+                                  const PluginInstallerStruct &installerStruct);
 
     bool NextStep(Jobs::Job* installModel);
 
@@ -74,7 +78,6 @@ class InstallerLogic
 
     friend class InstallerController;
 };
-
 }
 
 #endif // INSTALLER_LOGIC_H
index ee71e76..de4b99c 100644 (file)
 
 namespace Jobs {
 namespace WidgetInstall {
-
-FeatureLogic::FeatureLogic(const WrtDB::WidgetPkgName & pkgname)
-  : m_rejected(false)
+FeatureLogic::FeatureLogic(const WrtDB::TizenAppId & tzAppid) :
+    m_rejected(false)
 {
-    WrtDB::WidgetDAOReadOnly widgetDao(pkgname);
+    WrtDB::WidgetDAOReadOnly widgetDao(tzAppid);
     WidgetFeatureSet featureSet = widgetDao.getFeaturesList();
     FOREACH(it, featureSet) {
         LogInfo("Feature name : " << it->name);
         WrtDB::DeviceCapabilitySet dcs =
-          WrtDB::GlobalDAOReadOnly::GetDeviceCapability(it->name);
-        FOREACH (devCap, dcs) {
+            WrtDB::GlobalDAOReadOnly::GetDeviceCapability(it->name);
+        FOREACH(devCap, dcs) {
             LogInfo("--- dev cap  : " << *devCap);
         }
         Feature feature(*it, dcs);
@@ -60,7 +59,9 @@ bool FeatureLogic::isDone() const
 bool FeatureLogic::next()
 {
     while (!isDone()) {
-        if (m_currentFeature->currentCap != m_currentFeature->devCapSet.end()) {
+        if (m_currentFeature->currentCap !=
+            m_currentFeature->devCapSet.end())
+        {
             m_currentFeature->currentCap++;
         } else {
             ++m_currentFeature;
@@ -73,7 +74,6 @@ bool FeatureLogic::next()
     return false;
 }
 
-
 void FeatureLogic::setAceResponse(bool allowed)
 {
     Assert(isProcessable() && "Wrong usage");
@@ -102,7 +102,6 @@ bool FeatureLogic::isProcessable() const
 
     return true;
 }
-
 } // namespace WidgetInstall
 } // namespace Jobs
 
index 1c3ed23..03bb51a 100644 (file)
 
 namespace Jobs {
 namespace WidgetInstall {
-
-class FeatureLogic : DPL::Noncopyable {
+class FeatureLogic : DPL::Noncopyable
+{
   public:
 
-    FeatureLogic(const WrtDB::WidgetPkgName & pkgname);
+    FeatureLogic(const WrtDB::TizenAppId & tzAppid);
 
     bool isDone() const;
 
@@ -52,9 +52,10 @@ class FeatureLogic : DPL::Noncopyable {
         WrtDB::DeviceCapabilitySet devCapSet;
         WrtDB::DeviceCapabilitySet::const_iterator currentCap;
 
-        Feature(const WidgetFeature &wf, const WrtDB::DeviceCapabilitySet &set)
-          : WidgetFeature(wf)
-          , devCapSet(set)
+        Feature(const WidgetFeature &wf,
+                const WrtDB::DeviceCapabilitySet &set) :
+            WidgetFeature(wf)
+            , devCapSet(set)
         {
             currentCap = devCapSet.begin();
         }
@@ -65,8 +66,10 @@ class FeatureLogic : DPL::Noncopyable {
             currentCap = devCapSet.find(*second.currentCap);
             rejected = second.rejected;
         }
+
       private:
-        void operator=(const Feature &second) {
+        void operator=(const Feature &second)
+        {
             name = second.name;
             devCapSet = second.devCapSet;
             required = second.required;
@@ -80,8 +83,14 @@ class FeatureLogic : DPL::Noncopyable {
     typedef std::list<Feature> FeatureList;
     typedef FeatureList::const_iterator FeatureIterator;
 
-    FeatureIterator resultBegin() { return m_featureList.begin(); }
-    FeatureIterator resultEnd() { return m_featureList.end(); }
+    FeatureIterator resultBegin()
+    {
+        return m_featureList.begin();
+    }
+    FeatureIterator resultEnd()
+    {
+        return m_featureList.end();
+    }
 
   private:
     bool isProcessable() const;
@@ -92,7 +101,6 @@ class FeatureLogic : DPL::Noncopyable {
 };
 
 typedef std::shared_ptr<FeatureLogic> FeatureLogicPtr;
-
 } // namespace WidgetInstall
 } // namespace Jobs
 
index 61aa5cc..852ab9a 100644 (file)
 IMPLEMENT_SINGLETON(LibxmlUtils)
 
 LibxmlUtils::LibxmlUtils() : isInitialized(false)
-{
-}
+{}
 
 LibxmlUtils::~LibxmlUtils()
 {
-    if(isInitialized)
-    {
+    if (isInitialized) {
         LogDebug("Libxml - cleaning");
         // Cleanup function for the XML library.
         xmlCleanupParser();
@@ -42,13 +40,11 @@ LibxmlUtils::~LibxmlUtils()
 
 void LibxmlUtils::init()
 {
-    if(!isInitialized)
-    {
+    if (!isInitialized) {
         LIBXML_TEST_VERSION
-        isInitialized = true;
+            isInitialized = true;
         LogDebug("Libxml have been initialized");
     }
     LogDebug("Libxml already initialized");
 }
 
-
index d662bc7..5354bda 100644 (file)
@@ -39,7 +39,7 @@
  */
 class LibxmlUtils
 {
-public:
+  public:
     DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
     DECLARE_EXCEPTION_TYPE(Base, Libxml2Error)
 
@@ -47,7 +47,8 @@ public:
     ~LibxmlUtils();
 
     void init();
-private:
+
+  private:
     bool isInitialized;
 
     friend class DPL::Singleton<LibxmlUtils>;
index f6af03f..3fa621e 100644 (file)
@@ -61,7 +61,7 @@ void WacWidgetId::parse(const char *url)
     LogDebug("Widget id to parse: " << url);
 
     std::unique_ptr<iri_struct, std::function<void(iri_struct*)> >
-            iri(iri_parse(url), iri_destroy);
+    iri(iri_parse(url), iri_destroy);
 
     if (!iri.get()) {
         LogError("Error in parsing widget id.");
@@ -78,7 +78,8 @@ void WacWidgetId::parse(const char *url)
     }
 
     // should we support HTTP and HTTPS? wac says nothing
-    // std::transform(m_scheme.begin(), m_scheme.end(), m_scheme.begin(), tolower);
+    // std::transform(m_scheme.begin(), m_scheme.end(), m_scheme.begin(),
+    // tolower);
 
     // We only match "http" and "https" schemas
     if ((scheme != SCHEME_HTTP) && (scheme != SCHEME_HTTPS)) {
index 3751d60..4f794b6 100644 (file)
@@ -28,12 +28,10 @@ IMPLEMENT_SAFE_SINGLETON(WidgetInstallToExt)
 WidgetInstallToExt::WidgetInstallToExt() :
     m_handle(NULL),
     m_appId("")
-{
-}
+{}
 
 WidgetInstallToExt::~WidgetInstallToExt()
-{
-}
+{}
 
 void WidgetInstallToExt::initialize(std::string appId)
 {
@@ -50,8 +48,9 @@ void WidgetInstallToExt::deinitialize()
 {
     LogDebug("WidgetInstallToExt::deinitialize()");
     if (NULL != m_handle) {
-        if ( 0 < app2ext_deinit(m_handle)) {
-            ThrowMsg(Exception::ErrorInstallToExt, "app2ext deinitialize \
+        if (0 < app2ext_deinit(m_handle)) {
+            ThrowMsg(Exception::ErrorInstallToExt,
+                     "app2ext deinitialize \
                     failed");
         }
     }
@@ -64,7 +63,7 @@ void WidgetInstallToExt::preInstallation(GList *dirList, int dSize)
 
     int ret = m_handle->interface.pre_install(m_appId.c_str(), dirList, dSize);
 
-    if (APP2EXT_SUCCESS == ret ) {
+    if (APP2EXT_SUCCESS == ret) {
         LogDebug("App2Ext pre install success");
     } else {
         postInstallation(false);
@@ -79,10 +78,10 @@ void WidgetInstallToExt::postInstallation(bool status)
 
     if (status) {
         m_handle->interface.post_install(m_appId.c_str(),
-                APP2EXT_STATUS_SUCCESS);
+                                         APP2EXT_STATUS_SUCCESS);
     } else {
         m_handle->interface.post_install(m_appId.c_str(),
-                APP2EXT_STATUS_FAILED);
+                                         APP2EXT_STATUS_FAILED);
     }
 }
 
@@ -92,7 +91,7 @@ void WidgetInstallToExt::preUpgrade(GList *dirList, int dSize)
     Assert(m_handle);
 
     int ret = m_handle->interface.pre_upgrade(m_appId.c_str(), dirList, dSize);
-    if (APP2EXT_SUCCESS == ret ) {
+    if (APP2EXT_SUCCESS == ret) {
         LogDebug("App2Ext pre-upgrade success");
     } else {
         postUpgrade(false);
@@ -107,10 +106,10 @@ void WidgetInstallToExt::postUpgrade(bool status)
 
     if (status) {
         m_handle->interface.post_upgrade(m_appId.c_str(),
-                APP2EXT_STATUS_SUCCESS);
+                                         APP2EXT_STATUS_SUCCESS);
     } else {
         m_handle->interface.post_upgrade(m_appId.c_str(),
-                APP2EXT_STATUS_FAILED);
+                                         APP2EXT_STATUS_FAILED);
     }
 }
 
@@ -121,9 +120,10 @@ void WidgetInstallToExt::uninstallation()
     Assert(m_handle);
 
     int ret = m_handle->interface.pre_uninstall(m_appId.c_str());
-    if (APP2EXT_SUCCESS == ret ) {
+    if (APP2EXT_SUCCESS == ret) {
         if (APP2EXT_SUCCESS ==
-                m_handle->interface.post_uninstall(m_appId.c_str())) {
+            m_handle->interface.post_uninstall(m_appId.c_str()))
+        {
             LogDebug("App2Ext pre-uninstall success");
         } else {
             ThrowMsg(Exception::ErrorInstallToExt, "post-uninstall failed");
index 9f71906..732f70a 100644 (file)
 #include <dpl/string.h>
 #include <app2ext_interface.h>
 
-
 class WidgetInstallToExt
 {
-public:
+  public:
     class Exception
     {
       public:
@@ -44,7 +43,7 @@ public:
     void postUpgrade(bool status);
     void uninstallation();
 
-private:
+  private:
     app2ext_handle *m_handle;
     std::string m_appId;
 
index 35a8026..d6fff67 100644 (file)
 
 #include <widget_install/task_commons.h>
 
+WidgetLocation::DirectoryDeletor::DirectoryDeletor() :
+    m_dirpath(Jobs::WidgetInstall::createTempPath())
+{}
 
-WidgetLocation::DirectoryDeletor::DirectoryDeletor()
-{
-    m_dirpath = Jobs::WidgetInstall::createTempPath();
-}
-
-WidgetLocation::DirectoryDeletor::DirectoryDeletor(std::string tempPath)
-{
-    m_dirpath = tempPath;
-}
+WidgetLocation::DirectoryDeletor::DirectoryDeletor(std::string tempPath) :
+        m_dirpath(tempPath)
+{}
 
 WidgetLocation::DirectoryDeletor::~DirectoryDeletor()
 {
-    LogDebug("Removing widget installation temporary directory: " << m_dirpath.c_str());
-    if(!WrtUtilRemove(m_dirpath)){
+    LogDebug(
+        "Removing widget installation temporary directory: " << m_dirpath.c_str());
+    if (!WrtUtilRemove(m_dirpath)) {
         LogError("Fail at removing directory: " << m_dirpath.c_str());
     }
 }
@@ -53,26 +51,23 @@ std::string WidgetLocation::DirectoryDeletor::getTempPath() const
 }
 
 WidgetLocation::WidgetLocation()
-{
-}
+{}
 
 WidgetLocation::WidgetLocation(const std::string & widgetname) :
-                                        m_pkgname(widgetname)
-{
-}
+    m_pkgid(widgetname)
+{}
 
 WidgetLocation::~WidgetLocation()
-{
-}
+{}
 
 WidgetLocation::WidgetLocation(const std::string & widgetname,
                                std::string sourcePath,
                                WrtDB::PackagingType t,
-                               InstallLocationType locationType):
-                                    m_pkgname(widgetname),
-                                    m_widgetSource(sourcePath),
-                                    m_type(t),
-                                    m_temp(new WidgetLocation::DirectoryDeletor())
+                               InstallLocationType locationType) :
+    m_pkgid(widgetname),
+    m_widgetSource(sourcePath),
+    m_type(t),
+    m_temp(new WidgetLocation::DirectoryDeletor())
 {
     if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
         m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
@@ -85,12 +80,12 @@ WidgetLocation::WidgetLocation(const std::string & widgetname,
                                std::string sourcePath,
                                std::string dirPath,
                                WrtDB::PackagingType t,
-                               InstallLocationType locationType):
-                                    m_pkgname(widgetname),
-                                    m_widgetSource(sourcePath),
-                                    m_type(t),
-                                    m_temp(new
-                                            WidgetLocation::DirectoryDeletor(dirPath))
+                               InstallLocationType locationType) :
+    m_pkgid(widgetname),
+    m_widgetSource(sourcePath),
+    m_type(t),
+    m_temp(new
+           WidgetLocation::DirectoryDeletor(dirPath))
 {
     if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
         m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
@@ -107,24 +102,24 @@ std::string WidgetLocation::getInstallationDir() const
 
 std::string WidgetLocation::getPackageInstallationDir() const
 {
-    return m_installedPath + "/" + m_pkgname;
+    return m_installedPath + "/" + m_pkgid;
 }
 
 std::string WidgetLocation::getSourceDir() const
 {
     return m_installedPath + "/"
-            + m_pkgname + WrtDB::GlobalConfig::GetWidgetSrcPath();
+           + m_pkgid + WrtDB::GlobalConfig::GetWidgetSrcPath();
 }
 
 std::string WidgetLocation::getBinaryDir() const
 {
     return m_installedPath + "/"
-            + m_pkgname + WrtDB::GlobalConfig::GetUserWidgetExecPath();
+           + m_pkgid + WrtDB::GlobalConfig::GetUserWidgetExecPath();
 }
 
 std::string WidgetLocation::getExecFile() const
 {
-    return getBinaryDir() + "/" + m_pkgname;
+    return getBinaryDir() + "/" + m_appid;
 }
 
 std::string WidgetLocation::getBackupDir() const
@@ -144,25 +139,19 @@ std::string WidgetLocation::getBackupBinaryDir() const
 
 std::string WidgetLocation::getBackupExecFile() const
 {
-    return getBackupBinaryDir() + "/" + m_pkgname;
+    return getBackupBinaryDir() + "/" + m_appid;
 }
 
 std::string WidgetLocation::getUserDataRootDir() const
 {
     return std::string(WrtDB::GlobalConfig::GetWidgetUserDataPath()) +
-        "/" + m_pkgname;
+           "/" + m_pkgid;
 }
 
 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();
+           WrtDB::GlobalConfig::GetWidgetPrivateStoragePath();
 }
 
 std::string WidgetLocation::getTemporaryPackageDir() const
@@ -173,42 +162,34 @@ std::string WidgetLocation::getTemporaryPackageDir() const
 std::string WidgetLocation::getTemporaryRootDir() const
 {
     if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) {
-        return getWidgetSource();
+        return getWidgetSource() + WrtDB::GlobalConfig::GetWidgetSrcPath();
     }
-    if(m_type == WrtDB::PKG_TYPE_HYBRID_WEB_APP)
-    {
+    if (m_type == WrtDB::PKG_TYPE_HYBRID_WEB_APP) {
         return getTemporaryPackageDir() + WrtDB::GlobalConfig::GetWidgetSrcPath();
-    }
-    else
-    {
+    } else {
         return getTemporaryPackageDir();
     }
 }
 
 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("\\/");
-        if (index != std::string::npos)
-        {
+        std::size_t index = m_widgetSource.find_last_of("\\/");
+        if (index != std::string::npos) {
             path = m_widgetSource.substr(0, index);
         }
         return path;
-    }
-    else if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
-    {
+    } else if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) {
         return getWidgetSource() + WrtDB::GlobalConfig::GetWidgetSrcPath();
-    } else
-    {
+    } else {
         return getTemporaryRootDir();
     }
 }
 
-DPL::String WidgetLocation::getPkgname() const
+DPL::String WidgetLocation::getPkgId() const
 {
-    return DPL::FromUTF8String(m_pkgname);
+    return DPL::FromUTF8String(m_pkgid);
 }
 
 std::string WidgetLocation::getInstalledIconPath() const
@@ -235,3 +216,8 @@ WrtDB::ExternalLocationList WidgetLocation::listExternalLocations() const
 {
     return m_externals;
 }
+
+void WidgetLocation::registerAppid(const std::string & appid)
+{
+    m_appid = appid;
+}
index e04c3dd..ca98aa6 100644 (file)
  *                               \___ [widgets_archive_content]
  *
  * 1) Normal Widget
- *  Developer provides content of res/wgt directory (package contains that directory as root).
+ *  Developer provides content of res/wgt directory (package contains that
+ * directory as root).
  *
  * 2) For OSP Service Hybrid App is actually a bit different:
  *  Root is OSP Service directory, WebApp content is located in [root]/res/wgt
  *
  * Temporary directory is directory when widget is placed at the begining
- * of installation process. After parsing process of config.xml, destination directory is created.
+ * of installation process. After parsing process of config.xml, destination
+ * directory is created.
  */
 class WidgetLocation
 {
     class DirectoryDeletor
     {
-    public:
+      public:
         DirectoryDeletor();
         DirectoryDeletor(std::string tempPath);
         ~DirectoryDeletor();
         std::string getTempPath() const;
-    private:
+
+      private:
         std::string m_dirpath;
     };
 
-public:
+  public:
     DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
     DECLARE_EXCEPTION_TYPE(Base, NoTemporaryPath)
     /**
@@ -76,7 +79,8 @@ public:
      */
     WidgetLocation();
     /**
-     * @brief WidgetLocation Builds paths for widget location during uninstallation
+     * @brief WidgetLocation Builds paths for widget location during
+     * uninstallation
      *
      * Uninstallation process needs only installed package directory.
      *
@@ -84,7 +88,8 @@ public:
      */
     WidgetLocation(const std::string & widgetname);
     /**
-     * @brief WidgetLocation Builds paths for widget location during installation
+     * @brief WidgetLocation Builds paths for widget location during
+     * installation
      *
      * @param widgetname name of widget
      * @param sourcePath given source path
@@ -95,34 +100,34 @@ public:
     WidgetLocation(const std::string & widgetname, std::string sourcePath,
                    WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
                    InstallLocationType ltype =
-                        INSTALL_LOCATION_TYPE_NOMAL);
+                       INSTALL_LOCATION_TYPE_NOMAL);
 
     WidgetLocation(const std::string & widgetname, std::string sourcePath,
                    std::string dirPath,
                    WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
                    InstallLocationType ltype =
-                        INSTALL_LOCATION_TYPE_NOMAL);
+                       INSTALL_LOCATION_TYPE_NOMAL);
 
     ~WidgetLocation();
 
     // Installed paths
-    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
-    std::string getExecFile() const;                    // /opt/apps/[package]/bin/[package]
-    std::string getBackupDir() const;                    // /opt/apps/[package]/backup
-    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
+    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
+    std::string getExecFile() const;   // /opt/apps/[package]/bin/[package]
+    std::string getBackupDir() const;  // /opt/apps/[package]/backup
+    std::string getBackupSourceDir() const; // /opt/apps/[pkg]/backup/res/wgt
+    std::string getBackupBinaryDir() const; // /opt/apps/[pkg]/backup/bin
+    std::string getBackupExecFile() const;  // /opt/apps/[pkg]/backup/bin/[pkg]
+    std::string getUserDataRootDir() const; // /opt/usr/apps/[package]
+    std::string getPrivateStorageDir() const; // /opt/usr/apps/[package]/data
 
     // Temporary paths
     /**
      * @brief getTemporaryRootDir
-     * @return value of root for developer's provide package (root of unpacked .wgt file)
+     * @return value of root for developer's provide package (root of unpacked
+     * .wgt file)
      */
     std::string getTemporaryPackageDir() const;
     /**
@@ -130,14 +135,17 @@ public:
      *
      * Value of this will differs according to type of installed widget.
      *
-     * @return value of root for content in temporary directory to be copied into 'res/wgt'
+     * @return value of root for content in temporary directory to be copied
+     * into 'res/wgt'
      */
     std::string getTemporaryRootDir() const;
     /**
-     * @brief getConfigurationDir Returns rott directory for configuration requirements
+     * @brief getConfigurationDir Returns rott directory for configuration
+     * requirements
      *
      * 1) For packed widgets it is just root of unpacked sources
-     * 2) For browser installation it is directory name of widget passed to installer
+     * 2) For browser installation it is directory name of widget passed to
+     * installer
      *
      * @return configuration directory
      */
@@ -145,7 +153,8 @@ public:
 
     //icons
     /**
-     * @brief setIconTargetFilenameForLocale set installed ion path according to locale
+     * @brief setIconTargetFilenameForLocale set installed ion path according to
+     * locale
      * @param icon path of application icon
      */
     void setIconTargetFilenameForLocale(const std::string &icon);
@@ -168,10 +177,10 @@ public:
      */
     std::string getWidgetSource() const;
     /**
-     * @brief pkgname Returns pkgname
-     * @return pkgname
+     * @brief pkgid Returns pkgid
+     * @return pkgid
      */
-    DPL::String getPkgname() const;
+    DPL::String getPkgId() const;
 
     //external files
     /**
@@ -188,9 +197,16 @@ public:
      */
     WrtDB::ExternalLocationList listExternalLocations() const;
 
-private:
-    std::string m_widgetSource;                   // Source widget zip file/widget url
-    std::string m_pkgname;                        //name of package
+    /*
+     * @brief set appid
+     */
+    void registerAppid(const std::string & appid);
+
+  private:
+    std::string m_pkgid;                        //id of package
+    std::string m_widgetSource;                   // Source widget zip
+                                                  // file/widget url
+    std::string m_appid;                        //id of app
     std::string m_iconPath;                       //installed icon path
     WrtDB::PackagingType m_type;
     std::shared_ptr<DirectoryDeletor> m_temp;      //directory
index ea06b72..eb754ea 100755 (executable)
@@ -41,7 +41,7 @@ TARGET_LINK_LIBRARIES(${TARGET_BACKEND_LIB}
 )
 
 SET_TARGET_PROPERTIES(${TARGET_BACKEND_LIB} PROPERTIES
-    LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both -Wl"
+    LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both"
 )
 
 INSTALL(TARGETS ${TARGET_BACKEND_LIB}
index f2ebcf5..37952c1 100644 (file)
@@ -23,6 +23,7 @@
  *             to package manager
  */
 #include "package-manager-plugin.h"
+#include <regex.h>
 #include <dlog.h>
 #include <dpl/wrt-dao-ro/global_config.h>
 #include <vcore/VCore.h>
@@ -43,7 +44,7 @@ using namespace WrtDB;
 #undef FALSE
 #define TRUE 0
 #define FALSE -1
-#define GET_DIRECTORY_SIZE_KB(x)    (x)/1024
+#define GET_DIRECTORY_SIZE_KB(x)    (x) / 1024
 
 #ifdef __cplusplus
 extern "C"
@@ -53,11 +54,17 @@ extern "C"
 static void pkg_native_plugin_on_unload();
 static int pkg_plugin_app_is_installed(const char *pkg_name);
 static int pkg_plugin_get_installed_apps_list(const char *category,
-        const char *option, package_manager_pkg_info_t **list, int *count);
-static int pkg_plugin_get_app_detail_info(const char *pkg_name,
-        package_manager_pkg_detail_info_t *pkg_detail_info);
-static int pkg_plugin_get_app_detail_info_from_package(const char *pkg_path,
-        package_manager_pkg_detail_info_t *pkg_detail_info);
+                                              const char *option,
+                                              package_manager_pkg_info_t **list,
+                                              int *count);
+static int pkg_plugin_get_app_detail_info(
+    const char *pkg_name,
+    package_manager_pkg_detail_info_t *
+    pkg_detail_info);
+static int pkg_plugin_get_app_detail_info_from_package(
+    const char *pkg_path,
+    package_manager_pkg_detail_info_t
+    *pkg_detail_info);
 
 static void pkg_native_plugin_on_unload()
 {
@@ -66,12 +73,28 @@ static void pkg_native_plugin_on_unload()
 
 static int pkg_plugin_app_is_installed(const char *pkg_name)
 {
+    const char* REG_PKGID_PATTERN = "^[a-zA-Z0-9]{10}$";
     LogDebug("pkg_plugin_app_is_installed() is called");
 
     WrtDB::WrtDatabase::attachToThreadRO();
 
-    bool result = WidgetDAOReadOnly::isWidgetInstalled(
-                    DPL::FromUTF8String(pkg_name));
+    regex_t reg;
+    if (regcomp(&reg, REG_PKGID_PATTERN, REG_NOSUB | REG_EXTENDED) != 0) {
+        LogDebug("Regcomp failed");
+    }
+
+    WrtDB::TizenAppId appid;
+
+    if ((regexec(&reg, pkg_name,
+                    static_cast<size_t>(0), NULL, 0) == 0))
+    {
+        WrtDB::TizenPkgId pkgid(DPL::FromUTF8String(pkg_name));
+        appid = WidgetDAOReadOnly::getTzAppId(pkgid);
+    } else {
+        appid = DPL::FromUTF8String(pkg_name);
+    }
+
+    bool result = WidgetDAOReadOnly::isWidgetInstalled(appid);
     WrtDB::WrtDatabase::detachFromThread();
 
     if (result) {
@@ -82,19 +105,20 @@ static int pkg_plugin_app_is_installed(const char *pkg_name)
 }
 
 static int pkg_plugin_get_installed_apps_list(const char * /*category*/,
-        const char * /*option*/, package_manager_pkg_info_t **list, int *count)
+                                              const char * /*option*/,
+                                              package_manager_pkg_info_t **list,
+                                              int *count)
 {
     LogDebug("pkg_plugin_get_installed_apps_list() is called");
 
     package_manager_pkg_info_t *pkg_list = NULL;
     package_manager_pkg_info_t *pkg_last = NULL;
 
-
     WrtDB::WrtDatabase::attachToThreadRO();
-    WidgetPkgNameList pkgnameslList = WidgetDAOReadOnly::getPkgnameList();
+    TizenAppIdList tizenAppidList = WidgetDAOReadOnly::getTizenAppidList();
     *count = 0;
 
-    FOREACH(iterator, pkgnameslList) {
+    FOREACH(iterator, tizenAppidList) {
         package_manager_pkg_info_t *pkg_info =
             static_cast<package_manager_pkg_info_t*>
             (malloc(sizeof(package_manager_pkg_info_t)));
@@ -106,11 +130,11 @@ static int pkg_plugin_get_installed_apps_list(const char * /*category*/,
             pkg_last->next = pkg_info;
         }
 
-        WidgetPkgName pkgname = *iterator;
-        WidgetDAOReadOnly widget(pkgname);
+        TizenAppId tzAppid = *iterator;
+        WidgetDAOReadOnly widget(tzAppid);
         strncpy(pkg_info->pkg_type, "wgt", PKG_TYPE_STRING_LEN_MAX);
         snprintf(pkg_info->pkg_name, PKG_NAME_STRING_LEN_MAX, "%s",
-                DPL::ToUTF8String(pkgname).c_str());
+                 DPL::ToUTF8String(tzAppid).c_str());
 
         DPL::Optional<DPL::String> version = widget.getVersion();
         if (!version.IsNull()) {
@@ -128,15 +152,16 @@ static int pkg_plugin_get_installed_apps_list(const char * /*category*/,
     return TRUE;
 }
 
-static int pkg_plugin_get_app_detail_info(const char *pkg_name,
-        package_manager_pkg_detail_info_t *pkg_detail_info)
+static int pkg_plugin_get_app_detail_info(
+    const char *pkg_name,
+    package_manager_pkg_detail_info_t *
+    pkg_detail_info)
 {
     LogDebug("pkg_plugin_get_app_detail_info() is called");
 
-
     WrtDB::WrtDatabase::attachToThreadRO();
     int handle = WidgetDAOReadOnly::getHandle(
-                    DPL::FromUTF8String(pkg_name));
+            DPL::FromUTF8String(pkg_name));
     WidgetDAOReadOnly widget(handle);
 
     DPL::Optional<DPL::String> version = widget.getVersion();
@@ -149,7 +174,7 @@ static int pkg_plugin_get_app_detail_info(const char *pkg_name,
                 PKG_VERSION_STRING_LEN_MAX - 1);
     }
     snprintf(pkg_detail_info->optional_id, PKG_NAME_STRING_LEN_MAX, "%d",
-           handle);
+             handle);
     WidgetLocalizedInfo localizedInfo;
 
     if (locale.IsNull()) {
@@ -197,8 +222,8 @@ static int pkg_plugin_get_app_detail_info(const char *pkg_name,
 }
 
 static int pkg_plugin_get_app_detail_info_from_package(
-        const char * /*pkg_path*/,
-        package_manager_pkg_detail_info_t * /*pkg_detail_info*/)
+    const char * /*pkg_path*/,
+    package_manager_pkg_detail_info_t * /*pkg_detail_info*/)
 {
     LogDebug("pkg_plugin_get_app_detail_info_from_package() is called");
 
index 4b48b83..1732b27 100644 (file)
 #include <pkgmgr_installer.h>
 #include <pkg-manager/pkgmgr_signal.h>
 
-
 namespace PackageManager {
-
 PkgmgrSignal::PkgmgrSignal() :
     m_initialized(false),
     m_handle(NULL),
     m_noPopup(false),
     m_reqType(PKGMGR_REQ_INVALID)
-{
-}
+{}
 
 PkgmgrSignal::~PkgmgrSignal()
-{
-}
+{}
 
 bool PkgmgrSignal::initialize(int argc, char* argv[])
 {
-    if(m_handle)
-    {
+    if (m_handle) {
         LogInfo("Release already allocated pkgmgr handle");
         pkgmgr_installer_free(m_handle);
         m_handle = NULL;
     }
 
     m_handle = pkgmgr_installer_new();
-    if(!m_handle) {
+    if (!m_handle) {
         LogError("Fail to get pkgmgr installer handle");
         return false;
     }
 
     // set information from pkgmgr
     if (!pkgmgr_installer_receive_request(
-                m_handle, argc, argv))
+            m_handle, argc, argv))
     {
         m_noPopup = pkgmgr_installer_is_quiet(m_handle);
         m_reqType = pkgmgr_installer_get_request_type(m_handle);
         if (m_reqType != PKGMGR_REQ_INSTALL &&
-                m_reqType != PKGMGR_REQ_UNINSTALL)
+            m_reqType != PKGMGR_REQ_UNINSTALL)
         {
             LogError("Fail to get request type of pkgmgr");
             pkgmgr_installer_free(m_handle);
@@ -81,8 +76,7 @@ bool PkgmgrSignal::initialize(int argc, char* argv[])
 
 bool PkgmgrSignal::deinitialize()
 {
-    if (!m_initialized)
-    {
+    if (!m_initialized) {
         LogError("PkgmgrSingal not yet intialized");
         return false;
     }
@@ -95,14 +89,12 @@ bool PkgmgrSignal::deinitialize()
 
 bool PkgmgrSignal::setPkgname(const std::string& name)
 {
-    if (!m_initialized)
-    {
+    if (!m_initialized) {
         LogError("PkgmgrSingal not yet intialized");
         return false;
     }
 
-    if (name.empty())
-    {
+    if (name.empty()) {
         LogError("name is empty");
         return false;
     }
@@ -113,30 +105,28 @@ bool PkgmgrSignal::setPkgname(const std::string& name)
     return true;
 }
 
-bool PkgmgrSignal::sendSignal(const std::string& key, const std::string& value) const
+bool PkgmgrSignal::sendSignal(const std::string& key,
+                              const std::string& value) const
 {
-    if (!m_initialized)
-    {
+    if (!m_initialized) {
         LogError("PkgmgrSingal not yet intialized");
         return false;
     }
 
-    if (key.empty() || value.empty())
-    {
+    if (key.empty() || value.empty()) {
         LogDebug("key or value is empty");
         return false;
     }
 
-    if (m_handle == NULL || m_type.empty() || m_pkgname.empty())
-    {
+    if (m_handle == NULL || m_type.empty() || m_pkgname.empty()) {
         LogError("Some data of PkgmgrSignal is empty");
         return false;
     }
 
     // send pkgmgr signal
     if (pkgmgr_installer_send_signal(
-                m_handle, m_type.c_str(), m_pkgname.c_str(),
-                key.c_str(), value.c_str()))
+            m_handle, m_type.c_str(), m_pkgname.c_str(),
+            key.c_str(), value.c_str()))
     {
         LogError("Fail to send pkgmgr signal");
         return false;
@@ -149,8 +139,7 @@ bool PkgmgrSignal::sendSignal(const std::string& key, const std::string& value)
 
 std::string PkgmgrSignal::getPkgname() const
 {
-    if (!m_initialized)
-    {
+    if (!m_initialized) {
         LogError("PkgmgrSingal not yet intialized");
     }
 
@@ -159,8 +148,7 @@ std::string PkgmgrSignal::getPkgname() const
 
 int PkgmgrSignal::getRequestedType() const
 {
-    if (!m_initialized)
-    {
+    if (!m_initialized) {
         LogError("PkgmgrSingal not yet intialized");
     }
 
@@ -169,8 +157,7 @@ int PkgmgrSignal::getRequestedType() const
 
 bool PkgmgrSignal::isNoPopupRequired() const
 {
-    if (!m_initialized)
-    {
+    if (!m_initialized) {
         LogError("PkgmgrSingal not yet intialized");
     }
 
index a939c50..f5fecd7 100644 (file)
 #include <pkg-manager/pkgmgr_signal_interface.h>
 #include <pkgmgr_installer.h>
 
-namespace PackageManager{
-
+namespace PackageManager {
 #define PKGMGR_WEBAPP_TYPE          "wgt"
 #define PKGMGR_START_KEY            "start"
 #define PKGMGR_START_INSTALL        "install"
+#define PKGMGR_START_UPDATE         "update"
 #define PKGMGR_START_UNINSTALL      "uninstall"
 #define PKGMGR_END_KEY              "end"
 #define PKGMGR_END_SUCCESS          "ok"
 #define PKGMGR_END_FAILURE          "fail"
 #define PKGMGR_PROGRESS_KEY         "install_percent"
+#define PKGMGR_ICON_PATH            "icon_path"
 
 typedef pkgmgr_installer* PkgmgrHandle;
 
-class PkgmgrSignal: public IPkgmgrSignal
+class PkgmgrSignal : public IPkgmgrSignal
 {
-    public:
-        bool initialize(int argc, char* argv[]);
-        bool deinitialize();
-        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;
+  public:
+    bool initialize(int argc, char* argv[]);
+    bool deinitialize();
+    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();
+    PkgmgrSignal();
+    virtual ~PkgmgrSignal();
 
-    private:
-        bool m_initialized;
-        PkgmgrHandle m_handle;
-        std::string m_type;
-        std::string m_pkgname;
-        bool m_noPopup;
-        int m_reqType;
+  private:
+    bool m_initialized;
+    PkgmgrHandle m_handle;
+    std::string m_type;
+    std::string m_pkgname;
+    bool m_noPopup;
+    int m_reqType;
 };
 } // PackageManager
 
index f8862ee..4c1b3e4 100644 (file)
 #include <pkg-manager/pkgmgr_signal_interface.h>
 
 namespace PackageManager {
-
-class PkgmgrSignalDummy: public IPkgmgrSignal
+class PkgmgrSignalDummy : public IPkgmgrSignal
 {
-public:
+  public:
     PkgmgrSignalDummy()
-    {
-    }
+    {}
 
     virtual ~PkgmgrSignalDummy()
-    {
-    }
-    bool setPkgname(const std::string& name)
+    {}
+    bool setPkgname(const std::string& /*name*/)
     {
         return false;
     }
 
-    bool sendSignal(const std::string& key, const std::string& value) const
+    bool sendSignal(const std::string& /*key*/, const std::string& /*value*/) const
     {
         return false;
     }
@@ -51,7 +48,6 @@ public:
         return "";
     }
 };
-
 } // PkgmgrSignalDummy
 
 #endif // WRT_PKGMGR_SIGNAL_DUMMY_H_
index 187efb5..1f3946d 100644 (file)
 
 #include <string>
 namespace PackageManager {
-
 class IPkgmgrSignal
 {
-public:
+  public:
     virtual bool setPkgname(const std::string& name) = 0;
-    virtual bool sendSignal(const std::string& key, const std::string& value) const = 0;
+    virtual bool sendSignal(const std::string& key,
+                            const std::string& value) const = 0;
     virtual std::string getPkgname() const = 0;
-    virtual ~IPkgmgrSignal(){};
+    virtual ~IPkgmgrSignal(){}
 };
-
 } // IPkgmgrSignal
 
 #endif // WRT_PKGMGR_SIGNAL_INTERFACE_H_
index 12d2c7c..aef18ba 100644 (file)
@@ -64,7 +64,7 @@ TARGET_LINK_LIBRARIES(${TARGET_INSTALLER}
 
 
 SET_TARGET_PROPERTIES(${TARGET_INSTALLER} PROPERTIES
-    LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both -Wl"
+    LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both"
     BUILD_WITH_INSTALL_RPATH ON
     INSTALL_RPATH_USE_LINK_PATH ON
 )
index 8571d68..275c3fd 100644 (file)
 #include <dpl/log/log.h>
 
 namespace InstallerCallbacksTranslate {
-WrtErrStatus TranslateError(CommonError::Type status)
-{
-    switch (status) {
-    case CommonError::WrtSuccess:
-        return WRT_SUCCESS;
-
-    case CommonError::HandleNotFound:
-        return WRT_ERROR_HANDLE_NOT_FOUND;
-
-    case CommonError::AlreadyRunning:
-        return WRT_ERROR_ALREADY_RUNNING;
-
-    case CommonError::InvalidLanguage:
-        return WRT_ERROR_INVALID_LANGUAGE;
-
-    case CommonError::AlreadyStopped:
-        return WRT_ERROR_ALREADY_STOPPED;
-
-    case CommonError::StillAuthorizing:
-        return WRT_ERROR_STILL_AUTHORIZING;
-
-    case CommonError::EarlyKilled:
-        return WRT_ERROR_EARLY_KILLED;
-
-    case CommonError::AccessDenied:
-        return WRT_ERROR_ACCESS_DENIED;
-
-    default:
-        LogError("Untranslatable error: " << status);
-        return WRT_ERROR_INTERNAL;
-    }
-}
-
-void StatusCallback(std::string tizenId,
-        CommonError::Type result,
-        void *data)
-{
-    LogDebug("StatusCallback called  " << tizenId << " | " << result);
-    Assert(data != NULL);
-
-    WrtErrStatus error = TranslateError(result);
-    StatusCallbackStruct* statusCallbackStruct =
-        static_cast<StatusCallbackStruct*>(data);
-
-    if (statusCallbackStruct->status_callback) {
-        statusCallbackStruct->status_callback(tizenId,
-                                              error,
-                                              statusCallbackStruct->userdata);
-    } else {
-        LogInfo("StatusCallback: ignoring NULL callback pointer");
-    }
-
-    delete statusCallbackStruct;
-}
 
 // callback for finished install
 void installFinishedCallback(void *userParam,
-        std::string tizenId,
-        Jobs::WidgetInstall::Exceptions::Type status)
+                             std::string tizenId,
+                             Jobs::WidgetInstall::Exceptions::Type status)
 {
     Assert(userParam != NULL);
 
@@ -98,10 +44,6 @@ void installFinishedCallback(void *userParam,
             errorStatus = WRT_SUCCESS;
             break;
 
-        case Jobs::WidgetInstall::Exceptions::ErrorInvalidWidgetPackage:
-            errorStatus = WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE;
-            break;
-
         case Jobs::WidgetInstall::Exceptions::ErrorWidgetDoesNotExist:
             errorStatus = WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST;
             break;
@@ -110,18 +52,10 @@ void installFinishedCallback(void *userParam,
             errorStatus = WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING;
             break;
 
-        case Jobs::WidgetInstall::Exceptions::ErrorOutOfDiskSpace:
-            errorStatus = WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE;
-            break;
-
         case Jobs::WidgetInstall::Exceptions::ErrorInvalidPackage:
             errorStatus = WRT_INSTALLER_ERROR_INVALID_CERTIFICATE;
             break;
 
-        case Jobs::WidgetInstall::Exceptions::ErrorAlreadyInstalled:
-            errorStatus = WRT_INSTALLER_ERROR_ALREADY_INSTALLED;
-            break;
-
         case Jobs::WidgetInstall::Exceptions::ErrorInternal:
             errorStatus = WRT_INSTALLER_ERROR_INTERNAL;
             break;
@@ -160,8 +94,8 @@ void installFinishedCallback(void *userParam,
 
 // callback for finished install
 void uninstallFinishedCallback(void *userParam,
-        std::string tizenId,
-        Jobs::WidgetUninstall::Exceptions::Type status)
+                               std::string tizenId,
+                               Jobs::WidgetUninstall::Exceptions::Type status)
 {
     Assert(userParam != NULL);
 
@@ -210,7 +144,7 @@ void uninstallFinishedCallback(void *userParam,
 }
 
 void pluginInstallFinishedCallback(void *userParam,
-        Jobs::PluginInstall::Exceptions::Type status)
+                                   Jobs::PluginInstall::Exceptions::Type status)
 {
     Assert(userParam);
 
@@ -255,8 +189,8 @@ void pluginInstallFinishedCallback(void *userParam,
 
 // callback for progress of install OR uninstall
 void installProgressCallback(void *userParam,
-        ProgressPercent percent,
-        const ProgressDescription &description)
+                             ProgressPercent percent,
+                             const ProgressDescription &description)
 {
     Assert(userParam != NULL);
 
@@ -273,6 +207,5 @@ void installProgressCallback(void *userParam,
         LogInfo("installProgressCallback: ignoring NULL callback pointer");
     }
 }
-
 } //namespace
 
index c32d253..c98e448 100644 (file)
@@ -38,13 +38,12 @@ struct StatusCallbackStruct
     WrtProgressCallback progress_callback;
 
     StatusCallbackStruct(void* u,
-            WrtInstallerStatusCallback s,
-            WrtProgressCallback p) :
+                         WrtInstallerStatusCallback s,
+                         WrtProgressCallback p) :
         userdata(u),
         status_callback(s),
         progress_callback(p)
-    {
-    }
+    {}
 };
 
 struct PluginStatusCallbackStruct
@@ -54,35 +53,29 @@ struct PluginStatusCallbackStruct
     WrtProgressCallback progressCallback;
 
     PluginStatusCallbackStruct(void* u,
-            WrtPluginInstallerStatusCallback s,
-            WrtProgressCallback p) :
+                               WrtPluginInstallerStatusCallback s,
+                               WrtProgressCallback p) :
         userdata(u),
         statusCallback(s),
         progressCallback(p)
-    {
-    }
+    {}
 };
 
-void StatusCallback(std::string tizenId,
-        CommonError::Type result,
-        void *data);
-
 void installFinishedCallback(void *userParam,
-        std::string tizenId,
-        Jobs::WidgetInstall::Exceptions::Type status);
+                             std::string tizenId,
+                             Jobs::WidgetInstall::Exceptions::Type status);
 
 void uninstallFinishedCallback(void *userParam,
-        std::string tizenId,
-        Jobs::WidgetUninstall::Exceptions::Type status);
+                               std::string tizenId,
+                               Jobs::WidgetUninstall::Exceptions::Type status);
 
 void pluginInstallFinishedCallback(void *userParam,
-        Jobs::PluginInstall::Exceptions::Type status);
+                                   Jobs::PluginInstall::Exceptions::Type status);
 
 // callback for progress of install OR uninstall
 void installProgressCallback(void *userParam,
-        ProgressPercent percent,
-        const ProgressDescription &description);
-
+                             ProgressPercent percent,
+                             const ProgressDescription &description);
 } //namespace
 
 #endif /* WRT_SRC_API_API_CALLBACKS_TRANSLATE_H_ */
old mode 100755 (executable)
new mode 100644 (file)
index c5d677b..b398d3c
@@ -32,10 +32,10 @@ IMPLEMENT_SINGLETON(InstallerMainThread)
 
 using namespace WrtDB;
 
-InstallerMainThread::InstallerMainThread() : m_attached(false) {
-}
+InstallerMainThread::InstallerMainThread() : m_attached(false) {}
 
-InstallerMainThread::~InstallerMainThread() {
+InstallerMainThread::~InstallerMainThread()
+{
     Assert(!m_attached);
 }
 
old mode 100755 (executable)
new mode 100644 (file)
index 67c1937..bd70b16
@@ -24,7 +24,8 @@
 
 #include <dpl/singleton.h>
 
-class InstallerMainThread {
+class InstallerMainThread
+{
   public:
     void AttachDatabases();
     void DetachDatabases();
index 119d5c6..8bf901f 100644 (file)
@@ -43,7 +43,9 @@ bool LanguageSubtagRstTree::ValidateLanguageTag(const std::string &tag_input)
     if (token == parts.end()) {
         return false;
     }
-    if (WrtDB::GlobalDAOReadOnly::IsValidSubTag(*token, RECORD_TYPE_LANGUAGE)) {
+    if (WrtDB::GlobalDAOReadOnly::IsValidSubTag(*token,
+                                                RECORD_TYPE_LANGUAGE))
+    {
         ++token;
     } else {
         return false;
@@ -93,7 +95,8 @@ bool LanguageSubtagRstTree::ValidateLanguageTag(const std::string &tag_input)
         bool one_or_more = false;
         while (token != parts.end() &&
                token->size() > 1 &&
-               token->size() <= 8) {
+               token->size() <= 8)
+        {
             one_or_more = true;
             ++token;
         }
@@ -111,7 +114,8 @@ bool LanguageSubtagRstTree::ValidateLanguageTag(const std::string &tag_input)
         bool one_or_more = false;
         while (token != parts.end() &&
                !token->empty() &&
-               token->size() <= 8) {
+               token->size() <= 8)
+        {
             one_or_more = true;
             ++token;
         }
@@ -131,7 +135,8 @@ bool LanguageSubtagRstTree::ValidateLanguageTag(const std::string &tag_input)
         bool one_or_more = false;
         while (token != parts.end() &&
                !token->empty() &&
-               token->size() <= 8) {
+               token->size() <= 8)
+        {
             one_or_more = true;
             ++token;
         }
@@ -143,28 +148,28 @@ bool LanguageSubtagRstTree::ValidateLanguageTag(const std::string &tag_input)
 }
 
 #define TEST_LANG(str, cond) \
-    if (LanguageSubtagRstTreeSingleton::Instance().\
-        ValidateLanguageTag(str) == cond) {\
-        LogDebug("Good validate status for lang: " << str);\
-    } else {\
-        LogError("Wrong validate status for lang: " << str\
-                 << ", should be " << cond);\
+    if (LanguageSubtagRstTreeSingleton::Instance(). \
+            ValidateLanguageTag(str) == cond) { \
+        LogDebug("Good validate status for lang: " << str); \
+    } else { \
+        LogError("Wrong validate status for lang: " << str \
+                                                    << ", should be " << cond); \
     }
 
 void LanguageSubtagRstTree::Initialize()
 {
     /* Temporarily added unit test. Commented out due to performance drop.
-    TEST_LANG("zh", true);
-    TEST_LANG("esx-al", true);
-    TEST_LANG("zh-Hant", true);
-    TEST_LANG("zh-Hant-CN", true);
-    TEST_LANG("zh-Hant-CN-x-private1-private2", true);
-    TEST_LANG("plxxx", false);
-    TEST_LANG("pl-x-private111", false);
-    TEST_LANG("x-private1", false); //do not support pure private ones
-    TEST_LANG("x-private22", false);
-    TEST_LANG("i-private22", false); //do not support i-*
-    */
+     * TEST_LANG("zh", true);
+     * TEST_LANG("esx-al", true);
+     * TEST_LANG("zh-Hant", true);
+     * TEST_LANG("zh-Hant-CN", true);
+     * TEST_LANG("zh-Hant-CN-x-private1-private2", true);
+     * TEST_LANG("plxxx", false);
+     * TEST_LANG("pl-x-private111", false);
+     * TEST_LANG("x-private1", false); //do not support pure private ones
+     * TEST_LANG("x-private22", false);
+     * TEST_LANG("i-private22", false); //do not support i-*
+     */
 }
 
 #undef TEST_LANG
index 334fbb4..982d86f 100644 (file)
@@ -34,15 +34,13 @@ DPL::OptionalString OptionParser::QueryOption(int argc,
 
     auto it = std::find_if(args.begin(),
                            args.end(),
-                           [&name](const std::string& option){
-                                return (option == name);
+                           [&name](const std::string & option){
+                               return (option == name);
                            });
 
-    if (it != args.end())
-    {
+    if (it != args.end()) {
         std::string value;
-        while ((++it != args.end()) && !IsOption(*it))
-        {
+        while ((++it != args.end()) && !IsOption(*it)) {
             value += *it + " ";
         }
         result = DPL::FromUTF8String(value);
index 599bc59..7fa8c3a 100644 (file)
 
 class OptionParser
 {
-public:
+  public:
     static DPL::OptionalString QueryOption(int argc,
                                            char* argv[],
-                                           const std::string& name);
+                                           const std::string & name);
 
-private:
+  private:
     static bool IsOption(const std::string& name);
 };
 
index ae29f5e..f168866 100644 (file)
  * @brief   Header file for plugin util
  */
 
+#include <unistd.h>
 #include "plugin_utils.h"
-#include <dpl/semaphore.h>
 #include <dpl/exception.h>
 #include <dpl/log/log.h>
 #include <dpl/wrt-dao-ro/global_config.h>
+#include <sys/file.h>
 
 using namespace WrtDB;
 
 namespace PluginUtils {
-const char PLUGIN_INSTALL_SEMAPHORE[] = "/.wrt_plugin_install_lock";
+const char* PLUGIN_INSTALL_LOCK_FILE = "/tmp/.wrt_plugin_install_lock";
 
-static DPL::Semaphore semaphore(PLUGIN_INSTALL_SEMAPHORE);
+static int s_plugin_install_lock_fd = -1;
 
 bool lockPluginInstallation()
 {
-    Try {
-        semaphore.Lock();
-        return true;
+    int ret = 0;
+
+    LogInfo("Try to lock for plugins installation.");
+
+    s_plugin_install_lock_fd =
+        open(PLUGIN_INSTALL_LOCK_FILE, O_RDONLY | O_CREAT, 0666);
+
+    if (s_plugin_install_lock_fd == -1) {
+        LogError("Lock file open failed!");
+
+        return false;
     }
-    Catch(DPL::Semaphore::Exception::Base){
+
+    ret = flock(s_plugin_install_lock_fd, LOCK_EX); //lock with waiting
+
+    if (ret == -1) {
+        LogError("Lock failed!");
+
+        close(s_plugin_install_lock_fd);
+        s_plugin_install_lock_fd = -1;
+
         return false;
     }
+
+    return true;
 }
 
 bool unlockPluginInstallation()
 {
-    Try {
-        semaphore.Unlock();
+    LogInfo("Unlock for plugins installation.");
+
+    if (s_plugin_install_lock_fd != -1) {
+        int ret = 0;
+
+        ret = flock(s_plugin_install_lock_fd, LOCK_UN); //unlock
+
+        if (ret == -1) {
+            LogError("Unlock failed!");
+        }
+
+        close(s_plugin_install_lock_fd);
+        s_plugin_install_lock_fd = -1;
+
         return true;
+    } else {
+        LogError("Lock file was not created!");
     }
-    Catch(DPL::Semaphore::Exception::Base){
-        return false;
-    }
+
+    return false;
 }
 
 bool checkPluginInstallationRequired()
@@ -64,11 +96,11 @@ bool checkPluginInstallationRequired()
         checkFile(installRequest);
 
     switch (installationRequest) {
-        case FileState::FILE_EXISTS:
-            return true;
-        case FileState::FILE_NOT_EXISTS:
-            return false;
-        default:
+    case FileState::FILE_EXISTS:
+        return true;
+    case FileState::FILE_NOT_EXISTS:
+        return false;
+    default:
         LogWarning("Opening installation request file failed");
         return false;
     }
old mode 100755 (executable)
new mode 100644 (file)
index 659e627..7b58e56
@@ -43,6 +43,5 @@ bool checkPluginInstallationRequired();
 bool removeInstallationRequiredFlag();
 FileState::Type checkFile(const std::string& filename);
 bool removeFile(const std::string& filename);
-
 }
 #endif // PLUGIN_UTILS_H
index 8deea1d..9037cff 100644 (file)
@@ -50,8 +50,6 @@
 #include <widget_parser.h>
 #include <root_parser.h>
 
-
-
 #define NOFILE_CNT_FOR_INSTALLER 9999
 
 using namespace WrtDB;
@@ -68,7 +66,10 @@ const char * const CONFIG_XML = "config.xml";
 
 struct free_deleter
 {
-    void operator()(void* x) { free(x); }
+    void operator()(void* x)
+    {
+        free(x);
+    }
 };
 
 struct PluginInstallerData
@@ -81,6 +82,7 @@ struct PluginInstallerData
 WrtInstaller::WrtInstaller(int argc, char **argv) :
     Application(argc, argv, "backend", false),
     DPL::TaskDecl<WrtInstaller>(this),
+    m_installPolicy(WRT_WIM_NOT_INSTALLED),
     m_packagePath(),
     m_handle(-1),
     m_initialized(false),
@@ -113,7 +115,7 @@ void WrtInstaller::OnCreate()
     fprintf(stderr,
             "===========================================================\n");
     fprintf(stderr, "# wrt-installer #\n");
-    fprintf(stderr, "# argc [%ld]\n", m_argc);
+    fprintf(stderr, "# argc [%d]\n", m_argc);
     fprintf(stderr, "# argv[0] = [%s]\n", m_argv[0]);
     fprintf(stderr, "# argv[1] = [%s]\n", m_argv[1]);
     fprintf(stderr, "# argv[2] = [%s]\n", m_argv[2]);
@@ -124,11 +126,12 @@ void WrtInstaller::OnCreate()
 
     std::string arg = m_argv[0];
 
-    pkgmgrSignalInterface = std::static_pointer_cast<PackageManager::IPkgmgrSignal>(
-                                std::shared_ptr<PackageManager::PkgmgrSignalDummy>(
-                                        new PackageManager::PkgmgrSignalDummy()
-                                )
-                            );
+    pkgmgrSignalInterface =
+        std::static_pointer_cast<PackageManager::IPkgmgrSignal>(
+            std::shared_ptr<PackageManager::PkgmgrSignalDummy>(
+                new PackageManager::PkgmgrSignalDummy()
+                )
+            );
 
     if (arg.empty()) {
         return showHelpAndQuit();
@@ -136,8 +139,7 @@ void WrtInstaller::OnCreate()
 
     installNewPlugins();
 
-    if (arg.find("wrt-installer") != std::string::npos)
-    {
+    if (arg.find("wrt-installer") != std::string::npos) {
         if (m_argc <= 1) {
             return showHelpAndQuit();
         }
@@ -168,9 +170,7 @@ void WrtInstaller::OnCreate()
             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
-            {
+            } else {
                 LogInfo("Installing from regular location");
                 m_installPolicy = WRT_WIM_POLICY_WAC;
             }
@@ -214,50 +214,49 @@ void WrtInstaller::OnCreate()
         } else {
             return showHelpAndQuit();
         }
-
     } else if (arg.find("backend") != std::string::npos) {
         using namespace PackageManager;
         m_installByPkgmgr = true;
 
-        auto pkgmgrSignal =  std::shared_ptr<PackageManager::PkgmgrSignal>(
-                                new PackageManager::PkgmgrSignal()
-                             );
+        auto pkgmgrSignal = std::shared_ptr<PackageManager::PkgmgrSignal>(
+                new PackageManager::PkgmgrSignal()
+                );
 
         pkgmgrSignal->initialize(m_argc, m_argv);
         m_quiet = pkgmgrSignal->isNoPopupRequired();
-        LogDebug("backend m_quiet"<<m_quiet);
+        LogDebug("backend m_quiet" << m_quiet);
 
         int reqType = pkgmgrSignal->getRequestedType();
 
         pkgmgrSignalInterface =
-                std::static_pointer_cast<PackageManager::IPkgmgrSignal>(pkgmgrSignal);
+            std::static_pointer_cast<PackageManager::IPkgmgrSignal>(
+                pkgmgrSignal);
         switch (reqType) {
-            case PKGMGR_REQ_INSTALL:
-                m_packagePath = m_argv[4];
-                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:
-                m_name = m_argv[4];
-                AddStep(&WrtInstaller::uninstallPkgNameStep);
-                break;
-            default:
-                LogDebug("Not available type");
-                break;
+        case PKGMGR_REQ_INSTALL:
+            m_packagePath = m_argv[4];
+            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:
+            m_name = m_argv[4];
+            AddStep(&WrtInstaller::uninstallPkgNameStep);
+            break;
+        default:
+            LogDebug("Not available type");
+            break;
         }
     }
 
     AddStep(&WrtInstaller::shutdownStep);
-    DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::PostEvent(
+    DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::
+        PostEvent(
         WRTInstallerNS::NextStepEvent());
 }
 
@@ -324,7 +323,8 @@ void WrtInstaller::OnEventReceived(const WRTInstallerNS::QuitEvent& /*event*/)
     if (m_initialized) {
         LogDebug("Wrt Shutdown now");
         SwitchToStep(&WrtInstaller::shutdownStep);
-        DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::PostEvent(
+        DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::
+            PostEvent(
             WRTInstallerNS::NextStepEvent());
     } else {
         LogDebug("Quiting application");
@@ -350,9 +350,9 @@ void WrtInstaller::OnEventReceived(
         (*m_pluginsPaths).pop_front();
 
         wrt_install_plugin(privateData->pluginPath.c_str(),
-                static_cast<void*>(privateData),
-                &staticWrtPluginInstallationCallback,
-                &staticWrtPluginInstallProgressCb);
+                           static_cast<void*>(privateData),
+                           &staticWrtPluginInstallationCallback,
+                           &staticWrtPluginInstallProgressCb);
     } else {
         delete privateData;
     }
@@ -367,7 +367,7 @@ void WrtInstaller::installStep()
 {
     LogDebug("Installing widget ...");
     std::unique_ptr<char, free_deleter> packagePath(canonicalize_file_name(
-            m_packagePath.c_str()));
+                                                        m_packagePath.c_str()));
 
     wrt_install_widget(packagePath ? packagePath.get() : m_packagePath.c_str(),
                        this, &staticWrtStatusCallback,
@@ -382,15 +382,15 @@ void WrtInstaller::installStep()
 void WrtInstaller::installPluginsStep()
 {
     LogDebug("Installing plugins ...");
-    fprintf(stderr,"Installing plugins ...\n");
+    fprintf(stderr, "Installing plugins ...\n");
 
     if (m_startupPluginInstallation) {
         LogInfo("Plugin installation started because new plugin package found");
     } else if (!PluginUtils::lockPluginInstallation()) {
         LogError("Failed to open plugin installation lock file"
-                " Plugins are currently installed by other process");
+                 " Plugins are currently installed by other process");
         staticWrtPluginInstallationCallback(WRT_PLUGIN_INSTALLER_ERROR_LOCK,
-                this);
+                                            this);
         return;
     }
 
@@ -404,22 +404,25 @@ void WrtInstaller::installPluginsStep()
     }
 
     LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
-    struct dirent* libdir;
-
-    errno = 0;
 
     std::list<std::string> pluginsPaths;
-
-    while ((libdir = readdir(dir)) != 0) {
-        if (strcmp(libdir->d_name, ".") == 0 ||
-            strcmp(libdir->d_name, "..") == 0)
+    struct dirent libdir;
+    struct dirent *result;
+    int return_code;
+    errno = 0;
+    for (return_code = readdir_r(dir, &libdir, &result);
+            result != NULL && return_code == 0;
+            return_code = readdir_r(dir, &libdir, &result))
+    {
+        if (strcmp(libdir.d_name, ".") == 0 ||
+            strcmp(libdir.d_name, "..") == 0)
         {
             continue;
         }
 
         std::string path = PLUGIN_PATH;
         path += "/";
-        path += libdir->d_name;
+        path += libdir.d_name;
 
         struct stat tmp;
 
@@ -436,6 +439,10 @@ void WrtInstaller::installPluginsStep()
         pluginsPaths.push_back(path);
     }
 
+    if (return_code != 0 || errno != 0) {
+        LogError("readdir_r() failed with " << DPL::GetErrnoString());
+    }
+
     //set nb of plugins to install
     //this value indicate how many callbacks are expected
     m_numPluginsToInstall = pluginsPaths.size();
@@ -448,7 +455,7 @@ void WrtInstaller::installPluginsStep()
 
     if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
         LogError("Failed to close dir: " << PLUGIN_PATH << " with error: "
-                << DPL::GetErrnoString());
+                                         << DPL::GetErrnoString());
     }
 }
 
@@ -457,26 +464,29 @@ void WrtInstaller::uninstallPkgNameStep()
     LogDebug("Uninstalling widget ...");
     LogDebug("Package name : " << m_name);
     wrt_uninstall_widget(m_name.c_str(), this, &staticWrtStatusCallback,
-            (!m_quiet || m_installByPkgmgr)
-            ? &staticWrtUninstallProgressCallback : NULL,
-            pkgmgrSignalInterface);
+                         (!m_quiet || m_installByPkgmgr)
+                         ? &staticWrtUninstallProgressCallback : NULL,
+                         pkgmgrSignalInterface);
 }
 
 void WrtInstaller::uninstallGuidStep()
 {
     LogDebug("Uninstalling widget ...");
-    std::string pkgname;
-    WrtErrStatus status = wrt_get_widget_by_guid(pkgname, m_name);
+    std::string appid;
+    WrtErrStatus status = wrt_get_widget_by_guid(appid, m_name);
     if (status == WRT_SUCCESS) {
         LogDebug("Guid : " << m_name);
-        wrt_uninstall_widget(pkgname.c_str(), this, &staticWrtStatusCallback,
-                !m_quiet ? &staticWrtUninstallProgressCallback : NULL,
-                pkgmgrSignalInterface);
+        wrt_uninstall_widget(
+            appid.c_str(), this, &staticWrtStatusCallback,
+            !m_quiet ? &staticWrtUninstallProgressCallback :
+            NULL,
+            pkgmgrSignalInterface);
     } else {
         printf("failed: can not uninstall widget\n");
         LogError("Fail to uninstalling widget... ");
         m_returnStatus = -1;
-        DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+        DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
+            PostEvent(
             WRTInstallerNS::QuitEvent());
     }
 }
@@ -492,11 +502,11 @@ void WrtInstaller::unistallWgtFileStep()
 
         // Open zip file
         std::unique_ptr<DPL::ZipInput> zipFile(
-                new DPL::ZipInput(m_packagePath));
+            new DPL::ZipInput(m_packagePath));
 
         // Open config.xml file
         std::unique_ptr<DPL::ZipInput::File> configFile(
-                zipFile->OpenFile(CONFIG_XML));
+            zipFile->OpenFile(CONFIG_XML));
 
         // Extract config
         DPL::BinaryQueue buffer;
@@ -504,27 +514,30 @@ void WrtInstaller::unistallWgtFileStep()
         DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
         DPL::Copy(&inputAdapter, &outputAdapter);
         parser.Parse(&buffer,
-                ElementParserPtr(
-                    new RootParser<WidgetParser>(configInfo,
-                        DPL::FromUTF32String(
-                            L"widget"))));
+                     ElementParserPtr(
+                         new RootParser<WidgetParser>(configInfo,
+                                                      DPL::FromUTF32String(
+                                                          L"widget"))));
 
         DPL::OptionalString widgetGUID = configInfo.widget_id;
 
         std::string guid = DPL::ToUTF8String(*widgetGUID);
 
-        std::string pkgname;
-        WrtErrStatus status = wrt_get_widget_by_guid(pkgname, guid);
+        std::string appid;
+        WrtErrStatus status = wrt_get_widget_by_guid(appid, guid);
         if (status == WRT_SUCCESS) {
-            LogDebug("Pkgname from packagePath : " << pkgname);
-            wrt_uninstall_widget(pkgname.c_str(), this, &staticWrtStatusCallback,
-                    !m_quiet ? &staticWrtUninstallProgressCallback : NULL,
-                    pkgmgrSignalInterface);
+            LogDebug("Appid from packagePath : " << appid);
+            wrt_uninstall_widget(
+                appid.c_str(), this, &staticWrtStatusCallback,
+                !m_quiet ? &staticWrtUninstallProgressCallback
+                : NULL,
+                pkgmgrSignalInterface);
         } else {
             LogError("Fail to uninstalling widget... ");
             m_returnStatus = -1;
-            DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
-                    WRTInstallerNS::QuitEvent());
+            DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
+                PostEvent(
+                WRTInstallerNS::QuitEvent());
         }
     }
     Catch(DPL::ZipInput::Exception::OpenFailed)
@@ -532,24 +545,27 @@ void WrtInstaller::unistallWgtFileStep()
         LogError("Failed to open widget package");
         printf("failed: widget package does not exist\n");
         m_returnStatus = -1;
-        DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
-                WRTInstallerNS::QuitEvent());
+        DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
+            PostEvent(
+            WRTInstallerNS::QuitEvent());
     }
     Catch(DPL::ZipInput::Exception::OpenFileFailed)
     {
         printf("failed: widget config file does not exist\n");
         LogError("Failed to open config.xml file");
         m_returnStatus = -1;
-        DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
-                WRTInstallerNS::QuitEvent());
+        DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
+            PostEvent(
+            WRTInstallerNS::QuitEvent());
     }
     Catch(ElementParser::Exception::ParseError)
     {
         printf("failed: can not parse config file\n");
         LogError("Failed to parse config.xml file");
         m_returnStatus = -1;
-        DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
-                WRTInstallerNS::QuitEvent());
+        DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
+            PostEvent(
+            WRTInstallerNS::QuitEvent());
     }
 }
 
@@ -559,13 +575,14 @@ void WrtInstaller::shutdownStep()
     if (m_initialized) {
         wrt_installer_shutdown();
         m_initialized = false;
-        DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+        DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
+            PostEvent(
             WRTInstallerNS::QuitEvent());
     }
 }
 
 void WrtInstaller::staticWrtInitCallback(WrtErrStatus status,
-                                      void* userdata)
+                                         void* userdata)
 {
     WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
     Assert(This);
@@ -585,7 +602,8 @@ void WrtInstaller::staticWrtInitCallback(WrtErrStatus status,
     } else {
         LogError("Init unsuccesfull");
         This->m_returnStatus = -1;
-        This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+        This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
+            PostEvent(
             WRTInstallerNS::QuitEvent());
     }
 }
@@ -601,13 +619,12 @@ void WrtInstaller::staticWrtStatusCallback(std::string tizenId,
     DPL::String resultMsg;
     std::string printMsg;
 
-    if (current == &WrtInstaller::installStep)
-    {
+    if (current == &WrtInstaller::installStep) {
         resultMsg = DPL::FromUTF8String(PKGMGR_INSTALL_MSG);
         printMsg = "installation";
     } else if (current == &WrtInstaller::uninstallPkgNameStep ||
-            current == &WrtInstaller::uninstallGuidStep ||
-            current == &WrtInstaller::unistallWgtFileStep)
+               current == &WrtInstaller::uninstallGuidStep ||
+               current == &WrtInstaller::unistallWgtFileStep)
     {
         resultMsg = DPL::FromUTF8String(PKGMGR_UNINSTALL_MSG);
         printMsg = "uninstallation";
@@ -619,7 +636,7 @@ void WrtInstaller::staticWrtStatusCallback(std::string tizenId,
         This->m_returnStatus = -1;
 
         if (This->popupsEnabled()) {
-            resultMsg +=  L" : " + DPL::FromUTF8String(PKGMGR_END_FAILURE);
+            resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_FAILURE);
             This->m_popup->showPopup(This, resultMsg, failResultCallback);
         } else {
             This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
@@ -643,11 +660,6 @@ void WrtInstaller::staticWrtStatusCallback(std::string tizenId,
                         tizenId.c_str(), printMsg.c_str());
                 break;
 
-            case WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE:
-                fprintf(stderr,"## wrt-installer : %s %s has failed - out of disk space\n",
-                        tizenId.c_str(), printMsg.c_str());
-                break;
-
             case WRT_INSTALLER_ERROR_INVALID_CERTIFICATE:
                 fprintf(stderr,"## wrt-installer : %s %s has failed - invalid certificate\n",
                         tizenId.c_str(), printMsg.c_str());
@@ -691,25 +703,28 @@ void WrtInstaller::staticWrtStatusCallback(std::string tizenId,
 
             default:
                 break;
-
         }
     } else {
-        fprintf(stderr, "## wrt-installer : %s %s was successful.\n", tizenId.c_str(), printMsg.c_str());
+        fprintf(stderr,
+                "## wrt-installer : %s %s was successful.\n",
+                tizenId.c_str(),
+                printMsg.c_str());
         LogDebug("Status succesfull");
         This->m_returnStatus = 0;
-        resultMsg +=  L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
+        resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
 
         if (This->popupsEnabled()) {
             This->m_popup->showPopup(This, resultMsg, showResultCallback);
         } else {
-            This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
+            This->DPL::Event::ControllerEventHandler<WRTInstallerNS::
+                                                         NextStepEvent>
                 ::PostEvent(WRTInstallerNS::NextStepEvent());
         }
     }
 }
 
 void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
-                                                    void* userdata)
+                                                       void* userdata)
 {
     Assert(userdata);
 
@@ -725,7 +740,7 @@ void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
 
     if (This->m_numPluginsToInstall < 1) {
         LogDebug("All plugins installation completed");
-        fprintf(stderr,"All plugins installation completed.\n");
+        fprintf(stderr, "All plugins installation completed.\n");
 
         //remove installation request
         if (!PluginUtils::removeInstallationRequiredFlag()) {
@@ -748,18 +763,23 @@ void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
     } else {
         if (This->popupsEnabled()) {
             This->m_popup->init();
-            float percent = (This->m_totalPlugins - This->m_numPluginsToInstall)/(float)This->m_totalPlugins;
+            float percent =
+                (This->m_totalPlugins -
+                 This->m_numPluginsToInstall) / (float)This->m_totalPlugins;
             elm_progressbar_value_set(This->m_popup->m_progressbar, percent);
             evas_object_show(This->m_popup->m_popup);
         }
 
-        This->DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>::PostEvent(
-                WRTInstallerNS::InstallPluginEvent());
+        This->DPL::Event::ControllerEventHandler<WRTInstallerNS::
+                                                     InstallPluginEvent>::
+            PostEvent(
+            WRTInstallerNS::InstallPluginEvent());
     }
 
     if (WRT_SUCCESS == status) {
         This->m_returnStatus = 0;
-        fprintf(stderr, "## wrt-installer : plugin installation successfull [%s]\n",
+        fprintf(stderr,
+                "## wrt-installer : plugin installation successfull [%s]\n",
                 path.c_str());
         LogDebug("One plugin Installation succesfull: " << path);
         return;
@@ -814,30 +834,30 @@ void WrtInstaller::staticWrtPluginInstallProgressCb(float percent,
 }
 
 void WrtInstaller::staticWrtInstallProgressCallback(float percent,
-        const char* description, void* userdata)
+                                                    const char* description,
+                                                    void* userdata)
 {
     WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
-    std::stringstream percentStr;
     LogInfo(" progress: " << percent <<
             " description: " << description);
 
     if (This->popupsEnabled()) {
         This->m_popup->init();
-        elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
+        elm_progressbar_value_set(This->m_popup->m_progressbar, percent / 100.0);
         evas_object_show(This->m_popup->m_popup);
     }
 }
 void WrtInstaller::staticWrtUninstallProgressCallback(float percent,
-        const char* description, void* userdata)
+                                                      const char* description,
+                                                      void* userdata)
 {
     WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
-    std::stringstream percentStr;
     LogInfo(" progress: " << percent <<
             " description: " << description);
 
     if (This->popupsEnabled()) {
         This->m_popup->init();
-        elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
+        elm_progressbar_value_set(This->m_popup->m_progressbar, percent / 100.0);
         evas_object_show(This->m_popup->m_popup);
     }
 }
@@ -846,8 +866,7 @@ WrtInstaller::InstallerPopup::InstallerPopup() :
     m_win(NULL),
     m_popup(NULL),
     m_progressbar(NULL)
-{
-}
+{}
 
 WrtInstaller::InstallerPopup::~InstallerPopup()
 {
@@ -870,9 +889,9 @@ void WrtInstaller::InstallerPopup::init()
         elm_object_style_set(m_progressbar, "list_progress");
         elm_progressbar_horizontal_set(m_progressbar, EINA_TRUE);
         evas_object_size_hint_align_set(m_progressbar, EVAS_HINT_FILL,
-            EVAS_HINT_FILL);
+                                        EVAS_HINT_FILL);
         evas_object_size_hint_weight_set(m_progressbar, EVAS_HINT_EXPAND,
-            EVAS_HINT_EXPAND);
+                                         EVAS_HINT_EXPAND);
         elm_object_content_set(m_popup, m_progressbar);
         elm_progressbar_value_set(m_progressbar, 0.0);
         evas_object_show(m_progressbar);
@@ -888,8 +907,9 @@ Evas_Object* WrtInstaller::InstallerPopup::createWin(const char *name)
     win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
 
     int w, h;
-    if(!win)
+    if (!win) {
         return NULL;
+    }
 
     elm_win_alpha_set(win, EINA_TRUE);
     elm_win_title_set(win, name);
@@ -907,14 +927,14 @@ void WrtInstaller::InstallerPopup::showPopup(void* userdata,
 {
     Evas_Object *btn;
 
-
     LogDebug("Result Popup Created");
     evas_object_del(m_popup);
     m_popup = NULL;
 
     m_popup = elm_popup_add(m_win);
-    if (!m_popup)
+    if (!m_popup) {
         return;
+    }
 
     btn = elm_button_add(m_popup);
     if (!btn) {
@@ -929,7 +949,6 @@ void WrtInstaller::InstallerPopup::showPopup(void* userdata,
 
     evas_object_show(m_popup);
     evas_object_show(m_win);
-
 }
 
 void WrtInstaller::showResultCallback(void *data, Evas_Object* /*obj*/,
@@ -991,8 +1010,8 @@ int main(int argc, char *argv[])
         // 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 << ")" );
+            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;
index 723236f..29e9835 100644 (file)
@@ -53,35 +53,35 @@ enum ReturnValue
 };
 
 class WrtInstaller :
-        public DPL::Application,
-        private DPL::Event::Controller<DPL::TypeListDecl<
-            WRTInstallerNS::QuitEvent,
-            WRTInstallerNS::NextStepEvent,
-            WRTInstallerNS::InstallPluginEvent>::Type>,
-        public DPL::TaskDecl<WrtInstaller>
+    public DPL::Application,
+    private DPL::Event::Controller<DPL::TypeListDecl<
+                                       WRTInstallerNS::QuitEvent,
+                                       WRTInstallerNS::NextStepEvent,
+                                       WRTInstallerNS::InstallPluginEvent>::
+                                       Type>,
+    public DPL::TaskDecl<WrtInstaller>
 {
   public:
     WrtInstaller(int argc,
-              char **argv);
+                 char **argv);
     virtual ~WrtInstaller();
 
-
     int getReturnStatus() const;
 
     class InstallerPopup
     {
-        public:
-            InstallerPopup();
-            virtual ~InstallerPopup();
-
-            void init();
-            Evas_Object* createWin(const char* name);
-            void showPopup(void* userdata, const DPL::String& pkgMsg,
-                           ShowResultCallback callback);
-
-            Evas_Object* m_win;
-            Evas_Object* m_popup;
-            Evas_Object* m_progressbar;
+      public:
+        InstallerPopup();
+        virtual ~InstallerPopup();
+
+        void init();
+        Evas_Object* createWin(const char* name);
+        void showPopup(void* userdata, const DPL::String& pkgMsg,
+                       ShowResultCallback callback);
+
+        Evas_Object* m_win;
+        Evas_Object* m_popup;
+        Evas_Object* m_progressbar;
     };
 
   protected:
@@ -96,7 +96,8 @@ class WrtInstaller :
     // Events
     virtual void OnEventReceived(const WRTInstallerNS::QuitEvent &event);
     virtual void OnEventReceived(const WRTInstallerNS::NextStepEvent& event);
-    virtual void OnEventReceived(const WRTInstallerNS::InstallPluginEvent& event);
+    virtual void OnEventReceived(
+        const WRTInstallerNS::InstallPluginEvent& event);
 
     // Installation steps
     void initStep();
@@ -110,7 +111,6 @@ class WrtInstaller :
     void registerCallbackStep();
     void queryListStep();
 
-
     // Static callbacks
     static void staticWrtInitCallback(WrtErrStatus status,
                                       void* userdata);
@@ -123,12 +123,12 @@ class WrtInstaller :
                                                  const char* description,
                                                  void* userdata);
     static void staticWrtInstallProgressCallback(float percent,
-                                                const char* description,
-                                                void* userdata);
+                                                 const char* description,
+                                                 void* userdata);
 
     static void staticWrtUninstallProgressCallback(float percent,
-                                                const char* description,
-                                                void* userdata);
+                                                   const char* description,
+                                                   void* userdata);
 
     static void showResultCallback(void *data, Evas_Object *obj,
                                    void *event_info);
index e481f2f..f6bb4fb 100644 (file)
@@ -59,561 +59,559 @@ using namespace WrtDB;
 extern "C"
 {
 #endif
-    inline WidgetUpdateMode::Type translateWidgetUpdateMode(
-            wrt_widget_update_mode_t updateMode)
-    {
-        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;
-        }
-
-        if (updateMode & WRT_WIM_INCOMING_VERSION_NOT_STD) {
-            result = result | WidgetUpdateMode::IncomingVersionNotStd;
-        }
-
-        if (updateMode & WRT_WIM_EXISTING_VERSION_NOT_STD) {
-            result = result | WidgetUpdateMode::ExistingVersionNotStd;
-        }
-
-        if (updateMode & WRT_WIM_BOTH_VERSIONS_NOT_STD) {
-            result = result | WidgetUpdateMode::BothVersionsNotStd;
-        }
-
-        if (updateMode & WRT_WIM_EXISTING_VERSION_OLDER) {
-            result = result | WidgetUpdateMode::ExistingVersionOlder;
-        }
+inline WidgetUpdateMode::Type translateWidgetUpdateMode(
+    wrt_widget_update_mode_t updateMode)
+{
+    if (updateMode == WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL) {
+        return WidgetUpdateMode::PolicyDirectoryForceInstall;
+    }
 
-        if (updateMode & WRT_WIM_EXISTING_VERSION_EQUAL) {
-            result = result | WidgetUpdateMode::ExistingVersionEqual;
-        }
+    WidgetUpdateMode::Type result = WidgetUpdateMode::Zero;
+    if (updateMode & WRT_WIM_NOT_INSTALLED) {
+        result = result | WidgetUpdateMode::NotInstalled;
+    }
 
-        if (updateMode & WRT_WIM_EXISTING_VERSION_NEWER) {
-            result = result | WidgetUpdateMode::ExistingVersionNewer;
-        }
+    if (updateMode & WRT_WIM_INCOMING_VERSION_NOT_STD) {
+        result = result | WidgetUpdateMode::IncomingVersionNotStd;
+    }
 
-        return result;
+    if (updateMode & WRT_WIM_EXISTING_VERSION_NOT_STD) {
+        result = result | WidgetUpdateMode::ExistingVersionNotStd;
     }
 
-    const char PLUGIN_INSTALL_SEMAPHORE[] = "/.wrt_plugin_install_lock";
-    static int wrt_count_plugin;
+    if (updateMode & WRT_WIM_BOTH_VERSIONS_NOT_STD) {
+        result = result | WidgetUpdateMode::BothVersionsNotStd;
+    }
 
-    static std::string cutOffFileName(const std::string& path)
-    {
-        size_t found = path.find_last_of("/");
-        if (found == std::string::npos) {
-            return path;
-        } else {
-            return path.substr(0, found);
-        }
+    if (updateMode & WRT_WIM_EXISTING_VERSION_OLDER) {
+        result = result | WidgetUpdateMode::ExistingVersionOlder;
     }
 
-    static bool checkPath(const std::string& path)
-    {
-        struct stat st;
-        if (0 == stat(path.c_str(), &st) && S_ISDIR(st.st_mode)) {
-            return true;
-        }
-        LogError("Cannot access directory [ " << path << " ]");
-        return false;
+    if (updateMode & WRT_WIM_EXISTING_VERSION_EQUAL) {
+        result = result | WidgetUpdateMode::ExistingVersionEqual;
     }
 
-    static bool checkPaths()
-    {
-        bool if_ok = true;
-        if_ok &= (checkPath(cutOffFileName(
-                GlobalConfig::GetWrtDatabaseFilePath())));
-        if (!if_ok) {
-            LogError(
-                "Path <" << GlobalConfig::GetWrtDatabaseFilePath() <<
-                "> does not exist.");
-        }
+    if (updateMode & WRT_WIM_EXISTING_VERSION_NEWER) {
+        result = result | WidgetUpdateMode::ExistingVersionNewer;
+    }
 
-        if_ok &= (checkPath(GlobalConfig::GetDevicePluginPath()));
-        if (!if_ok) {
-            LogError(
-                "Path <" << GlobalConfig::GetDevicePluginPath() <<
-                "> does not exist.");
-        }
+    return result;
+}
 
-        if_ok &= (checkPath(GlobalConfig::GetUserInstalledWidgetPath()));
-        if (!if_ok) {
-            LogError(
-                "Path <" << GlobalConfig::GetUserInstalledWidgetPath() <<
-                "> does not exist.");
-        }
+const char PLUGIN_INSTALL_SEMAPHORE[] = "/.wrt_plugin_install_lock";
+static int wrt_count_plugin;
 
-        if_ok &= (checkPath(GlobalConfig::GetUserPreloadedWidgetPath()));
-        if (!if_ok) {
-            LogError(
-                "Path <" << GlobalConfig::GetUserPreloadedWidgetPath() <<
-                "> does not exist.");
-        }
-        return if_ok;
+static std::string cutOffFileName(const std::string& path)
+{
+    size_t found = path.find_last_of("/");
+    if (found == std::string::npos) {
+        return path;
+    } else {
+        return path.substr(0, found);
     }
+}
 
-    void plugin_install_status_cb(WrtErrStatus status,
-                                  void* userparam)
-    {
-        Assert(userparam);
-
-        wrt_plugin_data *plugin_data = static_cast<wrt_plugin_data*>(userparam);
+static bool checkPath(const std::string& path)
+{
+    struct stat st;
+    if (0 == stat(path.c_str(), &st) && S_ISDIR(st.st_mode)) {
+        return true;
+    }
+    LogError("Cannot access directory [ " << path << " ]");
+    return false;
+}
 
-        if (--wrt_count_plugin < 1) {
-            LogDebug("All plugins installation completed");
+static bool checkPaths()
+{
+    bool if_ok = true;
+    if_ok &= (checkPath(cutOffFileName(
+                            GlobalConfig::GetWrtDatabaseFilePath())));
+    if (!if_ok) {
+        LogError(
+            "Path <" << GlobalConfig::GetWrtDatabaseFilePath() <<
+            "> does not exist.");
+    }
 
-            LogDebug("Call SetAllinstallpluginsCallback");
-            plugin_data->plugin_installed_cb(plugin_data->user_data);
-        }
+    if_ok &= (checkPath(GlobalConfig::GetDevicePluginPath()));
+    if (!if_ok) {
+        LogError(
+            "Path <" << GlobalConfig::GetDevicePluginPath() <<
+            "> does not exist.");
+    }
 
-        if (status == WRT_SUCCESS) {
-            LogInfo(
-                "plugin installation is successful: " <<
-                plugin_data->plugin_path);
-            return;
-        }
+    if_ok &= (checkPath(GlobalConfig::GetUserInstalledWidgetPath()));
+    if (!if_ok) {
+        LogError(
+            "Path <" << GlobalConfig::GetUserInstalledWidgetPath() <<
+            "> does not exist.");
+    }
 
-        LogError("Fail to install plugin : " << plugin_data->plugin_path);
-
-        switch (status) {
-        case WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH:
-            LogError("Failed : Plugin install path is wrong");
-            break;
-        case WRT_PLUGIN_INSTALLER_ERROR_METAFILE:
-            LogError("Failed : Plugin Metafile Error");
-            break;
-        case WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED:
-            LogError("Failed : This Plugin is already installed");
-            break;
-        case WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR:
-            LogError("Failed : Library Error. Missing symbol or structures");
-            break;
-        case WRT_PLUGIN_INSTALLER_ERROR_WAITING:
-            LogError("Failed : Waiting for plugin dependencies");
-            break;
-        case WRT_PLUGIN_INSTALLER_ERROR_LOCK:
-            LogError("Failed : Lock Error");
-            break;
-        case WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN:
-            LogError("Failed : Unkown Error");
-            break;
-        default:
-            break;
-        }
+    if_ok &= (checkPath(GlobalConfig::GetUserPreloadedWidgetPath()));
+    if (!if_ok) {
+        LogError(
+            "Path <" << GlobalConfig::GetUserPreloadedWidgetPath() <<
+            "> does not exist.");
     }
+    return if_ok;
+}
 
-    void plugin_install_progress_cb(float percent,
-                                    const char* description,
-                                    void* userdata)
-    {
-        char *plugin_path = static_cast<char*>(userdata);
+void plugin_install_status_cb(WrtErrStatus status,
+                              void* userparam)
+{
+    Assert(userparam);
 
-        LogInfo("Install plugin : " << plugin_path <<
-                ", Progress : " << percent <<
-                ", Description : " << description);
-    }
+    wrt_plugin_data *plugin_data = static_cast<wrt_plugin_data*>(userparam);
 
-    EXPORT_API int wrt_installer_init(void *userdata,
-                            WrtInstallerInitCallback callback)
-    {
-        // Set DPL/LOG MID
-        DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
+    if (--wrt_count_plugin < 1) {
+        LogDebug("All plugins installation completed");
 
-        try
-        {
-            LogInfo("[WRT-API] INITIALIZING WRT INSTALLER...");
-            LogInfo("[WRT-API] BUILD: " << __TIMESTAMP__);
-
-            // Touch InstallerController Singleton
-            InstallerMainThreadSingleton::Instance().TouchArchitecture();
-
-            // Check paths
-            if (!checkPaths()) {
-                if (callback) {
-                    callback(WRT_ERROR_NO_PATH, userdata);
-                }
-                return TRUE;
-            }
+        LogDebug("Call SetAllinstallpluginsCallback");
+        plugin_data->plugin_installed_cb(plugin_data->user_data);
+    }
 
-            // Initialize ValidationCore - this must be done before AttachDatabases
-            ValidationCore::VCoreInit(
-                    std::string(GlobalConfig::GetFingerprintListFile()),
-                    std::string(GlobalConfig::GetFingerprintListSchema()),
-                    std::string(GlobalConfig::GetVCoreDatabaseFilePath()));
+    if (status == WRT_SUCCESS) {
+        LogInfo(
+            "plugin installation is successful: " <<
+            plugin_data->plugin_path);
+        return;
+    }
 
-            InstallerMainThreadSingleton::Instance().AttachDatabases();
+    LogError("Fail to install plugin : " << plugin_data->plugin_path);
+
+    switch (status) {
+    case WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH:
+        LogError("Failed : Plugin install path is wrong");
+        break;
+    case WRT_PLUGIN_INSTALLER_ERROR_METAFILE:
+        LogError("Failed : Plugin Metafile Error");
+        break;
+    case WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED:
+        LogError("Failed : This Plugin is already installed");
+        break;
+    case WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR:
+        LogError("Failed : Library Error. Missing symbol or structures");
+        break;
+    case WRT_PLUGIN_INSTALLER_ERROR_WAITING:
+        LogError("Failed : Waiting for plugin dependencies");
+        break;
+    case WRT_PLUGIN_INSTALLER_ERROR_LOCK:
+        LogError("Failed : Lock Error");
+        break;
+    case WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN:
+        LogError("Failed : Unkown Error");
+        break;
+    default:
+        break;
+    }
+}
 
-            //checking for correct DB version
-//            if (!WrtDB::WrtDatabase::CheckTableExist(DB_CHECKSUM_STR)) {
-//                LogError("WRONG VERSION OF WRT DATABASE");
-//                Assert(false && "WRONG VERSION OF WRT DATABASE");
-//                return FALSE;
-//            }
-            LogWarning("Database check not implemented!");
+void plugin_install_progress_cb(float percent,
+                                const char* description,
+                                void* userdata)
+{
+    char *plugin_path = static_cast<char*>(userdata);
 
-            LogInfo("Prepare libxml2 to work in multithreaded program.");
-            xmlInitParser();
+    LogInfo("Install plugin : " << plugin_path <<
+            ", Progress : " << percent <<
+            ", Description : " << description);
+}
 
-            // Initialize Language Subtag registry
-            LanguageSubtagRstTreeSingleton::Instance().Initialize();
+EXPORT_API int wrt_installer_init(void *userdata,
+                                  WrtInstallerInitCallback callback)
+{
+    // Set DPL/LOG MID
+    DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
 
-            // Installer init
-            CONTROLLER_POST_SYNC_EVENT(
-                    Logic::InstallerController,
-                    InstallerControllerEvents::
-                    InitializeEvent());
+    try {
+        LogInfo("[WRT-API] INITIALIZING WRT INSTALLER...");
+        LogInfo("[WRT-API] BUILD: " << __TIMESTAMP__);
 
-            // Install deferred widget packages
-            CONTROLLER_POST_EVENT(
-                    Logic::InstallerController,
-                    InstallerControllerEvents::
-                    InstallDeferredWidgetPackagesEvent());
+        // Touch InstallerController Singleton
+        InstallerMainThreadSingleton::Instance().TouchArchitecture();
 
+        // Check paths
+        if (!checkPaths()) {
             if (callback) {
-                LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK");
-                callback(WRT_SUCCESS, userdata);
+                callback(WRT_ERROR_NO_PATH, userdata);
             }
+            return TRUE;
         }
-        catch (const DPL::Exception& ex)
-        {
-            LogError("Internal Error during Init:");
-            DPL::Exception::DisplayKnownException(ex);
-            if (callback) {
-                callback(WRT_ERROR_INTERNAL, userdata);
-            }
-            return FALSE;
-        }
-        // OK
-        return TRUE;
-    }
-
-    EXPORT_API void wrt_installer_shutdown()
-    {
-        try
-        {
-            LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER...");
-
-            // Installer termination
-            CONTROLLER_POST_SYNC_EVENT(
-                    Logic::InstallerController,
-                    InstallerControllerEvents::
-                    TerminateEvent());
-
-            InstallerMainThreadSingleton::Instance().DetachDatabases();
-
-            // This must be done after DetachDatabase
-            ValidationCore::VCoreDeinit();
-
-            // Global deinit check
-            LogInfo("Cleanup libxml2 global values.");
-            xmlCleanupParser();
 
+        // Initialize ValidationCore - this must be done before AttachDatabases
+        ValidationCore::VCoreInit(
+            std::string(GlobalConfig::GetFingerprintListFile()),
+            std::string(GlobalConfig::GetFingerprintListSchema()),
+            std::string(GlobalConfig::GetVCoreDatabaseFilePath()));
+
+        InstallerMainThreadSingleton::Instance().AttachDatabases();
+
+        //checking for correct DB version
+        //            if (!WrtDB::WrtDatabase::CheckTableExist(DB_CHECKSUM_STR))
+        // {
+        //                LogError("WRONG VERSION OF WRT DATABASE");
+        //                Assert(false && "WRONG VERSION OF WRT DATABASE");
+        //                return FALSE;
+        //            }
+        LogWarning("Database check not implemented!");
+
+        LogInfo("Prepare libxml2 to work in multithreaded program.");
+        xmlInitParser();
+
+        // Initialize Language Subtag registry
+        LanguageSubtagRstTreeSingleton::Instance().Initialize();
+
+        // Installer init
+        CONTROLLER_POST_SYNC_EVENT(
+            Logic::InstallerController,
+            InstallerControllerEvents::
+                InitializeEvent());
+
+        // Install deferred widget packages
+        CONTROLLER_POST_EVENT(
+            Logic::InstallerController,
+            InstallerControllerEvents::
+                InstallDeferredWidgetPackagesEvent());
+
+        if (callback) {
+            LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK");
+            callback(WRT_SUCCESS, userdata);
         }
-        catch (const DPL::Exception& ex)
-        {
-            LogError("Internal Error during Shutdown:");
-            DPL::Exception::DisplayKnownException(ex);
+    } catch (const DPL::Exception& ex) {
+        LogError("Internal Error during Init:");
+        DPL::Exception::DisplayKnownException(ex);
+        if (callback) {
+            callback(WRT_ERROR_INTERNAL, userdata);
         }
+        return FALSE;
     }
+    // OK
+    return TRUE;
+}
 
-    EXPORT_API void wrt_install_widget(const char *path,
-                                       void* userdata,
-                                       WrtInstallerStatusCallback status_cb,
-                                       WrtProgressCallback progress_cb,
-                                       wrt_widget_update_mode_t update_mode,
-                                       bool quiet,
-                                       bool preload,
-                                       std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrInterface
-                                       )
+EXPORT_API void wrt_installer_shutdown()
+{
+    try {
+        LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER...");
+
+        // Installer termination
+        CONTROLLER_POST_SYNC_EVENT(
+            Logic::InstallerController,
+            InstallerControllerEvents::
+                TerminateEvent());
+
+        InstallerMainThreadSingleton::Instance().DetachDatabases();
+
+        // This must be done after DetachDatabase
+        ValidationCore::VCoreDeinit();
+
+        // Global deinit check
+        LogInfo("Cleanup libxml2 global values.");
+        xmlCleanupParser();
+    } catch (const DPL::Exception& ex) {
+        LogError("Internal Error during Shutdown:");
+        DPL::Exception::DisplayKnownException(ex);
+    }
+}
+
+EXPORT_API void wrt_install_widget(
+    const char *path,
+    void* userdata,
+    WrtInstallerStatusCallback status_cb,
+    WrtProgressCallback progress_cb,
+    wrt_widget_update_mode_t update_mode,
+    bool quiet,
+    bool preload,
+    std::shared_ptr<PackageManager::
+                        IPkgmgrSignal> pkgmgrInterface
+    )
+{
+    UNHANDLED_EXCEPTION_HANDLER_BEGIN
     {
-        UNHANDLED_EXCEPTION_HANDLER_BEGIN
-        {
-            LogInfo("[WRT-API] INSTALL WIDGET: " << path);
-            // Post installation event
-            CONTROLLER_POST_EVENT(
-                Logic::InstallerController,
-                InstallerControllerEvents::InstallWidgetEvent(
-                    path, WidgetInstallationStruct(
-                        InstallerCallbacksTranslate::installFinishedCallback,
-                        InstallerCallbacksTranslate::installProgressCallback,
-                        new InstallerCallbacksTranslate::StatusCallbackStruct(
-                            userdata, status_cb, progress_cb),
-                        translateWidgetUpdateMode(update_mode),
-                        quiet,
-                        preload,
-                        pkgmgrInterface)));
-        }
-        UNHANDLED_EXCEPTION_HANDLER_END
+        LogInfo("[WRT-API] INSTALL WIDGET: " << path);
+        // Post installation event
+        CONTROLLER_POST_EVENT(
+            Logic::InstallerController,
+            InstallerControllerEvents::InstallWidgetEvent(
+                path, WidgetInstallationStruct(
+                    InstallerCallbacksTranslate::installFinishedCallback,
+                    InstallerCallbacksTranslate::installProgressCallback,
+                    new InstallerCallbacksTranslate::StatusCallbackStruct(
+                        userdata, status_cb, progress_cb),
+                    translateWidgetUpdateMode(update_mode),
+                    quiet,
+                    preload,
+                    pkgmgrInterface)));
     }
+    UNHANDLED_EXCEPTION_HANDLER_END
+}
 
-    EXPORT_API void wrt_uninstall_widget(const char * const pkg_name,
-                                         void* userdata,
-                                         WrtInstallerStatusCallback status_cb,
-                                         WrtProgressCallback progress_cb,
-                                         std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrSignalInterface)
+EXPORT_API void wrt_uninstall_widget(
+    const char * const tzAppid,
+    void* userdata,
+    WrtInstallerStatusCallback status_cb,
+    WrtProgressCallback progress_cb,
+    std::shared_ptr<PackageManager::
+                        IPkgmgrSignal> pkgmgrSignalInterface)
+{
+    UNHANDLED_EXCEPTION_HANDLER_BEGIN
     {
-        UNHANDLED_EXCEPTION_HANDLER_BEGIN
-        {
-            std::string widgetPkgName(pkg_name);
-            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),
-                                    pkgmgrSignalInterface
-                            )
+        std::string tizenAppid(tzAppid);
+        LogInfo("[WRT-API] UNINSTALL WIDGET: " << tizenAppid);
+        // Post uninstallation event
+        CONTROLLER_POST_EVENT(
+            Logic::InstallerController,
+            InstallerControllerEvents::UninstallWidgetEvent(
+                tizenAppid,
+                WidgetUninstallationStruct(
+                    InstallerCallbacksTranslate::uninstallFinishedCallback,
+                    InstallerCallbacksTranslate::installProgressCallback,
+                    new InstallerCallbacksTranslate::StatusCallbackStruct(
+                        userdata, status_cb, progress_cb),
+                    pkgmgrSignalInterface
                     )
+                )
             );
-        }
-        UNHANDLED_EXCEPTION_HANDLER_END
     }
+    UNHANDLED_EXCEPTION_HANDLER_END
+}
 
-    EXPORT_API void wrt_install_plugin(
-        const char *pluginDir,
-        void *user_param,
-        WrtPluginInstallerStatusCallback status_cb,
-        WrtProgressCallback progress_cb)
+EXPORT_API void wrt_install_plugin(
+    const char *pluginDir,
+    void *user_param,
+    WrtPluginInstallerStatusCallback status_cb,
+    WrtProgressCallback progress_cb)
+{
+    UNHANDLED_EXCEPTION_HANDLER_BEGIN
     {
-        UNHANDLED_EXCEPTION_HANDLER_BEGIN
-        {
-            LogInfo("[WRT-API] INSTALL PLUGIN: " << pluginDir);
-            //Private data for status callback
-            //Resource is free in pluginInstallFinishedCallback
-            InstallerCallbacksTranslate::PluginStatusCallbackStruct*
-            callbackStruct =
-                new InstallerCallbacksTranslate::PluginStatusCallbackStruct(
-                    user_param, status_cb, progress_cb);
-
-            CONTROLLER_POST_EVENT(
-                Logic::InstallerController,
-                InstallerControllerEvents::InstallPluginEvent(
-                    std::string(pluginDir),
-                    PluginInstallerStruct(
-                        InstallerCallbacksTranslate::
+        LogInfo("[WRT-API] INSTALL PLUGIN: " << pluginDir);
+        //Private data for status callback
+        //Resource is free in pluginInstallFinishedCallback
+        InstallerCallbacksTranslate::PluginStatusCallbackStruct*
+        callbackStruct =
+            new InstallerCallbacksTranslate::PluginStatusCallbackStruct(
+                user_param, status_cb, progress_cb);
+
+        CONTROLLER_POST_EVENT(
+            Logic::InstallerController,
+            InstallerControllerEvents::InstallPluginEvent(
+                std::string(pluginDir),
+                PluginInstallerStruct(
+                    InstallerCallbacksTranslate::
                         pluginInstallFinishedCallback,
-                        InstallerCallbacksTranslate::
+                    InstallerCallbacksTranslate::
                         installProgressCallback, callbackStruct)));
-        }
-        UNHANDLED_EXCEPTION_HANDLER_END
     }
+    UNHANDLED_EXCEPTION_HANDLER_END
+}
 
-    EXPORT_API void wrt_install_all_plugins(
-        WrtAllPluginInstalledCallback installed_cb,
-        void *user_param)
+EXPORT_API void wrt_install_all_plugins(
+    WrtAllPluginInstalledCallback installed_cb,
+    void *user_param)
+{
+    UNHANDLED_EXCEPTION_HANDLER_BEGIN
     {
-        UNHANDLED_EXCEPTION_HANDLER_BEGIN
-        {
-            std::string installRequest =
-                std::string(GlobalConfig::GetPluginInstallInitializerName());
-
-            LogDebug("Install new plugins");
-
-            Try {
-                DPL::Semaphore lock(PLUGIN_INSTALL_SEMAPHORE);
-            }
-            Catch(DPL::Semaphore::Exception::Base){
-                LogError("Failed to create installation lock");
-                return;
-            }
+        std::string installRequest =
+            std::string(GlobalConfig::GetPluginInstallInitializerName());
 
-            struct stat tmp;
+        LogDebug("Install new plugins");
 
-            if (-1 == stat(installRequest.c_str(), &tmp) ||
-                    !S_ISREG(tmp.st_mode))
-            {
-                if (ENOENT == errno) {
-                    LogDebug("Plugin installation not required");
+        Try {
+            DPL::Semaphore lock(PLUGIN_INSTALL_SEMAPHORE);
+        }
+        Catch(DPL::Semaphore::Exception::Base){
+            LogError("Failed to create installation lock");
+            return;
+        }
 
-                    LogDebug("Call SetAllinstallPluginCallback");
-                    installed_cb(user_param);
+        struct stat tmp;
 
-                    DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
-                    return;
-                }
-                LogWarning("Opening installation request file failed");
-            }
+        if (-1 == stat(installRequest.c_str(), &tmp) ||
+            !S_ISREG(tmp.st_mode))
+        {
+            if (ENOENT == errno) {
+                LogDebug("Plugin installation not required");
 
-            std::string PLUGIN_PATH =
-                std::string(GlobalConfig::GetDevicePluginPath());
+                LogDebug("Call SetAllinstallPluginCallback");
+                installed_cb(user_param);
 
-            DIR *dir;
-            dir = opendir(PLUGIN_PATH.c_str());
-            if (!dir) {
                 DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
                 return;
             }
+            LogWarning("Opening installation request file failed");
+        }
 
-            LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
-            struct dirent* libdir;
+        std::string PLUGIN_PATH =
+            std::string(GlobalConfig::GetDevicePluginPath());
 
-            errno = 0;
+        DIR *dir;
+        dir = opendir(PLUGIN_PATH.c_str());
+        if (!dir) {
+            DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
+            return;
+        }
 
-            std::list<std::string> pluginsPaths;
+        LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
+        struct dirent libdir;
+        struct dirent *result;
+        int return_code;
 
-            while ((libdir = readdir(dir)) != 0) {
-                if (strcmp(libdir->d_name, ".") == 0 ||
-                    strcmp(libdir->d_name, "..") == 0)
-                {
-                    continue;
-                }
+        errno = 0;
 
-                std::string path = PLUGIN_PATH;
-                path += "/";
-                path += libdir->d_name;
+        std::list<std::string> pluginsPaths;
 
-                struct stat tmp;
+        for (return_code = readdir_r(dir, &libdir, &result);
+                    result != NULL && return_code == 0;
+                    return_code = readdir_r(dir, &libdir, &result))
+        {
+            if (strcmp(libdir.d_name, ".") == 0 ||
+                strcmp(libdir.d_name, "..") == 0)
+            {
+                continue;
+            }
 
-                if (stat(path.c_str(), &tmp) == -1) {
-                    LogError("Failed to open file" << path);
-                    continue;
-                }
+            std::string path = PLUGIN_PATH;
+            path += "/";
+            path += libdir.d_name;
 
-                if (!S_ISDIR(tmp.st_mode)) {
-                    LogError("Not a directory" << path);
-                    continue;
-                }
+            struct stat tmp;
 
-                pluginsPaths.push_back(path);
+            if (stat(path.c_str(), &tmp) == -1) {
+                LogError("Failed to open file" << path);
+                continue;
             }
 
-            wrt_count_plugin = pluginsPaths.size();
+            if (!S_ISDIR(tmp.st_mode)) {
+                LogError("Not a directory" << path);
+                continue;
+            }
 
-            FOREACH(it, pluginsPaths) {
-                wrt_plugin_data *plugin_data = new wrt_plugin_data;
+            pluginsPaths.push_back(path);
+        }
 
-                plugin_data->plugin_installed_cb = installed_cb;
-                plugin_data->plugin_path = const_cast<char*>(it->c_str());
-                plugin_data->user_data = user_param;
+        wrt_count_plugin = pluginsPaths.size();
 
-                wrt_install_plugin(
-                    it->c_str(), static_cast<void*>(plugin_data),
-                    plugin_install_status_cb,
-                    plugin_install_progress_cb);
-            }
+        FOREACH(it, pluginsPaths) {
+            wrt_plugin_data *plugin_data = new wrt_plugin_data;
 
-            if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
-                LogError("Failed to close dir: " << PLUGIN_PATH << " with error: "
-                        << DPL::GetErrnoString());
-            }
+            plugin_data->plugin_installed_cb = installed_cb;
+            plugin_data->plugin_path = const_cast<char*>(it->c_str());
+            plugin_data->user_data = user_param;
 
-            if (0 != unlink(installRequest.c_str())) {
-                LogError("Failed to remove file initializing plugin "
-                         "installation");
-            }
+            wrt_install_plugin(
+                it->c_str(), static_cast<void*>(plugin_data),
+                plugin_install_status_cb,
+                plugin_install_progress_cb);
+        }
 
-            Try {
-                DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
-            }
-            Catch(DPL::Semaphore::Exception::Base){
-                LogInfo("Failed to remove installation lock");
-            }
+        if (return_code != 0 || errno != 0) {
+            LogError("readdir_r() failed with " << DPL::GetErrnoString());
+        }
+
+        errno = 0;
+        if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
+            LogError("Failed to close dir: " << PLUGIN_PATH << " with error: "
+                                             << DPL::GetErrnoString());
+        }
+
+        if (0 != unlink(installRequest.c_str())) {
+            LogError("Failed to remove file initializing plugin "
+                     "installation");
+        }
+
+        Try {
+            DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
+        }
+        Catch(DPL::Semaphore::Exception::Base){
+            LogInfo("Failed to remove installation lock");
         }
-        UNHANDLED_EXCEPTION_HANDLER_END
     }
+    UNHANDLED_EXCEPTION_HANDLER_END
+}
 
-    EXPORT_API int wrt_installer_init_for_tests(void *userdata,
-                            WrtInstallerInitCallback callback)
-    {
-        // Set DPL/LOG MID
-        DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
+EXPORT_API int wrt_installer_init_for_tests(void *userdata,
+                                            WrtInstallerInitCallback callback)
+{
+    // Set DPL/LOG MID
+    DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
 
-        try
-        {
-            LogInfo("[WRT-API] INITIALIZING WRT INSTALLER...");
-            LogInfo("[WRT-API] BUILD: " << __TIMESTAMP__);
-
-            // Touch InstallerController Singleton
-            InstallerMainThreadSingleton::Instance().
-                TouchArchitectureOnlyInstaller();
-
-            // Check paths
-            if (!checkPaths()) {
-                if (callback) {
-                    callback(WRT_ERROR_NO_PATH, userdata);
-                }
-                return TRUE;
-            }
+    try {
+        LogInfo("[WRT-API] INITIALIZING WRT INSTALLER...");
+        LogInfo("[WRT-API] BUILD: " << __TIMESTAMP__);
 
-            CONTROLLER_POST_SYNC_EVENT(
-                    Logic::InstallerController,
-                    InstallerControllerEvents::
-                    InitializeEvent());
+        // Touch InstallerController Singleton
+        InstallerMainThreadSingleton::Instance().
+            TouchArchitectureOnlyInstaller();
 
+        // Check paths
+        if (!checkPaths()) {
             if (callback) {
-                LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK");
-                callback(WRT_SUCCESS, userdata);
+                callback(WRT_ERROR_NO_PATH, userdata);
             }
+            return TRUE;
         }
-        catch (const DPL::Exception& ex)
-        {
-            LogError("Internal Error during Init:");
-            DPL::Exception::DisplayKnownException(ex);
-            if (callback) {
-                callback(WRT_ERROR_INTERNAL, userdata);
-            }
-            return FALSE;
-        }
-
-        // OK
-        return TRUE;
-    }
 
-    EXPORT_API void wrt_installer_shutdown_for_tests()
-    {
-        try
-        {
-            LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER...");
+        CONTROLLER_POST_SYNC_EVENT(
+            Logic::InstallerController,
+            InstallerControllerEvents::
+                InitializeEvent());
 
-            // Installer termination
-            CONTROLLER_POST_SYNC_EVENT(
-                    Logic::InstallerController,
-                    InstallerControllerEvents::
-                    TerminateEvent());
-
-            // Global deinit check
-            LogInfo("Cleanup libxml2 global values.");
-            xmlCleanupParser();
+        if (callback) {
+            LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK");
+            callback(WRT_SUCCESS, userdata);
         }
-        catch (const DPL::Exception& ex)
-        {
-            LogError("Internal Error during Shutdown:");
-            DPL::Exception::DisplayKnownException(ex);
+    } catch (const DPL::Exception& ex) {
+        LogError("Internal Error during Init:");
+        DPL::Exception::DisplayKnownException(ex);
+        if (callback) {
+            callback(WRT_ERROR_INTERNAL, userdata);
         }
+        return FALSE;
     }
 
-    EXPORT_API WrtErrStatus wrt_get_widget_by_guid(std::string & pkgname,
-                                                   const std::string guid)
-    {
-        try
-        {
-            LogInfo("[WRT-API] GETTING WIDGET PACKAGE NAME BY WidgetID : "
-                    << guid);
+    // OK
+    return TRUE;
+}
 
-            WidgetGUID widget_guid = DPL::FromUTF8String(guid);
-            WrtDB::WidgetDAOReadOnly dao(widget_guid);
-            pkgname = DPL::ToUTF8String(dao.getPkgName());
-            return WRT_SUCCESS;
-        }
-        catch (WidgetDAOReadOnly::Exception::WidgetNotExist)
-        {
-            LogError("Error package name is not found");
-            return WRT_ERROR_PKGNAME_NOT_FOUND;
-        }
-        catch (const DPL::Exception& ex)
-        {
-            LogError("Internal Error during get widget id by package name");
-            DPL::Exception::DisplayKnownException(ex);
-            return WRT_ERROR_INTERNAL;
-        }
+EXPORT_API void wrt_installer_shutdown_for_tests()
+{
+    try {
+        LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER...");
+
+        // Installer termination
+        CONTROLLER_POST_SYNC_EVENT(
+            Logic::InstallerController,
+            InstallerControllerEvents::
+                TerminateEvent());
+
+        // Global deinit check
+        LogInfo("Cleanup libxml2 global values.");
+        xmlCleanupParser();
+    } catch (const DPL::Exception& ex) {
+        LogError("Internal Error during Shutdown:");
+        DPL::Exception::DisplayKnownException(ex);
     }
+}
+
+EXPORT_API WrtErrStatus wrt_get_widget_by_guid(std::string & tzAppid,
+                                               const std::string & guid)
+{
+    try {
+        LogInfo("[WRT-API] GETTING WIDGET PACKAGE NAME BY WidgetID : "
+                << guid);
+
+        WidgetGUID widget_guid = DPL::FromUTF8String(guid);
+        WrtDB::WidgetDAOReadOnly dao(widget_guid);
+        tzAppid = DPL::ToUTF8String(dao.getTzAppId());
+        return WRT_SUCCESS;
+    } catch (WidgetDAOReadOnly::Exception::WidgetNotExist&) {
+        LogError("Error package name is not found");
+        return WRT_ERROR_PKGNAME_NOT_FOUND;
+    } catch (const DPL::Exception& ex) {
+        LogError("Internal Error during get widget id by package name");
+        DPL::Exception::DisplayKnownException(ex);
+        return WRT_ERROR_INTERNAL;
+    }
+}
 #ifdef __cplusplus
 }
 #endif
old mode 100755 (executable)
new mode 100644 (file)
index 6f2bea6..c8a058c
@@ -44,7 +44,7 @@ extern "C" {
  * Callback function type invoked after async init function
  */
 typedef void (*WrtInstallerInitCallback)(WrtErrStatus status,
-                                void *data);
+                                         void *data);
 
 /**
  * Callback function type invoked after async functions
@@ -56,8 +56,8 @@ typedef void (*WrtPluginInstallerStatusCallback)(WrtErrStatus status,
  * Callback function type invoked after async functions
  */
 typedef void (*WrtInstallerStatusCallback)(std::string tizenId,
-                                  WrtErrStatus status,
-                                  void *data);
+                                           WrtErrStatus status,
+                                           void *data);
 
 /**
  * Callback function type invoked after async functions
@@ -160,7 +160,7 @@ typedef enum wrt_widget_install_mode_e
 } wrt_widget_update_mode_t;
 
 int wrt_installer_init(void *userdata,
-        WrtInstallerInitCallback callback);
+                       WrtInstallerInitCallback callback);
 
 /**
  * @fn void wrt_installer_shutdown(void)
@@ -237,31 +237,33 @@ void wrt_installer_shutdown(void);
  *
  * @see wrt_installer_uninstall_widget
  */
-void wrt_install_widget(const char *path,
-        void *user_parameter,
-        WrtInstallerStatusCallback status_callback,
-        WrtProgressCallback progress_callback,
-        wrt_widget_update_mode_t update_mode,
-        bool quiet,
-        bool preload,
-        std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrInterface
-        );
+void wrt_install_widget(
+    const char *path,
+    void *user_parameter,
+    WrtInstallerStatusCallback status_callback,
+    WrtProgressCallback progress_callback,
+    wrt_widget_update_mode_t update_mode,
+    bool quiet,
+    bool preload,
+    std::shared_ptr<PackageManager::IPkgmgrSignal>
+    pkgmgrInterface
+    );
 
 /**
- * @fn void wrt_installer_uninstall_widget (const char * const pkg_name,
+ * @fn void wrt_installer_uninstall_widget (const char * const tizenAppid,
  *                                void* userdata,
  *                                WrtInstallerStatusCallback cb)
  * @brief Uninstalls widget using its name
  *
- * This method is used to uninstall the widget specified by its pkgname.
+ * This method is used to uninstall the widget specified by its appid.
  * The callback function is called when the uninstall operation is done.
  *
- * @param [in]  pkg_name    - package name
+ * @param [in]  tzAppid     - tizen appid
  * @param [in]  userdata    - user parameters to be passed to the callback
  * @param [in]  status_cb   - Call to this one will be done at the end of
  *                            operation
  *                            The callback is called in the context of the
                             application's
*                            application's
  * @param [in]  progress_cb - Callback function to get data of install progress
  *                            If you don't want to get progress data, this
  *                            should be NULL
@@ -275,11 +277,13 @@ void wrt_install_widget(const char *path,
  *
  * @see wrt_installer_install_widget
  */
-void wrt_uninstall_widget (const char * const pkg_name,
-        void* userdata,
-        WrtInstallerStatusCallback status_cb,
-        WrtProgressCallback progress_cb,
-        std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrSignalInterface);
+void wrt_uninstall_widget (
+    const char * const tzAppid,
+    void* userdata,
+    WrtInstallerStatusCallback status_cb,
+    WrtProgressCallback progress_cb,
+    std::shared_ptr<PackageManager::IPkgmgrSignal>
+    pkgmgrSignalInterface);
 
 /**
  *  @fn void wrt_install_plugin(const char *pluginDirectory,
@@ -308,9 +312,9 @@ void wrt_uninstall_widget (const char * const pkg_name,
  * @see wrt_install_plugin
  */
 void wrt_install_plugin(const char *pluginDirectory,
-        void *userData,
-        WrtPluginInstallerStatusCallback statusCallback,
-        WrtProgressCallback progressCallback);
+                        void *userData,
+                        WrtPluginInstallerStatusCallback statusCallback,
+                        WrtProgressCallback progressCallback);
 
 /**
  * @brief To install plugins for first excution
@@ -320,7 +324,7 @@ void wrt_install_plugin(const char *pluginDirectory,
  * @return nothing
  */
 void wrt_install_all_plugins(WrtAllPluginInstalledCallback installed_cb,
-        void *user_param);
+                             void *user_param);
 
 /**
  * @brief To initialize for tests
@@ -330,7 +334,7 @@ void wrt_install_all_plugins(WrtAllPluginInstalledCallback installed_cb,
  * @return int
  */
 int wrt_installer_init_for_tests(void *userdata,
-        WrtInstallerInitCallback callback);
+                                 WrtInstallerInitCallback callback);
 
 /**
  * @brief To shutdown for tests
@@ -342,12 +346,13 @@ int wrt_installer_init_for_tests(void *userdata,
 void wrt_installer_shutdown_for_tests();
 
 /**
- * @brief wrt_get_widget_by_guid Returns pkgname by pkg guid (widgetId)
- * @param pkgname pkgname argument ot be set
+ * @brief wrt_get_widget_by_guid Returns tizenAppid by pkg guid (widgetId)
+ * @param tzAppid tizen appid argument ot be set
  * @param guid guid that we look for
  * @return error code
  */
-WrtErrStatus wrt_get_widget_by_guid(std::string &pkgname, const std::string guid);
+WrtErrStatus wrt_get_widget_by_guid(std::string &tzAppid,
+                                    const std::string &guid);
 #ifdef __cplusplus
 }
 #endif
old mode 100755 (executable)
new mode 100644 (file)
index 8e5abb7..f061805
@@ -42,60 +42,36 @@ typedef enum
 {
     /* Generic success */
     WRT_SUCCESS = 0,                /*< Success*/
-    WRT_ALREADY_INIT,               /*< Wrt already initialized*/
-    WRT_UPDATE_NEED,                /*< Widget data has been updated*/
-    WRT_SHUTDOWN,                   /*<WRT daemon has been closed*/
-
-    /* Version result */
-    WRT_VERSION_OLD = 128,          /*< widget's version is older*/
-    WRT_VERSION_NEW,                /*< widget's version is latest*/
-    WRT_VERSION_EXACT,              /*< widget's version the same as in arg*/
-    WRT_VERSION_NOT_COMPARABLE,     /*< widget's version are not comparable */
 
     /* Error result */
     WRT_ERROR_INTERNAL = -128,      /*< Internal library error.
-                                       Should never occur */
-    WRT_ERROR_INVALID_PARAMETER,    /*< Invalid parameter value was given
-                                       (eg. NULL) */
-    WRT_ERROR_HANDLE_NOT_FOUND,     /*< Widget handle was not found */
-    WRT_ERROR_ID_NOT_FOUND,         /*< Widget id was not found */
+                                     * Should never occur */
+
     WRT_ERROR_PKGNAME_NOT_FOUND,    /*< package name was not found */
-    WRT_ERROR_ALREADY_RUNNING,      /*< Widget is already running */
-    WRT_ERROR_ALREADY_STOPPED,      /*< Widget is already stopped */
-    WRT_ERROR_STILL_AUTHORIZING,    /*< Widget is still autorizing and has not
-                                       yet finished it */
-    WRT_ERROR_EARLY_KILLED,         /*< Widget was early killed during launch */
-    WRT_ERROR_ACCESS_DENIED,        /*< Access denied from ACE */
-    WRT_ERROR_NOT_INITIALIZED,      /*<Occur if wrt initialization fails*/
-    WRT_ERROR_INIT,                 /*<Occur if wrt initialization fails*/
-    WRT_ERROR_CONNECTION,           /*<Connectiond error occured*/
     WRT_ERROR_NO_PATH,              /*<One of specific directory does not
-                                       exist*/
+                                     * exist*/
 
     /* Installer Errors*/
-    WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE, /*<  */
-    WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST,  /*<  */
+    WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE, /*< package is malformed */
+    WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST,  /*< given tizenAppId is invalid */
 
     WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING,   /*< Widget is already being
-                                                   uninstalled */
-    WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE,     /*<  */
+                                                 * uninstalled */
     WRT_INSTALLER_ERROR_INVALID_CERTIFICATE,    /*<  */
     WRT_INSTALLER_ERROR_ALREADY_INSTALLED,      /*< Widget is already installed
                                                  */
-    WRT_INSTALLER_ERROR_INTERNAL,               /*<  */
+    WRT_INSTALLER_ERROR_INTERNAL,               /*< Internal error due to inconsistency */
     WRT_INSTALLER_ERROR_NOT_ALLOWED,            /*< Widget installation or
-                                                   update not allowed */
+                                                 * update not allowed */
                                                 /*< because violation of policy
-                                                   ocurred */
+                                                 * ocurred */
     WRT_INSTALLER_ERROR_DEFERRED,               /*< Widget installation deferred
                                                  */
     WRT_INSTALLER_ERROR_DATABASE_FAILURE,       /*< Failure in database */
     WRT_INSTALLER_ERROR_UNKNOWN,                /*< Temporary error. Try to not
-                                                   use this. */
-    WRT_INSTALLER_ERROR_OSPSVC,                 /*< */
-    WRT_ERROR_INVALID_LANGUAGE,                 /*< Widget is not valid in
-                                                    current locales*/
-
+                                                 * use this. */
+    WRT_INSTALLER_ERROR_OSPSVC,                 /*< Error of installation
+                                                 * of osp service */
     /* Plugin Installer Errors */
     WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH,       /*< Wrong Path to plugin Dir */
     WRT_PLUGIN_INSTALLER_ERROR_METAFILE,         /*< Plugin metafile error */
@@ -103,150 +79,11 @@ typedef enum
     WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR,    /*< Shared library error*/
     WRT_PLUGIN_INSTALLER_ERROR_WAITING,          /*< Missing dependencies*/
     WRT_PLUGIN_INSTALLER_ERROR_LOCK,             /*< Another installation
-                                                     in progress or lock file
-                                                     error*/
+                                                  *  in progress or lock file
+                                                  *  error*/
     WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN           /*< Unknown error*/
 } WrtErrStatus;
 
-typedef struct
-{
-    char* id;           /**< the widget's id
-                           (read from its config.xml during installation)*/
-    char* name;         /**< the widget's name
-                           (read from its config.xml during installation)*/
-    char* version;      /**< the widget's varsion
-                           (read from its config.xml during installation)*/
-    char* icon_path;    /**< the widget's icon_path
-                           (read from its config.xml during installation)*/
-    char* pkg_name;     /**< the widget's pkg name */
-
-    /**< the widget's application storage size */
-    size_t application_size;
-    /**< the widget's data storage size */
-    size_t data_size;
-} wrt_widget_info;
-
-typedef struct
-{
-    char *src; /**< valid path to widget's icon*/
-    int width;  /**< the width of the icon in pixels*/
-    int height;  /**< the height of the icon in pixels*/
-} wrt_widget_icon;
-
-typedef struct
-{
-    int width;      /**< the width of the widget in pixels*/
-    int height;     /**< the height of the widget in pixels*/
-} wrt_widget_size;
-
-typedef struct
-{
-    char *widget_name;              /**< the widget's name*/
-    wrt_widget_icon *widget_icon;   /**< the widget's icon data*/
-    wrt_widget_size widget_size;    /**< the widget's size data*/
-    wrt_widget_info *widget_info;   /**< the widget's info data*/
-} wrt_widget_info_data;
-
-
-/**
- * @fn inline bool wrt_has_succeded(WrtErrStatus err)
- * @brief Checks whether call succeded
- *
- * This function checks whether call succeded.
- * If call succeded it returns TRUE.
- *
- * @param [in] err WrtErrStatus to check
- *
- * @return Result of the test
- * @retval TRUE     - the call was successful
- * @retval FALSE    - the call failed
- *
- * Sample code:
- * @code
- *      static void InitCallback(WrtErrStatus status, void *data)
- *      {
- *          MyApplication *This = (MyApplication *)(data);
- *
- *          printf("[LAUNCH-WIDGET] init callback");
- *
- *          if (wrt_has_succeded(status) && status!=WRT_UPDATE_NEED)
- *          {
- *             This->InstallAllPlugins();
- *
- *             if (This->m_argc == 2)
- *                 wrt_install_widget(This->m_argv[1], This, InstallCallback);
- *          }
- *          else if(wrt_has_failed(status))
- *              printf("[LAUNCH-WIDGET] INITIALIZATION HAS FAILED");
- *      }
- * @endcode
- *
- * @see wrt_has_failed
- */
-inline bool wrt_has_succeded(WrtErrStatus err)
-{
-    return (err >= 0);
-}
-
-/**
- * @fn inline bool wrt_has_failed(WrtErrStatus err)
- * @brief Checks whether call failed
- *
- * This function checks whether call failed.
- * If call failed it returns TRUE.
- *
- * @param [in] err WrtErrStatus to check
- *
- * @return Result of the test
- * @retval TRUE     - the call failed
- * @retval FALSE    - the call was successful
- *
- * Sample code:
- * @code
- *      static void InitCallback(WrtErrStatus status, void *data)
- *      {
- *          MyApplication *This = (MyApplication *)(data);
- *
- *          printf("[LAUNCH-WIDGET] init callback");
- *
- *          if (wrt_has_succeded(status) && status!=WRT_UPDATE_NEED)
- *          {
- *             This->InstallAllPlugins();
- *
- *             if (This->m_argc == 2)
- *                 wrt_install_widget(This->m_argv[1], This, InstallCallback);
- *          }
- *          else if(wrt_has_failed(status))
- *              printf("[LAUNCH-WIDGET] INITIALIZATION HAS FAILED");
- *      }
- * @endcode
- *
- * @see wrt_has_succeded
- */
-inline bool wrt_has_failed(WrtErrStatus err)
-{
-    return (err < 0);
-}
-
-namespace CommonError {
-enum Type
-{
-    WrtSuccess,                ///< Success
-
-    HandleNotFound,         ///< Widget handle was not found
-    AlreadyRunning,         ///< Widget is already running
-    AlreadyStopped,         ///< Widget is already stopped
-    InvalidLanguage,        ///< Widget is invalid in current locales
-    StillAuthorizing,       ///< Widget is still autorizing and has not yet finished it
-    EarlyKilled,            ///< Widget was early killed during launch
-    AccessDenied,           ///< Access denied from ACE
-    CertificateRevoked,     ///< Some certificate was revoked.
-                            ///  Widget is not allowed to run.
-
-    Unknown                 ///< Temporary error. Try to not use this.
-};
-}
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5951524
--- /dev/null
@@ -0,0 +1,20 @@
+# Copyright (c) 2013 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        CMakeLists.txt
+# @author      Karol Pawlowski (k.pawlowski@samsung.com)
+#
+
+
+ADD_SUBDIRECTORY(general)
diff --git a/tests/general/BackgroundPageTests.cpp b/tests/general/BackgroundPageTests.cpp
new file mode 100644 (file)
index 0000000..b996cbe
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013 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    TestCases.cpp
+ * @author  Karol Pawlowski (k.pawlowski@samsung.com)
+ * @author  Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ * @brief   Background page installation test's bodies
+ */
+
+#include <string>
+#include <dpl/test/test_runner.h>
+#include <InstallerWrapper.h>
+
+using namespace InstallerWrapper;
+
+////////////////////////////////////////////////////////////////////////////////
+
+RUNNER_TEST_GROUP_INIT(BackgroundPage)
+
+/*
+Name: widgetWithBackgroundPage
+Description: Tests if widget with background page is installed correctly
+Expected: widget should be installed correctly
+*/
+RUNNER_TEST(widgetWithBackgroundPage)
+{
+    std::string tizenId;
+    RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/bg-00-with_bg.wgt",
+            tizenId) == InstallerWrapper::Success);
+    uninstall(tizenId);
+}
+
+/*
+Name: missingBackgroundFile
+Description: Tests if widget with declared in conifg background page
+ but missing background file will be installed correctly.
+Expected: widget should NOT be installed
+*/
+RUNNER_TEST(missingBackgroundFile)
+{
+    std::string tizenId;
+    if(install(miscWidgetsStuff + "widgets/bg-01-missing_file.wgt",
+            tizenId) == InstallerWrapper::Success) {
+        uninstall(tizenId);
+        RUNNER_ASSERT_MSG(false, "Invalid widget package installed");
+    }
+}
+
+/*
+Name: widgetWithoutBackgroundPage
+Description: Complementary test to check if normal widget\
+ without background page is successfully installed
+Expected: widget should be installed
+*/
+RUNNER_TEST(widgetWithoutBackgroundPage)
+{
+    std::string tizenId;
+    RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/bg-02-without_bg.wgt",
+            tizenId) == InstallerWrapper::Success);
+    uninstall(tizenId);
+}
diff --git a/tests/general/CMakeLists.txt b/tests/general/CMakeLists.txt
new file mode 100644 (file)
index 0000000..cf87bdf
--- /dev/null
@@ -0,0 +1,141 @@
+# Copyright (c) 2013 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        CMakeLists.txt
+# @author      Karol Pawlowski (k.pawlowski@samsung.com)
+#
+
+PKG_CHECK_MODULES(COMMON_LIB_PKGS
+    dbus-1
+    libpcrecpp
+    dpl-efl
+    dpl-test-efl
+    dpl-utils-efl
+    dpl-wrt-dao-ro
+    dpl-event-efl
+    xmlsec1
+    libiri
+    REQUIRED
+    )
+
+pkg_search_module(dpl REQUIRED dpl-efl)
+pkg_search_module(dpl-test REQUIRED dpl-test-efl)
+
+SET(WRT_TEST_LIBRARY "wrt-tests-libs")
+
+include_directories(
+  ${dpl_INCLUDE_DIRS}
+  ${dpl-test_INCLUDE_DIRS}
+)
+
+SET(COMMON_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}")
+
+SET_PROPERTY(GLOBAL APPEND PROPERTY COMMON_TESTS_LIBRARY ${WRT_TEST_LIBRARY})
+
+SET_PROPERTY(GLOBAL APPEND PROPERTY TESTS_INCLUDE_DIRS ${COMMON_LIB_PKGS_INCLUDE_DIRS})
+
+SET_PROPERTY(GLOBAL APPEND PROPERTY TESTS_LIBRARY_DIRS ${COMMON_LIB_PKGS_LIBRARY_DIRS})
+
+SET_PROPERTY(GLOBAL APPEND PROPERTY TESTS_LIBRARIES ${COMMON_LIB_PKGS_LIBRARIES})
+
+SET(WRT_DETAIL_SOURCES
+    ${CMAKE_CURRENT_SOURCE_DIR}/InstallerWrapper.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/ManifestFile.cpp
+)
+
+INCLUDE_DIRECTORIES(${COMMON_INCLUDES})
+INCLUDE_DIRECTORIES(${COMMON_LIB_PKGS_INCLUDE_DIRS})
+
+ADD_LIBRARY(${WRT_TEST_LIBRARY} STATIC ${WRT_DETAIL_SOURCES})
+
+SET(INSTALLER_TESTS_SOURCES
+    ${CMAKE_CURRENT_SOURCE_DIR}/TestInit.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/ManifestTests.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/BackgroundPageTests.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/NonRootUserTests.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/NPluginsInstallTests.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/ParsingTizenAppserviceTests.cpp
+)
+
+SET(INSTALLER_TESTS_TARGET "wrt-installer-tests-general")
+
+# Functions used to build test targets (proper sources, includes, libs are
+# added automatically)
+FUNCTION(WRT_TEST_BUILD TARGET_NAME)
+    SET(SOURCES "${ARGN}")
+    ADD_EXECUTABLE("${TARGET_NAME}" ${SOURCES})
+
+    # get include dirs global property
+    GET_PROPERTY(INCLUDE_DIRS GLOBAL PROPERTY TESTS_INCLUDE_DIRS)
+    GET_PROPERTY(TEST_INCLUDE_DIRS GLOBAL PROPERTY ${TARGET_NAME}_INCLUDE_DIRS)
+    INCLUDE_DIRECTORIES(
+        ${INCLUDE_DIRS}
+        ${TEST_INCLUDE_DIRS}
+    )
+
+    # get library dirs global property
+    GET_PROPERTY(LIBRARY_DIRS GLOBAL PROPERTY TESTS_LIBRARY_DIRS)
+    GET_PROPERTY(TEST_LIBRARY_DIRS GLOBAL PROPERTY ${TARGET_NAME}_LIBRARY_DIRS)
+    LINK_DIRECTORIES(
+        ${LIBRARY_DIRS}
+        ${TEST_LIBRARY_DIRS}
+    )
+
+    # get link libraries global property
+    GET_PROPERTY(LINK_LIBRARIES GLOBAL PROPERTY TESTS_LIBRARIES)
+    GET_PROPERTY(TEST_LIBRARIES GLOBAL PROPERTY ${TARGET_NAME}_LIBRARIES)
+    TARGET_LINK_LIBRARIES("${TARGET_NAME}"
+        ${LINK_LIBRARIES}
+        ${TEST_LIBRARIES}
+    )
+ENDFUNCTION(WRT_TEST_BUILD)
+
+FUNCTION(WRT_TEST_INSTALL)
+    SET_TARGET_PROPERTIES(${ARGV} PROPERTIES
+        BUILD_WITH_INSTALL_RPATH ON
+        INSTALL_RPATH_USE_LINK_PATH ON
+    )
+    INSTALL(TARGETS ${ARGV}
+        DESTINATION bin
+        PERMISSIONS OWNER_READ
+                    OWNER_WRITE
+                    OWNER_EXECUTE
+                    GROUP_READ
+                    GROUP_EXECUTE
+                    WORLD_READ
+                    WORLD_EXECUTE
+    )
+ENDFUNCTION(WRT_TEST_INSTALL)
+
+WRT_TEST_BUILD(${INSTALLER_TESTS_TARGET} ${INSTALLER_TESTS_SOURCES})
+WRT_TEST_INSTALL(${INSTALLER_TESTS_TARGET})
+target_link_libraries(${INSTALLER_TESTS_TARGET}
+  ${dpl_LIBRARIES}
+  ${dpl-test_LIBRARIES}
+  ${WRT_TEST_LIBRARY}
+  ${TARGET_CORE_MODULE_LIB}
+  ${COMMON_LIB_PKGS_LIBRARIES}
+)
+
+#widgets
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/manifest.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/bg-00-with_bg.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/bg-01-missing_file.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/bg-02-without_bg.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/nonroot.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/inst_nplug_1.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/inst_nplug_2.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/inst_nplug_3.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/inst_nplug_4.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/appservice_dispos.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
diff --git a/tests/general/InstallerWrapper.cpp b/tests/general/InstallerWrapper.cpp
new file mode 100644 (file)
index 0000000..662f617
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * 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.
+ */
+
+#include "InstallerWrapper.h"
+
+#include <dpl/log/log.h>
+
+#include <cstdio>
+
+namespace
+{
+
+const std::string params = "DPL_USE_OLD_STYLE_LOGS=0 "
+    "DPL_USE_OLD_STYLE_PEDANTIC_LOGS=0 WRT_TEST_MODE=1 ";
+const std::string installCmd = params + "wrt-installer -if ";
+const std::string uninstallCmd = params + "wrt-installer -un ";
+const std::string uninstallByGuidCmd = params + "wrt-installer -ug \"";
+const std::string redirection =  " 2>&1";
+const std::string INSTALLER_MESSAGE_ID_LINE =
+    "## wrt-installer : %s installation was successful.\n";
+const std::string INSTALLER_MESSSGE_START = "## wrt-installer : ";
+
+std::string getAndCutInstallerLogLine(std::string &src)
+{
+    size_t startIndex = src.find(INSTALLER_MESSSGE_START);
+    if (startIndex == std::string::npos)
+    {
+        LogWarning("Installer message can not be found");
+        return std::string();
+    }
+    size_t newLineIndex = src.find("\n", startIndex);
+    std::string line = src.substr(startIndex, newLineIndex - startIndex + 1);
+    src.erase(0, newLineIndex + 1);
+    return line;
+}
+
+}
+
+namespace InstallerWrapper
+{
+
+InstallResult install(
+        const std::string& path,
+        std::string& tizenId,
+        const std::string& user)
+{
+    std::string msg;
+
+    auto cmd = installCmd + path + redirection;
+    if(user.length()) //if other user should be used
+    {
+        cmd = "su " + user + " -c '" + cmd + "'";
+    }
+    auto filehandle = popen(cmd.c_str(), "r");
+    if (!filehandle) {;
+        return OtherError;
+    }
+
+    char buffer[1024] = "";
+    while ( fread_unlocked(buffer, sizeof(char),
+            sizeof(buffer)/sizeof(char), filehandle) > 0 )
+    {
+        msg += buffer;
+    }
+    LogDebug(msg);
+    auto err = pclose(filehandle);
+    if (!WIFEXITED(err)) {
+        return OtherError;
+    }
+    if (0 != WEXITSTATUS(err)) {
+        if (1 == WEXITSTATUS(err)) {
+            return WrongWidgetPackage;
+        }
+        return OtherError;
+    }
+
+    char* id = NULL;
+    std::string line;
+
+    while ((line = getAndCutInstallerLogLine(msg)) != "")
+    {
+        if (line.find("successful") != std::string::npos)
+        {
+            id = new char[line.length()];
+            int nr = sscanf(line.c_str(), INSTALLER_MESSAGE_ID_LINE.c_str(), id);
+
+            if (1 != nr)
+            {
+                LogWarning("Can not read widget ID from message: " << line);
+                delete[] id;
+                return OtherError;
+            }
+            tizenId = id;
+            delete[] id;
+            if (tizenId != "plugin")
+            {
+                return Success;
+            }
+        }
+    }
+
+    return OtherError;
+}
+
+bool uninstall(const std::string& tizenId)
+{
+    std::string cmd = uninstallCmd + tizenId + " > /dev/null 2>/dev/null";
+    LogDebug("executing: " << cmd);
+    return (system(cmd.c_str()) == EXIT_SUCCESS);
+}
+
+bool uninstallByGuid(const std::string& guid)
+{
+    std::string cmd = uninstallByGuidCmd + guid + "\" > /dev/null 2>/dev/null";
+    LogDebug("executing: " << cmd);
+    return (system(cmd.c_str()) == EXIT_SUCCESS);
+}
+
+bool sigintWrtClients()
+{
+    return (system("pkill -2 wrt-client") == 0);
+}
+
+}
+
diff --git a/tests/general/InstallerWrapper.h b/tests/general/InstallerWrapper.h
new file mode 100644 (file)
index 0000000..ee3d0a8
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+#ifndef WRT_INSTALLER_TESTS_GENERAL_INSTALLER_WRAPPER_H
+#define WRT_INSTALLER_TESTS_GENERAL_INSTALLER_WRAPPER_H
+
+#include <string>
+
+namespace InstallerWrapper
+{
+
+typedef int InstallResult;
+const InstallResult WrongWidgetPackage = -2;
+const InstallResult OtherError = -1;
+const InstallResult Success = 0;
+
+const std::string miscWidgetsStuff = "/opt/share/widget/tests/installer/";
+
+struct Result {
+    bool m_exc;
+    bool m_exd;
+    bool m_exs;
+    std::string message;
+    Result(bool exc = false, bool exd = false, bool exs = false)
+        : m_exc(exc), m_exd(exd), m_exs(exs) {}
+};
+
+InstallResult install(
+        const std::string& path,
+        std::string& tizenId,
+        const std::string& user = "");
+bool uninstall(const std::string& tizenId);
+bool uninstallByGuid(const std::string& guid);
+/**
+ * @brief killWrtClients kills processes that matches 'wrt-client'
+ * @return True if any client was killed
+ */
+bool sigintWrtClients();
+
+}
+
+#endif//WRT_INSTALLER_TESTS_GENERAL_INSTALLER_WRAPPER_H
diff --git a/tests/general/ManifestFile.cpp b/tests/general/ManifestFile.cpp
new file mode 100644 (file)
index 0000000..e88a507
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * 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        ManifestFile.cpp
+ * @author      Tomasz Iwanek (t.iwanek@samsung.com)
+ * @brief       Manifest file reading
+ */
+
+#include <ManifestFile.h>
+
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
+#include <dpl/log/log.h>
+
+//TODO: This file reads manifest file. This functionality is familiar with writing
+//      in wrt-installer but reading ws not necessary there.
+//      Maybe it should be changed in some way.
+
+ManifestFile::ManifestFile(const std::string & file) : filename(file)
+{
+    xmlInitParser();
+    LIBXML_TEST_VERSION
+    xmlXPathInit();
+    parse();
+}
+
+ManifestFile::~ManifestFile()
+{
+    xmlXPathFreeContext(xpathCtx);
+    xmlFreeDoc(doc);
+    xmlCleanupParser();
+}
+
+void ManifestFile::parse()
+{
+    doc = xmlReadFile(filename.c_str(), NULL, 0);
+    if (doc == NULL)
+    {
+        ThrowMsg(ManifestParseError,"File Problem");
+    }
+    else
+    {
+        //context
+        xpathCtx = xmlXPathNewContext(doc);
+        if(xpathCtx == NULL)
+        {
+            ThrowMsg(ManifestParseError,"Error: unable to create new XPath context\n");
+        }
+        xpathCtx->node = xmlDocGetRootElement(doc);
+
+        if(xmlXPathRegisterNs(xpathCtx, BAD_CAST "p", BAD_CAST "http://tizen.org/ns/packages") != 0)
+        {
+            ThrowMsg(ManifestParseError,"Error: unable to register namespace\n");
+        }
+    }
+}
+
+std::string ManifestFile::getValueByXpath(const std::string & path) const
+{
+    std::string result;
+    xmlXPathObjectPtr xpathObject;
+    //get requested node's values
+    xpathObject = xmlXPathEvalExpression(BAD_CAST path.c_str(), xpathCtx);
+    if(xpathObject == NULL)
+    {
+        ThrowMsg(ManifestParseError,"XPath evaluation failure: " << path);
+    }
+    xmlNodeSetPtr nodes = xpathObject->nodesetval;
+    int size = (nodes) ? nodes->nodeNr : 0;
+    if(size != 1)
+    {
+        ThrowMsg(ManifestParseError,"Xpath does not point 1 element but " << size
+                 << " for xpath: " << path);
+    }
+    else
+    {
+        if(nodes->nodeTab[0]->type == XML_ELEMENT_NODE)
+        {
+            xmlNodePtr cur = nodes->nodeTab[0];
+            xmlChar * value = xmlNodeGetContent(cur);
+            result = std::string(reinterpret_cast<char*>(value)); //this cast should be safe...
+            xmlFree(value);
+        }
+        else if(nodes->nodeTab[0]->type == XML_ATTRIBUTE_NODE)
+        {
+            xmlNodePtr cur = nodes->nodeTab[0];
+            xmlChar * value = xmlNodeGetContent(cur);
+            result = std::string(reinterpret_cast<char*>(value));
+            xmlFree(value);
+        }
+    }
+    //Cleanup of XPath data
+    xmlXPathFreeObject(xpathObject);
+    return result;
+}
diff --git a/tests/general/ManifestFile.h b/tests/general/ManifestFile.h
new file mode 100644 (file)
index 0000000..ccb6a7b
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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        ManifestFile.h
+ * @author      Tomasz Iwanek (t.iwanek@samsung.com)
+ * @brief       Manifest file reading
+ */
+
+#ifndef WRT_INSTALLER_TESTS_GENERAL_MANIFESTFILE_H
+#define WRT_INSTALLER_TESTS_GENERAL_MANIFESTFILE_H
+
+#include <string>
+
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+
+#include <dpl/exception.h>
+
+/**
+ * @brief The ManifestFile class which serialize xml file to tree
+ */
+class ManifestFile
+{
+public:
+    DECLARE_EXCEPTION_TYPE(DPL::Exception,Base)
+    DECLARE_EXCEPTION_TYPE(Base,ManifestParseError)
+
+    ManifestFile(const std::string & file);
+    ~ManifestFile();
+
+    std::string getValueByXpath(const std::string & path) const;
+private:
+    void parse();
+
+    std::string filename;
+    xmlDocPtr doc;
+    xmlXPathContextPtr xpathCtx;
+};
+
+
+#endif //WRT_INSTALLER_TESTS_GENERAL_MANIFESTFILE_H
diff --git a/tests/general/ManifestTests.cpp b/tests/general/ManifestTests.cpp
new file mode 100644 (file)
index 0000000..769bfa3
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2013 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    TestCases.cpp
+ * @author  Karol Pawlowski (k.pawlowski@samsung.com)
+ * @author  Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ * @brief   Manifest installation test's bodies
+ */
+
+#include <string>
+#include <dpl/utils/wrt_utility.h>
+#include <dpl/test/test_runner.h>
+#include <InstallerWrapper.h>
+#include <ManifestFile.h>
+
+using namespace InstallerWrapper;
+
+////////////////////////////////////////////////////////////////////////////////
+
+RUNNER_TEST_GROUP_INIT(Manifest)
+
+/*
+Name: creatingManifestFile
+Description: Creation of manifest file by wrt-installer test
+Expected: file should be created and installed by wrt-installer. Content should
+ match expected values
+*/
+RUNNER_TEST(creatingManifestFile)
+{
+    const char * manifestPath = "/opt/share/packages/manifest01.xml";
+    /* This widget removal should stay here in case previous test run failed
+     * (so widget has not been uninstalled) */
+    uninstallByGuid("http://test.samsung.com/widget/manifestTest");
+    std::string tizenId;
+    RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/manifest.wgt", tizenId)
+            == InstallerWrapper::Success);
+    RUNNER_ASSERT(WrtUtilFileExists(manifestPath));
+    ManifestFile mf(manifestPath);
+
+    Try
+    {
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@package")
+                      == "manifest01");
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@type")
+                      == "wgt");
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@version")
+                      == "1.0");
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:label")
+                      == "Manifest Example");
+
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author/@email")
+                      == "manifest@misc.test.create.desktop.com");
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author/@href")
+                      == "http://misc.test.create.desktop.com");
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author")
+                      == "Manifest");
+
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@appid")
+                      == "manifest01");
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@nodisplay")
+                      == "false");
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@type")
+                      == "webapp");
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@extraid")
+                      == "http://test.samsung.com/widget/manifestTest");
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@taskmanage")
+                      == "true");
+
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:icon")
+                      == "manifest01.png");
+
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[not(@xml:lang)]")
+                      == "Manifest Example");
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='de_DE']")
+                      == "Manifest Beispiel");
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='en_US']")
+                      == "Manifest Example");
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='pl']")
+                      == "PrzykĹ‚ad Manifest");
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='pt_PT']")
+                      == "Exemplo manifesto");
+    }
+    Catch(ManifestFile::ManifestParseError)
+    {
+        RUNNER_ASSERT_MSG(false,DPL::Exception::KnownExceptionToString(_rethrown_exception));
+    }
+    /* If test finished sucessfully than uninstall test widget */
+    uninstall(tizenId);
+}
diff --git a/tests/general/NPluginsInstallTests.cpp b/tests/general/NPluginsInstallTests.cpp
new file mode 100644 (file)
index 0000000..ae39eb4
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013 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    TestCases.cpp
+ * @author  Karol Pawlowski (k.pawlowski@samsung.com)
+ * @author  Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ * @brief   NPlugins installation test's bodies
+ */
+
+#include <string>
+#include <dpl/test/test_runner.h>
+#include <InstallerWrapper.h>
+
+using namespace InstallerWrapper;
+
+////////////////////////////////////////////////////////////////////////////////
+
+RUNNER_TEST_GROUP_INIT(NPluginsInstall)
+
+/*
+Name: pluginFilesAdded
+Description: Tests installation of plugins attached to widget
+Expected: widget should be succesfully installed
+*/
+RUNNER_TEST(pluginFilesAdded)
+{
+    std::string tizenId;
+    RUNNER_ASSERT(install(miscWidgetsStuff
+            + "widgets/inst_nplug_1.wgt", tizenId) == InstallerWrapper::Success);
+    uninstall(tizenId);
+}
+
+/*
+Name: emptyPluginsDir
+Description: Tests installation with empty 'plugins' directory
+Expected: widget should be not installed
+*/
+RUNNER_TEST(emptyPluginsDir)
+{
+    std::string tizenId;
+    if(install(miscWidgetsStuff + "widgets/inst_nplug_2.wgt",
+            tizenId) == InstallerWrapper::Success) {
+        uninstall(tizenId);
+        RUNNER_ASSERT_MSG(false, "Invalid widget package installed");
+    }
+}
+
+/*
+Name: pluginFileAndOtherFile
+Description: Tests installation with plugins directory and data files
+Expected: widget should be installed
+*/
+RUNNER_TEST(pluginFileAndOtherFile)
+{
+    std::string tizenId;
+    RUNNER_ASSERT(install(miscWidgetsStuff
+            + "widgets/inst_nplug_3.wgt", tizenId) == InstallerWrapper::Success);
+    uninstall(tizenId);
+}
+
+/*
+Name: pluginFileAndSubdir
+Description: Tests installation with 'plugins' directory and subdirectories
+ inside plugin directory
+Expected: widget should be not installed
+*/
+RUNNER_TEST(pluginFileAndSubdir)
+{
+    std::string tizenId;
+    if(install(miscWidgetsStuff + "widgets/inst_nplug_4.wgt",
+            tizenId) == InstallerWrapper::Success) {
+        uninstall(tizenId);
+        RUNNER_ASSERT_MSG(false, "Invalid widget package installed");
+    }
+}
diff --git a/tests/general/NonRootUserTests.cpp b/tests/general/NonRootUserTests.cpp
new file mode 100644 (file)
index 0000000..bd01cc8
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2013 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    TestCases.cpp
+ * @author  Karol Pawlowski (k.pawlowski@samsung.com)
+ * @author  Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ * @brief   Non root user installation test's bodies
+ */
+
+#include <string>
+#include <dpl/test/test_runner.h>
+#include <InstallerWrapper.h>
+
+using namespace InstallerWrapper;
+
+////////////////////////////////////////////////////////////////////////////////
+
+RUNNER_TEST_GROUP_INIT(NonRootUser)
+
+/*
+Name: widgetNonRootInstallation
+Description: Check installation from other user than root
+Expected: widget should be installed
+*/
+RUNNER_TEST(widgetNonRootInstallation)
+{
+    std::string tizenId;
+    RUNNER_ASSERT(install(
+                miscWidgetsStuff + "widgets/nonroot.wgt",
+                tizenId,
+                "app") == InstallerWrapper::Success);
+    uninstall(tizenId);
+}
diff --git a/tests/general/ParsingTizenAppserviceTests.cpp b/tests/general/ParsingTizenAppserviceTests.cpp
new file mode 100644 (file)
index 0000000..0ac368b
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013 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    TestCases.cpp
+ * @author  Karol Pawlowski (k.pawlowski@samsung.com)
+ * @author  Andrzej Surdej (a.surdej@samsung.com)
+ * @version 1.0
+ * @brief   Parsing Tizen Appservice test's bodies
+ */
+
+#include <string>
+#include <algorithm>
+#include <dpl/test/test_runner.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <InstallerWrapper.h>
+
+using namespace InstallerWrapper;
+
+////////////////////////////////////////////////////////////////////////////////
+
+RUNNER_TEST_GROUP_INIT(ParsingTizenAppservice)
+
+/*
+Name: correct_csp_policy
+Description: Tests if widget policy is correctly parsed from config file
+             and stored into database
+Expected: widget should be installed and policy should mach
+*/
+RUNNER_TEST(tizen_appservice_disposition)
+{
+    std::string tizenId;
+    RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/appservice_dispos.wgt",
+            tizenId) == InstallerWrapper::Success);
+
+    WrtDB::WidgetDAOReadOnly dao(DPL::FromASCIIString(tizenId));
+    WidgetApplicationServiceList appsvcList;
+    dao.getAppServiceList(appsvcList);
+    uninstall(tizenId);
+
+    RUNNER_ASSERT_MSG(appsvcList.size() == 4, "Incorrect list size");
+    WidgetApplicationService s;
+    s.src = DPL::FromUTF8String("edit1.html");
+    s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/edit");
+    s.mime = DPL::FromUTF8String("image/jpg");      /* mime type */
+    s.disposition = WidgetApplicationService::Disposition::WINDOW;
+    RUNNER_ASSERT_MSG(
+        std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
+        "Unable to find service #");
+
+    s.src = DPL::FromUTF8String("edit2.html");
+    s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/view");
+    s.mime = DPL::FromUTF8String("audio/ogg");      /* mime type */
+    s.disposition = WidgetApplicationService::Disposition::WINDOW;
+    RUNNER_ASSERT_MSG(
+        std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
+        "Unable to find service ##");
+
+    s.src = DPL::FromUTF8String("edit3.html");
+    s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/call");
+    s.mime = DPL::FromUTF8String("image/png");      /* mime type */
+    s.disposition = WidgetApplicationService::Disposition::INLINE;
+    RUNNER_ASSERT_MSG(
+        std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
+        "Unable to find service ###");
+
+    s.src = DPL::FromUTF8String("edit4.html");
+    s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/send");
+    s.mime = DPL::FromUTF8String("text/css");      /* mime type */
+    s.disposition = WidgetApplicationService::Disposition::WINDOW;
+    RUNNER_ASSERT_MSG(
+        std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
+        "Unable to find service ####");
+}
diff --git a/tests/general/TestInit.cpp b/tests/general/TestInit.cpp
new file mode 100644 (file)
index 0000000..62e30a4
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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    TestInit.cpp
+ * @author  Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ * @brief   Main for wrt-installer general tests
+ */
+
+#include <dpl/test/test_runner.h>
+#include <dpl/log/log.h>
+#include <dpl/wrt-dao-ro/WrtDatabase.h>
+
+int main (int argc, char *argv[])
+{
+    LogInfo("Starting tests");
+
+    WrtDB::WrtDatabase::attachToThreadRW();
+    int status =
+        DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
+    WrtDB::WrtDatabase::detachFromThread();
+
+    return status;
+}
diff --git a/tests/general/widgets/appservice_dispos.wgt b/tests/general/widgets/appservice_dispos.wgt
new file mode 100644 (file)
index 0000000..9451a4f
Binary files /dev/null and b/tests/general/widgets/appservice_dispos.wgt differ
diff --git a/tests/general/widgets/bg-00-with_bg.wgt b/tests/general/widgets/bg-00-with_bg.wgt
new file mode 100644 (file)
index 0000000..36d2452
Binary files /dev/null and b/tests/general/widgets/bg-00-with_bg.wgt differ
diff --git a/tests/general/widgets/bg-01-missing_file.wgt b/tests/general/widgets/bg-01-missing_file.wgt
new file mode 100644 (file)
index 0000000..aca63a7
Binary files /dev/null and b/tests/general/widgets/bg-01-missing_file.wgt differ
diff --git a/tests/general/widgets/bg-02-without_bg.wgt b/tests/general/widgets/bg-02-without_bg.wgt
new file mode 100644 (file)
index 0000000..ccbf1df
Binary files /dev/null and b/tests/general/widgets/bg-02-without_bg.wgt differ
diff --git a/tests/general/widgets/inst_nplug_1.wgt b/tests/general/widgets/inst_nplug_1.wgt
new file mode 100644 (file)
index 0000000..fc075cf
Binary files /dev/null and b/tests/general/widgets/inst_nplug_1.wgt differ
diff --git a/tests/general/widgets/inst_nplug_2.wgt b/tests/general/widgets/inst_nplug_2.wgt
new file mode 100644 (file)
index 0000000..95f3d69
Binary files /dev/null and b/tests/general/widgets/inst_nplug_2.wgt differ
diff --git a/tests/general/widgets/inst_nplug_3.wgt b/tests/general/widgets/inst_nplug_3.wgt
new file mode 100644 (file)
index 0000000..5d98267
Binary files /dev/null and b/tests/general/widgets/inst_nplug_3.wgt differ
diff --git a/tests/general/widgets/inst_nplug_4.wgt b/tests/general/widgets/inst_nplug_4.wgt
new file mode 100644 (file)
index 0000000..9275cca
Binary files /dev/null and b/tests/general/widgets/inst_nplug_4.wgt differ
diff --git a/tests/general/widgets/manifest.wgt b/tests/general/widgets/manifest.wgt
new file mode 100644 (file)
index 0000000..17e56f5
Binary files /dev/null and b/tests/general/widgets/manifest.wgt differ
diff --git a/tests/general/widgets/nonroot.wgt b/tests/general/widgets/nonroot.wgt
new file mode 100644 (file)
index 0000000..641283f
Binary files /dev/null and b/tests/general/widgets/nonroot.wgt differ
diff --git a/tests/general/widgets/tizen_appservice_disposition/config.xml b/tests/general/widgets/tizen_appservice_disposition/config.xml
new file mode 100755 (executable)
index 0000000..4544234
--- /dev/null
@@ -0,0 +1,12 @@
+<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets"
+    id="http://test.samsung.com/widget/wac/tizen_appservice"
+    version="1.0.0"
+    min-version="1.0">
+  <name short="Disposition">Disposition_attribute</name>
+  <icon src="icon.png" height="75" width="75"/>
+  <tizen:appservice src="edit1.html" operation="http://tizen.org/appsvc/operation/edit" mime="image/jpg" />
+  <tizen:appservice src="edit2.html" operation="http://tizen.org/appsvc/operation/view" mime="audio/ogg" disposition="window"/>
+  <tizen:appservice src="edit3.html" operation="http://tizen.org/appsvc/operation/call" mime="image/png" disposition="inline"/>
+  <tizen:appservice src="edit4.html" operation="http://tizen.org/appsvc/operation/send" mime="text/css" disposition="wrongone"/>
+  <content src="index.html" />
+</widget>
diff --git a/tests/general/widgets/tizen_appservice_disposition/icon.png b/tests/general/widgets/tizen_appservice_disposition/icon.png
new file mode 100755 (executable)
index 0000000..b835ed1
Binary files /dev/null and b/tests/general/widgets/tizen_appservice_disposition/icon.png differ
diff --git a/tests/general/widgets/tizen_appservice_disposition/index.htm b/tests/general/widgets/tizen_appservice_disposition/index.htm
new file mode 100755 (executable)
index 0000000..5e7036c
--- /dev/null
@@ -0,0 +1,8 @@
+<html>
+  <head>
+    <title>Disposition attribute</title>
+  </head>
+  <body style="background-color:gray">
+    <h1>Check database.</h1>
+  </body>
+</html>
diff --git a/uncrustify.cfg b/uncrustify.cfg
new file mode 100644 (file)
index 0000000..2bf1d96
--- /dev/null
@@ -0,0 +1,170 @@
+indent_align_string=true\r
+indent_braces=false\r
+indent_braces_no_func=false\r
+indent_brace_parent=false\r
+indent_namespace=false\r
+indent_extern=false\r
+indent_class=true\r
+indent_class_colon=false\r
+indent_else_if=false\r
+indent_func_call_param=false\r
+indent_func_def_param=false\r
+indent_func_proto_param=false\r
+indent_func_class_param=false\r
+indent_func_ctor_var_param=false\r
+indent_template_param=false\r
+indent_func_param_double=false\r
+indent_relative_single_line_comments=false\r
+indent_col1_comment=true\r
+indent_access_spec_body=false\r
+indent_paren_nl=false\r
+indent_comma_paren=false\r
+indent_bool_paren=false\r
+indent_square_nl=false\r
+indent_preserve_sql=false\r
+indent_align_assign=false\r
+sp_balance_nested_parens=false\r
+align_keep_tabs=false\r
+align_with_tabs=false\r
+align_on_tabstop=false\r
+align_number_left=false\r
+align_func_params=false\r
+align_same_func_call_params=false\r
+align_var_def_colon=false\r
+align_var_def_attribute=false\r
+align_var_def_inline=false\r
+align_right_cmt_mix=false\r
+align_on_operator=false\r
+align_mix_var_proto=false\r
+align_single_line_func=false\r
+align_single_line_brace=false\r
+align_nl_cont=false\r
+align_left_shift=true\r
+nl_collapse_empty_body=true\r
+nl_assign_leave_one_liners=false\r
+nl_class_leave_one_liners=false\r
+nl_enum_leave_one_liners=false\r
+nl_getset_leave_one_liners=false\r
+nl_func_leave_one_liners=false\r
+nl_if_leave_one_liners=false\r
+nl_multi_line_cond=true\r
+nl_multi_line_define=false\r
+nl_before_case=false\r
+nl_after_case=false\r
+nl_after_return=false\r
+nl_after_semicolon=true\r
+nl_after_brace_open=false\r
+nl_after_brace_open_cmt=false\r
+nl_after_vbrace_open=false\r
+nl_after_brace_close=false\r
+nl_define_macro=false\r
+nl_squeeze_ifdef=false\r
+nl_ds_struct_enum_cmt=false\r
+nl_ds_struct_enum_close_brace=false\r
+nl_create_if_one_liner=false\r
+nl_create_for_one_liner=false\r
+nl_create_while_one_liner=false\r
+ls_for_split_full=true\r
+ls_func_split_full=true\r
+nl_after_multiline_comment=false\r
+eat_blanks_after_open_brace=true\r
+eat_blanks_before_close_brace=true\r
+mod_pawn_semicolon=false\r
+mod_full_paren_if_bool=false\r
+mod_remove_extra_semicolon=true\r
+mod_sort_import=false\r
+mod_sort_using=false\r
+mod_sort_include=false\r
+mod_move_case_break=false\r
+mod_remove_empty_return=false\r
+cmt_indent_multi=true\r
+cmt_c_group=false\r
+cmt_c_nl_start=false\r
+cmt_c_nl_end=false\r
+cmt_cpp_group=false\r
+cmt_cpp_nl_start=false\r
+cmt_cpp_nl_end=false\r
+cmt_cpp_to_c=false\r
+cmt_star_cont=true\r
+cmt_multi_check_last=true\r
+cmt_insert_before_preproc=false\r
+pp_indent_at_level=false\r
+pp_region_indent_code=false\r
+pp_if_indent_code=false\r
+pp_define_at_level=false\r
+indent_columns=4\r
+indent_member=4\r
+indent_access_spec=-2\r
+code_width=80\r
+nl_max=2\r
+nl_before_access_spec=2\r
+cmt_width=80\r
+indent_with_tabs=0\r
+sp_arith=force\r
+sp_assign=force\r
+sp_enum_assign=force\r
+sp_pp_concat=remove\r
+sp_pp_stringify=remove\r
+sp_bool=force\r
+sp_compare=force\r
+sp_paren_brace=force\r
+sp_angle_paren=remove\r
+sp_before_sparen=force\r
+sp_inside_sparen=remove\r
+sp_after_sparen=force\r
+sp_sparen_brace=force\r
+sp_before_semi=remove\r
+sp_after_semi_for_empty=remove\r
+sp_before_square=remove\r
+sp_before_squares=remove\r
+sp_inside_square=remove\r
+sp_after_comma=force\r
+sp_before_comma=remove\r
+sp_after_class_colon=force\r
+sp_before_class_colon=force\r
+sp_before_case_colon=remove\r
+sp_inside_braces=add\r
+sp_inside_fparens=remove\r
+sp_inside_fparen=remove\r
+sp_func_call_paren=remove\r
+sp_func_class_paren=remove\r
+sp_else_brace=force\r
+sp_brace_else=force\r
+sp_catch_brace=force\r
+sp_brace_catch=force\r
+sp_try_brace=force\r
+sp_before_dc=remove\r
+sp_after_dc=remove\r
+sp_not=remove\r
+sp_inv=remove\r
+sp_addr=remove\r
+sp_member=remove\r
+sp_deref=remove\r
+sp_sign=remove\r
+sp_incdec=remove\r
+sp_cond_colon=force\r
+sp_cond_question=force\r
+sp_case_label=force\r
+nl_assign_brace=remove\r
+nl_if_brace=remove\r
+nl_brace_else=remove\r
+nl_elseif_brace=remove\r
+nl_else_brace=remove\r
+nl_else_if=remove\r
+nl_try_brace=remove\r
+nl_for_brace=remove\r
+nl_catch_brace=remove\r
+nl_brace_catch=remove\r
+nl_while_brace=remove\r
+nl_do_brace=remove\r
+nl_brace_while=remove\r
+nl_switch_brace=remove\r
+nl_namespace_brace=remove\r
+nl_class_brace=force\r
+nl_fdef_brace=force\r
+pos_class_comma=trail\r
+pos_class_colon=trail\r
+mod_full_brace_do=add\r
+mod_full_brace_for=add\r
+mod_full_brace_if=add\r
+mod_full_brace_while=add\r
diff --git a/uncrustify.sh b/uncrustify.sh
new file mode 100755 (executable)
index 0000000..49ad3cf
--- /dev/null
@@ -0,0 +1 @@
+uncrustify -c uncrustify.cfg --no-backup `find . -regex "\(.*\.cpp\|.*\.h\|.*\.c\|.*\.cc\)" | grep -v "orm.h\|orm_generator.h\|3rdparty\|examples"`