[gnome-software] Allow plugins to add application review information



commit f5a2140f0a58be5588a4dd3caeb3e1efc86e86e0
Author: Robert Ancell <robert ancell canonical com>
Date:   Tue Feb 9 10:55:27 2016 +0000

    Allow plugins to add application review information
    
    Signed-off-by: Richard Hughes <richard hughsie com>

 src/gs-cmd.c                  |    2 ++
 src/gs-plugin.h               |    1 +
 src/gs-shell-details.c        |    6 ++++--
 src/plugins/gs-plugin-dummy.c |   15 +++++++++++++++
 4 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-cmd.c b/src/gs-cmd.c
index a5b4005..1b3c2e0 100644
--- a/src/gs-cmd.c
+++ b/src/gs-cmd.c
@@ -140,6 +140,8 @@ gs_cmd_refine_flag_from_string (const gchar *flag, GError **error)
                return GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPGRADE_REMOVED;
        if (g_strcmp0 (flag, "provenance") == 0)
                return GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROVENANCE;
+       if (g_strcmp0 (flag, "reviews") == 0)
+               return GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS;
        g_set_error (error,
                     GS_PLUGIN_ERROR,
                     GS_PLUGIN_ERROR_NOT_SUPPORTED,
diff --git a/src/gs-plugin.h b/src/gs-plugin.h
index e346371..5e67565 100644
--- a/src/gs-plugin.h
+++ b/src/gs-plugin.h
@@ -107,6 +107,7 @@ typedef enum {
        GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_SEVERITY  = 1 << 15,
        GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPGRADE_REMOVED  = 1 << 16,
        GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROVENANCE       = 1 << 17,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS          = 1 << 18,
        GS_PLUGIN_REFINE_FLAGS_LAST
 } GsPluginRefineFlags;
 
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 6a38501..37bb8a3 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -1070,7 +1070,8 @@ gs_shell_details_set_filename (GsShellDetails *self, const gchar *filename)
        gs_plugin_loader_filename_to_app_async (self->plugin_loader,
                                                filename,
                                                GS_PLUGIN_REFINE_FLAGS_DEFAULT |
-                                               GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING,
+                                               GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING |
+                                               GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS,
                                                self->cancellable,
                                                gs_shell_details_filename_to_app_cb,
                                                self);
@@ -1094,7 +1095,8 @@ gs_shell_details_load (GsShellDetails *self)
                                           GS_PLUGIN_REFINE_FLAGS_REQUIRE_URL |
                                           GS_PLUGIN_REFINE_FLAGS_REQUIRE_SETUP_ACTION |
                                           GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROVENANCE |
-                                          GS_PLUGIN_REFINE_FLAGS_REQUIRE_ADDONS,
+                                          GS_PLUGIN_REFINE_FLAGS_REQUIRE_ADDONS |
+                                          GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS,
                                           self->cancellable,
                                           gs_shell_details_app_refine_cb,
                                           self);
diff --git a/src/plugins/gs-plugin-dummy.c b/src/plugins/gs-plugin-dummy.c
index 0be6975..e021213 100644
--- a/src/plugins/gs-plugin-dummy.c
+++ b/src/plugins/gs-plugin-dummy.c
@@ -161,6 +161,21 @@ gs_plugin_refine (GsPlugin *plugin,
                        }
                }
        }
+
+       /* add fake review */
+       if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS) {
+               for (l = *list; l != NULL; l = l->next) {
+                       g_autoptr(GsReview) review = NULL;
+                       app = GS_APP (l->data);
+                       review = gs_review_new ();
+                       gs_review_set_rating (review, 50);
+                       gs_review_set_reviewer (review, "Angela Avery");
+                       gs_review_set_summary (review, "Steep learning curve, but worth it");
+                       gs_review_set_text (review, "Best overall 3D application I've ever used overall 3D 
application I've ever used. Best overall 3D application I've ever used overall 3D application I've ever used. 
Best overall 3D application I've ever used overall 3D application I've ever used. Best overall 3D application 
I've ever used overall 3D application I've ever used.");
+                       gs_review_set_version (review, "3.16.4");
+                       gs_app_add_review (app, review);
+               }
+       }
        return TRUE;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]