Add pkgmgrinfo_pkginfo_get_api_version 41/52241/1 accepted/tizen/mobile/20151124.084646 accepted/tizen/tv/20151124.084703 accepted/tizen/wearable/20151124.084722 submit/tizen/20151123.053026
authorSangyoon Jang <s89.jang@samsung.com>
Fri, 20 Nov 2015 06:00:55 +0000 (15:00 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Fri, 20 Nov 2015 06:00:55 +0000 (15:00 +0900)
Change-Id: I39777e10b4065078ed081196df26a704d33b600f
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
include/pkgmgr-info.h
src/pkgmgrinfo_pkginfo.c

index a9c0a07..2463d06 100644 (file)
@@ -412,6 +412,45 @@ static int get_pkg_version(const char *pkgid)
 int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version);
 
 /**
+ * @fn int pkgmgrinfo_pkginfo_get_api_version(pkgmgrinfo_pkginfo_h handle, char **api_version)
+ * @brief      This API gets the package api_version from the package ID
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in]  handle  pointer to package info handle
+ * @param[out] api_version             pointer to hold package api_version
+ * @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
+ * @pre                pkgmgrinfo_pkginfo_get_pkginfo()
+ * @post               pkgmgrinfo_pkginfo_destroy_pkginfo()
+ * @see                pkgmgrinfo_pkginfo_get_pkgid()
+ * @see                pkgmgrinfo_pkginfo_is_removable()
+ * @code
+static int get_pkg_api_version(const char *pkgid)
+{
+       int ret = 0;
+       char *api_version = NULL;
+       pkgmgrinfo_pkginfo_h handle = NULL;
+       ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_pkginfo_get_api_version(handle, &api_version);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+               return -1;
+       }
+       printf("pkg api_version: %s\n", api_version);
+       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_pkginfo_get_api_version(pkgmgrinfo_pkginfo_h handle, char **api_version);
+
+/**
  * @fn int pkgmgrinfo_pkginfo_get_tep_name(pkgmgrinfo_pkginfo_h handle, char **tep_name)
  * @brief      This API gets tep(tizen expansion package) file name associated with the package
  *
index 7a086d6..2a85d4f 100644 (file)
@@ -876,6 +876,21 @@ API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **versi
        return PMINFO_R_OK;
 }
 
+API int pkgmgrinfo_pkginfo_get_api_version(pkgmgrinfo_pkginfo_h handle, char **api_version)
+{
+       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+       retvm_if(api_version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+       if (info->pkg_info == NULL || info->pkg_info->api_version == NULL)
+               return PMINFO_R_ERROR;
+
+       *api_version = (char *)info->pkg_info->api_version;
+
+       return PMINFO_R_OK;
+}
+
 API int pkgmgrinfo_pkginfo_get_tep_name(pkgmgrinfo_pkginfo_h handle, char **tep_name)
 {
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;