Update wrt-installer_0.0.53
[framework/web/wrt-installer.git] / src / jobs / widget_install / job_widget_install.cpp
index 9dc31b0..24db446 100755 (executable)
@@ -48,6 +48,7 @@
 #include <widget_install/task_update_files.h>
 #include <widget_install/task_new_db_insert.h>
 #include <widget_install/task_remove_backup.h>
+#include <widget_install/task_encrypt_resource.h>
 #include <widget_install/widget_install_errors.h>
 #include <widget_install/widget_install_context.h>
 #include <string>
@@ -76,6 +77,9 @@ const char* REG_TIZENID_PATTERN = "^[-. a-zA-Z0-9_@+=]*$";
 const int RESERVED_COUNT = 20;  //number of chars reserved in name (e.g. for '.desktop')
 const int MAX_TIZENID_LENTH = 255 - RESERVED_COUNT;
 
+static const DPL::String SETTING_VALUE_ENCRYPTION = L"encryption";
+static const DPL::String SETTING_VALUE_ENCRYPTION_ENABLE = L"enable";
+
 class InstallerTaskFail :
     public DPL::TaskDecl<InstallerTaskFail>
 {
@@ -148,7 +152,7 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
             m_installerContext.browserRequest,
             m_installerContext.widgetConfig.pType);
     WidgetUpdateInfo update = detectWidgetUpdate(configData);
-
+    bool needEncryption = detectResourceEncryption(configData);
 
     // Configure installation
     ConfigureResult result = ConfigureInstallation(widgetPath,
@@ -180,6 +184,9 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
         }
         AddTask(new TaskWidgetConfig(m_installerContext));
         AddTask(new TaskCertify(m_installerContext));
+        if (needEncryption) {
+            AddTask(new TaskEncryptResource(m_installerContext));
+        }
         AddTask(new TaskDbUpdate(m_installerContext));
         // TODO: Update progress information for this task
 
@@ -757,5 +764,18 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType(
     return pType;
 }
 
+bool JobWidgetInstall::detectResourceEncryption(const WrtDB::ConfigParserData &configData)
+{
+    FOREACH(it, configData.settingsList)
+    {
+        if (it->m_name == SETTING_VALUE_ENCRYPTION &&
+                it->m_value == SETTING_VALUE_ENCRYPTION_ENABLE) {
+            LogDebug("resource need encryption");
+            return true;
+        }
+    }
+    return false;
+}
+
 } //namespace WidgetInstall
 } //namespace Jobs