Tizen 2.1 base
authorJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 17:05:49 +0000 (02:05 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 17:05:49 +0000 (02:05 +0900)
131 files changed:
CMakeLists.txt
LICENSE [new file with mode: 0644]
configuration/config.tizen.xsd [new file with mode: 0644]
configuration/config.xml [new file with mode: 0755]
configuration/config.xsd [new file with mode: 0755]
configuration/its.xsd [new file with mode: 0644]
configuration/local.xsd [new file with mode: 0644]
configuration/signature_schema.xsd [new file with mode: 0644]
configuration/xml.xsd [new file with mode: 0644]
data/widget_install_popup.edc [new file with mode: 0755]
debian/changelog
debian/control
debian/rules
debian/wrt-installer.install.in
debian/wrt-installer.postinst
etc/CMakeLists.txt [new file with mode: 0644]
etc/DESCRIPTION [new file with mode: 0644]
etc/wrt_preinstall_widgets.sh [new file with mode: 0755]
packaging/wrt-installer.spec [new file with mode: 0644]
packaging/wrt-preinstall-widgets.service [new file with mode: 0644]
src/CMakeLists.txt
src/commons/wrt_common_types.h
src/commons/wrt_error.h
src/configuration_parser/WidgetConfigurationManager.cpp
src/configuration_parser/WidgetConfigurationManager.h
src/configuration_parser/element_parser.h
src/configuration_parser/ignoring_parser.cpp
src/configuration_parser/parser_runner.cpp
src/configuration_parser/widget_parser.cpp [changed mode: 0644->0755]
src/configuration_parser/widget_parser.h [changed mode: 0644->0755]
src/jobs/job.cpp
src/jobs/plugin_install/plugin_install_task.cpp
src/jobs/plugin_install/plugin_install_task.h
src/jobs/plugin_install/plugin_metafile_reader.cpp
src/jobs/plugin_install/plugin_metafile_reader.h
src/jobs/plugin_install/plugin_objects.h
src/jobs/widget_install/ace_registration.cpp [new file with mode: 0644]
src/jobs/widget_install/ace_registration.h [new file with mode: 0644]
src/jobs/widget_install/job_widget_install.cpp
src/jobs/widget_install/job_widget_install.h
src/jobs/widget_install/manifest.cpp [new file with mode: 0755]
src/jobs/widget_install/manifest.h [new file with mode: 0755]
src/jobs/widget_install/task_ace_check.cpp
src/jobs/widget_install/task_ace_check.h
src/jobs/widget_install/task_certificates.cpp [new file with mode: 0644]
src/jobs/widget_install/task_certificates.h [new file with mode: 0755]
src/jobs/widget_install/task_certify.cpp [changed mode: 0644->0755]
src/jobs/widget_install/task_certify.h [changed mode: 0644->0755]
src/jobs/widget_install/task_commons.cpp [new file with mode: 0644]
src/jobs/widget_install/task_commons.h [new file with mode: 0644]
src/jobs/widget_install/task_database.cpp [new file with mode: 0644]
src/jobs/widget_install/task_database.h [new file with mode: 0644]
src/jobs/widget_install/task_encrypt_resource.cpp [new file with mode: 0644]
src/jobs/widget_install/task_encrypt_resource.h [new file with mode: 0644]
src/jobs/widget_install/task_file_manipulation.cpp [new file with mode: 0644]
src/jobs/widget_install/task_file_manipulation.h [new file with mode: 0644]
src/jobs/widget_install/task_install_ospsvc.cpp [new file with mode: 0644]
src/jobs/widget_install/task_install_ospsvc.h [new file with mode: 0644]
src/jobs/widget_install/task_manifest_file.cpp [new file with mode: 0644]
src/jobs/widget_install/task_manifest_file.h [new file with mode: 0755]
src/jobs/widget_install/task_plugins_copy.cpp [new file with mode: 0644]
src/jobs/widget_install/task_plugins_copy.h [new file with mode: 0644]
src/jobs/widget_install/task_prepare_files.cpp [new file with mode: 0644]
src/jobs/widget_install/task_prepare_files.h [new file with mode: 0644]
src/jobs/widget_install/task_recovery.cpp [new file with mode: 0644]
src/jobs/widget_install/task_recovery.h [new file with mode: 0644]
src/jobs/widget_install/task_remove_backup.cpp [new file with mode: 0644]
src/jobs/widget_install/task_remove_backup.h [new file with mode: 0644]
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 [new file with mode: 0644]
src/jobs/widget_install/task_update_files.h [new file with mode: 0644]
src/jobs/widget_install/task_widget_config.cpp
src/jobs/widget_install/task_widget_config.h [changed mode: 0644->0755]
src/jobs/widget_install/view_mode.h [new file with mode: 0644]
src/jobs/widget_install/wac_security.cpp
src/jobs/widget_install/wac_security.h
src/jobs/widget_install/widget_install_context.h [changed mode: 0644->0755]
src/jobs/widget_install/widget_install_errors.h
src/jobs/widget_install/widget_install_popup.cpp [new file with mode: 0755]
src/jobs/widget_install/widget_install_popup.h [new file with mode: 0755]
src/jobs/widget_install/widget_installer_struct.h [changed mode: 0644->0755]
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_delete_certificates.cpp [new file with mode: 0755]
src/jobs/widget_uninstall/task_delete_certificates.h [new file with mode: 0644]
src/jobs/widget_uninstall/task_remove_custom_handlers.cpp [new file with mode: 0644]
src/jobs/widget_uninstall/task_remove_custom_handlers.h [new file with mode: 0644]
src/jobs/widget_uninstall/task_remove_files.cpp
src/jobs/widget_uninstall/task_remove_files.h
src/jobs/widget_uninstall/task_smack.cpp
src/jobs/widget_uninstall/task_uninstall_ospsvc.cpp [new file with mode: 0644]
src/jobs/widget_uninstall/task_uninstall_ospsvc.h [new file with mode: 0644]
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 [new file with mode: 0644]
src/misc/libxml_utils.h [new file with mode: 0644]
src/misc/wac_widget_id.cpp
src/misc/widget_install_to_external.cpp [new file with mode: 0644]
src/misc/widget_install_to_external.h [new file with mode: 0644]
src/misc/widget_location.cpp [new file with mode: 0644]
src/misc/widget_location.h [new file with mode: 0644]
src/pkg-manager/backendlib.cpp [changed mode: 0755->0644]
src/pkg-manager/pkgmgr_signal.cpp [new file with mode: 0644]
src/pkg-manager/pkgmgr_signal.h [new file with mode: 0644]
src/pkg-manager/pkgmgr_signal_dummy.h [new file with mode: 0644]
src/pkg-manager/pkgmgr_signal_interface.h [new file with mode: 0644]
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
src/wrt-installer/plugin_utils.cpp [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
src/wrt-installer/wrt_type.h
wrt-installer.manifest [new file with mode: 0644]

index d97a407..f85fa56 100644 (file)
 ############################# Check minimum CMake version #####################
 
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-SET(CMAKE_EDIT_COMMAND vim)
 PROJECT("wrt-installer")
 
 ############################# cmake packages ##################################
 
 INCLUDE(FindPkgConfig)
 
+############################# build type ######################################
+
+IF(NOT CMAKE_BUILD_TYPE)
+    SET(CMAKE_BUILD_TYPE "Release")
+ENDIF(NOT CMAKE_BUILD_TYPE)
+
 ############################# compilation defines #############################
 
 # EMPTY
 
 ############################# compiler flags ##################################
 
-SET(CMAKE_C_FLAGS_PROFILING    "-O0 -g -pg")
-SET(CMAKE_CXX_FLAGS_PROFILING  "-O0 -std=c++0x -g -pg")
+SET(CMAKE_C_FLAGS_PROFILING    "-O2")
+SET(CMAKE_CXX_FLAGS_PROFILING  "-O2 -std=c++0x")
 SET(CMAKE_C_FLAGS_DEBUG        "-O0 -g")
 SET(CMAKE_CXX_FLAGS_DEBUG      "-O0 -std=c++0x -g")
 SET(CMAKE_C_FLAGS_RELEASE      "-O2 -g")
 SET(CMAKE_CXX_FLAGS_RELEASE    "-O2 -std=c++0x -g")
+SET(CMAKE_CXX_FLAGS_CCOV       "-O0 -std=c++0x -g --coverage")
+
+OPTION(DPL_LOG "DPL logs status" ON)
+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")
 
 # 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
@@ -46,37 +60,39 @@ SET(CMAKE_CXX_FLAGS_RELEASE    "-O2 -std=c++0x -g")
 # (BJ: our ARM too?)
 ADD_DEFINITIONS("-fPIC")
 
-ADD_DEFINITIONS("-DSEPARATED_SINGLETON_IMPLEMENTATION")
-
 # Set the default ELF image symbol visibility to hidden - all symbols will be
 # marked with this unless overridden within the code.
 #ADD_DEFINITIONS("-fvisibility=hidden")
 
 # Set compiler warning flags
-#ADD_DEFINITIONS("-Werror")                      # Make all warnings into errors.
-ADD_DEFINITIONS("-Wall")                        # Generate all warnings
-ADD_DEFINITIONS("-Wextra")                      # Generate even more extra warnings
-ADD_DEFINITIONS("-Wno-variadic-macros")         # Inhibit variadic macros warnings (needed for ORM)
-ADD_DEFINITIONS("-Wno-deprecated")               # No warnings about deprecated features
-ADD_DEFINITIONS("-std=c++0x")               # No warnings about deprecated features
-
-# Set Logs
-OPTION(DPL_LOG "DPL logs status" ON)
-IF(DPL_LOG)
-    MESSAGE(STATUS "Logging enabled for DPL")
-    ADD_DEFINITIONS("-DDPL_LOGS_ENABLED")
-ELSE(DPL_LOG)
-    MESSAGE(STATUS "Logging disabled for DPL")
-ENDIF(DPL_LOG)
+#ADD_DEFINITIONS("-Werror")             # Make all warnings into errors.
+ADD_DEFINITIONS("-Wall")                # Generate all warnings
+ADD_DEFINITIONS("-Wextra")              # Generate even more extra warnings
+ADD_DEFINITIONS("-Wno-variadic-macros") # Inhibit variadic macros warnings (needed for ORM)
+ADD_DEFINITIONS("-Wno-deprecated")      # No warnings about deprecated features
+ADD_DEFINITIONS("-std=c++0x")           # accept C++11x standard
+#ADD_DEFINITIONS("-DWRT_SMACK_ENABLED")
 
 ############################# Targets names ###################################
 
 SET(TARGET_INSTALLER_STATIC "wrt-installer_static")
 SET(TARGET_INSTALLER "wrt-installer")
 SET(TARGET_BACKEND_LIB "wgt")
-SET(TARGET_CONFIG_GEN_LIB "wrt-config-generator")
 
-############################# subdirectories ##################################
+ADD_CUSTOM_COMMAND(
+    OUTPUT ${PROJECT_SOURCE_DIR}/data/widget_install_popup.edj
+    COMMAND edje_cc
+    ARGS  ${PROJECT_SOURCE_DIR}/data/widget_install_popup.edc
+          ${PROJECT_SOURCE_DIR}/data/widget_install_popup.edj
+    DEPENDS ${PROJECT_SOURCE_DIR}/data/widget_install_popup.edc
+    )
+ADD_CUSTOM_TARGET(widget_install_popup ALL DEPENDS
+    ${PROJECT_SOURCE_DIR}/data/widget_install_popup.edj
+    )
+INSTALL(FILES   ${PROJECT_SOURCE_DIR}/data/widget_install_popup.edj
+    DESTINATION share/edje/wrt
+    )
 
+############################# subdirectories ##################################
 ADD_SUBDIRECTORY(src)
-ADD_SUBDIRECTORY(tests)
\ No newline at end of file
+ADD_SUBDIRECTORY(etc)
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..247c97d
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,203 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
diff --git a/configuration/config.tizen.xsd b/configuration/config.tizen.xsd
new file mode 100644 (file)
index 0000000..4bc46ea
--- /dev/null
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Widget Configuration Document Extensions XSD For TIZEN -->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"   xmlns:tizen="http://tizen.org/ns/widgets" targetNamespace="http://tizen.org/ns/widgets" xmlns:widgets="http://www.w3.org/ns/widgets">
+    <xs:import namespace="http://www.w3.org/ns/widgets" schemaLocation="config.xsd"/>
+<xs:simpleType name="appserviceOperationType">
+    <!--               
+    <xs:restriction base="xs:token">           
+        <xs:enumeration value="http://tizen.org/appsvc/operation/edit"/>
+        <xs:enumeration value="http://tizen.org/appsvc/operation/view"/>
+        <xs:enumeration value="http://tizen.org/appsvc/operation/pick"/>
+        <xs:enumeration value="http://tizen.org/appsvc/operation/create_content"/>
+        <xs:enumeration value="http://tizen.org/appsvc/operation/call"/>
+        <xs:enumeration value="http://tizen.org/appsvc/operation/send"/>
+        <xs:enumeration value="http://tizen.org/appsvc/operation/dial"/>
+        <xs:enumeration value="http://tizen.org/appsvc/operation/search"/>
+    </xs:restriction>          
+    -->
+    <xs:restriction base="xs:anyURI"/>
+</xs:simpleType>
+
+<xs:simpleType name="applicationIdType">
+    <xs:restriction base="xs:string">
+        <xs:pattern value="[0-9a-zA-Z]{10}"/>
+    </xs:restriction>
+</xs:simpleType>
+
+<xs:simpleType name="screenOrientationType">
+    <xs:restriction base="xs:token">
+        <xs:enumeration value="portrait"/>
+        <xs:enumeration value="landscape"/>
+    </xs:restriction>
+</xs:simpleType>
+
+<xs:simpleType name="activationType">
+    <xs:restriction base="xs:token">
+        <xs:enumeration value="enable"/>
+        <xs:enumeration value="disable"/>
+    </xs:restriction>
+</xs:simpleType>
+
+<xs:simpleType name="liveboxIdType">
+    <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="updatePeriodType">
+    <xs:restriction base="xs:float">
+        <xs:minInclusive value="60"/>
+    </xs:restriction>
+</xs:simpleType>
+
+<xs:element name="content">
+    <xs:complexType>
+        <xs:attribute name="src" use="required" type="xs:anyURI"/>
+    </xs:complexType>
+</xs:element>
+
+<!-- TODO : appservice will be removed. Please use app-control-->
+<xs:element name="appservice">
+    <xs:complexType>
+        <xs:attribute name="src" type="xs:NCName" use="required"/>
+        <xs:attribute name="operation" type="tizen:appserviceOperationType" use="required"/>
+        <xs:attribute name="scheme" type="xs:string" use="optional"/>
+        <xs:attribute name="mime" type="xs:string" use="optional"/>
+    </xs:complexType>
+</xs:element>
+
+<xs:element name="application">
+    <xs:complexType>
+        <xs:attribute name="id" type="tizen:applicationIdType" use="required"/>
+        <xs:attribute name="required_version" type="xs:float" use="required"/>
+    </xs:complexType>
+</xs:element>
+
+<xs:element name="setting">
+    <xs:complexType>
+        <xs:attribute name="screen-orientation" type="tizen:screenOrientationType" use="optional"/> <!-- default: portrait -->
+        <xs:attribute name="context-menu" type="tizen:activationType" use="optional"/> <!-- default: enable -->
+        <xs:attribute name="background-support" type="tizen:activationType" use="optional"/> <!-- default: enable -->
+        <xs:attribute name="encryption" type="tizen:activationType" use="optional"/> <!-- default: disable -->
+        <xs:attribute name="install-location" type="tizen:InstallLocationType" use="optional"/>
+    </xs:complexType>
+</xs:element>
+
+<xs:element name="app-control">
+  <xs:complexType>
+    <xs:sequence>
+      <xs:choice maxOccurs="unbounded">
+        <xs:element ref="tizen:src"/>
+        <xs:element ref="tizen:operation"/>
+        <xs:element ref="tizen:uri"/>
+        <xs:element ref="tizen:mime"/>
+      </xs:choice>
+    </xs:sequence>
+  </xs:complexType>
+</xs:element>
+
+<xs:element name="category">
+  <xs:complexType>
+    <xs:anyAttribute processContents="lax"/>
+  </xs:complexType>
+</xs:element>
+
+<xs:element name="src">
+    <xs:complexType>
+        <xs:attribute name="name" use="required"/>
+    </xs:complexType>
+</xs:element>
+
+<xs:element name="operation">
+    <xs:complexType>
+        <xs:attribute name="name" use="required"/>
+    </xs:complexType>
+</xs:element>
+
+<xs:element name="uri">
+    <xs:complexType>
+        <xs:attribute name="name" use="required"/>
+    </xs:complexType>
+</xs:element>
+
+<xs:element name="mime">
+  <xs:complexType>
+    <xs:attribute name="name" use="required"/>
+  </xs:complexType>
+</xs:element>
+
+<xs:element name="livebox">
+    <xs:complexType mixed="true">
+        <xs:all>
+            <xs:element ref="tizen:box-label"/>
+            <xs:element ref="tizen:box-icon"/>
+            <xs:element ref="tizen:box-content"/>
+        </xs:all>     
+        <xs:attribute name="id" type="tizen:liveboxIdType" use="required"/>
+        <xs:attribute name="primary" type="widgets:data.boolean" use="required"/>
+        <xs:attribute name="auto-launch" type="widgets:data.boolean" use="optional"/>
+        <xs:attribute name="update-period" type="tizen:updatePeriodType" use="optional"/>
+    </xs:complexType>
+</xs:element>
+
+<xs:element name="privilege">
+    <xs:complexType mixed="true">
+        <xs:choice minOccurs="0" maxOccurs="unbounded">
+            <xs:element ref="widgets:param"/>
+        </xs:choice>
+        <xs:attribute name="name" use="required" type="xs:anyURI"/>
+        <xs:attributeGroup ref="widgets:extension"/>
+    </xs:complexType>
+</xs:element>
+
+<xs:element name="box-label" type="xs:string"/>
+
+<xs:element name="box-icon">
+    <xs:complexType>
+    <xs:attribute name="src" use="required" type="xs:anyURI"/>
+    </xs:complexType>
+</xs:element>
+
+<xs:element name="box-content">
+    <xs:complexType mixed="true">
+        <xs:sequence>
+            <xs:element ref="tizen:box-size" minOccurs="1" maxOccurs="5"/>
+            <xs:element ref="tizen:pd"/>
+        </xs:sequence>
+        <xs:attribute name="src" use="required" type="xs:anyURI"/>
+    </xs:complexType>
+</xs:element>
+
+<xs:element name="pd">
+    <xs:complexType>
+        <xs:attribute name="src" use="required" type="xs:anyURI"/>
+        <xs:attribute name="width" use="required" type="xs:int"/>
+        <xs:attribute name="height" use="required" type="xs:int"/>
+    </xs:complexType>
+</xs:element>
+
+<xs:element name="box-size">
+    <xs:complexType mixed="true">
+    <xs:attribute name="preview" use="optional" type="xs:anyURI"/>
+    </xs:complexType>
+</xs:element>
+
+<xs:simpleType name="InstallLocationType">
+    <xs:restriction base="xs:string">
+        <xs:enumeration value="auto"/>
+        <xs:enumeration value="internal-only"/>
+        <xs:enumeration value="prefer-external"/>
+    </xs:restriction>
+</xs:simpleType>
+
+</xs:schema>
diff --git a/configuration/config.xml b/configuration/config.xml
new file mode 100755 (executable)
index 0000000..3e5dc15
--- /dev/null
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" version="2.0 Beta" viewmodes="fullscreen" id="http://tizen.org/cert">
+  <feature name="http://tizen.org/privilege/accelerometer" />
+  <feature name="http://tizen.org/privilege/account" />
+  <feature name="http://tizen.org/privilege/application" />
+  <feature name="http://tizen.org/privilege/callHistory.read" />
+  <feature name="http://tizen.org/privilege/callHistory.write" />
+  <feature name="http://tizen.org/privilege/deviceapis" />
+  <feature name="http://tizen.org/privilege/deviceinteraction" />
+  <feature name="http://tizen.org/privilege/gallery" />
+  <feature name="http://tizen.org/privilege/gyroscope" />
+  <feature name="http://tizen.org/privilege/intel-messaging" />
+  <feature name="http://tizen.org/privilege/messaging" />
+  <feature name="http://tizen.org/privilege/messaging.send" />
+  <feature name="http://tizen.org/privilege/messaging.read" />
+  <feature name="http://tizen.org/privilege/messaging.write" />
+  <feature name="http://tizen.org/privilege/pim" />
+  <feature name="http://tizen.org/privilege/orientation" />
+  <feature name="http://tizen.org/privilege/systeminfo" />
+  <feature name="http://tizen.org/privilege/waclog" />
+  <name> hello </name>
+  <icon src="icon.png" />
+
+  <!-- tizen appservice element -->
+  <tizen:appservice src="index.html" operation="http://tizen.org/appsvc/operation/edit" mime="image/jpeg"/>
+  <tizen:appservice src="index2.html" operation="http://tizen.org/appsvc/operation/view" mime="image/jpeg"/>
+  <tizen:appservice src="index2.html" operation="http://tizen.org/appsvc/operation/test" mime="image/jpeg"/>
+
+  <!-- tizen application element -->
+  <tizen:application id="Ea31aD3a23" required_version="1.0"/>
+
+  <!-- tizen setting element -->
+  <tizen:setting screen-orientation="portrait" />
+  <tizen:setting contextmenu="disable" />
+  <tizen:setting nodisplay="false" />
+</widget>
diff --git a/configuration/config.xsd b/configuration/config.xsd
new file mode 100755 (executable)
index 0000000..4e6a005
--- /dev/null
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!-- Widgets 1.0 (Working Draft) RELAX NG schema -->\r
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.w3.org/ns/widgets" xmlns:its="http://www.w3.org/2005/11/its" xmlns:widgets="http://www.w3.org/ns/widgets" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/ns/widgets config.xsd">\r
+    <xs:import schemaLocation="local.xsd"/>\r
+    <xs:import namespace="http://www.w3.org/2005/11/its" schemaLocation="its.xsd"/>\r
+    <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>\r
+    <xs:import namespace="http://tizen.org/ns/widgets" schemaLocation="config.tizen.xsd"/>\r
+    <xs:group name="extension">\r
+        <xs:sequence>\r
+            <xs:group minOccurs="0" maxOccurs="unbounded" ref="widgets:anyElement"/>\r
+        </xs:sequence>\r
+    </xs:group>\r
+    <xs:attributeGroup name="extension">\r
+        <xs:attributeGroup ref="widgets:attr.allowed"/>\r
+    </xs:attributeGroup>\r
+    <xs:group name="anyElement">\r
+        <xs:sequence>\r
+            <xs:choice minOccurs="0" maxOccurs="unbounded">\r
+                <xs:any namespace="##other" processContents="skip"/>\r
+                <xs:any namespace="##local" processContents="skip"/>\r
+            </xs:choice>\r
+        </xs:sequence>\r
+    </xs:group>\r
+    <xs:group name="any">\r
+        <xs:sequence>\r
+            <xs:group minOccurs="0" maxOccurs="unbounded" ref="widgets:anyElement"/>\r
+        </xs:sequence>\r
+    </xs:group>\r
+    <xs:attributeGroup name="any">\r
+        <xs:anyAttribute processContents="skip"/>\r
+    </xs:attributeGroup>\r
+    <xs:attributeGroup name="attr.allowed">\r
+        <xs:attributeGroup ref="local"/>\r
+    </xs:attributeGroup>\r
+    <xs:attributeGroup name="attr.xmllang">\r
+        <xs:attribute ref="xml:lang" use="required"/>\r
+    </xs:attributeGroup>\r
+    <xs:attributeGroup name="attr.itsdir">\r
+        <xs:attribute ref="its:dir" use="required"/>\r
+    </xs:attributeGroup>\r
+    <xs:simpleType name="data.positiveNumber">\r
+        <xs:restriction base="xs:string">\r
+            <xs:pattern value="[1-9]\d*"/>\r
+        </xs:restriction>\r
+    </xs:simpleType>\r
+    <xs:simpleType name="data.boolean">\r
+        <xs:restriction base="xs:string">\r
+            <xs:enumeration value="true"/>\r
+            <xs:enumeration value="false"/>\r
+        </xs:restriction>\r
+    </xs:simpleType>\r
+    <xs:simpleType name="data.versionNumber">\r
+        <xs:restriction base="xs:string">\r
+            <xs:pattern value="[0-9]{2}.[0-9]{2}.[0-9]{4}"/>\r
+        </xs:restriction>\r
+    </xs:simpleType>\r
+    <xs:element name="widget">\r
+        <xs:complexType mixed="true">\r
+            <xs:choice minOccurs="0" maxOccurs="unbounded">\r
+                <xs:element ref="widgets:name"/>\r
+                <xs:element ref="widgets:description"/>\r
+                <xs:element ref="widgets:icon"/>\r
+                <xs:element ref="widgets:author"/>\r
+                <xs:element ref="widgets:license"/>\r
+                <xs:element ref="widgets:content"/>\r
+                <xs:element ref="widgets:feature"/>\r
+                <xs:element ref="widgets:preference"/>\r
+                <xs:element ref="widgets:access"/>\r
+                <!-- "widgets:extension" group is commented. Otherwise, error: cos-nonambig: Content model violates the unique particle attribution rule. -->\r
+                <!-- Allowing Any Elements or Attributes from a Particular Namespace -->\r
+                <!-- The wildcards permitted within the list are ##local (a nonqualified element) and ##targetNamespace (the target namespace). Two wildcards can also be used instead of the list: ##any (any namespace) and ##other (any namespace other than the target namespace). -->\r
+                <!--xs:group ref="widgets:extension"/-->\r
+                <xs:element ref="tizen:appservice"  maxOccurs="unbounded" xmlns:tizen="http://tizen.org/ns/widgets"/>\r
+                <xs:element ref="tizen:app-control"  maxOccurs="unbounded" xmlns:tizen="http://tizen.org/ns/widgets"/>\r
+                <xs:element ref="tizen:setting"  maxOccurs="unbounded" xmlns:tizen="http://tizen.org/ns/widgets"/>\r
+                <xs:element ref="tizen:application" minOccurs="1" maxOccurs="1" xmlns:tizen="http://tizen.org/ns/widgets"/>\r
+                <xs:element ref="tizen:content"  minOccurs="1" maxOccurs="1" xmlns:tizen="http://tizen.org/ns/widgets"/>\r
+                <xs:element ref="tizen:livebox"  minOccurs="0" maxOccurs="unbounded" xmlns:tizen="http://tizen.org/ns/widgets"/>\r
+                <xs:element ref="tizen:privilege"  minOccurs="0" maxOccurs="unbounded" xmlns:tizen="http://tizen.org/ns/widgets"/>\r
+                </xs:choice>\r
+            <xs:attribute ref="xml:lang"/>\r
+            <xs:attribute name="id" type="xs:anyURI"/>\r
+            <xs:attribute name="version" type="widgets:data.versionNumber"/>\r
+            <xs:attribute name="height" type="widgets:data.positiveNumber"/>\r
+            <xs:attribute name="width" type="widgets:data.positiveNumber"/>\r
+            <xs:attribute name="viewmodes">\r
+                <xs:simpleType>\r
+                    <xs:list>\r
+                        <xs:simpleType>\r
+                            <xs:restriction base="xs:token">\r
+                                <xs:enumeration value="maximized"/>\r
+                                <xs:enumeration value="fullscreen"/>\r
+                            </xs:restriction>\r
+                        </xs:simpleType>\r
+                    </xs:list>\r
+                </xs:simpleType>\r
+            </xs:attribute>\r
+            <xs:attributeGroup ref="widgets:extension"/>\r
+        </xs:complexType>\r
+    </xs:element>\r
+    <xs:element name="name">\r
+        <xs:complexType mixed="true">\r
+            <xs:attribute ref="xml:lang"/>\r
+            <xs:attribute ref="its:dir"/>\r
+            <xs:attribute name="short"/>\r
+            <xs:attributeGroup ref="widgets:extension"/>\r
+        </xs:complexType>\r
+    </xs:element>\r
+    <xs:element name="description">\r
+        <xs:complexType mixed="true">\r
+            <xs:attribute ref="xml:lang"/>\r
+            <xs:attribute ref="its:dir"/>\r
+            <xs:attributeGroup ref="widgets:extension"/>\r
+        </xs:complexType>\r
+    </xs:element>\r
+    <xs:element name="icon">\r
+        <xs:complexType>\r
+            <xs:attributeGroup ref="widgets:attr.allowed"/>\r
+            <xs:attribute name="src" use="required" type="xs:anyURI"/>\r
+            <xs:attribute name="height" type="widgets:data.positiveNumber"/>\r
+            <xs:attribute name="width" type="widgets:data.positiveNumber"/>\r
+        </xs:complexType>\r
+    </xs:element>\r
+    <xs:element name="access">\r
+        <xs:complexType>\r
+            <xs:attributeGroup ref="widgets:attr.allowed"/>\r
+            <xs:attribute name="origin" use="required" type="xs:anyURI"/>\r
+            <xs:attribute name="subdomains" use="optional" type="widgets:data.boolean"/>\r
+        </xs:complexType>\r
+    </xs:element>\r
+    <xs:element name="author">\r
+        <xs:complexType mixed="true">\r
+            <xs:attribute ref="xml:lang"/>\r
+            <xs:attribute ref="its:dir"/>\r
+            <xs:attribute name="href" type="xs:anyURI"/>\r
+            <xs:attribute name="email">\r
+                <xs:simpleType>\r
+                    <xs:restriction base="xs:string">\r
+                    </xs:restriction>\r
+                </xs:simpleType>\r
+            </xs:attribute>\r
+            <xs:attributeGroup ref="widgets:extension"/>\r
+        </xs:complexType>\r
+    </xs:element>\r
+    <xs:element name="license">\r
+        <xs:complexType mixed="true">\r
+            <xs:attribute ref="xml:lang"/>\r
+            <xs:attribute ref="its:dir"/>\r
+            <xs:attribute name="href" type="xs:anyURI"/>\r
+            <xs:attributeGroup ref="widgets:extension"/>\r
+        </xs:complexType>\r
+    </xs:element>\r
+    <xs:element name="content">\r
+        <xs:complexType>\r
+            <xs:attributeGroup ref="widgets:attr.allowed"/>\r
+            <xs:attribute name="src" use="required" type="xs:anyURI"/>\r
+            <xs:attribute name="type"/>\r
+            <xs:attribute name="charset"/>\r
+        </xs:complexType>\r
+    </xs:element>\r
+    <xs:element name="feature">\r
+        <xs:complexType mixed="true">\r
+            <xs:choice minOccurs="0" maxOccurs="unbounded">\r
+                <xs:element ref="widgets:param"/>\r
+            </xs:choice>\r
+            <xs:attribute name="name" use="required" type="xs:anyURI"/>\r
+            <xs:attributeGroup ref="widgets:extension"/>\r
+        </xs:complexType>\r
+    </xs:element>\r
+    <xs:element name="param">\r
+        <xs:complexType mixed="true">\r
+            <xs:attribute name="name" use="required"/>\r
+            <xs:attribute name="value" use="required"/>\r
+            <xs:attributeGroup ref="widgets:extension"/>\r
+        </xs:complexType>\r
+    </xs:element>\r
+    <xs:element name="preference">\r
+        <xs:complexType mixed="true">\r
+            <xs:attribute ref="xml:lang"/>\r
+            <xs:attribute name="name" use="required"/>\r
+            <xs:attribute name="value"/>\r
+            <xs:attribute name="readonly" type="widgets:data.boolean"/>\r
+            <xs:attributeGroup ref="widgets:extension"/>\r
+        </xs:complexType>\r
+    </xs:element>\r
+</xs:schema>\r
diff --git a/configuration/its.xsd b/configuration/its.xsd
new file mode 100644 (file)
index 0000000..49a2acd
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.w3.org/2005/11/its" xmlns:widgets="http://www.w3.org/ns/widgets" xmlns:its="http://www.w3.org/2005/11/its">
+  <xs:import schemaLocation="local.xsd"/>
+  <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
+  <xs:attribute name="dir">
+    <xs:simpleType>
+      <xs:restriction base="xs:token">
+        <xs:enumeration value="ltr"/>
+        <xs:enumeration value="rtl"/>
+        <xs:enumeration value="lro"/>
+        <xs:enumeration value="rlo"/>
+      </xs:restriction>
+    </xs:simpleType>
+  </xs:attribute>
+</xs:schema>
diff --git a/configuration/local.xsd b/configuration/local.xsd
new file mode 100644 (file)
index 0000000..59a9833
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns:widgets="http://www.w3.org/ns/widgets" xmlns:its="http://www.w3.org/2005/11/its">
+  <xs:import namespace="http://www.w3.org/2005/11/its" schemaLocation="its.xsd"/>
+  <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
+  <xs:attributeGroup name="local">
+    <xs:anyAttribute namespace="##other" processContents="skip"/>
+  </xs:attributeGroup>
+</xs:schema>
diff --git a/configuration/signature_schema.xsd b/configuration/signature_schema.xsd
new file mode 100644 (file)
index 0000000..1ca3bd3
--- /dev/null
@@ -0,0 +1,310 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.w3.org/2000/09/xmldsig#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
+  <!--
+    Relax NG Grammar for XML Signature
+    Namespace: http://www.w3.org/2000/09/xmldsig#
+    $Revision: 1.7 $ on $Date: 2008/07/16 18:04:37 $ by $Author: roessler $
+
+    Copyright 2001 The Internet Society and W3C (Massachusetts Institute
+            of Technology, Institut National de Recherche en Informatique et en
+            Automatique, Keio University). All Rights Reserved.
+    http://www.w3.org/Consortium/Legal/
+
+    This document is governed by the W3C Software License [1] as described
+    in the FAQ [2].
+
+    [1] http://www.w3.org/Consortium/Legal/copyright-software-19980720
+    [2] http://www.w3.org/Consortium/Legal/IPR-FAQ-20000620.html#DTD
+
+    Constructed by hand from xmldsig-core-schema.xsd by
+    Norman.Walsh@marklogic.com on 5 May 2008.
+
+    Notes:
+
+    You must not use the RELAX NG DTD Compatibility features with thi
+    grammar. DTD Compatibility features, ID type attributes, and
+    wildcard attributes are mutually exclusive.
+
+    The definition for the Signature element includes a SignatureType
+    pattern. The rest of the patterns are "inline". This is a matter of
+    style. I constructed only one "type" pattern as an example of the
+    style, not because it's significant in the Signature pattern.
+  -->
+  <!-- Start Signature -->
+  <xs:complexType name="SignatureType">
+    <xs:sequence>
+      <xs:element ref="ds:SignedInfo"/>
+      <xs:element ref="ds:SignatureValue"/>
+      <xs:element minOccurs="0" ref="ds:KeyInfo"/>
+      <xs:element maxOccurs="unbounded" ref="ds:Object"/>
+    </xs:sequence>
+    <xs:attribute name="Id" type="xs:ID"/>
+  </xs:complexType>
+  <xs:element name="Signature" type="ds:SignatureType"/>
+  <xs:element name="SignatureValue">
+    <xs:complexType>
+      <xs:simpleContent>
+        <xs:extension base="xs:base64Binary">
+          <xs:attribute name="Id" type="xs:ID"/>
+        </xs:extension>
+      </xs:simpleContent>
+    </xs:complexType>
+  </xs:element>
+  <!-- Start SignedInfo -->
+  <xs:element name="SignedInfo">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element ref="ds:CanonicalizationMethod"/>
+        <xs:element ref="ds:SignatureMethod"/>
+        <xs:element maxOccurs="unbounded" ref="ds:Reference"/>
+      </xs:sequence>
+      <xs:attribute name="Id" type="xs:ID"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="CanonicalizationMethod">
+    <xs:complexType mixed="true">
+      <xs:group minOccurs="0" maxOccurs="unbounded" ref="ds:anyElement"/>
+      <xs:attribute name="Algorithm" use="required" type="xs:anyURI"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="SignatureMethod">
+    <xs:complexType mixed="true">
+      <xs:choice minOccurs="0" maxOccurs="unbounded">
+        <xs:element ref="ds:HMACOutputLength"/>
+        <xs:group ref="ds:anyOtherElement"/>
+      </xs:choice>
+      <xs:attribute name="Algorithm" use="required" type="xs:anyURI"/>
+    </xs:complexType>
+  </xs:element>
+  <!-- Start Reference -->
+  <xs:element name="Reference">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element minOccurs="0" ref="ds:Transforms"/>
+        <xs:element ref="ds:DigestMethod"/>
+        <xs:element ref="ds:DigestValue"/>
+      </xs:sequence>
+      <xs:attribute name="Id" type="xs:ID"/>
+      <xs:attribute name="URI" type="xs:anyURI"/>
+      <xs:attribute name="Type" type="xs:anyURI"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="Transforms">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element maxOccurs="unbounded" ref="ds:Transform"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="Transform">
+    <xs:complexType>
+      <xs:choice minOccurs="0" maxOccurs="unbounded">
+        <xs:group ref="ds:anyOtherElement"/>
+        <xs:element ref="ds:XPath"/>
+      </xs:choice>
+      <xs:attribute name="Algorithm" use="required" type="xs:anyURI"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="XPath" type="xs:string"/>
+  <!-- End Reference -->
+  <xs:element name="DigestMethod">
+    <xs:complexType>
+      <xs:group minOccurs="0" maxOccurs="unbounded" ref="ds:anyOtherElement"/>
+      <xs:attribute name="Algorithm" use="required" type="xs:anyURI"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="DigestValue" type="ds:DigestValueType"/>
+  <xs:simpleType name="DigestValueType">
+    <xs:restriction base="xs:base64Binary"/>
+  </xs:simpleType>
+  <!-- End SignedInfo -->
+  <!-- Start KeyInfo -->
+  <xs:element name="KeyInfo">
+    <xs:complexType mixed="true">
+      <xs:choice minOccurs="0" maxOccurs="unbounded">
+        <xs:element ref="ds:KeyName"/>
+        <xs:element ref="ds:KeyValue"/>
+        <xs:element ref="ds:RetrievalMethod"/>
+        <xs:element ref="ds:X509Data"/>
+        <xs:element ref="ds:PGPData"/>
+        <xs:element ref="ds:SPKIData"/>
+        <xs:element ref="ds:MgmtData"/>
+        <xs:group ref="ds:anyOtherElement"/>
+      </xs:choice>
+      <xs:attribute name="Id" type="xs:ID"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="KeyName" type="xs:string"/>
+  <xs:element name="MgmtData" type="xs:string"/>
+  <xs:element name="KeyValue">
+    <xs:complexType mixed="true">
+      <xs:choice minOccurs="0" maxOccurs="unbounded">
+        <xs:element ref="ds:DSAKeyValue"/>
+        <xs:element ref="ds:RSAKeyValue"/>
+        <xs:group ref="ds:anyOtherElement"/>
+      </xs:choice>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="RetrievalMethod">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element minOccurs="0" ref="ds:Transforms"/>
+      </xs:sequence>
+      <xs:attribute name="URI" use="required" type="xs:anyURI"/>
+      <xs:attribute name="Type" type="xs:anyURI"/>
+    </xs:complexType>
+  </xs:element>
+  <!-- Start X509Data -->
+  <xs:element name="X509Data">
+    <xs:complexType>
+      <xs:choice minOccurs="0" maxOccurs="unbounded">
+        <xs:element ref="ds:X509IssuerSerial"/>
+        <xs:element ref="ds:X509SKI"/>
+        <xs:element ref="ds:X509SubjectName"/>
+        <xs:element ref="ds:X509Certificate"/>
+        <xs:element ref="ds:X509CRL"/>
+        <xs:group ref="ds:anyOtherElement"/>
+      </xs:choice>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="X509IssuerSerial">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element ref="ds:X509IssuerName"/>
+        <xs:element ref="ds:X509SerialNumber"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="X509IssuerName" type="xs:string"/>
+  <xs:element name="X509SerialNumber" type="xs:integer"/>
+  <xs:element name="X509SKI" type="xs:base64Binary"/>
+  <xs:element name="X509SubjectName" type="xs:string"/>
+  <xs:element name="X509Certificate" type="xs:base64Binary"/>
+  <xs:element name="X509CRL" type="xs:base64Binary"/>
+  <!-- End X509Data -->
+  <!-- Begin PGPData -->
+  <xs:element name="PGPData">
+    <xs:complexType>
+      <xs:choice>
+        <xs:sequence>
+          <xs:element ref="ds:PGPKeyID"/>
+          <xs:element minOccurs="0" ref="ds:PGPKeyPacket"/>
+          <xs:group minOccurs="0" maxOccurs="unbounded" ref="ds:anyOtherElement"/>
+        </xs:sequence>
+        <xs:sequence>
+          <xs:element ref="ds:PGPKeyPacket"/>
+          <xs:group minOccurs="0" maxOccurs="unbounded" ref="ds:anyOtherElement"/>
+        </xs:sequence>
+      </xs:choice>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="PGPKeyID" type="xs:base64Binary"/>
+  <xs:element name="PGPKeyPacket" type="xs:base64Binary"/>
+  <!-- End PGPData -->
+  <!-- Begin SPKIData -->
+  <xs:element name="SPKIData">
+    <xs:complexType>
+      <xs:sequence maxOccurs="unbounded">
+        <xs:element ref="ds:SPKISexp"/>
+        <xs:group minOccurs="0" maxOccurs="unbounded" ref="ds:anyOtherElement"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="SPKISexp" type="xs:base64Binary"/>
+  <!-- End SPKIData -->
+  <!-- End KeyInfo -->
+  <!-- Start Object (Manifest, SignatureProperty) -->
+  <xs:element name="Object">
+    <xs:complexType mixed="true">
+      <xs:sequence>
+        <xs:element ref="ds:SignatureProperties"/>
+        <xs:group minOccurs="0" maxOccurs="unbounded" ref="ds:anyElement"/>
+      </xs:sequence>
+      <xs:attribute name="Id" type="xs:ID"/>
+      <xs:attribute name="MimeType" type="xs:string"/>
+      <xs:attribute name="Encoding" type="xs:anyURI"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="Manifest">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element maxOccurs="unbounded" ref="ds:Reference"/>
+      </xs:sequence>
+      <xs:attribute name="Id" type="xs:ID"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="SignatureProperties">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element maxOccurs="unbounded" ref="ds:SignatureProperty"/>
+      </xs:sequence>
+      <xs:attribute name="Id" type="xs:ID"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="SignatureProperty">
+    <xs:complexType>
+      <xs:group maxOccurs="unbounded" ref="ds:anyOtherElement"/>
+      <xs:attribute name="Id" type="xs:ID"/>
+      <xs:attribute name="Target" use="required" type="xs:anyURI"/>
+    </xs:complexType>
+  </xs:element>
+  <!-- End Object (Manifest, SignatureProperty) -->
+  <!-- Start Algorithm Parameters -->
+  <xs:element name="HMACOutputLength" type="xs:integer"/>
+  <!-- Start KeyValue Element-types -->
+  <xs:element name="DSAKeyValue">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:sequence minOccurs="0">
+          <xs:element ref="ds:P"/>
+          <xs:element ref="ds:Q"/>
+        </xs:sequence>
+        <xs:element minOccurs="0" ref="ds:G"/>
+        <xs:element ref="ds:Y"/>
+        <xs:element minOccurs="0" ref="ds:J"/>
+        <xs:sequence minOccurs="0">
+          <xs:element ref="ds:Seed"/>
+          <xs:element ref="ds:PgenCounter"/>
+        </xs:sequence>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="P" type="ds:CryptoBinary"/>
+  <xs:element name="Q" type="ds:CryptoBinary"/>
+  <xs:element name="G" type="ds:CryptoBinary"/>
+  <xs:element name="Y" type="ds:CryptoBinary"/>
+  <xs:element name="J" type="ds:CryptoBinary"/>
+  <xs:element name="Seed" type="ds:CryptoBinary"/>
+  <xs:element name="PgenCounter" type="ds:CryptoBinary"/>
+  <xs:simpleType name="CryptoBinary">
+    <xs:restriction base="xs:base64Binary"/>
+  </xs:simpleType>
+  <xs:element name="RSAKeyValue">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element ref="ds:Modulus"/>
+        <xs:element ref="ds:Exponent"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="Modulus" type="ds:CryptoBinary"/>
+  <xs:element name="Exponent" type="ds:CryptoBinary"/>
+  <!-- End KeyValue Element-types -->
+  <!-- End Signature -->
+  <!-- Definitions for the *any* wild card and the *any other* wildcard -->
+  <xs:attributeGroup name="anyAttribute">
+    <xs:anyAttribute processContents="skip"/>
+  </xs:attributeGroup>
+  <xs:group name="anyElement">
+    <xs:sequence>
+      <xs:any processContents="skip"/>
+    </xs:sequence>
+  </xs:group>
+  <xs:group name="anyOtherElement">
+    <xs:choice>
+      <xs:any namespace="##other" processContents="skip"/>
+      <xs:any namespace="##local" processContents="skip"/>
+    </xs:choice>
+  </xs:group>
+</xs:schema>
+<!-- EOF -->
diff --git a/configuration/xml.xsd b/configuration/xml.xsd
new file mode 100644 (file)
index 0000000..d9ed2aa
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:widgets="http://www.w3.org/ns/widgets" xmlns:its="http://www.w3.org/2005/11/its"  targetNamespace="http://www.w3.org/XML/1998/namespace" elementFormDefault="qualified">
+    <xs:import schemaLocation="local.xsd"/>
+    <xs:import namespace="http://www.w3.org/2005/11/its" schemaLocation="its.xsd"/>
+    <xs:attribute name="lang" type="xs:language"/>
+</xs:schema>
diff --git a/data/widget_install_popup.edc b/data/widget_install_popup.edc
new file mode 100755 (executable)
index 0000000..2440f9f
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * 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.
+ */
+
+collections {
+    group {
+        name: "popup";
+        parts{
+            part {
+                name: "pad_t";
+                type: RECT;
+                scale: 1;
+                description {
+                    state: "default" 0.0;
+                    min: 0 90;
+                    fixed: 0 1;
+                    visible: 0;
+                    color: 19 222 249  255;
+                    align: 0.0 0.0;
+                    rel1 {
+                        relative: 1.0 0.0; to_x: "pad_l";
+                    }
+                    rel2 {
+                        relative: 0.0 0.0; to_x: "pad_r";
+                    }
+                }
+            }
+            part {
+                name: "pad_l";
+                type: RECT;
+                scale: 1;
+                description {
+                    state: "default" 0.0;
+                    min: 10 300;
+                    fixed: 1 0;
+                    visible: 0;
+                    color: 255 255 255 255;
+                    align: 0.0 0.0;
+                    rel1 {
+                        relative: 0.0 0.0;
+                    }
+                    rel2 {
+                        relative: 0.0 1.0;
+                    }
+                }
+            }
+            part {
+                name: "pad_r";
+                type: RECT;
+                scale: 1;
+                description {
+                    state: "default" 0.0;
+                    min: 10 300;
+                    fixed: 1 0;
+                    visible: 0;
+                    color: 255 255 255 255;
+                    align: 1.0 0.0;
+                    rel1 {
+                        relative: 1.0 0.0;
+                    }
+                    rel2 {
+                        relative: 1.0 1.0;
+                    }
+                }
+            }
+            part {
+                name: "elm.swallow.label";
+                type: SWALLOW;
+                scale: 1;
+                description {
+                    state: "default" 0.0;
+                    align: 0.5 0.0;
+                    visible: 1;
+                    min: 10 100;
+                    fixed: 1 1;
+                    color: 19 222 249  255;
+                    rel1 {
+                        relative: 0.0 0.0; to: "pad_t";
+                    }
+                    rel2 {
+                        relative: 1.0 1.0; to: "pad_t";
+                    }
+                }
+            }
+            part {
+                name: "elm.swallow.separator";
+                type: SWALLOW;
+                scale: 1;
+                description {
+                    state: "default" 0.0;
+                    align: 0.5 0.5;
+                    visible: 0;
+                    min: 600 10;
+                    fixed: 1 1;
+                    color: 19 222 249  255;
+                    rel1 {
+                        relative: 0.5 1.0; to: "pad_t";
+                    }
+                    rel2 {
+                        relative: 0.5 0.0; to: "pad_b";
+                    }
+                }
+            }
+            part {
+                name: "elm.swallow.scroller";
+                type: SWALLOW;
+                scale: 1;
+                description {
+                    state: "default" 0.0;
+                    min: 550 160;
+                    align: 0.5 0.5;
+                    fixed: 1 1;
+                    visible: 1;
+                    color : 92 93 94 95;
+                    rel1 {
+                        relative: 0.5 1.0; to: "elm.swallow.separator";
+                   }
+                    rel2 {
+                        relative: 0.5 1.0; to: "pad_b";
+                   }
+                }
+           }
+           part {
+                name: "pad_b";
+                type: RECT;
+                scale: 1;
+                description {
+                    state: "default" 0.0;
+                    fixed: 1 1;
+                    visible: 0;
+                    align: 0.0 1.0;
+                    color: 250 189 18 255;
+                    min: 0 170;
+                    rel1 {
+                        relative: 1.0 1.0; to_x: "pad_l";
+                    }
+                    rel2 {
+                        relative: 0.0 1.0; to_x: "pad_r";
+                    }
+                }
+            }
+        }
+    }
+}
index 87600b7..856ba17 100644 (file)
+wrt-installer (0.0.94.1) unstable; urgency=low
+
+  * Fixed to send progress signal during RDS update.
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Tue, 29 Jan 2013 16:02:14 +0900
+
+wrt-installer (0.0.94) unstable; urgency=low
+
+  * Modify app control element.
+  * Modify config.xml
+  * preinstall plugin during booting time for window SDK
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.94
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Wed, 16 Jan 2013 16:57:22 +0900
+
+wrt-installer (0.0.93) unstable; urgency=low
+
+  * privilege skip checking ACE.
+  * Add external installation setting in config.tizen.xsd
+  * Fixed installation failed when new tizenId generated in SDK.
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.93
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Wed, 16 Jan 2013 11:21:08 +0900
+
+wrt-installer (0.0.92) unstable; urgency=low
+
+  * livebox xsd has been changed
+  * [Prevent] Fixing issues: 35409
+  * Task database fix - TC11
+  * On nodisplay mode,icon not appear in task manager
+  * [Issue] Deleting temporary API.
+  * Add <tizen:privilege> feature in config.xsd
+  *  modified for livebox code to use proper member in WidgetRegisterInfo
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.92
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Mon, 14 Jan 2013 20:25:09 +0900
+
+wrt-installer (0.0.91) unstable; urgency=low
+
+  * [prevent] closed directory
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.91
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Wed, 09 Jan 2013 14:45:21 +0900
+
+wrt-installer (0.0.90) unstable; urgency=low
+
+  * Change vconf create mechanism
+  * [Custom handler] Remove custom handlers during uninstall
+  * Add required attribute name
+  * For livebox, xsd has been changed
+  * Add log for command
+  * Changed PkgName type from DPL::Optional<DPL::String> to DPL::String. PART 2
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Tue, 08 Jan 2013 11:28:01 +0900
+
+wrt-installer (0.0.89) unstable; urgency=low
+
+  * Throw error on no ElementParser
+  * Closed directory
+  * Apply vconf key path builder
+  * Add vconf creation for memory saving mode
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.89
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Wed, 02 Jan 2013 11:17:14 +0900
+
+wrt-installer (0.0.88) unstable; urgency=low
+
+  * Create/Remove vconf for security settings
+  * Remove required attribute and viewmode Change windowed to maximized
+  * auto-launch tag has been changed
+  * livebox configuration valuables has been modified
+  * For livebox configuration
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.88
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Fri, 28 Dec 2012 16:59:20 +0900
+
+wrt-installer (0.0.86) unstable; urgency=low
+
+  * Add installation to external location(sdcard)
+  * Remove installed directory and manifest file when installation failed after ace check
+  * Fixed directory installation using pkgcmd
+  * Fixed crash for external installation
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.86
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Wed, 26 Dec 2012 13:45:45 +0900
+
+wrt-installer (0.0.85) unstable; urgency=low
+
+  * Add category element at manifest and config.xml 
+
+ -- KEONGEUN <lke01.lee@samsung.com>  Fri, 21 Dec 2012 16:48:54 +0900
+
+wrt-installer (0.0.84) unstable; urgency=low
+
+  * Fix for unhandled exception
+  * Dummy PkgmgrSignal for command line installation
+  * Support privilege database table
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.84
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 20 Dec 2012 08:49:25 +0900
+
+wrt-installer (0.0.83) unstable; urgency=low
+
+  * Handle unhandled exceptions in wrt-installer
+  * Support <tizen:privilege>
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.83
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Fri, 14 Dec 2012 10:47:26 +0900
+
+wrt-installer (0.0.82) unstable; urgency=low
+
+  * Fixed build break
+  * [systemd] fix build error
+  * Directory install feature fix
+  * Update schema files
+  * [Prevent] Removed warning from Prevent.
+  * [Prevent] Removed warning from Prevent.
+  * Fixed package manager doesn't receive signal for widget update failed.
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.82
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Wed, 12 Dec 2012 15:50:01 +0900
+
+wrt-installer (0.0.81) unstable; urgency=low
+
+  * Merge branch 'systemd'
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.81
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Thu, 06 Dec 2012 14:02:20 +0900
+
+wrt-installer (0.0.80) unstable; urgency=low
+
+  * Distinguish between system headers and project headers.
+  * Add nodisplay setting
+  * arrangement of directory creation.
+  * add to create share directory
+  * Fixed nodisplay when other setting values exist.
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.80
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Wed, 05 Dec 2012 17:23:51 +0900
+
+wrt-installer (0.0.79) unstable; urgency=low
+
+  * Direcotry install feature added to wrt-installer
+  * [Prevent] Handle return value of regcomp.
+  * Removing unused merged code
+  * Pkgname (tizen id) - not null
+  * Platform version check during wgt installation - fixed
+  * Revert "Pkgname (tizen id) - not null"
+  * save installed path to db for preload widget
+  * Fixed certificate of authentication value to base64.
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.79
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Fri, 30 Nov 2012 21:44:41 +0900
+
+wrt-installer (0.0.78) unstable; urgency=low
+
+  * [Prevent] Handle fread return value.
+  * [Prevent] Handle return value from CertificateCollection::sort.
+  * remove temporary drm library and header files.
+  * [Installer] Clean up Flash Parser.
+  * Fixed can't remove preinstall widget during booting
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.78
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Tue, 27 Nov 2012 16:51:00 +0900
+
+wrt-installer (0.0.77) unstable; urgency=low
+
+  * Revert "Platform version check during wgt installation"
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.77
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Fri, 23 Nov 2012 21:19:17 +0900
+
+wrt-installer (0.0.76) unstable; urgency=low
+
+  * Filter output from wrt-installer needs for "expr match" to succeed
+  * Introduce systemd support
+  * Removed deprecated code
+  * Handle return value
+  * Platform version check during wgt installation
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.76
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Fri, 23 Nov 2012 12:01:17 +0900
+
+wrt-installer (0.0.75) unstable; urgency=low
+
+  * Fail to install package
+  * External file removal fix
+  * Removed GetFactoryWidget.
+  * Ace database fulfill implemented
+  * update drm library for temporary
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.75
+
+ -- sy037.kim <sy037kim@soyoung-DeskTop>  Mon, 19 Nov 2012 19:56:28 +0900
+
+wrt-installer (0.0.74) unstable; urgency=low
+
+  * Replace SignatureValidator.
+  * Fixed to set certi information
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.74
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Thu, 15 Nov 2012 16:46:02 +0900
+
+wrt-installer (0.0.73) unstable; urgency=low
+
+  * WidgetHandle removal - part 4
+  * Fix resource leak
+  * Fix resource leak in case of error, fix strncpy usage
+  * Removed compilation warnings
+  * Fail to copy web application icon
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.73
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Wed, 14 Nov 2012 11:22:23 +0900
+
+wrt-installer (0.0.72) unstable; urgency=low
+
+  * livebox path has been changed
+  * Removed drm-trusted package dependency.
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.72
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Wed, 07 Nov 2012 15:17:39 +0900
+
+wrt-installer (0.0.71) unstalbe; urgency=low
+
+  * Add installation drm file
+  * Fixed save certification to pkgmgr
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.71
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Mon, 05 Nov 2012 16:52:34 +0900
+
+wrt-installer (0.0.70) unstalbe; urgency=low
+
+  * Replacing recursive opendir with a utility function
+  * Fixes for recursive opendir
+  * Logs fixed
+  * Change profiling build
+  * Removed factory_widget field from WidgetExtendedInfo DB table
+  * WidgetHandle removal - part 2
+  * WidgetHandle removal - part 3
+  * Fixed xsd data type for configure file
+  * tizen widget configration schema file update
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.70
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Fri, 02 Nov 2012 11:57:09 +0900
+
+wrt-installer (0.0.69) unstable; urgency=low
+
+  * [Installer] Replacing calls to FileUtils::*Exists
+  * [Installer] Replacing calls to FileUtils functions
+  * [Installer] Task manifest - using WidgetConfig values instead of read back from database
+  * [Installer] Sanitize popen, system, exec* argument
+  * [Installer] Task_certificates using widgets config instead of values stored in db
+  * Remove language variable from widget conf. parser
+  * [Installer] Fixed Support for author certification
+
+  * Release wrt-installer_0.0.69
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.69
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Wed, 24 Oct 2012 20:02:44 +0900
+
+wrt-installer (0.0.68) unstable; urgency=low
+
+  * Release wrt-installer_0.0.68
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.68
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Thu, 18 Oct 2012 11:38:56 +0900
+
+wrt-installer (0.0.67) unstable; urgency=low
+
+  * [Installer] Support for authors certificates (part 2).
+  * [installer] Fixed save encrypted list to db
+  * [Installer] Fixed uninstall command for hybrid webapp
+  * [Installer] Set Certificate Information using pkgmgt API
+  * [Installer] Replacing old _WrtUtil* functions
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.67
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Wed, 17 Oct 2012 22:36:46 +0900
+
+wrt-installer (0.0.66) unstable; urgency=low
+
+  * Release wrt-installer_0.0.66
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.66
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Fri, 12 Oct 2012 14:26:58 +0900
+
+wrt-installer (0.0.65) unstable; urgency=low
+
+  * Remove usage of deprecated localization API
+  * Add widget's plugins installation
+  * Replace managed api
+  * Add license installing
+  * WidgetHandle removal - part 1
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.65
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Fri, 12 Oct 2012 08:28:40 +0900
+
+wrt-installer (0.0.64) unstable; urgency=low
+
+  * Manifest file changed
+  * Fixed to generate manifest file
+  * Replace widget handle with Tizen id in result output
+  * Replace widget handle with Tizen id from widget's exec path - bugfix
+  * Same feature register in ace db once for app
+  * Manifest pkgmgr's parsing API usage clean up
+  * Task private stroage - effective privileges check
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.64
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com>  Tue, 09 Oct 2012 21:06:09 +0900
+
+wrt-installer (0.0.63) unstable; urgency=low
+
+  * [Installer] Remove 'floating','maximized' and 'minimized' mode
+  * Removed unnecessary use of localization utils
+  * [Installer] Remove dependency to deprecated vcore header
+  * Cleaning related to new LanguageTags
+  * [Installer] Tizen id generation and pattern fix
+  * [Installer] Replace widget handle with Tizen id from widget's exec path
+  * [Installer] Fixed PLM issue(P120925-3434)
+  * [Installer] Remove unused install option
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.63
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Fri, 05 Oct 2012 07:51:39 +0900
+
+wrt-installer (0.0.62) unstable; urgency=low
+
+  * [Installer] Fixed PLM P120926-3287
+  * [Installer] Fixed widget update crash during already widget is launched
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.62
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Fri, 28 Sep 2012 15:27:51 +0900
+
+wrt-installer (0.0.61) unstable; urgency=low
+
+  * Add SEL verification tag
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.61
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com>  Thu, 27 Sep 2012 21:25:53 +0900
+
+wrt-installer (0.0.60) unstable; urgency=low
+
+  * DPL pointer replaced by std pointers
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.60
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com>  Thu, 27 Sep 2012 17:21:38 +0900
+
+wrt-installer (0.0.59) unstable; urgency=low
+
+  * POWDER remains removed
+  * User has no opportunity to cancel installation of the widget that access network.
+  * Livebox directory creation fix
+  * Modify installation command for hybrid webapp.
+  * Fixed preinstall script and add exception logic
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.59
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Wed, 26 Sep 2012 19:46:02 +0900
+
+wrt-installer (0.0.58) unstable; urgency=low
+
+  * Re-release
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.58
+
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Thu, 20 Sep 2012 20:04:31 +0900
+
+wrt-installer (0.0.57) unstable; urgency=low
+
+  * fix for wrt test mode
+  * Popup cleanup
+  * Add configuration file for tizen
+  * Add smack manifest
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.57
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Thu, 20 Sep 2012 20:04:31 +0900
+
+wrt-installer (0.0.56) unstable; urgency=low
+
+  * [Installer] -iu option removed
+  * [Installer] Upgrade Security dependencies
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.56
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Tue, 11 Sep 2012 15:44:41 +0900
+
+wrt-installer (0.0.55) unstable; urgency=low
+
+  * [Installer] Livebox configuration file copy
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.55
+
+ -- Yunchan Cho <yunchan.cho@samsung.com>  Thu, 06 Sep 2012 1:48:12 +0900
+
+wrt-installer (0.0.54) unstable; urgency=low
+
+  * Parsing XML namespace from config.xml bug fix.
+  * code clean up
+  * TaskDbUpdate splitted into TaskDbUpdate and TaskFileManipulation
+  * Widget paths refactor
+
+  * Git : framework/web/wrt-installer
+  * Tag : wrt-installer_0.0.54
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com>  Fri, 31 Aug 2012 20:38:33 +0900
+
+wrt-installer (0.0.53) unstable; urgency=low
+
+  * [Installer] Add encrypt task
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.53
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Wed, 29 Aug 2012 13:43:57 +0900
+
+wrt-installer (0.0.52) unstable; urgency=low
+
+  * [Engine] Support execution of backend library on multiple threads
+  * [Installer] Code cleanup - desktop file
+  * [Engine] bugfix of browser installation and support shortcut for webapp from browser
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.52
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 23 Aug 2012 16:26:22 +0900
+
+wrt-installer (0.0.51) unstable; urgency=low
+
+  * Fix for typo in help message
+  * Add check MEID druring installation process
+  * Save list of accepted api-features
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.51
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 13 Aug 2012 16:09:11 +0900
+
+wrt-installer (0.0.50) unstable; urgency=low
+
+  * Fixed taskmanager for apptray
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.50
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 09 Aug 2012 15:23:40 +0900
+
+wrt-installer (0.0.49) unstable; urgency=low
+
+  * Add manifest generation step instead of desktop step
+  * Add new build type for code coverage
+  * Processing src attribute in icon element in config file fix
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.49
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Mon, 06 Aug 2012 15:46:30 +0900
+
+wrt-installer (0.0.48) unstable; urgency=low
+
+  * Re-upload packages
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.48
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Tue, 31 Jul 2012 11:39:18 +0900
+
+wrt-installer (0.0.47) unstable; urgency=low
+
+  * Update dependency.
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.47
+
+ -- Bartlomiej Grzelewski <b.grzelewski@samsung.com>  Mon, 30 Jul 2012 16:22:22 +0200
+
+wrt-installer (0.0.46) unstable; urgency=low
+
+  * Revert dependency code to wrt-security
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.46
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 30 Jul 2012 10:04:54 +0900
+
+wrt-installer (0.0.45) unstable; urgency=low
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.45
+
+ -- Leerang Song <leerang.song@samsung.com>  Fri, 27 Jul 2012 13:45:24 +0900
+
+wrt-installer (0.0.44) unstable; urgency=low
+
+  * Adjust to API changes in wrt-security and security-server
+  * Add splash screen
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.44
+
+ -- Zbigniew Kostrzewa <z.kostrzewa@samsung.com>  Wed, 25 Jul 2012 15:52:43 +0200
+
+wrt-installer (0.0.43) unstable; urgency=low
+
+  * Upgrade dependencies
+  * Save list of accepted api-features
+  * Add check MEID druring installation process
+  * Add updating widget process
+  * fixed crash during widget uninstallation
+  * Fixed crash when widget uninstall
+  * evert "[Installer] Web app data sharing From orange requirement"
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.43
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Wed, 25 Jul 2012 10:18:27 +0900
+
+wrt-installer (0.0.42) unstable; urgency=low
+
+  * fixed install path
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.42
+
+ -- Leerang Song <leerang.song@samsung.com>  Fri, 20 Jul 2012 20:19:09 +0900
+
+wrt-installer (0.0.41) unstable; urgency=low
+
+  * modify osp installation/uninstallation
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.40
+
+ -- Leerang Song <leerang.song@samsung.com>  Fri, 20 Jul 2012 17:55:12 +0900
+
+wrt-installer (0.0.40) unstable; urgency=low
+
+  * Fixed compile error
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.40
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Thu, 19 Jul 2012 20:35:49 +0900
+
+wrt-installer (0.0.39) unstable; urgency=low
+
+  * support tizen extension requirement regarding application id / required
+  * Add C++ single packaging 
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.39
+
+ -- Leerang Song <leerang.song@samsung.com>  Thu, 19 Jul 2012 19:35:13 +0900
+
+wrt-installer (0.0.38) unstable; urgency=low
+
+  * Multiple INVALID_WIDGET_HANDLE definition
+  * Installion of widget with not supported feature fix
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.38
+
+ -- Leerang Song <leerang.song@samsung.com>  Mon, 16 Jul 2012 15:03:38 +0900
+
+wrt-installer (0.0.37-1) unstable; urgency=low
+
+  * Add tag for auto SR
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.37-1
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 12 Jul 2012 16:02:52 +0900
+
+wrt-installer (0.0.37) unstable; urgency=low
+
+  * Fixed abort rename path
+  * Use updated DeveloperModeValidator class
+  * remove all related with dpl-popup
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.37
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 12 Jul 2012 14:04:43 +0900
+
+wrt-installer (0.0.36) unstable; urgency=low
+
+  * Set SW backend in the emul env
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.36
+
+ -- SongERang <leerang.song@samsung.com>  Thu, 05 Jul 2012 10:04:37 +0900
+
+wrt-installer (0.0.35) unstable; urgency=low
+
+  * Klocwork fixes
+  * refactoring install popup source, using elementary
+  * Wrt DB DefferedWidgetPackageInstallation clean up
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.35
+
+ -- SongERang <leerang.song@samsung.com>  Fri, 29 Jun 2012 13:25:44 +0900
+
+wrt-installer (0.0.34) unstable; urgency=low
+
+  * Added new C-API (ace-install) in wrt-installer
+  * Remove WK1
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.34
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Tue, 19 Jun 2012 09:49:46 +0900
+
+wrt-installer (0.0.33) unstable; urgency=low
+
+  * Add preinstall script from web-app
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.33
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Mon, 04 Jun 2012 19:02:25 +0900
+
+wrt-installer (0.0.32) unstable; urgency=low
+
+  * Chanage of dlopen() mode.
+  * Add ail updating after save desktop file
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.32
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com>  Mon, 04 Jun 2012 19:02:25 +0900
+
+wrt-installer (0.0.31) unstable; urgency=low
+
+  * Changed package name to use wiget name
+  * Support sending signals of package manager
+  * Fixed abort when help command
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.31
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 31 May 2012 12:01:58 +0900
+
+wrt-installer (0.0.30) unstable; urgency=low
+
+  * Removing DSEPARATED_SINGLETON_IMPLEMENTATION flag
+  * A patch for compliance test widget-api/NoInterfaceObject
+  * Changes related with wrt-commons/neested_loop removal
+  * Modify desktop default icon path
+  * Change default wrt-client to wk2
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.30
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 24 May 2012 18:54:24 +0900
+
+wrt-installer (0.0.29) unstable; urgency=low
+
+  * Revert "[Engine] Changed package name to use wiget name"
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.29
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 17 May 2012 21:50:09 +0900
+
+wrt-installer (0.0.28) unstable; urgency=low
+
+  * Changed package name to use wiget name
+  * Unlock plugins installation
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.28
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 17 May 2012 19:59:09 +0900
+
+wrt-installer (0.0.27) unstable; urgency=low
+
+  * Modify abort during widget uninstallation
+  * Remove webkit dependency
+  * Remove exception code related GeoLocation
+  * Delete temporary directory
+  * Update obs spec file
+  * Randomizing widget handle
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.27
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 14 May 2012 19:49:11 +0900
+
+wrt-installer (0.0.26) unstable; urgency=low
+
+  * Config generator removed
+  * Add recovery mechanism for during booting
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.26
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 07 May 2012 17:38:20 +0900
+
+wrt-installer (0.0.25) unstable; urgency=low
+
+  * Fix the problem regarding display of progress of installer
+  * JIL and WAC1.0 leftovers removal
+  * Icon validation bug
+  * Switching to the TestModeFlag
+  * Changing WidgetDAO rw to ro permissions where appropriate
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.25
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 03 May 2012 10:25:52 +0900
+
+wrt-installer (0.0.24) unstable; urgency=low
+
+  * Unused parameter removed
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.24
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 23 Apr 2012 14:19:36 +0900
+
+wrt-installer (0.0.23) unstable; urgency=low
+
+  * Fixed Nabi_SE N_SE-727
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.23
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Sat, 21 Apr 2012 13:05:45 +0900
+
+wrt-installer (0.0.22) unstable; urgency=low
+
+  * Language changed callback is moved to WRT engine
+  * Hosted app installation modified
+  * Hosted app installation invocation modified
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.22
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 16 Apr 2012 11:58:16 +0900
+
+wrt-installer (0.0.21) unstable; urgency=low
+
+  * Mapping from features to device caps is obtained from .so
+  * Remove unneeded check during plugin installation
+  * Fixed background color is black during widget installation
+  * Cleanup condition for evas backend
+  * add LICENSE
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.21
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 09 Apr 2012 14:03:57 +0900
+
+wrt-installer (0.0.20) unstable; urgency=low
+
+  * removed BackSupport attribute
+  * clean-up powder, parental mode
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.20
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Wed, 28 Mar 2012 18:44:59 +0900
+
+wrt-installer (0.0.19) unstable; urgency=low
+
+  * Optimize OBS
+  * Add 'nodisplay' field to Desktop file
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.19
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Fri, 23 Mar 2012 11:05:51 +0900
+
+wrt-installer (0.0.18) unstable; urgency=low
+
+  * replace desktop define
+  * Fix for namespaces bug in config.xml parser
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.18
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 19 Mar 2012 17:52:20 +0900
+
+wrt-installer (0.0.17-1) unstable; urgency=low
+
+  * Apply changed EFL APIs
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.17-1
+
+ -- Yunchan Cho <yunchan.cho@samsung.com>  Wed, 14 Mar 2012 10:14:34 +0900
+
+wrt-installer (0.0.17) unstable; urgency=low
+
+  * Support OBS, SMACK 
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.17
+
+ -- Yunchan Cho <yunchan.cho@samsung.com>  Tue, 13 Mar 2012 20:02:25 +0900
+
+wrt-installer (0.0.16) unstable; urgency=low
+
+  * Package adjusted to wrt-security
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.16
+
+ -- Grzegorz Krawczyk <g.krawczyk@samsung.com>  Thu, 08 Feb 2012 11:53:20 +0100
+
+wrt-installer (0.0.15) unstable; urgency=low
+
+  * Implemented WebInstaller
+  * Support for plugins without libraries (geolocation case)
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.15
+
+ -- Grzegorz Krawczyk <g.krawczyk@samsung.com>  Mon, 05 Feb 2012 15:53:10 +0100
+
+wrt-installer (0.0.14) unstable; urgency=low
+
+  * Adjusted to new wrt-commons
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.14
+
+ -- Grzegorz Krawczyk <g.krawczyk@samsung.com>  Tue, 28 Feb 2012 17:43:10 +0100
+
+wrt-installer (0.0.13) unstable; urgency=low
+
+  * Adjusted to new wrt-security
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.13
+
+ -- Grzegorz Krawczyk <g.krawczyk@samsung.com>  Fri, 24 Feb 2012 18:20:20 +0100
+
+wrt-installer (0.0.12) unstable; urgency=low
+
+  * Debianize 0.0.12
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.12
+
+ -- Hoseon LEE <hoseon46.lee@samsung.com>  Fri, 24 Feb 2012 09:40:54 +0100
+
+wrt-installer (0.0.11) unstable; urgency=low
+
+  * WAC compliance test WL-3240 fix. 
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.11
+
+ -- Zbigniew Kostrzewa <z.kostrzewa@samsung.com>  Wed, 22 Feb 2012 09:40:54 +0100
+
 wrt-installer (0.0.10) unstable; urgency=low
 
-  * Boilerplate update
+  * Fixed static dev cap setting. 
 
-  * Git : tizen2/pkgs/w/wrt-installer
+  * Git : slp/pkgs/w/wrt-installer
   * Tag : wrt-installer_0.0.10
 
- -- Tae-Jeong Lee <taejeong.lee@samsung.com>  Thu, 23 Feb 2012 16:14:18 +0900
+ -- Zbigniew Kostrzewa <z.kostrzewa@samsung.com>  Wed, 22 Feb 2012 08:18:15 +0100
 
 wrt-installer (0.0.9) unstable; urgency=low
 
-  * debianize
+  * WAC policy test suite bugfix
 
-  * Git : tizen2/pkgs/w/wrt-installer
+  * Git : slp/pkgs/w/wrt-installer
   * Tag : wrt-installer_0.0.9
 
- -- Yunchan Cho <yunchan.cho@samsung.com>  Wed, 22 Feb 2012 16:55:58 +0900
+ -- Grzegorz Krawczyk <g.krawczyk@samsung.com>  Mon, 20 Feb 2012 16:30:20 +0100
 
 wrt-installer (0.0.8) unstable; urgency=low
 
-  * Init changelog
+  * Add prefix for debian
+  * Remove -j option
 
-  * Git : tizen2/pkgs/w/wrt-installer
+  * Git : slp/pkgs/w/wrt-installer
   * Tag : wrt-installer_0.0.8
 
  -- Jihoon Chung <jihoon.chung@samsung.com>  Wed, 15 Feb 2012 13:40:40 +0900
+
+wrt-installer (0.0.7) unstable; urgency=low
+
+  * Fixed progress bar for plugins installation
+  * Fixed install fail with No ID widget
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.7
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Tue, 14 Feb 2012 16:35:31 +0900
+
+wrt-installer (0.0.6) unstable; urgency=low
+
+  * code regarding installation from browser
+  * add X-SLP-PackageID to desktop file
+  * remove sensitive string
+  * remove plugin service
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.6
+
+ -- Yunchan Cho <yunchan.cho@samsung.com>  Tue, 14 Feb 2012 09:53:56 +0900
+
+wrt-installer (0.0.5) unstable; urgency=low
+
+  * Remove assert code in the callback
+  * ACE bugfix: handling undetermined attributes
+  * change owner of private directory.
+  * Removing unnecessary include
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.5
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Wed, 08 Feb 2012 18:14:02 +0100
+
+wrt-installer (0.0.4) unstable; urgency=low
+
+  * Fixed postinst
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.4
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Thu, 02 Feb 2012 16:41:15 +0900
+
+wrt-installer (0.0.3) unstable; urgency=low
+
+  * Clean up and Add wrt-installer option
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.3
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Thu, 02 Feb 2012 16:41:15 +0900
+
+wrt-installer (0.0.2) unstable; urgency=low
+
+  * Debianized wrt-installer_0.0.2
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.2
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Wed, 01 Feb 2012 16:49:07 +0900
+
+wrt-installer (0.0.1) unstable; urgency=low
+
+  * Debianized wrt-installer_0.0.1
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.1
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Wed, 01 Feb 2012 16:49:07 +0900
+
+wrt-installer (0.0.0) unstable; urgency=low
+
+  * create new repository
+
+  * Git : slp/pkgs/w/wrt-installer
+  * Tag : wrt-installer_0.0.0
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Mon, 23 Jan 2012 13:54:11 +0900
index a606c26..b4856ce 100644 (file)
@@ -3,13 +3,13 @@ Section: devel
 Priority: extra
 Maintainer:  Krzysztof Jackiewicz<k.jackiewicz@samsung.com>,  Bartlomiej Grzelewski<b.grzelewski@samsung.com>, jihoon Chung <jihoon.chung@samsung.com>, yunchan Cho <yunchan.cho@samsung.com>
 Uploaders: Lukasz Wrzosek <l.wrzosek@samsung.com>,  Grzegorz Krawczyk <g.krawczyk@samsung.com>, Soyoung Kim <sy037.kim@samsung.com>,Pawel Sikorski <p.sikorski@samsung.com>,  Zbigniew Kostrzewa <z.kostrzewa@samsung.com>
-Build-Depends: debhelper (>= 5), libglib2.0-dev, libsqlite3-dev, libwebkit-engine-dev, libelm-webview-dev, libxml2-dev, libdbus-1-dev, libefreet-dev, libappcore-efl-dev, openssl (>= 0.9.7), libcert-svc-dev, wrt-commons-dev (>= 0.2.15), libpcre-dev, libelm-dev, libecore-dev, libeina-dev, libui-gadget-dev, libslp-utilx-dev, libsecurity-server-client-dev, libpkgmgr-installer-dev, libxmlsec1-dev, libidn11-dev, libpkgmgr-types-dev, libss-client-dev, libiri-dev
+Build-Depends: debhelper (>= 5), libglib2.0-dev, libsqlite3-dev, libxml2-dev, libdbus-1-dev, libefreet-dev, libappcore-efl-dev, openssl (>= 0.9.7), libcert-svc-dev, wrt-commons-dev (>= 0.2.22), libpcre-dev, libelm-dev, libecore-dev, libeina-dev, libui-gadget-dev, libslp-utilx-dev, libsecurity-server-client-dev, libpkgmgr-installer-dev, libpkgmgr-parser-dev, libxmlsec1-dev, libidn11-dev, libpkgmgr-types-dev, libss-client-dev, libiri-dev, wrt-security-dev(>= 0.0.28)
 Standards-Version: 0.0.1
 
 Package: wrt-installer
 Architecture: any
 Section: libs
-Depends: ${shlibs:Depends}, ${misc:Depends}, openssl, libug-picker-efl
+Depends: ${shlibs:Depends}, ${misc:Depends}, openssl, libug-picker-efl, wrt-commons (>=0.2.22), wrt-security(>= 0.0.28)
 Replaces: wrt-installer
 Provides: wrt-installer
 Conflicts: wrt-installer
@@ -21,5 +21,5 @@ Replaces: wrt-installer-dbg
 Provides: wrt-installer-dbg
 Conflicts: wrt-installer-dbg
 Section: debug
-Depends: ${shlibs:Depends}, ${misc:Depends}, wrt (= ${Source-Version})
+Depends: ${shlibs:Depends}, ${misc:Depends}
 Description: online widget(W3C, BONDI, JIL, MSC) platform - debug
index af33220..075ebbe 100755 (executable)
@@ -6,54 +6,27 @@
 # dh-make output file, you may use that output file without restriction.
 # This special exception was added by Craig Small in version 0.37 of dh-make.
 
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-
-# These are used for cross-compiling and for saving the configure script
-# from having to guess our platform (since we know it already)
-DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
-DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
-PACKAGE_VERSION ?= $(shell sed -n "1 p" debian/changelog | sed 's/.*(\(.*\)).*/\1/')
+PACKAGE_VERSION ?= $(shell dpkg-parsechangelog | sed -n 's/^Version: // p')
 
 PREFIX ?= /usr
 DATADIR ?= /opt
 LDFLAGS = -Wl,--rpath=$(PREFIX)/lib
-# Please set CFLAGS only in CMakeLists.txt, as they are dependent on CMake build type.
-
+CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
 
-ifeq (,$(findstring no,$(DPL_LOG)))
+ifeq (,$(findstring no,$(DPL_LOGS)))
        DPL_LOGS_STATUS = "ON"
 else
        DPL_LOGS_STATUS = "OFF"
 endif
 
-ifeq (1,$(WRT_SKIP_ACE_SUPPORT))
-    WRT_SKIP_ACE = "ON"
-else
-    WRT_SKIP_ACE = "OFF"
-endif
-
-ifeq (1,$(WRT_SMACK_ENABLE))
-    SMACK_STATUS = "ON"
-else
-    SMACK_STATUS = "OFF"
-endif
-
-#for building with:
-#efl library, use TARGET=X1
-export TARGET=X1
-
-CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
-
-#config.status: configure
 config.status:
        dh_testdir
        # Add here commands to configure the package.
        mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && \
-       cmake ${SRCDIR} -DBUILD_TYPE="${TARGET}" -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DCMAKE_BUILD_TYPE="$(BUILD_TYPE)" -DDPL_LOG=$(DPL_LOGS_STATUS) -DSMACK_ENABLED=${SMACK_STATUS} -DCMAKE_PACKAGE_VERSION="$(PACKAGE_VERSION)" -DWRT_SKIP_ACE_SUPPORT="${WRT_SKIP_ACE}" ..
-
-
+       cmake ${SRCDIR} \
+               -DCMAKE_INSTALL_PREFIX="${PREFIX}"      \
+               -DDPL_LOG=$(DPL_LOGS_STATUS)            \
+               -DCMAKE_PACKAGE_VERSION=${PACKAGE_VERSION} ..
 build: build-stamp
 
 build-stamp:  config.status
@@ -61,7 +34,6 @@ build-stamp:  config.status
        # Add here commands to compile the package.
        cd $(CMAKE_BUILD_DIR) && $(MAKE) -j 4
        #docbook-to-man debian/ncurses.sgml > ncurses.1
-
        for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
                cat $$f > $${f%.in}; \
                sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
index 6a9bf3e..2f17fcc 100644 (file)
@@ -1,4 +1,4 @@
 @PREFIX@/bin/*
-@PREFIX@/lib/*
 @PREFIX@/etc/*
-/opt/apps/config_gen/*
+/etc/rc.d/init.d/*
+@PREFIX@/share/edje/wrt/*
index 3b16852..ce2fd36 100755 (executable)
@@ -5,4 +5,9 @@ chmod +s /usr/bin/wrt-installer
 #symlink for package manager
 ln -sf /usr/bin/wrt-installer /usr/etc/package-manager/backend/wgt
 
+#for recovery
+mkdir -p /opt/share/widget/temp_info
+ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc3.d/S46lwrt_preinstall_widgets.sh
+ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh
+
 echo "[WRT-INSTALLER] wrt-installer postinst done ..."
diff --git a/etc/CMakeLists.txt b/etc/CMakeLists.txt
new file mode 100644 (file)
index 0000000..370d4af
--- /dev/null
@@ -0,0 +1,3 @@
+SET(ETC_DIR ${PROJECT_SOURCE_DIR}/etc)
+
+INSTALL(PROGRAMS ${ETC_DIR}/wrt_preinstall_widgets.sh DESTINATION /etc/rc.d/init.d)
diff --git a/etc/DESCRIPTION b/etc/DESCRIPTION
new file mode 100644 (file)
index 0000000..bf6eac9
--- /dev/null
@@ -0,0 +1 @@
+This directory contain confiration scripts, config files, certificates and all other data that don't fit to other directories.
diff --git a/etc/wrt_preinstall_widgets.sh b/etc/wrt_preinstall_widgets.sh
new file mode 100755 (executable)
index 0000000..2d7b9d5
--- /dev/null
@@ -0,0 +1,81 @@
+#!/bin/sh
+# 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.
+#
+
+_working_dir="/opt/media/Downloads/.preinstallWidgets"
+_widget_temp="/opt/share/widget/*";
+
+install_widgets() {
+       _wgt_list=`find $_working_dir -name '*.wgt'`
+    install_failed=0
+       for list in $_wgt_list
+       do
+               echo "Install $list"
+               return_string=`wrt-installer -il $list`
+        if [ "$return_string" != "${return_string/installed/}" ]; then
+            echo "$list widget installation success"
+            rm -rf $list
+        else
+            echo "$list widget installaiton failed"
+            install_failed=1
+        fi
+       done
+
+    if [ $install_failed -ne 1 ];then
+        echo "preinstall success"
+        rm -rf $_working_dir
+    fi
+}
+
+restore_widget() {
+#Remove temporary directory during widget installation
+for file in $_widget_temp; do
+    if [[ -d $file  &&  ${file#*temp_[0-9]*} != $file ]]; then
+        rm -rf $file
+    fi
+done
+
+
+#Reinstall widget during booting
+_temp_widget_path=/opt/share/widget/temp_info
+
+FILE_LIST=`ls $_temp_widget_path`
+
+if [ -n "$FILE_LIST" ]; then
+    echo "There are widgets to need reinstall."
+    for widget in $FILE_LIST; do
+        FILE_NAME=$_temp_widget_path/$widget
+        line=`cat $FILE_NAME`
+        echo "----------------------------------------------------------------"
+        echo "UnInstalling widget : $line ..."
+        wrt-installer -up $line
+        echo "Installing widget : $line ..."
+        wrt-installer -i $line
+    done
+else
+    echo "There is no reinstall widget."
+fi
+}
+
+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
diff --git a/packaging/wrt-installer.spec b/packaging/wrt-installer.spec
new file mode 100644 (file)
index 0000000..1b2f14c
--- /dev/null
@@ -0,0 +1,101 @@
+#git:framework/web/wrt-installer wrt-installer 0.0.94.1
+Name:       wrt-installer
+Summary:    Installer for tizen Webruntime
+Version:    0.0.94.1
+Release:    1
+Group:      Development/Libraries
+License:    Apache License, Version 2.0
+URL:        N/A
+Source0:    %{name}-%{version}.tar.gz
+Source100:  wrt-preinstall-widgets.service
+BuildRequires:  cmake
+BuildRequires:  edje-tools
+BuildRequires:  pkgconfig(appsvc)
+BuildRequires:  pkgconfig(libxml-2.0)
+BuildRequires:  pkgconfig(openssl)
+BuildRequires:  pkgconfig(dpl-efl)
+BuildRequires:  pkgconfig(cert-svc-vcore)
+BuildRequires:  pkgconfig(dpl-event-efl)
+BuildRequires:  pkgconfig(dpl-utils-efl)
+BuildRequires:  pkgconfig(dpl-wrt-dao-ro)
+BuildRequires:  pkgconfig(dpl-wrt-dao-rw)
+BuildRequires:  pkgconfig(security-install)
+BuildRequires:  pkgconfig(ecore-x)
+BuildRequires:  pkgconfig(xmlsec1)
+BuildRequires:  pkgconfig(libidn)
+BuildRequires:  pkgconfig(libiri)
+BuildRequires:  pkgconfig(libpcrecpp)
+BuildRequires:  pkgconfig(pkgmgr-installer)
+BuildRequires:  pkgconfig(pkgmgr-parser)
+BuildRequires:  pkgconfig(pkgmgr-types)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(cert-svc)
+BuildRequires:  pkgconfig(utilX)
+BuildRequires:  pkgconfig(wrt-plugins-types)
+BuildRequires:  pkgconfig(tapi)
+BuildRequires:  pkgconfig(shortcut)
+BuildRequires:  pkgconfig(dpl-encryption)
+BuildRequires:  pkgconfig(capi-appfw-app-manager)
+BuildRequires:  pkgconfig(drm-service-core-intel)
+BuildRequires:  pkgconfig(app2sd)
+Requires: xmlsec1
+
+%description
+Description: Wrt Installer for Tizen apps and Wac apps
+
+%prep
+%setup -q
+
+%build
+
+export LDFLAGS+="-Wl,--rpath=/usr/lib -Wl,--hash-style=both -Wl,--as-needed"
+LDFLAGS="$LDFLAGS"
+
+cmake . -DCMAKE_INSTALL_PREFIX=/usr \
+        -DDPL_LOG=ON \
+        -DCMAKE_PACKAGE_VERSION=%{version} \
+        -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
+cp LICENSE %{buildroot}/usr/share/license/%{name}
+%make_install
+
+mkdir -p %{buildroot}%{_libdir}/systemd/user
+install -m 644 %{SOURCE100} %{buildroot}%{_libdir}/systemd/user
+mkdir -p %{buildroot}%{_libdir}/systemd/user/tizen-mobile-session.target.wants
+ln -s ../wrt-preinstall-widgets.service %{buildroot}%{_libdir}/systemd/user/tizen-mobile-session.target.wants
+
+mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc3.d/
+mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc5.d/
+ln -s ../init.d/wrt_preinstall_widgets.sh %{buildroot}%{_sysconfdir}/rc.d/rc3.d/S46lwrt_preinstall_widgets.sh
+ln -s ../init.d/wrt_preinstall_widgets.sh %{buildroot}%{_sysconfdir}/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh
+
+%clean
+rm -rf %{buildroot}
+
+%post
+chmod +s /usr/bin/wrt-installer
+
+#symlink for package manager
+ln -sf /usr/bin/wrt-installer /usr/etc/package-manager/backend/wgt
+
+#for booting recovery
+mkdir -p /opt/share/widget/temp_info
+
+# for downloadable Application icons path
+mkdir -p /opt/share/icons/default/small
+
+%files
+%manifest wrt-installer.manifest
+%attr(755,root,root) %{_bindir}/wrt-installer
+%attr(775,root,root) %{_initddir}/wrt_preinstall_widgets.sh
+%{_sysconfdir}/rc.d/rc3.d/S46lwrt_preinstall_widgets.sh
+%{_sysconfdir}/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh
+%attr(644,root,root) %{_datadir}/edje/wrt/*
+/usr/etc/package-manager/backendlib/libwgt.so
+%{_datadir}/license/%{name}
+%{_libdir}/systemd/user/tizen-mobile-session.target.wants/wrt-preinstall-widgets.service
+%{_libdir}/systemd/user/wrt-preinstall-widgets.service
diff --git a/packaging/wrt-preinstall-widgets.service b/packaging/wrt-preinstall-widgets.service
new file mode 100644 (file)
index 0000000..2bf8181
--- /dev/null
@@ -0,0 +1,8 @@
+[Unit]
+Description=Installation of pre-installed widgets
+ConditionPathExists=/opt/media/Downloads/.preinstallWidgets
+After=xorg.target e17.service
+
+[Service]
+Type=oneshot
+ExecStart=/etc/init.d/wrt_preinstall_widgets.sh
index 3a3281f..c07dbab 100644 (file)
@@ -20,6 +20,8 @@
 
 SET(TARGET_INSTALLER "wrt-installer")
 
+OPTION(LB_SUPPORT "lb support" OFF)
+
 SET(INSTALLER_SRC_DIR
     ${PROJECT_SOURCE_DIR}/src
     )
@@ -32,17 +34,6 @@ SET(INSTALLER_JOBS
     ${INSTALLER_SRC_DIR}/jobs
     )
 
-SET(INSTALLER_SECURITY
-    ${INSTALLER_SRC_DIR}/security
-    )
-
-SET(INSTALLER_DEP_CORE_BASE_SOURCE
-    ${INSTALLER_SECURITY}/attribute_facade.cpp
-    ${INSTALLER_SECURITY}/simple_roaming_agent.cpp
-    ${INSTALLER_SECURITY}/security_controller.cpp
-    ${INSTALLER_SECURITY}/security_logic.cpp
-    )
-
 SET(INSTALLER_INCLUDES
     ${INSTALLER_SRC_DIR}
     ${INSTALLER_SRC_DIR}/logic
@@ -53,8 +44,8 @@ SET(INSTALLER_INCLUDES
     ${INSTALLER_SRC_DIR}/misc
     ${INSTALLER_SRC_DIR}/configuration_parser
     ${INSTALLER_SRC_DIR}/wrt-installer
-    ${INSTALLER_SRC_DIR}/security
     ${INSTALLER_SRC_DIR}/commons
+    ${INSTALLER_SRC_DIR}/pkg-manager
 )
 
 SET(INSTALLER_SOURCES
@@ -62,63 +53,102 @@ SET(INSTALLER_SOURCES
     ${INSTALLER_CONFIG_PARSER}/parser_runner.cpp
     ${INSTALLER_CONFIG_PARSER}/ignoring_parser.cpp
     ${INSTALLER_CONFIG_PARSER}/deny_all_parser.cpp
-    ${INSTALLER_CONFIG_PARSER}/powder_parser.cpp
     ${INSTALLER_CONFIG_PARSER}/libiriwrapper.cpp
-    ${INSTALLER_CONFIG_PARSER}/WidgetConfigurationManager.cpp
     ${INSTALLER_JOBS}/job.cpp
     ${INSTALLER_JOBS}/plugin_install/job_plugin_install.cpp
     ${INSTALLER_JOBS}/plugin_install/plugin_install_task.cpp
     ${INSTALLER_JOBS}/plugin_install/plugin_objects.cpp
     ${INSTALLER_JOBS}/plugin_install/plugin_metafile_reader.cpp
     ${INSTALLER_JOBS}/widget_install/job_widget_install.cpp
+    ${INSTALLER_JOBS}/widget_install/manifest.cpp
+    ${INSTALLER_JOBS}/widget_install/task_commons.cpp
     ${INSTALLER_JOBS}/widget_install/task_unzip.cpp
     ${INSTALLER_JOBS}/widget_install/task_widget_config.cpp
-    ${INSTALLER_JOBS}/widget_install/task_db_update.cpp
+    ${INSTALLER_JOBS}/widget_install/task_database.cpp
+    ${INSTALLER_JOBS}/widget_install/ace_registration.cpp
+    ${INSTALLER_JOBS}/widget_install/task_file_manipulation.cpp
     ${INSTALLER_JOBS}/widget_install/task_smack.cpp
     ${INSTALLER_JOBS}/widget_install/task_ace_check.cpp
-    ${INSTALLER_JOBS}/widget_install/task_desktop_file.cpp
-    ${INSTALLER_JOBS}/widget_install/task_parental_mode.cpp
+    ${INSTALLER_JOBS}/widget_install/task_manifest_file.cpp
     ${INSTALLER_JOBS}/widget_install/task_certify.cpp
-    ${INSTALLER_JOBS}/widget_install/task_private_storage.cpp
+    ${INSTALLER_JOBS}/widget_install/task_prepare_files.cpp
+    ${INSTALLER_JOBS}/widget_install/task_recovery.cpp
+    ${INSTALLER_JOBS}/widget_install/task_install_ospsvc.cpp
+    ${INSTALLER_JOBS}/widget_install/task_update_files.cpp
+    ${INSTALLER_JOBS}/widget_install/task_remove_backup.cpp
+    ${INSTALLER_JOBS}/widget_install/task_encrypt_resource.cpp
+    ${INSTALLER_JOBS}/widget_install/task_plugins_copy.cpp
+    ${INSTALLER_JOBS}/widget_install/task_certificates.cpp
     ${INSTALLER_JOBS}/widget_install/wac_security.cpp
     ${INSTALLER_JOBS}/widget_install/widget_update_info.cpp
+    ${INSTALLER_JOBS}/widget_install/widget_install_popup.cpp
     ${INSTALLER_JOBS}/widget_uninstall/job_widget_uninstall.cpp
     ${INSTALLER_JOBS}/widget_uninstall/task_check.cpp
     ${INSTALLER_JOBS}/widget_uninstall/task_remove_files.cpp
+    ${INSTALLER_JOBS}/widget_uninstall/task_remove_custom_handlers.cpp
     ${INSTALLER_JOBS}/widget_uninstall/task_db_update.cpp
     ${INSTALLER_JOBS}/widget_uninstall/task_smack.cpp
+    ${INSTALLER_JOBS}/widget_uninstall/task_uninstall_ospsvc.cpp
+    ${INSTALLER_JOBS}/widget_uninstall/task_delete_certificates.cpp
     ${INSTALLER_SRC_DIR}/logic/installer_logic.cpp
     ${INSTALLER_SRC_DIR}/logic/installer_controller.cpp
-    ${INSTALLER_SRC_DIR}/misc/wrt_powder_info_util.cpp
     ${INSTALLER_SRC_DIR}/misc/wac_widget_id.cpp
     ${INSTALLER_SRC_DIR}/misc/feature_logic.cpp
+    ${INSTALLER_SRC_DIR}/misc/libxml_utils.cpp
+    ${INSTALLER_SRC_DIR}/misc/widget_location.cpp
+    ${INSTALLER_SRC_DIR}/misc/widget_install_to_external.cpp
+    ${INSTALLER_SRC_DIR}/pkg-manager/pkgmgr_signal.cpp
     )
 
+IF(LB_SUPPORT)
+    SET(INSTALLER_SOURCES
+        ${INSTALLER_SOURCES}
+        )
+    MESSAGE(STATUS "adding definition -DLB_SUPPORT")
+    ADD_DEFINITIONS("-DLB_SUPPORT")
+ENDIF(LB_SUPPORT)
+
 MESSAGE(STATUS "add -DSEP_INSTALLER")
 ADD_DEFINITIONS("-DSEP_INSTALLER")
 
 
 PKG_CHECK_MODULES(INSTALLER_STATIC_DEP
-    libxml-2.0
-    openssl
     dpl-efl
-    dpl-vcore
     dpl-event-efl
     dpl-utils-efl
-    dpl-popup-efl
     dpl-wrt-dao-ro
     dpl-wrt-dao-rw
-    dpl-ace
-    dpl-ace-dao-ro
-    dpl-ace-dao-rw
+    wrt-commons-custom-handler-dao-rw
+    dpl-encryption
+    wrt-plugins-types
+    pkgmgr-installer
+    pkgmgr-parser
+    REQUIRED
+)
+
+PKG_CHECK_MODULES(SYS_INSTALLER_STATIC_DEP
+    appsvc
+    libxml-2.0
+    openssl
+    cert-svc-vcore
+    security-install
     ecore-x
-    elm-webview
     xmlsec1
     libidn
     libiri
     libpcrecpp
+    ail
+    elementary
+    tapi
+    shortcut
+    capi-appfw-app-manager
+    drm-service-core-intel
+    app2sd
+    vconf
     REQUIRED
-    )
+)
+
+INCLUDE_DIRECTORIES( SYSTEM ${SYS_INSTALLER_STATIC_DEP_INCLUDE_DIRS})
 
 INCLUDE_DIRECTORIES(
     ${INSTALLER_DEP_INCLUDES}
@@ -127,20 +157,18 @@ INCLUDE_DIRECTORIES(
     )
 
 ADD_LIBRARY(${TARGET_INSTALLER_STATIC} STATIC
-    ${INSTALLER_DEP_CORE_BASE_SOURCE}
     ${INSTALLER_SOURCES}
     )
 
 ADD_DEFINITIONS(${INSTALLER_STATIC_DEP_CFLAGS})
 ADD_DEFINITIONS(${INSTALLER_STATIC_DEP_CFLAGS_OTHERS})
+ADD_DEFINITIONS(${SYS_INSTALLER_STATIC_DEP_CFLAGS})
+ADD_DEFINITIONS(${SYS_INSTALLER_STATIC_DEP_CFLAGS_OTHERS})
 
 TARGET_LINK_LIBRARIES(${TARGET_INSTALLER_STATIC}
-    ${INSTALLER_STATIC_DEP_LIBRARIES}
+    ${INSTALLER_STATIC_DEP_LIBRARIES} "-ldl"
+    ${SYS_INSTALLER_STATIC_DEP_LIBRARIES} "-ldl"
     )
 
-SET_TARGET_PROPERTIES(${TARGET_INSTALLER_STATIC} PROPERTIES
-        COMPILE_FLAGS -fPIC)
-
 ADD_SUBDIRECTORY(pkg-manager)
 ADD_SUBDIRECTORY(wrt-installer)
-ADD_SUBDIRECTORY(config_generator)
index 9b80c8a..4fe586f 100644 (file)
 */
 typedef DPL::Optional<WidgetVersion> OptionalWidgetVersion;
 
-
 /* Define db type */
-typedef WrtDB::DbWidgetHandle WidgetHandle;
-typedef WrtDB::DbWidgetHandleList WidgetHandleList;
-
 typedef WrtDB::DbWidgetFeature WidgetFeature;
 typedef WrtDB::DbWidgetFeatureSet WidgetFeatureSet;
 
@@ -42,4 +38,12 @@ typedef WrtDB::DbWidgetSize WidgetSize;
 
 typedef WrtDB::DbPluginHandle PluginHandle;
 
+enum InstallLocationType
+{
+    INSTALL_LOCATION_TYPE_UNKNOWN = 0,
+    INSTALL_LOCATION_TYPE_NOMAL,
+    INSTALL_LOCATION_TYPE_PRELOAD,
+    INSTALL_LOCATION_TYPE_EXTERNAL
+};
+
 #endif /* PLUGIN_COMMON_TYPES_H */
index 5a1960a..22599f3 100644 (file)
@@ -111,8 +111,7 @@ enum WrtError
     WRT_WM_ERR_REMOVE_FILES_FAILED = WRT_WM_ERRCODE + WRT_ERROR_SET(0x0e),
     WRT_WM_ERR_ALREADY_LATEST = WRT_WM_ERRCODE + WRT_ERROR_SET(0x0f),
     WRT_WM_ERR_UPDATE_CANCEL = WRT_WM_ERRCODE + WRT_ERROR_SET(0x10),
-    WRT_WM_ERR_IS_FACTORY_WIDGET = WRT_WM_ERRCODE + WRT_ERROR_SET(0x11),
-    WRT_WM_ERR_INVALID_APP_ID = WRT_WM_ERRCODE + WRT_ERROR_SET(0x12),
+    WRT_WM_ERR_INVALID_APP_ID = WRT_WM_ERRCODE + WRT_ERROR_SET(0x11),
 
     /* Access Control Manager */
     WRT_SAI_ERR_INIT_ACE_FAILED = WRT_SAI_ERRCODE + WRT_ERROR_SET(0x01)
index 2441731..94a7c54 100644 (file)
@@ -58,83 +58,111 @@ bool WidgetConfigurationManager::locateAndParseConfigurationFile(
         return false;
     }
 
-    //TODO: use DPL::String in the caller to this function too.
-    DPL::String currentPath = DPL::FromUTF8String(_currentPath);
+    ConfigParserData& configInfo = pWidgetConfigInfo.configInfo;
 
-    if (currentPath.empty() || baseFolder.empty()) {
-        *pErrCode = WRT_ERR_INVALID_ARG;
-        return false;
-    }
+    // check if this installation from browser, or not.
+    size_t pos = _currentPath.rfind("/");
+    std::ostringstream infoPath;
+    infoPath << _currentPath.substr(pos+1);
 
-    //TODO: rewrite this madness
-    char cfgAbsPath[MAX_WIDGET_PATH_SIZE + 1] = { 0 };
-    DIR* dir = NULL;
-    struct dirent* ptr = NULL;
+    ParserRunner parser;
     std::string language = "";
 
-    dir = opendir(_currentPath.c_str());
-    if (dir == NULL) {
-        *pErrCode = WRT_ERR_UNKNOWN;
-        return false;
-    }
+    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);
 
-    ConfigParserData& configInfo = pWidgetConfigInfo.configInfo;
+        if (currentPath.empty() || baseFolder.empty()) {
+            *pErrCode = WRT_ERR_INVALID_ARG;
+            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);
-                ParserRunner parser;
-
-                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;
-                }
+        //TODO: rewrite this madness
+        char cfgAbsPath[MAX_WIDGET_PATH_SIZE + 1] = { 0 };
+        DIR* dir = NULL;
+        struct dirent* ptr = NULL;
 
-                //
-                //                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;
+        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);
+        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;
+        //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;
@@ -160,15 +188,11 @@ bool WidgetConfigurationManager::locateAndParseConfigurationFile(
         }
     }
 
-    if (!!configInfo.pkgname) {
-        if (!pWidgetConfigInfo.pkgname) {
-            pWidgetConfigInfo.pkgname = configInfo.pkgname;
-        } else {
-            if (pWidgetConfigInfo.pkgname != configInfo.pkgname) {
-                *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
-                LogDebug("Invalid archive - Package Name not same error");
-                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;
         }
     }
 
@@ -184,6 +208,12 @@ bool WidgetConfigurationManager::locateAndParseConfigurationFile(
         }
     }
 
+    if (!!configInfo.minVersionRequired) {
+        pWidgetConfigInfo.minVersion = configInfo.minVersionRequired;
+    } else if (!!configInfo.tizenMinVersionRequired) {
+        pWidgetConfigInfo.minVersion = configInfo.tizenMinVersionRequired;
+    }
+
     return true;
 }
 
index fc0ac5e..84ad2f7 100644 (file)
@@ -27,7 +27,7 @@
 #include <dpl/string.h>
 #include <dpl/optional.h>
 #include <dpl/wrt-dao-ro/config_parser_data.h>
-#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <list>
 
 class WidgetConfigurationManager
index 50a74bb..4751672 100644 (file)
@@ -25,6 +25,8 @@
 #include <map>
 #include <string>
 #include <cstring>
+#include <memory>
+
 #include <dpl/fast_delegate.h>
 #include <dpl/exception.h>
 #include <dpl/optional.h>
@@ -34,6 +36,7 @@
 
 struct XmlAttribute
 {
+    DPL::String prefix;
     DPL::String name;
     DPL::String value;
     DPL::String ns;
@@ -57,9 +60,9 @@ struct Text
 
 class ElementParser;
 
-typedef DPL::SharedPtr<ElementParser> ElementParserPtr;
+typedef std::shared_ptr<ElementParser> ElementParserPtr;
 
-class ElementParser : public DPL::EnableSharedFromThis<ElementParser>
+class ElementParser : public std::enable_shared_from_this<ElementParser>
 {
   public:
     class Exception
index a997f29..9fc90a0 100644 (file)
@@ -21,6 +21,8 @@
  */
 #include "ignoring_parser.h"
 
+#include <memory>
+
 IgnoringParser::IgnoringParser() : ElementParser()
 {
 }
@@ -32,7 +34,7 @@ ElementParserPtr IgnoringParser::Create()
 
 ElementParserPtr IgnoringParser::Reuse()
 {
-    return SharedFromThis();
+    return shared_from_this();
 }
 
 ElementParser::ActionFunc IgnoringParser::GetElementParser(const DPL::String& /*ns*/,
index 79d5f16..6de0c0d 100644 (file)
@@ -206,7 +206,6 @@ class ParserRunner::Impl
         Assert(m_reader);
 
         Element element;
-        element.name = GetNameWithoutNamespace();
         element.value = GetValue();
         element.lang = GetLanguageTag();
         element.ns = GetNamespace();
@@ -228,11 +227,15 @@ class ParserRunner::Impl
             xmlTextReaderMoveToAttributeNo(m_reader, i);
 
             XmlAttribute attribute;
-            attribute.name = GetName();
+            attribute.ns = GetAttributeNamespace();
+            attribute.prefix = GetNamePrefix();
+            attribute.name = GetNameWithoutNamespace();
             attribute.value = GetValue();
             attribute.lang = GetLanguageTag();
             LogDebug("Attribute name: " << attribute.name <<
                      ", value: " << attribute.value <<
+                     ", prefix: " << attribute.prefix <<
+                     ", namespace: " << attribute.ns <<
                      ", lang: " << attribute.lang);
             parser->Accept(attribute);
         }
@@ -251,7 +254,8 @@ class ParserRunner::Impl
         DPL::String ret_value;
         const xmlChar* value = xmlTextReaderConstValue(m_reader);
         if (value) {
-            ret_value = DPL::FromUTF8String(reinterpret_cast<const char*>(value));
+            ret_value =
+                DPL::FromUTF8String(reinterpret_cast<const char*>(value));
         }
 
         return ret_value;
@@ -262,7 +266,21 @@ class ParserRunner::Impl
         DPL::String ret_value;
         const xmlChar* value = xmlTextReaderGetAttributeNo(m_reader, pos);
         if (value) {
-            ret_value = DPL::FromUTF8String(reinterpret_cast<const char*>(value));
+            ret_value =
+                DPL::FromUTF8String(reinterpret_cast<const char*>(value));
+        }
+        xmlFree(const_cast<xmlChar*>(value));
+
+        return ret_value;
+    }
+
+    DPL::String GetAttributeNamespace() const
+    {
+        DPL::String ret_value;
+        const xmlChar* value = xmlTextReaderLookupNamespace(m_reader, NULL);
+        if (value) {
+            ret_value =
+                DPL::FromUTF8String(reinterpret_cast<const char*>(value));
         }
         xmlFree(const_cast<xmlChar*>(value));
 
@@ -274,7 +292,20 @@ class ParserRunner::Impl
         DPL::String ret_value;
         const xmlChar* value = xmlTextReaderConstName(m_reader);
         if (value) {
-            ret_value = DPL::FromUTF8String(reinterpret_cast<const char*>(value));
+            ret_value =
+                DPL::FromUTF8String(reinterpret_cast<const char*>(value));
+        }
+
+        return ret_value;
+    }
+
+    DPL::String GetNamePrefix() const
+    {
+        DPL::String ret_value;
+        const xmlChar* value = xmlTextReaderPrefix(m_reader);
+        if (value) {
+            ret_value =
+                DPL::FromUTF8String(reinterpret_cast<const char*>(value));
         }
 
         return ret_value;
@@ -285,7 +316,8 @@ class ParserRunner::Impl
         DPL::String ret_value;
         const xmlChar* value = xmlTextReaderLocalName(m_reader);
         if (value) {
-            ret_value = DPL::FromUTF8String(reinterpret_cast<const char*>(value));
+            ret_value =
+                DPL::FromUTF8String(reinterpret_cast<const char*>(value));
         }
 
         return ret_value;
@@ -294,9 +326,11 @@ class ParserRunner::Impl
     DPL::String GetNamespace() const
     {
         DPL::String ret_value;
+
         const xmlChar* value = xmlTextReaderConstNamespaceUri(m_reader);
         if (value) {
-            ret_value = DPL::FromUTF8String(reinterpret_cast<const char*>(value));
+            ret_value =
+                DPL::FromUTF8String(reinterpret_cast<const char*>(value));
         }
 
         return ret_value;
@@ -307,7 +341,8 @@ class ParserRunner::Impl
         DPL::String ret_value;
         const xmlChar* value = xmlTextReaderConstXmlLang(m_reader);
         if (value) {
-            ret_value = DPL::FromUTF8String(reinterpret_cast<const char*>(value));
+            ret_value =
+                DPL::FromUTF8String(reinterpret_cast<const char*>(value));
         }
 
         return ret_value;
old mode 100644 (file)
new mode 100755 (executable)
index e46b2a7..d740ac3
@@ -32,7 +32,6 @@
 #include <dpl/utils/warp_iri.h>
 #include <dpl/utils/mime_type_utils.h>
 #include <language_subtag_rst_tree.h>
-#include <ewk_main.h>
 
 #include <iri.h>
 #include <dpl/log/log.h>
@@ -140,8 +139,8 @@ class InnerElementsParser : public ElementParser
     ElementParserPtr Other()
     {
         return ElementParserPtr(new InnerElementsParser(
-                                    DPL::StaticPointerCast<ElementParser>(
-                                        SharedFromThis())));
+                                    std::static_pointer_cast<ElementParser>(
+                                        shared_from_this())));
     }
 
   private:
@@ -213,8 +212,8 @@ class NameParser : public ElementParser
     ElementParserPtr Other()
     {
         return ElementParserPtr(new InnerElementsParser(
-                                    DPL::StaticPointerCast<ElementParser>(
-                                        SharedFromThis())));
+                                    std::static_pointer_cast<ElementParser>(
+                                        shared_from_this())));
     }
 
   private:
@@ -232,7 +231,6 @@ class AccessParser : public ElementParser
     enum StandardType
     {
         STANDARD_TYPE_NONE,
-        STANDARD_TYPE_JIL,
         STANDARD_TYPE_WARP
     };
 
@@ -244,12 +242,12 @@ class AccessParser : public ElementParser
 
     virtual void Accept(const Element& element)
     {
-        if (element.ns == ConfigurationNamespace::W3CWidgetNamespaceName) {
+        // for tizen web apps WARP should be used
+        if (element.ns == ConfigurationNamespace::W3CWidgetNamespaceName ||
+            element.ns == ConfigurationNamespace::TizenWebAppNamespaceName)
+        {
             m_standardType = STANDARD_TYPE_WARP;
         }
-        if (element.ns == ConfigurationNamespace::JilWidgetNamespaceName) {
-            m_standardType = STANDARD_TYPE_JIL;
-        }
     }
 
     virtual void Accept(const Text& /*text*/)
@@ -273,26 +271,12 @@ class AccessParser : public ElementParser
         }
     }
 
-    void AcceptJil(const XmlAttribute& attribute)
-    {
-        if (attribute.name == DPL::FromASCIIString("network")) {
-            if (attribute.value == DPL::FromASCIIString("true")) {
-                m_network = true;
-            } else {
-                m_network = false;
-            }
-        }
-    }
-
     virtual void Accept(const XmlAttribute& attribute)
     {
         switch (m_standardType) {
         case STANDARD_TYPE_WARP:
             AcceptWac(attribute);
             break;
-        case STANDARD_TYPE_JIL:
-            AcceptJil(attribute);
-            break;
         default:
             LogError("Error in Access tag - unknown standard.");
         }
@@ -317,20 +301,12 @@ class AccessParser : public ElementParser
             m_data.accessInfoSet.insert(accessInfo);
     }
 
-    void VerifyJil()
-    {
-        m_data.accessNetwork = m_network;
-    }
-
     virtual void Verify()
     {
         switch (m_standardType) {
         case STANDARD_TYPE_WARP:
             VerifyWac();
             break;
-        case STANDARD_TYPE_JIL:
-            VerifyJil();
-            break;
         default:
             LogError("Error in Access tag - unknown standard.");
         }
@@ -348,7 +324,7 @@ class AccessParser : public ElementParser
     ElementParserPtr Other()
     {
         return ElementParserPtr(new InnerElementsParser(
-                                    ElementParserPtr(SharedFromThis())));
+                                    ElementParserPtr(shared_from_this())));
     }
 
   private:
@@ -359,73 +335,6 @@ class AccessParser : public ElementParser
     ConfigParserData& m_data;
 };
 
-class PkgnameParser : public ElementParser
-{
-  public:
-    virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& /*name*/)
-    {
-       return &DenyAllParser::Create;
-    }
-
-    virtual void Accept(const Element& element)
-    {
-        if (element.ns == ConfigurationNamespace::TizenWebAppNamespaceName) {
-            m_properNamespace = true;
-        }
-
-        LogDebug("element pkgname");
-    }
-
-    ElementParserPtr Other()
-    {
-        return ElementParserPtr(new InnerElementsParser(
-                                    DPL::StaticPointerCast<ElementParser>(
-                                        SharedFromThis())));
-    }
-
-    virtual void Accept(const Text& text)
-    {
-        if(m_properNamespace) {
-            m_pkgname = text.value;
-            LogDebug("Pkgname value: " << m_pkgname);
-        }
-    }
-
-    virtual void Accept(const XmlAttribute& attribute)
-    {
-        if (m_properNamespace) {
-            ThrowMsg(Exception::ParseError,
-                     "attirubte: '" + DPL::ToUTF8String(attribute.name) +
-                     "' in pkgname element not allowed");
-        }
-    }
-
-    virtual void Verify()
-    {
-        if (m_properNamespace) {
-            if (m_pkgname.IsNull()) {
-                ThrowMsg(Exception::ParseError,
-                         "pkgname element must have value");
-            }
-            m_data.pkgname = m_pkgname;
-            LogDebug("Pkgname = " << m_pkgname);
-        }
-    }
-
-    PkgnameParser(ConfigParserData& data) :
-        m_properNamespace(false),
-        m_data(data),
-        m_pkgname()
-    {
-    }
-
-  private:
-    bool m_properNamespace;
-    ConfigParserData& m_data;
-    DPL::OptionalString m_pkgname;
-};
-
 class DescriptionParser : public ElementParser
 {
   public:
@@ -444,8 +353,8 @@ class DescriptionParser : public ElementParser
     ElementParserPtr Other()
     {
         return ElementParserPtr(new InnerElementsParser(
-                                    DPL::StaticPointerCast<ElementParser>(
-                                        SharedFromThis())));
+                                    std::static_pointer_cast<ElementParser>(
+                                        shared_from_this())));
     }
 
     virtual void Accept(const Text& text)
@@ -557,8 +466,8 @@ class AuthorParser : public ElementParser
     ElementParserPtr Other()
     {
         return ElementParserPtr(new InnerElementsParser(
-                                    DPL::StaticPointerCast<ElementParser>(
-                                        SharedFromThis())));
+                                    std::static_pointer_cast<ElementParser>(
+                                        shared_from_this())));
     }
 
   private:
@@ -632,7 +541,7 @@ class LicenseParser : public ElementParser
     ElementParserPtr Other()
     {
         return ElementParserPtr(new InnerElementsParser(
-                                    ElementParserPtr(SharedFromThis())));
+                                    ElementParserPtr(shared_from_this())));
     }
 
   private:
@@ -648,6 +557,8 @@ class LicenseParser : public ElementParser
 
 class IconParser : public ElementParser
 {
+    DECLARE_EXCEPTION_TYPE(ElementParser::Exception::ParseError, BadSrcError)
+
   public:
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
             const DPL::String& /*name*/)
@@ -689,14 +600,21 @@ class IconParser : public ElementParser
             return;
         }
 
-        ConfigParserData::Icon icon(*m_src);
-        icon.width = m_width;
-        icon.height = m_height;
-
-        ConfigParserData::IconsList::iterator it = std::find(
-                m_data.iconsList.begin(), m_data.iconsList.end(), icon);
-        if (it == m_data.iconsList.end()) {
-            m_data.iconsList.push_front(icon);
+        Try
+        {
+            ConfigParserData::Icon icon(delocalizeSrcPath(*m_src));
+            icon.width = m_width;
+            icon.height = m_height;
+
+            ConfigParserData::IconsList::iterator it = std::find(
+                    m_data.iconsList.begin(), m_data.iconsList.end(), icon);
+            if (it == m_data.iconsList.end()) {
+                m_data.iconsList.push_front(icon);
+            }
+        }
+        Catch(BadSrcError)
+        {
+            LogWarning("src attribute is invalid: " << m_src);
         }
     }
 
@@ -725,6 +643,36 @@ class IconParser : public ElementParser
         }
         return DPL::OptionalInt::Null;
     }
+
+    /**
+     * @brief delocalizePath removes locales folder from relative path if neccessary
+     * @param source source string
+     *
+     * @throw BadSrcError if string is bad value of src attribute
+     *
+     * @return corrected string
+     */
+    static DPL::String delocalizeSrcPath(const DPL::String & source)
+    {
+        static const DPL::String localeFolder(L"locales/");
+        static const int index = localeFolder.size();
+
+        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
+            {
+                Throw(BadSrcError);
+            }
+        }
+        return result;
+    }
 };
 
 class ContentParser : public ElementParser
@@ -787,8 +735,7 @@ class ContentParser : public ElementParser
 
         if (!!m_src) {
             m_data.startFileContentType = m_type;
-            if (!!m_encoding && ewk_text_encoding_is_valid(
-                    DPL::ToUTF8String(*m_encoding).c_str())) {
+            if (!!m_encoding) {
                 m_data.startFileEncoding = m_encoding;
             } else {
                 m_data.startFileEncoding = L"UTF-8";
@@ -996,54 +943,6 @@ class PreferenceParser : public ElementParser
     ConfigParserData& m_data;
 };
 
-class FlashParser : public ElementParser
-{
-  public:
-    virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& /*name*/)
-    {
-        return &IgnoringParser::Create;
-    }
-
-    virtual void Accept(const XmlAttribute& attribute)
-    {
-        if (attribute.name == L"needed") {
-            if (attribute.value == L"true") {
-                m_flashNeeded = true;
-            } else {
-                m_flashNeeded = false;
-            }
-        }
-    }
-
-    virtual void Accept(const Element& /*element*/)
-    {
-        //if empty flash element will be passed, we say true
-        m_data.flashNeeded = true;
-    }
-
-    virtual void Accept(const Text& /*text*/)
-    {
-        ThrowMsg(Exception::ParseError, "flash element must be empty");
-    }
-
-    virtual void Verify()
-    {
-        m_data.flashNeeded = m_flashNeeded;
-    }
-
-    FlashParser(ConfigParserData& data) :
-        ElementParser(),
-        m_flashNeeded(false),
-        m_data(data)
-    {
-    }
-
-  private:
-    bool m_flashNeeded;
-    ConfigParserData& m_data;
-};
-
 class LinkParser : public ElementParser
 {
   public:
@@ -1105,8 +1004,6 @@ class LinkParser : public ElementParser
             ThrowMsg(Exception::ParseError,
                      "href attribute must be a valid iri/uri/url");
         }
-
-        m_data.powderDescriptionLinks.insert(*m_href);
     }
 
     LinkParser(ConfigParserData& data) :
@@ -1123,154 +1020,6 @@ class LinkParser : public ElementParser
     DPL::OptionalString m_href;
 };
 
-class MinVersionParser : public ElementParser
-{
-  public:
-    virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& /*name*/)
-    {
-        return &DenyAllParser::Create;
-    }
-
-    virtual void Accept(const XmlAttribute& attribute)
-    {
-        if (m_properNamespace) {
-            ThrowMsg(Exception::ParseError,
-                     "attirubte: '" + DPL::ToUTF8String(attribute.name) +
-                     "' in min-version element not allowed");
-        }
-    }
-
-    virtual void Accept(const Element& element)
-    {
-        if (element.ns == ConfigurationNamespace::WacWidgetNamespaceName) {
-            m_properNamespace = true;
-        }
-
-        LogDebug("element min-version");
-    }
-
-    virtual void Accept(const Text& text)
-    {
-        if (m_properNamespace) {
-            m_minVersion = text.value;
-            LogDebug("min-version value: " << m_minVersion);
-        }
-    }
-
-    virtual void Verify()
-    {
-        if (m_properNamespace) {
-            if (m_minVersion.IsNull()) {
-                ThrowMsg(Exception::ParseError,
-                         "min-version element must have value");
-            }
-
-            DPL::OptionalFloat version = ParseMinVersion(*m_minVersion);
-            if (version.IsNull()) {
-                ThrowMsg(Exception::ParseError,
-                         "min-version element must have value"
-                         " that can be parsed to float");
-            }
-
-            if (m_data.minVersionRequiredFound.IsNull()) {
-                m_data.minVersionRequiredFound = 1;
-                m_data.minVersionRequired = version;
-                LogDebug("MinVersionRequired = " << version);
-            } else {
-                ThrowMsg(Exception::ParseError,
-                         "multiple min-version elements not allowed");
-            }
-        }
-    }
-
-    MinVersionParser(ConfigParserData& data) :
-        ElementParser(),
-        m_properNamespace(false),
-        m_data(data),
-        m_minVersion()
-    {
-        LogDebug("MinVersionParser created");
-    }
-
-  private:
-    bool m_properNamespace;
-    ConfigParserData& m_data;
-    DPL::OptionalString m_minVersion;
-
-    static DPL::OptionalFloat ParseMinVersion(const DPL::String& value)
-    {
-        DPL::OptionalString normalizedValue = value;
-        NormalizeString(normalizedValue);
-        if (!(*normalizedValue).empty()) {
-            char* reterr = NULL;
-            errno = 0;
-            float valueFloat =
-                strtof(DPL::ToUTF8String(value).c_str(), &reterr);
-            if (errno != 0 ||
-                std::string(reterr) == DPL::ToUTF8String(value) ||
-                valueFloat <= 0.0) {
-                return DPL::OptionalFloat::Null;
-            } else {
-                return valueFloat;
-            }
-        }
-        return DPL::OptionalFloat::Null;
-    }
-};
-
-// tag: <back supported=true>
-class BackParser : public ElementParser
-{
-  public:
-    virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-            const DPL::String& /*name*/)
-    {
-        return &IgnoringParser::Create;
-    }
-
-    virtual void Accept(const XmlAttribute& attribute)
-    {
-        LogDebug("attribute");
-        if (attribute.name == L"supported") {
-            if (attribute.value == L"true") {
-                m_backSupported = true;
-            } else {
-                m_backSupported = false;
-            }
-        }
-    }
-
-    virtual void Accept(const Element&)
-    {
-        LogDebug("element");
-        //if empty back element will be passed, we say true
-        m_data.backSupported = true;
-    }
-
-    virtual void Accept(const Text&)
-    {
-        LogDebug("text");
-        ThrowMsg(Exception::ParseError, "back element must be empty");
-    }
-
-    virtual void Verify()
-    {
-        m_data.backSupported = m_backSupported;
-    }
-
-    BackParser(ConfigParserData& data) :
-        ElementParser(),
-        m_backSupported(false),
-        m_data(data)
-    {
-    }
-
-  private:
-    bool m_backSupported;
-    ConfigParserData& m_data;
-};
-
 class SettingParser : public ElementParser
 {
   public:
@@ -1311,7 +1060,7 @@ class SettingParser : public ElementParser
     ConfigParserData::Setting m_setting;
 };
 
-class ServiceParser : public ElementParser
+class AppServiceParser : public ElementParser
 {
   public:
     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
@@ -1397,7 +1146,7 @@ class ServiceParser : public ElementParser
         m_data.appServiceList.push_back(serviceInfo);
     }
 
-    ServiceParser(ConfigParserData& data) :
+    AppServiceParser(ConfigParserData& data) :
         ElementParser(),
         m_src(DPL::OptionalString::Null),
         m_operation(DPL::OptionalString::Null),
@@ -1415,44 +1164,1019 @@ class ServiceParser : public ElementParser
     ConfigParserData& m_data;
 };
 
-ElementParser::ActionFunc WidgetParser::GetElementParser(const DPL::String& /*ns*/,
-        const DPL::String& name)
+class AppControlParser : public ElementParser
 {
-    FuncMap::const_iterator it = m_map.find(name);
-    if (it != m_map.end()) {
-        return it->second;
-    } else {
-        return &IgnoringParser::Create;
+  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;
+     };
+     
+    virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+            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);
+        } else if (name == L"uri") {
+            return DPL::MakeDelegate(this, &AppControlParser::OnUriElement);
+        }  else if (name == L"mime") {
+            return DPL::MakeDelegate(this, &AppControlParser::OnMimeElement);
+        } else {
+            return &IgnoringParser::Create;
+        }
     }
-}
 
-WidgetParser::WidgetParser(ConfigParserData& data) :
-    m_data(data),
-    m_textDirection(Unicode::EMPTY)
-{
-    m_map[L"name"] = DPL::MakeDelegate(this, &WidgetParser::OnNameElement);
-    m_map[L"access"] = DPL::MakeDelegate(this, &WidgetParser::OnAccessElement);
-    m_map[L"description"] =
-        DPL::MakeDelegate(this, &WidgetParser::OnDescriptionElement);
-    m_map[L"author"] = DPL::MakeDelegate(this, &WidgetParser::OnAuthorElement);
-    m_map[L"license"] =
-        DPL::MakeDelegate(this, &WidgetParser::OnLicenseElement);
-    m_map[L"icon"] = DPL::MakeDelegate(this, &WidgetParser::OnIconElement);
-    m_map[L"content"] =
-        DPL::MakeDelegate(this, &WidgetParser::OnContentElement);
-    m_map[L"feature"] =
-        DPL::MakeDelegate(this, &WidgetParser::OnFeatureElement);
-    m_map[L"preference"] =
-        DPL::MakeDelegate(this, &WidgetParser::OnPreferenceElement);
-    m_map[L"flash"] = DPL::MakeDelegate(this, &WidgetParser::OnFlashElement);
+    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");
+        }
+    }
+
+    virtual void Accept(const Text& /*text*/)
+    {
+        ThrowMsg(Exception::ParseError, "param element must be empty");
+    }
+
+    virtual void Verify()
+    {
+        if (m_appControl.m_src == L""){
+            LogWarning("service element must have src element");
+            return;
+        }
+
+        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);
+    }
+
+    ElementParserPtr OnSourceElement()
+    {
+        return ElementParserPtr(new SourceParser(m_appControl));
+    }
+
+    ElementParserPtr OnOperationElement()
+    {
+        return ElementParserPtr(new OperationParser(m_appControl));
+    }
+
+    ElementParserPtr OnUriElement()
+    {
+        return ElementParserPtr(new UriParser(m_appControl));
+    }
+
+    ElementParserPtr OnMimeElement()
+    {
+        return ElementParserPtr(new MimeParser(m_appControl));
+    }
+    
+    AppControlParser(ConfigParserData& data) :
+        ElementParser(),
+        m_data(data),
+        m_appControl(L"")
+    {
+    }
+
+  private:
+    ConfigParserData& m_data;
+    ConfigParserData::AppControlInfo m_appControl;
+};
+
+class ApplicationParser : public ElementParser
+{
+  public:
+    virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+            const DPL::String& /*name*/)
+    {
+        return &IgnoringParser::Create;
+    }
+
+    virtual void Accept(const Text& text)
+    {
+        if (m_properNamespace) {
+            LogDebug("text");
+            ThrowMsg(Exception::ParseError, "application element must be empty");
+        }
+    }
+
+    virtual void Accept(const Element& element)
+    {
+        if (element.ns ==
+            ConfigurationNamespace::TizenWebAppNamespaceName)
+        {
+            m_properNamespace = true;
+        }
+        LogDebug("element");
+    }
+
+    virtual void Accept(const XmlAttribute& attribute)
+    {
+        if (m_properNamespace) {
+            LogDebug("attribute");
+            if (attribute.name == L"id") {
+                m_id = attribute.value;
+            } else if (attribute.name == L"required_version") {
+                m_version = attribute.value;
+                NormalizeString(m_version);
+            } else {
+                ThrowMsg(Exception::ParseError,
+                         "unknown attribute '" +
+                         DPL::ToUTF8String(attribute.name) +
+                         "' in application element");
+            }
+        }
+    }
+
+    virtual void Verify()
+    {
+        if(!m_id) {
+            ThrowMsg(Exception::ParseError,
+                     "application element must have id attribute");
+        }
+
+        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.tizenMinVersionRequired = m_version;
+    }
+
+    ApplicationParser(ConfigParserData& data) :
+        ElementParser(),
+        m_data(data),
+        m_id(DPL::OptionalString::Null),
+        m_version(DPL::OptionalString::Null),
+        m_properNamespace(false)
+    {
+    }
+
+  private:
+    ConfigParserData& m_data;
+    DPL::OptionalString m_id;
+    DPL::OptionalString m_version;
+    bool m_properNamespace;
+};
+
+class SplashParser : public ElementParser
+{
+  public:
+    virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+                                        const DPL::String& /*name*/)
+    {
+        return &IgnoringParser::Create;
+    }
+
+    virtual void Accept(const XmlAttribute& attribute)
+    {
+        if (attribute.name == L"src") {
+            if (attribute.value.size() > 0) {
+                m_src = attribute.value;
+            }
+        }
+    }
+
+    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");
+            return;
+        }
+
+        m_data.splashImgSrc = m_src;
+    }
+
+    SplashParser(ConfigParserData& data) :
+        ElementParser(),
+        m_data(data)
+    {
+    }
+
+  private:
+    DPL::OptionalString m_src;
+    ConfigParserData& m_data;
+};
+
+class BackgroundParser : public ElementParser
+{
+  public:
+    virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+                                        const DPL::String& /*name*/)
+    {
+        return &IgnoringParser::Create;
+    }
+
+    virtual void Accept(const XmlAttribute& attribute)
+    {
+        if (attribute.name == L"src") {
+            if (attribute.value.size() > 0) {
+                m_src = attribute.value;
+            }
+        }
+    }
+
+    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");
+            return;
+        }
+
+        m_data.backgroundPage = m_src;
+    }
+
+    explicit BackgroundParser(ConfigParserData& data) :
+        m_data(data)
+    {
+    }
+
+  private:
+    DPL::OptionalString m_src;
+    ConfigParserData& m_data;
+};
+
+class PrivilegeParser : 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)
+    {
+        if (element.ns ==
+            ConfigurationNamespace::TizenWebAppNamespaceName)
+        {
+            m_properNamespace = true;
+        }
+        LogDebug("element");
+    }
+
+    virtual void Accept(const XmlAttribute& attribute)
+    {
+        if (m_properNamespace) {
+            if (attribute.name == L"name") {
+                m_feature.name = attribute.value;
+                m_privilege.name = attribute.value;
+            }
+        }
+        m_feature.required = false;
+    }
+
+    virtual void Verify()
+    {
+        LibIri::Wrapper iri(DPL::ToUTF8String(m_feature.name).c_str());
+
+        if (m_feature.name != L"") {
+            if (iri.Validate()) {
+                if (m_data.featuresList.find(m_feature) ==
+                    m_data.featuresList.end()) {
+                    m_data.featuresList.insert(m_feature);
+                } else {
+                    LogDebug("Ignoring feature with name" <<
+                             DPL::ToUTF8String(m_feature.name));
+                }
+            }
+        }
+
+        LibIri::Wrapper iriPrivilege(
+            DPL::ToUTF8String(m_privilege.name).c_str());
+
+        if (m_privilege.name != L"") {
+            if (iriPrivilege.Validate()) {
+                if (m_data.privilegeList.find(m_privilege) ==
+                    m_data.privilegeList.end()) {
+                    m_data.privilegeList.insert(m_privilege);
+                } else {
+                    LogDebug("Ignoring privilege with name" <<
+                             DPL::ToUTF8String(m_privilege.name));
+                }
+            }
+        }
+    }
+
+    PrivilegeParser(ConfigParserData& data) :
+        ElementParser(),
+        m_data(data),
+        m_feature(L""),
+        m_privilege(L""),
+        m_properNamespace(false)
+    {
+    }
+
+  private:
+    ConfigParserData& m_data;
+    ConfigParserData::Feature m_feature;
+    ConfigParserData::Privilege m_privilege;
+    bool m_properNamespace;
+};
+
+class CategoryParser : public ElementParser
+{
+  public:
+    virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+                                        const DPL::String& /*name*/)
+    {
+        return &IgnoringParser::Create;
+    }
+
+    virtual void Accept(const XmlAttribute& attribute)
+    {
+        if (attribute.name == L"name") {
+            if (attribute.value.size() > 0) {
+                m_name = attribute.value;
+            }
+        }
+    }
+
+    virtual void Accept(const Element& /*element*/)
+    {
+    }
+
+    virtual void Accept(const Text& /*text*/)
+    {
+    }
+
+    virtual void Verify()
+    {
+        if (m_name.IsNull()) {
+            LogWarning("name attribute of category element is mandatory - ignoring");
+            return;
+        }
+
+        if (m_data.categoryList.find(*m_name) ==
+            m_data.categoryList.end()) {
+            m_data.categoryList.insert(*m_name);
+        }
+    }
+
+    explicit CategoryParser(ConfigParserData& data) :
+        m_data(data)
+    {
+    }
+
+  private:
+    DPL::OptionalString m_name;
+    ConfigParserData& m_data;
+};
+
+class LiveboxParser : public ElementParser
+{
+    public:
+
+    struct BoxLabelParser : public ElementParser
+    {
+        virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+                const DPL::String& /*name*/)
+        {
+            return &IgnoringParser::Create;
+        }
+
+        virtual void Accept(const XmlAttribute& attribute)
+        {
+        }
+
+        virtual void Accept(const Element& element)
+        {
+            if (element.ns ==
+                    ConfigurationNamespace::TizenWebAppNamespaceName)
+            {
+                m_properNamespace = true;
+            }
+        }
+
+        virtual void Accept(const Text& text)
+        {
+            if(m_properNamespace)
+                m_label = text.value;
+        }
+
+        virtual void Verify()
+        {
+            m_data.m_label = m_label;
+        }
+
+        BoxLabelParser(ConfigParserData::LiveboxInfo& data) :
+            ElementParser(),
+            m_properNamespace(false),
+            m_data(data)
+        {
+        }
+
+        private:
+        DPL::String m_label;
+        bool m_properNamespace;
+        ConfigParserData::LiveboxInfo& m_data;
+    };
+
+    struct BoxIconParser : public ElementParser
+    {
+        virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+                const DPL::String& /*name*/)
+        {
+            return &IgnoringParser::Create;
+        }
+
+        virtual void Accept(const XmlAttribute& attribute)
+        {
+            if(m_properNamespace) {
+                if (attribute.name == L"src") {
+                    m_icon = attribute.value;
+                }
+            }
+        }
+
+        virtual void Accept(const Element& element)
+        {
+            if (element.ns ==
+                    ConfigurationNamespace::TizenWebAppNamespaceName)
+            {
+                m_properNamespace = true;
+            }
+        }
+
+        virtual void Accept(const Text& /*text*/)
+        {
+        }
+
+        virtual void Verify()
+        {
+            m_data.m_icon = m_icon;
+        }
+
+        explicit BoxIconParser(ConfigParserData::LiveboxInfo& data) :
+            ElementParser(),
+            m_properNamespace(false),
+            m_data(data)
+        {
+        }
+
+        private:
+        DPL::String m_icon;
+        bool m_properNamespace;
+        ConfigParserData::LiveboxInfo& m_data;
+    };
+
+    struct BoxContentParser : public ElementParser
+    {
+        struct BoxSizeParser : public ElementParser
+        {
+            virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+                    const DPL::String& /*name*/)
+            {
+                return &IgnoringParser::Create;
+            }
+
+            virtual void Accept(const XmlAttribute& attribute)
+            {
+                if(m_properNamespace) {
+                    if (attribute.name == L"preview") {
+                        m_preview = attribute.value;
+                    }
+                }
+            }
+
+            virtual void Accept(const Element& element)
+            {
+                if (element.ns ==
+                        ConfigurationNamespace::TizenWebAppNamespaceName)
+                {
+                    m_properNamespace = true;
+                }
+            }
+
+            virtual void Accept(const Text& text)
+            {
+                if(m_properNamespace)
+                    m_size = text.value;
+            }
+
+            virtual void Verify()
+            {
+                std::pair<DPL::String, DPL::String> boxSize;
+                boxSize.first = m_size;
+                boxSize.second = m_preview;
+                m_data.m_boxSize.push_back(boxSize);
+            }
+
+            explicit BoxSizeParser(ConfigParserData::LiveboxInfo::BoxContentInfo& data) :
+                ElementParser(),
+                m_data(data)
+            {
+            }
+
+            private:
+            DPL::String m_size;
+            DPL::String m_preview;
+            bool m_properNamespace;
+            ConfigParserData::LiveboxInfo::BoxContentInfo& m_data;
+        };
+
+        struct PdParser : public ElementParser
+        {
+            virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+                    const DPL::String& name)
+            {
+                return &IgnoringParser::Create;
+            }
+
+            virtual void Accept(const XmlAttribute& attribute)
+            {
+                if(m_properNamespace) {
+                    if (attribute.name == L"src") {
+                        m_src = attribute.value;
+                    } else if (attribute.name == L"width") {
+                        m_width = attribute.value;
+                    } else if (attribute.name == L"height") {
+                        m_height = attribute.value;
+                    }
+                }
+            }
+
+            virtual void Accept(const Element& element)
+            {
+                if (element.ns ==
+                        ConfigurationNamespace::TizenWebAppNamespaceName)
+                {
+                    m_properNamespace = true;
+                }
+            }
+
+            virtual void Accept(const Text& /*text*/)
+            {
+            }
+
+            virtual void Verify()
+            {
+                m_data.m_pdSrc = m_src;
+                m_data.m_pdWidth = m_width;
+                m_data.m_pdHeight = m_height;
+            }
+
+            explicit PdParser(ConfigParserData::LiveboxInfo::BoxContentInfo& data) :
+                ElementParser(),
+                m_properNamespace(false),
+                m_data(data)
+            {
+            }
+
+            private:
+            DPL::String m_src;
+            DPL::String m_width;
+            DPL::String m_height;
+
+            bool m_properNamespace;
+            ConfigParserData::LiveboxInfo::BoxContentInfo& m_data;
+        };
+
+        virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+                const DPL::String& name)
+        {
+            if (name == L"box-size") {
+                return DPL::MakeDelegate(this, &LiveboxParser::BoxContentParser::OnBoxSizeElement);
+            } else if (name == L"pd") {
+                return DPL::MakeDelegate(this, &LiveboxParser::BoxContentParser::OnPdElement);
+            } else{
+                ThrowMsg(Exception::ParseError, "No element parser for name: " << name);
+            }
+        }
+
+        virtual void Accept(const XmlAttribute& attribute)
+        {
+            if (m_properNamespace) {
+                if (attribute.name == L"src")
+                    m_box.m_boxSrc = attribute.value;
+            }
+        }
+
+        virtual void Accept(const Element& element)
+        {
+            if (element.ns ==
+                    ConfigurationNamespace::TizenWebAppNamespaceName)
+            {
+                m_properNamespace = true;
+            }
+        }
+
+        virtual void Accept(const Text& /*text*/)
+        {
+        }
+
+        virtual void Verify()
+        {
+            m_data.m_boxInfo = m_box;
+        }
+
+        explicit BoxContentParser(ConfigParserData::LiveboxInfo& data) :
+            ElementParser(),
+            m_properNamespace(false),
+            m_data(data)
+        {
+        }
+
+        ElementParserPtr OnBoxSizeElement()
+        {
+            return ElementParserPtr(new BoxSizeParser(m_box));
+        }
+
+        ElementParserPtr OnPdElement()
+        {
+            return ElementParserPtr(new PdParser(m_box));
+        }
+
+        private:
+        DPL::String m_src;
+        bool m_properNamespace;
+        ConfigParserData::LiveboxInfo& m_data;
+        ConfigParserData::LiveboxInfo::BoxContentInfo m_box;
+    };
+
+    virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+            const DPL::String& name)
+    {
+        if (name == L"box-label") {
+            return DPL::MakeDelegate(this, &LiveboxParser::OnBoxLabelElement);
+        } else if (name == L"box-icon") {
+            return DPL::MakeDelegate(this, &LiveboxParser::OnBoxIconElement);
+        }  else if (name == L"box-content") {
+            return DPL::MakeDelegate(this, &LiveboxParser::OnBoxContentElement);
+        } else {
+            return &IgnoringParser::Create;
+        }
+    }
+
+    virtual void Accept(const XmlAttribute& attribute)
+    {
+        if (m_properNamespace) {
+            if (attribute.name == L"id") {
+                m_liveboxId = attribute.value;
+            } else if (attribute.name == L"primary") {
+                m_primary = attribute.value;
+            } else if (attribute.name == L"auto-launch") {
+                m_autoLaunch = attribute.value;
+            } else if (attribute.name == L"update-period") {
+                m_updatePeriod = attribute.value;
+            }
+        }
+    }
+
+    virtual void Accept(const Element& element)
+    {
+        if (element.ns ==
+                ConfigurationNamespace::TizenWebAppNamespaceName)
+        {
+            m_properNamespace = true;
+        }
+    }
+
+    virtual void Accept(const Text& /*text*/)
+    {
+    }
+
+    virtual void Verify()
+    {
+        m_livebox.m_liveboxId = m_liveboxId;
+        m_livebox.m_primary = m_primary;
+        m_livebox.m_autoLaunch = m_autoLaunch;
+        m_livebox.m_updatePeriod = m_updatePeriod;
+
+        m_data.m_livebox.push_back(m_livebox);
+    }
+
+    explicit LiveboxParser(ConfigParserData& data) :
+        ElementParser(),
+        m_data(data),
+        m_properNamespace(false)
+    {
+        m_livebox = ConfigParserData::LiveboxInfo();
+    }
+
+    ElementParserPtr OnBoxLabelElement()
+    {
+        return ElementParserPtr(new BoxLabelParser(m_livebox));
+    }
+
+    ElementParserPtr OnBoxIconElement()
+    {
+        return ElementParserPtr(new BoxIconParser(m_livebox));
+    }
+
+    ElementParserPtr OnBoxContentElement()
+    {
+        return ElementParserPtr(new BoxContentParser(m_livebox));
+    }
+
+  private:
+    ConfigParserData& m_data;
+    ConfigParserData::LiveboxInfo m_livebox;
+    DPL::String m_liveboxId;
+    DPL::String m_primary;
+    DPL::String m_autoLaunch;
+    DPL::String m_updatePeriod;
+    bool m_properNamespace;
+
+};
+
+
+ElementParser::ActionFunc WidgetParser::GetElementParser(const DPL::String& /*ns*/,
+        const DPL::String& name)
+{
+    FuncMap::const_iterator it = m_map.find(name);
+    if (it != m_map.end()) {
+        return it->second;
+    } else {
+        return &IgnoringParser::Create;
+    }
+}
+
+WidgetParser::WidgetParser(ConfigParserData& data) :
+    m_data(data),
+    m_textDirection(Unicode::EMPTY)
+{
+    m_map[L"name"] = DPL::MakeDelegate(this, &WidgetParser::OnNameElement);
+    m_map[L"access"] = DPL::MakeDelegate(this, &WidgetParser::OnAccessElement);
+    m_map[L"description"] =
+        DPL::MakeDelegate(this, &WidgetParser::OnDescriptionElement);
+    m_map[L"author"] = DPL::MakeDelegate(this, &WidgetParser::OnAuthorElement);
+    m_map[L"license"] =
+        DPL::MakeDelegate(this, &WidgetParser::OnLicenseElement);
+    m_map[L"icon"] = DPL::MakeDelegate(this, &WidgetParser::OnIconElement);
+    m_map[L"content"] =
+        DPL::MakeDelegate(this, &WidgetParser::OnContentElement);
+    m_map[L"feature"] =
+        DPL::MakeDelegate(this, &WidgetParser::OnFeatureElement);
+    m_map[L"preference"] =
+        DPL::MakeDelegate(this, &WidgetParser::OnPreferenceElement);
     m_map[L"link"] = DPL::MakeDelegate(this, &WidgetParser::OnLinkElement);
-    m_map[L"min-version"] =
-        DPL::MakeDelegate(this, &WidgetParser::OnMinVersionElement);
-    m_map[L"back"] = DPL::MakeDelegate(this, &WidgetParser::OnBackElement);
-    m_map[L"pkgname"] = DPL::MakeDelegate(this, &WidgetParser::OnPkgnameElement);
     m_map[L"setting"] =
         DPL::MakeDelegate(this, &WidgetParser::OnSettingElement);
-    m_map[L"appservice"] = DPL::MakeDelegate(this, &WidgetParser::OnServiceElement);
+    // TODO: appservice will be removed
+    m_map[L"appservice"] = DPL::MakeDelegate(this, &WidgetParser::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"category"] = DPL::MakeDelegate(this,
+            &WidgetParser::OnCategoryElement);
+    m_map[L"livebox"] = DPL::MakeDelegate(this, &WidgetParser::OnLiveboxElement);
+
 }
 
 ElementParserPtr WidgetParser::OnNameElement()
@@ -1500,44 +2224,61 @@ ElementParserPtr WidgetParser::OnPreferenceElement()
     return ElementParserPtr(new PreferenceParser(m_data));
 }
 
-ElementParserPtr WidgetParser::OnFlashElement()
+ElementParserPtr WidgetParser::OnLinkElement()
 {
-    return ElementParserPtr(new FlashParser(m_data));
+    return ElementParserPtr(new LinkParser(m_data));
 }
 
-ElementParserPtr WidgetParser::OnLinkElement()
+ElementParserPtr WidgetParser::OnSettingElement()
 {
-    return ElementParserPtr(new LinkParser(m_data));
+    return ElementParserPtr(new SettingParser(m_data));
 }
 
-ElementParserPtr WidgetParser::OnMinVersionElement()
+ElementParserPtr WidgetParser::OnApplicationElement()
 {
-    return ElementParserPtr(new MinVersionParser(m_data));
+    return ElementParserPtr(new ApplicationParser(m_data));
 }
 
-ElementParserPtr WidgetParser::OnBackElement()
+ElementParserPtr WidgetParser::OnSplashElement()
 {
-    return ElementParserPtr(new BackParser(m_data));
+    return ElementParserPtr(new SplashParser(m_data));
 }
 
-ElementParserPtr WidgetParser::OnPkgnameElement()
+ElementParserPtr WidgetParser::OnBackgroundElement()
 {
-    return ElementParserPtr(new PkgnameParser(m_data));
+    return ElementParserPtr(new BackgroundParser(m_data));
 }
 
-ElementParserPtr WidgetParser::OnSettingElement()
+ElementParserPtr WidgetParser::OnPrivilegeElement()
 {
-    return ElementParserPtr(new SettingParser(m_data));
+    return ElementParserPtr(new PrivilegeParser(m_data));
+}
+
+ElementParserPtr WidgetParser::OnAppServiceElement()
+{
+    return ElementParserPtr(new AppServiceParser(m_data));
+}
+
+ElementParserPtr WidgetParser::OnAppControlElement()
+{
+    return ElementParserPtr(new AppControlParser(m_data));
+}
+
+ElementParserPtr WidgetParser::OnCategoryElement()
+{
+    return ElementParserPtr(new CategoryParser(m_data));
 }
 
-ElementParserPtr WidgetParser::OnServiceElement()
+ElementParserPtr WidgetParser::OnLiveboxElement()
 {
-    return ElementParserPtr(new ServiceParser(m_data));
+    return ElementParserPtr(new LiveboxParser(m_data));
 }
 
 void WidgetParser::Accept(const Element& element)
 {
-    if (element.ns != ConfigurationNamespace::W3CWidgetNamespaceName) {
+    if (element.ns != ConfigurationNamespace::W3CWidgetNamespaceName &&
+        element.ns != ConfigurationNamespace::TizenWebAppNamespaceName)
+    {
         ThrowMsg(Exception::ParseError,
                  "Wrong xml namespace for widget element");
     }
@@ -1557,10 +2298,17 @@ void WidgetParser::Accept(const XmlAttribute& attribute)
         if (iri.Validate()) {
             m_data.widget_id = attribute.value;
             NormalizeString(m_data.widget_id);
+        } else {
+            LogWarning("Widget id validation failed: " << attribute.value);
         }
     } else if (attribute.name == L"version") {
         m_version = attribute.value;
         NormalizeString(m_version);
+    } else if (attribute.name == L"min-version") {
+        LogInfo("min-version attribute was found. Value: " << attribute.value);
+        m_minVersion = attribute.value;
+        NormalizeString(m_minVersion);
+        m_data.minVersionRequired = m_minVersion;
     } else if (attribute.name == L"height") {
         DPL::OptionalString value = attribute.value;
         NormalizeString(value);
@@ -1626,18 +2374,16 @@ void WidgetParser::Accept(const XmlAttribute& attribute)
         } else {
             LogWarning("Ignoring subsequent default locale");
         }
-    } else if (DPL::StringCompare(L"xmlns", attribute.name) < 0) {
-        LogWarning("namespace domain" << attribute.name);
-        LogWarning("namespace value  " << attribute.value);
-        DPL::OptionalString ns = attribute.value;
 
-        if (attribute.name == L"xmlns:wac") {
-            m_nameSpaces.push_back(attribute.value);
-        } else if (attribute.name == L"xmlns:tizen") {
-            m_nameSpaces.push_back(attribute.value);
-        } else if (attribute.name == L"xmlns:jil") {
-            m_nameSpaces.push_back(attribute.value);
-        }
+    //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);
     }
 }
 
@@ -1656,7 +2402,7 @@ void WidgetParser::Verify()
     }
     m_data.defaultlocale = m_defaultlocale;
     FOREACH(ns, m_nameSpaces) {
-        m_data.nameSpaces.insert(*ns);
+        m_data.nameSpaces.insert(ns->second);
     }
 }
 
old mode 100644 (file)
new mode 100755 (executable)
index d008a59..82b406c
 
 #include "element_parser.h"
 #include <list>
+#include <map>
 #include <dpl/foreach.h>
 #include <dpl/wrt-dao-ro/config_parser_data.h>
 
 namespace ConfigurationNamespace {
 static const DPL::String W3CWidgetNamespaceName =
     L"http://www.w3.org/ns/widgets";
-static const DPL::String JilWidgetNamespaceName =
-    L"http://www.jil.org/ns/widgets1.2";
 static const DPL::String WacWidgetNamespaceNameForLinkElement =
     L"http://wacapps.net/ns/widgets#";
 static const DPL::String WacWidgetNamespaceName =
@@ -74,13 +73,16 @@ class WidgetParser : public ElementParser
     ElementParserPtr OnFeatureElement();
     ElementParserPtr OnPreferenceElement();
     ElementParserPtr OnAccessElement();
-    ElementParserPtr OnFlashElement();
     ElementParserPtr OnLinkElement();
-    ElementParserPtr OnMinVersionElement();
-    ElementParserPtr OnBackElement();
-    ElementParserPtr OnPkgnameElement();
     ElementParserPtr OnSettingElement();
-    ElementParserPtr OnServiceElement();
+    ElementParserPtr OnApplicationElement();
+    ElementParserPtr OnSplashElement();
+    ElementParserPtr OnBackgroundElement();
+    ElementParserPtr OnPrivilegeElement();
+    ElementParserPtr OnAppServiceElement();
+    ElementParserPtr OnAppControlElement();
+    ElementParserPtr OnCategoryElement();
+    ElementParserPtr OnLiveboxElement();
 
     virtual ActionFunc GetElementParser(const DPL::String& ns,
             const DPL::String& name);
@@ -100,9 +102,10 @@ class WidgetParser : public ElementParser
     Unicode::Direction m_textDirection;
     FuncMap m_map;
     DPL::Optional<DPL::String> m_version;
+    DPL::Optional<DPL::String> m_minVersion;
     std::list<DPL::String> m_windowModes;
     DPL::Optional<DPL::String> m_defaultlocale;
-    std::list<DPL::String> m_nameSpaces;
+    std::map<DPL::String, DPL::String> m_nameSpaces;
 };
 
 struct IconParser;
index 70fef1a..64903b2 100644 (file)
@@ -73,7 +73,7 @@ void Job::Resume()
     m_paused = false;
 
     // Trigger next steps
-    CONTROLLER_POST_EVENT(InstallerController,
+    CONTROLLER_POST_EVENT(Logic::InstallerController,
                           InstallerControllerEvents::NextStepEvent(this));
 }
 
index 218e10b..57d3c0c 100644 (file)
@@ -28,6 +28,7 @@
 
 //WRT INCLUDES
 #include <dpl/log/log.h>
+#include <dpl/foreach.h>
 #include <job.h>
 #include "plugin_install_task.h"
 #include "job_plugin_install.h"
@@ -39,6 +40,7 @@
 #include <dpl/wrt-dao-rw/feature_dao.h>
 #include <dpl/wrt-dao-rw/plugin_dao.h>
 #include "plugin_objects.h"
+#include <wrt_plugin_export.h>
 
 using namespace WrtDB;
 
@@ -50,14 +52,24 @@ const std::string DIRECTORY_SEPARATOR = std::string("/");
     m_context->installerTask->UpdateProgress(               \
         PluginInstallerContext::step, desc);
 
+#define DISABLE_IF_PLUGIN_WITHOUT_LIB()        \
+    if(m_pluginInfo.m_libraryName.empty()) \
+    {                                          \
+        LogWarning("Plugin without library."); \
+        return;                                \
+    }
+
 namespace Jobs {
 namespace PluginInstall {
+
 PluginInstallTask::PluginInstallTask(PluginInstallerContext *inCont) :
     DPL::TaskDecl<PluginInstallTask>(this),
-    m_context(inCont)
+    m_context(inCont),
+    m_dataFromConfigXML(true)
 {
     AddStep(&PluginInstallTask::stepCheckPluginPath);
     AddStep(&PluginInstallTask::stepParseConfigFile);
+    AddStep(&PluginInstallTask::stepFindPluginLibrary);
     AddStep(&PluginInstallTask::stepCheckIfAlreadyInstalled);
     AddStep(&PluginInstallTask::stepLoadPluginLibrary);
     AddStep(&PluginInstallTask::stepRegisterPlugin);
@@ -95,16 +107,31 @@ void PluginInstallTask::stepParseConfigFile()
 {
     LogInfo("Plugin installation: step parse config file");
 
+    struct stat tmp;
+
     std::string filename = m_context->pluginFilePath + DIRECTORY_SEPARATOR +
         std::string(GlobalConfig::GetPluginMetafileName());
 
+    if (-1 == stat(filename.c_str(), &tmp)) {
+        m_dataFromConfigXML = false;
+        return;
+    }
+
     LogInfo("Plugin Config file::" << filename);
 
     Try
     {
         PluginMetafileReader reader;
         reader.initialize(filename);
-        reader.read(m_pluginMetafile);
+        reader.read(m_pluginInfo);
+
+        FOREACH(it, m_pluginInfo.m_featureContainer)
+        {
+            LogDebug("Parsed feature : " << it->m_name);
+            FOREACH (devCap, it->m_deviceCapabilities) {
+                LogDebug("  |  DevCap : " << *devCap);
+            }
+        }
 
         SET_PLUGIN_INSTALL_PROGRESS(PLUGIN_PATH, "Config file analyzed");
     }
@@ -116,9 +143,34 @@ void PluginInstallTask::stepParseConfigFile()
     }
 }
 
+void PluginInstallTask::stepFindPluginLibrary()
+{
+    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)
+    {
+        indexpos = 0;
+    }
+    else
+    {
+        indexpos += 1;  // move after '/'
+    }
+
+    std::string libName = pluginPath.substr(indexpos);
+    libName = GlobalConfig::GetPluginPrefix() + libName + GlobalConfig::GetPluginSuffix();
+    LogDebug("Plugin .so: " << libName);
+    m_pluginInfo.m_libraryName = libName;
+}
+
 void PluginInstallTask::stepCheckIfAlreadyInstalled()
 {
-    if (PluginDAO::isPluginInstalled(m_pluginMetafile.m_libraryName)) {
+    if (PluginDAO::isPluginInstalled(m_pluginInfo.m_libraryName)) {
         ThrowMsg(Exceptions::PluginAlreadyInstalled,
                  "Plugin already installed");
     }
@@ -130,12 +182,14 @@ void PluginInstallTask::stepLoadPluginLibrary()
 {
     LogInfo("Plugin installation: step load library");
 
+    DISABLE_IF_PLUGIN_WITHOUT_LIB()
+
     std::string filename = m_context->pluginFilePath + DIRECTORY_SEPARATOR +
-        m_pluginMetafile.m_libraryName;
+        m_pluginInfo.m_libraryName;
 
     LogDebug("Loading plugin: " << filename);
 
-    void *dlHandle = dlopen(filename.c_str(), RTLD_LAZY);
+    void *dlHandle = dlopen(filename.c_str(), RTLD_NOW);
     if (dlHandle == NULL ) {
         LogError(
                 "Failed to load plugin: " << filename <<
@@ -143,59 +197,116 @@ void PluginInstallTask::stepLoadPluginLibrary()
         ThrowMsg(Exceptions::PluginLibraryError, "Library error");
     }
 
-    const class_definition_t *rawClassList = NULL;
-    get_widget_class_map_proc *getWidgetClassMapProcPtr = NULL;
+    const js_entity_definition_t *rawEntityList = NULL;
+    get_widget_entity_map_proc *getWidgetEntityMapProcPtr = NULL;
 
-    getWidgetClassMapProcPtr =
-        reinterpret_cast<get_widget_class_map_proc *>(dlsym(dlHandle,
+    getWidgetEntityMapProcPtr =
+        reinterpret_cast<get_widget_entity_map_proc *>(dlsym(dlHandle,
                     PLUGIN_GET_CLASS_MAP_PROC_NAME));
 
-    if (getWidgetClassMapProcPtr) {
-        rawClassList = (*getWidgetClassMapProcPtr)();
+    if (getWidgetEntityMapProcPtr) {
+        rawEntityList = (*getWidgetEntityMapProcPtr)();
     } else {
-        rawClassList =
-            static_cast<const class_definition_t *>(dlsym(dlHandle,
+        rawEntityList =
+            static_cast<const js_entity_definition_t *>(dlsym(dlHandle,
                         PLUGIN_CLASS_MAP_NAME));
     }
 
-    if (rawClassList == NULL) {
+    if (rawEntityList == NULL) {
         dlclose(dlHandle);
         LogError("Failed to read class name" << filename);
         ThrowMsg(Exceptions::PluginLibraryError, "Library error");
     }
 
+    if (!m_dataFromConfigXML)
+    {
+        on_widget_init_proc *onWidgetInitProc =
+            reinterpret_cast<on_widget_init_proc *>(
+                dlsym(dlHandle, PLUGIN_WIDGET_INIT_PROC_NAME));
+
+        if (NULL == onWidgetInitProc)
+        {
+            dlclose(dlHandle);
+            LogError("Failed to read onWidgetInit symbol" << filename);
+            ThrowMsg(Exceptions::PluginLibraryError, "Library error");
+        }
+
+        // obtain feature -> dev-cap mapping
+        feature_mapping_interface_t mappingInterface = { NULL, NULL, NULL };
+        (*onWidgetInitProc)(&mappingInterface);
+
+        if (!mappingInterface.featGetter || !mappingInterface.release ||
+            !mappingInterface.dcGetter)
+        {
+            LogError("Failed to obtain mapping interface from .so");
+            ThrowMsg(Exceptions::PluginLibraryError, "Library error");
+        }
+
+        feature_mapping_t* devcapMapping = mappingInterface.featGetter();
+
+        LogDebug("Getting mapping from features to device capabilities");
+
+        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);
+
+            LogDebug("device=cap: " << dc);
+
+            if (dc)
+            {
+                LogDebug("devcaps count: " << dc->devCapsCount);
+
+                for (size_t j = 0; j < dc->devCapsCount; ++j)
+                {
+                    LogDebug("devcap: " << dc->deviceCaps[j]);
+                    feature.m_deviceCapabilities.insert(dc->deviceCaps[j]);
+                }
+            }
+
+            m_pluginInfo.m_featureContainer.insert(feature);
+        }
+
+        mappingInterface.release(devcapMapping);
+    }
+
     m_libraryObjects = PluginObjectsPtr(new PluginObjects());
-    const class_definition_t *rawClassListIterator = rawClassList;
+    const js_entity_definition_t *rawEntityListIterator = rawEntityList;
 
     LogInfo("#####");
     LogInfo("##### Plugin: " << filename << " supports new plugin API");
     LogInfo("#####");
 
-    while (rawClassListIterator->parent_name != NULL &&
-            rawClassListIterator->object_name != NULL &&
-            rawClassListIterator->js_class_template != NULL) {
-        LogInfo("#####     [" << rawClassListIterator->object_name << "]: ");
-        LogInfo("#####     Parent: " << rawClassListIterator->parent_name);
+    while (rawEntityListIterator->parent_name != NULL &&
+            rawEntityListIterator->object_name != NULL)
+    {
+        LogInfo("#####     [" << rawEntityListIterator->object_name << "]: ");
+        LogInfo("#####     Parent: " << rawEntityListIterator->parent_name);
         LogInfo("#####");
 
-        m_libraryObjects->addObjects(rawClassListIterator->parent_name,
-                rawClassListIterator->object_name);
+        m_libraryObjects->addObjects(rawEntityListIterator->parent_name,
+                rawEntityListIterator->object_name);
 
-        ++rawClassListIterator;
-}
+        ++rawEntityListIterator;
+    }
 
-// Unload library
-if (dlclose(dlHandle) != 0) {
-    LogError("Cannot close plugin handle");
-} else {
-    LogDebug("Library is unloaded");
-}
+    // Unload library
+    if (dlclose(dlHandle) != 0) {
+        LogError("Cannot close plugin handle");
+    } else {
+        LogDebug("Library is unloaded");
+    }
 
     // Load export table
     LogDebug("Library successfuly loaded and parsed");
 
     SET_PLUGIN_INSTALL_PROGRESS(LOADING_LIBRARY, "Library loaded and analyzed");
-    //TODO unload library;
 }
 
 void PluginInstallTask::stepRegisterPlugin()
@@ -203,7 +314,7 @@ void PluginInstallTask::stepRegisterPlugin()
     LogInfo("Plugin installation: step register Plugin");
 
     m_pluginHandle =
-        PluginDAO::registerPlugin(m_pluginMetafile, m_context->pluginFilePath);
+        PluginDAO::registerPlugin(m_pluginInfo, m_context->pluginFilePath);
 
     SET_PLUGIN_INSTALL_PROGRESS(REGISTER_PLUGIN, "Plugin registered");
 }
@@ -212,7 +323,7 @@ void PluginInstallTask::stepRegisterFeatures()
 {
     LogInfo("Plugin installation: step register features");
 
-    FOREACH(it, m_pluginMetafile.m_featureContainer)
+    FOREACH(it, m_pluginInfo.m_featureContainer)
     {
         LogError("PluginHandle: " << m_pluginHandle);
         FeatureDAO::RegisterFeature(*it, m_pluginHandle);
@@ -224,6 +335,8 @@ void PluginInstallTask::stepRegisterPluginObjects()
 {
     LogInfo("Plugin installation: step register objects");
 
+    DISABLE_IF_PLUGIN_WITHOUT_LIB()
+
     //register implemented objects
     PluginObjects::ObjectsPtr objects =
         m_libraryObjects->getImplementedObject();
@@ -253,6 +366,18 @@ 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);
+        //Installation completed
+        m_context->pluginHandle = m_pluginHandle;
+        m_context->installationCompleted = true;
+        LogWarning("Plugin without library.");
+        return;
+    }
+
     PluginHandleSetPtr handles = PluginHandleSetPtr(new PluginHandleSet);
 
     DbPluginHandle handle = INVALID_PLUGIN_HANDLE;
index f3eaa99..c7a5d8c 100644 (file)
@@ -43,15 +43,18 @@ class PluginInstallTask :
     PluginInstallerContext *m_context;
 
     //PluginMetafile
-    WrtDB::PluginMetafileData m_pluginMetafile;
+    WrtDB::PluginMetafileData m_pluginInfo;
 
     //Plugin LibraryObjects
     PluginObjectsPtr m_libraryObjects;
 
     WrtDB::DbPluginHandle m_pluginHandle;
 
+    bool m_dataFromConfigXML;
+
     //steps
     void stepCheckPluginPath();
+    void stepFindPluginLibrary();
     void stepParseConfigFile();
     void stepCheckIfAlreadyInstalled();
     void stepLoadPluginLibrary();
index f8b91e5..ac500e8 100644 (file)
@@ -28,10 +28,6 @@ namespace {
 const std::string XML_NAMESPACE = "";
 
 const std::string TOKEN_LIBRARY_NAME = "library-name";
-const std::string TOKEN_FEATURE_INSTALL_URI = "feature-install-uri";
-const std::string TOKEN_FEATURE_KEY_CN = "feature-key-cn";
-const std::string TOKEN_FEATURE_ROOT_CN = "feature-root-cn";
-const std::string TOKEN_FEATURE_ROOT_FINGERPRINT = "feature-root-fingerprint";
 const std::string TOKEN_API_FEATURE = "api-feature";
 const std::string TOKEN_NAME = "name";
 const std::string TOKEN_DEVICECAPABILITY = "device-capability";
@@ -45,26 +41,6 @@ PluginMetafileReader::PluginMetafileReader() : m_parserSchema(this)
         &PluginMetafileReader::tokenEndLibraryName);
 
     m_parserSchema.addEndTagCallback(
-        TOKEN_FEATURE_INSTALL_URI,
-        XML_NAMESPACE,
-        &PluginMetafileReader::tokenEndFeatureInstallURI);
-
-    m_parserSchema.addEndTagCallback(
-        TOKEN_FEATURE_KEY_CN,
-        XML_NAMESPACE,
-        &PluginMetafileReader::tokenEndFeatureKeyCN);
-
-    m_parserSchema.addEndTagCallback(
-        TOKEN_FEATURE_ROOT_CN,
-        XML_NAMESPACE,
-        &PluginMetafileReader::tokenEndFeatureRootCN);
-
-    m_parserSchema.addEndTagCallback(
-        TOKEN_FEATURE_ROOT_FINGERPRINT,
-        XML_NAMESPACE,
-        &PluginMetafileReader::tokenEndFeatureRootFingerprint);
-
-    m_parserSchema.addEndTagCallback(
         TOKEN_API_FEATURE,
         XML_NAMESPACE,
         &PluginMetafileReader::tokenEndApiFeature);
@@ -89,30 +65,10 @@ void PluginMetafileReader::tokenEndLibraryName(PluginMetafileData &data)
     data.m_libraryName = m_parserSchema.getText();
 }
 
-void PluginMetafileReader::tokenEndFeatureInstallURI(PluginMetafileData &data)
-{
-    data.m_featuresInstallURI = m_parserSchema.getText();
-}
-
-void PluginMetafileReader::tokenEndFeatureKeyCN(PluginMetafileData &data)
-{
-    data.m_featuresKeyCN = m_parserSchema.getText();
-}
-
-void PluginMetafileReader::tokenEndFeatureRootCN(PluginMetafileData &data)
-{
-    data.m_featuresRootCN = m_parserSchema.getText();
-}
-
-void PluginMetafileReader::tokenEndFeatureRootFingerprint(
-        PluginMetafileData &data)
-{
-    data.m_featuresRootFingerprint = m_parserSchema.getText();
-}
-
 void PluginMetafileReader::tokenEndApiFeature(PluginMetafileData &data)
 {
     data.m_featureContainer.insert(m_feature);
+    m_feature.m_deviceCapabilities.clear();
 }
 
 void PluginMetafileReader::tokenEndName(PluginMetafileData & /* data */)
index 8de27ed..b0c88f0 100644 (file)
@@ -48,10 +48,6 @@ class PluginMetafileReader
     void blankFunction(WrtDB::PluginMetafileData &data);
 
     void tokenEndLibraryName(WrtDB::PluginMetafileData &data);
-    void tokenEndFeatureInstallURI(WrtDB::PluginMetafileData &data);
-    void tokenEndFeatureKeyCN(WrtDB::PluginMetafileData &data);
-    void tokenEndFeatureRootCN(WrtDB::PluginMetafileData &data);
-    void tokenEndFeatureRootFingerprint(WrtDB::PluginMetafileData &data);
     void tokenEndApiFeature(WrtDB::PluginMetafileData &data);
     void tokenEndName(WrtDB::PluginMetafileData &data);
     void tokenEndDeviceCapability(WrtDB::PluginMetafileData &data);
index 95696d8..4a8ab14 100644 (file)
@@ -23,7 +23,7 @@
 #ifndef WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_OBJECTS_H_
 #define WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_OBJECTS_H_
 
-#include <dpl/shared_ptr.h>
+#include <memory>
 #include <string>
 #include <set>
 #include <list>
@@ -53,27 +53,6 @@ class PluginObjects : public WrtDB::PluginObjectsDAO
     void addDependentObject(const std::string& value);
 };
 
-typedef DPL::SharedPtr<PluginObjects> PluginObjectsPtr;
-
-/**
- +* Plugin export names
- +*/
-#define PLUGIN_GET_CLASS_MAP_PROC_NAME  "get_widget_class_map"
-#define PLUGIN_CLASS_MAP_NAME           "class_map"
-
-typedef struct class_definition_s
-{
-    const char  *parent_name;
-    const char  *object_name;
-    const void  *js_class_template;
-    //class options may be null - default
-    void        *class_options;
-} class_definition_t;
-
-/**
- +* Plugin export typedefs
- +*/
-typedef const class_definition_t *class_definition_ptr_t;
-typedef const class_definition_t* (*get_widget_class_map_proc)();
+typedef std::shared_ptr<PluginObjects> PluginObjectsPtr;
 
 #endif
diff --git a/src/jobs/widget_install/ace_registration.cpp b/src/jobs/widget_install/ace_registration.cpp
new file mode 100644 (file)
index 0000000..00165f1
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    ace_registration.cpp
+ * @author  Andrzej Surdej (a.surdej@gmail.com)
+ * @version 1.0
+ * @brief   Translate structures to ace api - implementation file
+ */
+
+#include <ace_registration.h>
+#include <dpl/log/log.h>
+#include <dpl/foreach.h>
+#include <ace_api_install.h>
+
+namespace {
+
+char* toAceString(const DPL::OptionalString& os)
+{
+    if (!os.IsNull())
+        return strdup(DPL::ToUTF8String(*os).c_str());
+    else
+        return NULL;
+}
+
+char* toAceString(const std::string& str)
+{
+    if (!str.empty())
+        return strdup(str.c_str());
+    else
+        return NULL;
+}
+
+} //anonymous namespace
+
+namespace AceApi {
+
+bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle,
+                               const WrtDB::WidgetRegisterInfo& widgetConfig,
+                               const WrtDB::WidgetCertificateDataList& certList)
+{
+    LogDebug("Updating Ace database");
+    struct widget_info wi;
+    DPL::OptionalString os;
+
+    switch(widgetConfig.webAppType.appType)
+    {
+        case WrtDB::APP_TYPE_WAC20:
+            wi.type = WAC20;
+            break;
+        case WrtDB::APP_TYPE_TIZENWEBAPP:
+            wi.type = Tizen;
+            break;
+        default:
+            LogError("Unknown application type");
+            return false;
+    }
+
+    wi.id = toAceString(widgetConfig.configInfo.widget_id);
+    wi.version = toAceString(widgetConfig.configInfo.version);
+    wi.author = toAceString(widgetConfig.configInfo.authorName);
+    wi.shareHerf = strdup(widgetConfig.shareHref.c_str());
+    LogDebug("Basic data converted. Certificates begin.");
+
+    //one more element for NULL termination
+    LogDebug("Found: " << certList.size() << " certificates");
+    ace_certificate_data** certData = new ace_certificate_data*[certList.size() + 1];
+    certData[certList.size()] = NULL; // last element set to NULL
+
+    int i = 0;
+    FOREACH(it, certList)
+    {
+        certData[i] = new ace_certificate_data;
+        switch (it->owner) {
+        case WrtDB::WidgetCertificateData::AUTHOR :
+            certData[i]->owner = AUTHOR;
+            break;
+        case WrtDB::WidgetCertificateData::DISTRIBUTOR :
+            certData[i]->owner = DISTRIBUTOR;
+            break;
+        default :
+            LogDebug("Unknown owner type of cert");
+            certData[i]->owner = UNKNOWN;
+        }
+        switch (it->type) {
+            case WrtDB::WidgetCertificateData::ENDENTITY :
+                certData[i]->type = ENDENTITY;
+                break;
+            case WrtDB::WidgetCertificateData::ROOT :
+                certData[i]->type = ROOT;
+                break;
+            default :
+                LogError("Unknown type of cert");
+                certData[i]->type = ENDENTITY;
+        }
+        certData[i]->chain_id = it->chainId;
+
+        certData[i]->md5_fp = toAceString(it->strMD5Fingerprint);
+        certData[i]->sha1_fp = toAceString(it->strSHA1Fingerprint);
+        certData[i]->common_name = toAceString(DPL::ToUTF8String(it->strCommonName));
+        ++i;
+    }
+
+    LogDebug("Registerign widget in ace");
+    ace_return_t retval = ACE_ACE_UNKNOWN_ERROR;
+    retval = ace_register_widget(
+        static_cast<ace_widget_handle_t>(widgetHandle), &wi, certData);
+
+    //clean up - WidgetInfo
+    free(wi.author);
+    free(wi.id);
+    free(wi.shareHerf);
+    free(wi.version);
+
+    //free cert list
+    i = 0;
+    while (certData[i] != NULL) {
+        free(certData[i]->common_name);
+        free(certData[i]->md5_fp);
+        free(certData[i]->sha1_fp);
+        delete certData[i];
+        ++i;
+    }
+    delete[] certData;
+    return retval == ACE_OK;
+}
+}
diff --git a/src/jobs/widget_install/ace_registration.h b/src/jobs/widget_install/ace_registration.h
new file mode 100644 (file)
index 0000000..2f4a3b0
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    ace_registration.h
+ * @author  Andrzej Surdej (a.surdej@gmail.com)
+ * @version 1.0
+ * @brief   Translate structures to ace api - header file
+ */
+#ifndef WRT_SRC_INSTALLER_CORE_ACE_REGISTRATION_H_
+#define WRT_SRC_INSTALLER_CORE_ACE_REGISTRATION_H_
+
+#include <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_ */
+
index 114878d..5b5148b 100644 (file)
  * @version 1.0
  * @brief   Implementation file for main installer task
  */
+#include <memory>
+#include <string>
+#include <sys/time.h>
+#include <ctime>
+#include <cstdlib>
+#include <limits.h>
+#include <regex.h>
+
 #include <dpl/noncopyable.h>
 #include <dpl/abstract_waitable_input_adapter.h>
 #include <dpl/abstract_waitable_output_adapter.h>
 #include <dpl/zip_input.h>
-#include <dpl/scoped_ptr.h>
 #include <dpl/binary_queue.h>
 #include <dpl/copy.h>
 #include <dpl/assert.h>
 #include <dpl/sstream.h>
+#include <dpl/file_input.h>
+#include <dpl/utils/wrt_utility.h>
+#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-rw/global_dao.h> // TODO remove
+#include <dpl/localization/w3c_file_localization.h>
+
+#include <libiriwrapper.h>
+#include <pkg-manager/pkgmgr_signal.h>
+#include <app_manager.h>
+//#include <drm_client.h>
+#include <drm-oem-intel.h> //temporary code
+
 #include "root_parser.h"
 #include "widget_parser.h"
 #include "parser_runner.h"
 #include <widget_install/job_widget_install.h>
-#include <widget_install/task_parental_mode.h>
-#include <widget_install/task_unzip.h>
 #include <widget_install/task_certify.h>
 #include <widget_install/task_widget_config.h>
-#include <widget_install/task_db_update.h>
+#include <widget_install/task_file_manipulation.h>
 #include <widget_install/task_ace_check.h>
 #include <widget_install/task_smack.h>
-#include <widget_install/task_desktop_file.h>
-#include <widget_install/task_private_storage.h>
+#include <widget_install/task_manifest_file.h>
+#include <widget_install/task_prepare_files.h>
+#include <widget_install/task_recovery.h>
+#include <widget_install/task_install_ospsvc.h>
+#include <widget_install/task_update_files.h>
+#include <widget_install/task_database.h>
+#include <widget_install/task_remove_backup.h>
+#include <widget_install/task_encrypt_resource.h>
+#include <widget_install/task_certificates.h>
+#include <widget_install/task_unzip.h>
+#include <widget_install/task_commons.h>
+
+#include <widget_install/task_plugins_copy.h>
+
 #include <widget_install/widget_install_errors.h>
 #include <widget_install/widget_install_context.h>
-#include <string>
-#include <dpl/wrt-dao-rw/widget_dao.h> //TODO remove
-#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
-#include <dpl/wrt-dao-rw/global_dao.h> // TODO remove
-#include <aul.h>
-#include <dpl/localization/w3c_file_localization.h>
+#include <widget_install_to_external.h>
 
 using namespace WrtDB;
 
 namespace // anonymous
 {
 const char * const CONFIG_XML = "config.xml";
+const char * const WITH_OSP_XML = "res/wgt/config.xml";
 
-struct PathAndFilePair
-{
-    std::string path;
-    std::string file;
-
-    PathAndFilePair(const std::string &p,
-            const std::string &f) :
-        path(p),
-        file(f)
-    {
-    }
-};
+//allowed: a-z, A-Z, 0-9
+const char* REG_TIZENID_PATTERN = "^[a-zA-Z0-9]{10}$";
 
-PathAndFilePair SplitFileAndPath(const std::string &filePath)
-{
-    std::string::size_type position = filePath.rfind('/');
-
-    // Is this only a file without a path ?
-    if (position == std::string::npos) {
-        return PathAndFilePair(std::string(), filePath);
-    }
-
-    // This is full file-path pair
-    return PathAndFilePair(filePath.substr(0,
-                                           position),
-                           filePath.substr(position + 1));
-}
+static const DPL::String SETTING_VALUE_ENCRYPTION = L"encryption";
+static const DPL::String SETTING_VALUE_ENCRYPTION_ENABLE = L"enable";
+const DPL::String SETTING_VALUE_INSTALLTOEXT_NAME =
+    L"install-location-type";
+const DPL::String SETTING_VALUE_INSTALLTOEXT_PREPER_EXT =
+    L"prefer-external";
 
 class InstallerTaskFail :
     public DPL::TaskDecl<InstallerTaskFail>
@@ -110,6 +119,36 @@ class InstallerTaskFail :
         AddStep(&InstallerTaskFail::StepFail);
     }
 };
+
+const std::string XML_EXTENSION = ".xml";
+
+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);
+        return false;
+    }
+    return (0 == filename.compare(fileLen-extLen, extLen, extension));
+}
+
+bool checkTizenIdExist(const std::string& tizenId) {
+    std::string installPath =
+        std::string(GlobalConfig::GetUserInstalledWidgetPath()) +
+        "/" + tizenId;
+    std::string preinstallPath =
+        std::string(GlobalConfig::GetUserPreloadedWidgetPath()) +
+        "/" + tizenId;
+
+    struct stat dirStat;
+    if ((stat(installPath.c_str(), &dirStat) == 0) &&
+            (stat(preinstallPath.c_str(), &dirStat) == 0)) {
+        return true;
+    }
+    return false;
+}
 } // namespace anonymous
 
 namespace Jobs {
@@ -120,28 +159,105 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
     JobContextBase<WidgetInstallationStruct>(installerStruct),
     m_exceptionCaught(Exceptions::Success)
 {
-    // Configure installation
-    ConfigureResult result = ConfigureInstallation(widgetPath);
+    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");
 
+        AddTask(new TaskRecovery(m_installerContext));
+
         // Create installation tasks
-        AddTask(new TaskParentalMode(m_installerContext));
-        AddTask(new TaskUnzip(m_installerContext));
+        if (m_installerContext.widgetConfig.packagingType !=
+                WrtDB::PKG_TYPE_DIRECTORY_WEB_APP &&
+            m_installerContext.widgetConfig.packagingType !=
+                WrtDB::PKG_TYPE_HOSTED_WEB_APP &&
+            !m_isDRM)
+        {
+            AddTask(new TaskUnzip(m_installerContext));
+        }
+
         AddTask(new TaskWidgetConfig(m_installerContext));
+        if (m_installerContext.widgetConfig.packagingType  ==
+                WrtDB::PKG_TYPE_HOSTED_WEB_APP)
+        {
+            AddTask(new TaskPrepareFiles(m_installerContext));
+        }
         AddTask(new TaskCertify(m_installerContext));
-        AddTask(new TaskDbUpdate(m_installerContext));
+        if (m_needEncryption) {
+            AddTask(new TaskEncryptResource(m_installerContext));
+        }
+
+        AddTask(new TaskFileManipulation(m_installerContext));
         // TODO: Update progress information for this task
 
-        AddTask(new TaskAceCheck(m_installerContext));
         //This is sort of quick solution, because ACE verdicts are based upon
         //data from DAO (DB). So AceCheck for now has to be AFTER DbUpdate
         //task.
         AddTask(new TaskSmack(m_installerContext));
 
-        AddTask(new TaskDesktopFile(m_installerContext));
-        AddTask(new TaskPrivateStorage(m_installerContext));
+        AddTask(new TaskManifestFile(m_installerContext));
+        AddTask(new TaskCertificates(m_installerContext));
+        if (m_installerContext.widgetConfig.packagingType ==
+                PKG_TYPE_HYBRID_WEB_APP) {
+            AddTask(new TaskInstallOspsvc(m_installerContext));
+        }
+        AddTask(new TaskPluginsCopy(m_installerContext));
+        AddTask(new TaskDatabase(m_installerContext));
+        AddTask(new TaskAceCheck(m_installerContext));
+    } else if (result == ConfigureResult::Updated) {
+        LogInfo("Configure installation updated");
+        LogInfo("Widget Update");
+        if (m_installerContext.widgetConfig.packagingType !=
+                WrtDB::PKG_TYPE_HOSTED_WEB_APP &&
+            m_installerContext.widgetConfig.packagingType !=
+                WrtDB::PKG_TYPE_DIRECTORY_WEB_APP &&
+            !m_isDRM)
+        {
+            AddTask(new TaskUnzip(m_installerContext));
+        }
+
+        AddTask(new TaskWidgetConfig(m_installerContext));
+
+        if (m_installerContext.widgetConfig.packagingType ==
+                WrtDB::PKG_TYPE_HOSTED_WEB_APP)
+        {
+            AddTask(new TaskPrepareFiles(m_installerContext));
+        }
+
+        AddTask(new TaskCertify(m_installerContext));
+        if (m_installerContext.widgetConfig.packagingType !=
+            WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
+        {
+            AddTask(new TaskUpdateFiles(m_installerContext));
+        }
+
+        /* TODO : To backup file, save md5 values */
+        AddTask(new TaskSmack(m_installerContext));
+
+        AddTask(new TaskManifestFile(m_installerContext));
+        if (m_installerContext.widgetConfig.packagingType ==
+                PKG_TYPE_HYBRID_WEB_APP) {
+            AddTask(new TaskInstallOspsvc(m_installerContext));
+        }
+        if (m_installerContext.widgetConfig.packagingType !=
+            WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
+        {
+            AddTask(new TaskRemoveBackupFiles(m_installerContext));
+        }
+        AddTask(new TaskPluginsCopy(m_installerContext));
+        AddTask(new TaskDatabase(m_installerContext));
+        AddTask(new TaskAceCheck(m_installerContext));
+        //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");
@@ -157,27 +273,152 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
     }
 }
 
-DPL::Optional<WidgetHandle> JobWidgetInstall::getNewWidgetHandle() const
+JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation(
+        const std::string &widgetPath)
 {
-    return m_installerContext.widgetHandle;
+    ConfigureResult result;
+    m_needEncryption = false;
+
+    Try
+    {
+        std::string tempDir =
+            Jobs::WidgetInstall::createTempPath(m_jobStruct.m_preload);
+
+        m_isDRM = isDRMWidget(widgetPath);
+        if (true == m_isDRM) {
+            LogDebug("decrypt DRM widget");
+            if(DecryptDRMWidget(widgetPath, tempDir)) {
+                LogDebug("Failed decrypt DRM widget");
+                return ConfigureResult::Failed;
+            }
+        }
+
+        LogDebug("widgetPath:" << widgetPath);
+
+        m_installerContext.widgetConfig.packagingType =
+            checkPackageType(widgetPath, tempDir);
+        ConfigParserData configData = getWidgetDataFromXML(
+            widgetPath,
+            tempDir,
+            m_installerContext.widgetConfig.packagingType,
+            m_isDRM);
+        LogDebug("widget packaging type : " <<
+                m_installerContext.widgetConfig.packagingType.pkgType);
+
+        setTizenId(configData);
+        setApplicationType(configData);
+        m_needEncryption = detectResourceEncryption(configData);
+        setInstallLocationType(configData);
+
+        // Configure installation
+        result = ConfigureInstallation(widgetPath, configData, tempDir);
+    }
+    Catch(Exceptions::ExtractFileFailed)
+    {
+        LogError("Failed to create temporary path for widget");
+        result = ConfigureResult::Failed;
+    }
+
+    return result;
 }
 
-bool JobWidgetInstall::getUnzipStartedFlag() const
+void JobWidgetInstall::setTizenId(
+        const WrtDB::ConfigParserData &configInfo)
 {
-    return m_installerContext.unzipStarted;
+    using namespace PackageManager;
+
+    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;
+
+    } else {
+        WidgetPkgName tizenId = WidgetDAOReadOnly::generateTizenId();
+        LogDebug("Checking if tizen id is unique");
+        while (true) {
+            if (checkTizenIdExist(DPL::ToUTF8String(tizenId))) {
+                //path exist, chose another one
+                tizenId = WidgetDAOReadOnly::generateTizenId();
+                continue;
+            }
+            break;
+        }
+
+        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);
+    }
+
+    LogInfo("Tizen Id : " << m_installerContext.widgetConfig.pkgName);
+    LogInfo("W3C Widget GUID : " << m_installerContext.widgetConfig.guid);
 }
 
-bool JobWidgetInstall::getUnzipFinishedFlag() const
+void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath,
+                                               const std::string& tempPath)
 {
-    return m_installerContext.unzipFinished;
+    m_installerContext.locations =
+        WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig.pkgName),
+                widgetPath, tempPath,
+                m_installerContext.widgetConfig.packagingType,
+                m_installerContext.locationType);
+
+    LogInfo("widgetSource " << widgetPath);
 }
 
 JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
-        const std::string &widgetPath)
+        const std::string &widgetSource,
+        const WrtDB::ConfigParserData &configData,
+        const std::string &tempPath)
 {
-    // Detect widget update
-    WidgetUpdateInfo update = detectWidgetUpdate(widgetPath);
+    WidgetUpdateInfo update = detectWidgetUpdate(configData,
+            m_installerContext.widgetConfig.webAppType,
+            m_installerContext.widgetConfig.pkgName);
+    ConfigureResult result = checkWidgetUpdate(update);
+
+    // Validate tizenId
+    regex_t reg;
+    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))
+    {
+        //it is true when tizenId does not fit REG_TIZENID_PATTERN
+        LogError("tizen_id provided but not proper.");
+        regfree(&reg);
+        return ConfigureResult::Failed;
+    }
+    regfree(&reg);
+
+    configureWidgetLocation(widgetSource, tempPath);
+
+    // Init installer context
+    m_installerContext.installStep = InstallerContext::INSTALL_START;
+    m_installerContext.job = this;
+    m_installerContext.existingWidgetInfo = update.existingWidgetInfo;
+    m_installerContext.widgetConfig.shareHref = std::string();
+
+    return result;
+}
 
+JobWidgetInstall::ConfigureResult JobWidgetInstall::checkWidgetUpdate(
+        const WidgetUpdateInfo &update)
+{
     LogInfo(
         "Widget install/update: incoming guid = '" <<
         update.incomingGUID << "'");
@@ -192,65 +433,56 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
         LogInfo("Widget info does not exist");
         updateTypeCheckBit = WidgetUpdateMode::NotInstalled;
     } else {
-        LogInfo("Widget info exists. Handle: " <<
-                update.existingWidgetInfo.existingHandle);
+        LogInfo("Widget info exists. PkgName: " <<
+                update.existingWidgetInfo.pkgname);
+
+        WidgetPkgName pkgname = update.existingWidgetInfo.pkgname;
 
-        DPL::OStringStream pkgName;
-        DPL::OptionalString pkgname =
-            WidgetDAOReadOnly(update.existingWidgetInfo.existingHandle).getPkgname();
+        LogInfo("Widget model exists. package name: " << pkgname);
 
-        if(pkgname.IsNull()) {
-            LogInfo("But widget package name doesn't exist");
+        // Check running state
+        int retval = APP_MANAGER_ERROR_NONE;
+        bool isRunning = false;
+        retval = app_manager_is_running(DPL::ToUTF8String(pkgname).c_str(), &isRunning);
+        if (APP_MANAGER_ERROR_NONE != retval) {
+            LogError("Fail to get running state");
             return ConfigureResult::Failed;
         }
 
-        LogInfo("Widget model exists. Package name: " << pkgName);
-        if (aul_app_is_running(DPL::ToUTF8String(*pkgname).c_str())) {
+        if (true == isRunning) {
             // Must be deferred when update in progress
             if (m_jobStruct.updateMode == WidgetUpdateMode::PolicyWac) {
                 LogInfo(
                     "Widget is already running. Policy is update according to WAC");
-                LogInfo("Installation deferred: " << widgetPath);
-
-                GlobalDAO::AddDefferedWidgetPackageInstallation(
-                    DPL::FromUTF8String(widgetPath));
 
                 return ConfigureResult::Deferred;
             } else {
                 LogInfo(
                     "Widget is already running. Policy is not update according to WAC");
-                LogInfo("Installation aborted: " << widgetPath);
 
                 return ConfigureResult::Failed;
             }
         }
 
+        m_installerContext.widgetConfig.pkgName = pkgname;
         OptionalWidgetVersion existingVersion;
         existingVersion = update.existingWidgetInfo.existingVersion;
         OptionalWidgetVersion incomingVersion = update.incomingVersion;
 
         updateTypeCheckBit = CalcWidgetUpdatePolicy(existingVersion,
                                                     incomingVersion);
+        // Calc proceed flag
+        if ((m_jobStruct.updateMode & updateTypeCheckBit) > 0 ||
+            m_jobStruct.updateMode ==
+                WidgetUpdateMode::PolicyDirectoryForceInstall)
+        {
+            LogInfo("Whether widget policy allow proceed ok");
+            return ConfigureResult::Updated;
+        }
+        else
+            return ConfigureResult::Failed;
     }
-
-    // Calc proceed flag
-    bool canProceed = (m_jobStruct.updateMode & updateTypeCheckBit) > 0;
-
-    LogInfo("Whether widget policy allow proceed: " << canProceed);
-
-    // Init installer context
-    m_installerContext.widgetFilePath = widgetPath;
-    m_installerContext.tempWidgetPath = std::string();
-    m_installerContext.widgetConfig = WidgetRegisterInfo();
-    m_installerContext.unzipStarted = false;
-    m_installerContext.unzipFinished = false;
-    m_installerContext.installStep = InstallerContext::INSTALL_START;
-    m_installerContext.job = this;
-    m_installerContext.existingWidgetInfo = update.existingWidgetInfo;
-    m_installerContext.widgetConfig.shareHref = std::string();
-
-    // Return result
-    return canProceed ? ConfigureResult::Ok : ConfigureResult::Failed;
+    return ConfigureResult::Ok;
 }
 
 WidgetUpdateMode::Type JobWidgetInstall::CalcWidgetUpdatePolicy(
@@ -286,100 +518,185 @@ WidgetUpdateMode::Type JobWidgetInstall::CalcWidgetUpdatePolicy(
     }
 }
 
-WidgetUpdateInfo JobWidgetInstall::detectWidgetUpdate(
-        const std::string &widgetPath)
+ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
+        const std::string &widgetSource,
+        const std::string &tempPath,
+        WrtDB::PackagingType pkgType,
+        bool isDRM)
 {
-    LogInfo("Checking up widget package for config.xml...");
+    // Parse config
+    ParserRunner parser;
+    ConfigParserData configInfo;
 
     Try
     {
-        // Open zip file
-        DPL::ScopedPtr<DPL::ZipInput> zipFile(
-            new DPL::ZipInput(widgetPath));
-
-        // Open config.xml file
-        DPL::ScopedPtr<DPL::ZipInput::File> configFile(
-            zipFile->OpenFile(CONFIG_XML));
-
-        // Extract config
-        DPL::BinaryQueue buffer;
-        DPL::AbstractWaitableInputAdapter inputAdapter(configFile.Get());
-        DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
-        DPL::Copy(&inputAdapter, &outputAdapter);
-
-        // Parse config
-        ParserRunner parser;
-        ConfigParserData configInfo;
-
-        parser.Parse(&buffer,
-                     ElementParserPtr(
-                         new RootParser<WidgetParser>(configInfo,
-                                                      DPL::FromUTF32String(
-                                                          L"widget"))));
-
-        // Check widget id
-        DPL::OptionalString widgetGUID = configInfo.widget_id;
-
-        if (widgetGUID.IsNull()) {
-            LogDebug("Installed widget has no GUID");
-            return WidgetUpdateInfo();
-        }
-
-        LogDebug("Installed widget GUID: " << *widgetGUID);
-
-        // Locate widget ID with this GUID
-        // Incoming widget version
-        OptionalWidgetVersion widgetVersion;
-        if (!configInfo.version.IsNull()) {
-            widgetVersion =
-                DPL::Optional<WidgetVersion>(
-                    WidgetVersion(*configInfo.version));
-        }
-
-        try
-        {
-            // Search widget handle by GUID
-            WidgetDAO dao(widgetGUID);
-            return WidgetUpdateInfo(
-                widgetGUID,
-                widgetVersion,
-                WidgetUpdateInfo::ExistingWidgetInfo(
-                    dao.getHandle(), dao.getVersion()));
-        }
-        Catch(WidgetDAO::Exception::WidgetNotExist){
-            // GUID isn't installed
-            return WidgetUpdateInfo(
-                widgetGUID,
-                widgetVersion,
-                WidgetUpdateInfo::ExistingWidgetInfo());
+        if (pkgType == PKG_TYPE_HOSTED_WEB_APP) {
+            parser.Parse(widgetSource,
+                    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"))));
+        } else {
+            if (!isDRM) {
+                std::unique_ptr<DPL::ZipInput> zipFile(
+                        new DPL::ZipInput(widgetSource));
+
+                std::unique_ptr<DPL::ZipInput::File> configFile;
+
+                // Open config.xml file
+                if (pkgType == PKG_TYPE_HYBRID_WEB_APP) {
+                    configFile.reset(zipFile->OpenFile(WITH_OSP_XML));
+                } else {
+                    configFile.reset(zipFile->OpenFile(CONFIG_XML));
+                }
+
+                // Extract config
+                DPL::BinaryQueue buffer;
+                DPL::AbstractWaitableInputAdapter inputAdapter(configFile.get());
+                DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
+                DPL::Copy(&inputAdapter, &outputAdapter);
+                parser.Parse(&buffer,
+                        ElementParserPtr(
+                            new RootParser<WidgetParser>(configInfo,
+                                DPL::FromUTF32String(
+                                    L"widget"))));
+            } else {
+                // DRM widget
+                std::string configFile;
+                if (pkgType == PKG_TYPE_HYBRID_WEB_APP) {
+                    configFile = tempPath + "/" + WITH_OSP_XML;
+                } else {
+                    configFile = tempPath + "/" + CONFIG_XML;
+                }
+
+                parser.Parse(configFile,
+                        ElementParserPtr(
+                            new RootParser<WidgetParser>(configInfo,
+                                DPL::FromUTF32String(
+                                    L"widget"))));
+            }
         }
     }
     Catch(DPL::ZipInput::Exception::OpenFailed)
     {
-        LogDebug("Failed to open widget package");
-        return WidgetUpdateInfo();
+        LogError("Failed to open widget package");
+        return ConfigParserData();
     }
     Catch(DPL::ZipInput::Exception::OpenFileFailed)
     {
-        LogDebug("Failed to open config.xml file");
-        return WidgetUpdateInfo();
+        LogError("Failed to open config.xml file");
+        return ConfigParserData();
     }
     Catch(DPL::CopyFailed)
     {
-        LogDebug("Failed to extract config.xml file");
-        return WidgetUpdateInfo();
+        LogError("Failed to extract config.xml file");
+        return ConfigParserData();
+    }
+    Catch(DPL::FileInput::Exception::OpenFailed)
+    {
+        LogError("Failed to open config.xml file");
+        return ConfigParserData();
     }
     Catch(ElementParser::Exception::ParseError)
     {
-        LogDebug("Failed to parse config.xml file");
+        LogError("Failed to parse config.xml file");
+        return ConfigParserData();
+    }
+    Catch(DPL::ZipInput::Exception::SeekFileFailed)
+    {
+        LogError("Failed to seek widget archive - corrupted package?");
+        return ConfigParserData();
+    }
+    return configInfo;
+}
+
+WidgetUpdateInfo JobWidgetInstall::detectWidgetUpdate(
+        const ConfigParserData &configInfo,
+        const WrtDB::WidgetType appType,
+        const WrtDB::WidgetPkgName &tizenId)
+{
+    LogInfo("Checking up widget package for config.xml...");
+
+    DPL::OptionalString widgetGUID;
+    OptionalWidgetVersion widgetVersion;
+
+    // Check widget id
+    widgetGUID = configInfo.widget_id;
+
+    if (widgetGUID.IsNull()) {
+        LogWarning("Installed widget has no GUID");
         return WidgetUpdateInfo();
     }
+
+    LogDebug("Installed widget GUID: " << *widgetGUID);
+
+    // Locate widget ID with this GUID
+    // Incoming widget version
+    if (!configInfo.version.IsNull()) {
+        widgetVersion =
+            DPL::Optional<WidgetVersion>(
+                WidgetVersion(*configInfo.version));
+    }
+
+    if (appType == APP_TYPE_WAC20) {
+        Try
+        {
+            // Search widget handle by GUID
+            WidgetDAOReadOnly dao(widgetGUID);
+            return WidgetUpdateInfo(
+                    widgetGUID,
+                    widgetVersion,
+                    WidgetUpdateInfo::ExistingWidgetInfo(
+                        dao.getPkgName(), dao.getVersion()));
+        }
+        Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
+        {
+            // GUID isn't installed
+            return WidgetUpdateInfo(
+                    widgetGUID,
+                    widgetVersion,
+                    WidgetUpdateInfo::ExistingWidgetInfo());
+        }
+    } else {
+        Try
+        {
+            // Search widget handle by appId
+            WidgetDAOReadOnly dao(tizenId);
+            return WidgetUpdateInfo(
+                    widgetGUID,
+                    widgetVersion,
+                    WidgetUpdateInfo::ExistingWidgetInfo(
+                        dao.getPkgName(), dao.getVersion()));
+        }
+        Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
+        {
+            // GUID isn't installed
+            return WidgetUpdateInfo(
+                    widgetGUID,
+                    widgetVersion,
+                    WidgetUpdateInfo::ExistingWidgetInfo());
+        }
+
+    }
 }
 
 void JobWidgetInstall::SendProgress()
 {
+    using namespace PackageManager;
     if (GetProgressFlag() != false) {
         if (getInstallerStruct().progressCallback != NULL) {
+            // send progress signal of pkgmgr
+            std::ostringstream percent;
+            percent << static_cast<int>(GetProgressPercent());
+            getInstallerStruct().pkgmgrInterface->sendSignal(
+                        PKGMGR_PROGRESS_KEY,
+                        percent.str());
 
             LogDebug("Call widget install progressCallbak");
             getInstallerStruct().progressCallback(getInstallerStruct().userParam,
@@ -390,27 +707,57 @@ void JobWidgetInstall::SendProgress()
 
 void JobWidgetInstall::SendFinishedSuccess()
 {
+    using namespace PackageManager;
+    // TODO : sync should move to separate task.
+    sync();
+
+
+    if (INSTALL_LOCATION_TYPE_EXTERNAL == m_installerContext.locationType) {
+        if (false == m_installerContext.existingWidgetInfo.isExist) {
+            WidgetInstallToExtSingleton::Instance().postInstallation(true);
+        } else {
+            WidgetInstallToExtSingleton::Instance().postUpgrade(true);
+        }
+        WidgetInstallToExtSingleton::Instance().deinitialize();
+    }
+
+    // remove widget install information file
+    unlink(m_installerContext.installInfo.c_str());
+
     //inform widget info
     JobWidgetInstall::displayWidgetInfo();
 
-    DPL::Optional<WidgetHandle> handle = getNewWidgetHandle();
-    const WidgetHandle INVALID_WIDGET_HANDLE = 0;
+    WidgetPkgName& tizenId = m_installerContext.widgetConfig.pkgName;
+
+    // send signal of pkgmgr
+    getInstallerStruct().pkgmgrInterface->sendSignal(
+                PKGMGR_END_KEY,
+                PKGMGR_END_SUCCESS);
 
     LogDebug("Call widget install successfinishedCallback");
     getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
-            !!handle ? *handle : INVALID_WIDGET_HANDLE, Exceptions::Success);
+            DPL::ToUTF8String(tizenId), Exceptions::Success);
 }
 
 void JobWidgetInstall::SendFinishedFailure()
 {
+    using namespace PackageManager;
+    // remove widget install information file
+    unlink(m_installerContext.installInfo.c_str());
+
     LogError("Error in installation step: " << m_exceptionCaught);
     LogError("Message: " << m_exceptionMessage);
-    DPL::Optional<WidgetHandle> handle = getNewWidgetHandle();
-    const WidgetHandle INVALID_WIDGET_HANDLE = 0;
+    WidgetPkgName & tizenId = m_installerContext.widgetConfig.pkgName;
 
     LogDebug("Call widget install failure finishedCallback");
+
+    // send signal of pkgmgr
+    getInstallerStruct().pkgmgrInterface->sendSignal(
+                PKGMGR_END_KEY,
+                PKGMGR_END_FAILURE);
+
     getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
-            !!handle ? *handle : INVALID_WIDGET_HANDLE, m_exceptionCaught);
+            DPL::ToUTF8String(tizenId), m_exceptionCaught);
 }
 
 void JobWidgetInstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
@@ -421,24 +768,22 @@ void JobWidgetInstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
 
 void JobWidgetInstall::displayWidgetInfo()
 {
-    DPL::Optional<WidgetHandle> handle = getNewWidgetHandle();
-    Assert(!!handle);
-
-    WidgetDAO dao(*handle);
+    WidgetDAOReadOnly dao(m_installerContext.locations->getPkgname());
 
     std::ostringstream out;
     WidgetLocalizedInfo localizedInfo =
-        W3CFileLocalization::getLocalizedInfo(*handle);
+        W3CFileLocalization::getLocalizedInfo(dao.getPkgName());
 
     out << std::endl <<
         "===================================== INSTALLED WIDGET INFO ========="\
         "============================";
     out << std::endl << "Name:                        " << localizedInfo.name;
+    out << std::endl << "PkgName:                     " << dao.getPkgName();
     WidgetSize size = dao.getPreferredSize();
     out << std::endl << "Width:                       " << size.width;
     out << std::endl << "Height:                      " << size.height;
     out << std::endl << "Start File:                  " <<
-        W3CFileLocalization::getStartFile(*handle);
+        W3CFileLocalization::getStartFile(dao.getPkgName());
     out << std::endl << "Version:                     " << dao.getVersion();
     out << std::endl << "Licence:                     " <<
         localizedInfo.license;
@@ -453,9 +798,8 @@ void JobWidgetInstall::displayWidgetInfo()
         dao.isDistributorSigned();
     out << std::endl << "Widget trusted:              " << dao.isTrusted();
 
-    OptionalWidgetIcon icon = W3CFileLocalization::getIcon(*handle);
-    DPL::OptionalString iconSrc =
-        !!icon ? icon->src : DPL::OptionalString::Null;
+    OptionalWidgetIcon icon = W3CFileLocalization::getIcon(dao.getPkgName());
+    DPL::OptionalString iconSrc = !!icon ? icon->src : DPL::OptionalString::Null;
     out << std::endl << "Icon:                        " << iconSrc;
 
     out << std::endl << "Preferences:";
@@ -481,12 +825,212 @@ void JobWidgetInstall::displayWidgetInfo()
         }
     }
 
-    out << std::endl << "Back Supported:              " <<
-        (dao.getBackSupported() ? "YES" : "NO");
-
     out << std::endl;
 
     LogInfo(out.str());
 }
+
+WrtDB::PackagingType JobWidgetInstall::checkPackageType(
+        const std::string &widgetSource,
+        const std::string &tempPath)
+{
+    // Check installation type (direcotory/ or config.xml or widget.wgt)
+    if (WidgetUpdateMode::PolicyDirectoryForceInstall == m_jobStruct.updateMode)
+    {
+        LogDebug("Install directly from directory");
+        return PKG_TYPE_DIRECTORY_WEB_APP;
+    }
+    if (hasExtension(widgetSource, XML_EXTENSION)) {
+        LogInfo("Hosted app installation");
+        return PKG_TYPE_HOSTED_WEB_APP;
+    }
+
+    if (m_isDRM) {
+        std::string configFile = tempPath + "/" + CONFIG_XML;
+        if (WrtUtilFileExists(configFile)) {
+            return PKG_TYPE_NOMAL_WEB_APP;
+        }
+
+        configFile = tempPath + "/" + WITH_OSP_XML;
+        if (WrtUtilFileExists(configFile)) {
+            return PKG_TYPE_HYBRID_WEB_APP;
+        }
+    } else {
+        std::unique_ptr<DPL::ZipInput> zipFile;
+
+        Try
+        {
+            // Open zip file
+            zipFile.reset(new DPL::ZipInput(widgetSource));
+
+        }
+        Catch(DPL::ZipInput::Exception::OpenFailed)
+        {
+            LogDebug("Failed to open widget package");
+            return PKG_TYPE_UNKNOWN;
+        }
+        Catch(DPL::ZipInput::Exception::SeekFileFailed)
+        {
+            LogError("Failed to seek widget package file");
+            return PKG_TYPE_UNKNOWN;
+        }
+
+        Try
+        {
+            // Open config.xml file in package root
+            std::unique_ptr<DPL::ZipInput::File> configFile(
+                    zipFile->OpenFile(CONFIG_XML));
+            return PKG_TYPE_NOMAL_WEB_APP;
+        }
+        Catch(DPL::ZipInput::Exception::OpenFileFailed)
+        {
+            LogDebug("Could not find config.xml");
+        }
+
+        Try
+        {
+            // Open config.xml file in package root
+            std::unique_ptr<DPL::ZipInput::File> configFile(
+                    zipFile->OpenFile(WITH_OSP_XML));
+
+            return PKG_TYPE_HYBRID_WEB_APP;
+        }
+        Catch(DPL::ZipInput::Exception::OpenFileFailed)
+        {
+            LogDebug("Could not find wgt/config.xml");
+            return PKG_TYPE_UNKNOWN;
+        }
+    }
+
+    return PKG_TYPE_UNKNOWN;
+}
+
+void JobWidgetInstall::setApplicationType(
+        const WrtDB::ConfigParserData &configInfo)
+{
+
+    FOREACH(iterator, configInfo.nameSpaces) {
+        LogInfo("namespace = [" << *iterator << "]");
+        AppType currentAppType = APP_TYPE_UNKNOWN;
+
+        if (*iterator == ConfigurationNamespace::W3CWidgetNamespaceName) {
+            continue;
+        } else if (
+            *iterator ==
+            ConfigurationNamespace::WacWidgetNamespaceNameForLinkElement ||
+            *iterator ==
+            ConfigurationNamespace::WacWidgetNamespaceName)
+        {
+            currentAppType = APP_TYPE_WAC20;
+        } else if (*iterator ==
+                ConfigurationNamespace::TizenWebAppNamespaceName) {
+            currentAppType = APP_TYPE_TIZENWEBAPP;
+        }
+
+        if (m_installerContext.widgetConfig.webAppType ==
+                APP_TYPE_UNKNOWN) {
+            m_installerContext.widgetConfig.webAppType = currentAppType;
+        } else if (m_installerContext.widgetConfig.webAppType ==
+                currentAppType) {
+            continue;
+        } else {
+            ThrowMsg(Exceptions::WidgetConfigFileInvalid,
+                     "Config.xml has more than one namespace");
+        }
+    }
+
+    // If there is no define, type set to WAC 2.0
+    if (m_installerContext.widgetConfig.webAppType == APP_TYPE_UNKNOWN) {
+        m_installerContext.widgetConfig.webAppType = APP_TYPE_WAC20;
+    }
+
+    LogInfo("type = [" <<
+            m_installerContext.widgetConfig.webAppType.getApptypeToString() << "]");
+}
+
+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) {
+            LogDebug("resource need encryption");
+            return true;
+        }
+    }
+    return false;
+}
+
+void JobWidgetInstall::setInstallLocationType(const
+        WrtDB::ConfigParserData &configData)
+{
+    m_installerContext.locationType = INSTALL_LOCATION_TYPE_NOMAL;
+
+    if (true == m_jobStruct.m_preload) {
+        m_installerContext.locationType =
+            INSTALL_LOCATION_TYPE_PRELOAD;
+    } else {
+        FOREACH(it, configData.settingsList)
+        {
+            if (it->m_name == SETTING_VALUE_INSTALLTOEXT_NAME &&
+                    it->m_value ==
+                    SETTING_VALUE_INSTALLTOEXT_PREPER_EXT) {
+                LogDebug("This widget will be installed to sd card");
+                m_installerContext.locationType =
+                    INSTALL_LOCATION_TYPE_EXTERNAL;
+            }
+        }
+    }
+}
+
+bool JobWidgetInstall::isDRMWidget(std::string widgetPath)
+{
+    /* TODO :
+    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) {
+        return true;
+    } else {
+        return false;
+    }
+}
+
+bool JobWidgetInstall::DecryptDRMWidget(std::string widgetPath,
+        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;
+    }
+    */
+    if (drm_oem_intel_decrypt_package(const_cast<char*>(widgetPath.c_str()),
+                const_cast<char*>(destPath.c_str())) != 0) {
+        return true;
+    } else {
+        return false;
+    }
+}
+
 } //namespace WidgetInstall
 } //namespace Jobs
index 8822978..6066c26 100644 (file)
@@ -30,6 +30,7 @@
 #include <dpl/utils/widget_version.h>
 #include <widget_install/widget_install_context.h>
 #include <widget_install/widget_update_info.h>
+#include <dpl/wrt-dao-ro/config_parser_data.h>
 #include "widget_installer_struct.h"
 
 namespace Jobs {
@@ -41,26 +42,52 @@ class JobWidgetInstall :
     public JobContextBase<WidgetInstallationStruct>   //TODO typedef
 {
   private:
-    typedef DPL::Optional<WidgetHandle> OptionalWidgetHandle;
-
     InstallerContext m_installerContext;
 
-    //TODO move it to base class of all jobs
+    //TODO move it to base class of all jobs -> make it base template class??
     Exceptions::Type m_exceptionCaught;
     std::string m_exceptionMessage;
     WidgetUpdateInfo m_widgetUpdateInfo;
+    bool    m_needEncryption;
+    bool    m_isDRM;
 
     enum class ConfigureResult
     {
-        Ok, Failed, Deferred
+        Ok, Failed, Deferred, Updated
     };
 
-    ConfigureResult ConfigureInstallation(const std::string &widgetPath);
-    WidgetUpdateInfo detectWidgetUpdate(const std::string &widgetPath);
+    ConfigureResult ConfigureInstallation(const std::string &widgetSource,
+                                          const WrtDB::ConfigParserData
+                                          &configData,
+                                          const std::string &tempPath);
+    static WrtDB::ConfigParserData getWidgetDataFromXML(
+            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);
     WidgetUpdateMode::Type CalcWidgetUpdatePolicy(
             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);
+    bool detectResourceEncryption(const WrtDB::ConfigParserData &configData);
+    void setInstallLocationType(const WrtDB::ConfigParserData
+            &configData);
+    bool isDRMWidget(std::string widgetPath);
+    bool DecryptDRMWidget(std::string widgetPath, std::string destPath);
+    ConfigureResult PrePareInstallation(const std::string &widgetPath);
+    ConfigureResult checkWidgetUpdate(const WidgetUpdateInfo &update);
+    void setApplicationType(const WrtDB::ConfigParserData &configInfo);
 
   public:
     /**
@@ -69,10 +96,6 @@ class JobWidgetInstall :
     JobWidgetInstall(std::string const & widgetPath,
             const WidgetInstallationStruct &installerStruct);
 
-    DPL::Optional<WidgetHandle> getNewWidgetHandle() const;
-    bool getUnzipStartedFlag() const;
-    bool getUnzipFinishedFlag() const;
-
     //overrides
     void SendProgress();
     void SendFinishedSuccess();
diff --git a/src/jobs/widget_install/manifest.cpp b/src/jobs/widget_install/manifest.cpp
new file mode 100755 (executable)
index 0000000..98adb96
--- /dev/null
@@ -0,0 +1,385 @@
+/*
+ * 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    manifest.cpp
+ * @author  Mariusz Domanski (m.domanski@samsung.com)
+ */
+
+#include "manifest.h"
+#include "libxml_utils.h"
+#include <widget_install/task_manifest_file.h>
+#include <dpl/foreach.h>
+
+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)
+    {
+        ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteElement failed");
+    }
+}
+
+void writeText(xmlTextWriterPtr writer, DPL::String text)
+{
+    int state = xmlTextWriterWriteString(writer,
+            BAD_CAST DPL::ToUTF8String(text).c_str());
+    if (state < 0)
+    {
+        ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteText failed");
+    }
+}
+
+void writeElement(xmlTextWriterPtr writer, const char * name, const char * body)
+{
+    int state = xmlTextWriterWriteElement(writer, BAD_CAST name, BAD_CAST body);
+    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)
+{
+    startElement(writer, name);
+    writeAttribute(writer, nameAttr, bodyAttr, condition);
+    writeText(writer, body);
+    endElement(writer);
+}
+
+void startElement(xmlTextWriterPtr writer, const char * name)
+{
+    int state = xmlTextWriterStartElement(writer, BAD_CAST name);
+    if (state < 0)
+    {
+        ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterStartElement failed");
+    }
+}
+
+void endElement(xmlTextWriterPtr writer)
+{
+    int state = xmlTextWriterEndElement(writer);
+    if (state < 0)
+    {
+        ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterEndElement failed");
+    }
+}
+
+void writeAttribute(xmlTextWriterPtr writer, const char * name, DPL::String body,
+        bool condition = true)
+{
+    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");
+    }
+}
+
+void writeAttribute(xmlTextWriterPtr writer, const char * name, const char * body,
+        bool condition = true)
+{
+    if (!condition)
+        return;
+    int state = xmlTextWriterWriteAttribute(writer, BAD_CAST name, BAD_CAST body);
+    if (state < 0)
+    {
+        ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterWriteAttribute failed");
+    }
+}
+
+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)
+        ThrowMsg(LibxmlUtils::Libxml2Error, "xmlNewTextWriterFilename failed");
+    state = xmlTextWriterSetIndent (writer, 1);
+    if (state < 0)
+    {
+        ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterSetIndent failed");
+    }
+
+    state = xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL);
+    if (state < 0)
+    {
+        ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterStartDocument failed");
+    }
+    this->serialize(writer);
+    state = xmlTextWriterEndDocument(writer);
+    if (state < 0)
+    {
+        ThrowMsg(LibxmlUtils::Libxml2Error, "xmlTextWriterEndDocument failed");
+    }
+    if (writer != NULL)
+    {
+        xmlFreeTextWriter(writer);
+        writer = NULL;
+    }
+}
+
+void Manifest::serialize(xmlTextWriterPtr writer)
+{
+    startElement(writer, "manifest");
+    {
+        writeAttribute(writer, "xmlns", "http://tizen.org/ns/packages");
+        writeAttribute(writer, "package", this->package);
+        writeAttribute(writer, "type", this->type);
+        writeAttribute(writer, "version", this->version);
+        if (!this->installLocation.IsNull())
+            writeAttribute(writer, "install-location", (*this->installLocation),
+                    (*this->installLocation).empty());
+
+        FOREACH(l, this->label)
+        {
+            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());
+        }
+        FOREACH(a, this->author)
+        {
+            a->serialize(writer);
+        }
+        FOREACH(d, this->description)
+        {
+            writeElementWithOneAttribute(writer, "description", d->getString(),
+                    "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(f, this->font) { f->serialize(writer); }
+        FOREACH(l, this->livebox) { l->serialize(writer); }
+    }
+    endElement(writer);
+}
+
+void Author::serialize(xmlTextWriterPtr writer)
+{
+    startElement(writer, "author");
+    writeAttribute(writer, "email", this->email, !this->email.empty());
+    writeAttribute(writer, "href", this->href, !this->href.empty());
+    writeAttribute(writer, "xml:lang", this->lang, !this->lang.empty());
+    writeText(writer, body);
+    endElement(writer);
+}
+
+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, "exec", this->exec);
+    writeAttribute(writer, "on-boot", (!this->onBoot.IsNull() &&
+            (*this->onBoot)) ? "true" : "false");
+    writeAttribute(writer, "type", this->type);
+    FOREACH(l, this->label)
+    {
+        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());
+    }
+    FOREACH(a, this->appControl)
+    {
+        a->serialize(writer);
+    }
+    endElement(writer);
+}
+
+void UiApplication::serialize(xmlTextWriterPtr writer)
+{
+    startElement(writer, "ui-application");
+    writeAttribute(writer, "appid", this->appid);
+    writeAttribute(writer, "exec", this->exec);
+    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");
+    writeAttribute(writer, "type", this->type);
+    writeAttribute(writer, "extraid", this->extraid);
+    if (!this->categories.IsNull())
+        writeAttribute(writer, "categories", (*this->categories));
+    FOREACH(l, this->label)
+    {
+        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());
+    }
+    FOREACH(a, this->appControl)
+    {
+        a->serialize(writer);
+    }
+    FOREACH(c, this->appCategory)
+    {
+        startElement(writer, "category");
+        writeAttribute(writer, "name", *c);
+        endElement(writer);
+    }
+    endElement(writer);
+}
+
+void ImeApplication::serialize(xmlTextWriterPtr writer)
+{
+    startElement(writer, "ime-application");
+    writeAttribute(writer, "appid", this->appid);
+    writeAttribute(writer, "exec", this->exec);
+    if (!this->multiple.IsNull())
+        writeAttribute(writer, "multiple", (*this->multiple) ? "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());
+    }
+    FOREACH(i, this->icon)
+    {
+        writeElementWithOneAttribute(writer, "icon", i->getString(), "xml:lang",
+                i->getLang(), i->hasLang());
+    }
+    endElement(writer);
+}
+
+void AppControl::serialize(xmlTextWriterPtr writer)
+{
+    startElement(writer, "app-control");
+    FOREACH(o, this->operation)
+    {
+        startElement(writer, "operation");
+        writeAttribute(writer, "name", *o);
+        endElement(writer);
+    }
+    FOREACH(u, this->uri)
+    {
+        startElement(writer, "uri");
+        writeAttribute(writer, "name", *u);
+        endElement(writer);
+    }
+    FOREACH(m, this->mime)
+    {
+        startElement(writer, "mime");
+        writeAttribute(writer, "name", *m);
+        endElement(writer);
+    }
+    endElement(writer);
+}
+
+void LiveBox::serialize(xmlTextWriterPtr writer)
+{
+    startElement(writer, "livebox");
+    if(!this->liveboxId.empty()) {
+        writeAttribute(writer, "appid", this->liveboxId);
+    }
+
+    if(!this->primary.empty()) {
+        writeAttribute(writer, "primary", this->primary);
+    }
+
+    if(!this->updatePeriod.empty()) {
+        writeAttribute(writer, "period", this->updatePeriod);
+    }
+
+    writeAttribute(writer, "abi", "html");
+    writeAttribute(writer, "network", "true");
+    writeAttribute(writer, "nodisplay", "false");
+
+    if(!this->label.empty()) {
+        startElement(writer, "label");
+        writeText(writer, this->label);
+        endElement(writer);
+    }
+
+    if(!this->icon.empty()) {
+        startElement(writer, "icon");
+        writeText(writer, this->icon);
+        endElement(writer);
+    }
+
+    if(!this->autoLaunch.empty()) {
+        startElement(writer, "launch");
+        writeText(writer, this->autoLaunch);
+        endElement(writer);
+    }
+
+    if(!this->box.boxSrc.empty() && !this->box.boxSize.empty())
+    {
+        startElement(writer, "box");
+        writeAttribute(writer, "type", "buffer");
+
+        FOREACH(m, this->box.boxSize)
+        {
+            std::pair<DPL::String, DPL::String> boxSize = *m;
+            startElement(writer, "size");
+            if(!boxSize.second.empty())
+                writeAttribute(writer, "preview", boxSize.second);
+            writeText(writer, boxSize.first);
+            endElement(writer);
+        }
+
+        startElement(writer, "script");
+        writeAttribute(writer, "src", this->box.boxSrc);
+        endElement(writer);
+
+        endElement(writer);
+
+        if(!this->box.pdSrc.empty() && ! this->box.pdWidth.empty() && ! this->box.pdHeight.empty()) {
+            startElement(writer, "pd");
+            writeAttribute(writer, "type", "buffer");
+
+            startElement(writer, "size");
+            DPL::String pdSize = this->box.pdWidth+DPL::String(L"x")+this->box.pdHeight;
+            writeText(writer, pdSize);
+            endElement(writer);
+
+            startElement(writer, "script");
+            writeAttribute(writer, "src", this->box.pdSrc);
+            endElement(writer);
+
+            endElement(writer);
+        }
+    }
+
+    endElement(writer);
+}
+
+} //namespace Jobs
+} //namespace WidgetInstall
diff --git a/src/jobs/widget_install/manifest.h b/src/jobs/widget_install/manifest.h
new file mode 100755 (executable)
index 0000000..ac469d2
--- /dev/null
@@ -0,0 +1,342 @@
+/*
+ * 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    manifest.h
+ * @author  Mariusz Domanski (m.domanski@samsung.com)
+ */
+
+#ifndef INSTALLER_JOBS_MANIFEST_H
+#define INSTALLER_JOBS_MANIFEST_H
+
+#include <list>
+
+#include <libxml/encoding.h>
+#include <libxml/xmlwriter.h>
+
+#include <dpl/string.h>
+#include <dpl/optional_typedefs.h>
+#include <dpl/foreach.h>
+
+namespace Jobs {
+namespace WidgetInstall {
+
+/**
+ * @brief string with optional language attribute
+ */
+class StringWithLang
+{
+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:
+    DPL::String string;
+    DPL::String lang;
+};
+
+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
+ * errors (related to usage of not allowed characters in given places).
+ */
+typedef DPL::String NcnameType, NmtokenType, AnySimpleType, LangType;
+typedef DPL::String OperationType, MimeType, UriType, TypeType, PackageType;
+typedef DPL::OptionalString InstallLocationType, CategoriesType;
+typedef DPL::String AppCategoryType;
+
+/**
+ * xmllib2 wrappers
+ */
+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 startElement(xmlTextWriterPtr writer, const char * name);
+void endElement(xmlTextWriterPtr writer);
+void writeAttribute(xmlTextWriterPtr writer, const char * name,
+        DPL::String body, bool condition);
+void writeAttribute(xmlTextWriterPtr writer, const char * name,
+        const char * body, bool condition);
+
+/**
+ * @brief author element
+ */
+class Author
+{
+public:
+    Author() {}
+    Author(AnySimpleType e,
+            NcnameType h,
+            LangType l,
+            DPL::String b)
+        : email(e), href(h), lang(l), body(b) {}
+    void serialize(xmlTextWriterPtr writer);
+private:
+    AnySimpleType email;
+    NcnameType href;
+    LangType lang;
+    DPL::String body;
+};
+
+typedef Author AuthorType;
+
+/**
+ * @brief application-service element
+ */
+class AppControl
+{
+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 serialize(xmlTextWriterPtr writer);
+private:
+    std::list<OperationType> operation; //attr name AnySimpleType
+    std::list<UriType> uri; //attr name AnySimpleType
+    std::list<MimeType> mime; //attr name AnySimpleType
+};
+
+typedef AppControl AppControlType;
+
+/**
+ * @brief ime-application element
+ */
+class ImeApplication
+{
+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 serialize(xmlTextWriterPtr writer);
+private:
+    NcnameType appid;
+    NcnameType exec;
+    DPL::OptionalBool multiple;
+    DPL::OptionalBool nodisplay;
+    TypeType type;
+    std::list<LabelType> label;
+    std::list<IconType> icon;
+};
+
+typedef ImeApplication ImeApplicationType;
+
+/**
+ * @brief service-application element
+ */
+class ServiceApplication
+{
+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 addAppControl(const AppControlType &x)
+    {
+        this->appControl.push_back(x);
+    }
+    void serialize(xmlTextWriterPtr writer);
+private:
+    NcnameType appid;
+    DPL::OptionalBool autoRestart;
+    AnySimpleType exec;
+    DPL::OptionalBool onBoot;
+    TypeType type;
+    std::list<LabelType> label; //attr name AnySimpleType
+    std::list<IconType> icon; //attr name AnySimpleType
+    std::list<AppControlType> appControl; //attr name AnySimpleType
+};
+
+typedef ServiceApplication ServiceApplicationType;
+
+/**
+ * @brief ui-application element
+ */
+class UiApplication
+{
+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 addAppControl(const AppControlType &x)
+    {
+        this->appControl.push_back(x);
+    }
+    void addAppCategory(const AppCategoryType &x)
+    {
+        this->appCategory.push_back(x);
+    }
+    void serialize(xmlTextWriterPtr writer);
+private:
+    NcnameType appid;
+    NcnameType extraid;
+    AnySimpleType exec;
+    DPL::OptionalBool multiple;
+    DPL::OptionalBool nodisplay;
+    DPL::OptionalBool taskmanage;
+    TypeType type;
+    CategoriesType categories;
+    std::list<LabelType> label;
+    std::list<IconType> icon;
+    std::list<AppControlType> appControl;
+    std::list<AppCategoryType> appCategory;
+};
+
+typedef UiApplication UiApplicationType;
+
+/**
+ * @brief LiveBox element
+ */
+typedef std::list<std::pair<DPL::String, DPL::String>> boxSizeType;
+
+
+struct BoxInfo
+{
+    NcnameType boxSrc;
+    boxSizeType boxSize;
+    NcnameType pdSrc;
+    NcnameType pdWidth;
+    NcnameType pdHeight;
+};
+typedef BoxInfo BoxInfoType;
+
+class LiveBox
+{
+public:
+    LiveBox() { }
+    void setLiveboxId(const NcnameType &x) { this->liveboxId = x; }
+    void setPrimary(const NcnameType &x) { this->primary = x; }
+    void setAutoLaunch(const NcnameType &x) { this->autoLaunch = x; }
+    void setUpdatePeriod(const NcnameType &x) { this->updatePeriod = x; }
+    void setLabel(const NcnameType &x) { this->label = x; }
+    void setIcon(const NcnameType &x) { this->icon = x; }
+    void setBox(const BoxInfoType &x) { this->box = x; }
+
+    void serialize(xmlTextWriterPtr writer);
+
+private:
+    NcnameType liveboxId;
+    NcnameType primary;
+    NcnameType autoLaunch;
+    NcnameType updatePeriod;
+    NcnameType timeout;
+    NcnameType label;
+    NcnameType icon;
+    BoxInfoType box;
+};
+
+typedef LiveBox LiveBoxInfo;
+
+/**
+ * @brief manifest element
+ *
+ * Manifest xml file representation.
+ */
+class Manifest
+{
+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 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 addServiceApplication(const ServiceApplicationType &x)
+    {
+        this->serviceApplication.push_back(x);
+    }
+    void addUiApplication(const UiApplicationType &x)
+    {
+        this->uiApplication.push_back(x);
+    }
+    void addImeApplication(const ImeApplicationType &x)
+    {
+        this->imeApplication.push_back(x);
+    }
+//    void addFont(const FontType &x) { this->font.push_back(x); }
+
+    void addLivebox(const LiveBoxInfo &x)
+    {
+        this->livebox.push_back(x);
+    }
+
+    void setInstallLocation(const InstallLocationType &x)
+    {
+        this->installLocation = x;
+    }
+    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<ServiceApplicationType> serviceApplication;
+    std::list<UiApplicationType> uiApplication;
+    std::list<ImeApplicationType> imeApplication;
+//    std::list<FontType> font;
+    std::list<LiveBoxInfo> livebox;
+    InstallLocationType installLocation;
+    NcnameType package;
+    PackageType type;
+    NmtokenType version;
+};
+
+} //namespace Jobs
+} //namespace WidgetInstall
+
+#endif //INSTALLER_JOBS_MANIFEST_H
index ed87a98..7436f4b 100644 (file)
  * @brief   Implementation file for installer task ace check
  */
 
+#include <utility>
+#include <vector>
+#include <string>
+
 #include <widget_install/task_ace_check.h>
 #include <dpl/assert.h>
+#include <dpl/log/log.h>
+#include <dpl/foreach.h>
 
 #include <widget_install/widget_install_context.h>
 #include <widget_install/widget_install_errors.h>
 #include <widget_install/job_widget_install.h>
-#include <security_controller.h>
 
-#include <dpl/ace/PolicyResult.h>
-#include <dpl/ace/Request.h>
+#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <ace_api_install.h>
 
 namespace Jobs {
 namespace WidgetInstall {
+
 TaskAceCheck::TaskAceCheck(InstallerContext& context) :
     DPL::TaskDecl<TaskAceCheck>(this),
     m_context(context)
@@ -45,14 +51,16 @@ TaskAceCheck::TaskAceCheck(InstallerContext& context) :
 
 void TaskAceCheck::StepPrepareForAce()
 {
-    Assert(!!m_context.widgetHandle);
     m_context.featureLogic =
-        FeatureLogicPtr(new FeatureLogic(*m_context.widgetHandle));
+        FeatureLogicPtr(new FeatureLogic(m_context.locations->getPkgname()));
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_ACE_PREPARE,
+        "Widget Access Control Check Prepared");
 }
 
 void TaskAceCheck::StepAceCheck()
 {
-
+    WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
     LogInfo("StepAceCheck!");
     // This widget does not use any device cap
     if (m_context.featureLogic->isDone()) {
@@ -63,30 +71,97 @@ void TaskAceCheck::StepAceCheck()
     DPL::String deviceCap = m_context.featureLogic->getDevice();
 
     LogInfo("StepAceCheck!");
+    LogInfo("DevCap is : " << deviceCap);
+
+    std::string devCapStr = DPL::ToUTF8String(deviceCap);
+    ace_policy_result_t policyResult = ACE_DENY;
+    ace_return_t ret = ace_get_policy_result(
+            const_cast<const ace_resource_t>(devCapStr.c_str()),
+            dao.getHandle(),                         //TODO: remove dao.getHandle()
+            &policyResult);
+    if (ACE_OK != ret) {
+        ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
+                 "ACE check failure");
+    }
 
-    Assert(!!m_context.widgetHandle);
-    Request *request = new Request(*m_context.widgetHandle,
-                                   WidgetExecutionPhase_WidgetInstall);
-    request->addDeviceCapability(DPL::ToUTF8String(deviceCap));
-
-    CONTROLLER_POST_EVENT(
-        SecurityController,
-        SecurityControllerEvents::AuthorizeWidgetInstallEvent(
-            request,
-            makeICDelegate(&TaskAceCheck::ProcessAceResponse)));
+    LogInfo("PolicyResult is : " << static_cast<int>(policyResult));
+    m_context.staticPermittedDevCaps.insert(std::make_pair(deviceCap,
+            policyResult == ACE_PERMIT));
 
-    // PorcessAceResponse will Resume me.
-    m_context.job->Pause();
+    m_context.featureLogic->setAceResponse(policyResult != ACE_DENY);
 }
 
 void TaskAceCheck::StepProcessAceResponse()
 {
+    WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
+    if (m_context.widgetConfig.packagingType ==
+            WrtDB::PKG_TYPE_HOSTED_WEB_APP) {
+        return;
+    }
+
     LogInfo("StepProcessAceResponse");
     m_context.featureLogic->next();
 
     // No device caps left to process
     if (m_context.featureLogic->isDone()) {
         LogInfo("All responses has been received from ACE.");
+        // Data to convert to C API
+        std::vector<std::string> devCaps;
+        std::vector<bool> devCapsSmack;
+        // Saving static dev cap permissions
+        FOREACH (cap, m_context.staticPermittedDevCaps) {
+            LogInfo("staticPermittedDevCaps : " << cap->first
+                    << " smack: " << cap->second);
+            std::string devCapStr = DPL::ToUTF8String(cap->first);
+            devCaps.push_back(devCapStr);
+            devCapsSmack.push_back(cap->second);
+        }
+        ace_requested_dev_cap_list_t list;
+        list.count = devCaps.size();
+        list.items = new ace_requested_dev_cap_t[list.count];
+
+        for (unsigned int i = 0; i < devCaps.size(); ++i) {
+            list.items[i].device_capability =
+                    const_cast<const ace_resource_t>(devCaps[i].c_str());
+            list.items[i].smack_granted =
+                    devCapsSmack[i] ? ACE_TRUE : ACE_FALSE;
+        }
+        ace_return_t ret = ace_set_requested_dev_caps(dao.getHandle(),   //TODO: remove dao.getHandle()
+                                                      &list);
+        if (ACE_OK != ret) {
+            ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
+                     "ACE failure");
+        }
+        delete [] list.items;
+
+        std::set<std::string> acceptedFeature;
+        auto it = m_context.featureLogic->resultBegin();
+        for (;it != m_context.featureLogic->resultEnd(); ++it) {
+            if (!(it->rejected)) {
+                acceptedFeature.insert(DPL::ToUTF8String(it->name));
+            }
+        }
+        ace_feature_list_t featureList;
+        featureList.count = acceptedFeature.size();
+        featureList.items = new ace_string_t[featureList.count];
+
+        size_t i=0;
+        for (std::set<std::string>::const_iterator iter = acceptedFeature.begin();
+                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()
+
+        delete [] featureList.items;
+
+        if (ACE_OK != ret) {
+            LogError("Error in ace_set_feature");
+            ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
+              "ace_set_feature failure.");
+        }
         return;
     }
 
@@ -99,24 +174,25 @@ void TaskAceCheck::StepCheckAceResponse()
 {
     LogInfo("Checking ACE response");
     if (m_context.featureLogic->isRejected()) {
-        LogDebug("Installation failure. Some devCap was not accepted by ACE.");
+        LogError("Installation failure. Some devCap was not accepted by ACE.");
         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);
+        if (it->rejected) {
+            WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
+            dao.updateFeatureRejectStatus(*it);
+        }
+    }
     LogInfo("Installation continues...");
-}
-
-void TaskAceCheck::ProcessAceResponse(PolicyResult policyResult)
-{
-    LogInfo("Received ACE response.");
-
-    DPL::String deviceCap = m_context.featureLogic->getDevice();
-
-    if (policyResult == PolicyEffect::PERMIT)
-      m_context.staticPermittedDevCaps.insert(deviceCap);
 
-    m_context.featureLogic->setAceResponse(policyResult != PolicyEffect::DENY);
-    m_context.job->Resume();
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_ACE_CHECK,
+        "Widget Access Control Check Finished");
 }
 
 } //namespace WidgetInstall
index 4f9a110..d3c5955 100644 (file)
@@ -24,7 +24,6 @@
 
 #include <dpl/task.h>
 #include <dpl/event/inter_context_delegate.h>
-#include <dpl/ace/PolicyResult.h>
 
 class InstallerContext;
 
@@ -41,7 +40,6 @@ class TaskAceCheck :
     void StepAceCheck();
     void StepProcessAceResponse();
     void StepCheckAceResponse();
-    void ProcessAceResponse(PolicyResult result);
 
   public:
     TaskAceCheck(InstallerContext& context);
diff --git a/src/jobs/widget_install/task_certificates.cpp b/src/jobs/widget_install/task_certificates.cpp
new file mode 100644 (file)
index 0000000..92fc86f
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file    task_certificates.cpp
+ * @author  Leerang Song(leerang.song@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for installer task certificates
+ */
+#include <widget_install/task_certificates.h>
+#include <widget_install/widget_install_context.h>
+#include <widget_install/widget_install_errors.h>
+#include <widget_install/job_widget_install.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <pkgmgr_installer.h>
+#include <vcore/CryptoHash.h>
+
+#include <dpl/log/log.h>
+#include <dlog.h>
+#include <sstream>
+#include <dpl/foreach.h>
+#include <dpl/sstream.h>
+
+using namespace WrtDB;
+
+namespace Jobs {
+namespace WidgetInstall {
+
+TaskCertificates::TaskCertificates(InstallerContext& context) :
+    DPL::TaskDecl<TaskCertificates>(this),
+    m_context(context)
+{
+    AddStep(&TaskCertificates::StepSetCertiInfo);
+    AddAbortStep(&TaskCertificates::StepAbortCertiInfo);
+}
+
+void TaskCertificates::StepSetCertiInfo()
+{
+    LogDebug("StepSetCertiInfo");
+
+    if (pkgmgr_installer_create_certinfo_set_handle(&m_pkgHandle) < 0) {
+        LogError("pkgmgrInstallerCreateCertinfoSetHandle fail");
+        ThrowMsg(Exceptions::SetCertificateInfoFailed,
+                "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) {
+        LogError("pkgmgrInstallerSaveCertinfo fail");
+        ThrowMsg(Exceptions::SetCertificateInfoFailed,
+                "Failed to Installer Save Certinfo");
+    } else {
+        LogDebug("Succeed to save Certinfo");
+    }
+
+    if (pkgmgr_installer_destroy_certinfo_set_handle(m_pkgHandle) < 0) {
+        LogError("pkgmgrInstallerDestroyCertinfoSetHandle fail");
+    }
+}
+
+void TaskCertificates::SetCertiInfo(CertificateSource source)
+{
+    LogDebug("Set CertiInfo to pkgmgr : " << source);
+    CertificateChainList certificateChainList;
+    m_context.wacSecurity.getCertificateChainList(certificateChainList, source);
+
+    FOREACH(it, certificateChainList)
+    {
+        LogDebug("Insert certinfo to pkgmgr structure");
+
+        ValidationCore::CertificateCollection chain;
+        if (false == chain.load(*it)) {
+            LogError("Chain is broken");
+            ThrowMsg(Exceptions::SetCertificateInfoFailed,
+                    "Failed to Installer Save Certinfo");
+        }
+
+        if (!chain.sort()){
+            LogError("Chain failed at sorting");
+        }
+
+        ValidationCore::CertificateList list = chain.getCertificateList();
+
+        FOREACH(certIt, list) 
+        {
+            pkgmgr_instcert_type instCertType;
+
+            if (source == SIGNATURE_DISTRIBUTOR) {
+                std::string
+                    Name(DPL::ToUTF8String(*(*certIt)->getOrganizationName()));
+                size_t found = Name.find("Tizen");
+
+                if (found != std::string::npos) {
+                    LogDebug("Set SIGNATURE_DISTRIBUTOR");
+                    if ((*certIt)->isRootCert()) {
+                        instCertType = PM_SET_DISTRIBUTOR_ROOT_CERT;
+                    } else {
+                        if ((*certIt)->isCA()) {
+                            instCertType = PM_SET_DISTRIBUTOR_INTERMEDIATE_CERT;
+                        } else {
+                            instCertType = PM_SET_DISTRIBUTOR_SIGNER_CERT;
+                        }
+                    }
+                } else {
+                    LogDebug("Set SIGNATURE_DISTRIBUTOR2");
+                    if ((*certIt)->isRootCert()) {
+                        instCertType = PM_SET_DISTRIBUTOR2_ROOT_CERT;
+                    } else {
+                        if ((*certIt)->isCA()) {
+                            instCertType = PM_SET_DISTRIBUTOR2_INTERMEDIATE_CERT;
+                        } else {
+                            instCertType = PM_SET_DISTRIBUTOR2_SIGNER_CERT;
+                        }
+                    }
+                }
+            } else {
+                LogDebug("set SIGNATURE_AUTHOR");
+                if ((*certIt)->isRootCert()) {
+                    instCertType = PM_SET_AUTHOR_ROOT_CERT;
+                } else {
+                    if ((*certIt)->isCA()) {
+                        instCertType = PM_SET_AUTHOR_INTERMEDIATE_CERT;
+                    } else {
+                        instCertType = PM_SET_AUTHOR_SIGNER_CERT;
+                    }
+                }
+            }
+            LogDebug("cert type : " << instCertType);
+            if((pkgmgr_installer_set_cert_value(
+                            m_pkgHandle,
+                            instCertType,
+                            const_cast<char*>(((*certIt)->getBase64()).c_str()))) < 0) {
+                LogError("pkgmgrInstallerSetCertValue fail");
+                ThrowMsg(Exceptions::SetCertificateInfoFailed,
+                        "Failed to Set CertValue");
+            }
+        }
+    }
+}
+
+void TaskCertificates::StepAbortCertiInfo()
+{
+    if ((pkgmgr_installer_delete_certinfo(
+                    const_cast<char*>(DPL::ToUTF8String(
+                            m_context.widgetConfig.pkgName).c_str()))) < 0) {
+        LogError("pkgmgr_installer_delete_certinfo fail");
+    }
+}
+
+} //namespace WidgetInstall
+} //namespace Jobs
diff --git a/src/jobs/widget_install/task_certificates.h b/src/jobs/widget_install/task_certificates.h
new file mode 100755 (executable)
index 0000000..8a377d6
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file    task_certificates.h
+ * @author  Leerang Song(leerang.song@samsung.com)
+ * @version 1.0
+ * @brief   Header file for installer task certificates
+ */
+#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_CERTIFICATES_H
+#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_CERTIFICATES_H
+
+#include <dpl/task.h>
+#include <dpl/event/inter_context_delegate.h>
+#include <dpl/foreach.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+
+#include <pkgmgr_installer.h>
+using namespace WrtDB;
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+class TaskCertificates:
+    public DPL::TaskDecl<TaskCertificates>,
+    public DPL::Event::ICDelegateSupport<TaskCertificates>
+{
+  private:
+    InstallerContext& m_context;
+
+    void StepSetCertiInfo();
+    void StepAbortCertiInfo();
+    void SetCertiInfo(CertificateSource source);
+
+    pkgmgr_instcertinfo_h m_pkgHandle;
+
+  public:
+    TaskCertificates(InstallerContext& context);
+};
+} //namespace WidgetInstall
+} //namespace Jobs
+
+#endif /* INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_CERTIFICATES_H */
old mode 100644 (file)
new mode 100755 (executable)
index d801066..40a17cd
@@ -24,7 +24,6 @@
 #include <cstring>
 #include <string>
 #include <dpl/assert.h>
-#include <dpl/event/nested_loop.h>
 #include <appcore-common.h> //TODO is it necessary here?
 #include <pcrecpp.h>
 
 #include <dpl/wrt-dao-ro/global_config.h>
 #include "wac_widget_id.h"
 
+#include <vcore/Certificate.h>
 #include <vcore/SignatureReader.h>
 #include <vcore/SignatureFinder.h>
-#include <vcore/SignatureValidator.h>
+#include <vcore/WrtSignatureValidator.h>
 #include <vcore/DeveloperModeValidator.h>
 #include <dpl/utils/wrt_global_settings.h>
 #include <dpl/wrt-dao-ro/global_dao_read_only.h>
 
+#include <ITapiModem.h>
+#include <tapi_common.h>
+
 using namespace ValidationCore;
 using namespace WrtDB;
 
 namespace {
-enum ButtonId
-{
-    BUTTON_ID_INSTALL,
-    BUTTON_ID_RESIGN
-};
-
 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?";
 
 WidgetCertificateData toWidgetCertificateData(const SignatureData &data,
                                               bool root)
@@ -79,16 +78,17 @@ WidgetCertificateData toWidgetCertificateData(const SignatureData &data,
         certificate = data.getEndEntityCertificatePtr();
     }
 
-    Assert(!certificate->getCommonName().IsNull() && "CommonName is Null");
+    Assert(certificate && !certificate->getCommonName().IsNull() &&
+            "CommonName is Null");
 
     result.strCommonName = *certificate->getCommonName();
 
     result.strMD5Fingerprint = std::string("md5 ") +
-        SignatureValidator::FingerprintToColonHex(
+        Certificate::FingerprintToColonHex(
             certificate->getFingerprint(Certificate::FINGERPRINT_MD5));
 
     result.strSHA1Fingerprint = std::string("sha-1 ") +
-        SignatureValidator::FingerprintToColonHex(
+        Certificate::FingerprintToColonHex(
             certificate->getFingerprint(Certificate::FINGERPRINT_SHA1));
 
     return result;
@@ -100,19 +100,20 @@ namespace WidgetInstall {
 TaskCertify::TaskCertify(InstallerContext &inCont) :
     DPL::TaskDecl<TaskCertify>(this),
     m_contextData(inCont),
-    m_cancelInstallation(false),
-    m_userAgreedToInstallUntrustedWidget(false)
+    WidgetInstallPopup(inCont)
 {
     AddStep(&TaskCertify::stepSignature);
-    AddStep(&TaskCertify::stepWarningPopup);
-    AddStep(&TaskCertify::stepWarningPopupAnswer);
-    AddStep(&TaskCertify::stepAuthorInfoPopup);
-    AddStep(&TaskCertify::stepAuthorInfoPopupAnswer);
-    AddStep(&TaskCertify::stepFinalize);
-}
 
-TaskCertify::~TaskCertify()
-{
+    // Block until fixed popup issues
+    if (!GlobalSettings::PopupsTestModeEnabled()
+            && !m_installContext.m_quiet && !isTizenWebApp()) {
+        AddStep(&TaskCertify::stepWarningPopup);
+        AddStep(&TaskCertify::stepWarningPopupAnswer);
+        AddStep(&TaskCertify::stepAuthorInfoPopup);
+        AddStep(&TaskCertify::stepAuthorInfoPopupAnswer);
+        AddStep(&TaskCertify::StepDeletePopupWin);
+    }
+    AddStep(&TaskCertify::stepFinalize);
 }
 
 void TaskCertify::processDistributorSignature(const SignatureData &data,
@@ -128,7 +129,9 @@ void TaskCertify::processDistributorSignature(const SignatureData &data,
 
     CertificateCollection collection;
     collection.load(data.getCertList());
-    collection.sort();
+    Assert(collection.sort() &&
+            "Certificate collection can't sort");
+
     Assert(collection.isChain() &&
            "Certificate collection is not able to create chain. "
            "It is not possible to verify this signature.");
@@ -159,8 +162,19 @@ void TaskCertify::processAuthorSignature(const SignatureData &data)
     // match widget_id with one from dns identity set
     WacWidgetId widgetId(m_contextData.widgetConfig.configInfo.widget_id);
 
-    Certificate::AltNameSet dnsIdentity =
-        data.getEndEntityCertificatePtr()->getAlternativeNameDNS();
+    CertificatePtr cert = data.getEndEntityCertificatePtr();
+    Assert(cert);
+    Certificate::AltNameSet dnsIdentity = cert->getAlternativeNameDNS();
+
+    CertificateCollection collection;
+    collection.load(data.getCertList());
+    collection.sort();
+    Assert(collection.isChain() &&
+           "Certificate collection is not able to create chain. "
+           "It is not possible to verify this signature.");
+
+    m_contextData.wacSecurity.getAuthorsCertificateChainListRef().push_back(
+            collection);
 
     FOREACH(it, dnsIdentity){
         if (widgetId.matchHost(*it)) {
@@ -172,9 +186,9 @@ void TaskCertify::processAuthorSignature(const SignatureData &data)
 
 void TaskCertify::stepSignature()
 {
-    Assert(!m_contextData.tempWidgetPath.empty());
+    LogInfo("================ Step: <<Signature>> ENTER ===============");
 
-    std::string widgetPath = m_contextData.tempWidgetPath + "/";
+    std::string widgetPath = m_contextData.locations->getTemporaryRootDir() + "/";
 
     SignatureFileInfoSet signatureFiles;
     SignatureFinder signatureFinder(widgetPath);
@@ -185,7 +199,7 @@ void TaskCertify::stepSignature()
     }
 
     SignatureFileInfoSet::reverse_iterator iter = signatureFiles.rbegin();
-    LogInfo("No of signatures: " << signatureFiles.size());
+    LogInfo("Number of signatures: " << signatureFiles.size());
 
     bool firstDistributorSignature = true;
     bool testCertificate = false;
@@ -201,19 +215,29 @@ void TaskCertify::stepSignature()
             SignatureReader xml;
             xml.initialize(data, GlobalConfig::GetSignatureXmlSchema());
             xml.read(data);
-            SignatureValidator validator(GlobalConfig::IsOCSPEnabled(),
-                                         GlobalConfig::IsCRLEnabled(),
-                                         complianceMode);
-            SignatureValidator::Result result =
+
+            WrtSignatureValidator::AppType appType = WrtSignatureValidator::WAC20;
+
+            if (m_installContext.widgetConfig.webAppType == APP_TYPE_TIZENWEBAPP) {
+                appType = WrtSignatureValidator::TIZEN;
+            }
+
+            WrtSignatureValidator validator(
+                appType,
+                !GlobalSettings::OCSPTestModeEnabled(),
+                !GlobalSettings::CrlTestModeEnabled(),
+                complianceMode);
+
+            WrtSignatureValidator::Result result =
                 validator.check(data, widgetPath);
 
-            if (result == SignatureValidator::SIGNATURE_REVOKED) {
+            if (result == WrtSignatureValidator::SIGNATURE_REVOKED) {
                 LogWarning("Certificate is REVOKED");
                 ThrowMsg(Exceptions::InvalidPackage,
                          "Certificate is REVOKED");
             }
 
-            if (result == SignatureValidator::SIGNATURE_INVALID) {
+            if (result == WrtSignatureValidator::SIGNATURE_INVALID) {
                 LogWarning("Signature is INVALID");
                 // TODO change exception name
                 ThrowMsg(Exceptions::InvalidPackage,
@@ -221,15 +245,15 @@ void TaskCertify::stepSignature()
             }
 
             if (data.isAuthorSignature()) {
-                if (result == SignatureValidator::SIGNATURE_VERIFIED ||
+                if (result == WrtSignatureValidator::SIGNATURE_VERIFIED ||
                     m_contextData.wacSecurity.isDistributorSigned())
                 {
                     processAuthorSignature(data);
-                } else if (result == SignatureValidator::SIGNATURE_DISREGARD) {
+                } else if (result == WrtSignatureValidator::SIGNATURE_DISREGARD) {
                     continue;
                 }
             } else {
-                if (result == SignatureValidator::SIGNATURE_DISREGARD) {
+                if (result == WrtSignatureValidator::SIGNATURE_DISREGARD) {
                     continue;
                 }
                 // now signature _must_ be verified
@@ -237,20 +261,32 @@ void TaskCertify::stepSignature()
                 firstDistributorSignature = false;
             }
 
+            bool developerMode = GlobalDAOReadOnly::GetDeveloperMode();
+
+            std::string realMEID;
+            TapiHandle *tapiHandle = tel_init(NULL);
+            char *meid = tel_get_misc_me_sn_sync(tapiHandle);
+            if (meid)
+            {
+                realMEID = meid;
+                free(meid);
+            }
+            tel_deinit(tapiHandle);
+
             DeveloperModeValidator developerModeValidator(
                 complianceMode,
+                developerMode,
                 GlobalDAOReadOnly::getComplianceFakeImei(),
-                GlobalDAOReadOnly::getComplianceFakeMeid());
+                GlobalDAOReadOnly::getComplianceFakeMeid(),
+                realMEID);
 
             developerModeValidator.check(data);
 
             testCertificate |=
                 data.getStorageType().contains(CertStoreId::DEVELOPER);
 
-            bool developerMode = GlobalDAOReadOnly::GetDeveloperMode();
-
             if (testCertificate && !developerMode) {
-                LogDebug("Widget signed by test certificate, "
+                LogError("Widget signed by test certificate, "
                          "but developer mode is off.");
                 ThrowMsg(Exceptions::InvalidPackage,
                          "Widget signed by test certificate, "
@@ -258,12 +294,12 @@ void TaskCertify::stepSignature()
             }
             m_contextData.widgetConfig.isTestWidget = testCertificate;
         } Catch(ParserSchemaException::Base) {
-            LogDebug("Error occured in ParserSchema.");
+            LogError("Error occured in ParserSchema.");
             ReThrowMsg(Exceptions::InvalidPackage,
                        "Error occured in ParserSchema.");
         }
         Catch(DeveloperModeValidator::Exception::Base) {
-            LogDebug("Cannot validate developer certificate.");
+            LogError("Cannot validate developer certificate.");
             ReThrowMsg(Exceptions::InvalidPackage,
                        "Cannot validate developer certificate.");
         }
@@ -273,7 +309,28 @@ void TaskCertify::stepSignature()
         LogInfo("No signature files has been found.");
     }
 
-    LogInfo("================ Step: <<CSignature>> DONE ================");
+    LogInfo("================ Step: <<Signature>> DONE ================");
+
+    m_contextData.job->UpdateProgress(
+        InstallerContext::INSTALL_DIGSIG_CHECK,
+        "Widget Signature checked");
+}
+
+void TaskCertify::createInstallPopup(PopupType type, const std::string &label)
+{
+    m_contextData.job->Pause();
+    if(m_popup)
+        destroyPopup();
+    bool ret = createPopup();
+    if(ret)
+    {
+        loadPopup(type, label);
+        showPopup();
+    }
+}
+void TaskCertify::StepDeletePopupWin()
+{
+    destroyPopup();
 }
 
 void TaskCertify::stepWarningPopup()
@@ -285,51 +342,10 @@ void TaskCertify::stepWarningPopup()
     //          user decide whether it should be installed as an untrusted
     //          application.
     if (!m_contextData.wacSecurity.isDistributorSigned()) {
-        if (GlobalSettings::GetPopupsEnabledFlag()) {
-            m_contextData.job->Pause();
-            std::string label = _("IDS_IM_POP_WIDGET_UNTRUSTED_WARNING") +
-                                LABEL_NEW_LINE +
-                                _("IDS_IM_WIDGET_WANT_TO_INSTALL");
-            using namespace DPL::Popup;
-            CtrlPopupPtr popup =
-                PopupControllerSingleton::Instance().CreatePopup();
-            popup->SetTitle(_("IDS_IM_POP_WIDGET_UNTRUSTED_TITLE"));
-            popup->Append(new PopupObject::Label(label));
-            popup->Append(new PopupObject::Button(_("IDS_IM_BUTTON_INSTALL"),
-                                                   BUTTON_ID_INSTALL));
-            popup->Append(new PopupObject::Button(_("IDS_IM_BUTTON_RESIGN"),
-                                                   BUTTON_ID_RESIGN));
-
-            ListenForAnswer(popup);
-
-            PopupAnswerCallback cb = MakeAnswerCallback(this,
-                    &TaskCertify::onWarningPopupAnswer);
-
-            ShowPopupEvent event(popup, cb, DPL::Event::UNDEFINED_LOOP_HANDLE);
-            CONTROLLER_POST_EVENT(PopupController, event);
-        } else {
-            m_userAgreedToInstallUntrustedWidget = true;
-        }
-    }
-}
-
-void TaskCertify::stepWarningPopupAnswer()
-{
-    LogInfo("Step: <<Warning Popup Answer>>");
-    if (false == m_contextData.wacSecurity.isDistributorSigned() &&
-        false == m_userAgreedToInstallUntrustedWidget)
-    {
-        LogWarning("User does not agreed to install unsigned widgets!");
-        ThrowMsg(Exceptions::NotAllowed, "Widget not allowed");
-    }
-}
-
-void TaskCertify::stepAuthorInfoPopupAnswer()
-{
-    LogInfo("Step: <<Author Info Popup Answer>>");
-    if (m_cancelInstallation) {
-        LogWarning("User does not agreed to install widget!");
-        ThrowMsg(Exceptions::NotAllowed, "Widget not allowed");
+        std::string label = UNTRUSTED_WIDGET +
+            LABEL_NEW_LINE_2 +
+            QUESTION;
+        createInstallPopup(PopupType::WIDGET_UNRECOGNIZED, label);
     }
 }
 
@@ -337,9 +353,11 @@ std::string TaskCertify::createAuthorWidgetInfo() const
 {
     std::string authorInfo;
     if (m_contextData.wacSecurity.isRecognized()) {
-        authorInfo += _("IDS_IM_WIDGET_RECOGNISED");
+        //authorInfo += _("IDS_IM_WIDGET_RECOGNISED");
+        authorInfo += _("WIDGET RECOGNISED");
     } else {
-        authorInfo += _("IDS_IM_WIDGET_UNRECOGNISED");
+        //authorInfo += _("IDS_IM_WIDGET_UNRECOGNISED");
+        authorInfo += _("WIDGET UNRECOGNISED");
     }
 
     authorInfo += LABEL_NEW_LINE_2;
@@ -349,13 +367,15 @@ std::string TaskCertify::createAuthorWidgetInfo() const
         DPL::Optional < DPL::String > organizationName =
             authorCert->getOrganizationName();
 
-        authorInfo += _("IDS_IM_WIDGET_AUTHOR_ORGANIZATION_NAME");
+        //authorInfo += _("IDS_IM_WIDGET_AUTHOR_ORGANIZATION_NAME");
+        authorInfo += _("AUTHOR ORGANIZATION NAME");
         authorInfo += LABEL_NEW_LINE;
 
         if (!organizationName.IsNull()) {
             authorInfo += DPL::ToUTF8String(*organizationName);
         } else {
-            authorInfo += _("IDS_IM_WIDGET_ORGANIZATION_UNKNOWN");
+            //authorInfo += _("IDS_IM_WIDGET_ORGANIZATION_UNKNOWN");
+            authorInfo += _("WIDGET ORGANIZATION UNKNOWN");
         }
 
         authorInfo += LABEL_NEW_LINE_2;
@@ -363,17 +383,20 @@ std::string TaskCertify::createAuthorWidgetInfo() const
         DPL::Optional < DPL::String > countryName =
             authorCert->getCountryName();
 
-        authorInfo += _("IDS_IM_WIDGET_COUNTRY_NAME");
+        //authorInfo += _("IDS_IM_WIDGET_COUNTRY_NAME");
+        authorInfo += _("WIDGET COUNTRY NAME");
         authorInfo += LABEL_NEW_LINE;
 
         if (!countryName.IsNull()) {
             authorInfo += DPL::ToUTF8String(*countryName);
         } else {
-            authorInfo += _("IDS_IM_WIDGET_COUNTRY_UNKNOWN");
+            //authorInfo += _("IDS_IM_WIDGET_COUNTRY_UNKNOWN");
+            authorInfo += _("WIDGET COUNTRY UNKNOWN");
         }
     } else {
         authorInfo +=
-            _("IDS_IM_WIDGET_DOES_NOT_CONTAIN_RECOGNIZED_AUTHOR_SIGNATURE");
+            //_("IDS_IM_WIDGET_DOES_NOT_CONTAIN_RECOGNIZED_AUTHOR_SIGNATURE");
+            _("Widget does not contain recognized author signature");
     }
     return authorInfo;
 }
@@ -381,57 +404,54 @@ std::string TaskCertify::createAuthorWidgetInfo() const
 void TaskCertify::stepAuthorInfoPopup()
 {
     LogInfo("Step:: <<Author Popup Information>>");
-
-    if (!GlobalSettings::GetPopupsEnabledFlag()) {
-        LogDebug("Popups are not enabled! Author information wont be shown.");
-        return;
-    }
-
-    using namespace DPL::Popup;
-    m_contextData.job->Pause();
-    std::string label = createAuthorWidgetInfo() + LABEL_NEW_LINE + _("IDS_IM_WIDGET_WANT_TO_INSTALL");
-
-    CtrlPopupPtr popup = PopupControllerSingleton::Instance().CreatePopup();
-    popup->SetTitle(_("IDS_IM_WIDGET_HEAD"));
-    popup->Append(new PopupObject::Label(label));
-    popup->Append(new PopupObject::Button(_("IDS_IM_BUTTON_INSTALL"),
-                                           BUTTON_ID_INSTALL));
-    popup->Append(new PopupObject::Button(_("IDS_IM_BUTTON_RESIGN"),
-                                           BUTTON_ID_RESIGN));
-    ListenForAnswer(popup);
-    ShowPopupEvent event(popup,
-                         MakeAnswerCallback(
-                             this,
-                             &TaskCertify::onAuthorInfoPopupAnswer),
-                         DPL::Event::UNDEFINED_LOOP_HANDLE);
-    CONTROLLER_POST_EVENT(PopupController, event);
+        std::string label
+            = createAuthorWidgetInfo() + LABEL_NEW_LINE_2 + QUESTION;
+        createInstallPopup(PopupType::WIDGET_AUTHOR_INFO, label);
 }
 
 void TaskCertify::stepFinalize()
 {
     LogInfo("Step: <<CERTYFYING DONE>>");
+
+    m_contextData.job->UpdateProgress(
+        InstallerContext::INSTALL_CERT_CHECK,
+        "Widget Certification Check Finished");
 }
 
-void TaskCertify::onWarningPopupAnswer(const DPL::Popup::AnswerCallbackData& answer)
+
+void TaskCertify::stepWarningPopupAnswer()
 {
-    m_contextData.job->Resume();
-    if (BUTTON_ID_RESIGN == answer.buttonAnswer) {
-        m_userAgreedToInstallUntrustedWidget = false;
-    } else if (BUTTON_ID_INSTALL == answer.buttonAnswer) {
-        m_userAgreedToInstallUntrustedWidget = true;
-    } else {
-        Assert(false && "Unpredicted answer received.");
+    LogInfo("Step: <<Warning Popup Answer>>");
+    if (false == m_contextData.wacSecurity.isDistributorSigned() &&
+            WRT_POPUP_BUTTON_CANCEL == m_installCancel)
+    {
+        LogWarning("User does not agreed to install unsigned widgets!");
+        m_installCancel = WRT_POPUP_BUTTON;
+        destroyPopup();
+        ThrowMsg(Exceptions::NotAllowed, "Widget not allowed");
     }
 }
 
-void TaskCertify::onAuthorInfoPopupAnswer(
-        const DPL::Popup::AnswerCallbackData& answer)
+void TaskCertify::stepAuthorInfoPopupAnswer()
 {
-    m_contextData.job->Resume();
-    if (BUTTON_ID_RESIGN == answer.buttonAnswer) {
-        m_cancelInstallation = true;
+    LogInfo("Step: <<Author Info Popup Answer>>");
+    if ( WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
+        LogWarning("User does not agreed to install widget!");
+        m_installCancel = WRT_POPUP_BUTTON;
+        destroyPopup();
+        ThrowMsg(Exceptions::NotAllowed, "Widget not allowed");
     }
 }
+
+bool TaskCertify::isTizenWebApp() const
+{
+    bool ret = FALSE;
+    if (m_installContext.widgetConfig.webAppType.appType
+            == WrtDB::AppType::APP_TYPE_TIZENWEBAPP)
+        ret = TRUE;
+
+    return ret;
+}
 } //namespace WidgetInstall
 } //namespace Jobs
 
old mode 100644 (file)
new mode 100755 (executable)
index dbd99bf..e6ca9ac
@@ -28,7 +28,7 @@
 
 //WRT INCLUDES
 #include <dpl/task.h>
-#include <dpl/popup/popup_controller.h>
+#include <widget_install/widget_install_popup.h>
 
 class InstallerContext;
 
@@ -40,25 +40,24 @@ namespace Jobs {
 namespace WidgetInstall {
 class TaskCertify :
     public DPL::TaskDecl<TaskCertify>,
-    public DPL::Popup::PopupControllerUser
+    public WidgetInstallPopup
 {
   public:
     TaskCertify(InstallerContext &inCont);
-    virtual ~TaskCertify();
 
   private:
     //data
     InstallerContext& m_contextData;
-    bool m_cancelInstallation;
-    bool m_userAgreedToInstallUntrustedWidget;
 
     //steps
     void stepSignature();
     void stepWarningPopup();
-    void stepWarningPopupAnswer();
     void stepAuthorInfoPopup();
+    void stepWarningPopupAnswer();
     void stepAuthorInfoPopupAnswer();
+    void StepDeletePopupWin();
     void stepFinalize();
+    void createInstallPopup(PopupType type, const std::string &label);
 
     void processDistributorSignature(const ValidationCore::SignatureData &data,
             bool first);
@@ -66,8 +65,8 @@ class TaskCertify :
 
     std::string createAuthorWidgetInfo() const;
 
-    void onWarningPopupAnswer(const DPL::Popup::AnswerCallbackData &answer);
-    void onAuthorInfoPopupAnswer(const DPL::Popup::AnswerCallbackData &answer);
+    bool isTizenWebApp() const;
+
 };
 } //namespace WidgetInstall
 } //namespace Jobs
diff --git a/src/jobs/widget_install/task_commons.cpp b/src/jobs/widget_install/task_commons.cpp
new file mode 100644 (file)
index 0000000..fea9ea1
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file       task_commons.cpp
+ * @author     Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version    1.0
+ */
+
+#include "task_commons.h"
+#include <unistd.h>
+#include <sstream>
+#include <ftw.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/log/log.h>
+#include <dpl/exception.h>
+#include <dpl/errno_string.h>
+#include <dpl/utils/wrt_utility.h>
+#include <widget_install/widget_install_errors.h>
+
+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;
+}
+
+void createTempPath(const std::string& path)
+{
+   if(!WrtUtilMakeDir(path, TEMPORARY_PATH_MODE)){
+       ThrowMsg(Exceptions::InternalError, "Failed to create temporary directory");
+   }
+}
+
+} // WidgetInstall
+} // Jobs
diff --git a/src/jobs/widget_install/task_commons.h b/src/jobs/widget_install/task_commons.h
new file mode 100644 (file)
index 0000000..5193c3d
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file       task_commons.h
+ * @author     Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version    1.0
+ */
+
+#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_COMMONS_H_
+#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_COMMONS_H_
+
+#include <string>
+
+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_ */
diff --git a/src/jobs/widget_install/task_database.cpp b/src/jobs/widget_install/task_database.cpp
new file mode 100644 (file)
index 0000000..78c06ef
--- /dev/null
@@ -0,0 +1,268 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    task_new_db_insert.cpp
+ * @author  Lukasz Wrzosek(l.wrzosek@samsung.com)
+ * @author  Soyoung kim(sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for installer task database updating for widget update
+ */
+#include <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 <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 <string>
+#include <sstream>
+#include <ace_api_install.h>
+#include <ace_registration.h>
+#include <errno.h>
+#include <string.h>
+#include <vconf.h>
+#include <map>
+
+using namespace WrtDB;
+
+namespace Jobs {
+namespace WidgetInstall {
+
+TaskDatabase::TaskDatabase(InstallerContext& context) :
+    DPL::TaskDecl<TaskDatabase>(this),
+    m_context(context),
+    m_handleToRemove(INVALID_WIDGET_HANDLE),
+    m_handle(INVALID_WIDGET_HANDLE)
+{
+    AddStep(&TaskDatabase::StepRegisterExternalFiles);
+    AddStep(&TaskDatabase::StepWrtDBInsert);
+    AddStep(&TaskDatabase::StepAceDBInsert);
+    AddStep(&TaskDatabase::StepRemoveExternalFiles);
+    AddStep(&TaskDatabase::StepCreateVconf);
+
+    AddAbortStep(&TaskDatabase::StepAbortDBInsert);
+}
+
+void TaskDatabase::StepWrtDBInsert()
+{
+    Try
+    {
+        /* Set install Time */
+        time(&m_context.widgetConfig.installedTime);
+
+        if (m_context.existingWidgetInfo.isExist) //update
+        {
+            LogInfo("Registering widget... (update)");
+            Try
+            {
+                m_handleToRemove = WidgetDAOReadOnly::getHandle(
+                    m_context.locations->getPkgname());
+            }
+            Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
+            {
+                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_handle = WidgetDAOReadOnly::getHandle(
+                m_context.locations->getPkgname());
+        }
+        else //new installation
+        {
+            LogInfo("Registering widget...");
+            WidgetDAO::registerWidget(
+                    m_context.locations->getPkgname(),
+                    m_context.widgetConfig,
+                    m_context.wacSecurity);
+            m_handle = WidgetDAOReadOnly::getHandle(
+                m_context.locations->getPkgname());
+        }
+
+        FOREACH (cap, m_context.staticPermittedDevCaps) {
+            LogInfo("staticPermittedDevCaps : " << cap->first
+                    << " smack status: " << cap->second);
+        }
+
+        LogInfo("Widget registered");
+    }
+    Catch(WidgetDAO::Exception::DatabaseError)
+    {
+        LogError("Database failure!");
+        ReThrowMsg(Exceptions::InsertNewWidgetFailed, "Database failure!");
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base)
+    {
+        LogError("Database failure!");
+        ReThrowMsg(Exceptions::InsertNewWidgetFailed, "Database failure!");
+    }
+}
+
+void TaskDatabase::StepAceDBInsert()
+{
+    LogDebug("Inserting Ace database entry. New handle: " << m_handle);
+    if (INVALID_WIDGET_HANDLE != m_handleToRemove) {
+        LogDebug("Removing old insallation. Handle: " << m_handleToRemove);
+        if (ACE_OK != ace_unregister_widget(
+                static_cast<ace_widget_handle_t>(m_handleToRemove)))
+        {
+            LogWarning("Error while removing ace entry for previous insallation");
+        };
+    }
+
+    if(!AceApi::registerAceWidget(m_handle, m_context.widgetConfig,
+                                  m_context.wacSecurity.getCertificateList()))
+    {
+        LogError("ace database insert failed");
+        ThrowMsg(Exceptions::UpdateFailed, "Update failure. ace_register_widget failed");
+    }
+    LogDebug("Ace data inserted");
+
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_NEW_DB_INSERT,
+        "New Widget DB UPDATE Finished");
+}
+
+void TaskDatabase::StepRegisterExternalFiles()
+{
+    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();
+            FOREACH(file, externalLocationsDB)
+            {
+                if(std::find(externalLocationsUpdate.begin(), externalLocationsUpdate.end(), *file) == externalLocationsUpdate.end())
+                {
+                    m_externalLocationsToRemove.push_back(*file);
+                }
+            }
+        }
+        Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
+        {
+            LogError("Given tizenId not found for update installation (Same GUID?)");
+            ThrowMsg(Exceptions::UpdateFailed, "Given tizenId not found for update installation");
+        }
+    }
+    LogDebug("Registering external files:");
+    FOREACH(file, externalLocationsUpdate)
+    {
+        LogDebug("  -> " << *file);
+    }
+
+    //set external locations to be registered
+    m_context.widgetConfig.externalLocations = externalLocationsUpdate;
+}
+
+void TaskDatabase::StepRemoveExternalFiles()
+{
+    if(!m_externalLocationsToRemove.empty())
+    {
+        LogDebug("Removing external files:");
+    }
+
+    FOREACH(file, m_externalLocationsToRemove)
+    {
+        if(WrtUtilFileExists(*file))
+        {
+            LogDebug("  -> " << *file);
+            remove(file->c_str());
+        }
+        else if(WrtUtilDirExists(*file))
+        {
+            LogDebug("  -> " << *file);
+            if(!WrtUtilRemove(*file)){
+                ThrowMsg(Exceptions::RemovingFolderFailure,
+                        "Failed to remove external directory");
+            }
+        }
+        else
+        {
+            LogWarning("  -> " << *file << "(no such a path)");
+        }
+    }
+}
+
+void TaskDatabase::StepCreateVconf()
+{
+    LogDebug("StepCreateVconf");
+    std::map<std::string, WrtDB::SettingsType> vconfData;
+    vconfData[
+        WrtDB::VconfConfig::GetVconfKeyPopupUsage(
+            m_context.locations->getPkgname())] = WrtDB::SETTINGS_TYPE_ON;
+    vconfData[
+        WrtDB::VconfConfig::GetVconfKeyGeolocationUsage(
+            m_context.locations->getPkgname())] = 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;
+    vconfData[
+        WrtDB::VconfConfig::GetVconfKeyMemorySavingMode(
+            m_context.locations->getPkgname())] = WrtDB::SETTINGS_TYPE_OFF;
+
+    // vconftool -g 5000 set -t int <path> initialize value
+    // Current installer should use vconftool for setting group ID
+    // In case of install application by pkgcmd, permission for others
+    // set to read-only
+    FOREACH(it, vconfData) {
+        std::ostringstream command;
+        command << "vconftool -g 5000 set -t int ";
+        command << (*it).first;
+        command << " \"" << static_cast<int>((*it).second) << "\"";
+        int ret = system(command.str().c_str());
+        if (-1 == ret) {
+            ThrowMsg(Exceptions::CreateVconfFailure, "Failed to create vconf files");
+        }
+    }
+}
+
+void TaskDatabase::StepAbortDBInsert()
+{
+    LogWarning("[DB Update Task] Aborting... (DB Clean)");
+    Try
+    {
+        WidgetDAO::unregisterWidget(m_context.locations->getPkgname());
+        LogDebug("Cleaning DB successful!");
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base)
+    {
+        LogError("Failed to handle StepAbortDBClean!");
+    }
+
+    ace_unregister_widget(static_cast<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)
+        ace_unregister_widget(static_cast<ace_widget_handle_t>(m_handle));
+}
+
+} //namespace WidgetInstall
+} //namespace Jobs
diff --git a/src/jobs/widget_install/task_database.h b/src/jobs/widget_install/task_database.h
new file mode 100644 (file)
index 0000000..f2098bc
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file    task_database.h
+ * @author  Lukasz Wrzosek(l.wrzosek@samsung.com)
+ * @author  Soyoung kim(sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief   Header file for installer task database updating
+ */
+#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_DATABASE_H
+#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_DATABASE_H
+
+#include <dpl/task.h>
+#include <dpl/wrt-dao-ro/common_dao_types.h>
+
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+class TaskDatabase:
+    public DPL::TaskDecl<TaskDatabase>
+{
+  private:
+    InstallerContext& m_context;
+    WrtDB::ExternalLocationList m_externalLocationsToRemove;
+
+    //TODO: temporary needed until security-server start to use pkgName instead
+    //of widget handle
+    WrtDB::DbWidgetHandle m_handleToRemove;
+    WrtDB::DbWidgetHandle m_handle;
+
+    void StepRegisterExternalFiles();
+    void StepWrtDBInsert();
+    void StepAceDBInsert();
+    void StepRemoveExternalFiles();
+    void StepCreateVconf();
+
+    void StepAbortDBInsert();
+
+  public:
+    TaskDatabase(InstallerContext& context);
+};
+} //namespace WidgetInstall
+} //namespace Jobs
+
+#endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_DATABASE_H
diff --git a/src/jobs/widget_install/task_encrypt_resource.cpp b/src/jobs/widget_install/task_encrypt_resource.cpp
new file mode 100644 (file)
index 0000000..71752e5
--- /dev/null
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    task_ecnrypt_resource.cpp
+ * @author  Soyoung Kim (sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for installer task encrypt resource
+ */
+#include "task_encrypt_resource.h"
+
+#undef __USE_FILE_OFFSET64
+
+#include <unistd.h>
+#include <string>
+#include <sys/stat.h>
+#include <fts.h>
+#include <string.h>
+#include <errno.h>
+
+#include <dpl/log/log.h>
+#include <dpl/errno_string.h>
+#include <dpl/foreach.h>
+#include <dpl/wrt-dao-ro/global_config.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 {
+std::set<std::string>& getSupportedForEncryption()
+{
+    static std::set<std::string> encryptSet;
+    if (encryptSet.empty()) {
+        encryptSet.insert(".html");
+        encryptSet.insert(".css");
+        encryptSet.insert(".js");
+    }
+    return encryptSet;
+}
+
+bool isSupportedForEncryption(const std::string &file)
+{
+    size_t foundKey = file.rfind(".");
+    if (std::string::npos != foundKey) {
+        std::string mimeType = file.substr(foundKey);
+        return getSupportedForEncryption().count(mimeType) > 0;
+    }
+    return false;
+}
+}
+
+namespace Jobs {
+namespace WidgetInstall {
+TaskEncryptResource::TaskEncryptResource(InstallerContext& context) :
+    DPL::TaskDecl<TaskEncryptResource>(this),
+    m_context(context)
+{
+    AddStep(&TaskEncryptResource::StepEncryptResource);
+}
+
+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());
+}
+
+void TaskEncryptResource::EncryptDirectory(std::string path)
+{
+    FTS *fts;
+    FTSENT *ftsent;
+    char * const paths[] = {const_cast<char * const>(path.c_str()), 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));
+        ThrowMsg(Exceptions::InternalError, "Error reading directory: "
+                << 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");
+        }
+    }
+
+    if (fts_close(fts) == -1) {
+        int error = errno;
+        LogWarning(__PRETTY_FUNCTION__ << ": fts_close failed with error: "
+                << strerror(error));
+    }
+}
+
+void TaskEncryptResource::EncryptFile(const std::string &fileName)
+{
+    Try
+    {
+        LogDebug("Need to ecnrypt file Name " << 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;
+
+            FILE* resFp = fopen(fileName.c_str(), "r");
+            if ( NULL == resFp) {
+                LogError("Couldnot open file : " << fileName);
+                return;
+            }
+
+            int blockSize = m_resEnc->GetBlockSize(fileSize);
+            LogDebug("Get block size : " << blockSize);
+
+            unsigned char readBuf[fileSize];
+            unsigned char outEncBuf[blockSize];
+            memset(readBuf, 0, fileSize);
+            memset(outEncBuf, 0, blockSize);
+
+            ret = fread(readBuf, sizeof(unsigned char), fileSize, resFp);
+            if (ret!=fileSize){
+                LogError("Failed to read ecryption buffer with error: " << strerror(errno) );
+                fclose(resFp);
+               return;
+            }
+
+            m_resEnc->EncryptChunk(readBuf, outEncBuf, fileSize);
+
+            FILE* encFp = fopen(encFile.c_str(), "w");
+            if (NULL == encFp) {
+                LogError("Failed to open ecryption file");
+                fclose(resFp);
+                return;
+            }
+            fwrite(outEncBuf, sizeof(unsigned char), blockSize, encFp);
+
+            fclose(resFp);
+            fclose(encFp);
+
+            LogDebug("Success to encrypt file");
+            LogDebug("Remove unecrypted file : " << fileName);
+
+            unlink(fileName.c_str());
+            if ((rename(encFile.c_str(), fileName.c_str())) != 0) {
+                ThrowMsg(Exceptions::ExtractFileFailed, fileName);
+            }
+
+            std::string realPath = fileName;
+            realPath.replace(0, m_context.locations->getTemporaryRootDir().length(),
+                    m_context.locations->getSourceDir());
+
+            WrtDB::EncryptedFileInfo info;
+            info.fileName = DPL::FromUTF8String(realPath);
+            info.fileSize = fileSize;
+
+            m_context.widgetConfig.encryptedFiles.insert(info);
+        }
+    }
+    Catch(ResourceEncryptor::Exception::Base)
+    {
+        ReThrowMsg(Exceptions::ExtractFileFailed, fileName);
+    }
+}
+} //namespace WidgetInstall
+} //namespace Jobs
diff --git a/src/jobs/widget_install/task_encrypt_resource.h b/src/jobs/widget_install/task_encrypt_resource.h
new file mode 100644 (file)
index 0000000..de37640
--- /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.
+ */
+/*
+ * @file       task_encrypt_resource.h
+ * @author     soyoung kim (sy037.kim@samsung.com)
+ * @version    1.0
+ */
+
+#ifndef SRC_JOBS_WIDGET_INSTALL_TASK_RESOURCE_ENCRYPT_H_
+#define SRC_JOBS_WIDGET_INSTALL_TASK_RESOURCE_ENCRYPT_H_
+
+#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:
+    // Installation context
+    InstallerContext &m_context;
+    std::string tempInstalledPath;
+
+    void StepEncryptResource();
+
+    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_ */
diff --git a/src/jobs/widget_install/task_file_manipulation.cpp b/src/jobs/widget_install/task_file_manipulation.cpp
new file mode 100644 (file)
index 0000000..8306799
--- /dev/null
@@ -0,0 +1,349 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    task_db_update.cpp
+ * @author  Lukasz Wrzosek(l.wrzosek@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for installer task database updating
+ */
+#include <sys/stat.h>
+#include <dirent.h>
+#include <widget_install/task_file_manipulation.h>
+#include <widget_install/job_widget_install.h>
+#include <widget_install/widget_install_errors.h>
+#include <widget_install/widget_install_context.h>
+#include <dpl/utils/wrt_utility.h>
+#include <dpl/foreach.h>
+#include <dpl/log/log.h>
+#include <dpl/assert.h>
+#include <dpl/utils/folder_size.h>
+#include <string>
+#include <fstream>
+#include <widget_install_to_external.h>
+
+#define WEBAPP_DEFAULT_UID  5000
+#define WEBAPP_DEFAULT_GID  5000
+
+namespace {
+const mode_t PRIVATE_STORAGE_MODE = 0700;
+const mode_t SHARE_MODE = 0705;
+}
+
+using namespace WrtDB;
+
+namespace {
+const char* GLIST_RES_DIR = "res";
+const char* GLIST_BIN_DIR = "bin";
+
+bool _FolderCopy(std::string source, std::string dest)
+{
+    DIR* dir = opendir(source.c_str());
+    if (NULL == dir) {
+        return false;
+    }
+
+    struct dirent* dEntry = NULL;
+    do {
+        struct stat statInfo;
+        if (dEntry = readdir(dir)) {
+            std::string fileName = dEntry->d_name;
+            std::string fullName = source + "/" + fileName;
+
+            if (stat(fullName.c_str(), &statInfo) != 0) {
+                closedir(dir);
+                return false;
+            }
+
+            if (S_ISDIR(statInfo.st_mode)) {
+                if(("." == fileName) || (".." == fileName)) {
+                    continue;
+                }
+                std::string destFolder = dest + "/" + fileName;
+                WrtUtilMakeDir(destFolder);
+
+                if (!_FolderCopy(fullName, destFolder)) {
+                    closedir(dir);
+                    return false;
+                }
+            }
+
+            std::string destFile = dest + "/" + fileName;
+            std::ifstream infile(fullName);
+            std::ofstream outfile(destFile);
+            outfile << infile.rdbuf();
+            outfile.close();
+            infile.close();
+        }
+    } while(dEntry);
+    closedir(dir);
+    return true;
+}
+}
+
+namespace Jobs {
+namespace WidgetInstall {
+TaskFileManipulation::TaskFileManipulation(InstallerContext& context) :
+    DPL::TaskDecl<TaskFileManipulation>(this),
+    m_context(context)
+{
+    if (INSTALL_LOCATION_TYPE_EXTERNAL !=
+            m_context.locationType) {
+        AddStep(&TaskFileManipulation::StepCreateDirs);
+        AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir);
+        AddStep(&TaskFileManipulation::StepCreateShareDir);
+        if (m_context.widgetConfig.packagingType !=
+                WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
+        {
+            AddStep(&TaskFileManipulation::StepRenamePath);
+            AddAbortStep(&TaskFileManipulation::StepAbortRenamePath);
+        }
+    } else {
+        AddStep(&TaskFileManipulation::StepPrepareExternalDir);
+        AddStep(&TaskFileManipulation::StepInstallToExternal);
+        AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir);
+        AddStep(&TaskFileManipulation::StepCreateShareDir);
+
+        AddAbortStep(&TaskFileManipulation::StepAbortCreateExternalDir);
+    }
+}
+
+void TaskFileManipulation::StepCreateDirs()
+{
+    std::string widgetPath;
+
+    widgetPath = m_context.locations->getPackageInstallationDir();
+
+    std::string widgetBinPath = m_context.locations->getBinaryDir();
+    std::string widgetSrcPath = m_context.locations->getSourceDir();
+
+    WrtUtilMakeDir(widgetPath);
+
+    // If package type is widget with osp service, we don't need to make bin
+    // and src directory
+    if (m_context.widgetConfig.packagingType == PKG_TYPE_HYBRID_WEB_APP) {
+        LogDebug("Doesn't need to create resource directory");
+    } else {
+        LogDebug("Create resource directory");
+        WrtUtilMakeDir(widgetBinPath);
+        WrtUtilMakeDir(widgetSrcPath);
+    }
+
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_DIR_CREATE,
+        "Widget Directory Created");
+}
+
+void TaskFileManipulation::StepCreatePrivateStorageDir()
+{
+    std::string storagePath = m_context.locations->getPrivateStorageDir();
+
+    if (euidaccess(storagePath.c_str(), F_OK) != 0) {
+        if(!WrtUtilMakeDir(storagePath, PRIVATE_STORAGE_MODE)){
+            LogError("Failed to create directory for private storage");
+            ThrowMsg(Exceptions::InternalError,
+                    "Failed to create directory for private storage");
+        }
+        // '5000' is default uid, gid for applications.
+        // So installed applications should be launched as process of uid '5000'.
+        // the process can access private directory 'data' of itself.
+        if(chown(storagePath.c_str(),
+                 WEBAPP_DEFAULT_UID,
+                 WEBAPP_DEFAULT_GID) != 0)
+        {
+            ThrowMsg(Exceptions::InternalError,
+                 "Chown to invaild user");
+        }
+    } else if (euidaccess(storagePath.c_str(), W_OK | R_OK | X_OK) == 0) {
+        LogInfo("Private storage already exists.");
+        // Even if private directory already is created, private dircetory
+        // should change owner.
+        if(chown(storagePath.c_str(),
+                 WEBAPP_DEFAULT_UID,
+                 WEBAPP_DEFAULT_GID) != 0)
+        {
+            ThrowMsg(Exceptions::InternalError,
+                 "Chown to invaild user");
+        }
+        if(chmod(storagePath.c_str(), PRIVATE_STORAGE_MODE) != 0) {
+            ThrowMsg(Exceptions::InternalError,
+                 "chmod to 0700");
+        }
+
+    } else {
+        ThrowMsg(Exceptions::InternalError,
+                 "No access to private storage.");
+    }
+}
+
+void TaskFileManipulation::StepCreateShareDir()
+{
+    std::string sharePath = m_context.locations->getShareDir();
+
+    if (euidaccess(sharePath.c_str(), F_OK) != 0) {
+        if(!WrtUtilMakeDir(sharePath, SHARE_MODE)){
+            LogError("Failed to create directory for share");
+            ThrowMsg(Exceptions::InternalError,
+                    "Failed to create directory for share");
+        }
+        // '5000' is default uid, gid for applications.
+        // So installed applications should be launched as process of uid '5000'.
+        // the process can access private directory 'data' of itself.
+        if(chown(sharePath.c_str(),
+                 WEBAPP_DEFAULT_UID,
+                 WEBAPP_DEFAULT_GID) != 0)
+        {
+            ThrowMsg(Exceptions::InternalError,
+                 "Chown to invaild user");
+        }
+    } else if (euidaccess(sharePath.c_str(), W_OK | R_OK | X_OK) == 0) {
+        LogInfo("Share directory already exists.");
+        // Even if share directory already is created, share dircetory
+        // should change owner.
+        if(chown(sharePath.c_str(),
+                 WEBAPP_DEFAULT_UID,
+                 WEBAPP_DEFAULT_GID) != 0)
+        {
+            ThrowMsg(Exceptions::InternalError,
+                 "Chown to invaild user");
+        }
+        if(chmod(sharePath.c_str(), SHARE_MODE) != 0) {
+            ThrowMsg(Exceptions::InternalError,
+                 "chmod to 0700");
+        }
+
+    } else {
+        ThrowMsg(Exceptions::InternalError,
+                 "No access to private storage.");
+    }
+
+}
+
+void TaskFileManipulation::StepRenamePath()
+{
+    std::string instDir;
+
+    if (m_context.widgetConfig.packagingType == PKG_TYPE_HYBRID_WEB_APP) {
+        instDir = m_context.locations->getPackageInstallationDir();
+    } else {
+        instDir = m_context.locations->getSourceDir();
+    }
+
+    LogDebug("Copy file from temp directory to " << instDir);
+    if (!WrtUtilRemove(instDir)) {
+        ThrowMsg(Exceptions::RemovingFolderFailure,
+                "Error occurs during removing existing folder");
+    }
+
+    if (!(rename(m_context.locations->getTemporaryPackageDir().c_str(), instDir.c_str()) == 0)) {
+        ThrowMsg(Exceptions::UnknownError,
+                "Error occurs during renaming widget folder");
+    }
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_RENAME_PATH,
+        "Widget Rename path Finished");
+}
+
+void TaskFileManipulation::StepAbortRenamePath()
+{
+    LogDebug("[Rename Widget Path] Aborting.... (Rename path)");
+    std::string widgetPath;
+    if (m_context.widgetConfig.packagingType != PKG_TYPE_HYBRID_WEB_APP) {
+        widgetPath = m_context.locations->getPackageInstallationDir();
+        if (!WrtUtilRemove(widgetPath)) {
+            ThrowMsg(Exceptions::RemovingFolderFailure,
+                    "Error occurs during removing existing folder");
+        }
+    }
+    LogDebug("Rename widget path sucessful!");
+}
+
+void TaskFileManipulation::StepPrepareExternalDir()
+{
+    LogDebug("Step prepare to install in exernal directory");
+    Try {
+        std::string pkgname =
+            DPL::ToUTF8String(*m_context.widgetConfig.pkgname);
+
+        WidgetInstallToExtSingleton::Instance().initialize(pkgname);
+
+        size_t totalSize =
+            Utils::getFolderSize(m_context.locations->getTemporaryPackageDir());
+
+        int folderSize = (int)(totalSize / (1024 * 1024)) + 1;
+
+        GList *list = NULL;
+        app2ext_dir_details* dirDetail = NULL;
+
+        std::string dirNames[2] = {GLIST_RES_DIR, GLIST_BIN_DIR};
+
+        for (int i = 0; i < 2; i++) {
+            dirDetail = (app2ext_dir_details*) calloc(1,
+                    sizeof(app2ext_dir_details));
+            if (NULL == dirDetail) {
+                ThrowMsg(Exceptions::ErrorExternalInstallingFailure, "error in app2ext");
+            }
+            dirDetail->name = strdup(dirNames[i].c_str());
+            dirDetail->type = APP2EXT_DIR_RO;
+            list = g_list_append(list, dirDetail);
+        }
+
+        if (false == m_context.existingWidgetInfo.isExist) {
+            WidgetInstallToExtSingleton::Instance().preInstallation(list,
+                    folderSize);
+        } else {
+            WidgetInstallToExtSingleton::Instance().preUpgrade(list,
+                    folderSize);
+        }
+        free(dirDetail);
+        g_list_free(list);
+    }
+    Catch (WidgetInstallToExt::Exception::ErrorInstallToExt)
+    {
+        ReThrowMsg(Exceptions::ErrorExternalInstallingFailure, "Error during \
+                create external folder ");
+    }
+}
+
+void TaskFileManipulation::StepInstallToExternal()
+{
+    LogDebug("StepInstallExternal");
+    if (!WrtUtilMakeDir(m_context.locations->getSourceDir())) {
+        ThrowMsg(Exceptions::ErrorExternalInstallingFailure, "To make src \
+                directory failed");
+    }
+
+    LogDebug("Resource move to external storage " <<
+            m_context.locations->getSourceDir());
+    if (!_FolderCopy(m_context.locations->getTemporaryPackageDir(),
+                m_context.locations->getSourceDir()))
+    {
+        ThrowMsg(Exceptions::UnknownError,
+                "Error occurs during renaming widget folder");
+    }
+}
+
+void TaskFileManipulation::StepAbortCreateExternalDir()
+{
+    LogError("Abort StepAbortCreateExternalDir");
+    if (false == m_context.existingWidgetInfo.isExist) {
+        WidgetInstallToExtSingleton::Instance().postInstallation(false);
+    } else {
+        WidgetInstallToExtSingleton::Instance().postUpgrade(false);
+    }
+    WidgetInstallToExtSingleton::Instance().deinitialize();
+}
+} //namespace WidgetInstall
+} //namespace Jobs
diff --git a/src/jobs/widget_install/task_file_manipulation.h b/src/jobs/widget_install/task_file_manipulation.h
new file mode 100644 (file)
index 0000000..e3f615e
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file    task_db_update.h
+ * @author  Lukasz Wrzosek(l.wrzosek@samsung.com)
+ * @version 1.0
+ * @brief   Header file for installer task database updating
+ */
+#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_FILE_MANIPULATION_H
+#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_FILE_MANIPULATION_UPDATE_H
+
+#include <dpl/task.h>
+#include <app2ext_interface.h>
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+class TaskFileManipulation :
+    public DPL::TaskDecl<TaskFileManipulation>
+{
+    InstallerContext& m_context;
+    app2ext_handle *m_extHandle;
+
+    // install internal location
+    void StepCreateDirs();
+    void StepRenamePath();
+    void StepCreatePrivateStorageDir();
+    void StepCreateShareDir();
+
+    void StepAbortRenamePath();
+
+    // install external location
+    void StepPrepareExternalDir();
+    void StepInstallToExternal();
+    void StepFinishExternalInstallation();
+    void StepAbortCreateExternalDir();
+
+  public:
+    TaskFileManipulation(InstallerContext& context);
+};
+} //namespace WidgetInstall
+} //namespace Jobs
+
+#endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_FILE_MANIPULATION_H
diff --git a/src/jobs/widget_install/task_install_ospsvc.cpp b/src/jobs/widget_install/task_install_ospsvc.cpp
new file mode 100644 (file)
index 0000000..150f60f
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    task_install_ospsvc.cpp
+ * @author  Soyoung Kim (sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for installer task  install osp service
+ */
+#include "task_install_ospsvc.h"
+
+#include <unistd.h>
+#include <string>
+
+#include <dpl/log/log.h>
+#include <dpl/errno_string.h>
+#include <dpl/foreach.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/utils/bash_utils.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;
+
+namespace {
+const int MAX_BUF_SIZE = 128;
+const char* OSP_INSTALL_STR = "/usr/etc/package-manager/backend/tpk -iv ";
+}
+
+namespace Jobs {
+namespace WidgetInstall {
+TaskInstallOspsvc::TaskInstallOspsvc(InstallerContext& context) :
+    DPL::TaskDecl<TaskInstallOspsvc>(this),
+    m_context(context)
+{
+    AddStep(&TaskInstallOspsvc::StepInstallOspService);
+}
+
+void TaskInstallOspsvc::StepInstallOspService()
+{
+    LogInfo("Step: installation for osp service");
+
+    std::ostringstream commStr;
+    commStr << OSP_INSTALL_STR << BashUtils::escape_arg(m_context.locations->getPackageInstallationDir());
+    //commStr << " 2>&1";
+    LogDebug("osp install command : " << commStr.str());
+
+    char readBuf[MAX_BUF_SIZE];
+    FILE *fd;
+    fd = popen(commStr.str().c_str(), "r");
+    if (NULL == fd) {
+        LogError("Failed to installtion osp service");
+        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\
+                install osp service");
+    }
+
+    pclose(fd);
+
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_INSTALL_OSPSVC,
+        "Installed Osp servcie");
+}
+} //namespace WidgetInstall
+} //namespace Jobs
diff --git a/src/jobs/widget_install/task_install_ospsvc.h b/src/jobs/widget_install/task_install_ospsvc.h
new file mode 100644 (file)
index 0000000..29d6d80
--- /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.
+ */
+/*
+ * @file       task_install_ospsvc.h
+ * @author     soyoung kim (sy037.kim@samsung.com)
+ * @version    1.0
+ */
+
+#ifndef SRC_JOBS_WIDGET_INSTALL_TASK_INSTALL_OSPSVC_H_
+#define SRC_JOBS_WIDGET_INSTALL_TASK_INSTALL_OSPSVC_H_
+
+#include <dpl/task.h>
+#include <string>
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+
+class TaskInstallOspsvc : public DPL::TaskDecl<TaskInstallOspsvc>
+{
+private:
+    // Installation context
+    InstallerContext &m_context;
+
+    void StepInstallOspService();
+
+    void StepAbortInstall();
+
+    // 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);
+
+  public:
+    explicit TaskInstallOspsvc(InstallerContext &installerContext);
+};
+
+} // namespace WidgetInstall
+} // namespace Jobs
+#endif /* SRC_JOBS_WIDGET_INSTALL_TASK_INSTALL_OSPSVC_H_ */
diff --git a/src/jobs/widget_install/task_manifest_file.cpp b/src/jobs/widget_install/task_manifest_file.cpp
new file mode 100644 (file)
index 0000000..b34b13c
--- /dev/null
@@ -0,0 +1,919 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    task_manifest_file.cpp
+ * @author  Pawel Sikorski (p.sikorski@samgsung.com)
+ * @version
+ * @brief
+ */
+
+//SYSTEM INCLUDES
+#include <string>
+#include <dpl/assert.h>
+#include <dirent.h>
+#include <fstream>
+#include <ail.h>
+
+//WRT INCLUDES
+#include <widget_install/task_manifest_file.h>
+#include <widget_install/job_widget_install.h>
+#include <widget_install/widget_install_errors.h>
+#include <widget_install/widget_install_context.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/log/log.h>
+#include <dpl/file_input.h>
+#include <dpl/errno_string.h>
+#include <dpl/file_output.h>
+#include <dpl/copy.h>
+#include <dpl/exception.h>
+#include <dpl/foreach.h>
+#include <dpl/sstream.h>
+#include <dpl/string.h>
+#include <dpl/optional.h>
+#include <dpl/utils/wrt_utility.h>
+#include <map>
+#include <libxml_utils.h>
+#include <pkgmgr/pkgmgr_parser.h>
+#include <dpl/localization/LanguageTagsProvider.h>
+
+#define DEFAULT_ICON_NAME   "icon.png"
+
+using namespace WrtDB;
+
+namespace {
+typedef std::map<DPL::String, DPL::String> LanguageTagMap;
+
+const char* const ST_TRUE = "true";
+const char* const ST_NODISPLAY = "nodisplay";
+
+LanguageTagMap getLanguageTagMap()
+{
+    LanguageTagMap map;
+
+#define ADD(tag, l_tag) map.insert(std::make_pair(L ## # tag, L ## # l_tag));
+#include "languages.def"
+#undef ADD
+
+    return map;
+}
+
+DPL::OptionalString getLangTag(const DPL::String& tag)
+{
+    static LanguageTagMap TagsMap =
+        getLanguageTagMap();
+
+    DPL::String langTag = tag;
+
+    LogDebug("Trying to map language tag: " << langTag);
+    size_t pos = langTag.find_first_of(L'_');
+    if (pos != DPL::String::npos) {
+        langTag.erase(pos);
+    }
+    DPL::OptionalString ret;
+
+    LanguageTagMap::iterator it = TagsMap.find(langTag);
+    if (it != TagsMap.end()) {
+        ret = it->second;
+    }
+    LogDebug("Mapping IANA Language tag to language tag: " <<
+             langTag << " -> " << ret);
+
+    return ret;
+}
+}
+
+namespace Jobs {
+namespace WidgetInstall {
+
+const char * TaskManifestFile::encoding = "UTF-8";
+
+TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
+    DPL::TaskDecl<TaskManifestFile>(this),
+    m_context(inCont)
+{
+    if (false == m_context.existingWidgetInfo.isExist) {
+        AddStep(&TaskManifestFile::stepCopyIconFiles);
+        AddStep(&TaskManifestFile::stepCreateExecFile);
+        AddStep(&TaskManifestFile::stepGenerateManifest);
+        AddStep(&TaskManifestFile::stepParseManifest);
+        AddStep(&TaskManifestFile::stepFinalize);
+
+        AddAbortStep(&TaskManifestFile::stepAbortParseManifest);
+    } else {
+    // for widget update.
+        AddStep(&TaskManifestFile::stepBackupIconFiles);
+        AddStep(&TaskManifestFile::stepCopyIconFiles);
+        AddStep(&TaskManifestFile::stepGenerateManifest);
+        AddStep(&TaskManifestFile::stepParseUpgradedManifest);
+        AddStep(&TaskManifestFile::stepUpdateFinalize);
+
+        AddAbortStep(&TaskManifestFile::stepAbortIconFiles);
+    }
+}
+
+TaskManifestFile::~TaskManifestFile()
+{
+}
+
+void TaskManifestFile::stepCreateExecFile()
+{
+    std::string exec = m_context.locations->getExecFile();
+    std::string clientExeStr = GlobalConfig::GetWrtClientExec();
+
+    LogInfo("link -s " << clientExeStr << " " << exec);
+    symlink(clientExeStr.c_str(), exec.c_str());
+
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_CREATE_EXECFILE,
+        "Widget execfile creation Finished");
+}
+
+void TaskManifestFile::stepCopyIconFiles()
+{
+    LogDebug("CopyIconFiles");
+
+    //This function copies icon to desktop icon path. For each locale avaliable
+    //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
+
+    std::vector<Locale> generatedLocales;
+
+    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++)
+    {
+        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())
+            {
+                LogDebug("Skipping - has that locale");
+                continue;
+            }
+            else
+            {
+                generatedLocales.push_back(*locale);
+            }
+
+            std::ostringstream sourceFile;
+            std::ostringstream targetFile;
+
+            sourceFile << m_context.locations->getSourceDir() << "/";
+
+            if (!locale->empty()) {
+                sourceFile << "locales/" << *locale << "/";
+            }
+
+            sourceFile << src;
+
+            targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
+            targetFile << getIconTargetFilename(*locale);
+
+
+            if (m_context.widgetConfig.packagingType ==
+                    WrtDB::PKG_TYPE_HOSTED_WEB_APP) {
+                m_context.locations->setIconTargetFilenameForLocale(targetFile.str());
+            }
+
+            LogDebug("Copying icon: " << sourceFile.str() <<
+                     " -> " << targetFile.str());
+
+            icon_list.push_back(targetFile.str());
+
+            Try
+            {
+                DPL::FileInput input(sourceFile.str());
+                DPL::FileOutput output(targetFile.str());
+                DPL::Copy(&input, &output);
+            }
+
+            Catch(DPL::FileInput::Exception::Base)
+            {
+                // Error while opening or closing source file
+                //ReThrowMsg(InstallerException::CopyIconFailed, sourceFile.str());
+                LogError(
+                    "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());
+                LogError(
+                    "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());
+                LogError(
+                    "Copying widget's icon failed. Widget's icon will not be"\
+                    "available from Main Screen");
+            }
+        }
+    }
+
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_COPY_ICONFILE,
+        "Widget iconfile copy Finished");
+}
+
+void TaskManifestFile::stepBackupIconFiles()
+{
+    LogDebug("Backup Icon Files");
+
+    backup_dir << m_context.locations->getPackageInstallationDir();
+    backup_dir << "/" << "backup" << "/";
+
+    backupIconFiles();
+
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_BACKUP_ICONFILE,
+        "New Widget icon file backup Finished");
+}
+
+void TaskManifestFile::stepAbortIconFiles()
+{
+    LogDebug("Abrot Icon Files");
+    FOREACH(it, icon_list)
+    {
+        LogDebug("Remove Update Icon : " << (*it));
+        unlink((*it).c_str());
+    }
+
+    std::ostringstream b_icon_dir;
+    b_icon_dir << backup_dir.str() << "icons";
+
+    std::list<std::string> fileList;
+    getFileList(b_icon_dir.str().c_str(), fileList);
+
+    FOREACH(back_icon, fileList)
+    {
+        std::ostringstream res_file;
+        res_file << GlobalConfig::GetUserWidgetDesktopIconPath();
+        res_file << "/" << (*back_icon);
+
+        std::ostringstream backup_file;
+        backup_file << b_icon_dir.str() << "/" << (*back_icon);
+
+        Try
+        {
+            DPL::FileInput input(backup_file.str());
+            DPL::FileOutput output(res_file.str());
+            DPL::Copy(&input, &output);
+        }
+        Catch(DPL::FileInput::Exception::Base)
+        {
+            LogError("Restoration icon File Failed." << backup_file.str()
+                    << " to " << res_file.str());
+        }
+
+        Catch(DPL::FileOutput::Exception::Base)
+        {
+            LogError("Restoration icon File Failed." << backup_file.str()
+                    << " to " << res_file.str());
+        }
+        Catch(DPL::CopyFailed)
+        {
+            LogError("Restoration icon File Failed." << backup_file.str()
+                    << " to " << res_file.str());
+        }
+    }
+}
+
+void TaskManifestFile::stepUpdateFinalize()
+{
+    commitManifest();
+    LogDebug("Finished Update Desktopfile");
+}
+
+DPL::String TaskManifestFile::getIconTargetFilename(
+        const DPL::String& languageTag) const
+{
+    DPL::OStringStream filename;
+    WidgetPkgName pkgname = m_context.widgetConfig.pkgName;
+
+    filename << DPL::ToUTF8String(pkgname).c_str();
+
+    if (!languageTag.empty()) {
+        DPL::OptionalString tag = getLangTag(languageTag); // translate en -> en_US etc
+        if (tag.IsNull()) { tag = languageTag; }
+        DPL::String locale =
+            LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
+
+       if(locale.empty()) {
+            filename << L"." << languageTag;
+        } else {
+            filename << L"." << locale;
+        }
+    }
+
+    filename << L".png";
+    return filename.str();
+}
+
+void TaskManifestFile::stepFinalize()
+{
+    commitManifest();
+    LogInfo("Finished ManifestFile step");
+}
+
+
+void TaskManifestFile::saveLocalizedKey(std::ofstream &file,
+        const DPL::String& key,
+        const DPL::String& languageTag)
+{
+    DPL::String locale =
+            LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag);
+
+    file << key;
+    if (!locale.empty()) {
+        file << "[" << locale << "]";
+    }
+    file << "=";
+}
+
+void TaskManifestFile::updateAilInfo()
+{
+    // Update ail for desktop
+    std::string cfgPkgname =
+        DPL::ToUTF8String(m_context.widgetConfig.pkgName);
+    const char* pkgname = cfgPkgname.c_str();
+
+    LogDebug("Update ail desktop : " << pkgname );
+    ail_appinfo_h ai = NULL;
+    ail_error_e ret;
+
+    ret = ail_package_get_appinfo(pkgname, &ai);
+    if (ai) {
+        ail_package_destroy_appinfo(ai);
+    }
+
+    if (AIL_ERROR_NO_DATA == ret) {
+        if (ail_desktop_add(pkgname) < 0) {
+            LogWarning("Failed to add ail desktop : " << pkgname);
+        }
+    } else if (AIL_ERROR_OK == ret) {
+        if (ail_desktop_update(pkgname) < 0) {
+            LogWarning("Failed to update ail desktop : " << pkgname);
+        }
+    }
+}
+
+void TaskManifestFile::backupIconFiles()
+{
+    LogInfo("Backup Icon Files");
+
+    std::ostringstream b_icon_dir;
+    b_icon_dir << backup_dir.str() << "icons";
+
+    LogDebug("Create icon backup folder : " << b_icon_dir.str());
+    WrtUtilMakeDir(b_icon_dir.str());
+
+    std::list<std::string> fileList;
+    getFileList(GlobalConfig::GetUserWidgetDesktopIconPath(), fileList);
+    std::string pkgname = DPL::ToUTF8String(m_context.widgetConfig.pkgName);
+
+    FOREACH(it, fileList)
+    {
+        if (0 == (strncmp((*it).c_str(), pkgname.c_str(),
+                        strlen(pkgname.c_str())))) {
+            std::ostringstream icon_file, backup_icon;
+            icon_file << GlobalConfig::GetUserWidgetDesktopIconPath();
+            icon_file << "/" << (*it);
+
+            backup_icon << b_icon_dir.str() << "/" << (*it);
+
+            LogDebug("Backup icon file " << icon_file.str() << " to " <<
+                    backup_icon.str());
+            Try
+            {
+                DPL::FileInput input(icon_file.str());
+                DPL::FileOutput output(backup_icon.str());
+                DPL::Copy(&input, &output);
+            }
+            Catch(DPL::FileInput::Exception::Base)
+            {
+                LogError("Backup Desktop File Failed.");
+                ReThrowMsg(Exceptions::BackupFailed, icon_file.str());
+            }
+
+            Catch(DPL::FileOutput::Exception::Base)
+            {
+                LogError("Backup Desktop File Failed.");
+                ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
+            }
+            Catch(DPL::CopyFailed)
+            {
+                LogError("Backup Desktop File Failed.");
+                ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
+            }
+            unlink((*it).c_str());
+        }
+    }
+}
+
+void TaskManifestFile::getFileList(const char* path,
+        std::list<std::string> &list)
+{
+    DIR* dir = opendir(path);
+    if (!dir) {
+        LogError("icon directory doesn't exist");
+        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);
+        }
+    }while(d_ent);
+    if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
+        LogError("Failed to close dir: " << path << " with error: "
+                << DPL::GetErrnoString());
+    }
+}
+
+void TaskManifestFile::stepGenerateManifest()
+{
+    WidgetPkgName pkgname = m_context.widgetConfig.pkgName;
+    manifest_name = pkgname + L".xml";
+    manifest_file += L"/tmp/" + manifest_name;
+
+    //libxml - init and check
+    LibxmlSingleton::Instance().init();
+
+    writeManifest(manifest_file);
+
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_CREATE_MANIFEST,
+        "Widget Manifest Creation Finished");
+}
+
+void TaskManifestFile::stepParseManifest()
+{
+    int code = pkgmgr_parser_parse_manifest_for_installation(
+            DPL::ToUTF8String(manifest_file).c_str(), NULL);
+
+    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.
+    updateAilInfo();
+
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_CREATE_MANIFEST,
+        "Widget Manifest Parsing Finished");
+    LogDebug("Manifest parsed");
+}
+
+void TaskManifestFile::stepParseUpgradedManifest()
+{
+    int code = pkgmgr_parser_parse_manifest_for_upgrade(
+            DPL::ToUTF8String(manifest_file).c_str(), NULL);
+
+    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.
+    updateAilInfo();
+
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_CREATE_MANIFEST,
+        "Widget Manifest Parsing Finished");
+    LogDebug("Manifest parsed");
+}
+
+void TaskManifestFile::commitManifest()
+{
+    LogDebug("Commiting manifest file : " << manifest_file);
+
+    std::ostringstream destFile;
+    destFile << "/opt/share/packages" << "/"; //TODO constant with path
+    destFile << DPL::ToUTF8String(manifest_name);
+    LogInfo("cp " << manifest_file << " " << destFile.str());
+
+    DPL::FileInput input(DPL::ToUTF8String(manifest_file));
+    DPL::FileOutput output(destFile.str());
+    DPL::Copy(&input, &output);
+    LogDebug("Manifest writen to: " << destFile.str());
+
+    //removing temp file
+    unlink((DPL::ToUTF8String(manifest_file)).c_str());
+    manifest_file = DPL::FromUTF8String(destFile.str().c_str());
+}
+
+void TaskManifestFile::writeManifest(const DPL::String & path)
+{
+    LogDebug("Generating manifest file : " << path);
+    Manifest manifest;
+    UiApplication uiApp;
+
+    setWidgetExecPath(uiApp);
+    setWidgetName(manifest, uiApp);
+    setWidgetIcons(uiApp);
+    setWidgetManifest(manifest);
+    setWidgetOtherInfo(uiApp);
+    setAppServiceInfo(uiApp);
+    setAppControlInfo(uiApp);
+    setAppCategory(uiApp);
+    setLiveBoxInfo(manifest);
+
+    manifest.addUiApplication(uiApp);
+    manifest.generate(path);
+    LogDebug("Manifest file serialized");
+}
+
+void TaskManifestFile::setWidgetExecPath(UiApplication & uiApp)
+{
+    uiApp.setExec(DPL::FromASCIIString(m_context.locations->getExecFile()));
+}
+
+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;
+    //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())
+        {
+            tag = i;
+        }
+        DPL::OptionalString name = localizedData->second.name;
+        generateWidgetName(manifest, uiApp, tag, name, defaultNameSaved);
+
+        //store default locale localized data
+        if(!!defaultLocale && defaultLocale == i)
+        {
+            defaultLocalizedData = *localizedData;
+        }
+    }
+
+    if (!!defaultLocale && !defaultNameSaved)
+    {
+        DPL::OptionalString name = defaultLocalizedData.second.name;
+        generateWidgetName(manifest, uiApp, DPL::OptionalString::Null, name, defaultNameSaved);
+    }
+    //appid
+    WidgetPkgName pkgname = m_context.widgetConfig.pkgName;
+    uiApp.setAppid(pkgname);
+
+
+    //extraid
+    if(!!m_context.widgetConfig.guid) {
+        uiApp.setExtraid(*m_context.widgetConfig.guid);
+    } else {
+        if(!pkgname.empty()) {
+            uiApp.setExtraid(DPL::String(L"http://") + pkgname);
+        }
+    }
+
+    //type
+    uiApp.setType(DPL::FromASCIIString("webapp"));
+    manifest.setType(L"wgt");
+}
+
+void TaskManifestFile::generateWidgetName(Manifest & manifest, UiApplication &uiApp, const DPL::OptionalString& tag, DPL::OptionalString name, bool & defaultNameSaved)
+{
+    if (!!name) {
+        if (!!tag)
+        {
+            DPL::String locale =
+                    LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
+
+            if (!locale.empty()) {
+                uiApp.addLabel(LabelType(*name,*tag));
+            }
+            else
+            {
+                uiApp.addLabel(LabelType(*name));
+                manifest.addLabel(LabelType(*name));
+            }
+        }
+        else
+        {
+            defaultNameSaved = true;
+            uiApp.addLabel(LabelType(*name));
+            manifest.addLabel(LabelType(*name));
+        }
+    }
+}
+
+void TaskManifestFile::setWidgetIcons(UiApplication & uiApp)
+{
+    //TODO this file will need to be updated when user locale preferences
+    //changes.
+    bool defaultIconSaved = false;
+
+    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++)
+    {
+        FOREACH(locale, icon->availableLocales)
+        {
+            if(std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end())
+            {
+                LogDebug("Skipping - has that locale - already in manifest");
+                continue;
+            }
+            else
+            {
+                generatedLocales.push_back(*locale);
+            }
+
+            DPL::OptionalString tag = getLangTag(*locale); // translate en -> en_US etc
+            if (tag.IsNull()) { tag = *locale; }
+
+            generateWidgetIcon(uiApp, tag, *locale, 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)
+{
+    DPL::String locale;
+    if (!!tag)
+    {
+        locale = LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
+    }
+    else
+    {
+        defaultIconSaved = true;
+    }
+
+    DPL::String iconText;
+    iconText += getIconTargetFilename(language);
+
+    if(!locale.empty())
+    {
+        uiApp.addIcon(IconType(iconText, locale));
+    }
+    else
+    {
+        uiApp.addIcon(IconType(iconText));
+    }
+}
+
+void TaskManifestFile::setWidgetManifest(Manifest & manifest)
+{
+    manifest.setPackage(m_context.widgetConfig.pkgName);
+
+    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"");
+    DPL::String href = (!!m_context.widgetConfig.configInfo.authorHref ?
+                            *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));
+}
+
+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)) {
+                uiApp.setNodisplay(true);
+                uiApp.setTaskmanage(false);
+             }
+             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 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;
+
+    if (appServiceList.empty()) {
+        LogInfo("Widget doesn't contain application service");
+        return;
+    }
+
+    // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
+    FOREACH(it, appServiceList) {
+        AppControl appControl;
+        if (!it->m_operation.empty()) {
+            appControl.addOperation(it->m_operation); //TODO: encapsulation?
+        }
+        if (!it->m_scheme.empty()) {
+            appControl.addUri(it->m_scheme);
+        }
+        if (!it->m_mime.empty()) {
+            appControl.addMime(it->m_mime);
+        }
+        uiApp.addAppControl(appControl);
+    }
+}
+
+void TaskManifestFile::setAppControlInfo(UiApplication & uiApp)
+{
+    WrtDB::ConfigParserData::AppControlInfoList appControlList =
+        m_context.widgetConfig.configInfo.appControlList;
+
+    if (appControlList.empty()) {
+        LogInfo("Widget doesn't contain app control");
+        return;
+    }
+
+    // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
+    FOREACH(it, appControlList) {
+        AppControl appControl;
+        if (!it->m_operation.empty()) {
+            appControl.addOperation(it->m_operation); //TODO: encapsulation?
+        }
+        if (!it->m_uriList.empty()) {
+            FOREACH(uri, it->m_uriList) {
+                appControl.addUri(*uri);
+            }
+        }
+        if (!it->m_mimeList.empty()) {
+            FOREACH(mime, it->m_mimeList) {
+                appControl.addMime(*mime);
+            }
+        }
+        uiApp.addAppControl(appControl);
+    }
+}
+
+void TaskManifestFile::setAppCategory(UiApplication &uiApp)
+{
+    WrtDB::ConfigParserData::CategoryList categoryList =
+        m_context.widgetConfig.configInfo.categoryList;
+
+    if (categoryList.empty()) {
+        LogInfo("Widget doesn't contain application category");
+        return;
+    }
+    FOREACH(it, categoryList) {
+        if (!(*it).empty()) {
+            uiApp.addAppCategory(*it);
+        }
+    }
+}
+
+void TaskManifestFile::stepAbortParseManifest()
+{
+    LogError("[Parse Manifest] Abroting....");
+
+    int code = pkgmgr_parser_parse_manifest_for_uninstallation(
+            DPL::ToUTF8String(manifest_file).c_str(), NULL);
+
+    if (0 != code)
+    {
+        LogWarning("Manifest parser error: " << code);
+        ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
+    }
+    int ret = unlink(DPL::ToUTF8String(manifest_file).c_str());
+    if (0 != ret)
+    {
+        LogWarning("No manifest file found: " << manifest_file);
+    }
+}
+
+void TaskManifestFile::setLiveBoxInfo(Manifest& manifest)
+{
+    FOREACH(it, m_context.widgetConfig.configInfo.m_livebox) {
+        LogInfo("setLiveBoxInfo");
+        LiveBoxInfo liveBox;
+        DPL::Optional<WrtDB::ConfigParserData::LiveboxInfo> ConfigInfo = *it;
+        DPL::String pkgname = m_context.widgetConfig.pkgName;
+        size_t found;
+
+        if(ConfigInfo->m_liveboxId != L"") {
+            found = ConfigInfo->m_liveboxId.find_first_of(L".");
+            if(found != std::string::npos) {
+                if(0 == ConfigInfo->m_liveboxId.compare(0, found, pkgname))
+                    liveBox.setLiveboxId(ConfigInfo->m_liveboxId);
+                else {
+                    DPL::String liveboxId =
+                        pkgname+DPL::String(L".")+ConfigInfo->m_liveboxId;
+                    liveBox.setLiveboxId(liveboxId);
+                }
+            } else {
+                DPL::String liveboxId =
+                    pkgname+DPL::String(L".")+ConfigInfo->m_liveboxId;
+                liveBox.setLiveboxId(liveboxId);
+            }
+        }
+
+        if(ConfigInfo->m_primary != L"")
+            liveBox.setPrimary(ConfigInfo->m_primary);
+
+        if(ConfigInfo->m_autoLaunch == L"true")
+            liveBox.setAutoLaunch(pkgname);
+
+        if(ConfigInfo->m_updatePeriod != L"")
+            liveBox.setUpdatePeriod(ConfigInfo->m_updatePeriod);
+
+        if(ConfigInfo->m_label != L"")
+            liveBox.setLabel(ConfigInfo->m_label);
+
+        DPL::String defaultLocale
+            = DPL::FromUTF8String(m_context.locations->getPackageInstallationDir())
+            + DPL::String(L"/res/wgt/");
+
+        if(ConfigInfo->m_icon!=L"") {
+            liveBox.setIcon(defaultLocale+ConfigInfo->m_icon);
+        }
+
+        if (ConfigInfo->m_boxInfo.m_boxSrc.empty() || ConfigInfo->m_boxInfo.m_boxSize.empty()) {
+            LogInfo("Widget doesn't contain box");
+            return;
+        } else {
+            BoxInfoType box;
+            if (!ConfigInfo->m_boxInfo.m_boxSrc.empty()) {
+                if((0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 4, L"http"))
+                        || (0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 5, L"https")))
+                    box.boxSrc = ConfigInfo->m_boxInfo.m_boxSrc;
+                else
+                    box.boxSrc = defaultLocale + ConfigInfo->m_boxInfo.m_boxSrc;
+            }
+
+            std::list<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())
+                    boxSize.second = defaultLocale + boxSize.second;
+                box.boxSize.push_back(boxSize);
+            }
+
+            if (!ConfigInfo->m_boxInfo.m_pdSrc.empty()
+                    && !ConfigInfo->m_boxInfo.m_pdWidth.empty()
+                    && !ConfigInfo->m_boxInfo.m_pdHeight.empty()) {
+                box.pdSrc = defaultLocale + ConfigInfo->m_boxInfo.m_pdSrc;
+                box.pdWidth = ConfigInfo->m_boxInfo.m_pdWidth;
+                box.pdHeight = ConfigInfo->m_boxInfo.m_pdHeight;
+            }
+
+            liveBox.setBox(box);
+        }
+
+        manifest.addLivebox(liveBox);
+    }
+
+}
+
+} //namespace WidgetInstall
+} //namespace Jobs
diff --git a/src/jobs/widget_install/task_manifest_file.h b/src/jobs/widget_install/task_manifest_file.h
new file mode 100755 (executable)
index 0000000..ec9e12b
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    task_manifest_file.h
+ * @author  Pawel Sikorski (p.sikorski@samgsung.com)
+ * @version
+ * @brief
+ */
+
+#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_DESKTOP_FILE_H
+#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_DESKTOP_FILE_H
+
+//SYSTEM INCLUDES
+#include <fstream>
+
+//WRT INCLUDES
+#include <dpl/task.h>
+#include <dpl/localization/localization_utils.h>
+
+#include <libxml2/libxml/xmlwriter.h>
+
+#include <libxml_utils.h>
+#include <widget_install/manifest.h>
+#include <dpl/localization/localization_utils.h>
+
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+class TaskManifestFile :
+    public DPL::TaskDecl<TaskManifestFile>
+{
+  public:
+
+    DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+    DECLARE_EXCEPTION_TYPE(Base, ManifestValidationError)
+    DECLARE_EXCEPTION_TYPE(Base, ManifestParsingError)
+
+    TaskManifestFile(InstallerContext &inCont);
+    virtual ~TaskManifestFile();
+
+  private:
+    //context data
+    InstallerContext &m_context;
+
+    //TODO stepAbort
+    //steps
+    void stepCreateExecFile();
+    void stepFinalize();
+    void stepCopyIconFiles();
+    void stepGenerateManifest();
+    void stepParseManifest();
+    void stepParseUpgradedManifest();
+
+    void stepAbortParseManifest();
+
+    //For widget update
+    void stepBackupIconFiles();
+    void stepUpdateFinalize();
+
+    void stepAbortIconFiles();
+
+    //private data
+    std::list<std::string> icon_list; //TODO: this should be registered as external files
+    std::ostringstream backup_dir;
+    xmlTextWriterPtr writer;
+    DPL::String manifest_name;
+    DPL::String manifest_file;
+
+    //private methods
+    void updateAilInfo();
+
+    void writeManifest(const DPL::String & path);
+    void commitManifest();
+
+    void setWidgetExecPath(UiApplication & uiApp);
+    void setWidgetName(Manifest & manifest, UiApplication & uiApp);
+    void setWidgetIcons(UiApplication & uiApp);
+    void setWidgetManifest(Manifest & manifest);
+    void setWidgetOtherInfo(UiApplication & uiApp);
+    /*  please use AppControl. this function will be removed. */
+    void setAppServiceInfo(UiApplication & uiApp);
+    void setAppControlInfo(UiApplication & uiApp);
+    void setAppCategory(UiApplication & uiApp);
+    void setLiveBoxInfo(Manifest& manifest);
+
+    void generateWidgetName(Manifest & manifest, UiApplication &uiApp, const DPL::OptionalString& tag, DPL::OptionalString name, bool & defaultNameSaved);
+    void generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag, const DPL::String& language, bool & defaultIconSaved);
+
+    //for widget update
+    void backupIconFiles();
+    void getFileList(const char* path, std::list<std::string> &list);
+    DPL::String getIconTargetFilename(const DPL::String& languageTag) const;
+
+    static void saveLocalizedKey(std::ofstream &file,
+            const DPL::String& key,
+            const DPL::String& languageTag);
+
+    static const char * encoding;
+
+};
+} //namespace WidgetInstall
+} //namespace Jobs
+
+#endif /* INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_DESKTOP_FILE_H */
diff --git a/src/jobs/widget_install/task_plugins_copy.cpp b/src/jobs/widget_install/task_plugins_copy.cpp
new file mode 100644 (file)
index 0000000..528f12e
--- /dev/null
@@ -0,0 +1,195 @@
+/*
+ * 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    task_plugin_copy.cpp
+ * @author  Marcin Kaminski (marcin.ka@samsung.com)
+ * @version 1.0
+ * @brief   Copying plugins delivered in widget package.
+ */
+
+#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_context.h>
+#include <widget_install/widget_install_errors.h>
+#include <dpl/exception.h>
+/* Headers needed for listing directories */
+#include <sys/stat.h>
+#include <dirent.h>
+/* Installation expceptions support */
+#include <dpl/exception.h>
+#include <cerrno>
+
+/* wrt-installer has to copy plugins for ARM architecture
+ * when running on target or for i586 architecture if launched
+ * on SDK emulator. */
+#ifdef __arm__
+const std::string plugins_dir = "arm";
+#else
+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;
+}
+
+namespace Jobs {
+namespace WidgetInstall {
+
+TaskPluginsCopy::TaskPluginsCopy(InstallerContext& context) :
+    DPL::TaskDecl<TaskPluginsCopy>(this),
+    m_context(context)
+{
+    LogDebug("Starting widget plugins copy task");
+    AddStep(&TaskPluginsCopy::StepFindPlugins);
+    AddStep(&TaskPluginsCopy::StepCopyPlugins);
+    AddStep(&TaskPluginsCopy::StepCopyingFinished);
+    LogDebug("Widget plugins copy task ended");
+    m_npsource = m_context.locations->getSourceDir() + PackagePluginsDir
+            + plugins_dir;
+    m_npdestination = m_context.locations->getPackageInstallationDir()
+            + InstallationPluginsDir;
+}
+
+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");
+        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) {
+        LogError("Unable to open plugins directory");
+        ThrowMsg(Exceptions::InternalError, "Unable to read plugins directory");
+    }
+    std::string tempname;
+    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");
+            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) {
+                LogError("Directory detected instead of plugin file: "
+                        << 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());
+                }
+                ThrowMsg(Exceptions::PluginsSubdirectory,
+                        "Subdirectories inside plugins directory are not supported");
+            }
+            else {
+                continue;
+            }
+        }
+
+        tempname = std::string(entry->d_name);
+        /* Check whether file extension is ".so" */
+        if(tempname.compare(tempname.size()-ext.size(), ext.size(), ext) == 0) {
+            /* Plugin file found */
+            LogDebug("Plugin file found: " <<tempname);
+            m_nplugins.push_back(tempname);
+        }
+        else {
+            /* Non-.so file found in plugins directory- skipping */
+            LogWarning("Non-plugin file found: " <<tempname);
+        }
+    }
+    if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
+        LogError("Failed to close dir: " << m_npsource << " with error: "
+                << DPL::GetErrnoString());
+    }
+    /* If no .so files found (list is empty) abort taks*/
+    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("Plugins finding step ended");
+}
+
+void TaskPluginsCopy::StepCopyPlugins()
+{
+    LogDebug("Starting plugins copying step");
+    std::string source;
+    std::string destination;
+
+    /* Create new directory for plugins (data/.netscape/plugins/) */
+    LogDebug("Creating destination plugin directory");
+    if(!WrtUtilMakeDir(m_npdestination, InstallationPluginsDirMode)){
+        LogError("Failed to create directory for plugins");
+        ThrowMsg(Exceptions::InternalError, "Failed to create directory for plugins");
+    }
+
+    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++) {
+        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 <<")");
+            ThrowMsg(Exceptions::InternalError, "Failed to copy plugin file");
+        }
+    }
+
+    /* Remove last part of path in source directory path
+     * (that is "arm" or "i586" depending on architecture) */
+    size_t position = m_npsource.find_last_of('/');
+    source = m_npsource.substr(0, position);
+    LogDebug("Removing unnecessary directory: " << source);
+    /* Remove source directory with plugins (possibly for multiple
+     * architectures). */
+    if(!WrtUtilRemove(source)){
+        LogError("Failed to plugins source remove directory");
+        ThrowMsg(Exceptions::InternalError, "Failed to plugins source remove directory");
+    }
+    LogDebug("Plugins copying step ended");
+}
+
+void TaskPluginsCopy::StepCopyingFinished()
+{
+    LogDebug("Plugins copy task finished");
+}
+
+} //namespace WidgetInstall
+} //namespace Jobs
diff --git a/src/jobs/widget_install/task_plugins_copy.h b/src/jobs/widget_install/task_plugins_copy.h
new file mode 100644 (file)
index 0000000..3f3a205
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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    task_plugin_copy.h
+ * @author  Marcin Kaminski (marcin.ka@samsung.com)
+ * @version 1.0
+ * @brief   Copying plugins delivered in widget package.
+ */
+
+#ifndef WRT_INSTALLER_SRC_JOBS_WIDGET_INSTALL_TASK_PLUGINS_COPY_H
+#define WRT_INSTALLER_SRC_JOBS_WIDGET_INSTALL_TASK_PLUGINS_COPY_H
+
+class InstallerContext;
+
+#include <string>
+#include <dpl/task.h>
+#include <dpl/string.h>
+#include <list>
+
+namespace Jobs {
+namespace WidgetInstall {
+class TaskPluginsCopy : public DPL::TaskDecl<TaskPluginsCopy>
+{
+public:
+    TaskPluginsCopy(InstallerContext &context);
+private:
+    /* Widget installer context */
+    InstallerContext &m_context;
+    /* Path to plugins directory in unpacked widget*/
+    std::string m_npsource;
+    /* Path to plugins destination (install) directory */
+    std::string m_npdestination;
+    /* List of found .so files to copy*/
+    std::list<std::string> m_nplugins;
+
+    /* Plugins copying task steps. */
+    void StepFindPlugins();
+    void StepCopyPlugins();
+    void StepCopyingFinished();
+};
+} //namespace WidgetInstall
+} //namespace Jobs
+
+#endif /* WRT_INSTALLER_SRC_JOBS_WIDGET_INSTALL_TASK_PLUGINS_COPY_H */
diff --git a/src/jobs/widget_install/task_prepare_files.cpp b/src/jobs/widget_install/task_prepare_files.cpp
new file mode 100644 (file)
index 0000000..9395094
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file       task_generate_config.cpp
+ * @author     Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version    1.0
+ */
+
+#include "task_prepare_files.h"
+#include <memory>
+#include <string>
+#include <iostream>
+#include <dpl/file_output.h>
+#include <dpl/file_input.h>
+#include <dpl/copy.h>
+#include <dpl/log/log.h>
+#include <dpl/wrt-dao-ro/feature_dao_read_only.h>
+#include <dpl/foreach.h>
+#include <widget_install/widget_install_context.h>
+#include <widget_install_errors.h>
+#include <task_commons.h>
+
+namespace Jobs {
+namespace WidgetInstall {
+
+TaskPrepareFiles::TaskPrepareFiles(InstallerContext &installerContext) :
+    DPL::TaskDecl<TaskPrepareFiles>(this),
+    m_installerContext(installerContext)
+{
+    // Install steps
+    AddStep(&TaskPrepareFiles::StepCopyFiles);
+}
+
+void TaskPrepareFiles::CopyFile(const std::string& source)
+{
+    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 );
+    }
+    std::string target = m_installerContext.locations->getTemporaryPackageDir() + '/' + filename;
+    LogDebug("source " << source);
+    LogDebug("target " << target);
+
+    Try
+    {
+        DPL::FileInput input(source);
+        DPL::FileOutput output(target);
+        DPL::Copy(&input, &output);
+    }
+    Catch(DPL::FileInput::Exception::Base)
+    {
+        LogError("File input error");
+        // Error while opening or closing source file
+        ReThrowMsg(Exceptions::CopyIconFailed, source);
+    }
+    Catch(DPL::FileOutput::Exception::Base)
+    {
+        LogError("File output error");
+        // Error while opening or closing target file
+        ReThrowMsg(Exceptions::CopyIconFailed, target);
+    }
+    Catch(DPL::CopyFailed)
+    {
+        LogError("File copy error");
+        // Error while copying
+        ReThrowMsg(Exceptions::CopyIconFailed, target);
+    }
+}
+
+void TaskPrepareFiles::StepCopyFiles()
+{
+    CopyFile(m_installerContext.locations->getWidgetSource());
+
+    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);
+    }
+
+    LogDebug("Icons copy...");
+    FOREACH(it, m_installerContext.widgetConfig.configInfo.iconsList) {
+        std::ostringstream os;
+        LogDebug("Coping: " << sourceDir << DPL::ToUTF8String(it->src));
+        os << sourceDir << DPL::ToUTF8String(it->src);
+        CopyFile(os.str());
+    }
+}
+
+} // namespace WidgetInstall
+} // namespace Jobs
diff --git a/src/jobs/widget_install/task_prepare_files.h b/src/jobs/widget_install/task_prepare_files.h
new file mode 100644 (file)
index 0000000..7db10cf
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file       task_prepare_files.h
+ * @author     Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version    1.0
+ */
+
+#ifndef SRC_JOBS_WIDGET_INSTALL_TASK_PREPARE_FILES_H_
+#define SRC_JOBS_WIDGET_INSTALL_TASK_PREPARE_FILES_H_
+
+#include <dpl/task.h>
+#include <string>
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+
+class TaskPrepareFiles : public DPL::TaskDecl<TaskPrepareFiles>
+{
+private:
+    // Installation context
+    InstallerContext &m_installerContext;
+
+    void CopyFile(const std::string& source);
+
+    // Steps
+    void StepCopyFiles();
+
+  public:
+    explicit TaskPrepareFiles(InstallerContext &installerContext);
+};
+
+} // namespace WidgetInstall
+} // namespace Jobs
+#endif /* SRC_JOBS_WIDGET_INSTALL_TASK_PREPARE_FILES_H_ */
diff --git a/src/jobs/widget_install/task_recovery.cpp b/src/jobs/widget_install/task_recovery.cpp
new file mode 100644 (file)
index 0000000..7daba5e
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    task_recovery.cpp
+ * @author  Soyoung Kim (sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for installer task recovery
+ */
+#include "task_recovery.h"
+
+#include <pwd.h>
+#include <grp.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <string>
+#include <ail.h>
+
+#include <dpl/log/log.h>
+#include <dpl/errno_string.h>
+#include <dpl/foreach.h>
+
+#include <dpl/wrt-dao-ro/widget_config.h>
+#include <dpl/utils/wrt_utility.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;
+
+namespace Jobs {
+namespace WidgetInstall {
+TaskRecovery::TaskRecovery(InstallerContext& context) :
+    DPL::TaskDecl<TaskRecovery>(this),
+    m_context(context)
+{
+    AddStep(&TaskRecovery::StepCreateCheckFile);
+}
+
+void TaskRecovery::StepCreateCheckFile()
+{
+    LogInfo("Step: create information file for recovery");
+
+    size_t pos = m_context.locations->getWidgetSource().rfind("/");
+    std::ostringstream infoPath;
+    infoPath << GlobalConfig::GetTempInstallInfoPath();
+    infoPath << "/";
+    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);
+            ThrowMsg(Exceptions::InternalError, "Fail to fsync for recovery.");
+        }
+        fclose(temp);
+
+        m_context.installInfo = infoPath.str();
+
+        LogDebug("Create file : " << m_context.installInfo);
+    } else {
+        ThrowMsg(Exceptions::InternalError, "Fail to create file for recovery.");
+    }
+
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_CHECK_FILE,
+        "Create information file for recovery");
+}
+} //namespace WidgetInstall
+} //namespace Jobs
diff --git a/src/jobs/widget_install/task_recovery.h b/src/jobs/widget_install/task_recovery.h
new file mode 100644 (file)
index 0000000..5a5fd54
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file       task_recovery.h
+ * @author     soyoung kim (sy037.kim@samsung.com)
+ * @version    1.0
+ */
+
+#ifndef SRC_JOBS_WIDGET_INSTALL_TASK_RECOVERY_FILES_H_
+#define SRC_JOBS_WIDGET_INSTALL_TASK_RECOVERY_FILES_H_
+
+#include <dpl/task.h>
+#include <string>
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+
+class TaskRecovery : public DPL::TaskDecl<TaskRecovery>
+{
+private:
+    // Installation context
+    InstallerContext &m_context;
+
+    void StepCreateCheckFile();
+
+  public:
+    explicit TaskRecovery(InstallerContext &installerContext);
+};
+
+} // namespace WidgetInstall
+} // namespace Jobs
+#endif /* SRC_JOBS_WIDGET_INSTALL_TASK_RECOVERY_FILES_H_ */
diff --git a/src/jobs/widget_install/task_remove_backup.cpp b/src/jobs/widget_install/task_remove_backup.cpp
new file mode 100644 (file)
index 0000000..bcf7317
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    task_remove_backup.cpp
+ * @author  Soyoung kim(sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for installer task backup files remove
+ */
+#include <widget_install/task_remove_backup.h>
+
+#include <sys/stat.h>
+#include <string>
+#include <sstream>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/foreach.h>
+#include <dpl/log/log.h>
+#include <dpl/assert.h>
+#include <dpl/utils/wrt_utility.h>
+#include <widget_install/job_widget_install.h>
+#include <widget_install/widget_install_errors.h>
+#include <widget_install/widget_install_context.h>
+
+using namespace WrtDB;
+
+namespace Jobs {
+namespace WidgetInstall {
+TaskRemoveBackupFiles::TaskRemoveBackupFiles(InstallerContext& context) :
+    DPL::TaskDecl<TaskRemoveBackupFiles>(this),
+    m_context(context)
+{
+    AddStep(&TaskRemoveBackupFiles::StepRemoveBackupFiles);
+}
+
+void TaskRemoveBackupFiles::StepRemoveBackupFiles()
+{
+    std::ostringstream backupDir;
+    backupDir << m_context.locations->getBackupDir();
+
+    if (WrtUtilRemove(backupDir.str())) {
+        LogDebug("Success to remove backup files : " << backupDir.str());
+    } else {
+        LogError("Failed to remove backup directory : " << backupDir.str());
+        ThrowMsg(Exceptions::RemoveBackupFailed,
+                 "Error occurs during removing existing folder");
+    }
+
+    std::string tmp = m_context.locations->getTemporaryPackageDir();
+    if (WrtUtilRemove(tmp)) {
+        LogDebug("Success to remove temp directory : " << tmp);
+    } else {
+        LogError("Failed to remove temp directory : " << tmp);
+        ThrowMsg(Exceptions::RemoveBackupFailed,
+                 "Error occurs during removing existing folder");
+    }
+
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_REMOVE_BACKUP_FILE,
+        "Backup widget file delete Finished");
+}
+
+} //namespace WidgetInstall
+} //namespace Jobs
diff --git a/src/jobs/widget_install/task_remove_backup.h b/src/jobs/widget_install/task_remove_backup.h
new file mode 100644 (file)
index 0000000..b12cec7
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file    task_remove_backup.h
+ * @author  Soyoung kim(sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief   Header file for installer task backup files remove
+ */
+#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_REMOVE_BACKUP_FILES_H
+#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_REMOVE_BACKUP_FILES_H
+
+#include <dpl/task.h>
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+class TaskRemoveBackupFiles:
+    public DPL::TaskDecl<TaskRemoveBackupFiles>
+{
+  private:
+    InstallerContext& m_context;
+
+    void StepRemoveBackupFiles();
+
+  public:
+    TaskRemoveBackupFiles(InstallerContext& context);
+};
+} //namespace WidgetInstall
+} //namespace Jobs
+
+#endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_REMOVE_BACKUP_FILES_H
index f8e679c..b468d3b 100644 (file)
@@ -46,18 +46,22 @@ void TaskSmack::Step()
 #ifdef WRT_SMACK_ENABLED
     std::stringstream devcaps;
     FOREACH(it, m_context.staticPermittedDevCaps) {
-      std::string utf8 = DPL::ToUTF8String(*it);
-      if (it != m_context.staticPermittedDevCaps.begin())
-          devcaps << ",";
-      devcaps << utf8;
+        if (it->second) {
+            std::string utf8 = DPL::ToUTF8String(it->first);
+            if (it != m_context.staticPermittedDevCaps.begin())
+                devcaps << ",";
+            devcaps << utf8;
+        }
     }
-    DPL::OptionalString pkgName = m_context.widgetConfig.Pkgname;
-    Assert(!pkgName.IsNull() && "widget doesn't have a pkg name");
+    WidgetPkgName pkgName = m_context.widgetConfig.pkgName;
     int result = handle_access_control_conf_forWAC(
-                     DPL::ToUTF8String(*pkgName).c_str(),
+                     DPL::ToUTF8String(pkgName).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");
 #endif
 }
 
index e4ba39a..8d87e04 100644 (file)
@@ -24,7 +24,6 @@
 
 #include <dpl/task.h>
 #include <dpl/event/inter_context_delegate.h>
-#include <dpl/ace/PolicyResult.h>
 
 class InstallerContext;
 
index 1da1176..fb084f6 100644 (file)
 #include <widget_install/task_unzip.h>
 #include <widget_install/widget_install_errors.h>
 #include <widget_install/widget_install_context.h>
-#include <dpl/wrt-dao-ro/global_config.h>
+#include <widget_install/job_widget_install.h>
 #include <dpl/log/log.h>
 #include <dpl/copy.h>
 #include <dpl/file_output.h>
 #include <dpl/abstract_waitable_input_adapter.h>
-#include <dpl/errno_string.h>
-#include <unistd.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <task_commons.h>
 #include <sys/stat.h>
-#include <sys/time.h>
-#include <errno.h>
-#include <ftw.h>
-#include <dpl/utils/file_utils.h>
 
 using namespace WrtDB;
 
-namespace // anonymous
-{
-const char * const TEMPORARY_PATH_POSTFIX = "temp";
-const mode_t TEMPORARY_PATH_MODE = 0775;
-
+namespace {
 struct PathAndFilePair
 {
     std::string path;
@@ -69,31 +61,7 @@ PathAndFilePair SplitFileAndPath(const std::string &filePath)
                                            position),
                            filePath.substr(position + 1));
 }
-
-static int lambdaDeleteFile(const char *fpath,
-        const struct stat *sb,
-        int tflag,
-        struct FTW *ftwbuf)
-{
-    (void)sb;
-    (void)ftwbuf;
-
-    switch (tflag) {
-    case FTW_D:
-    case FTW_DNR:
-    case FTW_DP:
-        LogInfo("Removing old temporary directory" << fpath);
-        return rmdir(fpath);
-        break;
-    default:
-        LogInfo("Unlinking old temporary file" << fpath);
-        return unlink(fpath);
-        break;
-    }
-
-    return 0;
 }
-} // namespace anonymous
 
 namespace Jobs {
 namespace WidgetInstall {
@@ -102,12 +70,9 @@ TaskUnzip::TaskUnzip(InstallerContext &installerContext) :
     m_installerContext(installerContext)
 {
     // Install steps
-    AddStep(&TaskUnzip::StepCreateTempPath);
     AddStep(&TaskUnzip::StepUnzipPrepare);
     AddStep(&TaskUnzip::StepUnzipProgress);
     AddStep(&TaskUnzip::StepUnzipFinished);
-
-    AddAbortStep(&TaskUnzip::StepAbort);
 }
 
 void TaskUnzip::ExtractFile(DPL::ZipInput::File *input,
@@ -130,62 +95,18 @@ void TaskUnzip::ExtractFile(DPL::ZipInput::File *input,
     }
 }
 
-void TaskUnzip::StepCreateTempPath()
-{
-    LogInfo("Step: Creating temporary path");
-
-    // Temporary path
-    std::ostringstream tempPathBuilder;
-
-    tempPathBuilder << GlobalConfig::GetUserInstalledWidgetPath();
-    tempPathBuilder << "/";
-    tempPathBuilder << "widget";
-    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;
-
-    // FIXME: what if there are more then maxDepth recursive directories
-    static const int maxDepth = 1024;
-    if (stat(tempPath.c_str(), &fileInfo) == 0) {
-        int error = nftw(
-                tempPath.c_str(), lambdaDeleteFile, maxDepth, FTW_DEPTH);
-
-        if (error == -1) {
-            ThrowMsg(DPL::CommonException::InternalError,
-                     DPL::GetErrnoString());
-        }
-    }
-    // Create new path
-    FileUtils::MakePath(tempPath, TEMPORARY_PATH_MODE);
-
-    // Step succedded, save temporary widget path
-    m_installerContext.tempWidgetPath = tempPath;
-    m_installerContext.unzipStarted = true;
-}
-
 void TaskUnzip::StepUnzipPrepare()
 {
     LogInfo("Prepare to unzip...");
 
     Try
     {
-        m_zip.Reset(new DPL::ZipInput(m_installerContext.widgetFilePath));
+        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.widgetFilePath);
+            ThrowMsg(Exceptions::ZipEmpty, m_installerContext.locations->getWidgetSource());
         }
 
         // Set iterator to first file
@@ -193,7 +114,11 @@ void TaskUnzip::StepUnzipPrepare()
     }
     Catch(DPL::ZipInput::Exception::OpenFailed)
     {
-        ReThrowMsg(Exceptions::OpenZipFailed, m_installerContext.widgetFilePath);
+        ReThrowMsg(Exceptions::OpenZipFailed, m_installerContext.locations->getWidgetSource());
+    }
+    Catch(DPL::ZipInput::Exception::SeekFileFailed)
+    {
+        ThrowMsg(Exceptions::ExtractFileFailed,"m_installerContext.locations->getWidgetSource()");
     }
 }
 
@@ -213,16 +138,16 @@ void TaskUnzip::StepUnzipProgress()
 
     if (fileName[fileName.size() - 1] == '/') {
         // This is path
-        std::string newPath = m_installerContext.tempWidgetPath + "/" +
+        std::string newPath = m_installerContext.locations->getTemporaryPackageDir() + "/" +
             fileName.substr(0, fileName.size() - 1);
         LogPedantic("Path to extract: " << newPath);
 
         // Create path in case of it is empty
-        FileUtils::MakePath(newPath, TEMPORARY_PATH_MODE);
+        createTempPath(newPath);
     } else {
         // This is regular file
         std::string fileExtractPath =
-            m_installerContext.tempWidgetPath + "/" + fileName;
+            m_installerContext.locations->getTemporaryPackageDir() + "/" + fileName;
 
         LogPedantic("File to extract: " << fileExtractPath);
 
@@ -234,16 +159,16 @@ void TaskUnzip::StepUnzipProgress()
                     " : " << pathAndFile.file);
 
         // First, ensure that path exists
-        FileUtils::MakePath(pathAndFile.path, TEMPORARY_PATH_MODE);
+        createTempPath(pathAndFile.path);
 
         Try
         {
             // Open file
-            DPL::ScopedPtr<DPL::ZipInput::File> file(
+            std::unique_ptr<DPL::ZipInput::File> file(
                 m_zip->OpenFile(fileName));
 
             // Extract single file
-            ExtractFile(file.Get(), fileExtractPath);
+            ExtractFile(file.get(), fileExtractPath);
         }
         Catch(DPL::ZipInput::Exception::OpenFileFailed)
         {
@@ -257,30 +182,20 @@ void TaskUnzip::StepUnzipProgress()
     } else {
         SwitchToStep(&TaskUnzip::StepUnzipProgress);
     }
+
+    m_installerContext.job->UpdateProgress(
+        InstallerContext::INSTALL_UNZIP_FILES,
+        "Unzip widget files to temporary directory");
 }
 
 void TaskUnzip::StepUnzipFinished()
 {
     // Unzip finished, close internal structures
-    m_zip.Reset();
-
-    m_installerContext.unzipFinished = true;
+    m_zip.reset();
 
     // Done
     LogInfo("Unzip finished");
 }
 
-void TaskUnzip::StepAbort()
-{
-    LogError("[Unzip Task] Aborting... (removing temporary dir: " <<
-             m_installerContext.tempWidgetPath << " )");
-
-    static const int maxDepth = 1024;
-    struct stat fileInfo;
-    if (stat(m_installerContext.tempWidgetPath.c_str(), &fileInfo) == 0) {
-        nftw(m_installerContext.tempWidgetPath.c_str(),
-             lambdaDeleteFile, maxDepth, FTW_DEPTH);
-    }
-}
 } //namespace WidgetInstall
 } //namespace Jobs
index 3b0de40..3962297 100644 (file)
 #ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_UNZIP_H
 #define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_UNZIP_H
 
+#include <string>
+#include <memory>
+
 #include <dpl/zip_input.h>
-#include <dpl/scoped_ptr.h>
 #include <dpl/task.h>
-#include <string>
+#include <dpl/encryption/resource_encryption.h>
 
 class InstallerContext;
 
@@ -39,19 +41,20 @@ class TaskUnzip :
     InstallerContext &m_installerContext;
 
     // Unzip state
-    DPL::ScopedPtr<DPL::ZipInput> m_zip;
+    std::unique_ptr<DPL::ZipInput> m_zip;
     DPL::ZipInput::const_iterator m_zipIterator;
 
+    WRTEncryptor::ResourceEncryptor *m_resEnc;
+
     void ExtractFile(DPL::ZipInput::File *input,
             const std::string &destFileName);
 
-    // Steps
-    void StepCreateTempPath();
+    void EncryptionFile(const std::string &fileName);
 
+    // Steps
     void StepUnzipPrepare();
     void StepUnzipProgress();
     void StepUnzipFinished();
-    void StepAbort();
 
   public:
     TaskUnzip(InstallerContext &installerContext);
diff --git a/src/jobs/widget_install/task_update_files.cpp b/src/jobs/widget_install/task_update_files.cpp
new file mode 100644 (file)
index 0000000..30589a9
--- /dev/null
@@ -0,0 +1,284 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file    task_update_files.cpp
+ * @author  Soyoung Kim (sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for installer task update files
+ */
+
+#include <utility>
+#include <vector>
+#include <string>
+#include <algorithm>
+#include <sys/stat.h>
+#include <dirent.h>
+
+#include <widget_install/task_update_files.h>
+#include <dpl/assert.h>
+#include <dpl/log/log.h>
+#include <dpl/foreach.h>
+#include <dpl/utils/wrt_utility.h>
+
+#include <widget_install/widget_install_context.h>
+#include <widget_install/widget_install_errors.h>
+#include <widget_install/job_widget_install.h>
+
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/exception.h>
+#include <dpl/errno_string.h>
+
+using namespace WrtDB;
+
+namespace {
+
+inline const char* GetWidgetBackupDirPath()
+{
+    return "backup";
+}
+}
+
+namespace Jobs {
+namespace WidgetInstall {
+
+TaskUpdateFiles::TaskUpdateFiles(InstallerContext& context) :
+    DPL::TaskDecl<TaskUpdateFiles>(this),
+    m_context(context)
+{
+    AddStep(&TaskUpdateFiles::StepCreateBackupFolder);
+    AddStep(&TaskUpdateFiles::StepResourceFilesBackup);
+    AddStep(&TaskUpdateFiles::StepExecFileBackup);
+
+    AddAbortStep(&TaskUpdateFiles::StepAbortCreateBackupFolder);
+    AddAbortStep(&TaskUpdateFiles::StepAbortExecFileBackup);
+    AddAbortStep(&TaskUpdateFiles::StepAbortResourceFilesBackup);
+}
+
+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 \
+                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 \
+                directory.");
+    }
+
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_CREATE_BACKUP_DIR,
+        "Backup directory created for update");
+}
+
+void TaskUpdateFiles::ReadDirList(std::string dirPath, ExistFileList &list,
+        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 \
+                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");
+            }
+
+            if (S_ISDIR(statInfo.st_mode)) {
+                if(strcmp(dirent->d_name, ".") == 0 || strcmp(dirent->d_name,
+                            "..") == 0) {
+                    continue;
+                }
+                ReadDirList(absFileName, list, subLen);
+            }
+
+            list.insert(absFileName.substr(subLen));
+        }
+    }
+    while(dirent);
+    //closing the directory
+    if (-1 == TEMP_FAILURE_RETRY(closedir(pkgDir))) {
+        LogError("Failed to close dir: " << dirPath << " with error: "
+                << DPL::GetErrnoString());
+    }
+}
+
+void TaskUpdateFiles::StepResourceFilesBackup()
+{
+    LogDebug("StepCopyFiles");
+
+    ExistFileList resList;
+    ExistFileList tempList;
+
+    std::string pkgSrc = m_context.locations->getSourceDir();
+    ReadDirList(pkgSrc, resList, strlen(pkgSrc.c_str())+1);
+
+
+    std::string tempSrc = m_context.locations->getTemporaryPackageDir();
+    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);
+
+        if (res != resList.end()) {
+            std::string backupFile = m_context.locations->getBackupSourceDir() +
+                    "/"+ (*it);
+
+            struct stat sInfo;
+            if (stat(resFile.c_str(), &sInfo) != 0) {
+                ThrowMsg(Exceptions::InternalError, "Error occurs read file");
+            }
+
+            if (S_ISDIR(sInfo.st_mode)) {
+                LogDebug(resFile << " is a directory. so create a folder : " <<
+                        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 \
+                            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 \
+                            rename file");
+                }
+                LogDebug("copy : " << newFile << " to " << resFile);
+            }
+            resList.erase(res);
+        } else {
+            if ((rename(newFile.c_str(), resFile.c_str())) != 0) {
+                LogError("Failed to rename " << newFile << " to " << resFile);
+                ThrowMsg(Exceptions::BackupFailed, "Error occurs during \
+                        rename file");
+            }
+            LogDebug("only copy : " << newFile << " to " << resFile);
+        }
+    }
+
+    if (resList.empty() != 0) {
+        FOREACH(remain, resList) {
+            std::string pkgFile = pkgSrc + "/" + (*remain);
+            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 \
+                        rename file");
+            }
+            LogDebug("only backup : " << pkgFile << " to " << backFile);
+        }
+    }
+
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_BACKUP_RES_FILES,
+        "Backup resource file for update");
+}
+
+void TaskUpdateFiles::StepExecFileBackup()
+{
+    std::string execFile = m_context.locations->getExecFile();
+
+    LogDebug(" source : " << execFile);
+
+    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 \
+                rename file");
+    }
+    LogDebug("Backup : " << execFile << " to " << tempSource);
+
+    std::string clientPath = GlobalConfig::GetWrtClientExec();
+
+    LogInfo("link -s " << clientPath << " " << execFile);
+    symlink(clientPath.c_str(), execFile.c_str());
+
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_BACKUP_EXEC,
+        "Backup execution file for update");
+}
+
+void TaskUpdateFiles::StepAbortResourceFilesBackup()
+{
+    LogDebug("StepAbortCopyFiles");
+    std::string srcPath = m_context.locations->getSourceDir();
+    std::string srcBuPath = m_context.locations->getBackupSourceDir();
+
+    LogDebug("Backup Folder " << srcBuPath << " to " << srcPath);
+
+    if(!WrtUtilRemove(srcPath)) {
+        LogError("Failed to remove " << srcPath);
+    }
+
+    if (rename(srcBuPath.c_str(), srcPath.c_str()) != 0) {
+        LogError("Failed to rename " << srcBuPath << " to " << srcPath);
+    }
+}
+
+void TaskUpdateFiles::StepAbortExecFileBackup()
+{
+    LogDebug("StepAbortExecFileBackup");
+    std::string binPath = m_context.locations->getBinaryDir();
+
+    if(!WrtUtilRemove(binPath)) {
+        LogError("Failed to remove " << binPath);
+    }
+
+    std::string binBuPath = m_context.locations->getBackupBinaryDir();
+    if (rename(binBuPath.c_str(), binPath.c_str()) != 0) {
+        LogError("Failed to rename " << binBuPath << " to " << binPath);
+    }
+    LogDebug("Backup Folder " << binBuPath << "move to " << binPath);
+}
+
+void TaskUpdateFiles::StepAbortCreateBackupFolder()
+{
+    LogDebug("StepAbortCreateBackupFolder");
+    std::ostringstream path;
+    path << m_context.locations->getBackupDir();
+    LogDebug("Remove backup directory : " << path.str());
+
+    if(!WrtUtilRemove(path.str())) {
+        LogError("Failed to remove " << path);
+    }
+}
+
+} //namespace WidgetInstall
+} //namespace Jobs
diff --git a/src/jobs/widget_install/task_update_files.h b/src/jobs/widget_install/task_update_files.h
new file mode 100644 (file)
index 0000000..b95e5c9
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file    task_update_files.h
+ * @author  Soyoung Kim (sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief   Header file for installer task update files
+ */
+#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_UPDATE_FILES_H
+#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_UPDATE_FILES_H
+
+#include <set>
+#include <dpl/task.h>
+#include <dpl/string.h>
+
+class InstallerContext;
+
+namespace {
+typedef std::set<std::string> ExistFileList;
+}
+
+namespace Jobs {
+namespace WidgetInstall {
+class TaskUpdateFiles :
+    public DPL::TaskDecl<TaskUpdateFiles>
+{
+  private:
+    InstallerContext& m_context;
+
+    /* TODO : md5 check */
+    void StepCreateBackupFolder();
+    void StepResourceFilesBackup();
+    void StepExecFileBackup();
+
+    void ReadDirList(std::string dirPath, ExistFileList &list, size_t subLen);
+
+    void StepAbortResourceFilesBackup();
+    void StepAbortCreateBackupFolder();
+    void StepAbortExecFileBackup();
+
+  public:
+    TaskUpdateFiles(InstallerContext& context);
+};
+} //namespace WidgetInstall
+} //namespace Jobs
+
+#endif /* INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_UPDATE_FILES_H */
index 8f4710f..54a8f31 100644 (file)
  * @version 1.0
  * @brief   Implementation file for installer task widget config
  */
-#include <string>
+
 #include <sstream>
-#include <dpl/foreach.h>
+#include <string>
+#include <sys/stat.h>
+#include <dirent.h>
+
 #include <dpl/errno_string.h>
-#include <dpl/wrt-dao-rw/feature_dao.h>
+#include <dpl/foreach.h>
+#include <dpl/localization/w3c_file_localization.h>
+#include <dpl/singleton_impl.h>
+#include <dpl/utils/mime_type_utils.h>
+#include <dpl/utils/wrt_global_settings.h>
 #include <dpl/utils/wrt_utility.h>
-#include <root_parser.h>
-#include <powder_parser.h>
-#include <widget_parser.h>
-#include <parser_runner.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-rw/feature_dao.h>
+
 #include <libiriwrapper.h>
-#include <widget_install/task_widget_config.h>
+#include <parser_runner.h>
+#include <root_parser.h>
+
 #include <widget_install/job_widget_install.h>
-#include <widget_install/widget_install_errors.h>
+#include <widget_install/task_widget_config.h>
 #include <widget_install/widget_install_context.h>
-#include <dpl/utils/file_utils.h>
-#include <dpl/utils/mime_type_utils.h>
-#include <sys/stat.h>
-#include "wrt_powder_info_util.h"
-#include <dpl/utils/wrt_global_settings.h>
+#include <widget_install/widget_install_errors.h>
+#include <widget_parser.h>
+#include <wrt_error.h>
+
 
 namespace { // anonymous
-const char *WIDGET_SCHEMA = "widget";
-const WidgetHandle WIDGET_HANDLE_START_VALUE = 1000;
-const char * AGE_RATING = "Age Rating: ";
-const char * CATEGORY = "Category: ";
-const char * LEVEL = "Level: ";
-const char * CONTEXT = "Context: ";
-const DPL::String POWDER_INFO = DPL::FromUTF8String("Powder Info");
-const DPL::String POWDER_PASSWORD = DPL::FromUTF8String(
-        "Parental Mode is ON.<br>"
-        "Please enter your password");
-const DPL::String WIDGET_HEAD = DPL::FromUTF8String("Widget information");
-const std::string OK_BUTTON_LABEL = "OK";
-const std::string CANCEL_BUTTON_LABEL = "Cancel";
 const DPL::String BR = DPL::FromUTF8String("<br>");
-const DPL::String DOUBLE_BR = DPL::FromUTF8String("<br><br>");
-const DPL::String POWDER_HEAD = DPL::FromUTF8String("Powder information");
-const DPL::String FEATURE_HEAD = DPL::FromUTF8String("Feature information");
-} // namespace anonymous
+const std::string WIDGET_NOT_COMPATIBLE = "This widget is "
+        "not compatible with WRT.<br><br>";
+const std::string QUESTION = "Do you want to install it anyway?";
+
+const char *const DEFAULT_LANGUAGE = "default";
+
+const char *const WRT_WIDGET_CONFIG_FILE_NAME = "config.xml";
+
+const std::string WINDGET_INSTALL_NETWORK_ACCESS = "network access";
+}
+
 
 namespace Jobs {
 namespace WidgetInstall {
 void InstallerTaskWidgetPopupData::PopupData::addWidgetInfo(
-        const DPL::String &head,
         const DPL::String &info)
 {
-    widgetInfo += head;
-    widgetInfo += DOUBLE_BR;
-    widgetInfo += info;
-    widgetInfo += BR;
+    widgetInfo = info;
 }
 
 TaskWidgetConfig::TaskWidgetConfig(InstallerContext& installContext) :
     DPL::TaskDecl<TaskWidgetConfig>(this),
-    m_installContext(installContext),
-    m_installCancel(false)
+    WidgetInstallPopup(installContext),
+    m_installContext(installContext)
+
 {
     AddStep(&TaskWidgetConfig::StepProcessConfigurationFile);
     AddStep(&TaskWidgetConfig::ReadLocaleFolders);
     AddStep(&TaskWidgetConfig::ProcessLocalizedStartFiles);
+    AddStep(&TaskWidgetConfig::ProcessBackgroundPageFile);
     AddStep(&TaskWidgetConfig::ProcessLocalizedIcons);
-    AddStep(&TaskWidgetConfig::StepProcessPowderFile);
+    AddStep(&TaskWidgetConfig::ProcessWidgetInstalledPath);
     AddStep(&TaskWidgetConfig::StepVerifyFeatures);
+    AddStep(&TaskWidgetConfig::StepCheckMinVersionInfo);
 
-    //in case of tests, no popups are shown
-    if (GlobalSettings::GetPopupsEnabledFlag()) {
+    if (!GlobalSettings::TestModeEnabled() && !m_installContext.m_quiet) {
+        AddStep(&TaskWidgetConfig::StepCancelWidgetInstallationAfterVerifyFeatures);
         AddStep(&TaskWidgetConfig::StepShowWidgetInfo);
         AddStep(&TaskWidgetConfig::StepCancelWidgetInstallation);
+        AddStep(&TaskWidgetConfig::StepCancelWidgetInstallationAfterMinVersion);
+        AddStep(&TaskWidgetConfig::StepDeletePopupWin);
     }
 }
 
@@ -95,30 +97,20 @@ void TaskWidgetConfig::StepProcessConfigurationFile()
 {
     Try
     {
-        WidgetConfigurationManagerSingleton::Instance().processFile(
-            m_installContext.tempWidgetPath,
-            m_installContext.widgetConfig);
+        std::string path = m_installContext.locations->getConfigurationDir();
+        LogInfo("path: " << path);
+
+        processFile(path, m_installContext.widgetConfig);
     }
-    Catch(WidgetConfigurationManager::Exception::ProcessFailed)
+    Catch(Exception::ConfigParseFailed)
     {
         LogError("Parsing failed.");
         ReThrow(Exceptions::WidgetConfigFileInvalid);
     }
-    Try
-    {
-        // To get widget type for distribute WAC, TIZEN WebApp
-        setApplicationType();
-    }
-    Catch(WidgetConfigurationManager::Exception::ProcessFailed)
-    {
-        LogError("Config.xml has more than one namespace");
-        ReThrow(Exceptions::WidgetConfigFileInvalid);
-    }
 
-    m_installContext.job->SetProgressFlag(true);
     m_installContext.job->UpdateProgress(
         InstallerContext::INSTALL_WIDGET_CONFIG1,
-        "Parsing was suscessfull");
+        "Parse elements of configuration file and save them");
 }
 
 void TaskWidgetConfig::ReadLocaleFolders()
@@ -127,7 +119,7 @@ void TaskWidgetConfig::ReadLocaleFolders()
     //Adding default locale
     m_localeFolders.insert(L"");
 
-    std::string localePath = m_installContext.tempWidgetPath + "/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.");
@@ -163,8 +155,9 @@ void TaskWidgetConfig::ReadLocaleFolders()
         LogError("readdir() failed with " << DPL::GetErrnoString());
     }
 
-    if (closedir(localeDir)) {
-        LogError("closedir() failed with " << DPL::GetErrnoString());
+    if (-1 == TEMP_FAILURE_RETRY(closedir(localeDir))) {
+        LogError("Failed to close dir: " << localePath << " with error: "
+                << DPL::GetErrnoString());
     }
 }
 
@@ -211,10 +204,10 @@ void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path,
 
             DPL::String relativePath = pathPrefix + *path;
             DPL::String absolutePath = DPL::FromUTF8String(
-                    m_installContext.tempWidgetPath) + L"/" + relativePath;
+                    m_installContext.locations->getConfigurationDir()) + L"/" + relativePath;
 
             // get property data from packaged app
-            if (FileUtils::FileExists(absolutePath)) {
+            if (WrtUtilFileExists(DPL::ToUTF8String(absolutePath))) {
                 WidgetRegisterInfo::StartFileProperties startFileProperties;
                 if (!!type) {
                     startFileProperties.type = *type;
@@ -256,12 +249,12 @@ void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path,
             } else {
                 // set property data for hosted start url
                 // Hosted start url only support TIZEN WebApp
-                if (m_installContext.widgetConfig.type ==
-                    APP_TYPE_TIZENWEBAPP)
+                if (m_installContext.widgetConfig.webAppType ==
+                        APP_TYPE_TIZENWEBAPP)
                 {
-                    const char *startPath =
-                        DPL::ToUTF8String(startFileData.path).c_str();
-                    if (strstr(startPath, "http") == startPath) {
+                    std::string startPath =  DPL::ToUTF8String(startFileData.path);
+
+                    if (strstr(startPath.c_str(), "http") == startPath.c_str()) {
                         WidgetRegisterInfo::StartFileProperties
                             startFileProperties;
                         if (!!type) {
@@ -282,6 +275,21 @@ void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path,
     }
 }
 
+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.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");
+        }
+    }
+}
+
 void TaskWidgetConfig::ProcessLocalizedIcons()
 {
     using namespace WrtDB;
@@ -299,7 +307,8 @@ void TaskWidgetConfig::ProcessLocalizedIcons()
 
 void TaskWidgetConfig::ProcessIcon(const WrtDB::ConfigParserData::Icon& icon)
 {
-    bool isAnyIconExisted = false;
+    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
     //in database.
@@ -309,7 +318,6 @@ void TaskWidgetConfig::ProcessIcon(const WrtDB::ConfigParserData::Icon& icon)
     if (m_processedIconSet.count(icon.src) > 0) {
         return;
     }
-
     m_processedIconSet.insert(icon.src);
 
     LocaleSet localesAvailableForIcon;
@@ -323,21 +331,21 @@ void TaskWidgetConfig::ProcessIcon(const WrtDB::ConfigParserData::Icon& icon)
 
         DPL::String relativePath = pathPrefix + icon.src;
         DPL::String absolutePath = DPL::FromUTF8String(
-                m_installContext.tempWidgetPath) + L"/" + relativePath;
+                m_installContext.locations->getConfigurationDir()) + L"/" + relativePath;
 
-        if (FileUtils::FileExists(absolutePath)) {
-            isAnyIconExisted = true;
+        if (WrtUtilFileExists(DPL::ToUTF8String(absolutePath))) {
             DPL::String type = MimeTypeUtils::identifyFileMimeType(absolutePath);
 
             if (MimeTypeUtils::isMimeTypeSupportedForIcon(type)) {
+                isAnyIconValid = true;
                 localesAvailableForIcon.insert(*i);
+                LogInfo("Icon absolutePath :" << absolutePath <<
+                        ", assigned locale :" << *i << ", type: " << type);
             }
-            LogInfo("Icon absolutePath :" << absolutePath <<
-                    ", assigned locale :" << *i);
         }
     }
 
-    if(isAnyIconExisted)
+    if(isAnyIconValid)
     {
         WidgetRegisterInfo::LocalizedIcon localizedIcon(icon,
                                                         localesAvailableForIcon);
@@ -346,172 +354,93 @@ void TaskWidgetConfig::ProcessIcon(const WrtDB::ConfigParserData::Icon& icon)
     }
 }
 
-void TaskWidgetConfig::StepProcessPowderFile(void)
+void TaskWidgetConfig::ProcessWidgetInstalledPath()
 {
-    using namespace WrtDB;
-    const std::string& path = m_installContext.tempWidgetPath;
-    WidgetRegisterInfo* widgetConfiguration =
-        &m_installContext.widgetConfig;
-
-    LogInfo("Process powder for guid " <<
-            widgetConfiguration->guid);
-    if (!!widgetConfiguration->guid) {
-        LibIri::Wrapper iri(DPL::ToUTF8String(
-                                *widgetConfiguration->guid).c_str());
-        DPL::String widgetHost;
-        DPL::String widgetPath;
-        if (NULL != iri.m_Iri->host) {
-            widgetHost = DPL::FromUTF8String(iri.m_Iri->host);
-        }
-        if (NULL != iri.m_Iri->path) {
-            widgetPath = DPL::FromUTF8String(iri.m_Iri->path);
-        }
-        PowderParserData parserData(&widgetConfiguration->powderDescription,
-                                    widgetHost, widgetPath);
-        ConfigParserData::StringsList& descriptions =
-            widgetConfiguration->configInfo.powderDescriptionLinks;
-
-        FOREACH(linkIter, descriptions)
-        {
-            LogInfo("Process powder link: " << *linkIter);
-            LibIri::Wrapper link(DPL::ToUTF8String(*linkIter).c_str());
-            LogInfo("Parser link" << link);
-            if (strcmp(link.m_Iri->scheme, WIDGET_SCHEMA) == 0) {
-                if (NULL != link.m_Iri->host) {
-                    std::ostringstream stream;
-                    //FIXME: Current libiri library is not able to parse
-                    //       URL: widget:/powder.xml Field host
-                    //       is filed with path
-                    stream << path << "/" << link.m_Iri->host;
-                    ParserRunner().Parse(
-                        stream.str(),
-                        ElementParserPtr(new
-                                         RootParser<PowderParser>(&parserData,
-                                                                  DPL::
-                                                                      FromUTF32String(
-                                                                      L"powder"))));
-                } else {
-                    ThrowMsg(Exceptions::WidgetConfigFileInvalid,
-                             "Powder link " << *linkIter << " path empty.");
-                }
-            } else {
-                ThrowMsg(Exceptions::WidgetConfigFileInvalid,
-                         "Powder link " <<
-                         *linkIter <<
-                         " schema not supported.");
-            }
-        }
-    }
-
-    //TODO:FIXME make progress valid
-    m_installContext.job->UpdateProgress(
-        InstallerContext::INSTALL_WIDGET_CONFIG1,
-        "Widget Config powder step Finished");
+    LogDebug("ProcessWidgetInstalledPath");
+    m_installContext.widgetConfig.widgetInstalledPath =
+        DPL::FromUTF8String(m_installContext.locations->getPackageInstallationDir());
 }
 
-void TaskWidgetConfig::AnswerCallback(const DPL::Popup::AnswerCallbackData &answer)
+void TaskWidgetConfig::StepCancelWidgetInstallationAfterVerifyFeatures()
 {
-    LogInfo("Callback called");
-    if (WRT_POPUP_BUTTON_CANCEL == answer.buttonAnswer) {
-        m_installCancel = WRT_POPUP_BUTTON_CANCEL;
+    LogDebug("StepCancelWidgetInstallationAfterVerifyFeatures");
+    if (InfoPopupButton::WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
+        m_installCancel = WRT_POPUP_BUTTON;
+        destroyPopup();
+        ThrowMsg(Exceptions::WidgetConfigFileInvalid, "Widget not allowed");
     }
-    m_installContext.job->Resume();
 }
 
 void TaskWidgetConfig::StepCancelWidgetInstallation()
 {
-    if (WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
+    if (InfoPopupButton::WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
+        m_installCancel = WRT_POPUP_BUTTON;
+        destroyPopup();
         ThrowMsg(Exceptions::NotAllowed, "Widget not allowed");
     }
 }
 
-//TODO this step is not added in constructor
-void TaskWidgetConfig::StepShowPowderPasswordCancel()
+void TaskWidgetConfig::StepCancelWidgetInstallationAfterMinVersion()
 {
-    if (WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
-        ThrowMsg(Exceptions::NotAllowed, "Parental Mode is ON");
+    if (InfoPopupButton::WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
+        m_installCancel = WRT_POPUP_BUTTON;
+        destroyPopup();
+        ThrowMsg(Exceptions::NotAllowed, "WRT version incompatible.");
     }
 }
 
-void TaskWidgetConfig::PopupCreate()
+void TaskWidgetConfig::createInstallPopup(PopupType type, const std::string &label)
 {
     m_installContext.job->Pause();
-    using namespace DPL::Popup;
-    CtrlPopupPtr popup = PopupControllerSingleton::Instance().CreatePopup();
-    popup->SetTitle(DPL::ToUTF8String(WIDGET_HEAD));
-    popup->Append(new PopupObject::Label(
-                      DPL::ToUTF8String(m_popupData.widgetInfo)));
-    m_popupData.widgetInfo.clear();
-    popup->Append(new PopupObject::Button(OK_BUTTON_LABEL,
-                                           WRT_POPUP_BUTTON_OK));
-    popup->Append(new PopupObject::Button(CANCEL_BUTTON_LABEL,
-                                           WRT_POPUP_BUTTON_CANCEL));
-    ListenForAnswer(popup);
-    ShowPopupEvent event(popup, MakeAnswerCallback(
-                             this,
-                             &TaskWidgetConfig::
-                                 AnswerCallback), DPL::Event::UNDEFINED_LOOP_HANDLE);
-    CONTROLLER_POST_EVENT(PopupController, event);
-}
+    if (m_popup)
+        destroyPopup();
 
-DPL::String TaskWidgetConfig::createPowderInfo() const
-{
-    WrtDB::Powder::Description &powderDescription =
-        m_installContext.widgetConfig.powderDescription;
-    std::ostringstream powderInfo;
-    if (!!powderDescription.ageRating) {
-        powderInfo << AGE_RATING;
-        powderInfo << *powderDescription.ageRating;
-        powderInfo << BR;
-    }
-    FOREACH(categoriesIterator, powderDescription.categories) {
-        powderInfo << CATEGORY;
-        powderInfo << PowderInfoUtilSingleton::Instance().
-            getCategoryLabel(categoriesIterator->first);
-        powderInfo << BR;
-
-        FOREACH(levelIterator, categoriesIterator->second.levels) {
-            powderInfo << LEVEL;
-            powderInfo << static_cast<int>(levelIterator->level);
-            powderInfo << BR;
-
-            FOREACH(contextIterator, levelIterator->context) {
-                powderInfo << CONTEXT;
-                powderInfo << PowderInfoUtilSingleton::Instance().
-                    getContextLabel(*contextIterator);
-                powderInfo << BR;
-            }
-        }
+    bool ret = createPopup();
+    if (ret)
+    {
+        loadPopup( type, label);
+        showPopup();
     }
+}
 
-    return DPL::FromUTF8String(powderInfo.str());
+void TaskWidgetConfig::StepDeletePopupWin()
+{
+    destroyPopup();
 }
 
 void TaskWidgetConfig::StepShowWidgetInfo()
 {
-    if (!createPowderInfo().empty()) {
-        m_popupData.addWidgetInfo(POWDER_HEAD,
-                                  createPowderInfo());
-    }
-
     if (!m_popupData.widgetInfo.empty()) {
-        PopupCreate();
+            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");
     }
 }
 
-//TODO this step is not added in constructor
-void TaskWidgetConfig::StepShowPowderPassword()
+void TaskWidgetConfig::StepCheckMinVersionInfo()
 {
-    using namespace WrtDB;
-    if (GlobalDAOReadOnly::GetParentalMode()) {
-        m_popupData.addWidgetInfo(POWDER_INFO, POWDER_PASSWORD);
+    if (!isMinVersionCompatible(
+                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");
+            ThrowMsg(Exceptions::NotAllowed,
+                    "Platform version does not meet requirements");
+        }
     }
+
     m_installContext.job->UpdateProgress(
-        InstallerContext::INSTALL_WIDGET_CONFIG2,
-        "Show Powder Password Finished");
+            InstallerContext::INSTALL_WIDGET_CONFIG2,
+            "Check MinVersion Finished");
 }
 
 void TaskWidgetConfig::StepVerifyFeatures()
@@ -527,14 +456,15 @@ void TaskWidgetConfig::StepVerifyFeatures()
     {
         // check feature vender for permission
         // WAC, TIZEN WebApp cannot use other feature
-        if (!isFeatureAllowed(m_installContext.widgetConfig.type.appType,
+
+        if (!isFeatureAllowed(m_installContext.widgetConfig.webAppType.appType,
                               it->name))
         {
             LogInfo("This application type not allowed to use this feature");
             ThrowMsg(
                 Exceptions::WidgetConfigFileInvalid,
                 "This app type [" <<
-                m_installContext.widgetConfig.type.getApptypeToString() <<
+                m_installContext.widgetConfig.webAppType.getApptypeToString() <<
                 "] cannot be allowed to use [" <<
                 DPL::ToUTF8String(it->name) + "] feature");
         }
@@ -544,15 +474,19 @@ void TaskWidgetConfig::StepVerifyFeatures()
                        DPL::ToUTF8String(it->name) << "]");
 
             if (it->required) {
-                LogWarning(
-                    "Required Features missing, Installation topped: [" <<
-                    DPL::ToUTF8String(it->name) << "]");
-
-                ThrowMsg(
-                    Exceptions::WidgetConfigFileInvalid,
-                    "Widget cannot be installedm equired feature is missing:["
-                    +
-                    DPL::ToUTF8String(it->name) + "]");
+                /**
+                 * WL-3210 The WRT MUST inform the user if a widget cannot be
+                 * installed because one or more required features are not
+                 * supported.
+                 */
+                std::ostringstream os;
+                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);
+                }
+                ThrowMsg(Exceptions::WidgetConfigFileInvalid, os.str());
             }
         } else {
             newList.insert(*it);
@@ -560,10 +494,13 @@ void TaskWidgetConfig::StepVerifyFeatures()
             featureInfo += DPL::ToUTF8String(BR);
         }
     }
+    if(!data.accessInfoSet.empty()) {
+        featureInfo += WINDGET_INSTALL_NETWORK_ACCESS;
+        featureInfo += DPL::ToUTF8String(BR);
+    }
     data.featuresList = newList;
     if (!featureInfo.empty()) {
-        m_popupData.addWidgetInfo(FEATURE_HEAD,
-                                  DPL::FromUTF8String(featureInfo));
+        m_popupData.addWidgetInfo(DPL::FromUTF8String(featureInfo));
     }
 
     m_installContext.job->UpdateProgress(
@@ -571,50 +508,6 @@ void TaskWidgetConfig::StepVerifyFeatures()
         "Widget Config step2 Finished");
 }
 
-void TaskWidgetConfig::setApplicationType()
-{
-    using namespace WrtDB;
-    WidgetRegisterInfo* widgetInfo = &(m_installContext.widgetConfig);
-    ConfigParserData* configInfo = &(widgetInfo->configInfo);
-
-    FOREACH(iterator, configInfo->nameSpaces) {
-        LogInfo("namespace = [" << *iterator << "]");
-        AppType currentAppType = APP_TYPE_UNKNOWN;
-
-        if (*iterator == ConfigurationNamespace::W3CWidgetNamespaceName) {
-            continue;
-        } else if (*iterator ==
-                ConfigurationNamespace::JilWidgetNamespaceName) {
-            currentAppType = APP_TYPE_WAC10;
-        } else if (
-            *iterator ==
-            ConfigurationNamespace::WacWidgetNamespaceNameForLinkElement ||
-            *iterator ==
-            ConfigurationNamespace::WacWidgetNamespaceName)
-        {
-            currentAppType = APP_TYPE_WAC20;
-        } else if (*iterator == ConfigurationNamespace::TizenWebAppNamespaceName) {
-            currentAppType = APP_TYPE_TIZENWEBAPP;
-        }
-
-        if (widgetInfo->type == APP_TYPE_UNKNOWN) {
-            widgetInfo->type = currentAppType;
-        } else if (widgetInfo->type == currentAppType) {
-            continue;
-        } else {
-            ThrowMsg(Exceptions::WidgetConfigFileInvalid,
-                     "Config.xml has more than one namespace");
-        }
-    }
-
-    // If there is no define, type set to WAC 2.0
-    if (widgetInfo->type == APP_TYPE_UNKNOWN) {
-        widgetInfo->type = APP_TYPE_WAC20;
-    }
-
-    LogInfo("type = [" << widgetInfo->type.getApptypeToString() << "]");
-}
-
 bool TaskWidgetConfig::isFeatureAllowed(WrtDB::AppType appType,
                                         DPL::String featureName)
 {
@@ -624,7 +517,9 @@ bool TaskWidgetConfig::isFeatureAllowed(WrtDB::AppType appType,
     LogInfo("FetureName = [" << featureName << "]");
 
     AppType featureType = APP_TYPE_UNKNOWN;
-    const char* feature = DPL::ToUTF8String(featureName).c_str();
+    std::string featureStr = DPL::ToUTF8String(featureName);
+    const char* feature = featureStr.c_str();
+
     // check prefix of  feature name
     if (strstr(feature, PluginsPrefix::TIZENPluginsPrefix) == feature) {
         // Tizen WebApp feature
@@ -648,5 +543,269 @@ bool TaskWidgetConfig::isFeatureAllowed(WrtDB::AppType appType,
     return false;
 }
 
+bool TaskWidgetConfig::parseVersionString(const std::string &version,
+        long &majorVersion, long &minorVersion, long &microVersion) const
+{
+    std::istringstream inputString(version);
+    inputString >> majorVersion;
+    if (inputString.bad() || inputString.fail()) {
+        LogWarning("Invalid minVersion format.");
+        return false;
+    }
+    inputString.get(); // skip period
+    inputString >> minorVersion;
+    if (inputString.bad() || inputString.fail()) {
+        LogWarning("Invalid minVersion format");
+        return false;
+    } else {
+        inputString.get(); // skip period
+        if (inputString.bad() || inputString.fail()) {
+            inputString >> microVersion;
+        }
+    }
+    return true;
+}
+
+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;
+    }
+
+    //Parse widget version
+    long majorWidget = 0, minorWidget = 0, microWidget = 0;
+    if (!parseVersionString(DPL::ToUTF8String(*widgetVersion), majorWidget,
+            minorWidget, microWidget)) {
+        LogWarning("Invalid format of widget version string.");
+        return true;
+    }
+
+    //Parse supported version
+    long majorSupported = 0, minorSupported = 0, microSupported = 0;
+    std::string version;
+    if (appType == WrtDB::AppType::APP_TYPE_TIZENWEBAPP) {
+        version = WrtDB::GlobalConfig::GetTizenVersion();
+    } else if (appType == WrtDB::AppType::APP_TYPE_WAC20) {
+        version = WrtDB::GlobalConfig::GetWACVersion();
+    } else {
+        LogWarning("Invaild AppType");
+        return false;
+    }
+
+    if (!parseVersionString(version,
+                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))
+    {
+        LogInfo("Platform doesn't support this widget.");
+        return false;
+    }
+    return true;
+}
+
+bool TaskWidgetConfig::isTizenWebApp() const
+{
+    bool ret = FALSE;
+    if (m_installContext.widgetConfig.webAppType.appType
+            == WrtDB::AppType::APP_TYPE_TIZENWEBAPP)
+        ret = TRUE;
+
+    return ret;
+}
+
+bool TaskWidgetConfig::parseConfigurationFileBrowser(WrtDB::ConfigParserData& configInfo,
+                                    const std::string& _currentPath, int* pErrCode)
+{
+    ParserRunner parser;
+    Try
+    {
+        parser.Parse(_currentPath, ElementParserPtr(new
+                                                  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)
+{
+    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;
+    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);
+                WrtUtilJoinPaths(cfgAbsPath, _currentPath, dName);
+
+                //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)
+                {
+                    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());
+                    }
+                    return false;
+                }
+
+                has_config_xml = true;
+                break;
+            }
+        }
+    }
+    if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
+        LogError("Failed to close dir: " << _currentPath << " with error: "
+                << 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)
+{
+    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);
+
+    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))
+        {
+            return false;
+        }
+    } else {
+        // in case of browser installation
+        if(!parseConfigurationFileBrowser(configInfo, _currentPath, pErrCode))
+        {
+            return false;
+        }
+    }
+
+    if(!fillWidgetConfig(pWidgetConfigInfo, configInfo))
+    {
+        *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
+        return false;
+    }
+    return true;
+}
+
+bool TaskWidgetConfig::fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
+                                        WrtDB::ConfigParserData& configInfo)
+{
+    if (!!configInfo.widget_id) {
+        if (!pWidgetConfigInfo.guid) {
+            pWidgetConfigInfo.guid = configInfo.widget_id;
+        } else {
+            if (pWidgetConfigInfo.guid != configInfo.widget_id) {
+                LogError("Invalid archive");
+                return false;
+            }
+        }
+    }
+    if (!!configInfo.tizenId) {
+       if (pWidgetConfigInfo.pkgName != *configInfo.tizenId) {
+           LogError("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) {
+                LogError("Invalid archive");
+                return false;
+            }
+        }
+    }
+    if (!!configInfo.minVersionRequired) {
+        pWidgetConfigInfo.minVersion = configInfo.minVersionRequired;
+    } else if (!!configInfo.tizenMinVersionRequired) {
+        pWidgetConfigInfo.minVersion = configInfo.tizenMinVersionRequired;
+    }
+    return true;
+}
+
+void TaskWidgetConfig::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::ConfigParseFailed, path);
+    }
+}
+
 } //namespace WidgetInstall
 } //namespace Jobs
old mode 100644 (file)
new mode 100755 (executable)
index 0655964..9b44559
@@ -14,7 +14,7 @@
  *    limitations under the License.
  */
 /*
- * @file    task_widget_config.cpp
+ * @file    task_widget_config.h
  * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version 1.0
  * @brief   Implementation file for installer task widget config
 #ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_WIDGET_CONFIG_H
 #define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_WIDGET_CONFIG_H
 
-#include <WidgetConfigurationManager.h>
+#include <set>
+#include <list>
+
 #include <dpl/task.h>
 #include <dpl/task_list.h>
 #include <dpl/string.h>
-#include <dpl/event/nested_loop.h>
-#include <wrt_error.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 <dpl/wrt-dao-ro/global_config.h>
-#include <set>
-#include <dpl/popup/popup_controller.h>
-#include <dpl/popup/popup_manager.h>
-#include <dpl/popup/popup_renderer.h>
+
+#include <wrt_error.h>
 #include <wrt_common_types.h>
+#include <widget_install/widget_install_popup.h>
 
 class InstallerContext;
 
@@ -43,25 +45,27 @@ namespace InstallerTaskWidgetPopupData {
 struct PopupData
 {
     DPL::String widgetInfo;
-    void addWidgetInfo(const DPL::String &head,
-            const DPL::String &info);
+    void addWidgetInfo(const DPL::String &info);
 };
 } // InstalllerTaskWidgetPopupData
 
 class TaskWidgetConfig :
     public DPL::TaskDecl<TaskWidgetConfig>,
-    public DPL::Popup::PopupControllerUser
+    public WidgetInstallPopup
 {
   private:
-    enum PowderInfoButton
+    class Exception
     {
-        WRT_POPUP_BUTTON_OK, WRT_POPUP_BUTTON_CANCEL
+      public:
+        DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+        DECLARE_EXCEPTION_TYPE(Base, ConfigParseFailed)
     };
 
+    typedef std::list<std::pair<DPL::String, DPL::String> > StringPairList;
+
     InstallerContext& m_installContext;
     WrtDB::LocaleSet m_localeFolders;
     std::set<DPL::String> m_processedIconSet;
-    bool m_installCancel;
     InstallerTaskWidgetPopupData::PopupData m_popupData;
 
     void StepProcessConfigurationFile();
@@ -71,24 +75,55 @@ class TaskWidgetConfig :
             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);
-    void StepProcessPowderFile();
+    void ProcessWidgetInstalledPath();
     void StepVerifyFeatures();
     void StepShowWidgetInfo();
-    void StepPowderCancel();
-    void StepFeatureCancel();
+    void StepCheckMinVersionInfo();
+
+    template <typename Ex, const char* Msg>
+    void StepCancelInstallation();
+
+    void StepDeletePopupWin();
+    void StepCancelWidgetInstallationAfterVerifyFeatures();
     void StepCancelWidgetInstallation();
-    void StepShowPowderPassword();
-    void StepShowPowderPasswordCancel();
-    void PopupCreate();
-    DPL::String createPowderInfo() const;
-    void AnswerCallback(const DPL::Popup::AnswerCallbackData& answer);
+    void StepCancelWidgetInstallationAfterMinVersion();
+    void createInstallPopup(PopupType type, const std::string &label);
     DPL::String createAuthorWidgetInfo() const;
-    void setApplicationType();
     bool isFeatureAllowed(
             WrtDB::AppType appType, DPL::String featureName);
+    bool isMinVersionCompatible(
+            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;
+    /**
+     * 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);
 
+    bool locateAndParseConfigurationFile(const std::string& currentPath,
+            WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
+            const std::string& baseFolder,
+            int* pErrCode);
+    bool parseConfigurationFileBrowser(WrtDB::ConfigParserData& configInfo,
+                                    const std::string& _currentPath, int* pErrCode);
+    bool parseConfigurationFileWidget(WrtDB::ConfigParserData& configInfo,
+                                    const std::string& _currentPath, int* pErrCode);
+    bool fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
+                                    WrtDB::ConfigParserData& configInfo);
   public:
     TaskWidgetConfig(InstallerContext& installTaskContext);
 };
diff --git a/src/jobs/widget_install/view_mode.h b/src/jobs/widget_install/view_mode.h
new file mode 100644 (file)
index 0000000..6054388
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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       view_mode.h
+ * @author     Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version    1.0
+ */
+
+#ifndef SRC_JOBS_WIDGET_INSTALL_VIEW_MODE_H_
+#define SRC_JOBS_WIDGET_INSTALL_VIEW_MODE_H_
+
+namespace Jobs {
+namespace WidgetInstall {
+
+enum ViewMode
+{
+    WINDOWED = 0,
+    FLOATING,
+    FULLSCREEN,
+    MAXIMIZED,
+    MINIMIZED
+};
+
+} // WidgetInstall
+} // Jobs
+
+#endif /* SRC_JOBS_WIDGET_INSTALL_VIEW_MODE_H_ */
index b8ce123..6dafd02 100644 (file)
@@ -27,10 +27,16 @@ namespace Jobs {
 namespace WidgetInstall {
 
 void WacSecurity::getCertificateChainList(
-        WrtDB::CertificateChainList& list) const
+        WrtDB::CertificateChainList& list,
+        WrtDB::CertificateSource source) const
 {
-    FOREACH(certIter,mCertificateChainList)
-        list.push_back(certIter->toBase64String());
+    if (source == WrtDB::CertificateSource::SIGNATURE_DISTRIBUTOR){
+        FOREACH(certIter, mCertificateChainList)
+            list.push_back(certIter->toBase64String());
+    } else {
+        FOREACH(certIter, mAuthorsCertificateChainList)
+            list.push_back(certIter->toBase64String());
+    }
 }
 
 } // namespace WidgetInstall
index 702a8f4..a2095da 100644 (file)
@@ -53,7 +53,8 @@ class WacSecurity : public WrtDB::IWacSecurity
     virtual bool isWacSigned() const { return mWacSigned; }
 
     virtual void getCertificateChainList(
-            WrtDB::CertificateChainList& list) const;
+            WrtDB::CertificateChainList& list,
+            WrtDB::CertificateSource source) const;
 
     void setRecognized(bool recognized) { mRecognized = recognized; }
     void setDistributorSigned(bool distributorSigned)
@@ -68,6 +69,11 @@ class WacSecurity : public WrtDB::IWacSecurity
         return mCertificateChainList;
     }
 
+    ValidationCore::CertificateCollectionList& getAuthorsCertificateChainListRef()
+    {
+        return mAuthorsCertificateChainList;
+    }
+
     WrtDB::WidgetCertificateDataList& getCertificateListRef()
     {
         return mCertificateList;
@@ -89,6 +95,8 @@ class WacSecurity : public WrtDB::IWacSecurity
     ValidationCore::CertificatePtr mAuthorCertificate;
     // This certificates are used by OCSP/CRL
     ValidationCore::CertificateCollectionList mCertificateChainList;
+    // This authors certificates are used by tizen
+    ValidationCore::CertificateCollectionList mAuthorsCertificateChainList;
 };
 
 } // namespace WidgetInstall
old mode 100644 (file)
new mode 100755 (executable)
index c277dea..284cc1b
 #ifndef INSTALLER_CONTEXT_H
 #define INSTALLER_CONTEXT_H
 
+#include <map>
 #include <string>
+#include <dpl/string.h>
 #include <dpl/wrt-dao-rw/widget_dao.h>
 #include <widget_install/wac_security.h>
 #include <feature_logic.h>
 #include <widget_install/widget_update_info.h>
+#include <widget_location.h>
 
 namespace Jobs {
 namespace WidgetInstall {
@@ -36,47 +39,70 @@ class JobWidgetInstall;
 
 class WidgetModel;
 
+typedef std::map<DPL::String, bool> RequestedDevCapsMap;
+
 struct InstallerContext
 {
     typedef enum InstallStepEnum
     {
         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_DIR_CREATE,
         INSTALL_RENAME_PATH,
-        INSTALL_CREATE_DESKTOP,
-        INSTALL_CREATE_EXECFILE,
+
+        INSTALL_CREATE_BACKUP_DIR = INSTALL_DB_UPDATE, /* 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_PRIVATE_STORAGE,
+        INSTALL_CREATE_EXECFILE,
+        INSTALL_CREATE_MANIFEST,
+        INSTALL_CREATE_DESKTOP,
+        INSTALL_CREATE_SHORTCUT,
+        INSTALL_INSTALL_OSPSVC,
+
+        INSTALL_UPDATE_DESKTOP = INSTALL_CREATE_DESKTOP, /* For Update */
+        INSTALL_DELETE_OLD_DB,                           /* For Update */
+        INSTALL_REMOVE_BACKUP_FILE,
+
         INSTALL_END
     } InstallStep;
 
     // Installation state variables
-    std::string widgetFilePath;           ///< Source widget zip file
-    std::string tempWidgetPath;           ///< Unpacked widget temporary path
     WrtDB::WidgetRegisterInfo widgetConfig;      ///< WidgetConfigInfo
-    DPL::Optional<WrtDB::DbWidgetHandle> widgetHandle;
+    DPL::Optional<WidgetLocation> locations;
     Jobs::WidgetInstall::WacSecurity wacSecurity;///< Widget Domain information.
-    bool unzipStarted;
-        ///< flag that indicates whether installer starts to unzip .wgt file
-    bool unzipFinished;
-        ///< flag that indicates whether installer finishes to unzip completely.
     InstallStep installStep;              ///< current step of installation
     Jobs::WidgetInstall::JobWidgetInstall *job;
         ///< pointer of instance of JobWidgetInstall
     WidgetUpdateInfo::ExistingWidgetInfo existingWidgetInfo;
         ///< Whether this is an update or normal installation
     Jobs::WidgetInstall::FeatureLogicPtr featureLogic;
-    /** List of dev-caps that get "static" permission (will always
-    * have PERMIT from ACE Policy). They will therefore receive
+    /** 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). */
-    std::set<DPL::String> staticPermittedDevCaps;
+    RequestedDevCapsMap staticPermittedDevCaps;
+    std::string installInfo;            ///<For recovery>
+    bool m_quiet;
+    InstallLocationType locationType;
 };
 
 #endif // INSTALLER_CONTEXT_H
index 5ed746e..b3bf040 100644 (file)
@@ -37,18 +37,20 @@ enum Type
 
     ErrorInvalidWidgetPackage,       ///< ?
     ErrorWidgetDoesNotExist,         ///< ?
-    ErrorFactoryWidget,              ///< Widget is factory installed, and cannot be uninstalled
     ErrorAreadyUninstalling,         ///< Widget is already being uninstalled
     ErrorOutOfDiskSpace,             ///< ?
     ErrorInvalidPackage,             ///< Widget signature is invalid.
     ErrorAlreadyInstalled,           ///< ?
     ErrorInternal,                   ///< ?
-    ErrorParentalMode,               ///< Widget cannot be installed when parental mode is active
     ErrorNotAllowed,                 ///< Widget installation or update not allowed
                                      ///< because violation of policy ocurred
     ErrorDeferred,                   ///< Widget installation was deferred and will be continued when possible
     ErrorDatabaseFailure,            ///< Failure in database
     ErrorRemovingFolderFailure,      ///< Failure in removing existing widget folder
+    ErrorCreateVconfFailure,         ///< Failure in creating vconf
+    ErrorInstallOspServcie,          ///< Failure in installing osp service
+    ErrorUpdateWidget,               ///< Failure in widget update.
+    ErrorInstallToExt,               ///< Failure in install to sdcard
     ErrorUnknown                     ///< Temporary error. Try to not use this.
 };
 
@@ -57,9 +59,7 @@ DECLARE_JOB_EXCEPTION_BASE(JobExceptionBase, Base, ErrorUnknown)
 // PREPARE
 DECLARE_JOB_EXCEPTION(Base, NotAllowed, ErrorNotAllowed)
 DECLARE_JOB_EXCEPTION(Base, Deferred, ErrorDeferred)
-
-//PARENTAL MODE
-DECLARE_JOB_EXCEPTION(Base, ParentalModeActive, ErrorParentalMode)
+DECLARE_JOB_EXCEPTION(Base, InvalidWidgetUrl, ErrorInvalidWidgetPackage)
 
 //UNZIP
 DECLARE_JOB_EXCEPTION(Base, OpenZipFailed, ErrorInvalidWidgetPackage)
@@ -76,15 +76,35 @@ DECLARE_JOB_EXCEPTION(Base, InvalidPackage, ErrorInvalidPackage)
 
 //WCONFIG
 DECLARE_JOB_EXCEPTION(Base, WidgetConfigFileInvalid, ErrorInvalidWidgetPackage)
-DECLARE_JOB_EXCEPTION(Base, WidgetPowderFileInvalid, 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, CreateVconfFailure, ErrorCreateVconfFailure)
 
 DECLARE_JOB_EXCEPTION(Base, CopyIconFailed, ErrorUnknown)
+
+DECLARE_JOB_EXCEPTION(Base, ErrorExternalInstallingFailure, ErrorInstallToExt)
+
+// Installation osp service
+DECLARE_JOB_EXCEPTION(Base, RequestInstallOspsvc, ErrorInstallOspServcie)
+DECLARE_JOB_EXCEPTION(Base, InstallOspsvcFailed, ErrorInstallOspServcie)
+//UPDATE
+DECLARE_JOB_EXCEPTION(Base, BackupFailed, ErrorUpdateWidget)
+DECLARE_JOB_EXCEPTION(Base, InsertNewWidgetFailed, ErrorUpdateWidget)
+DECLARE_JOB_EXCEPTION(Base, RemoveBackupFailed, ErrorUpdateWidget)
+
+//Database
+DECLARE_JOB_EXCEPTION(Base, UpdateFailed, ErrorInvalidWidgetPackage)
+
+// Plugins copy errors
+DECLARE_JOB_EXCEPTION(Base, EmptyPluginsDirectory, ErrorInvalidWidgetPackage)
+DECLARE_JOB_EXCEPTION(Base, PluginsSubdirectory, ErrorInvalidWidgetPackage)
+
+DECLARE_JOB_EXCEPTION(Base, SetCertificateInfoFailed, ErrorUnknown)
+
 } //namespace
 } //namespace
 } //namespace
diff --git a/src/jobs/widget_install/widget_install_popup.cpp b/src/jobs/widget_install/widget_install_popup.cpp
new file mode 100755 (executable)
index 0000000..34c3fa1
--- /dev/null
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file    widget_install_popup.cpp
+ * @author  lke01.lee (lke01.lee@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for installer popup
+ */
+#include <dpl/log/log.h>
+#include <widget_install/job_widget_install.h>
+#include <widget_install/widget_install_errors.h>
+#include <widget_install/widget_install_context.h>
+#include <widget_install_popup.h>
+
+namespace {
+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 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_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?";
+}
+
+namespace Jobs {
+namespace WidgetInstall {
+WidgetInstallPopup::WidgetInstallPopup(InstallerContext &installContext) :
+    m_win(NULL),
+    m_popup(NULL),
+    m_installContext(installContext),
+    m_installCancel(WRT_POPUP_BUTTON)
+{
+    LogDebug("InstallPopup");
+}
+
+WidgetInstallPopup::~WidgetInstallPopup()
+{
+    LogDebug("~InstallPopup");
+}
+
+bool WidgetInstallPopup::addWin(const char *name)
+{
+    int w, h;
+    m_win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
+    if(!m_win)
+    {
+        LogError("addWin failed");
+        return false;
+    }
+
+    elm_win_alpha_set(m_win, EINA_TRUE);
+    elm_win_title_set(m_win, name);
+    elm_win_borderless_set(m_win, EINA_TRUE);
+    elm_win_raise(m_win);
+
+    ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
+    evas_object_resize(m_win, w, h);
+    return true;
+}
+
+bool WidgetInstallPopup::addPopup()
+{
+    m_popup = elm_popup_add(m_win);
+    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);
+    return true;
+}
+
+void WidgetInstallPopup::addTitle(PopupType type)
+{
+    switch (type) {
+    case PopupType::WIDGET_FEATURE_INFO :
+        elm_object_part_text_set(m_popup, TITLE_TEXT, FEATURE_TITLE);
+    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 :
+        elm_object_part_text_set(m_popup, TITLE_TEXT, WARNING_TITLE);
+    break;
+    case PopupType::WIDGET_WRONG_FEATURE_INFO :
+        elm_object_part_text_set(m_popup, TITLE_TEXT, INSTALLATION_FAILURE);
+    break;
+    default :
+    break;
+}
+}
+
+void WidgetInstallPopup::addScrollLabel(const std::string &str)
+{
+    Evas_Object *ly = elm_layout_add(m_popup);
+    if (!ly)
+    {
+        LogError(" install popup layout add failed");
+        return;
+    }
+    elm_layout_file_set(ly, EDJFILE, "popup");
+    evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
+    evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    evas_object_show(ly);
+    elm_object_content_set(m_popup, ly);
+
+    Evas_Object *question_label = elm_label_add(m_popup);
+    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_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)
+        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);
+    elm_scroller_bounce_set(scroller, EINA_TRUE, EINA_TRUE);
+    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)
+        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_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)
+{
+    switch (type) {
+    case PopupType::WIDGET_FEATURE_INFO :
+        addScrollLabel(str);
+    break;
+    default :
+        elm_object_part_text_set(m_popup, "default", str.c_str());
+    break;
+    }
+}
+
+void WidgetInstallPopup::addButton(PopupType  type)
+{
+    Evas_Object *lbutton = elm_button_add(m_popup);
+    Evas_Object *rbutton = elm_button_add(m_popup);
+    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;
+    }
+
+    elm_object_part_content_set(m_popup, "button1", lbutton);
+    evas_object_smart_callback_add(lbutton,
+            "clicked",
+            userPermitCallback,
+            this);
+    elm_object_part_content_set(m_popup, "button2", rbutton);
+    evas_object_smart_callback_add(rbutton,
+            "clicked",
+            userCancelCallback,
+            this);
+}
+
+bool WidgetInstallPopup::createPopup()
+{
+    bool ret = addWin(name);
+    if(!ret)
+        return false;
+    evas_object_show(m_win);
+
+    ret = addPopup();
+    if(!ret)
+    {
+        evas_object_del(m_win);
+        m_win = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+void WidgetInstallPopup::destroyPopup()
+{
+    if(m_win) {
+           evas_object_del(m_win);
+           m_win = NULL;
+           m_popup = NULL;
+       }
+}
+
+void WidgetInstallPopup::loadPopup(PopupType type, const std::string &label)
+{
+    addTitle(type);
+    addContent(type, label);
+    addButton(type);
+}
+
+void WidgetInstallPopup::showPopup()
+{
+    evas_object_show(m_popup);
+}
+
+void WidgetInstallPopup::userPermitCallback(void * data,
+        Evas_Object */*obj*/,
+        void */*event_info*/)
+{
+    WidgetInstallPopup *This = static_cast<WidgetInstallPopup *>(data);
+    This->m_installCancel = WRT_POPUP_BUTTON_OK;
+    This->m_installContext.job->Resume();
+}
+
+void WidgetInstallPopup::userCancelCallback(void *data,
+        Evas_Object */*obj*/,
+        void */*event_info*/)
+{
+    WidgetInstallPopup *This = static_cast<WidgetInstallPopup *>(data);
+    This->m_installCancel = WRT_POPUP_BUTTON_CANCEL;
+    This->m_installContext.job->Resume();
+}
+}
+}
+
+
diff --git a/src/jobs/widget_install/widget_install_popup.h b/src/jobs/widget_install/widget_install_popup.h
new file mode 100755 (executable)
index 0000000..d2859f7
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file    widget_install_popup.h
+ * @author  lke01.lee (lke01.lee@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for installer popup
+ */
+
+#ifndef WIDGET_INSTALL_POPUP_H
+#define WIDGET_INSTALL_POPUP_H
+
+#include <Evas.h>
+#include <Ecore_X.h>
+#include <Elementary.h>
+
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+
+enum PopupType {
+    WIDGET_INSTALL_POPUP = 0,
+    WIDGET_FEATURE_INFO,  //sp-2390
+    WIDGET_WRONG_FEATURE_INFO,  //sp-3240
+    WIDGET_AUTHOR_INFO,
+    WIDGET_MIN_VERSION,  //sp-3240
+    WIDGET_UNRECOGNIZED
+};
+
+enum InfoPopupButton
+{
+    WRT_POPUP_BUTTON = 0,
+    WRT_POPUP_BUTTON_OK,
+    WRT_POPUP_BUTTON_CANCEL
+};
+
+
+class 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);
+
+      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;
+};
+}
+}
+#endif
+
old mode 100644 (file)
new mode 100755 (executable)
index 33674ad..2a655c8
 #include <job.h>
 #include <widget_install/widget_install_errors.h>
 #include <wrt_common_types.h>
+#include <pkgmgr_signal_interface.h>
+#include <memory>
+#include <string>
 
 //Widget Installer typedefs
 typedef void (*InstallerFinishedCallback)(
     void *userParam,
-    WidgetHandle,
+    std::string tizenId,
     Jobs::WidgetInstall::Exceptions::Type);
 
 typedef void (*InstallerProgressCallback)(void *userParam,
@@ -70,7 +73,8 @@ enum Type
         ExistingVersionEqual |
         ExistingVersionNewer,
 
-    PolicyForceInstall = PolicyAlwaysInstall
+    PolicyForceInstall = PolicyAlwaysInstall,
+    PolicyDirectoryForceInstall
 };
 
 inline Type operator | (const Type &a,
@@ -98,18 +102,30 @@ WidgetInstallCallbackBase;
 struct WidgetInstallationStruct : public WidgetInstallCallbackBase
 {
     WidgetUpdateMode::Type updateMode;
+    bool m_quiet;
+    bool m_preload;
+    std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrInterface;
 
     // It must be empty-constructible as a parameter of generic event
-    WidgetInstallationStruct() : updateMode(WidgetUpdateMode::Zero)
+    WidgetInstallationStruct() : updateMode(WidgetUpdateMode::Zero),
+                                m_quiet(true),
+                                m_preload(false)
     {
     }
 
     WidgetInstallationStruct(InstallerFinishedCallback finished,
             InstallerProgressCallback progress,
             void *param,
-            WidgetUpdateMode::Type mode) :
+            WidgetUpdateMode::Type mode,
+            bool quiet,
+            bool preload,
+            std::shared_ptr<PackageManager::IPkgmgrSignal> _pkgmgrInterface
+            ) :
         WidgetInstallCallbackBase(finished, progress, param),
-        updateMode(mode)
+        updateMode(mode),
+        m_quiet(quiet),
+        m_preload(preload),
+        pkgmgrInterface(_pkgmgrInterface)
     {
     }
 };
index e0b124c..3e93084 100644 (file)
 #include "widget_update_info.h"
 
 WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo() :
-    isExist(false),
-    existingHandle(0)
+    isExist(false)
 {
 }
 
 WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo(
-    const WidgetHandle handle,
+    const WrtDB::WidgetPkgName & name,
     const DPL::Optional<WidgetVersion> &version) :
+    pkgname(name),
     isExist(true),
-    existingHandle(handle),
     existingVersion(version)
 {
 }
 
 WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo(
-    const WidgetHandle handle,
+    const WrtDB::WidgetPkgName & name,
     const DPL::Optional<DPL::String> &version) :
-    isExist(true),
-    existingHandle(handle)
+    pkgname(name),
+    isExist(true)
 {
     if (!!version) {
         existingVersion = WidgetVersion(*version);
index d08540e..9f10cb3 100644 (file)
@@ -34,14 +34,14 @@ struct WidgetUpdateInfo
 {
     struct ExistingWidgetInfo
     {
+        WrtDB::WidgetPkgName pkgname;
         bool isExist;
-        WidgetHandle existingHandle;
         DPL::Optional<WidgetVersion> existingVersion;
 
         ExistingWidgetInfo();
-        ExistingWidgetInfo(const WidgetHandle handle,
+        ExistingWidgetInfo(const WrtDB::WidgetPkgName & name,
                            const DPL::Optional<WidgetVersion> &version);
-        ExistingWidgetInfo(const WidgetHandle handle,
+        ExistingWidgetInfo(const WrtDB::WidgetPkgName & name,
                            const DPL::Optional<DPL::String> &version);
     };
 
index 8c1c5b8..3cb8d82 100644 (file)
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
  */
+
 #include <widget_uninstall/job_widget_uninstall.h>
+#include <widget_uninstall/widget_uninstall_errors.h>
 #include <widget_uninstall/task_check.h>
 #include <widget_uninstall/task_db_update.h>
 #include <widget_uninstall/task_remove_files.h>
+#include <widget_uninstall/task_remove_custom_handlers.h>
 #include <widget_uninstall/task_smack.h>
+#include <widget_uninstall/task_uninstall_ospsvc.h>
+#include <widget_uninstall/task_delete_certificates.h>
+#include <pkg-manager/pkgmgr_signal.h>
+#include <app2ext_interface.h>
 
 using namespace WrtDB;
 
+namespace { //anonymous
+class UninstallerTaskFail :
+    public DPL::TaskDecl<UninstallerTaskFail>
+{
+  private:
+    bool m_uninstalled;
+
+    void StepFail()
+    {
+        if(m_uninstalled) {
+            ThrowMsg(Jobs::WidgetUninstall::Exceptions::WidgetNotExist,
+                    "Widget does not exist");
+        } else {
+            Throw(Jobs::WidgetUninstall::Exceptions::Base);
+        }
+    }
+
+  public:
+    UninstallerTaskFail(bool uninstalled) :
+        DPL::TaskDecl<UninstallerTaskFail>(this),
+        m_uninstalled(uninstalled)
+    {
+        AddStep(&UninstallerTaskFail::StepFail);
+    }
+};
+}
+
 namespace Jobs {
 namespace WidgetUninstall {
-JobWidgetUninstall::JobWidgetUninstall(WidgetHandle widgetHandle,
+JobWidgetUninstall::JobWidgetUninstall(const std::string & widgetPkgName,
         const WidgetUninstallationStruct &uninstallerStruct) :
     Job(Uninstallation),
     JobContextBase<WidgetUninstallationStruct>(uninstallerStruct)
 {
-    WidgetDAO dao(widgetHandle);
-
-    m_context.widgetHandle = widgetHandle;
+    using namespace PackageManager;
     m_context.removeStarted = false;
     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);
+
+        LogInfo("Widget model exists. Pkg name: " << m_context.pkgname);
+
+        AddTask(new TaskSmack(m_context));
+        AddTask(new TaskCheck(m_context));
 
-    AddTask(new TaskSmack(m_context));
-    AddTask(new TaskCheck(m_context));
-    AddTask(new TaskRemoveFiles(m_context));
-    AddTask(new TaskDbUpdate(m_context));
+        if (dao.getPackagingType() == PKG_TYPE_HYBRID_WEB_APP) {
+            AddTask(new TaskUninstallOspsvc(m_context));
+        }
+        AddTask(new TaskRemoveFiles(m_context));
+        AddTask(new TaskDbUpdate(m_context));
+        AddTask(new TaskRemoveCustomHandlers(m_context));
+        AddTask(new TaskDeleteCertificates(m_context));
+
+        // send start signal of pkgmgr
+        if (getInstallerStruct().pkgmgrInterface->setPkgname(m_context.pkgname)) {
+            getInstallerStruct().pkgmgrInterface->sendSignal(
+                    PKGMGR_START_KEY,
+                    PKGMGR_START_UNINSTALL);
+        }
+    } Catch (WidgetDAOReadOnly::Exception::WidgetNotExist) {
+        AddTask(new UninstallerTaskFail(true));
+    } Catch (WidgetDAOReadOnly::Exception::Base) {
+        AddTask(new UninstallerTaskFail(false));
+    }
 }
 
-WidgetHandle JobWidgetUninstall::getRemovedWidgetHandle() const
+std::string JobWidgetUninstall::getRemovedTizenId() const
 {
-    return m_context.widgetHandle;
+    return m_context.pkgname;
 }
 
 bool JobWidgetUninstall::getRemoveStartedFlag() const
@@ -59,9 +118,17 @@ bool JobWidgetUninstall::getRemoveFinishedFlag() const
 
 void JobWidgetUninstall::SendProgress()
 {
+    using namespace PackageManager;
     if (!getRemoveStartedFlag() ||
         (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());
+
             LogDebug("Call widget uninstall progressCallback");
             getInstallerStruct().progressCallback(
                     getInstallerStruct().userParam,
@@ -72,19 +139,31 @@ void JobWidgetUninstall::SendProgress()
 
 void JobWidgetUninstall::SendFinishedSuccess()
 {
+    using namespace PackageManager;
+    // send signal of pkgmgr
+    getInstallerStruct().pkgmgrInterface->sendSignal(
+                PKGMGR_END_KEY,
+                PKGMGR_END_SUCCESS);
+
     LogDebug("Call widget uninstall success finishedCallback");
     getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
-            getRemovedWidgetHandle(),Exceptions::Success);
+            getRemovedTizenId(),Exceptions::Success);
 }
 
 void JobWidgetUninstall::SendFinishedFailure()
 {
+    using namespace PackageManager;
     LogError("Error in uninstallation step: " << m_exceptionCaught);
     LogError("Message: " << m_exceptionMessage);
 
+    // send signal of pkgmgr
+    getInstallerStruct().pkgmgrInterface->sendSignal(
+                PKGMGR_END_KEY,
+                PKGMGR_END_FAILURE);
+
     LogDebug("Call widget uninstall failure finishedCallback");
     getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
-        getRemovedWidgetHandle(), m_exceptionCaught); //TODO
+            getRemovedTizenId(), m_exceptionCaught); //TODO
     LogDebug("[JobWidgetUninstall] Asynchronous failure callback status sent");
 }
 
@@ -93,5 +172,17 @@ void JobWidgetUninstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
     m_exceptionCaught = static_cast<Exceptions::Type>(e.getParam());
     m_exceptionMessage = e.GetMessage();
 }
+
+bool JobWidgetUninstall::getExternalWidgetFlag() const
+{
+
+    LogDebug("Get external widget");
+    if (APP2EXT_SD_CARD == app2ext_get_app_location(m_context.pkgname.c_str())) {
+        LogDebug("This widget is in external stroage");
+        return true;
+    }
+    return false;
+}
+
 } //namespace WidgetUninstall
 } //namespace Jobs
index ddf3b4e..80c188c 100644 (file)
@@ -22,6 +22,7 @@
 #ifndef WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_JOB_WIDGET_UNINSTALL_H_
 #define WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_JOB_WIDGET_UNINSTALL_H_
 
+#include <string>
 #include <job.h>
 #include <job_base.h>
 #include <widget_uninstall/widget_uninstaller_struct.h>
@@ -46,14 +47,15 @@ class JobWidgetUninstall :
     /**
      * @brief Uninstaller must to know which widget to uninstall.
      *
-     * @param[in] const int& widget_id - wdget to uninstall
+     * @param[in] WrtDB::WidgetPkgName widgetPkgName - widget to uninstall
      */
-    JobWidgetUninstall(WidgetHandle widgetHandle,
+    JobWidgetUninstall(const std::string &widgetPkgName,
             const WidgetUninstallationStruct& uninstallerStruct);
 
-    WidgetHandle getRemovedWidgetHandle() const;
+    std::string getRemovedTizenId() const;
     bool getRemoveStartedFlag() const;
     bool getRemoveFinishedFlag() const;
+    bool getExternalWidgetFlag() const;
 
     void SendProgress();
     void SendFinishedSuccess();
index e1eb8d4..8670ac5 100644 (file)
 #include <widget_uninstall/task_check.h>
 #include <widget_uninstall/job_widget_uninstall.h>
 #include <widget_uninstall/uninstaller_context.h>
+#include <widget_uninstall/widget_uninstall_errors.h>
 #include <dpl/wrt-dao-ro/global_config.h>
-#include <aul.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <app_manager.h>
 
 namespace Jobs {
 namespace WidgetUninstall {
@@ -41,15 +43,20 @@ TaskCheck::~TaskCheck()
 
 void TaskCheck::StepUninstallPreCheck()
 {
-    LogInfo("Uninstall check for widget Handle: " << m_context.widgetHandle);
+    LogInfo("Uninstall check for pkgname: " << m_context.locations->getPkgname());
     //check if deferred
     //TODO if widget to be updated, then remove it from Deferred list?
 
-    DPL::OptionalString pkgName =
-            WrtDB::WidgetDAO(m_context.widgetHandle).getPkgname();
+    int ret = APP_MANAGER_ERROR_NONE;
+    bool isRunning = false;
+    ret = app_manager_is_running(m_context.pkgname.c_str(), &isRunning);
+    if (APP_MANAGER_ERROR_NONE != ret) {
+        LogError("Fail to get running state");
+        ThrowMsg(Exceptions::PlatformAPIFailure,
+                 "Fail to get widget state");
+    }
 
-    LogInfo("Widget model exists. Pkg name: " << pkgName);
-    if (aul_app_is_running(DPL::ToUTF8String(*pkgName).c_str())) {
+    if (true == isRunning) {
         LogError("Widget is not stopped. Cannot uninstall!");
         //TODO different error
         ThrowMsg(Exceptions::AlreadyUninstalling,
@@ -57,8 +64,8 @@ void TaskCheck::StepUninstallPreCheck()
         //TODO or defer uninstall?
     }
 
-    LogInfo("Widget Can be uninstalled. Handle : " << m_context.widgetHandle);
-    m_context.job->UpdateProgress(UninstallerContext::UNINSTALL_CHECK,
+    LogInfo("Widget Can be uninstalled. Pkgname : " << m_context.locations->getPkgname());
+    m_context.job->UpdateProgress(UninstallerContext::UNINSTALL_PRECHECK,
                                   "Uninstall pre-checking Finished");
 }
 
index a7db085..d3f2c93 100644 (file)
 #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>
 
 using namespace WrtDB;
 
@@ -45,13 +48,16 @@ void TaskDbUpdate::StepDbUpdate()
 {
     Try
     {
-        WidgetDAO::unregisterWidget(m_context.widgetHandle);
+        //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());
 
         LogDebug("Unregistered widget successfully!");
     }
     Catch(DPL::DB::SqlConnection::Exception::Base)
     {
-        LogDebug("Failed to handle StepDbUpdate!");
+        LogError("Failed to handle StepDbUpdate!");
         ReThrowMsg(Exceptions::DatabaseFailure,
                    "Failed to handle StepDbUpdate!");
     }
diff --git a/src/jobs/widget_uninstall/task_delete_certificates.cpp b/src/jobs/widget_uninstall/task_delete_certificates.cpp
new file mode 100755 (executable)
index 0000000..d656c39
--- /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.
+ */
+/**
+ * @file    task_delete_certificates.cpp
+ * @author  Leerang Song(leerang.song@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for uninstaller delete certi info from pkgmgr
+ */
+
+#include <widget_uninstall/task_delete_certificates.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 <pkgmgr_installer.h>
+#include <dpl/assert.h>
+
+namespace Jobs {
+namespace WidgetUninstall {
+TaskDeleteCertificates::TaskDeleteCertificates(
+    UninstallerContext& context) :
+    DPL::TaskDecl<TaskDeleteCertificates>(this),
+    m_context(context)
+{
+    AddStep(&TaskDeleteCertificates::StepDeleteCertificates);
+}
+
+TaskDeleteCertificates::~TaskDeleteCertificates()
+{
+}
+
+void TaskDeleteCertificates::StepDeleteCertificates()
+{
+    pkgmgr_instcertinfo_h handle;
+
+    if ((pkgmgr_installer_delete_certinfo(
+                    const_cast<char*>((
+                            m_context.pkgname).c_str()))) < 0) {
+        LogError("pkgmgr_installer_delete_certinfo fail");
+    }
+}
+} //namespace WidgetUninstall
+} //namespace Jobs
diff --git a/src/jobs/widget_uninstall/task_delete_certificates.h b/src/jobs/widget_uninstall/task_delete_certificates.h
new file mode 100644 (file)
index 0000000..94efa67
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    task_delete_certificates.h
+ * @author  Leerang Song(leerang.song@samsung.com)
+ * @version 1.0
+ * @brief   Header file for uninstaller task delete certi info from pkgmgr
+ */
+
+#ifndef WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_DELETE_CERTIFICATES_H_
+#define WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_DELETE_CERTIFICATES_H_
+
+#include <dpl/task.h>
+
+#include <widget_uninstall/uninstaller_context.h> //todo forward decl
+
+#include <string>
+
+namespace Jobs {
+namespace WidgetUninstall {
+class TaskDeleteCertificates :
+    public DPL::TaskDecl<TaskDeleteCertificates>
+{
+    UninstallerContext& m_context;
+
+  private:
+    void StepDeleteCertificates();
+
+  public:
+    TaskDeleteCertificates(UninstallerContext& context);
+    virtual ~TaskDeleteCertificates();
+};
+} //namespace WidgetUninstall
+} //namespace Jobs
+
+#endif // WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_DELETE_CERTIFICATES_H_
diff --git a/src/jobs/widget_uninstall/task_remove_custom_handlers.cpp b/src/jobs/widget_uninstall/task_remove_custom_handlers.cpp
new file mode 100644 (file)
index 0000000..5c020a9
--- /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.
+ */
+/*
+ * @file    task_remove_custom_handlers.cpp
+ * @author  Przemyslaw Ciezkowski (p.ciezkowski@samsung.com)
+ * @version 1.0
+ * @brief   File for uninstaller - remove custom handlers
+ */
+
+#include <widget_uninstall/task_remove_custom_handlers.h>
+#include <widget_uninstall/uninstaller_context.h>
+#include <dpl/log/log.h>
+#include <dpl/optional_typedefs.h>
+#include <appsvc.h>
+#include <wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h>
+#include <wrt-commons/custom-handler-dao-rw/custom_handler_dao.h>
+
+namespace Jobs {
+namespace WidgetUninstall {
+TaskRemoveCustomHandlers::TaskRemoveCustomHandlers(UninstallerContext& context) :
+    DPL::TaskDecl<TaskRemoveCustomHandlers>(this),
+    m_context(context)
+{
+    AddStep(&TaskRemoveCustomHandlers::Step);
+}
+
+void TaskRemoveCustomHandlers::Step()
+{
+    LogDebug("Removing widget from appsvc");
+    int result = appsvc_unset_defapp(m_context.pkgname.c_str());
+    LogDebug("Result: " << result);
+
+    CustomHandlerDB::Interface::attachDatabaseRW();
+    CustomHandlerDB::CustomHandlerDAO handlersDao(
+            DPL::FromASCIIString(m_context.pkgname));
+    handlersDao.removeWidgetProtocolHandlers();
+    handlersDao.removeWidgetContentHandlers();
+    CustomHandlerDB::Interface::detachDatabase();
+}
+
+} //namespace WidgetUninstall
+} //namespace Jobs
diff --git a/src/jobs/widget_uninstall/task_remove_custom_handlers.h b/src/jobs/widget_uninstall/task_remove_custom_handlers.h
new file mode 100644 (file)
index 0000000..c0812c1
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file    task_remove_custom_handlers.h
+ * @author  Przemyslaw Ciezkowski (p.ciezkowski@samsung.com)
+ * @version 1.0
+ * @brief   Header file for uninstaller - remove custom handlers
+ */
+#ifndef INSTALLER_CORE_JOBS_WIDGET_UNINSTALL_TASK_REMOVE_CUSTOM_HANDLERS_H
+#define INSTALLER_CORE_JOBS_WIDGET_UNINSTALL_TASK_REMOVE_CUSTOM_HANDLERS_H
+
+#include <dpl/task.h>
+
+class UninstallerContext;
+
+namespace Jobs {
+namespace WidgetUninstall {
+class TaskRemoveCustomHandlers:
+    public DPL::TaskDecl<TaskRemoveCustomHandlers>
+{
+  private:
+    UninstallerContext& m_context;
+
+    void Step();
+
+  public:
+    TaskRemoveCustomHandlers(UninstallerContext& context);
+};
+} //namespace WidgetUninstall
+} //namespace Jobs
+
+#endif /* INSTALLER_CORE_JOBS_WIDGET_UNINSTALL_TASK_REMOVE_CUSTOM_HANDLERS_H */
index efde73b..d7c3157 100644 (file)
 
 #include <widget_uninstall/task_remove_files.h>
 #include <widget_uninstall/job_widget_uninstall.h>
+#include <widget_uninstall/uninstaller_context.h>
+#include <dpl/wrt-dao-rw/widget_dao.h>
 #include <dpl/wrt-dao-ro/widget_config.h>
-
-#include <errno.h>
+#include <dpl/wrt-dao-ro/vconf_config.h>
 #include <dpl/assert.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <dirent.h>
 #include <dpl/utils/wrt_utility.h>
+#include <ail.h>
+#include <pkgmgr/pkgmgr_parser.h>
+#include <errno.h>
+#include <string.h>
+#include <widget_install_to_external.h>
+#include <vconf.h>
 
 namespace Jobs {
 namespace WidgetUninstall {
 
 using namespace WrtDB;
 
-void TaskRemoveFiles::ReadDir(const std::string& path,
-        std::list<std::string>& filesList)
-{
-    LogInfo("Reading directory " << path);
-    DIR* dir = NULL;
-    struct dirent* ptr = NULL;
-    dir = opendir(path.c_str());
-    std::string delim = "";
-
-    // adding / for path to directory to build a proper path to file under directory
-    if (path[path.size() - 1] != '/') {
-        delim = "/";
-    }
-
-    if (dir) {
-        while ((ptr = readdir(dir)) != NULL) {
-            if ((!strcmp(ptr->d_name, ".")) || (!strcmp(ptr->d_name, ".."))) {
-                LogPedantic("Omiting " << ptr->d_name);
-                continue;
-            }
-            std::string childPath = path + delim + ptr->d_name;
-
-            struct stat st;
-            if (0 != lstat(childPath.c_str(), &st)) {
-                switch (errno) {
-                case EACCES:
-                    LogWarning(
-                        "EACCESS Error occured during lstat with path: " <<
-                        childPath);
-                    continue;
-                case EBADF:
-                    LogWarning(
-                        "EBADF Error occured during lstat with path: " <<
-                        childPath);
-                    continue;
-                case ENOENT:
-                    LogWarning(
-                        "ENOENT Error occured during lstat with path: " <<
-                        childPath);
-                    continue;
-                case ENOTDIR:
-                    LogWarning(
-                        "ENOTDIR Error occured during lstat with path: " <<
-                        childPath);
-                    continue;
-                default:
-                    LogWarning(
-                        "Unknown Error occured during lstat with path: " <<
-                        childPath);
-                    continue;
-                }
-            } else {
-                if (S_ISDIR(st.st_mode)) {
-                    LogPedantic(
-                        "Calling ReadDir in recursive way " << childPath);
-                    ReadDir(childPath, filesList);
-                } else if (S_ISREG(st.st_mode) ||
-                           S_ISCHR(st.st_mode) ||
-                           S_ISBLK(st.st_mode) ||
-                           S_ISFIFO(st.st_mode) ||
-                           S_ISLNK(st.st_mode) ||
-                           S_ISSOCK(st.st_mode)) {
-                    LogPedantic("Adding to list  " << childPath);
-                    filesList.push_front(childPath);
-                } else {
-                    LogWarning("Uknown file type ??");
-                }
-            }
-        }
-        closedir(dir);
-    } else if (errno == ENOTDIR) {
-        LogDebug("Adding to list " << path);
-        filesList.push_front(path);
-    } else {
-        LogWarning("Unknown error");
-    }
+namespace {
+const char * const VCONF_KEY_PREFIX = "file/private/";
 }
 
 TaskRemoveFiles::TaskRemoveFiles(UninstallerContext& context) :
     DPL::TaskDecl<TaskRemoveFiles>(this),
     m_context(context)
 {
-    AddStep(&TaskRemoveFiles::StepPrepare);
-    AddStep(&TaskRemoveFiles::StepRemoveOneFile);
-    AddStep(&TaskRemoveFiles::StepRemoveDirectories);
-    AddStep(&TaskRemoveFiles::StepRemoveDesktop);
+    if (!m_context.isExternalWidget) {
+        AddStep(&TaskRemoveFiles::StepRemoveInstallationDirectory);
+    } else {
+        AddStep(&TaskRemoveFiles::StepRemoveExternalWidget);
+    }
+    //AddStep(&TaskRemoveFiles::StepRemoveDesktop);
+    AddStep(&TaskRemoveFiles::StepRemoveManifest);
+    AddStep(&TaskRemoveFiles::StepRemoveExternalLocations);
+    AddStep(&TaskRemoveFiles::StepRemoveVconf);
     AddStep(&TaskRemoveFiles::StepRemoveFinished);
 }
 
@@ -130,58 +64,23 @@ TaskRemoveFiles::~TaskRemoveFiles()
 {
 }
 
-void TaskRemoveFiles::StepPrepare()
+void TaskRemoveFiles::StepRemoveInstallationDirectory()
 {
-    LogInfo("StepPrepare started");
-
-    std::ostringstream widgetDir;
-
-    DPL::OptionalString pkgname = WidgetDAO(m_context.widgetHandle).getPkgname();
-    widgetDir << GlobalConfig::GetUserInstalledWidgetPath() << "/";
-    widgetDir << pkgname << "/";
-
-    uninstRootDir = widgetDir.str();
-    ReadDir(uninstRootDir, filesList);
+    LogInfo("StepRemoveInstallationDirectory started");
 
-    LogInfo("StepPrepare finished");
-
-    m_context.job->UpdateProgress(
-        UninstallerContext::UNINSTALL_REMOVE_PREPARE,
-        "Widget remove prepare Finished");
     m_context.removeStarted = true;
-}
-
-void TaskRemoveFiles::StepRemoveOneFile()
-{
-    if (filesList.size() > 0) {
-        LogDebug("Removing " << filesList.front());
-        if (0 != unlink(filesList.front().c_str())) {
-            LogWarning("Failed to remove file" << filesList.front());
-        }
-        filesList.pop_front();
-        SwitchToStep(&TaskRemoveFiles::StepRemoveOneFile);
-    } else {
-        m_context.removeFinished = true;
+    std::string widgetDir =
+        m_context.locations->getPackageInstallationDir();
+    if(!WrtUtilRemove(widgetDir)){
+        LogWarning("Removing widget installation directory failed");
     }
-
-    m_context.job->UpdateProgress(
-        UninstallerContext::UNINSTALL_REMOVE_ONEFILE,
-        "Widget remove onefile Finished");
-}
-
-void TaskRemoveFiles::StepRemoveDirectories()
-{
-    using namespace WrtDB;
-    LogInfo("StepRemoveDirectories started");
-
-    if (!_WrtUtilRemoveDir(uninstRootDir.c_str())) {
-        LogWarning("Failed to remove directory" << uninstRootDir.c_str());
+    std::string dataDir = m_context.locations->getUserDataRootDir();
+    if(!WrtUtilRemove(dataDir)){
+        LogWarning(dataDir + " is already removed");
     }
-    LogInfo("StepRemoveDirectories finished");
-
     m_context.job->UpdateProgress(
-        UninstallerContext::UNINSTALL_REMOVE_DIRECTORIES,
-        "Widget remove directories Finished");
+        UninstallerContext::UNINSTALL_REMOVE_WIDGETDIR,
+        "Widget INstallation Directory Removal Finished");
 }
 
 void TaskRemoveFiles::StepRemoveFinished()
@@ -197,15 +96,110 @@ void TaskRemoveFiles::StepRemoveDesktop()
 {
     std::ostringstream desktopFile;
 
-    DPL::OptionalString pkgname = WidgetDAO(m_context.widgetHandle).getPkgname();
     desktopFile << GlobalConfig::GetUserWidgetDesktopPath() << "/";
-    desktopFile << pkgname << ".desktop";
+    desktopFile << m_context.pkgname << ".desktop";
 
     unlink(desktopFile.str().c_str());
 
+    ail_appinfo_h ai = NULL;
+    ail_error_e ret;
+
+    const char* package = m_context.pkgname.c_str();
+    LogDebug("ail delete : " << package);
+
+    ret = ail_package_get_appinfo(package, &ai);
+    if (ai) {
+        ail_package_destroy_appinfo(ai);
+    }
+
+    if (AIL_ERROR_OK == ret) {
+        if ( 0 > ail_desktop_remove(package)) {
+            LogWarning("Failed to remove ail information : " << package);
+        }
+    }
+
     m_context.job->UpdateProgress(
         UninstallerContext::UNINSTALL_REMOVE_DESKTOP,
         "Widget remove desktop Finished");
 }
+
+void TaskRemoveFiles::StepRemoveManifest()
+{
+    std::ostringstream manifest_name;
+    manifest_name << m_context.pkgname << ".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 ret2 = unlink(destFile.str().c_str());
+    if(ret1 != 0)
+    {
+        LogWarning("Manifest file failed to parse for uninstallation");
+    }
+    if(ret2 != 0)
+    {
+        LogWarning("No manifest file found: " << destFile.str());
+    }
+    else
+    {
+        LogDebug("Manifest file removed: " << destFile.str());
+    }
+}
+
+void TaskRemoveFiles::StepRemoveExternalLocations()
+{
+    WidgetDAO dao(m_context.locations->getPkgname());
+    LogDebug("Removing external locations:");
+    WrtDB::ExternalLocationList externalPaths = dao.getWidgetExternalLocations();
+    FOREACH(path, externalPaths)
+    {
+        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));
+            }
+        }
+        else if(WrtUtilDirExists(*path))
+        {
+            LogDebug("  -> " << *path);
+            if(!WrtUtilRemove(*path)){
+                Throw(Jobs::WidgetUninstall::TaskRemoveFiles::Exception::RemoveFilesFailed);
+            }
+        }
+        else
+        {
+            LogWarning("  -> " << *path << "(no such a path)");
+        }
+    }
+    dao.unregisterAllExternalLocations();
+}
+
+void TaskRemoveFiles::StepRemoveVconf()
+{
+    std::string key =
+        WrtDB::VconfConfig::GetVconfKeyRootPath(
+            m_context.locations->getPkgname());
+    if(vconf_unset_recursive(key.c_str())) {
+        LogError("Fail to unset vconf file");
+    } else {
+        LogDebug("vconf file is removed");
+    }
+}
+
+void TaskRemoveFiles::StepRemoveExternalWidget()
+{
+    Try {
+        WidgetInstallToExtSingleton::Instance().initialize(m_context.pkgname);
+        WidgetInstallToExtSingleton::Instance().uninstallation();
+        WidgetInstallToExtSingleton::Instance().deinitialize();
+    }
+    Catch (WidgetInstallToExt::Exception::ErrorInstallToExt)
+    {
+        Throw(Jobs::WidgetUninstall::TaskRemoveFiles::Exception::RemoveFilesFailed);
+    }
+}
+
 } //namespace WidgetUninstall
 } //namespace Jobs
index 393732b..0336443 100644 (file)
 #ifndef WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_REMOVE_FILES_H_
 #define WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_REMOVE_FILES_H_
 
-#include <dpl/task.h>
-#include <dpl/wrt-dao-rw/widget_dao.h> //todo not needed here
+//forward declaration
+struct UninstallerContext;
 
-#include <widget_uninstall/uninstaller_context.h> //TODO forward decl
+#include <dpl/task.h>
+#include <dpl/log/log.h>
 
 #include <string>
 
@@ -43,18 +44,15 @@ class TaskRemoveFiles :
     };
 
     UninstallerContext& m_context;
-    std::list<std::string> filesList;
-    std::string uninstRootDir;
-
-    static void ReadDir(const std::string& path,
-            std::list<std::string>& filesList);
 
   private:
-    void StepPrepare();
-    void StepRemoveOneFile();
-    void StepRemoveDirectories();
+    void StepRemoveInstallationDirectory();
     void StepRemoveFinished();
     void StepRemoveDesktop();
+    void StepRemoveManifest();
+    void StepRemoveExternalLocations();
+    void StepRemoveVconf();
+    void StepRemoveExternalWidget();
 
   public:
     explicit TaskRemoveFiles(UninstallerContext& context);
index 0d529ca..23d2df6 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <widget_uninstall/task_smack.h>
 #include <widget_uninstall/uninstaller_context.h>
+#include <dpl/log/log.h>
 #include <dpl/optional_typedefs.h>
 #ifdef WRT_SMACK_ENABLED
 #include <privilege-control.h>
@@ -41,18 +42,21 @@ void TaskSmack::Step()
     LogInfo("------------------------> SMACK: Jobs::WidgetUninstall::TaskSmack::Step()");
 #ifdef WRT_SMACK_ENABLED
     try {
-      WrtDB::WidgetDAOReadOnly dao(m_context.widgetHandle);
-      DPL::OptionalString pkgName = dao.getPkgname();
-      Assert(!pkgName.IsNull() && "widget doesn't have a pkg name");
+      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(),
+                       DPL::ToUTF8String(pkgName).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");
     }
+
+    m_context.job->UpdateProgress(
+        UninstallerContext::INSTALL_SMACK_ENABLE,
+        "Widget SMACK Enabled");
 #endif
 }
 
diff --git a/src/jobs/widget_uninstall/task_uninstall_ospsvc.cpp b/src/jobs/widget_uninstall/task_uninstall_ospsvc.cpp
new file mode 100644 (file)
index 0000000..187d958
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    task_uninstall_ospsvc.cpp
+ * @author  Soyoung Kim(sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief   Header file for widget uninstall task to uninstall ospsvc
+ */
+#include <dpl/sstream.h>
+#include <dpl/utils/bash_utils.h>
+#include <widget_uninstall/task_uninstall_ospsvc.h>
+#include <widget_uninstall/job_widget_uninstall.h>
+#include <widget_uninstall/uninstaller_context.h>
+#include <widget_uninstall/widget_uninstall_errors.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+
+using namespace WrtDB;
+
+namespace {
+const int MAX_BUF_SIZE = 128;
+const char* OSP_INSTALL_STR = "/usr/etc/package-manager/backend/tpk -uv ";
+}
+
+namespace Jobs {
+namespace WidgetUninstall {
+TaskUninstallOspsvc::TaskUninstallOspsvc(UninstallerContext& context) :
+    DPL::TaskDecl<TaskUninstallOspsvc>(this),
+    m_context(context)
+{
+    AddStep(&TaskUninstallOspsvc::StepUninstallOspsvc);
+}
+
+TaskUninstallOspsvc::~TaskUninstallOspsvc()
+{
+}
+
+void TaskUninstallOspsvc::StepUninstallOspsvc()
+{
+    LogInfo("Step : Uninstall Osp service ");
+
+    std::ostringstream commStr;
+    commStr << OSP_INSTALL_STR << BashUtils::escape_arg(m_context.pkgname);
+    LogDebug("osp uninstall command : " << commStr.str());
+
+    char readBuf[MAX_BUF_SIZE];
+    FILE *fd;
+    fd = popen(commStr.str().c_str(), "r");
+    if (NULL == fd) {
+        LogError("Failed to uninstalltion osp service");
+        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\
+                install osp service");
+    }
+
+    pclose(fd);
+    
+    LogInfo("Widget Can be uninstalled. Pkgname : " << m_context.pkgname);
+    m_context.job->UpdateProgress(UninstallerContext::UNINSTALL_REMOVE_OSPSVC,
+                                  "Uninstall OSP service finished");
+}
+
+} //namespace WidgetUninstall
+} //namespace Jobs
diff --git a/src/jobs/widget_uninstall/task_uninstall_ospsvc.h b/src/jobs/widget_uninstall/task_uninstall_ospsvc.h
new file mode 100644 (file)
index 0000000..3ba8d41
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    task_uninstall_ospsvc.h
+ * @author  Pawel Sikorski(p.sikorski@samsung.com)
+ * @version 1.0
+ * @brief   Header file for widget uninstall task to uninstall ospsvc
+ */
+
+#ifndef WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_UNINSTALL_OSPSVC_H
+#define WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_UNINSTALL_OSPSVC_H
+
+#include <dpl/task.h>
+
+struct UninstallerContext; //forward declaration
+
+namespace Jobs {
+namespace WidgetUninstall {
+class TaskUninstallOspsvc :
+    public DPL::TaskDecl<TaskUninstallOspsvc>
+{
+  private:
+    //context
+    UninstallerContext& m_context;
+
+    //steps
+    void StepUninstallOspsvc();
+
+  public:
+    TaskUninstallOspsvc(UninstallerContext& context);
+    virtual ~TaskUninstallOspsvc();
+};
+} //namespace WidgetUninstall
+} //namespace Jobs
+
+#endif /* WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_UNINSTALL_OSPSVC_H */
index 9317654..caedcb7 100644 (file)
@@ -24,8 +24,8 @@
 #define WRT_SRC_INSTALLER_CORE_UNINSTALLER_TASKS_UNINSTALLER_CONTEXT_H_
 
 #include <string>
-#include <dpl/wrt-dao-rw/widget_dao.h>
 #include <widget_uninstall/widget_uninstaller_struct.h>
+#include <widget_location.h>
 
 namespace Jobs {
 namespace WidgetUninstall {
@@ -38,26 +38,29 @@ struct UninstallerContext
     enum UninstallStep
     {
         UNINSTALL_START,
-        UNINSTALL_CHECK,
-        UNINSTALL_DB_UPDATE,
-        UNINSTALL_REMOVE_PREPARE,
-        UNINSTALL_REMOVE_ONEFILE,
-        UNINSTALL_REMOVE_DIRECTORIES,
-        UNINSTALL_REMOVE_FINISHED,
+        UNINSTALL_SMACK_ENABLE,
+        UNINSTALL_PRECHECK,
+        UNINSTALL_REMOVE_WIDGETDIR,
         UNINSTALL_REMOVE_DESKTOP,
+        UNINSTALL_REMOVE_FINISHED,
+        UNINSTALL_DB_UPDATE,
+        UNINSTALL_REMOVE_OSPSVC,
         UNINSTALL_END
     };
 
-    WidgetHandle widgetHandle;
-
     ///< flag that indicates whether installer starts
     //to remove files.rStruct;
     bool removeStarted;
     ///< flag that indicates whether installer finishes
     //to remove files completely.
     bool removeFinished;
+
+    DPL::Optional<WidgetLocation> locations;
+
     UninstallStep uninstallStep;       ///< current step of installation
     Jobs::WidgetUninstall::JobWidgetUninstall *job;
+    std::string pkgname;
+    bool isExternalWidget;
 };
 
 #endif // WRT_SRC_INSTALLER_CORE_UNINSTALLER_TASKS_UNINSTALLER_CONTEXT_H_
index 91173a0..f08d33d 100644 (file)
@@ -33,18 +33,21 @@ enum Type
     Success,
 
     ErrorWidgetDoesNotExist,
-    ErrorFactoryWidget,
     ErrorAlreadyUninstalling,
     ErrorDatabaseFailure,
+    ErrorUninstallOspSvcFailed,
+    ErrorPlatformAPI,
     ErrorUnknown
 };
 
 DECLARE_JOB_EXCEPTION_BASE(JobExceptionBase, Base, ErrorUnknown)
 
 DECLARE_JOB_EXCEPTION(Base, DatabaseFailure, ErrorDatabaseFailure)
-DECLARE_JOB_EXCEPTION(Base, FactoryWidget, ErrorFactoryWidget)
 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 fb7a152..ce2d4cc 100644 (file)
 #include <job_base.h>
 #include <wrt_common_types.h>
 #include <widget_uninstall/widget_uninstall_errors.h>
+#include <pkgmgr_signal_interface.h>
+#include <memory>
 
 //Widget Uninstaller typedefs
 typedef void (*UninstallerFinishedCallback)(
     void *userParam,
-    WidgetHandle,
+    std::string tizenId,
     Jobs::WidgetUninstall::Exceptions::Type);
 
 typedef void (*UninstallerProgressCallback)(
@@ -44,6 +46,26 @@ typedef void (*UninstallerProgressCallback)(
 //UninstallationStruct
 typedef Jobs::JobCallbacksBase<UninstallerFinishedCallback,
                                UninstallerProgressCallback>
-WidgetUninstallationStruct;
+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
+            ) :
+        WidgetUninstallCallbackBase(finished, progress, param),
+        pkgmgrInterface(_pkgmgrInterface)
+    {
+    }
+};
 #endif // WRT_SRC_INSTALLER_CORE_UNINSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_
index 8009b98..8995d33 100644 (file)
 #include "installer_controller.h"
 #include <dpl/log/log.h>
 #include <dpl/singleton_impl.h>
-IMPLEMENT_SINGLETON(InstallerController)
+
+IMPLEMENT_SINGLETON(Logic::InstallerController)
+
+namespace Logic
+{
 
 InstallerController::InstallerController()
 {
@@ -25,13 +29,9 @@ InstallerController::InstallerController()
 void InstallerController::OnEventReceived(
         const InstallerControllerEvents::InstallWidgetEvent &event)
 {
-    std::string zipFileName = event.GetArg0();
+    std::string fileName = event.GetArg0();
     WidgetInstallationStruct installerStruct = event.GetArg1();
-    Jobs::JobHandle handle =
-        m_installerLogic.InstallWidget(zipFileName, installerStruct);
-
-    //TODO return handle to API
-    (void)handle;
+    m_installerLogic.InstallWidget(fileName, installerStruct);
 }
 
 void InstallerController::OnEventReceived(
@@ -39,32 +39,15 @@ void InstallerController::OnEventReceived(
 {
     std::string dirName = event.GetArg0();
     PluginInstallerStruct installerStruct = event.GetArg1();
-
-    Jobs::JobHandle handle =
-        m_installerLogic.InstallPlugin(dirName, installerStruct);
-
-    //TODO return handle to API
-    (void)handle;
-}
-
-void InstallerController::OnEventReceived(const InstallerControllerEvents::
-            InstallPluginGeolocationEvent &event)
-{
-    PluginInstallerStruct installerStruct = event.GetArg0();
-
-    InstallerLogic::InstallPluginGeolocation(installerStruct);
+    m_installerLogic.InstallPlugin(dirName, installerStruct);
 }
 
 void InstallerController::OnEventReceived(
         const InstallerControllerEvents::UninstallWidgetEvent &event)
 {
-    WidgetHandle widgetHandle = event.GetArg0();
+    std::string widgetPkgName = event.GetArg0();
     WidgetUninstallationStruct uninstallerStruct = event.GetArg1();
-    Jobs::JobHandle handle =
-        m_installerLogic.UninstallWidget(widgetHandle, uninstallerStruct);
-
-    //TODO return handle to API
-    (void)handle;
+    m_installerLogic.UninstallWidget(widgetPkgName, uninstallerStruct);
 }
 
 Eina_Bool InstallerController::AddNextStep(void *data)
@@ -106,3 +89,6 @@ void InstallerController::OnEventReceived(
 {
     m_installerLogic.Terminate();
 }
+
+} //Logic
+
index 8ce43fc..55c68fe 100644 (file)
@@ -50,17 +50,12 @@ DECLARE_GENERIC_EVENT_2(InstallWidgetEvent,
 DECLARE_GENERIC_EVENT_2(InstallPluginEvent, std::string, PluginInstallerStruct)
 
 /**
- * @brief Event for indiciating W3C Geolocation plugin instalation process.
- */
-DECLARE_GENERIC_EVENT_1(InstallPluginGeolocationEvent, PluginInstallerStruct) //
-
-/**
  * @brief Event for inicietig widget uninstallation.
  *
- * WidgetHandler is used to point witch widget shuld be uninstalled
+ * tizen id is used to point witch widget shuld be uninstalled
  */
 DECLARE_GENERIC_EVENT_2(UninstallWidgetEvent,
-                        WidgetHandle,
+                        std::string,
                         WidgetUninstallationStruct)
 
 /**
@@ -75,6 +70,9 @@ DECLARE_GENERIC_EVENT_0(TerminateEvent)
 
 } // namespace InstallerEvents
 
+
+namespace Logic {
+
 /**
  * @brief Controls Widget installation
  *
@@ -91,7 +89,6 @@ DECLARE_GENERIC_EVENT_0(TerminateEvent)
 typedef DPL::TypeListDecl<
     InstallerControllerEvents::InstallWidgetEvent,
     InstallerControllerEvents::InstallPluginEvent,
-    InstallerControllerEvents::InstallPluginGeolocationEvent,
     InstallerControllerEvents::UninstallWidgetEvent,
     InstallerControllerEvents::NextStepEvent,
     InstallerControllerEvents::InstallDeferredWidgetPackagesEvent,
@@ -115,13 +112,6 @@ class InstallerController : public DPL::Event::Controller<InstallerControllerEve
             const InstallerControllerEvents::InstallPluginEvent &event);
 
     /**
-     * @brief Executed on InstallPluginEvent received.
-     */
-    virtual void OnEventReceived(
-            const InstallerControllerEvents::InstallPluginGeolocationEvent
-            &event);
-
-    /**
      * @brief Executed on UninstallWidgetEvent received.
      */
     virtual void OnEventReceived(
@@ -143,7 +133,7 @@ class InstallerController : public DPL::Event::Controller<InstallerControllerEve
 
   private:
     // Embedded logic
-    InstallerLogic m_installerLogic;
+    Logic::InstallerLogic m_installerLogic;
 
     InstallerController();
 
@@ -154,4 +144,6 @@ class InstallerController : public DPL::Event::Controller<InstallerControllerEve
 
 typedef DPL::Singleton<InstallerController> InstallerControllerSingleton;
 
+}
+
 #endif // INSTALLER_CONTROLLER_H
index 4cb7eb0..2cd734e 100644 (file)
 #include <installer_controller.h>
 #include <dpl/string.h>
 #include <dpl/foreach.h>
-//#include <plugin_logic.h>
 #include <dpl/wrt-dao-rw/feature_dao.h>
 #include <dpl/wrt-dao-rw/plugin_dao.h>
-#include <dpl/wrt-dao-ro/global_config.h>
 #include <widget_install/job_widget_install.h>
 #include <widget_uninstall/job_widget_uninstall.h>
 #include <plugin_install/job_plugin_install.h>
@@ -29,6 +27,8 @@
 
 using namespace WrtDB;
 
+namespace Logic {
+
 InstallerLogic::InstallerLogic() :
     m_NextHandle(0)
 {
@@ -72,8 +72,7 @@ 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
-// i.e. widgetHandle, path etc...
-Jobs::JobHandle InstallerLogic::InstallWidget(std::string const & widgetPath,
+Jobs::JobHandle InstallerLogic::InstallWidget(const std::string & widgetPath,
         const WidgetInstallationStruct &installerStruct)
 {
     LogDebug("New Widget Installation:");
@@ -84,13 +83,13 @@ Jobs::JobHandle InstallerLogic::InstallWidget(std::string const & widgetPath,
     return AddAndStartJob(job);
 }
 
-Jobs::JobHandle InstallerLogic::UninstallWidget(WidgetHandle widgetHandle,
+Jobs::JobHandle InstallerLogic::UninstallWidget(const std::string & widgetPkgName,
         const WidgetUninstallationStruct &uninstallerStruct)
 {
     LogDebug("New Widget Uninstallation");
 
     Jobs::Job *job =
-        new Jobs::WidgetUninstall::JobWidgetUninstall(widgetHandle,
+        new Jobs::WidgetUninstall::JobWidgetUninstall(widgetPkgName,
                                                       uninstallerStruct);
 
     return AddAndStartJob(job);
@@ -103,7 +102,9 @@ Jobs::JobHandle InstallerLogic::InstallPlugin(std::string const & pluginPath,
 
     Jobs::Job *job =
         new Jobs::PluginInstall::JobPluginInstall(pluginPath, installerStruct);
-
+    // before start install plugin, reset plugin data which is stopped
+    // during installing. (PluginDAO::INSTALLATION_IN_PROGRESS)
+    ResetProgressPlugins();
     return AddAndStartJob(job);
 }
 
@@ -117,9 +118,9 @@ bool InstallerLogic::NextStep(Jobs::Job *job)
     Try {
         bool stepSucceded = job->NextStep();
 
-        if (stepSucceded) {
-            job->SendProgress();
+        job->SendProgress();
 
+        if (stepSucceded) {
             return !job->IsPaused();
         }
 
@@ -211,17 +212,6 @@ void InstallerLogic::InstallSingleDeferredPackage()
     //                        WidgetUpdateMode::PolicyWac)));
 }
 
-void InstallerLogic::InstallPluginGeolocation(
-        const PluginInstallerStruct &installerStruct)
-{
-    FeatureDAO::RegisterStrangeFeature(
-        std::string(GlobalConfig::GetW3CGeolocationFeatureName()));
-
-    LogDebug("Call plugins installer FinishedCallback");
-    installerStruct.finishedCallback(installerStruct.userParam,
-        Jobs::PluginInstall::Exceptions::Success);
-}
-
 void InstallerLogic::InstallWaitingPlugins()
 {
     PluginHandleSetPtr waitingPlugins;
@@ -235,6 +225,23 @@ void InstallerLogic::InstallWaitingPlugins()
     }
 }
 
+void InstallerLogic::ResetProgressPlugins()
+{
+    PluginHandleSetPtr progressPlugins;
+
+    progressPlugins =
+        PluginDAO::getPluginHandleByStatus(PluginDAO::INSTALLATION_IN_PROGRESS);
+
+    FOREACH(it, *progressPlugins) {
+        FeatureHandleListPtr featureListPtr =
+            FeatureDAOReadOnly::GetFeatureHandleListForPlugin(*it);
+        FOREACH(ItFeature, *featureListPtr) {
+            FeatureDAO::UnregisterFeature(*ItFeature);
+        }
+        PluginDAO::unregisterPlugin(*it);
+    }
+}
+
 bool InstallerLogic::resolvePluginDependencies(PluginHandle handle)
 {
     PluginHandleSetPtr dependencies(new PluginHandleSet);
@@ -268,3 +275,5 @@ bool InstallerLogic::resolvePluginDependencies(PluginHandle handle)
     return true;
 }
 
+}
+
index db45295..479313e 100644 (file)
@@ -24,7 +24,7 @@
 #include <plugin_install/plugin_installer_struct.h>
 #include <job.h>
 
-//TODO create namespace
+namespace Logic {
 
 class InstallerLogic
 {
@@ -34,6 +34,7 @@ class InstallerLogic
     void InstallDeferredWidgetPackages();
     void InstallSingleDeferredPackage();
 
+    void ResetProgressPlugins();
     void InstallWaitingPlugins();
     bool resolvePluginDependencies(PluginHandle handle);
 
@@ -50,10 +51,10 @@ class InstallerLogic
 
     void Terminate();
 
-    Jobs::JobHandle InstallWidget(std::string const & widgetPath,
+    Jobs::JobHandle InstallWidget(const std::string & widgetPath,
             const WidgetInstallationStruct &installerStruct);
 
-    Jobs::JobHandle UninstallWidget(WidgetHandle widgetHandle,
+    Jobs::JobHandle UninstallWidget(const std::string & widgetPkgName,
             const WidgetUninstallationStruct &uninstallerStruct);
 
     Jobs::JobHandle InstallPlugin(std::string const & pluginPath,
@@ -68,12 +69,12 @@ class InstallerLogic
         return true;
     }
 
-    static void InstallPluginGeolocation(
-            const PluginInstallerStruct &installerStruct);
   private:
     InstallerLogic();
 
     friend class InstallerController;
 };
 
+}
+
 #endif // INSTALLER_LOGIC_H
index a4e4bd3..ee71e76 100644 (file)
 #include <dpl/noncopyable.h>
 #include <dpl/string.h>
 #include <dpl/foreach.h>
-
-#include <dpl/wrt-dao-rw/widget_dao.h>
-#include <dpl/wrt-dao-rw/global_dao.h>
+#include <dpl/log/log.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <dpl/wrt-dao-ro/global_dao_read_only.h>
 
 namespace Jobs {
 namespace WidgetInstall {
 
-FeatureLogic::FeatureLogic(WidgetHandle handle)
+FeatureLogic::FeatureLogic(const WrtDB::WidgetPkgName & pkgname)
   : m_rejected(false)
 {
-    WrtDB::WidgetDAO widgetDao(handle);
+    WrtDB::WidgetDAOReadOnly widgetDao(pkgname);
     WidgetFeatureSet featureSet = widgetDao.getFeaturesList();
     FOREACH(it, featureSet) {
+        LogInfo("Feature name : " << it->name);
         WrtDB::DeviceCapabilitySet dcs =
-          WrtDB::GlobalDAO::GetDeviceCapability(it->name);
+          WrtDB::GlobalDAOReadOnly::GetDeviceCapability(it->name);
+        FOREACH (devCap, dcs) {
+            LogInfo("--- dev cap  : " << *devCap);
+        }
         Feature feature(*it, dcs);
         m_featureList.push_back(feature);
     }
index 550c123..1c3ed23 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <dpl/assert.h>
 #include <dpl/noncopyable.h>
-#include <dpl/shared_ptr.h>
+#include <memory>
 
 #include <dpl/wrt-dao-ro/global_dao_read_only.h>
 #include <wrt_common_types.h>
@@ -33,7 +33,7 @@ namespace WidgetInstall {
 class FeatureLogic : DPL::Noncopyable {
   public:
 
-    FeatureLogic(WidgetHandle handle);
+    FeatureLogic(const WrtDB::WidgetPkgName & pkgname);
 
     bool isDone() const;
 
@@ -48,18 +48,13 @@ class FeatureLogic : DPL::Noncopyable {
         return m_rejected;
     }
 
-  private:
-    bool isProcessable() const;
-
     struct Feature : public WidgetFeature {
         WrtDB::DeviceCapabilitySet devCapSet;
         WrtDB::DeviceCapabilitySet::const_iterator currentCap;
-        bool rejected;
 
         Feature(const WidgetFeature &wf, const WrtDB::DeviceCapabilitySet &set)
           : WidgetFeature(wf)
           , devCapSet(set)
-          , rejected(false)
         {
             currentCap = devCapSet.begin();
         }
@@ -81,14 +76,22 @@ class FeatureLogic : DPL::Noncopyable {
             currentCap = devCapSet.find(*second.currentCap);
         }
     };
+
     typedef std::list<Feature> FeatureList;
+    typedef FeatureList::const_iterator FeatureIterator;
+
+    FeatureIterator resultBegin() { return m_featureList.begin(); }
+    FeatureIterator resultEnd() { return m_featureList.end(); }
+
+  private:
+    bool isProcessable() const;
 
     FeatureList m_featureList;
     FeatureList::iterator m_currentFeature;
     bool m_rejected;
 };
 
-typedef DPL::SharedPtr<FeatureLogic> FeatureLogicPtr;
+typedef std::shared_ptr<FeatureLogic> FeatureLogicPtr;
 
 } // namespace WidgetInstall
 } // namespace Jobs
diff --git a/src/misc/libxml_utils.cpp b/src/misc/libxml_utils.cpp
new file mode 100644 (file)
index 0000000..61aa5cc
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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    libxml_utils.cpp
+ * @author  Tomasz Iwanek (t.iwanek@samsung.com)
+ */
+
+#include "libxml_utils.h"
+
+#include <dpl/singleton_impl.h>
+
+IMPLEMENT_SINGLETON(LibxmlUtils)
+
+LibxmlUtils::LibxmlUtils() : isInitialized(false)
+{
+}
+
+LibxmlUtils::~LibxmlUtils()
+{
+    if(isInitialized)
+    {
+        LogDebug("Libxml - cleaning");
+        // Cleanup function for the XML library.
+        xmlCleanupParser();
+        //this is to debug memory for regression tests
+        xmlMemoryDump();
+    }
+}
+
+void LibxmlUtils::init()
+{
+    if(!isInitialized)
+    {
+        LIBXML_TEST_VERSION
+        isInitialized = true;
+        LogDebug("Libxml have been initialized");
+    }
+    LogDebug("Libxml already initialized");
+}
+
+
diff --git a/src/misc/libxml_utils.h b/src/misc/libxml_utils.h
new file mode 100644 (file)
index 0000000..d662bc7
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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    libxml_utils.h
+ * @author  Tomasz Iwanek (t.iwanek@samsung.com)
+ */
+
+#ifndef LIBXML_UTILS_H
+#define LIBXML_UTILS_H
+
+#include <libxml/encoding.h>
+#include <libxml/xmlwriter.h>
+
+#include <dpl/singleton.h>
+#include <dpl/log/log.h>
+#include <dpl/string.h>
+#include <dpl/exception.h>
+
+/**
+ * @brief The LibxmlUtils class
+ *
+ * Singleton for assurence for libxml2 initialization
+ *
+ * Use: LibxmlUtils::Instance().init(); to initialize library
+ *
+ */
+class LibxmlUtils
+{
+public:
+    DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+    DECLARE_EXCEPTION_TYPE(Base, Libxml2Error)
+
+    LibxmlUtils();
+    ~LibxmlUtils();
+
+    void init();
+private:
+    bool isInitialized;
+
+    friend class DPL::Singleton<LibxmlUtils>;
+};
+
+typedef DPL::Singleton<LibxmlUtils> LibxmlSingleton;
+
+#endif // LIBXML_UTILS_H
index bc1f128..f6af03f 100644 (file)
@@ -28,7 +28,6 @@
 #include <dpl/string.h>
 
 #include <iri.h>
-#include <vcore/ValidatorCommon.h>
 
 namespace {
 const char *SCHEME_HTTP = "http";
@@ -65,7 +64,7 @@ void WacWidgetId::parse(const char *url)
             iri(iri_parse(url), iri_destroy);
 
     if (!iri.get()) {
-        LogDebug("Error in parsing widget id.");
+        LogError("Error in parsing widget id.");
         return; // m_schemaMatch == false;
     }
 
diff --git a/src/misc/widget_install_to_external.cpp b/src/misc/widget_install_to_external.cpp
new file mode 100644 (file)
index 0000000..3751d60
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file        widget_install_to_external.cpp
+ * @author      Soyoung Kim (sy037.kim@smasung.com)
+ */
+#include "widget_install_to_external.h"
+
+#include <dpl/singleton_safe_impl.h>
+#include <dpl/assert.h>
+#include <dpl/log/log.h>
+
+IMPLEMENT_SAFE_SINGLETON(WidgetInstallToExt)
+
+WidgetInstallToExt::WidgetInstallToExt() :
+    m_handle(NULL),
+    m_appId("")
+{
+}
+
+WidgetInstallToExt::~WidgetInstallToExt()
+{
+}
+
+void WidgetInstallToExt::initialize(std::string appId)
+{
+    LogDebug("WidgetInstallToExt::initialize()");
+    m_appId = appId;
+
+    m_handle = app2ext_init(APP2EXT_SD_CARD);
+    if (NULL == m_handle) {
+        ThrowMsg(Exception::ErrorInstallToExt, "initialize failed");
+    }
+}
+
+void WidgetInstallToExt::deinitialize()
+{
+    LogDebug("WidgetInstallToExt::deinitialize()");
+    if (NULL != m_handle) {
+        if ( 0 < app2ext_deinit(m_handle)) {
+            ThrowMsg(Exception::ErrorInstallToExt, "app2ext deinitialize \
+                    failed");
+        }
+    }
+}
+
+void WidgetInstallToExt::preInstallation(GList *dirList, int dSize)
+{
+    LogDebug("WidgetInstallToExt::preInstallation()");
+    Assert(m_handle);
+
+    int ret = m_handle->interface.pre_install(m_appId.c_str(), dirList, dSize);
+
+    if (APP2EXT_SUCCESS == ret ) {
+        LogDebug("App2Ext pre install success");
+    } else {
+        postInstallation(false);
+        ThrowMsg(Exception::ErrorInstallToExt, "pre-install failed");
+    }
+}
+
+void WidgetInstallToExt::postInstallation(bool status)
+{
+    LogDebug("WidgetInstallToExt::postInstallation()");
+    Assert(m_handle);
+
+    if (status) {
+        m_handle->interface.post_install(m_appId.c_str(),
+                APP2EXT_STATUS_SUCCESS);
+    } else {
+        m_handle->interface.post_install(m_appId.c_str(),
+                APP2EXT_STATUS_FAILED);
+    }
+}
+
+void WidgetInstallToExt::preUpgrade(GList *dirList, int dSize)
+{
+    LogDebug("WidgetInstallToExt::preUpgrade()");
+    Assert(m_handle);
+
+    int ret = m_handle->interface.pre_upgrade(m_appId.c_str(), dirList, dSize);
+    if (APP2EXT_SUCCESS == ret ) {
+        LogDebug("App2Ext pre-upgrade success");
+    } else {
+        postUpgrade(false);
+        ThrowMsg(Exception::ErrorInstallToExt, "pre-upgrade failed");
+    }
+}
+
+void WidgetInstallToExt::postUpgrade(bool status)
+{
+    LogDebug("WidgetInstallToExt::postUpgrade()");
+    Assert(m_handle);
+
+    if (status) {
+        m_handle->interface.post_upgrade(m_appId.c_str(),
+                APP2EXT_STATUS_SUCCESS);
+    } else {
+        m_handle->interface.post_upgrade(m_appId.c_str(),
+                APP2EXT_STATUS_FAILED);
+    }
+}
+
+void WidgetInstallToExt::uninstallation()
+{
+    LogDebug("WidgetInstallToExt::uninstallation()");
+
+    Assert(m_handle);
+
+    int ret = m_handle->interface.pre_uninstall(m_appId.c_str());
+    if (APP2EXT_SUCCESS == ret ) {
+        if (APP2EXT_SUCCESS ==
+                m_handle->interface.post_uninstall(m_appId.c_str())) {
+            LogDebug("App2Ext pre-uninstall success");
+        } else {
+            ThrowMsg(Exception::ErrorInstallToExt, "post-uninstall failed");
+        }
+    } else {
+        ThrowMsg(Exception::ErrorInstallToExt, "pre-uninstall failed");
+    }
+}
diff --git a/src/misc/widget_install_to_external.h b/src/misc/widget_install_to_external.h
new file mode 100644 (file)
index 0000000..9f71906
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file        widget_install_to_external.h
+ * @author      Soyoung Kim (sy037.kim@smasung.com)
+ */
+#ifndef WRT_INSTALLER_SRC_MISC_WIDGET_INSTALL_TO_EXTERNAL_H
+#define WRT_INSTALLER_SRC_MISC_WIDGET_INSTALL_TO_EXTERNAL_H
+
+#include <string>
+#include <dpl/singleton.h>
+#include <dpl/string.h>
+#include <app2ext_interface.h>
+
+
+class WidgetInstallToExt
+{
+public:
+    class Exception
+    {
+      public:
+        DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+        DECLARE_EXCEPTION_TYPE(Base, ErrorInstallToExt)
+    };
+
+    void initialize(std::string appId);
+    void deinitialize();
+    void preInstallation(GList* dirList, int dSize);
+    void postInstallation(bool status);
+    void preUpgrade(GList* dirList, int dSize);
+    void postUpgrade(bool status);
+    void uninstallation();
+
+private:
+    app2ext_handle *m_handle;
+    std::string m_appId;
+
+    WidgetInstallToExt();
+    ~WidgetInstallToExt();
+
+    friend class DPL::Singleton<WidgetInstallToExt>;
+};
+
+typedef DPL::Singleton<WidgetInstallToExt> WidgetInstallToExtSingleton;
+
+#endif // WRT_INSTALLER_SRC_MISC_WIDGET_INSTALL_TO_EXTERNAL_H
diff --git a/src/misc/widget_location.cpp b/src/misc/widget_location.cpp
new file mode 100644 (file)
index 0000000..35a8026
--- /dev/null
@@ -0,0 +1,237 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file        widget_location.cpp
+ * @author      Iwanek Tomasz (t.iwanek@smasung.com)
+ */
+#include "widget_location.h"
+
+#include <dpl/utils/wrt_utility.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/assert.h>
+#include <dpl/log/log.h>
+#include <dpl/sstream.h>
+#include <dpl/localization/localization_utils.h>
+
+#include <widget_install/task_commons.h>
+
+
+WidgetLocation::DirectoryDeletor::DirectoryDeletor()
+{
+    m_dirpath = Jobs::WidgetInstall::createTempPath();
+}
+
+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)){
+        LogError("Fail at removing directory: " << m_dirpath.c_str());
+    }
+}
+
+std::string WidgetLocation::DirectoryDeletor::getTempPath() const
+{
+    return m_dirpath;
+}
+
+WidgetLocation::WidgetLocation()
+{
+}
+
+WidgetLocation::WidgetLocation(const std::string & widgetname) :
+                                        m_pkgname(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())
+{
+    if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
+        m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
+    } else {
+        m_installedPath += WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
+    }
+}
+
+WidgetLocation::WidgetLocation(const std::string & widgetname,
+                               std::string sourcePath,
+                               std::string dirPath,
+                               WrtDB::PackagingType t,
+                               InstallLocationType locationType):
+                                    m_pkgname(widgetname),
+                                    m_widgetSource(sourcePath),
+                                    m_type(t),
+                                    m_temp(new
+                                            WidgetLocation::DirectoryDeletor(dirPath))
+{
+    if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
+        m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
+    } else {
+        m_installedPath += WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
+    }
+}
+
+// TODO cache all these paths
+std::string WidgetLocation::getInstallationDir() const
+{
+    return m_installedPath;
+}
+
+std::string WidgetLocation::getPackageInstallationDir() const
+{
+    return m_installedPath + "/" + m_pkgname;
+}
+
+std::string WidgetLocation::getSourceDir() const
+{
+    return m_installedPath + "/"
+            + m_pkgname + WrtDB::GlobalConfig::GetWidgetSrcPath();
+}
+
+std::string WidgetLocation::getBinaryDir() const
+{
+    return m_installedPath + "/"
+            + m_pkgname + WrtDB::GlobalConfig::GetUserWidgetExecPath();
+}
+
+std::string WidgetLocation::getExecFile() const
+{
+    return getBinaryDir() + "/" + m_pkgname;
+}
+
+std::string WidgetLocation::getBackupDir() const
+{
+    return getPackageInstallationDir() + "/backup";
+}
+
+std::string WidgetLocation::getBackupSourceDir() const
+{
+    return getBackupDir() + WrtDB::GlobalConfig::GetWidgetSrcPath();
+}
+
+std::string WidgetLocation::getBackupBinaryDir() const
+{
+    return getBackupDir() + WrtDB::GlobalConfig::GetUserWidgetExecPath();
+}
+
+std::string WidgetLocation::getBackupExecFile() const
+{
+    return getBackupBinaryDir() + "/" + m_pkgname;
+}
+
+std::string WidgetLocation::getUserDataRootDir() const
+{
+    return std::string(WrtDB::GlobalConfig::GetWidgetUserDataPath()) +
+        "/" + m_pkgname;
+}
+
+std::string WidgetLocation::getPrivateStorageDir() const
+{
+    return getUserDataRootDir() + "/" +
+        WrtDB::GlobalConfig::GetWidgetPrivateStoragePath();
+}
+
+std::string WidgetLocation::getShareDir() const
+{
+    return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
+            + m_pkgname + "/" + WrtDB::GlobalConfig::GetWidgetSharePath();
+}
+
+std::string WidgetLocation::getTemporaryPackageDir() const
+{
+    return m_temp->getTempPath();
+}
+
+std::string WidgetLocation::getTemporaryRootDir() const
+{
+    if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) {
+        return getWidgetSource();
+    }
+    if(m_type == WrtDB::PKG_TYPE_HYBRID_WEB_APP)
+    {
+        return getTemporaryPackageDir() + WrtDB::GlobalConfig::GetWidgetSrcPath();
+    }
+    else
+    {
+        return getTemporaryPackageDir();
+    }
+}
+
+std::string WidgetLocation::getConfigurationDir() const
+{
+    if(m_type == WrtDB::PKG_TYPE_HOSTED_WEB_APP)
+    {
+        std::string path = ".";
+        int 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)
+    {
+        return getWidgetSource() + WrtDB::GlobalConfig::GetWidgetSrcPath();
+    } else
+    {
+        return getTemporaryRootDir();
+    }
+}
+
+DPL::String WidgetLocation::getPkgname() const
+{
+    return DPL::FromUTF8String(m_pkgname);
+}
+
+std::string WidgetLocation::getInstalledIconPath() const
+{
+    return m_iconPath;
+}
+
+std::string WidgetLocation::getWidgetSource() const
+{
+    return m_widgetSource;
+}
+
+void WidgetLocation::setIconTargetFilenameForLocale(const std::string & icon)
+{
+    m_iconPath = icon;
+}
+
+void WidgetLocation::registerExternalLocation(const std::string & file)
+{
+    m_externals.push_back(file);
+}
+
+WrtDB::ExternalLocationList WidgetLocation::listExternalLocations() const
+{
+    return m_externals;
+}
diff --git a/src/misc/widget_location.h b/src/misc/widget_location.h
new file mode 100644 (file)
index 0000000..e04c3dd
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file        widget_location.h
+ * @author      Iwanek Tomasz (t.iwanek@smasung.com)
+ */
+#ifndef WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H
+#define WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H
+
+#include <string>
+#include <memory>
+
+#include <dpl/wrt-dao-ro/common_dao_types.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <wrt_common_types.h>
+
+/**
+ * @brief The WidgetLocation class
+ *
+ * Object that stores locations of several files/directories according
+ * to package name
+ *
+ * Current package layout (of installed package) is following:
+ *
+ * /opt/apps/[package_name]
+ *           \_____________ /data
+ *           \_____________ /share
+ *           \_____________ /bin
+ *           \_____________ /bin/[id_of_installed_package]
+ *           \_____________ /res/wgt/
+ *                               \___ config.xml
+ *                               \___ [widgets_archive_content]
+ *
+ * 1) Normal Widget
+ *  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.
+ */
+class WidgetLocation
+{
+    class DirectoryDeletor
+    {
+    public:
+        DirectoryDeletor();
+        DirectoryDeletor(std::string tempPath);
+        ~DirectoryDeletor();
+        std::string getTempPath() const;
+    private:
+        std::string m_dirpath;
+    };
+
+public:
+    DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+    DECLARE_EXCEPTION_TYPE(Base, NoTemporaryPath)
+    /**
+     * @brief WidgetLocation
+     *
+     * Creates useless object. Needed by DPL::Optional
+     */
+    WidgetLocation();
+    /**
+     * @brief WidgetLocation Builds paths for widget location during uninstallation
+     *
+     * Uninstallation process needs only installed package directory.
+     *
+     * @param widgetname name of widget
+     */
+    WidgetLocation(const std::string & widgetname);
+    /**
+     * @brief WidgetLocation Builds paths for widget location during installation
+     *
+     * @param widgetname name of widget
+     * @param sourcePath given source path
+     * @param t declaraced type of widget if type is needed
+     *
+     * In destruction removes temporary directory
+     */
+    WidgetLocation(const std::string & widgetname, std::string sourcePath,
+                   WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
+                   InstallLocationType ltype =
+                        INSTALL_LOCATION_TYPE_NOMAL);
+
+    WidgetLocation(const std::string & widgetname, std::string sourcePath,
+                   std::string dirPath,
+                   WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
+                   InstallLocationType ltype =
+                        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
+
+    // Temporary paths
+    /**
+     * @brief getTemporaryRootDir
+     * @return value of root for developer's provide package (root of unpacked .wgt file)
+     */
+    std::string getTemporaryPackageDir() const;
+    /**
+     * @brief getTemporaryRootDir
+     *
+     * 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'
+     */
+    std::string getTemporaryRootDir() const;
+    /**
+     * @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
+     *
+     * @return configuration directory
+     */
+    std::string getConfigurationDir() const;
+
+    //icons
+    /**
+     * @brief setIconTargetFilenameForLocale set installed ion path according to locale
+     * @param icon path of application icon
+     */
+    void setIconTargetFilenameForLocale(const std::string &icon);
+    /**
+     * @brief getIconTargetFilename gets icon path suffix for locale
+     * @param languageTag language tag
+     * @return value of suffix of path
+     */
+    DPL::String getIconTargetFilename(const DPL::String& languageTag) const;
+    /**
+     * @brief getIconTargetFilename gets icon full path
+     * @param languageTag language tag
+     * @return value of full path
+     */
+    std::string getInstalledIconPath() const;
+
+    /**
+     * @brief getWidgetSourcePath return widget's source path given to installer
+     * @return value of source path
+     */
+    std::string getWidgetSource() const;
+    /**
+     * @brief pkgname Returns pkgname
+     * @return pkgname
+     */
+    DPL::String getPkgname() const;
+
+    //external files
+    /**
+     * @brief registerExternalFile Registers file for database registration
+     * @param file
+     *
+     * Registered file will be stored in database and removed automatically a
+     *
+     * @return
+     */
+    void registerExternalLocation(const std::string & file);
+    /**
+     * @brief listExternalFile list all file to be registered
+     */
+    WrtDB::ExternalLocationList listExternalLocations() const;
+
+private:
+    std::string m_widgetSource;                   // Source widget zip file/widget url
+    std::string m_pkgname;                        //name of package
+    std::string m_iconPath;                       //installed icon path
+    WrtDB::PackagingType m_type;
+    std::shared_ptr<DirectoryDeletor> m_temp;      //directory
+    WrtDB::ExternalLocationList m_externals;
+    std::string m_installedPath;
+};
+
+#endif // WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H
old mode 100755 (executable)
new mode 100644 (file)
index 85b2f5d..f2ebcf5
 #include "package-manager-plugin.h"
 #include <dlog.h>
 #include <dpl/wrt-dao-ro/global_config.h>
-#include <dpl/ace-dao-rw/AceDAO.h>
 #include <vcore/VCore.h>
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
-#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <dpl/wrt-dao-ro/feature_dao_read_only.h>
 #include <dpl/wrt-dao-ro/widget_config.h>
 #include <string>
 #include <dpl/db/sql_connection.h>
 #include <dpl/log/log.h>
 #include <dpl/foreach.h>
-#include <dpl/ace-dao-ro/wrt_db_types.h>
 #include <dpl/utils/folder_size.h>
+#include <dpl/wrt-dao-ro/wrt_db_types.h>
 
 using namespace WrtDB;
 
@@ -51,22 +50,6 @@ extern "C"
 {
 #endif
 
-class DatabaseConnection
-{
-  public:
-    void AttachDatabase()
-    {
-        WrtDB::WrtDatabase::attachToThread();
-    }
-
-    void DetachDatabase()
-    {
-        WrtDB::WrtDatabase::detachFromThread();
-    }
-};
-
-static DPL::ScopedPtr<DatabaseConnection> g_databaseConnection;
-
 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,
@@ -76,22 +59,6 @@ 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);
 
-static int is_connected()
-{
-    if (NULL == g_databaseConnection) {
-        Try {
-            g_databaseConnection.Reset(new DatabaseConnection());
-            g_databaseConnection->AttachDatabase();
-        }
-        Catch (DPL::DB::SqlConnection::Exception::Base) {
-            LogDebug("Fail to connect DB");
-            return FALSE;
-        }
-    }
-
-    return TRUE;
-}
-
 static void pkg_native_plugin_on_unload()
 {
     LogDebug("pkg_native_plugin_unload() is called");
@@ -101,23 +68,17 @@ static int pkg_plugin_app_is_installed(const char *pkg_name)
 {
     LogDebug("pkg_plugin_app_is_installed() is called");
 
-    if (FALSE == is_connected()) {
-        LogError("Fail DB Connect");
-        return FALSE;
-    }
+    WrtDB::WrtDatabase::attachToThreadRO();
 
-    Try {
-        if (WidgetDAOReadOnly::isWidgetInstalled(
-                DPL::FromUTF8String(pkg_name))) {
-            return TRUE;
-        }
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        LogDebug("Databas Error");
+    bool result = WidgetDAOReadOnly::isWidgetInstalled(
+                    DPL::FromUTF8String(pkg_name));
+    WrtDB::WrtDatabase::detachFromThread();
+
+    if (result) {
+        return TRUE;
+    } else {
         return FALSE;
     }
-
-    LogDebug("Widget Not Found");
-    return FALSE;
 }
 
 static int pkg_plugin_get_installed_apps_list(const char * /*category*/,
@@ -128,55 +89,42 @@ static int pkg_plugin_get_installed_apps_list(const char * /*category*/,
     package_manager_pkg_info_t *pkg_list = NULL;
     package_manager_pkg_info_t *pkg_last = NULL;
 
-    Try {
-        if (FALSE == is_connected()) {
-            LogError("Fail DB Connect");
-            return FALSE;
-        }
 
-        WidgetHandleList hndlList = WidgetDAO::getHandleList();
-        *count = 0;
-
-        FOREACH(iterator, hndlList) {
-            package_manager_pkg_info_t *pkg_info =
-                static_cast<package_manager_pkg_info_t*>
-                (malloc(sizeof(package_manager_pkg_info_t)));
-            if (NULL == pkg_info) {
-                LogError("Error in malloc");
-                return FALSE;
-            }
-
-            if (NULL == pkg_list) {
-                pkg_list = pkg_info;
-                pkg_last = pkg_info;
-            } else {
-                pkg_last->next = pkg_info;
-            }
-
-            WidgetDAO widget(*iterator);
-            DPL::Optional<DPL::String> pkgname = widget.getPkgname();
-            strncpy(pkg_info->pkg_type, "wgt", PKG_TYPE_STRING_LEN_MAX);
-            if(!pkgname.IsNull()) {
-                snprintf(pkg_info->pkg_name, PKG_NAME_STRING_LEN_MAX, "%s",
-                        DPL::ToUTF8String(*pkgname).c_str());
-            }
-
-            DPL::Optional<DPL::String> version = widget.getVersion();
-            if (!version.IsNull()) {
-                strncpy(pkg_info->version,
-                        DPL::ToUTF8String(*version).c_str(),
-                        PKG_VERSION_STRING_LEN_MAX);
-            }
-
-            (*count)++;
+    WrtDB::WrtDatabase::attachToThreadRO();
+    WidgetPkgNameList pkgnameslList = WidgetDAOReadOnly::getPkgnameList();
+    *count = 0;
+
+    FOREACH(iterator, pkgnameslList) {
+        package_manager_pkg_info_t *pkg_info =
+            static_cast<package_manager_pkg_info_t*>
+            (malloc(sizeof(package_manager_pkg_info_t)));
+
+        if (NULL == pkg_list) {
+            pkg_list = pkg_info;
             pkg_last = pkg_info;
+        } else {
+            pkg_last->next = pkg_info;
         }
-        *list = pkg_list;
-    }
-    Catch (WidgetDAO::Exception::DatabaseError) {
-        LogError("Database Error");
-        return FALSE;
+
+        WidgetPkgName pkgname = *iterator;
+        WidgetDAOReadOnly widget(pkgname);
+        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::Optional<DPL::String> version = widget.getVersion();
+        if (!version.IsNull()) {
+            strncpy(pkg_info->version,
+                    DPL::ToUTF8String(*version).c_str(),
+                    PKG_VERSION_STRING_LEN_MAX - 1);
+        }
+
+        (*count)++;
+        pkg_last = pkg_info;
     }
+    *list = pkg_list;
+    WrtDB::WrtDatabase::detachFromThread();
+
     return TRUE;
 }
 
@@ -185,73 +133,66 @@ static int pkg_plugin_get_app_detail_info(const char *pkg_name,
 {
     LogDebug("pkg_plugin_get_app_detail_info() is called");
 
-    Try {
-        if (FALSE == is_connected()) {
-            LogError("Fail DB Connect");
-            return FALSE;
-        }
-
-        int handle = WidgetDAOReadOnly::getHandle(
-                        DPL::FromUTF8String(pkg_name));
-        WidgetDAO widget(handle);
 
-        DPL::Optional<DPL::String> version = widget.getVersion();
-        DPL::Optional<DPL::String> id = widget.getGUID();
-        DPL::Optional<DPL::String> locale = widget.getDefaultlocale();
+    WrtDB::WrtDatabase::attachToThreadRO();
+    int handle = WidgetDAOReadOnly::getHandle(
+                    DPL::FromUTF8String(pkg_name));
+    WidgetDAOReadOnly widget(handle);
 
-        if (!version.IsNull()) {
-            strncpy(pkg_detail_info->version,
-                    DPL::ToUTF8String(*version).c_str(),
-                    PKG_VERSION_STRING_LEN_MAX);
-        }
-        snprintf(pkg_detail_info->optional_id, PKG_NAME_STRING_LEN_MAX, "%d",
-               handle);
-        WidgetLocalizedInfo localizedInfo;
-
-        if (locale.IsNull()) {
-            LogError("is NULL");
-            DPL::String languageTag(L"");
-            localizedInfo = widget.getLocalizedInfo(languageTag);
-        } else {
-            localizedInfo = widget.getLocalizedInfo(*locale);
-        }
-        DPL::Optional<DPL::String> desc(localizedInfo.description);
+    DPL::Optional<DPL::String> version = widget.getVersion();
+    DPL::Optional<DPL::String> id = widget.getGUID();
+    DPL::Optional<DPL::String> locale = widget.getDefaultlocale();
 
-        if (!desc.IsNull()) {
-            strncpy(pkg_detail_info->pkg_description,
-                    DPL::ToUTF8String(*desc).c_str(),
-                    PKG_VALUE_STRING_LEN_MAX);
-        }
-        strncpy(pkg_detail_info->pkg_type, "wgt", PKG_TYPE_STRING_LEN_MAX);
-        strncpy(pkg_detail_info->pkg_name, pkg_name, PKG_NAME_STRING_LEN_MAX);
-
-        /* set installed time */
-        pkg_detail_info->installed_time = widget.getInstallTime();
-
-        /* set Widget size */
-        DPL::String pkgName = DPL::FromUTF8String(pkg_name);
-        std::string installPath = WidgetConfig::GetWidgetBasePath(pkgName);
-        std::string persistentPath =
-            WidgetConfig::GetWidgetPersistentStoragePath(pkgName);
-        std::string tempPath =
-            WidgetConfig::GetWidgetTemporaryStoragePath(pkgName);
-        installPath += "/";
-        tempPath += "/";
-        persistentPath += "/";
-
-        size_t installedSize = Utils::getFolderSize(installPath);
-        size_t persistentSize = Utils::getFolderSize(persistentPath);
-        size_t appSize = installedSize - persistentSize;
-        size_t dataSize = persistentSize + Utils::getFolderSize(tempPath);
-
-        pkg_detail_info->installed_size = GET_DIRECTORY_SIZE_KB(installedSize);
-        pkg_detail_info->app_size = GET_DIRECTORY_SIZE_KB(appSize);
-        pkg_detail_info->data_size = GET_DIRECTORY_SIZE_KB(dataSize);
+    if (!version.IsNull()) {
+        strncpy(pkg_detail_info->version,
+                DPL::ToUTF8String(*version).c_str(),
+                PKG_VERSION_STRING_LEN_MAX - 1);
     }
-    Catch (WidgetDAO::Exception::DatabaseError) {
-        LogError("Database Error");
-        return FALSE;
+    snprintf(pkg_detail_info->optional_id, PKG_NAME_STRING_LEN_MAX, "%d",
+           handle);
+    WidgetLocalizedInfo localizedInfo;
+
+    if (locale.IsNull()) {
+        LogError("is NULL");
+        DPL::String languageTag(L"");
+        localizedInfo = widget.getLocalizedInfo(languageTag);
+    } else {
+        localizedInfo = widget.getLocalizedInfo(*locale);
+    }
+    DPL::Optional<DPL::String> desc(localizedInfo.description);
+
+    if (!desc.IsNull()) {
+        strncpy(pkg_detail_info->pkg_description,
+                DPL::ToUTF8String(*desc).c_str(),
+                PKG_VALUE_STRING_LEN_MAX - 1);
     }
+    strncpy(pkg_detail_info->pkg_type, "wgt", PKG_TYPE_STRING_LEN_MAX);
+    strncpy(pkg_detail_info->pkg_name, pkg_name, PKG_NAME_STRING_LEN_MAX - 1);
+
+    /* set installed time */
+    pkg_detail_info->installed_time = widget.getInstallTime();
+
+    /* set Widget size */
+    DPL::String pkgName = DPL::FromUTF8String(pkg_name);
+    std::string installPath = WidgetConfig::GetWidgetBasePath(pkgName);
+    std::string persistentPath =
+        WidgetConfig::GetWidgetPersistentStoragePath(pkgName);
+    std::string tempPath =
+        WidgetConfig::GetWidgetTemporaryStoragePath(pkgName);
+    installPath += "/";
+    tempPath += "/";
+    persistentPath += "/";
+
+    size_t installedSize = Utils::getFolderSize(installPath);
+    size_t persistentSize = Utils::getFolderSize(persistentPath);
+    size_t appSize = installedSize - persistentSize;
+    size_t dataSize = persistentSize + Utils::getFolderSize(tempPath);
+
+    pkg_detail_info->installed_size = GET_DIRECTORY_SIZE_KB(installedSize);
+    pkg_detail_info->app_size = GET_DIRECTORY_SIZE_KB(appSize);
+    pkg_detail_info->data_size = GET_DIRECTORY_SIZE_KB(dataSize);
+
+    WrtDB::WrtDatabase::detachFromThread();
     return TRUE;
 }
 
diff --git a/src/pkg-manager/pkgmgr_signal.cpp b/src/pkg-manager/pkgmgr_signal.cpp
new file mode 100644 (file)
index 0000000..4b48b83
--- /dev/null
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @author      Yunchan Cho (yunchan.cho@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#include <dpl/log/log.h>
+#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)
+    {
+        LogInfo("Release already allocated pkgmgr handle");
+        pkgmgr_installer_free(m_handle);
+        m_handle = NULL;
+    }
+
+    m_handle = pkgmgr_installer_new();
+    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_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)
+        {
+            LogError("Fail to get request type of pkgmgr");
+            pkgmgr_installer_free(m_handle);
+            m_handle = NULL;
+            return false;
+        }
+    } else {
+        LogError("Fail to get information of pkgmgr's request");
+        pkgmgr_installer_free(m_handle);
+        m_handle = NULL;
+        return false;
+    }
+
+    m_type = PKGMGR_WEBAPP_TYPE;
+    m_initialized = true;
+    return true;
+}
+
+bool PkgmgrSignal::deinitialize()
+{
+    if (!m_initialized)
+    {
+        LogError("PkgmgrSingal not yet intialized");
+        return false;
+    }
+
+    pkgmgr_installer_free(m_handle);
+    m_handle = NULL;
+    m_initialized = false;
+    return true;
+}
+
+bool PkgmgrSignal::setPkgname(const std::string& name)
+{
+    if (!m_initialized)
+    {
+        LogError("PkgmgrSingal not yet intialized");
+        return false;
+    }
+
+    if (name.empty())
+    {
+        LogError("name is empty");
+        return false;
+    }
+
+    m_pkgname = name;
+    LogInfo("Success to set tizen package name: " << m_pkgname);
+
+    return true;
+}
+
+bool PkgmgrSignal::sendSignal(const std::string& key, const std::string& value) const
+{
+    if (!m_initialized)
+    {
+        LogError("PkgmgrSingal not yet intialized");
+        return false;
+    }
+
+    if (key.empty() || value.empty())
+    {
+        LogDebug("key or value is empty");
+        return false;
+    }
+
+    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()))
+    {
+        LogError("Fail to send pkgmgr signal");
+        return false;
+    }
+
+    LogInfo("Success to send pkgmgr signal: " << key <<
+            " - " << value);
+    return true;
+}
+
+std::string PkgmgrSignal::getPkgname() const
+{
+    if (!m_initialized)
+    {
+        LogError("PkgmgrSingal not yet intialized");
+    }
+
+    return m_pkgname;
+}
+
+int PkgmgrSignal::getRequestedType() const
+{
+    if (!m_initialized)
+    {
+        LogError("PkgmgrSingal not yet intialized");
+    }
+
+    return m_reqType;
+}
+
+bool PkgmgrSignal::isNoPopupRequired() const
+{
+    if (!m_initialized)
+    {
+        LogError("PkgmgrSingal not yet intialized");
+    }
+
+    return m_noPopup;
+}
+} // PackageManager
diff --git a/src/pkg-manager/pkgmgr_signal.h b/src/pkg-manager/pkgmgr_signal.h
new file mode 100644 (file)
index 0000000..a939c50
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @author      Yunchan Cho (yunchan.cho@samsung.com)
+ * @author      Jan Olszak (j.olszak@samsung.com)
+ * @version     0.2
+ * @brief
+ */
+
+#ifndef WRT_PKGMGR_SIGNAL_H_
+#define WRT_PKGMGR_SINGAL_H_
+
+#include <pkg-manager/pkgmgr_signal_interface.h>
+#include <pkgmgr_installer.h>
+
+namespace PackageManager{
+
+#define PKGMGR_WEBAPP_TYPE          "wgt"
+#define PKGMGR_START_KEY            "start"
+#define PKGMGR_START_INSTALL        "install"
+#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"
+
+typedef pkgmgr_installer* PkgmgrHandle;
+
+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;
+
+        PkgmgrSignal();
+        virtual ~PkgmgrSignal();
+
+    private:
+        bool m_initialized;
+        PkgmgrHandle m_handle;
+        std::string m_type;
+        std::string m_pkgname;
+        bool m_noPopup;
+        int m_reqType;
+};
+} // PackageManager
+
+#endif // WRT_PKGMGR_SIGNAL_H_
+
diff --git a/src/pkg-manager/pkgmgr_signal_dummy.h b/src/pkg-manager/pkgmgr_signal_dummy.h
new file mode 100644 (file)
index 0000000..f8862ee
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @author      Jan Olszak (j.olszak@samsung.com)
+ * @version     0.1
+ * @brief       Dummy version of PkgmgrSignal.
+ */
+
+#ifndef WRT_PKGMGR_SIGNAL_DUMMY_H_
+#define WRT_PKGMGR_SIGNAL_DUMMY_H_
+
+#include <pkg-manager/pkgmgr_signal_interface.h>
+
+namespace PackageManager {
+
+class PkgmgrSignalDummy: public IPkgmgrSignal
+{
+public:
+    PkgmgrSignalDummy()
+    {
+    }
+
+    virtual ~PkgmgrSignalDummy()
+    {
+    }
+    bool setPkgname(const std::string& name)
+    {
+        return false;
+    }
+
+    bool sendSignal(const std::string& key, const std::string& value) const
+    {
+        return false;
+    }
+
+    std::string getPkgname() const
+    {
+        return "";
+    }
+};
+
+} // PkgmgrSignalDummy
+
+#endif // WRT_PKGMGR_SIGNAL_DUMMY_H_
diff --git a/src/pkg-manager/pkgmgr_signal_interface.h b/src/pkg-manager/pkgmgr_signal_interface.h
new file mode 100644 (file)
index 0000000..187efb5
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @author      Jan Olszak (j.olszak@samsung.com)
+ * @version     0.1
+ * @brief       Interface for PkgmgrSignal.
+ */
+
+#ifndef WRT_PKGMGR_SIGNAL_INTERFACE_H_
+#define WRT_PKGMGR_SIGNAL_INTERFACE_H_
+
+#include <string>
+namespace PackageManager {
+
+class IPkgmgrSignal
+{
+public:
+    virtual bool setPkgname(const std::string& name) = 0;
+    virtual bool sendSignal(const std::string& key, const std::string& value) const = 0;
+    virtual std::string getPkgname() const = 0;
+    virtual ~IPkgmgrSignal(){};
+};
+
+} // IPkgmgrSignal
+
+#endif // WRT_PKGMGR_SIGNAL_INTERFACE_H_
index 9065231..12d2c7c 100644 (file)
@@ -22,6 +22,10 @@ SET(WRT_INSTALLER_DIR
     ${INSTALLER_SRC_DIR}/wrt-installer
     )
 
+SET(PKG_MANAGER_DIR
+    ${INSTALLER_SRC_DIR}/pkg-manager
+    )
+
 SET(WRT_INSTALLER_SOURCES
     ${WRT_INSTALLER_DIR}/wrt_installer.cpp
     ${WRT_INSTALLER_DIR}/wrt_installer_api.cpp
@@ -30,14 +34,17 @@ SET(WRT_INSTALLER_SOURCES
     ${WRT_INSTALLER_DIR}/language_subtag_rst_tree.cpp
     ${WRT_INSTALLER_DIR}/installer_main_thread.cpp
     ${WRT_INSTALLER_DIR}/option_parser.cpp
+    ${PKG_MANAGER_DIR}/pkgmgr_signal.cpp
 )
 
 PKG_CHECK_MODULES(WRT_INSTALLER_DEPS
     pkgmgr-installer
     libpcrecpp
+    security-install
     REQUIRED)
 
 INCLUDE_DIRECTORIES(
+    ${PKG_MANAGER_DIR}
     ${WRT_INSTALLER_DEP_INCLUDES}
     ${WRT_INSTALLER_INCLUDES}
     ${WRT_INSTALLER_DEPS_INCLUDE_DIRS}
@@ -48,7 +55,6 @@ ADD_EXECUTABLE(${TARGET_INSTALLER}
     ${WRT_INSTALLER_SOURCES}
 )
 
-ADD_DEFINITIONS("-DSEPARATE_INSTALLER_FOR_DAO") # TODO do not use ifdefs!
 ADD_DEFINITIONS(${WRT_INSTALLER_DEPS_CFLAGS})
 
 TARGET_LINK_LIBRARIES(${TARGET_INSTALLER}
index 4be1c06..8571d68 100644 (file)
@@ -57,11 +57,11 @@ WrtErrStatus TranslateError(CommonError::Type status)
     }
 }
 
-void StatusCallback(int widget_handle,
+void StatusCallback(std::string tizenId,
         CommonError::Type result,
         void *data)
 {
-    LogDebug("StatusCallback called  " << widget_handle << " | " << result);
+    LogDebug("StatusCallback called  " << tizenId << " | " << result);
     Assert(data != NULL);
 
     WrtErrStatus error = TranslateError(result);
@@ -69,7 +69,7 @@ void StatusCallback(int widget_handle,
         static_cast<StatusCallbackStruct*>(data);
 
     if (statusCallbackStruct->status_callback) {
-        statusCallbackStruct->status_callback(widget_handle,
+        statusCallbackStruct->status_callback(tizenId,
                                               error,
                                               statusCallbackStruct->userdata);
     } else {
@@ -81,7 +81,7 @@ void StatusCallback(int widget_handle,
 
 // callback for finished install
 void installFinishedCallback(void *userParam,
-        WidgetHandle widget_handle,
+        std::string tizenId,
         Jobs::WidgetInstall::Exceptions::Type status)
 {
     Assert(userParam != NULL);
@@ -106,10 +106,6 @@ void installFinishedCallback(void *userParam,
             errorStatus = WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST;
             break;
 
-        case Jobs::WidgetInstall::Exceptions::ErrorFactoryWidget:
-            errorStatus = WRT_INSTALLER_ERROR_FACTORY_WIDGET;
-            break;
-
         case Jobs::WidgetInstall::Exceptions::ErrorAreadyUninstalling:
             errorStatus = WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING;
             break;
@@ -142,6 +138,10 @@ void installFinishedCallback(void *userParam,
             errorStatus = WRT_INSTALLER_ERROR_DATABASE_FAILURE;
             break;
 
+        case Jobs::WidgetInstall::Exceptions::ErrorInstallOspServcie:
+            errorStatus = WRT_INSTALLER_ERROR_OSPSVC;
+            break;
+
         case Jobs::WidgetInstall::Exceptions::ErrorUnknown:
             errorStatus = WRT_INSTALLER_ERROR_UNKNOWN;
             break;
@@ -152,7 +152,7 @@ void installFinishedCallback(void *userParam,
         }
 
         // Callback
-        apiStr->status_callback(widget_handle, errorStatus, apiStr->userdata);
+        apiStr->status_callback(tizenId, errorStatus, apiStr->userdata);
     } else {
         LogInfo("installFinishedCallback: No callback");
     }
@@ -160,7 +160,7 @@ void installFinishedCallback(void *userParam,
 
 // callback for finished install
 void uninstallFinishedCallback(void *userParam,
-        WidgetHandle widget_handle,
+        std::string tizenId,
         Jobs::WidgetUninstall::Exceptions::Type status)
 {
     Assert(userParam != NULL);
@@ -177,14 +177,22 @@ void uninstallFinishedCallback(void *userParam,
             errorStatus = WRT_SUCCESS;
             break;
 
-        // case Jobs::WidgetInstall::Exceptions::ErrorAreadyUninstalling:
-        //     errorStatus = WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING;
-        //     break;
+        case Jobs::WidgetUninstall::Exceptions::ErrorAlreadyUninstalling:
+            errorStatus = WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING;
+            break;
+
+        case Jobs::WidgetUninstall::Exceptions::ErrorWidgetDoesNotExist:
+            errorStatus = WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST;
+            break;
 
         case Jobs::WidgetUninstall::Exceptions::ErrorDatabaseFailure:
             errorStatus = WRT_INSTALLER_ERROR_DATABASE_FAILURE;
             break;
 
+        case Jobs::WidgetUninstall::Exceptions::ErrorUninstallOspSvcFailed:
+            errorStatus = WRT_INSTALLER_ERROR_OSPSVC;
+            break;
+
         case Jobs::WidgetUninstall::Exceptions::ErrorUnknown:
             errorStatus = WRT_INSTALLER_ERROR_UNKNOWN;
             break;
@@ -195,7 +203,7 @@ void uninstallFinishedCallback(void *userParam,
         }
 
         // Callback
-        apiStr->status_callback(widget_handle, errorStatus, apiStr->userdata);
+        apiStr->status_callback(tizenId, errorStatus, apiStr->userdata);
     } else {
         LogInfo("uninstallFinishedCallback: No callback");
     }
index 87cf668..c32d253 100644 (file)
@@ -28,6 +28,7 @@
 #include <widget_uninstall/widget_uninstall_errors.h>
 #include <plugin_install/plugin_installer_errors.h>
 #include <job_base.h>
+#include <string>
 
 namespace InstallerCallbacksTranslate {
 struct StatusCallbackStruct
@@ -62,16 +63,16 @@ struct PluginStatusCallbackStruct
     }
 };
 
-void StatusCallback(int widget_handle,
+void StatusCallback(std::string tizenId,
         CommonError::Type result,
         void *data);
 
 void installFinishedCallback(void *userParam,
-        WidgetHandle widget_handle,
+        std::string tizenId,
         Jobs::WidgetInstall::Exceptions::Type status);
 
 void uninstallFinishedCallback(void *userParam,
-        WidgetHandle widget_handle,
+        std::string tizenId,
         Jobs::WidgetUninstall::Exceptions::Type status);
 
 void pluginInstallFinishedCallback(void *userParam,
index c984769..c5d677b 100755 (executable)
 #include "installer_main_thread.h"
 #include <dpl/assert.h>
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
-#include <dpl/ace-dao-rw/AceDAO.h>
 #include <vcore/VCore.h>
 #include <dpl/singleton_impl.h>
 #include <dpl/assert.h>
 #include <installer_controller.h>
-#include <security_controller.h>
-#include <dpl/popup/popup_controller.h>
-#include <dpl/popup/popup_manager.h>
+#include <ace_api_install.h>
+
 IMPLEMENT_SINGLETON(InstallerMainThread)
 
 using namespace WrtDB;
-using namespace DPL::Popup;
 
 InstallerMainThread::InstallerMainThread() : m_attached(false) {
 }
@@ -46,9 +43,10 @@ void InstallerMainThread::AttachDatabases()
 {
     Assert(!m_attached);
     // Attach databases
-    ValidationCore::AttachToThread();
-    AceDB::AceDAO::attachToThread();
-    WrtDB::WrtDatabase::attachToThread();
+    ValidationCore::AttachToThreadRW();
+    ace_return_t ret = ace_install_initialize();
+    Assert(ACE_OK == ret); // to be changed to exception in the future
+    WrtDB::WrtDatabase::attachToThreadRW();
     m_attached = true;
 }
 
@@ -58,20 +56,19 @@ void InstallerMainThread::DetachDatabases()
     m_attached = false;
     // Detach databases
     ValidationCore::DetachFromThread();
-    AceDB::AceDAO::detachFromThread();
+    ace_return_t ret = ace_install_shutdown();
+    Assert(ACE_OK == ret); // to be changed to exception in the future
     WrtDB::WrtDatabase::detachFromThread();
 }
 
 void InstallerMainThread::TouchArchitecture()
 {
     // Touch controller
-    InstallerControllerSingleton::Instance().Touch();
-    SecurityControllerSingleton::Instance().Touch();
-    DPL::Popup::PopupControllerSingleton::Instance().Touch();
+    Logic::InstallerControllerSingleton::Instance().Touch();
 }
 
 void InstallerMainThread::TouchArchitectureOnlyInstaller()
 {
     // Touch controller
-    InstallerControllerSingleton::Instance().Touch();
+    Logic::InstallerControllerSingleton::Instance().Touch();
 }
old mode 100755 (executable)
new mode 100644 (file)
index 18db0eb..ae29f5e
@@ -31,16 +31,14 @@ using namespace WrtDB;
 namespace PluginUtils {
 const char PLUGIN_INSTALL_SEMAPHORE[] = "/.wrt_plugin_install_lock";
 
+static DPL::Semaphore semaphore(PLUGIN_INSTALL_SEMAPHORE);
+
 bool lockPluginInstallation()
 {
     Try {
-        DPL::Semaphore lock(PLUGIN_INSTALL_SEMAPHORE);
+        semaphore.Lock();
         return true;
     }
-    Catch(DPL::Semaphore::Exception::CreateFailed){
-        LogError("create");
-        return false;
-    }
     Catch(DPL::Semaphore::Exception::Base){
         return false;
     }
@@ -49,7 +47,7 @@ bool lockPluginInstallation()
 bool unlockPluginInstallation()
 {
     Try {
-        DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
+        semaphore.Unlock();
         return true;
     }
     Catch(DPL::Semaphore::Exception::Base){
index a61292b..8deea1d 100644 (file)
@@ -25,6 +25,8 @@
 #include <string>
 #include <fstream>
 #include <unistd.h>
+#include <memory>
+#include <sys/resource.h>
 #include <dpl/optional.h>
 #include <dpl/scoped_free.h>
 #include <dpl/optional_typedefs.h>
 #include <dpl/sstream.h>
 #include <vconf.h>
 #include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-ro/config_parser_data.h>
 #include <dpl/localization/localization_utils.h>
-#include <dpl/popup/popup_controller.h>
 #include <dpl/optional_typedefs.h>
 #include <dpl/string.h>
+#include <dpl/abstract_waitable_input_adapter.h>
+#include <dpl/abstract_waitable_output_adapter.h>
+#include <dpl/zip_input.h>
+#include <dpl/binary_queue.h>
+#include <dpl/copy.h>
+#include <dpl/errno_string.h>
+#include <dpl/utils/wrt_global_settings.h>
 #include "option_parser.h"
+#include <parser_runner.h>
+#include <widget_parser.h>
+#include <root_parser.h>
+
+
+
+#define NOFILE_CNT_FOR_INSTALLER 9999
 
-#define PKGMGR_SEND_SIG(installer, pkg_name, key, val) \
-    if(pkgmgr_installer_send_signal(installer, PKG_TYPE, pkg_name, key, val)) {\
-        LogDebug("Failed to send signal to pkgmgr");                           \
-    }
 using namespace WrtDB;
+
 namespace { // anonymous
 const char AUL_ARG_KEY[] = "widget_arg";
-const char PKGMGR_START_KEY[] = "start";
-const char PKGMGR_END_KEY[] = "end";
-const char PKG_TYPE[] = "wgt";
-const char PKGMGR_PROGRESS_KEY[] = "install_percent";
-const char PKGMGR_OK_VAL[] = "ok";
-const char PKGMGR_FAIL_VAL[] = "fail";
-const char PKGMGR_INSTALL_MSG[] = "Install widget";
-const char PKGMGR_UNINSTALL_MSG[] = "Uninstall widget";
+const char * const PKGMGR_INSTALL_MSG = "Install widget";
+const char * const PKGMGR_UNINSTALL_MSG = "Uninstall widget";
 
 const double BASE_LAYOUT_W = 720.0f;
 const double BASE_LAYOUT_H = 1280.0f;
 
+const char * const CONFIG_XML = "config.xml";
+
+struct free_deleter
+{
+    void operator()(void* x) { free(x); }
+};
+
 struct PluginInstallerData
 {
     void* wrtInstaller;
@@ -73,12 +87,11 @@ WrtInstaller::WrtInstaller(int argc, char **argv) :
     m_numPluginsToInstall(0),
     m_totalPlugins(0),
     m_returnStatus(-1),
-    m_installer(NULL),
     m_installByPkgmgr(false),
     m_quiet(true),
-    m_sendSig(false),
     m_popup(NULL),
-    m_startupPluginInstallation(false)
+    m_startupPluginInstallation(false),
+    m_preloadWidget(false)
 {
     Touch();
     LogDebug("App Created");
@@ -97,11 +110,26 @@ void WrtInstaller::OnStop()
 void WrtInstaller::OnCreate()
 {
     LogInfo("Creating DummyClient");
+    fprintf(stderr,
+            "===========================================================\n");
+    fprintf(stderr, "# wrt-installer #\n");
+    fprintf(stderr, "# argc [%ld]\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]);
+    fprintf(stderr,
+            "===========================================================\n");
 
     AddStep(&WrtInstaller::initStep);
 
     std::string arg = m_argv[0];
 
+    pkgmgrSignalInterface = std::static_pointer_cast<PackageManager::IPkgmgrSignal>(
+                                std::shared_ptr<PackageManager::PkgmgrSignalDummy>(
+                                        new PackageManager::PkgmgrSignalDummy()
+                                )
+                            );
+
     if (arg.empty()) {
         return showHelpAndQuit();
     }
@@ -115,14 +143,13 @@ void WrtInstaller::OnCreate()
         }
 
         arg = m_argv[1];
-
         if (arg == "-h" || arg == "--help") {
             if (m_argc != 2) {
                 return showHelpAndQuit();
             }
 
             // Just show help
-            showHelpAndQuit();
+            return showHelpAndQuit();
         } else if (arg == "-p" || arg == "--install-plugins") {
             if (m_argc != 2) {
                 return showHelpAndQuit();
@@ -137,16 +164,17 @@ void WrtInstaller::OnCreate()
                 return showHelpAndQuit();
             }
 
-            m_packagePath = m_argv[2];
-            m_installPolicy = WRT_WIM_POLICY_NEVER_UPDATE;
-            AddStep(&WrtInstaller::installStep);
-        } else if (arg == "-iu" || arg == "--install-or-update") {
-            if (m_argc != 3) {
-                return showHelpAndQuit();
+            struct stat info;
+            if (-1 != stat(m_argv[2], &info) && S_ISDIR(info.st_mode)) {
+                LogInfo("Installing package directly from directory");
+                m_installPolicy = WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL;
+            }
+            else
+            {
+                LogInfo("Installing from regular location");
+                m_installPolicy = WRT_WIM_POLICY_WAC;
             }
-
             m_packagePath = m_argv[2];
-            m_installPolicy = WRT_WIM_POLICY_WAC;
             AddStep(&WrtInstaller::installStep);
         } else if (arg == "-if" || arg == "--install-force") {
             if (m_argc != 3) {
@@ -156,21 +184,15 @@ void WrtInstaller::OnCreate()
             m_packagePath = m_argv[2];
             m_installPolicy = WRT_WIM_POLICY_FORCE_INSTALL;
             AddStep(&WrtInstaller::installStep);
-        } else if (arg == "-inq" || arg == "--install-not-quiet") {
+        } else if (arg == "-il" || arg == "--install-preload") {
             if (m_argc != 3) {
                 return showHelpAndQuit();
             }
-            m_quiet = false;
+
             m_packagePath = m_argv[2];
-            m_installPolicy = WRT_WIM_POLICY_NEVER_UPDATE;
+            m_preloadWidget = true;
+            m_installPolicy = WRT_WIM_POLICY_WAC;
             AddStep(&WrtInstaller::installStep);
-        } else if (arg == "-u" || arg == "--uninstall") {
-            if (m_argc != 3) {
-                return showHelpAndQuit();
-            }
-
-            m_handle = atoi(m_argv[2]);
-            AddStep(&WrtInstaller::uninstallStep);
         } else if (arg == "-un" || arg == "--uninstall-name") {
             if (m_argc != 3) {
                 return showHelpAndQuit();
@@ -183,42 +205,45 @@ void WrtInstaller::OnCreate()
             }
             m_name = m_argv[2];
             AddStep(&WrtInstaller::uninstallGuidStep);
-        } else if (arg == "-unq" || arg == "--uninstall-not-quiet") {
+        } else if (arg == "-up" || arg == "--uninstall-packagepath") {
             if (m_argc != 3) {
                 return showHelpAndQuit();
             }
-            m_quiet = false;
-            m_handle = atoi(m_argv[2]);
-            AddStep(&WrtInstaller::uninstallStep);
+            m_packagePath = m_argv[2];
+            AddStep(&WrtInstaller::unistallWgtFileStep);
+        } else {
+            return showHelpAndQuit();
         }
-        else if (arg == "--url") {
-            if (m_argc < 3) {
-                return showHelpAndQuit();
-            }
-            m_webAppUrl = m_argv[2];
 
-            DPL::OptionalString icon = OptionParser::QueryOption(m_argc,
-                                                                 m_argv,
-                                                                 "--icon");
-            if (!icon.IsNull()) {
-                m_webAppIcon = DPL::ToUTF8String(*icon);
-            }
-        }
     } else if (arg.find("backend") != std::string::npos) {
+        using namespace PackageManager;
         m_installByPkgmgr = true;
-        m_quiet = false;
-        m_sendSig = true;
 
-        m_installer = pkgmgr_installer_new();
-        if (!pkgmgr_installer_receive_request(m_installer, m_argc, m_argv)) {
-            //For package manager
-            int reqType = pkgmgr_installer_get_request_type(m_installer);
-            m_quiet = pkgmgr_installer_is_quiet(m_installer);
+        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);
 
-            switch (reqType) {
+        int reqType = pkgmgrSignal->getRequestedType();
+
+        pkgmgrSignalInterface =
+                std::static_pointer_cast<PackageManager::IPkgmgrSignal>(pkgmgrSignal);
+        switch (reqType) {
             case PKGMGR_REQ_INSTALL:
                 m_packagePath = m_argv[4];
-                m_installPolicy = WRT_WIM_POLICY_NEVER_UPDATE;
+                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:
@@ -228,22 +253,7 @@ void WrtInstaller::OnCreate()
             default:
                 LogDebug("Not available type");
                 break;
-            }
         }
-    } else {
-        // Launch widget based on application basename
-        size_t pos = arg.find_last_of('/');
-
-        if (pos != std::string::npos) {
-            arg = arg.erase(0, pos + 1);
-        }
-
-        if (sscanf(arg.c_str(), "%i", &m_handle) != 1) {
-            printf("failed: invalid widget handle\n");
-            return showHelpAndQuit();
-        }
-
-        LogDebug("Widget Id: " << m_handle << " (" << arg << ")");
     }
 
     AddStep(&WrtInstaller::shutdownStep);
@@ -273,6 +283,7 @@ int WrtInstaller::getReturnStatus() const
 void WrtInstaller::OnTerminate()
 {
     LogDebug("Wrt Shutdown now");
+    PluginUtils::unlockPluginInstallation();
     if (m_initialized) {
         wrt_installer_shutdown();
     }
@@ -292,25 +303,15 @@ void WrtInstaller::showHelpAndQuit()
            "  -h,    --help                                 show this help\n"
            "  -p,    --install-plugins                      install plugins\n"
            "  -i,    --install                              "
-           "install widget package for given path\n"
-           "  -iu,   --install-or-update                    "
            "install or update widget package for given path\n"
            "  -if,   --install-force                        "
            "install forcibly widget package for given path\n"
-           "  -inq,  --install-not-quiet                    "
-           "install with popup                   \n"
-           "  -u,    --uninstall                            "
-           "uninstall widget for given ID\n"
-           "  -un,   --uninstall for given package name     "
-           "uninstall widget for given pakcage name\n"
+           "  -un,   --uninstall-name                       "
+           "uninstall widget for given package name\n"
            "  -ug,   --uninstall-guid                       "
            "uninstall widget for given Global Unique IDentifier\n"
-           "  -unq,  --uninstall-not-quiet                  "
-           "uninstall with popup                 \n"
-           "  --url                                         "
-           "URL of the remote page for Web Application installed from browser\n"
-           "  --icon                                        "
-           "path to the icon for Web Application installed from browser\n"
+           "  -up,   --uninstall-packagepath                "
+           "uninstall widget for given package file path\n"
            "\n");
 
     Quit();
@@ -352,6 +353,8 @@ void WrtInstaller::OnEventReceived(
                 static_cast<void*>(privateData),
                 &staticWrtPluginInstallationCallback,
                 &staticWrtPluginInstallProgressCb);
+    } else {
+        delete privateData;
     }
 }
 
@@ -363,21 +366,23 @@ void WrtInstaller::initStep()
 void WrtInstaller::installStep()
 {
     LogDebug("Installing widget ...");
-    if (!m_quiet) {
-        m_popup->init();
-    }
-    DPL::ScopedFree<char> packagePath(canonicalize_file_name(
+    std::unique_ptr<char, free_deleter> packagePath(canonicalize_file_name(
             m_packagePath.c_str()));
-    wrt_install_widget(packagePath ? packagePath.Get() : m_packagePath.c_str(),
+
+    wrt_install_widget(packagePath ? packagePath.get() : m_packagePath.c_str(),
                        this, &staticWrtStatusCallback,
                        (!m_quiet || m_installByPkgmgr)
                        ? &staticWrtInstallProgressCallback : NULL,
-                       m_installPolicy);
+                       m_installPolicy,
+                       m_quiet,
+                       m_preloadWidget,
+                       pkgmgrSignalInterface);
 }
 
 void WrtInstaller::installPluginsStep()
 {
     LogDebug("Installing plugins ...");
+    fprintf(stderr,"Installing plugins ...\n");
 
     if (m_startupPluginInstallation) {
         LogInfo("Plugin installation started because new plugin package found");
@@ -437,47 +442,38 @@ void WrtInstaller::installPluginsStep()
     LogInfo("Plugins to install: " << m_numPluginsToInstall);
     m_pluginsPaths = pluginsPaths;
 
-    // install geolocation plugin
-    {
-        m_numPluginsToInstall++;
-        (*m_pluginsPaths).push_back(GlobalConfig::GetW3CGeolocationFeatureName());
-    }
-
     m_totalPlugins = m_numPluginsToInstall;
     DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>
         ::PostEvent(WRTInstallerNS::InstallPluginEvent());
 
     if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
-        LogError("Failed to close dir: " << dir);
+        LogError("Failed to close dir: " << PLUGIN_PATH << " with error: "
+                << DPL::GetErrnoString());
     }
 }
 
-void WrtInstaller::uninstallStep()
+void WrtInstaller::uninstallPkgNameStep()
 {
     LogDebug("Uninstalling widget ...");
-    if (!m_quiet) {
-        m_popup->init();
-    }
-
-    wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
+    LogDebug("Package name : " << m_name);
+    wrt_uninstall_widget(m_name.c_str(), this, &staticWrtStatusCallback,
             (!m_quiet || m_installByPkgmgr)
-            ? &staticWrtUninstallProgressCallback : NULL);
+            ? &staticWrtUninstallProgressCallback : NULL,
+            pkgmgrSignalInterface);
 }
 
-void WrtInstaller::uninstallPkgNameStep()
+void WrtInstaller::uninstallGuidStep()
 {
     LogDebug("Uninstalling widget ...");
-    if (!m_quiet) {
-        m_popup->init();
-    }
-
-    WrtErrStatus status = wrt_get_widget_by_pkgname(m_name, &m_handle);
+    std::string pkgname;
+    WrtErrStatus status = wrt_get_widget_by_guid(pkgname, m_name);
     if (status == WRT_SUCCESS) {
-        LogDebug("Get Widget Handle by package name : " << m_handle);
-        wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
-                (!m_quiet || m_installByPkgmgr)
-                ? &staticWrtUninstallProgressCallback : NULL);
+        LogDebug("Guid : " << m_name);
+        wrt_uninstall_widget(pkgname.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(
@@ -485,23 +481,75 @@ void WrtInstaller::uninstallPkgNameStep()
     }
 }
 
-void WrtInstaller::uninstallGuidStep()
+void WrtInstaller::unistallWgtFileStep()
 {
     LogDebug("Uninstalling widget ...");
-    if (!m_quiet) {
-        m_popup->init();
-    }
 
-    WrtErrStatus status = wrt_get_widget_by_guid(m_name, &m_handle);
-    if (status == WRT_SUCCESS) {
-        LogDebug("Get Widget Handle by guid : " << m_handle);
-        wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
-                !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
-    } else {
-        LogError("Fail to uninstalling widget... ");
+    Try {
+        // Parse config
+        ParserRunner parser;
+        ConfigParserData configInfo;
+
+        // Open zip file
+        std::unique_ptr<DPL::ZipInput> zipFile(
+                new DPL::ZipInput(m_packagePath));
+
+        // Open config.xml file
+        std::unique_ptr<DPL::ZipInput::File> configFile(
+                zipFile->OpenFile(CONFIG_XML));
+
+        // Extract config
+        DPL::BinaryQueue buffer;
+        DPL::AbstractWaitableInputAdapter inputAdapter(configFile.get());
+        DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
+        DPL::Copy(&inputAdapter, &outputAdapter);
+        parser.Parse(&buffer,
+                ElementParserPtr(
+                    new RootParser<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);
+        if (status == WRT_SUCCESS) {
+            LogDebug("Pkgname from packagePath : " << pkgname);
+            wrt_uninstall_widget(pkgname.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());
+        }
+    }
+    Catch(DPL::ZipInput::Exception::OpenFailed)
+    {
+        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());
+                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());
+    }
+    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());
     }
 }
 
@@ -527,7 +575,7 @@ void WrtInstaller::staticWrtInitCallback(WrtErrStatus status,
         This->m_initialized = true;
         This->m_returnStatus = 0;
 
-        if (!This->m_quiet) {
+        if (This->popupsEnabled()) {
             This->m_popup = new InstallerPopup;
             This->m_popup->init();
         }
@@ -542,7 +590,7 @@ void WrtInstaller::staticWrtInitCallback(WrtErrStatus status,
     }
 }
 
-void WrtInstaller::staticWrtStatusCallback(int handle,
+void WrtInstaller::staticWrtStatusCallback(std::string tizenId,
                                            WrtErrStatus status,
                                            void* userdata)
 {
@@ -556,27 +604,22 @@ void WrtInstaller::staticWrtStatusCallback(int handle,
     if (current == &WrtInstaller::installStep)
     {
         resultMsg = DPL::FromUTF8String(PKGMGR_INSTALL_MSG);
-        printMsg = "installed";
-    } else if (current == &WrtInstaller::uninstallStep ||
-            current == &WrtInstaller::uninstallPkgNameStep ||
-            current == &WrtInstaller::uninstallGuidStep)
+        printMsg = "installation";
+    } else if (current == &WrtInstaller::uninstallPkgNameStep ||
+            current == &WrtInstaller::uninstallGuidStep ||
+            current == &WrtInstaller::unistallWgtFileStep)
     {
         resultMsg = DPL::FromUTF8String(PKGMGR_UNINSTALL_MSG);
-        printMsg = "uninstalled";
+        printMsg = "uninstallation";
     }
 
     if (WRT_SUCCESS != status) {
         // Failure
-        LogDebug("Step failed");
+        LogError("Step failed");
         This->m_returnStatus = -1;
 
-        if (This->m_installByPkgmgr) {
-            PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
-                            PKGMGR_END_KEY, PKGMGR_FAIL_VAL);
-        }
-
-        if (!This->m_quiet) {
-            resultMsg +=  L" : " + DPL::FromUTF8String(PKGMGR_FAIL_VAL);
+        if (This->popupsEnabled()) {
+            resultMsg +=  L" : " + DPL::FromUTF8String(PKGMGR_END_FAILURE);
             This->m_popup->showPopup(This, resultMsg, failResultCallback);
         } else {
             This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
@@ -586,72 +629,77 @@ void WrtInstaller::staticWrtStatusCallback(int handle,
         switch (status) {
             case WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE:
                 This->m_returnStatus = 1; //this status is specific
-                printf("failed: invalid widget package\n");
+                fprintf(stderr, "## wrt-installer : %s %s has failed - invalid widget package\n",
+                        tizenId.c_str(), printMsg.c_str());
                 break;
 
             case WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST:
-                printf("failed: widget package does not exist\n");
-                break;
-
-            case WRT_INSTALLER_ERROR_FACTORY_WIDGET:
-                printf("failed: factory widget\n");
+                fprintf(stderr, "## wrt-installer : %s %s has failed - widget package does not exist\n",
+                        tizenId.c_str(), printMsg.c_str());
                 break;
 
             case WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING:
-                printf("failed: already uninstalling\n");
+                fprintf(stderr, "## wrt-installer : %s %s has failed - already uninstalling\n",
+                        tizenId.c_str(), printMsg.c_str());
                 break;
 
             case WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE:
-                printf("failed: out of disk space\n");
+                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:
-                printf("failed: invalid certificate\n");
+                fprintf(stderr,"## wrt-installer : %s %s has failed - invalid certificate\n",
+                        tizenId.c_str(), printMsg.c_str());
                 break;
 
             case WRT_INSTALLER_ERROR_ALREADY_INSTALLED:
-                printf("failed: already installed\n");
+                fprintf(stderr,"## wrt-installer : %s %s has failed - already installed\n",
+                        tizenId.c_str(), printMsg.c_str());
                 break;
 
             case WRT_INSTALLER_ERROR_INTERNAL:
-                printf("failed: internal error\n");
+                fprintf(stderr,"## wrt-installer : %s %s has failed - internal error\n",
+                        tizenId.c_str(), printMsg.c_str());
                 break;
 
             case WRT_INSTALLER_ERROR_NOT_ALLOWED:
-                printf("failed: installation or update not allowed; invalid"
-                       " mode\n");
+                fprintf(stderr,"## wrt-installer : %s %s has failed - installation or update not allowed; invalid"
+                       " mode\n", tizenId.c_str(), printMsg.c_str());
                 break;
 
             case WRT_INSTALLER_ERROR_DEFERRED:
-                printf("deferred: widget update will continue after the widget"
+                fprintf(stderr,"## wrt-installer : deferred: widget update will continue after the widget"
                        " has been stopped\n");
                 break;
 
             case WRT_INSTALLER_ERROR_DATABASE_FAILURE:
-                printf("failed: database failure\n");
+                fprintf(stderr,"## wrt-installer : %s %s has failed - database failure\n",
+                        tizenId.c_str(), printMsg.c_str());
+                break;
+
+            case WRT_INSTALLER_ERROR_OSPSVC:
+                fprintf(stderr,"## wrt-installer : %s %s has failed - during installation or"
+                        " uninstallation osp service\n", tizenId.c_str(),
+                        printMsg.c_str());
                 break;
 
             case WRT_INSTALLER_ERROR_UNKNOWN:
-                printf("failed: unknown error\n");
+                fprintf(stderr,"## wrt-installer : %s %s has failed - unknown error\n",
+                        tizenId.c_str(), printMsg.c_str());
                 break;
 
             default:
                 break;
+
         }
     } else {
-
-        printf("%s : %d\n", printMsg.c_str(), handle);
+        fprintf(stderr, "## wrt-installer : %s %s was successful.\n", tizenId.c_str(), printMsg.c_str());
         LogDebug("Status succesfull");
-        This->m_handle = handle;
         This->m_returnStatus = 0;
-        resultMsg +=  L" : " + DPL::FromUTF8String(PKGMGR_OK_VAL);
+        resultMsg +=  L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
 
-        if (This->m_installByPkgmgr) {
-            PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
-                            PKGMGR_END_KEY, PKGMGR_OK_VAL);
-        }
-
-        if (!This->m_quiet) {
+        if (This->popupsEnabled()) {
             This->m_popup->showPopup(This, resultMsg, showResultCallback);
         } else {
             This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
@@ -677,18 +725,20 @@ void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
 
     if (This->m_numPluginsToInstall < 1) {
         LogDebug("All plugins installation completed");
-
-        //remove lock file
-        if (!PluginUtils::unlockPluginInstallation()) {
-            LogInfo("Failed to remove installation lock");
-        }
+        fprintf(stderr,"All plugins installation completed.\n");
 
         //remove installation request
         if (!PluginUtils::removeInstallationRequiredFlag()) {
             LogInfo("Failed to remove file initializing plugin installation");
         }
 
-        if (!This->m_quiet) {
+        //remove lock file
+        if (!PluginUtils::unlockPluginInstallation()) {
+            LogInfo("Failed to remove installation lock");
+        }
+
+        if (This->popupsEnabled()) {
+            This->m_popup->init();
             elm_progressbar_value_set(This->m_popup->m_progressbar, 100.0);
             evas_object_show(This->m_popup->m_popup);
         }
@@ -696,7 +746,8 @@ void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
         This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
             ::PostEvent(WRTInstallerNS::NextStepEvent());
     } else {
-        if (!This->m_quiet) {
+        if (This->popupsEnabled()) {
+            This->m_popup->init();
             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);
@@ -708,6 +759,8 @@ void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
 
     if (WRT_SUCCESS == status) {
         This->m_returnStatus = 0;
+        fprintf(stderr, "## wrt-installer : plugin installation successfull [%s]\n",
+                path.c_str());
         LogDebug("One plugin Installation succesfull: " << path);
         return;
     }
@@ -717,6 +770,8 @@ void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
 
     if (WRT_PLUGIN_INSTALLER_ERROR_WAITING == status) {
         LogInfo("Plugin installation is waiting for dependencies");
+        fprintf(stderr, "## wrt-installer : plugin installation failed [%s]\n",
+                path.c_str());
     }
 
     switch (status) {
@@ -764,30 +819,10 @@ void WrtInstaller::staticWrtInstallProgressCallback(float percent,
     WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
     std::stringstream percentStr;
     LogInfo(" progress: " << percent <<
-            "description " << description);
-
-    if (This->m_installByPkgmgr) {
-        if (This->m_sendSig) {
-            std::string desc = description;
-            size_t index = desc.find(" ");
-            std::string widgetId = desc.substr(0, index - 1);
-            This->m_name = desc.substr(index + 1, desc.length() - index);
+            " description: " << description);
 
-            PKGMGR_SEND_SIG(This->m_installer, widgetId.c_str(),
-                            PKGMGR_START_KEY, "install");
-            PKGMGR_SEND_SIG(This->m_installer, widgetId.c_str(),
-                            "change_pkg_name", This->m_name.c_str());
-
-            This->m_sendSig = false;
-        }
-        LogDebug("Broadcast Progress, pkgname" << This->m_name);
-
-        percentStr << static_cast<int>(percent);
-        PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
-                        PKGMGR_PROGRESS_KEY, percentStr.str().c_str());
-    }
-
-    if (!This->m_quiet) {
+    if (This->popupsEnabled()) {
+        This->m_popup->init();
         elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
         evas_object_show(This->m_popup->m_popup);
     }
@@ -798,22 +833,10 @@ void WrtInstaller::staticWrtUninstallProgressCallback(float percent,
     WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
     std::stringstream percentStr;
     LogInfo(" progress: " << percent <<
-            "description " << description);
-
-    if (This->m_installByPkgmgr) {
-        if (This->m_sendSig) {
-            PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
-                            PKGMGR_START_KEY, "uninstall");
-            This->m_sendSig = false;
-        }
-        LogDebug("Broadcast Progress, pkgname" << This->m_name);
+            " description: " << description);
 
-        percentStr << static_cast<int>(percent);
-        PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
-                        PKGMGR_PROGRESS_KEY, percentStr.str().c_str());
-    }
-
-    if (!This->m_quiet) {
+    if (This->popupsEnabled()) {
+        This->m_popup->init();
         elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
         evas_object_show(This->m_popup->m_popup);
     }
@@ -835,31 +858,28 @@ void WrtInstaller::InstallerPopup::init()
 {
     LogDebug("Window Init");
 
-    // create window
-    m_win = createWin("wrt-installer");
+    if (m_win == NULL) {
+        // create window
+        m_win = createWin("wrt-installer");
 
-    // security popup uses installer window
-    using namespace DPL::Popup;
-    PopupControllerSingleton::Instance().setExternalCanvas(m_win);
-    evas_object_show(m_win);
-
-    // create popup
-    m_popup = elm_popup_add(m_win);
+        // create popup
+        m_popup = elm_popup_add(m_win);
 
-    // create progressbar
-    m_progressbar = elm_progressbar_add(m_popup);
-    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,
+        // create progressbar
+        m_progressbar = elm_progressbar_add(m_popup);
+        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_object_size_hint_weight_set(m_progressbar, EVAS_HINT_EXPAND,
+        evas_object_size_hint_weight_set(m_progressbar, EVAS_HINT_EXPAND,
             EVAS_HINT_EXPAND);
-    elm_popup_content_set(m_popup, m_progressbar);
-    elm_progressbar_value_set(m_progressbar, 0.0);
-    evas_object_show(m_progressbar);
+        elm_object_content_set(m_popup, m_progressbar);
+        elm_progressbar_value_set(m_progressbar, 0.0);
+        evas_object_show(m_progressbar);
 
-    // set progressbar to popup
-    evas_object_show(m_popup);
+        evas_object_show(m_popup);
+        evas_object_show(m_win);
+    }
 }
 
 Evas_Object* WrtInstaller::InstallerPopup::createWin(const char *name)
@@ -867,47 +887,17 @@ Evas_Object* WrtInstaller::InstallerPopup::createWin(const char *name)
     Evas_Object *win;
     win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
 
-    int w, h, x, y;
-    int ret = 0;
-    int count;
-    int rotation = -1;
-    unsigned char *prop_data = NULL;
-    double xScale, yScale, scale;
-
-    if (win) {
-        elm_win_alpha_set(win, EINA_TRUE);
-        elm_win_title_set(win, name);
-        elm_win_borderless_set(win, EINA_TRUE);
-        elm_win_raise(win);
-        ecore_x_window_geometry_get(ecore_x_window_root_get(
-                ecore_x_window_focus_get()),
-                &x,
-                &y,
-                &w,
-                &h);
-        ret  = ecore_x_window_prop_property_get(ecore_x_window_root_get(
-                    ecore_x_window_focus_get()),
-                    ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE,
-                    ECORE_X_ATOM_CARDINAL, 32, &prop_data, &count);
-    }
-    if (ret && prop_data) {
-        Assert(count != sizeof(int));
-        memcpy(&rotation, prop_data, sizeof(int));
-    }
-    if (prop_data) {
-        free(prop_data);
-    }
-    evas_object_resize(win, w, h);
-
-    if (rotation != -1) {
-        elm_win_rotation_with_resize_set(win, rotation);
-    }
+    int w, h;
+    if(!win)
+        return NULL;
 
-    xScale = (double)w  / BASE_LAYOUT_W;
-    yScale = (double)h  / BASE_LAYOUT_H;
-    scale  = xScale < yScale ? xScale : yScale;
-    elm_scale_set(scale);
+    elm_win_alpha_set(win, EINA_TRUE);
+    elm_win_title_set(win, name);
+    elm_win_borderless_set(win, EINA_TRUE);
+    elm_win_raise(win);
 
+    ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
+    evas_object_resize(win, w, h);
     return win;
 }
 
@@ -915,15 +905,31 @@ void WrtInstaller::InstallerPopup::showPopup(void* userdata,
                                              const DPL::String& pkgMsg,
                                              ShowResultCallback callback)
 {
+    Evas_Object *btn;
+
+
     LogDebug("Result Popup Created");
     evas_object_del(m_popup);
     m_popup = NULL;
 
-    m_popup = elm_popup_with_buttons_add(m_win, "RESULT",
-                                         DPL::ToUTF8String(pkgMsg).c_str(),
-                                         1, "OK", 5, NULL);
-    evas_object_smart_callback_add(m_popup, "response", callback, userdata);
+    m_popup = elm_popup_add(m_win);
+    if (!m_popup)
+        return;
+
+    btn = elm_button_add(m_popup);
+    if (!btn) {
+        evas_object_del(m_popup);
+        return;
+    }
+    elm_object_text_set(btn, "OK");
+    evas_object_smart_callback_add(btn, "clicked", callback, userdata);
+    elm_object_part_content_set(m_popup, "button1", btn);
+    elm_object_part_text_set(m_popup, "title,text", "RESULT");
+    elm_object_text_set(m_popup, DPL::ToUTF8String(pkgMsg).c_str());
+
     evas_object_show(m_popup);
+    evas_object_show(m_win);
+
 }
 
 void WrtInstaller::showResultCallback(void *data, Evas_Object* /*obj*/,
@@ -965,27 +971,55 @@ void WrtInstaller::installNewPlugins()
     AddStep(&WrtInstaller::installPluginsStep);
 }
 
+bool WrtInstaller::popupsEnabled() const
+{
+    return !m_quiet && !GlobalSettings::PopupsTestModeEnabled();
+}
+
 int main(int argc, char *argv[])
 {
-    // Output on stdout will be flushed after every newline character,
-    // even if it is redirected to a pipe. This is useful for running
-    // from a script and parsing output.
-    // (Standard behavior of stdlib is to use full buffering when
-    // redirected to a pipe, which means even after an end of line
-    // the output may not be flushed).
-    setlinebuf(stdout);
-
-    // enable gl
-    if (!getenv("ELM_ENGINE")) {
-        if (setenv("ELM_ENGINE", "gl", 1)) {
-                LogDebug("Enable gl for HW Accel");
+    UNHANDLED_EXCEPTION_HANDLER_BEGIN
+    {
+        // Output on stdout will be flushed after every newline character,
+        // even if it is redirected to a pipe. This is useful for running
+        // from a script and parsing output.
+        // (Standard behavior of stdlib is to use full buffering when
+        // redirected to a pipe, which means even after an end of line
+        // the output may not be flushed).
+        setlinebuf(stdout);
+
+        // Check and re-set the file open limitation
+        struct rlimit rlim;
+        if (getrlimit(RLIMIT_NOFILE, &rlim) != -1) {
+            LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")" );
+            LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")" );
+
+            if (rlim.rlim_cur < NOFILE_CNT_FOR_INSTALLER) {
+                rlim.rlim_cur = NOFILE_CNT_FOR_INSTALLER;
+                rlim.rlim_max = NOFILE_CNT_FOR_INSTALLER;
+                if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) {
+                    LogError("setrlimit is fail!!");
+                }
+            }
+        } else {
+            LogError("getrlimit is fail!!");
         }
-    }
 
-    WrtInstaller app(argc, argv);
-    int ret = app.Exec();
-    LogDebug("App returned: " << ret);
-    ret = app.getReturnStatus();
-    LogDebug("WrtInstaller returned: " << ret);
-    return ret;
+        // set evas backend type for emulator
+        // popup isn't showed in the emulator,
+        // if backend isn't set to SW backend
+        if (GlobalSettings::IsEmulator()) {
+            if (setenv("ELM_ENGINE", "x11", 1)) {
+                LogDebug("Enable backend");
+            }
+        }
+
+        WrtInstaller app(argc, argv);
+        int ret = app.Exec();
+        LogDebug("App returned: " << ret);
+        ret = app.getReturnStatus();
+        LogDebug("WrtInstaller returned: " << ret);
+        return ret;
+    }
+    UNHANDLED_EXCEPTION_HANDLER_END
 }
index c043985..723236f 100644 (file)
 #include <string>
 #include <utilX.h>
 #include <wrt_installer_api.h>
-#include <pkgmgr_installer.h>
+
+#include <pkg-manager/pkgmgr_signal_interface.h>
+#include <pkg-manager/pkgmgr_signal_dummy.h>
+#include <pkg-manager/pkgmgr_signal.h>
+#include <memory>
 
 namespace WRTInstallerNS { //anonymous
 DECLARE_GENERIC_EVENT_0(QuitEvent)
@@ -99,9 +103,9 @@ class WrtInstaller :
     void installStep();
     void installNewPlugins();
     void installPluginsStep();
-    void uninstallStep();
     void uninstallPkgNameStep();
     void uninstallGuidStep();
+    void unistallWgtFileStep();
     void shutdownStep();
     void registerCallbackStep();
     void queryListStep();
@@ -110,7 +114,7 @@ class WrtInstaller :
     // Static callbacks
     static void staticWrtInitCallback(WrtErrStatus status,
                                       void* userdata);
-    static void staticWrtStatusCallback(int handle,
+    static void staticWrtStatusCallback(std::string tizenId,
                                         WrtErrStatus status,
                                         void* userdata);
     static void staticWrtPluginInstallationCallback(WrtErrStatus status,
@@ -131,7 +135,10 @@ class WrtInstaller :
     static void failResultCallback(void *data, Evas_Object *obj,
                                    void *event_info);
 
+    bool popupsEnabled() const;
+
     // Private data
+    std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrSignalInterface;
     wrt_widget_install_mode_e m_installPolicy;
     std::string m_bundleValue;
     std::string m_packagePath;
@@ -141,15 +148,13 @@ class WrtInstaller :
     size_t m_numPluginsToInstall;
     size_t m_totalPlugins;
     int m_returnStatus;
-    //For package manager
-    pkgmgr_installer *m_installer;
     bool m_installByPkgmgr;
     bool m_quiet;
-    bool m_sendSig;
     InstallerPopup *m_popup;
     bool m_startupPluginInstallation;
-    std::string m_webAppUrl;
+    std::string m_webAppConfig;
     std::string m_webAppIcon;
+    bool m_preloadWidget;
 
     typedef std::list<std::string> PluginPathList;
     DPL::Optional<PluginPathList> m_pluginsPaths;
index 7954f01..e481f2f 100644 (file)
 #include <dpl/exception.h>
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
+#include <dpl/semaphore.h>
 #include <dpl/sstream.h>
+#include <dpl/errno_string.h>
 #include <libxml/parser.h>
+#include <vconf.h>
 
 #include <wrt_installer_api.h>
 #include <installer_callbacks_translate.h>
 #include <installer_controller.h>
-#include <security_controller.h>
 #include <language_subtag_rst_tree.h>
-#include <dpl/localization/localization_utils.h>
 #include <dpl/wrt-dao-ro/global_config.h>
 #include <dpl/utils/widget_version.h>
-#include <dpl/popup/popup_manager.h>
-#include <dpl/popup/popup_controller.h>
-#include <attribute_facade.h>
 #include <wrt_type.h>
 #include <dpl/localization/w3c_file_localization.h>
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
@@ -64,8 +62,10 @@ extern "C"
     inline WidgetUpdateMode::Type translateWidgetUpdateMode(
             wrt_widget_update_mode_t updateMode)
     {
-        WidgetUpdateMode::Type result = WidgetUpdateMode::Zero;
+        if (updateMode == WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL)
+            return WidgetUpdateMode::PolicyDirectoryForceInstall;
 
+        WidgetUpdateMode::Type result = WidgetUpdateMode::Zero;
         if (updateMode & WRT_WIM_NOT_INSTALLED) {
             result = result | WidgetUpdateMode::NotInstalled;
         }
@@ -138,17 +138,17 @@ extern "C"
                 "> does not exist.");
         }
 
-        if_ok &= (checkPath(GlobalConfig::GetFactoryInstalledWidgetPath()));
+        if_ok &= (checkPath(GlobalConfig::GetUserInstalledWidgetPath()));
         if (!if_ok) {
             LogError(
-                "Path <" << GlobalConfig::GetFactoryInstalledWidgetPath() <<
+                "Path <" << GlobalConfig::GetUserInstalledWidgetPath() <<
                 "> does not exist.");
         }
 
-        if_ok &= (checkPath(GlobalConfig::GetUserInstalledWidgetPath()));
+        if_ok &= (checkPath(GlobalConfig::GetUserPreloadedWidgetPath()));
         if (!if_ok) {
             LogError(
-                "Path <" << GlobalConfig::GetUserInstalledWidgetPath() <<
+                "Path <" << GlobalConfig::GetUserPreloadedWidgetPath() <<
                 "> does not exist.");
         }
         return if_ok;
@@ -237,6 +237,12 @@ extern "C"
                 return TRUE;
             }
 
+            // 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
@@ -250,35 +256,18 @@ extern "C"
             LogInfo("Prepare libxml2 to work in multithreaded program.");
             xmlInitParser();
 
-            using namespace DPL::Popup;
-            // Initialize popup manager
-            PopupManagerSingleton::Instance().Initialize(
-                    PopupRendererPtr(new PopupRenderer));
-
             // Initialize Language Subtag registry
             LanguageSubtagRstTreeSingleton::Instance().Initialize();
-            LocalizationUtils::Initialize();
-
-            // Initialize ValidationCore
-            ValidationCore::VCoreInit(
-                    std::string(GlobalConfig::GetFingerprintListFile()),
-                    std::string(GlobalConfig::GetFingerprintListSchema()),
-                    std::string(GlobalConfig::GetVCoreDatabaseFilePath()));
-
-            // Security Logic initialization
-            CONTROLLER_POST_SYNC_EVENT(
-                    SecurityController,
-                    SecurityControllerEvents::InitializeSyncEvent());
 
             // Installer init
             CONTROLLER_POST_SYNC_EVENT(
-                    InstallerController,
+                    Logic::InstallerController,
                     InstallerControllerEvents::
                     InitializeEvent());
 
             // Install deferred widget packages
             CONTROLLER_POST_EVENT(
-                    InstallerController,
+                    Logic::InstallerController,
                     InstallerControllerEvents::
                     InstallDeferredWidgetPackagesEvent());
 
@@ -306,26 +295,21 @@ extern "C"
         {
             LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER...");
 
-            // Deinitialize Security Logic
-            CONTROLLER_POST_SYNC_EVENT(
-                    SecurityController,
-                    SecurityControllerEvents::
-                    TerminateSyncEvent());
-
             // Installer termination
             CONTROLLER_POST_SYNC_EVENT(
-                    InstallerController,
+                    Logic::InstallerController,
                     InstallerControllerEvents::
                     TerminateEvent());
 
             InstallerMainThreadSingleton::Instance().DetachDatabases();
 
+            // This must be done after DetachDatabase
+            ValidationCore::VCoreDeinit();
+
             // Global deinit check
             LogInfo("Cleanup libxml2 global values.");
             xmlCleanupParser();
 
-            // Deinitialize popup manager
-            DPL::Popup::PopupManagerSingleton::Instance().Deinitialize();
         }
         catch (const DPL::Exception& ex)
         {
@@ -338,43 +322,56 @@ extern "C"
                                        void* userdata,
                                        WrtInstallerStatusCallback status_cb,
                                        WrtProgressCallback progress_cb,
-                                       wrt_widget_update_mode_t update_mode)
+                                       wrt_widget_update_mode_t update_mode,
+                                       bool quiet,
+                                       bool preload,
+                                       std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrInterface
+                                       )
     {
         UNHANDLED_EXCEPTION_HANDLER_BEGIN
         {
             LogInfo("[WRT-API] INSTALL WIDGET: " << path);
             // Post installation event
             CONTROLLER_POST_EVENT(
-                InstallerController,
+                Logic::InstallerController,
                 InstallerControllerEvents::InstallWidgetEvent(
                     path, WidgetInstallationStruct(
                         InstallerCallbacksTranslate::installFinishedCallback,
                         InstallerCallbacksTranslate::installProgressCallback,
                         new InstallerCallbacksTranslate::StatusCallbackStruct(
                             userdata, status_cb, progress_cb),
-                        translateWidgetUpdateMode(update_mode))));
+                        translateWidgetUpdateMode(update_mode),
+                        quiet,
+                        preload,
+                        pkgmgrInterface)));
         }
         UNHANDLED_EXCEPTION_HANDLER_END
     }
 
-    EXPORT_API void wrt_uninstall_widget(int widget_handle,
+    EXPORT_API void wrt_uninstall_widget(const char * const pkg_name,
                                          void* userdata,
                                          WrtInstallerStatusCallback status_cb,
-                                         WrtProgressCallback progress_cb)
+                                         WrtProgressCallback progress_cb,
+                                         std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrSignalInterface)
     {
         UNHANDLED_EXCEPTION_HANDLER_BEGIN
         {
-            LogInfo("[WRT-API] UNINSTALL WIDGET: " << widget_handle);
+            std::string widgetPkgName(pkg_name);
+            LogInfo("[WRT-API] UNINSTALL WIDGET: " << widgetPkgName);
             // Post uninstallation event
             CONTROLLER_POST_EVENT(
-                InstallerController,
-                InstallerControllerEvents::UninstallWidgetEvent(
-                    widget_handle,
-                    WidgetUninstallationStruct(
-                        InstallerCallbacksTranslate::uninstallFinishedCallback,
-                        InstallerCallbacksTranslate::installProgressCallback,
-                        new InstallerCallbacksTranslate::StatusCallbackStruct(
-                            userdata, status_cb, progress_cb))));
+                    Logic::InstallerController,
+                    InstallerControllerEvents::UninstallWidgetEvent(
+                            widgetPkgName,
+                            WidgetUninstallationStruct(
+                                    InstallerCallbacksTranslate::uninstallFinishedCallback,
+                                    InstallerCallbacksTranslate::installProgressCallback,
+                                    new InstallerCallbacksTranslate::StatusCallbackStruct(
+                                            userdata, status_cb, progress_cb),
+                                    pkgmgrSignalInterface
+                            )
+                    )
+            );
         }
         UNHANDLED_EXCEPTION_HANDLER_END
     }
@@ -394,32 +391,16 @@ extern "C"
             callbackStruct =
                 new InstallerCallbacksTranslate::PluginStatusCallbackStruct(
                     user_param, status_cb, progress_cb);
-            // Added geolocation feature in FeaturesList DB for installing
-            // widget using gelocation feature.
-            // If other strange features are added, it will be changed
-            // for using all of strange features.
-            if (strcmp(pluginDir,
-                       GlobalConfig::GetW3CGeolocationFeatureName()) == 0)
-            {
-                CONTROLLER_POST_EVENT(
-                    InstallerController,
-                    InstallerControllerEvents::InstallPluginGeolocationEvent(
-                        PluginInstallerStruct(
-                            InstallerCallbacksTranslate::
-                            pluginInstallFinishedCallback,
-                            InstallerCallbacksTranslate::
-                            installProgressCallback, callbackStruct)));
-            } else {
-                CONTROLLER_POST_EVENT(
-                    InstallerController,
-                    InstallerControllerEvents::InstallPluginEvent(
-                        std::string(pluginDir),
-                        PluginInstallerStruct(
-                            InstallerCallbacksTranslate::
-                            pluginInstallFinishedCallback,
-                            InstallerCallbacksTranslate::
-                            installProgressCallback, callbackStruct)));
-            }
+
+            CONTROLLER_POST_EVENT(
+                Logic::InstallerController,
+                InstallerControllerEvents::InstallPluginEvent(
+                    std::string(pluginDir),
+                    PluginInstallerStruct(
+                        InstallerCallbacksTranslate::
+                        pluginInstallFinishedCallback,
+                        InstallerCallbacksTranslate::
+                        installProgressCallback, callbackStruct)));
         }
         UNHANDLED_EXCEPTION_HANDLER_END
     }
@@ -518,11 +499,9 @@ extern "C"
                     plugin_install_progress_cb);
             }
 
-            wrt_install_plugin(
-                GlobalConfig::GetW3CGeolocationFeatureName(), NULL, NULL, NULL);
-
             if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
-                LogError("Failed to close dir: " << dir);
+                LogError("Failed to close dir: " << PLUGIN_PATH << " with error: "
+                        << DPL::GetErrnoString());
             }
 
             if (0 != unlink(installRequest.c_str())) {
@@ -564,7 +543,7 @@ extern "C"
             }
 
             CONTROLLER_POST_SYNC_EVENT(
-                    InstallerController,
+                    Logic::InstallerController,
                     InstallerControllerEvents::
                     InitializeEvent());
 
@@ -595,7 +574,7 @@ extern "C"
 
             // Installer termination
             CONTROLLER_POST_SYNC_EVENT(
-                    InstallerController,
+                    Logic::InstallerController,
                     InstallerControllerEvents::
                     TerminateEvent());
 
@@ -610,43 +589,17 @@ extern "C"
         }
     }
 
-    EXPORT_API WrtErrStatus wrt_get_widget_by_pkgname(const std::string pkgname,
-            int *widget_handle)
-    {
-        try
-        {
-            LogInfo("[WRT-API] GETTING WIDGET HANDLE BY PKG NAME : "
-                    << pkgname);
-
-            WidgetHandle handle = WidgetDAO::getHandle(
-                    DPL::FromASCIIString(pkgname));
-            *widget_handle = static_cast<int>(handle);
-            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 WrtErrStatus wrt_get_widget_by_guid(const std::string guid,
-            int *widget_handle)
+    EXPORT_API WrtErrStatus wrt_get_widget_by_guid(std::string & pkgname,
+                                                   const std::string guid)
     {
         try
         {
-            LogInfo("[WRT-API] GETTING WIDGET HANDLE BY WidgetID : "
+            LogInfo("[WRT-API] GETTING WIDGET PACKAGE NAME BY WidgetID : "
                     << guid);
 
             WidgetGUID widget_guid = DPL::FromUTF8String(guid);
-            WidgetHandle handle = WidgetDAO::getHandle(widget_guid);
-            *widget_handle = static_cast<int>(handle);
+            WrtDB::WidgetDAOReadOnly dao(widget_guid);
+            pkgname = DPL::ToUTF8String(dao.getPkgName());
             return WRT_SUCCESS;
         }
         catch (WidgetDAOReadOnly::Exception::WidgetNotExist)
index fe5ca85..6f2bea6 100755 (executable)
@@ -33,6 +33,8 @@
 #include <stdbool.h>
 #include <stddef.h>
 #include <wrt_type.h>
+#include <pkgmgr_signal_interface.h>
+#include <memory>
 
 #ifdef __cplusplus
 extern "C" {
@@ -53,7 +55,7 @@ typedef void (*WrtPluginInstallerStatusCallback)(WrtErrStatus status,
 /**
  * Callback function type invoked after async functions
  */
-typedef void (*WrtInstallerStatusCallback)(int widget_handle,
+typedef void (*WrtInstallerStatusCallback)(std::string tizenId,
                                   WrtErrStatus status,
                                   void *data);
 
@@ -151,7 +153,10 @@ typedef enum wrt_widget_install_mode_e
 
     /* Force install policy
      */
-    WRT_WIM_POLICY_FORCE_INSTALL = WRT_WIM_POLICY_ALWAYS_INSTALL
+    WRT_WIM_POLICY_FORCE_INSTALL = WRT_WIM_POLICY_ALWAYS_INSTALL,
+    /* Installation from directory - forced update
+     */
+    WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL
 } wrt_widget_update_mode_t;
 
 int wrt_installer_init(void *userdata,
@@ -196,7 +201,9 @@ void wrt_installer_shutdown(void);
  *                      void *user_parameter,
  *                      WrtInstallerStatusCallback status_callback,
  *                      WrtProgressCallback progress_callback,
- *                      wrt_widget_update_mode_t update_mode);
+ *                      wrt_widget_update_mode_t update_mode,
+ *                      bool quiet,
+ *                      bool preload);
  *
  * @brief Installs widget from given path
  *
@@ -213,6 +220,8 @@ void wrt_installer_shutdown(void);
  *                                  If you don't want to get progress data, this
  *                                  should be NULL
  * @param [in]  install_mode        Installation mode
+ * @param [in]  quiet               quiet mode
+ * @param [in]  preload             preload widget install
  * @return                          Nothing (status returned in callback).
  *
  * Sample code:
@@ -221,7 +230,9 @@ void wrt_installer_shutdown(void);
  *                      NULL,
  *                      install_cb,
  *                      progress_cb,
- *                      WRT_WIM_POLICY_WAC);
+ *                      WRT_WIM_POLICY_WAC,
+ *                      false,
+ *                      false);
  * @endcode
  *
  * @see wrt_installer_uninstall_widget
@@ -230,18 +241,22 @@ void wrt_install_widget(const char *path,
         void *user_parameter,
         WrtInstallerStatusCallback status_callback,
         WrtProgressCallback progress_callback,
-        wrt_widget_update_mode_t update_mode);
+        wrt_widget_update_mode_t update_mode,
+        bool quiet,
+        bool preload,
+        std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrInterface
+        );
 
 /**
- * @fn void wrt_installer_uninstall_widget (int widget_handle,
+ * @fn void wrt_installer_uninstall_widget (const char * const pkg_name,
  *                                void* userdata,
  *                                WrtInstallerStatusCallback cb)
- * @brief Uninstalls widget using its id
+ * @brief Uninstalls widget using its name
  *
- * This method is used to uninstall the widget specified by its handle.
+ * This method is used to uninstall the widget specified by its pkgname.
  * The callback function is called when the uninstall operation is done.
  *
- * @param [in]  widget_handle - widget id
+ * @param [in]  pkg_name    - package name
  * @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
@@ -260,10 +275,11 @@ void wrt_install_widget(const char *path,
  *
  * @see wrt_installer_install_widget
  */
-void wrt_uninstall_widget (int widget_handle,
+void wrt_uninstall_widget (const char * const pkg_name,
         void* userdata,
         WrtInstallerStatusCallback status_cb,
-        WrtProgressCallback progress_cb);
+        WrtProgressCallback progress_cb,
+        std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrSignalInterface);
 
 /**
  *  @fn void wrt_install_plugin(const char *pluginDirectory,
@@ -325,11 +341,13 @@ int wrt_installer_init_for_tests(void *userdata,
  */
 void wrt_installer_shutdown_for_tests();
 
-WrtErrStatus wrt_get_widget_by_pkgname(const std::string pkgname,
-        int *widget_handle);
-
-WrtErrStatus wrt_get_widget_by_guid(const std::string guid,
-        int *widget_handle);
+/**
+ * @brief wrt_get_widget_by_guid Returns pkgname by pkg guid (widgetId)
+ * @param pkgname pkgname 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);
 #ifdef __cplusplus
 }
 #endif
index f636395..8e5abb7 100755 (executable)
@@ -75,8 +75,7 @@ typedef enum
     /* Installer Errors*/
     WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE, /*<  */
     WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST,  /*<  */
-    WRT_INSTALLER_ERROR_FACTORY_WIDGET,         /*< Widget is factory installed,
-                                                   and cannot be uninstalled */
+
     WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING,   /*< Widget is already being
                                                    uninstalled */
     WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE,     /*<  */
@@ -93,6 +92,7 @@ typedef enum
     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*/
 
diff --git a/wrt-installer.manifest b/wrt-installer.manifest
new file mode 100644 (file)
index 0000000..7e8324f
--- /dev/null
@@ -0,0 +1,11 @@
+<manifest>
+  <define>
+    <domain name="wrt-installer" />
+    <provide>
+      <label name="wrt-installer::installer" />
+    </provide>
+  </define>
+  <request>
+    <domain name="_" />
+  </request>
+</manifest>