make it simple to use pkgmgrinfo apis 21/100321/4
authorjongmyeongko <jongmyeong.ko@samsung.com>
Sun, 27 Nov 2016 09:40:17 +0000 (18:40 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Wed, 30 Nov 2016 05:24:39 +0000 (21:24 -0800)
Change-Id: I964c631d1fd342eed64cbc4b977e9cac921d8e19
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
src/pkg_cmd.c

index 274a386..108b0a0 100644 (file)
@@ -379,10 +379,7 @@ static int __is_app_installed(char *pkgid, uid_t uid)
 {
        pkgmgrinfo_pkginfo_h handle;
        int ret;
-       if (uid != GLOBAL_USER)
-               ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
-       else
-               ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+       ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
 
        if (ret < 0) {
                printf("package is not in pkgmgr_info DB\n");
@@ -519,12 +516,8 @@ static int __pkg_list_cb(const pkgmgrinfo_pkginfo_h handle, void *user_data)
        if (ret < 0)
                printf("pkgmgrinfo_pkginfo_get_pkgid() failed\n");
 
-       if (uid_info->uid != GLOBAL_USER)
-               ret = pkgmgr_client_usr_request_service(PM_REQUEST_GET_SIZE, PM_GET_TOTAL_SIZE,
+       ret = pkgmgr_client_usr_request_service(PM_REQUEST_GET_SIZE, PM_GET_TOTAL_SIZE,
                                (pkgmgr_client *)user_data, NULL, pkgid, uid_info->uid, NULL, NULL, NULL);
-       else
-               ret = pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, PM_GET_TOTAL_SIZE,
-                               (pkgmgr_client *)user_data, NULL, pkgid, NULL, NULL, NULL);
        if (ret < 0) {
                printf("pkgmgr_client_request_service Failed\n");
                return -1;
@@ -816,11 +809,7 @@ static int __process_request(uid_t target_uid)
        case CLEAR_ALL_REQ:
                if (data.pkg_type[0] == '\0') {
                        ret = 0;
-                       if (target_uid != GLOBAL_USER)
-                               ret = pkgmgrinfo_pkginfo_get_usr_list(__pkgmgr_list_clear_cb, NULL, target_uid);
-                       else
-                               ret = pkgmgrinfo_pkginfo_get_list(__pkgmgr_list_clear_cb, NULL);
-
+                       ret = pkgmgrinfo_pkginfo_get_usr_list(__pkgmgr_list_clear_cb, NULL, target_uid);
                        if (ret == -1)
                                printf("no packages found\n");
                        break;
@@ -840,11 +829,7 @@ static int __process_request(uid_t target_uid)
                                break;
                        }
 
-                       if (target_uid != GLOBAL_USER)
-                               ret = pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(handle, __pkgmgr_list_clear_cb, NULL, target_uid);
-                       else
-                               ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkgmgr_list_clear_cb, NULL);
-
+                       ret = pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(handle, __pkgmgr_list_clear_cb, NULL, target_uid);
                        if (ret != PMINFO_R_OK)
                                printf("no package filter list\n");
 
@@ -1053,11 +1038,7 @@ static int __process_request(uid_t target_uid)
        case LIST_REQ:
                if (data.pkg_type[0] == '\0') {
                        ret = 0;
-                       if (target_uid != GLOBAL_USER)
-                               ret = pkgmgrinfo_pkginfo_get_usr_list(__pkgmgr_list_cb, NULL, target_uid);
-                       else
-                               ret = pkgmgrinfo_pkginfo_get_list(__pkgmgr_list_cb, NULL);
-
+                       ret = pkgmgrinfo_pkginfo_get_usr_list(__pkgmgr_list_cb, NULL, target_uid);
                        if (ret == -1)
                                printf("no packages found\n");
                        break;
@@ -1077,11 +1058,7 @@ static int __process_request(uid_t target_uid)
                                break;
                        }
 
-                       if (target_uid != GLOBAL_USER)
-                               ret = pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(handle, __pkgmgr_list_cb, NULL, target_uid);
-                       else
-                               ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkgmgr_list_cb, NULL);
-
+                       ret = pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(handle, __pkgmgr_list_cb, NULL, target_uid);
                        if (ret != PMINFO_R_OK)
                                printf("no package filter list\n");