[Release] wrt-installer_0.1.54
[framework/web/wrt-installer.git] / src / jobs / widget_install / job_widget_install.cpp
index aa46a4e..72c2332 100644 (file)
@@ -90,6 +90,7 @@ const size_t PACKAGE_ID_LENGTH = 10;
 
 static const DPL::String SETTING_VALUE_ENCRYPTION = L"encryption";
 static const DPL::String SETTING_VALUE_ENCRYPTION_ENABLE = L"enable";
+static const DPL::String SETTING_VALUE_ENCRYPTION_DISABLE = L"disable";
 const DPL::String SETTING_VALUE_INSTALLTOEXT_NAME =
     L"install-location";
 const DPL::String SETTING_VALUE_INSTALLTOEXT_PREPER_EXT =
@@ -139,6 +140,9 @@ class InstallerTaskFail :
         } else if (m_result == ConfigureResult::Failed_DrmError) {
             ThrowMsg(Jobs::WidgetInstall::Exceptions::DRMFailed,
                     "drm failed");
+        } else if (m_result == ConfigureResult::Failed_NotSupportRDSUpdate) {
+            ThrowMsg(Jobs::WidgetInstall::Exceptions::NotSupportRDSUpdate,
+                    "RDS update failed");
         } else {
             ThrowMsg(Jobs::WidgetInstall::Exceptions::NotAllowed,
                     "widget installation or update not allowed!");
@@ -480,6 +484,9 @@ ConfigureResult JobWidgetInstall::ConfigureInstallation(
             // Already installed TizenAppId. return failed
             return ConfigureResult::Failed_AlreadyInstalled;
         }
+        if (!checkSupportRDSUpdate(configData)) {
+            return ConfigureResult::Failed_NotSupportRDSUpdate;
+        }
         m_installerContext.isUpdateMode = true;
     }
     Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) {
@@ -1104,5 +1111,40 @@ bool JobWidgetInstall::DecryptDRMWidget(std::string /*widgetPath*/,
     /* TODO */
     return false;
 }
+
+bool JobWidgetInstall::checkSupportRDSUpdate(const WrtDB::ConfigParserData
+        &configInfo)
+{
+    if (m_installerContext.mode.command ==
+            InstallMode::Command::REINSTALL)
+    {
+        DPL::String configValue = SETTING_VALUE_ENCRYPTION_DISABLE;
+        DPL::String dbValue = SETTING_VALUE_ENCRYPTION_DISABLE;
+
+        WidgetDAOReadOnly dao(m_installerContext.widgetConfig.tzAppid);
+        WrtDB::WidgetSettings widgetSettings;
+        dao.getWidgetSettings(widgetSettings);
+
+        FOREACH(it, widgetSettings) {
+            if (it->settingName == SETTING_VALUE_ENCRYPTION) {
+                dbValue = it->settingValue;
+            }
+        }
+
+        FOREACH(data, configInfo.settingsList)
+        {
+            if (data->m_name == SETTING_VALUE_ENCRYPTION) 
+            {
+                configValue = data->m_value;
+            }
+        }
+        if (configValue != dbValue) {
+            LogError("Not Support RDS mode because of encryption setting");
+            return false;
+        }
+    }
+
+    return true;
+}
 } //namespace WidgetInstall
 } //namespace Jobs