[gnome-software] Use a moduleset.d directory other desktops can install into



commit 3959dbf320ceebc4caa93210c328612f31fe766e
Author: Richard Hughes <richard hughsie com>
Date:   Sun Feb 9 15:59:51 2014 +0100

    Use a moduleset.d directory other desktops can install into
    
    This also allows us to reduce the number of plugins installed.

 configure.ac                                       |    1 +
 data/Makefile.am                                   |    6 +-
 data/moduleset-core.xml                            |    8 -
 data/moduleset-gnome-apps.xml                      |   34 -----
 data/modulesets/Makefile.am                        |    6 +
 data/modulesets/base.xml                           |    4 +
 data/modulesets/gnome.xml                          |   60 +++++++++
 data/popular-apps.xml                              |   20 ---
 po/POTFILES.in                                     |    2 +-
 src/gs-self-test.c                                 |    2 +-
 src/plugins/Makefile.am                            |   28 +---
 src/plugins/gs-moduleset.c                         |   67 +++++++---
 src/plugins/gs-moduleset.h                         |    9 +-
 src/plugins/gs-plugin-moduleset-gnome.c            |  138 --------------------
 src/plugins/gs-plugin-moduleset-popular.c          |   19 +--
 ...ugin-moduleset-core.c => gs-plugin-moduleset.c} |  113 ++++++++++++----
 16 files changed, 230 insertions(+), 287 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2248da7..bb51dec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -116,6 +116,7 @@ po/Makefile.in
 data/appdata/Makefile
 data/featured.ini
 data/Makefile
+data/modulesets/Makefile
 data/icons/Makefile
 data/icons/16x16/Makefile
 data/icons/22x22/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index 3daf9c4..819a8db 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,5 +1,6 @@
 SUBDIRS =                                              \
        appdata                                         \
+       modulesets                                      \
        icons
 
 resourcesdir = $(datadir)/gnome-software
@@ -16,10 +17,7 @@ dist_resources_DATA =                                        \
        featured-weather.png                            \
        featured-weather-bg.png                         \
        featured-xchat.png                              \
-       featured.ini                                    \
-       popular-apps.xml                                \
-       moduleset-core.xml                              \
-       moduleset-gnome-apps.xml
+       featured.ini
 
 @GSETTINGS_RULES@
 gsettings_SCHEMAS = org.gnome.software.gschema.xml
diff --git a/data/modulesets/Makefile.am b/data/modulesets/Makefile.am
new file mode 100644
index 0000000..0ba95e4
--- /dev/null
+++ b/data/modulesets/Makefile.am
@@ -0,0 +1,6 @@
+modulesetsdir = $(datadir)/gnome-software/modulesets.d
+dist_modulesets_DATA =                                 \
+       base.xml                                        \
+       gnome.xml
+
+-include $(top_srcdir)/git.mk
diff --git a/data/modulesets/base.xml b/data/modulesets/base.xml
new file mode 100644
index 0000000..32f5c87
--- /dev/null
+++ b/data/modulesets/base.xml
@@ -0,0 +1,4 @@
+<moduleset name="core">
+  <module type="pkgname">kernel</module>
+  <module type="pkgname">glibc</module>
+</moduleset>
diff --git a/data/modulesets/gnome.xml b/data/modulesets/gnome.xml
new file mode 100644
index 0000000..654e7d3
--- /dev/null
+++ b/data/modulesets/gnome.xml
@@ -0,0 +1,60 @@
+<moduleset name="core">
+  <module type="pkgname">glib2</module>
+  <module type="pkgname">gtk3</module>
+</moduleset>
+
+<moduleset name="popular">
+  <module type="application">transmission-gtk.desktop</module>
+  <module type="application">inkscape.desktop</module>
+  <module type="application">scribus.desktop</module>
+  <module type="application">simple-scan.desktop</module>
+  <module type="application">tomboy.desktop</module>
+  <module type="application">gtg.desktop</module>
+  <module type="application">stellarium.desktop</module>
+  <module type="application">gnome-maps.desktop</module>
+  <module type="application">calibre.desktop</module>
+  <module type="application">hotot-gtk.desktop</module>
+  <module type="application">musique.desktop</module>
+  <module type="application">sol.desktop</module>
+  <module type="application">shutter.desktop</module>
+  <module type="application">gnucash.desktop</module>
+  <module type="application">iagno.desktop</module>
+  <module type="application">mozilla-thunderbird.desktop</module>
+  <module type="application">geary.desktop</module>
+  <module type="application">pdfshuffler.desktop</module>
+</moduleset>
+
+<moduleset name="system">
+  <module type="application">baobab.desktop</module>
+  <module type="application">eog.desktop</module>
+  <module type="application">epiphany.desktop</module>
+  <module type="application">evince.desktop</module>
+  <module type="application">empathy.desktop</module>
+  <module type="application">gcalctool.desktop</module>
+  <module type="application">gedit.desktop</module>
+  <module type="application">gnome-bluetooth.desktop</module>
+  <module type="application">gnome-clocks.desktop</module>
+  <module type="application">gnome-contacts.desktop</module>
+  <module type="application">gnome-dictionary.desktop</module>
+  <module type="application">gnome-disks.desktop</module>
+  <module type="application">gnome-eog.desktop</module>
+  <module type="application">gnome-font-viewer.desktop</module>
+  <module type="application">gnome-gucharmap.desktop</module>
+  <module type="application">gnome-keyring.desktop</module>
+  <module type="application">gnome-menus.desktop</module>
+  <module type="application">gnome-packagekit.desktop</module>
+  <module type="application">gnome-screenshot.desktop</module>
+  <module type="application">gnome-session.desktop</module>
+  <module type="application">gnome-software.desktop</module>
+  <module type="application">gnome-system-log.desktop</module>
+  <module type="application">gnome-system-monitor.desktop</module>
+  <module type="application">gnome-terminal.desktop</module>
+  <module type="application">gnome-user-docs.desktop</module>
+  <module type="application">gnome-user-share.desktop</module>
+  <module type="application">gucharmap.desktop</module>
+  <module type="application">nautilus.desktop</module>
+  <module type="application">sushi.desktop</module>
+  <module type="application">totem.desktop</module>
+  <module type="application">vino.desktop</module>
+  <module type="application">yelp.desktop</module>
+</moduleset>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c709bf0..bcbb55d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -28,7 +28,7 @@ src/gs-utils.c
 src/plugins/gs-plugin-appstream.c
 src/plugins/gs-plugin-epiphany.c
 src/plugins/gs-plugin-hardcoded-categories.c
-src/plugins/gs-plugin-hardcoded-popular.c
+src/plugins/gs-plugin-moduleset.c
 src/plugins/gs-plugin-packagekit.c
 src/plugins/gs-plugin-packagekit-refine.c
 src/plugins/menu-spec-common.c
diff --git a/src/gs-self-test.c b/src/gs-self-test.c
index 5d2d775..2f6ec79 100644
--- a/src/gs-self-test.c
+++ b/src/gs-self-test.c
@@ -371,7 +371,7 @@ gs_plugin_loader_func (void)
        g_assert (ret);
        ret = gs_plugin_loader_set_enabled (loader, "hardcoded-kind", TRUE);
        g_assert (ret);
-       ret = gs_plugin_loader_set_enabled (loader, "moduleset-popular", TRUE);
+       ret = gs_plugin_loader_set_enabled (loader, "moduleset", TRUE);
        g_assert (ret);
        ret = gs_plugin_loader_set_enabled (loader, "hardcoded-ratings", TRUE);
        g_assert (ret);
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 380e2c1..12e5cf7 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -10,6 +10,7 @@ AM_CPPFLAGS =                                         \
        $(SQLITE_CFLAGS)                                \
        -DBINDIR=\"$(bindir)\"                          \
        -DDATADIR=\"$(datadir)\"                        \
+       -DGS_MODULESETDIR=\"$(datadir)/gnome-software/modulesets.d\" \
        -DG_LOG_DOMAIN=\"GsPlugin\"                     \
        -DLIBDIR=\""$(libdir)"\"                        \
        -DLOCALSTATEDIR=\""$(localstatedir)"\"          \
@@ -31,10 +32,8 @@ plugin_LTLIBRARIES =                                 \
        libgs_plugin_datadir_filename_local.la          \
        libgs_plugin_desktopdb.la                       \
        libgs_plugin_hardcoded-featured.la              \
-       libgs_plugin_moduleset-core.la                  \
-       libgs_plugin_moduleset-gnome.la                 \
        libgs_plugin_hardcoded-categories.la            \
-       libgs_plugin_moduleset-popular.la               \
+       libgs_plugin_moduleset.la                       \
        libgs_plugin_menu-spec-categories.la            \
        libgs_plugin_menu-spec-refine.la                \
        libgs_plugin_local-ratings.la                   \
@@ -103,26 +102,13 @@ libgs_plugin_appdata_la_LIBADD = $(GS_PLUGIN_LIBS)
 libgs_plugin_appdata_la_LDFLAGS = -module -avoid-version
 libgs_plugin_appdata_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
 
-libgs_plugin_moduleset_gnome_la_SOURCES =              \
+libgs_plugin_moduleset_la_SOURCES =                    \
        gs-moduleset.c                                  \
        gs-moduleset.h                                  \
-       gs-plugin-moduleset-gnome.c
-libgs_plugin_moduleset_gnome_la_LIBADD = $(GS_PLUGIN_LIBS)
-libgs_plugin_moduleset_gnome_la_LDFLAGS = -module -avoid-version
-libgs_plugin_moduleset_gnome_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
-
-libgs_plugin_moduleset_core_la_SOURCES =               \
-       gs-moduleset.c                                  \
-       gs-moduleset.h                                  \
-       gs-plugin-moduleset-core.c
-libgs_plugin_moduleset_core_la_LIBADD = $(GS_PLUGIN_LIBS)
-libgs_plugin_moduleset_core_la_LDFLAGS = -module -avoid-version
-libgs_plugin_moduleset_core_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
-
-libgs_plugin_moduleset_popular_la_SOURCES = gs-plugin-moduleset-popular.c
-libgs_plugin_moduleset_popular_la_LIBADD = $(GS_PLUGIN_LIBS)
-libgs_plugin_moduleset_popular_la_LDFLAGS = -module -avoid-version
-libgs_plugin_moduleset_popular_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
+       gs-plugin-moduleset.c
+libgs_plugin_moduleset_la_LIBADD = $(GS_PLUGIN_LIBS)
+libgs_plugin_moduleset_la_LDFLAGS = -module -avoid-version
+libgs_plugin_moduleset_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
 
 libgs_plugin_hardcoded_categories_la_SOURCES = gs-plugin-hardcoded-categories.c
 libgs_plugin_hardcoded_categories_la_LIBADD = $(GS_PLUGIN_LIBS)
diff --git a/src/plugins/gs-moduleset.c b/src/plugins/gs-moduleset.c
index a3c88f5..3af855e 100644
--- a/src/plugins/gs-moduleset.c
+++ b/src/plugins/gs-moduleset.c
@@ -28,6 +28,7 @@
 
 typedef struct {
        GsModulesetModuleKind    module_kind;
+       gchar                   *name;
        gchar                   *id;
 } GsModulesetEntry;
 
@@ -39,7 +40,7 @@ typedef enum {
 } GsModulesetParserSection;
 
 typedef struct {
-       gchar                   *name;
+       gchar                   *name_tmp;
        GPtrArray               *array;
        GsModulesetEntry        *entry_tmp;
        GsModulesetParserSection section;
@@ -48,20 +49,12 @@ typedef struct {
 G_DEFINE_TYPE_WITH_PRIVATE (GsModuleset, gs_moduleset, G_TYPE_OBJECT)
 
 /**
- * gs_moduleset_get_name:
- **/
-const gchar *
-gs_moduleset_get_name (GsModuleset *moduleset)
-{
-       GsModulesetPrivate *priv = gs_moduleset_get_instance_private (moduleset);
-       return priv->name;
-}
-
-/**
- * gs_moduleset_get_by_kind:
+ * gs_moduleset_get_modules:
  **/
 gchar **
-gs_moduleset_get_by_kind (GsModuleset *moduleset, GsModulesetModuleKind module_kind)
+gs_moduleset_get_modules (GsModuleset *moduleset,
+                         GsModulesetModuleKind module_kind,
+                         const gchar *name)
 {
        GsModulesetPrivate *priv = gs_moduleset_get_instance_private (moduleset);
        GsModulesetEntry *entry;
@@ -75,8 +68,11 @@ gs_moduleset_get_by_kind (GsModuleset *moduleset, GsModulesetModuleKind module_k
        data = g_new0 (gchar *, priv->array->len);
        for (i = 0; i < priv->array->len; i++) {
                entry = g_ptr_array_index (priv->array, i);
-               if (entry->module_kind == module_kind)
-                       data[idx++] = g_strdup (entry->id);
+               if (entry->module_kind != module_kind)
+                       continue;
+               if (g_strcmp0 (entry->name, name) != 0)
+                       continue;
+               data[idx++] = g_strdup (entry->id);
        }
 
        return data;
@@ -134,8 +130,8 @@ gs_moduleset_parser_start_element (GMarkupParseContext *context,
                if (section_new == GS_MODULESET_PARSER_SECTION_MODULESET) {
                        for (i = 0; attribute_names[i] != NULL; i++) {
                                if (g_strcmp0 (attribute_names[i], "name") == 0) {
-                                       g_free (priv->name);
-                                       priv->name = g_strdup (attribute_values[i]);
+                                       g_free (priv->name_tmp);
+                                       priv->name_tmp = g_strdup (attribute_values[i]);
                                }
                        }
                        priv->section = section_new;
@@ -147,6 +143,7 @@ gs_moduleset_parser_start_element (GMarkupParseContext *context,
                if (section_new == GS_MODULESET_PARSER_SECTION_MODULE) {
                        priv->section = section_new;
                        priv->entry_tmp = g_slice_new0 (GsModulesetEntry);
+                       priv->entry_tmp->name = g_strdup (priv->name_tmp);
                        for (i = 0; attribute_names[i] != NULL; i++) {
                                if (g_strcmp0 (attribute_names[i], "type") == 0) {
                                        kind = gs_moduleset_module_kind_from_string (attribute_values[i]);
@@ -178,6 +175,8 @@ gs_moduleset_parser_end_element (GMarkupParseContext *context,
        switch (priv->section) {
        case GS_MODULESET_PARSER_SECTION_MODULESET:
                priv->section = GS_MODULESET_PARSER_SECTION_UNKNOWN;
+               g_free (priv->name_tmp);
+               priv->name_tmp = NULL;
                break;
        case GS_MODULESET_PARSER_SECTION_MODULE:
                priv->section = GS_MODULESET_PARSER_SECTION_MODULESET;
@@ -248,10 +247,43 @@ out:
        return ret;
 }
 
+/**
+ * gs_moduleset_parse_path:
+ **/
+gboolean
+gs_moduleset_parse_path (GsModuleset *moduleset, const gchar *path, GError **error)
+{
+       GDir *dir;
+       gboolean ret = TRUE;
+       const gchar *filename;
+       gchar *tmp;
+
+       /* search all the files in the path */
+       dir = g_dir_open (path, 0, error);
+       if (dir == NULL) {
+               ret = FALSE;
+               goto out;
+       }
+       while ((filename = g_dir_read_name (dir)) != NULL) {
+               if (!g_str_has_suffix (filename, ".xml"))
+                       continue;
+               tmp = g_build_filename (path, filename, NULL);
+               ret = gs_moduleset_parse_filename (moduleset, tmp, error);
+               g_free (tmp);
+               if (!ret)
+                       goto out;
+       }
+out:
+       if (dir != NULL)
+               g_dir_close (dir);
+       return ret;
+}
+
 static void
 gs_moduleset_entry_free (GsModulesetEntry *entry)
 {
        g_free (entry->id);
+       g_free (entry->name);
        g_slice_free (GsModulesetEntry, entry);
 }
 
@@ -266,7 +298,6 @@ gs_moduleset_finalize (GObject *object)
        moduleset = GS_MODULESET (object);
        priv = gs_moduleset_get_instance_private (moduleset);
        g_ptr_array_unref (priv->array);
-       g_free (priv->name);
 
        G_OBJECT_CLASS (gs_moduleset_parent_class)->finalize (object);
 }
diff --git a/src/plugins/gs-moduleset.h b/src/plugins/gs-moduleset.h
index 069c26a..5860f8b 100644
--- a/src/plugins/gs-moduleset.h
+++ b/src/plugins/gs-moduleset.h
@@ -49,12 +49,15 @@ typedef enum {
 GType           gs_moduleset_get_type                  (void);
 GsModuleset    *gs_moduleset_new                       (void);
 
-const gchar    *gs_moduleset_get_name                  (GsModuleset            *moduleset);
-gchar          **gs_moduleset_get_by_kind              (GsModuleset            *moduleset,
-                                                        GsModulesetModuleKind   module_kind);
+gchar          **gs_moduleset_get_modules              (GsModuleset            *moduleset,
+                                                        GsModulesetModuleKind   module_kind,
+                                                        const gchar            *name);
 gboolean        gs_moduleset_parse_filename            (GsModuleset            *moduleset,
                                                         const gchar            *filename,
                                                         GError                 **error);
+gboolean        gs_moduleset_parse_path                (GsModuleset            *moduleset,
+                                                        const gchar            *path,
+                                                        GError                 **error);
 
 G_END_DECLS
 
diff --git a/src/plugins/gs-plugin-moduleset-popular.c b/src/plugins/gs-plugin-moduleset-popular.c
index b6e0647..bd4e0fc 100644
--- a/src/plugins/gs-plugin-moduleset-popular.c
+++ b/src/plugins/gs-plugin-moduleset-popular.c
@@ -1,6 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  *
- * Copyright (C) 2011-2013 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2011-2014 Richard Hughes <richard hughsie com>
  * Copyright (C) 2013 Matthias Clasen <mclasen redhat com>
  *
  * Licensed under the GNU General Public License Version 2
@@ -69,21 +69,15 @@ static gboolean
 gs_plugin_startup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
 {
        gboolean ret;
-       gchar *filename;
 
        /* Parse the XML */
        gs_profile_start (plugin->profile, "moduleset-popular::startup");
-       filename = g_build_filename (DATADIR,
-                                    "gnome-software",
-                                    "popular-apps.xml",
-                                    NULL);
-       ret = gs_moduleset_parse_filename (plugin->priv->moduleset,
-                                          filename,
-                                          error);
+       ret = gs_moduleset_parse_path (plugin->priv->moduleset,
+                                      GS_MODULESETDIR,
+                                      error);
        if (!ret)
                goto out;
 out:
-       g_free (filename);
        gs_profile_stop (plugin->profile, "moduleset-popular::startup");
        return ret;
 }
@@ -113,8 +107,9 @@ gs_plugin_add_popular (GsPlugin *plugin,
        if (g_getenv ("GNOME_SOFTWARE_POPULAR")) {
                apps = g_strsplit (g_getenv ("GNOME_SOFTWARE_POPULAR"), ",", 0);
        } else {
-               apps = gs_moduleset_get_by_kind (plugin->priv->moduleset,
-                                                GS_MODULESET_MODULE_KIND_APPLICATION);
+               apps = gs_moduleset_get_modules (plugin->priv->moduleset,
+                                                GS_MODULESET_MODULE_KIND_APPLICATION,
+                                                "popular");
        }
 
        /* just add all */
diff --git a/src/plugins/gs-plugin-moduleset-core.c b/src/plugins/gs-plugin-moduleset.c
similarity index 57%
rename from src/plugins/gs-plugin-moduleset-core.c
rename to src/plugins/gs-plugin-moduleset.c
index 9188dbe..4b90814 100644
--- a/src/plugins/gs-plugin-moduleset-core.c
+++ b/src/plugins/gs-plugin-moduleset.c
@@ -1,6 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  *
- * Copyright (C) 2013-2014 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2011-2014 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2013 Matthias Clasen <mclasen redhat com>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -21,7 +22,10 @@
 
 #include <config.h>
 
+#include <glib/gi18n.h>
+
 #include <gs-plugin.h>
+#include <gs-category.h>
 
 #include "gs-moduleset.h"
 
@@ -36,7 +40,20 @@ struct GsPluginPrivate {
 const gchar *
 gs_plugin_get_name (void)
 {
-       return "moduleset-core";
+       return "moduleset";
+}
+
+/**
+ * gs_plugin_get_deps:
+ */
+const gchar **
+gs_plugin_get_deps (GsPlugin *plugin)
+{
+       static const gchar *deps[] = {
+               "appstream",            /* requires id */
+               "packagekit",           /* pkgname */
+               NULL };
+       return deps;
 }
 
 /**
@@ -59,40 +76,63 @@ gs_plugin_destroy (GsPlugin *plugin)
 }
 
 /**
- * gs_plugin_get_deps:
- */
-const gchar **
-gs_plugin_get_deps (GsPlugin *plugin)
-{
-       static const gchar *deps[] = {
-               "packagekit",           /* pkgname */
-               NULL };
-       return deps;
-}
-
-/**
  * gs_plugin_startup:
  */
 static gboolean
 gs_plugin_startup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
 {
        gboolean ret;
-       gchar *filename;
 
        /* Parse the XML */
-       gs_profile_start (plugin->profile, "moduleset-core::startup");
-       filename = g_build_filename (DATADIR,
-                                    "gnome-software",
-                                    "moduleset-core.xml",
-                                    NULL);
-       ret = gs_moduleset_parse_filename (plugin->priv->moduleset,
-                                          filename,
-                                          error);
+       gs_profile_start (plugin->profile, "moduleset::startup");
+       ret = gs_moduleset_parse_path (plugin->priv->moduleset,
+                                      GS_MODULESETDIR,
+                                      error);
        if (!ret)
                goto out;
 out:
-       g_free (filename);
-       gs_profile_stop (plugin->profile, "moduleset-core::startup");
+       gs_profile_stop (plugin->profile, "moduleset::startup");
+       return ret;
+}
+
+/**
+ * gs_plugin_add_popular:
+ */
+gboolean
+gs_plugin_add_popular (GsPlugin *plugin,
+                      GList **list,
+                      GCancellable *cancellable,
+                      GError **error)
+{
+       GsApp *app;
+       gboolean ret = TRUE;
+       gchar **apps = NULL;
+       guint i;
+
+       /* load XML files */
+       if (g_once_init_enter (&plugin->priv->done_init)) {
+               ret = gs_plugin_startup (plugin, cancellable, error);
+               g_once_init_leave (&plugin->priv->done_init, TRUE);
+               if (!ret)
+                       goto out;
+       }
+
+       if (g_getenv ("GNOME_SOFTWARE_POPULAR")) {
+               apps = g_strsplit (g_getenv ("GNOME_SOFTWARE_POPULAR"), ",", 0);
+       } else {
+               apps = gs_moduleset_get_modules (plugin->priv->moduleset,
+                                                GS_MODULESET_MODULE_KIND_APPLICATION,
+                                                "popular");
+       }
+
+       /* just add all */
+       for (i = 0; apps[i]; i++) {
+               app = gs_app_new (apps[i]);
+               gs_plugin_add_app (list, app);
+               g_object_unref (app);
+       }
+out:
+       g_strfreev (apps);
        return ret;
 }
 
@@ -109,6 +149,7 @@ gs_plugin_refine (GsPlugin *plugin,
        GList *l;
        GsApp *app;
        gboolean ret = TRUE;
+       gchar **apps = NULL;
        gchar **pkgs = NULL;
        guint i;
 
@@ -121,8 +162,23 @@ gs_plugin_refine (GsPlugin *plugin,
        }
 
        /* just mark each one as core */
-       pkgs = gs_moduleset_get_by_kind (plugin->priv->moduleset,
-                                        GS_MODULESET_MODULE_KIND_PACKAGE);
+       apps = gs_moduleset_get_modules (plugin->priv->moduleset,
+                                        GS_MODULESET_MODULE_KIND_APPLICATION,
+                                        "system");
+       for (l = *list; l != NULL; l = l->next) {
+               app = GS_APP (l->data);
+               for (i = 0; apps[i] != NULL; i++) {
+                       if (g_strcmp0 (apps[i], gs_app_get_id_full (app)) == 0) {
+                               gs_app_set_kind (app, GS_APP_KIND_SYSTEM);
+                               break;
+                       }
+               }
+       }
+
+       /* just mark each one as core */
+       pkgs = gs_moduleset_get_modules (plugin->priv->moduleset,
+                                        GS_MODULESET_MODULE_KIND_PACKAGE,
+                                        "core");
        for (l = *list; l != NULL; l = l->next) {
                app = GS_APP (l->data);
                for (i = 0; pkgs[i] != NULL; i++) {
@@ -133,6 +189,9 @@ gs_plugin_refine (GsPlugin *plugin,
                }
        }
 out:
+       g_strfreev (apps);
        g_strfreev (pkgs);
        return ret;
 }
+
+/* vim: set noexpandtab: */


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