[gnome-software/gnome-3-26] fwupd: Do not crash when trying to list a locked device
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-26] fwupd: Do not crash when trying to list a locked device
- Date: Tue, 21 Nov 2017 11:04:23 +0000 (UTC)
commit 088fca0cacdedd0024a3d7375280121ad0798520
Author: Richard Hughes <richard hughsie com>
Date: Mon Nov 20 14:29:23 2017 +0000
fwupd: Do not crash when trying to list a locked device
Locked devices do not have FwupdRelease objects set as the 'Install' action is
mapped internally to an 'Unlock' action instead. Create a GsApp object based
just on the FwupdDevice properties in this case.
Should resolve: https://bugzilla.gnome.org/show_bug.cgi?id=789985
(This cherry picks applicable portions from commit
d1b75f27e46c0dd5b656ce7bc5859158a80299c7)
plugins/fwupd/gs-plugin-fwupd.c | 51 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 50 insertions(+), 1 deletions(-)
---
diff --git a/plugins/fwupd/gs-plugin-fwupd.c b/plugins/fwupd/gs-plugin-fwupd.c
index 56ec906..f66428c 100644
--- a/plugins/fwupd/gs-plugin-fwupd.c
+++ b/plugins/fwupd/gs-plugin-fwupd.c
@@ -416,6 +416,55 @@ gs_plugin_fwupd_new_app_from_results (GsPlugin *plugin, FwupdResult *res)
return app;
}
+#if FWUPD_CHECK_VERSION(1,0,0)
+static gchar *
+gs_plugin_fwupd_build_device_id (FwupdDevice *dev)
+{
+ g_autofree gchar *tmp = g_strdup (fwupd_device_get_id (dev));
+ g_strdelimit (tmp, "/", '_');
+ return g_strdup_printf ("org.fwupd.%s.device", tmp);
+}
+
+static GsApp *
+gs_plugin_fwupd_new_app_from_device_raw (GsPlugin *plugin, FwupdDevice *device)
+{
+ GPtrArray *icons;
+ g_autofree gchar *id = NULL;
+ g_autoptr(GsApp) app = NULL;
+
+ /* create a GsApp based on the device, not the release */
+ id = gs_plugin_fwupd_build_device_id (device);
+ app = gs_app_new (id);
+ gs_app_set_kind (app, AS_APP_KIND_FIRMWARE);
+ gs_app_set_scope (app, AS_APP_SCOPE_SYSTEM);
+ gs_app_set_state (app, AS_APP_STATE_INSTALLED);
+ gs_app_add_quirk (app, AS_APP_QUIRK_NOT_LAUNCHABLE);
+ gs_app_set_version (app, fwupd_device_get_version (device));
+ gs_app_set_name (app, GS_APP_QUALITY_LOWEST, fwupd_device_get_name (device));
+ gs_app_set_summary (app, GS_APP_QUALITY_LOWEST, fwupd_device_get_summary (device));
+ gs_app_set_description (app, GS_APP_QUALITY_LOWEST, fwupd_device_get_description (device));
+ gs_app_set_origin (app, fwupd_device_get_vendor (device));
+ gs_fwupd_app_set_device_id (app, fwupd_device_get_id (device));
+ gs_app_set_management_plugin (app, "fwupd");
+
+ /* create icon */
+ icons = fwupd_device_get_icons (device);
+ for (guint j = 0; j < icons->len; j++) {
+ const gchar *icon = g_ptr_array_index (icons, j);
+ g_autoptr(AsIcon) icon_tmp = as_icon_new ();
+ if (g_str_has_prefix (icon, "/")) {
+ as_icon_set_kind (icon_tmp, AS_ICON_KIND_LOCAL);
+ as_icon_set_filename (icon_tmp, icon);
+ } else {
+ as_icon_set_kind (icon_tmp, AS_ICON_KIND_STOCK);
+ as_icon_set_name (icon_tmp, icon);
+ }
+ gs_app_add_icon (app, icon_tmp);
+ }
+ return g_steal_pointer (&app);
+}
+#endif
+
static gboolean
gs_plugin_add_update_app (GsPlugin *plugin,
GsAppList *list,
@@ -641,7 +690,7 @@ gs_plugin_fwupd_add_updates (GsPlugin *plugin,
/* locked device that needs unlocking */
if (fwupd_device_has_flag (dev, FWUPD_DEVICE_FLAG_LOCKED)) {
g_autoptr(GsApp) app = NULL;
- app = gs_plugin_fwupd_new_app_from_device (plugin, dev);
+ app = gs_plugin_fwupd_new_app_from_device_raw (plugin, dev);
gs_fwupd_app_set_is_locked (app, TRUE);
gs_app_list_add (list, app);
continue;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]