Fixed can't uninstall using pkgid from pkgcmd
authorSoyoung Kim <sy037.kim@samsung.com>
Thu, 21 Feb 2013 08:40:09 +0000 (17:40 +0900)
committerSoyoung Kim <sy037.kim@samsung.com>
Thu, 21 Feb 2013 08:43:18 +0000 (17:43 +0900)
[Issue#] N/A
[Problem] can't uninstall from pkgcmd
[Cause] pkg_plugin_app_is_installed() has a bug about pkgid.
[Solution] Add routine to get appid if parameter is pkgid in pkg_plugin_app_is_installed().
[SCMRequest] N/A

src/pkg-manager/backendlib.cpp

index 3eed3f9..37952c1 100644 (file)
@@ -23,6 +23,7 @@
  *             to package manager
  */
 #include "package-manager-plugin.h"
+#include <regex.h>
 #include <dlog.h>
 #include <dpl/wrt-dao-ro/global_config.h>
 #include <vcore/VCore.h>
@@ -72,12 +73,28 @@ static void pkg_native_plugin_on_unload()
 
 static int pkg_plugin_app_is_installed(const char *pkg_name)
 {
+    const char* REG_PKGID_PATTERN = "^[a-zA-Z0-9]{10}$";
     LogDebug("pkg_plugin_app_is_installed() is called");
 
     WrtDB::WrtDatabase::attachToThreadRO();
 
-    bool result = WidgetDAOReadOnly::isWidgetInstalled(
-            DPL::FromUTF8String(pkg_name));
+    regex_t reg;
+    if (regcomp(&reg, REG_PKGID_PATTERN, REG_NOSUB | REG_EXTENDED) != 0) {
+        LogDebug("Regcomp failed");
+    }
+
+    WrtDB::TizenAppId appid;
+
+    if ((regexec(&reg, pkg_name,
+                    static_cast<size_t>(0), NULL, 0) == 0))
+    {
+        WrtDB::TizenPkgId pkgid(DPL::FromUTF8String(pkg_name));
+        appid = WidgetDAOReadOnly::getTzAppId(pkgid);
+    } else {
+        appid = DPL::FromUTF8String(pkg_name);
+    }
+
+    bool result = WidgetDAOReadOnly::isWidgetInstalled(appid);
     WrtDB::WrtDatabase::detachFromThread();
 
     if (result) {