From: Sangyoon Jang Date: Fri, 23 Jan 2015 06:47:15 +0000 (+0900) Subject: Add pkgmgrinfo_appinfo_is_category_exists X-Git-Tag: accepted/tizen/mobile/20150127.061159^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=336762f67831eaccc3fa088bbce21d76aa768a6d;p=platform%2Fcore%2Fappfw%2Fpkgmgr-info.git Add pkgmgrinfo_appinfo_is_category_exists Change-Id: I2b7aa3eec0e2d2f6cdfe4a13fe420cfe16bacf82 Signed-off-by: Sangyoon Jang --- diff --git a/include/pkgmgr-info.h b/include/pkgmgr-info.h index 901015b..3358c2f 100644 --- a/include/pkgmgr-info.h +++ b/include/pkgmgr-info.h @@ -3866,6 +3866,44 @@ static int get_app_submode(const char *appid) int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode); /** + * @fn int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist) + * @brief This API checks if the application has the given category + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * + * @param[in] handle pointer to the application info handle + * @param[in] category category + * @param[out] exist value Gets whether the application has the given category + * @return 0 if success, error code(<0) if fail + * @retval PMINFO_R_OK success + * @retval PMINFO_R_EINVAL invalid argument + * @retval PMINFO_R_ERROR internal error + * @code +static int is_category_exist(const char *appid, const char *category) +{ + int ret = 0; + pkgmgrinfo_appinfo_h handle; + bool exist = false; + + ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); + if (ret != PMINFO_R_OK) + return -1; + + ret = pkgmgrinfo_appinfo_is_category_exist(handle, category, &exist); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return -1; + } + + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return 0; +} + * @endcode + */ +int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist); + +/** * @fn int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle) * @brief This API destroys the application information handle freeing up all the resources * diff --git a/src/pkgmgr-info.c b/src/pkgmgr-info.c index 62cde6a..ccd1689 100644 --- a/src/pkgmgr-info.c +++ b/src/pkgmgr-info.c @@ -6457,6 +6457,32 @@ API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode return PMINFO_R_OK; } +API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist) +{ + retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL"); + retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL"); + retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL"); + + category_x *ptr = NULL; + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + + *exist = 0; + + ptr = info->uiapp_info->category; + + for (; ptr; ptr = ptr->next) { + if (ptr->name) { + if (strcasecmp(ptr->name, category) == 0) + { + *exist = 1; + break; + } + } + } + + return PMINFO_R_OK; +} + API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle) { retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");