From 84fd5d6ac9f289bcb85a7266df278281b473791b Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Mon, 28 Nov 2016 21:01:23 +0900 Subject: [PATCH] Add functions for change application label Related changes: [pkgmgr-server] : https://review.tizen.org/gerrit/100580 Change-Id: I806d2ab020b53159474676da13b2aff4270ba518 Signed-off-by: Junghyun Yeon --- client/include/package-manager.h | 16 ++++++++++++++++ client/src/pkgmgr.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/client/include/package-manager.h b/client/include/package-manager.h index d0722f3..11d60cf 100644 --- a/client/include/package-manager.h +++ b/client/include/package-manager.h @@ -1075,6 +1075,22 @@ int pkgmgr_client_usr_unset_pkg_restriction_mode(pkgmgr_client *pc, const char * int pkgmgr_client_get_pkg_restriction_mode(pkgmgr_client *pc, const char *pkgid, int *mode); int pkgmgr_client_usr_get_pkg_restriction_mode(pkgmgr_client *pc, const char *pkgid, int *mode, uid_t uid); +/** + * @brief Change application's label + * + * This API sets label of application specified.\n + * + * @param[in] pc The pointer to pkgmgr_client instance + * @param[in] appid app id to be changed. + * @param[in] label application's label to change. + * @param[out] mode restriction mode bit + * @return 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_set_app_label(pkgmgr_client *pc, char *appid, char *label); +int pkgmgr_client_usr_set_app_label(pkgmgr_client *pc, char *appid, char *label, uid_t uid); /** @} */ diff --git a/client/src/pkgmgr.c b/client/src/pkgmgr.c index 3a711d5..73aae94 100644 --- a/client/src/pkgmgr.c +++ b/client/src/pkgmgr.c @@ -2119,3 +2119,34 @@ API int pkgmgr_client_free_pkginfo(pkgmgr_info *info) return PKGMGR_R_OK; } + +API int pkgmgr_client_usr_set_app_label(pkgmgr_client *pc, char *appid, + char *label, uid_t uid) +{ + GVariant *result; + int ret = -1; + struct pkgmgr_client_t *client = (struct pkgmgr_client_t *)pc; + + if (pc == NULL || appid == NULL || label == NULL) { + ERR("Invalid parameter"); + return PKGMGR_R_EINVAL; + } + + ret = pkgmgr_client_connection_send_request(client, + "set_app_label", + g_variant_new("(uss)", uid, appid, label), &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_set_app_label(pkgmgr_client *pc, char *appid, char *label) +{ + return pkgmgr_client_usr_set_app_label(pc, appid, label, _getuid()); +} -- 2.34.1