From c1e3ded9a3d66e9f356bbaa6968243e1d4ad65ed Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Thu, 17 Mar 2016 09:43:04 +0000 Subject: [PATCH] Add fwupd_trust_flag_to_string() --- libfwupd/fwupd-enums.c | 34 ++++++++++++++++++++++++++++++++++ libfwupd/fwupd-enums.h | 2 ++ 2 files changed, 36 insertions(+) diff --git a/libfwupd/fwupd-enums.c b/libfwupd/fwupd-enums.c index d76f5131e..f750b28c6 100644 --- a/libfwupd/fwupd-enums.c +++ b/libfwupd/fwupd-enums.c @@ -118,3 +118,37 @@ fwupd_device_flag_from_string (const gchar *device_flag) return FU_DEVICE_FLAG_LOCKED; return FU_DEVICE_FLAG_LAST; } + +/** + * fwupd_trust_flag_to_string: + * + * Since: 0.7.0 + **/ +const gchar * +fwupd_trust_flag_to_string (FwupdTrustFlags trust_flag) +{ + if (trust_flag == FWUPD_TRUST_FLAG_NONE) + return "none"; + if (trust_flag == FWUPD_TRUST_FLAG_PAYLOAD) + return "payload"; + if (trust_flag == FWUPD_TRUST_FLAG_METADATA) + return "metadata"; + return NULL; +} + +/** + * fwupd_trust_flag_from_string: + * + * Since: 0.7.0 + **/ +FwupdTrustFlags +fwupd_trust_flag_from_string (const gchar *trust_flag) +{ + if (g_strcmp0 (trust_flag, "none") == 0) + return FWUPD_TRUST_FLAG_NONE; + if (g_strcmp0 (trust_flag, "payload") == 0) + return FWUPD_TRUST_FLAG_PAYLOAD; + if (g_strcmp0 (trust_flag, "metadata") == 0) + return FWUPD_TRUST_FLAG_METADATA; + return FWUPD_TRUST_FLAG_LAST; +} diff --git a/libfwupd/fwupd-enums.h b/libfwupd/fwupd-enums.h index 1b19ba356..c15f2ecb9 100644 --- a/libfwupd/fwupd-enums.h +++ b/libfwupd/fwupd-enums.h @@ -83,5 +83,7 @@ const gchar *fwupd_status_to_string (FwupdStatus status); FwupdStatus fwupd_status_from_string (const gchar *status); const gchar *fwupd_device_flag_to_string (FwupdDeviceFlags device_flag); FwupdDeviceFlags fwupd_device_flag_from_string (const gchar *device_flag); +const gchar *fwupd_trust_flag_to_string (FwupdTrustFlags trust_flag); +FwupdTrustFlags fwupd_trust_flag_from_string (const gchar *trust_flag); #endif /* __FWUPD_ENUMS_H */