[gnome-software/wip/hughsie/battery-level-too-low] fwupd: Add support for a new error type
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/hughsie/battery-level-too-low] fwupd: Add support for a new error type
- Date: Thu, 11 Jul 2019 16:11:07 +0000 (UTC)
commit 5a73deb7b419dbde65588005e6b840a0c1cc38da
Author: Richard Hughes <richard hughsie com>
Date: Thu Jul 11 17:09:38 2019 +0100
fwupd: Add support for a new error type
Fixes https://gitlab.gnome.org/GNOME/gnome-software/issues/714
lib/gs-plugin-types.h | 2 ++
lib/gs-plugin.c | 2 ++
plugins/fwupd/gs-plugin-fwupd.c | 5 +++++
src/gs-shell.c | 40 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 49 insertions(+)
---
diff --git a/lib/gs-plugin-types.h b/lib/gs-plugin-types.h
index adee4b6e..394cd4b4 100644
--- a/lib/gs-plugin-types.h
+++ b/lib/gs-plugin-types.h
@@ -66,6 +66,7 @@ typedef guint64 GsPluginFlags;
* @GS_PLUGIN_ERROR_RESTART_REQUIRED: A restart is required
* @GS_PLUGIN_ERROR_AC_POWER_REQUIRED: AC power is required
* @GS_PLUGIN_ERROR_TIMED_OUT: The job timed out
+ * @GS_PLUGIN_ERROR_BATTERY_LEVEL_TOO_LOW: The system battery level is too low
*
* The failure error types.
**/
@@ -86,6 +87,7 @@ typedef enum {
GS_PLUGIN_ERROR_RESTART_REQUIRED,
GS_PLUGIN_ERROR_AC_POWER_REQUIRED,
GS_PLUGIN_ERROR_TIMED_OUT,
+ GS_PLUGIN_ERROR_BATTERY_LEVEL_TOO_LOW,
/*< private >*/
GS_PLUGIN_ERROR_LAST
} GsPluginError;
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index 26d4185c..aea94128 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -1548,6 +1548,8 @@ gs_plugin_error_to_string (GsPluginError error)
return "restart-required";
if (error == GS_PLUGIN_ERROR_AC_POWER_REQUIRED)
return "ac-power-required";
+ if (error == GS_PLUGIN_ERROR_BATTERY_LEVEL_TOO_LOW)
+ return "battery-level-too-low";
if (error == GS_PLUGIN_ERROR_TIMED_OUT)
return "timed-out";
return NULL;
diff --git a/plugins/fwupd/gs-plugin-fwupd.c b/plugins/fwupd/gs-plugin-fwupd.c
index 071471b2..cf6abfa9 100644
--- a/plugins/fwupd/gs-plugin-fwupd.c
+++ b/plugins/fwupd/gs-plugin-fwupd.c
@@ -71,6 +71,11 @@ gs_plugin_fwupd_error_convert (GError **perror)
case FWUPD_ERROR_AC_POWER_REQUIRED:
error->code = GS_PLUGIN_ERROR_AC_POWER_REQUIRED;
break;
+#if FWUPD_CHECK_VERSION(1,2,10)
+ case FWUPD_ERROR_BATTERY_LEVEL_TOO_LOW:
+ error->code = GS_PLUGIN_ERROR_BATTERY_LEVEL_TOO_LOW;
+ break;
+#endif
default:
error->code = GS_PLUGIN_ERROR_FAILED;
break;
diff --git a/src/gs-shell.c b/src/gs-shell.c
index f1c5bd13..df12aa69 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -1179,6 +1179,13 @@ gs_shell_show_event_install (GsShell *shell, GsPluginEvent *event)
"AC power is required"),
str_app);
break;
+ case GS_PLUGIN_ERROR_BATTERY_LEVEL_TOO_LOW:
+ /* TRANSLATORS: failure text for the in-app notification,
+ * where the %s is the application name (e.g. "Dell XPS 13") */
+ g_string_append_printf (str, _("Unable to install %s: "
+ "The battery level is too low"),
+ str_app);
+ break;
case GS_PLUGIN_ERROR_CANCELLED:
break;
default:
@@ -1334,6 +1341,21 @@ gs_shell_show_event_update (GsShell *shell, GsPluginEvent *event)
"AC power is required"));
}
break;
+ case GS_PLUGIN_ERROR_BATTERY_LEVEL_TOO_LOW:
+ if (app != NULL) {
+ str_app = gs_shell_get_title_from_app (app);
+ /* TRANSLATORS: failure text for the in-app notification,
+ * where the %s is the application name (e.g. "Dell XPS 13") */
+ g_string_append_printf (str, _("Unable to update %s: "
+ "The battery level is too low"),
+ str_app);
+ } else {
+ /* TRANSLATORS: failure text for the in-app notification,
+ * where the %s is the application name (e.g. "Dell XPS 13") */
+ g_string_append_printf (str, _("Unable to install updates: "
+ "The battery level is too low"));
+ }
+ break;
case GS_PLUGIN_ERROR_CANCELLED:
break;
default:
@@ -1443,6 +1465,13 @@ gs_shell_show_event_upgrade (GsShell *shell, GsPluginEvent *event)
"AC power is required"),
str_app);
break;
+ case GS_PLUGIN_ERROR_BATTERY_LEVEL_TOO_LOW:
+ /* TRANSLATORS: failure text for the in-app notification,
+ * where the %s is the distro name (e.g. "Fedora 25") */
+ g_string_append_printf (str, _("Unable to upgrade to %s: "
+ "The battery level is too low"),
+ str_app);
+ break;
case GS_PLUGIN_ERROR_CANCELLED:
break;
default:
@@ -1509,6 +1538,13 @@ gs_shell_show_event_remove (GsShell *shell, GsPluginEvent *event)
"AC power is required"),
str_app);
break;
+ case GS_PLUGIN_ERROR_BATTERY_LEVEL_TOO_LOW:
+ /* TRANSLATORS: failure text for the in-app notification,
+ * where the %s is the application name (e.g. "GIMP") */
+ g_string_append_printf (str, _("Unable to remove %s: "
+ "The battery level is too low"),
+ str_app);
+ break;
case GS_PLUGIN_ERROR_CANCELLED:
break;
default:
@@ -1730,6 +1766,10 @@ gs_shell_show_event_fallback (GsShell *shell, GsPluginEvent *event)
/* TRANSLATORS: need to be connected to the AC power */
g_string_append (str, _("AC power is required"));
break;
+ case GS_PLUGIN_ERROR_BATTERY_LEVEL_TOO_LOW:
+ /* TRANSLATORS: not enough juice to do this safely */
+ g_string_append (str, _("The battery level is too low"));
+ break;
case GS_PLUGIN_ERROR_CANCELLED:
break;
default:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]