Fix widget version support
authorLukasz Marek <l.marek@samsung.com>
Mon, 27 May 2013 16:44:55 +0000 (18:44 +0200)
committerGerrit Code Review <gerrit2@kim11>
Wed, 29 May 2013 14:29:47 +0000 (23:29 +0900)
[Issue#] N/A
[Problem] wrt-installer was able to install older or the save version of the widget
[Cause] N/A
[Solution] Check version before installation
[SCMRequest] N/A

Change-Id: Id00d0a0587526e457290e32ff572545fa7972f17

src/jobs/job_exception_error.h
src/jobs/widget_install/job_widget_install.cpp
src/jobs/widget_install/job_widget_install.h
src/jobs/widget_install/widget_install_errors.h

index 1caba99..86e5a18 100644 (file)
@@ -42,6 +42,7 @@ enum Type
     ErrorPackageNotFound,                       ///<
     ErrorPackageInvalid,                        ///< invalid widget package
     ErrorPackageLowerVersion,                   ///< given version is lower
+    ErrorPackageTheSameVersion,                 ///< given version is the same
     ErrorPackageExecutableNotFound,
 
     ErrorManifestNotFound = 11,                 ///<
index 73efb6c..41d07ad 100644 (file)
@@ -128,6 +128,9 @@ class InstallerTaskFail :
         } else if (m_result == ConfigureResult::Failed_LowerVersion) {
             ThrowMsg(Jobs::WidgetInstall::Exceptions::PackageLowerVersion,
                     "package version is lower than installed version");
+        } else if (m_result == ConfigureResult::Failed_TheSameVersion) {
+            ThrowMsg(Jobs::WidgetInstall::Exceptions::PackageTheSameVersion,
+                    "package version is the same as installed version");
         } else if (m_result == ConfigureResult::Failed_AlreadyInstalled) {
             ThrowMsg(Jobs::WidgetInstall::Exceptions::PackageAlreadyInstalled,
                     "package is already installed");
@@ -562,6 +565,16 @@ ConfigureResult JobWidgetInstall::checkWidgetUpdate(
     LogInfo("incoming version = '" << update.incomingVersion);
     LogInfo("Tizen AppID = " << update.tzAppId);
 
+    if (update.incomingVersion < update.existingVersion) {
+        LogError("Widget is older than installed one.");
+        return ConfigureResult::Failed_LowerVersion;
+    }
+
+    if (update.incomingVersion == update.existingVersion) {
+        LogError("Widget is already installed in this version.");
+        return ConfigureResult::Failed_TheSameVersion;
+    }
+
     // Check running state
     bool isRunning = false;
     int ret =
index 2b2f120..909c0ee 100644 (file)
@@ -44,6 +44,7 @@ enum class ConfigureResult
     Failed,
     Failed_InvalidConfig,
     Failed_LowerVersion,
+    Failed_TheSameVersion,
     Failed_AlreadyInstalled,
     Failed_WidgetRunning,
     Failed_DrmError,
index 653c84d..b24f511 100644 (file)
@@ -45,6 +45,7 @@ DECLARE_JOB_EXCEPTION(Base, PluginsSubdirectory, ErrorPackageInvalid)
 DECLARE_JOB_EXCEPTION(Base, RDSDeltaFailure, ErrorPackageInvalid)
 
 DECLARE_JOB_EXCEPTION(Base, PackageLowerVersion, ErrorPackageLowerVersion)
+DECLARE_JOB_EXCEPTION(Base, PackageTheSameVersion, ErrorPackageTheSameVersion)
 
 DECLARE_JOB_EXCEPTION(Base, ManifestInvalid, ErrorManifestInvalid)