[gnome-software] lib: Add a quirk for parental filtering and filter results with it
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] lib: Add a quirk for parental filtering and filter results with it
- Date: Fri, 16 Nov 2018 14:45:08 +0000 (UTC)
commit 4d188f3362ccb7f5e2394555e19ae71f7c0812a3
Author: Philip Withnall <withnall endlessm com>
Date: Mon Nov 12 18:50:37 2018 +0000
lib: Add a quirk for parental filtering and filter results with it
In readiness for an upcoming feature, add a GsApp quirk to indicate
‘this app has been filtered by parental controls’. Apps will typically
be filtered due to their OARS ratings, but in order to keep the policy
flexible (and implementable by different plugins), we do the filtering
on the presence of a quirk.
Completely hide apps which have this quirk, unless they have been
installed already (which we take to mean that the parent has deemed them
acceptable for the system, despite their OARS rating).
Policy changes to set the new quirk will follow eventually.
Signed-off-by: Philip Withnall <withnall endlessm com>
lib/gs-app.h | 2 ++
lib/gs-plugin-loader.c | 9 +++++++++
src/gs-details-page.c | 16 ++++++++++++++++
3 files changed, 27 insertions(+)
---
diff --git a/lib/gs-app.h b/lib/gs-app.h
index f7c7e5b4..fe04601a 100644
--- a/lib/gs-app.h
+++ b/lib/gs-app.h
@@ -97,6 +97,7 @@ typedef enum {
* @GS_APP_QUIRK_IS_PROXY: Is a proxy app that operates on other applications
* @GS_APP_QUIRK_REMOVABLE_HARDWARE: The device is unusable whilst the action is performed
* @GS_APP_QUIRK_DEVELOPER_VERIFIED: The app developer has been verified
+ * @GS_APP_QUIRK_PARENTAL_FILTER: The app has been filtered by parental controls, and should be hidden
*
* The application attributes.
**/
@@ -114,6 +115,7 @@ typedef enum {
GS_APP_QUIRK_IS_PROXY = 1 << 9, /* Since: 3.32 */
GS_APP_QUIRK_REMOVABLE_HARDWARE = 1 << 10, /* Since: 3.32 */
GS_APP_QUIRK_DEVELOPER_VERIFIED = 1 << 11, /* Since: 3.32 */
+ GS_APP_QUIRK_PARENTAL_FILTER = 1 << 12, /* Since: 3.32 */
/*< private >*/
GS_APP_QUIRK_LAST
} GsAppQuirk;
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index cb29f94c..5472fd55 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -1229,6 +1229,15 @@ gs_plugin_loader_app_is_valid (GsApp *app, gpointer user_data)
return FALSE;
}
+ /* Don’t show parentally filtered apps unless they’re already
+ * installed. See the comments in gs-details-page.c for details. */
+ if (!gs_app_is_installed (app) &&
+ gs_app_has_quirk (app, GS_APP_QUIRK_PARENTAL_FILTER)) {
+ g_debug ("app invalid as parentally filtered %s",
+ gs_plugin_loader_get_app_str (app));
+ return FALSE;
+ }
+
/* don't show sources */
if (gs_app_get_kind (app) == AS_APP_KIND_SOURCE) {
g_debug ("app invalid as source %s",
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index d3cf8078..789960c4 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -1696,6 +1696,22 @@ gs_details_page_load_stage1_cb (GObject *source,
return;
}
+ /* Hide the app if it’s not suitable for the user, but only if it’s not
+ * already installed — a parent could have decided that a particular
+ * app *is* actually suitable for their child, despite its age rating.
+ *
+ * Make it look like the app doesn’t exist, to not tantalise the
+ * child. */
+ if (!gs_app_is_installed (self->app) &&
+ gs_app_has_quirk (self->app, GS_APP_QUIRK_PARENTAL_FILTER)) {
+ g_autofree gchar *str = NULL;
+ const gchar *id = gs_app_get_id (self->app);
+ str = g_strdup_printf (_("Unable to find “%s”"), id == NULL ? gs_app_get_source_default
(self->app) : id);
+ gtk_label_set_text (GTK_LABEL (self->label_failed), str);
+ gs_details_page_set_state (self, GS_DETAILS_PAGE_STATE_FAILED);
+ return;
+ }
+
/* do 2nd stage refine */
gs_details_page_load_stage2 (self);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]