TaskConfiguration refactoring - part 2/3
authorTomasz Iwanek <t.iwanek@samsung.com>
Tue, 3 Sep 2013 12:05:07 +0000 (14:05 +0200)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Tue, 1 Oct 2013 13:45:27 +0000 (13:45 +0000)
[Issue#]       LINUXWRT-820
[Problem]      Refactoring
[Cause]        Code needs clean up
[Solution]     This change is solving:
 - "Stepifying" TaskConfiguration (identification of sub-problems of this task)

This change makes clean up/reordering in TaskConfiguration,
(now called) TaskProcessWidget is just to be fixed.

[Verification] Walk through following procedure:
1. Testing SetupTempDirStep & DetectUpdateInstallationStep
   (run app after each installation, uninstall successfully app if not needed):
 1.1. Install any new widget for first time
 1.2. Update widget several times
 1.3. Test installtion from browser installation:
       wrt-installer -i /opt/share/widget/tests/widgetstest/config.xml (wrt-extra)
 1.4. hybrid app -> test new installation
       (hybrid app can be found in "HybridApplication/res" directory
        in TCT behavioural tests; change extension to .wgt)
 1.5. hybrid app -> test update installation (run it again)
2. Testing ResourceEncryptionStep:
 2.1 Check points 1.1 and 1.2 for encrypted widget.
3. (optional if possible) Testing InstallationFSLocationSte:
 3.1 Check installation on external card
      (sets setting in widget config: install-location="prefer-external")
      (make sure it's really installed on card)
4. Testing CheckRDSSupportStep:
 4.1 Install widget without encryption using SDk and update it (reinstall).
     SDK should run RDS deployment (check console for succesfull installation messages)
 4.2 Install widget encryption using SDK and update it (reinstall).
     SDK should run normal installation.
     SDK may try to install it with RDS. wrt-installer should prompt then about error (RDS not supported).
     SDK shoudl recognized message and run normal installation automatically if RDS fails.
5. Testing pkgmgr interaction (pkgmgr should display proper type of instalaltion, notifications and icons):
 5.1. Run new isntallation through Installer app on phone (access .wgt from myfiles)
 5.2. Run update installation through Installer app on phone (access .wgt from myfiles)
 5.3. Run new isntallation through Installer app on phone (access .wgt from myfiles) of hybrid app
 5.4. Run update installation through Installer app on phone (access .wgt from myfiles) of hybrid app

---

Update may be tested (1.2.):
 wrt-installer-tests-general --output=text --regexp="Update"
Hosted app may be tested (1.3.):
 wrt-extra-tests-widgets --output=text --regexp="hosted_app_simple_install"
Encrypted widget is located:
 /opt/share/widget/tests/misc/widgets/encrypted.wgt (wrt-extra).

---

This change is also fixing hosted app installation as it was broken.

---

Change-Id: Idd1bfba88d3c8569fcbbc80eda1462cf7dfc9f16

src/CMakeLists.txt
src/jobs/widget_install/job_widget_install.cpp
src/jobs/widget_install/task_configuration.cpp
src/jobs/widget_install/task_configuration.h
src/jobs/widget_install/task_process_config.cpp [moved from src/jobs/widget_install/task_widget_config.cpp with 91% similarity]
src/jobs/widget_install/task_process_config.h [moved from src/jobs/widget_install/task_widget_config.h with 91% similarity]

index 5b5fdcf..8009d61 100644 (file)
@@ -62,7 +62,7 @@ SET(INSTALLER_SOURCES
     ${INSTALLER_JOBS}/widget_install/job_widget_install.cpp
     ${INSTALLER_JOBS}/widget_install/manifest.cpp
     ${INSTALLER_JOBS}/widget_install/task_commons.cpp
-    ${INSTALLER_JOBS}/widget_install/task_widget_config.cpp
+    ${INSTALLER_JOBS}/widget_install/task_process_config.cpp
     ${INSTALLER_JOBS}/widget_install/task_database.cpp
     ${INSTALLER_JOBS}/widget_install/task_configuration.cpp
     ${INSTALLER_JOBS}/widget_install/ace_registration.cpp
index da0c536..7241597 100644 (file)
@@ -40,7 +40,7 @@
 #include <widget_install/job_widget_install.h>
 #include <widget_install/task_certify.h>
 #include <widget_install/task_certify_level.h>
-#include <widget_install/task_widget_config.h>
+#include <widget_install/task_process_config.h>
 #include <widget_install/task_file_manipulation.h>
 #include <widget_install/task_ace_check.h>
 #include <widget_install/task_smack.h>
@@ -85,7 +85,10 @@ JobWidgetInstall::JobWidgetInstall(
     // Init installer context
     m_installerContext.installStep = InstallerContext::INSTALL_START;
     m_installerContext.job = this;
-    m_installerContext.widgetConfig.shareHref = std::string();
+
+    m_installerContext.callerPkgId
+            = DPL::FromUTF8String(m_jobStruct.pkgmgrInterface->getCallerId());
+    _D("Caller Package Id : %s", DPL::ToUTF8String(m_installerContext.callerPkgId).c_str());
 }
 
 void JobWidgetInstall::appendNewInstallationTaskList()
@@ -95,7 +98,7 @@ void JobWidgetInstall::appendNewInstallationTaskList()
 
     AddTask(new TaskRecovery(m_installerContext));
 
-    AddTask(new TaskWidgetConfig(m_installerContext));
+    AddTask(new TaskProcessConfig(m_installerContext));
     if (m_installerContext.widgetConfig.packagingType ==
         WrtDB::PKG_TYPE_HOSTED_WEB_APP)
     {
@@ -131,7 +134,7 @@ void JobWidgetInstall::appendUpdateInstallationTaskList()
         AddTask(new TaskPrepareReinstall(m_installerContext));
     }
 
-    AddTask(new TaskWidgetConfig(m_installerContext));
+    AddTask(new TaskProcessConfig(m_installerContext));
 
     if (m_installerContext.widgetConfig.packagingType ==
         WrtDB::PKG_TYPE_HOSTED_WEB_APP)
index e61207c..052af02 100644 (file)
@@ -39,7 +39,6 @@
 #include <dpl/localization/w3c_file_localization.h>
 
 #include <libiriwrapper.h>
-#include <pkg-manager/pkgmgr_signal.h>
 #include <app_manager.h>
 
 #include "root_parser.h"
@@ -98,8 +97,24 @@ TaskConfiguration::TaskConfiguration(InstallerContext& context) :
     m_context(context)
 {
     AddStep(&TaskConfiguration::StartStep);
-    AddStep(&TaskConfiguration::PrepareInstallationStep);
+
+    AddStep(&TaskConfiguration::SetupTempDirStep);
+    AddStep(&TaskConfiguration::CheckPackageTypeStep);
+
+    AddStep(&TaskConfiguration::ParseXMLConfigStep);
+
+    AddStep(&TaskConfiguration::TizenIdStep);
+    AddStep(&TaskConfiguration::ApplicationTypeStep);
+    AddStep(&TaskConfiguration::ResourceEncryptionStep);
+    AddStep(&TaskConfiguration::InstallationFSLocationStep);
+
+    AddStep(&TaskConfiguration::DetectUpdateInstallationStep);
+    AddStep(&TaskConfiguration::CheckRDSSupportStep);
+    AddStep(&TaskConfiguration::ConfigureWidgetLocationStep);
+    AddStep(&TaskConfiguration::PkgmgrStartStep);
+
     AddStep(&TaskConfiguration::AppendTasklistStep);
+
     AddStep(&TaskConfiguration::EndStep);
 }
 
@@ -113,6 +128,13 @@ void TaskConfiguration::EndStep()
     _D("--------- <TaskConfiguration> : END ----------");
 }
 
+void TaskConfiguration::PkgmgrStartStep()
+{
+    pkgMgrInterface()->sendSignal(
+            PKGMGR_PROGRESS_KEY,
+            PKGMGR_START_VALUE);
+}
+
 void TaskConfiguration::AppendTasklistStep()
 {
     if (!m_context.isUpdateMode) {
@@ -124,13 +146,15 @@ void TaskConfiguration::AppendTasklistStep()
     }
 }
 
-void TaskConfiguration::PrepareInstallationStep()
+std::shared_ptr<PackageManager::IPkgmgrSignal> TaskConfiguration::pkgMgrInterface()
 {
-    // TODO: (job_install_refactoring) clean up this task
-    std::string widgetPath = m_context.requestedPath;
-    bool result;
-    m_context.needEncryption = false;
-    std::string tempDir;
+    return m_context.job->GetInstallerStruct().pkgmgrInterface;
+}
+
+void TaskConfiguration::SetupTempDirStep()
+{
+    _D("widgetPath: %s", m_context.requestedPath.c_str());
+    _D("tempPath: %s", m_tempDir.c_str());
     if (m_context.mode.extension == InstallMode::ExtensionType::DIR) {
         if (m_context.mode.command ==
                 InstallMode::Command::REINSTALL) {
@@ -138,65 +162,53 @@ void TaskConfiguration::PrepareInstallationStep()
             tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
             tempPathBuilder << WrtDB::GlobalConfig::GetTmpDirPath();
             tempPathBuilder << "/";
-            tempPathBuilder << widgetPath;
-            tempDir = tempPathBuilder.str();
+            tempPathBuilder << m_context.requestedPath;
+            m_tempDir = tempPathBuilder.str();
         } else {
-            tempDir = widgetPath;
+            m_tempDir = m_context.requestedPath;
         }
     } else {
-        tempDir =
+        m_tempDir =
             Jobs::WidgetInstall::createTempPath(
                     m_context.mode.rootPath ==
                         InstallMode::RootPath::RO);
-        WidgetUnzip wgtUnzip;
-        wgtUnzip.unzipWgtFile(widgetPath, tempDir);
+        if(!hasExtension(m_context.requestedPath, XML_EXTENSION)) //unzip everything except xml files
+        {
+            WidgetUnzip wgtUnzip;
+            wgtUnzip.unzipWgtFile(m_context.requestedPath, m_tempDir);
+        }
+        else
+        {
+            _D("From browser installation - unzip is not done");
+        }
     }
+}
 
-    _D("widgetPath: %s", widgetPath.c_str());
-    _D("tempPath: %s", tempDir.c_str());
-
-    m_context.widgetConfig.packagingType =
-        checkPackageType(widgetPath, tempDir);
-    ConfigParserData configData = getWidgetDataFromXML(
-            widgetPath,
-            tempDir,
+void TaskConfiguration::ParseXMLConfigStep()
+{
+    m_widgetConfig = getWidgetDataFromXML( //TODO: make one parsing of config.xml
+            m_context.requestedPath, m_tempDir,
             m_context.widgetConfig.packagingType,
             m_context.mode.command == InstallMode::Command::REINSTALL);
     _D("widget packaging type : %d", static_cast<WrtDB::PkgType>(m_context.widgetConfig.packagingType.pkgType));
-
-    setTizenId(configData);
-    setApplicationType(configData);
-    m_context.needEncryption = detectResourceEncryption(configData);
-    setInstallLocationType(configData);
-    // TODO: (job_install_refactoring) hide this call
-    m_context.callerPkgId =
-        DPL::FromUTF8String(m_context.job->GetInstallerStruct().pkgmgrInterface->getCallerId());
-    _D("Caller Package Id : %s", DPL::ToUTF8String(m_context.callerPkgId).c_str());
-
-    // Configure installation
-    result = ConfigureInstallation(widgetPath, configData, tempDir);
-    // TODO: (job_install_refactoring) hide this call
-    m_context.job->GetInstallerStruct().pkgmgrInterface->sendSignal(
-            PKGMGR_PROGRESS_KEY,
-            PKGMGR_START_VALUE);
-
-    m_context.isUpdateMode = result;
 }
 
-void TaskConfiguration::setTizenId(
-    const WrtDB::ConfigParserData &configInfo)
+void TaskConfiguration::TizenIdStep()
 {
     bool shouldMakeAppid = false;
     using namespace PackageManager;
-    if (!!configInfo.tizenAppId) {
-        _D("Setting tizenAppId provided in config.xml: %ls", (*configInfo.tizenAppId).c_str());
-        m_context.widgetConfig.tzAppid = *configInfo.tizenAppId;
+
+    if (!!m_widgetConfig.tizenAppId) {
+        _D("Setting tizenAppId provided in config.xml: %s", DPL::ToUTF8String(*m_widgetConfig.tizenAppId).c_str());
+
+        m_context.widgetConfig.tzAppid = *m_widgetConfig.tizenAppId;
         //check package id.
-        if (!!configInfo.tizenPkgId) {
-            _D("Setting tizenPkgId provided in config.xml: %ls", (*configInfo.tizenPkgId).c_str());
-            m_context.widgetConfig.tzPkgid = *configInfo.tizenPkgId;
+        if (!!m_widgetConfig.tizenPkgId) {
+            _D("Setting tizenPkgId provided in config.xml: %s", DPL::ToUTF8String(*m_widgetConfig.tizenPkgId).c_str());
+
+            m_context.widgetConfig.tzPkgid = *m_widgetConfig.tizenPkgId;
         } else {
-            DPL::String appid = *configInfo.tizenAppId;
+            DPL::String appid = *m_widgetConfig.tizenAppId;
             if (appid.length() > PACKAGE_ID_LENGTH) {
                 m_context.widgetConfig.tzPkgid =
                     appid.substr(0, PACKAGE_ID_LENGTH);
@@ -204,7 +216,7 @@ void TaskConfiguration::setTizenId(
                 //old version appid only has 10byte random character is able to install for a while.
                 //this case appid equal pkgid.
                 m_context.widgetConfig.tzPkgid =
-                    *configInfo.tizenAppId;
+                    *m_widgetConfig.tizenAppId;
                 shouldMakeAppid = true;
             }
         }
@@ -226,9 +238,9 @@ void TaskConfiguration::setTizenId(
 
     if (shouldMakeAppid == true) {
         DPL::OptionalString name;
-        DPL::OptionalString defaultLocale = configInfo.defaultlocale;
+        DPL::OptionalString defaultLocale = m_widgetConfig.defaultlocale;
 
-        FOREACH(localizedData, configInfo.localizedDataSet)
+        FOREACH(localizedData, m_widgetConfig.localizedDataSet)
         {
             Locale i = localizedData->first;
             if (!!defaultLocale) {
@@ -250,8 +262,7 @@ void TaskConfiguration::setTizenId(
         if (!name || (regexec(&regx, DPL::ToUTF8String(*name).c_str(),
                               static_cast<size_t>(0), NULL, 0) != REG_NOERROR))
         {
-            // TODO : (job_install_refactoring) generate name move to wrt-commons
-            std::string allowedString("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+            const std::string allowedString("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
             std::ostringstream genName;
             struct timeval tv;
             gettimeofday(&tv, NULL);
@@ -273,22 +284,17 @@ void TaskConfiguration::setTizenId(
     }
 
     // send start signal of pkgmgr
-    // TODO: (job_install_refactoring) hide this call
-    m_context.job->GetInstallerStruct().pkgmgrInterface->setPkgname(DPL::ToUTF8String(
-                                                         m_context.
-                                                             widgetConfig.
-                                                             tzPkgid));
-    _D("Tizen App Id : %ls", m_context.widgetConfig.tzAppid.c_str());
-    _D("Tizen Pkg Id : %ls", m_context.widgetConfig.tzPkgid.c_str());
+    pkgMgrInterface()->setPkgname(DPL::ToUTF8String(m_context.widgetConfig.tzPkgid));
+
+    _D("Tizen App Id : %ls", (m_context.widgetConfig.tzAppid).c_str());
+    _D("Tizen Pkg Id : %ls", (m_context.widgetConfig.tzPkgid).c_str());
 }
 
-void TaskConfiguration::configureWidgetLocation(const std::string & widgetPath,
-                                               const std::string& tempPath)
+void TaskConfiguration::ConfigureWidgetLocationStep()
 {
     m_context.locations =
-        WidgetLocation(DPL::ToUTF8String(m_context.widgetConfig.
-                                             tzPkgid),
-                       widgetPath, tempPath,
+        WidgetLocation(DPL::ToUTF8String(m_context.widgetConfig.tzPkgid),
+                       m_context.requestedPath, m_tempDir,
                        m_context.widgetConfig.packagingType,
                        m_context.mode.rootPath ==
                            InstallMode::RootPath::RO,
@@ -296,46 +302,28 @@ void TaskConfiguration::configureWidgetLocation(const std::string & widgetPath,
     m_context.locations->registerAppid(
         DPL::ToUTF8String(m_context.widgetConfig.tzAppid));
 
-    _D("widgetSource %s", widgetPath.c_str());
+    _D("widgetSource %s", m_context.requestedPath.c_str());
 }
 
-bool TaskConfiguration::ConfigureInstallation(
-    const std::string &widgetSource,
-    const WrtDB::ConfigParserData &configData,
-    const std::string &tempPath)
+void TaskConfiguration::DetectUpdateInstallationStep()
 {
-    bool result;
-
     WidgetUpdateInfo update;
-
     // checking installed web application
     Try {
         // no excpetion means, it isn't update mode
-        // TODO: (job_install_refactoring) hide this call/
-        m_context.job->GetInstallerStruct().pkgmgrInterface->sendSignal(
-                PKGMGR_START_KEY,
-                PKGMGR_START_UPDATE);
-
-        update = detectWidgetUpdate(configData,
+        update = detectWidgetUpdate(m_widgetConfig,
                                     m_context.widgetConfig.tzAppid);
-        result = checkWidgetUpdate(update);
-        if (!result) {
-            // Already installed TizenAppId. return failed
-            ThrowMsg(Jobs::WidgetInstall::Exceptions::PackageAlreadyInstalled,
-                "package is already installed");
-        }
-        if (!checkSupportRDSUpdate(configData)) {
-            ThrowMsg(Jobs::WidgetInstall::Exceptions::NotSupportRDSUpdate,
-                "RDS update failed");
-        }
-        result = true;
+        checkWidgetUpdate(update);
+
+        m_context.isUpdateMode = true;
+
+        //if update, notify pkgmgr that this is update
+        pkgMgrInterface()->sendSignal( PKGMGR_START_KEY, PKGMGR_START_UPDATE);
     }
     Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) {
-        // TODO: (job_install_refactoring) hide this call
-        m_context.job->GetInstallerStruct().pkgmgrInterface->sendSignal(
-                PKGMGR_START_KEY,
-                PKGMGR_START_INSTALL);
-        result = false;
+        pkgMgrInterface()->sendSignal(PKGMGR_START_KEY, PKGMGR_START_INSTALL);
+
+        m_context.isUpdateMode = false;
 
         if (!validateTizenApplicationID(
             m_context.widgetConfig.tzAppid))
@@ -350,10 +338,18 @@ bool TaskConfiguration::ConfigureInstallation(
                 "package is already installed");
         }
     }
+}
 
-    configureWidgetLocation(widgetSource, tempPath);
-
-    return result;
+void TaskConfiguration::CheckRDSSupportStep()
+{
+    //update needs RDS support to go ahead
+    if(m_context.isUpdateMode)
+    {
+        if (!checkSupportRDSUpdate(m_widgetConfig)) {
+            ThrowMsg(Jobs::WidgetInstall::Exceptions::NotSupportRDSUpdate,
+                "RDS update failed");
+        }
+    }
 }
 
 bool TaskConfiguration::validateTizenApplicationID(
@@ -404,7 +400,7 @@ bool TaskConfiguration::checkWidgetUpdate(
     _D("incoming version = '%ls", update.incomingVersion->Raw().c_str());
     _D("Tizen AppID = %ls", update.tzAppId.c_str());
 
-    // Check running state
+    // TODO: step Check running state
     bool isRunning = false;
     int ret =
         app_manager_is_running(DPL::ToUTF8String(update.tzAppId).c_str(),
@@ -412,7 +408,7 @@ bool TaskConfiguration::checkWidgetUpdate(
     if (APP_MANAGER_ERROR_NONE != ret) {
         _E("Fail to get running state");
         ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
-            "widget is running");
+                "widget is running");
     }
 
     if (true == isRunning) {
@@ -426,7 +422,7 @@ bool TaskConfiguration::checkWidgetUpdate(
         if (APP_MANAGER_ERROR_NONE != ret) {
             _E("Fail to get app_context");
             ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
-                "widget is running");
+                    "widget is running");
         }
 
         // terminate app_context_h
@@ -435,7 +431,7 @@ bool TaskConfiguration::checkWidgetUpdate(
             _E("Fail to terminate running application");
             app_context_destroy(appCtx);
             ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
-                "widget is running");
+                    "widget is running");
         } else {
             app_context_destroy(appCtx);
             // app_manager_terminate_app isn't sync API
@@ -452,7 +448,7 @@ bool TaskConfiguration::checkWidgetUpdate(
                 if (APP_MANAGER_ERROR_NONE != ret) {
                     _E("Fail to get running state");
                     ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
-                        "widget is running");
+                            "widget is running");
                 }
                 if (!isStillRunning) {
                     break;
@@ -461,11 +457,12 @@ bool TaskConfiguration::checkWidgetUpdate(
             if (isStillRunning) {
                 _E("Fail to terminate running application");
                 ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
-                    "widget is running");
+                        "widget is running");
             }
             _D("terminate application");
         }
     }
+    //...
 
     m_context.widgetConfig.tzAppid = update.tzAppId;
 
@@ -519,6 +516,13 @@ ConfigParserData TaskConfiguration::getWidgetDataFromXML(
                 ThrowMsg(Exceptions::MissingConfig, "Config file not exists");
             }
 
+#ifdef SCHEMA_VALIDATION_ENABLED
+            if(!parser.Validate(configFilePath, WRT_WIDGETS_XML_SCHEMA))
+            {
+                _E("Invalid configuration file - schema validation failed");
+                ThrowMsg(Exceptions::WidgetConfigFileInvalid, "Failed to parse config.xml file");
+            }
+#endif
             parser.Parse(configFile,
                     ElementParserPtr(
                         new RootParser<WidgetParser>(configInfo,
@@ -572,29 +576,27 @@ WidgetUpdateInfo TaskConfiguration::detectWidgetUpdate(
         incomingVersion);
 }
 
-
-WrtDB::PackagingType TaskConfiguration::checkPackageType(
-    const std::string &widgetSource,
-    const std::string &tempPath)
+void TaskConfiguration::CheckPackageTypeStep()
 {
-    if (hasExtension(widgetSource, XML_EXTENSION)) {
+    if (hasExtension(m_context.requestedPath, XML_EXTENSION)) {
         _D("Hosted app installation");
-        return PKG_TYPE_HOSTED_WEB_APP;
+        m_context.widgetConfig.packagingType = PKG_TYPE_HOSTED_WEB_APP;
+        return;
     }
 
-    std::string configFile = tempPath + "/" + OSP_MANIFEST_XML;
+    std::string configFile = m_tempDir + "/" + OSP_MANIFEST_XML;
     if (WrtUtilFileExists(configFile)) {
-        return PKG_TYPE_HYBRID_WEB_APP;
+        m_context.widgetConfig.packagingType = PKG_TYPE_HYBRID_WEB_APP;
+        return;
     }
 
-    return PKG_TYPE_NOMAL_WEB_APP;
+    m_context.widgetConfig.packagingType = PKG_TYPE_NOMAL_WEB_APP;
 }
 
-void TaskConfiguration::setApplicationType(
-    const WrtDB::ConfigParserData &configInfo)
+void TaskConfiguration::ApplicationTypeStep() //TODO: is this really needed as WAC is not supported?
 {
     AppType widgetAppType = APP_TYPE_UNKNOWN;
-    FOREACH(iterator, configInfo.nameSpaces) {
+    FOREACH(iterator, m_widgetConfig.nameSpaces) {
         _D("namespace = [%ls]", (*iterator).c_str());
 
         if (*iterator == ConfigurationNamespace::TizenWebAppNamespaceName) {
@@ -608,27 +610,25 @@ void TaskConfiguration::setApplicationType(
     _D("type = [%s]", m_context.widgetConfig.webAppType.getApptypeToString().c_str());
 }
 
-bool TaskConfiguration::detectResourceEncryption(
-    const WrtDB::ConfigParserData &configData)
-{
-    FOREACH(it, configData.settingsList)
+void TaskConfiguration::ResourceEncryptionStep()
+{    
+    m_context.needEncryption = false;
+    FOREACH(it, m_widgetConfig.settingsList)
     {
         if (it->m_name == SETTING_VALUE_ENCRYPTION &&
             it->m_value == SETTING_VALUE_ENCRYPTION_ENABLE)
         {
             _D("resource need encryption");
-            return true;
+            m_context.needEncryption = true;
         }
     }
-    return false;
 }
 
-void TaskConfiguration::setInstallLocationType(
-    const WrtDB::ConfigParserData & configData)
+void TaskConfiguration::InstallationFSLocationStep()
 {
     m_context.locationType = INSTALL_LOCATION_TYPE_NOMAL;
     if (m_context.mode.installTime != InstallMode::InstallTime::PRELOAD) {
-        FOREACH(it, configData.settingsList) {
+        FOREACH(it, m_widgetConfig.settingsList) {
             if (it->m_name == SETTING_VALUE_INSTALLTOEXT_NAME &&
                 it->m_value ==
                 SETTING_VALUE_INSTALLTOEXT_PREPER_EXT)
index a8cd89c..3a50ca7 100644 (file)
 #ifndef TASK_CONFIGURATION_H
 #define TASK_CONFIGURATION_H
 
+#include <string>
+
 #include <dpl/task_list.h>
 #include <dpl/wrt-dao-ro/config_parser_data.h>
 
 #include <widget_install/widget_update_info.h>
 #include <widget_install/widget_install_context.h>
 
+#include <pkg-manager/pkgmgr_signal.h>
+
 class InstallerContext;
 
 namespace Jobs {
@@ -36,41 +40,48 @@ namespace WidgetInstall {
 class TaskConfiguration : public DPL::TaskDecl<TaskConfiguration>
 {
     InstallerContext& m_context;
+    std::string m_tempDir;
+    WrtDB::ConfigParserData m_widgetConfig; //TODO: temporary result of config.xml parsing
+
     WidgetUpdateInfo m_widgetUpdateInfo;
 
-    bool ConfigureInstallation(const std::string &widgetSource,
-                                          const WrtDB::ConfigParserData
-                                          &configData,
-                                          const std::string &tempPath);
     static WrtDB::ConfigParserData getWidgetDataFromXML(
         const std::string &widgetSource,
         const std::string &tempPath,
         WrtDB::PackagingType pkgType,
         bool isReinstall);
+
     static WidgetUpdateInfo detectWidgetUpdate(
         const WrtDB::ConfigParserData &configInfo,
         const WrtDB::TizenAppId &tizenId);
-    void setTizenId(const WrtDB::ConfigParserData &configInfo);
-    void configureWidgetLocation(const std::string & widgetPath,
-                                 const std::string &tempPath);
-
-    WrtDB::PackagingType checkPackageType(
-        const std::string &widgetSource,
-        const std::string &tempPath);
-    bool detectResourceEncryption(const WrtDB::ConfigParserData &configData);
-    void setInstallLocationType(const WrtDB::ConfigParserData
-                                &configData);
 
     bool validateTizenApplicationID(const WrtDB::TizenAppId &tizenAppId);
     bool validateTizenPackageID(const WrtDB::TizenPkgId &tizenPkgId);
     bool checkWidgetUpdate(const WidgetUpdateInfo &update);
-    void setApplicationType(const WrtDB::ConfigParserData &configInfo);
+    void ApplicationTypeStep(const WrtDB::ConfigParserData &configInfo);
     bool checkSupportRDSUpdate(const WrtDB::ConfigParserData &configInfo);
 
-    void PrepareInstallationStep();
-    void AppendTasklistStep();
+    std::shared_ptr<PackageManager::IPkgmgrSignal> pkgMgrInterface();
 
+    //steps
     void StartStep();
+
+    void SetupTempDirStep();
+    void CheckPackageTypeStep();
+    void ParseXMLConfigStep();
+
+    void TizenIdStep();
+    void DetectUpdateInstallationStep();
+    void PkgmgrStartStep();
+
+    void ApplicationTypeStep();
+    void ResourceEncryptionStep();
+    void InstallationFSLocationStep();
+
+    void ConfigureWidgetLocationStep();
+    void CheckRDSSupportStep();
+
+    void AppendTasklistStep();
     void EndStep();
 
 public:
similarity index 91%
rename from src/jobs/widget_install/task_widget_config.cpp
rename to src/jobs/widget_install/task_process_config.cpp
index 1449ecb..f2967b9 100755 (executable)
@@ -14,7 +14,7 @@
  *    limitations under the License.
  */
 /*
- * @file    task_widget_config.cpp
+ * @file    task_process_config.cpp
  * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version 1.0
  * @brief   Implementation file for installer task widget config
@@ -42,7 +42,7 @@
 #include <root_parser.h>
 
 #include <widget_install/job_widget_install.h>
-#include <widget_install/task_widget_config.h>
+#include <widget_install/task_process_config.h>
 #include <widget_install/widget_install_context.h>
 #include <widget_install/widget_install_errors.h>
 #include <widget_parser.h>
@@ -56,7 +56,6 @@ namespace { // anonymous
 const DPL::String BR = DPL::FromUTF8String("<br>");
 const std::string WIDGET_NOT_COMPATIBLE = "This widget is "
                                           "not compatible with WRT.<br><br>";
-const std::string QUESTION = "Do you want to install it anyway?";
 
 const char *const DEFAULT_LANGUAGE = "default";
 
@@ -70,26 +69,26 @@ const char WRT_WIDGETS_XML_SCHEMA[] = "/usr/etc/wrt-installer/widgets.xsd";
 namespace Jobs {
 namespace WidgetInstall {
 
-TaskWidgetConfig::TaskWidgetConfig(InstallerContext& installContext) :
-    DPL::TaskDecl<TaskWidgetConfig>(this),
+TaskProcessConfig::TaskProcessConfig(InstallerContext& installContext) :
+    DPL::TaskDecl<TaskProcessConfig>(this),
     m_installContext(installContext)
 {
-    AddStep(&TaskWidgetConfig::StartStep);
-    AddStep(&TaskWidgetConfig::StepProcessConfigurationFile);
-    AddStep(&TaskWidgetConfig::ReadLocaleFolders);
-    AddStep(&TaskWidgetConfig::ProcessLocalizedStartFiles);
-    AddStep(&TaskWidgetConfig::ProcessBackgroundPageFile);
-    AddStep(&TaskWidgetConfig::ProcessLocalizedIcons);
-    AddStep(&TaskWidgetConfig::ProcessWidgetInstalledPath);
-    AddStep(&TaskWidgetConfig::ProcessAppControlInfo);
-    AddStep(&TaskWidgetConfig::ProcessSecurityModel);
-    AddStep(&TaskWidgetConfig::StepVerifyFeatures);
-    AddStep(&TaskWidgetConfig::StepVerifyLivebox);
-    AddStep(&TaskWidgetConfig::StepCheckMinVersionInfo);
-    AddStep(&TaskWidgetConfig::EndStep);
+    AddStep(&TaskProcessConfig::StartStep);
+    AddStep(&TaskProcessConfig::ReadLocaleFolders);
+    AddStep(&TaskProcessConfig::StepProcessConfigurationFile);
+    AddStep(&TaskProcessConfig::ProcessLocalizedStartFiles);
+    AddStep(&TaskProcessConfig::ProcessBackgroundPageFile);
+    AddStep(&TaskProcessConfig::ProcessLocalizedIcons);
+    AddStep(&TaskProcessConfig::ProcessWidgetInstalledPath);
+    AddStep(&TaskProcessConfig::ProcessAppControlInfo);
+    AddStep(&TaskProcessConfig::ProcessSecurityModel);
+    AddStep(&TaskProcessConfig::StepVerifyFeatures);
+    AddStep(&TaskProcessConfig::StepVerifyLivebox);
+    AddStep(&TaskProcessConfig::StepCheckMinVersionInfo);
+    AddStep(&TaskProcessConfig::EndStep);
 }
 
-void TaskWidgetConfig::StepProcessConfigurationFile()
+void TaskProcessConfig::StepProcessConfigurationFile()
 {
     Try
     {
@@ -108,7 +107,7 @@ void TaskWidgetConfig::StepProcessConfigurationFile()
         "Parse elements of configuration file and save them");
 }
 
-void TaskWidgetConfig::ReadLocaleFolders()
+void TaskProcessConfig::ReadLocaleFolders()
 {
     _D("Reading locale");
     //Adding default locale
@@ -158,7 +157,7 @@ void TaskWidgetConfig::ReadLocaleFolders()
     }
 }
 
-void TaskWidgetConfig::ProcessLocalizedStartFiles()
+void TaskProcessConfig::ProcessLocalizedStartFiles()
 {
     typedef DPL::String S;
     ProcessStartFile(
@@ -182,7 +181,7 @@ void TaskWidgetConfig::ProcessLocalizedStartFiles()
              "The Widget has no valid start file");
 }
 
-void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path,
+void TaskProcessConfig::ProcessStartFile(const DPL::OptionalString& path,
                                         const DPL::OptionalString& type,
                                         const DPL::OptionalString& encoding,
                                         bool typeForcedInConfig)
@@ -276,7 +275,7 @@ void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path,
     }
 }
 
-void TaskWidgetConfig::ProcessBackgroundPageFile()
+void TaskProcessConfig::ProcessBackgroundPageFile()
 {
     if (!!m_installContext.widgetConfig.configInfo.backgroundPage) {
         // check whether file exists
@@ -291,7 +290,7 @@ void TaskWidgetConfig::ProcessBackgroundPageFile()
     }
 }
 
-void TaskWidgetConfig::ProcessLocalizedIcons()
+void TaskProcessConfig::ProcessLocalizedIcons()
 {
     using namespace WrtDB;
     FOREACH(i, m_installContext.widgetConfig.configInfo.iconsList)
@@ -305,7 +304,7 @@ void TaskWidgetConfig::ProcessLocalizedIcons()
     ProcessIcon(ConfigParserData::Icon(L"icon.jpg"));
 }
 
-void TaskWidgetConfig::ProcessIcon(const WrtDB::ConfigParserData::Icon& icon)
+void TaskProcessConfig::ProcessIcon(const WrtDB::ConfigParserData::Icon& icon)
 {
     _D("enter");
     bool isAnyIconValid = false;
@@ -355,7 +354,7 @@ void TaskWidgetConfig::ProcessIcon(const WrtDB::ConfigParserData::Icon& icon)
     }
 }
 
-void TaskWidgetConfig::ProcessWidgetInstalledPath()
+void TaskProcessConfig::ProcessWidgetInstalledPath()
 {
     _D("ProcessWidgetInstalledPath");
     m_installContext.widgetConfig.widgetInstalledPath =
@@ -363,7 +362,7 @@ void TaskWidgetConfig::ProcessWidgetInstalledPath()
             m_installContext.locations->getPackageInstallationDir());
 }
 
-void TaskWidgetConfig::ProcessAppControlInfo()
+void TaskProcessConfig::ProcessAppControlInfo()
 {
     _D("ProcessAppControlInfo");
     using namespace WrtDB;
@@ -382,7 +381,7 @@ void TaskWidgetConfig::ProcessAppControlInfo()
     }
 }
 
-void TaskWidgetConfig::ProcessSecurityModel()
+void TaskProcessConfig::ProcessSecurityModel()
 {
     // 0104.  If the "required_version" specified in the Web Application's
     // configuration is 2.2 or higher and if the Web Application's
@@ -438,7 +437,7 @@ void TaskWidgetConfig::ProcessSecurityModel()
         "Finished process security model");
 }
 
-void TaskWidgetConfig::StepCheckMinVersionInfo()
+void TaskProcessConfig::StepCheckMinVersionInfo()
 {
     if (!isMinVersionCompatible(
             m_installContext.widgetConfig.webAppType.appType,
@@ -454,7 +453,7 @@ void TaskWidgetConfig::StepCheckMinVersionInfo()
         "Check MinVersion Finished");
 }
 
-void TaskWidgetConfig::StepVerifyFeatures()
+void TaskProcessConfig::StepVerifyFeatures()
 {
     using namespace WrtDB;
     ConfigParserData &data = m_installContext.widgetConfig.configInfo;
@@ -496,7 +495,7 @@ void TaskWidgetConfig::StepVerifyFeatures()
         "Widget Config step2 Finished");
 }
 
-void TaskWidgetConfig::StepVerifyLivebox()
+void TaskProcessConfig::StepVerifyLivebox()
 {
     using namespace WrtDB;
     ConfigParserData &data = m_installContext.widgetConfig.configInfo;
@@ -542,7 +541,7 @@ void TaskWidgetConfig::StepVerifyLivebox()
     }
 }
 
-bool TaskWidgetConfig::isFeatureAllowed(WrtDB::AppType appType,
+bool TaskProcessConfig::isFeatureAllowed(WrtDB::AppType appType,
                                         DPL::String featureName)
 {
     using namespace WrtDB;
@@ -573,7 +572,7 @@ bool TaskWidgetConfig::isFeatureAllowed(WrtDB::AppType appType,
     return false;
 }
 
-bool TaskWidgetConfig::parseVersionString(const std::string &version,
+bool TaskProcessConfig::parseVersionString(const std::string &version,
                                           long &majorVersion,
                                           long &minorVersion,
                                           long &microVersion) const
@@ -598,7 +597,7 @@ bool TaskWidgetConfig::parseVersionString(const std::string &version,
     return true;
 }
 
-bool TaskWidgetConfig::isMinVersionCompatible(
+bool TaskProcessConfig::isMinVersionCompatible(
     WrtDB::AppType appType,
     const DPL::OptionalString &
     widgetVersion) const
@@ -650,7 +649,7 @@ bool TaskWidgetConfig::isMinVersionCompatible(
     return true;
 }
 
-bool TaskWidgetConfig::isTizenWebApp() const
+bool TaskProcessConfig::isTizenWebApp() const
 {
     bool ret = FALSE;
     if (m_installContext.widgetConfig.webAppType.appType
@@ -662,7 +661,7 @@ bool TaskWidgetConfig::isTizenWebApp() const
     return ret;
 }
 
-bool TaskWidgetConfig::parseConfigurationFileBrowser(
+bool TaskProcessConfig::parseConfigurationFileBrowser(
     WrtDB::ConfigParserData& configInfo,
     const std::string& _currentPath)
 {
@@ -684,7 +683,7 @@ bool TaskWidgetConfig::parseConfigurationFileBrowser(
     return true;
 }
 
-bool TaskWidgetConfig::parseConfigurationFileWidget(
+bool TaskProcessConfig::parseConfigurationFileWidget(
     WrtDB::ConfigParserData& configInfo,
     const std::string& _currentPath)
 {
@@ -721,7 +720,7 @@ bool TaskWidgetConfig::parseConfigurationFileWidget(
     }
 }
 
-bool TaskWidgetConfig::locateAndParseConfigurationFile(
+bool TaskProcessConfig::locateAndParseConfigurationFile(
     const std::string& _currentPath,
     WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
     const std::string& baseFolder)
@@ -757,7 +756,7 @@ bool TaskWidgetConfig::locateAndParseConfigurationFile(
     return true;
 }
 
-bool TaskWidgetConfig::fillWidgetConfig(
+bool TaskProcessConfig::fillWidgetConfig(
     WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
     WrtDB::ConfigParserData& configInfo)
 {
@@ -804,7 +803,7 @@ bool TaskWidgetConfig::fillWidgetConfig(
     return true;
 }
 
-void TaskWidgetConfig::processFile(
+void TaskProcessConfig::processFile(
     const std::string& path,
     WrtDB::WidgetRegisterInfo &
     widgetConfiguration)
@@ -817,14 +816,15 @@ void TaskWidgetConfig::processFile(
     }
 }
 
-void TaskWidgetConfig::StartStep()
+void TaskProcessConfig::StartStep()
 {
-    _D("---------- <TaskWidgetConfig> : START ----------");
+    _D("--------- <TaskProcessConfig> : START ----------");
 }
 
-void TaskWidgetConfig::EndStep()
+void TaskProcessConfig::EndStep()
 {
-    _D("---------- <TaskWidgetConfig> : END ----------");
+    _D("--------- <TaskProcessConfig> : END ----------");
 }
+
 } //namespace WidgetInstall
 } //namespace Jobs
similarity index 91%
rename from src/jobs/widget_install/task_widget_config.h
rename to src/jobs/widget_install/task_process_config.h
index fa9b46c..f9cbc57 100755 (executable)
  *    limitations under the License.
  */
 /*
- * @file    task_widget_config.h
+ * @file    task_process_config.h
  * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version 1.0
  * @brief   Implementation file for installer task widget config
  */
-#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_WIDGET_CONFIG_H
-#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_WIDGET_CONFIG_H
+#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_PROCESS_CONFIG_H
+#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_PROCESS_CONFIG_H
 
 #include <set>
 #include <list>
@@ -40,8 +40,8 @@ class InstallerContext;
 namespace Jobs {
 namespace WidgetInstall {
 
-class TaskWidgetConfig :
-    public DPL::TaskDecl<TaskWidgetConfig>
+class TaskProcessConfig :
+    public DPL::TaskDecl<TaskProcessConfig>
 {
   private:
     class Exception
@@ -118,9 +118,9 @@ class TaskWidgetConfig :
                           WrtDB::ConfigParserData& configInfo);
 
   public:
-    TaskWidgetConfig(InstallerContext& installTaskContext);
+    TaskProcessConfig(InstallerContext& installTaskContext);
 };
 } //namespace WidgetInstall
 } //namespace Jobs
 
-#endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_WIDGET_CONFIG_H
+#endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_PROCESS_CONFIG_H