Update wrt-installer_0.0.69
authorSoyoung Kim <sy037.kim@samsung.com>
Thu, 25 Oct 2012 14:59:10 +0000 (23:59 +0900)
committerGerrit Code Review <gerrit2@kim11>
Fri, 26 Oct 2012 06:37:11 +0000 (15:37 +0900)
76 files changed:
configuration/config.tizen.xsd [new file with mode: 0644]
configuration/config.xml [new file with mode: 0644]
configuration/config.xsd [new file with mode: 0644]
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]
debian/changelog
debian/wrt-installer.postinst
etc/wrt_preinstall_widgets.sh
packaging/wrt-installer.spec
src/CMakeLists.txt
src/configuration_parser/element_parser.h
src/configuration_parser/ignoring_parser.cpp
src/configuration_parser/widget_parser.cpp
src/configuration_parser/widget_parser.h
src/jobs/plugin_install/plugin_objects.h
src/jobs/widget_install/job_widget_install.cpp
src/jobs/widget_install/job_widget_install.h
src/jobs/widget_install/task_ace_check.cpp
src/jobs/widget_install/task_certificates.cpp [new file with mode: 0755]
src/jobs/widget_install/task_certificates.h [new file with mode: 0755]
src/jobs/widget_install/task_certify.cpp
src/jobs/widget_install/task_certify.h
src/jobs/widget_install/task_commons.cpp
src/jobs/widget_install/task_commons.h
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_file_manipulation.cpp
src/jobs/widget_install/task_file_manipulation.h
src/jobs/widget_install/task_install_ospsvc.cpp
src/jobs/widget_install/task_livebox_conf.cpp [new file with mode: 0644]
src/jobs/widget_install/task_livebox_conf.h [new file with mode: 0644]
src/jobs/widget_install/task_manifest_file.cpp
src/jobs/widget_install/task_manifest_file.h
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_private_storage.cpp
src/jobs/widget_install/task_recovery.cpp
src/jobs/widget_install/task_remove_backup.cpp
src/jobs/widget_install/task_unzip.cpp
src/jobs/widget_install/task_unzip.h
src/jobs/widget_install/task_update_files.cpp
src/jobs/widget_install/task_update_files.h
src/jobs/widget_install/task_widget_config.cpp
src/jobs/widget_install/task_widget_config.h
src/jobs/widget_install/wac_security.cpp
src/jobs/widget_install/wac_security.h
src/jobs/widget_install/widget_install_errors.h
src/jobs/widget_install/widget_installer_struct.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_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_files.cpp
src/jobs/widget_uninstall/task_remove_files.h
src/jobs/widget_uninstall/task_uninstall_ospsvc.cpp
src/jobs/widget_uninstall/widget_uninstall_errors.h
src/jobs/widget_uninstall/widget_uninstaller_struct.h
src/logic/installer_controller.cpp
src/logic/installer_logic.cpp
src/logic/installer_logic.h
src/misc/feature_logic.h
src/misc/wac_widget_id.cpp
src/misc/widget_location.cpp
src/misc/widget_location.h
src/wrt-installer/CMakeLists.txt
src/wrt-installer/installer_callbacks_translate.cpp
src/wrt-installer/installer_callbacks_translate.h
src/wrt-installer/installer_main_thread.cpp
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
wrt-installer.manifest [new file with mode: 0644]

diff --git a/configuration/config.tizen.xsd b/configuration/config.tizen.xsd
new file mode 100644 (file)
index 0000000..1c42269
--- /dev/null
@@ -0,0 +1,64 @@
+<?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">
+
+<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:element name="appservice">
+    <xs:complexType>
+        <xs:attribute name="src" type="xs:string" 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="contextmenu" type="tizen:activationType" use="optional"/>
+    </xs:complexType>
+</xs:element>
+
+</xs:schema>
diff --git a/configuration/config.xml b/configuration/config.xml
new file mode 100644 (file)
index 0000000..4038a23
--- /dev/null
@@ -0,0 +1,35 @@
+<?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/api/accelerometer" required="false"/>
+  <feature name="http://tizen.org/api/account" required="false"/>
+  <feature name="http://tizen.org/api/application" required="false"/>
+  <feature name="http://tizen.org/api/callHistory.read" required="false"/>
+  <feature name="http://tizen.org/api/callHistory.write" required="false"/>
+  <feature name="http://tizen.org/api/deviceapis" required="false"/>
+  <feature name="http://tizen.org/api/deviceinteraction" required="false"/>
+  <feature name="http://tizen.org/api/gallery" required="false"/>
+  <feature name="http://tizen.org/api/gyroscope" required="false"/>
+  <feature name="http://tizen.org/api/intel-messaging" required="false"/>
+  <feature name="http://tizen.org/api/messaging" required="false"/>
+  <feature name="http://tizen.org/api/messaging.send" required="false"/>
+  <feature name="http://tizen.org/api/messaging.read" required="false"/>
+  <feature name="http://tizen.org/api/messaging.write" required="false"/>
+  <feature name="http://tizen.org/api/pim" required ="false"/>
+  <feature name="http://tizen.org/api/orientation" required="false"/>
+  <feature name="http://tizen.org/api/systeminfo" required="false"/>
+  <feature name="http://tizen.org/api/waclog" required="false"/>
+  <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" />
+</widget>
diff --git a/configuration/config.xsd b/configuration/config.xsd
new file mode 100644 (file)
index 0000000..84d734d
--- /dev/null
@@ -0,0 +1,178 @@
+<?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: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: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:choice>\r
+            <xs:attribute ref="xml:lang"/>\r
+            <xs:attribute name="id" type="xs:anyURI"/>\r
+            <xs:attribute name="version"/>\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="windowed"/>\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:attribute name="required" type="widgets:data.boolean"/>\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>
index 4a47ced..73ad220 100644 (file)
@@ -1,3 +1,177 @@
+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
+
+ -- sy037.kim <sy037kim@soyoung-DeskTop>  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.
index c72a8b2..ce2fd36 100755 (executable)
@@ -6,7 +6,7 @@ chmod +s /usr/bin/wrt-installer
 ln -sf /usr/bin/wrt-installer /usr/etc/package-manager/backend/wgt
 
 #for recovery
-mkdir -p /opt/apps/widget/temp_info
+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
 
index 3732590..66c5515 100755 (executable)
 #
 
 _working_dir="/opt/media/Downloads/.preinstallWidgets"
-_widget_temp="/opt/apps/widget/*";
+_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"
-               wrt-installer -i $list 
+               return_string=`wrt-installer -i $list`
+        if [ `expr match "$return_string" 'installed'` -gt 0 ]; then
+            echo "$list widget installation success"
+            rm -rf $list
+        else
+            echo "$list widget installaiton failed"
+            install_failed=1
+        fi
        done
 
-       rm -rf $_working_dir
+    if [ $install_failed -ne 1 ];then
+        echo "preinstall success"
+        rm -rf $_working_dir
+    fi
 }
 
 restore_widget() {
@@ -38,7 +49,7 @@ done
 
 
 #Reinstall widget during booting
-_temp_widget_path=/opt/apps/widget/temp_info
+_temp_widget_path=/opt/share/widget/temp_info
 
 FILE_LIST=`ls $_temp_widget_path`
 
index 653c2de..ee86ba1 100644 (file)
@@ -1,7 +1,7 @@
-#sbs-git:slp/pkgs/w/wrt-installer wrt-installer 0.0.54
+#sbs-git:slp/pkgs/w/wrt-installer wrt-installer 0.0.69
 Name:       wrt-installer
 Summary:    Installer for tizen Webruntime
-Version:    0.0.54
+Version:    0.0.69
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
@@ -12,16 +12,14 @@ BuildRequires:  edje-tools
 BuildRequires:  pkgconfig(libxml-2.0)
 BuildRequires:  pkgconfig(openssl)
 BuildRequires:  pkgconfig(dpl-efl)
-BuildRequires:  pkgconfig(vcore)
+BuildRequires:  pkgconfig(cert-svc-vcore)
 BuildRequires:  pkgconfig(dpl-event-efl)
 BuildRequires:  pkgconfig(dpl-utils-efl)
-BuildRequires:  pkgconfig(dpl-popup-efl)
 BuildRequires:  pkgconfig(dpl-wrt-dao-ro)
 BuildRequires:  pkgconfig(dpl-wrt-dao-rw)
 BuildRequires:  pkgconfig(ecore-x)
-BuildRequires:  pkgconfig(ace)
-BuildRequires:  pkgconfig(ace-dao-ro)
-BuildRequires:  pkgconfig(ace-dao-rw)
+BuildRequires:  pkgconfig(security)
+BuildRequires:  pkgconfig(security-install)
 BuildRequires:  pkgconfig(xmlsec1)
 BuildRequires:  pkgconfig(libidn)
 BuildRequires:  pkgconfig(libiri)
@@ -36,6 +34,8 @@ BuildRequires:  pkgconfig(wrt-plugins-types)
 BuildRequires:  pkgconfig(tapi)
 BuildRequires:  pkgconfig(shortcut)
 BuildRequires:  pkgconfig(dpl-encryption)
+BuildRequires:  pkgconfig(capi-appfw-app-manager)
+Requires: xmlsec1
 
 %description
 Description: Wrt Installer for Tizen apps and Wac apps
@@ -49,12 +49,15 @@ LDFLAGS="$LDFLAGS"
 
 cmake . -DCMAKE_INSTALL_PREFIX=/usr \
         -DDPL_LOG=ON \
+        -DLB_SUPPORT=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
 
 %clean
@@ -67,14 +70,16 @@ chmod +s /usr/bin/wrt-installer
 ln -sf /usr/bin/wrt-installer /usr/etc/package-manager/backend/wgt
 
 #for booting recovery
-mkdir -p /opt/apps/widget/temp_info
+mkdir -p /opt/share/widget/temp_info
 [ -h /etc/rc.d/rc3.d/S46lwrt_preinstall_widgets.sh ] && rm /etc/rc.d/rc3.d/S46lwrt_preinstall_widgets.sh
 [ -h /etc/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh ] && rm /etc/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh
 ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc3.d/S46lwrt_preinstall_widgets.sh
 ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh
 
 %files
+%manifest wrt-installer.manifest
 %attr(755,root,root) %{_bindir}/wrt-installer
 %attr(775,root,root) %{_initrddir}/wrt_preinstall_widgets.sh
 %attr(644,root,root) %{_datadir}/edje/wrt/*
 /usr/etc/package-manager/backendlib/libwgt.so
+%{_datadir}/license/%{name}
index 559fa55..0f235dd 100755 (executable)
@@ -20,6 +20,8 @@
 
 SET(TARGET_INSTALLER "wrt-installer")
 
+OPTION(LB_SUPPORT "lb support" OFF)
+
 SET(INSTALLER_SRC_DIR
     ${PROJECT_SOURCE_DIR}/src
     )
@@ -62,7 +64,7 @@ SET(INSTALLER_SOURCES
     ${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/task_file_manipulation.cpp
     ${INSTALLER_JOBS}/widget_install/task_smack.cpp
     ${INSTALLER_JOBS}/widget_install/task_ace_check.cpp
@@ -73,9 +75,10 @@ SET(INSTALLER_SOURCES
     ${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_new_db_insert.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
@@ -85,6 +88,7 @@ SET(INSTALLER_SOURCES
     ${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/wac_widget_id.cpp
@@ -94,6 +98,14 @@ SET(INSTALLER_SOURCES
     ${INSTALLER_SRC_DIR}/pkg-manager/pkgmgr_signal.cpp
     )
 
+IF(LB_SUPPORT)
+    SET(INSTALLER_SOURCES
+        ${INSTALLER_SOURCES}
+        ${INSTALLER_JOBS}/widget_install/task_livebox_conf.cpp)
+    MESSAGE(STATUS "adding definition -DLB_SUPPORT")
+    ADD_DEFINITIONS("-DLB_SUPPORT")
+ENDIF(LB_SUPPORT)
+
 MESSAGE(STATUS "add -DSEP_INSTALLER")
 ADD_DEFINITIONS("-DSEP_INSTALLER")
 
@@ -102,14 +114,14 @@ PKG_CHECK_MODULES(INSTALLER_STATIC_DEP
     libxml-2.0
     openssl
     dpl-efl
-    vcore
-    wrt-security
+    cert-svc-vcore
+    security-core
     dpl-event-efl
     dpl-utils-efl
     dpl-wrt-dao-ro
     dpl-wrt-dao-rw
     dpl-encryption
-    ace-install
+    security-install
     ecore-x
     xmlsec1
     libidn
@@ -122,6 +134,7 @@ PKG_CHECK_MODULES(INSTALLER_STATIC_DEP
     pkgmgr-parser
     tapi
     shortcut
+    capi-appfw-app-manager
     REQUIRED
     )
 
index dc843b6..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>
@@ -58,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 4d4262e..a61e14b 100755 (executable)
@@ -139,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:
@@ -212,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:
@@ -324,7 +324,7 @@ class AccessParser : public ElementParser
     ElementParserPtr Other()
     {
         return ElementParserPtr(new InnerElementsParser(
-                                    ElementParserPtr(SharedFromThis())));
+                                    ElementParserPtr(shared_from_this())));
     }
 
   private:
@@ -353,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)
@@ -466,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:
@@ -541,7 +541,7 @@ class LicenseParser : public ElementParser
     ElementParserPtr Other()
     {
         return ElementParserPtr(new InnerElementsParser(
-                                    ElementParserPtr(SharedFromThis())));
+                                    ElementParserPtr(shared_from_this())));
     }
 
   private:
@@ -1052,8 +1052,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) :
@@ -1233,7 +1231,7 @@ class ApplicationParser : public ElementParser
 
     virtual void Accept(const Element& element)
     {
-        if (element.ns == 
+        if (element.ns ==
             ConfigurationNamespace::TizenWebAppNamespaceName)
         {
             m_properNamespace = true;
@@ -1339,6 +1337,52 @@ class SplashParser : public ElementParser
     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;
+};
+
 ElementParser::ActionFunc WidgetParser::GetElementParser(const DPL::String& /*ns*/,
         const DPL::String& name)
 {
@@ -1375,6 +1419,7 @@ WidgetParser::WidgetParser(ConfigParserData& data) :
     m_map[L"appservice"] = DPL::MakeDelegate(this, &WidgetParser::OnServiceElement);
     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);
 }
 
 ElementParserPtr WidgetParser::OnNameElement()
@@ -1452,6 +1497,11 @@ ElementParserPtr WidgetParser::OnSplashElement()
     return ElementParserPtr(new SplashParser(m_data));
 }
 
+ElementParserPtr WidgetParser::OnBackgroundElement()
+{
+    return ElementParserPtr(new BackgroundParser(m_data));
+}
+
 void WidgetParser::Accept(const Element& element)
 {
     if (element.ns != ConfigurationNamespace::W3CWidgetNamespaceName &&
@@ -1476,6 +1526,8 @@ 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;
index aeaab35..6ea2ffb 100755 (executable)
@@ -79,6 +79,7 @@ class WidgetParser : public ElementParser
     ElementParserPtr OnServiceElement();
     ElementParserPtr OnApplicationElement();
     ElementParserPtr OnSplashElement();
+    ElementParserPtr OnBackgroundElement();
 
     virtual ActionFunc GetElementParser(const DPL::String& ns,
             const DPL::String& name);
index c4cda28..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,6 +53,6 @@ class PluginObjects : public WrtDB::PluginObjectsDAO
     void addDependentObject(const std::string& value);
 };
 
-typedef DPL::SharedPtr<PluginObjects> PluginObjectsPtr;
+typedef std::shared_ptr<PluginObjects> PluginObjectsPtr;
 
 #endif
index 059a957..a1da7ac 100755 (executable)
  * @version 1.0
  * @brief   Implementation file for main installer task
  */
+#include <memory>
+
 #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/wrt-dao-ro/common_dao_types.h>
-#include <dpl/utils/file_utils.h>
 #include "root_parser.h"
 #include "widget_parser.h"
 #include "parser_runner.h"
@@ -38,7 +38,6 @@
 #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_recovery.h>
 #include <widget_install/task_install_ospsvc.h>
 #include <widget_install/task_update_files.h>
-#include <widget_install/task_new_db_insert.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>
+
+#ifdef LB_SUPPORT
+#include <widget_install/task_livebox_conf.h>
+#endif
+#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-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 <aul.h>
 #include <dpl/localization/w3c_file_localization.h>
 #include <libiriwrapper.h>
 #include <pkg-manager/pkgmgr_signal.h>
+#include <app_manager.h>
 
 using namespace WrtDB;
 
@@ -74,10 +80,9 @@ namespace // anonymous
 const char * const CONFIG_XML = "config.xml";
 const char * const WITH_OSP_XML = "res/wgt/config.xml";
 
-//allowed: a-z, A-Z, 0-9, '.', '-', '_', ' '
-const char* REG_TIZENID_PATTERN = "^[-. a-zA-Z0-9_@+=]*$";
-const int RESERVED_COUNT = 20;  //number of chars reserved in name (e.g. for '.desktop')
-const int MAX_TIZENID_LENTH = 255 - RESERVED_COUNT;
+//allowed: a-z, A-Z, 0-9
+const char* REG_TIZENID_PATTERN = "^[a-zA-Z0-9]{10}$";
+const int MAX_TIZENID_LENGTH = 10;
 
 static const DPL::String SETTING_VALUE_ENCRYPTION = L"encryption";
 static const DPL::String SETTING_VALUE_ENCRYPTION_ENABLE = L"enable";
@@ -145,7 +150,7 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
         LogInfo("Random widget handle: " << handle);
     } while (WidgetDAOReadOnly::isWidgetInstalled(handle));
 
-    m_installerContext.widgetHandle = handle;
+    m_installerContext.widgetHandle = handle;   //TODO: mvoe to wrt-commons (ace_widget_handle_t not int needed)
     m_installerContext.m_quiet = m_jobStruct.m_quiet;
 
     if(!browserRequest)
@@ -161,29 +166,12 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
     ConfigParserData configData = getWidgetDataFromXML(widgetPath, browserRequest,
             m_installerContext.widgetConfig.pType);
     WidgetUpdateInfo update = detectWidgetUpdate(configData);
-
     bool needEncryption = detectResourceEncryption(configData);
 
-
     // Configure installation
-    ConfigureResult result = ConfigureInstallation(widgetPath, update);
-    if (!setTizenId(configData)) {
-        result = ConfigureResult::Failed;
-    } else {
-        using namespace PackageManager;
-        LogInfo("WidgetHandle: " << m_installerContext.widgetHandle);
-        LogInfo("Tizen Id: " << m_installerContext.widgetConfig.pkgname);
-
-        configureWidgetLocation(widgetPath, browserRequest);
+    ConfigureResult result = ConfigureInstallation(widgetPath, configData,
+                                                   update, browserRequest);
 
-        // send start signal of pkgmgr
-        PkgmgrSignalSingleton::Instance().setPkgname(
-                    DPL::ToUTF8String(
-                        *m_installerContext.widgetConfig.pkgname));
-        PkgmgrSignalSingleton::Instance().sendSignal(
-                    PKGMGR_START_KEY,
-                    PKGMGR_START_INSTALL);
-    }
     if (result == ConfigureResult::Ok) {
         LogInfo("Configure installation succeeded");
 
@@ -201,7 +189,7 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
         if (needEncryption) {
             AddTask(new TaskEncryptResource(m_installerContext));
         }
-        AddTask(new TaskDbUpdate(m_installerContext));
+        AddTask(new TaskDatabase(m_installerContext)); //TODO: this should belast task (or almost)
         AddTask(new TaskFileManipulation(m_installerContext));
         // TODO: Update progress information for this task
 
@@ -213,10 +201,15 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
         AddTask(new TaskSmack(m_installerContext));
 
         AddTask(new TaskManifestFile(m_installerContext));
+        AddTask(new TaskCertificates(m_installerContext));
         if (m_installerContext.widgetConfig.pType ==
                 PKG_TYPE_TIZEN_WITHSVCAPP) {
             AddTask(new TaskInstallOspsvc(m_installerContext));
         }
+#ifdef LB_SUPPORT
+        AddTask(new TaskLiveboxConf(m_installerContext));
+#endif
+        AddTask(new TaskPluginsCopy(m_installerContext));
     } else if (result == ConfigureResult::Updated) {
         LogInfo("Configure installation updated");
         LogInfo("Widget Update");
@@ -231,7 +224,7 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
 
         AddTask(new TaskCertify(m_installerContext));
         AddTask(new TaskUpdateFiles(m_installerContext));
-        AddTask(new TaskNewDbInsert(m_installerContext));
+        AddTask(new TaskDatabase(m_installerContext)); //TODO: this should belast task (or almost)
 
         /* TODO : To backup file, save md5 values */
         AddTask(new TaskAceCheck(m_installerContext));
@@ -243,6 +236,10 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
                 PKG_TYPE_TIZEN_WITHSVCAPP) {
             AddTask(new TaskInstallOspsvc(m_installerContext));
         }
+#ifdef LB_SUPPORT
+        AddTask(new TaskLiveboxConf(m_installerContext));
+#endif
+        AddTask(new TaskPluginsCopy(m_installerContext));
     } else if (result == ConfigureResult::Deferred) {
         // Installation is deferred
         LogInfo("Configure installation deferred");
@@ -258,92 +255,69 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
     }
 }
 
+std::string JobWidgetInstall::generateTizenId() {
+    std::string allowed("0123456789"
+        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+        "abcdefghijklmnopqrstuvwxyz");
+    std::string tizenId;
+    tizenId.resize(MAX_TIZENID_LENGTH);
+    for (int i = 0; i < MAX_TIZENID_LENGTH; ++i) {
+        tizenId[i] = allowed[rand() % allowed.length()];
+    }
+    return tizenId;
+}
+
 bool JobWidgetInstall::setTizenId(
-        const WrtDB::ConfigParserData &configInfo)
+        const WrtDB::ConfigParserData &configInfo, ConfigureResult result)
 {
     Assert(!!m_installerContext.widgetHandle
            && "Widget Handle should be initialized");
 
     regex_t reg;
-    regcomp(&reg, REG_TIZENID_PATTERN, REG_NOSUB);
+    regcomp(&reg, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED);
     struct stat dirStat;
     if(!!configInfo.tizenId) {
-        LogDebug("Setting tizenId provided in config.xml");
+        LogDebug("Setting tizenId provided in config.xml: " << configInfo.tizenId);
         if ((regexec(&reg, DPL::ToUTF8String(*(configInfo.tizenId)).c_str(),
-             static_cast<size_t>(0), NULL, 0) != 0) ||
-            (DPL::ToUTF8String(*(configInfo.tizenId)).size() > MAX_TIZENID_LENTH) ||
+             static_cast<size_t>(0), NULL, 0) != REG_NOERROR) ||
             (stat((std::string(GlobalConfig::GetUserInstalledWidgetPath()) + "/"
                    + DPL::ToUTF8String(*(configInfo.tizenId))).c_str(), &dirStat) == 0))
         {
             //it is true when tizenId does not fit REG_TIZENID_PATTERN
-            LogError("pkgName provided but not proper.");
+            LogError("tizen_id provided but not proper.");
             regfree(&reg);
             return false;
         }
         m_installerContext.widgetConfig.pkgname = configInfo.tizenId;
 
     } else {
-        LogInfo("package name is generated by WRT");
-        // tizen id should be generated by secure random algorithm
-        std::string pkgName = WrtDB::GlobalConfig::GetPkgnamePrefix();
-
-        bool named = false;
-        FOREACH(it, configInfo.localizedDataSet)
-        {
-            if (!!((it->second).name)) {
-                //there is a name provided
-                std::string name =  DPL::ToUTF8String(*(it->second).name);
-                //cut very long widget's name
-                name = name.substr(0, MAX_TIZENID_LENTH - strlen(
-                    WrtDB::GlobalConfig::GetPkgnamePrefix()));
-                //check name if all characters are supported by filesystem
-                if (regexec(&reg, name.c_str(), static_cast<size_t>(0), NULL, 0)
-                    == 0)
-                {
-                    //WidgetName is ok and can be used as package name
-                    //replace all spaces with '_'
-                    size_t pos = 0;
-                    while((pos = name.find(" ", pos)) != std::string::npos) {
-                        name.replace(pos, 1, "_");
-                        ++pos;
-                    }
-                    pkgName += name;
-                    named = true;
+        std::string tizenId = generateTizenId();
+
+        // only for installation, not for update
+        if (result == ConfigureResult::Ok) {
+            //check if there is package with same name and if generate different name
+            std::string path = GlobalConfig::GetUserInstalledWidgetPath();
+            path += "/";
+
+            std::ostringstream newPath;
+            newPath << path << tizenId;
+
+            LogDebug("Checking if tizen id is unique");
+            while (true) {
+                if (stat(newPath.str().c_str(), &dirStat) == 0) {
+                    //path exist, chose another one
+                    tizenId = generateTizenId();
+                    newPath.str("");
+                    newPath << path << tizenId;
+                    continue;
                 }
                 break;
             }
-        }
 
-        if (!named) // there is no widget name provided, use widgetHandle
-        {
-            pkgName += std::to_string(*(m_installerContext.widgetHandle));
-        }
-
-        //check if there is package with same name and if generate different name
-        std::string path = GlobalConfig::GetUserInstalledWidgetPath();
-        path += "/";
-
-        std::ostringstream newPath;
-        newPath << path << pkgName;
-
-        std::string suffix;
-        for (int i = 0;; ++i) {
-            if (stat(newPath.str().c_str(), &dirStat) == 0) {
-                //path exist, chose another one, eg. widgetName1
-                suffix = std::to_string(i + 1);
-                pkgName = pkgName.substr(
-                        0, MAX_TIZENID_LENTH - suffix.size());
-                newPath.str("");
-                newPath << path << pkgName << suffix;
-                continue;
-            }
-            pkgName += suffix;
-            break;
+            m_installerContext.widgetConfig.pkgname =
+                DPL::FromUTF8String(tizenId);
         }
-
-        m_installerContext.widgetConfig.pkgname =
-            DPL::FromUTF8String(pkgName);
-
+        LogInfo("tizen_id name was generated by WRT: " << tizenId);
     }
     regfree(&reg);
 
@@ -357,25 +331,24 @@ DPL::Optional<WidgetHandle> JobWidgetInstall::getNewWidgetHandle() const
     return m_installerContext.widgetHandle;
 }
 
+DPL::OptionalString JobWidgetInstall::getNewTizenId() const
+{
+    return m_installerContext.widgetConfig.pkgname;
+}
+
 void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath, bool browserRequest)
 {
-    Try
-    {
-        m_installerContext.locations = WidgetLocation(DPL::ToUTF8String(*m_installerContext.widgetConfig.pkgname),
-                    widgetPath, browserRequest, m_installerContext.widgetConfig.pType);
-    }
-    Catch(FileUtils::CreateDirectoryException)
-    {
-        LogError("Failed to create temporary path for widget");
-        ReThrowMsg(FileUtils::CreateDirectoryException, "Failed to create temporary path for widget");
-    }
+    m_installerContext.locations = WidgetLocation(DPL::ToUTF8String(*m_installerContext.widgetConfig.pkgname),
+            widgetPath, browserRequest, m_installerContext.widgetConfig.pType);
 
     LogInfo("widgetSource " << widgetPath);
 }
 
 JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
         const std::string &widgetSource,
-        const WidgetUpdateInfo &update)
+        const WrtDB::ConfigParserData &configData,
+        const WidgetUpdateInfo &update,
+        bool browserRequest)
 {
     LogInfo(
         "Widget install/update: incoming guid = '" <<
@@ -386,6 +359,8 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
 
     // Check policy
     WidgetUpdateMode::Type updateTypeCheckBit;
+    bool isUpdate = false;
+    JobWidgetInstall::ConfigureResult ret = ConfigureResult::Ok;
 
     if (update.existingWidgetInfo.isExist == false) {
         LogInfo("Widget info does not exist");
@@ -403,7 +378,17 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
         }
 
         LogInfo("Widget model exists. package name: " << pkgname);
-        if (aul_app_is_running(DPL::ToUTF8String(*pkgname).c_str())) {
+
+        // 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;
+        }
+
+        if (true == isRunning) {
             // Must be deferred when update in progress
             if (m_jobStruct.updateMode == WidgetUpdateMode::PolicyWac) {
                 LogInfo(
@@ -426,12 +411,32 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
 
         updateTypeCheckBit = CalcWidgetUpdatePolicy(existingVersion,
                                                     incomingVersion);
+        // Calc proceed flag
+        if ((m_jobStruct.updateMode & updateTypeCheckBit) > 0) {
+            LogInfo("Whether widget policy allow proceed ok");
+            ret = ConfigureResult::Updated;
+        }
+        else
+            return ConfigureResult::Failed;
     }
 
-    // Calc proceed flag
-    bool canProceed = (m_jobStruct.updateMode & updateTypeCheckBit) > 0;
+    if (!setTizenId(configData, ret)) {
+        return ConfigureResult::Failed;
+    } else {
+        using namespace PackageManager;
+        LogInfo("WidgetHandle: " << m_installerContext.widgetHandle);
+        LogInfo("Tizen Id: " << m_installerContext.widgetConfig.pkgname);
+
+        configureWidgetLocation(widgetSource, browserRequest);
 
-    LogInfo("Whether widget policy allow proceed: " << canProceed);
+        // send start signal of pkgmgr
+        PkgmgrSignalSingleton::Instance().setPkgname(
+                    DPL::ToUTF8String(
+                        *m_installerContext.widgetConfig.pkgname));
+        PkgmgrSignalSingleton::Instance().sendSignal(
+                    PKGMGR_START_KEY,
+                    PKGMGR_START_INSTALL);
+    }
 
     // Init installer context
     m_installerContext.installStep = InstallerContext::INSTALL_START;
@@ -439,12 +444,8 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
     m_installerContext.existingWidgetInfo = update.existingWidgetInfo;
     m_installerContext.widgetConfig.shareHref = std::string();
 
-    if (m_installerContext.existingWidgetInfo.isExist) {
-        return canProceed ? ConfigureResult::Updated : ConfigureResult::Failed;
-    }
-
     // Return result
-    return canProceed ? ConfigureResult::Ok : ConfigureResult::Failed;
+    return ret;
 }
 
 WidgetUpdateMode::Type JobWidgetInstall::CalcWidgetUpdatePolicy(
@@ -499,21 +500,21 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
         }
         else {
             // Open zip file
-            DPL::ScopedPtr<DPL::ZipInput> zipFile(
+            std::unique_ptr<DPL::ZipInput> zipFile(
                 new DPL::ZipInput(widgetSource));
 
-            DPL::ScopedPtr<DPL::ZipInput::File> configFile;
+            std::unique_ptr<DPL::ZipInput::File> configFile;
 
             // Open config.xml file
             if (isOspsvc == PKG_TYPE_TIZEN_WITHSVCAPP) {
-                configFile.Reset(zipFile->OpenFile(WITH_OSP_XML));
+                configFile.reset(zipFile->OpenFile(WITH_OSP_XML));
             } else {
-                configFile.Reset(zipFile->OpenFile(CONFIG_XML));
+                configFile.reset(zipFile->OpenFile(CONFIG_XML));
             }
 
             // Extract config
             DPL::BinaryQueue buffer;
-            DPL::AbstractWaitableInputAdapter inputAdapter(configFile.Get());
+            DPL::AbstractWaitableInputAdapter inputAdapter(configFile.get());
             DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
             DPL::Copy(&inputAdapter, &outputAdapter);
             parser.Parse(&buffer,
@@ -624,7 +625,7 @@ void JobWidgetInstall::SendFinishedSuccess()
     //inform widget info
     JobWidgetInstall::displayWidgetInfo();
 
-    DPL::Optional<WidgetHandle> handle = getNewWidgetHandle();
+    DPL::OptionalString tizenId = getNewTizenId();
 
     // send signal of pkgmgr
     PkgmgrSignalSingleton::Instance().sendSignal(
@@ -633,7 +634,7 @@ void JobWidgetInstall::SendFinishedSuccess()
 
     LogDebug("Call widget install successfinishedCallback");
     getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
-            !!handle ? *handle : WrtDB::INVALID_WIDGET_HANDLE, Exceptions::Success);
+            tizenId.IsNull() ? "" : DPL::ToUTF8String(*tizenId), Exceptions::Success);
 }
 
 void JobWidgetInstall::SendFinishedFailure()
@@ -644,7 +645,7 @@ void JobWidgetInstall::SendFinishedFailure()
 
     LogError("Error in installation step: " << m_exceptionCaught);
     LogError("Message: " << m_exceptionMessage);
-    DPL::Optional<WidgetHandle> handle = getNewWidgetHandle();
+    DPL::OptionalString tizenId = getNewTizenId();
 
     LogDebug("Call widget install failure finishedCallback");
 
@@ -654,7 +655,7 @@ void JobWidgetInstall::SendFinishedFailure()
                 PKGMGR_END_FAILURE);
 
     getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
-            !!handle ? *handle : WrtDB::INVALID_WIDGET_HANDLE, m_exceptionCaught);
+            tizenId.IsNull() ? "" : DPL::ToUTF8String(*tizenId), m_exceptionCaught);
 }
 
 void JobWidgetInstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
@@ -737,12 +738,12 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType(
     using namespace WrtDB;
 
     PackagingType pType = PKG_TYPE_UNKNOWN;
-    DPL::ScopedPtr<DPL::ZipInput> zipFile;
+    std::unique_ptr<DPL::ZipInput> zipFile;
 
     Try
     {
         // Open zip file
-        zipFile.Reset(new DPL::ZipInput(widgetSource));
+        zipFile.reset(new DPL::ZipInput(widgetSource));
 
     }
     Catch(DPL::ZipInput::Exception::OpenFailed)
@@ -754,7 +755,7 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType(
     Try
     {
         // Open config.xml file in package root
-        DPL::ScopedPtr<DPL::ZipInput::File> configFile(
+        std::unique_ptr<DPL::ZipInput::File> configFile(
                 zipFile->OpenFile(CONFIG_XML));
         pType = PKG_TYPE_TIZEN_WEBAPP;
     }
@@ -766,7 +767,7 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType(
     Try
     {
         // Open config.xml file in package root
-        DPL::ScopedPtr<DPL::ZipInput::File> configFile(
+        std::unique_ptr<DPL::ZipInput::File> configFile(
                 zipFile->OpenFile(WITH_OSP_XML));
         if (pType == PKG_TYPE_TIZEN_WEBAPP) {
             return PKG_TYPE_UNKNOWN;
index 6230d17..0cc096d 100644 (file)
@@ -57,7 +57,10 @@ class JobWidgetInstall :
     };
 
     ConfigureResult ConfigureInstallation(const std::string &widgetSource,
-                                          const WidgetUpdateInfo &update);
+                                          const WrtDB::ConfigParserData
+                                          &configData,
+                                          const WidgetUpdateInfo &update,
+                                          bool browserRequest);
     static WrtDB::ConfigParserData getWidgetDataFromXML(
             const std::string &widgetSource,
             bool fromBrowser, WrtDB::PkgType isOspsvc);
@@ -66,13 +69,15 @@ class JobWidgetInstall :
     WidgetUpdateMode::Type CalcWidgetUpdatePolicy(
             const OptionalWidgetVersion &existingVersion,
             const OptionalWidgetVersion &incomingVersion) const;
-    bool setTizenId(const WrtDB::ConfigParserData &configInfo);
+    bool setTizenId(const WrtDB::ConfigParserData &configInfo,
+                    ConfigureResult result);
     void displayWidgetInfo();
     void configureWidgetLocation(const std::string & widgetPath, bool browserRequest);
 
     WrtDB::PackagingType checkPackageType(
             const std::string &widgetSorce);
     bool detectResourceEncryption(const WrtDB::ConfigParserData &configData);
+    std::string generateTizenId();
 
   public:
     /**
@@ -82,6 +87,7 @@ class JobWidgetInstall :
             const WidgetInstallationStruct &installerStruct);
 
     DPL::Optional<WidgetHandle> getNewWidgetHandle() const;
+    DPL::OptionalString getNewTizenId() const;
 
     //overrides
     void SendProgress();
index 192247f..6f45eaa 100644 (file)
@@ -126,7 +126,7 @@ void TaskAceCheck::StepProcessAceResponse()
             list.items[i].smack_granted =
                     devCapsSmack[i] ? ACE_TRUE : ACE_FALSE;
         }
-        ace_return_t ret = ace_set_requested_dev_caps(*(m_context.widgetHandle),
+        ace_return_t ret = ace_set_requested_dev_caps(*(m_context.widgetHandle),  //TODO: (ace_widget_handle_t not int needed)
                                                       &list);
         if (ACE_OK != ret) {
             ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
@@ -134,20 +134,23 @@ void TaskAceCheck::StepProcessAceResponse()
         }
         delete [] list.items;
 
-        std::vector<std::string> acceptedFeature;
+        std::set<std::string> acceptedFeature;
         auto it = m_context.featureLogic->resultBegin();
         for (;it != m_context.featureLogic->resultEnd(); ++it) {
             if (!(it->rejected)) {
-                acceptedFeature.push_back(DPL::ToUTF8String(it->name));
+                acceptedFeature.insert(DPL::ToUTF8String(it->name));
             }
         }
         ace_feature_list_t featureList;
         featureList.count = acceptedFeature.size();
         featureList.items = new ace_string_t[featureList.count];
 
-        for (size_t i=0; i<acceptedFeature.size(); ++i) {
-            featureList.items[i] =
-                const_cast<char *>(acceptedFeature[i].c_str());
+        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(
diff --git a/src/jobs/widget_install/task_certificates.cpp b/src/jobs/widget_install/task_certificates.cpp
new file mode 100755 (executable)
index 0000000..7285b50
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * 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");
+    SetCertiInfo(SIGNATURE_AUTHOR);
+    SetCertiInfo(SIGNATURE_DISTRIBUTOR);
+}
+
+void TaskCertificates::SetCertiInfo(CertificateSource source)
+{
+    LogDebug("Set CertiInfo to pkgmgr : " << source);
+    CertificateChainList certificateChainList;
+    m_context.wacSecurity.getCertificateChainList(certificateChainList, source);
+
+    pkgmgr_instcertinfo_h handle;
+
+    FOREACH(it, certificateChainList)
+    {
+        LogDebug("Insert certinfo to pkgmgr db");
+
+        ValidationCore::CertificateCollection chain;
+        if (false == chain.load(*it)) {
+            LogError("Chain is broken");
+        }
+
+        chain.sort();
+
+        ValidationCore::CertificateList list = chain.getCertificateList();
+
+        FOREACH(certIt, list) 
+        {
+            ValidationCore::Crypto::Hash::SHA1 sha1;
+            sha1.Append((*certIt)->getDER());
+            sha1.Finish();
+            std::string sha1String = sha1.ToBase64String();
+
+            if (pkgmgr_installer_create_certinfo_set_handle(&handle)< 0) {
+                LogError("pkgmgrInstallerCreateCertinfoSetHandle fail");
+                ThrowMsg(Exceptions::SetCertificateInfoFailed,
+                        "Failed to create certificate handle");
+            }
+
+            if (source == SIGNATURE_DISTRIBUTOR) {
+                if((pkgmgr_installer_set_cert_value(
+                                handle,
+                                PM_SET_DISTRIBUTOR_SIGNER_CERT,
+                                const_cast<char*>(sha1String.c_str()))) < 0) {
+                    LogError("pkgmgrInstallerSetCertValue fail");
+                    ThrowMsg(Exceptions::SetCertificateInfoFailed,
+                            "Failed to Set CertValue");
+                }
+            }
+            else {
+                if((pkgmgr_installer_set_cert_value(
+                                handle,
+                                PM_SET_AUTHOR_SIGNER_CERT,
+                                const_cast<char*>(sha1String.c_str()))) < 0) {
+                    LogError("pkgmgrInstallerSetCertValue fail");
+                    ThrowMsg(Exceptions::SetCertificateInfoFailed,
+                            "Failed to Installer Set CertValue");
+                }
+            }
+
+            if ((pkgmgr_installer_save_certinfo(
+                            const_cast<char*>(DPL::ToUTF8String(
+                                    *m_context.widgetConfig.pkgname).c_str()),
+                            handle)) < 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(handle) < 0) {
+                LogError("pkgmgrInstallerDestroyCertinfoSetHandle fail");
+            }
+        }
+    }
+}
+
+void TaskCertificates::StepAbortCertiInfo()
+{
+    pkgmgr_instcertinfo_h handle;
+
+    if ((pkgmgr_installer_delete_certinfo(
+            const_cast<char*>(DPL::ToUTF8String(
+                *m_context.widgetConfig.pkgname).c_str()))) < 0) {
+        LogError("pkgmgr_installer_delete_certinfo fail");
+    }
+}
+}
+}
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..5193929
--- /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    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);
+
+  public:
+    TaskCertificates(InstallerContext& context);
+};
+} //namespace WidgetInstall
+} //namespace Jobs
+
+#endif /* INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_CERTIFICATES_H */
index 2cf7c94..a958288 100755 (executable)
@@ -107,7 +107,7 @@ TaskCertify::TaskCertify(InstallerContext &inCont) :
     */
 
     // Block until fixed popup issues
-    if (!GlobalSettings::TestModeEnabled()
+    if (!GlobalSettings::PopupsTestModeEnabled()
             && !m_installContext.m_quiet && !isTizenWebApp()) {
         AddStep(&TaskCertify::stepWarningPopup);
         AddStep(&TaskCertify::stepWarningPopupAnswer);
@@ -166,6 +166,16 @@ void TaskCertify::processAuthorSignature(const SignatureData &data)
     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)) {
             m_contextData.wacSecurity.setRecognized(true);
@@ -205,8 +215,9 @@ void TaskCertify::stepSignature()
             SignatureReader xml;
             xml.initialize(data, GlobalConfig::GetSignatureXmlSchema());
             xml.read(data);
-            SignatureValidator validator(!GlobalSettings::TestModeEnabled(),
-                                         !GlobalSettings::TestModeEnabled(),
+
+            SignatureValidator validator(!GlobalSettings::OCSPTestModeEnabled(),
+                                         !GlobalSettings::CrlTestModeEnabled(),
                                          complianceMode);
             SignatureValidator::Result result =
                 validator.check(data, widgetPath);
index a818496..e6ca9ac 100755 (executable)
@@ -28,7 +28,6 @@
 
 //WRT INCLUDES
 #include <dpl/task.h>
-#include <dpl/popup/popup_controller.h>
 #include <widget_install/widget_install_popup.h>
 
 class InstallerContext;
index b64e61b..10c73e8 100644 (file)
@@ -29,7 +29,8 @@
 #include <dpl/log/log.h>
 #include <dpl/exception.h>
 #include <dpl/errno_string.h>
-#include <dpl/utils/file_utils.h>
+#include <dpl/utils/wrt_utility.h>
+#include <widget_install/widget_install_errors.h>
 
 namespace Jobs {
 namespace WidgetInstall {
@@ -39,39 +40,8 @@ namespace {
 const char * const TEMPORARY_PATH_POSTFIX = "temp";
 const mode_t TEMPORARY_PATH_MODE = 0775;
 
-int lambdaDeleteFile(const char *fpath,
-                     const struct stat* /*sb*/,
-                     int tflag,
-                     struct FTW* /*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
 
-void removeTemporaryDir(const std::string& dir)
-{
-    LogError("[GenerateConfig Task] Aborting... (removing temporary dir: " <<
-             dir << " )");
-
-    static const int maxDepth = 1024;
-    struct stat fileInfo;
-    if (stat(dir.c_str(), &fileInfo) == 0) {
-        nftw(dir.c_str(), lambdaDeleteFile, maxDepth, FTW_DEPTH);
-    }
-}
 
 std::string createTempPath()
 {
@@ -82,8 +52,6 @@ std::string createTempPath()
 
    tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
    tempPathBuilder << "/";
-   tempPathBuilder << "widget";
-   tempPathBuilder << "/";
    tempPathBuilder << TEMPORARY_PATH_POSTFIX;
    tempPathBuilder << "_";
 
@@ -98,26 +66,25 @@ std::string createTempPath()
    // 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());
+       if(!WrtUtilRemove(tempPath)){
+           ThrowMsg(Exceptions::RemovingFolderFailure,
+                    "Failed to to remove temporary directory");
        }
    }
    // Create new path
-   FileUtils::MakePath(tempPath, TEMPORARY_PATH_MODE);
+   if(!WrtUtilMakeDir(tempPath, TEMPORARY_PATH_MODE)){
+       ThrowMsg(Exceptions::InternalError, "Failed to create temporary directory");
+   }
 
    return tempPath;
 }
 
 void createTempPath(const std::string& path)
 {
-    FileUtils::MakePath(path, TEMPORARY_PATH_MODE);
+   if(!WrtUtilMakeDir(path, TEMPORARY_PATH_MODE)){
+       ThrowMsg(Exceptions::InternalError, "Failed to create temporary directory");
+   }
 }
 
 } // WidgetInstall
index 940c710..dbb41eb 100644 (file)
@@ -29,8 +29,6 @@ namespace WidgetInstall {
 
 //TODO make directory like jobs common?
 
-void removeTemporaryDir(const std::string& path);
-
 std::string createTempPath();
 
 void createTempPath(const std::string& path);
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..6117b4e
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * 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-ro/config_parser_data.h>
+#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <dpl/foreach.h>
+#include <dpl/log/log.h>
+#include <dpl/assert.h>
+//#include <dpl/wrt-dao-ro/global_config.h>
+#include <string>
+#include <sstream>
+
+using namespace WrtDB;
+
+namespace Jobs {
+namespace WidgetInstall {
+TaskDatabase::TaskDatabase(InstallerContext& context) :
+    DPL::TaskDecl<TaskDatabase>(this),
+    m_context(context)
+{
+    AddStep(&TaskDatabase::StepDBInsert);
+
+    AddAbortStep(&TaskDatabase::StepAbortDBInsert);
+}
+
+void TaskDatabase::StepDBInsert()
+{
+    Try
+    {
+        /* Set install Time */
+        time(&m_context.widgetConfig.installedTime);
+
+        LogInfo("Registering widget...");
+
+        WidgetDAO::registerWidget(
+                *(m_context.widgetHandle),
+                m_context.widgetConfig,
+                m_context.wacSecurity);
+
+        FOREACH (cap, m_context.staticPermittedDevCaps) {
+            LogInfo("staticPermittedDevCaps : " << cap->first
+                    << " smack status: " << cap->second);
+        }
+
+        Assert(!!m_context.widgetConfig.pkgname
+               && "pkgName should be initialized");
+
+        WrtDB::WidgetDAO widgetDao(*m_context.widgetHandle);
+        widgetDao.setPkgName(m_context.widgetConfig.pkgname);
+
+        LogInfo("Widget registered");
+    }
+    Catch(WidgetDAO::Exception::DatabaseError)
+    {
+        LogWarning("Database failure!");
+        ReThrowMsg(Exceptions::InsertNewWidgetFailed, "Database failure!");
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base)
+    {
+        LogDebug("Database failure!");
+        ReThrowMsg(Exceptions::InsertNewWidgetFailed, "Database failure!");
+    }
+
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_NEW_DB_INSERT,
+        "New Widget DB UPDATE Finished");
+}
+
+void TaskDatabase::StepAbortDBInsert()
+{
+    LogWarning("[DB Update Task] Aborting... (DB Clean)");
+    Assert(!!m_context.widgetHandle);
+    Try
+    {
+        WidgetDAO::unregisterWidget(*m_context.widgetHandle); //TODO: unregister by pkgname (ace_widget_handle_t not int needed)
+
+        LogDebug("Cleaning DB successful!");
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base)
+    {
+        LogError("Failed to handle StepAbortDBClean!");
+    }
+}
+
+} //namespace WidgetInstall
+} //namespace Jobs
diff --git a/src/jobs/widget_install/task_database.h b/src/jobs/widget_install/task_database.h
new file mode 100644 (file)
index 0000000..c0ff0eb
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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>
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+class TaskDatabase:
+    public DPL::TaskDecl<TaskDatabase>
+{
+  private:
+    InstallerContext& m_context;
+
+    void StepDBInsert();
+
+    void StepAbortDBInsert();
+
+  public:
+    TaskDatabase(InstallerContext& context);
+};
+} //namespace WidgetInstall
+} //namespace Jobs
+
+#endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_DATABASE_H
index 1bf51a8..c240bc3 100644 (file)
@@ -40,6 +40,7 @@ TaskFileManipulation::TaskFileManipulation(InstallerContext& context) :
 {
     AddStep(&TaskFileManipulation::StepCreateDirs);
     AddStep(&TaskFileManipulation::StepRenamePath);
+    AddStep(&TaskFileManipulation::StepRegisterExternalFiles);
 
     AddAbortStep(&TaskFileManipulation::StepAbortRenamePath);
 }
@@ -57,7 +58,7 @@ void TaskFileManipulation::StepCreateDirs()
     std::string widgetBinPath = m_context.locations->getBinaryDir();
     std::string widgetSrcPath = m_context.locations->getSourceDir();
 
-    _WrtMakeDir(widgetPath.c_str(), 0755, WRT_FILEUTILS_RECUR);
+    WrtUtilMakeDir(widgetPath);
 
     // If package type is widget with osp service, we don't need to make bin
     // and src directory
@@ -65,8 +66,8 @@ void TaskFileManipulation::StepCreateDirs()
         LogDebug("Doesn't need to create resource directory");
     } else {
         LogDebug("Create resource directory");
-        _WrtMakeDir(widgetBinPath.c_str(), 0755, WRT_FILEUTILS_RECUR);
-        _WrtMakeDir(widgetSrcPath.c_str(), 0755, WRT_FILEUTILS_RECUR);
+        WrtUtilMakeDir(widgetBinPath);
+        WrtUtilMakeDir(widgetSrcPath);
     }
 
     m_context.job->UpdateProgress(
@@ -89,7 +90,7 @@ void TaskFileManipulation::StepRenamePath()
     }
 
     LogDebug("Copy file from temp directory to " << instDir);
-    if (!_WrtUtilRemoveDir(instDir.c_str())) {
+    if (!WrtUtilRemove(instDir)) {
         ThrowMsg(Exceptions::RemovingFolderFailure,
                 "Error occurs during removing existing folder");
     }
@@ -104,10 +105,21 @@ void TaskFileManipulation::StepRenamePath()
         "Widget Rename path Finished");
 }
 
+void TaskFileManipulation::StepRegisterExternalFiles()
+{
+    LogDebug("Registering external files:");
+    WrtDB::ExternalLocationList externalPaths = m_context.locations->listExternalLocations();
+    FOREACH(path, externalPaths)
+    {
+        LogDebug("  -> " << *path);
+    }
+    WidgetDAO dao(m_context.locations->getPkgname());
+    dao.registerExternalLocations(externalPaths);
+}
+
 void TaskFileManipulation::StepAbortRenamePath()
 {
     LogDebug("[Rename Widget Path] Aborting.... (Rename path)");
-    Assert(!!m_context.widgetHandle);
     std::string widgetPath;
     if (m_context.widgetConfig.pType == PKG_TYPE_TIZEN_WITHSVCAPP) {
         widgetPath = m_context.locations->getPackageInstallationDir();
index 162dbbf..db567b7 100644 (file)
@@ -36,6 +36,7 @@ class TaskFileManipulation :
 
     void StepCreateDirs();
     void StepRenamePath();
+    void StepRegisterExternalFiles();
 
     void StepAbortRenamePath();
 
index 3d1b901..150f60f 100644 (file)
@@ -28,6 +28,7 @@
 #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>
@@ -54,7 +55,7 @@ void TaskInstallOspsvc::StepInstallOspService()
     LogInfo("Step: installation for osp service");
 
     std::ostringstream commStr;
-    commStr << OSP_INSTALL_STR << m_context.locations->getPackageInstallationDir();
+    commStr << OSP_INSTALL_STR << BashUtils::escape_arg(m_context.locations->getPackageInstallationDir());
     //commStr << " 2>&1";
     LogDebug("osp install command : " << commStr.str());
 
diff --git a/src/jobs/widget_install/task_livebox_conf.cpp b/src/jobs/widget_install/task_livebox_conf.cpp
new file mode 100644 (file)
index 0000000..0e99c2c
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * 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_livebox_conf.cpp
+ * @author  Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ * @brief   Livebox support task
+ */
+
+#include "task_livebox_conf.h"
+
+#include <dpl/log/log.h>
+#include <dpl/string.h>
+#include <dpl/utils/wrt_utility.h>
+#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <dpl/file_input.h>
+#include <dpl/file_output.h>
+#include <dpl/copy.h>
+#include <dpl/utils/wrt_utility.h>
+
+#include <widget_install_context.h>
+
+TaskLiveboxConf::TaskLiveboxConf(InstallerContext &inCont) :
+    DPL::TaskDecl<TaskLiveboxConf>(this),
+    m_context(inCont)
+{
+    AddStep(&TaskLiveboxConf::StepConfigureLivebox);
+}
+
+void TaskLiveboxConf::StepConfigureLivebox()
+{
+    const std::string confFile = getLiveboxConfiguration();
+    const std::string liveboxDir = std::string("/opt/live/")
+            + DPL::ToUTF8String(*m_context.widgetConfig.pkgname);
+    const std::string destination = liveboxDir + "/etc/";
+    const std::string targetFile = destination + getLiveboxConfigurationFile();
+
+    if(WrtUtilFileExists(confFile))
+    {
+        WrtUtilMakeDir(destination);
+
+        LogDebug("Registering widget's livebox directory under /opt/live/");
+        WrtDB::ExternalLocationList list;
+        list.push_back(liveboxDir);
+        WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
+        dao.registerExternalLocations(list);
+
+        LogInfo("Coping livebox configuration file: " << confFile << " -> " << targetFile);
+        DPL::FileInput input(confFile);
+        DPL::FileOutput output(targetFile);
+        DPL::Copy(&input, &output);
+    }
+    else
+    {
+        LogInfo("No livebox configuration file: " << confFile);
+    }
+}
+
+std::string TaskLiveboxConf::getLiveboxConfigurationDirectory() const
+{
+    return m_context.locations->getSourceDir() + "/livebox/";
+}
+
+std::string TaskLiveboxConf::getLiveboxConfigurationFile() const
+{
+    return DPL::ToUTF8String(*m_context.widgetConfig.pkgname) + ".conf";
+}
+
+std::string TaskLiveboxConf::getLiveboxConfiguration() const
+{
+    return getLiveboxConfigurationDirectory() + getLiveboxConfigurationFile();
+}
diff --git a/src/jobs/widget_install/task_livebox_conf.h b/src/jobs/widget_install/task_livebox_conf.h
new file mode 100644 (file)
index 0000000..26085a0
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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_livebox_conf.h
+ * @author  Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ * @brief   Livebox support task
+ */
+
+#ifndef WRT_INSTALLER_SRC_JOBS_WIDGET_INSTALL_TASK_LIVEBOX_CONF_H
+#define WRT_INSTALLER_SRC_JOBS_WIDGET_INSTALL_TASK_LIVEBOX_CONF_H
+
+//forward declaration
+class InstallerContext;
+
+#include <string>
+
+#include <dpl/task.h>
+
+class TaskLiveboxConf : public DPL::TaskDecl<TaskLiveboxConf>
+{
+public:
+    TaskLiveboxConf(InstallerContext &inCont);
+private:
+
+    void StepConfigureLivebox();
+
+    /**
+     * @brief getLiveboxConfiguration returns value of configuration path
+     *                                        pointing at .conf file
+     * @return path
+     */
+    std::string getLiveboxConfiguration() const;
+    /**
+     * @brief getLiveboxConfiguration returns value of configuration directory
+     * @return path
+     */
+    std::string getLiveboxConfigurationDirectory() const;
+    std::string getLiveboxConfigurationFile() const;
+
+    //context data
+    InstallerContext &m_context;
+};
+
+#endif // WRT_INSTALLER_SRC_JOBS_WIDGET_INSTALL_TASK_LIVEBOX_CONF_H
index facdef3..edd18f1 100644 (file)
@@ -46,6 +46,7 @@
 #include <map>
 #include <libxml_utils.h>
 #include <pkgmgr/pkgmgr_parser.h>
+#include <dpl/localization/LanguageTagsProvider.h>
 
 #define DEFAULT_ICON_NAME   "icon.png"
 
@@ -123,19 +124,11 @@ TaskManifestFile::~TaskManifestFile()
 
 void TaskManifestFile::stepCreateExecFile()
 {
-    //ln -s /usr/bin/wrt-client {widget-handle}
-
-    std::ostringstream real_path;
-    DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
-    if (pkgname.IsNull()) {
-        ThrowMsg(Exceptions::InternalError, "No Package name exists.");
-    }
-
-    real_path << m_context.locations->getBinaryDir() << "/" << m_context.widgetHandle;
+    std::string exec = m_context.locations->getExecFile();
     std::string clientExeStr = GlobalConfig::GetWrtClientExec();
 
-    LogInfo("link -s " << clientExeStr << " " << real_path.str());
-    symlink(clientExeStr.c_str(), real_path.str().c_str());
+    LogInfo("link -s " << clientExeStr << " " << exec);
+    symlink(clientExeStr.c_str(), exec.c_str());
 
     m_context.job->UpdateProgress(
         InstallerContext::INSTALL_CREATE_EXECFILE,
@@ -146,97 +139,91 @@ void TaskManifestFile::stepCopyIconFiles()
 {
     LogDebug("CopyIconFiles");
 
-    DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
-    if (pkgname.IsNull()) {
-        ThrowMsg(Exceptions::InternalError, "No Package name exists.");
-    }
-    Assert(!!m_context.widgetHandle);
+    //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
 
-    WidgetDAOReadOnly dao(*m_context.widgetHandle);
-    WidgetDAOReadOnly::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
-    WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
+    std::vector<Locale> generatedLocales;
 
-    FOREACH(it, locList)
+    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++)
     {
-        DPL::String i = it->widgetLocale;
-        DPL::OptionalString src;
-        FOREACH(icon, list)
+        FOREACH(locale, icon->availableLocales)
         {
-            if (icon->iconId == it->iconId) {
-                src = icon->iconSrc;
-            }
-        }
-        LogDebug("Icon for locale: " << i << "is : " << src);
+            DPL::String src = icon->src;
+            LogDebug("Icon for locale: " << *locale << "is : " << src);
 
-        std::ostringstream sourceFile;
-        std::ostringstream targetFile;
+            if(std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end())
+            {
+                LogDebug("Skipping - has that locale");
+                continue;
+            }
+            else
+            {
+                generatedLocales.push_back(*locale);
+            }
 
-        if (!!src) {
+            std::ostringstream sourceFile;
+            std::ostringstream targetFile;
 
             sourceFile << m_context.locations->getSourceDir() << "/";
 
-            if (!i.empty()) {
-                sourceFile << "locales/" << i << "/";
+            if (!locale->empty()) {
+                sourceFile << "locales/" << *locale << "/";
             }
 
-            sourceFile << *src;
+            sourceFile << src;
 
             targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
-            targetFile << getIconTargetFilename(i);
+            targetFile << getIconTargetFilename(*locale);
 
             if (m_context.locations->browserRequest())
             {
                 m_context.locations->setIconTargetFilenameForLocale(targetFile.str());
             }
 
-        } else {
-            //Use WRT default (not from the widget) only if widget default (not
-            // localized) doesn't exist.
-            if (i.empty()) {
-                LogError("Using Default Icon for widget");
-                sourceFile << GlobalConfig::GetUserWidgetDefaultIconFile();
-            } else {
-                continue;
-            }
-        }
+            LogDebug("Copying icon: " << sourceFile.str() <<
+                     " -> " << targetFile.str());
 
-        LogDebug("Copying icon: " << sourceFile.str() <<
-                 " -> " << targetFile.str());
+            icon_list.push_back(targetFile.str());
 
-        icon_list.push_back(targetFile.str());
-
-        Try
-        {
-            DPL::FileInput input(sourceFile.str());
-            DPL::FileOutput output(targetFile.str());
-            DPL::Copy(&input, &output);
-        }
+            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::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::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");
+            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");
+            }
         }
     }
 
@@ -310,6 +297,7 @@ void TaskManifestFile::stepAbortIconFiles()
 
 void TaskManifestFile::stepUpdateFinalize()
 {
+    commitManifest();
     LogDebug("Finished Update Desktopfile");
 }
 
@@ -328,7 +316,7 @@ DPL::String TaskManifestFile::getIconTargetFilename(
         DPL::OptionalString tag = getLangTag(languageTag); // translate en -> en_US etc
         if (tag.IsNull()) { tag = languageTag; }
         DPL::String locale =
-            LocalizationUtils::BCP47LanguageTagToLocale(*tag);
+            LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
 
        if(locale.empty()) {
             filename << L"." << languageTag;
@@ -343,6 +331,7 @@ DPL::String TaskManifestFile::getIconTargetFilename(
 
 void TaskManifestFile::stepFinalize()
 {
+    commitManifest();
     LogInfo("Finished ManifestFile step");
 }
 
@@ -352,7 +341,7 @@ void TaskManifestFile::saveLocalizedKey(std::ofstream &file,
         const DPL::String& languageTag)
 {
     DPL::String locale =
-        LocalizationUtils::BCP47LanguageTagToLocale(languageTag);
+            LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag);
 
     file << key;
     if (!locale.empty()) {
@@ -376,7 +365,7 @@ void TaskManifestFile::updateAilInfo()
     if (ai) {
         ail_package_destroy_appinfo(ai);
     }
-    
+
     if (AIL_ERROR_NO_DATA == ret) {
         if (ail_desktop_add(pkgname) < 0) {
             LogDebug("Failed to add ail desktop : " << pkgname);
@@ -396,12 +385,12 @@ void TaskManifestFile::backupIconFiles()
     b_icon_dir << backup_dir.str() << "icons";
 
     LogDebug("Create icon backup folder : " << b_icon_dir.str());
-    _WrtMakeDir(b_icon_dir.str().c_str(), 0755, WRT_FILEUTILS_RECUR);
+    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(),
@@ -453,7 +442,7 @@ void TaskManifestFile::getFileList(const char* path,
     struct dirent* d_ent;
     do {
         if ((d_ent = readdir(dir))) {
-            if(strcmp(d_ent->d_name, ".") == 0 || 
+            if(strcmp(d_ent->d_name, ".") == 0 ||
                     strcmp(d_ent->d_name, "..") == 0) {
                 continue;
             }
@@ -473,8 +462,6 @@ void TaskManifestFile::stepGenerateManifest()
     LibxmlSingleton::Instance().init();
 
     writeManifest(manifest_file);
-    validateManifest();
-    commitManifest();
 
     m_context.job->UpdateProgress(
         InstallerContext::INSTALL_CREATE_MANIFEST,
@@ -521,26 +508,6 @@ void TaskManifestFile::stepParseUpgradedManifest()
     LogDebug("Manifest parsed");
 }
 
-void TaskManifestFile::validateManifest()
-{
-    int code = pkgmgr_parser_check_manifest_validation(
-            DPL::ToUTF8String(manifest_name).c_str());
-
-    if(code != 0)
-    {
-        LogError("Manifest validation error");
-        //TODO: manifest files are not yet validating properly because of href
-        // attribute in author element (incompatible types in W3C spec. and
-        // manifest spec.)
-        //ThrowMsg(ManifestValidationError, "Validation returncode: " << code);
-    }
-
-    m_context.job->UpdateProgress(
-        InstallerContext::INSTALL_CREATE_MANIFEST,
-        "Widget Manifest Validation Finished");
-    LogDebug("Manifest validated");
-}
-
 void TaskManifestFile::commitManifest()
 {
     LogDebug("Commiting manifest file : " << manifest_file);
@@ -580,38 +547,37 @@ void TaskManifestFile::writeManifest(const DPL::String & path)
 
 void TaskManifestFile::setWidgetExecPath(UiApplication & uiApp)
 {
-    DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
-    if (pkgname.IsNull()) {
-        ThrowMsg(Exceptions::InternalError, "No Package name exists.");
-    }
-
-    std::ostringstream path;
-    path << m_context.locations->getBinaryDir() << "/" << *m_context.widgetHandle;
-    uiApp.setExec(DPL::FromASCIIString(path.str()));
+    uiApp.setExec(DPL::FromASCIIString(m_context.locations->getExecFile()));
 }
 
 void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp)
 {
-    Assert(!!m_context.widgetHandle);
-    WidgetDAOReadOnly dao(*m_context.widgetHandle);
-    LanguageTagsList languageTags(dao.getLanguageTags());
     bool defaultNameSaved = false;
 
+    DPL::OptionalString defaultLocale = m_context.widgetConfig.configInfo.defaultlocale;
+    std::pair<DPL::String, WrtDB::ConfigParserData::LocalizedData> defaultLocalizedData;
     //labels
-    FOREACH(i, languageTags)
+    FOREACH(localizedData, m_context.widgetConfig.configInfo.localizedDataSet)
     {
-        DPL::OptionalString tag = getLangTag(*i); // translate en -> en_US etc
+        Locale i = localizedData->first;
+        DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
         if (tag.IsNull())
         {
-            tag = *i;
+            tag = i;
         }
-        DPL::OptionalString name = dao.getLocalizedInfo(*i).name;
+        DPL::OptionalString name = localizedData->second.name;
         generateWidgetName(manifest, uiApp, tag, name, defaultNameSaved);
+
+        //store default locale localized data
+        if(!!defaultLocale && defaultLocale == i)
+        {
+            defaultLocalizedData = *localizedData;
+        }
     }
-    DPL::OptionalString defaultLocale = dao.getDefaultlocale();
+
     if (!!defaultLocale && !defaultNameSaved)
     {
-        DPL::OptionalString name = dao.getLocalizedInfo(*defaultLocale).name;
+        DPL::OptionalString name = defaultLocalizedData.second.name;
         generateWidgetName(manifest, uiApp, DPL::OptionalString::Null, name, defaultNameSaved);
     }
     //appid
@@ -643,7 +609,7 @@ void TaskManifestFile::generateWidgetName(Manifest & manifest, UiApplication &ui
         if (!!tag)
         {
             DPL::String locale =
-                LocalizationUtils::BCP47LanguageTagToLocale(*tag);
+                    LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
 
             if (!locale.empty()) {
                 uiApp.addLabel(LabelType(*name,*tag));
@@ -672,76 +638,65 @@ void TaskManifestFile::setWidgetIcons(UiApplication & uiApp)
 
     //TODO this file will need to be updated when user locale preferences
     //changes.
-    Assert(!!m_context.widgetHandle);
-    WidgetDAOReadOnly dao(*m_context.widgetHandle);
-
-    WidgetDAOReadOnly::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
-    WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
     bool defaultIconSaved = false;
 
-    FOREACH(it, locList)
-    {
-        DPL::String i = it->widgetLocale;
-        DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
-        if (tag.IsNull()) { tag = i; }
+    DPL::OptionalString defaultLocale = m_context.widgetConfig.configInfo.defaultlocale;
 
-        generateWidgetIcon(uiApp, tag, i, it->iconId, list, defaultIconSaved);
-    }
-    DPL::OptionalString defaultLocale = dao.getDefaultlocale();
-    if (!!defaultLocale && !defaultIconSaved)
+    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++)
     {
-        int iconId = -1;
-        FOREACH(it, locList)
+        FOREACH(locale, icon->availableLocales)
         {
-            if (it->widgetLocale == *defaultLocale)
+            if(std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end())
             {
-                iconId = it->iconId;
+                LogDebug("Skipping - has that locale - already in manifest");
+                continue;
             }
-        }
-        if (-1 != iconId)
-        {
-            generateWidgetIcon(uiApp, DPL::OptionalString::Null,
-                               DPL::String(),
-                               iconId,
-                               list,
-                               defaultIconSaved);
+            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, int iconId, const WrtDB::WidgetDAOReadOnly::WidgetIconList & list,
-        bool & defaultIconSaved)
+        const DPL::String& language, bool & defaultIconSaved)
 {
     DPL::String locale;
     if (!!tag)
     {
-        locale = LocalizationUtils::BCP47LanguageTagToLocale(*tag);
+        locale = LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
     }
     else
     {
         defaultIconSaved = true;
     }
 
-    DPL::OptionalString src;
-    FOREACH(icon, list)
+    DPL::String iconText;
+    iconText += getIconTargetFilename(language);
+
+    if(!locale.empty())
     {
-        if (icon->iconId == iconId) {
-            src = icon->iconSrc;
-        }
+        uiApp.addIcon(IconType(iconText, locale));
     }
-    if (!!src) {
-        DPL::String iconText;
-        iconText += getIconTargetFilename(language);
-
-        if(!locale.empty())
-        {
-            uiApp.addIcon(IconType(iconText,locale));
-        }
-        else
-        {
-            uiApp.addIcon(IconType(iconText));
-        }
+    else
+    {
+        uiApp.addIcon(IconType(iconText));
     }
 }
 
@@ -776,27 +731,24 @@ void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp)
 
 void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp)
 {
-    Assert(!!m_context.widgetHandle);
-    WidgetDAOReadOnly dao(*m_context.widgetHandle);
-    WidgetApplicationServiceList appServiceList;
-    dao.getAppServiceList(appServiceList);
+    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/appsvc/operation/pick|NULL|image;
+    // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
     FOREACH(it, appServiceList) {
         ApplicationService appService;
-        if (!it->operation.empty()) {
-            appService.addOperation(it->operation);
+        if (!it->m_operation.empty()) {
+            appService.addOperation(it->m_operation); //TODO: encapsulation?
         }
-        if (!it->scheme.empty()) {
-            appService.addUri(it->scheme);
+        if (!it->m_scheme.empty()) {
+            appService.addUri(it->m_scheme);
         }
-        if (!it->mime.empty()) {
-            appService.addMime(it->mime);
+        if (!it->m_mime.empty()) {
+            appService.addMime(it->m_mime);
         }
         uiApp.addApplicationService(appService);
     }
index 57c44f4..86edffe 100644 (file)
@@ -75,7 +75,7 @@ class TaskManifestFile :
     void stepAbortIconFiles();
 
     //private data
-    std::list<std::string> icon_list;
+    std::list<std::string> icon_list; //TODO: this should be registered as external files
     std::ostringstream backup_dir;
     xmlTextWriterPtr writer;
     DPL::String manifest_name;
@@ -85,7 +85,6 @@ class TaskManifestFile :
     void updateAilInfo();
 
     void writeManifest(const DPL::String & path);
-    void validateManifest();
     void commitManifest();
 
     void setWidgetExecPath(UiApplication & uiApp);
@@ -96,7 +95,7 @@ class TaskManifestFile :
     void setAppServiceInfo(UiApplication & uiApp);
 
     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, int iconId, const WrtDB::WidgetDAOReadOnly::WidgetIconList & list, bool & defaultIconSaved);
+    void generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag, const DPL::String& language, bool & defaultIconSaved);
 
     //for widget update
     void backupIconFiles();
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..7860797
--- /dev/null
@@ -0,0 +1,185 @@
+/*
+ * 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 <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) {
+            LogDebug("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 */
+                closedir(dir);
+                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);
+        }
+    }
+    closedir(dir);
+    /* 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 */
index 7b5cb85..8d9934f 100644 (file)
@@ -33,7 +33,7 @@
 #include <dpl/errno_string.h>
 
 #include <dpl/wrt-dao-ro/widget_config.h>
-#include <dpl/utils/file_utils.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>
@@ -71,7 +71,7 @@ void TaskPrivateStorage::StepCreateDirectory()
         ThrowMsg(Exceptions::InternalError, "No Package name exists.");
     }
 
-    if (access(widgetPath.str().c_str(), W_OK | X_OK) != 0) {
+    if (euidaccess(widgetPath.str().c_str(), W_OK | X_OK) != 0) {
         ThrowMsg(Exceptions::InternalError, DPL::GetErrnoString());
     }
 
@@ -79,8 +79,12 @@ void TaskPrivateStorage::StepCreateDirectory()
     storagePath << widgetPath.str().c_str()
                 << GlobalConfig::GetWidgetPrivateStoragePath();
 
-    if (access(storagePath.str().c_str(), F_OK) != 0) {
-        FileUtils::MakePath(storagePath.str(), PRIVATE_STORAGE_MODE);
+    if (euidaccess(storagePath.str().c_str(), F_OK) != 0) {
+        if(!WrtUtilMakeDir(storagePath.str(), PRIVATE_STORAGE_MODE)){
+            LogError("Failed to create directory for private storage");
+            ThrowMsg(Exceptions::InternalError,
+                    "Failed to create directory for private storage");
+        }
         // '5000' is default uid, gid for applications.
         // So installed applications should be launched as process of uid '5000'.
         // the process can access private directory 'data' of itself.
@@ -91,7 +95,7 @@ void TaskPrivateStorage::StepCreateDirectory()
             ThrowMsg(Exceptions::InternalError,
                  "Chown to invaild user");
         }
-    } else if (access(storagePath.str().c_str(), W_OK | R_OK | X_OK) == 0) {
+    } else if (euidaccess(storagePath.str().c_str(), W_OK | R_OK | X_OK) == 0) {
         LogInfo("Private storage already exists.");
         // Even if private directory already is created, private dircetory
         // should change owner.
index 6ff2218..1b922db 100644 (file)
@@ -34,7 +34,6 @@
 #include <dpl/foreach.h>
 
 #include <dpl/wrt-dao-ro/widget_config.h>
-#include <dpl/utils/file_utils.h>
 #include <dpl/utils/wrt_utility.h>
 #include <widget_install/job_widget_install.h>
 #include <widget_install/widget_install_context.h>
@@ -64,7 +63,10 @@ void TaskRecovery::StepCreateCheckFile()
     FILE *temp = fopen(infoPath.str().c_str(), "w+");
     if (temp != NULL) {
         fputs(m_context.locations->getWidgetSource().c_str(), temp);
-        fsync(temp->_fileno);
+        if (-1 == fsync(temp->_fileno)) {
+            fclose(temp);
+            ThrowMsg(Exceptions::InternalError, "Fail to fsync for recovery.");
+        }
         fclose(temp);
 
         m_context.installInfo = infoPath.str();
index 77e0f4d..0067c47 100644 (file)
@@ -75,7 +75,7 @@ void TaskRemoveBackupFiles::StepRemoveBackupFiles()
     std::ostringstream backupDir;
     backupDir << m_context.locations->getBackupDir();
 
-    if (_WrtUtilRemoveDir(backupDir.str().c_str())) {
+    if (WrtUtilRemove(backupDir.str())) {
         LogDebug("Success to remove backup files : " << backupDir.str());
     } else {
         LogDebug("Failed to remove backup directory : " << backupDir.str());
@@ -84,7 +84,7 @@ void TaskRemoveBackupFiles::StepRemoveBackupFiles()
     }
 
     std::string tmp = m_context.locations->getTemporaryPackageDir();
-    if (_WrtUtilRemoveDir(tmp.c_str())) {
+    if (WrtUtilRemove(tmp)) {
         LogDebug("Success to remove temp directory : " << tmp);
     } else {
         LogDebug("Failed to remove temp directory : " << tmp);
index c5f63d3..b19bc19 100644 (file)
@@ -101,7 +101,7 @@ void TaskUnzip::StepUnzipPrepare()
 
     Try
     {
-        m_zip.Reset(new DPL::ZipInput(m_installerContext.locations->getWidgetSource()));
+        m_zip.reset(new DPL::ZipInput(m_installerContext.locations->getWidgetSource()));
         LogInfo("Widget package comment: " << m_zip->GetGlobalComment());
 
         // Widget package must not be empty
@@ -160,11 +160,11 @@ void TaskUnzip::StepUnzipProgress()
         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)
         {
@@ -187,7 +187,7 @@ void TaskUnzip::StepUnzipProgress()
 void TaskUnzip::StepUnzipFinished()
 {
     // Unzip finished, close internal structures
-    m_zip.Reset();
+    m_zip.reset();
 
     // Done
     LogInfo("Unzip finished");
index 13ec3c8..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;
@@ -40,7 +41,7 @@ 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;
index 9e29493..b13ab39 100644 (file)
@@ -23,6 +23,7 @@
 #include <utility>
 #include <vector>
 #include <string>
+#include <algorithm>
 #include <sys/stat.h>
 #include <dirent.h>
 
@@ -30,6 +31,7 @@
 #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>
@@ -60,6 +62,7 @@ TaskUpdateFiles::TaskUpdateFiles(InstallerContext& context) :
     AddStep(&TaskUpdateFiles::StepCreateBackupFolder);
     AddStep(&TaskUpdateFiles::StepResourceFilesBackup);
     AddStep(&TaskUpdateFiles::StepExecFileBackup);
+    AddStep(&TaskUpdateFiles::StepUpdateExternalFiles);
 
     AddAbortStep(&TaskUpdateFiles::StepAbortCreateBackupFolder);
     AddAbortStep(&TaskUpdateFiles::StepAbortExecFileBackup);
@@ -71,17 +74,16 @@ void TaskUpdateFiles::StepCreateBackupFolder()
     LogDebug("StepCreateBackupFolder");
     std::ostringstream backDirPath;
 
-    backDirPath << m_context.locations->getBackupDir();
-    m_srcBuPath = backDirPath.str() + GlobalConfig::GetWidgetSrcPath();
-    LogDebug("backup resource directory path : " << m_srcBuPath);
-    if(!_WrtMakeDir(m_srcBuPath.c_str(), 0755, WRT_FILEUTILS_RECUR)) {
+    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.");
     }
 
-    m_binBuPath = backDirPath.str() + GlobalConfig::GetUserWidgetExecPath();
-    LogDebug("backup execution directory path : " << m_binBuPath);
-    if(!_WrtMakeDir(m_binBuPath.c_str(), 0755, WRT_FILEUTILS_RECUR)) {
+    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.");
     }
@@ -96,7 +98,7 @@ void TaskUpdateFiles::ReadDirList(std::string dirPath, ExistFileList &list,
 {
     DIR* pkgDir = opendir(dirPath.c_str());
     if (!pkgDir) {
-        LogDebug("Package directory doesn't exist");
+        LogError("Package directory " << dirPath << " doesn't exist");
         ThrowMsg(Exceptions::InternalError, "Error occurs during read \
                 directory");
     }
@@ -132,7 +134,7 @@ void TaskUpdateFiles::StepResourceFilesBackup()
     ExistFileList resList;
     ExistFileList tempList;
 
-    std::string pkgSrc = m_pkgPath + "/" + GlobalConfig::GetWidgetSrcPath();
+    std::string pkgSrc = m_context.locations->getSourceDir();
     ReadDirList(pkgSrc, resList, strlen(pkgSrc.c_str())+1);
 
 
@@ -146,7 +148,8 @@ void TaskUpdateFiles::StepResourceFilesBackup()
         std::string newFile = tempSrc + "/" +(*it);
 
         if (res != resList.end()) {
-            std::string backupFile = m_srcBuPath + "/"+ (*it);
+            std::string backupFile = m_context.locations->getBackupSourceDir() +
+                    "/"+ (*it);
 
             struct stat sInfo;
             if (stat(resFile.c_str(), &sInfo) != 0) {
@@ -156,7 +159,7 @@ void TaskUpdateFiles::StepResourceFilesBackup()
             if (S_ISDIR(sInfo.st_mode)) {
                 LogDebug(resFile << " is a directory. so create a folder : " <<
                         backupFile);
-                _WrtMakeDir(backupFile.c_str(), 0755, WRT_FILEUTILS_RECUR);
+                WrtUtilMakeDir(backupFile);
             } else {
                 if ((rename(resFile.c_str(), backupFile.c_str())) != 0) {
                     LogError("Failed to rename " << resFile << " to " << backupFile);
@@ -204,33 +207,25 @@ void TaskUpdateFiles::StepResourceFilesBackup()
 
 void TaskUpdateFiles::StepExecFileBackup()
 {
-    std::ostringstream source;
-    source << m_pkgPath << "/" << GlobalConfig::GetUserWidgetExecPath();
-    source << "/" << m_context.existingWidgetInfo.existingHandle;
+    std::string execFile = m_context.locations->getExecFile();
 
-    LogDebug(" source : " << source.str());
+    LogDebug(" source : " << execFile);
 
-    std::ostringstream tempSource;
-    tempSource << m_binBuPath << "/" <<
-        m_context.existingWidgetInfo.existingHandle;
-    LogDebug(" source : " << tempSource.str());
+    std::string tempSource= m_context.locations->getBackupExecFile();
+    LogDebug(" source : " << tempSource);
 
-    if ((rename(source.str().c_str(), tempSource.str().c_str())) != 0) {
-        LogError("Failed to rename " << source.str() << " to " <<
-                tempSource.str());
+    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 : " << source.str() << " to " << tempSource.str());
-
-    std::ostringstream newClient;
-    newClient << m_pkgPath << "/" << GlobalConfig::GetUserWidgetExecPath();
-    newClient << "/" << m_context.widgetHandle;
+    LogDebug("Backup : " << execFile << " to " << tempSource);
 
     std::string clientPath = GlobalConfig::GetWrtClientExec();
 
-    LogInfo("link -s " << clientPath << " " << newClient.str());
-    symlink(clientPath.c_str(), newClient.str().c_str());
+    LogInfo("link -s " << clientPath << " " << execFile);
+    symlink(clientPath.c_str(), execFile.c_str());
 
     m_context.job->UpdateProgress(
         InstallerContext::INSTALL_BACKUP_EXEC,
@@ -240,33 +235,34 @@ void TaskUpdateFiles::StepExecFileBackup()
 void TaskUpdateFiles::StepAbortResourceFilesBackup()
 {
     LogDebug("StepAbortCopyFiles");
-    std::string srcPath = m_pkgPath + "/" + GlobalConfig::GetWidgetSrcPath();
+    std::string srcPath = m_context.locations->getSourceDir();
+    std::string srcBuPath = m_context.locations->getBackupSourceDir();
 
-    LogDebug("Backup Folder " << m_srcBuPath << " to " << srcPath);
+    LogDebug("Backup Folder " << srcBuPath << " to " << srcPath);
 
-    if(!_WrtUtilRemoveDir(srcPath.c_str())) {
+    if(!WrtUtilRemove(srcPath)) {
         LogError("Failed to remove " << srcPath);
     }
 
-    if (rename(m_srcBuPath.c_str(), srcPath.c_str()) != 0) {
-        LogError("Failed to rename " << m_srcBuPath << " to " << 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_pkgPath + "/" +
-        GlobalConfig::GetUserWidgetExecPath();
+    std::string binPath = m_context.locations->getBinaryDir();
 
-    if(!_WrtUtilRemoveDir(binPath.c_str())) {
+    if(!WrtUtilRemove(binPath)) {
         LogError("Failed to remove " << binPath);
     }
 
-    if (rename(m_binBuPath.c_str(), binPath.c_str()) != 0) {
-        LogError("Failed to rename " << m_binBuPath << " to " << 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 " << m_binBuPath << "move to " << binPath);
+    LogDebug("Backup Folder " << binBuPath << "move to " << binPath);
 }
 
 void TaskUpdateFiles::StepAbortCreateBackupFolder()
@@ -276,9 +272,48 @@ void TaskUpdateFiles::StepAbortCreateBackupFolder()
     path << m_context.locations->getBackupDir();
     LogDebug("Remove backup directory : " << path.str());
 
-    if(!_WrtUtilRemoveDir(path.str().c_str())) {
+    if(!WrtUtilRemove(path.str())) {
         LogError("Failed to remove " << path);
     }
 }
+
+void TaskUpdateFiles::StepUpdateExternalFiles()
+{
+    WidgetDAO dao(m_context.locations->getPkgname());
+    WrtDB::ExternalLocationList externalLocationsUpdate = m_context.locations->listExternalLocations();
+    WrtDB::ExternalLocationList externalLocationsDB = dao.getWidgetExternalLocations();
+    LogDebug("Removing external files:");
+    FOREACH(file, externalLocationsDB)
+    {
+        if(std::find(externalLocationsUpdate.begin(), externalLocationsUpdate.end(), *file) == externalLocationsUpdate.end())
+        {
+            if(WrtUtilFileExists(*file))
+            {
+                LogDebug("  -> " << *file);
+                remove(file->c_str());
+            }
+            else if(WrtUtilDirExists(*file))
+            {
+                LogDebug("  -> " << *file);
+                if(!WrtUtilRemove(*file)){
+                    ThrowMsg(Exceptions::RemovingFolderFailure,
+                            "Failed to remove external directory");
+                }
+            }
+            else
+            {
+                LogWarning("  -> " << *file << "(no such a path)");
+            }
+        }
+    }
+    dao.unregisterAllExternalLocations();
+    LogDebug("Registering(update) external files:");
+    FOREACH(file, externalLocationsUpdate)
+    {
+        LogDebug("  -> " << *file);
+    }
+    dao.registerExternalLocations(externalLocationsUpdate);
+}
+
 } //namespace WidgetInstall
 } //namespace Jobs
index 61b0412..c9e9806 100644 (file)
@@ -44,6 +44,7 @@ class TaskUpdateFiles :
     void StepCreateBackupFolder();
     void StepResourceFilesBackup();
     void StepExecFileBackup();
+    void StepUpdateExternalFiles();
 
     void ReadDirList(std::string dirPath, ExistFileList &list, size_t subLen);
 
@@ -51,10 +52,6 @@ class TaskUpdateFiles :
     void StepAbortCreateBackupFolder();
     void StepAbortExecFileBackup();
 
-    std::string m_pkgPath;
-    std::string m_srcBuPath;
-    std::string m_binBuPath;
-
   public:
     TaskUpdateFiles(InstallerContext& context);
 };
index 0e22985..f7c9c9f 100755 (executable)
@@ -29,7 +29,6 @@
 #include <dpl/foreach.h>
 #include <dpl/localization/w3c_file_localization.h>
 #include <dpl/singleton_impl.h>
-#include <dpl/utils/file_utils.h>
 #include <dpl/utils/mime_type_utils.h>
 #include <dpl/utils/wrt_global_settings.h>
 #include <dpl/utils/wrt_utility.h>
@@ -56,9 +55,10 @@ const std::string WIDGET_NOT_COMPATIBLE = "This widget is "
 const std::string QUESTION = "Do you want to install it anyway?";
 
 const char *const DEFAULT_LANGUAGE = "default";
-const size_t MAX_WIDGET_PATH_SIZE = 1024;
 
 const char *const WRT_WIDGET_CONFIG_FILE_NAME = "config.xml";
+
+const std::string WINDGET_INSTALL_NETWORK_ACCESS = "network access";
 }
 
 
@@ -78,6 +78,7 @@ TaskWidgetConfig::TaskWidgetConfig(InstallerContext& installContext) :
     AddStep(&TaskWidgetConfig::StepProcessConfigurationFile);
     AddStep(&TaskWidgetConfig::ReadLocaleFolders);
     AddStep(&TaskWidgetConfig::ProcessLocalizedStartFiles);
+    AddStep(&TaskWidgetConfig::ProcessBackgroundPageFile);
     AddStep(&TaskWidgetConfig::ProcessLocalizedIcons);
     AddStep(&TaskWidgetConfig::StepVerifyFeatures);
 
@@ -214,7 +215,7 @@ void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path,
                     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;
@@ -282,6 +283,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;
@@ -325,7 +341,7 @@ void TaskWidgetConfig::ProcessIcon(const WrtDB::ConfigParserData::Icon& icon)
         DPL::String absolutePath = DPL::FromUTF8String(
                 m_installContext.locations->getConfigurationDir()) + L"/" + relativePath;
 
-        if (FileUtils::FileExists(absolutePath)) {
+        if (WrtUtilFileExists(DPL::ToUTF8String(absolutePath))) {
             DPL::String type = MimeTypeUtils::identifyFileMimeType(absolutePath);
 
             if (MimeTypeUtils::isMimeTypeSupportedForIcon(type)) {
@@ -469,6 +485,10 @@ 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(DPL::FromUTF8String(featureInfo));
@@ -659,7 +679,7 @@ bool TaskWidgetConfig::parseConfigurationFileWidget(WrtDB::ConfigParserData& con
     ParserRunner parser;
 
     //TODO: rewrite this madness
-    char cfgAbsPath[MAX_WIDGET_PATH_SIZE + 1] = { 0 };
+    std::string cfgAbsPath;
     DIR* dir = NULL;
     struct dirent* ptr = NULL;
 
@@ -673,8 +693,9 @@ bool TaskWidgetConfig::parseConfigurationFileWidget(WrtDB::ConfigParserData& con
     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);
+                std::string dName(ptr->d_name);
+                WrtUtilJoinPaths(cfgAbsPath, _currentPath, dName);
+
                 //Parse widget configuration file
                 LogDebug("Found config: " << cfgAbsPath);
 
@@ -733,8 +754,6 @@ bool TaskWidgetConfig::locateAndParseConfigurationFile(
     std::ostringstream infoPath;
     infoPath << _currentPath.substr(pos+1);
 
-    std::string language = "";
-
     if (infoPath.str() != WRT_WIDGET_CONFIG_FILE_NAME) {
         if (_currentPath.empty() || baseFolder.empty()) {
             *pErrCode = WRT_ERR_INVALID_ARG;
@@ -753,19 +772,6 @@ bool TaskWidgetConfig::locateAndParseConfigurationFile(
         }
     }
 
-    char *tmp_language;
-    if (!_WrtUtilStringToLower(baseFolder.c_str(), &tmp_language)) {
-        *pErrCode = WRT_ERR_UNKNOWN;
-        return false;
-    }
-
-    if (!tmp_language) {
-        *pErrCode = WRT_ERR_UNKNOWN;
-        return false;
-    }
-    language = tmp_language;
-    free(tmp_language);
-
     if(!fillWidgetConfig(pWidgetConfigInfo, configInfo))
     {
         *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
index 632128e..740af5f 100755 (executable)
@@ -75,6 +75,7 @@ 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 StepVerifyFeatures();
index b8ce123..4f81120 100644 (file)
@@ -29,9 +29,22 @@ namespace WidgetInstall {
 void WacSecurity::getCertificateChainList(
         WrtDB::CertificateChainList& list) const
 {
-    FOREACH(certIter,mCertificateChainList)
+    FOREACH(certIter, mCertificateChainList)
         list.push_back(certIter->toBase64String());
 }
 
+void WacSecurity::getCertificateChainList(
+        WrtDB::CertificateChainList& list,
+        WrtDB::CertificateSource source) const
+{
+    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
 } // namespace Jobs
index 702a8f4..e899ad8 100644 (file)
@@ -55,6 +55,10 @@ class WacSecurity : public WrtDB::IWacSecurity
     virtual void getCertificateChainList(
             WrtDB::CertificateChainList& list) const;
 
+    virtual void getCertificateChainList(
+            WrtDB::CertificateChainList& list,
+            WrtDB::CertificateSource source) const;
+
     void setRecognized(bool recognized) { mRecognized = recognized; }
     void setDistributorSigned(bool distributorSigned)
     {
@@ -68,6 +72,11 @@ class WacSecurity : public WrtDB::IWacSecurity
         return mCertificateChainList;
     }
 
+    ValidationCore::CertificateCollectionList& getAuthorsCertificateChainListRef()
+    {
+        return mAuthorsCertificateChainList;
+    }
+
     WrtDB::WidgetCertificateDataList& getCertificateListRef()
     {
         return mCertificateList;
@@ -89,6 +98,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
index b91962a..cec0242 100644 (file)
@@ -91,6 +91,13 @@ DECLARE_JOB_EXCEPTION(Base, InstallOspsvcFailed, ErrorInstallOspServcie)
 DECLARE_JOB_EXCEPTION(Base, BackupFailed, ErrorUpdateWidget)
 DECLARE_JOB_EXCEPTION(Base, InsertNewWidgetFailed, ErrorUpdateWidget)
 DECLARE_JOB_EXCEPTION(Base, RemoveBackupFailed, ErrorUpdateWidget)
+
+// Plugins copy errors
+DECLARE_JOB_EXCEPTION(Base, EmptyPluginsDirectory, ErrorInvalidWidgetPackage)
+DECLARE_JOB_EXCEPTION(Base, PluginsSubdirectory, ErrorInvalidWidgetPackage)
+
+DECLARE_JOB_EXCEPTION(Base, SetCertificateInfoFailed, ErrorUnknown)
+
 } //namespace
 } //namespace
 } //namespace
index 74d1f24..2c7e3c8 100755 (executable)
 #include <job.h>
 #include <widget_install/widget_install_errors.h>
 #include <wrt_common_types.h>
+#include <string>
 
 //Widget Installer typedefs
 typedef void (*InstallerFinishedCallback)(
     void *userParam,
-    WidgetHandle,
+    std::string tizenId,
     Jobs::WidgetInstall::Exceptions::Type);
 
 typedef void (*InstallerProgressCallback)(void *userParam,
index 9c6a0de..08ab319 100644 (file)
@@ -14,8 +14,6 @@
  *    limitations under the License.
  */
 
-#include <dpl/utils/file_utils.h>
-
 #include <widget_uninstall/job_widget_uninstall.h>
 #include <widget_uninstall/widget_uninstall_errors.h>
 #include <widget_uninstall/task_check.h>
@@ -23,6 +21,7 @@
 #include <widget_uninstall/task_remove_files.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>
 
 using namespace WrtDB;
@@ -84,6 +83,7 @@ JobWidgetUninstall::JobWidgetUninstall(WidgetHandle widgetHandle,
         }
         AddTask(new TaskRemoveFiles(m_context));
         AddTask(new TaskDbUpdate(m_context));
+        AddTask(new TaskDeleteCertificates(m_context));
 
         // send start signal of pkgmgr
         if (PkgmgrSignalSingleton::Instance().setPkgname(m_context.pkgname)) {
@@ -91,9 +91,6 @@ JobWidgetUninstall::JobWidgetUninstall(WidgetHandle widgetHandle,
                     PKGMGR_START_KEY,
                     PKGMGR_START_UNINSTALL);
         }
-    } Catch(FileUtils::CreateDirectoryException) {
-        LogError("Failed to create temporary path for widget");
-        AddTask(new UninstallerTaskFail(false));
     } Catch (WidgetDAOReadOnly::Exception::WidgetNotExist) {
         AddTask(new UninstallerTaskFail(true));
     } Catch (WidgetDAOReadOnly::Exception::Base) {
@@ -106,6 +103,11 @@ WidgetHandle JobWidgetUninstall::getRemovedWidgetHandle() const
     return m_context.widgetHandle;
 }
 
+std::string JobWidgetUninstall::getRemovedTizenId() const
+{
+    return m_context.pkgname;
+}
+
 bool JobWidgetUninstall::getRemoveStartedFlag() const
 {
     return m_context.removeStarted;
@@ -147,7 +149,7 @@ void JobWidgetUninstall::SendFinishedSuccess()
 
     LogDebug("Call widget uninstall success finishedCallback");
     getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
-            getRemovedWidgetHandle(),Exceptions::Success);
+            getRemovedTizenId(),Exceptions::Success);
 }
 
 void JobWidgetUninstall::SendFinishedFailure()
@@ -163,7 +165,7 @@ void JobWidgetUninstall::SendFinishedFailure()
 
     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");
 }
 
index ddf3b4e..77115b3 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>
@@ -52,6 +53,7 @@ class JobWidgetUninstall :
             const WidgetUninstallationStruct& uninstallerStruct);
 
     WidgetHandle getRemovedWidgetHandle() const;
+    std::string getRemovedTizenId() const;
     bool getRemoveStartedFlag() const;
     bool getRemoveFinishedFlag() const;
 
index 7628ca4..20f33af 100644 (file)
@@ -26,7 +26,7 @@
 #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>
-#include <aul.h>
+#include <app_manager.h>
 
 namespace Jobs {
 namespace WidgetUninstall {
@@ -47,7 +47,16 @@ void TaskCheck::StepUninstallPreCheck()
     //check if deferred
     //TODO if widget to be updated, then remove it from Deferred list?
 
-    if (aul_app_is_running(m_context.pkgname.c_str())) {
+    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");
+    }
+
+    if (true == isRunning) {
         LogError("Widget is not stopped. Cannot uninstall!");
         //TODO different error
         ThrowMsg(Exceptions::AlreadyUninstalling,
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_
index b747b7e..a9eaebb 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-ro/widget_dao_read_only.h>
+#include <dpl/wrt-dao-rw/widget_dao.h>
 #include <dpl/wrt-dao-ro/widget_config.h>
-
 #include <errno.h>
 #include <dpl/assert.h>
+#include <dpl/utils/wrt_utility.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -128,6 +128,7 @@ TaskRemoveFiles::TaskRemoveFiles(UninstallerContext& context) :
     AddStep(&TaskRemoveFiles::StepRemoveDirectories);
     //AddStep(&TaskRemoveFiles::StepRemoveDesktop);
     AddStep(&TaskRemoveFiles::StepRemoveManifest);
+    AddStep(&TaskRemoveFiles::StepRemoveExternalLocations);
     AddStep(&TaskRemoveFiles::StepRemoveFinished);
 }
 
@@ -177,8 +178,8 @@ void TaskRemoveFiles::StepRemoveDirectories()
     using namespace WrtDB;
     LogInfo("StepRemoveDirectories started");
 
-    if (!_WrtUtilRemoveDir(uninstRootDir.c_str())) {
-        LogWarning("Failed to remove directory" << uninstRootDir.c_str());
+    if (!WrtUtilRemove(uninstRootDir)) {
+        LogWarning("Failed to remove directory" << uninstRootDir);
     }
     LogInfo("StepRemoveDirectories finished");
 
@@ -250,5 +251,32 @@ void TaskRemoveFiles::StepRemoveManifest()
     }
 }
 
+void TaskRemoveFiles::StepRemoveExternalLocations()
+{
+    WidgetDAO dao(m_context.widgetHandle);
+    LogDebug("Removing external locations:");
+    WrtDB::ExternalLocationList externalPaths = dao.getWidgetExternalLocations();
+    FOREACH(path, externalPaths)
+    {
+        if(WrtUtilFileExists(*path))
+        {
+            LogDebug("  -> " << *path);
+            remove(path->c_str());
+        }
+        else if(WrtUtilDirExists(*path))
+        {
+            LogDebug("  -> " << *path);
+            if(!WrtUtilRemove(*path)){
+                Throw(Jobs::WidgetUninstall::TaskRemoveFiles::Exception::RemoveFilesFailed);
+            }
+        }
+        else
+        {
+            LogWarning("  -> " << *path << "(no such a path)");
+        }
+    }
+    dao.unregisterAllExternalLocations();
+}
+
 } //namespace WidgetUninstall
 } //namespace Jobs
index 496bee9..38fcdb9 100644 (file)
@@ -57,6 +57,7 @@ class TaskRemoveFiles :
     void StepRemoveFinished();
     void StepRemoveDesktop();
     void StepRemoveManifest();
+    void StepRemoveExternalLocations();
 
   public:
     explicit TaskRemoveFiles(UninstallerContext& context);
index 4357ba9..f3c4824 100644 (file)
@@ -20,6 +20,7 @@
  * @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>
@@ -52,7 +53,7 @@ void TaskUninstallOspsvc::StepUninstallOspsvc()
     LogInfo("Step : Uninstall Osp service ");
 
     std::ostringstream commStr;
-    commStr << OSP_INSTALL_STR << m_context.pkgname;;
+    commStr << OSP_INSTALL_STR << BashUtils::escape_arg(m_context.pkgname);
     LogDebug("osp uninstall command : " << commStr.str());
 
     char readBuf[MAX_BUF_SIZE];
index e76070a..f2e1a99 100644 (file)
@@ -37,6 +37,7 @@ enum Type
     ErrorAlreadyUninstalling,
     ErrorDatabaseFailure,
     ErrorUninstallOspSvcFailed,
+    ErrorPlatformAPI,
     ErrorUnknown
 };
 
@@ -47,6 +48,8 @@ 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..4388164 100644 (file)
@@ -33,7 +33,7 @@
 //Widget Uninstaller typedefs
 typedef void (*UninstallerFinishedCallback)(
     void *userParam,
-    WidgetHandle,
+    std::string tizenId,
     Jobs::WidgetUninstall::Exceptions::Type);
 
 typedef void (*UninstallerProgressCallback)(
index 754a886..8026350 100644 (file)
@@ -31,11 +31,7 @@ void InstallerController::OnEventReceived(
 {
     std::string fileName = event.GetArg0();
     WidgetInstallationStruct installerStruct = event.GetArg1();
-    Jobs::JobHandle handle =
-        m_installerLogic.InstallWidget(fileName, installerStruct);
-
-    //TODO return handle to API
-    (void)handle;
+    m_installerLogic.InstallWidget(fileName, installerStruct);
 }
 
 void InstallerController::OnEventReceived(
@@ -43,12 +39,7 @@ 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;
+    m_installerLogic.InstallPlugin(dirName, installerStruct);
 }
 
 void InstallerController::OnEventReceived(
@@ -56,11 +47,7 @@ void InstallerController::OnEventReceived(
 {
     WidgetHandle widgetHandle = event.GetArg0();
     WidgetUninstallationStruct uninstallerStruct = event.GetArg1();
-    Jobs::JobHandle handle =
-        m_installerLogic.UninstallWidget(widgetHandle, uninstallerStruct);
-
-    //TODO return handle to API
-    (void)handle;
+    m_installerLogic.UninstallWidget(widgetHandle, uninstallerStruct);
 }
 
 Eina_Bool InstallerController::AddNextStep(void *data)
index 607ec92..aee7de8 100644 (file)
@@ -103,7 +103,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);
 }
 
@@ -224,6 +226,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);
index 5490841..9314602 100644 (file)
@@ -34,6 +34,7 @@ class InstallerLogic
     void InstallDeferredWidgetPackages();
     void InstallSingleDeferredPackage();
 
+    void ResetProgressPlugins();
     void InstallWaitingPlugins();
     bool resolvePluginDependencies(PluginHandle handle);
 
index 5a95628..8c38c6f 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>
@@ -91,7 +91,7 @@ class FeatureLogic : DPL::Noncopyable {
     bool m_rejected;
 };
 
-typedef DPL::SharedPtr<FeatureLogic> FeatureLogicPtr;
+typedef std::shared_ptr<FeatureLogic> FeatureLogicPtr;
 
 } // namespace WidgetInstall
 } // namespace Jobs
index bc1f128..1acbb52 100644 (file)
@@ -28,7 +28,6 @@
 #include <dpl/string.h>
 
 #include <iri.h>
-#include <vcore/ValidatorCommon.h>
 
 namespace {
 const char *SCHEME_HTTP = "http";
index 3427433..712f344 100644 (file)
@@ -37,7 +37,7 @@ WidgetLocation::DirectoryDeletor::DirectoryDeletor()
 WidgetLocation::DirectoryDeletor::~DirectoryDeletor()
 {
     LogDebug("Removing widget installation temporary directory: " << m_dirpath.c_str());
-    _WrtUtilRemoveDir(m_dirpath.c_str());
+    WrtUtilRemove(m_dirpath);
 }
 
 std::string WidgetLocation::DirectoryDeletor::getTempPath() const
@@ -69,6 +69,7 @@ WidgetLocation::WidgetLocation(const std::string & widgetname,
 {
 }
 
+// TODO cache all these paths
 std::string WidgetLocation::getInstallationDir() const
 {
     return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath());
@@ -83,13 +84,18 @@ std::string WidgetLocation::getPackageInstallationDir() const
 std::string WidgetLocation::getSourceDir() const
 {
     return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
-            + m_pkgname + "/" + WrtDB::GlobalConfig::GetWidgetSrcPath();
+            + m_pkgname + WrtDB::GlobalConfig::GetWidgetSrcPath();
 }
 
 std::string WidgetLocation::getBinaryDir() const
 {
     return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
-            + m_pkgname + "/" + WrtDB::GlobalConfig::GetUserWidgetExecPath();
+            + m_pkgname + WrtDB::GlobalConfig::GetUserWidgetExecPath();
+}
+
+std::string WidgetLocation::getExecFile() const
+{
+    return getBinaryDir() + "/" + m_pkgname;
 }
 
 std::string WidgetLocation::getBackupDir() const
@@ -97,6 +103,21 @@ 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::getTemporaryPackageDir() const
 {
     return m_temp->getTempPath();
@@ -111,7 +132,7 @@ std::string WidgetLocation::getTemporaryRootDir() const
 {
     if(m_type == WrtDB::PKG_TYPE_TIZEN_WITHSVCAPP)
     {
-        return getTemporaryPackageDir() + "/" + WrtDB::GlobalConfig::GetWidgetSrcPath();
+        return getTemporaryPackageDir() + WrtDB::GlobalConfig::GetWidgetSrcPath();
     }
     else
     {
@@ -137,6 +158,11 @@ std::string WidgetLocation::getConfigurationDir() const
     }
 }
 
+DPL::String WidgetLocation::getPkgname() const
+{
+    return DPL::FromUTF8String(m_pkgname);
+}
+
 std::string WidgetLocation::getInstalledIconPath() const
 {
     return m_iconPath;
@@ -151,3 +177,13 @@ 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;
+}
index 2c3a636..84106e4 100644 (file)
 #define WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H
 
 #include <string>
+#include <memory>
 
-#include <dpl/shared_ptr.h>
 #include <dpl/wrt-dao-ro/common_dao_types.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 
 /**
  * @brief The WidgetLocation class
@@ -98,7 +99,11 @@ public:
     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]
 
     bool browserRequest() const;
 
@@ -150,6 +155,26 @@ public:
      * @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
@@ -157,7 +182,8 @@ private:
     std::string m_pkgname;                        //name of package
     std::string m_iconPath;                       //installed icon path
     WrtDB::PkgType m_type;
-    DPL::SharedPtr<DirectoryDeletor> m_temp;      //directory
+    std::shared_ptr<DirectoryDeletor> m_temp;      //directory
+    WrtDB::ExternalLocationList m_externals;
 };
 
 #endif // WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H
index a47d772..12d2c7c 100644 (file)
@@ -40,7 +40,7 @@ SET(WRT_INSTALLER_SOURCES
 PKG_CHECK_MODULES(WRT_INSTALLER_DEPS
     pkgmgr-installer
     libpcrecpp
-    ace-install
+    security-install
     REQUIRED)
 
 INCLUDE_DIRECTORIES(
index e15143a..dfc8586 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);
@@ -156,7 +156,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");
     }
@@ -164,7 +164,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);
@@ -207,7 +207,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 911b3cb..c5d677b 100755 (executable)
 #include <dpl/singleton_impl.h>
 #include <dpl/assert.h>
 #include <installer_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) {
 }
index 27d2b01..b02a2dc 100644 (file)
@@ -25,6 +25,7 @@
 #include <string>
 #include <fstream>
 #include <unistd.h>
+#include <memory>
 #include <sys/resource.h>
 #include <dpl/optional.h>
 #include <dpl/scoped_free.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/scoped_ptr.h>
 #include <dpl/binary_queue.h>
 #include <dpl/copy.h>
 #include <dpl/utils/wrt_global_settings.h>
@@ -65,6 +64,11 @@ 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;
@@ -145,14 +149,6 @@ void WrtInstaller::OnCreate()
             m_packagePath = m_argv[2];
             m_installPolicy = WRT_WIM_POLICY_WAC;
             AddStep(&WrtInstaller::installStep);
-        } else if (arg == "-iu" || arg == "--install-or-update") {
-            if (m_argc != 3) {
-                return showHelpAndQuit();
-            }
-
-            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) {
                 return showHelpAndQuit();
@@ -161,14 +157,6 @@ 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") {
-            if (m_argc != 3) {
-                return showHelpAndQuit();
-            }
-            m_quiet = false;
-            m_packagePath = m_argv[2];
-            m_installPolicy = WRT_WIM_POLICY_NEVER_UPDATE;
-            AddStep(&WrtInstaller::installStep);
         } else if (arg == "-u" || arg == "--uninstall") {
             if (m_argc != 3) {
                 return showHelpAndQuit();
@@ -194,14 +182,10 @@ void WrtInstaller::OnCreate()
             }
             m_packagePath = m_argv[2];
             AddStep(&WrtInstaller::unistallWgtFileStep);
-        } else if (arg == "-unq" || arg == "--uninstall-not-quiet") {
-            if (m_argc != 3) {
-                return showHelpAndQuit();
-            }
-            m_quiet = false;
-            m_handle = atoi(m_argv[2]);
-            AddStep(&WrtInstaller::uninstallStep);
+        } else {
+            return showHelpAndQuit();
         }
+
     } else if (arg.find("backend") != std::string::npos) {
         using namespace PackageManager;
         m_installByPkgmgr = true;
@@ -289,13 +273,9 @@ 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     "
@@ -304,8 +284,6 @@ void WrtInstaller::showHelpAndQuit()
            "uninstall widget for given package path\n"
            "  -up,   --uninstall-packagepath                "
            "uninstall widget for given Global Unique IDentifier\n"
-           "  -unq,  --uninstall-not-quiet                  "
-           "uninstall with popup                 \n"
            "\n");
 
     Quit();
@@ -360,10 +338,10 @@ void WrtInstaller::initStep()
 void WrtInstaller::installStep()
 {
     LogDebug("Installing widget ...");
-    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,
@@ -495,16 +473,16 @@ void WrtInstaller::unistallWgtFileStep()
         ConfigParserData configInfo;
 
         // Open zip file
-        DPL::ScopedPtr<DPL::ZipInput> zipFile(
+        std::unique_ptr<DPL::ZipInput> zipFile(
                 new DPL::ZipInput(m_packagePath));
 
         // Open config.xml file
-        DPL::ScopedPtr<DPL::ZipInput::File> configFile(
+        std::unique_ptr<DPL::ZipInput::File> configFile(
                 zipFile->OpenFile(CONFIG_XML));
 
         // Extract config
         DPL::BinaryQueue buffer;
-        DPL::AbstractWaitableInputAdapter inputAdapter(configFile.Get());
+        DPL::AbstractWaitableInputAdapter inputAdapter(configFile.get());
         DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
         DPL::Copy(&inputAdapter, &outputAdapter);
         parser.Parse(&buffer,
@@ -577,7 +555,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();
         }
@@ -592,7 +570,7 @@ void WrtInstaller::staticWrtInitCallback(WrtErrStatus status,
     }
 }
 
-void WrtInstaller::staticWrtStatusCallback(int handle,
+void WrtInstaller::staticWrtStatusCallback(std::string tizenId,
                                            WrtErrStatus status,
                                            void* userdata)
 {
@@ -621,7 +599,7 @@ void WrtInstaller::staticWrtStatusCallback(int handle,
         LogDebug("Step failed");
         This->m_returnStatus = -1;
 
-        if (!This->m_quiet) {
+        if (This->popupsEnabled()) {
             resultMsg +=  L" : " + DPL::FromUTF8String(PKGMGR_END_FAILURE);
             This->m_popup->showPopup(This, resultMsg, failResultCallback);
         } else {
@@ -690,13 +668,12 @@ void WrtInstaller::staticWrtStatusCallback(int handle,
         }
     } else {
 
-        printf("%s : %d\n", printMsg.c_str(), handle);
+        printf("%s : %s\n", printMsg.c_str(), tizenId.c_str());
         LogDebug("Status succesfull");
-        This->m_handle = handle;
         This->m_returnStatus = 0;
         resultMsg +=  L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
 
-        if (!This->m_quiet) {
+        if (This->popupsEnabled()) {
             This->m_popup->showPopup(This, resultMsg, showResultCallback);
         } else {
             This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
@@ -733,7 +710,7 @@ void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
             LogInfo("Failed to remove installation lock");
         }
 
-        if (!This->m_quiet) {
+        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);
@@ -742,7 +719,7 @@ 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);
@@ -813,7 +790,7 @@ void WrtInstaller::staticWrtInstallProgressCallback(float percent,
     LogInfo(" progress: " << percent <<
             " description: " << description);
 
-    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);
@@ -827,7 +804,7 @@ void WrtInstaller::staticWrtUninstallProgressCallback(float percent,
     LogInfo(" progress: " << percent <<
             " description: " << description);
 
-    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);
@@ -963,6 +940,11 @@ 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,
index 4139ff6..d06092a 100644 (file)
@@ -111,7 +111,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,
@@ -132,6 +132,8 @@ class WrtInstaller :
     static void failResultCallback(void *data, Evas_Object *obj,
                                    void *event_info);
 
+    bool popupsEnabled() const;
+
     // Private data
     wrt_widget_install_mode_e m_installPolicy;
     std::string m_bundleValue;
index 43a6234..9921fdf 100755 (executable)
 #include <installer_callbacks_translate.h>
 #include <installer_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 <wrt_type.h>
 #include <dpl/localization/w3c_file_localization.h>
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
@@ -97,24 +94,6 @@ extern "C"
         return result;
     }
 
-    void localizationSetting()
-    {
-        char* lang = vconf_get_str(VCONFKEY_LANGSET);
-        if (!lang) {
-            LogError("Cannot get locale settings from vconf");
-        } else {
-            LogDebug("Language set to: " << lang);
-
-            using namespace LocalizationUtils;
-
-            LanguageTagsList list;
-            list.push_back(DPL::FromUTF8String(lang));
-            SetSystemLanguageTags(list);
-
-            LogDebug("LanguageChanged to " << lang);
-        }
-    }
-
     const char PLUGIN_INSTALL_SEMAPHORE[] = "/.wrt_plugin_install_lock";
     static int wrt_count_plugin;
 
@@ -276,7 +255,6 @@ extern "C"
 
             // Initialize Language Subtag registry
             LanguageSubtagRstTreeSingleton::Instance().Initialize();
-            localizationSetting();
 
             // Installer init
             CONTROLLER_POST_SYNC_EVENT(
index 8d8a814..9bc7146 100755 (executable)
@@ -53,7 +53,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);
 
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>