Add a new API 00/283400/2
authorChanggyu Choi <changyu.choi@samsung.com>
Wed, 26 Oct 2022 02:37:24 +0000 (11:37 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Thu, 27 Oct 2022 00:45:18 +0000 (09:45 +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 7167d9810cdb1194aa26ed19705fc48d5710108d..6e334a51567c5ca7c9a8731fd92ddbcf5b809c13 100644 (file)
@@ -762,6 +762,31 @@ int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
                                const char *pkgid, pkgmgr_mode mode);
 int pkgmgr_client_usr_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
                                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 650b2fe98f1764fcdc17d7b147c299920e836aee..d08f8f330509ed2693e2b735a5d6535706b8c0bd 100644 (file)
@@ -1809,6 +1809,44 @@ API int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
                        _getuid());
 }
 
+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;