[gnome-software: 10/18] gs-plugin: Drop review actions from GsPlugin and GsPluginLoader
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 10/18] gs-plugin: Drop review actions from GsPlugin and GsPluginLoader
- Date: Wed, 9 Jun 2021 13:45:49 +0000 (UTC)
commit 9877c84d0a20b456353bde2f96e9e8a2d274f09a
Author: Philip Withnall <pwithnall endlessos org>
Date: Tue May 18 17:07:12 2021 +0100
gs-plugin: Drop review actions from GsPlugin and GsPluginLoader
The only plugin to implement them was ODRS, and since porting the
details and moderate pages to call `GsOdrsProvider` directly, they are
not used anywhere. So drop them.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
lib/gs-odrs-provider.c | 16 ++++-
lib/gs-plugin-loader.c | 45 -------------
lib/gs-plugin-types.h | 14 -----
lib/gs-plugin-vfuncs.h | 136 ----------------------------------------
lib/gs-plugin.c | 42 -------------
plugins/dummy/gs-plugin-dummy.c | 59 -----------------
plugins/odrs/gs-plugin-odrs.c | 90 --------------------------
7 files changed, 14 insertions(+), 388 deletions(-)
---
diff --git a/lib/gs-odrs-provider.c b/lib/gs-odrs-provider.c
index 68b1bd0a1..2b17db5d0 100644
--- a/lib/gs-odrs-provider.c
+++ b/lib/gs-odrs-provider.c
@@ -1402,7 +1402,13 @@ gs_odrs_provider_submit_review (GsOdrsProvider *self,
/* POST */
uri = g_strdup_printf ("%s/submit", self->review_server);
- return gs_odrs_provider_json_post (self->session, uri, data, error);
+ if (!gs_odrs_provider_json_post (self->session, uri, data, error))
+ return FALSE;
+
+ /* modify the local app */
+ gs_app_add_review (app, review);
+
+ return TRUE;
}
/**
@@ -1528,7 +1534,13 @@ gs_odrs_provider_remove_review (GsOdrsProvider *self,
{
g_autofree gchar *uri = NULL;
uri = g_strdup_printf ("%s/remove", self->review_server);
- return gs_odrs_provider_vote (self, review, uri, error);
+ if (!gs_odrs_provider_vote (self, review, uri, error))
+ return FALSE;
+
+ /* update the local app */
+ gs_app_remove_review (app, review);
+
+ return TRUE;
}
/**
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 634a301a5..b71663754 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -140,11 +140,6 @@ typedef gboolean (*GsPluginActionFunc) (GsPlugin *plugin,
GsApp *app,
GCancellable *cancellable,
GError **error);
-typedef gboolean (*GsPluginReviewFunc) (GsPlugin *plugin,
- GsApp *app,
- AsReview *review,
- GCancellable *cancellable,
- GError **error);
typedef gboolean (*GsPluginRefineFunc) (GsPlugin *plugin,
GsAppList *list,
GsPluginRefineFlags refine_flags,
@@ -616,19 +611,6 @@ gs_plugin_loader_call_vfunc (GsPluginLoaderHelper *helper,
ret = plugin_func (plugin, app, cancellable, &error_local);
}
break;
- case GS_PLUGIN_ACTION_REVIEW_SUBMIT:
- case GS_PLUGIN_ACTION_REVIEW_UPVOTE:
- case GS_PLUGIN_ACTION_REVIEW_DOWNVOTE:
- case GS_PLUGIN_ACTION_REVIEW_REPORT:
- case GS_PLUGIN_ACTION_REVIEW_REMOVE:
- case GS_PLUGIN_ACTION_REVIEW_DISMISS:
- {
- GsPluginReviewFunc plugin_func = func;
- ret = plugin_func (plugin, app,
- gs_plugin_job_get_review (helper->plugin_job),
- cancellable, &error_local);
- }
- break;
case GS_PLUGIN_ACTION_GET_RECENT:
{
GsPluginGetRecentFunc plugin_func = func;
@@ -640,7 +622,6 @@ gs_plugin_loader_call_vfunc (GsPluginLoaderHelper *helper,
case GS_PLUGIN_ACTION_GET_UPDATES:
case GS_PLUGIN_ACTION_GET_UPDATES_HISTORICAL:
case GS_PLUGIN_ACTION_GET_DISTRO_UPDATES:
- case GS_PLUGIN_ACTION_GET_UNVOTED_REVIEWS:
case GS_PLUGIN_ACTION_GET_SOURCES:
case GS_PLUGIN_ACTION_GET_INSTALLED:
case GS_PLUGIN_ACTION_GET_POPULAR:
@@ -3259,18 +3240,6 @@ gs_plugin_loader_process_thread_cb (GTask *task,
}
}
- /* modify the local app */
- switch (action) {
- case GS_PLUGIN_ACTION_REVIEW_SUBMIT:
- gs_app_add_review (gs_plugin_job_get_app (helper->plugin_job), gs_plugin_job_get_review
(helper->plugin_job));
- break;
- case GS_PLUGIN_ACTION_REVIEW_REMOVE:
- gs_app_remove_review (gs_plugin_job_get_app (helper->plugin_job), gs_plugin_job_get_review
(helper->plugin_job));
- break;
- default:
- break;
- }
-
/* refine with enough data so that the sort_func in
* gs_plugin_loader_job_sorted_truncation() can do what it needs */
filter_flags = gs_plugin_job_get_filter_flags (helper->plugin_job);
@@ -3671,20 +3640,6 @@ gs_plugin_loader_job_process_async (GsPluginLoader *plugin_loader,
return;
}
break;
- case GS_PLUGIN_ACTION_REVIEW_SUBMIT:
- case GS_PLUGIN_ACTION_REVIEW_UPVOTE:
- case GS_PLUGIN_ACTION_REVIEW_DOWNVOTE:
- case GS_PLUGIN_ACTION_REVIEW_REPORT:
- case GS_PLUGIN_ACTION_REVIEW_REMOVE:
- case GS_PLUGIN_ACTION_REVIEW_DISMISS:
- if (gs_plugin_job_get_review (plugin_job) == NULL) {
- g_task_return_new_error (task,
- GS_PLUGIN_ERROR,
- GS_PLUGIN_ERROR_NOT_SUPPORTED,
- "no valid review object");
- return;
- }
- break;
default:
break;
}
diff --git a/lib/gs-plugin-types.h b/lib/gs-plugin-types.h
index ed81da4c9..5d8760918 100644
--- a/lib/gs-plugin-types.h
+++ b/lib/gs-plugin-types.h
@@ -198,15 +198,8 @@ typedef enum {
* @GS_PLUGIN_ACTION_UPDATE_CANCEL: Cancel the update
* @GS_PLUGIN_ACTION_ADD_SHORTCUT: Add a shortcut to an application
* @GS_PLUGIN_ACTION_REMOVE_SHORTCUT: Remove a shortcut to an application
- * @GS_PLUGIN_ACTION_REVIEW_SUBMIT: Submit a new review
- * @GS_PLUGIN_ACTION_REVIEW_UPVOTE: Upvote an existing review
- * @GS_PLUGIN_ACTION_REVIEW_DOWNVOTE: Downvote an existing review
- * @GS_PLUGIN_ACTION_REVIEW_REPORT: Report an existing review
- * @GS_PLUGIN_ACTION_REVIEW_REMOVE: Remove a review written by the user
- * @GS_PLUGIN_ACTION_REVIEW_DISMISS: Dismiss (ignore) a review when moderating
* @GS_PLUGIN_ACTION_GET_UPDATES: Get the list of updates
* @GS_PLUGIN_ACTION_GET_DISTRO_UPDATES: Get the list of distro updates
- * @GS_PLUGIN_ACTION_GET_UNVOTED_REVIEWS: Get the list of moderatable reviews
* @GS_PLUGIN_ACTION_GET_SOURCES: Get the list of sources
* @GS_PLUGIN_ACTION_GET_INSTALLED: Get the list of installed applications
* @GS_PLUGIN_ACTION_GET_POPULAR: Get the list of popular applications
@@ -243,15 +236,8 @@ typedef enum {
GS_PLUGIN_ACTION_UPDATE_CANCEL,
GS_PLUGIN_ACTION_ADD_SHORTCUT,
GS_PLUGIN_ACTION_REMOVE_SHORTCUT,
- GS_PLUGIN_ACTION_REVIEW_SUBMIT,
- GS_PLUGIN_ACTION_REVIEW_UPVOTE,
- GS_PLUGIN_ACTION_REVIEW_DOWNVOTE,
- GS_PLUGIN_ACTION_REVIEW_REPORT,
- GS_PLUGIN_ACTION_REVIEW_REMOVE,
- GS_PLUGIN_ACTION_REVIEW_DISMISS,
GS_PLUGIN_ACTION_GET_UPDATES,
GS_PLUGIN_ACTION_GET_DISTRO_UPDATES,
- GS_PLUGIN_ACTION_GET_UNVOTED_REVIEWS,
GS_PLUGIN_ACTION_GET_SOURCES,
GS_PLUGIN_ACTION_GET_INSTALLED,
GS_PLUGIN_ACTION_GET_POPULAR,
diff --git a/lib/gs-plugin-vfuncs.h b/lib/gs-plugin-vfuncs.h
index 7f7361b05..37652f017 100644
--- a/lib/gs-plugin-vfuncs.h
+++ b/lib/gs-plugin-vfuncs.h
@@ -381,27 +381,6 @@ gboolean gs_plugin_add_featured (GsPlugin *plugin,
GCancellable *cancellable,
GError **error);
-/**
- * gs_plugin_add_unvoted_reviews:
- * @plugin: a #GsPlugin
- * @list: a #GsAppList
- * @cancellable: a #GCancellable, or %NULL
- * @error: a #GError, or %NULL
- *
- * Gets the list of unvoted reviews. Only applications should be returned where
- * there are reviews, and where the user has not previously moderated them.
- * This function is supposed to be used to display a moderation panel for
- * reviewers.
- *
- * Plugins are expected to add new apps using gs_app_list_add().
- *
- * Returns: %TRUE for success or if not relevant
- **/
-gboolean gs_plugin_add_unvoted_reviews (GsPlugin *plugin,
- GsAppList *list,
- GCancellable *cancellable,
- GError **error);
-
/**
* gs_plugin_refine:
* @plugin: a #GsPlugin
@@ -717,121 +696,6 @@ gboolean gs_plugin_app_upgrade_trigger (GsPlugin *plugin,
GCancellable *cancellable,
GError **error);
-/**
- * gs_plugin_review_submit:
- * @plugin: a #GsPlugin
- * @app: a #GsApp
- * @review: a #AsReview
- * @cancellable: a #GCancellable, or %NULL
- * @error: a #GError, or %NULL
- *
- * Submits a new end-user application review.
- *
- * Returns: %TRUE for success or if not relevant
- **/
-gboolean gs_plugin_review_submit (GsPlugin *plugin,
- GsApp *app,
- AsReview *review,
- GCancellable *cancellable,
- GError **error);
-
-/**
- * gs_plugin_review_upvote:
- * @plugin: a #GsPlugin
- * @app: a #GsApp
- * @review: a #AsReview
- * @cancellable: a #GCancellable, or %NULL
- * @error: a #GError, or %NULL
- *
- * Upvote a specific review to indicate the review is helpful.
- *
- * Returns: %TRUE for success or if not relevant
- **/
-gboolean gs_plugin_review_upvote (GsPlugin *plugin,
- GsApp *app,
- AsReview *review,
- GCancellable *cancellable,
- GError **error);
-
-/**
- * gs_plugin_review_downvote:
- * @plugin: a #GsPlugin
- * @app: a #GsApp
- * @review: a #AsReview
- * @cancellable: a #GCancellable, or %NULL
- * @error: a #GError, or %NULL
- *
- * Downvote a specific review to indicate the review is unhelpful.
- *
- * Plugins are expected to add new apps using gs_app_list_add().
- *
- * Returns: %TRUE for success or if not relevant
- **/
-gboolean gs_plugin_review_downvote (GsPlugin *plugin,
- GsApp *app,
- AsReview *review,
- GCancellable *cancellable,
- GError **error);
-
-/**
- * gs_plugin_review_report:
- * @plugin: a #GsPlugin
- * @app: a #GsApp
- * @review: a #AsReview
- * @cancellable: a #GCancellable, or %NULL
- * @error: a #GError, or %NULL
- *
- * Report a review that is not suitable in some way.
- * It is expected that this action flags a review to be checked by a moderator
- * and that the review won't be shown to any users until this happens.
- *
- * Returns: %TRUE for success or if not relevant
- **/
-gboolean gs_plugin_review_report (GsPlugin *plugin,
- GsApp *app,
- AsReview *review,
- GCancellable *cancellable,
- GError **error);
-
-/**
- * gs_plugin_review_remove:
- * @plugin: a #GsPlugin
- * @app: a #GsApp
- * @review: a #AsReview
- * @cancellable: a #GCancellable, or %NULL
- * @error: a #GError, or %NULL
- *
- * Remove a review that the user wrote.
- * NOTE: Users should only be able to remove reviews with %AS_REVIEW_FLAG_SELF.
- *
- * Returns: %TRUE for success or if not relevant
- **/
-gboolean gs_plugin_review_remove (GsPlugin *plugin,
- GsApp *app,
- AsReview *review,
- GCancellable *cancellable,
- GError **error);
-
-/**
- * gs_plugin_review_dismiss:
- * @plugin: a #GsPlugin
- * @app: a #GsApp
- * @review: a #AsReview
- * @cancellable: a #GCancellable, or %NULL
- * @error: a #GError, or %NULL
- *
- * Dismisses a review, i.e. hide it from future moderated views.
- * This action is useful when the moderator is unable to speak the language of
- * the review for example.
- *
- * Returns: %TRUE for success or if not relevant
- **/
-gboolean gs_plugin_review_dismiss (GsPlugin *plugin,
- GsApp *app,
- AsReview *review,
- GCancellable *cancellable,
- GError **error);
-
/**
* gs_plugin_refresh:
* @plugin: a #GsPlugin
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index b9a609150..7a6729e1c 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -1627,18 +1627,6 @@ gs_plugin_action_to_function_name (GsPluginAction action)
{
if (action == GS_PLUGIN_ACTION_REFRESH)
return "gs_plugin_refresh";
- if (action == GS_PLUGIN_ACTION_REVIEW_SUBMIT)
- return "gs_plugin_review_submit";
- if (action == GS_PLUGIN_ACTION_REVIEW_UPVOTE)
- return "gs_plugin_review_upvote";
- if (action == GS_PLUGIN_ACTION_REVIEW_DOWNVOTE)
- return "gs_plugin_review_downvote";
- if (action == GS_PLUGIN_ACTION_REVIEW_REPORT)
- return "gs_plugin_review_report";
- if (action == GS_PLUGIN_ACTION_REVIEW_REMOVE)
- return "gs_plugin_review_remove";
- if (action == GS_PLUGIN_ACTION_REVIEW_DISMISS)
- return "gs_plugin_review_dismiss";
if (action == GS_PLUGIN_ACTION_INSTALL)
return "gs_plugin_app_install";
if (action == GS_PLUGIN_ACTION_REMOVE)
@@ -1671,8 +1659,6 @@ gs_plugin_action_to_function_name (GsPluginAction action)
return "gs_plugin_add_distro_upgrades";
if (action == GS_PLUGIN_ACTION_GET_SOURCES)
return "gs_plugin_add_sources";
- if (action == GS_PLUGIN_ACTION_GET_UNVOTED_REVIEWS)
- return "gs_plugin_add_unvoted_reviews";
if (action == GS_PLUGIN_ACTION_GET_INSTALLED)
return "gs_plugin_add_installed";
if (action == GS_PLUGIN_ACTION_GET_FEATURED)
@@ -1745,24 +1731,10 @@ gs_plugin_action_to_string (GsPluginAction action)
return "add-shortcut";
if (action == GS_PLUGIN_ACTION_REMOVE_SHORTCUT)
return "remove-shortcut";
- if (action == GS_PLUGIN_ACTION_REVIEW_SUBMIT)
- return "review-submit";
- if (action == GS_PLUGIN_ACTION_REVIEW_UPVOTE)
- return "review-upvote";
- if (action == GS_PLUGIN_ACTION_REVIEW_DOWNVOTE)
- return "review-downvote";
- if (action == GS_PLUGIN_ACTION_REVIEW_REPORT)
- return "review-report";
- if (action == GS_PLUGIN_ACTION_REVIEW_REMOVE)
- return "review-remove";
- if (action == GS_PLUGIN_ACTION_REVIEW_DISMISS)
- return "review-dismiss";
if (action == GS_PLUGIN_ACTION_GET_UPDATES)
return "get-updates";
if (action == GS_PLUGIN_ACTION_GET_DISTRO_UPDATES)
return "get-distro-updates";
- if (action == GS_PLUGIN_ACTION_GET_UNVOTED_REVIEWS)
- return "get-unvoted-reviews";
if (action == GS_PLUGIN_ACTION_GET_SOURCES)
return "get-sources";
if (action == GS_PLUGIN_ACTION_GET_INSTALLED)
@@ -1841,24 +1813,10 @@ gs_plugin_action_from_string (const gchar *action)
return GS_PLUGIN_ACTION_ADD_SHORTCUT;
if (g_strcmp0 (action, "remove-shortcut") == 0)
return GS_PLUGIN_ACTION_REMOVE_SHORTCUT;
- if (g_strcmp0 (action, "review-submit") == 0)
- return GS_PLUGIN_ACTION_REVIEW_SUBMIT;
- if (g_strcmp0 (action, "review-upvote") == 0)
- return GS_PLUGIN_ACTION_REVIEW_UPVOTE;
- if (g_strcmp0 (action, "review-downvote") == 0)
- return GS_PLUGIN_ACTION_REVIEW_DOWNVOTE;
- if (g_strcmp0 (action, "review-report") == 0)
- return GS_PLUGIN_ACTION_REVIEW_REPORT;
- if (g_strcmp0 (action, "review-remove") == 0)
- return GS_PLUGIN_ACTION_REVIEW_REMOVE;
- if (g_strcmp0 (action, "review-dismiss") == 0)
- return GS_PLUGIN_ACTION_REVIEW_DISMISS;
if (g_strcmp0 (action, "get-updates") == 0)
return GS_PLUGIN_ACTION_GET_UPDATES;
if (g_strcmp0 (action, "get-distro-updates") == 0)
return GS_PLUGIN_ACTION_GET_DISTRO_UPDATES;
- if (g_strcmp0 (action, "get-unvoted-reviews") == 0)
- return GS_PLUGIN_ACTION_GET_UNVOTED_REVIEWS;
if (g_strcmp0 (action, "get-sources") == 0)
return GS_PLUGIN_ACTION_GET_SOURCES;
if (g_strcmp0 (action, "get-installed") == 0)
diff --git a/plugins/dummy/gs-plugin-dummy.c b/plugins/dummy/gs-plugin-dummy.c
index c6cbe46af..a5640b49e 100644
--- a/plugins/dummy/gs-plugin-dummy.c
+++ b/plugins/dummy/gs-plugin-dummy.c
@@ -870,62 +870,3 @@ gs_plugin_update_cancel (GsPlugin *plugin, GsApp *app,
{
return TRUE;
}
-
-gboolean
-gs_plugin_review_submit (GsPlugin *plugin,
- GsApp *app,
- AsReview *review,
- GCancellable *cancellable,
- GError **error)
-{
- g_debug ("Submitting dummy review");
- return TRUE;
-}
-
-gboolean
-gs_plugin_review_report (GsPlugin *plugin,
- GsApp *app,
- AsReview *review,
- GCancellable *cancellable,
- GError **error)
-{
- g_debug ("Reporting dummy review");
- as_review_add_flags (review, AS_REVIEW_FLAG_VOTED);
- return TRUE;
-}
-
-gboolean
-gs_plugin_review_upvote (GsPlugin *plugin,
- GsApp *app,
- AsReview *review,
- GCancellable *cancellable,
- GError **error)
-{
- g_debug ("Upvoting dummy review");
- as_review_add_flags (review, AS_REVIEW_FLAG_VOTED);
- return TRUE;
-}
-
-gboolean
-gs_plugin_review_downvote (GsPlugin *plugin,
- GsApp *app,
- AsReview *review,
- GCancellable *cancellable,
- GError **error)
-{
- g_debug ("Downvoting dummy review");
- as_review_add_flags (review, AS_REVIEW_FLAG_VOTED);
- return TRUE;
-}
-
-gboolean
-gs_plugin_review_remove (GsPlugin *plugin,
- GsApp *app,
- AsReview *review,
- GCancellable *cancellable,
- GError **error)
-{
- /* all okay */
- g_debug ("Removing dummy self-review");
- return TRUE;
-}
diff --git a/plugins/odrs/gs-plugin-odrs.c b/plugins/odrs/gs-plugin-odrs.c
index 9060976c8..921167abd 100644
--- a/plugins/odrs/gs-plugin-odrs.c
+++ b/plugins/odrs/gs-plugin-odrs.c
@@ -121,93 +121,3 @@ gs_plugin_refine (GsPlugin *plugin,
return gs_odrs_provider_refine (priv->provider, list, flags, cancellable, error);
}
-
-gboolean
-gs_plugin_review_submit (GsPlugin *plugin,
- GsApp *app,
- AsReview *review,
- GCancellable *cancellable,
- GError **error)
-{
- GsPluginData *priv = gs_plugin_get_data (plugin);
-
- return gs_odrs_provider_submit_review (priv->provider, app,
- review, cancellable, error);
-}
-
-gboolean
-gs_plugin_review_report (GsPlugin *plugin,
- GsApp *app,
- AsReview *review,
- GCancellable *cancellable,
- GError **error)
-{
- GsPluginData *priv = gs_plugin_get_data (plugin);
-
- return gs_odrs_provider_report_review (priv->provider, app,
- review, cancellable, error);
-}
-
-gboolean
-gs_plugin_review_upvote (GsPlugin *plugin,
- GsApp *app,
- AsReview *review,
- GCancellable *cancellable,
- GError **error)
-{
- GsPluginData *priv = gs_plugin_get_data (plugin);
-
- return gs_odrs_provider_upvote_review (priv->provider, app,
- review, cancellable, error);
-}
-
-gboolean
-gs_plugin_review_downvote (GsPlugin *plugin,
- GsApp *app,
- AsReview *review,
- GCancellable *cancellable,
- GError **error)
-{
- GsPluginData *priv = gs_plugin_get_data (plugin);
-
- return gs_odrs_provider_downvote_review (priv->provider, app,
- review, cancellable, error);
-}
-
-gboolean
-gs_plugin_review_dismiss (GsPlugin *plugin,
- GsApp *app,
- AsReview *review,
- GCancellable *cancellable,
- GError **error)
-{
- GsPluginData *priv = gs_plugin_get_data (plugin);
-
- return gs_odrs_provider_dismiss_review (priv->provider, app,
- review, cancellable, error);
-}
-
-gboolean
-gs_plugin_review_remove (GsPlugin *plugin,
- GsApp *app,
- AsReview *review,
- GCancellable *cancellable,
- GError **error)
-{
- GsPluginData *priv = gs_plugin_get_data (plugin);
-
- return gs_odrs_provider_remove_review (priv->provider, app,
- review, cancellable, error);
-}
-
-gboolean
-gs_plugin_add_unvoted_reviews (GsPlugin *plugin,
- GsAppList *list,
- GCancellable *cancellable,
- GError **error)
-{
- GsPluginData *priv = gs_plugin_get_data (plugin);
-
- return gs_odrs_provider_add_unvoted_reviews (priv->provider, list,
- cancellable, error);
-}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]