[gnome-software/wip/hughsie/GsApp-custom: 1/3] Add gs_plugin_app_new() and allow plugins to use a custom GsApp type



commit a6103c077fa8e58250d3d7e3ae61d925e9049e87
Author: Richard Hughes <richard hughsie com>
Date:   Mon Feb 11 11:15:28 2019 +0000

    Add gs_plugin_app_new() and allow plugins to use a custom GsApp type
    
    Commit 1509cb00 removed this useful functionality, because it was causing hard
    to debug crashes. This, in a large part, was due to plugins creating GsApps
    themselves, rather than calling into the plugin.
    
    To prevent this happening again actually hide the gs_app_new() functionality
    from the plugins, and provide two helpers for the cases where this doesn't need
    to go via the plugin loader; which are download status reporting and wildcards.

 lib/gs-app-private.h                               |  1 +
 lib/gs-app.c                                       | 40 ++++++++++++++++++++++
 lib/gs-app.h                                       |  3 +-
 lib/gs-plugin.c                                    | 23 +++++++++++++
 lib/gs-plugin.h                                    |  6 +++-
 plugins/core/gs-appstream.c                        | 11 +++---
 plugins/core/gs-plugin-generic-updates.c           |  2 +-
 plugins/core/gs-plugin-hardcoded-featured.c        |  3 +-
 plugins/core/gs-plugin-hardcoded-popular.c         |  3 +-
 plugins/core/gs-plugin-os-release.c                |  2 +-
 plugins/core/gs-plugin-rewrite-resource.c          |  2 +-
 plugins/dpkg/gs-plugin-dpkg.c                      |  2 +-
 plugins/dummy/gs-plugin-dummy.c                    | 36 +++++++++----------
 .../gs-plugin-fedora-pkgdb-collections.c           |  7 ++--
 plugins/flatpak/gs-flatpak.c                       |  6 ++--
 plugins/fwupd/gs-plugin-fwupd.c                    | 11 +++---
 plugins/odrs/gs-plugin-odrs.c                      | 11 +++---
 plugins/packagekit/gs-plugin-packagekit-history.c  |  8 ++---
 plugins/packagekit/gs-plugin-packagekit-local.c    |  2 +-
 plugins/packagekit/gs-plugin-packagekit-offline.c  |  4 +--
 plugins/packagekit/gs-plugin-packagekit-refresh.c  |  2 +-
 .../packagekit/gs-plugin-packagekit-url-to-app.c   |  2 +-
 plugins/packagekit/gs-plugin-packagekit.c          |  4 +--
 plugins/packagekit/packagekit-common.c             |  2 +-
 plugins/rpm-ostree/gs-plugin-rpm-ostree.c          |  6 ++--
 .../shell-extensions/gs-plugin-shell-extensions.c  |  8 ++---
 plugins/snap/gs-plugin-snap.c                      |  2 +-
 27 files changed, 135 insertions(+), 74 deletions(-)
---
diff --git a/lib/gs-app-private.h b/lib/gs-app-private.h
index 95025e65..715b4bcf 100644
--- a/lib/gs-app-private.h
+++ b/lib/gs-app-private.h
@@ -25,5 +25,6 @@ void           gs_app_set_pending_action      (GsApp          *app,
                                                 GsPluginAction  action);
 gint            gs_app_compare_priority        (GsApp          *app1,
                                                 GsApp          *app2);
+GsApp          *gs_app_new                     (const gchar    *id);
 
 G_END_DECLS
diff --git a/lib/gs-app.c b/lib/gs-app.c
index 186ceb54..1b0df824 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -4390,6 +4390,46 @@ gs_app_new (const gchar *id)
        return GS_APP (app);
 }
 
+/**
+ * gs_app_new_wildcard:
+ * @id: an application ID, or %NULL, e.g. "org.gnome.Software.desktop"
+ *
+ * Creates a new application wildcard object. The applications created using
+ * this function will be converted to "actual" #GsApp objects that can be
+ * installed by a specific plugin.
+ *
+ * Returns: a new #GsApp
+ *
+ * Since: 3.34
+ **/
+GsApp *
+gs_app_new_wildcard (const gchar *id)
+{
+       GsApp *app = gs_app_new (id);
+       gs_app_add_quirk (app, GS_APP_QUIRK_IS_WILDCARD);
+       return app;
+}
+
+/**
+ * gs_app_new_source:
+ * @id: an application ID, or %NULL, e.g. "org.gnome.Software.desktop"
+ *
+ * Creates a new application source object, typically used for reporting
+ * download progress. The applications created using this function should not
+ * be added as results to the various plugin vfuncs.
+ *
+ * Returns: a new #GsApp
+ *
+ * Since: 3.34
+ **/
+GsApp *
+gs_app_new_source (const gchar *id)
+{
+       GsApp *app = gs_app_new (id);
+       gs_app_set_kind (app, AS_APP_KIND_SOURCE);
+       return app;
+}
+
 /**
  * gs_app_set_from_unique_id:
  * @app: a #GsApp
diff --git a/lib/gs-app.h b/lib/gs-app.h
index cd185154..a57b937e 100644
--- a/lib/gs-app.h
+++ b/lib/gs-app.h
@@ -159,7 +159,8 @@ typedef enum {
 #define MEDIUM_PERMISSIONS (LIMITED_PERMISSIONS | \
                        GS_APP_PERMISSIONS_X11)
 
-GsApp          *gs_app_new                     (const gchar    *id);
+GsApp          *gs_app_new_wildcard            (const gchar    *id);
+GsApp          *gs_app_new_source              (const gchar    *id);
 G_DEPRECATED_FOR(gs_app_set_from_unique_id)
 GsApp          *gs_app_new_from_unique_id      (const gchar    *unique_id);
 void            gs_app_set_from_unique_id      (GsApp          *app,
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index eab2287a..d7cd2b32 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -40,6 +40,7 @@
 #endif
 
 #include "gs-app-list-private.h"
+#include "gs-app-private.h"
 #include "gs-os-release.h"
 #include "gs-plugin-private.h"
 #include "gs-plugin.h"
@@ -376,6 +377,28 @@ gs_plugin_interactive_dec (GsPlugin *plugin)
                gs_plugin_remove_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE);
 }
 
+/**
+ * gs_plugin_app_new:
+ * @plugin: a #GsPlugin
+ * @id: an application ID
+ *
+ * Creates a GsApp, which may possibly be a subclassed type.
+ * To set a custom type used when creating objects, plugins can use the
+ * GsPluginClass:create_app() vfunc.
+ *
+ * Returns: (transfer full): a #GsApp
+ *
+ * Since: 3.34
+ **/
+GsApp *
+gs_plugin_app_new (GsPlugin *plugin, const gchar *id)
+{
+       GsPluginClass *klass = GS_PLUGIN_GET_CLASS (plugin);
+       if (klass->create_app != NULL)
+               return klass->create_app (plugin, id);
+       return gs_app_new (id);
+}
+
 /**
  * gs_plugin_get_name:
  * @plugin: a #GsPlugin
diff --git a/lib/gs-plugin.h b/lib/gs-plugin.h
index d4595186..bcde77e5 100644
--- a/lib/gs-plugin.h
+++ b/lib/gs-plugin.h
@@ -38,7 +38,9 @@ struct _GsPluginClass
                                                         GsPluginEvent  *event);
        void                    (*allow_updates)        (GsPlugin       *plugin,
                                                         gboolean        allow_updates);
-       gpointer                 padding[26];
+       GsApp                   *(*create_app)          (GsPlugin       *plugin,
+                                                        const gchar    *id);
+       gpointer                 padding[25];
 };
 
 typedef struct GsPluginData    GsPluginData;
@@ -59,6 +61,8 @@ void           gs_plugin_set_appstream_id             (GsPlugin       *plugin,
 gboolean        gs_plugin_get_enabled                  (GsPlugin       *plugin);
 void            gs_plugin_set_enabled                  (GsPlugin       *plugin,
                                                         gboolean        enabled);
+GsApp          *gs_plugin_app_new                      (GsPlugin       *plugin,
+                                                        const gchar    *id);
 gboolean        gs_plugin_has_flags                    (GsPlugin       *plugin,
                                                         GsPluginFlags   flags);
 void            gs_plugin_add_flags                    (GsPlugin       *plugin,
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index de54a20d..911875ac 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -18,7 +18,7 @@ GsApp *
 gs_appstream_create_app (GsPlugin *plugin, XbSilo *silo, XbNode *component, GError **error)
 {
        GsApp *app;
-       g_autoptr(GsApp) app_new = gs_app_new (NULL);
+       g_autoptr(GsApp) app_new = gs_plugin_app_new (plugin, NULL);
 
        /* refine enough to get the unique ID */
        if (!gs_appstream_refine_app (plugin, app_new, silo, component,
@@ -1222,8 +1222,7 @@ gs_appstream_add_popular (GsPlugin *plugin,
                const gchar *component_id = xb_node_query_text (component, "id", NULL);
                if (component_id == NULL)
                        continue;
-               app = gs_app_new (component_id);
-               gs_app_add_quirk (app, GS_APP_QUIRK_IS_WILDCARD);
+               app = gs_app_new_wildcard (component_id);
                gs_app_list_add (list, app);
        }
        return TRUE;
@@ -1312,8 +1311,7 @@ gs_appstream_add_alternates (GsPlugin *plugin,
        for (guint i = 0; i < ids->len; i++) {
                XbNode *n = g_ptr_array_index (ids, i);
                g_autoptr(GsApp) app2 = NULL;
-               app2 = gs_app_new (xb_node_get_text (n));
-               gs_app_add_quirk (app2, GS_APP_QUIRK_IS_WILDCARD);
+               app2 = gs_app_new_wildcard (xb_node_get_text (n));
                gs_app_list_add (list, app2);
        }
        return TRUE;
@@ -1348,8 +1346,7 @@ gs_appstream_add_featured (GsPlugin *plugin,
                const gchar *component_id = xb_node_query_text (component, "id", NULL);
                if (component_id == NULL)
                        continue;
-               app = gs_app_new (component_id);
-               gs_app_add_quirk (app, GS_APP_QUIRK_IS_WILDCARD);
+               app = gs_app_new_wildcard (component_id);
                if (!gs_appstream_copy_metadata (app, component, error))
                        return FALSE;
                gs_app_list_add (list, app);
diff --git a/plugins/core/gs-plugin-generic-updates.c b/plugins/core/gs-plugin-generic-updates.c
index 9512a7ec..25dc5cde 100644
--- a/plugins/core/gs-plugin-generic-updates.c
+++ b/plugins/core/gs-plugin-generic-updates.c
@@ -43,7 +43,7 @@ gs_plugin_generic_updates_get_os_update (GsPlugin *plugin)
        g_autoptr(AsIcon) ic = NULL;
 
        /* create new */
-       app = gs_app_new (id);
+       app = gs_plugin_app_new (plugin, id);
        gs_app_add_quirk (app, GS_APP_QUIRK_IS_PROXY);
        gs_app_set_management_plugin (app, "");
        gs_app_set_kind (app, AS_APP_KIND_OS_UPDATE);
diff --git a/plugins/core/gs-plugin-hardcoded-featured.c b/plugins/core/gs-plugin-hardcoded-featured.c
index bb10fb73..005dee62 100644
--- a/plugins/core/gs-plugin-hardcoded-featured.c
+++ b/plugins/core/gs-plugin-hardcoded-featured.c
@@ -61,8 +61,7 @@ gs_plugin_add_featured (GsPlugin *plugin,
                }
 
                /* create new */
-               app = gs_app_new (myapps[i].id);
-               gs_app_add_quirk (app, GS_APP_QUIRK_IS_WILDCARD);
+               app = gs_app_new_wildcard (myapps[i].id);
                gs_app_set_metadata (app, "GnomeSoftware::Creator",
                                     gs_plugin_get_name (plugin));
                gs_app_set_metadata (app, "GnomeSoftware::FeatureTile-css",
diff --git a/plugins/core/gs-plugin-hardcoded-popular.c b/plugins/core/gs-plugin-hardcoded-popular.c
index 7a246599..3069a9a5 100644
--- a/plugins/core/gs-plugin-hardcoded-popular.c
+++ b/plugins/core/gs-plugin-hardcoded-popular.c
@@ -52,8 +52,7 @@ gs_plugin_add_popular (GsPlugin *plugin,
                }
 
                /* create new */
-               app = gs_app_new (apps[i]);
-               gs_app_add_quirk (app, GS_APP_QUIRK_IS_WILDCARD);
+               app = gs_app_new_wildcard (apps[i]);
                gs_app_set_metadata (app, "GnomeSoftware::Creator",
                                     gs_plugin_get_name (plugin));
                gs_app_list_add (list, app);
diff --git a/plugins/core/gs-plugin-os-release.c b/plugins/core/gs-plugin-os-release.c
index 2bbb2f28..5892674c 100644
--- a/plugins/core/gs-plugin-os-release.c
+++ b/plugins/core/gs-plugin-os-release.c
@@ -17,7 +17,7 @@ void
 gs_plugin_initialize (GsPlugin *plugin)
 {
        GsPluginData *priv = gs_plugin_alloc_data (plugin, sizeof(GsPluginData));
-       priv->app_system = gs_app_new ("system");
+       priv->app_system = gs_plugin_app_new (plugin, "system");
        gs_app_set_kind (priv->app_system, AS_APP_KIND_OS_UPGRADE);
        gs_app_set_state (priv->app_system, AS_APP_STATE_INSTALLED);
 }
diff --git a/plugins/core/gs-plugin-rewrite-resource.c b/plugins/core/gs-plugin-rewrite-resource.c
index cf66b746..292b189c 100644
--- a/plugins/core/gs-plugin-rewrite-resource.c
+++ b/plugins/core/gs-plugin-rewrite-resource.c
@@ -35,7 +35,7 @@ gs_plugin_refine_app (GsPlugin *plugin,
                const gchar *css = gs_app_get_metadata_item (app, keys[i]);
                if (css != NULL) {
                        g_autofree gchar *css_new = NULL;
-                       g_autoptr(GsApp) app_dl = gs_app_new (gs_plugin_get_name (plugin));
+                       g_autoptr(GsApp) app_dl = gs_app_new_source (gs_plugin_get_name (plugin));
                        gs_app_set_summary_missing (app_dl,
                                                    /* TRANSLATORS: status text when downloading */
                                                    _("Downloading featured images…"));
diff --git a/plugins/dpkg/gs-plugin-dpkg.c b/plugins/dpkg/gs-plugin-dpkg.c
index a90c838a..7c1cacc9 100644
--- a/plugins/dpkg/gs-plugin-dpkg.c
+++ b/plugins/dpkg/gs-plugin-dpkg.c
@@ -75,7 +75,7 @@ gs_plugin_file_to_app (GsPlugin *plugin,
        }
 
        /* create app */
-       app = gs_app_new (NULL);
+       app = gs_plugin_app_new (plugin, NULL);
        gs_app_set_state (app, AS_APP_STATE_AVAILABLE_LOCAL);
        gs_app_add_source (app, tokens[0]);
        gs_app_set_name (app, GS_APP_QUALITY_LOWEST, tokens[0]);
diff --git a/plugins/dummy/gs-plugin-dummy.c b/plugins/dummy/gs-plugin-dummy.c
index bb3b1b12..bbab3c55 100644
--- a/plugins/dummy/gs-plugin-dummy.c
+++ b/plugins/dummy/gs-plugin-dummy.c
@@ -62,7 +62,7 @@ gs_plugin_initialize (GsPlugin *plugin)
        }
 
        /* add source */
-       priv->cached_origin = gs_app_new (gs_plugin_get_name (plugin));
+       priv->cached_origin = gs_app_new_source (gs_plugin_get_name (plugin));
        gs_app_set_kind (priv->cached_origin, AS_APP_KIND_SOURCE);
        gs_app_set_origin_hostname (priv->cached_origin, "http://www.bbc.co.uk/";);
 
@@ -197,7 +197,7 @@ gs_plugin_url_to_app (GsPlugin *plugin,
 
        /* create app */
        path = gs_utils_get_url_path (url);
-       app = gs_app_new (path);
+       app = gs_plugin_app_new (plugin, path);
        gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
        gs_app_set_metadata (app, "GnomeSoftware::Creator",
                             gs_plugin_get_name (plugin));
@@ -271,7 +271,7 @@ gs_plugin_add_alternates (GsPlugin *plugin,
                          GError **error)
 {
        if (g_strcmp0 (gs_app_get_id (app), "zeus.desktop") == 0) {
-               g_autoptr(GsApp) app2 = gs_app_new ("chiron.desktop");
+               g_autoptr(GsApp) app2 = gs_plugin_app_new (plugin, "chiron.desktop");
                gs_app_list_add (list, app2);
        }
        return TRUE;
@@ -320,7 +320,7 @@ gs_plugin_add_search (GsPlugin *plugin,
        as_icon_set_name (ic, "drive-harddisk");
 
        /* add a live updatable normal application */
-       app = gs_app_new ("chiron.desktop");
+       app = gs_plugin_app_new (plugin, "chiron.desktop");
        gs_app_set_name (app, GS_APP_QUALITY_NORMAL, "Chiron");
        gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, "A teaching application");
        gs_app_add_icon (app, ic);
@@ -362,7 +362,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
        as_icon_set_name (ic, "drive-harddisk");
 
        /* add a live updatable normal application */
-       app = gs_app_new ("chiron.desktop");
+       app = gs_plugin_app_new (plugin, "chiron.desktop");
        gs_app_set_name (app, GS_APP_QUALITY_NORMAL, "Chiron");
        gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, "A teaching application");
        gs_app_set_update_details (app, "Do not crash when using libvirt.");
@@ -375,7 +375,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
        g_object_unref (app);
 
        /* add a offline OS update */
-       app = gs_app_new (NULL);
+       app = gs_plugin_app_new (plugin, NULL);
        gs_app_set_name (app, GS_APP_QUALITY_NORMAL, "libvirt-glib-devel");
        gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, "Development files for libvirt");
        gs_app_set_update_details (app, "Fix several memory leaks.");
@@ -391,7 +391,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
        g_object_unref (app);
 
        /* add a live OS update */
-       app = gs_app_new (NULL);
+       app = gs_plugin_app_new (plugin, NULL);
        gs_app_set_name (app, GS_APP_QUALITY_NORMAL, "chiron-libs");
        gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, "library for chiron");
        gs_app_set_update_details (app, "Do not crash when using libvirt.");
@@ -407,7 +407,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
        g_object_unref (app);
 
        /* add a proxy app update */
-       proxy = gs_app_new ("proxy.desktop");
+       proxy = gs_plugin_app_new (plugin, "proxy.desktop");
        gs_app_set_name (proxy, GS_APP_QUALITY_NORMAL, "Proxy");
        gs_app_set_summary (proxy, GS_APP_QUALITY_NORMAL, "A proxy app");
        gs_app_set_update_details (proxy, "Update all related apps.");
@@ -421,7 +421,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
        g_object_unref (proxy);
 
        /* add a proxy related app */
-       app = gs_app_new ("proxy-related-app.desktop");
+       app = gs_plugin_app_new (plugin, "proxy-related-app.desktop");
        gs_app_set_name (app, GS_APP_QUALITY_NORMAL, "Related app");
        gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, "A related app");
        gs_app_set_kind (app, AS_APP_KIND_DESKTOP);
@@ -431,7 +431,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
        g_object_unref (app);
 
        /* add another proxy related app */
-       app = gs_app_new ("proxy-another-related-app.desktop");
+       app = gs_plugin_app_new (plugin, "proxy-another-related-app.desktop");
        gs_app_set_name (app, GS_APP_QUALITY_NORMAL, "Another Related app");
        gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, "A related app");
        gs_app_set_kind (app, AS_APP_KIND_DESKTOP);
@@ -455,7 +455,7 @@ gs_plugin_add_installed (GsPlugin *plugin,
 
        /* add all packages */
        for (i = 0; packages[i] != NULL; i++) {
-               g_autoptr(GsApp) app = gs_app_new (NULL);
+               g_autoptr(GsApp) app = gs_plugin_app_new (plugin, NULL);
                gs_app_add_source (app, packages[i]);
                gs_app_set_state (app, AS_APP_STATE_INSTALLED);
                gs_app_set_kind (app, AS_APP_KIND_GENERIC);
@@ -466,7 +466,7 @@ gs_plugin_add_installed (GsPlugin *plugin,
 
        /* add all app-ids */
        for (i = 0; app_ids[i] != NULL; i++) {
-               g_autoptr(GsApp) app = gs_app_new (app_ids[i]);
+               g_autoptr(GsApp) app = gs_plugin_app_new (plugin, app_ids[i]);
                gs_app_set_state (app, AS_APP_STATE_INSTALLED);
                gs_app_set_kind (app, AS_APP_KIND_DESKTOP);
                gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
@@ -486,14 +486,14 @@ gs_plugin_add_popular (GsPlugin *plugin,
        g_autoptr(GsApp) app2 = NULL;
 
        /* add wildcard */
-       app1 = gs_app_new ("zeus.desktop");
+       app1 = gs_plugin_app_new (plugin, "zeus.desktop");
        gs_app_add_quirk (app1, GS_APP_QUIRK_IS_WILDCARD);
        gs_app_set_metadata (app1, "GnomeSoftware::Creator",
                             gs_plugin_get_name (plugin));
        gs_app_list_add (list, app1);
 
        /* add again, this time with a prefix so it gets deduplicated */
-       app2 = gs_app_new ("zeus.desktop");
+       app2 = gs_plugin_app_new (plugin, "zeus.desktop");
        gs_app_set_scope (app2, AS_APP_SCOPE_USER);
        gs_app_set_bundle_kind (app2, AS_BUNDLE_KIND_SNAP);
        gs_app_set_metadata (app2, "GnomeSoftware::Creator",
@@ -730,7 +730,7 @@ gs_plugin_add_category_apps (GsPlugin *plugin,
                             GCancellable *cancellable,
                             GError **error)
 {
-       g_autoptr(GsApp) app = gs_app_new ("chiron.desktop");
+       g_autoptr(GsApp) app = gs_plugin_app_new (plugin, "chiron.desktop");
        gs_app_set_name (app, GS_APP_QUALITY_NORMAL, "Chiron");
        gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, "View and use virtual machines");
        gs_app_set_url (app, AS_URL_KIND_HOMEPAGE, "http://www.box.org";);
@@ -750,7 +750,7 @@ gs_plugin_add_recent (GsPlugin *plugin,
                      GCancellable *cancellable,
                      GError **error)
 {
-       g_autoptr(GsApp) app = gs_app_new ("chiron.desktop");
+       g_autoptr(GsApp) app = gs_plugin_app_new (plugin, "chiron.desktop");
        gs_app_set_name (app, GS_APP_QUALITY_NORMAL, "Chiron");
        gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, "View and use virtual machines");
        gs_app_set_url (app, AS_URL_KIND_HOMEPAGE, "http://www.box.org";);
@@ -784,7 +784,7 @@ gs_plugin_add_distro_upgrades (GsPlugin *plugin,
                return TRUE;
        }
 
-       app = gs_app_new ("org.fedoraproject.release-rawhide.upgrade");
+       app = gs_plugin_app_new (plugin, "org.fedoraproject.release-rawhide.upgrade");
        gs_app_set_scope (app, AS_APP_SCOPE_USER);
        gs_app_set_kind (app, AS_APP_KIND_OS_UPGRADE);
        gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_PACKAGE);
@@ -828,7 +828,7 @@ gs_plugin_refresh (GsPlugin *plugin,
                   GCancellable *cancellable,
                   GError **error)
 {
-       g_autoptr(GsApp) app = gs_app_new (NULL);
+       g_autoptr(GsApp) app = gs_plugin_app_new (plugin, NULL);
        return gs_plugin_dummy_delay (plugin, app, 3100, cancellable, error);
 }
 
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 e41bbc88..6db6e082 100644
--- a/plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c
+++ b/plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c
@@ -151,8 +151,7 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
        }
 
        /* add source */
-       priv->cached_origin = gs_app_new (gs_plugin_get_name (plugin));
-       gs_app_set_kind (priv->cached_origin, AS_APP_KIND_SOURCE);
+       priv->cached_origin = gs_app_new_source (gs_plugin_get_name (plugin));
        gs_app_set_origin_hostname (priv->cached_origin,
                                    FEDORA_PKGDB_COLLECTIONS_API_URI);
 
@@ -173,7 +172,7 @@ _refresh_cache (GsPlugin *plugin,
                GError **error)
 {
        GsPluginData *priv = gs_plugin_get_data (plugin);
-       g_autoptr(GsApp) app_dl = gs_app_new (gs_plugin_get_name (plugin));
+       g_autoptr(GsApp) app_dl = gs_app_new_source (gs_plugin_get_name (plugin));
 
        /* check cache age */
        if (cache_age > 0) {
@@ -273,7 +272,7 @@ _create_upgrade_from_info (GsPlugin *plugin, PkgdbItem *item)
        as_icon_set_filename (ic, "/usr/share/pixmaps/fedora-logo-sprite.png");
 
        /* create */
-       app = gs_app_new (app_id);
+       app = gs_plugin_app_new (plugin, app_id);
        gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
        gs_app_set_kind (app, AS_APP_KIND_OS_UPGRADE);
        gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_PACKAGE);
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 3360ee2b..e9c20b7c 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -231,7 +231,7 @@ gs_flatpak_create_app (GsFlatpak *self, const gchar *origin, FlatpakRef *xref)
        g_autoptr(GsApp) app = NULL;
 
        /* create a temp GsApp */
-       app = gs_app_new (flatpak_ref_get_name (xref));
+       app = gs_plugin_app_new (self->plugin, flatpak_ref_get_name (xref));
        gs_flatpak_set_metadata (self, app, xref);
        if (origin != NULL)
                gs_app_set_origin (app, origin);
@@ -814,7 +814,7 @@ gs_flatpak_refresh_appstream_remote (GsFlatpak *self,
                                     GError **error)
 {
        g_autofree gchar *str = NULL;
-       g_autoptr(GsApp) app_dl = gs_app_new (gs_plugin_get_name (self->plugin));
+       g_autoptr(GsApp) app_dl = gs_app_new_source (gs_plugin_get_name (self->plugin));
        g_autoptr(GsFlatpakProgressHelper) phelper = NULL;
        g_autoptr(GError) error_local = NULL;
 
@@ -1772,7 +1772,7 @@ gs_flatpak_create_runtime (GsFlatpak *self, GsApp *parent, const gchar *runtime)
                return NULL;
 
        /* create the complete GsApp from the single string */
-       app = gs_app_new (split[0]);
+       app = gs_plugin_app_new (self->plugin, split[0]);
        gs_flatpak_claim_app (self, app);
        source = g_strdup_printf ("runtime/%s", runtime);
        gs_app_add_source (app, source);
diff --git a/plugins/fwupd/gs-plugin-fwupd.c b/plugins/fwupd/gs-plugin-fwupd.c
index 071471b2..d256020e 100644
--- a/plugins/fwupd/gs-plugin-fwupd.c
+++ b/plugins/fwupd/gs-plugin-fwupd.c
@@ -218,8 +218,7 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
        GsPluginData *priv = gs_plugin_get_data (plugin);
 
        /* add source */
-       priv->cached_origin = gs_app_new (gs_plugin_get_name (plugin));
-       gs_app_set_kind (priv->cached_origin, AS_APP_KIND_SOURCE);
+       priv->cached_origin = gs_app_new_source (gs_plugin_get_name (plugin));
        gs_app_set_bundle_kind (priv->cached_origin, AS_BUNDLE_KIND_CABINET);
 
        /* add the source to the plugin cache which allows us to match the
@@ -266,7 +265,7 @@ gs_plugin_fwupd_new_app_from_device (GsPlugin *plugin, FwupdDevice *dev)
                                       NULL);
        app = gs_plugin_cache_lookup (plugin, id);
        if (app == NULL) {
-               app = gs_app_new (id);
+               app = gs_plugin_app_new (plugin, id);
                gs_plugin_cache_add (plugin, id, app);
        }
 
@@ -315,7 +314,7 @@ gs_plugin_fwupd_new_app_from_device_raw (GsPlugin *plugin, FwupdDevice *device)
 
        /* create a GsApp based on the device, not the release */
        id = gs_plugin_fwupd_build_device_id (device);
-       app = gs_app_new (id);
+       app = gs_plugin_app_new (plugin, id);
        gs_app_set_kind (app, AS_APP_KIND_FIRMWARE);
        gs_app_set_scope (app, AS_APP_SCOPE_SYSTEM);
        gs_app_set_state (app, AS_APP_STATE_INSTALLED);
@@ -626,7 +625,7 @@ gs_plugin_fwupd_refresh_remote (GsPlugin *plugin,
        g_autofree gchar *filename = NULL;
        g_autofree gchar *filename_sig = NULL;
        g_autoptr(GBytes) data = NULL;
-       g_autoptr(GsApp) app_dl = gs_app_new (gs_plugin_get_name (plugin));
+       g_autoptr(GsApp) app_dl = gs_app_new_source (gs_plugin_get_name (plugin));
 
        /* sanity check */
        if (fwupd_remote_get_filename_cache_sig (remote) == NULL) {
@@ -1019,7 +1018,7 @@ gs_plugin_add_sources (GsPlugin *plugin,
 
                /* create something that we can use to enable/disable */
                id = g_strdup_printf ("org.fwupd.%s.remote", fwupd_remote_get_id (remote));
-               app = gs_app_new (id);
+               app = gs_plugin_app_new (plugin, id);
                gs_app_set_kind (app, AS_APP_KIND_SOURCE);
                gs_app_set_scope (app, AS_APP_SCOPE_SYSTEM);
                gs_app_set_state (app, fwupd_remote_get_enabled (remote) ?
diff --git a/plugins/odrs/gs-plugin-odrs.c b/plugins/odrs/gs-plugin-odrs.c
index bbe3b8b2..2cec4a11 100644
--- a/plugins/odrs/gs-plugin-odrs.c
+++ b/plugins/odrs/gs-plugin-odrs.c
@@ -67,8 +67,7 @@ gs_plugin_initialize (GsPlugin *plugin)
        }
 
        /* add source */
-       priv->cached_origin = gs_app_new (gs_plugin_get_name (plugin));
-       gs_app_set_kind (priv->cached_origin, AS_APP_KIND_SOURCE);
+       priv->cached_origin = gs_app_new_source (gs_plugin_get_name (plugin));
        gs_app_set_origin_hostname (priv->cached_origin, priv->review_server);
 
        /* add the source to the plugin cache which allows us to match the
@@ -167,7 +166,7 @@ gs_plugin_refresh (GsPlugin *plugin,
        g_autofree gchar *fn = NULL;
        g_autofree gchar *uri = NULL;
        g_autoptr(GError) error_local = NULL;
-       g_autoptr(GsApp) app_dl = gs_app_new (gs_plugin_get_name (plugin));
+       g_autoptr(GsApp) app_dl = gs_app_new_source (gs_plugin_get_name (plugin));
 
        /* check cache age */
        fn = gs_utils_get_cache_filename ("odrs",
@@ -989,9 +988,9 @@ gs_plugin_review_remove (GsPlugin *plugin,
 }
 
 static GsApp *
-gs_plugin_create_app_dummy (const gchar *id)
+gs_plugin_create_app_dummy (GsPlugin *plugin, const gchar *id)
 {
-       GsApp *app = gs_app_new (id);
+       GsApp *app = gs_plugin_app_new (plugin, id);
        g_autoptr(GString) str = NULL;
        str = g_string_new (id);
        as_utils_string_replace (str, ".desktop", "");
@@ -1058,7 +1057,7 @@ gs_plugin_add_unvoted_reviews (GsPlugin *plugin,
                app_id = as_review_get_metadata_item (review, "app_id");
                app = g_hash_table_lookup (hash, app_id);
                if (app == NULL) {
-                       app = gs_plugin_create_app_dummy (app_id);
+                       app = gs_plugin_create_app_dummy (plugin, app_id);
                        gs_app_list_add (list, app);
                        g_hash_table_insert (hash, g_strdup (app_id), app);
                }
diff --git a/plugins/packagekit/gs-plugin-packagekit-history.c 
b/plugins/packagekit/gs-plugin-packagekit-history.c
index 3a70a693..0d3bf100 100644
--- a/plugins/packagekit/gs-plugin-packagekit-history.c
+++ b/plugins/packagekit/gs-plugin-packagekit-history.c
@@ -44,7 +44,7 @@ gs_plugin_destroy (GsPlugin *plugin)
 }
 
 static void
-gs_plugin_packagekit_refine_add_history (GsApp *app, GVariant *dict)
+gs_plugin_packagekit_refine_add_history (GsPlugin *plugin, GsApp *app, GVariant *dict)
 {
        const gchar *version;
        gboolean ret;
@@ -53,7 +53,7 @@ gs_plugin_packagekit_refine_add_history (GsApp *app, GVariant *dict)
        g_autoptr(GsApp) history = NULL;
 
        /* create new history item with same ID as parent */
-       history = gs_app_new (gs_app_get_id (app));
+       history = gs_plugin_app_new (plugin, gs_app_get_id (app));
        gs_app_set_kind (history, AS_APP_KIND_GENERIC);
        gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_PACKAGE);
        gs_app_set_name (history, GS_APP_QUALITY_NORMAL, gs_app_get_name (app));
@@ -195,7 +195,7 @@ gs_plugin_packagekit_refine (GsPlugin *plugin,
                         * least installed at some point in time */
                        if (gs_app_get_state (app) == AS_APP_STATE_INSTALLED) {
                                g_autoptr(GsApp) app_dummy = NULL;
-                               app_dummy = gs_app_new (gs_app_get_id (app));
+                               app_dummy = gs_plugin_app_new (plugin, gs_app_get_id (app));
                                gs_plugin_packagekit_set_packaging_format (plugin, app);
                                gs_app_set_metadata (app_dummy, "GnomeSoftware::Creator",
                                                     gs_plugin_get_name (plugin));
@@ -212,7 +212,7 @@ gs_plugin_packagekit_refine (GsPlugin *plugin,
                /* add history for application */
                g_variant_iter_init (&iter, entries);
                while ((value = g_variant_iter_next_value (&iter))) {
-                       gs_plugin_packagekit_refine_add_history (app, value);
+                       gs_plugin_packagekit_refine_add_history (plugin, app, value);
                        g_variant_unref (value);
                }
        }
diff --git a/plugins/packagekit/gs-plugin-packagekit-local.c b/plugins/packagekit/gs-plugin-packagekit-local.c
index 77ffe881..ae74c0ab 100644
--- a/plugins/packagekit/gs-plugin-packagekit-local.c
+++ b/plugins/packagekit/gs-plugin-packagekit-local.c
@@ -183,7 +183,7 @@ gs_plugin_file_to_app (GsPlugin *plugin,
 
        /* create application */
        item = g_ptr_array_index (array, 0);
-       app = gs_app_new (NULL);
+       app = gs_plugin_app_new (plugin, NULL);
        gs_plugin_packagekit_set_packaging_format (plugin, app);
        gs_app_set_metadata (app, "GnomeSoftware::Creator",
                             gs_plugin_get_name (plugin));
diff --git a/plugins/packagekit/gs-plugin-packagekit-offline.c 
b/plugins/packagekit/gs-plugin-packagekit-offline.c
index b2b019be..c0f392d9 100644
--- a/plugins/packagekit/gs-plugin-packagekit-offline.c
+++ b/plugins/packagekit/gs-plugin-packagekit-offline.c
@@ -137,7 +137,7 @@ gs_plugin_add_updates_historical (GsPlugin *plugin,
        if (pk_results_get_role (results) == PK_ROLE_ENUM_UPGRADE_SYSTEM) {
                g_autoptr(GsApp) app = NULL;
 
-               app = gs_app_new (NULL);
+               app = gs_plugin_app_new (plugin, NULL);
                gs_app_set_from_unique_id (app, "*/*/*/*/system/*");
                gs_app_set_management_plugin (app, "packagekit");
                gs_app_add_quirk (app, GS_APP_QUIRK_IS_WILDCARD);
@@ -160,7 +160,7 @@ gs_plugin_add_updates_historical (GsPlugin *plugin,
                g_autoptr(GsApp) app = NULL;
                g_auto(GStrv) split = NULL;
 
-               app = gs_app_new (NULL);
+               app = gs_plugin_app_new (plugin, NULL);
                package_id = pk_package_get_id (pkg);
                split = g_strsplit (package_id, ";", 4);
                gs_plugin_packagekit_set_packaging_format (plugin, app);
diff --git a/plugins/packagekit/gs-plugin-packagekit-refresh.c 
b/plugins/packagekit/gs-plugin-packagekit-refresh.c
index 283f144d..c736605e 100644
--- a/plugins/packagekit/gs-plugin-packagekit-refresh.c
+++ b/plugins/packagekit/gs-plugin-packagekit-refresh.c
@@ -144,7 +144,7 @@ gs_plugin_refresh (GsPlugin *plugin,
 {
        GsPluginData *priv = gs_plugin_get_data (plugin);
        g_autoptr(GsPackagekitHelper) helper = gs_packagekit_helper_new (plugin);
-       g_autoptr(GsApp) app_dl = gs_app_new (gs_plugin_get_name (plugin));
+       g_autoptr(GsApp) app_dl = gs_app_new_source (gs_plugin_get_name (plugin));
        g_autoptr(PkResults) results = NULL;
 
        gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_WAITING);
diff --git a/plugins/packagekit/gs-plugin-packagekit-url-to-app.c 
b/plugins/packagekit/gs-plugin-packagekit-url-to-app.c
index d9c2ed66..37bf0a2c 100644
--- a/plugins/packagekit/gs-plugin-packagekit-url-to-app.c
+++ b/plugins/packagekit/gs-plugin-packagekit-url-to-app.c
@@ -77,7 +77,7 @@ gs_plugin_url_to_app (GsPlugin *plugin,
                }
        }
 
-       app = gs_app_new (NULL);
+       app = gs_plugin_app_new (plugin, NULL);
        gs_plugin_packagekit_set_packaging_format (plugin, app);
        gs_app_add_source (app, path);
        gs_app_set_kind (app, AS_APP_KIND_GENERIC);
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index e51a2666..6b5cbb08 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -148,7 +148,7 @@ gs_plugin_add_sources (GsPlugin *plugin,
                g_autoptr(GsApp) app = NULL;
                rd = g_ptr_array_index (array, i);
                id = pk_repo_detail_get_id (rd);
-               app = gs_app_new (id);
+               app = gs_plugin_app_new (plugin, id);
                gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
                gs_app_set_kind (app, AS_APP_KIND_SOURCE);
                gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_PACKAGE);
@@ -550,7 +550,7 @@ gs_plugin_packagekit_build_update_app (GsPlugin *plugin, PkPackage *package)
        GsApp *app = gs_plugin_cache_lookup (plugin, pk_package_get_id (package));
        if (app != NULL)
                return app;
-       app = gs_app_new (NULL);
+       app = gs_plugin_app_new (plugin, NULL);
        gs_plugin_packagekit_set_packaging_format (plugin, app);
        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/packagekit/packagekit-common.c b/plugins/packagekit/packagekit-common.c
index 074b8d21..5f0d5e25 100644
--- a/plugins/packagekit/packagekit-common.c
+++ b/plugins/packagekit/packagekit-common.c
@@ -241,7 +241,7 @@ gs_plugin_packagekit_add_results (GsPlugin *plugin,
 
                app = gs_plugin_cache_lookup (plugin, pk_package_get_id (package));
                if (app == NULL) {
-                       app = gs_app_new (NULL);
+                       app = gs_plugin_app_new (plugin, NULL);
                        gs_plugin_packagekit_set_packaging_format (plugin, app);
                        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 8b0578a7..f719eb73 100644
--- a/plugins/rpm-ostree/gs-plugin-rpm-ostree.c
+++ b/plugins/rpm-ostree/gs-plugin-rpm-ostree.c
@@ -399,7 +399,7 @@ app_from_modified_pkg_variant (GsPlugin *plugin, GVariant *variant)
                return g_steal_pointer (&app);
 
        /* create new app */
-       app = gs_app_new (NULL);
+       app = gs_plugin_app_new (plugin, NULL);
        gs_app_set_management_plugin (app, "rpm-ostree");
        gs_app_add_quirk (app, GS_APP_QUIRK_NEEDS_REBOOT);
        app_set_rpm_ostree_packaging_format (app);
@@ -438,7 +438,7 @@ app_from_single_pkg_variant (GsPlugin *plugin, GVariant *variant, gboolean addit
                return g_steal_pointer (&app);
 
        /* create new app */
-       app = gs_app_new (NULL);
+       app = gs_plugin_app_new (plugin, NULL);
        gs_app_set_management_plugin (app, "rpm-ostree");
        gs_app_add_quirk (app, GS_APP_QUIRK_NEEDS_REBOOT);
        app_set_rpm_ostree_packaging_format (app);
@@ -1540,7 +1540,7 @@ gs_plugin_file_to_app (GsPlugin *plugin,
                goto out;
        }
 
-       app = gs_app_new (NULL);
+       app = gs_plugin_app_new (plugin, 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_add_quirk (app, GS_APP_QUIRK_NEEDS_REBOOT);
diff --git a/plugins/shell-extensions/gs-plugin-shell-extensions.c 
b/plugins/shell-extensions/gs-plugin-shell-extensions.c
index 2b6411ba..aa560362 100644
--- a/plugins/shell-extensions/gs-plugin-shell-extensions.c
+++ b/plugins/shell-extensions/gs-plugin-shell-extensions.c
@@ -68,7 +68,7 @@ gs_plugin_initialize (GsPlugin *plugin)
        g_rw_lock_init (&priv->silo_lock);
 
        /* add source */
-       priv->cached_origin = gs_app_new (gs_plugin_get_name (plugin));
+       priv->cached_origin = gs_app_new_source (gs_plugin_get_name (plugin));
        gs_app_set_kind (priv->cached_origin, AS_APP_KIND_SOURCE);
        gs_app_set_origin_hostname (priv->cached_origin, SHELL_EXTENSIONS_API_URI);
 
@@ -137,7 +137,7 @@ gs_plugin_shell_extensions_parse_installed (GsPlugin *plugin,
        g_autoptr(GsApp) app = NULL;
 
        id = as_utils_appstream_id_build (uuid);
-       app = gs_app_new (id);
+       app = gs_plugin_app_new (plugin, id);
        gs_app_set_metadata (app, "GnomeSoftware::Creator",
                             gs_plugin_get_name (plugin));
        gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
@@ -391,7 +391,7 @@ gs_plugin_add_sources (GsPlugin *plugin,
        g_autoptr(GsApp) app = NULL;
 
        /* create something that we can use to enable/disable */
-       app = gs_app_new ("org.gnome.extensions");
+       app = gs_plugin_app_new (plugin, "org.gnome.extensions");
        gs_app_set_kind (app, AS_APP_KIND_SOURCE);
        gs_app_set_scope (app, AS_APP_SCOPE_USER);
        if (g_settings_get_boolean (priv->settings, "enable-shell-extensions-repo"))
@@ -772,7 +772,7 @@ gs_plugin_shell_extensions_refresh (GsPlugin *plugin,
        g_autofree gchar *uri = NULL;
        g_autoptr(GFile) file = NULL;
        g_autoptr(GRWLockReaderLocker) locker = NULL;
-       g_autoptr(GsApp) app_dl = gs_app_new (gs_plugin_get_name (plugin));
+       g_autoptr(GsApp) app_dl = gs_app_new_source (gs_plugin_get_name (plugin));
 
        /* get cache filename */
        fn = gs_utils_get_cache_filename ("shell-extensions",
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index 18146f60..7be29ad2 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -327,7 +327,7 @@ snap_to_app (GsPlugin *plugin, SnapdSnap *snap)
 
        app = gs_plugin_cache_lookup (plugin, unique_id);
        if (app == NULL) {
-               app = gs_app_new (NULL);
+               app = gs_plugin_app_new (plugin, NULL);
                gs_app_set_from_unique_id (app, unique_id);
                gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_SNAP);
                gs_app_set_metadata (app, "snap::name", snapd_snap_get_name (snap));


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