[network-manager-applet] editor: implement blank CA certificate nag dialog



commit 87eafbfd93f2f3c53464b967b62a7f847fd08b0c
Author: Dan Williams <dcbw redhat com>
Date:   Tue Mar 13 17:58:38 2012 -0500

    editor: implement blank CA certificate nag dialog
    
    This got lost somewhere.  Oddly, it's a lot easier to do in the
    editor than the applet wireless dialog.

 src/connection-editor/ce-page.c                |    8 ++++++
 src/connection-editor/ce-page.h                |    4 +++
 src/connection-editor/nm-connection-editor.c   |   33 ++++++++++++++++++++++++
 src/connection-editor/nm-connection-editor.h   |    1 +
 src/connection-editor/page-wired-security.c    |    9 ++++++
 src/connection-editor/page-wireless-security.c |   10 +++++++
 6 files changed, 65 insertions(+), 0 deletions(-)
---
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c
index 528757f..c0d8eb4 100644
--- a/src/connection-editor/ce-page.c
+++ b/src/connection-editor/ce-page.c
@@ -254,6 +254,14 @@ ce_page_get_next_available_name (GSList *connections, const char *format)
 	return cname;
 }
 
+GtkWidget *
+ce_page_nag_user (CEPage *self)
+{
+	if (CE_PAGE_GET_CLASS (self)->nag_user)
+		return CE_PAGE_GET_CLASS (self)->nag_user (self);
+	return NULL;
+}
+
 static void
 emit_initialized (CEPage *self, GError *error)
 {
diff --git a/src/connection-editor/ce-page.h b/src/connection-editor/ce-page.h
index fae6522..b5ec497 100644
--- a/src/connection-editor/ce-page.h
+++ b/src/connection-editor/ce-page.h
@@ -80,6 +80,8 @@ typedef struct {
 	/* Virtual functions */
 	gboolean    (*validate)     (CEPage *self, NMConnection *connection, GError **error);
 	char **     (*get_mac_list) (CEPage *self);
+	/* Let the page warn the user if some property needs review */
+	GtkWidget * (*nag_user)     (CEPage *self);
 
 	/* Signals */
 	void        (*changed)     (CEPage *self);
@@ -123,6 +125,8 @@ gboolean ce_page_get_initialized (CEPage *self);
 
 char *ce_page_get_next_available_name (GSList *connections, const char *format);
 
+GtkWidget *ce_page_nag_user (CEPage *self);
+
 /* Only for subclasses */
 NMConnection *ce_page_new_connection (const char *format,
                                       const char *ctype,
diff --git a/src/connection-editor/nm-connection-editor.c b/src/connection-editor/nm-connection-editor.c
index 1f54ae4..93d0e51 100644
--- a/src/connection-editor/nm-connection-editor.c
+++ b/src/connection-editor/nm-connection-editor.c
@@ -835,9 +835,42 @@ editor_closed_cb (GtkWidget *widget, GdkEvent *event, gpointer user_data)
 }
 
 static void
+nag_dialog_response_cb (GtkDialog *dialog,
+                        gint response,
+                        gpointer user_data)
+{
+	NMConnectionEditor *self = NM_CONNECTION_EDITOR (user_data);
+
+	gtk_widget_hide (GTK_WIDGET (dialog));
+	if (response == GTK_RESPONSE_NO) {
+		/* user opted not to correct the warning */
+		g_signal_emit (self, editor_signals[EDITOR_DONE], 0, GTK_RESPONSE_OK, NULL);
+	}
+	g_signal_handler_disconnect (dialog, self->nag_id);
+	self->nag_id = 0;
+}
+
+static void
 ok_button_clicked_cb (GtkWidget *widget, gpointer user_data)
 {
 	NMConnectionEditor *self = NM_CONNECTION_EDITOR (user_data);
+	GSList *iter;
+
+	/* Make sure the user is warned about insecure security options like no
+	 * CA certificate.
+	 */
+	g_warn_if_fail (self->nag_id == 0);
+	for (iter = self->pages; iter; iter = g_slist_next (iter)) {
+		CEPage *page = iter->data;
+		GtkWidget *nag_dialog;
+
+		nag_dialog = ce_page_nag_user (page);
+		if (nag_dialog) {
+			gtk_window_set_transient_for (GTK_WINDOW (nag_dialog), GTK_WINDOW (self->window));
+			self->nag_id = g_signal_connect (nag_dialog, "response", G_CALLBACK (nag_dialog_response_cb), self);
+			return;
+		}
+	}
 
 	g_signal_emit (self, editor_signals[EDITOR_DONE], 0, GTK_RESPONSE_OK, NULL);
 }
diff --git a/src/connection-editor/nm-connection-editor.h b/src/connection-editor/nm-connection-editor.h
index 3e66fe6..250f7b9 100644
--- a/src/connection-editor/nm-connection-editor.h
+++ b/src/connection-editor/nm-connection-editor.h
@@ -56,6 +56,7 @@ typedef struct {
 	GtkWidget *window;
 	GtkWidget *ok_button;
 	GtkWidget *cancel_button;
+	guint nag_id;
 
 	gboolean busy;
 	gboolean init_run;
diff --git a/src/connection-editor/page-wired-security.c b/src/connection-editor/page-wired-security.c
index 3e20ff1..9fb01b5 100644
--- a/src/connection-editor/page-wired-security.c
+++ b/src/connection-editor/page-wired-security.c
@@ -187,6 +187,14 @@ validate (CEPage *page, NMConnection *connection, GError **error)
 	return valid;
 }
 
+static GtkWidget *
+nag_user (CEPage *page)
+{
+	CEPageWiredSecurityPrivate *priv = CE_PAGE_WIRED_SECURITY_GET_PRIVATE (page);
+
+	return priv->security ? wireless_security_nag_user (priv->security) : NULL;
+}
+
 static void
 ce_page_wired_security_init (CEPageWiredSecurity *self)
 {
@@ -220,4 +228,5 @@ ce_page_wired_security_class_init (CEPageWiredSecurityClass *wired_security_clas
 	object_class->dispose = dispose;
 
 	parent_class->validate = validate;
+	parent_class->nag_user = nag_user;
 }
diff --git a/src/connection-editor/page-wireless-security.c b/src/connection-editor/page-wireless-security.c
index 839e166..68fd75e 100644
--- a/src/connection-editor/page-wireless-security.c
+++ b/src/connection-editor/page-wireless-security.c
@@ -461,6 +461,15 @@ validate (CEPage *page, NMConnection *connection, GError **error)
 	return valid;
 }
 
+static GtkWidget *
+nag_user (CEPage *page)
+{
+	WirelessSecurity *sec;
+
+	sec = wireless_security_combo_get_active (CE_PAGE_WIRELESS_SECURITY (page));
+	return sec ? wireless_security_nag_user (sec) : NULL;
+}
+
 static void
 ce_page_wireless_security_class_init (CEPageWirelessSecurityClass *wireless_security_class)
 {
@@ -471,4 +480,5 @@ ce_page_wireless_security_class_init (CEPageWirelessSecurityClass *wireless_secu
 	object_class->dispose = dispose;
 
 	parent_class->validate = validate;
+	parent_class->nag_user = nag_user;
 }



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