Change condition of reinstall preload app after uninstall
authorSoyoung Kim <sy037.kim@samsung.com>
Thu, 18 Jul 2013 06:30:54 +0000 (15:30 +0900)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Tue, 23 Jul 2013 10:33:04 +0000 (10:33 +0000)
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] using check system app api.
[SCMRequest] N/A

Change-Id: Ie909a0308ec331955e056e7fb7fea83240befcc1

src/wrt-installer/wrt-installer.cpp
src/wrt-installer/wrt-installer.h

index 5f1ed02..4221367 100644 (file)
@@ -46,7 +46,7 @@
 #include <parser_runner.h>
 #include <widget_parser.h>
 #include <root_parser.h>
-#include <package-manager.h>
+#include <pkgmgr-info.h>
 
 #include <Elementary.h>
 
@@ -298,9 +298,32 @@ void WrtInstaller::OnCreate()
             AddStep(&WrtInstaller::installStep);
             break;
         case PKGMGR_REQ_UNINSTALL:
-            m_name = m_argv[4];
-            AddStep(&WrtInstaller::uninstallPkgNameStep);
-            break;
+            {
+                m_name = m_argv[4];
+                pkgmgrinfo_pkginfo_h handle = NULL;
+                bool system_app = false; // system app is preloaded and unremovable.
+                bool update = false;
+
+                if (0 == pkgmgrinfo_pkginfo_get_pkginfo(m_name.c_str(), &handle)) {
+                    if (0 > pkgmgrinfo_pkginfo_is_system(handle, &system_app)) {
+                        LogError("Can't get package information : " << m_name);
+                    }
+                    if (0 > pkgmgrinfo_pkginfo_is_update(handle, &update)) {
+                        LogError("Can't get package information about update : "
+                                << m_name);
+                    }
+                }
+
+                LogDebug("system app : " << system_app);
+                LogDebug("update : " << update);
+
+                if (system_app && update) {
+                    AddStep(&WrtInstaller::removeUpdateStep);
+                } else {
+                    AddStep(&WrtInstaller::uninstallPkgNameStep);
+                }
+                break;
+            }
         case PKGMGR_REQ_REINSTALL:
             m_packagePath = m_argv[4];
             m_installMode.command = InstallMode::Command::REINSTALL;
@@ -530,30 +553,25 @@ void WrtInstaller::uninstallPkgNameStep()
 {
     LogDebug("Uninstalling widget ...");
     LogDebug("Package name : " << m_name);
-    pkgmgr_pkginfo_h handle;
-    int ret = -1;
-    bool preload = false;
 
-    if (0 == pkgmgr_pkginfo_get_pkginfo(m_name.c_str(), &handle)) {
-        if (pkgmgr_pkginfo_is_preload(handle, &preload) < 0) {
-            LogError("Can't get package information : " << m_name);
-        }
-    }
+    wrt_uninstall_widget(m_name.c_str(), this,
+            &staticWrtStatusCallback,
+            (m_installByPkgmgr)
+            ? &staticWrtUninstallProgressCallback : NULL,
+            pkgmgrSignalInterface);
+}
+
+void WrtInstaller::removeUpdateStep()
+{
+    LogDebug("This web app need to initialize preload app");
+    LogDebug("Package name : " << m_name);
+
+    wrt_uninstall_widget(m_name.c_str(), this,
+            &staticWrtInitializeToPreloadCallback,
+            (m_installByPkgmgr)
+            ? &staticWrtUninstallProgressCallback : NULL,
+            pkgmgrSignalInterface);
 
-    if (preload) {
-        LogDebug("This web app need to initialize preload app");
-        wrt_uninstall_widget(m_name.c_str(), this,
-                &staticWrtInitializeToPreloadCallback,
-                (m_installByPkgmgr)
-                ? &staticWrtUninstallProgressCallback : NULL,
-                pkgmgrSignalInterface);
-    } else {
-        wrt_uninstall_widget(m_name.c_str(), this,
-                &staticWrtStatusCallback,
-                (m_installByPkgmgr)
-                ? &staticWrtUninstallProgressCallback : NULL,
-                pkgmgrSignalInterface);
-    }
 }
 
 void WrtInstaller::unistallWgtFileStep()
index f8aeebd..94d515d 100644 (file)
@@ -95,6 +95,7 @@ class WrtInstaller :
     void installPluginsStep();
     void uninstallPkgNameStep();
     void unistallWgtFileStep();
+    void removeUpdateStep();
     void shutdownStep();
 
     // Static callbacks