diff options
author | Changgyu Choi <changyu.choi@samsung.com> | 2022-10-26 11:37:24 +0900 |
---|---|---|
committer | Changgyu Choi <changyu.choi@samsung.com> | 2022-10-27 09:45:18 +0900 |
commit | 334bdb079bf870f67b7b12748e5299abe25cc300 (patch) | |
tree | 8475809fdb2a25540369e74821a9b4f749790c99 | |
parent | 4d4e89e483c0fc3e4d3b1f24023501d392d17152 (diff) | |
download | slp-pkgmgr-334bdb079bf870f67b7b12748e5299abe25cc300.tar.gz slp-pkgmgr-334bdb079bf870f67b7b12748e5299abe25cc300.tar.bz2 slp-pkgmgr-334bdb079bf870f67b7b12748e5299abe25cc300.zip |
Add a new API
Adds:
- pkgmgr_client_clear_user_data_with_path()
Change-Id: I30480116398a015605f906209352eac338316a94
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
-rw-r--r-- | client/include/package-manager.h | 25 | ||||
-rw-r--r-- | client/src/pkgmgr.c | 38 |
2 files changed, 63 insertions, 0 deletions
diff --git a/client/include/package-manager.h b/client/include/package-manager.h index 7167d98..6e334a5 100644 --- a/client/include/package-manager.h +++ b/client/include/package-manager.h @@ -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 * diff --git a/client/src/pkgmgr.c b/client/src/pkgmgr.c index 650b2fe..d08f8f3 100644 --- a/client/src/pkgmgr.c +++ b/client/src/pkgmgr.c @@ -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; |