[gnome-software/gnome-3-20] Allow the provenance plugin to accept a glob
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-20] Allow the provenance plugin to accept a glob
- Date: Thu, 14 Apr 2016 17:28:49 +0000 (UTC)
commit eb4c860ddca5464ed824cb3b7098994d3e583cbd
Author: Richard Hughes <richard hughsie com>
Date: Thu Apr 14 12:15:21 2016 +0100
Allow the provenance plugin to accept a glob
This makes it more suitable for use in Ubuntu.
src/plugins/gs-plugin-provenance.c | 37 +++++++++++++++++++++++++++--------
1 files changed, 28 insertions(+), 9 deletions(-)
---
diff --git a/src/plugins/gs-plugin-provenance.c b/src/plugins/gs-plugin-provenance.c
index 5f70a36..48a0be7 100644
--- a/src/plugins/gs-plugin-provenance.c
+++ b/src/plugins/gs-plugin-provenance.c
@@ -21,6 +21,8 @@
#include <config.h>
+#include <fnmatch.h>
+
#include <gs-plugin.h>
/*
@@ -95,17 +97,36 @@ gs_plugin_destroy (GsPlugin *plugin)
}
/**
+ * gs_utils_strv_fnmatch:
+ */
+static gboolean
+gs_utils_strv_fnmatch (gchar **strv, const gchar *str)
+{
+ guint i;
+
+ /* empty */
+ if (strv == NULL)
+ return FALSE;
+
+ /* look at each one */
+ for (i = 0; strv[i] != NULL; i++) {
+ if (fnmatch (strv[i], str, 0) == 0)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/**
* gs_plugin_provenance_refine_app:
*/
static void
gs_plugin_provenance_refine_app (GsPlugin *plugin, GsApp *app)
{
const gchar *origin;
- const gchar * const *sources;
- guint i;
+ gchar **sources;
/* nothing to search */
- sources = (const gchar * const *) plugin->priv->sources;
+ sources = plugin->priv->sources;
if (sources == NULL || sources[0] == NULL) {
gs_app_add_quirk (app, AS_APP_QUIRK_PROVENANCE);
return;
@@ -113,7 +134,7 @@ gs_plugin_provenance_refine_app (GsPlugin *plugin, GsApp *app)
/* simple case */
origin = gs_app_get_origin (app);
- if (origin != NULL && g_strv_contains (sources, origin)) {
+ if (origin != NULL && gs_utils_strv_fnmatch (sources, origin)) {
gs_app_add_quirk (app, AS_APP_QUIRK_PROVENANCE);
return;
}
@@ -127,11 +148,9 @@ gs_plugin_provenance_refine_app (GsPlugin *plugin, GsApp *app)
return;
if (g_str_has_prefix (origin + 1, "installed:"))
origin += 10;
- for (i = 0; sources[i] != NULL; i++) {
- if (g_strcmp0 (origin + 1, sources[i]) == 0) {
- gs_app_add_quirk (app, AS_APP_QUIRK_PROVENANCE);
- break;
- }
+ if (gs_utils_strv_fnmatch (sources, origin + 1)) {
+ gs_app_add_quirk (app, AS_APP_QUIRK_PROVENANCE);
+ return;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]