implement functions to used by capi-package-manager 77/64577/3 accepted/tizen/common/20160406.144151 accepted/tizen/ivi/20160406.071936 accepted/tizen/mobile/20160406.071830 accepted/tizen/tv/20160406.071852 accepted/tizen/wearable/20160406.071913 submit/tizen/20160406.013051
authorJunghyun Yeon <jungh.yeon@samsung.com>
Mon, 4 Apr 2016 00:01:55 +0000 (09:01 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 5 Apr 2016 04:56:42 +0000 (13:56 +0900)
when unset event cb

Change-Id: I3589e878537a04b9bbea41f995f7e631e3a81002
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
client/include/package-manager.h
client/src/pkgmgr.c

index 47d5a9f..77fcc27 100644 (file)
@@ -660,6 +660,19 @@ int pkgmgr_client_listen_app_status(pkgmgr_client *pc, pkgmgr_app_handler event_
                                    void *data);
 
 /**
+ * @brief      This API request to stop listen the pkgmgr's broadcasting
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in]  pc      pkgmgr_client
+ * @return     0 if success, error code(<0) if fail\n
+ * @retval     PKGMGR_R_OK     success
+ * @retval     PKGMGR_R_EINVAL invalid argument
+ * @retval     PKGMGR_R_ERROR          internal error
+*/
+int pkgmgr_client_remove_listen_status(pkgmgr_client *pc);
+
+/**
  * @brief      This API broadcasts pkgmgr's status
  *
  * This API is for package-manager client application.\n
index 503c8ad..fbe262c 100644 (file)
@@ -289,6 +289,21 @@ static req_cb_info *__find_op_cbinfo(pkgmgr_client_t *pc, const char *req_key)
        return NULL;
 }
 
+static int __remove_stat_cbinfo(pkgmgr_client_t *pc)
+{
+       listen_cb_info *info = pc->info.listening.lhead;
+       listen_cb_info *next = NULL;
+
+       while (info != NULL) {
+               next = info->next;
+               free(info);
+               info = next;
+       }
+
+       pc->info.listening.lhead = NULL;
+       return 0;
+}
+
 static void __add_app_stat_cbinfo(pkgmgr_client_t *pc, int request_id,
                              pkgmgr_app_handler event_cb, void *data)
 {
@@ -1682,6 +1697,22 @@ API int pkgmgr_client_listen_app_status(pkgmgr_client *pc, pkgmgr_app_handler ev
        return req_id;
 }
 
+API int pkgmgr_client_remove_listen_status(pkgmgr_client *pc)
+{
+       int ret = -1;
+
+       retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client pc is NULL");
+       pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+       ret = __remove_stat_cbinfo(mpc);
+       if (ret != 0) {
+               ERR("failed to remove status callback");
+               return PKGMGR_R_ERROR;
+       }
+
+       return PKGMGR_R_OK;
+}
+
 API int pkgmgr_client_broadcast_status(pkgmgr_client *pc, const char *pkg_type,
                                       const char *pkgid, const char *key,
                                       const char *val)