Add filter prop for support-disable on pkg_info
[platform/core/appfw/slp-pkgmgr.git] / tool / pkg_info.c
old mode 100755 (executable)
new mode 100644 (file)
index 55d2d40..8b6dc25
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/types.h>
+
 #include <vconf.h>
+//Work around for https://bugs.tizen.org/jira/browse/TC-2399
+#include <ail_vconf.h>
 #include <pkgmgr_parser.h>
 #include <pkgmgr-info.h>
+
 #include "package-manager.h"
 #include "package-manager-types.h"
-#include "pkgmgr-dbinfo.h"
 #include "pkgmgr_installer.h"
 
 #define OWNER_ROOT 0
@@ -50,17 +53,16 @@ static int __add_app_filter(uid_t uid);
 static int __add_pkg_filter(uid_t uid);
 static int __insert_manifest_in_db(char *manifest, uid_t uid);
 static int __remove_manifest_from_db(char *manifest, uid_t uid);
-static int __set_pkginfo_in_db(char *pkgid, uid_t uid);
-static int __set_certinfo_in_db(char *pkgid);
-static int __get_certinfo_from_db(char *pkgid);
+static int __set_certinfo_in_db(char *pkgid, uid_t uid);
+static int __get_certinfo_from_db(char *pkgid, uid_t uid);
 static int __del_certinfo_from_db(char *pkgid);
 static int __get_integer_input_data(void);
 char *__get_string_input_data(void);
-static int __pkg_list_cb (const pkgmgr_pkginfo_h handle, void *user_data);
+static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data);
 static int __app_category_list_cb(const char *category_name, void *user_data);
-static int __app_control_list_cb(pkgmgrinfo_appcontrol_h handle, void *user_data);
+static int __app_control_list_cb(const char *operation, const char *uri, const char *mime, void *user_data);
 static int __app_metadata_list_cb(const char *metadata_name, const char *metadata_value, void *user_data);
-int app_func(const pkgmgr_appinfo_h handle, void *user_data);
+int app_func(const pkgmgrinfo_appinfo_h handle, void *user_data);
 
 static void __get_pkgmgrinfo_pkginfo(const pkgmgrinfo_pkginfo_h handle, void *user_data)
 {
@@ -72,7 +74,7 @@ static void __get_pkgmgrinfo_pkginfo(const pkgmgrinfo_pkginfo_h handle, void *us
        char *author_href = NULL;
        char *root_path = NULL;
        char *mainappid = NULL;
-       pkgmgr_install_location location = 0;
+       pkgmgrinfo_install_location location = 0;
        char *icon = NULL;
        char *label = NULL;
        char *desc = NULL;
@@ -281,8 +283,6 @@ static void __print_usage()
        printf("\tpkginfo --appcontrol <appid>\n\n");
        printf("To insert|remove manifest info in DB\n");
        printf("\tpkginfo --[imd|rmd] <manifest file name>\n\n");
-       printf("To set pkginfo in DB\n");
-       printf("\tpkginfo --setdb <pkgid>\n\n");
        printf("To set manifest validation\n");
        printf("\tpkginfo --check <manifest file name>\n\n");
        printf("To set cert info in DB\n");
@@ -415,6 +415,8 @@ static int __add_app_filter(uid_t uid)
                printf("15 --> filter by app taskmanage [0|1]\n");
                printf("16 --> filter by app hwacceleration\n");
                printf("17 --> filter by app screenreader\n");
+               printf("18 --> filter by app ui-gadget [0|1]\n");
+               printf("19 --> filter by app support disable [0|1]\n");
                choice = __get_integer_input_data();
                switch (choice) {
                case 0:
@@ -619,6 +621,26 @@ static int __add_app_filter(uid_t uid)
                        free(value);
                        value = NULL;
                        break;
+               case 18:
+                       val = __get_integer_input_data();
+                       ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
+                                       PMINFO_APPINFO_PROP_APP_UI_GADGET, val);
+                       if (ret < 0) {
+                               printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+                               ret = -1;
+                               goto err;
+                       }
+                       break;
+               case 19:
+                       val = __get_integer_input_data();
+                       ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
+                                       PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE, val);
+                       if (ret < 0) {
+                               printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+                               ret = -1;
+                               goto err;
+                       }
+                       break;
                default:
                        printf("Invalid filter property\n");
                                pkgmgrinfo_appinfo_filter_destroy(handle);
@@ -669,6 +691,8 @@ static int __add_pkg_filter(uid_t uid)
                printf("13 --> filter by package appsetting [0|1]\n");
                printf("14 --> filter by package size\n");
                printf("15 --> filter by package installed storage[installed_internal | installed_external]\n");
+               printf("16 --> filter by package privilege\n");
+               printf("17 --> filter by package support disable [0|1]\n");
                choice = __get_integer_input_data();
                switch (choice) {
                case 0:
@@ -850,9 +874,31 @@ static int __add_pkg_filter(uid_t uid)
                        free(value);
                        value = NULL;
                        break;
+               case 16:
+                       value = __get_string_input_data();
+                       ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
+                                       PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE,
+                                       value);
+                       if (ret < 0) {
+                               printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+                               ret = -1;
+                               goto err;
+                       }
+                       free(value);
+                       value = NULL;
+                       break;
+               case 17:
+                       val = __get_integer_input_data();
+                       ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
+                               PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE, val);
+                       if (ret < 0) {
+                               printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
+                               ret = -1;
+                               goto err;
+                       }
+                       break;
                default:
                        printf("Invalid filter property\n");
-                               pkgmgrinfo_pkginfo_filter_destroy(handle);
                        ret = -1;
                        goto err;
                }
@@ -1050,7 +1096,7 @@ static int __del_certinfo_from_db(char *pkgid)
        return 0;
 }
 
-static int __get_certinfo_from_db(char *pkgid)
+static int __get_certinfo_from_db(char *pkgid, uid_t uid)
 {
        if (pkgid == NULL) {
                printf("pkgid is NULL\n");
@@ -1060,15 +1106,15 @@ static int __get_certinfo_from_db(char *pkgid)
        int choice = -1;
        int i = 0;
        const char *value = NULL;
-       pkgmgr_certinfo_h handle = NULL;
-       ret = pkgmgr_pkginfo_create_certinfo(&handle);
+       pkgmgrinfo_certinfo_h handle = NULL;
+       ret = pkgmgrinfo_pkginfo_create_certinfo(&handle);
        if (ret < 0) {
-               printf("pkgmgr_pkginfo_create_certinfo failed\n");
+               printf("pkgmgrinfo_pkginfo_create_certinfo failed\n");
                return -1;
        }
-       ret = pkgmgr_pkginfo_load_certinfo(pkgid, handle);
+       ret = pkgmgrinfo_pkginfo_load_certinfo(pkgid, handle, uid);
        if (ret < 0) {
-               printf("pkgmgr_pkginfo_load_certinfo failed\n");
+               printf("pkgmgrinfo_pkginfo_load_certinfo failed\n");
                return -1;
        }
        while (choice != 10)
@@ -1090,13 +1136,13 @@ static int __get_certinfo_from_db(char *pkgid)
                case 0:
                        for (i = 0; i < 9; i++)
                        {
-                               pkgmgr_pkginfo_get_cert_value(handle, i, &value);
+                               pkgmgrinfo_pkginfo_get_cert_value(handle, i, &value);
                                if (value)
                                        printf("cert type[%d] value = %s\n", i, value);
                        }
-                       ret = pkgmgr_pkginfo_destroy_certinfo(handle);
+                       ret = pkgmgrinfo_pkginfo_destroy_certinfo(handle);
                        if (ret < 0) {
-                               printf("pkgmgr_pkginfo_destroy_certinfo failed\n");
+                               printf("pkgmgrinfo_pkginfo_destroy_certinfo failed\n");
                                return -1;
                        }
                        return 0;
@@ -1109,14 +1155,14 @@ static int __get_certinfo_from_db(char *pkgid)
                case 7:
                case 8:
                case 9:
-                       ret = pkgmgr_pkginfo_get_cert_value(handle, choice - 1, &value);
+                       ret = pkgmgrinfo_pkginfo_get_cert_value(handle, choice - 1, &value);
                        if (value)
                                printf("cert type[%d] value = %s\n", choice - 1, value);
                        break;
                case 10:
-                       ret = pkgmgr_pkginfo_destroy_certinfo(handle);
+                       ret = pkgmgrinfo_pkginfo_destroy_certinfo(handle);
                        if (ret < 0) {
-                               printf("pkgmgr_pkginfo_destroy_certinfo failed\n");
+                               printf("pkgmgrinfo_pkginfo_destroy_certinfo failed\n");
                                return -1;
                        }
                        return 0;
@@ -1173,7 +1219,7 @@ static int __compare_app_certinfo_from_db(char *lhs_appid, char *rhs_appid, uid_
        return 0;
 }
 
-static int __set_certinfo_in_db(char *pkgid)
+static int __set_certinfo_in_db(char *pkgid, uid_t uid)
 {
        if (pkgid == NULL) {
                printf("pkgid is NULL\n");
@@ -1204,7 +1250,7 @@ static int __set_certinfo_in_db(char *pkgid)
                choice = __get_integer_input_data();
                switch (choice) {
                case 0:
-                       ret = pkgmgr_installer_save_certinfo(pkgid, handle);
+                       ret = pkgmgr_installer_save_certinfo(pkgid, handle, uid);
                        if (ret < 0) {
                                printf("pkgmgr_installer_save_certinfo failed\n");
                                pkgmgr_installer_destroy_certinfo_set_handle(handle);
@@ -1344,227 +1390,6 @@ err:
        return ret;
 }
 
-static int __set_pkginfo_in_db(char *pkgid, uid_t uid)
-{
-       if (pkgid == NULL) {
-               printf("pkgid is NULL\n");
-               return -1;
-       }
-       int ret = 0;
-       int choice = -1;
-       int preload = -1;
-       int removable = -1;
-       int location = -1;
-       char *locale = NULL;
-       pkgmgr_pkgdbinfo_h handle = NULL;
-       INSTALL_LOCATION storage = 0;
-
-       if(uid != GLOBAL_USER)
-               ret = pkgmgrinfo_create_pkgusrdbinfo(pkgid, uid, &handle);
-       else
-               ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
-       if (ret < 0) {
-               printf("pkgmgrinfo_create_pkgdbinfo failed\n");
-               return -1;
-       }
-       while (choice != 0)
-       {
-               printf("Enter the choice you want to set\n");
-               printf("0 --> to set data in DB\n");
-               printf("1 --> pkg type\n");
-               printf("2 --> pkg version\n");
-               printf("3 --> pkg instal location\n");
-               printf("4 --> pkg label\n");
-               printf("5 --> pkg icon\n");
-               printf("6 --> pkg description\n");
-               printf("7 --> pkg author\n");
-               printf("8 --> pkg removable\n");
-               printf("9 --> pkg preload\n");
-               printf("10 --> pkg size\n");
-               printf("11 --> pkg installed storage\n");
-               choice = __get_integer_input_data();
-               switch (choice) {
-               case 0:
-                       ret = pkgmgrinfo_save_pkgdbinfo(handle);
-                       if (ret < 0) {
-                               printf("pkgmgrinfo_save_pkgdbinfo failed\n");
-                               pkgmgrinfo_destroy_pkgdbinfo(handle);
-                               return -1;
-                       }
-                       ret = pkgmgrinfo_destroy_pkgdbinfo(handle);
-                       if (ret < 0) {
-                               printf("pkgmgrinfo_destroy_pkgdbinfo failed\n");
-                               return -1;
-                       }
-                       break;
-               case 1:
-                       printf("Enter type: \n");
-                       char *type = __get_string_input_data();
-                       ret = pkgmgrinfo_set_type_to_pkgdbinfo(handle, type);
-                       if (ret < 0) {
-                               printf("pkgmgrinfo_set_type_to_pkgdbinfo failed\n");
-                               pkgmgrinfo_destroy_pkgdbinfo(handle);
-                               free(type);
-                               return -1;
-                       }
-                       free(type);
-                       break;
-               case 2:
-                       printf("Enter version: \n");
-                       char *version = __get_string_input_data();
-                       ret = pkgmgrinfo_set_version_to_pkgdbinfo(handle, version);
-                       if (ret < 0) {
-                               printf("pkgmgrinfo_set_version_to_pkgdbinfo failed\n");
-                               pkgmgrinfo_destroy_pkgdbinfo(handle);
-                               free(version);
-                               return -1;
-                       }
-                       free(version);
-                       break;
-               case 3:
-                       printf("Enter install location [0:internal | 1:external]: \n");
-                       location = __get_integer_input_data();
-                       ret = pkgmgrinfo_set_install_location_to_pkgdbinfo(handle, location);
-                       if (ret < 0) {
-                               printf("pkgmgrinfo_set_install_location_to_pkgdbinfo failed\n");
-                               pkgmgrinfo_destroy_pkgdbinfo(handle);
-                               return -1;
-                       }
-                       break;
-               case 4:
-                       printf("Enter label :\n");
-                       char *label = __get_string_input_data();
-                       printf("Enter locale ['def' for default]: \n");
-                       locale = __get_string_input_data();
-                       if (strcmp(locale, "def") == 0)
-                               ret = pkgmgrinfo_set_label_to_pkgdbinfo(handle, label, NULL);
-                       else
-                               ret = pkgmgrinfo_set_label_to_pkgdbinfo(handle, label, locale);
-                       if (ret < 0) {
-                               printf("pkgmgrinfo_set_label_to_pkgdbinfo failed\n");
-                               pkgmgrinfo_destroy_pkgdbinfo(handle);
-                               free(locale);
-                               free(label);
-                               return -1;
-                       }
-                       free(locale);
-                       free(label);
-                       break;
-               case 5:
-                       printf("Enter icon: \n");
-                       char *icon = __get_string_input_data();
-                       printf("Enter locale ['def' for default]: \n");
-                       locale = __get_string_input_data();
-                       if (strcmp(locale, "def") == 0)
-                               ret = pkgmgrinfo_set_icon_to_pkgdbinfo(handle, icon, NULL);
-                       else
-                               ret = pkgmgrinfo_set_icon_to_pkgdbinfo(handle, icon, locale);
-                       if (ret < 0) {
-                               printf("pkgmgrinfo_set_icon_to_pkgdbinfo failed\n");
-                               pkgmgrinfo_destroy_pkgdbinfo(handle);
-                               free(locale);
-                               free(icon);
-                               return -1;
-                       }
-                       free(locale);
-                       free(icon);
-                       break;
-               case 6:
-                       printf("Enter description: \n");
-                       char *description = __get_string_input_data();
-                       printf("Enter locale ['def' for default]: \n");
-                       locale = __get_string_input_data();
-                       if (strcmp(locale, "def") == 0)
-                               ret = pkgmgrinfo_set_description_to_pkgdbinfo(handle, description, NULL);
-                       else
-                               ret = pkgmgrinfo_set_description_to_pkgdbinfo(handle, description, locale);
-                       if (ret < 0) {
-                               printf("pkgmgrinfo_set_description_to_pkgdbinfo failed\n");
-                               pkgmgrinfo_destroy_pkgdbinfo(handle);
-                               free(locale);
-                               free(description);
-                               return -1;
-                       }
-                       free(locale);
-                       free(description);
-                       break;
-               case 7:
-                       printf("Enter author name: \n");
-                       char *author_name = __get_string_input_data();
-                       printf("Enter locale ['def' for default]: \n");
-                       locale = __get_string_input_data();
-                       printf("Enter author email: \n");
-                       char *author_email = __get_string_input_data();
-                       printf("Enter author href: \n");
-                       char *author_href = __get_string_input_data();
-                       if (strcmp(locale, "def") == 0)
-                               ret = pkgmgrinfo_set_author_to_pkgdbinfo(handle, author_name, author_email, author_href, NULL);
-                       else
-                               ret = pkgmgrinfo_set_author_to_pkgdbinfo(handle, author_name, author_email, author_href, locale);
-                       if (ret < 0) {
-                               printf("pkgmgrinfo_set_author_to_pkgdbinfo failed\n");
-                               pkgmgrinfo_destroy_pkgdbinfo(handle);
-                               free(locale);
-                               free(author_name);
-                               free(author_email);
-                               free(author_href);
-                               return -1;
-                       }
-                       free(locale);
-                       free(author_name);
-                       free(author_email);
-                       free(author_href);
-                       break;
-               case 8:
-                       printf("Enter removable [0:false | 1:true]: \n");
-                       removable = __get_integer_input_data();
-                       ret = pkgmgrinfo_set_removable_to_pkgdbinfo(handle, removable);
-                       if (ret < 0) {
-                               printf("pkgmgrinfo_set_removable_to_pkgdbinfo failed\n");
-                               pkgmgrinfo_destroy_pkgdbinfo(handle);
-                               return -1;
-                       }
-                       break;
-               case 9:
-                       printf("Enter preload [0:false | 1:true]: \n");
-                       preload = __get_integer_input_data();
-                       ret = pkgmgrinfo_set_preload_to_pkgdbinfo(handle, preload);
-                       if (ret < 0) {
-                               printf("pkgmgrinfo_set_preload_to_pkgdbinfo failed\n");
-                               pkgmgrinfo_destroy_pkgdbinfo(handle);
-                               return -1;
-                       }
-                       break;
-               case 10:
-                       printf("Enter size in MB \n");
-                       char *size = __get_string_input_data();
-                       ret = pkgmgrinfo_set_size_to_pkgdbinfo(handle, size);
-                       if (ret < 0) {
-                               printf("pkgmgrinfo_set_size_to_pkgdbinfo failed\n");
-                               pkgmgrinfo_destroy_pkgdbinfo(handle);
-                               free(size);
-                               return -1;
-                       }
-                       free(size);
-                       break;
-               case 11:
-                       printf("Enter insatlled storage [ 0:INTERNAL | 1:EXTERNAL ] \n");
-                       storage = __get_integer_input_data();
-                       ret = pkgmgrinfo_set_installed_storage_to_pkgdbinfo(handle, storage);
-                       if (ret < 0) {
-                               printf("pkgmgrinfo_set_installed_storage_to_pkgdbinfo failed\n");
-                               pkgmgrinfo_destroy_pkgdbinfo(handle);
-                               return -1;
-                       }
-                       break;
-               default:
-                       printf("Invalid number entered\n");
-                       continue;
-               }
-       }
-       return 0;
-}
-
 static int __insert_manifest_in_db(char *manifest, uid_t uid)
 {
        int ret = 0;
@@ -1572,10 +1397,10 @@ static int __insert_manifest_in_db(char *manifest, uid_t uid)
                printf("Manifest file is NULL\n");
                return -1;
        }
-       if (uid != GLOBAL_USER)
-               ret = pkgmgr_parser_parse_usr_manifest_for_installation(manifest, uid, NULL);
-       else
+       if (uid == GLOBAL_USER || uid == OWNER_ROOT)
                ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
+       else
+               ret = pkgmgr_parser_parse_usr_manifest_for_installation(manifest, uid, NULL);
        if (ret < 0) {
                printf("insert in db failed\n");
                return -1;
@@ -1621,7 +1446,7 @@ static int __remove_manifest_from_db(char *manifest, uid_t uid)
        return 0;
 }
 
-int app_func(const pkgmgr_appinfo_h handle, void *user_data)
+int app_func(const pkgmgrinfo_appinfo_h handle, void *user_data)
 {
        char *appid;
        char *data = NULL;
@@ -1632,88 +1457,88 @@ int app_func(const pkgmgr_appinfo_h handle, void *user_data)
        char *exec = NULL;
        char *icon = NULL;
        char *label = NULL;
-       pkgmgr_app_component component = 0;
+       pkgmgrinfo_app_component component = 0;
        char *apptype = NULL;
        bool nodisplay = 0;
        bool multiple = 0;
        bool taskmanage = 0;
-       pkgmgr_hwacceleration_type hwacceleration;
+       pkgmgrinfo_app_hwacceleration hwacceleration;
        pkgmgrinfo_app_screenreader screenreader;
        bool onboot = 0;
        bool autorestart = 0;
        char *package = NULL;
 
-       ret = pkgmgr_appinfo_get_appid(handle, &appid);
+       ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
        if (ret < 0) {
                printf("Failed to get appid\n");
        }
        if (appid)
                printf("Appid: %s\n", appid);
 
-       ret = pkgmgr_appinfo_get_pkgid(handle, &package);
+       ret = pkgmgrinfo_appinfo_get_pkgid(handle, &package);
        if (ret < 0) {
                printf("Failed to get package\n");
        }
        if (package)
                printf("Package: %s\n", package);
 
-       ret = pkgmgr_appinfo_get_exec(handle, &exec);
+       ret = pkgmgrinfo_appinfo_get_exec(handle, &exec);
        if (ret < 0) {
                printf("Failed to get exec\n");
        }
        if (exec)
                printf("Exec: %s\n", exec);
 
-       ret = pkgmgr_appinfo_get_icon(handle, &icon);
+       ret = pkgmgrinfo_appinfo_get_icon(handle, &icon);
        if (ret < 0) {
                printf("Failed to get icon\n");
        }
        if (icon)
                printf("Icon: %s\n", icon);
 
-       ret = pkgmgr_appinfo_get_label(handle, &label);
+       ret = pkgmgrinfo_appinfo_get_label(handle, &label);
        if (ret < 0) {
                printf("Failed to get label\n");
        }
        if (label)
                printf("Label: %s\n", label);
 
-       ret = pkgmgr_appinfo_get_component(handle, &component);
+       ret = pkgmgrinfo_appinfo_get_component(handle, &component);
        if (ret < 0) {
                printf("Failed to get component\n");
        }
 
-       ret = pkgmgr_appinfo_get_apptype(handle, &apptype);
+       ret = pkgmgrinfo_appinfo_get_apptype(handle, &apptype);
        if (ret < 0) {
                printf("Failed to get apptype\n");
        }
        if (apptype)
                printf("Apptype: %s\n", apptype);
 
-       if (component == PM_UI_APP) {
+       if (component == PMINFO_UI_APP) {
                printf("component: uiapp\n");
-               ret = pkgmgr_appinfo_is_multiple(handle, &multiple);
+               ret = pkgmgrinfo_appinfo_is_multiple(handle, &multiple);
                if (ret < 0) {
                        printf("Failed to get multiple\n");
                } else {
                        printf("Multiple: %d\n", multiple);
                }
 
-               ret = pkgmgr_appinfo_is_nodisplay(handle, &nodisplay);
+               ret = pkgmgrinfo_appinfo_is_nodisplay(handle, &nodisplay);
                if (ret < 0) {
                        printf("Failed to get nodisplay\n");
                } else {
                        printf("Nodisplay: %d \n", nodisplay);
                }
 
-               ret = pkgmgr_appinfo_is_taskmanage(handle, &taskmanage);
+               ret = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage);
                if (ret < 0) {
                        printf("Failed to get taskmanage\n");
                } else {
                        printf("Taskmanage: %d\n", taskmanage);
                }
 
-               ret = pkgmgr_appinfo_get_hwacceleration(handle, &hwacceleration);
+               ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacceleration);
                if (ret < 0) {
                        printf("Failed to get hwacceleration\n");
                } else {
@@ -1728,16 +1553,16 @@ int app_func(const pkgmgr_appinfo_h handle, void *user_data)
                }
 
        }
-       if (component == PM_SVC_APP) {
+       if (component == PMINFO_SVC_APP) {
                printf("component: svcapp\n");
-               ret = pkgmgr_appinfo_is_onboot(handle, &onboot);
+               ret = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
                if (ret < 0) {
                        printf("Failed to get onboot\n");
                } else {
                        printf("Onboot: %d\n", onboot);
                }
 
-               ret = pkgmgr_appinfo_is_autorestart(handle, &autorestart);
+               ret = pkgmgrinfo_appinfo_is_autorestart(handle, &autorestart);
                if (ret < 0) {
                        printf("Failed to get autorestart\n");
                } else {
@@ -1751,7 +1576,7 @@ int app_func(const pkgmgr_appinfo_h handle, void *user_data)
 }
 
 
-static int __pkg_list_cb (const pkgmgr_pkginfo_h handle, void *user_data)
+static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
 {
        char *test_data = "test data";
        int ret = -1;
@@ -1762,25 +1587,25 @@ static int __pkg_list_cb (const pkgmgr_pkginfo_h handle, void *user_data)
        int installed_time = -1;
 
        pkgmgrinfo_uidinfo_t *uid_info = (pkgmgrinfo_uidinfo_t *) handle;
-       ret = pkgmgr_pkginfo_get_pkgid(handle, &pkgid);
+       ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
        if(ret < 0) {
-               printf("pkgmgr_pkginfo_get_pkgid() failed\n");
+               printf("pkgmgrinfo_pkginfo_get_pkgid() failed\n");
        }
-       ret = pkgmgr_pkginfo_get_type(handle, &pkg_type);
+       ret = pkgmgrinfo_pkginfo_get_type(handle, &pkg_type);
        if(ret < 0) {
-               printf("pkgmgr_pkginfo_get_type() failed\n");
+               printf("pkgmgrinfo_pkginfo_get_type() failed\n");
        }
-       ret = pkgmgr_pkginfo_get_version(handle, &pkg_version);
+       ret = pkgmgrinfo_pkginfo_get_version(handle, &pkg_version);
        if(ret < 0) {
-               printf("pkgmgr_pkginfo_get_version() failed\n");
+               printf("pkgmgrinfo_pkginfo_get_version() failed\n");
        }
-       ret = pkgmgr_pkginfo_is_preload(handle, &preload);
+       ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
        if(ret < 0) {
-               printf("pkgmgr_pkginfo_is_preload() failed\n");
+               printf("pkgmgrinfo_pkginfo_is_preload() failed\n");
        }
-       ret = pkgmgr_pkginfo_get_installed_time(handle, &installed_time);
+       ret = pkgmgrinfo_pkginfo_get_installed_time(handle, &installed_time);
        if(ret < 0) {
-               printf("pkgmgr_pkginfo_get_installed_time() failed\n");
+               printf("pkgmgrinfo_pkginfo_get_installed_time() failed\n");
        }
 
 
@@ -1790,23 +1615,23 @@ static int __pkg_list_cb (const pkgmgr_pkginfo_h handle, void *user_data)
 
        if (uid_info->uid != GLOBAL_USER) {
                printf("**List of Ui-Apps**\n");
-               ret = pkgmgr_appinfo_get_usr_list(handle, PM_UI_APP, app_func, (void *)test_data, uid_info->uid);
+               ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_UI_APP, app_func, (void *)test_data, uid_info->uid);
                if (ret < 0) {
                        printf("pkgmgr_get_info_app() failed\n");
                }
                printf("**List of Svc-Apps**\n");
-               ret = pkgmgr_appinfo_get_usr_list(handle, PM_SVC_APP, app_func, (void *)test_data, uid_info->uid);
+               ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_SVC_APP, app_func, (void *)test_data, uid_info->uid);
                if (ret < 0) {
                        printf("pkgmgr_get_info_app() failed\n");
                }
        } else {
                printf("**List of Ui-Apps**\n");
-               ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, app_func, (void *)test_data);
+               ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, app_func, (void *)test_data);
                if (ret < 0) {
                        printf("pkgmgr_get_info_app() failed\n");
                }
                printf("**List of Svc-Apps**\n");
-               ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, app_func, (void *)test_data);
+               ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, app_func, (void *)test_data);
                if (ret < 0) {
                        printf("pkgmgr_get_info_app() failed\n");
                }
@@ -1820,11 +1645,11 @@ static int __get_pkg_list(uid_t uid)
 {
        int ret = -1;
        if (uid != GLOBAL_USER)
-               ret = pkgmgr_pkginfo_get_usr_list(__pkg_list_cb, NULL, uid);
+               ret = pkgmgrinfo_pkginfo_get_usr_list(__pkg_list_cb, NULL, uid);
        else
-               ret = pkgmgr_pkginfo_get_list(__pkg_list_cb, NULL);
+               ret = pkgmgrinfo_pkginfo_get_list(__pkg_list_cb, NULL);
        if (ret < 0) {
-               printf("pkgmgr_pkginfo_get_list() failed\n");
+               printf("pkgmgrinfo_pkginfo_get_list() failed\n");
                return -1;
        }
        return 0;
@@ -1862,58 +1687,12 @@ static int __app_metadata_list_cb(const char *metadata_name, const char *metadat
        return 0;
 }
 
-static int __app_control_list_cb(pkgmgrinfo_appcontrol_h handle, void *user_data)
+static int __app_control_list_cb(const char *operation, const char *uri, const char *mime, void *user_data)
 {
        printf("-------------------------------------------------------\n");
-       int i = 0;
-       int ret = 0;
-       int oc = 0;
-       int mc = 0;
-       int uc = 0;
-       int sc = 0;
-       char **operation = NULL;
-       char **uri = NULL;
-       char **mime = NULL;
-       char **subapp = NULL;
-
-       ret = pkgmgrinfo_appinfo_get_operation(handle, &oc, &operation);
-       if (ret < 0) {
-               printf("Get Operation Failed\n");
-               return -1;
-       }
-       ret = pkgmgrinfo_appinfo_get_uri(handle, &uc, &uri);
-       if (ret < 0) {
-               printf("Get Uri Failed\n");
-               return -1;
-       }
-       ret = pkgmgrinfo_appinfo_get_mime(handle, &mc, &mime);
-       if (ret < 0) {
-               printf("Get Mime Failed\n");
-               return -1;
-       }
-       ret = pkgmgrinfo_appinfo_get_subapp(handle, &sc, &subapp);
-       if (ret < 0) {
-               printf("Get subapp Failed\n");
-               return -1;
-       }
-
-       for (i = 0; i < oc; i++) {
-               if (operation && operation[i])
-                       printf("Operation: %s\n", operation[i]);
-       }
-       for (i = 0; i < uc; i++) {
-               if (uri && uri[i])
-                       printf("Uri: %s\n", uri[i]);
-       }
-       for (i = 0; i < mc; i++) {
-               if (mime && mime[i])
-                       printf("Mime: %s\n", mime[i]);
-       }
-       for (i = 0; i < sc; i++) {
-               if (subapp && subapp[i])
-                       printf("subapp: %s\n", subapp[i]);
-       }
-
+       printf("Operation: %s\n", operation);
+       printf("Uri: %s\n", uri);
+       printf("Mime: %s\n", mime);
        printf("-------------------------------------------------------\n\n");
        return 0;
 }
@@ -1922,27 +1701,27 @@ static int __app_control_list_cb(pkgmgrinfo_appcontrol_h handle, void *user_data
 static int __get_app_category_list(char *appid)
 {
        int ret = -1;
-       pkgmgr_appinfo_h handle;
-       ret = pkgmgr_appinfo_get_appinfo(appid, &handle);
+       pkgmgrinfo_appinfo_h handle;
+       ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
        if (ret < 0) {
                printf("Failed to get handle\n");
                return -1;
        }
-       ret = pkgmgr_appinfo_foreach_category(handle, __app_category_list_cb, NULL);
+       ret = pkgmgrinfo_appinfo_foreach_category(handle, __app_category_list_cb, NULL);
        if (ret < 0) {
-               printf("pkgmgr_appinfo_foreach_category() failed\n");
-               pkgmgr_appinfo_destroy_appinfo(handle);
+               printf("pkgmgrinfo_appinfo_foreach_category() failed\n");
+               pkgmgrinfo_appinfo_destroy_appinfo(handle);
                return -1;
        }
-       pkgmgr_appinfo_destroy_appinfo(handle);
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
        return 0;
 }
 
 static int __get_app_metadata_list(char *appid)
 {
        int ret = -1;
-       pkgmgr_appinfo_h handle;
-       ret = pkgmgr_appinfo_get_appinfo(appid, &handle);
+       pkgmgrinfo_appinfo_h handle;
+       ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
        if (ret < 0) {
                printf("Failed to get handle\n");
                return -1;
@@ -1950,18 +1729,18 @@ static int __get_app_metadata_list(char *appid)
        ret = pkgmgrinfo_appinfo_foreach_metadata(handle, __app_metadata_list_cb, NULL);
        if (ret < 0) {
                printf("pkgmgrinfo_appinfo_foreach_metadata() failed\n");
-               pkgmgr_appinfo_destroy_appinfo(handle);
+               pkgmgrinfo_appinfo_destroy_appinfo(handle);
                return -1;
        }
-       pkgmgr_appinfo_destroy_appinfo(handle);
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
        return 0;
 }
 
 static int __get_app_control_list(char *appid)
 {
        int ret = -1;
-       pkgmgr_appinfo_h handle;
-       ret = pkgmgr_appinfo_get_appinfo(appid, &handle);
+       pkgmgrinfo_appinfo_h handle;
+       ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
        if (ret < 0) {
                printf("Failed to get handle\n");
                return -1;
@@ -1969,10 +1748,10 @@ static int __get_app_control_list(char *appid)
        ret = pkgmgrinfo_appinfo_foreach_appcontrol(handle, __app_control_list_cb, NULL);
        if (ret < 0) {
                printf("pkgmgrinfo_appinfo_foreach_appcontrol() failed\n");
-               pkgmgr_appinfo_destroy_appinfo(handle);
+               pkgmgrinfo_appinfo_destroy_appinfo(handle);
                return -1;
        }
-       pkgmgr_appinfo_destroy_appinfo(handle);
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
        return 0;
 }
 
@@ -1989,41 +1768,41 @@ static int __set_app_enabled(char *appid, bool enabled)
 
 static int __get_app_list(char *pkgid, uid_t uid)
 {
-       pkgmgr_pkginfo_h handle;
+       pkgmgrinfo_pkginfo_h handle;
        int ret = -1;
        char *test_data = "test data";
        if(uid != GLOBAL_USER)
-               ret = pkgmgr_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
+               ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
        else
-               ret = pkgmgr_pkginfo_get_pkginfo(pkgid, &handle);
+               ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
        if (ret < 0) {
                printf("Failed to get handle\n");
                return -1;
        }
        if (uid != GLOBAL_USER) {
                printf("List of Ui-Apps\n\n");
-               ret = pkgmgr_appinfo_get_usr_list(handle, PM_UI_APP, app_func, (void *)test_data, uid);
+               ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_UI_APP, app_func, (void *)test_data, uid);
                if (ret < 0) {
-                       printf("pkgmgr_appinfo_get_list() failed\n");
+                       printf("pkgmgrinfo_appinfo_get_list() failed\n");
                }
                printf("List of Svc-Apps\n\n");
-               ret = pkgmgr_appinfo_get_usr_list(handle, PM_SVC_APP, app_func, (void *)test_data, uid);
+               ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_SVC_APP, app_func, (void *)test_data, uid);
                if (ret < 0) {
-                       printf("pkgmgr_appinfo_get_list() failed\n");
+                       printf("pkgmgrinfo_appinfo_get_list() failed\n");
                }
        } else {
                printf("List of Ui-Apps\n\n");
-               ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, app_func, (void *)test_data);
+               ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, app_func, (void *)test_data);
                if (ret < 0) {
-                       printf("pkgmgr_appinfo_get_list() failed\n");
+                       printf("pkgmgrinfo_appinfo_get_list() failed\n");
                }
                printf("List of Svc-Apps\n\n");
-               ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, app_func, (void *)test_data);
+               ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, app_func, (void *)test_data);
                if (ret < 0) {
-                       printf("pkgmgr_appinfo_get_list() failed\n");
+                       printf("pkgmgrinfo_appinfo_get_list() failed\n");
                }
        }
-       pkgmgr_pkginfo_destroy_pkginfo(handle);
+       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
        return 0;
 }
 
@@ -2057,69 +1836,69 @@ static int __get_app_info(char *appid)
        char *icon = NULL;
        char *label = NULL;
        char *package = NULL;
-       pkgmgr_app_component component = 0;
+       pkgmgrinfo_app_component component = 0;
        bool nodisplay = 0;
        bool multiple = 0;
        bool taskmanage = 0;
-       pkgmgr_hwacceleration_type hwacceleration;
+       pkgmgrinfo_app_hwacceleration hwacceleration;
        pkgmgrinfo_app_screenreader screenreader;
        bool onboot = 0;
        bool autorestart = 0;
        bool enabled = 0;
        bool preload = 0;
-       pkgmgr_appinfo_h handle;
+       pkgmgrinfo_appinfo_h handle;
        int ret = -1;
 
-       ret = pkgmgr_appinfo_get_appinfo(appid, &handle);
+       ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
        if (ret < 0) {
                printf("Failed to get handle\n");
                return -1;
        }
 
-       ret = pkgmgr_appinfo_get_pkgid(handle, &package);
+       ret = pkgmgrinfo_appinfo_get_pkgid(handle, &package);
        if (ret < 0) {
                printf("Failed to get package\n");
        }
 
-       ret = pkgmgr_appinfo_get_appid(handle, &app_id);
+       ret = pkgmgrinfo_appinfo_get_appid(handle, &app_id);
        if (ret < 0) {
                printf("Failed to get exec\n");
        }
 
-       ret = pkgmgr_appinfo_get_label(handle, &label);
+       ret = pkgmgrinfo_appinfo_get_label(handle, &label);
        if (ret < 0) {
                printf("Failed to get label\n");
        }
-       ret = pkgmgr_appinfo_get_icon(handle, &icon);
+       ret = pkgmgrinfo_appinfo_get_icon(handle, &icon);
        if (ret < 0) {
                printf("Failed to get icon\n");
        }
 
-       ret = pkgmgr_appinfo_get_exec(handle, &exec);
+       ret = pkgmgrinfo_appinfo_get_exec(handle, &exec);
        if (ret < 0) {
                printf("Failed to get exec\n");
        }
-       ret = pkgmgr_appinfo_get_component(handle, &component);
+       ret = pkgmgrinfo_appinfo_get_component(handle, &component);
        if (ret < 0) {
                printf("Failed to get component\n");
        }
-       ret = pkgmgr_appinfo_get_apptype(handle, &apptype);
+       ret = pkgmgrinfo_appinfo_get_apptype(handle, &apptype);
        if (ret < 0) {
                printf("Failed to get apptype\n");
        }
-       ret = pkgmgr_appinfo_is_nodisplay(handle, &nodisplay);
+       ret = pkgmgrinfo_appinfo_is_nodisplay(handle, &nodisplay);
        if (ret < 0) {
                printf("Failed to get nodisplay\n");
        }
-       ret = pkgmgr_appinfo_is_multiple(handle, &multiple);
+       ret = pkgmgrinfo_appinfo_is_multiple(handle, &multiple);
        if (ret < 0) {
                printf("Failed to get multiple\n");
        }
-       ret = pkgmgr_appinfo_is_taskmanage(handle, &taskmanage);
+       ret = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage);
        if (ret < 0) {
                printf("Failed to get taskmanage\n");
        }
-       ret = pkgmgr_appinfo_get_hwacceleration(handle, &hwacceleration);
+       ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacceleration);
        if (ret < 0) {
                printf("Failed to get hwacceleration\n");
        }
@@ -2127,11 +1906,11 @@ static int __get_app_info(char *appid)
        if (ret < 0) {
                printf("Failed to get screenreader\n");
        }
-       ret = pkgmgr_appinfo_is_onboot(handle, &onboot);
+       ret = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
        if (ret < 0) {
                printf("Failed to get onboot\n");
        }
-       ret = pkgmgr_appinfo_is_autorestart(handle, &autorestart);
+       ret = pkgmgrinfo_appinfo_is_autorestart(handle, &autorestart);
        if (ret < 0) {
                printf("Failed to get autorestart\n");
        }
@@ -2155,7 +1934,7 @@ static int __get_app_info(char *appid)
        if (apptype)
                printf("Apptype: %s\n", apptype);
 
-       if (component == PM_UI_APP) {
+       if (component == PMINFO_UI_APP) {
                printf("component: uiapp\n");
 
                if (icon)
@@ -2168,7 +1947,7 @@ static int __get_app_info(char *appid)
                printf("Taskmanage: %d\n", taskmanage);
                printf("Hw-Acceleration: %d\n", hwacceleration);
                printf("Screenreader: %d\n", screenreader);
-       } else if (component == PM_SVC_APP) {
+       } else if (component == PMINFO_SVC_APP) {
                printf("component: svcapp\n");
 
                if (icon)
@@ -2185,7 +1964,7 @@ static int __get_app_info(char *appid)
        printf("Enabled: %d\n", enabled);
        printf("Preload: %d\n", preload);
 
-       pkgmgr_appinfo_destroy_appinfo(handle);
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
        return 0;
 
 }
@@ -2216,7 +1995,8 @@ int main(int argc, char *argv[])
        gettimeofday(&tv, NULL);
        starttime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
 
-       locale = vconf_get_str(VCONFKEY_LANGSET);
+       locale = ail_vconf_get_str(VCONFKEY_LANGSET); 
+       //Work around for https://bugs.tizen.org/jira/browse/TC-2399
        if (locale == NULL) {
                printf("locale is NULL\n");
                ret = -1;
@@ -2226,11 +2006,6 @@ int main(int argc, char *argv[])
                printf("Locale is %s\n", locale);
 
 
-       if(getuid() == OWNER_ROOT) {
-               printf("User is Root! : Only tizenglobalapp or regular user are allowed\n");
-               return -1;
-       }
-       
        free(locale);
        locale = NULL;
        if (argc == 2) {
@@ -2369,20 +2144,14 @@ int main(int argc, char *argv[])
                        printf("remove from db failed\n");
                        goto end;
                }
-       } else if (strcmp(argv[1], "--setdb") == 0) {
-               ret = __set_pkginfo_in_db(argv[2], getuid());
-               if (ret == -1) {
-                       printf("set pkginfo in db failed\n");
-                       goto end;
-               }
        } else if (strcmp(argv[1], "--setcert") == 0) {
-               ret = __set_certinfo_in_db(argv[2]);
+               ret = __set_certinfo_in_db(argv[2], getuid());
                if (ret == -1) {
                        printf("set certinfo in db failed\n");
                        goto end;
                }
        } else if (strcmp(argv[1], "--getcert") == 0) {
-               ret = __get_certinfo_from_db(argv[2]);
+               ret = __get_certinfo_from_db(argv[2], getuid());
                if (ret == -1) {
                        printf("get certinfo from db failed\n");
                        goto end;