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



commit f2f39dbb2f6bbea953e5043c4f7527271f2425e2
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-private.h                            |  1 +
 lib/gs-plugin.c                                    | 55 ++++++++++++++++++++++
 lib/gs-plugin.h                                    |  4 ++
 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 +-
 .../shell-extensions/gs-plugin-shell-extensions.c  |  8 ++--
 plugins/snap/gs-plugin-snap.c                      |  2 +-
 27 files changed, 164 insertions(+), 70 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 aa6f2a06..ddbcabb0 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -4372,6 +4372,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.32
+ **/
+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.32
+ **/
+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 18d4bb4b..cfd7a210 100644
--- a/lib/gs-app.h
+++ b/lib/gs-app.h
@@ -157,7 +157,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-private.h b/lib/gs-plugin-private.h
index d6a6dfbd..3aa257c0 100644
--- a/lib/gs-plugin-private.h
+++ b/lib/gs-plugin-private.h
@@ -47,6 +47,7 @@ gpointer       gs_plugin_get_symbol                   (GsPlugin       *plugin,
                                                         const gchar    *function_name);
 void            gs_plugin_interactive_inc              (GsPlugin       *plugin);
 void            gs_plugin_interactive_dec              (GsPlugin       *plugin);
+GType           gs_plugin_get_app_gtype                (GsPlugin       *plugin);
 gchar          *gs_plugin_refine_flags_to_string       (GsPluginRefineFlags refine_flags);
 void            gs_plugin_set_network_monitor          (GsPlugin               *plugin,
                                                         GNetworkMonitor        *monitor);
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index 32bdb805..103f8d16 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -60,6 +60,7 @@ typedef struct
        gboolean                 enabled;
        guint                    interactive_cnt;
        GMutex                   interactive_mutex;
+       GType                    app_gtype;
        gchar                   *locale;                /* allow-none */
        gchar                   *language;              /* allow-none */
        gchar                   *name;
@@ -374,6 +375,59 @@ gs_plugin_interactive_dec (GsPlugin *plugin)
                gs_plugin_remove_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE);
 }
 
+/**
+ * gs_plugin_get_app_gtype:
+ * @plugin: a #GsPlugin
+ *
+ * Gets the native application GType.
+ *
+ * Returns: a #GType, e.g. %GS_TYPE_APP
+ *
+ * Since: 3.32
+ **/
+GType
+gs_plugin_get_app_gtype (GsPlugin *plugin)
+{
+       GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
+       return priv->app_gtype;
+}
+
+/**
+ * gs_plugin_set_app_gtype:
+ * @plugin: a #GsPlugin
+ * @app_gtype: the #GType state
+ *
+ * Sets the native application GType.
+ *
+ * Since: 3.32
+ **/
+void
+gs_plugin_set_app_gtype (GsPlugin *plugin, GType app_gtype)
+{
+       GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
+       priv->app_gtype = app_gtype;
+}
+
+/**
+ * gs_plugin_app_new:
+ * @plugin: a #GsPlugin
+ * @id: an application ID
+ *
+ * Creates a GsApp, which may possibly be a subclassed type.
+ * To set the type used when creating objects, plugins must use
+ * gs_plugin_set_app_gtype() with a custom #GType.
+ *
+ * Returns: a #GsApp
+ *
+ * Since: 3.32
+ **/
+GsApp *
+gs_plugin_app_new (GsPlugin *plugin, const gchar *id)
+{
+       GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
+       return GS_APP (g_object_new (priv->app_gtype, "id", id, NULL));
+}
+
 /**
  * gs_plugin_get_name:
  * @plugin: a #GsPlugin
@@ -2013,6 +2067,7 @@ gs_plugin_init (GsPlugin *plugin)
                priv->rules[i] = g_ptr_array_new_with_free_func (g_free);
 
        priv->enabled = TRUE;
+       priv->app_gtype = GS_TYPE_APP;
        priv->scale = 1;
        priv->cache = g_hash_table_new_full ((GHashFunc) as_utils_unique_id_hash,
                                             (GEqualFunc) as_utils_unique_id_equal,
diff --git a/lib/gs-plugin.h b/lib/gs-plugin.h
index d4595186..27f5cc99 100644
--- a/lib/gs-plugin.h
+++ b/lib/gs-plugin.h
@@ -59,6 +59,10 @@ void          gs_plugin_set_appstream_id             (GsPlugin       *plugin,
 gboolean        gs_plugin_get_enabled                  (GsPlugin       *plugin);
 void            gs_plugin_set_enabled                  (GsPlugin       *plugin,
                                                         gboolean        enabled);
+void            gs_plugin_set_app_gtype                (GsPlugin       *plugin,
+                                                        GType           app_gtype);
+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 bce2e0d6..d14ea455 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,
@@ -1216,8 +1216,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;
@@ -1306,8 +1305,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;
@@ -1342,8 +1340,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 5fc7ad9f..62fb99b3 100644
--- a/plugins/core/gs-plugin-generic-updates.c
+++ b/plugins/core/gs-plugin-generic-updates.c
@@ -42,7 +42,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 92aa2974..98b3558b 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 7b7c67ea..d0a67791 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -241,7 +241,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) local_error = NULL;
 
@@ -1746,7 +1746,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 db37d482..914d8a55 100644
--- a/plugins/fwupd/gs-plugin-fwupd.c
+++ b/plugins/fwupd/gs-plugin-fwupd.c
@@ -214,8 +214,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
@@ -262,7 +261,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);
        }
 
@@ -311,7 +310,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);
@@ -622,7 +621,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) {
@@ -1013,7 +1012,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 32c0c266..93ae8b48 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",
@@ -973,9 +972,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", "");
@@ -1042,7 +1041,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 e6ebb7fd..811d348e 100644
--- a/plugins/packagekit/gs-plugin-packagekit-local.c
+++ b/plugins/packagekit/gs-plugin-packagekit-local.c
@@ -175,7 +175,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 dc93c7a0..6c101e66 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);
@@ -161,7 +161,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 b470e7cb..1a6146bb 100644
--- a/plugins/packagekit/gs-plugin-packagekit-refresh.c
+++ b/plugins/packagekit/gs-plugin-packagekit-refresh.c
@@ -132,7 +132,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;
 
        /* cache age of 1 is user-initiated */
diff --git a/plugins/packagekit/gs-plugin-packagekit-url-to-app.c 
b/plugins/packagekit/gs-plugin-packagekit-url-to-app.c
index 3a4da3f3..817aa229 100644
--- a/plugins/packagekit/gs-plugin-packagekit-url-to-app.c
+++ b/plugins/packagekit/gs-plugin-packagekit-url-to-app.c
@@ -73,7 +73,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 899525de..23ff4cd4 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -140,7 +140,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);
@@ -526,7 +526,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 d0b056e0..74540d2d 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/shell-extensions/gs-plugin-shell-extensions.c 
b/plugins/shell-extensions/gs-plugin-shell-extensions.c
index d427ca73..5d477f53 100644
--- a/plugins/shell-extensions/gs-plugin-shell-extensions.c
+++ b/plugins/shell-extensions/gs-plugin-shell-extensions.c
@@ -63,7 +63,7 @@ gs_plugin_initialize (GsPlugin *plugin)
        GsPluginData *priv = gs_plugin_alloc_data (plugin, sizeof(GsPluginData));
 
        /* 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);
 
@@ -131,7 +131,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));
@@ -379,7 +379,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"))
@@ -751,7 +751,7 @@ gs_plugin_shell_extensions_refresh (GsPlugin *plugin,
        g_autofree gchar *fn = NULL;
        g_autofree gchar *uri = NULL;
        g_autoptr(GFile) file = 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 38da2b68..879551c6 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -310,7 +310,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]