summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-04-28 15:18:50 (GMT)
committerRichard Hughes <richard@hughsie.com>2016-04-28 15:18:57 (GMT)
commita39c27561f47e190fa8eb4164570c55f84928692 (patch)
treeccbfba6ffada54f16dabcb0fe22f0cf08310faa2 /src/plugins/gs-plugin-fwupd.c
parent28c6daa7771d800dd16c58fb427e848955ceada9 (diff)
downloadgnome-software-a39c27561f47e190fa8eb4164570c55f84928692.zip
gnome-software-a39c27561f47e190fa8eb4164570c55f84928692.tar.xz
Do not unconditionally invalidate the updates list on hardware hotplug
fwupd >= 0.7.1 supports per-device signals, and also the SUPPORTED flag -- so we can limit number of UI refreshes and keep the delay to a minimum.
Diffstat (limited to 'src/plugins/gs-plugin-fwupd.c')
-rw-r--r--src/plugins/gs-plugin-fwupd.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/plugins/gs-plugin-fwupd.c b/src/plugins/gs-plugin-fwupd.c
index 8f5a790..4625ac4 100644
--- a/src/plugins/gs-plugin-fwupd.c
+++ b/src/plugins/gs-plugin-fwupd.c
@@ -101,9 +101,37 @@ gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
static void
gs_plugin_fwupd_changed_cb (FwupdClient *client, GsPlugin *plugin)
{
+#if !FWUPD_CHECK_VERSION(0,7,1)
+ /* fwupd < 0.7.1 only supported the ::Changed() signal */
gs_plugin_updates_changed (plugin);
+#endif
}
+#if FWUPD_CHECK_VERSION(0,7,1)
+/**
+ * gs_plugin_fwupd_device_changed_cb:
+ */
+static void
+gs_plugin_fwupd_device_changed_cb (FwupdClient *client,
+ FwupdResult *device,
+ GsPlugin *plugin)
+{
+ /* fwupd >= 0.7.1 supports per-device signals, and also the
+ * SUPPORTED flag -- so we can limit number of UI refreshes */
+ if (!fwupd_result_has_device_flag (device, FU_DEVICE_FLAG_SUPPORTED)) {
+ g_debug ("%s changed (not supported) so ignoring",
+ fwupd_result_get_device_id (device));
+ return;
+ }
+
+ /* If the flag is set the device matches something in the
+ * metadata as therefor is worth refreshing the update list */
+ g_debug ("%s changed (supported) so reloading",
+ fwupd_result_get_device_id (device));
+ gs_plugin_updates_changed (plugin);
+}
+#endif
+
/**
* gs_plugin_setup:
*/
@@ -118,6 +146,14 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
fwupd_error_quark ();
g_signal_connect (priv->client, "changed",
G_CALLBACK (gs_plugin_fwupd_changed_cb), plugin);
+#if FWUPD_CHECK_VERSION(0,7,1)
+ g_signal_connect (priv->client, "device-added",
+ G_CALLBACK (gs_plugin_fwupd_device_changed_cb), plugin);
+ g_signal_connect (priv->client, "device-removed",
+ G_CALLBACK (gs_plugin_fwupd_device_changed_cb), plugin);
+ g_signal_connect (priv->client, "device-changed",
+ G_CALLBACK (gs_plugin_fwupd_device_changed_cb), plugin);
+#endif
/* get the hash of the previously downloaded file */
priv->lvfs_sig_fn = gs_utils_get_cache_filename ("firmware",