[gnome-software] fwupd: Support live updates of firmware where supported



commit 37f1b8206af0e7e62172ce64eee4d783a3162000
Author: Richard Hughes <richard hughsie com>
Date:   Wed Nov 25 16:41:00 2015 +0000

    fwupd: Support live updates of firmware where supported

 src/plugins/gs-plugin-fwupd.c |   30 ++++++++++++++++++++++++++----
 1 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/src/plugins/gs-plugin-fwupd.c b/src/plugins/gs-plugin-fwupd.c
index 2bdd690..7349e1c 100644
--- a/src/plugins/gs-plugin-fwupd.c
+++ b/src/plugins/gs-plugin-fwupd.c
@@ -793,6 +793,7 @@ static gboolean
 gs_plugin_fwupd_upgrade (GsPlugin *plugin,
                         const gchar *filename,
                         const gchar *device_id,
+                        gboolean do_offline,
                         GCancellable *cancellable,
                         GError **error)
 {
@@ -815,8 +816,10 @@ gs_plugin_fwupd_upgrade (GsPlugin *plugin,
                               "reason", g_variant_new_string ("system-update"));
        g_variant_builder_add (&builder, "{sv}",
                               "filename", g_variant_new_string (filename));
-       g_variant_builder_add (&builder, "{sv}",
-                              "offline", g_variant_new_boolean (TRUE));
+       if (do_offline) {
+               g_variant_builder_add (&builder, "{sv}",
+                                      "offline", g_variant_new_boolean (TRUE));
+       }
 
        /* open file */
        fd = open (filename, O_RDONLY);
@@ -891,7 +894,7 @@ gs_plugin_app_upgrade (GsPlugin *plugin,
                return FALSE;
        }
        gs_app_set_state (app, AS_APP_STATE_INSTALLING);
-       if (!gs_plugin_fwupd_upgrade (plugin, filename, device_id,
+       if (!gs_plugin_fwupd_upgrade (plugin, filename, device_id, TRUE,
                                      cancellable, error))
                return FALSE;
        gs_app_set_state (app, AS_APP_STATE_INSTALLED);
@@ -920,6 +923,8 @@ gs_plugin_offline_update (GsPlugin *plugin,
 
 /**
  * gs_plugin_app_install:
+ *
+ * Called when a user double clicks on a .cab file
  */
 gboolean
 gs_plugin_app_install (GsPlugin *plugin,
@@ -928,6 +933,7 @@ gs_plugin_app_install (GsPlugin *plugin,
                       GError **error)
 {
        const gchar *filename;
+       gboolean offline = TRUE;
 
        /* only process this app if was created by this plugin */
        if (g_strcmp0 (gs_app_get_management_plugin (app), "fwupd") != 0)
@@ -943,7 +949,9 @@ gs_plugin_app_install (GsPlugin *plugin,
                return FALSE;
        }
        gs_app_set_state (app, AS_APP_STATE_INSTALLING);
-       if (!gs_plugin_fwupd_upgrade (plugin, filename, FWUPD_DEVICE_ID_ANY,
+       if (gs_app_get_kind (app) == GS_APP_KIND_FIRMWARE_UPDATE)
+               offline = FALSE;
+       if (!gs_plugin_fwupd_upgrade (plugin, filename, FWUPD_DEVICE_ID_ANY, offline,
                                      cancellable, error))
                return FALSE;
        gs_app_set_state (app, AS_APP_STATE_INSTALLED);
@@ -951,6 +959,20 @@ gs_plugin_app_install (GsPlugin *plugin,
 }
 
 /**
+ * gs_plugin_app_update:
+ *
+ * This is only called when updating device firmware live.
+ */
+gboolean
+gs_plugin_app_update (GsPlugin *plugin,
+                     GsApp *app,
+                     GCancellable *cancellable,
+                     GError **error)
+{
+       return gs_plugin_app_install (plugin, app, cancellable, error);
+}
+
+/**
  * gs_plugin_fwupd_content_type_matches:
  */
 static gboolean


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