[gnome-software] Allow plugins to conflict with each other
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Allow plugins to conflict with each other
- Date: Fri, 25 Mar 2016 09:54:15 +0000 (UTC)
commit c99ff29f379e7736d5c33d14f38d2c5359ad8560
Author: Richard Hughes <richard hughsie com>
Date: Thu Mar 24 20:14:39 2016 +0000
Allow plugins to conflict with each other
The plugin defining the conflict is prefered, and if mutual then the lower
priority plugin is automatically disabled.
src/gs-plugin-loader.c | 25 +++++++++++++++++++++++++
src/gs-plugin.h | 2 ++
src/plugins/gs-plugin-ostree.c | 19 +++++++++++++++++++
src/plugins/gs-plugin-ubuntu-reviews.c | 12 ++++++++++++
4 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 292c8a9..2e271b8 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -2907,6 +2907,7 @@ gs_plugin_loader_open_plugin (GsPluginLoader *plugin_loader,
GModule *module;
GsPluginGetNameFunc plugin_name = NULL;
GsPluginGetDepsFunc plugin_deps = NULL;
+ GsPluginGetDepsFunc plugin_conflicts = NULL;
GsPlugin *plugin = NULL;
module = g_module_open (filename, 0);
@@ -2930,6 +2931,9 @@ gs_plugin_loader_open_plugin (GsPluginLoader *plugin_loader,
(void) g_module_symbol (module,
"gs_plugin_get_deps",
(gpointer *) &plugin_deps);
+ g_module_symbol (module,
+ "gs_plugin_get_conflicts",
+ (gpointer *) &plugin_conflicts);
/* print what we know */
plugin = g_slice_new0 (GsPlugin);
@@ -2938,6 +2942,7 @@ gs_plugin_loader_open_plugin (GsPluginLoader *plugin_loader,
plugin->pixbuf_size = 64;
plugin->priority = 0.f;
plugin->deps = plugin_deps != NULL ? plugin_deps (plugin) : NULL;
+ plugin->conflicts = plugin_conflicts != NULL ? plugin_conflicts (plugin) : NULL;
plugin->name = g_strdup (plugin_name ());
plugin->locale = priv->locale;
plugin->status_update_fn = gs_plugin_loader_status_update_cb;
@@ -3125,6 +3130,26 @@ gs_plugin_loader_setup (GsPluginLoader *plugin_loader, GError **error)
/* run the plugins */
gs_plugin_loader_run (plugin_loader, "gs_plugin_initialize");
+ /* check for conflicts */
+ for (i = 0; i < priv->plugins->len; i++) {
+ plugin = g_ptr_array_index (priv->plugins, i);
+ if (!plugin->enabled)
+ continue;
+ if (plugin->conflicts == NULL)
+ continue;
+ for (j = 0; plugin->conflicts[j] != NULL && !changes; j++) {
+ dep = gs_plugin_loader_find_plugin (plugin_loader,
+ plugin->conflicts[j]);
+ if (dep == NULL)
+ continue;
+ if (!dep->enabled)
+ continue;
+ g_debug ("disabling %s as conflicts with %s",
+ dep->name, plugin->name);
+ dep->enabled = FALSE;
+ }
+ }
+
/* now we can load the install-queue */
if (!load_install_queue (plugin_loader, error))
return FALSE;
diff --git a/src/gs-plugin.h b/src/gs-plugin.h
index 6955bf5..c76c9b5 100644
--- a/src/gs-plugin.h
+++ b/src/gs-plugin.h
@@ -65,6 +65,7 @@ struct GsPlugin {
GModule *module;
gdouble priority; /* largest number gets run first */
const gchar **deps; /* allow-none */
+ const gchar **conflicts; /* allow-none */
gboolean enabled;
gchar *name;
GsPluginPrivate *priv;
@@ -220,6 +221,7 @@ gboolean gs_plugin_add_search_what_provides (GsPlugin *plugin,
GCancellable *cancellable,
GError **error);
const gchar **gs_plugin_get_deps (GsPlugin *plugin);
+const gchar **gs_plugin_get_conflicts (GsPlugin *plugin);
gboolean gs_plugin_add_installed (GsPlugin *plugin,
GList **list,
GCancellable *cancellable,
diff --git a/src/plugins/gs-plugin-ostree.c b/src/plugins/gs-plugin-ostree.c
index 7d4ad2b..b923733 100644
--- a/src/plugins/gs-plugin-ostree.c
+++ b/src/plugins/gs-plugin-ostree.c
@@ -58,6 +58,25 @@ gs_plugin_initialize (GsPlugin *plugin)
}
/**
+ * gs_plugin_get_conflicts:
+ */
+const gchar **
+gs_plugin_get_conflicts (GsPlugin *plugin)
+{
+ static const gchar *deps[] = {
+ "packagekit",
+ "packagekit-history",
+ "packagekit-offline",
+ "packagekit-origin",
+ "packagekit-proxy",
+ "packagekit-refine",
+ "packagekit-refresh",
+ "systemd-updates",
+ NULL };
+ return deps;
+}
+
+/**
* gs_plugin_destroy:
*/
void
diff --git a/src/plugins/gs-plugin-ubuntu-reviews.c b/src/plugins/gs-plugin-ubuntu-reviews.c
index 79f0239..02d783a 100644
--- a/src/plugins/gs-plugin-ubuntu-reviews.c
+++ b/src/plugins/gs-plugin-ubuntu-reviews.c
@@ -84,6 +84,18 @@ gs_plugin_get_deps (GsPlugin *plugin)
return deps;
}
+/**
+ * gs_plugin_get_conflicts:
+ */
+const gchar **
+gs_plugin_get_conflicts (GsPlugin *plugin)
+{
+ static const gchar *deps[] = {
+ "odrs",
+ NULL };
+ return deps;
+}
+
void
gs_plugin_destroy (GsPlugin *plugin)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]