Add new feature to change app's icon 35/140335/4
authorjongmyeongko <jongmyeong.ko@samsung.com>
Mon, 24 Jul 2017 13:27:35 +0000 (22:27 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Tue, 8 Aug 2017 08:33:42 +0000 (17:33 +0900)
Change-Id: Id731b9c57909e8e16001272a7bf0b5391f607032
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
client/include/package-manager.h
client/src/pkgmgr.c

index a7709e0..fec595b 100644 (file)
@@ -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
index babdd8c..95a9b08 100644 (file)
@@ -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;