Platform version check during wgt installation - fixed
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_widget_config.cpp
index c1f0706..5deefb4 100644 (file)
@@ -71,8 +71,9 @@ void InstallerTaskWidgetPopupData::PopupData::addWidgetInfo(
 
 TaskWidgetConfig::TaskWidgetConfig(InstallerContext& installContext) :
     DPL::TaskDecl<TaskWidgetConfig>(this),
-    m_installContext(installContext),
-    WidgetInstallPopup(installContext)
+    WidgetInstallPopup(installContext),
+    m_installContext(installContext)
+
 {
     AddStep(&TaskWidgetConfig::StepProcessConfigurationFile);
     AddStep(&TaskWidgetConfig::ReadLocaleFolders);
@@ -80,12 +81,12 @@ TaskWidgetConfig::TaskWidgetConfig(InstallerContext& installContext) :
     AddStep(&TaskWidgetConfig::ProcessBackgroundPageFile);
     AddStep(&TaskWidgetConfig::ProcessLocalizedIcons);
     AddStep(&TaskWidgetConfig::StepVerifyFeatures);
+    AddStep(&TaskWidgetConfig::StepCheckMinVersionInfo);
 
     if (!GlobalSettings::TestModeEnabled() && !m_installContext.m_quiet) {
         AddStep(&TaskWidgetConfig::StepCancelWidgetInstallationAfterVerifyFeatures);
         AddStep(&TaskWidgetConfig::StepShowWidgetInfo);
         AddStep(&TaskWidgetConfig::StepCancelWidgetInstallation);
-        AddStep(&TaskWidgetConfig::StepCheckMinVersionInfo);
         AddStep(&TaskWidgetConfig::StepCancelWidgetInstallationAfterMinVersion);
         AddStep(&TaskWidgetConfig::StepDeletePopupWin);
     }
@@ -257,7 +258,7 @@ void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path,
             } else {
                 // set property data for hosted start url
                 // Hosted start url only support TIZEN WebApp
-                if (m_installContext.widgetConfig.type ==
+                if (m_installContext.widgetConfig.webAppType ==
                         APP_TYPE_TIZENWEBAPP)
                 {
                     const char *startPath =
@@ -423,10 +424,20 @@ void TaskWidgetConfig::StepShowWidgetInfo()
 void TaskWidgetConfig::StepCheckMinVersionInfo()
 {
     if (!isMinVersionCompatible(
-                m_installContext.widgetConfig.type.appType,
+                m_installContext.widgetConfig.webAppType.appType,
                 m_installContext.widgetConfig.minVersion)) {
-        std::string label = WIDGET_NOT_COMPATIBLE + QUESTION;
-        createInstallPopup(PopupType::WIDGET_MIN_VERSION, label);
+        if(!GlobalSettings::TestModeEnabled() && !m_installContext.m_quiet)
+        {
+            LogDebug("Platform version to low - launching");
+            std::string label = WIDGET_NOT_COMPATIBLE + QUESTION;
+            createInstallPopup(PopupType::WIDGET_MIN_VERSION, label);
+        }
+        else
+        {
+            LogError("Platform version lower than required -> cancelling installation");
+            ThrowMsg(Exceptions::NotAllowed,
+                    "Platform version does not meet requirements");
+        }
     }
 
     m_installContext.job->UpdateProgress(
@@ -448,14 +459,14 @@ void TaskWidgetConfig::StepVerifyFeatures()
         // check feature vender for permission
         // WAC, TIZEN WebApp cannot use other feature
 
-        if (!isFeatureAllowed(m_installContext.widgetConfig.type.appType,
+        if (!isFeatureAllowed(m_installContext.widgetConfig.webAppType.appType,
                               it->name))
         {
             LogInfo("This application type not allowed to use this feature");
             ThrowMsg(
                 Exceptions::WidgetConfigFileInvalid,
                 "This app type [" <<
-                m_installContext.widgetConfig.type.getApptypeToString() <<
+                m_installContext.widgetConfig.webAppType.getApptypeToString() <<
                 "] cannot be allowed to use [" <<
                 DPL::ToUTF8String(it->name) + "] feature");
         }
@@ -522,9 +533,9 @@ void TaskWidgetConfig::setApplicationType()
             currentAppType = APP_TYPE_TIZENWEBAPP;
         }
 
-        if (widgetInfo->type == APP_TYPE_UNKNOWN) {
-            widgetInfo->type = currentAppType;
-        } else if (widgetInfo->type == currentAppType) {
+        if (widgetInfo->webAppType == APP_TYPE_UNKNOWN) {
+            widgetInfo->webAppType = currentAppType;
+        } else if (widgetInfo->webAppType == currentAppType) {
             continue;
         } else {
             ThrowMsg(Exceptions::WidgetConfigFileInvalid,
@@ -533,11 +544,11 @@ void TaskWidgetConfig::setApplicationType()
     }
 
     // If there is no define, type set to WAC 2.0
-    if (widgetInfo->type == APP_TYPE_UNKNOWN) {
-        widgetInfo->type = APP_TYPE_WAC20;
+    if (widgetInfo->webAppType == APP_TYPE_UNKNOWN) {
+        widgetInfo->webAppType = APP_TYPE_WAC20;
     }
 
-    LogInfo("type = [" << widgetInfo->type.getApptypeToString() << "]");
+    LogInfo("type = [" << widgetInfo->webAppType.getApptypeToString() << "]");
 }
 
 bool TaskWidgetConfig::isFeatureAllowed(WrtDB::AppType appType,
@@ -628,13 +639,15 @@ bool TaskWidgetConfig::isMinVersionCompatible(WrtDB::AppType appType,
 
     if (!parseVersionString(version,
                 majorSupported, minorSupported, microSupported)) {
-        LogWarning("Invalid format of WAC version string.");
+        LogWarning("Invalid format of platform version string.");
         return true;
     }
 
     if (majorWidget > majorSupported ||
-            minorWidget > minorSupported ||
-            microWidget > microSupported) {
+            (majorWidget == majorSupported && minorWidget > minorSupported) ||
+            (majorWidget == majorSupported && minorWidget == minorSupported
+                    && microWidget > microSupported))
+    {
         LogInfo("Platform doesn't support this widget.");
         return false;
     }
@@ -644,7 +657,7 @@ bool TaskWidgetConfig::isMinVersionCompatible(WrtDB::AppType appType,
 bool TaskWidgetConfig::isTizenWebApp() const
 {
     bool ret = FALSE;
-    if (m_installContext.widgetConfig.type.appType
+    if (m_installContext.widgetConfig.webAppType.appType
             == WrtDB::AppType::APP_TYPE_TIZENWEBAPP)
         ret = TRUE;
 
@@ -800,13 +813,9 @@ bool TaskWidgetConfig::fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfig
         }
     }
     if (!!configInfo.tizenId) {
-        if (!pWidgetConfigInfo.pkgname) {
-            pWidgetConfigInfo.pkgname = configInfo.tizenId;
-        } else {
-            if (pWidgetConfigInfo.pkgname != configInfo.tizenId) {
-                LogError("Invalid archive - Tizen ID not same error");
-                return false;
-            }
+        if (pWidgetConfigInfo.pkgname_NOTNULL != *configInfo.tizenId) {
+            LogError("Invalid archive - Tizen ID not same error");
+            return false;
         }
     }
     if (!!configInfo.version) {