[gnome-software] Remove gs_plugin_app_new() and prevent plugins from registering GTypes



commit 1509cb00a2bc57e2b422352b0f0c0d1c8437caff
Author: Richard Hughes <richard hughsie com>
Date:   Tue Oct 17 14:22:13 2017 +0100

    Remove gs_plugin_app_new() and prevent plugins from registering GTypes
    
    It turns out this did not seem to solve any real issue we couldn't solve in a
    simpler way, and it only seemed to increase complexity and the number of bugs.

 lib/gs-plugin-private.h         |    1 -
 lib/gs-plugin.c                 |   55 ---------------------------------------
 lib/gs-plugin.h                 |    4 ---
 plugins/core/gs-appstream.c     |    2 +-
 plugins/flatpak/gs-flatpak.c    |    2 +-
 plugins/fwupd/gs-plugin-fwupd.c |    2 +-
 plugins/snap/gs-plugin-snap.c   |    2 +-
 7 files changed, 4 insertions(+), 64 deletions(-)
---
diff --git a/lib/gs-plugin-private.h b/lib/gs-plugin-private.h
index df42f7c..7de3a0d 100644
--- a/lib/gs-plugin-private.h
+++ b/lib/gs-plugin-private.h
@@ -71,7 +71,6 @@ GPtrArray     *gs_plugin_get_rules                    (GsPlugin       *plugin,
                                                         GsPluginRule    rule);
 gpointer        gs_plugin_get_symbol                   (GsPlugin       *plugin,
                                                         const gchar    *function_name);
-GType           gs_plugin_get_app_gtype                (GsPlugin       *plugin);
 gchar          *gs_plugin_failure_flags_to_string      (GsPluginFailureFlags failure_flags);
 gchar          *gs_plugin_refine_flags_to_string       (GsPluginRefineFlags refine_flags);
 
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index 8fcf031..8bdced4 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -74,7 +74,6 @@ typedef struct
        GHashTable              *vfuncs;                /* string:pointer */
        GMutex                   vfuncs_mutex;
        gboolean                 enabled;
-       GType                    app_gtype;
        gchar                   *locale;                /* allow-none */
        gchar                   *language;              /* allow-none */
        gchar                   *name;
@@ -442,59 +441,6 @@ gs_plugin_set_enabled (GsPlugin *plugin, gboolean enabled)
 }
 
 /**
- * gs_plugin_get_app_gtype:
- * @plugin: a #GsPlugin
- *
- * Gets the native application GType.
- *
- * Returns: a #GType, e.g. %GS_TYPE_APP
- *
- * Since: 3.26
- **/
-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.26
- **/
-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.26
- **/
-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
  *
@@ -2211,7 +2157,6 @@ 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->profile = as_profile_new ();
        priv->cache = g_hash_table_new_full ((GHashFunc) as_utils_unique_id_hash,
diff --git a/lib/gs-plugin.h b/lib/gs-plugin.h
index 822f942..fe10aa1 100644
--- a/lib/gs-plugin.h
+++ b/lib/gs-plugin.h
@@ -74,10 +74,6 @@ 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 9259150..8350697 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -47,7 +47,7 @@ gs_appstream_create_app (GsPlugin *plugin, AsApp *item, GError **error)
        }
 
        if (app == NULL) {
-               app = gs_plugin_app_new (plugin, NULL);
+               app = gs_app_new (NULL);
                gs_app_set_from_unique_id (app, unique_id);
                gs_app_set_metadata (app, "GnomeSoftware::Creator",
                                     gs_plugin_get_name (plugin));
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 92c3f52..2829eef 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -1683,7 +1683,7 @@ gs_flatpak_create_runtime (GsPlugin *plugin, GsApp *parent, const gchar *runtime
                return NULL;
 
        /* create the complete GsApp from the single string */
-       app = gs_plugin_app_new (plugin, split[0]);
+       app = gs_app_new (split[0]);
        source = g_strdup_printf ("runtime/%s", runtime);
        gs_app_add_source (app, source);
        gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_FLATPAK);
diff --git a/plugins/fwupd/gs-plugin-fwupd.c b/plugins/fwupd/gs-plugin-fwupd.c
index a2972d1..e20a47f 100644
--- a/plugins/fwupd/gs-plugin-fwupd.c
+++ b/plugins/fwupd/gs-plugin-fwupd.c
@@ -385,7 +385,7 @@ gs_plugin_fwupd_new_app_from_results (GsPlugin *plugin, FwupdResult *res)
                                       NULL);
        app = gs_plugin_cache_lookup (plugin, id);
        if (app == NULL) {
-               app = gs_plugin_app_new (plugin, id);
+               app = gs_app_new (id);
                gs_plugin_cache_add (plugin, id, app);
        }
 
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index e456b28..60dffbe 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -298,7 +298,7 @@ snap_to_app (GsPlugin *plugin, SnapdSnap *snap)
 
        cached_app = gs_plugin_cache_lookup (plugin, unique_id);
        if (cached_app == NULL) {
-               app = gs_plugin_app_new (plugin, NULL);
+               app = gs_app_new (NULL);
                gs_app_set_from_unique_id (app, unique_id);
                gs_plugin_cache_add (plugin, unique_id, app);
        }


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