Add api for listen status for resource copy
authorIlho Kim <ilho159.kim@samsung.com>
Wed, 18 Aug 2021 02:20:16 +0000 (11:20 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 2 Sep 2021 07:56:39 +0000 (16:56 +0900)
Change-Id: Ifa46499326a2b690d7a15b7090fee26590c15dec
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
client/include/package-manager.h
client/src/pkgmgr.c
client/src/pkgmgr_client_connection.c

index bb53f47..152edc8 100644 (file)
@@ -115,6 +115,9 @@ extern "C" {
 #define PKGMGR_CLIENT_STATUS_ENABLE_APP_SPLASH_SCREEN          0x0200
 #define PKGMGR_CLIENT_STATUS_DISABLE_APP_SPLASH_SCREEN         0x0400
 #define PKGMGR_CLIENT_STATUS_CLEAR_CACHE                       0x0800
+#define PKGMGR_CLIENT_STATUS_RES_COPY                          0x1000
+#define PKGMGR_CLIENT_STATUS_RES_REMOVE                                0x2000
+#define PKGMGR_CLIENT_STATUS_RES_UNINSTALL                     0x4000
 
 /** @} */
 
@@ -785,6 +788,22 @@ int pkgmgr_client_listen_app_status(pkgmgr_client *pc, pkgmgr_app_handler event_
                                    void *data);
 
 /**
+ * @brief      This API request to listen the pkgmgr's broadcasting about resource copy
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in]  pc              pkgmgr_client
+ * @param[in]  event_cb        user callback
+ * @param[in]  data            user data
+ * @return     request_id (>0) if success, error code(<0) if fail\n
+ * @retval     PKGMGR_R_OK     success
+ * @retval     PKGMGR_R_EINVAL invalid argument
+ * @retval     PKGMGR_R_ENOMEM out of memory
+*/
+int pkgmgr_client_listen_res_copy_status(pkgmgr_client *pc,
+               pkgmgr_res_copy_handler event_cb, void *data);
+
+/**
  * @brief      This API request to stop listen the pkgmgr's broadcasting
  *
  * This API is for package-manager client application.\n
index 68ad27d..fa8d444 100644 (file)
@@ -1880,6 +1880,37 @@ API int pkgmgr_client_listen_app_status(pkgmgr_client *pc,
        return cb_info->req_id;
 }
 
+API int pkgmgr_client_listen_res_copy_status(pkgmgr_client *pc,
+               pkgmgr_res_copy_handler event_cb, void *data)
+{
+       int ret;
+       struct pkgmgr_client_t *client = (struct pkgmgr_client_t *)pc;
+       struct cb_info *cb_info;
+
+       if (pc == NULL || event_cb == NULL) {
+               ERR("invalid parameter");
+               return PKGMGR_R_EINVAL;
+       }
+
+       if (client->pc_type != PC_LISTENING) {
+               ERR("client->pc_type is not PC_LISTENING");
+               return PKGMGR_R_EINVAL;
+       }
+
+       cb_info = __create_res_copy_event_cb_info(client, event_cb, data, NULL);
+       if (cb_info == NULL)
+               return PKGMGR_R_ENOMEM;
+       cb_info->status_type = client->status_type;
+       ret = pkgmgr_client_connection_set_callback(client, cb_info);
+       if (ret != PKGMGR_R_OK) {
+               __free_cb_info(cb_info);
+               return ret;
+       }
+       client->cb_info_list = g_list_append(client->cb_info_list, cb_info);
+
+       return cb_info->req_id;
+}
+
 API int pkgmgr_client_remove_listen_status(pkgmgr_client *pc)
 {
        struct pkgmgr_client_t *client = (struct pkgmgr_client_t *)pc;
index af172eb..be882bc 100644 (file)
@@ -103,6 +103,11 @@ struct signal_map map[] = {
                PKGMGR_CLIENT_STATUS_ENABLE_APP_SPLASH_SCREEN},
        {PKGMGR_INSTALLER_APP_DISABLE_SPLASH_SCREEN_EVENT_STR,
                PKGMGR_CLIENT_STATUS_DISABLE_APP_SPLASH_SCREEN},
+       {PKGMGR_INSTALLER_RES_COPY_EVENT_STR, PKGMGR_CLIENT_STATUS_RES_COPY},
+       {PKGMGR_INSTALLER_RES_REMOVE_EVENT_STR,
+               PKGMGR_CLIENT_STATUS_RES_REMOVE},
+       {PKGMGR_INSTALLER_RES_UNINSTALL_EVENT_STR,
+               PKGMGR_CLIENT_STATUS_RES_UNINSTALL},
        {NULL, -1}
 };