[Release] wrt-installer_0.0.90
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_widget_config.cpp
index 8423144..eefaf0a 100644 (file)
@@ -80,13 +80,14 @@ TaskWidgetConfig::TaskWidgetConfig(InstallerContext& installContext) :
     AddStep(&TaskWidgetConfig::ProcessLocalizedStartFiles);
     AddStep(&TaskWidgetConfig::ProcessBackgroundPageFile);
     AddStep(&TaskWidgetConfig::ProcessLocalizedIcons);
+    AddStep(&TaskWidgetConfig::ProcessWidgetInstalledPath);
     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);
     }
@@ -261,9 +262,9 @@ void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path,
                 if (m_installContext.widgetConfig.webAppType ==
                         APP_TYPE_TIZENWEBAPP)
                 {
-                    const char *startPath =
-                        DPL::ToUTF8String(startFileData.path).c_str();
-                    if (strstr(startPath, "http") == startPath) {
+                    std::string startPath =  DPL::ToUTF8String(startFileData.path);
+
+                    if (strstr(startPath.c_str(), "http") == startPath.c_str()) {
                         WidgetRegisterInfo::StartFileProperties
                             startFileProperties;
                         if (!!type) {
@@ -363,6 +364,13 @@ void TaskWidgetConfig::ProcessIcon(const WrtDB::ConfigParserData::Icon& icon)
     }
 }
 
+void TaskWidgetConfig::ProcessWidgetInstalledPath()
+{
+    LogDebug("ProcessWidgetInstalledPath");
+    m_installContext.widgetConfig.widgetInstalledPath =
+        DPL::FromUTF8String(m_installContext.locations->getPackageInstallationDir());
+}
+
 void TaskWidgetConfig::StepCancelWidgetInstallationAfterVerifyFeatures()
 {
     LogDebug("StepCancelWidgetInstallationAfterVerifyFeatures");
@@ -426,8 +434,18 @@ void TaskWidgetConfig::StepCheckMinVersionInfo()
     if (!isMinVersionCompatible(
                 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(
@@ -550,7 +568,9 @@ bool TaskWidgetConfig::isFeatureAllowed(WrtDB::AppType appType,
     LogInfo("FetureName = [" << featureName << "]");
 
     AppType featureType = APP_TYPE_UNKNOWN;
-    const char* feature = DPL::ToUTF8String(featureName).c_str();
+    std::string featureStr = DPL::ToUTF8String(featureName);
+    const char* feature = featureStr.c_str();
+
     // check prefix of  feature name
     if (strstr(feature, PluginsPrefix::TIZENPluginsPrefix) == feature) {
         // Tizen WebApp feature
@@ -629,13 +649,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;
     }
@@ -801,14 +823,10 @@ 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 != *configInfo.tizenId) {
+           LogError("Invalid archive - Tizen ID not same error");
+           return false;
+       }
     }
     if (!!configInfo.version) {
         if (!pWidgetConfigInfo.version) {