[network-manager-applet] gsm: give some feedback when the PIN or PUK is wrong



commit 6af4893bf0f85ade17924bb32ead20b849ce6ce8
Author: Dan Williams <dcbw redhat com>
Date:   Thu Mar 18 00:07:54 2010 -0700

    gsm: give some feedback when the PIN or PUK is wrong

 src/applet-device-gsm.c |   18 ++++++++++++++----
 src/applet-dialogs.c    |   20 ++++++++++++++++----
 src/applet-dialogs.h    |    2 +-
 3 files changed, 31 insertions(+), 9 deletions(-)
---
diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
index d02a19e..413dfe0 100644
--- a/src/applet-device-gsm.c
+++ b/src/applet-device-gsm.c
@@ -839,15 +839,20 @@ unlock_pin_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
 {
 	GsmDeviceInfo *info = user_data;
 	GError *error = NULL;
+	const char *dbus_error, *msg = NULL;
 
 	if (dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID)) {
 		unlock_dialog_destroy (info);
 		return;
 	}
 
-	/* FIXME: show the error in the dialog or something */
+	dbus_error = dbus_g_error_get_name (error);
+	if (dbus_error && !strcmp (dbus_error, "org.freedesktop.ModemManager.Modem.Gsm.IncorrectPassword"))
+		msg = _("Wrong PIN code; please contact your provider.");
+	else
+		msg = error ? error->message : NULL;
 
-	applet_mobile_pin_dialog_stop_spinner (info->dialog);
+	applet_mobile_pin_dialog_stop_spinner (info->dialog, msg);
 	g_warning ("%s: error unlocking with PIN: %s", __func__, error->message);
 	g_clear_error (&error);
 }
@@ -857,15 +862,20 @@ unlock_puk_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
 {
 	GsmDeviceInfo *info = user_data;
 	GError *error = NULL;
+	const char *dbus_error, *msg = NULL;
 
 	if (dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID)) {
 		unlock_dialog_destroy (info);
 		return;
 	}
 
-	/* FIXME: show the error in the dialog or something */
+	dbus_error = dbus_g_error_get_name (error);
+	if (dbus_error && !strcmp (dbus_error, "org.freedesktop.ModemManager.Modem.Gsm.IncorrectPassword"))
+		msg = _("Wrong PUK code; please contact your provider.");
+	else
+		msg = error ? error->message : NULL;
 
-	applet_mobile_pin_dialog_stop_spinner (info->dialog);
+	applet_mobile_pin_dialog_stop_spinner (info->dialog, msg);
 	g_warning ("%s: error unlocking with PIN: %s", __func__, error->message);
 	g_clear_error (&error);
 }
diff --git a/src/applet-dialogs.c b/src/applet-dialogs.c
index 149187f..a7b0687 100644
--- a/src/applet-dialogs.c
+++ b/src/applet-dialogs.c
@@ -807,6 +807,10 @@ mpd_entry_changed (GtkWidget *widget, gpointer user_data)
 	valid = TRUE;
 
 done:
+	/* Clear any error text in the progress label now that the user has changed something */
+	widget = glade_xml_get_widget (xml, "progress_label");
+	gtk_label_set_text (GTK_LABEL (widget), "");
+
 	widget = glade_xml_get_widget (xml, "unlock_button");
 	g_warn_if_fail (widget != NULL);
 	gtk_widget_set_sensitive (widget, valid);
@@ -1098,10 +1102,10 @@ applet_mobile_pin_dialog_start_spinner (GtkWidget *dialog, const char *text)
 }
 
 void
-applet_mobile_pin_dialog_stop_spinner (GtkWidget *dialog)
+applet_mobile_pin_dialog_stop_spinner (GtkWidget *dialog, const char *text)
 {
 	GladeXML *xml;
-	GtkWidget *spinner, *widget;
+	GtkWidget *spinner, *widget, *align;
 
 	g_return_if_fail (dialog != NULL);
 
@@ -1111,10 +1115,18 @@ applet_mobile_pin_dialog_stop_spinner (GtkWidget *dialog)
 	spinner = g_object_get_data (G_OBJECT (dialog), "spinner");
 	g_return_if_fail (spinner != NULL);
 	nma_bling_spinner_stop (NMA_BLING_SPINNER (spinner));
-	gtk_widget_hide (spinner);
+	g_object_set_data (G_OBJECT (dialog), "spinner", NULL);
+
+	/* Remove it from the alignment */
+	align = glade_xml_get_widget (xml, "spinner_alignment");
+	gtk_container_remove (GTK_CONTAINER (align), spinner);
 
 	widget = glade_xml_get_widget (xml, "progress_label");
-	gtk_widget_hide (widget);
+	if (text) {
+		gtk_label_set_text (GTK_LABEL (widget), text);
+		gtk_widget_show (widget);
+	} else
+		gtk_widget_hide (widget);
 
 	/* Resensitize stuff */
 	widget = glade_xml_get_widget (xml, "code1_entry");
diff --git a/src/applet-dialogs.h b/src/applet-dialogs.h
index 1e7546e..55fd56c 100644
--- a/src/applet-dialogs.h
+++ b/src/applet-dialogs.h
@@ -68,6 +68,6 @@ const char *applet_mobile_pin_dialog_get_entry3 (GtkWidget *dialog);
 void applet_mobile_pin_dialog_match_23 (GtkWidget *dialog, gboolean match);
 
 void applet_mobile_pin_dialog_start_spinner (GtkWidget *dialog, const char *text);
-void applet_mobile_pin_dialog_stop_spinner (GtkWidget *dialog);
+void applet_mobile_pin_dialog_stop_spinner (GtkWidget *dialog, const char *text);
 
 #endif /* __APPLET_DIALOGS_H__ */



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