[Release]wrt-installer_0.1.6
[framework/web/wrt-installer.git] / 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) {