[Release] wrt-installer_0.1.53
authorJihoon Chung <jihoon.chung@samsung.com>
Tue, 7 May 2013 07:46:52 +0000 (16:46 +0900)
committerJihoon Chung <jihoon.chung@samsung.com>
Tue, 7 May 2013 07:47:24 +0000 (16:47 +0900)
63 files changed:
configuration/config.tizen.xsd
configuration/config.xml
configuration/config.xsd
packaging/wrt-installer.spec
src/CMakeLists.txt
src/commons/wrt_common_types.h
src/commons/wrt_install_mode.h [new file with mode: 0644]
src/configuration_parser/widget_parser.cpp
src/jobs/job_base.h
src/jobs/job_exception_error.h
src/jobs/widget_install/ace_registration.cpp
src/jobs/widget_install/ace_registration.h
src/jobs/widget_install/directory_api.cpp [new file with mode: 0644]
src/jobs/widget_install/directory_api.h [new file with mode: 0644]
src/jobs/widget_install/job_widget_install.cpp
src/jobs/widget_install/job_widget_install.h
src/jobs/widget_install/task_ace_check.cpp
src/jobs/widget_install/task_certify.cpp
src/jobs/widget_install/task_commons.h
src/jobs/widget_install/task_database.cpp
src/jobs/widget_install/task_database.h
src/jobs/widget_install/task_file_manipulation.cpp
src/jobs/widget_install/task_install_ospsvc.cpp
src/jobs/widget_install/task_install_ospsvc.h
src/jobs/widget_install/task_manifest_file.cpp
src/jobs/widget_install/task_prepare_reinstall.cpp
src/jobs/widget_install/task_remove_backup.cpp
src/jobs/widget_install/task_remove_backup.h
src/jobs/widget_install/task_smack.cpp
src/jobs/widget_install/task_update_files.cpp
src/jobs/widget_install/task_update_files.h
src/jobs/widget_install/widget_install_context.h
src/jobs/widget_install/widget_install_errors.h
src/jobs/widget_install/widget_installer_struct.h
src/misc/widget_location.cpp
src/misc/widget_location.h
src/pkg-manager/backendlib.cpp
src/wrt-installer/installer_callbacks_translate.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
src/wrt-installer/wrt_type.h
tests/general/CMakeLists.txt
tests/general/InstallerWrapper.cpp
tests/general/InstallerWrapper.h
tests/general/ManifestTests.cpp
tests/general/NPluginsInstallTests.cpp
tests/general/ParsingTizenAppcontrolTests.cpp [moved from tests/general/ParsingTizenAppserviceTests.cpp with 62% similarity]
tests/general/widgets/app-control.wgt [moved from tests/general/widgets/appservice_dispos.wgt with 83% similarity]
tests/general/widgets/bg-00-with_bg.wgt
tests/general/widgets/bg-01-missing_file.wgt
tests/general/widgets/bg-02-without_bg.wgt
tests/general/widgets/inst_nplug_1.wgt
tests/general/widgets/inst_nplug_2.wgt
tests/general/widgets/inst_nplug_3.wgt
tests/general/widgets/inst_nplug_4.wgt
tests/general/widgets/manifest.wgt
tests/general/widgets/nonroot.wgt
tests/general/widgets/tizen_app-control/config.xml [new file with mode: 0644]
tests/general/widgets/tizen_app-control/icon.png [moved from tests/general/widgets/tizen_appservice_disposition/icon.png with 100% similarity]
tests/general/widgets/tizen_app-control/index.htm [moved from tests/general/widgets/tizen_appservice_disposition/index.htm with 100% similarity]
tests/general/widgets/tizen_appservice_disposition/config.xml [deleted file]

index b2293d1..72addb1 100644 (file)
@@ -2,7 +2,6 @@
 <!-- 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:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
-
     <xs:simpleType name="data.boolean">
         <xs:restriction base="xs:string">
             <xs:enumeration value="true"/>
@@ -30,6 +29,7 @@
         <xs:restriction base="xs:token">
             <xs:enumeration value="portrait"/>
             <xs:enumeration value="landscape"/>
+            <xs:enumeration value="auto-rotation"/>
         </xs:restriction>
     </xs:simpleType>
 
       </xs:complexType>
     </xs:element>
 
+    <xs:element name="privilege">
+        <xs:complexType>
+            <xs:attribute name="name" use="required" type="xs:anyURI"/>
+        </xs:complexType>
+    </xs:element>
+
+    <xs:element name="content-security-policy" type="xs:string"/>
+    <xs:element name="content-security-policy-report-only" type="xs:string"/>
+    <xs:element name="allow-navigation" type="xs:string"/>
+
     <xs:element name="app-widget">
         <xs:complexType mixed="true">
             <xs:all>
             <xs:attribute name="primary" type="tizen:data.boolean" use="required"/>
             <xs:attribute name="auto-launch" type="tizen:data.boolean" use="optional"/>
             <xs:attribute name="update-period" type="tizen:updatePeriodType" use="optional"/>
-        </xs:complexType>
-    </xs:element>
-
-    <xs:element name="privilege">
-        <xs:complexType>
-            <xs:attribute name="name" use="required" type="xs:anyURI"/>
+            <xs:attribute name="type" type="xs:string" use="optional"/>
         </xs:complexType>
     </xs:element>
 
             <xs:attribute name="src" use="required" type="xs:anyURI"/>
             <xs:attribute name="width" use="required" type="xs:int"/>
             <xs:attribute name="height" use="required" type="xs:int"/>
+            <xs:attribute name="fast-open" use="optional" type="tizen:data.boolean"/>
         </xs:complexType>
     </xs:element>
 
         <xs:attribute ref="xml:lang"/>
       </xs:complexType>
     </xs:element>
-
 </xs:schema>
index 3e5dc15..9968071 100755 (executable)
@@ -1,36 +1,26 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" version="2.0 Beta" viewmodes="fullscreen" id="http://tizen.org/cert">
-  <feature name="http://tizen.org/privilege/accelerometer" />
-  <feature name="http://tizen.org/privilege/account" />
-  <feature name="http://tizen.org/privilege/application" />
-  <feature name="http://tizen.org/privilege/callHistory.read" />
-  <feature name="http://tizen.org/privilege/callHistory.write" />
-  <feature name="http://tizen.org/privilege/deviceapis" />
-  <feature name="http://tizen.org/privilege/deviceinteraction" />
-  <feature name="http://tizen.org/privilege/gallery" />
-  <feature name="http://tizen.org/privilege/gyroscope" />
-  <feature name="http://tizen.org/privilege/intel-messaging" />
-  <feature name="http://tizen.org/privilege/messaging" />
-  <feature name="http://tizen.org/privilege/messaging.send" />
-  <feature name="http://tizen.org/privilege/messaging.read" />
-  <feature name="http://tizen.org/privilege/messaging.write" />
-  <feature name="http://tizen.org/privilege/pim" />
-  <feature name="http://tizen.org/privilege/orientation" />
-  <feature name="http://tizen.org/privilege/systeminfo" />
-  <feature name="http://tizen.org/privilege/waclog" />
-  <name> hello </name>
+<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" version="0.0.1" viewmodes="fullscreen">
+  <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:application id="GfeI4eyhBG.Test" package="GfeI4eyhBG" required_version="2.1"/>
 
   <!-- tizen setting element -->
-  <tizen:setting screen-orientation="portrait" />
-  <tizen:setting contextmenu="disable" />
-  <tizen:setting nodisplay="false" />
+  <tizen:setting screen-orientation="landscape" context-menu="disable" background-support="enable" encryption="enable" install-location="internal-only"/>
+
+  <!-- tizen app-control element -->
+  <tizen:app-control>
+    <tizen:src name="index.html"/>
+    <tizen:operation name="http://tizen.org/appcontrol/operation/default"/>
+    <tizen:uri name="http"/>
+    <tizen:mime name="html"/>
+  </tizen:app-control>
+
+  <!-- tizen content-security-policy element -->
+  <tizen:content-security-policy>"img-src http://test.com 'unsafe-inline'; script-src 'unsafe-inline';"</tizen:content-security-policy>
+  <tizen:content-security-policy-report-only>img-src http://test.com 'unsafe-inline'; script-src 'unsafe-inline';</tizen:content-security-policy-report-only>
+
+  <!-- tizen allow-navigation element -->
+  <tizen:allow-navigation>test.com</tizen:allow-navigation>
 </widget>
index 6a9443e..4d7a823 100644 (file)
                 <xs:element ref="tizen:setting"  maxOccurs="unbounded" xmlns:tizen="http://tizen.org/ns/widgets"/>\r
                 <xs:element ref="tizen:application" minOccurs="1" maxOccurs="1" xmlns:tizen="http://tizen.org/ns/widgets"/>\r
                 <xs:element ref="tizen:content"  minOccurs="1" maxOccurs="1" xmlns:tizen="http://tizen.org/ns/widgets"/>\r
-                <xs:element ref="tizen:app-widget"  minOccurs="0" maxOccurs="unbounded" xmlns:tizen="http://tizen.org/ns/widgets"/>\r
                 <xs:element ref="tizen:privilege"  minOccurs="0" maxOccurs="unbounded" xmlns:tizen="http://tizen.org/ns/widgets"/>\r
+                <xs:element ref="tizen:content-security-policy" minOccurs="0" maxOccurs="1" xmlns:tizen="http://tizen.org/ns/widgets"/>\r
+                <xs:element ref="tizen:content-security-policy-report-only" minOccurs="0" maxOccurs="1" xmlns:tizen="http://tizen.org/ns/widgets"/>\r
+                <xs:element ref="tizen:allow-navigation" minOccurs="0" maxOccurs="1" xmlns:tizen="http://tizen.org/ns/widgets"/>\r
+                <xs:element ref="tizen:app-widget"  minOccurs="0" maxOccurs="unbounded" xmlns:tizen="http://tizen.org/ns/widgets"/>\r
                 <xs:element ref="tizen:account"  minOccurs="0" maxOccurs="unbounded" xmlns:tizen="http://tizen.org/ns/widgets"/>\r
-                </xs:choice>\r
+            </xs:choice>\r
             <xs:attribute ref="xml:lang"/>\r
             <xs:attribute name="id" type="xs:anyURI"/>\r
             <xs:attribute name="version" type="widgets:data.versionNumber"/>\r
index fdb0340..bc8c952 100644 (file)
@@ -1,7 +1,7 @@
-#git:framework/web/wrt-installer wrt-installer 0.1.49
+#git:framework/web/wrt-installer wrt-installer_0.1.53
 Name:       wrt-installer
 Summary:    Installer for tizen Webruntime
-Version:    0.1.49
+Version:    0.1.53
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
@@ -28,6 +28,7 @@ BuildRequires:  pkgconfig(libpcrecpp)
 BuildRequires:  pkgconfig(pkgmgr-installer)
 BuildRequires:  pkgconfig(pkgmgr-parser)
 BuildRequires:  pkgconfig(pkgmgr-types)
+BuildRequires:  pkgconfig(pkgmgr-info)
 BuildRequires:  pkgconfig(pkgmgr)
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(cert-svc)
@@ -43,6 +44,7 @@ BuildRequires:  pkgconfig(libprivilege-control)
 BuildRequires:  pkgconfig(osp-appfw)
 BuildRequires:  osp-appfw-internal-devel
 Requires: osp-appfw
+Requires: osp-installer
 Requires: xmlsec1
 
 %description
index 5e33b52..03997c0 100644 (file)
@@ -81,6 +81,7 @@ SET(INSTALLER_SOURCES
     ${INSTALLER_JOBS}/widget_install/task_prepare_reinstall.cpp
     ${INSTALLER_JOBS}/widget_install/wac_security.cpp
     ${INSTALLER_JOBS}/widget_install/widget_update_info.cpp
+    ${INSTALLER_JOBS}/widget_install/directory_api.cpp
     ${INSTALLER_JOBS}/widget_uninstall/job_widget_uninstall.cpp
     ${INSTALLER_JOBS}/widget_uninstall/task_check.cpp
     ${INSTALLER_JOBS}/widget_uninstall/task_remove_files.cpp
@@ -122,6 +123,7 @@ PKG_CHECK_MODULES(INSTALLER_STATIC_DEP
     wrt-plugins-types
     pkgmgr-installer
     pkgmgr-parser
+    pkgmgr-info
     web-provider
     osp-appfw
     REQUIRED
index f888c85..965db9c 100644 (file)
@@ -42,7 +42,6 @@ enum InstallLocationType
 {
     INSTALL_LOCATION_TYPE_UNKNOWN = 0,
     INSTALL_LOCATION_TYPE_NOMAL,
-    INSTALL_LOCATION_TYPE_PRELOAD,
     INSTALL_LOCATION_TYPE_EXTERNAL
 };
 
diff --git a/src/commons/wrt_install_mode.h b/src/commons/wrt_install_mode.h
new file mode 100644 (file)
index 0000000..a545f9c
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    wrt_install_mode.h
+ * @author  Jihoon Chung (jihoon.chung@samgsung.com)
+ * @version
+ * @brief   Definition file of widget install mode class
+ */
+
+#ifndef WRT_INSTALL_MODE_H
+#define WRT_INSTALL_MODE_H
+
+class InstallMode
+{
+  public:
+    enum class Command
+    {
+        INSTALL,
+        REINSTALL
+    };
+    enum class Location
+    {
+        INTERNAL,
+        EXTERNAL
+    };
+    enum class RootPath
+    {
+        RW,
+        RO
+    };
+    enum class ExtensionType
+    {
+        WGT,
+        DIR
+    };
+    enum class InstallTime
+    {
+        NORMAL,
+        PRELOAD
+    };
+
+    InstallMode(Command cmd = Command::INSTALL,
+                Location lo = Location::INTERNAL,
+                RootPath root = RootPath::RW,
+                ExtensionType extensionType = ExtensionType::WGT,
+                InstallTime time = InstallTime::NORMAL) :
+        command(cmd),
+        location(lo),
+        rootPath(root),
+        extension(extensionType),
+        installTime(time)
+    {};
+
+    Command command;
+    Location location;
+    RootPath rootPath;
+    ExtensionType extension;
+    InstallTime installTime;
+};
+
+#endif // WRT_INSTALL_MODE_H
+
index 289e30d..6433176 100644 (file)
@@ -1352,7 +1352,7 @@ class ApplicationParser : public ElementParser
 };
 
 const char* const ApplicationParser::REGEXP_PACKAGE = "[0-9A-Za-z]{10}";
-const char* const ApplicationParser::REGEXP_ID = "([0-9A-Za-z]{10})\\..{2,52}";
+const char* const ApplicationParser::REGEXP_ID = "([0-9A-Za-z]{10})\\.[0-9A-Za-z]{2,52}";
 const char* const ApplicationParser::REGEXP_VERSION = "\\d+\\.\\d+(\\.\\d+)?";
 
 class SplashParser : public ElementParser
index c2ed1d8..bb0bbf1 100644 (file)
@@ -59,7 +59,7 @@ class JobProgressBase
                         ProgressDescription const &description)
     {
         m_progresPercent =
-            ((static_cast<ProgressPercent>(step) + 1.0) /
+            ((static_cast<ProgressPercent>(step)) /
              static_cast<ProgressPercent>(lastElement)) * 100;
         m_progresDescription = description;
     }
index 52a98a1..9aebb74 100644 (file)
@@ -42,29 +42,31 @@ enum Type
     ErrorPackageNotFound,                       ///<
     ErrorPackageInvalid,                        ///< invalid widget package
     ErrorPackageLowerVersion,                   ///< given version is lower
-                                                ///< than existing version
-    ErrorManifestNotFound,                      ///<
+    ErrorPackageExecutableNotFound,
+
+    ErrorManifestNotFound = 11,                 ///<
     ErrorManifestInvalid,                       ///<
     ErrorConfigNotFound,                        ///< couldn't find config.xml
-                                                ///< in package.
     ErrorConfigInvalid,                         ///< invalid config.xml
-    ErrorSignatureNotFound,                     ///< signature file not exist.
+
+    ErrorSignatureNotFound = 21,                ///< signature file not exist.
     ErrorSignatureInvalid,                      ///< invalid signature file
     ErrorSignatureVerificationFailed,           ///< failure in verificate
                                                 ///< signature
-    ErrorRootCertificateNotFound,               ///< couldn't find root
-                                                ///< certificate.
+    ErrorRootCertificateNotFound = 31,          ///< couldn't find root
     ErrorCertificationInvaid,                   ///< invalid certification
     ErrorCertificateChainVerificationFailed,    ///< failure in verificate
-                                                ///< certification chain.
     ErrorCertificateExpired,                    ///< expire cerification.
-    ErrorInvalidPrivilege,                      ///< invalid privilege.
-    ErrorMenuIconNotFound,                      ///<
-    ErrorFatalError,                            ///< failure in db operation
-                                                ///< or file opertion..
-    ErrorOutOfStorage,                          ///< failure in shortage of
-                                                ///< memory
+
+    ErrorInvalidPrivilege = 41,                 ///< invalid privilege.
+    ErrorPrivilegeLevelViolation,
+
+    ErrorMenuIconNotFound = 51,                 ///<
+
+    ErrorFatalError = 61,                       ///< failure in db operation
+    ErrorOutOfStorage,                          ///< failure in shortage of memory
     ErrorOutOfMemory,                           ///< failure in shortage of RAM
+    ErrorArgumentInvalid,
 
     /* wrt-installer error */
     /* 121-140 : reserved for Web installer */
index e2077ef..ac266d1 100644 (file)
@@ -137,4 +137,102 @@ bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle,
     delete[] certData;
     return retval == ACE_OK;
 }
+bool registerAceWidgetFromDB(const WrtDB::DbWidgetHandle& widgetHandle)
+{
+    using namespace WrtDB;
+    LogDebug("Updating Ace database from Widget DB");
+    struct widget_info wi;
+    DPL::OptionalString os;
+    WrtDB::WidgetCertificateDataList certList;
+
+    Try {
+        WidgetDAOReadOnly dao(widgetHandle);
+
+        WidgetType type = dao.getWidgetType();
+        if (type == WrtDB::APP_TYPE_WAC20) {
+            wi.type = WAC20;
+        } else if (type == WrtDB::APP_TYPE_TIZENWEBAPP) {
+            wi.type = Tizen;
+        } else {
+            LogError("Unknown application type");
+            return false;
+        }
+
+        wi.id = toAceString(dao.getGUID());
+        wi.version = toAceString(dao.getVersion());
+        wi.author = toAceString(dao.getAuthorName());
+        wi.shareHerf = strdup(dao.getShareHref().c_str());
+        LogDebug("Basic data converted. Certificates begin.");
+        certList = dao.getCertificateDataList();
+    }
+    Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) {
+        LogError("Widget does not exist");
+        return false;
+    }
+
+    //one more element for NULL termination
+    LogDebug("Found: " << certList.size() << " certificates");
+    ace_certificate_data** certData = new ace_certificate_data *
+        [certList.size() + 1];
+    certData[certList.size()] = NULL; // last element set to NULL
+
+    int i = 0;
+    FOREACH(it, certList)
+    {
+        certData[i] = new ace_certificate_data;
+        switch (it->owner) {
+        case WrtDB::WidgetCertificateData::AUTHOR:
+            certData[i]->owner = AUTHOR;
+            break;
+        case WrtDB::WidgetCertificateData::DISTRIBUTOR:
+            certData[i]->owner = DISTRIBUTOR;
+            break;
+        default:
+            LogDebug("Unknown owner type of cert");
+            certData[i]->owner = UNKNOWN;
+            break;
+        }
+        switch (it->type) {
+        case WrtDB::WidgetCertificateData::ENDENTITY:
+            certData[i]->type = ENDENTITY;
+            break;
+        case WrtDB::WidgetCertificateData::ROOT:
+            certData[i]->type = ROOT;
+            break;
+        default:
+            LogError("Unknown type of cert");
+            certData[i]->type = ENDENTITY;
+            break;
+        }
+        certData[i]->chain_id = it->chainId;
+
+        certData[i]->md5_fp = toAceString(it->strMD5Fingerprint);
+        certData[i]->sha1_fp = toAceString(it->strSHA1Fingerprint);
+        certData[i]->common_name =
+            toAceString(DPL::ToUTF8String(it->strCommonName));
+        ++i;
+    }
+
+    LogDebug("Registerign widget in ace");
+    ace_return_t retval = ace_register_widget(
+            static_cast<ace_widget_handle_t>(widgetHandle), &wi, certData);
+
+    //clean up - WidgetInfo
+    free(wi.author);
+    free(wi.id);
+    free(wi.shareHerf);
+    free(wi.version);
+
+    //free cert list
+    i = 0;
+    while (certData[i] != NULL) {
+        free(certData[i]->common_name);
+        free(certData[i]->md5_fp);
+        free(certData[i]->sha1_fp);
+        delete certData[i];
+        ++i;
+    }
+    delete[] certData;
+    return retval == ACE_OK;
+}
 }
index a9e0577..f98c3ce 100644 (file)
@@ -28,6 +28,7 @@ namespace AceApi {
 bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle,
                        const WrtDB::WidgetRegisterInfo& widgetConfig,
                        const WrtDB::WidgetCertificateDataList& certList);
+bool registerAceWidgetFromDB(const WrtDB::DbWidgetHandle& widgetHandle);
 }
 
 #endif  /* WRT_SRC_INSTALLER_CORE_ACE_REGISTRATION_H_ */
diff --git a/src/jobs/widget_install/directory_api.cpp b/src/jobs/widget_install/directory_api.cpp
new file mode 100644 (file)
index 0000000..678ec1d
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * 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    directory_api.cpp
+ * @author  Soyoung Kim(sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief   directory api - implementation file
+ */
+
+#include <directory_api.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <fstream>
+#include <dpl/log/log.h>
+#include <dpl/foreach.h>
+#include <dpl/utils/wrt_utility.h>
+
+namespace DirectoryApi {
+bool DirectoryCopy(std::string source, std::string dest)
+{
+    DIR* dir = opendir(source.c_str());
+    if (NULL == dir) {
+        return false;
+    }
+
+    struct dirent dEntry;
+    struct dirent *dEntryResult;
+    int return_code;
+
+    do {
+        struct stat statInfo;
+        return_code = readdir_r(dir, &dEntry, &dEntryResult);
+        if (dEntryResult != NULL && return_code == 0) {
+            std::string fileName = dEntry.d_name;
+            std::string fullName = source + "/" + fileName;
+
+            if (stat(fullName.c_str(), &statInfo) != 0) {
+                closedir(dir);
+                return false;
+            }
+
+            if (S_ISDIR(statInfo.st_mode)) {
+                if (("." == fileName) || (".." == fileName)) {
+                    continue;
+                }
+                std::string destFolder = dest + "/" + fileName;
+                WrtUtilMakeDir(destFolder);
+
+                if (!DirectoryCopy(fullName, destFolder)) {
+                    closedir(dir);
+                    return false;
+                }
+            }
+
+            std::string destFile = dest + "/" + fileName;
+            std::ifstream infile(fullName);
+            std::ofstream outfile(destFile);
+            outfile << infile.rdbuf();
+            outfile.close();
+            infile.close();
+        }
+    } while (dEntryResult != NULL && return_code == 0);
+    closedir(dir);
+    return true;
+}
+}
diff --git a/src/jobs/widget_install/directory_api.h b/src/jobs/widget_install/directory_api.h
new file mode 100644 (file)
index 0000000..1632528
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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    directory_api.h
+ * @author  Soyoung Kim(sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief   directory api - header file
+ */
+#ifndef WRT_SRC_INSTALLER_CORE_DIRECTORY_API_H_
+#define WRT_SRC_INSTALLER_CORE_DIRECTORY_API_H_
+
+#include<string>
+
+namespace DirectoryApi {
+bool DirectoryCopy(std::string source, std::string dest);
+}
+
+#endif  /* WRT_SRC_INSTALLER_CORE_DIRECTORY_API_H_ */
+
index d733180..aa46a4e 100644 (file)
@@ -162,6 +162,7 @@ JobWidgetInstall::JobWidgetInstall(
     JobContextBase<WidgetInstallationStruct>(installerStruct),
     m_exceptionCaught(Jobs::Exceptions::Success)
 {
+    m_installerContext.mode = m_jobStruct.m_installMode;
     ConfigureResult result = PrePareInstallation(widgetPath);
 
     if (result == ConfigureResult::Ok) {
@@ -208,8 +209,8 @@ JobWidgetInstall::JobWidgetInstall(
         LogInfo("Widget Update");
         m_installerContext.job->SetProgressFlag(true);
 
-        if (m_jobStruct.m_installMode ==
-            InstallMode::REINSTALL_MODE_DIRECTORY)
+        if (m_installerContext.mode.command ==
+            InstallMode::Command::REINSTALL)
         {
             AddTask(new TaskPrepareReinstall(m_installerContext));
         }
@@ -240,6 +241,7 @@ JobWidgetInstall::JobWidgetInstall(
             WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
         {
             AddTask(new TaskUpdateFiles(m_installerContext));
+            AddTask(new TaskFileManipulation(m_installerContext));
         }
 
         AddTask(new TaskManifestFile(m_installerContext));
@@ -248,17 +250,14 @@ JobWidgetInstall::JobWidgetInstall(
         {
             AddTask(new TaskInstallOspsvc(m_installerContext));
         }
-        if (m_installerContext.widgetConfig.packagingType !=
-            WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
-        {
-            AddTask(new TaskRemoveBackupFiles(m_installerContext));
-        }
+        AddTask(new TaskCertificates(m_installerContext));
         AddTask(new TaskDatabase(m_installerContext));
         AddTask(new TaskAceCheck(m_installerContext));
         //TODO: remove widgetHandle from this task and move before database task
         // by now widget handle is needed in ace check
         // Any error in acecheck while update will break widget
         AddTask(new TaskSmack(m_installerContext));
+        AddTask(new TaskRemoveBackupFiles(m_installerContext));
     } else if (result == ConfigureResult::Deferred) {
         // Installation is deferred
         LogInfo("Configure installation deferred");
@@ -284,9 +283,7 @@ ConfigureResult JobWidgetInstall::PrePareInstallation(
     Try
     {
         std::string tempDir;
-        if (m_jobStruct.m_installMode ==
-            InstallMode::REINSTALL_MODE_DIRECTORY)
-        {
+        if (m_installerContext.mode.extension == InstallMode::ExtensionType::DIR) {
             std::ostringstream tempPathBuilder;
             tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
             tempPathBuilder << WrtDB::GlobalConfig::GetTmpDirPath();
@@ -296,8 +293,8 @@ ConfigureResult JobWidgetInstall::PrePareInstallation(
         } else {
             tempDir =
                 Jobs::WidgetInstall::createTempPath(
-                        m_jobStruct.m_installMode ==
-                            InstallMode::INSTALL_MODE_PRELOAD);
+                        m_installerContext.mode.rootPath ==
+                            InstallMode::RootPath::RO);
         }
 
         m_isDRM = isDRMWidget(widgetPath);
@@ -318,8 +315,7 @@ ConfigureResult JobWidgetInstall::PrePareInstallation(
                 tempDir,
                 m_installerContext.widgetConfig.packagingType,
                 m_isDRM,
-                m_jobStruct.m_installMode ==
-                    InstallMode::REINSTALL_MODE_DIRECTORY);
+                m_installerContext.mode.command == InstallMode::Command::REINSTALL);
         LogDebug("widget packaging type : " <<
                  m_installerContext.widgetConfig.packagingType.pkgType);
 
@@ -447,24 +443,13 @@ void JobWidgetInstall::setTizenId(
 void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath,
                                                const std::string& tempPath)
 {
-    if (m_jobStruct.m_installMode ==
-         InstallMode::REINSTALL_MODE_DIRECTORY)
-    {
-        // replace widget path to installed path
-        m_installerContext.locations =
-            WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig.
-                                                 tzPkgid),
-                           widgetPath, tempPath,
-                           m_installerContext.widgetConfig.packagingType,
-                           m_installerContext.locationType);
-    } else {
-        m_installerContext.locations =
-            WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig.
-                                                 tzPkgid),
-                           widgetPath, tempPath,
-                           m_installerContext.widgetConfig.packagingType,
-                           m_installerContext.locationType);
-    }
+    m_installerContext.locations =
+        WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig.
+                                             tzPkgid),
+                       widgetPath, tempPath,
+                       m_installerContext.widgetConfig.packagingType,
+                       m_installerContext.mode.rootPath ==
+                           InstallMode::RootPath::RO);
     m_installerContext.locations->registerAppid(
         DPL::ToUTF8String(m_installerContext.widgetConfig.tzAppid));
 
@@ -570,13 +555,14 @@ bool JobWidgetInstall::validateTizenPackageID(
 ConfigureResult JobWidgetInstall::checkWidgetUpdate(
     const WidgetUpdateInfo &update)
 {
-    LogInfo("incoming version = '" << update.incomingVersion);
-    LogInfo("Tizen AppID = " << update.tzAppId);
-
     if (update.existingVersion.IsNull() || update.incomingVersion.IsNull()) {
         return ConfigureResult::Failed;
     }
 
+    LogInfo("existing version = '" << update.existingVersion);
+    LogInfo("incoming version = '" << update.incomingVersion);
+    LogInfo("Tizen AppID = " << update.tzAppId);
+
     // Check running state
     bool isRunning = false;
     int ret =
@@ -637,47 +623,15 @@ ConfigureResult JobWidgetInstall::checkWidgetUpdate(
 
     m_installerContext.widgetConfig.tzAppid = update.tzAppId;
 
-    if (isUpperVersion(update.existingVersion, update.incomingVersion) ||
-        (m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_DIRECTORY) ||
-        (m_jobStruct.m_installMode == InstallMode::REINSTALL_MODE_DIRECTORY))
-    {
-        LogInfo("Whether widget policy allow proceed ok");
+    if (!!update.existingVersion ||
+            m_installerContext.mode.extension ==
+            InstallMode::ExtensionType::DIR) {
         return ConfigureResult::Updated;
-    } else {
-        return ConfigureResult::Failed_LowerVersion;
     }
 
     return ConfigureResult::Failed;
 }
 
-bool JobWidgetInstall::isUpperVersion(
-    const OptionalWidgetVersion &existingVersion,
-    const OptionalWidgetVersion &incomingVersion)
-{
-    LogInfo("Existing version = '" << *existingVersion);
-    LogInfo("Incoming version = '" << *incomingVersion);
-
-    if (!existingVersion && !incomingVersion) {
-        return false;
-    } else if (!existingVersion && !!incomingVersion) {
-        return false;
-    } else if (!!existingVersion && !incomingVersion) {
-        return true;
-    } else {
-        if (!existingVersion->IsWac() || !incomingVersion->IsWac()) {
-            return false;
-        } else {
-            if (*incomingVersion == *existingVersion) {
-                return false;
-            } else if (*incomingVersion > *existingVersion) {
-                return true;
-            } else {
-                return false;
-            }
-        }
-    }
-}
-
 ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
     const std::string &widgetSource,
     const std::string &tempPath,
@@ -991,9 +945,7 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType(
     const std::string &tempPath)
 {
     // Check installation type (direcotory/ or config.xml or widget.wgt)
-    if (m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_DIRECTORY ||
-         m_jobStruct.m_installMode == InstallMode::REINSTALL_MODE_DIRECTORY)
-    {
+    if (m_installerContext.mode.extension == InstallMode::ExtensionType::DIR) {
         LogDebug("Install directly from directory");
         return PKG_TYPE_DIRECTORY_WEB_APP;
     }
@@ -1123,18 +1075,11 @@ bool JobWidgetInstall::detectResourceEncryption(
 }
 
 void JobWidgetInstall::setInstallLocationType(
-    const
-    WrtDB::ConfigParserData &
-    configData)
+    const WrtDB::ConfigParserData & configData)
 {
     m_installerContext.locationType = INSTALL_LOCATION_TYPE_NOMAL;
-
-    if (m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_PRELOAD) {
-        m_installerContext.locationType =
-            INSTALL_LOCATION_TYPE_PRELOAD;
-    } else {
-        FOREACH(it, configData.settingsList)
-        {
+    if (m_installerContext.mode.installTime != InstallMode::InstallTime::PRELOAD) {
+        FOREACH(it, configData.settingsList) {
             if (it->m_name == SETTING_VALUE_INSTALLTOEXT_NAME &&
                 it->m_value ==
                 SETTING_VALUE_INSTALLTOEXT_PREPER_EXT)
index f0af6f2..549c80d 100644 (file)
@@ -79,9 +79,6 @@ class JobWidgetInstall :
     static WidgetUpdateInfo detectWidgetUpdate(
         const WrtDB::ConfigParserData &configInfo,
         const WrtDB::TizenAppId &tizenId);
-    bool isUpperVersion(
-        const OptionalWidgetVersion &existingVersion,
-        const OptionalWidgetVersion &incomingVersion);
     void setTizenId(const WrtDB::ConfigParserData &configInfo);
     void displayWidgetInfo();
     void configureWidgetLocation(const std::string & widgetPath,
index b8e4c70..b3d7e4a 100644 (file)
@@ -76,9 +76,7 @@ void TaskAceCheck::StepAceCheck()
     ace_policy_result_t policyResult = ACE_DENY;
 
     //TODO: remove dao.getHandle()
-    if (m_context.job->getInstallerStruct().m_installMode
-            == InstallMode::INSTALL_MODE_PRELOAD)
-    {
+    if (m_context.mode.installTime == InstallMode::InstallTime::PRELOAD) {
         LogDebug("This widget is prealoaded. So ace check will be skiped");
         policyResult = ACE_PERMIT;
     } else {
@@ -189,7 +187,7 @@ void TaskAceCheck::StepCheckAceResponse()
     if (m_context.featureLogic->isRejected()) {
         LogError("Installation failure. Some devCap was not accepted by ACE.");
         ThrowMsg(
-            Exceptions::AceCheckFailed,
+            Exceptions::PrivilegeLevelViolation,
             "Instalation failure. "
             "Some deviceCap was not accepted by ACE.");
     }
index 128f022..edf9f1d 100644 (file)
@@ -253,13 +253,9 @@ void TaskCertify::stepSignature()
 
             result = validator.check(data, widgetPath);
 
-            if (m_contextData.widgetConfig.packagingType
-                == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP ||
-               m_contextData.job->getInstallerStruct().m_installMode
-               == InstallMode::INSTALL_MODE_PRELOAD)
+            if (m_contextData.mode.installTime
+                ==  InstallMode::InstallTime::PRELOAD)
             {
-                // In directory installation mode, the validation is skipped.
-
                 result = WrtSignatureValidator::SIGNATURE_VERIFIED;
             }
 
index c87541d..caf9660 100644 (file)
@@ -28,7 +28,7 @@ namespace Jobs {
 namespace WidgetInstall {
 //TODO make directory like jobs common?
 
-std::string createTempPath(bool preload = false);
+std::string createTempPath(bool isReadOnly = false);
 void createTempPath(const std::string& path);
 } // WidgetInstall
 } // Jobs
index 0258359..a7b405b 100644 (file)
@@ -65,6 +65,7 @@ TaskDatabase::TaskDatabase(InstallerContext& context) :
     AddStep(&TaskDatabase::StepLiveboxDBInsert);
 
     AddAbortStep(&TaskDatabase::StepAbortDBInsert);
+    AddAbortStep(&TaskDatabase::StepAbortAceDBInsert);
 }
 
 void TaskDatabase::StepWrtDBInsert()
@@ -80,6 +81,11 @@ void TaskDatabase::StepWrtDBInsert()
             {
                 m_handleToRemove = WidgetDAOReadOnly::getHandle(
                         m_context.widgetConfig.tzAppid);
+
+                std::string makeAppid =
+                    DPL::ToUTF8String(m_context.widgetConfig.tzAppid) + "." +
+                    "backup";
+                m_backAppId = DPL::FromUTF8String(makeAppid);
             }
             Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
             {
@@ -88,7 +94,9 @@ void TaskDatabase::StepWrtDBInsert()
                 ThrowMsg(Exceptions::DatabaseFailure,
                          "Given tizenId not found for update installation");
             }
-            WidgetDAO::registerOrUpdateWidget(
+
+            WidgetDAO::backupAndUpdateWidget(
+                m_backAppId,
                 m_context.widgetConfig.tzAppid,
                 m_context.widgetConfig,
                 m_context.wacSecurity);
@@ -255,6 +263,9 @@ void TaskDatabase::StepCreateVconf()
         WrtDB::VconfConfig::GetVconfKeyWebNotificationUsage(
             m_context.widgetConfig.tzAppid)] = WrtDB::SETTINGS_TYPE_ON;
     vconfData[
+        WrtDB::VconfConfig::GetVconfKeyWebDatabaseUsage(
+            m_context.widgetConfig.tzAppid)] = WrtDB::SETTINGS_TYPE_ON;
+    vconfData[
         WrtDB::VconfConfig::GetVconfKeyMemorySavingMode(
             m_context.widgetConfig.tzAppid)] = WrtDB::SETTINGS_TYPE_OFF;
 
@@ -280,13 +291,19 @@ void TaskDatabase::StepAbortDBInsert()
     LogWarning("[DB Update Task] Aborting... (DB Clean)");
     Try
     {
-        WidgetDAO::unregisterWidget(m_context.widgetConfig.tzAppid);
+        WidgetDAO::restoreUpdateWidget(m_backAppId,
+                m_context.widgetConfig.tzAppid);
         LogDebug("Cleaning DB successful!");
     }
     Catch(DPL::DB::SqlConnection::Exception::Base)
     {
         LogError("Failed to handle StepAbortDBClean!");
     }
+}
+
+void TaskDatabase::StepAbortAceDBInsert()
+{
+    LogWarning("[DB Update Task] ACE DB Aborting... (DB Clean)");
 
     ace_unregister_widget(static_cast<ace_widget_handle_t>(m_handle));
     // Remove also old one. If it was already updated nothing wrong will happen,
@@ -294,6 +311,12 @@ void TaskDatabase::StepAbortDBInsert()
     if (INVALID_WIDGET_HANDLE != m_handleToRemove) {
         ace_unregister_widget(static_cast<ace_widget_handle_t>(m_handle));
     }
+
+    if (!AceApi::registerAceWidgetFromDB(m_handleToRemove))
+    {
+        LogError("ace database restore failed");
+    }
+    LogDebug("Ace data inserted");
 }
 
 void TaskDatabase::StepLiveboxDBInsert()
index 3e0beba..88d99e9 100644 (file)
@@ -43,6 +43,7 @@ class TaskDatabase :
     //of widget handle
     WrtDB::DbWidgetHandle m_handleToRemove;
     WrtDB::DbWidgetHandle m_handle;
+    WrtDB::TizenAppId m_backAppId;
 
     void StepRegisterExternalFiles();
     void StepWrtDBInsert();
@@ -53,6 +54,7 @@ class TaskDatabase :
     void StepLiveboxDBInsert();
 
     void StepAbortDBInsert();
+    void StepAbortAceDBInsert();
 
   public:
     TaskDatabase(InstallerContext& context);
index 4e25780..e32607b 100644 (file)
@@ -26,6 +26,7 @@
 #include <widget_install/job_widget_install.h>
 #include <widget_install/widget_install_errors.h>
 #include <widget_install/widget_install_context.h>
+#include <widget_install/directory_api.h>
 #include <dpl/utils/wrt_utility.h>
 #include <dpl/foreach.h>
 #include <dpl/log/log.h>
@@ -149,13 +150,13 @@ TaskFileManipulation::TaskFileManipulation(InstallerContext& context) :
             m_context.locationType)
     {
         AddStep(&TaskFileManipulation::StepCreateDirs);
-        AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir);
         if (m_context.widgetConfig.packagingType !=
             WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
         {
             AddStep(&TaskFileManipulation::StepRenamePath);
             AddAbortStep(&TaskFileManipulation::StepAbortRenamePath);
         }
+        AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir);
         AddStep(&TaskFileManipulation::StepLinkForPreload);
 
     } else {
@@ -186,9 +187,7 @@ void TaskFileManipulation::StepCreateDirs()
         LogDebug("Create resource directory");
         WrtUtilMakeDir(widgetBinPath);
         WrtUtilMakeDir(widgetSrcPath);
-        if (m_context.job->getInstallerStruct().m_installMode
-                == InstallMode::INSTALL_MODE_PRELOAD)
-        {
+        if (m_context.mode.installTime == InstallMode::InstallTime::PRELOAD) {
             std::string userWidgetDir = m_context.locations->getUserDataRootDir();
             WrtUtilMakeDir(userWidgetDir);
         }
@@ -204,6 +203,17 @@ void TaskFileManipulation::StepCreatePrivateStorageDir()
     std::string storagePath = m_context.locations->getPrivateStorageDir();
     LogDebug("Create private storage directory : " <<
             m_context.locations->getPrivateStorageDir());
+
+    if (m_context.isUpdateMode) { //update
+        std::string backData = m_context.locations->getBackupPrivateDir();
+        LogDebug("copy private storage " << backData << " to " << storagePath);
+        WrtUtilMakeDir(storagePath);
+        if (!DirectoryApi::DirectoryCopy(backData, storagePath)) {
+            LogError("Failed to rename " << backData << " to " << storagePath);
+            ThrowMsg(Exceptions::BackupFailed,
+                    "Error occurs copy private strage files");
+        }
+    }
     changeOwnerForDirectory(storagePath);
 }
 
@@ -236,9 +246,7 @@ void TaskFileManipulation::StepRenamePath()
 
 void TaskFileManipulation::StepLinkForPreload()
 {
-    if (m_context.job->getInstallerStruct().m_installMode
-            == InstallMode::INSTALL_MODE_PRELOAD)
-    {
+    if (m_context.mode.rootPath == InstallMode::RootPath::RO) {
         std::string srcDir = m_context.locations->getUserDataRootDir() +
             WrtDB::GlobalConfig::GetWidgetSrcPath();
 
index 7909c26..30c8101 100644 (file)
@@ -24,6 +24,9 @@
 #include <unistd.h>
 #include <string>
 
+#include <pkgmgr/pkgmgr_parser.h>
+#include <pkgmgr-info.h>
+#include <fstream>
 #include <dpl/log/log.h>
 #include <dpl/errno_string.h>
 #include <dpl/foreach.h>
@@ -48,6 +51,7 @@ TaskInstallOspsvc::TaskInstallOspsvc(InstallerContext& context) :
     m_context(context)
 {
     AddStep(&TaskInstallOspsvc::StepInstallOspService);
+    AddStep(&TaskInstallOspsvc::StepUpdateManifestFile);
 }
 
 void TaskInstallOspsvc::StepInstallOspService()
@@ -93,5 +97,39 @@ void TaskInstallOspsvc::StepInstallOspService()
         InstallerContext::INSTALL_INSTALL_OSPSVC,
         "Installed Osp servcie");
 }
+
+void TaskInstallOspsvc::StepUpdateManifestFile()
+{
+    std::string pkgid = DPL::ToUTF8String(m_context.widgetConfig.tzPkgid);
+    pkgmgrinfo_pkginfo_h handle;
+
+    int ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid.c_str(), &handle);
+    if (ret != PMINFO_R_OK) {
+        LogDebug("StepUpdateManifestFile");
+        std::ostringstream manifest_file;
+        if (m_context.mode.rootPath == InstallMode::RootPath::RO) {
+            manifest_file << "/usr/share/packages/"; //TODO constant with path
+        } else {
+            manifest_file << "/opt/share/packages/"; //TODO constant with path
+        }
+        manifest_file << pkgid;
+        manifest_file << ".xml";
+        LogDebug("manifest file : " << manifest_file.str());
+
+        int ret = pkgmgr_parser_parse_manifest_for_uninstallation(
+                manifest_file.str().c_str(), NULL);
+
+        if (ret != 0) {
+            LogError("Manifest parser error: " << ret);
+        }
+
+        int code = pkgmgr_parser_parse_manifest_for_installation(
+                manifest_file.str().c_str(), NULL);
+
+        if (code != 0) {
+            LogError("Manifest parser error: " << code);
+        }
+    }
+}
 } //namespace WidgetInstall
 } //namespace Jobs
index 445bfb4..819a1b0 100644 (file)
@@ -36,6 +36,7 @@ class TaskInstallOspsvc : public DPL::TaskDecl<TaskInstallOspsvc>
     InstallerContext &m_context;
 
     void StepInstallOspService();
+    void StepUpdateManifestFile();
 
     void StepAbortInstall();
 
index 7074609..7c3e165 100644 (file)
@@ -111,6 +111,7 @@ TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
         // for widget update.
         AddStep(&TaskManifestFile::stepBackupIconFiles);
         AddStep(&TaskManifestFile::stepCopyIconFiles);
+        AddStep(&TaskManifestFile::stepCreateExecFile);
         AddStep(&TaskManifestFile::stepGenerateManifest);
         AddStep(&TaskManifestFile::stepParseUpgradedManifest);
         AddStep(&TaskManifestFile::stepUpdateFinalize);
@@ -307,8 +308,7 @@ void TaskManifestFile::stepBackupIconFiles()
 {
     LogDebug("Backup Icon Files");
 
-    backup_dir << m_context.locations->getPackageInstallationDir();
-    backup_dir << "/" << "backup" << "/";
+    backup_dir << m_context.locations->getBackupDir() << "/";
 
     backupIconFiles();
 
@@ -544,18 +544,22 @@ void TaskManifestFile::stepParseManifest()
 
 void TaskManifestFile::stepParseUpgradedManifest()
 {
-    int code = pkgmgr_parser_parse_manifest_for_upgrade(
-            DPL::ToUTF8String(manifest_file).c_str(), NULL);
+    if (m_context.widgetConfig.packagingType !=
+            PKG_TYPE_HYBRID_WEB_APP)
+    {
+        int code = pkgmgr_parser_parse_manifest_for_upgrade(
+                DPL::ToUTF8String(manifest_file).c_str(), NULL);
 
-    if (code != 0) {
-        LogError("Manifest parser error: " << code);
-        ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
-    }
+        if (code != 0) {
+            LogError("Manifest parser error: " << code);
+            ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
+        }
 
-    m_context.job->UpdateProgress(
-        InstallerContext::INSTALL_CREATE_MANIFEST,
-        "Widget Manifest Parsing Finished");
-    LogDebug("Manifest parsed");
+        m_context.job->UpdateProgress(
+                InstallerContext::INSTALL_CREATE_MANIFEST,
+                "Widget Manifest Parsing Finished");
+        LogDebug("Manifest parsed");
+    }
 }
 
 void TaskManifestFile::commitManifest()
@@ -563,9 +567,7 @@ void TaskManifestFile::commitManifest()
     LogDebug("Commiting manifest file : " << manifest_file);
 
     std::ostringstream destFile;
-    if (m_context.job->getInstallerStruct().m_installMode
-            == InstallMode::INSTALL_MODE_PRELOAD)
-    {
+    if (m_context.mode.rootPath == InstallMode::RootPath::RO) {
         destFile << "/usr/share/packages" << "/"; //TODO constant with path
     } else {
         destFile << "/opt/share/packages" << "/"; //TODO constant with path
index 0e6bdc4..20a209c 100644 (file)
@@ -45,7 +45,7 @@ std::list<std::string> keyList = {KEY_DELETE, KEY_ADD, KEY_MODIFY};
 void verifyFile(const std::string &filePath)
 {
     if (access(filePath.c_str(), F_OK) != 0) {
-        ThrowMsg(Exceptions::AceCheckFailed, "File is missed " << filePath);
+        ThrowMsg(Exceptions::RDSDeltaFailure, "File is missed " << filePath);
     }
 }
 }
index 8841739..47e9cf4 100644 (file)
@@ -29,6 +29,7 @@
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
 #include <dpl/utils/wrt_utility.h>
+#include <dpl/wrt-dao-rw/widget_dao.h>
 #include <widget_install/job_widget_install.h>
 #include <widget_install/widget_install_errors.h>
 #include <widget_install/widget_install_context.h>
@@ -41,7 +42,12 @@ TaskRemoveBackupFiles::TaskRemoveBackupFiles(InstallerContext& context) :
     DPL::TaskDecl<TaskRemoveBackupFiles>(this),
     m_context(context)
 {
-    AddStep(&TaskRemoveBackupFiles::StepRemoveBackupFiles);
+    if (m_context.widgetConfig.packagingType !=
+            WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
+    {
+        AddStep(&TaskRemoveBackupFiles::StepRemoveBackupFiles);
+    }
+    AddStep(&TaskRemoveBackupFiles::StepDeleteBackupDB);
 }
 
 void TaskRemoveBackupFiles::StepRemoveBackupFiles()
@@ -62,13 +68,24 @@ void TaskRemoveBackupFiles::StepRemoveBackupFiles()
         LogDebug("Success to remove temp directory : " << tmp);
     } else {
         LogError("Failed to remove temp directory : " << tmp);
-        ThrowMsg(Exceptions::RemoveBackupFailed,
-                 "Error occurs during removing existing folder");
     }
+}
 
-    m_context.job->UpdateProgress(
-        InstallerContext::INSTALL_REMOVE_BACKUP_FILE,
-        "Backup widget file delete Finished");
+void TaskRemoveBackupFiles::StepDeleteBackupDB()
+{
+    LogDebug("StepDeleteBackupDB");
+    std::string oldAppid =
+        DPL::ToUTF8String(m_context.widgetConfig.tzAppid) + ".backup";
+
+    Try
+    {
+        WidgetDAO::unregisterWidget(DPL::FromUTF8String(oldAppid));
+    }
+    Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
+    {
+        LogError("Fail to delete old version db information");
+    }
 }
+
 } //namespace WidgetInstall
 } //namespace Jobs
index d269435..777f988 100644 (file)
@@ -35,6 +35,7 @@ class TaskRemoveBackupFiles :
     InstallerContext& m_context;
 
     void StepRemoveBackupFiles();
+    void StepDeleteBackupDB();
 
   public:
     TaskRemoveBackupFiles(InstallerContext& context);
index a5624a9..9857bf7 100644 (file)
@@ -35,7 +35,9 @@
 
 namespace {
 const int MAX_BUF_SIZE = 128;
+#ifdef WRT_SMACK_ENABLED
 const char* SMACK_RULE_STR = "/usr/bin/smackload-app.sh";
+#endif
 }
 
 namespace Jobs {
@@ -131,9 +133,7 @@ void TaskSmack::SmackPrivilegeStep()
     const char* perm_list[0];
     perm_list[0] = NULL;
 #endif
-    if (m_context.job->getInstallerStruct().m_installMode
-            != InstallMode::INSTALL_MODE_PRELOAD)
-    {
+    if (m_context.mode.installTime != InstallMode::InstallTime::PRELOAD) {
         int result = app_add_permissions(
                 DPL::ToUTF8String(tzPkgid).c_str(), perm_list);
         if (PC_OPERATION_SUCCESS != result) {
@@ -175,7 +175,7 @@ void TaskSmack::SmackTemporaryStep()
 #endif
 }
 
-void TaskSmack::SetEndofInstallation() 
+void TaskSmack::SetEndofInstallation()
 {
     m_context.job->UpdateProgress(
         InstallerContext::INSTALL_END,
index eeecb86..69b7053 100644 (file)
@@ -37,6 +37,7 @@
 #include <widget_install/widget_install_context.h>
 #include <widget_install/widget_install_errors.h>
 #include <widget_install/job_widget_install.h>
+#include <widget_install/directory_api.h>
 
 #include <dpl/wrt-dao-ro/global_config.h>
 #include <dpl/exception.h>
@@ -57,258 +58,48 @@ TaskUpdateFiles::TaskUpdateFiles(InstallerContext& context) :
     DPL::TaskDecl<TaskUpdateFiles>(this),
     m_context(context)
 {
-    AddStep(&TaskUpdateFiles::StepCreateBackupFolder);
-    AddStep(&TaskUpdateFiles::StepResourceFilesBackup);
-    AddStep(&TaskUpdateFiles::StepExecFileBackup);
+    AddStep(&TaskUpdateFiles::StepBackupDirectory);
 
-    AddAbortStep(&TaskUpdateFiles::StepAbortCreateBackupFolder);
-    AddAbortStep(&TaskUpdateFiles::StepAbortExecFileBackup);
-    AddAbortStep(&TaskUpdateFiles::StepAbortResourceFilesBackup);
+    AddAbortStep(&TaskUpdateFiles::StepAbortBackupDirectory);
 }
 
-void TaskUpdateFiles::StepCreateBackupFolder()
+void TaskUpdateFiles::StepBackupDirectory()
 {
     LogDebug("StepCreateBackupFolder");
 
-    std::string srcBuPath = m_context.locations->getBackupSourceDir();
-    LogDebug("backup resource directory path : " << srcBuPath);
-    if (!WrtUtilMakeDir(srcBuPath)) {
-        ThrowMsg(
-            Exceptions::BackupFailed,
-            "Error occurs during create \
-                backup directory.");
-    }
-
-    std::string binBuPath = m_context.locations->getBackupBinaryDir();
-    LogDebug("backup execution directory path : " << binBuPath);
-    if (!WrtUtilMakeDir(binBuPath)) {
-        ThrowMsg(
-            Exceptions::BackupFailed,
-            "Error occurs during create backup \
-                directory.");
-    }
-
-    m_context.job->UpdateProgress(
-        InstallerContext::INSTALL_CREATE_BACKUP_DIR,
-        "Backup directory created for update");
-}
-
-void TaskUpdateFiles::ReadDirList(std::string dirPath, ExistFileList &list,
-                                  size_t subLen)
-{
-    DIR* pkgDir = opendir(dirPath.c_str());
-    if (!pkgDir) {
-        LogError("Package directory " << dirPath << " doesn't exist");
-        ThrowMsg(Exceptions::BackupFailed,
-                 "Error occurs during read \
-                directory");
-    }
-
-    struct stat statInfo;
-    struct dirent dirent;
-    struct dirent *result;
-    int return_code;
-    errno = 0;
-    for (return_code = readdir_r(pkgDir, &dirent, &result);
-            result != NULL && return_code == 0;
-            return_code = readdir_r(pkgDir, &dirent, &result))
-    {
-        std::string dirName = dirent.d_name;
-        std::string absFileName = dirPath + "/" + dirName;
-        if (stat(absFileName.c_str(), &statInfo) != 0) {
-            ThrowMsg(Exceptions::BackupFailed, "Error occurs read file");
-        }
-
-        if (S_ISDIR(statInfo.st_mode)) {
-            if (strcmp(dirent.d_name, ".") == 0 || strcmp(dirent.d_name,
-                                                           "..") == 0)
-            {
-                continue;
-            }
-            ReadDirList(absFileName, list, subLen);
-        }
-
-        list.insert(absFileName.substr(subLen));
-    }
-    if (return_code != 0 || errno != 0) {
-        LogError("readdir_r() failed with " << DPL::GetErrnoString());
-    }
-    errno = 0;
-    //closing the directory
-    if (-1 == TEMP_FAILURE_RETRY(closedir(pkgDir))) {
-        LogError("Failed to close dir: " << dirPath << " with error: "
-                                         << DPL::GetErrnoString());
-    }
-}
-
-void TaskUpdateFiles::StepResourceFilesBackup()
-{
-    LogDebug("StepCopyFiles");
-
-    ExistFileList resList;
-    ExistFileList tempList;
-
-    std::string pkgSrc = m_context.locations->getSourceDir();
-    ReadDirList(pkgSrc, resList, strlen(pkgSrc.c_str()) + 1);
-
-    std::string tempSrc = m_context.locations->getTemporaryPackageDir();
-    ReadDirList(tempSrc, tempList, strlen(tempSrc.c_str()) + 1);
-
-    FOREACH(it, tempList) {
-        std::set<std::string>::iterator res;
-        res = resList.find(*it);
-        std::string resFile = pkgSrc + "/" + (*it);
-        std::string newFile = tempSrc + "/" + (*it);
-
-        if (res != resList.end()) {
-            std::string backupFile =
-                m_context.locations->getBackupSourceDir() +
-                "/" + (*it);
-
-            struct stat sInfo;
-            if (stat(resFile.c_str(), &sInfo) != 0) {
-                ThrowMsg(Exceptions::BackupFailed, "Error occurs read file");
-            }
-
-            if (S_ISDIR(sInfo.st_mode)) {
-                LogDebug(resFile << " is a directory. so create a folder : " <<
-                         backupFile);
-                WrtUtilMakeDir(backupFile);
-            } else {
-                if ((rename(resFile.c_str(), backupFile.c_str())) != 0) {
-                    LogError(
-                        "Failed to rename " << resFile << " to " <<
-                        backupFile);
-                    ThrowMsg(
-                        Exceptions::BackupFailed,
-                        "Error occurs during \
-                            rename file");
-                }
-
-                LogDebug("backup : " << resFile << " to " << backupFile);
+    std::string backPath = m_context.locations->getBackupDir();
+    LogDebug("backup resource directory path : " << backPath);
+    std::string pkgPath = m_context.locations->getPackageInstallationDir();
 
-                if ((rename(newFile.c_str(), resFile.c_str())) != 0) {
-                    LogError(
-                        "Failed to rename " << newFile << " to " << resFile);
-                    ThrowMsg(
-                        Exceptions::BackupFailed,
-                        "Error occurs during \
-                            rename file");
-                }
-                LogDebug("copy : " << newFile << " to " << resFile);
-            }
-            resList.erase(res);
-        } else {
-            if ((rename(newFile.c_str(), resFile.c_str())) != 0) {
-                LogError("Failed to rename " << newFile << " to " << resFile);
-                ThrowMsg(
-                    Exceptions::BackupFailed,
-                    "Error occurs during \
-                        rename file");
-            }
-            LogDebug("only copy : " << newFile << " to " << resFile);
-        }
-    }
-
-    if (resList.empty() != 0) {
-        FOREACH(remain, resList) {
-            std::string pkgFile = pkgSrc + "/" + (*remain);
-            std::string backFile = tempSrc + "/" + (*remain);
-            if ((rename(pkgFile.c_str(), backFile.c_str())) != 0) {
-                LogError("Failed to backup : " << pkgFile << " to " << backFile);
-                ThrowMsg(
-                    Exceptions::BackupFailed,
-                    "Error occurs during \
-                        rename file");
-            }
-            LogDebug("only backup : " << pkgFile << " to " << backFile);
-        }
-    }
-
-    m_context.job->UpdateProgress(
-        InstallerContext::INSTALL_BACKUP_RES_FILES,
-        "Backup resource file for update");
-}
-
-void TaskUpdateFiles::StepExecFileBackup()
-{
-    std::string execFile = m_context.locations->getExecFile();
-
-    LogDebug(" source : " << execFile);
-
-    std::string tempSource = m_context.locations->getBackupExecFile();
-    LogDebug(" source : " << tempSource);
-
-    if ((rename(execFile.c_str(), tempSource.c_str())) != 0) {
-        LogError("Failed to rename " << execFile << " to " <<
-                 tempSource);
+    LogDebug("copy : " << pkgPath << " to " << backPath);
+    if ((rename(pkgPath.c_str(), backPath.c_str())) != 0) {
+        LogError("Failed to rename " << pkgPath << " to " << backPath);
         ThrowMsg(Exceptions::BackupFailed,
-                 "Error occurs during \
-                rename file");
+                "Error occurs during rename file");
     }
-    LogDebug("Backup : " << execFile << " to " << tempSource);
 
-    std::string clientPath = GlobalConfig::GetWrtClientExec();
+    WrtUtilMakeDir(pkgPath);
 
-    LogInfo("link -s " << clientPath << " " << execFile);
-
-    errno = 0;
-    if( symlink(clientPath.c_str(), execFile.c_str()) != 0 )
-    {
-        int error = errno;
-        if(error)
-            LogPedantic("Failed to make a symbolic name for a file "
-                    << "[" <<  DPL::GetErrnoString(error) << "]");
-        ThrowMsg(Exceptions::BackupFailed,
-                "Error occurs during rename file");
-    }
     m_context.job->UpdateProgress(
-        InstallerContext::INSTALL_BACKUP_EXEC,
-        "Backup execution file for update");
+        InstallerContext::INSTALL_CREATE_BACKUP_DIR,
+        "Backup directory created for update");
 }
 
-void TaskUpdateFiles::StepAbortResourceFilesBackup()
+void TaskUpdateFiles::StepAbortBackupDirectory()
 {
     LogDebug("StepAbortCopyFiles");
-    std::string srcPath = m_context.locations->getSourceDir();
-    std::string srcBuPath = m_context.locations->getBackupSourceDir();
-
-    LogDebug("Backup Folder " << srcBuPath << " to " << srcPath);
-
-    if (!WrtUtilRemove(srcPath)) {
-        LogError("Failed to remove " << srcPath);
-    }
-
-    if (rename(srcBuPath.c_str(), srcPath.c_str()) != 0) {
-        LogError("Failed to rename " << srcBuPath << " to " << srcPath);
-    }
-}
 
-void TaskUpdateFiles::StepAbortExecFileBackup()
-{
-    LogDebug("StepAbortExecFileBackup");
-    std::string binPath = m_context.locations->getBinaryDir();
+    std::string backPath = m_context.locations->getBackupDir();
+    std::string pkgPath = m_context.locations->getPackageInstallationDir();
 
-    if (!WrtUtilRemove(binPath)) {
-        LogError("Failed to remove " << binPath);
-    }
+    LogDebug("Backup Folder " << backPath << " to " << pkgPath);
 
-    std::string binBuPath = m_context.locations->getBackupBinaryDir();
-    if (rename(binBuPath.c_str(), binPath.c_str()) != 0) {
-        LogError("Failed to rename " << binBuPath << " to " << binPath);
+    if (!WrtUtilRemove(pkgPath)) {
+        LogError("Failed to remove " << pkgPath);
     }
-    LogDebug("Backup Folder " << binBuPath << "move to " << binPath);
-}
-
-void TaskUpdateFiles::StepAbortCreateBackupFolder()
-{
-    LogDebug("StepAbortCreateBackupFolder");
-    std::ostringstream path;
-    path << m_context.locations->getBackupDir();
-    LogDebug("Remove backup directory : " << path.str());
 
-    if (!WrtUtilRemove(path.str())) {
-        LogError("Failed to remove " << path);
+    if (rename(backPath.c_str(), pkgPath.c_str()) != 0) {
+        LogError("Failed to rename " << backPath << " to " << pkgPath);
     }
 }
 } //namespace WidgetInstall
index b95e5c9..4161b13 100644 (file)
@@ -40,16 +40,9 @@ class TaskUpdateFiles :
   private:
     InstallerContext& m_context;
 
-    /* TODO : md5 check */
-    void StepCreateBackupFolder();
-    void StepResourceFilesBackup();
-    void StepExecFileBackup();
+    void StepBackupDirectory();
 
-    void ReadDirList(std::string dirPath, ExistFileList &list, size_t subLen);
-
-    void StepAbortResourceFilesBackup();
-    void StepAbortCreateBackupFolder();
-    void StepAbortExecFileBackup();
+    void StepAbortBackupDirectory();
 
   public:
     TaskUpdateFiles(InstallerContext& context);
index bd96390..a981670 100644 (file)
@@ -30,6 +30,7 @@
 #include <feature_logic.h>
 #include <widget_install/widget_update_info.h>
 #include <widget_location.h>
+#include <wrt_install_mode.h>
 
 namespace Jobs {
 namespace WidgetInstall {
@@ -100,6 +101,7 @@ struct InstallerContext
     std::string installInfo;            ///<For recovery>
     InstallLocationType locationType;
     bool isUpdateMode;
+    InstallMode mode;
 };
 
 #endif // INSTALLER_CONTEXT_H
index 6464504..9e3f8c9 100644 (file)
@@ -88,6 +88,7 @@ DECLARE_JOB_EXCEPTION(Base, PackageAlreadyInstalled, ErrorPackageAlreadyInstalle
 DECLARE_JOB_EXCEPTION(Base, AceCheckFailed, ErrorAceCheckFailed)
 DECLARE_JOB_EXCEPTION(Base, EncryptionFailed, ErrorEncryptionFailed)
 DECLARE_JOB_EXCEPTION(Base, InstallOspsvcFailed, ErrorInstallOspServcie)
+DECLARE_JOB_EXCEPTION(Base, PrivilegeLevelViolation, ErrorPrivilegeLevelViolation)
 } //namespace
 } //namespace
 } //namespace
index 0ebe48a..6f0c176 100644 (file)
@@ -30,6 +30,7 @@
 #include <job_base.h>
 #include <job.h>
 #include <widget_install/widget_install_errors.h>
+#include <wrt_install_mode.h>
 #include <wrt_common_types.h>
 #include <pkgmgr_signal_interface.h>
 #include <memory>
@@ -45,17 +46,6 @@ typedef void (*InstallerProgressCallback)(void *userParam,
                                           ProgressPercent percent,
                                           const ProgressDescription &);
 
-namespace InstallMode {
-enum Type
-{
-    WRONG_INSTALL_MODE = -1,
-    INSTALL_MODE_WGT,
-    INSTALL_MODE_DIRECTORY,
-    INSTALL_MODE_PRELOAD,
-    REINSTALL_MODE_DIRECTORY
-};
-}
-
 //TODO into namespace
 //InstallationStruct
 typedef Jobs::JobCallbacksBase<InstallerFinishedCallback,
@@ -65,19 +55,16 @@ WidgetInstallCallbackBase;
 //Widget Installation Struct
 struct WidgetInstallationStruct : public WidgetInstallCallbackBase
 {
-    InstallMode::Type m_installMode;
+    InstallMode m_installMode;
     std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrInterface;
 
     // It must be empty-constructible as a parameter of generic event
-    WidgetInstallationStruct() :
-        m_installMode(InstallMode::Type::INSTALL_MODE_WGT)
-    {}
-
+    WidgetInstallationStruct() {};
     WidgetInstallationStruct(
         InstallerFinishedCallback finished,
         InstallerProgressCallback progress,
         void *param,
-        InstallMode::Type mode,
+        InstallMode mode,
         std::shared_ptr<PackageManager::IPkgmgrSignal>
         _pkgmgrInterface
         ) :
index f48751f..adfbd44 100644 (file)
 #include <dpl/log/log.h>
 #include <dpl/sstream.h>
 #include <dpl/localization/localization_utils.h>
-
 #include <widget_install/task_commons.h>
 
-WidgetLocation::DirectoryDeletor::DirectoryDeletor(bool isPreload) :
-    m_dirpath(Jobs::WidgetInstall::createTempPath(isPreload))
+WidgetLocation::DirectoryDeletor::DirectoryDeletor(bool isReadOnly) :
+    m_dirpath(Jobs::WidgetInstall::createTempPath(isReadOnly))
 {}
 
 WidgetLocation::DirectoryDeletor::DirectoryDeletor(std::string tempPath) :
@@ -63,15 +62,14 @@ WidgetLocation::~WidgetLocation()
 WidgetLocation::WidgetLocation(const std::string & widgetname,
                                std::string sourcePath,
                                WrtDB::PackagingType t,
-                               InstallLocationType locationType) :
+                               bool isReadonly) :
     m_pkgid(widgetname),
     m_widgetSource(sourcePath),
     m_type(t),
     m_temp(
-        new WidgetLocation::DirectoryDeletor(
-            INSTALL_LOCATION_TYPE_PRELOAD == locationType))
+        new WidgetLocation::DirectoryDeletor(isReadonly))
 {
-    if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
+    if (isReadonly) {
         m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
     } else {
         m_installedPath += WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
@@ -86,14 +84,13 @@ WidgetLocation::WidgetLocation(const std::string & widgetname,
                                std::string sourcePath,
                                std::string dirPath,
                                WrtDB::PackagingType t,
-                               InstallLocationType locationType) :
+                               bool isReadonly) :
     m_pkgid(widgetname),
     m_widgetSource(sourcePath),
     m_type(t),
-    m_temp(new
-           WidgetLocation::DirectoryDeletor(dirPath))
+    m_temp(new WidgetLocation::DirectoryDeletor(dirPath))
 {
-    if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
+    if (isReadonly) {
         m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
     } else {
         m_installedPath += WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
@@ -140,7 +137,7 @@ std::string WidgetLocation::getExecFile() const
 
 std::string WidgetLocation::getBackupDir() const
 {
-    return getPackageInstallationDir() + "/backup";
+    return getPackageInstallationDir() + ".backup";
 }
 
 std::string WidgetLocation::getBackupSourceDir() const
@@ -158,6 +155,12 @@ std::string WidgetLocation::getBackupExecFile() const
     return getBackupBinaryDir() + "/" + m_appid;
 }
 
+std::string WidgetLocation::getBackupPrivateDir() const
+{
+    return getBackupDir() + "/" +
+        WrtDB::GlobalConfig::GetWidgetPrivateStoragePath();
+}
+
 std::string WidgetLocation::getUserDataRootDir() const
 {
     return std::string(WrtDB::GlobalConfig::GetWidgetUserDataPath()) +
index 07ea234..0cdcbdd 100644 (file)
@@ -101,14 +101,12 @@ class WidgetLocation
      */
     WidgetLocation(const std::string & widgetname, std::string sourcePath,
                    WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
-                   InstallLocationType ltype =
-                       INSTALL_LOCATION_TYPE_NOMAL);
+                   bool isReadonly = false);
 
     WidgetLocation(const std::string & widgetname, std::string sourcePath,
                    std::string dirPath,
                    WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
-                   InstallLocationType ltype =
-                       INSTALL_LOCATION_TYPE_NOMAL);
+                   bool isReadonly = false);
 
     ~WidgetLocation();
 
@@ -119,10 +117,11 @@ class WidgetLocation
     std::string getBinaryDir() const;  // /opt/apps/[package]/bin or /usr/apps/[package]/bin
     std::string getUserBinaryDir() const;  // /opt/apps/[package]/bin
     std::string getExecFile() const;   // /opt/apps/[package]/bin/[package]
-    std::string getBackupDir() const;  // /opt/apps/[package]/backup
-    std::string getBackupSourceDir() const; // /opt/apps/[pkg]/backup/res/wgt
-    std::string getBackupBinaryDir() const; // /opt/apps/[pkg]/backup/bin
-    std::string getBackupExecFile() const;  // /opt/apps/[pkg]/backup/bin/[pkg]
+    std::string getBackupDir() const;  // /opt/apps/[package].backup
+    std::string getBackupSourceDir() const; // /opt/apps/[pkg].backup/res/wgt
+    std::string getBackupBinaryDir() const; // /opt/apps/[pkg].backup/bin
+    std::string getBackupExecFile() const;  // /opt/apps/[pkg].backup/bin/[pkg]
+    std::string getBackupPrivateDir() const;  // /opt/apps/[pkg].backup/data
     std::string getUserDataRootDir() const; // /opt/usr/apps/[package]
     std::string getPrivateStorageDir() const; // /opt/usr/apps/[package]/data
 
index 497bf3f..3786026 100644 (file)
@@ -419,15 +419,16 @@ int getWidgetDetailInfoFromPackage(const char* pkgPath,
                 PKG_VALUE_STRING_LEN_MAX - 1);
     }
 
-    GList *privilege_list = pkg_detail_info->privilege_list;
 
+    pkg_detail_info->privilege_list = NULL;
     FOREACH(it, configInfo.featuresList) {
         std::string featureInfo =  DPL::ToUTF8String(it->name);
         LogDebug("privilege : " << featureInfo);
         int length = featureInfo.size();
         char *privilege = (char*) calloc(1, (sizeof(char) * (length + 1)));
         snprintf(privilege, length + 1, "%s", featureInfo.c_str());
-        privilege_list = g_list_append(privilege_list, &privilege);
+        pkg_detail_info->privilege_list =
+            g_list_append(pkg_detail_info->privilege_list, privilege);
     }
 
     std::string icon_name;
@@ -463,7 +464,7 @@ pkgmgr_info *pkgmgr_client_check_pkginfo_from_file(const char *pkg_path)
         LogError("Failed to get package detail info ");
         return NULL;
     }
-    return &pkg_detail_info;
+    return reinterpret_cast<pkgmgr_info*>(pkg_detail_info);
 }
 
 __attribute__ ((visibility("default")))
index ef479c8..fa1c9f2 100644 (file)
@@ -48,10 +48,18 @@ void installFinishedCallback(void *userParam,
             errorStatus = WRT_INSTALLER_ERROR_PACKAGE_NOT_FOUND;
             break;
 
+        case Jobs::Exceptions::ErrorPackageInvalid:
+            errorStatus = WRT_INSTALLER_ERROR_PACKAGE_INVALID;
+            break;
+
         case Jobs::Exceptions::ErrorPackageLowerVersion:
             errorStatus = WRT_INSTALLER_ERROR_PACKAGE_LOWER_VERSION;
             break;
 
+        case Jobs::Exceptions::ErrorPackageExecutableNotFound:
+            errorStatus = WRT_INSTALLER_ERROR_PACKAGE_EXCUTABLE_NOT_FOUND;
+            break;
+
         case Jobs::Exceptions::ErrorManifestNotFound:
             errorStatus = WRT_INSTALLER_ERROR_MANIFEST_NOT_FOUND;
             break;
@@ -102,6 +110,10 @@ void installFinishedCallback(void *userParam,
             errorStatus = WRT_INSTALLER_ERROR_INVALID_PRIVILEGE;
             break;
 
+        case Jobs::Exceptions::ErrorPrivilegeLevelViolation:
+            errorStatus = WRT_INSTALLER_ERROR_PRIVILEGE_LEVEL_VIOLATION;
+            break;
+
         case Jobs::Exceptions::ErrorMenuIconNotFound:
             errorStatus = WRT_INSTALLER_ERROR_MENU_ICON_NOT_FOUND;
             break;
@@ -118,6 +130,10 @@ void installFinishedCallback(void *userParam,
             errorStatus = WRT_INSTALLER_ERROR_OUT_OF_MEMORY;
             break;
 
+        case Jobs::Exceptions::ErrorArgumentInvalid:
+            errorStatus = WRT_INSTALLER_ERROR_ARGUMENT_INVALID;
+            break;
+
         case Jobs::Exceptions::ErrorPackageAlreadyInstalled:
             errorStatus = WRT_INSTALLER_ERROR_PACKAGE_ALREADY_INSTALLED;
             break;
index 58db8f4..77457f5 100644 (file)
@@ -82,7 +82,6 @@ struct PluginInstallerData
 WrtInstaller::WrtInstaller(int argc, char **argv) :
     Application(argc, argv, "backend", false),
     DPL::TaskDecl<WrtInstaller>(this),
-    m_installMode(WRT_INSTALL_MODE_UNKNOWN),
     m_packagePath(),
     m_initialized(false),
     m_numPluginsToInstall(0),
@@ -175,10 +174,10 @@ void WrtInstaller::OnCreate()
             struct stat info;
             if (-1 != stat(m_argv[2], &info) && S_ISDIR(info.st_mode)) {
                 LogInfo("Installing package directly from directory");
-                m_installMode = WRT_INSTALL_MODE_INSTALL_DIRECTORY;
+                m_installMode.extension = InstallMode::ExtensionType::DIR;
             } else {
                 LogInfo("Installing from regular location");
-                m_installMode = WRT_INSTALL_MODE_INSTALL_WGT;
+                m_installMode.extension = InstallMode::ExtensionType::WGT;
             }
             m_packagePath = m_argv[2];
 
@@ -189,7 +188,17 @@ void WrtInstaller::OnCreate()
                 return showHelpAndQuit();
             }
             m_packagePath = m_argv[2];
-            m_installMode = WRT_INSTALL_MODE_INSTALL_PRELOAD;
+            m_installMode.installTime = InstallMode::InstallTime::PRELOAD;
+            m_installMode.rootPath = InstallMode::RootPath::RO;
+            AddStep(&WrtInstaller::installStep);
+        } else if (arg == "-ipw" || arg == "--install-preload-writable") {
+            LogDebug("Install preload web application to writable storage");
+            if (m_argc != 3) {
+                return showHelpAndQuit();
+            }
+            m_packagePath = m_argv[2];
+            m_installMode.installTime = InstallMode::InstallTime::PRELOAD;
+            m_installMode.rootPath = InstallMode::RootPath::RW;
             AddStep(&WrtInstaller::installStep);
         } else if (arg == "-c" || arg == "--csc-update") {
             // "path=/opt/system/csc/Ozq2iEG15R-2.0.0-arm.wgt:op=install:removable=true"
@@ -208,7 +217,7 @@ void WrtInstaller::OnCreate()
 
             if (it->second == CSCConfiguration::VALUE_INSTALL) {
                 LogDebug("operation = " << it->second);
-                m_installMode = WRT_INSTALL_MODE_INSTALL_WGT;
+                m_installMode.extension = InstallMode::ExtensionType::WGT;
                 it = m_CSCconfigurationMap.find(CSCConfiguration::KEY_PATH);
                 if (it == m_CSCconfigurationMap.end()) {
                     return showHelpAndQuit();
@@ -249,7 +258,8 @@ void WrtInstaller::OnCreate()
                 return showHelpAndQuit();
             }
             LogInfo("Installing package directly from directory");
-            m_installMode = WRT_INSTALL_MODE_REINSTALL;
+            m_installMode.command = InstallMode::Command::REINSTALL;
+            m_installMode.extension = InstallMode::ExtensionType::DIR;
             m_packagePath = m_argv[2];
             AddStep(&WrtInstaller::installStep);
         } else {
@@ -276,10 +286,10 @@ void WrtInstaller::OnCreate()
             struct stat info;
             if (-1 != stat(m_argv[4], &info) && S_ISDIR(info.st_mode)) {
                 LogInfo("Installing package directly from directory");
-                m_installMode = WRT_INSTALL_MODE_INSTALL_DIRECTORY;
+                m_installMode.extension = InstallMode::ExtensionType::DIR;
             } else {
                 LogInfo("Installing from regular location");
-                m_installMode = WRT_INSTALL_MODE_INSTALL_WGT;
+                m_installMode.extension = InstallMode::ExtensionType::WGT;
             }
             AddStep(&WrtInstaller::installStep);
             break;
@@ -289,7 +299,8 @@ void WrtInstaller::OnCreate()
             break;
         case PKGMGR_REQ_REINSTALL:
             m_packagePath = m_argv[4];
-            m_installMode = WRT_INSTALL_MODE_REINSTALL;
+            m_installMode.command = InstallMode::Command::REINSTALL;
+            m_installMode.extension = InstallMode::ExtensionType::DIR;
             AddStep(&WrtInstaller::installStep);
             break;
         default:
@@ -312,8 +323,8 @@ void WrtInstaller::OnReset(bundle* /*b*/)
 void WrtInstaller::OnTerminate()
 {
     LogDebug("Wrt Shutdown now");
-    PluginUtils::unlockPluginInstallation(m_installMode ==
-            WRT_INSTALL_MODE_INSTALL_PRELOAD);
+    PluginUtils::unlockPluginInstallation(
+        m_installMode.installTime == InstallMode::InstallTime::PRELOAD);
     if (m_initialized) {
         wrt_installer_shutdown();
     }
@@ -414,8 +425,9 @@ void WrtInstaller::installPluginsStep()
 
     if (m_startupPluginInstallation) {
         LogInfo("Plugin installation started because new plugin package found");
-    } else if (!PluginUtils::lockPluginInstallation(m_installMode ==
-                WRT_INSTALL_MODE_INSTALL_PRELOAD)) {
+    } else if (!PluginUtils::lockPluginInstallation(
+        m_installMode.installTime == InstallMode::InstallTime::PRELOAD))
+    {
         LogError("Failed to open plugin installation lock file"
                  " Plugins are currently installed by other process");
         staticWrtPluginInstallationCallback(WRT_INSTALLER_ERROR_PLUGIN_INSTALLATION_FAILED,
@@ -745,6 +757,13 @@ void WrtInstaller::staticWrtStatusCallback(std::string tizenId,
                         tizenId.c_str(), printMsg.c_str());
                 break;
 
+            case WRT_INSTALLER_ERROR_PRIVILEGE_LEVEL_VIOLATION:
+                This->m_returnStatus = 1; //this status is specific
+                fprintf(stderr, "## wrt-installer : %s %s has failed - "
+                        "privilege level violation\n",
+                        tizenId.c_str(), printMsg.c_str());
+                break;
+
             case WRT_INSTALLER_ERROR_MENU_ICON_NOT_FOUND:
                 This->m_returnStatus = 1; //this status is specific
                 fprintf(stderr, "## wrt-installer : %s %s has failed - "
@@ -773,6 +792,13 @@ void WrtInstaller::staticWrtStatusCallback(std::string tizenId,
                         tizenId.c_str(), printMsg.c_str());
                 break;
 
+            case WRT_INSTALLER_ERROR_ARGUMENT_INVALID:
+                This->m_returnStatus = 1; //this status is specific
+                fprintf(stderr, "## wrt-installer : %s %s has failed - "
+                        "invalid argument\n",
+                        tizenId.c_str(), printMsg.c_str());
+                break;
+
             case WRT_INSTALLER_ERROR_PACKAGE_ALREADY_INSTALLED:
                 This->m_returnStatus = 1; //this status is specific
                 fprintf(stderr, "## wrt-installer : %s %s has failed - "
@@ -833,8 +859,9 @@ void WrtInstaller::staticWrtStatusCallback(std::string tizenId,
         This->m_returnStatus = 0;
         resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
 
-        if (This->m_installMode == WRT_INSTALL_MODE_INSTALL_PRELOAD &&
-                !This->m_packagePath.empty()) {
+        if (This->m_installMode.installTime == InstallMode::InstallTime::PRELOAD &&
+                !This->m_packagePath.empty())
+        {
             LogDebug("This widget is preloaded so it will be removed : "
                     << This->m_packagePath);
             if (!WrtUtilRemove(This->m_packagePath)) {
@@ -873,8 +900,9 @@ void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
         }
 
         //remove lock file
-        if (!PluginUtils::unlockPluginInstallation(This->m_installMode ==
-                WRT_INSTALL_MODE_INSTALL_PRELOAD)) {
+        if (!PluginUtils::unlockPluginInstallation(
+            This->m_installMode.installTime == InstallMode::InstallTime::PRELOAD))
+        {
             LogInfo("Failed to remove installation lock");
         }
 
@@ -967,16 +995,17 @@ void WrtInstaller::installNewPlugins()
 {
     LogDebug("Install new plugins");
 
-    if (!PluginUtils::lockPluginInstallation(m_installMode ==
-                WRT_INSTALL_MODE_INSTALL_PRELOAD)) {
+    if (!PluginUtils::lockPluginInstallation(
+        m_installMode.installTime == InstallMode::InstallTime::PRELOAD))
+    {
         LogInfo("Lock NOT created");
         return;
     }
 
     if (!PluginUtils::checkPluginInstallationRequired()) {
         LogDebug("Plugin installation not required");
-        PluginUtils::unlockPluginInstallation(m_installMode ==
-            WRT_INSTALL_MODE_INSTALL_PRELOAD);
+        PluginUtils::unlockPluginInstallation(
+            m_installMode.installTime == InstallMode::InstallTime::PRELOAD);
         return;
     }
 
@@ -1010,7 +1039,8 @@ CSCConfiguration::dataMap WrtInstaller::parseCSCConfiguration(
             CSCConfiguration::dataPair(string.substr(0, pos),
                                        string.substr(pos+1)));
     }
-     return result;
+    free(buf);
+    return result;
 }
 
 int main(int argc, char *argv[])
index da75d42..59bcc90 100644 (file)
@@ -29,6 +29,7 @@
 #include <string>
 #include <map>
 #include <wrt_installer_api.h>
+#include <wrt_install_mode.h>
 
 namespace WRTInstallerNS { //anonymous
 DECLARE_GENERIC_EVENT_0(QuitEvent)
@@ -122,7 +123,7 @@ class WrtInstaller :
 
     // Private data
     std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrSignalInterface;
-    WrtInstallMode m_installMode;
+    InstallMode m_installMode;
     std::string m_packagePath;
     std::string m_name;
     bool m_initialized;
index bb84730..83b5172 100644 (file)
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
 #include <vcore/VCore.h>
 #include <installer_main_thread.h>
+#include <wrt_install_mode.h>
 
 using namespace WrtDB;
 
-#ifdef __cplusplus
-
-#define EXPORT_API __attribute__((visibility("default")))
-extern "C"
-{
-#endif
-inline InstallMode::Type translateInstallMode(
-    WrtInstallMode installMode)
-{
-    if (WRT_INSTALL_MODE_INSTALL_WGT == installMode) {
-        return InstallMode::INSTALL_MODE_WGT;
-    } else if (WRT_INSTALL_MODE_INSTALL_DIRECTORY == installMode) {
-        return InstallMode::INSTALL_MODE_DIRECTORY;
-    } else if (WRT_INSTALL_MODE_INSTALL_PRELOAD == installMode) {
-        return InstallMode::INSTALL_MODE_PRELOAD;
-    } else if (WRT_INSTALL_MODE_REINSTALL == installMode) {
-        return InstallMode::REINSTALL_MODE_DIRECTORY;
-    }
-    Assert(true && "wrong argument is inputed");
-    return InstallMode::WRONG_INSTALL_MODE;
-}
-
 static std::string cutOffFileName(const std::string& path)
 {
     size_t found = path.find_last_of("/");
@@ -102,7 +81,7 @@ static bool checkPaths()
     return if_ok;
 }
 
-EXPORT_API void wrt_installer_init(void *userdata,
+void wrt_installer_init(void *userdata,
                                   WrtInstallerInitCallback callback)
 {
     // Set DPL/LOG MID
@@ -164,7 +143,7 @@ EXPORT_API void wrt_installer_init(void *userdata,
     return;
 }
 
-EXPORT_API void wrt_installer_shutdown()
+void wrt_installer_shutdown()
 {
     try {
         LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER...");
@@ -189,19 +168,19 @@ EXPORT_API void wrt_installer_shutdown()
     }
 }
 
-EXPORT_API void wrt_install_widget(
+void wrt_install_widget(
     const char *path,
     void* userdata,
     WrtInstallerStatusCallback status_cb,
     WrtProgressCallback progress_cb,
-    WrtInstallMode installMode,
+    InstallMode installMode,
     std::shared_ptr<PackageManager::
                         IPkgmgrSignal> pkgmgrInterface
     )
 {
     UNHANDLED_EXCEPTION_HANDLER_BEGIN
     {
-        if ( WRT_INSTALL_MODE_INSTALL_PRELOAD == installMode) {
+        if (InstallMode::InstallTime::PRELOAD == installMode.installTime) {
             DPL::Log::OldStyleLogProvider *oldStyleProvider =
                 new DPL::Log::OldStyleLogProvider(false, false, false, true,
                         false, true);
@@ -218,13 +197,13 @@ EXPORT_API void wrt_install_widget(
                     InstallerCallbacksTranslate::installProgressCallback,
                     new InstallerCallbacksTranslate::StatusCallbackStruct(
                         userdata, status_cb, progress_cb),
-                    translateInstallMode(installMode),
+                    installMode,
                     pkgmgrInterface)));
     }
     UNHANDLED_EXCEPTION_HANDLER_END
 }
 
-EXPORT_API void wrt_uninstall_widget(
+void wrt_uninstall_widget(
     const char * const tzAppid,
     void* userdata,
     WrtInstallerStatusCallback status_cb,
@@ -254,7 +233,7 @@ EXPORT_API void wrt_uninstall_widget(
     UNHANDLED_EXCEPTION_HANDLER_END
 }
 
-EXPORT_API void wrt_install_plugin(
+void wrt_install_plugin(
     const char *pluginDir,
     void *user_param,
     WrtPluginInstallerStatusCallback status_cb,
@@ -282,7 +261,3 @@ EXPORT_API void wrt_install_plugin(
     }
     UNHANDLED_EXCEPTION_HANDLER_END
 }
-
-#ifdef __cplusplus
-}
-#endif
index 512168b..694c9d1 100644 (file)
 #include <stdbool.h>
 #include <stddef.h>
 #include <wrt_type.h>
+#include <wrt_install_mode.h>
 #include <pkgmgr_signal_interface.h>
 #include <memory>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 typedef void (*WrtInstallerInitCallback)(WrtErrStatus status,
                                          void *data);
 typedef void (*WrtPluginInstallerStatusCallback)(WrtErrStatus status,
@@ -45,15 +42,6 @@ typedef void (*WrtProgressCallback)(float percent,
                                     const char *description,
                                     void *data);
 
-enum WrtInstallMode
-{
-    WRT_INSTALL_MODE_UNKNOWN = 0,
-    WRT_INSTALL_MODE_INSTALL_WGT,
-    WRT_INSTALL_MODE_INSTALL_DIRECTORY,
-    WRT_INSTALL_MODE_INSTALL_PRELOAD,
-    WRT_INSTALL_MODE_REINSTALL
-};
-
 void wrt_installer_init(
     void *userdata,
     WrtInstallerInitCallback callback);
@@ -63,7 +51,7 @@ void wrt_install_widget(
     void *user_parameter,
     WrtInstallerStatusCallback status_callback,
     WrtProgressCallback progress_callback,
-    WrtInstallMode install_mode,
+    InstallMode install_mode,
     std::shared_ptr<PackageManager::IPkgmgrSignal>
     pkgmgrInterface
     );
@@ -79,8 +67,4 @@ void wrt_install_plugin(const char *pluginDirectory,
                         WrtPluginInstallerStatusCallback statusCallback,
                         WrtProgressCallback progressCallback);
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif /* WRT_INSTALLER_API_H_ */
index 9781131..2cfb584 100644 (file)
@@ -47,25 +47,31 @@ typedef enum
     WRT_INSTALLER_ERROR_PACKAGE_NOT_FOUND,      ///<
     WRT_INSTALLER_ERROR_PACKAGE_INVALID,        ///< invalid widget package
     WRT_INSTALLER_ERROR_PACKAGE_LOWER_VERSION,  ///< given version is lower than existing version
-    WRT_INSTALLER_ERROR_MANIFEST_NOT_FOUND,     ///<                    
+    WRT_INSTALLER_ERROR_PACKAGE_EXCUTABLE_NOT_FOUND,
+
+    WRT_INSTALLER_ERROR_MANIFEST_NOT_FOUND = 11,///<
     WRT_INSTALLER_ERROR_MANIFEST_INVALID,       ///<
     WRT_INSTALLER_CONFIG_NOT_FOUND,             ///< couldn't find config.xml
                                                 ///< in package.
     WRT_INSTALLER_ERROR_CONFIG_INVALID,         ///< invalid config.xml
-    WRT_INSTALLER_ERROR_SIGNATURE_NOT_FOUND,    ///< signature file not exist.
-    WRT_INSTALLER_ERROR_SIGNATURE_INVALID,      ///< invalid signature file 
-    WRT_INSTALLER_ERROR_SIGNATURE_VERIFICATION_FAILED,  ///< failure in verificate
-                                                ///< signature
-    WRT_INSTALLER_ERROR_ROOT_CERTIFICATE_NOT_FOUND, ///< couldn't find root certificate.
-    WRT_INSTALLER_ERROR_CERTIFICATION_INVAID,   ///< invalid certification
-    WRT_INSTALLER_ERROR_CERTIFICATE_CHAIN_VERIFICATION_FAILED,    ///< failure in verificate
-                                                ///< certification chain.
-    WRT_INSTALLER_ERROR_CERTIFICATE_EXPIRED,    ///< expire cerification.
-    WRT_INSTALLER_ERROR_INVALID_PRIVILEGE,      ///< invalid privilege.
-    WRT_INSTALLER_ERROR_MENU_ICON_NOT_FOUND,    ///<
-    WRT_INSTALLER_ERROR_FATAL_ERROR,            ///< failure in db operation or file opertion..
-    WRT_INSTALLER_ERROR_OUT_OF_STORAGE,         ///< failure in shortage of memory
-    WRT_INSTALLER_ERROR_OUT_OF_MEMORY,          ///< failure in shortage of RAM
+
+    WRT_INSTALLER_ERROR_SIGNATURE_NOT_FOUND = 21,    ///< signature file not exist.
+    WRT_INSTALLER_ERROR_SIGNATURE_INVALID,           ///< invalid signature file
+    WRT_INSTALLER_ERROR_SIGNATURE_VERIFICATION_FAILED,  ///< failure in verificate signature
+    WRT_INSTALLER_ERROR_ROOT_CERTIFICATE_NOT_FOUND = 31, ///< couldn't find root certificate.
+    WRT_INSTALLER_ERROR_CERTIFICATION_INVAID,       ///< invalid certification
+    WRT_INSTALLER_ERROR_CERTIFICATE_CHAIN_VERIFICATION_FAILED,    ///< failure in verificate certification chain.
+    WRT_INSTALLER_ERROR_CERTIFICATE_EXPIRED,        ///< expire cerification.
+
+    WRT_INSTALLER_ERROR_INVALID_PRIVILEGE = 41,     ///< invalid privilege.
+    WRT_INSTALLER_ERROR_PRIVILEGE_LEVEL_VIOLATION,
+
+    WRT_INSTALLER_ERROR_MENU_ICON_NOT_FOUND = 51,   ///<
+
+    WRT_INSTALLER_ERROR_FATAL_ERROR = 61,           ///< failure in db operation or file opertion..
+    WRT_INSTALLER_ERROR_OUT_OF_STORAGE,             ///< failure in shortage of memory
+    WRT_INSTALLER_ERROR_OUT_OF_MEMORY,              ///< failure in shortage of RAM
+    WRT_INSTALLER_ERROR_ARGUMENT_INVALID,
 
     /* wrt-installer error */
     /* 121-140 : reserved for Web installer */
@@ -73,13 +79,13 @@ typedef enum
     /* installation */
     WRT_INSTALLER_ERROR_PACKAGE_ALREADY_INSTALLED = 121,
     WRT_INSTALLER_ERROR_ACE_CHECK_FAILED,
-    WRT_INSTALLER_ERROR_MANIFEST_CREATE_FAILED, ///<
-    WRT_INSTALLER_ERROR_ENCRYPTION_FAILED,      ///< Failure in reousrce encrypttion
-    WRT_INSTALLER_ERROR_INSTALL_OSP_SERVCIE,    ///< Failure in installing osp service
+    WRT_INSTALLER_ERROR_MANIFEST_CREATE_FAILED,     ///<
+    WRT_INSTALLER_ERROR_ENCRYPTION_FAILED,          ///< Failure in reousrce encrypttion
+    WRT_INSTALLER_ERROR_INSTALL_OSP_SERVCIE,        ///< Failure in installing osp service
     WRT_INSTALLER_ERROR_PLUGIN_INSTALLATION_FAILED,
     WRT_INSTALLER_ERROR_UNINSTALLATION_FAILED,
 
-    WRT_INSTALLER_ERROR_UNKNOWN,                ///< do not use this error code.
+    WRT_INSTALLER_ERROR_UNKNOWN = 140,              ///< do not use this error code.
 
 } WrtErrStatus;
 
index cf87bdf..8e67a1a 100644 (file)
@@ -65,7 +65,7 @@ SET(INSTALLER_TESTS_SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/BackgroundPageTests.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/NonRootUserTests.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/NPluginsInstallTests.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/ParsingTizenAppserviceTests.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/ParsingTizenAppcontrolTests.cpp
 )
 
 SET(INSTALLER_TESTS_TARGET "wrt-installer-tests-general")
@@ -138,4 +138,4 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/inst_nplug_1.wgt DESTINATION /
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/inst_nplug_2.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/inst_nplug_3.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/inst_nplug_4.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/appservice_dispos.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/app-control.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
index 662f617..71b0382 100644 (file)
@@ -25,12 +25,13 @@ namespace
 
 const std::string params = "DPL_USE_OLD_STYLE_LOGS=0 "
     "DPL_USE_OLD_STYLE_PEDANTIC_LOGS=0 WRT_TEST_MODE=1 ";
-const std::string installCmd = params + "wrt-installer -if ";
+const std::string installCmd = params + "wrt-installer -i ";
 const std::string uninstallCmd = params + "wrt-installer -un ";
-const std::string uninstallByGuidCmd = params + "wrt-installer -ug \"";
 const std::string redirection =  " 2>&1";
 const std::string INSTALLER_MESSAGE_ID_LINE =
     "## wrt-installer : %s installation was successful.\n";
+const std::string INSTALLER_MESSAGE_ID_LINE_FAIL =
+    "## wrt-installer : %s installation has failed - package already installed";
 const std::string INSTALLER_MESSSGE_START = "## wrt-installer : ";
 
 std::string getAndCutInstallerLogLine(std::string &src)
@@ -80,16 +81,34 @@ InstallResult install(
     if (!WIFEXITED(err)) {
         return OtherError;
     }
+
+    char* id = NULL;
+    std::string line;
+
     if (0 != WEXITSTATUS(err)) {
+        while ((line = getAndCutInstallerLogLine(msg)) != "")
+        {
+            if(line.find("failed") != std::string::npos)
+            {
+                id = new char[line.length()];
+                int nr = sscanf(line.c_str(), INSTALLER_MESSAGE_ID_LINE_FAIL.c_str(), id);
+                if (1 != nr)
+                {
+                    LogWarning("Can not read widget ID from message: " << line);
+                    delete[] id;
+                    return OtherError;
+                }
+                tizenId = id;
+                delete[] id;
+            }
+        }
+
         if (1 == WEXITSTATUS(err)) {
             return WrongWidgetPackage;
         }
         return OtherError;
     }
 
-    char* id = NULL;
-    std::string line;
-
     while ((line = getAndCutInstallerLogLine(msg)) != "")
     {
         if (line.find("successful") != std::string::npos)
@@ -122,13 +141,6 @@ bool uninstall(const std::string& tizenId)
     return (system(cmd.c_str()) == EXIT_SUCCESS);
 }
 
-bool uninstallByGuid(const std::string& guid)
-{
-    std::string cmd = uninstallByGuidCmd + guid + "\" > /dev/null 2>/dev/null";
-    LogDebug("executing: " << cmd);
-    return (system(cmd.c_str()) == EXIT_SUCCESS);
-}
-
 bool sigintWrtClients()
 {
     return (system("pkill -2 wrt-client") == 0);
index ee3d0a8..404a3e8 100644 (file)
@@ -43,7 +43,6 @@ InstallResult install(
         std::string& tizenId,
         const std::string& user = "");
 bool uninstall(const std::string& tizenId);
-bool uninstallByGuid(const std::string& guid);
 /**
  * @brief killWrtClients kills processes that matches 'wrt-client'
  * @return True if any client was killed
index 769bfa3..6b76d3a 100644 (file)
@@ -26,6 +26,7 @@
 #include <dpl/test/test_runner.h>
 #include <InstallerWrapper.h>
 #include <ManifestFile.h>
+#include <dpl/log/log.h>
 
 using namespace InstallerWrapper;
 
@@ -41,57 +42,76 @@ Expected: file should be created and installed by wrt-installer. Content should
 */
 RUNNER_TEST(creatingManifestFile)
 {
-    const char * manifestPath = "/opt/share/packages/manifest01.xml";
+    std::string manifestPath = "/opt/share/packages/";
     /* This widget removal should stay here in case previous test run failed
      * (so widget has not been uninstalled) */
-    uninstallByGuid("http://test.samsung.com/widget/manifestTest");
     std::string tizenId;
-    RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/manifest.wgt", tizenId)
-            == InstallerWrapper::Success);
-    RUNNER_ASSERT(WrtUtilFileExists(manifestPath));
+
+    if(install(miscWidgetsStuff + "widgets/manifest.wgt", tizenId)
+            != InstallerWrapper::Success)
+    {
+        uninstall(tizenId);
+        RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/manifest.wgt", tizenId)
+                == InstallerWrapper::Success);
+    }
+
+    RUNNER_ASSERT(WrtUtilFileExists(manifestPath.append(tizenId.substr(0,10)).append(".xml")));
     ManifestFile mf(manifestPath);
 
     Try
     {
+        LogDebug("Package " << mf.getValueByXpath("/p:manifest/@package"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@package")
-                      == "manifest01");
+                      == tizenId.substr(0,10));
+        LogDebug("type " << mf.getValueByXpath("/p:manifest/@type"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@type")
                       == "wgt");
+        LogDebug("version " << mf.getValueByXpath("/p:manifest/@version"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@version")
                       == "1.0");
+        LogDebug("label " << mf.getValueByXpath("/p:manifest/p:label"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:label")
                       == "Manifest Example");
 
+        LogDebug("email " << mf.getValueByXpath("/p:manifest/p:author/@email"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author/@email")
                       == "manifest@misc.test.create.desktop.com");
+        LogDebug("href " << mf.getValueByXpath("/p:manifest/p:author/@href"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author/@href")
                       == "http://misc.test.create.desktop.com");
+        LogDebug("author " << mf.getValueByXpath("/p:manifest/p:author"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author")
                       == "Manifest");
 
+        LogDebug("appid " << mf.getValueByXpath("/p:manifest/p:ui-application/@appid"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@appid")
-                      == "manifest01");
+                      == tizenId);
+        LogDebug("nodisplay " << mf.getValueByXpath("/p:manifest/p:ui-application/@nodisplay"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@nodisplay")
                       == "false");
+        LogDebug("type " << mf.getValueByXpath("/p:manifest/p:ui-application/@type"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@type")
                       == "webapp");
+        LogDebug("extraid " << mf.getValueByXpath("/p:manifest/p:ui-application/@extraid"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@extraid")
                       == "http://test.samsung.com/widget/manifestTest");
+        LogDebug("taskmanage " << mf.getValueByXpath("/p:manifest/p:ui-application/@taskmanage"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@taskmanage")
                       == "true");
 
+        LogDebug("icon " << mf.getValueByXpath("/p:manifest/p:ui-application/p:icon"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:icon")
-                      == "manifest01.png");
+                      == (tizenId + ".png"));
 
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[not(@xml:lang)]")
                       == "Manifest Example");
-        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='de_DE']")
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='de-de']")
                       == "Manifest Beispiel");
-        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='en_US']")
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='en-us']")
                       == "Manifest Example");
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='pl']")
                       == "PrzykĹ‚ad Manifest");
-        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='pt_PT']")
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='pt-pt']")
                       == "Exemplo manifesto");
     }
     Catch(ManifestFile::ManifestParseError)
index ae39eb4..ac141d8 100644 (file)
@@ -45,21 +45,6 @@ RUNNER_TEST(pluginFilesAdded)
 }
 
 /*
-Name: emptyPluginsDir
-Description: Tests installation with empty 'plugins' directory
-Expected: widget should be not installed
-*/
-RUNNER_TEST(emptyPluginsDir)
-{
-    std::string tizenId;
-    if(install(miscWidgetsStuff + "widgets/inst_nplug_2.wgt",
-            tizenId) == InstallerWrapper::Success) {
-        uninstall(tizenId);
-        RUNNER_ASSERT_MSG(false, "Invalid widget package installed");
-    }
-}
-
-/*
 Name: pluginFileAndOtherFile
 Description: Tests installation with plugins directory and data files
 Expected: widget should be installed
@@ -71,19 +56,3 @@ RUNNER_TEST(pluginFileAndOtherFile)
             + "widgets/inst_nplug_3.wgt", tizenId) == InstallerWrapper::Success);
     uninstall(tizenId);
 }
-
-/*
-Name: pluginFileAndSubdir
-Description: Tests installation with 'plugins' directory and subdirectories
- inside plugin directory
-Expected: widget should be not installed
-*/
-RUNNER_TEST(pluginFileAndSubdir)
-{
-    std::string tizenId;
-    if(install(miscWidgetsStuff + "widgets/inst_nplug_4.wgt",
-            tizenId) == InstallerWrapper::Success) {
-        uninstall(tizenId);
-        RUNNER_ASSERT_MSG(false, "Invalid widget package installed");
-    }
-}
@@ -18,7 +18,7 @@
  * @author  Karol Pawlowski (k.pawlowski@samsung.com)
  * @author  Andrzej Surdej (a.surdej@samsung.com)
  * @version 1.0
- * @brief   Parsing Tizen Appservice test's bodies
+ * @brief   Parsing Tizen app-control test's bodies
  */
 
 #include <string>
@@ -32,57 +32,60 @@ using namespace InstallerWrapper;
 
 ////////////////////////////////////////////////////////////////////////////////
 
-RUNNER_TEST_GROUP_INIT(ParsingTizenAppservice)
+RUNNER_TEST_GROUP_INIT(ParsingTizenAppcontrol)
 
 /*
-Name: correct_csp_policy
-Description: Tests if widget policy is correctly parsed from config file
-             and stored into database
-Expected: widget should be installed and policy should mach
+Name: tizen_app-contro
+Description: Tests if widget app-control tag is correctly parsed
+Expected: widget should be installed
 */
-RUNNER_TEST(tizen_appservice_disposition)
+RUNNER_TEST(tizen_app_control)
 {
     std::string tizenId;
-    RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/appservice_dispos.wgt",
+    RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/app-control.wgt",
             tizenId) == InstallerWrapper::Success);
 
     WrtDB::WidgetDAOReadOnly dao(DPL::FromASCIIString(tizenId));
-    WrtDB::WidgetAppControlList appsvcList;
-    dao.getAppControlList(appsvcList);
+    WrtDB::WidgetAppControlList appcontrolList;
+    dao.getAppControlList(appcontrolList);
     uninstall(tizenId);
 
-    LogDebug("Actual size" << appsvcList.size());
-    RUNNER_ASSERT_MSG(appsvcList.size() == 4, "Incorrect list size");
+    LogDebug("Actual size" << appcontrolList.size());
+    RUNNER_ASSERT_MSG(appcontrolList.size() == 4, "Incorrect list size");
     WrtDB::WidgetAppControl s;
     s.src = DPL::FromUTF8String("edit1.html");
-    s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/edit");
+    s.operation = DPL::FromUTF8String("http://tizen.org/appcontrol/operation/edit");
     s.mime = DPL::FromUTF8String("image/jpg");      /* mime type */
     s.disposition = WrtDB::WidgetAppControl::Disposition::WINDOW;
+
     RUNNER_ASSERT_MSG(
-        std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
+        std::find(appcontrolList.begin(), appcontrolList.end(), s) != appcontrolList.end(),
         "Unable to find service #");
 
     s.src = DPL::FromUTF8String("edit2.html");
-    s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/view");
+    s.operation = DPL::FromUTF8String("http://tizen.org/appcontrol/operation/view");
     s.mime = DPL::FromUTF8String("audio/ogg");      /* mime type */
     s.disposition = WrtDB::WidgetAppControl::Disposition::WINDOW;
+
     RUNNER_ASSERT_MSG(
-        std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
+        std::find(appcontrolList.begin(), appcontrolList.end(), s) != appcontrolList.end(),
         "Unable to find service ##");
 
     s.src = DPL::FromUTF8String("edit3.html");
-    s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/call");
+    s.operation = DPL::FromUTF8String("http://tizen.org/appcontrol/operation/call");
     s.mime = DPL::FromUTF8String("image/png");      /* mime type */
-    s.disposition = WrtDB::WidgetAppControl::Disposition::INLINE;
+    s.disposition = WrtDB::WidgetAppControl::Disposition::WINDOW;
+
     RUNNER_ASSERT_MSG(
-        std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
+        std::find(appcontrolList.begin(), appcontrolList.end(), s) != appcontrolList.end(),
         "Unable to find service ###");
 
     s.src = DPL::FromUTF8String("edit4.html");
-    s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/send");
+    s.operation = DPL::FromUTF8String("http://tizen.org/appcontrol/operation/send");
     s.mime = DPL::FromUTF8String("text/css");      /* mime type */
     s.disposition = WrtDB::WidgetAppControl::Disposition::WINDOW;
+
     RUNNER_ASSERT_MSG(
-        std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
+        std::find(appcontrolList.begin(), appcontrolList.end(), s) != appcontrolList.end(),
         "Unable to find service ####");
 }
similarity index 83%
rename from tests/general/widgets/appservice_dispos.wgt
rename to tests/general/widgets/app-control.wgt
index 9451a4f..4aa5c7f 100644 (file)
Binary files a/tests/general/widgets/appservice_dispos.wgt and b/tests/general/widgets/app-control.wgt differ
index 36d2452..6696e36 100644 (file)
Binary files a/tests/general/widgets/bg-00-with_bg.wgt and b/tests/general/widgets/bg-00-with_bg.wgt differ
index aca63a7..30ddb26 100644 (file)
Binary files a/tests/general/widgets/bg-01-missing_file.wgt and b/tests/general/widgets/bg-01-missing_file.wgt differ
index ccbf1df..df388cd 100644 (file)
Binary files a/tests/general/widgets/bg-02-without_bg.wgt and b/tests/general/widgets/bg-02-without_bg.wgt differ
index fc075cf..934ac25 100644 (file)
Binary files a/tests/general/widgets/inst_nplug_1.wgt and b/tests/general/widgets/inst_nplug_1.wgt differ
index 95f3d69..96e7195 100644 (file)
Binary files a/tests/general/widgets/inst_nplug_2.wgt and b/tests/general/widgets/inst_nplug_2.wgt differ
index 5d98267..39693c9 100644 (file)
Binary files a/tests/general/widgets/inst_nplug_3.wgt and b/tests/general/widgets/inst_nplug_3.wgt differ
index 9275cca..78dcecc 100644 (file)
Binary files a/tests/general/widgets/inst_nplug_4.wgt and b/tests/general/widgets/inst_nplug_4.wgt differ
index 17e56f5..0977e5b 100644 (file)
Binary files a/tests/general/widgets/manifest.wgt and b/tests/general/widgets/manifest.wgt differ
index 641283f..6633b1a 100644 (file)
Binary files a/tests/general/widgets/nonroot.wgt and b/tests/general/widgets/nonroot.wgt differ
diff --git a/tests/general/widgets/tizen_app-control/config.xml b/tests/general/widgets/tizen_app-control/config.xml
new file mode 100644 (file)
index 0000000..b2aa6af
--- /dev/null
@@ -0,0 +1,28 @@
+<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets"
+    id="http://test.samsung.com/widget/wac/tizen_appcontrol"
+    version="1.0.0"
+    min-version="1.0">
+  <name short="AppControl">app-control</name>
+  <icon src="icon.png" height="75" width="75"/>
+  <tizen:app-control>
+    <tizen:src name="edit1.html"/>
+    <tizen:operation name="http://tizen.org/appcontrol/operation/edit"/>
+    <tizen:mime name="image/jpg" />
+  </tizen:app-control>
+  <tizen:app-control>
+    <tizen:src name="edit2.html"/>
+    <tizen:operation name="http://tizen.org/appcontrol/operation/view"/>
+    <tizen:mime name="audio/ogg" />
+  </tizen:app-control>
+  <tizen:app-control>
+    <tizen:src name="edit3.html"/>
+    <tizen:operation name="http://tizen.org/appcontrol/operation/call"/>
+    <tizen:mime name="image/png" />
+  </tizen:app-control>
+  <tizen:app-control>
+    <tizen:src name="edit4.html"/>
+    <tizen:operation name="http://tizen.org/appcontrol/operation/send"/>
+    <tizen:mime name="text/css" />
+  </tizen:app-control>
+  <content src="index.html" />
+</widget>
diff --git a/tests/general/widgets/tizen_appservice_disposition/config.xml b/tests/general/widgets/tizen_appservice_disposition/config.xml
deleted file mode 100755 (executable)
index 4544234..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets"
-    id="http://test.samsung.com/widget/wac/tizen_appservice"
-    version="1.0.0"
-    min-version="1.0">
-  <name short="Disposition">Disposition_attribute</name>
-  <icon src="icon.png" height="75" width="75"/>
-  <tizen:appservice src="edit1.html" operation="http://tizen.org/appsvc/operation/edit" mime="image/jpg" />
-  <tizen:appservice src="edit2.html" operation="http://tizen.org/appsvc/operation/view" mime="audio/ogg" disposition="window"/>
-  <tizen:appservice src="edit3.html" operation="http://tizen.org/appsvc/operation/call" mime="image/png" disposition="inline"/>
-  <tizen:appservice src="edit4.html" operation="http://tizen.org/appsvc/operation/send" mime="text/css" disposition="wrongone"/>
-  <content src="index.html" />
-</widget>