Add pkgmgrinfo_appinfo_is_category_exists 08/34308/1 accepted/tizen/mobile/20150127.061159 accepted/tizen/tv/20150127.060443 accepted/tizen/wearable/20150127.060703 submit/tizen_mobile/20150127.020611 submit/tizen_tv/20150127.020604 submit/tizen_wearable/20150127.020617
authorSangyoon Jang <s89.jang@samsung.com>
Fri, 23 Jan 2015 06:47:15 +0000 (15:47 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Fri, 23 Jan 2015 06:47:15 +0000 (15:47 +0900)
Change-Id: I2b7aa3eec0e2d2f6cdfe4a13fe420cfe16bacf82
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
include/pkgmgr-info.h
src/pkgmgr-info.c

index 901015b..3358c2f 100644 (file)
@@ -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
  *
index 62cde6a..ccd1689 100644 (file)
@@ -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");