From 57aa9c3cb129c9dadd32f7c22e2233636c52468e Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Mon, 24 Jul 2017 22:27:35 +0900 Subject: [PATCH] Add new feature to change app's icon Change-Id: Id731b9c57909e8e16001272a7bf0b5391f607032 Signed-off-by: jongmyeongko --- client/include/package-manager.h | 16 ++++++++++++++++ client/src/pkgmgr.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/client/include/package-manager.h b/client/include/package-manager.h index a7709e0..fec595b 100644 --- a/client/include/package-manager.h +++ b/client/include/package-manager.h @@ -1087,6 +1087,22 @@ 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); /** + * @brief Change application's icon + * + * This API sets icon of application specified.\n + * + * @param[in] pc The pointer to pkgmgr_client instance + * @param[in] appid app id to be changed. + * @param[in] icon_path application's icon path to change. + * @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_icon(pkgmgr_client *pc, char *appid, char *icon_path); +int pkgmgr_client_usr_set_app_icon(pkgmgr_client *pc, char *appid, char *icon_path, uid_t uid); + +/** * @brief Set debug mode * * This API sets debug mode value for request.\n diff --git a/client/src/pkgmgr.c b/client/src/pkgmgr.c index babdd8c..95a9b08 100644 --- a/client/src/pkgmgr.c +++ b/client/src/pkgmgr.c @@ -2359,6 +2359,42 @@ 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()); } +API int pkgmgr_client_usr_set_app_icon(pkgmgr_client *pc, char *appid, + char *icon_path, uid_t uid) +{ + GVariant *result; + int ret = -1; + struct pkgmgr_client_t *client = (struct pkgmgr_client_t *)pc; + + if (pc == NULL || appid == NULL || icon_path == NULL) { + ERR("Invalid parameter"); + return PKGMGR_R_EINVAL; + } + + if (access(icon_path, F_OK) != 0) { + ERR("failed to access: %s", icon_path); + return PKGMGR_R_EINVAL; + } + + ret = pkgmgr_client_connection_send_request(client, + "set_app_icon", + g_variant_new("(uss)", uid, appid, icon_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_set_app_icon(pkgmgr_client *pc, char *appid, char *icon_path) +{ + return pkgmgr_client_usr_set_app_icon(pc, appid, icon_path, _getuid()); +} + API int pkgmgr_client_set_debug_mode(pkgmgr_client *pc, bool debug_mode) { struct pkgmgr_client_t *client = (struct pkgmgr_client_t *)pc; -- 2.7.4