X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=include%2Fpkgmgr-info.h;h=9a856d6dc0eece1e6ab47b23cdd5ad3028ed81d8;hb=524110d20b9d1ab771f3c25e43a949e3c086ba17;hp=9be500857858ae960c09f4c232ccc9ea56cf16b9;hpb=7f5e5d8b5c4dcbd1ee5bc27f47e78b585d125dfe;p=platform%2Fcore%2Fappfw%2Fpkgmgr-info.git diff --git a/include/pkgmgr-info.h b/include/pkgmgr-info.h index 9be5008..9a856d6 100644 --- a/include/pkgmgr-info.h +++ b/include/pkgmgr-info.h @@ -92,6 +92,8 @@ extern "C" { #define PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF "PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF" /** String property for filtering based on package info*/ #define PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE "PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE" + /** String property for filtering based on package info*/ +#define PMINFO_PKGINFO_PROP_PACKAGE_RES_TYPE "PMINFO_PKGINFO_PROP_PACKAGE_RES_TYPE" /** Boolean property for filtering based on package info*/ #define PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE "PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE" @@ -1354,6 +1356,71 @@ int pkgmgrinfo_updateinfo_foreach_updateinfo(pkgmgrinfo_foreach_updateinfo_cb ca int pkgmgrinfo_updateinfo_usr_foreach_updateinfo(uid_t uid, pkgmgrinfo_foreach_updateinfo_cb callback, void *user_data); /** + * @fn int pkgmgrinfo_plugininfo_is_executed(const char *pkgid, const char *appid, const char *plugin_type, const char *plugin_name, bool *is_executed); + * @brief This API checkes whether given plugin had been executed with given package ID and application ID or not. + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * + * @param[in] pkgid package ID + * @param[in] appid application ID + * @param[in] plugin_type plugin type to be checked + * @param[in] plugin_name plugin name to be checked + * @param[out] is_executed check result + * @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 bool check_execute_info(const char *pkgid, const char *appid, const char *plugin_type, const char *plugin_name) +{ + int ret = 0; + bool is_executed; + + ret = pkgmgrinfo_plugininfo_is_executed(pkgid, appid, plugin_type, plugin_name, &is_executed); + if (ret != PMINFO_R_OK) + return -1; + printf("is checked is [%d]\n", is_executed); + return 0; +} + * @endcode + */ +int pkgmgrinfo_plugininfo_is_executed(const char *pkgid, const char *appid, + const char *plugin_type, const char *plugin_name, bool *is_executed); + +/** + * @fn int pkgmgrinfo_plugininfo_foreach_plugininfo(const char *pkgid, const char *plugin_type, const char *plugin_name, pkgmgrinfo_plugin_list_cb plugin_list_cb, void *user_data); + * @brief This API retrieve the previous plugin execution info and invoke callbacks each of it. + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * + * @param[in] pkgid package ID + * @param[in] plugin_type type of plugin + * @param[in] plugin_name name of plugin + * @param[in] plugin_list_cb callback to be invoked for each plugin execution info + * @param[out] 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 + * @code +static int foreach_pkg_plugininfo(const char *pkgid, const char *plugin_type, const char *plugin_name, pkgmgrinfo_plugin_list_cb callback) +{ + int ret = 0; + + ret = pkgmgrinfo_plugininfo_foreach_plugininfo(pkgid, plugin_type, plugin_name, callback, NULL); + if (ret != PMINFO_R_OK) + return -1; + return 0; +} + * @endcode + */ +int pkgmgrinfo_plugininfo_foreach_plugininfo(const char *pkgid, + const char *plugin_type, const char *plugin_name, + pkgmgrinfo_plugin_list_cb plugin_list_cb, void *user_data); + +/** * @fn int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode) * @brief This API gets the launch mode of package from the package ID * @@ -1583,6 +1650,114 @@ static int get_csc_path(const char *pkgid) int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path); /** + * @fn int pkgmgrinfo_pkginfo_get_res_type(pkgmgrinfo_pkginfo_h handle, char **res_type) + * @brief This API gets the resource type of package + * + * @par Sync (or) Async : Synchronous API + * + * @param[in] handle pointer to package info handle + * @param[out] res_type pointer to hold resource type of package + * @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 get_res_type(const char *pkgid) +{ + int ret = 0; + char *res_type = 0; + pkgmgrinfo_pkginfo_h handle; + ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle); + if (ret != PMINFO_R_OK) + return -1; + + ret = pkgmgrinfo_pkginfo_get_res_type(handle, &res_type); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return -1; + } + printf("res_type : %s\n", res_type); + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + + return 0; +} + * @endcode + */ +int pkgmgrinfo_pkginfo_get_res_type(pkgmgrinfo_pkginfo_h handle, char **res_type); + +/** + * @fn int pkgmgrinfo_pkginfo_get_res_version(pkgmgrinfo_pkginfo_h handle, char **res_version) + * @brief This API gets the resource version of package + * + * @par Sync (or) Async : Synchronous API + * + * @param[in] handle pointer to package info handle + * @param[out] res_version pointer to hold resource version of package + * @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 get_res_version(const char *pkgid) +{ + int ret = 0; + char *res_version = 0; + pkgmgrinfo_pkginfo_h handle; + ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle); + if (ret != PMINFO_R_OK) + return -1; + + ret = pkgmgrinfo_pkginfo_get_res_version(handle, &res_version); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return -1; + } + printf("res_version : %s\n", res_version); + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + + return 0; +} + * @endcode + */ +int pkgmgrinfo_pkginfo_get_res_version(pkgmgrinfo_pkginfo_h handle, char **res_version); + +/** + * @fn int pkgmgrinfo_pkginfo_get_light_user_switch_mode(pkgmgrinfo_pkginfo_h handle, char **mode) + * @brief This API gets the light_user_switch_mode of package + * + * @par Sync (or) Async : Synchronous API + * + * @param[in] handle pointer to package info handle + * @param[out] mode pointer to hold resource version of package + * @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 get_light_user_switch_mode(const char *pkgid) +{ + int ret = 0; + char *mode = 0; + pkgmgrinfo_pkginfo_h handle; + ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle); + if (ret != PMINFO_R_OK) + return -1; + + ret = pkgmgrinfo_pkginfo_get_light_user_switch_mode(handle, &mode); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return -1; + } + printf("light_user_switch_mode : %s\n", mode); + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + + return 0; +} + * @endcode + */ +int pkgmgrinfo_pkginfo_get_light_user_switch_mode(pkgmgrinfo_pkginfo_h handle, char **mode); + +/** * @fn int pkgmgrinfo_pkginfo_get_support_mode(pkgmgrinfo_pkginfo_h handle, int *support_mode) * @brief This API gets the support_mode of package * @@ -1885,7 +2060,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 @@ -1961,7 +2136,7 @@ int pkgmgrinfo_pkginfo_is_support_disable(pkgmgrinfo_pkginfo_h handle, bool *sup /** * @fn int pkgmgrinfo_pkginfo_is_global(pkgmgrinfo_pkginfo_h handle, bool *global) - * @brief This API gets whethere the given package is global package or user package + * @brief This API gets whether the given package is global package or user package * * @par This API is for package-manager client application * @par Sync (or) Async : Synchronous API @@ -2487,55 +2662,61 @@ static int list_appdefined_privilege(const char *package) int pkgmgrinfo_pkginfo_foreach_appdefined_privilege(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_pkg_appdefined_privilege_list_cb privilege_func, void *user_data); -/* TODO: add doxygen comment here */ -int pkgmgrinfo_pkginfo_is_for_all_users(pkgmgrinfo_pkginfo_h handle, bool *for_all_users); - /** - * @fn int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_pkginfo_h *clone) - * @brief This API copy the application information handle + * @fn int pkgmgrinfo_pkginfo_foreach_plugin(pkgmgrinfo_pkginfo_h handle, + pkgmgrinfo_plugin_list_cb plugin_func, void *user_data); + * @brief This API gets the list of plugin execution info for a particular package * * @par This API is for package-manager client application * @par Sync (or) Async : Synchronous API - * - * @param[in] handle pointer to the package info handle. - * @param[out] handle pointer to the package info handle. + * @param[in] handle pointer to the package info handle. + * @param[in] plugin_func callback function for list + * @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 pkgmgrinfo_appinfo_destroy_appinfo() + * @pre pkgmgrinfo_pkginfo_get_pkginfo() + * @post pkgmgrinfo_pkginfo_destroy_pkginfo() * @code -static int get_appinfo_clone(pkgmgrinfo_pkginfo_h handle) +int plugin_func(const char *pkgid, const char *appid, + const char *plugin_type, const char *plugin_name, + void *user_data) { - int ret = 0; + printf("appid : %s, type : %s, name : %s\n", appid, plugin_type, plugin_name); - pkgmgrinfo_pkginfo_h clone; + return 0; +} - ret = pkgmgrinfo_appinfo_clone_appinfo(handle, &clone); +static int list_plugin(const char *package) +{ + int ret = 0; + pkgmgrinfo_pkginfo_h handle; + ret = pkgmgrinfo_pkginfo_get_pkginfo(package, &handle); if (ret != PMINFO_R_OK) return -1; - - - printf("package: %s\n", clone->package); - pkgmgrinfo_appinfo_destroy_appinfo(clone); + ret = pkgmgrinfo_pkginfo_foreach_plugin(handle, plugin_func, NULL); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return -1; + } + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); return 0; } * @endcode */ -int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_pkginfo_h *clone); - +int pkgmgrinfo_pkginfo_foreach_plugin(pkgmgrinfo_pkginfo_h handle, + pkgmgrinfo_plugin_list_cb plugin_func, void *user_data); /** - * @fn int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component, - pkgmgrinfo_app_list_cb app_func, void *user_data) - * @brief This API gets list of installed applications for a particular package + * @fn int pkgmgrinfo_pkginfo_foreach_metadata(pkgmgrinfo_pkginfo_h handle, + pkgmgrinfo_pkg_metadata_list_cb metadata_func, void *user_data); + * @brief This API gets the list of metadata for a particular package * * @par This API is for package-manager client application * @par Sync (or) Async : Synchronous API - * @param[in] handle package info handle - * @param[in] component application component - * @param[in] app_func iteration function for list + * @param[in] handle pointer to the package info handle. + * @param[in] metadata_func callback function for list * @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 @@ -2544,22 +2725,24 @@ int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_pkg * @pre pkgmgrinfo_pkginfo_get_pkginfo() * @post pkgmgrinfo_pkginfo_destroy_pkginfo() * @code -int app_func(pkgmgrinfo_appinfo_h handle, void *user_data) +int metadata_func(const char *key, const char *value, void *user_data) { - char *appid = NULL; - pkgmgrinfo_appinfo_get_appid(handle, &appid); - printf("appid : %s\n", appid); - return 0; + if (strcmp(key, (char *)user_data) == 0) { + printf("Value is %s\n", value); + return -1; + } + else + return 0; } -static int list_apps(const char *pkgid) +static int list_metadata(const char *pkgid, char *key) { int ret = 0; pkgmgrinfo_pkginfo_h handle; ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle); if (ret != PMINFO_R_OK) return -1; - ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, app_func, NULL); + ret = pkgmgrinfo_pkginfo_foreach_metadata(handle, metadata_func, (void *)key); if (ret != PMINFO_R_OK) { pkgmgrinfo_pkginfo_destroy_pkginfo(handle); return -1; @@ -2569,121 +2752,367 @@ static int list_apps(const char *pkgid) } * @endcode */ -int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component, - pkgmgrinfo_app_list_cb app_func, void *user_data); -int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component, - pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid); +int pkgmgrinfo_pkginfo_foreach_metadata(pkgmgrinfo_pkginfo_h handle, + pkgmgrinfo_pkg_metadata_list_cb metadata_func, void *user_data); /** - * @fn int pkgmgrinfo_appinfo_get_applist_for_amd(pkgmgrinfo_app_list_cb app_func, void *user_data); - * @brief This API gets list of installed applications from all packages with minimum informaion. + * @fn int pkgmgrinfo_pkginfo_metadata_filter_create(pkgmgrinfo_pkginfo_metadata_filter_h *handle) + * @brief This API creates the application's metadata information filter handle from db. * * @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] user_data user data to be passed to callback function + * + * @param[out] handle pointer to the package metadata info filter 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 None + * @post pkgmgrinfo_pkginfo_metadata_filter_destroy() + * @see pkgmgrinfo_pkginfo_metadata_filter_foreach() * @code -int app_list_cb(pkgmgrinfo_appinfo_h handle, void *user_data) +int pkg_list_cb(pkgmgrinfo_pkginfo_h handle, void *user_data) { - char *pkgid1 = NULL; - char *pkgid2 = NULL; - pkgid1 = (char *)user_data; - pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid2); - if (strcmp(pkgid1, pkgid2) == 0) { - return -1; - } else { - return 0; - } + char *pkgid = NULL; + pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid); + printf("pkgid : %s\n", pkgid); + return 0; } -static int list_apps() +static int get_pkg_list(const char *mkey, const char *mvalue) { int ret = 0; - char *name = "helloworld"; - ret = pkgmgrinfo_appinfo_get_applist_for_amd(app_list_cb, (void *)name); + pkgmgrinfo_pkginfo_metadata_filter_h handle; + ret = pkgmgrinfo_pkginfo_metadata_filter_create(&handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_pkginfo_metadata_filter_add(handle, mkey, mvalue); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_metadata_filter_destroy(handle); + return -1; + } + ret = pkgmgrinfo_pkginfo_metadata_filter_foreach(handle, pkg_list_cb, NULL); if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_metadata_filter_destroy(handle); return -1; } + pkgmgrinfo_pkginfo_metadata_filter_destroy(handle); return 0; } * @endcode */ -int pkgmgrinfo_appinfo_get_usr_applist_for_amd(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data); -int pkgmgrinfo_appinfo_get_applist_for_amd(pkgmgrinfo_app_list_cb app_func, void *user_data); +int pkgmgrinfo_pkginfo_metadata_filter_create(pkgmgrinfo_pkginfo_metadata_filter_h *handle); /** - * @fn int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data); - * @brief This API gets list of installed applications from all packages. + * @fn int pkgmgrinfo_pkginfo_metadata_filter_destroy(pkgmgrinfo_pkginfo_metadata_filter_h handle) + * @brief This API destroys the package's metadata information filter handle. * * @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] user_data user data to be passed to callback function + * + * @param[in] handle pointer to the package metadata info filter 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 + * @pre pkgmgrinfo_pkginfo_metadata_filter_create() * @post None + * @see pkgmgrinfo_pkginfo_metadata_filter_foreach() * @code -int app_list_cb(pkgmgrinfo_appinfo_h handle, void *user_data) +int pkg_list_cb(pkgmgrinfo_pkginfo_h handle, void *user_data) { - char *pkgid1 = NULL; - char *pkgid2 = NULL; - pkgid1 = (char *)user_data; - pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid2); - if (strcmp(pkgid1, pkgid2) == 0) { - return -1; - } else { - return 0; - } + char *pkgid = NULL; + pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid); + printf("pkgid : %s\n", pkgid); + return 0; } -static int list_apps() +static int get_pkg_list(const char *mkey, const char *mvalue) { int ret = 0; - char *name = "helloworld"; - ret = pkgmgrinfo_appinfo_get_installed_list(app_list_cb, (void *)name); + pkgmgrinfo_pkginfo_metadata_filter_h handle; + ret = pkgmgrinfo_pkginfo_metadata_filter_create(&handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_pkginfo_metadata_filter_add(handle, mkey, mvalue); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_metadata_filter_destroy(handle); + return -1; + } + ret = pkgmgrinfo_pkginfo_metadata_filter_foreach(handle, pkg_list_cb, NULL); if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_metadata_filter_destroy(handle); return -1; } + pkgmgrinfo_pkginfo_metadata_filter_destroy(handle); return 0; } * @endcode */ -int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data); -int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data); +int pkgmgrinfo_pkginfo_metadata_filter_destroy(pkgmgrinfo_pkginfo_metadata_filter_h handle); /** - * @fn int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle) - * @brief This API creates the disabled application information handle from db + * @fn int pkgmgrinfo_pkginfo_metadata_filter_add(pkgmgrinfo_pkginfo_metadata_filter_h handle, const char *key, const char *value) + * @brief This API adds filter condition for the query API. The query will search the entire package metadata information collected from + * the manifest file of all the installed packages. You can specify value as NULL to search based on key only. * * @par This API is for package-manager client application * @par Sync (or) Async : Synchronous API * - * @param[in] appid pointer to appid - * @param[out] handle pointer to the application info handle. + * @param[in] handle pointer to the package metadata info filter handle. + * @param[in] key pointer to metadata key + * @param[in] value pointer to metadata 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 None - * @post pkgmgrinfo_appinfo_destroy_appinfo() - * @see pkgmgrinfo_appinfo_get_pkgid() - * @see pkgmgrinfo_appinfo_is_multiple() + * @pre pkgmgrinfo_pkginfo_metadata_filter_create() + * @post pkgmgrinfo_pkginfo_metadata_filter_foreach(), pkgmgrinfo_pkginfo_metadata_filter_destroy() + * @see pkgmgrinfo_pkginfo_metadata_filter_foreach() * @code -static int get_disabled_app_type(const char *appid) +int pkg_list_cb(pkgmgrinfo_pkginfo_h handle, void *user_data) { - int ret = 0; - char *type = NULL; - pkgmgrinfo_appinfo_h handle; - ret = pkgmgrinfo_appinfo_get_disabled_appinfo(appid, &handle); + char *pkgid = NULL; + pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid); + printf("pkgid : %s\n", pkgid); + return 0; +} + +static int get_pkg_list(const char *mkey, const char *mvalue) +{ + int ret = 0; + pkgmgrinfo_pkginfo_metadata_filter_h handle; + ret = pkgmgrinfo_pkginfo_metadata_filter_create(&handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_pkginfo_metadata_filter_add(handle, mkey, mvalue); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_metadata_filter_destroy(handle); + return -1; + } + ret = pkgmgrinfo_pkginfo_metadata_filter_foreach(handle, pkg_list_cb, NULL); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_metadata_filter_destroy(handle); + return -1; + } + pkgmgrinfo_pkginfo_metadata_filter_destroy(handle); + return 0; +} + * @endcode + */ +int pkgmgrinfo_pkginfo_metadata_filter_add(pkgmgrinfo_pkginfo_metadata_filter_h handle, + const char *key, const char *value); + +/** + * @fn int pkgmgrinfo_pkginfo_metadata_filter_foreach(pkgmgrinfo_pkginfo_metadata_filter_h handle, pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data) + * @fn int pkgmgrinfo_pkginfo_usr_metadata_filter_foreach(pkgmgrinfo_pkginfo_metadata_filter_h handle, pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data, uid_t uid) + * @brief This API executes the filter query. The query will search the entire package metadata information collected from + * the manifest file of all the installed packages. For each package returned by the query, the callback will be called. If callback returns + * negative value, no more callbacks will be called and API will return. + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * + * @param[in] handle pointer to the package metadata info filter handle. + * @param[in] app_cb function pointer to callback + * @param[in] user_data pointer to user data + * @param[in] uid the addressee user id of the instruction + * @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_metadata_filter_create() + * @post pkgmgrinfo_pkginfo_metadata_filter_destroy() + * @code +int pkg_list_cb(pkgmgrinfo_pkginfo_h handle, void *user_data) +{ + char *pkgid = NULL; + pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid); + printf("pkgid : %s\n", pkgid); + return 0; +} + +static int get_pkg_list(const char *mkey, const char *mvalue) +{ + int ret = 0; + pkgmgrinfo_pkginfo_metadata_filter_h handle; + ret = pkgmgrinfo_pkginfo_metadata_filter_create(&handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_pkginfo_metadata_filter_add(handle, mkey, mvalue); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_metadata_filter_destroy(handle); + return -1; + } + ret = pkgmgrinfo_pkginfo_metadata_filter_foreach(handle, pkg_list_cb, NULL); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_metadata_filter_destroy(handle); + return -1; + } + pkgmgrinfo_pkginfo_metadata_filter_destroy(handle); + return 0; +} + * @endcode + */ +int pkgmgrinfo_pkginfo_metadata_filter_foreach(pkgmgrinfo_pkginfo_metadata_filter_h handle, + pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data); +int pkgmgrinfo_pkginfo_usr_metadata_filter_foreach(pkgmgrinfo_pkginfo_metadata_filter_h handle, + pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data, uid_t uid); + +/* TODO: add doxygen comment here */ +int pkgmgrinfo_pkginfo_is_for_all_users(pkgmgrinfo_pkginfo_h handle, bool *for_all_users); + +/** + * @fn int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_pkginfo_h *clone) + * @brief This API copy the application information handle + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * + * @param[in] handle pointer to the package info handle. + * @param[out] handle pointer to the package 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_appinfo_destroy_appinfo() + * @code +static int get_appinfo_clone(pkgmgrinfo_pkginfo_h handle) +{ + int ret = 0; + + pkgmgrinfo_pkginfo_h clone; + + ret = pkgmgrinfo_appinfo_clone_appinfo(handle, &clone); + if (ret != PMINFO_R_OK) + return -1; + + + printf("package: %s\n", clone->package); + pkgmgrinfo_appinfo_destroy_appinfo(clone); + return 0; +} + * @endcode + */ +int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_pkginfo_h *clone); + + +/** + * @fn int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component, + pkgmgrinfo_app_list_cb app_func, void *user_data) + * @brief This API gets list of installed applications for a particular package + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * @param[in] handle package info handle + * @param[in] component application component + * @param[in] app_func iteration function for list + * @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 pkgmgrinfo_pkginfo_get_pkginfo() + * @post pkgmgrinfo_pkginfo_destroy_pkginfo() + * @code +int app_func(pkgmgrinfo_appinfo_h handle, void *user_data) +{ + char *appid = NULL; + pkgmgrinfo_appinfo_get_appid(handle, &appid); + printf("appid : %s\n", appid); + return 0; +} + +static int list_apps(const char *pkgid) +{ + int ret = 0; + pkgmgrinfo_pkginfo_h handle; + ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, app_func, NULL); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return -1; + } + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return 0; +} + * @endcode + */ +int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component, + pkgmgrinfo_app_list_cb app_func, void *user_data); +int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component, + pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid); + +/** + * @fn int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data); + * @brief This API gets list of installed applications from all packages. + * + * @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] 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 + * @code +int app_list_cb(pkgmgrinfo_appinfo_h handle, void *user_data) +{ + char *pkgid1 = NULL; + char *pkgid2 = NULL; + pkgid1 = (char *)user_data; + pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid2); + if (strcmp(pkgid1, pkgid2) == 0) { + return -1; + } else { + return 0; + } +} + +static int list_apps() +{ + int ret = 0; + char *name = "helloworld"; + ret = pkgmgrinfo_appinfo_get_installed_list(app_list_cb, (void *)name); + if (ret != PMINFO_R_OK) { + return -1; + } + return 0; +} + * @endcode + */ +int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data); +int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data); + +/** + * @fn int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle) + * @brief This API creates the disabled application information handle from db + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * + * @param[in] appid pointer to appid + * @param[out] handle pointer to the application 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_appinfo_destroy_appinfo() + * @see pkgmgrinfo_appinfo_get_pkgid() + * @see pkgmgrinfo_appinfo_is_multiple() + * @code +static int get_disabled_app_type(const char *appid) +{ + int ret = 0; + char *type = NULL; + pkgmgrinfo_appinfo_h handle; + ret = pkgmgrinfo_appinfo_get_disabled_appinfo(appid, &handle); if (ret != PMINFO_R_OK) return -1; ret = pkgmgrinfo_appinfo_get_apptype(handle, &type); @@ -3204,317 +3633,101 @@ static int get_app_type(const char *appid) int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type); /** - * @fn int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle, - int *operation_count, char ***operation) - * @brief This API gets the list of operation of the application + * @fn int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon) + * @brief This API gets the notification icon of the application * * @par This API is for package-manager client application * @par Sync (or) Async : Synchronous API * - * @param[in] handle pointer to the appcontrol handle. - * @param[out] operation_count pointer to hold number of operations - * @param[out] operation pointer to hold list of operations + * @param[in] handle pointer to the application info handle. + * @param[out] path pointer to hold notification icon * @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_appinfo_get_appinfo() * @post pkgmgrinfo_appinfo_destroy_appinfo() - * @see pkgmgrinfo_appinfo_get_uri() - * @see pkgmgrinfo_appinfo_get_mime() + * @see pkgmgrinfo_appinfo_get_appid() + * @see pkgmgrinfo_appinfo_is_multiple() * @code -int appcontrol_func(pkgmgrinfo_appcontrol_h handle, void *user_data) -{ - int oc = 0; - int i = 0; - char **operation; - pkgmgrinfo_appinfo_get_operation(handle, &oc, &operation); - for (i = 0; i < oc; i++) { - if (strcmp(operation[i], (char *)user_data) == 0) - return -1; - else - return 0; - } -} - -static int check_operation(const char *appid, char *operation) +static int get_app_notification_icon(const char *appid) { int ret = 0; + char *notification_icon = NULL; pkgmgrinfo_appinfo_h handle; ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); if (ret != PMINFO_R_OK) return -1; - ret = pkgmgrinfo_appinfo_foreach_appcontrol(handle, appcontrol_func, (void *)operation); + ret = pkgmgrinfo_appinfo_get_notification_icon(handle, ¬ification_icon); if (ret != PMINFO_R_OK) { pkgmgrinfo_appinfo_destroy_appinfo(handle); return -1; } + printf("notification icon : %s\n", notification_icon); pkgmgrinfo_appinfo_destroy_appinfo(handle); return 0; } * @endcode */ -int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle, - int *operation_count, char ***operation); +int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon); /** - * @fn int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle, - int *uri_count, char ***uri) - * @brief This API gets the list of uri of the application + * @fn int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type) + * @brief This API gets the type of recent image on app-tray * * @par This API is for package-manager client application * @par Sync (or) Async : Synchronous API * - * @param[in] handle pointer to the appcontrol handle. - * @param[out] uri_count pointer to hold number of uris - * @param[out] uri pointer to hold list of uris + * @param[in] handle pointer to the application info handle. + * @param[out] type pointer to hold image 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_appinfo_get_appinfo() * @post pkgmgrinfo_appinfo_destroy_appinfo() - * @see pkgmgrinfo_appinfo_get_operation() - * @see pkgmgrinfo_appinfo_get_mime() + * @see pkgmgrinfo_appinfo_get_appid() + * @see pkgmgrinfo_appinfo_is_multiple() * @code -int appcontrol_func(pkgmgrinfo_appcontrol_h handle, void *user_data) -{ - int uc = 0; - int i = 0; - char **uri; - pkgmgrinfo_appinfo_get_uri(handle, &uc, &uri); - for (i = 0; i < uc; i++) { - if (strcmp(uri[i], (char *)user_data) == 0) - return -1; - else - return 0; - } -} - -static int check_uri(const char *appid, char *uri) +static int get_app_recent_image_type(const char *appid) { int ret = 0; + pkgmgrinfo_app_recentimage type; pkgmgrinfo_appinfo_h handle; ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); if (ret != PMINFO_R_OK) return -1; - ret = pkgmgrinfo_appinfo_foreach_appcontrol(handle, appcontrol_func, (void *)uri); + ret = pkgmgrinfo_appinfo_get_recent_image_type(handle, &type); if (ret != PMINFO_R_OK) { pkgmgrinfo_appinfo_destroy_appinfo(handle); return -1; } + printf("recent image type: %d\n", type); pkgmgrinfo_appinfo_destroy_appinfo(handle); return 0; } * @endcode */ -int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle, - int *uri_count, char ***uri); +int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type); + /** - * @fn int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle, - int *mime_count, char ***mime) - * @brief This API gets the list of mime of the application + * @fn int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img) + * @brief This API gets the preview image of application * - * @par This API is for package-manager client application * @par Sync (or) Async : Synchronous API * - * @param[in] handle pointer to the appcontrol handle. - * @param[out] mime_count pointer to hold number of mimes - * @param[out] mime pointer to hold list of mimes + * @param[in] handle pointer to the application info handle. + * @param[out] preview_img pointer to hold preview 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 * @pre pkgmgrinfo_appinfo_get_appinfo() * @post pkgmgrinfo_appinfo_destroy_appinfo() - * @see pkgmgrinfo_appinfo_get_uri() - * @see pkgmgrinfo_appinfo_get_operation() + * @see pkgmgrinfo_appinfo_get_appid() * @code -int appcontrol_func(pkgmgrinfo_appcontrol_h handle, void *user_data) -{ - int mc = 0; - int i = 0; - char **mime; - pkgmgrinfo_appinfo_get_operation(handle, &mc, &mime); - for (i = 0; i < mc; i++) { - if (strcmp(mime[i], (char *)user_data) == 0) - return -1; - else - return 0; - } -} - -static int check_mime(const char *appid, char *mime) -{ - int ret = 0; - pkgmgrinfo_appinfo_h handle; - ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); - if (ret != PMINFO_R_OK) - return -1; - ret = pkgmgrinfo_appinfo_foreach_appcontrol(handle, appcontrol_func, (void *)mime); - if (ret != PMINFO_R_OK) { - pkgmgrinfo_appinfo_destroy_appinfo(handle); - return -1; - } - pkgmgrinfo_appinfo_destroy_appinfo(handle); - return 0; -} - * @endcode - */ -int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle, - int *mime_count, char ***mime); - -/** - * @fn int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle, - int *subapp_count, char ***subapp) - * @brief This API gets the list of subapp of the application - * - * @par This API is for package-manager client application - * @par Sync (or) Async : Synchronous API - * - * @param[in] handle pointer to the appcontrol handle. - * @param[out] subapp_count pointer to hold number of subapp - * @param[out] subapp pointer to hold list of subapp - * @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_appinfo_get_appinfo() - * @post pkgmgrinfo_appinfo_destroy_appinfo() - * @see pkgmgrinfo_appinfo_get_uri() - * @see pkgmgrinfo_appinfo_get_operation() - * @code -int appcontrol_func(pkgmgrinfo_appcontrol_h handle, void *user_data) -{ - int sc = 0; - int i = 0; - char **subapp = NULL; - pkgmgrinfo_appinfo_get_subapp(handle, &sc, &subapp); - for (i = 0; i < sc; i++) { - if (strcmp(subapp[i], (char *)user_data) == 0) - return -1; - else - return 0; - } -} - -static int check_subapp(const char *appid, char *subapp) -{ - int ret = 0; - pkgmgrinfo_appinfo_h handle = NULL; - ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); - if (ret != PMINFO_R_OK) - return -1; - ret = pkgmgrinfo_appinfo_foreach_appcontrol(handle, appcontrol_func, (void *)subapp); - if (ret != PMINFO_R_OK) { - pkgmgrinfo_appinfo_destroy_appinfo(handle); - return -1; - } - pkgmgrinfo_appinfo_destroy_appinfo(handle); - return 0; -} - * @endcode - */ -int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle, - int *subapp_count, char ***subapp); - -/** - * @fn int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon) - * @brief This API gets the notification icon of the application - * - * @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[out] path pointer to hold notification icon - * @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_appinfo_get_appinfo() - * @post pkgmgrinfo_appinfo_destroy_appinfo() - * @see pkgmgrinfo_appinfo_get_appid() - * @see pkgmgrinfo_appinfo_is_multiple() - * @code -static int get_app_notification_icon(const char *appid) -{ - int ret = 0; - char *notification_icon = NULL; - pkgmgrinfo_appinfo_h handle; - ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); - if (ret != PMINFO_R_OK) - return -1; - ret = pkgmgrinfo_appinfo_get_notification_icon(handle, ¬ification_icon); - if (ret != PMINFO_R_OK) { - pkgmgrinfo_appinfo_destroy_appinfo(handle); - return -1; - } - printf("notification icon : %s\n", notification_icon); - pkgmgrinfo_appinfo_destroy_appinfo(handle); - return 0; -} - * @endcode - */ -int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon); - -/** - * @fn int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type) - * @brief This API gets the type of recent image on app-tray - * - * @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[out] type pointer to hold image 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_appinfo_get_appinfo() - * @post pkgmgrinfo_appinfo_destroy_appinfo() - * @see pkgmgrinfo_appinfo_get_appid() - * @see pkgmgrinfo_appinfo_is_multiple() - * @code -static int get_app_recent_image_type(const char *appid) -{ - int ret = 0; - pkgmgrinfo_app_recentimage type; - pkgmgrinfo_appinfo_h handle; - ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); - if (ret != PMINFO_R_OK) - return -1; - ret = pkgmgrinfo_appinfo_get_recent_image_type(handle, &type); - if (ret != PMINFO_R_OK) { - pkgmgrinfo_appinfo_destroy_appinfo(handle); - return -1; - } - printf("recent image type: %d\n", type); - pkgmgrinfo_appinfo_destroy_appinfo(handle); - return 0; -} - * @endcode - */ -int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type); - - -/** - * @fn int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img) - * @brief This API gets the preview image of application - * - * @par Sync (or) Async : Synchronous API - * - * @param[in] handle pointer to the application info handle. - * @param[out] preview_img pointer to hold preview 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 - * @pre pkgmgrinfo_appinfo_get_appinfo() - * @post pkgmgrinfo_appinfo_destroy_appinfo() - * @see pkgmgrinfo_appinfo_get_appid() - * @code -static int get_app_previewimage(const char *appid) +static int get_app_previewimage(const char *appid) { int ret = 0; char *preview = NULL; @@ -4337,18 +4550,15 @@ int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid, * @pre pkgmgrinfo_appinfo_get_appinfo() * @post pkgmgrinfo_appinfo_destroy_appinfo() * @code -int appcontrol_func(pkgmgrinfo_appcontrol_h handle, void *user_data) +int appcontrol_func(const char *operation, const char *uri, const char *mime, void *user_data) { - int oc = 0; int i = 0; char **operation; - pkgmgrinfo_appinfo_get_operation(handle, &oc, &operation); - for (i = 0; i < oc; i++) { - if (strcmp(operation[i], (char *)user_data) == 0) - return -1; - else - return 0; - } + char *compare_data = (char *)user_data; + if (strcmp(operation, compare_data) == 0) + return -1; + else + return 0; } static int check_operation(const char *appid, char *operation) @@ -4402,6 +4612,52 @@ int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_splash_screen_list_cb splash_screen_func, void *user_data); /** + * @fn int pkgmgrinfo_appinfo_foreach_res_control(pkgmgrinfo_appinfo_h handle, + pkgmgrinfo_app_res_control_list_cb res_control_func, void *user_data); + * @brief This API gets the list of resource control for a particular application + * + * @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] res_control_func callback function for list + * @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 pkgmgrinfo_appinfo_get_appinfo() + * @post pkgmgrinfo_appinfo_destroy_appinfo() + * @code +int res_control_func(const char *res_type, + const char *min_res_version, const char *max_res_version, + const char *auto_close, void *user_data) +{ + printf("res_type : %s\n", res_type); + return 0; +} + +static int list_res_control(const char *appid, char *key) +{ + int ret = 0; + pkgmgrinfo_appinfo_h handle; + ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_appinfo_foreach_res_control(handle, res_control_func, NULL); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return -1; + } + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return 0; +} + * @endcode + */ +int pkgmgrinfo_appinfo_foreach_res_control(pkgmgrinfo_appinfo_h handle, + pkgmgrinfo_app_res_control_list_cb res_control_func, + void *user_data); + +/** * @fn int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay) * @brief This API gets the application 'nodisplay' value from the app ID * @@ -5095,7 +5351,7 @@ int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled); /** * @fn int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global) - * @brief This API gets whethere the given application is global application or user application + * @brief This API gets whether the given application is global application or user application * * @par This API is for package-manager client application * @par Sync (or) Async : Synchronous API @@ -5179,6 +5435,22 @@ int pkgmgrinfo_appinfo_get_setup_appid(pkgmgrinfo_appinfo_h handle, char **setup int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle, bool *support_ambient); /** + * @fn int pkgmgrinfo_appinfo_get_light_user_switch_mode(pkgmgrinfo_appinfo_h handle, char *mode) + * @brief This API gets the application 'light_user_switch_mode' value from the app ID + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * + * @param[in] handle pointer to application info handle + * @param[out] mode pointer to hold package light_user_switch_mode 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 + */ +int pkgmgrinfo_appinfo_get_light_user_switch_mode(pkgmgrinfo_appinfo_h handle, char **mode); + +/** * @fn int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle) * @brief This API destroys the application information handle freeing up all the resources * @@ -5742,6 +6014,32 @@ int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filte pkgmgrinfo_app_list_cb app_cb, void *user_data); int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle, pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid); + +/** + * @fn int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle, + pkgmgrinfo_app_control_list_cb_v2 appcontrol_func, void *user_data); + * @fn int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(pkgmgrinfo_appinfo_h handle, + pkgmgrinfo_app_control_list_cb_v2 appcontrol_func, void *user_data); + * @brief This API gets the list of app-control for a particular application + * + * @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] appcontrol_func callback function for list + * @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 pkgmgrinfo_appinfo_get_appinfo() + * @post pkgmgrinfo_appinfo_destroy_appinfo() + */ +int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle, + pkgmgrinfo_app_control_list_cb_v2 appcontrol_func, + void *user_data); +int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(pkgmgrinfo_appinfo_h handle, + pkgmgrinfo_app_control_list_cb_v2 appcontrol_func, + void *user_data); /** * @fn int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle) * @brief This API creates the package cert information handle to get data from db. @@ -6107,25 +6405,6 @@ static int set_cert_in_db(const char *pkgid) int pkgmgrinfo_destroy_certinfo_set_handle(pkgmgrinfo_instcertinfo_h handle); /** - * @fn int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access) - * @brief This API gets the datacontrol info - * - * @par This API is for package-manager client application - * @par Sync (or) Async : Synchronous API - * - * @param[in] providerid pointer to the providerid of dataconltrol. - * @param[in] type pointer to the type of dataconltrol. - * @param[out] appid pointer to hold appid, need to free after using - * @param[out] access pointer to hold access, need to free after using - * @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 - * @endcode - */ -int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access); - -/** * @fn int pkgmgrinfo_appinfo_is_guestmode_appstatus(pkgmgrinfo_appinfo_h handle, bool *status) * @brief This API gets the application 'guest mode visibility' value from the DB * @@ -6199,42 +6478,716 @@ int pkgmgrinfo_compare_package_version(const char *current_version, const char *target_version, pkgmgrinfo_version_compare_type *res); /** - * @brief TEMP - */ - + * @fn int pkgmgrinfo_pkginfo_foreach_dependency(pkgmgrinfo_pkginfo_h handle, + pkgmgrinfo_pkg_dependency_list_cb dependency_cb, + void *user_data); + * @brief This API gets the list of dependency of a particular package + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * @param[in] handle pointer to the package info handle. + * @param[in] dependency_cb callback function for list + * @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 pkgmgrinfo_pkginfo_get_pkginfo() + * @post pkgmgrinfo_pkginfo_destroy_pkginfo() + * @code +int dependency_cb(const char *from const char *to, const char *type, + const char *required_version,void *user_data) +{ + printf("this package %s %s", type, to); + if (required_version) + printf("required version : %s", required_version); + return 0; +} -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); -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); +static int list_dependency(const char *package) +{ + int ret = 0; + pkgmgrinfo_pkginfo_h handle; + ret = pkgmgrinfo_pkginfo_get_pkginfo(package, &handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_pkginfo_foreach_dependency(handle, dependency_cb, NULL); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return -1; + } + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return 0; +} + * @endcode + */ +int pkgmgrinfo_pkginfo_foreach_dependency(pkgmgrinfo_pkginfo_h handle, + pkgmgrinfo_pkg_dependency_list_cb dependency_cb, + void *user_data); + +/** + * @fn int pkgmgrinfo_pkginfo_foreach_depends_on(pkgmgrinfo_pkginfo_h handle, + pkgmgrinfo_pkg_dependency_list_cb dependency_cb, + void *user_data); + * @brief This API gets the list of packages which has dependency directly + * and indirectly of a particular package + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * @param[in] handle pointer to the package info handle. + * @param[in] dependency_cb callback function for list + * @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 pkgmgrinfo_pkginfo_get_pkginfo() + * @post pkgmgrinfo_pkginfo_destroy_pkginfo() + * @code +int dependency_cb(const char *from, const char *to, const char *type, + const char *required_version,void *user_data) +{ + printf("%s %s %s package", from, to, type); + if (required_version) + printf("required version : %s", required_version); + return 0; +} +static int list_depends_on(const char *package) +{ + int ret = 0; + pkgmgrinfo_pkginfo_h handle; + ret = pkgmgrinfo_pkginfo_get_pkginfo(package, &handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_pkginfo_foreach_depends_on(handle, dependency_cb, NULL); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return -1; + } + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return 0; +} + * @endcode + */ +int pkgmgrinfo_pkginfo_foreach_depends_on(pkgmgrinfo_pkginfo_h handle, + pkgmgrinfo_pkg_dependency_list_cb dependency_cb, + void *user_data); +/** + * @fn int pkgmgrinfo_pkginfo_foreach_res_allowed_package(pkgmgrinfo_pkginfo_h handle, + pkgmgrinfo_res_allowed_package_list_cb res_allowed_package_cb, + void *user_data) + * @brief This API gets the list of allowed package for a particular package + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * @param[in] handle pointer to the package info handle. + * @param[in] res_allowed_package_cb callback function for list + * @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 pkgmgrinfo_pkginfo_get_pkginfo() + * @post pkgmgrinfo_pkginfo_destroy_pkginfo() + * @code +int res_allowed_package_cb(const char *allowed_package, + required_privilege_h handle, void *user_data) +{ + printf("allowed package : %s", allowed_package); + + return 0; +} + +static int list_res_allowed_package(const char *package) +{ + int ret = 0; + pkgmgrinfo_pkginfo_h handle; + ret = pkgmgrinfo_pkginfo_get_pkginfo(package, &handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_pkginfo_foreach_res_allowed_package(handle, res_allowed_package_cb, NULL); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return -1; + } + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return 0; +} + * @endcode + */ +int pkgmgrinfo_pkginfo_foreach_res_allowed_package(pkgmgrinfo_pkginfo_h handle, + pkgmgrinfo_res_allowed_package_list_cb res_allowed_package_cb, + void *user_data); + +/** + * @fn int pkgmgrinfo_pkginfo_foreach_required_privilege( + required_privilege_h handle, + pkgmgrinfo_pkg_privilege_list_cb privilege_func, + void *user_data) + * @brief This API gets the list of allowed package's required privileges + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * @param[in] handle pointer to the required privilege handle. + * @param[in] privilege_func callback function for list + * @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 + * @pre pkgmgrinfo_pkginfo_foreach_res_allowed_package() + * @post None + * @code +int privilege_func(const char *privilege_name, void *user_data) +{ + printf("required privilege : %s", privilege_name); + + return 0; +} + +int res_allowed_package_cb(const char *allowed_package, + required_privilege_h handle, void *user_data) +{ + int ret = 0; + printf("allowed package : %s", allowed_package); + + ret = pkgmgrinfo_pkginfo_foreach_required_privilege(handle, privilege_func, user_data); + if (ret != PMINFO_R_OK) + return -1; + + return 0; +} + +static int list_res_allowed_package(const char *package) +{ + int ret = 0; + pkgmgrinfo_pkginfo_h handle; + ret = pkgmgrinfo_pkginfo_get_pkginfo(package, &handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_pkginfo_foreach_res_allowed_package(handle, res_allowed_package_cb, NULL); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return -1; + } + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return 0; +} + * @endcode + */ +int pkgmgrinfo_pkginfo_foreach_required_privilege( + required_privilege_h handle, + pkgmgrinfo_pkg_privilege_list_cb privilege_func, + void *user_data); + +/** + * @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); /** + * @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 **/ @@ -6248,4 +7201,3 @@ int pkgmgrinfo_archiveinfo_get_icon(pkgmgrinfo_archiveinfo_h handle, * @} * @} */ -