Fix abnormal behavior of pkginfo functions 56/98656/3
authorJunghyun Yeon <jungh.yeon@samsung.com>
Fri, 18 Nov 2016 06:28:09 +0000 (15:28 +0900)
committerjongmyeong ko <jongmyeong.ko@samsung.com>
Wed, 23 Nov 2016 01:14:11 +0000 (17:14 -0800)
- If package_disable filter has applied
  hen retrieving pkg info, it will be used.
- Otherwise, package_disable='false' filter will
  be applied automatically

Change-Id: Ia4a76bf34109ec8470d58b29ce038d9d92677622
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/pkgmgrinfo_pkginfo.c

index d0c2e7c..f9cdebe 100644 (file)
@@ -60,6 +60,16 @@ static gint __compare_func(gconstpointer data1, gconstpointer data2)
                return -1;
 }
 
+static gint __pkg_disable_chk_func(gconstpointer data1, gconstpointer data2)
+{
+       pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
+
+       if (node->prop == E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE)
+               return 0;
+       else
+               return 1;
+}
+
 static void __destroy_each_node(gpointer data, gpointer user_data)
 {
        ret_if(data == NULL);
@@ -262,6 +272,20 @@ static void __free_packages(gpointer data)
        pkgmgrinfo_basic_free_package((package_x *)data);
 }
 
+static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter)
+{
+       GSList *link;
+
+       if (filter == NULL)
+               return false;
+
+       link = g_slist_find_custom(filter->list, NULL, __pkg_disable_chk_func);
+       if (link)
+               return true;
+
+       return false;
+}
+
 static int __bind_params(sqlite3_stmt *stmt, GList *params)
 {
        GList *tmp_list = NULL;
@@ -348,7 +372,10 @@ static int _pkginfo_get_packages(uid_t uid, const char *locale,
        }
 
        /* add package_disable='false' clause by default */
-       pkgmgrinfo_pkginfo_filter_add_bool(tmp_filter, PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, false);
+       if (__check_disable_filter_exist(tmp_filter) == false)
+               pkgmgrinfo_pkginfo_filter_add_bool(tmp_filter,
+                               PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, false);
+
 
        query_len = strlen(query_raw);
        snprintf(query, MAX_QUERY_LEN - 1, "%s", query_raw);