[gnome-packagekit] Show errors when using the firmware client, don't just silently fail



commit 96775dae196f9ce19010a38fbaa6adcc51b7ada9
Author: Richard Hughes <richard hughsie com>
Date:   Wed Aug 19 09:37:36 2009 +0100

    Show errors when using the firmware client, don't just silently fail

 src/gpk-firmware.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/src/gpk-firmware.c b/src/gpk-firmware.c
index e55ae5a..2f29165 100644
--- a/src/gpk-firmware.c
+++ b/src/gpk-firmware.c
@@ -43,6 +43,7 @@
 #include "egg-string.h"
 
 #include "gpk-common.h"
+#include "gpk-error.h"
 #include "gpk-firmware.h"
 
 static void     gpk_firmware_finalize	(GObject	  *object);
@@ -297,6 +298,35 @@ gpk_firmware_udev_text_decode (const gchar *data)
 }
 
 /**
+ * gpk_firmware_error_code_cb:
+ **/
+static void
+gpk_firmware_error_code_cb (PkClient *client, PkErrorCodeEnum code, const gchar *details, GpkFirmware *firmware)
+{
+	/* ignore some errors */
+	if (code == PK_ERROR_ENUM_PROCESS_KILL ||
+	    code == PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
+		egg_debug ("error ignored %s: %s", pk_error_enum_to_text (code), details);
+		return;
+	}
+
+//	/* ignore the ones we can handle */
+//	if (pk_error_code_is_need_untrusted (code)) {
+//		egg_debug ("error ignored as we're handling %s: %s", pk_error_enum_to_text (code), details);
+//		return;
+//	}
+
+	/* ignore not authorised, which seems odd but this will happen if the user clicks cancel */
+	if (code == PK_ERROR_ENUM_NOT_AUTHORIZED) {
+		egg_debug ("auth failure '%s' ignored: %s", pk_error_enum_to_text (code), details);
+		return;
+	}
+
+	gpk_error_dialog (gpk_error_enum_to_localised_text (code),
+			  gpk_error_enum_to_localised_message (code), details);
+}
+
+/**
  * gpk_firmware_class_init:
  * @klass: The GpkFirmwareClass
  **/
@@ -332,6 +362,9 @@ gpk_firmware_init (GpkFirmware *firmware)
 	pk_client_set_synchronous (firmware->priv->client_primary, TRUE, NULL);
 	pk_client_set_use_buffer (firmware->priv->client_primary, TRUE, NULL);
 
+	g_signal_connect (firmware->priv->client_primary, "error-code",
+			  G_CALLBACK (gpk_firmware_error_code_cb), firmware);
+
 	/* should we check and show the user */
 	ret = gconf_client_get_bool (firmware->priv->gconf_client, GPK_CONF_ENABLE_CHECK_FIRMWARE, NULL);
 	if (!ret) {



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