Add Foreach depdency API for Archiveinfo
[platform/core/appfw/pkgmgr-info.git] / include / pkgmgr-info.h
index 0634127..8fac17b 100644 (file)
@@ -1950,7 +1950,7 @@ int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly);
 
 /**
  * @fn int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
- * @brief      This API gets the package 'upate' value from the package ID
+ * @brief      This API gets the package 'update' value from the package ID
  *
  * @par                This API is for package-manager client application
  * @par Sync (or) Async : Synchronous API
@@ -6433,52 +6433,510 @@ int pkgmgrinfo_pkginfo_foreach_depends_on(pkgmgrinfo_pkginfo_h handle,
                void *user_data);
 
 /**
- * @brief      TEMP
- */
-
+ * @fn int pkgmgrinfo_pkginfo_get_list_full(pkgmgrinfo_pkg_list_cb pkg_list_cb, int flag, void *user_data)
+ * @brief      This API gets list of installed packages using flag that used for masking package's information
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ * @param[in]  pkg_list_cb     iteration function for list
+ * @param[in]  flag    enum value of pkgmgrinfo_pkginfo_get_option used for masking package's information
+ * @param[in]  user_data       user data to be passed to callback function
+ * @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       None
+ * @see                pkgmgrinfo_pkginfo_get_option
+ * @code
+int pkg_list_cb(pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+       char *label1 = NULL;
+       char *label2 = NULL;
+       label1 = (char *)user_data;
+       pkgmgrinfo_pkginfo_get_label(handle, &label2);
+       if (strcmp(label1, label2) == 0)
+               return -1;
+       else
+               return 0;
+}
 
+static int list_pkgs()
+{
+       int ret = 0;
+       char *label = "helloworld";
+       ret = pkgmgrinfo_pkginfo_get_list_full(pkg_list_cb, PMINFO_PKGINFO_GET_LABEL, (void *)name);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       return 0;
+}
+ * @endcode
+ */
 int pkgmgrinfo_pkginfo_get_usr_list_full(pkgmgrinfo_pkg_list_cb pkg_list_cb,
                int flag, void *user_data, uid_t uid);
 int pkgmgrinfo_pkginfo_get_list_full(pkgmgrinfo_pkg_list_cb pkg_list_cb,
                int flag, void *user_data);
+
+/**
+ * @fn int pkgmgrinfo_appinfo_get_installed_list_full(pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
+ * @brief      This API gets list of installed applications from all packages using flag that used for masking application's information
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ * @param[in]  app_func        iteration function for list
+ * @param[in]  flag    enum value of pkgmgrinfo_appinfo_get_option used for masking application's information
+ * @param[in]  user_data       user data to be passed to callback function
+ * @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       None
+ * @see                pkgmgrinfo_appinfo_get_option
+ * @code
+int app_list_cb(pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+       int ret = 0;
+       char *label1 = NULL;
+       char *label2 = NULL;
+       label1 = (char *)user_data;
+       ret = pkgmgrinfo_appinfo_get_label(handle, &label2);
+       if (ret != PMINFO_R_OK) {
+               printf("pkgmgrinfo_appinfo_get_label fail");
+               return -1;
+       }
+       if (strcmp(label1, label2) == 0)
+               return -1;
+       else
+               return 0;
+}
+
+static int list_apps()
+{
+       int ret = 0;
+       char *label = "helloworld";
+       ret = pkgmgrinfo_appinfo_get_installed_list_full(app_list_cb, PMINFO_APPINFO_GET_LABEL, (void *)label);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       return 0;
+}
+ * @endcode
+ */
 int pkgmgrinfo_appinfo_get_usr_installed_list_full(
                pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
                void *user_data);
 int pkgmgrinfo_appinfo_get_installed_list_full(
                pkgmgrinfo_app_list_cb app_func, int flag, void *user_data);
 
-
+/**
+ * @fn int pkgmgrinfo_archiveinfo_get_archiveinfo(const char *path, pkgmgrinfo_archiveinfo_h *handle)
+ * @brief      This API creates the package archive information handle from given path
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in]  path    path of package archive
+ * @param[out] handle  pointer to the package archive 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_archiveinfo_destroy_archiveinfo()
+ * @code
+static int get_pkg_archive_type(const char *path)
+{
+       int ret = 0;
+       char *type = NULL;
+       pkgmgrinfo_archiveinfo_h handle;
+       ret = pkgmgrinfo_archiveinfo_get_archiveinfo(path, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_archiveinfo_get_type(handle, &type);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+               return -1;
+       }
+       printf("pkg archive type: %s\n", type);
+       pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
 int pkgmgrinfo_archiveinfo_get_archiveinfo(const char *path,
                pkgmgrinfo_archiveinfo_h *handle);
+
+/**
+ * @fn int pkgmgrinfo_archiveinfo_destroy_archiveinfo(pkgmgrinfo_archiveinfo_h handle)
+ * @brief      This API destroys the package archive 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 archive info handle
+ * @return     0 if success, error code(<0) if fail
+ * @retval     PMINFO_R_OK     success
+ * @retval     PMINFO_R_EINVAL invalid argument
+ * @pre                pkgmgrinfo_archiveinfo_get_archiveinfo()
+ * @post       None
+ * @code
+static int get_pkg_archive_type(const char *path)
+{
+       int ret = 0;
+       char *type = NULL;
+       pkgmgrinfo_archiveinfo_h handle;
+       ret = pkgmgrinfo_archiveinfo_get_archiveinfo(path, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_archiveinfo_get_type(handle, &type);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+               return -1;
+       }
+       printf("pkg archive type: %s\n", type);
+       pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
 int pkgmgrinfo_archiveinfo_destroy_archiveinfo(pkgmgrinfo_archiveinfo_h handle);
+
+/**
+ * @fn int pkgmgrinfo_archiveinfo_get_pkgid(pkgmgrinfo_archiveinfo_h handle, char **pkgid)
+ * @brief      This API gets the package id from the package archive info handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in]  handle  pointer to package archive info handle
+ * @param[out] pkgid   pointer to hold package id
+ * @return     0 if success, error code(<0) if fail
+ * @retval     PMINFO_R_OK     success
+ * @retval     PMINFO_R_EINVAL invalid argument
+ * @pre                pkgmgrinfo_archiveinfo_get_archiveinfo()
+ * @post       pkgmgrinfo_archiveinfo_destroy_archiveinfo()
+ * @code
+static int get_pkg_archive_id(const char *path)
+{
+       int ret = 0;
+       char *pkg_id = NULL;
+       pkgmgrinfo_archiveinfo_h handle;
+       ret = pkgmgrinfo_archiveinfo_get_archiveinfo(path, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_archiveinfo_get_pkgid(handle, &pkg_id);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+               return -1;
+       }
+       printf("pkg archive id: %s\n", pkg_id);
+       pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
 int pkgmgrinfo_archiveinfo_get_pkgid(pkgmgrinfo_archiveinfo_h handle,
                const char **pkgid);
+
+/**
+ * @fn int pkgmgrinfo_archiveinfo_get_type(pkgmgrinfo_archiveinfo_h handle, char **type)
+ * @brief      This API gets the package type from the package archive info handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in]  handle  pointer to package archive info handle
+ * @param[out] type    pointer to hold package type
+ * @return     0 if success, error code(<0) if fail
+ * @retval     PMINFO_R_OK     success
+ * @retval     PMINFO_R_EINVAL invalid argument
+ * @pre                pkgmgrinfo_archiveinfo_get_archiveinfo()
+ * @post       pkgmgrinfo_archiveinfo_destroy_archiveinfo()
+ * @code
+static int get_pkg_archive_type(const char *path)
+{
+       int ret = 0;
+       char *type = NULL;
+       pkgmgrinfo_archiveinfo_h handle;
+       ret = pkgmgrinfo_archiveinfo_get_archiveinfo(path, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_archiveinfo_get_type(handle, &type);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+               return -1;
+       }
+       printf("pkg archive type: %s\n", type);
+       pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
 int pkgmgrinfo_archiveinfo_get_type(pkgmgrinfo_archiveinfo_h handle,
                const char **type);
+
+/**
+ * @fn int pkgmgrinfo_archiveinfo_get_version(pkgmgrinfo_archiveinfo_h handle, char **version)
+ * @brief      This API gets the package version from the package archive info handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in]  handle  pointer to package archive info handle
+ * @param[out] version pointer to hold package version
+ * @return     0 if success, error code(<0) if fail
+ * @retval     PMINFO_R_OK     success
+ * @retval     PMINFO_R_EINVAL invalid argument
+ * @pre                pkgmgrinfo_archiveinfo_get_archiveinfo()
+ * @post       pkgmgrinfo_archiveinfo_destroy_archiveinfo()
+ * @code
+static int get_pkg_archive_version(const char *path)
+{
+       int ret = 0;
+       char *version = NULL;
+       pkgmgrinfo_archiveinfo_h handle;
+       ret = pkgmgrinfo_archiveinfo_get_archiveinfo(path, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_archiveinfo_get_version(handle, &version);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+               return -1;
+       }
+       printf("pkg archive version: %s\n", version);
+       pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
 int pkgmgrinfo_archiveinfo_get_version(pkgmgrinfo_archiveinfo_h handle,
                const char **version);
+
+/**
+ * @fn int pkgmgrinfo_archiveinfo_get_api_version(pkgmgrinfo_archiveinfo_h handle, char **api_version)
+ * @brief      This API gets the package api version from the package archive info handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in]  handle  pointer to package archive 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
+ * @pre                pkgmgrinfo_archiveinfo_get_archiveinfo()
+ * @post       pkgmgrinfo_archiveinfo_destroy_archiveinfo()
+ * @code
+static int get_pkg_archive_api_version(const char *path)
+{
+       int ret = 0;
+       char *api_version = NULL;
+       pkgmgrinfo_archiveinfo_h handle;
+       ret = pkgmgrinfo_archiveinfo_get_archiveinfo(path, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_archiveinfo_get_api_version(handle, &api_version);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+               return -1;
+       }
+       printf("pkg archive api_version: %s\n", api_version);
+       pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
 int pkgmgrinfo_archiveinfo_get_api_version(pkgmgrinfo_archiveinfo_h handle,
                const char **api_version);
+
+/**
+ * @fn int pkgmgrinfo_archiveinfo_get_description(pkgmgrinfo_archiveinfo_h handle, char **description)
+ * @brief      This API gets the package description from the package archive info handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in]  handle  pointer to package archive info handle
+ * @param[out] description     pointer to hold package description
+ * @return     0 if success, error code(<0) if fail
+ * @retval     PMINFO_R_OK     success
+ * @retval     PMINFO_R_EINVAL invalid argument
+ * @pre                pkgmgrinfo_archiveinfo_get_archiveinfo()
+ * @post       pkgmgrinfo_archiveinfo_destroy_archiveinfo()
+ * @code
+static int get_pkg_archive_description(const char *path)
+{
+       int ret = 0;
+       char *description = NULL;
+       pkgmgrinfo_archiveinfo_h handle;
+       ret = pkgmgrinfo_archiveinfo_get_archiveinfo(path, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_archiveinfo_get_description(handle, &description);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+               return -1;
+       }
+       printf("pkg archive description: %s\n", description);
+       pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
 int pkgmgrinfo_archiveinfo_get_description(pkgmgrinfo_archiveinfo_h handle,
                const char **description);
+
+/**
+ * @fn int pkgmgrinfo_archiveinfo_get_label(pkgmgrinfo_archiveinfo_h handle, char **label)
+ * @brief      This API gets the package label from the package archive info handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in]  handle  pointer to package archive info handle
+ * @param[out] label   pointer to hold package label
+ * @return     0 if success, error code(<0) if fail
+ * @retval     PMINFO_R_OK     success
+ * @retval     PMINFO_R_EINVAL invalid argument
+ * @pre                pkgmgrinfo_archiveinfo_get_archiveinfo()
+ * @post       pkgmgrinfo_archiveinfo_destroy_archiveinfo()
+ * @code
+static int get_pkg_archive_label(const char *path)
+{
+       int ret = 0;
+       char *label = NULL;
+       pkgmgrinfo_archiveinfo_h handle;
+       ret = pkgmgrinfo_archiveinfo_get_archiveinfo(path, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_archiveinfo_get_label(handle, &label);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+               return -1;
+       }
+       printf("pkg archive label: %s\n", label);
+       pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
 int pkgmgrinfo_archiveinfo_get_label(pkgmgrinfo_archiveinfo_h handle,
                const char **label);
+
+/**
+ * @fn int pkgmgrinfo_archiveinfo_get_author(pkgmgrinfo_archiveinfo_h handle, char **author)
+ * @brief      This API gets the package author from the package archive info handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in]  handle  pointer to package archive info handle
+ * @param[out] author  pointer to hold package author
+ * @return     0 if success, error code(<0) if fail
+ * @retval     PMINFO_R_OK     success
+ * @retval     PMINFO_R_EINVAL invalid argument
+ * @pre                pkgmgrinfo_archiveinfo_get_archiveinfo()
+ * @post       pkgmgrinfo_archiveinfo_destroy_archiveinfo()
+ * @code
+static int get_pkg_archive_author(const char *path)
+{
+       int ret = 0;
+       char *author = NULL;
+       pkgmgrinfo_archiveinfo_h handle;
+       ret = pkgmgrinfo_archiveinfo_get_archiveinfo(path, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_archiveinfo_get_author(handle, &author);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+               return -1;
+       }
+       printf("pkg archive author: %s\n", author);
+       pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
 int pkgmgrinfo_archiveinfo_get_author(pkgmgrinfo_archiveinfo_h handle,
                const char **author);
+
+/**
+ * @fn int pkgmgrinfo_archiveinfo_get_icon(pkgmgrinfo_archiveinfo_h handle, const unsigned char **icon, size_t *size)
+ * @brief      This API gets the package icon and size from the package archive info handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in]  handle  pointer to package archive info handle
+ * @param[out] icon    pointer to hold package icon
+ * @param[out] size    pointer to hold size of package icon
+ * @return     0 if success, error code(<0) if fail
+ * @retval     PMINFO_R_OK     success
+ * @retval     PMINFO_R_EINVAL invalid argument
+ * @retval     PMINFO_R_ENOENT no result
+ * @pre                pkgmgrinfo_archiveinfo_get_archiveinfo()
+ * @post       pkgmgrinfo_archiveinfo_destroy_archiveinfo()
+ * @code
+static int get_pkg_archive_icon(const char *path)
+{
+       int ret = 0;
+       unsigned char *icon = NULL;
+       size_t icon_size = 0;
+       pkgmgrinfo_archiveinfo_h handle;
+       ret = pkgmgrinfo_archiveinfo_get_archiveinfo(path, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_archiveinfo_get_icon(handle, &icon, &icon_size);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+               return -1;
+       }
+       printf("pkg archive icon size : %zu\n", icon_size);
+       pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
 int pkgmgrinfo_archiveinfo_get_icon(pkgmgrinfo_archiveinfo_h handle,
                const unsigned char **icon, size_t *size);
 
-int pkgmgrinfo_appinfo_foreach_component_info(pkgmgrinfo_appinfo_h handle,
-               pkgmgrinfo_component_info_list_cb callback, void *user_data);
-
-int pkgmgrinfo_compinfo_get_appid(pkgmgrinfo_compinfo_h handle,
-               const char **appid);
-int pkgmgrinfo_compinfo_get_compid(pkgmgrinfo_compinfo_h handle,
-               const char **compid);
-int pkgmgrinfo_compinfo_get_type(pkgmgrinfo_compinfo_h handle,
-               const char **type);
-int pkgmgrinfo_compinfo_get_launch_mode(pkgmgrinfo_compinfo_h handle,
-               const char **launch_mode);
+/**
+ * @fn int pkgmgrinfo_archiveinfo_foreach_dependency(pkgmgrinfo_archiveinfo_h handle, pkgmgrinfo_dependency_cb callback, void *user_data)
+ * @brief      This API retrieve the dependency information and invoke given callback for it.
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in]  handle  pointer to package archive info handle
+ * @param[in]  callback        callback to be invoked for each retrieved dependency information
+ * @param[in]  user_data       user data to be passed to callback
+ * @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_archiveinfo_get_archiveinfo()
+ * @post       pkgmgrinfo_archiveinfo_destroy_archiveinfo()
+ * @code
+static int get_pkg_archive_dependency(const char *path, pkgmgrinfo_pkg_dependency_list_cb callback)
+{
+       int ret = 0;
+       size_t icon_size = 0;
+       pkgmgrinfo_archiveinfo_h handle;
+       ret = pkgmgrinfo_archiveinfo_get_archiveinfo(path, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_archiveinfo_foreach_dependency(handle, callback, NULL);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+               return -1;
+       }
+       pkgmgrinfo_archiveinfo_destroy_archiveinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_archiveinfo_foreach_dependency(pkgmgrinfo_archiveinfo_h handle,
+               pkgmgrinfo_pkg_dependency_list_cb callback, void *user_data);
 
 /**
  * @pkgmgrinfo client API end