clean unused api, debug message
authorjunsuk77.oh <junsuk77.oh@samsung.com>
Tue, 9 Apr 2013 08:09:05 +0000 (17:09 +0900)
committerjunsuk77.oh <junsuk77.oh@samsung.com>
Tue, 9 Apr 2013 08:09:05 +0000 (17:09 +0900)
Change-Id: I90e6c781dbdb7bef37fec073f4efa6490b9d202b
Signed-off-by: junsuk77.oh <junsuk77.oh@samsung.com>
include/pkgmgr-info.h
packaging/pkgmgr-info.spec
src/pkgmgr-info.c

index 683a87a..53ca65e 100755 (executable)
@@ -4052,6 +4052,599 @@ static int delete_cert_info(const char *pkgid)
  int pkgmgrinfo_delete_certinfo(const char *pkgid);
 
 /**
+ * @fn int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *handle)
+ * @brief      This API creates the package db information handle to set data in db.
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] pkgid    pointer to the package ID.
+ * @param[out] handle          pointer to the package db info handle.
+ * @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                None
+ * @post               pkgmgrinfo_destroy_pkgdbinfo()
+ * @see                pkgmgrinfo_save_pkgdbinfo()
+ * @see                pkgmgrinfo_set_type_to_pkgdbinfo()
+ * @code
+static int set_pkg_in_db(const char *pkgid)
+{
+       int ret = 0;
+       pkgmgrinfo_pkgdbinfo_h handle;
+       ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_set_version_to_pkgdbinfo(handle, "0.0.1");
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       ret = pkgmgrinfo_save_pkgdbinfo(handle);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       pkgmgrinfo_destroy_pkgdbinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *handle);
+
+/**
+ * @fn int pkgmgrinfo_set_type_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *type)
+ * @brief      This API sets the package type in db handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle   pointer to the pkgdbinfo handle.
+ * @param[in] type             pointer to the package type.
+ * @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_create_pkgdbinfo()
+ * @post               pkgmgrinfo_destroy_pkgdbinfo()
+ * @see                pkgmgrinfo_save_pkgdbinfo()
+ * @see                pkgmgrinfo_set_version_to_pkgdbinfo()
+ * @code
+static int set_pkg_type_in_db(const char *pkgid)
+{
+       int ret = 0;
+       pkgmgrinfo_pkgdbinfo_h handle;
+       ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_set_type_to_pkgdbinfo(handle, "wgt");
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       ret = pkgmgrinfo_save_pkgdbinfo(handle);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       pkgmgrinfo_destroy_pkgdbinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_set_type_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *type);
+
+/**
+ * @fn int pkgmgrinfo_set_version_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *version)
+ * @brief      This API sets the package version in db handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle   pointer to the pkgdbinfo handle.
+ * @param[in] version          pointer to the package 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_create_pkgdbinfo()
+ * @post               pkgmgrinfo_destroy_pkgdbinfo()
+ * @see                pkgmgrinfo_save_pkgdbinfo()
+ * @see                pkgmgrinfo_set_type_to_pkgdbinfo()
+ * @code
+static int set_pkg_version_in_db(const char *pkgid)
+{
+       int ret = 0;
+       pkgmgrinfo_pkgdbinfo_h handle;
+       ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_set_version_to_pkgdbinfo(handle, "0.0.1");
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       ret = pkgmgrinfo_save_pkgdbinfo(handle);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       pkgmgrinfo_destroy_pkgdbinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_set_version_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *version);
+
+/**
+ * @fn int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
+ * @brief      This API sets the package install location in db handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle   pointer to the pkgdbinfo handle.
+ * @param[in] location package install location
+ * @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_create_pkgdbinfo()
+ * @post               pkgmgrinfo_destroy_pkgdbinfo()
+ * @see                pkgmgrinfo_save_pkgdbinfo()
+ * @see                pkgmgrinfo_set_type_to_pkgdbinfo()
+ * @code
+static int set_pkg_install_location_in_db(const char *pkgid)
+{
+       int ret = 0;
+       pkgmgrinfo_pkgdbinfo_h handle;
+       ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_set_install_location_to_pkgdbinfo(handle, INSTALL_INTERNAL);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       ret = pkgmgrinfo_save_pkgdbinfo(handle);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       pkgmgrinfo_destroy_pkgdbinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location);
+
+/**
+ * @fn int pkgmgrinfo_set_size_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *size)
+ * @brief      This API sets the package size in db handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle   pointer to the pkgdbinfo handle.
+ * @param[in] size             pointer to the package size
+ * @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_create_pkgdbinfo()
+ * @post               pkgmgrinfo_destroy_pkgdbinfo()
+ * @see                pkgmgrinfo_save_pkgdbinfo()
+ * @see                pkgmgrinfo_set_type_to_pkgdbinfo()
+ * @code
+static int set_pkg_size_in_db(const char *pkgid)
+{
+       int ret = 0;
+       pkgmgrinfo_pkgdbinfo_h handle;
+       ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_set_size_to_pkgdbinfo(handle, "15");
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       ret = pkgmgrinfo_save_pkgdbinfo(handle);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       pkgmgrinfo_destroy_pkgdbinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_set_size_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *size);
+
+/**
+ * @fn int pkgmgrinfo_set_label_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *label, const char *locale)
+ * @brief      This API sets the package label in db handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle   pointer to the pkgdbinfo handle.
+ * @param[in] label            pointer to the package label
+ * @param[in] locale   pointer to the locale
+ * @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_create_pkgdbinfo()
+ * @post               pkgmgrinfo_destroy_pkgdbinfo()
+ * @see                pkgmgrinfo_save_pkgdbinfo()
+ * @see                pkgmgrinfo_set_type_to_pkgdbinfo()
+ * @code
+static int set_pkg_label_in_db(const char *pkgid)
+{
+       int ret = 0;
+       pkgmgrinfo_pkgdbinfo_h handle;
+       ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_set_label_to_pkgdbinfo(handle, "helloworld", "en-us");
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       ret = pkgmgrinfo_save_pkgdbinfo(handle);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       pkgmgrinfo_destroy_pkgdbinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_set_label_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *label, const char *locale);
+
+/**
+ * @fn int pkgmgrinfo_set_icon_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *icon, const char *locale)
+ * @brief      This API sets the package icon in db handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle   pointer to the pkgdbinfo handle.
+ * @param[in] icon             pointer to the package icon
+ * @param[in] locale   pointer to the locale
+ * @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_create_pkgdbinfo()
+ * @post               pkgmgrinfo_destroy_pkgdbinfo()
+ * @see                pkgmgrinfo_save_pkgdbinfo()
+ * @see                pkgmgrinfo_set_type_to_pkgdbinfo()
+ * @code
+static int set_pkg_icon_in_db(const char *pkgid)
+{
+       int ret = 0;
+       pkgmgrinfo_pkgdbinfo_h handle;
+       ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_set_icon_to_pkgdbinfo(handle, "helloworld.png", "en-us");
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       ret = pkgmgrinfo_save_pkgdbinfo(handle);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       pkgmgrinfo_destroy_pkgdbinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_set_icon_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *icon, const char *locale);
+
+/**
+ * @fn int pkgmgrinfo_set_description_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *description, const char *locale)
+ * @brief      This API sets the package description in db handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle   pointer to the pkgdbinfo handle.
+ * @param[in] description              pointer to the package description
+ * @param[in] locale   pointer to the locale
+ * @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_create_pkgdbinfo()
+ * @post               pkgmgrinfo_destroy_pkgdbinfo()
+ * @see                pkgmgrinfo_save_pkgdbinfo()
+ * @see                pkgmgrinfo_set_type_to_pkgdbinfo()
+ * @code
+static int set_pkg_description_in_db(const char *pkgid)
+{
+       int ret = 0;
+       pkgmgrinfo_pkgdbinfo_h handle;
+       ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_set_description_to_pkgdbinfo(handle, "helloworld application", "en-us");
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       ret = pkgmgrinfo_save_pkgdbinfo(handle);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       pkgmgrinfo_destroy_pkgdbinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_set_description_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *description, const char *locale);
+
+/**
+ * @fn int pkgmgrinfo_set_author_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *author_name,
+ const char *author_email, const char *author_href, const char *locale)
+ * @brief      This API sets the package author info in db handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle   pointer to the pkgdbinfo handle.
+ * @param[in] author_name              pointer to the package author name
+ * @param[in] author_email             pointer to the package author email
+ * @param[in] author_href              pointer to the package author href
+ * @param[in] locale   pointer to the locale
+ * @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_create_pkgdbinfo()
+ * @post               pkgmgrinfo_destroy_pkgdbinfo()
+ * @see                pkgmgrinfo_save_pkgdbinfo()
+ * @see                pkgmgrinfo_set_type_to_pkgdbinfo()
+ * @code
+static int set_pkg_author_in_db(const char *pkgid)
+{
+       int ret = 0;
+       pkgmgrinfo_pkgdbinfo_h handle;
+       ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_set_author_to_pkgdbinfo(handle, "John", "john@samsung.com", "www.samsung.com", "en-us");
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       ret = pkgmgrinfo_save_pkgdbinfo(handle);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       pkgmgrinfo_destroy_pkgdbinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_set_author_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *author_name,
+                       const char *author_email, const char *author_href, const char *locale);
+
+/**
+ * @fn int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int removable)
+ * @brief      This API sets the package 'removable' value in db handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle   pointer to the pkgdbinfo handle.
+ * @param[in] removable                package removable value
+ * @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_create_pkgdbinfo()
+ * @post               pkgmgrinfo_destroy_pkgdbinfo()
+ * @see                pkgmgrinfo_save_pkgdbinfo()
+ * @see                pkgmgrinfo_set_type_to_pkgdbinfo()
+ * @code
+static int set_pkg_removable_in_db(const char *pkgid)
+{
+       int ret = 0;
+       pkgmgrinfo_pkgdbinfo_h handle;
+       ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_set_removable_to_pkgdbinfo(handle, 1);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       ret = pkgmgrinfo_save_pkgdbinfo(handle);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       pkgmgrinfo_destroy_pkgdbinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int removable);
+
+/**
+ * @fn int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int preload)
+ * @brief      This API sets the package 'preload' value in db handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle   pointer to the pkgdbinfo handle.
+ * @param[in] preload          package preload value
+ * @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_create_pkgdbinfo()
+ * @post               pkgmgrinfo_destroy_pkgdbinfo()
+ * @see                pkgmgrinfo_save_pkgdbinfo()
+ * @see                pkgmgrinfo_set_type_to_pkgdbinfo()
+ * @code
+static int set_pkg_preload_in_db(const char *pkgid)
+{
+       int ret = 0;
+       pkgmgrinfo_pkgdbinfo_h handle;
+       ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_set_preload_to_pkgdbinfo(handle, 1);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       ret = pkgmgrinfo_save_pkgdbinfo(handle);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       pkgmgrinfo_destroy_pkgdbinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int preload);
+
+/**
+ * @fn int pkgmgrinfo_set_installed_storage_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
+ * @brief      This API sets the package 'installed_storage' value in db handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle   pointer to the pkgdbinfo handle.
+ * @param[in] location         installed_storage value
+ * @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_create_pkgdbinfo()
+ * @post               pkgmgrinfo_destroy_pkgdbinfo()
+ * @see                pkgmgrinfo_save_pkgdbinfo()
+ * @code
+static int set_pkg_installed_storage_in_db(const char *pkgid)
+{
+       int ret = 0;
+       pkgmgrinfo_pkgdbinfo_h handle;
+       ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_set_installed_storage_to_pkgdbinfo(handle, INSTALL_INTERNAL);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       ret = pkgmgrinfo_save_pkgdbinfo(handle);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       pkgmgrinfo_destroy_pkgdbinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_set_installed_storage_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location);
+
+/**
+ * @fn int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
+ * @brief      This API saves all the information from the handle to the DB.
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle           pointer to the package db info handle.
+ * @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_create_pkgdbinfo()
+ * @post               pkgmgrinfo_destroy_pkgdbinfo()
+ * @see                pkgmgrinfo_set_type_to_pkgdbinfo()
+ * @code
+static int set_pkg_in_db(const char *pkgid)
+{
+       int ret = 0;
+       pkgmgrinfo_pkgdbinfo_h handle;
+       ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_set_version_to_pkgdbinfo(handle, "0.0.1");
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       ret = pkgmgrinfo_save_pkgdbinfo(handle);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       pkgmgrinfo_destroy_pkgdbinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle);
+
+/**
+ * @fn int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
+ * @brief      This API destroys the package db information handle freeing up all the resources
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle           pointer to the package db info handle.
+ * @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_create_pkgdbinfo()
+ * @post               None
+ * @see                pkgmgrinfo_save_pkgdbinfo()
+ * @see                pkgmgrinfo_set_type_to_pkgdbinfo()
+ * @code
+static int set_pkg_in_db(const char *pkgid)
+{
+       int ret = 0;
+       pkgmgrinfo_pkgdbinfo_h handle;
+       ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_set_version_to_pkgdbinfo(handle, "0.0.1");
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       ret = pkgmgrinfo_save_pkgdbinfo(handle);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_destroy_pkgdbinfo(handle);
+               return -1;
+       }
+       pkgmgrinfo_destroy_pkgdbinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle);
+
+
+/**
  * @fn int pkgmgrinfo_create_certinfo_set_handle(pkgmgrinfo_instcertinfo_h *handle)
  * @brief      This API creates the package cert information handle to set data in db.
  *
index d183d0b..8bb9a8a 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       pkgmgr-info
 Summary:    Packager Manager infomation api for package
-Version:    0.0.95
+Version:    0.0.96
 Release:    1
 Group:      Application Framework/Package Management
 License:    Apache-2.0
index 7079d57..9a92173 100755 (executable)
@@ -2381,18 +2381,13 @@ API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *si
        char *location = NULL;
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
        location = (char *)info->manifest_info->installlocation;
-       if (strcmp(location, "prefer-external") == 0)
-       {
-               val = (char *)info->manifest_info->package_size;
-               if (val) {
-                       *size = atoi(val);
-               } else {
-                       *size = 0;
-                       _LOGE("package size is not specified\n");
-                       return PMINFO_R_ERROR;
-               }
+       val = (char *)info->manifest_info->package_size;
+       if (val) {
+               *size = atoi(val);
        } else {
                *size = 0;
+               _LOGE("package size is not specified\n");
+               return PMINFO_R_ERROR;
        }
        return PMINFO_R_OK;
 }
@@ -6242,133 +6237,95 @@ err:
 
 API int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *handle)
 {
-       if (!pkgid || !handle) {
-               _LOGE("Argument supplied is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
+       retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
+       char *manifest = NULL;
        manifest_x *mfx = NULL;
-       mfx = calloc(1, sizeof(manifest_x));
-       if (!mfx) {
-               _LOGE("Malloc Failed\n");
-               return PMINFO_R_ERROR;
+
+       manifest = pkgmgr_parser_get_manifest_file(pkgid);
+       retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
+
+       mfx = pkgmgr_parser_process_manifest_xml(manifest);
+       if (manifest) {
+               free(manifest);
+               manifest = NULL;
        }
-       mfx->package = strdup(pkgid);
+       retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
+
        *handle = (void *)mfx;
+
        return PMINFO_R_OK;
 }
 
 API int pkgmgrinfo_set_type_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *type)
 {
-       if (!type || !handle) {
-               _LOGE("Argument supplied is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(!type, PMINFO_R_EINVAL, "Argument supplied is NULL");
+       retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
        int len = strlen(type);
+       retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
+
        manifest_x *mfx = (manifest_x *)handle;
-       if (len > PKG_TYPE_STRING_LEN_MAX) {
-               _LOGE("pkg type length exceeds the max limit\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (mfx->type == NULL)
-               mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX);
-       else
-               mfx->type = type;
 
+       mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX);
        return PMINFO_R_OK;
 }
 
 API int pkgmgrinfo_set_version_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *version)
 {
-       if (!version || !handle) {
-               _LOGE("Argument supplied is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(!version, PMINFO_R_EINVAL, "Argument supplied is NULL");
+       retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
        int len = strlen(version);
+       retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
+
        manifest_x *mfx = (manifest_x *)handle;
-       if (len > PKG_VERSION_STRING_LEN_MAX) {
-               _LOGE("pkg version length exceeds the max limit\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (mfx->version == NULL)
-               mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX);
-       else
-               mfx->version = version;
 
+       mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX);
        return PMINFO_R_OK;
 }
 
 API int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
 {
-       if (!handle) {
-               _LOGE("Argument supplied is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (location < 0 || location > 1) {
-               _LOGE("Argument supplied is invalid\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+       retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
+
        manifest_x *mfx = (manifest_x *)handle;
-       if (mfx->installlocation == NULL) {
-               mfx->installlocation = (char *)calloc(1, strlen("prefer-external") + 1);
-               if (mfx->installlocation == NULL) {
-                       _LOGE("Malloc Failed\n");
-                       return PMINFO_R_ERROR;
-               }
-       }
-       if (location == INSTALL_INTERNAL) {
-               strcpy((char *)mfx->installlocation, "internal-only");
-       } else if (location == INSTALL_EXTERNAL) {
-               strcpy((char *)mfx->installlocation, "prefer-external");
-       } else {
-               _LOGE("Invalid location type\n");
-               return PMINFO_R_ERROR;
-       }
+
+       if (location == INSTALL_INTERNAL)
+               strcpy(mfx->installlocation, "internal-only");
+       else if (location == INSTALL_EXTERNAL)
+               strcpy(mfx->installlocation, "prefer-external");
+
        return PMINFO_R_OK;
 }
 
 API int pkgmgrinfo_set_size_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *size)
 {
-       if (!handle) {
-               _LOGE("Argument supplied is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (size == NULL) {
-               _LOGE("Argument supplied is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+       retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
        manifest_x *mfx = (manifest_x *)handle;
-       if (mfx->installlocation == NULL) {
-               _LOGE("cant set size without specifying install location\n");
-               return PMINFO_R_ERROR;
-       }
-       if (strcmp(mfx->installlocation, "prefer-external") == 0) {
-               if (mfx->package_size == NULL)
-                       mfx->package_size = strdup(size);
-               else
-                       mfx->package_size = size;
-       } else {
-               _LOGE("cant set size for internal location\n");
-               return PMINFO_R_ERROR;
-       }
+
+       mfx->package_size = strdup(size);
+
        return PMINFO_R_OK;
 }
+
 API int pkgmgrinfo_set_label_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *label_txt, const char *locale)
 {
-       if (!handle || !label_txt) {
-               _LOGE("Argument supplied is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+       retvm_if(!label_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
        int len = strlen(label_txt);
+       retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
+
        manifest_x *mfx = (manifest_x *)handle;
-       if (len > PKG_VALUE_STRING_LEN_MAX) {
-               _LOGE("label length exceeds the max limit\n");
-               return PMINFO_R_EINVAL;
-       }
+
        label_x *label = calloc(1, sizeof(label_x));
-       if (label == NULL) {
-               _LOGE("Malloc Failed\n");
-               return PMINFO_R_ERROR;
-       }
+       retvm_if(label == NULL, PMINFO_R_EINVAL, "Malloc Failed");
+
        LISTADD(mfx->label, label);
        if (locale)
                mfx->label->lang = strdup(locale);
@@ -6381,21 +6338,17 @@ API int pkgmgrinfo_set_label_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const c
 
 API int pkgmgrinfo_set_icon_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *icon_txt, const char *locale)
 {
-       if (!handle || !icon_txt) {
-               _LOGE("Argument supplied is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+       retvm_if(!icon_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
        int len = strlen(icon_txt);
+       retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
+
        manifest_x *mfx = (manifest_x *)handle;
-       if (len > PKG_VALUE_STRING_LEN_MAX) {
-               _LOGE("icon length exceeds the max limit\n");
-               return PMINFO_R_EINVAL;
-       }
+
        icon_x *icon = calloc(1, sizeof(icon_x));
-       if (icon == NULL) {
-               _LOGE("Malloc Failed\n");
-               return PMINFO_R_ERROR;
-       }
+       retvm_if(icon == NULL, PMINFO_R_EINVAL, "Malloc Failed");
+
        LISTADD(mfx->icon, icon);
        if (locale)
                mfx->icon->lang = strdup(locale);
@@ -6408,21 +6361,17 @@ API int pkgmgrinfo_set_icon_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const ch
 
 API int pkgmgrinfo_set_description_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *desc_txt, const char *locale)
 {
-       if (!handle || !desc_txt) {
-               _LOGE("Argument supplied is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+       retvm_if(!desc_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
        int len = strlen(desc_txt);
+       retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
+
        manifest_x *mfx = (manifest_x *)handle;
-       if (len > PKG_VALUE_STRING_LEN_MAX) {
-               _LOGE("description length exceeds the max limit\n");
-               return PMINFO_R_EINVAL;
-       }
+
        description_x *description = calloc(1, sizeof(description_x));
-       if (description == NULL) {
-               _LOGE("Malloc Failed\n");
-               return PMINFO_R_ERROR;
-       }
+       retvm_if(description == NULL, PMINFO_R_EINVAL, "Malloc Failed");
+
        LISTADD(mfx->description, description);
        if (locale)
                mfx->description->lang = strdup(locale);
@@ -6436,16 +6385,11 @@ API int pkgmgrinfo_set_description_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, c
 API int pkgmgrinfo_set_author_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *author_name,
                const char *author_email, const char *author_href, const char *locale)
 {
-       if (!handle) {
-               _LOGE("Argument supplied is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
        manifest_x *mfx = (manifest_x *)handle;
        author_x *author = calloc(1, sizeof(author_x));
-       if (author == NULL) {
-               _LOGE("Malloc Failed\n");
-               return PMINFO_R_ERROR;
-       }
+       retvm_if(author == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
        LISTADD(mfx->author, author);
        if (author_name)
                mfx->author->text = strdup(author_name);
@@ -6462,93 +6406,58 @@ API int pkgmgrinfo_set_author_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const
 
 API int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int removable)
 {
-       if (!handle) {
-               _LOGE("Argument supplied is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (removable < 0 || removable > 1) {
-               _LOGE("Argument supplied is invalid\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+       retvm_if((removable < 0) || (removable > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
+
        manifest_x *mfx = (manifest_x *)handle;
-       if (mfx->removable == NULL) {
-               mfx->removable = (char *)calloc(1, strlen("false") + 1);
-               if (mfx->removable == NULL) {
-                       _LOGE("Malloc Failed\n");
-                       return PMINFO_R_ERROR;
-               }
-       }
-       if (removable == 0) {
-               strcpy((char *)mfx->removable, "false");
-       } else if (removable == 1) {
-               strcpy((char *)mfx->removable, "true");
-       } else {
-               _LOGE("Invalid removable type\n");
-               return PMINFO_R_ERROR;
-       }
+
+       if (removable == 0)
+               strcpy(mfx->removable, "false");
+       else if (removable == 1)
+               strcpy(mfx->removable, "true");
+
        return PMINFO_R_OK;
 }
 
 API int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int preload)
 {
-       if (!handle) {
-               _LOGE("Argument supplied is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (preload < 0 || preload > 1) {
-               _LOGE("Argument supplied is invalid\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+       retvm_if((preload < 0) || (preload > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
+
        manifest_x *mfx = (manifest_x *)handle;
-       if (mfx->preload == NULL) {
-               mfx->preload = (char *)calloc(1, strlen("false") + 1);
-               if (mfx->preload == NULL) {
-                       _LOGE("Malloc Failed\n");
-                       return PMINFO_R_ERROR;
-               }
-       }
-       if (preload == 0) {
-               strcpy((char *)mfx->preload, "false");
-       } else if (preload == 1) {
-               strcpy((char *)mfx->preload, "true");
-       } else {
-               _LOGE("Invalid preload type\n");
-               return PMINFO_R_ERROR;
-       }
+
+       if (preload == 0)
+               strcpy(mfx->preload, "false");
+       else if (preload == 1)
+               strcpy(mfx->preload, "true");
+
+       return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_set_installed_storage_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
+{
+       retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+       retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
+
+       manifest_x *mfx = (manifest_x *)handle;
+
+       if (location == INSTALL_INTERNAL)
+               strcpy(mfx->installed_storage, "installed_internal");
+       else if (location == INSTALL_EXTERNAL)
+               strcpy(mfx->installed_storage, "installed_external");
+
        return PMINFO_R_OK;
 }
 
 API int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
 {
-       if (!handle) {
-               _LOGE("Argument supplied is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
        int ret = 0;
        manifest_x *mfx = NULL;
-       label_x *tmp1 = NULL;
-       icon_x *tmp2 = NULL;
-       description_x *tmp3 = NULL;
-       author_x *tmp4 = NULL;
        mfx = (manifest_x *)handle;
-       /*First move to head of all list pointers*/
-       if (mfx->label) {
-               LISTHEAD(mfx->label, tmp1);
-               mfx->label = tmp1;
-       }
-       if (mfx->icon) {
-               LISTHEAD(mfx->icon, tmp2);
-               mfx->icon = tmp2;
-       }
-       if (mfx->description) {
-               LISTHEAD(mfx->description, tmp3);
-               mfx->description= tmp3;
-       }
-       if (mfx->author) {
-               LISTHEAD(mfx->author, tmp4);
-               mfx->author = tmp4;
-       }
-       ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
+
+       ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
        if (ret == 0) {
                _LOGE("Successfully stored info in DB\n");
                return PMINFO_R_OK;
@@ -6560,10 +6469,8 @@ API int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
 
 API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
 {
-       if (!handle) {
-               _LOGE("Argument supplied is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
        manifest_x *mfx = NULL;
        mfx = (manifest_x *)handle;
        pkgmgr_parser_free_manifest_xml(mfx);