/**
+ * @brief Called to provide dependency information.
+ * @since_tizen 5.5
+ * @remarks @a from, @a to, @a type and @a required_version are managed by the platform and will be released after the callback exits.
+ * @param[in] from The ID of package which depends other package
+ * @param[in] to The ID of package which depended by other package
+ * @param[in] type The type of dependency
+ * @param[in] required_version The required version
+ * @param[in] user_data The user data passed from the foreach function
+ * @return @c true to continue with the next iteration of the loop,
+ * otherwise @c false to break out of the loop
+ * @pre package_info_foreach_dependency_info() will invoke this callback.
+ * @pre package_info_foreach_dependency_info_depends_on() will invoke this callback.
+ * @see package_info_foreach_dependency_info()
+ * @see package_info_foreach_dependency_info_depends_on()
+ */
+typedef bool (*package_info_dependency_info_cb) (const char *from, const char *to, const char *type, const char *required_version, void *user_data);
+
+
+/**
* @brief Retrieves all application IDs of each package.
* @since_tizen 2.3
* @param[in] package_info The package info handle
int package_info_foreach_privilege_info(package_info_h package_info, package_info_privilege_info_cb callback, void *user_data);
/**
+ * @brief Retrieves dependency information of the package.
+ * @details The results include packages that are only directly required by a given package.
+ * For example, if we have:
+ *
+ * B --> E
+ * A --> B --> C
+ * D --> C
+ *
+ * where A --> B means that A depends on B, and package_info_foreach_dependency_info(A) is called,
+ * the results will be: {from A to B}.
+ * @since_tizen 5.5
+ * @remarks The function provides the results synchronously. If there are no dependencies, this function will return PACKAGE_MANAGER_ERROR_NONE immediately and the callback will not be invoked.
+ * @param[in] package_info The package information
+ * @param[in] callback The iteration callback function
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
+ * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PACKAGE_MANAGER_ERROR_SYSTEM_ERROR Severe system error
+ */
+int package_info_foreach_dependency_info(package_info_h package_info, package_info_dependency_info_cb callback, void *user_data);
+
+/**
+ * @brief Retrieves information about which packages depend on a given package.
+ * @details The results include packages that both directly and indirectly depend on a given package.
+ * For example, if we have:
+ *
+ * B --> E
+ * A --> B --> C
+ * D --> C
+ *
+ * where A --> B means that A depends on B, and package_info_foreach_dependency_info_depends_on(C) is called,
+ * the results will be: {from B to C}, {from D to C}, {from A to B}.
+ * @since_tizen 5.5
+ * @remarks The function provides the results synchronously. If there are no dependencies, this function will return PACKAGE_MANAGER_ERROR_NONE immediately and the callback will not be invoked.
+ * @param[in] package_info The package information
+ * @param[in] callback The iteration callback function
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
+ * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PACKAGE_MANAGER_ERROR_SYSTEM_ERROR Severe system error
+ */
+int package_info_foreach_dependency_info_depends_on(package_info_h package_info, package_info_dependency_info_cb callback, void *user_data);
+
+/**
* @brief Gets the package update information for the given package.
* @since_tizen 4.0
* @remarks You must release @a info using package_info_updateinfo_destroy().
void *user_data;
} foreach_privilege_s;
+typedef struct _foreach_dependency_ {
+ package_info_dependency_info_cb callback;
+ void *user_data;
+} foreach_dependency_s;
+
static int package_info_foreach_updateinfo_cb(const pkgmgrinfo_updateinfo_h handle, void *user_data)
{
foreach_updateinfo_context_s *foreach_updateinfo = user_data;
return ret;
}
+static int package_info_foreach_dependency_cb(const char *from, const char *to, const char *type, const char *required_version, void *user_data)
+{
+ foreach_dependency_s *foreach_dependency = (foreach_dependency_s *)user_data;
+
+ if (!foreach_dependency->callback(from, to, type, required_version, user_data))
+ return -1;
+ else
+ return 0;
+}
+
+API int package_info_foreach_dependency_info(package_info_h package_info, package_info_dependency_info_cb callback, void *user_data)
+{
+ int ret = 0;
+ foreach_dependency_s foreach_dependency = {
+ .callback = callback,
+ .user_data = user_data,
+ };
+
+ if (package_info == NULL || callback == NULL)
+ return package_manager_error(PACKAGE_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+
+ ret = pkgmgrinfo_pkginfo_foreach_dependency(package_info->pkgmgr_pkginfo, package_info_foreach_dependency_cb, &foreach_dependency);
+ if (ret == PMINFO_R_EINVAL)
+ return package_manager_error(PACKAGE_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ else if (ret == PMINFO_R_ERROR)
+ return package_manager_error(PACKAGE_MANAGER_ERROR_SYSTEM_ERROR, __FUNCTION__, NULL);
+
+ return PACKAGE_MANAGER_ERROR_NONE;
+}
+
+API int package_info_foreach_dependency_info_depends_on(package_info_h package_info, package_info_dependency_info_cb callback, void *user_data)
+{
+ int ret = 0;
+ foreach_dependency_s foreach_dependency = {
+ .callback = callback,
+ .user_data = user_data,
+ };
+
+ if (package_info == NULL || callback == NULL)
+ return package_manager_error(PACKAGE_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+
+ ret = pkgmgrinfo_pkginfo_foreach_depends_on(package_info->pkgmgr_pkginfo, package_info_foreach_dependency_cb, &foreach_dependency);
+ if (ret == PMINFO_R_EINVAL)
+ return package_manager_error(PACKAGE_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ else if (ret == PMINFO_R_ERROR)
+ return package_manager_error(PACKAGE_MANAGER_ERROR_SYSTEM_ERROR, __FUNCTION__, NULL);
+
+ return PACKAGE_MANAGER_ERROR_NONE;
+}
+
API int package_info_updateinfo_create(const char *pkgid, package_updateinfo_h *info)
{
int ret;