Add new api to get external image path 41/120441/1
authorjongmyeongko <jongmyeong.ko@samsung.com>
Wed, 22 Mar 2017 06:21:43 +0000 (15:21 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Thu, 23 Mar 2017 02:13:25 +0000 (19:13 -0700)
Change-Id: I198cfdd2d4b489ce314a8ce0dcbd273511967b05
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
(cherry picked from commit a3c37400077cabe6cdc6dd83326cf34d99888d6a)

include/pkgmgr-info.h
src/pkgmgrinfo_pkginfo.c

index 4f2171c..471c881 100644 (file)
@@ -620,6 +620,47 @@ static int get_zip_mount_file(const char *pkgid)
 int pkgmgrinfo_pkginfo_get_zip_mount_file(pkgmgrinfo_pkginfo_h handle, char **zip_mount_file);
 
 /**
+ * @fn int pkgmgrinfo_pkginfo_get_external_image_path(pkgmgrinfo_pkginfo_h handle, char **ext_image_path)
+ * @brief      This API gets package external image path associated with the package
+ *                     if package is installed in external storage.
+ *                     Otherwise, the return value will be PMINFO_R_ENOENT.
+ *
+ * @par        This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle   pointer to the pkginfo handle.
+ * @param[out] ext_image_path  pointer to hold external image path
+ * @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
+ * @revall     PMINFO_R_ENOENT no valid data
+ * @pre        pkgmgrinfo_pkginfo_get_pkginfo()
+ * @post       pkgmgrinfo_pkginfo_destroy_pkginfo()
+ * @see        pkgmgrinfo_pkginfo_get_pkgid()
+ * @code
+static int get_external_image_path(const char *pkgid)
+{
+       int ret = 0;
+       char *ext_image_path = NULL;
+       pkgmgrinfo_pkginfo_h handle = NULL;
+       ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_pkginfo_get_external_image_path(handle, &ext_image_path);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+               return -1;
+       }
+       printf("external image path is: %s\n", ext_image_path);
+       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_pkginfo_get_external_image_path(pkgmgrinfo_pkginfo_h handle, char **ext_image_path);
+
+/**
  * @fn int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
  * @brief      This API gets the package install location from the package ID
  *
index fe4b52a..0272937 100644 (file)
@@ -1097,6 +1097,24 @@ API int pkgmgrinfo_pkginfo_get_zip_mount_file(pkgmgrinfo_pkginfo_h handle, char
        return PMINFO_R_OK;
 }
 
+API int pkgmgrinfo_pkginfo_get_external_image_path(pkgmgrinfo_pkginfo_h handle, char **ext_image_path)
+{
+       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+       retvm_if(ext_image_path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+       if (info->pkg_info == NULL)
+               return PMINFO_R_ERROR;
+
+       if (info->pkg_info->external_path == NULL)
+               return PMINFO_R_ENOENT;
+
+       *ext_image_path = (char *)info->pkg_info->external_path;
+
+       return PMINFO_R_OK;
+}
+
 API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
 {
        char *val;