Add a new API 97/319897/1 tizen_6.0
authorChanggyu Choi <changyu.choi@samsung.com>
Wed, 26 Oct 2022 02:37:24 +0000 (11:37 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Tue, 5 Nov 2024 06:08:26 +0000 (15:08 +0900)
Adds:
 - pkgmgr_client_clear_user_data_with_path()

Change-Id: I30480116398a015605f906209352eac338316a94
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
client/include/package-manager.h
client/src/pkgmgr.c

index 44de28f6ee4c334b60b1c89e60dad5618868e152..0374cb7263fb737e969c1b8d0b375534c15dd6a6 100644 (file)
@@ -759,9 +759,34 @@ int pkgmgr_client_activate_global_app_for_uid(pkgmgr_client *pc, const char *app
  * @retval     PKGMGR_R_ECOMM  communication error
 */
 int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
-                               const char *appid, pkgmgr_mode mode);
+                               const char *pkgid, pkgmgr_mode mode);
 int pkgmgr_client_usr_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
-                               const char *appid, pkgmgr_mode mode, uid_t uid);
+                               const char *pkgid, pkgmgr_mode mode, uid_t uid);
+
+
+/**
+ * @brief      This API deletes application's specific private data.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @remarks    You should call this function with regular uid
+ * @param[in]  pc      pkgmgr_client
+ * @param[in]  pkg_type                package type
+ * @param[in]  pkgid           package id
+ * @param[in]  file_path       file path that is relative path from the givin package user data directory.
+ * @param[in]  mode            installation mode  - PM_DEFAULT, PM_QUIET
+ * @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_ECOMM  communication error
+*/
+int pkgmgr_client_clear_user_data_with_path(pkgmgr_client *pc,
+               const char *pkg_type, const char *pkgid,
+               const char *file_path, pkgmgr_mode mode);
+int pkgmgr_client_usr_clear_user_data_with_path(pkgmgr_client *pc,
+               const char *pkg_type, const char *pkgid, const char *file_path,
+               pkgmgr_mode mode, uid_t uid);
+
 /**
  * @brief      This API set status type to listen for the pkgmgr's broadcasting
  *
index 990005c76bbbee9ee9597e917131f345a0523169..cc07c2e1b94b35b3f67523328d013f5197b7af9b 100644 (file)
@@ -1807,6 +1807,44 @@ API int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
                        _getuid());
 }
 
+API int pkgmgr_client_usr_clear_user_data_with_path(pkgmgr_client *pc,
+               const char *pkg_type, const char *pkgid, const char *file_path,
+               pkgmgr_mode mode, uid_t uid)
+{
+       GVariant *result;
+       int ret;
+       struct pkgmgr_client_t *client = (struct pkgmgr_client_t *)pc;
+
+       if (!pc || !pkgid || !file_path || uid == GLOBAL_USER) {
+               ERR("invalid parameter");
+               return PKGMGR_R_EINVAL;
+       }
+
+       if (client->pc_type != PC_REQUEST) {
+               ERR("client->pc_type is not PC_REQUEST");
+               return PKGMGR_R_EINVAL;
+       }
+
+       ret = pkgmgr_client_connection_send_request(client, "cleardata_with_path",
+                       g_variant_new("(uss)", uid, pkgid, file_path), &result);
+       if (ret != PKGMGR_R_OK) {
+               ERR("request failed: %d", ret);
+               return ret;
+       }
+
+       g_variant_get(result, "(i)", &ret);
+       g_variant_unref(result);
+
+       return ret;
+}
+
+API int pkgmgr_client_clear_user_data_with_path(pkgmgr_client *pc, const char *pkg_type,
+               const char *pkgid, const char *file_path, pkgmgr_mode mode)
+{
+       return pkgmgr_client_usr_clear_user_data_with_path(pc, pkg_type, pkgid,
+                       file_path, mode, _getuid());
+}
+
 API int pkgmgr_client_set_status_type(pkgmgr_client *pc, int status_type)
 {
        struct pkgmgr_client_t *client = (struct pkgmgr_client_t *)pc;