static gboolean
refine_reviews (GsPlugin *plugin, GsApp *app, GCancellable *cancellable, GError **error)
{
	GPtrArray *sources;
	guint i, j;

	/* Skip if already has reviews */
	if (gs_app_get_reviews (app)->len > 0)
		return TRUE;

	sources = gs_app_get_sources (app);
	for (i = 0; i < sources->len; i++) {
		const gchar *package_name;

		package_name = g_ptr_array_index (sources, i);
		for (j = 0; j < N_PAGES; j++) {
			gboolean ret;

			ret = download_reviews (plugin, app, package_name, j, cancellable, error);
			if (!ret)
				return FALSE;
		}
	}

	return TRUE;
}
示例#2
0
gboolean
gs_plugin_refine_app (GsPlugin *plugin,
		      GsApp *app,
		      GsPluginRefineFlags flags,
		      GCancellable *cancellable,
		      GError **error)
{
	/* not valid */
	if (gs_app_get_kind (app) == AS_APP_KIND_ADDON)
		return TRUE;
	if (gs_app_get_id (app) == NULL)
		return TRUE;

	/* add reviews if possible */
	if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS) {
		if (gs_app_get_reviews(app)->len > 0)
			return TRUE;
		if (!gs_plugin_odrs_refine_reviews (plugin, app,
						    cancellable, error))
			return FALSE;
	}

	/* add ratings if possible */
	if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEW_RATINGS ||
	    flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING) {
		if (gs_app_get_review_ratings(app) != NULL)
			return TRUE;
		if (!gs_plugin_odrs_refine_ratings (plugin, app,
						    cancellable, error))
			return FALSE;
	}

	return TRUE;
}
/**
 * gs_plugin_refine:
 */
gboolean
gs_plugin_refine (GsPlugin *plugin,
		  GList **list,
		  GsPluginRefineFlags flags,
		  GCancellable *cancellable,
		  GError **error)
{
	GsApp *app;
	GList *l;

	/* add reviews if possible */
	if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS) {
		for (l = *list; l != NULL; l = l->next) {
			g_autoptr(GError) error_local = NULL;
			app = GS_APP (l->data);
			if (gs_app_get_reviews(app)->len > 0)
				continue;
			if (gs_app_get_id_no_prefix (app) == NULL)
				continue;
			if (gs_app_get_id_kind (app) == AS_ID_KIND_ADDON)
				continue;
			if (!gs_plugin_refine_reviews (plugin, app,
						       cancellable,
						       &error_local)) {
				g_warning ("Failed to get reviews: %s",
					   error_local->message);
			}
		}
	}

	/* add ratings if possible */
	if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEW_RATINGS) {
		for (l = *list; l != NULL; l = l->next) {
			g_autoptr(GError) error_local = NULL;
			app = GS_APP (l->data);
			if (gs_app_get_review_ratings(app) != NULL)
				continue;
			if (gs_app_get_id_no_prefix (app) == NULL)
				continue;
			if (gs_app_get_id_kind (app) == AS_ID_KIND_ADDON)
				continue;
			if (!gs_plugin_refine_ratings (plugin, app,
						       cancellable,
						       &error_local)) {
				g_warning ("Failed to get ratings: %s",
					   error_local->message);
			}
		}
	}

	return TRUE;
}