Compare commits

...

3 Commits

Author SHA1 Message Date
Kate Hsuan
26421d4be9 Three fixes.
1. "Summary" will be the event title.
2. fwupd_event_to_log() was removed.
3. description was moved to subtitle.
2022-07-25 23:46:48 +08:00
Kate Hsuan
6ea23d553a Fetch summary content. 2022-07-25 13:57:01 +08:00
Kate Hsuan
9c0ab0c3d6 panel: firmware-security: Show description for each event
Showing the event description to improve the user friendly.

Link: https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1938
Signed-off-by: Kate Hsuan <hpa@redhat.com>
2022-07-12 18:46:17 +08:00
3 changed files with 25 additions and 141 deletions

View File

@@ -124,16 +124,17 @@ static void
parse_event_variant_iter (CcfirmwareSecurityPanel *self,
GVariantIter *iter)
{
FwupdSecurityAttrResult result = 0;
FwupdSecurityAttrFlags flags = 0;
g_autofree gchar *date_string = NULL;
g_autoptr (GDateTime) date = NULL;
const gchar *appstream_id = NULL;
const gchar *key;
const gchar *event_msg;
const gchar *description = NULL;
const gchar *summary = NULL;
guint64 timestamp = 0;
GVariant *value;
GtkWidget *row;
GtkWidget *subrow;
while (g_variant_iter_next (iter, "{&sv}", &key, &value))
{
@@ -141,10 +142,12 @@ parse_event_variant_iter (CcfirmwareSecurityPanel *self,
appstream_id = g_variant_get_string (value, NULL);
else if (g_strcmp0 (key, "Flags") == 0)
flags = g_variant_get_uint64(value);
else if (g_strcmp0 (key, "HsiResult") == 0)
result = g_variant_get_uint32 (value);
else if (g_strcmp0 (key, "Created") == 0)
timestamp = g_variant_get_uint64 (value);
else if (g_strcmp0 (key, "Description") == 0)
description = g_variant_get_string (value, NULL);
else if (g_strcmp0 (key, "Summary") == 0)
summary = g_variant_get_string (value, NULL);
g_variant_unref (value);
}
@@ -152,27 +155,38 @@ parse_event_variant_iter (CcfirmwareSecurityPanel *self,
if (appstream_id == NULL)
return;
event_msg = fwupd_event_to_log (appstream_id, result);
if (event_msg == NULL)
if (summary == NULL)
return;
/* build new row */
date = g_date_time_new_from_unix_local (timestamp);
date_string = g_date_time_format (date, "\%F \%H:\%m:\%S");
row = adw_action_row_new ();
row = adw_expander_row_new ();
if (flags & FWUPD_SECURITY_ATTR_FLAG_SUCCESS)
{
adw_action_row_set_icon_name (ADW_ACTION_ROW (row), "emblem-default-symbolic");
adw_expander_row_set_icon_name (ADW_EXPANDER_ROW (row), "emblem-default-symbolic");
gtk_widget_add_css_class (row, "success-icon");
}
else
{
adw_action_row_set_icon_name (ADW_ACTION_ROW (row), "dialog-warning-symbolic");
adw_expander_row_set_icon_name (ADW_EXPANDER_ROW (row), "dialog-warning-symbolic");
gtk_widget_add_css_class (row, "warning-icon");
}
adw_preferences_row_set_title (ADW_PREFERENCES_ROW (row), event_msg);
adw_action_row_set_subtitle (ADW_ACTION_ROW (row), date_string);
if (description)
{
subrow = adw_action_row_new ();
adw_action_row_set_subtitle (ADW_ACTION_ROW (subrow), dgettext ("fwupd", description));
adw_expander_row_add_row (ADW_EXPANDER_ROW (row), subrow);
}
else
{
adw_expander_row_set_enable_expansion (ADW_EXPANDER_ROW (row), false);
}
adw_preferences_row_set_title (ADW_PREFERENCES_ROW (row), dgettext ("fwupd", summary));
adw_expander_row_set_subtitle (ADW_EXPANDER_ROW (row), date_string);
adw_preferences_group_add (ADW_PREFERENCES_GROUP (self->firmware_security_log_pgroup), GTK_WIDGET (row));
adw_view_stack_set_visible_child_name (ADW_VIEW_STACK (self->firmware_security_log_stack), "page2");

View File

@@ -132,134 +132,6 @@ firmware_security_attr_has_flag (guint64 flags,
return (flags & flag) > 0;
}
const char *
fwupd_event_to_log (const char *appstream_id,
FwupdSecurityAttrResult result)
{
struct
{
const gchar *appstream_id;
FwupdSecurityAttrResult result;
const gchar *text;
} event_log_items[] =
{
{
"org.fwupd.hsi.Iommu",
FWUPD_SECURITY_ATTR_RESULT_ENABLED,
/* TRANSLATORS: HSI event title */
N_("IOMMU device protection enabled")
},
{
"org.fwupd.hsi.Iommu",
FWUPD_SECURITY_ATTR_RESULT_NOT_FOUND,
/* TRANSLATORS: HSI event title */
N_("IOMMU device protection disabled")},
{
"org.fwupd.hsi.Fwupd.Plugins",
FWUPD_SECURITY_ATTR_RESULT_NOT_TAINTED,
NULL
},
{
"org.fwupd.hsi.Fwupd.Plugins",
FWUPD_SECURITY_ATTR_RESULT_TAINTED,
NULL
},
{
"org.fwupd.hsi.Fwupd.Plugins",
FWUPD_SECURITY_ATTR_RESULT_NOT_ENABLED,
NULL
},
{
"org.fwupd.hsi.Kernel.Tainted",
FWUPD_SECURITY_ATTR_RESULT_NOT_TAINTED,
/* TRANSLATORS: HSI event title */
N_("Kernel is no longer tainted")
},
{
"org.fwupd.hsi.Kernel.Tainted",
FWUPD_SECURITY_ATTR_RESULT_TAINTED,
/* TRANSLATORS: HSI event title */
N_("Kernel is tainted")
},
{
"org.fwupd.hsi.Kernel.Lockdown",
FWUPD_SECURITY_ATTR_RESULT_NOT_ENABLED,
/* TRANSLATORS: HSI event title */
N_("Kernel lockdown disabled")
},
{
"org.fwupd.hsi.Kernel.Lockdown",
FWUPD_SECURITY_ATTR_RESULT_ENABLED,
/* TRANSLATORS: HSI event title */
N_("Kernel lockdown enabled")
},
{
"org.fwupd.hsi.AcpiDmar",
FWUPD_SECURITY_ATTR_RESULT_NOT_ENABLED,
/* TRANSLATORS: HSI event title */
N_("Pre-boot DMA protection is disabled")
},
{
"org.fwupd.hsi.AcpiDmar",
FWUPD_SECURITY_ATTR_RESULT_ENABLED,
/* TRANSLATORS: HSI event title */
N_("Pre-boot DMA protection is enabled")
},
{
"org.fwupd.hsi.Uefi.SecureBoot",
FWUPD_SECURITY_ATTR_RESULT_NOT_ENABLED,
/* TRANSLATORS: HSI event title */
N_("Secure Boot disabled")
},
{
"org.fwupd.hsi.Uefi.SecureBoot",
FWUPD_SECURITY_ATTR_RESULT_ENABLED,
/* TRANSLATORS: HSI event title */
N_("Secure Boot enabled")
},
{
"org.fwupd.hsi.Tpm.EmptyPcr",
FWUPD_SECURITY_ATTR_RESULT_VALID,
/* TRANSLATORS: HSI event title */
N_("All TPM PCRs are valid")
},
{
"org.fwupd.hsi.Tpm.EmptyPcr",
FWUPD_SECURITY_ATTR_RESULT_NOT_VALID,
/* TRANSLATORS: HSI event title */
N_("All TPM PCRs are now valid")
},
{
"org.fwupd.hsi.Uefi.SecureBoot",
FWUPD_SECURITY_ATTR_RESULT_VALID,
/* TRANSLATORS: HSI event title */
N_("A TPM PCR is now an invalid value")
},
{
"org.fwupd.hsi.Tpm.ReconstructionPcr0",
FWUPD_SECURITY_ATTR_RESULT_NOT_VALID,
/* TRANSLATORS: HSI event title */
N_("TPM PCR0 reconstruction is invalid")
},
{
NULL,
0,
NULL
}
};
for (int i = 0; event_log_items[i].appstream_id != NULL; i++)
{
if (g_strcmp0 (appstream_id, event_log_items[i].appstream_id) == 0 &&
result == event_log_items[i].result)
{
return _(event_log_items[i].text);
}
}
return NULL;
}
void
load_custom_css (const char *path)
{

View File

@@ -102,8 +102,6 @@ const gchar *fu_security_attr_get_name (const gchar *appstream
gboolean firmware_security_attr_has_flag (guint64 flags,
FwupdSecurityAttrFlags flag);
void load_custom_css (const char *path);
const char *fwupd_event_to_log (const char *appstream_id,
FwupdSecurityAttrResult result);
G_END_DECLS