[gnome-software] Add a cached origin to each plugin doing network I/O
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Add a cached origin to each plugin doing network I/O
- Date: Thu, 8 Sep 2016 20:55:55 +0000 (UTC)
commit e846f833a4d42437d646c8c21583be81ed97df9b
Author: Richard Hughes <richard hughsie com>
Date: Thu Sep 8 13:28:13 2016 +0100
Add a cached origin to each plugin doing network I/O
This will let us match the unique-id in any error message with a more useful
GsApp using the per-plugin cache.
src/plugins/gs-plugin-dummy.c | 14 ++++++++++++++
src/plugins/gs-plugin-fedora-distro-upgrades.c | 16 ++++++++++++++++
src/plugins/gs-plugin-fwupd.c | 16 ++++++++++++++++
src/plugins/gs-plugin-odrs.c | 14 ++++++++++++++
src/plugins/gs-plugin-shell-extensions.c | 16 +++++++++++++++-
5 files changed, 75 insertions(+), 1 deletions(-)
---
diff --git a/src/plugins/gs-plugin-dummy.c b/src/plugins/gs-plugin-dummy.c
index 76d8f22..c758684 100644
--- a/src/plugins/gs-plugin-dummy.c
+++ b/src/plugins/gs-plugin-dummy.c
@@ -32,6 +32,7 @@ struct GsPluginData {
guint quirk_id;
guint has_auth;
GsAuth *auth;
+ GsApp *cached_origin;
};
void
@@ -55,6 +56,18 @@ gs_plugin_initialize (GsPlugin *plugin)
/* lets assume we read this from disk somewhere */
gs_auth_set_username (priv->auth, "dummy");
+ /* add source */
+ priv->cached_origin = gs_app_new (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/");
+ gs_app_set_origin_ui (priv->cached_origin, "Dummy Repo");
+
+ /* add the source to the plugin cache which allows us to match the
+ * unique ID to a GsApp when creating an event */
+ gs_plugin_cache_add (plugin,
+ gs_app_get_unique_id (priv->cached_origin),
+ priv->cached_origin);
+
/* need help from appstream */
gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_AFTER, "appstream");
gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_CONFLICTS, "odrs");
@@ -66,6 +79,7 @@ gs_plugin_destroy (GsPlugin *plugin)
GsPluginData *priv = gs_plugin_get_data (plugin);
if (priv->quirk_id > 0)
g_source_remove (priv->quirk_id);
+ g_object_unref (priv->cached_origin);
}
void
diff --git a/src/plugins/gs-plugin-fedora-distro-upgrades.c b/src/plugins/gs-plugin-fedora-distro-upgrades.c
index 70056a2..99b302c 100644
--- a/src/plugins/gs-plugin-fedora-distro-upgrades.c
+++ b/src/plugins/gs-plugin-fedora-distro-upgrades.c
@@ -31,6 +31,7 @@ struct GsPluginData {
GFileMonitor *cachefn_monitor;
gchar *os_name;
guint64 os_version;
+ GsApp *cached_origin;
};
void
@@ -51,6 +52,8 @@ gs_plugin_destroy (GsPlugin *plugin)
GsPluginData *priv = gs_plugin_get_data (plugin);
if (priv->cachefn_monitor != NULL)
g_object_unref (priv->cachefn_monitor);
+ if (priv->cached_origin != NULL)
+ g_object_unref (priv->cached_origin);
g_free (priv->os_name);
g_free (priv->cachefn);
}
@@ -127,6 +130,19 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
return FALSE;
}
+ /* add source */
+ priv->cached_origin = gs_app_new (gs_plugin_get_name (plugin));
+ gs_app_set_kind (priv->cached_origin, AS_APP_KIND_SOURCE);
+ gs_app_set_origin_ui (priv->cached_origin, "Fedora Project PkgDb");
+ gs_app_set_origin_hostname (priv->cached_origin,
+ FEDORA_PKGDB_COLLECTIONS_API_URI);
+
+ /* add the source to the plugin cache which allows us to match the
+ * unique ID to a GsApp when creating an event */
+ gs_plugin_cache_add (plugin,
+ gs_app_get_unique_id (priv->cached_origin),
+ priv->cached_origin);
+
/* success */
return TRUE;
}
diff --git a/src/plugins/gs-plugin-fwupd.c b/src/plugins/gs-plugin-fwupd.c
index a2f0f2f..4063550 100644
--- a/src/plugins/gs-plugin-fwupd.c
+++ b/src/plugins/gs-plugin-fwupd.c
@@ -42,6 +42,7 @@ struct GsPluginData {
GPtrArray *to_download;
GPtrArray *to_ignore;
GsApp *app_current;
+ GsApp *cached_origin;
gchar *lvfs_sig_fn;
gchar *lvfs_sig_hash;
gchar *config_fn;
@@ -71,6 +72,8 @@ void
gs_plugin_destroy (GsPlugin *plugin)
{
GsPluginData *priv = gs_plugin_get_data (plugin);
+ if (priv->cached_origin != NULL)
+ g_object_unref (priv->cached_origin);
g_free (priv->lvfs_sig_fn);
g_free (priv->lvfs_sig_hash);
g_free (priv->config_fn);
@@ -192,6 +195,19 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
if (priv->download_uri == NULL)
return FALSE;
+ /* add source */
+ priv->cached_origin = gs_app_new (gs_plugin_get_name (plugin));
+ gs_app_set_kind (priv->cached_origin, AS_APP_KIND_SOURCE);
+ gs_app_set_bundle_kind (priv->cached_origin, AS_BUNDLE_KIND_CABINET);
+ gs_app_set_origin_hostname (priv->cached_origin, priv->download_uri);
+ gs_app_set_origin_ui (priv->cached_origin, "Linux Vendor Firmware Project");
+
+ /* add the source to the plugin cache which allows us to match the
+ * unique ID to a GsApp when creating an event */
+ gs_plugin_cache_add (plugin,
+ gs_app_get_unique_id (priv->cached_origin),
+ priv->cached_origin);
+
/* register D-Bus errors */
fwupd_error_quark ();
g_signal_connect (priv->client, "changed",
diff --git a/src/plugins/gs-plugin-odrs.c b/src/plugins/gs-plugin-odrs.c
index 85093d2..bedbec8 100644
--- a/src/plugins/gs-plugin-odrs.c
+++ b/src/plugins/gs-plugin-odrs.c
@@ -40,6 +40,7 @@ struct GsPluginData {
gchar *user_hash;
gchar *review_server;
GHashTable *ratings;
+ GsApp *cached_origin;
};
void
@@ -75,6 +76,18 @@ gs_plugin_initialize (GsPlugin *plugin)
priv->distro = g_strdup ("Unknown");
}
+ /* add source */
+ priv->cached_origin = gs_app_new (gs_plugin_get_name (plugin));
+ gs_app_set_kind (priv->cached_origin, AS_APP_KIND_SOURCE);
+ gs_app_set_origin_hostname (priv->cached_origin, priv->review_server);
+ gs_app_set_origin_ui (priv->cached_origin, "Open Desktop Review Server");
+
+ /* add the source to the plugin cache which allows us to match the
+ * unique ID to a GsApp when creating an event */
+ gs_plugin_cache_add (plugin,
+ gs_app_get_unique_id (priv->cached_origin),
+ priv->cached_origin);
+
/* need application IDs and version */
gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_AFTER, "appstream");
gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_AFTER, "flatpak-system");
@@ -221,6 +234,7 @@ gs_plugin_destroy (GsPlugin *plugin)
g_free (priv->distro);
g_hash_table_unref (priv->ratings);
g_object_unref (priv->settings);
+ g_object_unref (priv->cached_origin);
}
static AsReview *
diff --git a/src/plugins/gs-plugin-shell-extensions.c b/src/plugins/gs-plugin-shell-extensions.c
index 5821bc9..2fc11d6 100644
--- a/src/plugins/gs-plugin-shell-extensions.c
+++ b/src/plugins/gs-plugin-shell-extensions.c
@@ -43,6 +43,7 @@
struct GsPluginData {
GDBusProxy *proxy;
gchar *shell_version;
+ GsApp *cached_origin;
};
typedef enum {
@@ -65,7 +66,19 @@ typedef enum {
void
gs_plugin_initialize (GsPlugin *plugin)
{
- gs_plugin_alloc_data (plugin, sizeof(GsPluginData));
+ GsPluginData *priv = gs_plugin_alloc_data (plugin, sizeof(GsPluginData));
+
+ /* add source */
+ priv->cached_origin = gs_app_new (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);
+ gs_app_set_origin_ui (priv->cached_origin, "GNOME Shell Extensions");
+
+ /* add the source to the plugin cache which allows us to match the
+ * unique ID to a GsApp when creating an event */
+ gs_plugin_cache_add (plugin,
+ gs_app_get_unique_id (priv->cached_origin),
+ priv->cached_origin);
}
void
@@ -75,6 +88,7 @@ gs_plugin_destroy (GsPlugin *plugin)
g_free (priv->shell_version);
if (priv->proxy != NULL)
g_object_unref (priv->proxy);
+ g_object_unref (priv->cached_origin);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]