Fixed get detail information about widget from backend.
authorSoyoung Kim <sy037.kim@samsung.com>
Tue, 9 Apr 2013 07:08:48 +0000 (16:08 +0900)
committerGerrit Code Review <gerrit2@kim11>
Tue, 9 Apr 2013 07:13:51 +0000 (16:13 +0900)
[Issue#] N/A
[Problem] couldn't get detail information from widget file.
[Cause] counldn't get dao from pkgid.
[Solution] fixed get information from pkgid.
[SCMRequest] N/A

Change-Id: I095ad3d714cc3c9a8fb443aaf8bf0367ca32e7e9

src/pkg-manager/backendlib.cpp

index c7a58c3..e569561 100644 (file)
@@ -98,23 +98,23 @@ static int pkg_plugin_app_is_installed(const char *pkg_name)
 
     WrtDB::TizenAppId appid;
 
-    if ((regexec(&reg, pkg_name,
+    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);
+        LogError("Invalid argument : " << pkg_name);
+        return FALSE;
     }
 
-    bool result = WidgetDAOReadOnly::isWidgetInstalled(appid);
-    WrtDB::WrtDatabase::detachFromThread();
-
-    if (result) {
-        return TRUE;
-    } else {
+    Try {
+        WrtDB::TizenPkgId pkgid(DPL::FromUTF8String(pkg_name));
+        appid = WidgetDAOReadOnly::getTzAppId(pkgid);
+        LogDebug("appid : " << appid);
+    } Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) {
+        WrtDB::WrtDatabase::detachFromThread();
         return FALSE;
     }
+    WrtDB::WrtDatabase::detachFromThread();
+    return TRUE;
 }
 
 static int pkg_plugin_get_installed_apps_list(const char * /*category*/,
@@ -173,9 +173,18 @@ static int pkg_plugin_get_app_detail_info(
     LogDebug("pkg_plugin_get_app_detail_info() is called");
 
     WrtDB::WrtDatabase::attachToThreadRO();
-    int handle = WidgetDAOReadOnly::getHandle(
-            DPL::FromUTF8String(pkg_name));
-    WidgetDAOReadOnly widget(handle);
+
+    WrtDB::TizenAppId appid;
+    Try {
+        WrtDB::TizenPkgId pkgid(DPL::FromUTF8String(pkg_name));
+        appid = WidgetDAOReadOnly::getTzAppId(pkgid);
+        LogDebug("appid : " << appid);
+    } Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) {
+        WrtDB::WrtDatabase::detachFromThread();
+        return FALSE;
+    }
+
+    WidgetDAOReadOnly widget(appid);
 
     DPL::Optional<DPL::String> version = widget.getVersion();
     DPL::Optional<DPL::String> id = widget.getGUID();
@@ -186,12 +195,14 @@ static int pkg_plugin_get_app_detail_info(
                 DPL::ToUTF8String(*version).c_str(),
                 PKG_VERSION_STRING_LEN_MAX - 1);
     }
-    snprintf(pkg_detail_info->optional_id, PKG_NAME_STRING_LEN_MAX, "%d",
-             handle);
+    snprintf(pkg_detail_info->pkgid, PKG_NAME_STRING_LEN_MAX, "%s",
+             pkg_name);
+    snprintf(pkg_detail_info->optional_id, PKG_NAME_STRING_LEN_MAX, "%s",
+             DPL::ToUTF8String(appid).c_str());
     WidgetLocalizedInfo localizedInfo;
 
     if (locale.IsNull()) {
-        LogError("is NULL");
+        LogDebug("locale is NULL");
         DPL::String languageTag(L"");
         localizedInfo = widget.getLocalizedInfo(languageTag);
     } else {
@@ -207,6 +218,11 @@ static int pkg_plugin_get_app_detail_info(
     strncpy(pkg_detail_info->pkg_type, "wgt", PKG_TYPE_STRING_LEN_MAX);
     strncpy(pkg_detail_info->pkg_name, pkg_name, PKG_NAME_STRING_LEN_MAX - 1);
 
+    std::string min_version = DPL::ToUTF8String((*widget.getMinimumWacVersion()));
+
+    strncpy(pkg_detail_info->min_platform_version, min_version.c_str(),
+            PKG_VERSION_STRING_LEN_MAX - 1);
+
     /* set installed time */
     pkg_detail_info->installed_time = widget.getInstallTime();