[gnome-software: 5/9] gs-app: Store a weak pointer to the GsPlugin rather than the plugin name




commit 83f5653b2bf627e3956b831991b724cca1be7298
Author: Philip Withnall <pwithnall endlessos org>
Date:   Tue Nov 23 16:24:31 2021 +0000

    gs-app: Store a weak pointer to the GsPlugin rather than the plugin name
    
    This removes a lot of `g_strcmp0()` calls in all the plugin functions. I
    haven’t measured the performance improvement. It’s not likely to be
    large, but anything is good.
    
    More importantly, this means that the `GsPlugin` for a `GsApp` can now
    be accessed without having to have a pointer to the `GsPluginLoader` to
    look it up.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 doc/api/gnome-software-docs.xml                    |  4 +-
 lib/gs-app.c                                       | 75 ++++++++++++++--------
 lib/gs-app.h                                       |  9 ++-
 lib/gs-plugin-loader.c                             | 24 +++----
 plugins/core/gs-plugin-generic-updates.c           |  2 +-
 plugins/dummy/gs-plugin-dummy.c                    | 47 ++++++--------
 plugins/dummy/gs-self-test.c                       | 22 +++++--
 plugins/eos-updater/gs-plugin-eos-updater.c        |  5 +-
 .../gs-plugin-fedora-pkgdb-collections.c           |  2 +-
 plugins/flatpak/gs-flatpak-utils.c                 |  2 +-
 plugins/flatpak/gs-flatpak.c                       |  5 +-
 plugins/flatpak/gs-plugin-flatpak.c                | 12 ++--
 plugins/flatpak/gs-self-test.c                     | 32 ++++++---
 plugins/fwupd/gs-plugin-fwupd.c                    | 25 +++-----
 .../packagekit/gs-plugin-packagekit-refine-repos.c |  2 +-
 plugins/packagekit/gs-plugin-packagekit-refresh.c  |  4 +-
 plugins/packagekit/gs-plugin-packagekit.c          | 55 ++++++++--------
 plugins/packagekit/gs-plugin-systemd-updates.c     |  9 +--
 plugins/packagekit/packagekit-common.c             |  4 +-
 plugins/rpm-ostree/gs-plugin-rpm-ostree.c          | 41 ++++++------
 plugins/snap/gs-plugin-snap.c                      | 16 ++---
 src/gs-application.c                               | 22 ++++---
 src/gs-common.c                                    |  4 +-
 src/gs-repo-row.c                                  |  4 +-
 src/gs-repos-dialog.c                              | 12 +++-
 src/gs-shell.c                                     |  2 +-
 26 files changed, 248 insertions(+), 193 deletions(-)
---
diff --git a/doc/api/gnome-software-docs.xml b/doc/api/gnome-software-docs.xml
index a96fd65ab..fbff82664 100644
--- a/doc/api/gnome-software-docs.xml
+++ b/doc/api/gnome-software-docs.xml
@@ -202,7 +202,7 @@ gs_plugin_add_installed (GsPlugin *plugin,
 
   /* the trigger exists, so create a fake app */
   app = gs_app_new ("chiron.desktop");
-  gs_app_set_management_plugin (app, "example");
+  gs_app_set_management_plugin (app, plugin);
   gs_app_set_kind (app, AS_COMPONENT_KIND_DESKTOP_APP);
   gs_app_set_state (app, GS_APP_STATE_INSTALLED);
   gs_app_set_name (app, GS_APP_QUALITY_NORMAL, "Chiron");
@@ -533,7 +533,7 @@ void
 gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
 {
   if (gs_app_get_kind (app) == AS_COMPONENT_KIND_FIRMWARE)
-    gs_app_set_management_plugin (app, "fwupd");
+    gs_app_set_management_plugin (app, plugin);
 }
           </programlisting>
         </informalexample>
diff --git a/lib/gs-app.c b/lib/gs-app.c
index 1e7ab7e22..6e5af3f07 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -94,7 +94,7 @@ typedef struct
        gchar                   *update_details_markup;
        AsUrgencyKind            update_urgency;
        GsAppPermissions         update_permissions;
-       gchar                   *management_plugin;
+       GWeakRef                 management_plugin_weak;  /* (element-type GsPlugin) */
        guint                    match_value;
        guint                    priority;
        gint                     rating;
@@ -518,6 +518,7 @@ gs_app_to_string_append (GsApp *app, GString *str)
        GList *keys;
        const gchar *tmp;
        guint i;
+       g_autoptr(GsPlugin) management_plugin = NULL;
 
        g_return_if_fail (GS_IS_APP (app));
        g_return_if_fail (str != NULL);
@@ -636,8 +637,9 @@ gs_app_to_string_append (GsApp *app, GString *str)
                gs_app_kv_lpad (str, "license-is-free",
                                gs_app_get_license_is_free (app) ? "yes" : "no");
        }
-       if (priv->management_plugin != NULL)
-               gs_app_kv_lpad (str, "management-plugin", priv->management_plugin);
+       management_plugin = g_weak_ref_get (&priv->management_plugin_weak);
+       if (management_plugin != NULL)
+               gs_app_kv_lpad (str, "management-plugin", gs_plugin_get_name (management_plugin));
        if (priv->summary_missing != NULL)
                gs_app_kv_lpad (str, "summary-missing", priv->summary_missing);
        if (priv->menu_path != NULL &&
@@ -3207,48 +3209,70 @@ gs_app_set_update_urgency (GsApp *app, AsUrgencyKind update_urgency)
 }
 
 /**
- * gs_app_get_management_plugin:
+ * gs_app_dup_management_plugin:
  * @app: a #GsApp
  *
  * Gets the management plugin.
- * This is some metadata about the application which is used to work out
- * which plugin should handle the install, remove or upgrade actions.
  *
- * Typically plugins will just set this to the plugin name using
- * gs_plugin_get_name().
+ * This is some metadata about the application which gives which plugin should
+ * handle the install, remove or upgrade actions.
  *
- * Returns: a string, or %NULL for unset
+ * Returns: (nullable) (transfer full): the management plugin, or %NULL for unset
  *
- * Since: 3.22
+ * Since: 42
  **/
-const gchar *
-gs_app_get_management_plugin (GsApp *app)
+GsPlugin *
+gs_app_dup_management_plugin (GsApp *app)
 {
        GsAppPrivate *priv = gs_app_get_instance_private (app);
        g_return_val_if_fail (GS_IS_APP (app), NULL);
-       return priv->management_plugin;
+       return g_weak_ref_get (&priv->management_plugin_weak);
+}
+
+/**
+ * gs_app_has_management_plugin:
+ * @app: a #GsApp
+ * @plugin: (nullable) (transfer none): a #GsPlugin to check against, or %NULL
+ *
+ * Check whether the management plugin for @app is set to @plugin.
+ *
+ * If @plugin is %NULL, %TRUE is returned only if the @app has no management
+ * plugin set.
+ *
+ * Returns: %TRUE if @plugin is the management plugin for @app, %FALSE otherwise
+ * Since: 42
+ */
+gboolean
+gs_app_has_management_plugin (GsApp    *app,
+                              GsPlugin *plugin)
+{
+       g_autoptr(GsPlugin) app_plugin = gs_app_dup_management_plugin (app);
+       return (app_plugin == plugin);
 }
 
 /**
  * gs_app_set_management_plugin:
  * @app: a #GsApp
- * @management_plugin: a string, or %NULL, e.g. "fwupd"
+ * @management_plugin: (nullable) (transfer none): a plugin, or %NULL
  *
  * The management plugin is the plugin that can handle doing install and remove
  * operations on the #GsApp.
- * Typical values include "packagekit" and "flatpak"
  *
  * It is an error to attempt to change the management plugin once it has been
  * previously set or to try to use this function on a wildcard application.
  *
- * Since: 3.22
+ * Since: 42
  **/
 void
-gs_app_set_management_plugin (GsApp *app, const gchar *management_plugin)
+gs_app_set_management_plugin (GsApp    *app,
+                              GsPlugin *management_plugin)
 {
        GsAppPrivate *priv = gs_app_get_instance_private (app);
        g_autoptr(GMutexLocker) locker = NULL;
+       g_autoptr(GsPlugin) old_plugin = NULL;
+
        g_return_if_fail (GS_IS_APP (app));
+       g_return_if_fail (management_plugin == NULL || GS_IS_PLUGIN (management_plugin));
 
        locker = g_mutex_locker_new (&priv->mutex);
 
@@ -3257,26 +3281,27 @@ gs_app_set_management_plugin (GsApp *app, const gchar *management_plugin)
                g_warning ("plugins should not set the management plugin on "
                           "%s to %s -- create a new GsApp in refine()!",
                           gs_app_get_unique_id_unlocked (app),
-                          management_plugin);
+                          (management_plugin != NULL) ? gs_plugin_get_name (management_plugin) : "(null)");
                return;
        }
 
        /* same */
-       if (g_strcmp0 (priv->management_plugin, management_plugin) == 0)
+       old_plugin = g_weak_ref_get (&priv->management_plugin_weak);
+
+       if (old_plugin == management_plugin)
                return;
 
        /* trying to change */
-       if (priv->management_plugin != NULL && management_plugin != NULL) {
+       if (old_plugin != NULL && management_plugin != NULL) {
                g_warning ("automatically prevented from changing "
                           "management plugin on %s from %s to %s!",
                           gs_app_get_unique_id_unlocked (app),
-                          priv->management_plugin,
-                          management_plugin);
+                          gs_plugin_get_name (old_plugin),
+                          gs_plugin_get_name (management_plugin));
                return;
        }
 
-       g_free (priv->management_plugin);
-       priv->management_plugin = g_strdup (management_plugin);
+       g_weak_ref_set (&priv->management_plugin_weak, management_plugin);
 }
 
 /**
@@ -5092,6 +5117,7 @@ gs_app_dispose (GObject *object)
        g_clear_pointer (&priv->icons, g_ptr_array_unref);
        g_clear_pointer (&priv->version_history, g_ptr_array_unref);
        g_clear_pointer (&priv->relations, g_ptr_array_unref);
+       g_weak_ref_clear (&priv->management_plugin_weak);
 
        G_OBJECT_CLASS (gs_app_parent_class)->dispose (object);
 }
@@ -5130,7 +5156,6 @@ gs_app_finalize (GObject *object)
        g_free (priv->update_version);
        g_free (priv->update_version_ui);
        g_free (priv->update_details_markup);
-       g_free (priv->management_plugin);
        g_hash_table_unref (priv->metadata);
        g_ptr_array_unref (priv->categories);
        g_clear_pointer (&priv->key_colors, g_array_unref);
diff --git a/lib/gs-app.h b/lib/gs-app.h
index 8936e287f..01db4940f 100644
--- a/lib/gs-app.h
+++ b/lib/gs-app.h
@@ -17,6 +17,9 @@
 
 G_BEGIN_DECLS
 
+/* Dependency loop means we can’t include the header. */
+typedef struct _GsPlugin GsPlugin;
+
 #define GS_TYPE_APP (gs_app_get_type ())
 
 G_DECLARE_DERIVABLE_TYPE (GsApp, gs_app, GS, APP, GObject)
@@ -361,9 +364,11 @@ void                gs_app_set_update_details_text (GsApp          *app,
 AsUrgencyKind   gs_app_get_update_urgency      (GsApp          *app);
 void            gs_app_set_update_urgency      (GsApp          *app,
                                                 AsUrgencyKind   update_urgency);
-const gchar    *gs_app_get_management_plugin   (GsApp          *app);
+GsPlugin       *gs_app_dup_management_plugin   (GsApp          *app);
+gboolean        gs_app_has_management_plugin   (GsApp          *app,
+                                                GsPlugin       *plugin);
 void            gs_app_set_management_plugin   (GsApp          *app,
-                                                const gchar    *management_plugin);
+                                                GsPlugin       *management_plugin);
 GIcon          *gs_app_get_icon_for_size       (GsApp          *app,
                                                 guint           size,
                                                 guint           scale,
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index c5d7ef4f8..a76cd64ab 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -542,12 +542,15 @@ gs_plugin_loader_run_adopt (GsPluginLoader *plugin_loader, GsAppList *list)
                        continue;
                for (j = 0; j < gs_app_list_length (list); j++) {
                        GsApp *app = gs_app_list_index (list, j);
-                       if (gs_app_get_management_plugin (app) != NULL)
-                               continue;
+
                        if (gs_app_has_quirk (app, GS_APP_QUIRK_IS_WILDCARD))
                                continue;
+                       if (!gs_app_has_management_plugin (app, NULL))
+                               continue;
+
                        adopt_app_func (plugin, app);
-                       if (gs_app_get_management_plugin (app) != NULL) {
+
+                       if (!gs_app_has_management_plugin (app, NULL)) {
                                g_debug ("%s adopted %s",
                                         gs_plugin_get_name (plugin),
                                         gs_app_get_unique_id (app));
@@ -556,10 +559,12 @@ gs_plugin_loader_run_adopt (GsPluginLoader *plugin_loader, GsAppList *list)
        }
        for (j = 0; j < gs_app_list_length (list); j++) {
                GsApp *app = gs_app_list_index (list, j);
-               if (gs_app_get_management_plugin (app) != NULL)
-                       continue;
+
                if (gs_app_has_quirk (app, GS_APP_QUIRK_IS_WILDCARD))
                        continue;
+               if (!gs_app_has_management_plugin (app, NULL))
+                       continue;
+
                g_debug ("nothing adopted %s", gs_app_get_unique_id (app));
        }
 }
@@ -1291,15 +1296,10 @@ gs_plugin_loader_get_app_str (GsApp *app)
 static gboolean
 gs_plugin_loader_app_set_prio (GsApp *app, gpointer user_data)
 {
-       GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (user_data);
-       GsPlugin *plugin;
-       const gchar *tmp;
+       g_autoptr(GsPlugin) plugin = NULL;
 
        /* if set, copy the priority */
-       tmp = gs_app_get_management_plugin (app);
-       if (tmp == NULL)
-               return TRUE;
-       plugin = gs_plugin_loader_find_plugin (plugin_loader, tmp);
+       plugin = gs_app_dup_management_plugin (app);
        if (plugin == NULL)
                return TRUE;
        gs_app_set_priority (app, gs_plugin_get_priority (plugin));
diff --git a/plugins/core/gs-plugin-generic-updates.c b/plugins/core/gs-plugin-generic-updates.c
index 935deb627..c92130590 100644
--- a/plugins/core/gs-plugin-generic-updates.c
+++ b/plugins/core/gs-plugin-generic-updates.c
@@ -57,7 +57,7 @@ gs_plugin_generic_updates_get_os_update (GsPlugin *plugin)
        /* create new */
        app = gs_app_new (id);
        gs_app_add_quirk (app, GS_APP_QUIRK_IS_PROXY);
-       gs_app_set_management_plugin (app, "");
+       gs_app_set_management_plugin (app, plugin);
        gs_app_set_special_kind (app, GS_APP_SPECIAL_KIND_OS_UPDATE);
        gs_app_set_state (app, GS_APP_STATE_UPDATABLE_LIVE);
        gs_app_set_name (app,
diff --git a/plugins/dummy/gs-plugin-dummy.c b/plugins/dummy/gs-plugin-dummy.c
index f2f71f6bd..c09a5f1fa 100644
--- a/plugins/dummy/gs-plugin-dummy.c
+++ b/plugins/dummy/gs-plugin-dummy.c
@@ -89,7 +89,7 @@ gs_plugin_setup (GsPlugin      *plugin,
        self->cached_origin = gs_app_new (gs_plugin_get_name (plugin));
        gs_app_set_kind (self->cached_origin, AS_COMPONENT_KIND_REPOSITORY);
        gs_app_set_origin_hostname (self->cached_origin, "http://www.bbc.co.uk/";);
-       gs_app_set_management_plugin (self->cached_origin, gs_plugin_get_name (plugin));
+       gs_app_set_management_plugin (self->cached_origin, plugin);
 
        /* add the source to the plugin cache which allows us to match the
         * unique ID to a GsApp when creating an event */
@@ -119,7 +119,7 @@ gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
 {
        if (gs_app_get_id (app) != NULL &&
            g_str_has_prefix (gs_app_get_id (app), "dummy:")) {
-               gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+               gs_app_set_management_plugin (app, plugin);
                return;
        }
        if (g_strcmp0 (gs_app_get_id (app), "mate-spell.desktop") == 0 ||
@@ -128,7 +128,7 @@ gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
            g_strcmp0 (gs_app_get_id (app), "com.hughski.ColorHug2.driver") == 0 ||
            g_strcmp0 (gs_app_get_id (app), "zeus-spell.addon") == 0 ||
            g_strcmp0 (gs_app_get_source_default (app), "chiron") == 0)
-               gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+               gs_app_set_management_plugin (app, plugin);
 }
 
 static gboolean
@@ -204,7 +204,7 @@ gs_plugin_url_to_app (GsPlugin *plugin,
        /* create app */
        path = gs_utils_get_url_path (url);
        app = gs_app_new (path);
-       gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+       gs_app_set_management_plugin (app, plugin);
        gs_app_set_metadata (app, "GnomeSoftware::Creator",
                             gs_plugin_get_name (plugin));
        gs_app_list_add (list, app);
@@ -332,7 +332,7 @@ gs_plugin_add_search (GsPlugin *plugin,
        gs_app_set_size_download (app, 50 * 1024 * 1024);
        gs_app_set_kind (app, AS_COMPONENT_KIND_DESKTOP_APP);
        gs_app_set_state (app, GS_APP_STATE_INSTALLED);
-       gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+       gs_app_set_management_plugin (app, plugin);
        gs_app_set_metadata (app, "GnomeSoftware::Creator",
                             gs_plugin_get_name (plugin));
        gs_app_list_add (list, app);
@@ -372,7 +372,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
        gs_app_add_icon (app, ic);
        gs_app_set_kind (app, AS_COMPONENT_KIND_DESKTOP_APP);
        gs_app_set_state (app, GS_APP_STATE_UPDATABLE_LIVE);
-       gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+       gs_app_set_management_plugin (app, plugin);
        gs_app_list_add (list, app);
        g_object_unref (app);
 
@@ -388,7 +388,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
        gs_app_set_state (app, GS_APP_STATE_UPDATABLE);
        gs_app_add_source (app, "libvirt-glib-devel");
        gs_app_add_source_id (app, "libvirt-glib-devel;0.0.1;noarch;fedora");
-       gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+       gs_app_set_management_plugin (app, plugin);
        gs_app_list_add (list, app);
        g_object_unref (app);
 
@@ -404,7 +404,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
        gs_app_set_state (app, GS_APP_STATE_UPDATABLE_LIVE);
        gs_app_add_source (app, "chiron-libs");
        gs_app_add_source_id (app, "chiron-libs;0.0.1;i386;updates-testing");
-       gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+       gs_app_set_management_plugin (app, plugin);
        gs_app_list_add (list, app);
        g_object_unref (app);
 
@@ -418,7 +418,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
        gs_app_set_kind (proxy, AS_COMPONENT_KIND_DESKTOP_APP);
        gs_app_add_quirk (proxy, GS_APP_QUIRK_IS_PROXY);
        gs_app_set_state (proxy, GS_APP_STATE_UPDATABLE_LIVE);
-       gs_app_set_management_plugin (proxy, gs_plugin_get_name (plugin));
+       gs_app_set_management_plugin (proxy, plugin);
        gs_app_list_add (list, proxy);
        g_object_unref (proxy);
 
@@ -428,7 +428,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
        gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, "A related app");
        gs_app_set_kind (app, AS_COMPONENT_KIND_DESKTOP_APP);
        gs_app_set_state (app, GS_APP_STATE_UPDATABLE_LIVE);
-       gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+       gs_app_set_management_plugin (app, plugin);
        gs_app_add_related (proxy, app);
        g_object_unref (app);
 
@@ -438,7 +438,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
        gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, "A related app");
        gs_app_set_kind (app, AS_COMPONENT_KIND_DESKTOP_APP);
        gs_app_set_state (app, GS_APP_STATE_UPDATABLE_LIVE);
-       gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+       gs_app_set_management_plugin (app, plugin);
        gs_app_add_related (proxy, app);
        g_object_unref (app);
 
@@ -462,7 +462,7 @@ gs_plugin_add_installed (GsPlugin *plugin,
                gs_app_set_state (app, GS_APP_STATE_INSTALLED);
                gs_app_set_kind (app, AS_COMPONENT_KIND_GENERIC);
                gs_app_set_origin (app, "london-west");
-               gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+               gs_app_set_management_plugin (app, plugin);
                gs_app_list_add (list, app);
        }
 
@@ -471,7 +471,7 @@ gs_plugin_add_installed (GsPlugin *plugin,
                g_autoptr(GsApp) app = gs_app_new (app_ids[i]);
                gs_app_set_state (app, GS_APP_STATE_INSTALLED);
                gs_app_set_kind (app, AS_COMPONENT_KIND_DESKTOP_APP);
-               gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+               gs_app_set_management_plugin (app, plugin);
                gs_app_list_add (list, app);
        }
 
@@ -513,8 +513,7 @@ gs_plugin_app_remove (GsPlugin *plugin,
        GsPluginDummy *self = GS_PLUGIN_DUMMY (plugin);
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app),
-                      gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        /* remove app */
@@ -544,8 +543,7 @@ gs_plugin_app_install (GsPlugin *plugin,
        GsPluginDummy *self = GS_PLUGIN_DUMMY (plugin);
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app),
-                      gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        /* install app */
@@ -577,8 +575,7 @@ gs_plugin_update_app (GsPlugin *plugin,
        GsPluginDummy *self = GS_PLUGIN_DUMMY (plugin);
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app),
-                      gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        if (!g_str_has_prefix (gs_app_get_id (app), "proxy")) {
@@ -755,7 +752,7 @@ gs_plugin_add_category_apps (GsPlugin *plugin,
        gs_app_set_state (app, GS_APP_STATE_AVAILABLE);
        gs_app_add_icon (app, icon);
        gs_app_set_kind (app, AS_COMPONENT_KIND_DESKTOP_APP);
-       gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+       gs_app_set_management_plugin (app, plugin);
        gs_app_list_add (list, app);
        return TRUE;
 }
@@ -776,7 +773,7 @@ gs_plugin_add_recent (GsPlugin *plugin,
        gs_app_set_state (app, GS_APP_STATE_AVAILABLE);
        gs_app_add_icon (app, icon);
        gs_app_set_kind (app, AS_COMPONENT_KIND_DESKTOP_APP);
-       gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+       gs_app_set_management_plugin (app, plugin);
        gs_app_list_add (list, app);
        return TRUE;
 }
@@ -817,7 +814,7 @@ gs_plugin_add_distro_upgrades (GsPlugin *plugin,
        gs_app_set_size_installed (app, 256 * 1024 * 1024);
        gs_app_set_size_download (app, 1024 * 1024 * 1024);
        gs_app_set_license (app, GS_APP_QUALITY_LOWEST, "LicenseRef-free");
-       gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+       gs_app_set_management_plugin (app, plugin);
        gs_app_set_metadata (app, "GnomeSoftware::UpgradeBanner-css",
                             "background: url('file://" DATADIR "/gnome-software/upgrade-bg.png');"
                             "background-size: 100% 100%;"
@@ -854,8 +851,7 @@ gs_plugin_app_upgrade_download (GsPlugin *plugin, GsApp *app,
                                GCancellable *cancellable, GError **error)
 {
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app),
-                      gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        g_debug ("starting download");
@@ -873,8 +869,7 @@ gs_plugin_app_upgrade_trigger (GsPlugin *plugin, GsApp *app,
                               GCancellable *cancellable, GError **error)
 {
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app),
-                      gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        /* NOP */
diff --git a/plugins/dummy/gs-self-test.c b/plugins/dummy/gs-self-test.c
index bcb694157..cda6bc445 100644
--- a/plugins/dummy/gs-self-test.c
+++ b/plugins/dummy/gs-self-test.c
@@ -56,10 +56,12 @@ gs_plugins_dummy_install_func (GsPluginLoader *plugin_loader)
        g_autoptr(GsApp) app = NULL;
        g_autoptr(GsPluginJob) plugin_job = NULL;
        g_autoptr(GError) error = NULL;
+       GsPlugin *plugin;
 
        /* install */
        app = gs_app_new ("chiron.desktop");
-       gs_app_set_management_plugin (app, "dummy");
+       plugin = gs_plugin_loader_find_plugin (plugin_loader, "dummy");
+       gs_app_set_management_plugin (app, plugin);
        gs_app_set_state (app, GS_APP_STATE_AVAILABLE);
        plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_INSTALL,
                                         "app", app,
@@ -92,6 +94,7 @@ gs_plugins_dummy_error_func (GsPluginLoader *plugin_loader)
        g_autoptr(GsApp) app = NULL;
        g_autoptr(GsPluginEvent) event = NULL;
        g_autoptr(GsPluginJob) plugin_job = NULL;
+       GsPlugin *plugin;
 
        /* drop all caches */
        gs_utils_rmtree (g_getenv ("GS_SELF_TEST_CACHEDIR"), NULL);
@@ -99,7 +102,8 @@ gs_plugins_dummy_error_func (GsPluginLoader *plugin_loader)
 
        /* update, which should cause an error to be emitted */
        app = gs_app_new ("chiron.desktop");
-       gs_app_set_management_plugin (app, "dummy");
+       plugin = gs_plugin_loader_find_plugin (plugin_loader, "dummy");
+       gs_app_set_management_plugin (app, plugin);
        gs_app_set_state (app, GS_APP_STATE_AVAILABLE);
        plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_UPDATE,
                                         "app", app,
@@ -133,10 +137,12 @@ gs_plugins_dummy_refine_func (GsPluginLoader *plugin_loader)
        g_autoptr(GsApp) app = NULL;
        g_autoptr(GError) error = NULL;
        g_autoptr(GsPluginJob) plugin_job = NULL;
+       GsPlugin *plugin;
 
        /* get the extra bits */
        app = gs_app_new ("chiron.desktop");
-       gs_app_set_management_plugin (app, "dummy");
+       plugin = gs_plugin_loader_find_plugin (plugin_loader, "dummy");
+       gs_app_set_management_plugin (app, plugin);
        plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REFINE,
                                         "app", app,
                                         "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_DESCRIPTION |
@@ -160,10 +166,12 @@ gs_plugins_dummy_metadata_quirks (GsPluginLoader *plugin_loader)
        g_autoptr(GsApp) app = NULL;
        g_autoptr(GError) error = NULL;
        g_autoptr(GsPluginJob) plugin_job = NULL;
+       GsPlugin *plugin;
 
        /* get the extra bits */
        app = gs_app_new ("chiron.desktop");
-       gs_app_set_management_plugin (app, "dummy");
+       plugin = gs_plugin_loader_find_plugin (plugin_loader, "dummy");
+       gs_app_set_management_plugin (app, plugin);
        plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REFINE,
                                         "app", app,
                                         "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_DESCRIPTION,
@@ -618,6 +626,7 @@ gs_plugins_dummy_limit_parallel_ops_func (GsPluginLoader *plugin_loader)
         GsApp *app1 = NULL;
        g_autoptr(GsApp) app2 = NULL;
        g_autoptr(GsApp) app3 = NULL;
+       GsPlugin *plugin;
        g_autoptr(GsPluginJob) plugin_job1 = NULL;
        g_autoptr(GsPluginJob) plugin_job2 = NULL;
        g_autoptr(GsPluginJob) plugin_job3 = NULL;
@@ -646,12 +655,13 @@ gs_plugins_dummy_limit_parallel_ops_func (GsPluginLoader *plugin_loader)
        gs_plugin_loader_set_max_parallel_ops (plugin_loader, 1);
 
        app2 = gs_app_new ("chiron.desktop");
-       gs_app_set_management_plugin (app2, "dummy");
+       plugin = gs_plugin_loader_find_plugin (plugin_loader, "dummy");
+       gs_app_set_management_plugin (app2, plugin);
        gs_app_set_state (app2, GS_APP_STATE_AVAILABLE);
 
        /* use "proxy" prefix so the update function succeeds... */
        app3 = gs_app_new ("proxy-zeus.desktop");
-       gs_app_set_management_plugin (app3, "dummy");
+       gs_app_set_management_plugin (app3, plugin);
        gs_app_set_state (app3, GS_APP_STATE_UPDATABLE_LIVE);
 
        context = g_main_context_new ();
diff --git a/plugins/eos-updater/gs-plugin-eos-updater.c b/plugins/eos-updater/gs-plugin-eos-updater.c
index 454898c5b..186a2f342 100644
--- a/plugins/eos-updater/gs-plugin-eos-updater.c
+++ b/plugins/eos-updater/gs-plugin-eos-updater.c
@@ -569,7 +569,7 @@ gs_plugin_setup (GsPlugin *plugin,
        gs_app_add_quirk (app, GS_APP_QUIRK_NEEDS_REBOOT);
        gs_app_add_quirk (app, GS_APP_QUIRK_PROVENANCE);
        gs_app_add_quirk (app, GS_APP_QUIRK_NOT_REVIEWABLE);
-       gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+       gs_app_set_management_plugin (app, plugin);
        gs_app_set_metadata (app, "GnomeSoftware::UpgradeBanner-css",
                             "background: url('file://" DATADIR "/gnome-software/upgrade-bg.png');"
                             "background-size: 100% 100%;");
@@ -772,8 +772,7 @@ gs_plugin_app_upgrade_download (GsPlugin *plugin,
        g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&self->mutex);
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app),
-                      gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        /* if the OS upgrade has been disabled */
diff --git a/plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c 
b/plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c
index eaef561ab..13ab18604 100644
--- a/plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c
+++ b/plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c
@@ -170,7 +170,7 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
        gs_app_set_kind (self->cached_origin, AS_COMPONENT_KIND_REPOSITORY);
        gs_app_set_origin_hostname (self->cached_origin,
                                    FEDORA_PKGDB_COLLECTIONS_API_URI);
-       gs_app_set_management_plugin (self->cached_origin, gs_plugin_get_name (plugin));
+       gs_app_set_management_plugin (self->cached_origin, plugin);
 
        /* add the source to the plugin cache which allows us to match the
         * unique ID to a GsApp when creating an event */
diff --git a/plugins/flatpak/gs-flatpak-utils.c b/plugins/flatpak/gs-flatpak-utils.c
index 9932bb6f1..746533f80 100644
--- a/plugins/flatpak/gs-flatpak-utils.c
+++ b/plugins/flatpak/gs-flatpak-utils.c
@@ -85,7 +85,7 @@ gs_flatpak_app_new_from_remote (GsPlugin *plugin,
        gs_app_set_name (app, GS_APP_QUALITY_LOWEST,
                         flatpak_remote_get_name (xremote));
        gs_app_set_size_download (app, GS_APP_SIZE_UNKNOWABLE);
-       gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+       gs_app_set_management_plugin (app, plugin);
        gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_FLATPAK);
        gs_app_set_scope (app, is_user ? AS_COMPONENT_SCOPE_USER : AS_COMPONENT_SCOPE_SYSTEM);
 
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index f34d98a99..a8fafd8a9 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -62,9 +62,10 @@ gs_plugin_refine_item_scope (GsFlatpak *self, GsApp *app)
 static void
 gs_flatpak_claim_app (GsFlatpak *self, GsApp *app)
 {
-       if (gs_app_get_management_plugin (app) != NULL)
+       if (!gs_app_has_management_plugin (app, NULL))
                return;
-       gs_app_set_management_plugin (app, gs_plugin_get_name (self->plugin));
+
+       gs_app_set_management_plugin (app, self->plugin);
        gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_FLATPAK);
 
        /* only when we have a non-temp object */
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index 9e231ed4e..65fd054c9 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -101,7 +101,7 @@ void
 gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
 {
        if (gs_app_get_bundle_kind (app) == AS_BUNDLE_KIND_FLATPAK)
-               gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+               gs_app_set_management_plugin (app, plugin);
 }
 
 static gboolean
@@ -295,10 +295,8 @@ gs_plugin_flatpak_get_handler (GsPluginFlatpak *self,
        const gchar *object_id;
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app),
-                      gs_plugin_get_name (GS_PLUGIN (self))) != 0) {
+       if (!gs_app_has_management_plugin (app, GS_PLUGIN (self)))
                return NULL;
-       }
 
        /* specified an explicit name */
        object_id = gs_flatpak_app_get_object_id (app);
@@ -365,10 +363,8 @@ refine_app (GsPluginFlatpak      *self,
             GError              **error)
 {
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app),
-                      gs_plugin_get_name (GS_PLUGIN (self))) != 0) {
+       if (!gs_app_has_management_plugin (app, GS_PLUGIN (self)))
                return TRUE;
-       }
 
        /* get the runtime first */
        if (!gs_plugin_flatpak_refine_app (self, app, flags, cancellable, error))
@@ -1284,7 +1280,7 @@ gs_plugin_flatpak_file_to_app_repo (GsPluginFlatpak  *self,
        }
 
        /* this is new */
-       gs_app_set_management_plugin (app, gs_plugin_get_name (GS_PLUGIN (self)));
+       gs_app_set_management_plugin (app, GS_PLUGIN (self));
        return g_steal_pointer (&app);
 }
 
diff --git a/plugins/flatpak/gs-self-test.c b/plugins/flatpak/gs-self-test.c
index 6f752238a..d55abc86f 100644
--- a/plugins/flatpak/gs-self-test.c
+++ b/plugins/flatpak/gs-self-test.c
@@ -116,6 +116,7 @@ gs_plugins_flatpak_repo_func (GsPluginLoader *plugin_loader)
        g_autoptr(GsApp) app = NULL;
        g_autoptr(GsPluginJob) plugin_job = NULL;
        g_autoptr(GIcon) icon = NULL;
+       g_autoptr(GsPlugin) management_plugin = NULL;
 
        /* no flatpak, abort */
        if (!gs_plugin_loader_get_enabled (plugin_loader, "flatpak"))
@@ -143,7 +144,9 @@ gs_plugins_flatpak_repo_func (GsPluginLoader *plugin_loader)
        g_assert_cmpint (gs_app_get_kind (app), ==, AS_COMPONENT_KIND_REPOSITORY);
        g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE_LOCAL);
        g_assert_cmpstr (gs_app_get_id (app), ==, "example");
-       g_assert_cmpstr (gs_app_get_management_plugin (app), ==, "flatpak");
+       management_plugin = gs_app_dup_management_plugin (app);
+       g_assert_nonnull (management_plugin);
+       g_assert_cmpstr (gs_plugin_get_name (management_plugin), ==, "flatpak");
        g_assert_cmpstr (gs_app_get_origin_hostname (app), ==, "localhost");
        g_assert_cmpstr (gs_app_get_url (app, AS_URL_KIND_HOMEPAGE), ==, "http://foo.bar";);
        g_assert_cmpstr (gs_app_get_name (app), ==, "foo-bar");
@@ -267,6 +270,7 @@ gs_plugins_flatpak_app_with_runtime_func (GsPluginLoader *plugin_loader)
        g_autoptr(GsPluginJob) plugin_job = NULL;
        gulong signal_id;
        gboolean seen_unknown;
+       GsPlugin *plugin;
 
        /* drop all caches */
        gs_utils_rmtree (g_getenv ("GS_SELF_TEST_CACHEDIR"), NULL);
@@ -305,7 +309,8 @@ gs_plugins_flatpak_app_with_runtime_func (GsPluginLoader *plugin_loader)
                return;
        testdir_repourl = g_strdup_printf ("file://%s/repo", testdir);
        gs_app_set_kind (app_source, AS_COMPONENT_KIND_REPOSITORY);
-       gs_app_set_management_plugin (app_source, "flatpak");
+       plugin = gs_plugin_loader_find_plugin (plugin_loader, "flatpak");
+       gs_app_set_management_plugin (app_source, plugin);
        gs_app_set_state (app_source, GS_APP_STATE_AVAILABLE);
        gs_flatpak_app_set_repo_url (app_source, testdir_repourl);
        plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_INSTALL_REPO,
@@ -545,6 +550,7 @@ gs_plugins_flatpak_app_missing_runtime_func (GsPluginLoader *plugin_loader)
        g_autoptr(GsApp) app_source = NULL;
        g_autoptr(GsAppList) list = NULL;
        g_autoptr(GsPluginJob) plugin_job = NULL;
+       GsPlugin *plugin;
 
        /* drop all caches */
        gs_utils_rmtree (g_getenv ("GS_SELF_TEST_CACHEDIR"), NULL);
@@ -569,7 +575,8 @@ gs_plugins_flatpak_app_missing_runtime_func (GsPluginLoader *plugin_loader)
                return;
        testdir_repourl = g_strdup_printf ("file://%s/repo", testdir);
        gs_app_set_kind (app_source, AS_COMPONENT_KIND_REPOSITORY);
-       gs_app_set_management_plugin (app_source, "flatpak");
+       plugin = gs_plugin_loader_find_plugin (plugin_loader, "flatpak");
+       gs_app_set_management_plugin (app_source, plugin);
        gs_app_set_state (app_source, GS_APP_STATE_AVAILABLE);
        gs_flatpak_app_set_repo_url (app_source, testdir_repourl);
        plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_INSTALL_REPO,
@@ -983,6 +990,7 @@ gs_plugins_flatpak_broken_remote_func (GsPluginLoader *plugin_loader)
        g_autoptr(GsApp) app = NULL;
        g_autoptr(GsApp) app_source = NULL;
        g_autoptr(GsPluginJob) plugin_job = NULL;
+       GsPlugin *plugin;
 
        /* drop all caches */
        gs_utils_rmtree (g_getenv ("GS_SELF_TEST_CACHEDIR"), NULL);
@@ -998,7 +1006,8 @@ gs_plugins_flatpak_broken_remote_func (GsPluginLoader *plugin_loader)
        if (testdir == NULL)
                return;
        gs_app_set_kind (app_source, AS_COMPONENT_KIND_REPOSITORY);
-       gs_app_set_management_plugin (app_source, "flatpak");
+       plugin = gs_plugin_loader_find_plugin (plugin_loader, "flatpak");
+       gs_app_set_management_plugin (app_source, plugin);
        gs_app_set_state (app_source, GS_APP_STATE_AVAILABLE);
        gs_flatpak_app_set_repo_url (app_source, "file:///wont/work");
        plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_INSTALL_REPO,
@@ -1077,6 +1086,7 @@ flatpak_bundle_or_ref_helper (GsPluginLoader *plugin_loader,
        g_autoptr(GsAppList) search2 = NULL;
        g_autoptr(GsAppList) sources = NULL;
        g_autoptr(GsPluginJob) plugin_job = NULL;
+       GsPlugin *plugin;
 
        /* drop all caches */
        gs_utils_rmtree (g_getenv ("GS_SELF_TEST_CACHEDIR"), NULL);
@@ -1093,7 +1103,8 @@ flatpak_bundle_or_ref_helper (GsPluginLoader *plugin_loader,
                return;
        testdir_repourl = g_strdup_printf ("file://%s/repo", testdir);
        gs_app_set_kind (app_source, AS_COMPONENT_KIND_REPOSITORY);
-       gs_app_set_management_plugin (app_source, "flatpak");
+       plugin = gs_plugin_loader_find_plugin (plugin_loader, "flatpak");
+       gs_app_set_management_plugin (app_source, plugin);
        gs_app_set_state (app_source, GS_APP_STATE_AVAILABLE);
        gs_flatpak_app_set_repo_url (app_source, testdir_repourl);
        plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_INSTALL_REPO,
@@ -1293,7 +1304,8 @@ flatpak_bundle_or_ref_helper (GsPluginLoader *plugin_loader,
                /* remove remote added by RuntimeRepo= in flatpakref */
                g_autoptr(GsApp) runtime_source = gs_flatpak_app_new ("test-1");
                gs_app_set_kind (runtime_source, AS_COMPONENT_KIND_REPOSITORY);
-               gs_app_set_management_plugin (runtime_source, "flatpak");
+               plugin = gs_plugin_loader_find_plugin (plugin_loader, "flatpak");
+               gs_app_set_management_plugin (runtime_source, plugin);
                gs_app_set_state (runtime_source, GS_APP_STATE_INSTALLED);
                g_object_unref (plugin_job);
                plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REMOVE_REPO,
@@ -1370,6 +1382,7 @@ gs_plugins_flatpak_app_update_func (GsPluginLoader *plugin_loader)
        g_autoptr(GMainLoop) loop = g_main_loop_new (NULL, FALSE);
        g_autofree gchar *repo_path = NULL;
        g_autofree gchar *repo_url = NULL;
+       GsPlugin *plugin;
 
        /* drop all caches */
        gs_utils_rmtree (g_getenv ("GS_SELF_TEST_CACHEDIR"), NULL);
@@ -1401,7 +1414,8 @@ gs_plugins_flatpak_app_update_func (GsPluginLoader *plugin_loader)
        /* add a remote */
        app_source = gs_flatpak_app_new ("test");
        gs_app_set_kind (app_source, AS_COMPONENT_KIND_REPOSITORY);
-       gs_app_set_management_plugin (app_source, "flatpak");
+       plugin = gs_plugin_loader_find_plugin (plugin_loader, "flatpak");
+       gs_app_set_management_plugin (app_source, plugin);
        gs_app_set_state (app_source, GS_APP_STATE_AVAILABLE);
        repo_url = g_strdup_printf ("file://%s", repo_path);
        gs_flatpak_app_set_repo_url (app_source, repo_url);
@@ -1623,6 +1637,7 @@ gs_plugins_flatpak_runtime_extension_func (GsPluginLoader *plugin_loader)
        g_autoptr(GMainLoop) loop = g_main_loop_new (NULL, FALSE);
        g_autofree gchar *repo_path = NULL;
        g_autofree gchar *repo_url = NULL;
+       GsPlugin *plugin;
 
        /* drop all caches */
        gs_utils_rmtree (g_getenv ("GS_SELF_TEST_CACHEDIR"), NULL);
@@ -1652,7 +1667,8 @@ gs_plugins_flatpak_runtime_extension_func (GsPluginLoader *plugin_loader)
        /* add a remote */
        app_source = gs_flatpak_app_new ("test");
        gs_app_set_kind (app_source, AS_COMPONENT_KIND_REPOSITORY);
-       gs_app_set_management_plugin (app_source, "flatpak");
+       plugin = gs_plugin_loader_find_plugin (plugin_loader, "flatpak");
+       gs_app_set_management_plugin (app_source, plugin);
        gs_app_set_state (app_source, GS_APP_STATE_AVAILABLE);
        repo_url = g_strdup_printf ("file://%s", repo_path);
        gs_flatpak_app_set_repo_url (app_source, repo_url);
diff --git a/plugins/fwupd/gs-plugin-fwupd.c b/plugins/fwupd/gs-plugin-fwupd.c
index 1fc8612c7..abae291eb 100644
--- a/plugins/fwupd/gs-plugin-fwupd.c
+++ b/plugins/fwupd/gs-plugin-fwupd.c
@@ -118,7 +118,7 @@ void
 gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
 {
        if (gs_app_get_kind (app) == AS_COMPONENT_KIND_FIRMWARE)
-               gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+               gs_app_set_management_plugin (app, plugin);
 }
 
 static void
@@ -243,7 +243,7 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
        self->cached_origin = gs_app_new (gs_plugin_get_name (plugin));
        gs_app_set_kind (self->cached_origin, AS_COMPONENT_KIND_REPOSITORY);
        gs_app_set_bundle_kind (self->cached_origin, AS_BUNDLE_KIND_CABINET);
-       gs_app_set_management_plugin (self->cached_origin, gs_plugin_get_name (plugin));
+       gs_app_set_management_plugin (self->cached_origin, plugin);
 
        /* add the source to the plugin cache which allows us to match the
         * unique ID to a GsApp when creating an event */
@@ -297,7 +297,7 @@ gs_plugin_fwupd_new_app_from_device (GsPlugin *plugin, FwupdDevice *dev)
        gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_CABINET);
        gs_app_add_quirk (app, GS_APP_QUIRK_NOT_LAUNCHABLE);
        gs_app_add_quirk (app, GS_APP_QUIRK_DO_NOT_AUTO_UPDATE);
-       gs_app_set_management_plugin (app, "fwupd");
+       gs_app_set_management_plugin (app, plugin);
        gs_app_add_category (app, "System");
        gs_fwupd_app_set_device_id (app, fwupd_device_get_id (dev));
 
@@ -348,7 +348,7 @@ gs_plugin_fwupd_new_app_from_device_raw (GsPlugin *plugin, FwupdDevice *device)
        gs_app_set_description (app, GS_APP_QUALITY_LOWEST, fwupd_device_get_description (device));
        gs_app_set_origin (app, fwupd_device_get_vendor (device));
        gs_fwupd_app_set_device_id (app, fwupd_device_get_id (device));
-       gs_app_set_management_plugin (app, "fwupd");
+       gs_app_set_management_plugin (app, plugin);
 
        /* create icon */
        icons = fwupd_device_get_icons (device);
@@ -842,8 +842,7 @@ gs_plugin_app_install (GsPlugin *plugin,
 {
        GsPluginFwupd *self = GS_PLUGIN_FWUPD (plugin);
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app),
-                      gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        /* source -> remote, handled by dedicated function */
@@ -866,8 +865,7 @@ gs_plugin_download_app (GsPlugin *plugin,
        g_autoptr(GError) error_local = NULL;
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app),
-                      gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        /* not set */
@@ -922,8 +920,7 @@ gs_plugin_update_app (GsPlugin *plugin,
 {
        GsPluginFwupd *self = GS_PLUGIN_FWUPD (plugin);
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app),
-                      gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        /* locked devices need unlocking, rather than installing */
@@ -1038,7 +1035,7 @@ gs_plugin_add_sources (GsPlugin *plugin,
                                fwupd_remote_get_metadata_uri (remote));
                gs_app_set_metadata (app, "fwupd::remote-id",
                                     fwupd_remote_get_id (remote));
-               gs_app_set_management_plugin (app, "fwupd");
+               gs_app_set_management_plugin (app, plugin);
                gs_app_set_metadata (app, "GnomeSoftware::PackagingFormat", "fwupd");
                gs_app_set_metadata (app, "GnomeSoftware::SortKey", "800");
                gs_app_set_origin_ui (app, _("Firmware"));
@@ -1095,8 +1092,7 @@ gs_plugin_enable_repo (GsPlugin *plugin,
        GsPluginFwupd *self = GS_PLUGIN_FWUPD (plugin);
 
        /* only process this app if it was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (repo),
-                      gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (repo, plugin))
                return TRUE;
 
        /* source -> remote */
@@ -1121,8 +1117,7 @@ gs_plugin_disable_repo (GsPlugin *plugin,
        GsPluginFwupd *self = GS_PLUGIN_FWUPD (plugin);
 
        /* only process this app if it was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (repo),
-                      gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (repo, plugin))
                return TRUE;
 
        /* source -> remote */
diff --git a/plugins/packagekit/gs-plugin-packagekit-refine-repos.c 
b/plugins/packagekit/gs-plugin-packagekit-refine-repos.c
index 74633d1a6..ce50d1115 100644
--- a/plugins/packagekit/gs-plugin-packagekit-refine-repos.c
+++ b/plugins/packagekit/gs-plugin-packagekit-refine-repos.c
@@ -126,7 +126,7 @@ gs_plugin_refine (GsPlugin *plugin,
                        continue;
                if (gs_app_get_kind (app) != AS_COMPONENT_KIND_REPOSITORY)
                        continue;
-               if (g_strcmp0 (gs_app_get_management_plugin (app), "packagekit") != 0)
+               if (!gs_app_has_management_plugin (app, plugin))
                        continue;
                fn = gs_app_get_metadata_item (app, "repos::repo-filename");
                if (fn == NULL)
diff --git a/plugins/packagekit/gs-plugin-packagekit-refresh.c 
b/plugins/packagekit/gs-plugin-packagekit-refresh.c
index 2da3edf87..e0e965d1a 100644
--- a/plugins/packagekit/gs-plugin-packagekit-refresh.c
+++ b/plugins/packagekit/gs-plugin-packagekit-refresh.c
@@ -158,7 +158,7 @@ gs_plugin_download (GsPlugin *plugin,
 
                /* add this app */
                if (!gs_app_has_quirk (app, GS_APP_QUIRK_IS_PROXY)) {
-                       if (g_strcmp0 (gs_app_get_management_plugin (app), "packagekit") == 0)
+                       if (gs_app_has_management_plugin (app, plugin))
                                gs_app_list_add (list_tmp, app);
                        continue;
                }
@@ -166,7 +166,7 @@ gs_plugin_download (GsPlugin *plugin,
                /* add each related app */
                for (guint j = 0; j < gs_app_list_length (related); j++) {
                        GsApp *app_tmp = gs_app_list_index (related, j);
-                       if (g_strcmp0 (gs_app_get_management_plugin (app_tmp), "packagekit") == 0)
+                       if (gs_app_has_management_plugin (app_tmp, plugin))
                                gs_app_list_add (list_tmp, app_tmp);
                }
        }
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index 2a4bd9ac1..b4d04e910 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -301,7 +301,7 @@ gs_plugin_add_sources (GsPlugin *plugin,
                rd = g_ptr_array_index (array, i);
                id = pk_repo_detail_get_id (rd);
                app = gs_app_new (id);
-               gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+               gs_app_set_management_plugin (app, plugin);
                gs_app_set_kind (app, AS_COMPONENT_KIND_REPOSITORY);
                gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_PACKAGE);
                gs_app_set_scope (app, AS_COMPONENT_SCOPE_SYSTEM);
@@ -402,8 +402,7 @@ gs_plugin_app_install (GsPlugin *plugin,
        g_autoptr(PkResults) results = NULL;
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app),
-                      gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        /* enable repo, handled by dedicated function */
@@ -613,8 +612,7 @@ gs_plugin_app_remove (GsPlugin *plugin,
        g_auto(GStrv) package_ids = NULL;
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app),
-                      gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        /* disable repo, handled by dedicated function */
@@ -696,7 +694,7 @@ gs_plugin_packagekit_build_update_app (GsPlugin *plugin, PkPackage *package)
                            pk_package_get_summary (package));
        gs_app_set_metadata (app, "GnomeSoftware::Creator",
                             gs_plugin_get_name (plugin));
-       gs_app_set_management_plugin (app, "packagekit");
+       gs_app_set_management_plugin (app, plugin);
        gs_app_set_update_version (app, pk_package_get_version (package));
        gs_app_set_kind (app, AS_COMPONENT_KIND_GENERIC);
        gs_app_set_scope (app, AS_COMPONENT_SCOPE_SYSTEM);
@@ -832,9 +830,9 @@ gs_plugin_launch (GsPlugin *plugin,
                  GError **error)
 {
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app),
-                      gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
+
        return gs_plugin_app_launch (plugin, app, error);
 }
 
@@ -855,11 +853,11 @@ gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
 {
        if (gs_app_get_bundle_kind (app) == AS_BUNDLE_KIND_PACKAGE &&
            gs_app_get_scope (app) == AS_COMPONENT_SCOPE_SYSTEM) {
-               gs_app_set_management_plugin (app, "packagekit");
+               gs_app_set_management_plugin (app, plugin);
                gs_plugin_packagekit_set_packaging_format (plugin, app);
                return;
        } else if (gs_app_get_kind (app) == AS_COMPONENT_KIND_OPERATING_SYSTEM) {
-               gs_app_set_management_plugin (app, "packagekit");
+               gs_app_set_management_plugin (app, plugin);
        }
 }
 
@@ -1301,9 +1299,12 @@ gs_plugin_packagekit_refine_details (GsPluginPackagekit   *self,
        list_tmp = gs_app_list_new ();
        for (guint i = 0; i < gs_app_list_length (list); i++) {
                GsApp *app = gs_app_list_index (list, i);
+
                if (gs_app_has_quirk (app, GS_APP_QUIRK_IS_WILDCARD))
                        continue;
-               if (g_strcmp0 (gs_app_get_management_plugin (app), "packagekit") != 0)
+
+               /* only process this app if was created by this plugin */
+               if (!gs_app_has_management_plugin (app, GS_PLUGIN (self)))
                        continue;
                if (gs_app_get_source_id_default (app) == NULL)
                        continue;
@@ -1453,8 +1454,8 @@ gs_plugin_packagekit_refine_name_to_id (GsPluginPackagekit   *self,
                const gchar *tmp;
                if (gs_app_has_quirk (app, GS_APP_QUIRK_IS_WILDCARD))
                        continue;
-               tmp = gs_app_get_management_plugin (app);
-               if (tmp != NULL && g_strcmp0 (tmp, "packagekit") != 0)
+               if (!gs_app_has_management_plugin (app, NULL) &&
+                   !gs_app_has_management_plugin (app, GS_PLUGIN (self)))
                        continue;
                sources = gs_app_get_sources (app);
                if (sources->len == 0)
@@ -1498,8 +1499,8 @@ gs_plugin_packagekit_refine_filename_to_id (GsPluginPackagekit   *self,
                        continue;
                if (gs_app_get_source_id_default (app) != NULL)
                        continue;
-               tmp = gs_app_get_management_plugin (app);
-               if (tmp != NULL && g_strcmp0 (tmp, "packagekit") != 0)
+               if (!gs_app_has_management_plugin (app, NULL) &&
+                   !gs_app_has_management_plugin (app, GS_PLUGIN (self)))
                        continue;
                tmp = gs_app_get_id (app);
                if (tmp == NULL)
@@ -1544,15 +1545,15 @@ gs_plugin_packagekit_refine_update_details (GsPluginPackagekit   *self,
        g_autoptr(GsAppList) updatedetails_all = gs_app_list_new ();
        for (guint i = 0; i < gs_app_list_length (list); i++) {
                GsApp *app = gs_app_list_index (list, i);
-               const gchar *tmp;
+
                if (gs_app_has_quirk (app, GS_APP_QUIRK_IS_WILDCARD))
                        continue;
                if (gs_app_get_state (app) != GS_APP_STATE_UPDATABLE)
                        continue;
                if (gs_app_get_source_id_default (app) == NULL)
                        continue;
-               tmp = gs_app_get_management_plugin (app);
-               if (tmp != NULL && g_strcmp0 (tmp, "packagekit") != 0)
+               if (!gs_app_has_management_plugin (app, NULL) &&
+                   !gs_app_has_management_plugin (app, GS_PLUGIN (self)))
                        continue;
                if (gs_plugin_refine_requires_update_details (app, flags))
                        gs_app_list_add (updatedetails_all, app);
@@ -1616,7 +1617,7 @@ gs_plugin_refine (GsPlugin *plugin,
                GsApp *app = gs_app_list_index (list, i);
 
                /* only process this app if was created by this plugin */
-               if (g_strcmp0 (gs_app_get_management_plugin (app), "packagekit") != 0)
+               if (!gs_app_has_management_plugin (app, plugin))
                        continue;
 
                /* the scope is always system-wide */
@@ -1637,7 +1638,7 @@ gs_plugin_refine (GsPlugin *plugin,
                packages = gs_app_list_new ();
                for (i = 0; i < gs_app_list_length (list); i++) {
                        app = gs_app_list_index (list, i);
-                       if (g_strcmp0 (gs_app_get_management_plugin (app), "packagekit") != 0)
+                       if (!gs_app_has_management_plugin (app, plugin))
                                continue;
                        sources = gs_app_get_sources (app);
                        if (sources->len == 0)
@@ -2040,7 +2041,7 @@ gs_plugin_file_to_app (GsPlugin *plugin,
                             "invalid package-id: %s", package_id);
                return FALSE;
        }
-       gs_app_set_management_plugin (app, "packagekit");
+       gs_app_set_management_plugin (app, plugin);
        gs_app_set_kind (app, AS_COMPONENT_KIND_GENERIC);
        gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_PACKAGE);
        gs_app_set_state (app, GS_APP_STATE_AVAILABLE_LOCAL);
@@ -2199,7 +2200,7 @@ gs_plugin_add_updates_historical (GsPlugin *plugin,
 
                app = gs_app_new (NULL);
                gs_app_set_from_unique_id (app, "*/*/*/system/*", AS_COMPONENT_KIND_GENERIC);
-               gs_app_set_management_plugin (app, "packagekit");
+               gs_app_set_management_plugin (app, plugin);
                gs_app_add_quirk (app, GS_APP_QUIRK_IS_WILDCARD);
                gs_app_set_state (app, GS_APP_STATE_UNKNOWN);
                gs_app_set_kind (app, AS_COMPONENT_KIND_OPERATING_SYSTEM);
@@ -2226,7 +2227,7 @@ gs_plugin_add_updates_historical (GsPlugin *plugin,
                gs_plugin_packagekit_set_packaging_format (plugin, app);
                gs_app_add_source (app, split[0]);
                gs_app_set_update_version (app, split[1]);
-               gs_app_set_management_plugin (app, "packagekit");
+               gs_app_set_management_plugin (app, plugin);
                gs_app_add_source_id (app, package_id);
                gs_app_set_state (app, GS_APP_STATE_UPDATABLE);
                gs_app_set_kind (app, AS_COMPONENT_KIND_GENERIC);
@@ -2578,7 +2579,7 @@ gs_plugin_app_upgrade_download (GsPlugin *plugin,
        g_autoptr(PkResults) results = NULL;
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app), "packagekit") != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        /* check is distro-upgrade */
@@ -2651,8 +2652,7 @@ gs_plugin_enable_repo (GsPlugin *plugin,
        g_autoptr(PkError) error_code = NULL;
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (repo),
-                      gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (repo, plugin))
                return TRUE;
 
        /* is repo */
@@ -2707,8 +2707,7 @@ gs_plugin_disable_repo (GsPlugin *plugin,
        g_autoptr(PkError) error_code = NULL;
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (repo),
-                      gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (repo, plugin))
                return TRUE;
 
        /* is repo */
diff --git a/plugins/packagekit/gs-plugin-systemd-updates.c b/plugins/packagekit/gs-plugin-systemd-updates.c
index 17599932c..7eab573ce 100644
--- a/plugins/packagekit/gs-plugin-systemd-updates.c
+++ b/plugins/packagekit/gs-plugin-systemd-updates.c
@@ -160,7 +160,7 @@ gs_plugin_systemd_refine_app (GsPluginSystemdUpdates *self,
        g_autoptr(GMutexLocker) locker = NULL;
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app), "packagekit") != 0)
+       if (!gs_app_has_management_plugin (app, GS_PLUGIN (self)))
                return;
 
        /* the package is already downloaded */
@@ -404,7 +404,7 @@ _systemd_trigger_app (GsPluginSystemdUpdates  *self,
                return TRUE;
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app), "packagekit") != 0)
+       if (!gs_app_has_management_plugin (app, GS_PLUGIN (self)))
                return TRUE;
 
        /* already in correct state */
@@ -465,7 +465,7 @@ gs_plugin_update_cancel (GsPlugin *plugin,
        GsPluginSystemdUpdates *self = GS_PLUGIN_SYSTEMD_UPDATES (plugin);
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app), "packagekit") != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        /* already in correct state */
@@ -492,8 +492,9 @@ gs_plugin_app_upgrade_trigger (GsPlugin *plugin,
                                GError **error)
 {
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app), "packagekit") != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
+
        if (!gs_systemd_call_trigger_upgrade (plugin, PK_OFFLINE_ACTION_REBOOT, cancellable, error)) {
                gs_plugin_packagekit_error_convert (error);
                return FALSE;
diff --git a/plugins/packagekit/packagekit-common.c b/plugins/packagekit/packagekit-common.c
index 84dbfc695..042e4935d 100644
--- a/plugins/packagekit/packagekit-common.c
+++ b/plugins/packagekit/packagekit-common.c
@@ -263,7 +263,7 @@ gs_plugin_packagekit_add_results (GsPlugin *plugin,
                if (app == NULL) {
                        app = gs_app_new (NULL);
                        gs_plugin_packagekit_set_packaging_format (plugin, app);
-                       gs_app_set_management_plugin (app, "packagekit");
+                       gs_app_set_management_plugin (app, plugin);
                        gs_app_add_source (app, pk_package_get_name (package));
                        gs_app_add_source_id (app, pk_package_get_id (package));
                        gs_plugin_cache_add (plugin, pk_package_get_id (package), app);
@@ -379,7 +379,7 @@ gs_plugin_packagekit_set_metadata_from_package (GsPlugin *plugin,
        const gchar *data;
 
        gs_plugin_packagekit_set_packaging_format (plugin, app);
-       gs_app_set_management_plugin (app, "packagekit");
+       gs_app_set_management_plugin (app, plugin);
        gs_app_add_source (app, pk_package_get_name (package));
        gs_app_add_source_id (app, pk_package_get_id (package));
 
diff --git a/plugins/rpm-ostree/gs-plugin-rpm-ostree.c b/plugins/rpm-ostree/gs-plugin-rpm-ostree.c
index bd68c09c1..c13c3e867 100644
--- a/plugins/rpm-ostree/gs-plugin-rpm-ostree.c
+++ b/plugins/rpm-ostree/gs-plugin-rpm-ostree.c
@@ -341,13 +341,13 @@ gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
 {
        if (gs_app_get_bundle_kind (app) == AS_BUNDLE_KIND_PACKAGE &&
            gs_app_get_scope (app) == AS_COMPONENT_SCOPE_SYSTEM) {
-               gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+               gs_app_set_management_plugin (app, plugin);
                gs_app_add_quirk (app, GS_APP_QUIRK_NEEDS_REBOOT);
                app_set_rpm_ostree_packaging_format (app);
        }
 
        if (gs_app_get_kind (app) == AS_COMPONENT_KIND_OPERATING_SYSTEM) {
-               gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+               gs_app_set_management_plugin (app, plugin);
                gs_app_add_quirk (app, GS_APP_QUIRK_NEEDS_REBOOT);
        }
 }
@@ -627,7 +627,7 @@ app_from_modified_pkg_variant (GsPlugin *plugin, GVariant *variant)
 
        /* create new app */
        app = gs_app_new (NULL);
-       gs_app_set_management_plugin (app, "rpm-ostree");
+       gs_app_set_management_plugin (app, plugin);
        gs_app_add_quirk (app, GS_APP_QUIRK_NEEDS_REBOOT);
        app_set_rpm_ostree_packaging_format (app);
        gs_app_set_size_download (app, 0);
@@ -666,7 +666,7 @@ app_from_single_pkg_variant (GsPlugin *plugin, GVariant *variant, gboolean addit
 
        /* create new app */
        app = gs_app_new (NULL);
-       gs_app_set_management_plugin (app, "rpm-ostree");
+       gs_app_set_management_plugin (app, plugin);
        gs_app_add_quirk (app, GS_APP_QUIRK_NEEDS_REBOOT);
        app_set_rpm_ostree_packaging_format (app);
        gs_app_set_size_download (app, 0);
@@ -1163,7 +1163,7 @@ trigger_rpmostree_update (GsPluginRpmOstree *self,
                return TRUE;
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app), gs_plugin_get_name (GS_PLUGIN (self))) != 0)
+       if (!gs_app_has_management_plugin (app, GS_PLUGIN (self)))
                return TRUE;
 
        /* already in correct state */
@@ -1253,7 +1253,7 @@ gs_plugin_app_upgrade_trigger (GsPlugin *plugin,
        g_autoptr(GsRPMOSTreeSysroot) sysroot_proxy = NULL;
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app), gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        /* check is distro-upgrade */
@@ -1390,7 +1390,7 @@ gs_plugin_app_install (GsPlugin *plugin,
        g_autoptr(GsRPMOSTreeSysroot) sysroot_proxy = NULL;
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app), gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        /* enable repo, handled by dedicated function */
@@ -1496,7 +1496,7 @@ gs_plugin_app_remove (GsPlugin *plugin,
        g_autoptr(GsRPMOSTreeSysroot) sysroot_proxy = NULL;
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app), gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        if (!gs_rpmostree_ref_proxies (self, &os_proxy, &sysroot_proxy, cancellable, error))
@@ -1742,7 +1742,7 @@ resolve_appstream_source_file_to_package_name (GsPlugin *plugin,
                if (gs_app_get_source_default (app) == NULL) {
                        g_debug ("rpm: setting source to %s", name);
                        gs_app_add_source (app, name);
-                       gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+                       gs_app_set_management_plugin (app, plugin);
                        gs_app_add_quirk (app, GS_APP_QUIRK_NEEDS_REBOOT);
                        app_set_rpm_ostree_packaging_format (app);
                        gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_PACKAGE);
@@ -1834,23 +1834,23 @@ gs_rpm_ostree_refine_apps (GsPlugin *plugin,
                if (gs_app_has_quirk (app, GS_APP_QUIRK_IS_WILDCARD))
                        continue;
                /* set management plugin for apps where appstream just added the source package name in 
refine() */
-               if (gs_app_get_management_plugin (app) == NULL &&
+               if (gs_app_has_management_plugin (app, NULL) &&
                    gs_app_get_bundle_kind (app) == AS_BUNDLE_KIND_PACKAGE &&
                    gs_app_get_scope (app) == AS_COMPONENT_SCOPE_SYSTEM &&
                    gs_app_get_source_default (app) != NULL) {
-                       gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+                       gs_app_set_management_plugin (app, plugin);
                        gs_app_add_quirk (app, GS_APP_QUIRK_NEEDS_REBOOT);
                        app_set_rpm_ostree_packaging_format (app);
                }
                /* resolve the source package name based on installed appdata/desktop file name */
-               if (gs_app_get_management_plugin (app) == NULL &&
+               if (gs_app_has_management_plugin (app, NULL) &&
                    gs_app_get_bundle_kind (app) == AS_BUNDLE_KIND_UNKNOWN &&
                    gs_app_get_scope (app) == AS_COMPONENT_SCOPE_SYSTEM &&
                    gs_app_get_source_default (app) == NULL) {
                        if (!resolve_appstream_source_file_to_package_name (plugin, app, flags, cancellable, 
error))
                                return FALSE;
                }
-               if (g_strcmp0 (gs_app_get_management_plugin (app), gs_plugin_get_name (plugin)) != 0)
+               if (!gs_app_has_management_plugin (app, plugin))
                        continue;
                if (gs_app_get_source_default (app) == NULL)
                        continue;
@@ -1897,7 +1897,7 @@ gs_plugin_app_upgrade_download (GsPlugin *plugin,
        g_autoptr(GsRPMOSTreeSysroot) sysroot_proxy = NULL;
 
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app), gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        /* check is distro-upgrade */
@@ -1969,8 +1969,7 @@ gs_plugin_launch (GsPlugin *plugin,
                   GError **error)
 {
        /* only process this app if was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (app),
-                      gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        return gs_plugin_app_launch (plugin, app, error);
@@ -2050,7 +2049,7 @@ gs_plugin_file_to_app (GsPlugin *plugin,
 
        app = gs_app_new (NULL);
        gs_app_set_metadata (app, "GnomeSoftware::Creator", gs_plugin_get_name (plugin));
-       gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+       gs_app_set_management_plugin (app, plugin);
        if (h) {
                const gchar *str;
 
@@ -2178,7 +2177,7 @@ gs_plugin_add_search_what_provides (GsPlugin *plugin,
                /* create new app */
                app = gs_app_new (NULL);
                gs_app_set_metadata (app, "GnomeSoftware::Creator", gs_plugin_get_name (plugin));
-               gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+               gs_app_set_management_plugin (app, plugin);
                gs_app_add_quirk (app, GS_APP_QUIRK_NEEDS_REBOOT);
                app_set_rpm_ostree_packaging_format (app);
                gs_app_set_kind (app, AS_COMPONENT_KIND_GENERIC);
@@ -2221,7 +2220,7 @@ gs_plugin_add_sources (GsPlugin *plugin,
                        continue;
 
                app = gs_app_new (dnf_repo_get_id (repo));
-               gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+               gs_app_set_management_plugin (app, plugin);
                gs_app_set_kind (app, AS_COMPONENT_KIND_REPOSITORY);
                gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_PACKAGE);
                gs_app_add_quirk (app, GS_APP_QUIRK_NOT_LAUNCHABLE);
@@ -2253,7 +2252,7 @@ gs_plugin_enable_repo (GsPlugin *plugin,
        g_autoptr(GsRPMOSTreeSysroot) sysroot_proxy = NULL;
 
        /* only process this app if it was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (repo), gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (repo, plugin))
                return TRUE;
 
        /* enable repo */
@@ -2284,7 +2283,7 @@ gs_plugin_disable_repo (GsPlugin *plugin,
        g_autoptr(GsRPMOSTreeSysroot) sysroot_proxy = NULL;
 
        /* only process this app if it was created by this plugin */
-       if (g_strcmp0 (gs_app_get_management_plugin (repo), gs_plugin_get_name (plugin)) != 0)
+       if (!gs_app_has_management_plugin (repo, plugin))
                return TRUE;
 
        /* disable repo */
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index bc483c8a0..0c00bc130 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -148,7 +148,7 @@ void
 gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
 {
        if (gs_app_get_bundle_kind (app) == AS_BUNDLE_KIND_SNAP)
-               gs_app_set_management_plugin (app, "snap");
+               gs_app_set_management_plugin (app, plugin);
 
        if (gs_app_get_id (app) != NULL && g_str_has_prefix (gs_app_get_id (app), "io.snapcraft.")) {
                g_autofree gchar *name_and_id = NULL;
@@ -161,7 +161,7 @@ gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
                        snap_name = name_and_id;
                        /*id = divider + 1;*/ /* NOTE: Should probably validate ID */
 
-                       gs_app_set_management_plugin (app, "snap");
+                       gs_app_set_management_plugin (app, plugin);
                        gs_app_set_metadata (app, "snap::name", snap_name);
                        gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_SNAP);
                }
@@ -359,7 +359,7 @@ snap_to_app (GsPluginSnap *self, SnapdSnap *snap, const gchar *branch)
                gs_plugin_cache_add (GS_PLUGIN (self), cache_id, app);
        }
 
-       gs_app_set_management_plugin (app, "snap");
+       gs_app_set_management_plugin (app, plugin);
        gs_app_add_quirk (app, GS_APP_QUIRK_DO_NOT_AUTO_UPDATE);
        if (gs_app_get_kind (app) != AS_COMPONENT_KIND_DESKTOP_APP)
                gs_app_add_quirk (app, GS_APP_QUIRK_NOT_LAUNCHABLE);
@@ -719,7 +719,7 @@ gs_plugin_add_alternates (GsPlugin *plugin,
        GsPluginSnap *self = GS_PLUGIN_SNAP (plugin);
 
        /* If it is a snap, find the channels that snap provides, otherwise find snaps that match on common 
id */
-       if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") == 0) {
+       if (gs_app_has_management_plugin (app, plugin)) {
                const gchar *snap_name;
                g_autoptr(SnapdSnap) snap = NULL;
 
@@ -1083,7 +1083,7 @@ refine_app_with_client (GsPluginSnap         *self,
        guint64 release_date = 0;
 
        /* not us */
-       if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") != 0)
+       if (!gs_app_has_management_plugin (app, GS_PLUGIN (self)))
                return TRUE;
 
        snap_name = gs_app_get_metadata_item (app, "snap::name");
@@ -1301,7 +1301,7 @@ gs_plugin_app_install (GsPlugin *plugin,
        g_autoptr(GError) error_local = NULL;
 
        /* We can only install apps we know of */
-       if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        client = get_client (self, error);
@@ -1391,7 +1391,7 @@ gs_plugin_launch (GsPlugin *plugin,
        g_autoptr(GAppInfo) info = NULL;
 
        /* We can only launch apps we know of */
-       if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        launch_name = gs_app_get_metadata_item (app, "snap::launch-name");
@@ -1431,7 +1431,7 @@ gs_plugin_app_remove (GsPlugin *plugin,
        g_autoptr(SnapdClient) client = NULL;
 
        /* We can only remove apps we know of */
-       if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") != 0)
+       if (!gs_app_has_management_plugin (app, plugin))
                return TRUE;
 
        client = get_client (self, error);
diff --git a/src/gs-application.c b/src/gs-application.c
index c9df3656c..188eeb385 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -603,16 +603,19 @@ details_pkg_activated (GSimpleAction *action,
 {
        GsApplication *app = GS_APPLICATION (data);
        const gchar *name;
-       const gchar *plugin;
+       const gchar *plugin_name;
        g_autoptr (GsApp) a = NULL;
 
        gs_application_present_window (app, NULL);
 
-       g_variant_get (parameter, "(&s&s)", &name, &plugin);
+       g_variant_get (parameter, "(&s&s)", &name, &plugin_name);
        a = gs_app_new (NULL);
        gs_app_add_source (a, name);
-       if (strcmp (plugin, "") != 0)
+       if (strcmp (plugin_name, "") != 0) {
+               GsPlugin *plugin = gs_plugin_loader_find_plugin (app->plugin_loader, plugin_name);
                gs_app_set_management_plugin (a, plugin);
+       }
+
        gs_shell_reset_state (app->shell);
        gs_shell_show_app (app->shell, a);
 }
@@ -784,14 +787,15 @@ launch_activated (GSimpleAction *action,
 {
        GsApplication *self = GS_APPLICATION (data);
        GsApp *app = NULL;
-       const gchar *id, *management_plugin;
+       const gchar *id, *management_plugin_name;
        g_autoptr(GsAppList) list = NULL;
        g_autoptr(GsPluginJob) search_job = NULL;
        g_autoptr(GsPluginJob) launch_job = NULL;
        g_autoptr(GError) error = NULL;
        guint ii, len;
+       GsPlugin *management_plugin;
 
-       g_variant_get (parameter, "(&s&s)", &id, &management_plugin);
+       g_variant_get (parameter, "(&s&s)", &id, &management_plugin_name);
 
        search_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_SEARCH,
                                         "search", id,
@@ -801,21 +805,23 @@ launch_activated (GSimpleAction *action,
                                         NULL);
        list = gs_plugin_loader_job_process (self->plugin_loader, search_job, self->cancellable, &error);
        if (!list) {
-               g_warning ("Failed to search for application '%s' (from '%s'): %s", id, management_plugin, 
error ? error->message : "Unknown error");
+               g_warning ("Failed to search for application '%s' (from '%s'): %s", id, 
management_plugin_name, error ? error->message : "Unknown error");
                return;
        }
 
+       management_plugin = gs_plugin_loader_find_plugin (self->plugin_loader, management_plugin_name);
+
        len = gs_app_list_length (list);
        for (ii = 0; ii < len && !app; ii++) {
                GsApp *list_app = gs_app_list_index (list, ii);
 
                if (gs_app_is_installed (list_app) &&
-                   g_strcmp0 (gs_app_get_management_plugin (list_app), management_plugin) == 0)
+                   gs_app_has_management_plugin (list_app, management_plugin))
                        app = list_app;
        }
 
        if (!app) {
-               g_warning ("Did not find application '%s' from '%s'", id, management_plugin);
+               g_warning ("Did not find application '%s' from '%s'", id, management_plugin_name);
                return;
        }
 
diff --git a/src/gs-common.c b/src/gs-common.c
index 2e26bb176..8ef7d5932 100644
--- a/src/gs-common.c
+++ b/src/gs-common.c
@@ -169,10 +169,12 @@ gs_app_notify_installed (GsApp *app)
                                                       "app.reboot", NULL);
        } else if (gs_app_get_kind (app) == AS_COMPONENT_KIND_DESKTOP_APP) {
                /* TRANSLATORS: this is button that opens the newly installed application */
+               g_autoptr(GsPlugin) plugin = gs_app_dup_management_plugin (app);
+               const gchar *plugin_name = (plugin != NULL) ? gs_plugin_get_name (plugin) : "";
                g_notification_add_button_with_target (n, _("Launch"),
                                                       "app.launch", "(ss)",
                                                       gs_app_get_id (app),
-                                                      gs_app_get_management_plugin (app));
+                                                      plugin_name);
        }
        g_notification_set_default_action_and_target  (n, "app.details", "(ss)",
                                                       gs_app_get_unique_id (app), "");
diff --git a/src/gs-repo-row.c b/src/gs-repo-row.c
index e07cb946d..9efa6f12e 100644
--- a/src/gs-repo-row.c
+++ b/src/gs-repo-row.c
@@ -196,7 +196,7 @@ static void
 gs_repo_row_set_repo (GsRepoRow *self, GsApp *repo)
 {
        GsRepoRowPrivate *priv = gs_repo_row_get_instance_private (self);
-       GsPlugin *plugin;
+       g_autoptr(GsPlugin) plugin = NULL;
        g_autofree gchar *comment = NULL;
        const gchar *tmp;
 
@@ -207,7 +207,7 @@ gs_repo_row_set_repo (GsRepoRow *self, GsApp *repo)
                                 G_CALLBACK (repo_state_changed_cb),
                                 self, 0);
 
-       plugin = gs_plugin_loader_find_plugin (priv->plugin_loader, gs_app_get_management_plugin (repo));
+       plugin = gs_app_dup_management_plugin (repo);
        priv->supports_remove = plugin != NULL && gs_plugin_get_action_supported (plugin, 
GS_PLUGIN_ACTION_REMOVE_REPO);
        priv->supports_enable_disable = plugin != NULL &&
                gs_plugin_get_action_supported (plugin, GS_PLUGIN_ACTION_ENABLE_REPO) &&
diff --git a/src/gs-repos-dialog.c b/src/gs-repos-dialog.c
index 441570596..ed956163f 100644
--- a/src/gs-repos-dialog.c
+++ b/src/gs-repos-dialog.c
@@ -338,10 +338,13 @@ static gboolean
 is_third_party_repo (GsReposDialog *dialog,
                     GsApp *repo)
 {
+       g_autoptr(GsPlugin) plugin = gs_app_dup_management_plugin (repo);
+       const gchar *plugin_name = (plugin != NULL) ? gs_plugin_get_name (plugin) : NULL;
+
        return gs_app_get_scope (repo) == AS_COMPONENT_SCOPE_SYSTEM &&
               gs_fedora_third_party_util_is_third_party_repo (dialog->third_party_repos,
                                                               gs_app_get_id (repo),
-                                                              gs_app_get_management_plugin (repo));
+                                                              plugin_name);
 }
 
 static void
@@ -373,8 +376,11 @@ add_repo (GsReposDialog *dialog,
        origin_ui = gs_app_get_origin_ui (repo);
        if (!origin_ui)
                origin_ui = gs_app_get_packaging_format (repo);
-       if (!origin_ui)
-               origin_ui = g_strdup (gs_app_get_management_plugin (repo));
+       if (!origin_ui) {
+               g_autoptr(GsPlugin) plugin = gs_app_dup_management_plugin (repo);
+               origin_ui = (plugin != NULL) ? g_strdup (gs_plugin_get_name (plugin)) : NULL;
+       }
+
        section = g_hash_table_lookup (dialog->sections, origin_ui);
        if (section == NULL) {
                section = gs_repos_section_new (dialog->plugin_loader, FALSE);
diff --git a/src/gs-shell.c b/src/gs-shell.c
index a7f04f123..11abeee04 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -1251,7 +1251,7 @@ gs_shell_show_event_refresh (GsShell *shell, GsPluginEvent *event)
                                 * where the %s is the source (e.g. "alt.fedoraproject.org") */
                                g_string_append_printf (str, _("Unable to download updates from %s"),
                                                        str_origin);
-                               if (gs_app_get_management_plugin (origin) != NULL)
+                               if (!gs_app_has_management_plugin (origin, NULL))
                                        buttons |= GS_SHELL_EVENT_BUTTON_SOURCES;
                        }
                } else {


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