Seperate pkgmgr client for listen and request 71/88571/1 accepted/tizen/common/20160922.120315 accepted/tizen/ivi/20160922.233115 accepted/tizen/mobile/20160922.233049 accepted/tizen/tv/20160922.233109 accepted/tizen/wearable/20160922.233102 submit/tizen/20160922.003440
authorJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 20 Sep 2016 00:45:36 +0000 (09:45 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 20 Sep 2016 00:45:36 +0000 (09:45 +0900)
Change-Id: If7158a733a14b2d33e5c4e687d06a5b3d5b3cb6c
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/pkg_cmd.c

index a7059389976315a4f5f0c4cf32ed76223c9f96c3..f2191de4ff764e4e912c25a6f0c3fc8c758ce65b 100644 (file)
@@ -539,6 +539,7 @@ static int __process_request(uid_t uid)
 {
        int ret = -1;
        pkgmgr_client *pc = NULL;
+       pkgmgr_client *listen_pc = NULL;
        char buf[1024] = {'\0'};
        int pid = -1;
        char pkg_old[PATH_MAX] = {0, };
@@ -780,12 +781,13 @@ static int __process_request(uid_t uid)
                                /* enable app which belongs to this user */
                                ret = pkgmgr_client_usr_activate_app(pc, data.pkgid, __app_return_cb, uid);
                } else {
-                       ret = pkgmgr_client_set_status_type(pc, PKGMGR_CLIENT_STATUS_INSTALL);
-                       if (ret != PKGMGR_R_OK) {
-                               printf("Failed to set status type[%d]\n", ret);
+                       listen_pc = pkgmgr_client_new(PC_LISTENING);
+                       if (listen_pc == NULL) {
+                               printf("PkgMgr Client Creation Failed\n");
+                               ret = -1;
                                break;
                        }
-                       ret = pkgmgr_client_listen_status(pc, __return_cb, NULL);
+                       ret = pkgmgr_client_listen_status(listen_pc, __return_cb, NULL);
                        if (ret < 0) {
                                printf("Failed to set callback[%d]\n", ret);
                                break;
@@ -823,17 +825,17 @@ static int __process_request(uid_t uid)
                                /* disable app which belongs to this user */
                                ret = pkgmgr_client_usr_deactivate_app(pc, data.pkgid, __app_return_cb, uid);
                } else {
-                       ret = pkgmgr_client_set_status_type(pc, PKGMGR_CLIENT_STATUS_UNINSTALL);
-                       if (ret != PKGMGR_R_OK) {
-                               printf("Failed to set status type[%d]\n", ret);
+                       listen_pc = pkgmgr_client_new(PC_LISTENING);
+                       if (listen_pc == NULL) {
+                               printf("PkgMgr Client Creation Failed\n");
+                               ret = -1;
                                break;
                        }
-                       ret = pkgmgr_client_listen_status(pc, __return_cb, NULL);
+                       ret = pkgmgr_client_listen_status(listen_pc, __return_cb, NULL);
                        if (ret < 0) {
                                printf("Failed to set callback[%d]\n", ret);
                                break;
                        }
-                       /* disable package which belongs to this user*/
                        ret = pkgmgr_client_usr_deactivate(pc, data.pkg_type, data.pkgid, uid);
                }
                if (ret < 0)
@@ -1070,6 +1072,12 @@ static int __process_request(uid_t uid)
                pkgmgr_client_free(pc);
                pc = NULL;
        }
+
+       if (listen_pc) {
+               pkgmgr_client_free(listen_pc);
+               listen_pc = NULL;
+       }
+
        return ret;
 }