[gnome-software] Move the application blacklist data to a plugin
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Move the application blacklist data to a plugin
- Date: Mon, 18 Jan 2016 11:28:52 +0000 (UTC)
commit 8569b85ba986079cb8b87e4e598a3492428927c0
Author: Richard Hughes <richard hughsie com>
Date: Sun Jan 17 19:47:20 2016 +0000
Move the application blacklist data to a plugin
This has been removed from libappstream-glib.
src/gs-plugin-loader.c | 7 ++
src/plugins/Makefile.am | 6 ++
src/plugins/gs-plugin-hardcoded-blacklist.c | 110 +++++++++++++++++++++++++++
3 files changed, 123 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index d938d27..b0a2f16 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -542,6 +542,13 @@ gs_plugin_loader_app_is_valid (GsApp *app, gpointer user_data)
return FALSE;
}
+ /* don't show blacklisted apps */
+ if (gs_app_has_category (app, "Blacklisted")) {
+ g_debug ("app invalid as blacklisted %s",
+ gs_plugin_loader_get_app_str (app));
+ return FALSE;
+ }
+
/* don't show sources */
if (gs_app_get_kind (app) == GS_APP_KIND_SOURCE) {
g_debug ("app invalid as source %s",
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index ea59daa..d215463 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -30,6 +30,7 @@ plugindir = $(libdir)/gs-plugins-${GS_PLUGIN_API_VERSION}
plugin_LTLIBRARIES = \
libgs_plugin_appstream.la \
libgs_plugin_hardcoded-featured.la \
+ libgs_plugin_hardcoded-blacklist.la \
libgs_plugin_moduleset.la \
libgs_plugin_menu-spec-categories.la \
libgs_plugin_menu-spec-refine.la \
@@ -133,6 +134,11 @@ libgs_plugin_hardcoded_featured_la_LIBADD = $(GS_PLUGIN_LIBS)
libgs_plugin_hardcoded_featured_la_LDFLAGS = -module -avoid-version
libgs_plugin_hardcoded_featured_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARN_CFLAGS)
+libgs_plugin_hardcoded_blacklist_la_SOURCES = gs-plugin-hardcoded-blacklist.c
+libgs_plugin_hardcoded_blacklist_la_LIBADD = $(GS_PLUGIN_LIBS)
+libgs_plugin_hardcoded_blacklist_la_LDFLAGS = -module -avoid-version
+libgs_plugin_hardcoded_blacklist_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARN_CFLAGS)
+
libgs_plugin_local_ratings_la_SOURCES = gs-plugin-local-ratings.c
libgs_plugin_local_ratings_la_LIBADD = $(GS_PLUGIN_LIBS) $(SQLITE_LIBS)
libgs_plugin_local_ratings_la_LDFLAGS = -module -avoid-version
diff --git a/src/plugins/gs-plugin-hardcoded-blacklist.c b/src/plugins/gs-plugin-hardcoded-blacklist.c
new file mode 100644
index 0000000..2a27de4
--- /dev/null
+++ b/src/plugins/gs-plugin-hardcoded-blacklist.c
@@ -0,0 +1,110 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2016 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <config.h>
+#include <fnmatch.h>
+#include <gs-plugin.h>
+
+/*
+ * SECTION:
+ * Blacklists some applications based on a hardcoded list.
+ */
+
+/**
+ * gs_plugin_get_name:
+ */
+const gchar *
+gs_plugin_get_name (void)
+{
+ return "hardcoded-blacklist";
+}
+
+/**
+ * gs_plugin_get_deps:
+ */
+const gchar **
+gs_plugin_get_deps (GsPlugin *plugin)
+{
+ static const gchar *deps[] = {
+ "appstream", /* need ID */
+ NULL };
+ return deps;
+}
+
+/**
+ * gs_plugin_refine_app:
+ */
+static gboolean
+gs_plugin_refine_app (GsPlugin *plugin, GsApp *app, GError **error)
+{
+ guint i;
+ const gchar *app_globs[] = {
+ "freeciv-server.desktop",
+ "nm-connection-editor.desktop",
+ "plank.desktop",
+ "*release-notes*.desktop",
+ "*Release_Notes*.desktop",
+ "remote-viewer.desktop",
+ "Rodent-*.desktop",
+ "rygel-preferences.desktop",
+ "system-config-keyboard.desktop",
+ "tracker-preferences.desktop",
+ "Uninstall*.desktop",
+ NULL };
+
+ /* not set yet */
+ if (gs_app_get_id (app) == NULL)
+ return TRUE;
+
+ /* search */
+ for (i = 0; app_globs[i] != NULL; i++) {
+ if (fnmatch (app_globs[i], gs_app_get_id (app), 0) == 0) {
+ gs_app_add_category (app, "Blacklisted");
+ break;
+ }
+ }
+
+ return TRUE;
+}
+
+/**
+ * gs_plugin_refine:
+ */
+gboolean
+gs_plugin_refine (GsPlugin *plugin,
+ GList **list,
+ GsPluginRefineFlags flags,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GList *l;
+ GsApp *app;
+ g_autoptr(AsProfileTask) ptask = NULL;
+
+ /* are any of the packages on the blacklist? */
+ ptask = as_profile_start_literal (plugin->profile, "hardcoded-blacklist");
+ for (l = *list; l != NULL; l = l->next) {
+ app = GS_APP (l->data);
+ if (!gs_plugin_refine_app (plugin, app, error))
+ return FALSE;
+ }
+ return TRUE;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]