[gnome-software] trivial: Add some metadata to identify what plugin created a GsApp



commit 88abc9cf3c45ad908d0cc2c12d6af0402e19a481
Author: Richard Hughes <richard hughsie com>
Date:   Tue May 24 13:34:43 2016 +0100

    trivial: Add some metadata to identify what plugin created a GsApp
    
    This is super useful when trying to work out why there are duplicates.

 src/plugins/gs-plugin-appstream.c          |    2 ++
 src/plugins/gs-plugin-dpkg.c               |    2 ++
 src/plugins/gs-plugin-dummy.c              |    2 ++
 src/plugins/gs-plugin-flatpak.c            |   10 +++++++---
 src/plugins/gs-plugin-hardcoded-popular.c  |    2 ++
 src/plugins/gs-plugin-packagekit-history.c |    2 ++
 src/plugins/gs-plugin-packagekit-local.c   |    2 ++
 src/plugins/gs-plugin-packagekit-offline.c |    2 ++
 src/plugins/gs-plugin-shell-extensions.c   |   10 +++++++---
 src/plugins/packagekit-common.c            |    2 ++
 10 files changed, 30 insertions(+), 6 deletions(-)
---
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 093cad6..bef69b8 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -309,6 +309,8 @@ gs_plugin_appstream_create_app (GsPlugin *plugin, const gchar *id)
        GsApp *app = gs_plugin_cache_lookup (plugin, id);
        if (app == NULL) {
                app = gs_app_new (id);
+               gs_app_set_metadata (app, "GnomeSoftware::Creator",
+                                    gs_plugin_get_name (plugin));
                gs_plugin_cache_add (plugin, id, app);
        }
        return app;
diff --git a/src/plugins/gs-plugin-dpkg.c b/src/plugins/gs-plugin-dpkg.c
index 9ebdd04..b0c1004 100644
--- a/src/plugins/gs-plugin-dpkg.c
+++ b/src/plugins/gs-plugin-dpkg.c
@@ -96,6 +96,8 @@ gs_plugin_file_to_app (GsPlugin *plugin,
        gs_app_set_url (app, AS_URL_KIND_HOMEPAGE, tokens[3]);
        gs_app_set_summary (app, GS_APP_QUALITY_LOWEST, tokens[4]);
        gs_app_set_kind (app, AS_APP_KIND_GENERIC);
+       gs_app_set_metadata (app, "GnomeSoftware::Creator",
+                            gs_plugin_get_name (plugin));
 
        /* multiline text */
        str = g_string_new ("");
diff --git a/src/plugins/gs-plugin-dummy.c b/src/plugins/gs-plugin-dummy.c
index 4af6660..6fbe61c 100644
--- a/src/plugins/gs-plugin-dummy.c
+++ b/src/plugins/gs-plugin-dummy.c
@@ -160,6 +160,8 @@ gs_plugin_add_search (GsPlugin *plugin,
        gs_app_set_kind (app, AS_APP_KIND_DESKTOP);
        gs_app_set_state (app, AS_APP_STATE_INSTALLED);
        gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+       gs_app_set_metadata (app, "GnomeSoftware::Creator",
+                            gs_plugin_get_name (plugin));
        gs_app_list_add (list, app);
 
        /* add to cache so it can be found by the flashing callback */
diff --git a/src/plugins/gs-plugin-flatpak.c b/src/plugins/gs-plugin-flatpak.c
index cfe7a88..b05fc91 100644
--- a/src/plugins/gs-plugin-flatpak.c
+++ b/src/plugins/gs-plugin-flatpak.c
@@ -241,7 +241,9 @@ gs_plugin_flatpak_set_metadata (GsApp *app, FlatpakRef *xref)
 }
 
 static void
-gs_plugin_flatpak_set_metadata_installed (GsApp *app, FlatpakInstalledRef *xref)
+gs_plugin_flatpak_set_metadata_installed (GsPlugin *plugin,
+                                         GsApp *app,
+                                         FlatpakInstalledRef *xref)
 {
        guint64 mtime;
        guint64 size_installed;
@@ -251,6 +253,8 @@ gs_plugin_flatpak_set_metadata_installed (GsApp *app, FlatpakInstalledRef *xref)
 
        /* for all types */
        gs_plugin_flatpak_set_metadata (app, FLATPAK_REF (xref));
+       gs_app_set_metadata (app, "GnomeSoftware::Creator",
+                            gs_plugin_get_name (plugin));
 
        /* get the last time the app was updated */
        metadata_fn = g_build_filename (flatpak_installed_ref_get_deploy_dir (xref),
@@ -333,7 +337,7 @@ gs_plugin_flatpak_create_installed (GsPlugin *plugin,
                app = gs_app_new (id);
                gs_plugin_cache_add (plugin, id, app);
        }
-       gs_plugin_flatpak_set_metadata_installed (app, xref);
+       gs_plugin_flatpak_set_metadata_installed (plugin, app, xref);
 
        switch (flatpak_ref_get_kind (FLATPAK_REF(xref))) {
        case FLATPAK_REF_KIND_APP:
@@ -815,7 +819,7 @@ gs_plugin_refine_item_state (GsPlugin *plugin,
                /* mark as installed */
                g_debug ("marking %s as installed with flatpak",
                         gs_app_get_id (app));
-               gs_plugin_flatpak_set_metadata_installed (app, xref);
+               gs_plugin_flatpak_set_metadata_installed (plugin, app, xref);
                if (gs_app_get_state (app) == AS_APP_STATE_UNKNOWN)
                        gs_app_set_state (app, AS_APP_STATE_INSTALLED);
        }
diff --git a/src/plugins/gs-plugin-hardcoded-popular.c b/src/plugins/gs-plugin-hardcoded-popular.c
index 3836501..eaec448 100644
--- a/src/plugins/gs-plugin-hardcoded-popular.c
+++ b/src/plugins/gs-plugin-hardcoded-popular.c
@@ -68,6 +68,8 @@ gs_plugin_add_popular (GsPlugin *plugin,
                /* create new */
                app = gs_app_new (apps[i]);
                gs_app_add_quirk (app, AS_APP_QUIRK_MATCH_ANY_PREFIX);
+               gs_app_set_metadata (app, "GnomeSoftware::Creator",
+                                    gs_plugin_get_name (plugin));
                gs_app_list_add (list, app);
 
                /* save in the cache */
diff --git a/src/plugins/gs-plugin-packagekit-history.c b/src/plugins/gs-plugin-packagekit-history.c
index 0dbf3c3..47f0e28 100644
--- a/src/plugins/gs-plugin-packagekit-history.c
+++ b/src/plugins/gs-plugin-packagekit-history.c
@@ -197,6 +197,8 @@ gs_plugin_packagekit_refine (GsPlugin *plugin,
                        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));
+                               gs_app_set_metadata (app_dummy, "GnomeSoftware::Creator",
+                                                    gs_plugin_get_name (plugin));
                                gs_app_set_install_date (app_dummy, GS_APP_INSTALL_DATE_UNKNOWN);
                                gs_app_set_kind (app_dummy, AS_APP_KIND_GENERIC);
                                gs_app_set_state (app_dummy, AS_APP_STATE_INSTALLED);
diff --git a/src/plugins/gs-plugin-packagekit-local.c b/src/plugins/gs-plugin-packagekit-local.c
index ed2b683..8db10af 100644
--- a/src/plugins/gs-plugin-packagekit-local.c
+++ b/src/plugins/gs-plugin-packagekit-local.c
@@ -238,6 +238,8 @@ gs_plugin_file_to_app (GsPlugin *plugin,
        /* create application */
        item = g_ptr_array_index (array, 0);
        app = gs_app_new (NULL);
+       gs_app_set_metadata (app, "GnomeSoftware::Creator",
+                            gs_plugin_get_name (plugin));
        package_id = pk_details_get_package_id (item);
        split = pk_package_id_split (package_id);
        basename = g_path_get_basename (filename);
diff --git a/src/plugins/gs-plugin-packagekit-offline.c b/src/plugins/gs-plugin-packagekit-offline.c
index 66c34b1..105e0b7 100644
--- a/src/plugins/gs-plugin-packagekit-offline.c
+++ b/src/plugins/gs-plugin-packagekit-offline.c
@@ -183,6 +183,8 @@ gs_plugin_add_updates_historical (GsPlugin *plugin,
                gs_app_set_state (app, AS_APP_STATE_UPDATABLE);
                gs_app_set_kind (app, AS_APP_KIND_GENERIC);
                gs_app_set_install_date (app, mtime);
+               gs_app_set_metadata (app, "GnomeSoftware::Creator",
+                                    gs_plugin_get_name (plugin));
                gs_app_list_add (list, app);
        }
        return TRUE;
diff --git a/src/plugins/gs-plugin-shell-extensions.c b/src/plugins/gs-plugin-shell-extensions.c
index cc7b721..a8b219c 100644
--- a/src/plugins/gs-plugin-shell-extensions.c
+++ b/src/plugins/gs-plugin-shell-extensions.c
@@ -91,7 +91,8 @@ gs_plugin_shell_extensions_id_from_uuid (const gchar *uuid)
 }
 
 static GsApp *
-gs_plugin_shell_extensions_add_app (const gchar *uuid,
+gs_plugin_shell_extensions_add_app (GsPlugin *plugin,
+                                   const gchar *uuid,
                                    GVariantIter *iter,
                                    GError **error)
 {
@@ -106,7 +107,9 @@ gs_plugin_shell_extensions_add_app (const gchar *uuid,
        id = gs_plugin_shell_extensions_id_from_uuid (uuid);
        id_prefix = g_strdup_printf ("user:%s", id);
        app = gs_app_new (id_prefix);
-       gs_app_set_management_plugin (app, "shell-extensions");
+       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_metadata (app, "shell-extensions::uuid", uuid);
        gs_app_set_kind (app, AS_APP_KIND_SHELL_EXTENSION);
        gs_app_set_license (app, GS_APP_QUALITY_NORMAL, "GPL-2.0+");
@@ -283,7 +286,8 @@ gs_plugin_add_installed (GsPlugin *plugin,
                }
 
                /* parse the data into an GsApp */
-               app = gs_plugin_shell_extensions_add_app (ext_uuid,
+               app = gs_plugin_shell_extensions_add_app (plugin,
+                                                         ext_uuid,
                                                          ext_iter,
                                                          error);
                if (app == NULL)
diff --git a/src/plugins/packagekit-common.c b/src/plugins/packagekit-common.c
index 0a1ceeb..9709f22 100644
--- a/src/plugins/packagekit-common.c
+++ b/src/plugins/packagekit-common.c
@@ -241,6 +241,8 @@ gs_plugin_packagekit_add_results (GsPlugin *plugin,
                gs_app_set_summary (app,
                                    GS_APP_QUALITY_LOWEST,
                                    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_version (app, pk_package_get_version (package));
                switch (pk_package_get_info (package)) {


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