[network-manager-applet/thaller/758076_ui_no_ca_cert_required_2: 2/2] applet: remove the ca cert nag dialog.
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/thaller/758076_ui_no_ca_cert_required_2: 2/2] applet: remove the ca cert nag dialog.
- Date: Mon, 19 Aug 2013 13:28:59 +0000 (UTC)
commit 44d128799d36c70404c4d0d3381cb598f9d667b1
Author: Thomas Haller <thaller redhat com>
Date: Fri Aug 16 11:20:11 2013 +0200
applet: remove the ca cert nag dialog.
The previous commit introduced a new flag "No CA certificate required".
This change of the UI replaces the warning dialog (nag_dialog).
Signed-off-by: Thomas Haller <thaller redhat com>
src/wireless-security/eap-method-peap.c | 4 +-
src/wireless-security/eap-method-tls.c | 4 +-
src/wireless-security/eap-method-ttls.c | 4 +-
src/wireless-security/eap-method.c | 144 ++++---------------------------
src/wireless-security/eap-method.h | 11 +--
5 files changed, 33 insertions(+), 134 deletions(-)
---
diff --git a/src/wireless-security/eap-method-peap.c b/src/wireless-security/eap-method-peap.c
index d08887a..f61d57a 100644
--- a/src/wireless-security/eap-method-peap.c
+++ b/src/wireless-security/eap-method-peap.c
@@ -348,7 +348,9 @@ eap_method_peap_new (WirelessSecurity *ws_parent,
if (!parent)
return NULL;
- eap_method_nag_init (parent, "eap_peap_ca_cert_button", connection);
+ eap_method_ignore_ca_cert_init (parent, connection,
+ "eap_peap_ca_cert_not_required_checkbox",
+ "eap_peap_ca_cert_button");
method = (EAPMethodPEAP *) parent;
method->sec_parent = ws_parent;
diff --git a/src/wireless-security/eap-method-tls.c b/src/wireless-security/eap-method-tls.c
index 46d1931..efad6cb 100644
--- a/src/wireless-security/eap-method-tls.c
+++ b/src/wireless-security/eap-method-tls.c
@@ -431,7 +431,9 @@ eap_method_tls_new (WirelessSecurity *ws_parent,
method = (EAPMethodTLS *) parent;
method->new_connection = secrets_only ? FALSE : TRUE;
- eap_method_nag_init (parent, "eap_tls_ca_cert_button", connection);
+ eap_method_ignore_ca_cert_init (parent, connection,
+ "eap_tls_ca_cert_not_required_checkbox",
+ "eap_tls_ca_cert_button");
if (connection)
s_8021x = nm_connection_get_setting_802_1x (connection);
diff --git a/src/wireless-security/eap-method-ttls.c b/src/wireless-security/eap-method-ttls.c
index 4adb977..497a3eb 100644
--- a/src/wireless-security/eap-method-ttls.c
+++ b/src/wireless-security/eap-method-ttls.c
@@ -352,7 +352,9 @@ eap_method_ttls_new (WirelessSecurity *ws_parent,
if (!parent)
return NULL;
- eap_method_nag_init (parent, "eap_ttls_ca_cert_button", connection);
+ eap_method_ignore_ca_cert_init (parent, connection,
+ "eap_ttls_ca_cert_not_required_checkbox",
+ "eap_ttls_ca_cert_button");
method = (EAPMethodTTLS *) parent;
method->sec_parent = ws_parent;
diff --git a/src/wireless-security/eap-method.c b/src/wireless-security/eap-method.c
index a01428c..801530b 100644
--- a/src/wireless-security/eap-method.c
+++ b/src/wireless-security/eap-method.c
@@ -98,20 +98,6 @@ eap_method_update_secrets (EAPMethod *method, NMConnection *connection)
method->update_secrets (method, connection);
}
-typedef struct {
- EAPMethod *method;
- NMConnection *connection;
-} NagDialogResponseInfo;
-
-static void
-nag_dialog_destroyed (gpointer data, GObject *dialog_ptr)
-{
- NagDialogResponseInfo *info = (NagDialogResponseInfo *) data;
-
- memset (info, '\0', sizeof (NagDialogResponseInfo));
- g_free (info);
-}
-
static GSettings *
_get_ca_ignore_settings (const char *uuid)
{
@@ -139,41 +125,6 @@ _set_ignore_ca_cert (const char *uuid, gboolean phase2, gboolean ignore)
g_object_unref (settings);
}
-static void
-nag_dialog_response_cb (GtkDialog *nag_dialog,
- gint response,
- gpointer user_data)
-{
- NagDialogResponseInfo *info = (NagDialogResponseInfo *) user_data;
- EAPMethod *method = (EAPMethod *) info->method;
- NMConnection *connection = (NMConnection *) info->connection;
- GtkWidget *widget;
-
- if (response == GTK_RESPONSE_NO) {
- /* Grab the value of the "don't bother me" checkbox */
- widget = GTK_WIDGET (gtk_builder_get_object (method->nag_builder, "ignore_checkbox"));
- g_assert (widget);
-
- method->ignore_ca_cert = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-
- /* And save it */
- _set_ignore_ca_cert (nm_connection_get_uuid (connection),
- method->phase2,
- method->ignore_ca_cert);
- }
-
- gtk_widget_hide (GTK_WIDGET (nag_dialog));
-}
-
-static gboolean
-nag_dialog_delete_event_cb (GtkDialog *nag_dialog, GdkEvent *e, gpointer user_data)
-{
- // FIXME?: By emitting response signal, dismissing nag dialog with upper right "x" icon,
- // Alt-F4, or Esc would have the same behaviour as clicking "Ignore" button.
- //g_signal_emit_by_name (nag_dialog, "response", GTK_RESPONSE_NO, user_data);
- return TRUE; /* do not destroy */
-}
-
GtkWidget *
eap_method_nag_user (EAPMethod *method)
{
@@ -181,29 +132,24 @@ eap_method_nag_user (EAPMethod *method)
char *filename = NULL;
g_return_val_if_fail (method != NULL, NULL);
+ g_return_val_if_fail (method->connection != NULL, NULL);
- if (!method->nag_dialog || method->ignore_ca_cert)
- return NULL;
-
- /* Checkbox should be unchecked each time dialog comes up */
- widget = GTK_WIDGET (gtk_builder_get_object (method->nag_builder, "ignore_checkbox"));
- g_assert (widget);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
-
- /* Nag the user if the CA Cert is blank, since it's a security risk. */
widget = GTK_WIDGET (gtk_builder_get_object (method->builder, method->ca_cert_chooser));
g_assert (widget);
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
- if (filename != NULL) {
- g_free (filename);
- return NULL;
- }
- gtk_window_present (GTK_WINDOW (method->nag_dialog));
- return method->nag_dialog;
-}
+ /* Take the ca_cert_ignored checkbox value to assert that it is set to !filename. */
+ widget = GTK_WIDGET (gtk_builder_get_object (method->builder,
method->ca_cert_is_not_required_checkbox));
+ g_assert (widget && !filename == gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)));
-#define NAG_DIALOG_UI UIDIR "/nag-user-dialog.ui"
+ method->ignore_ca_cert = !filename;
+ _set_ignore_ca_cert (nm_connection_get_uuid (method->connection),
+ method->phase2,
+ method->ignore_ca_cert);
+
+ g_free (filename);
+ return NULL;
+}
static gboolean
_get_ignore_ca_cert (const char *uuid, gboolean phase2)
@@ -224,7 +170,9 @@ _get_ignore_ca_cert (const char *uuid, gboolean phase2)
}
void
-eap_method_ignore_ca_cert_init (EAPMethod *method, NMConnection *connection)
+eap_method_ignore_ca_cert_init (EAPMethod *method, NMConnection *connection,
+ const char *id_ca_cert_is_not_required_checkbox,
+ const char *id_ca_cert_chooser)
{
if (connection) {
NMSettingConnection *s_con;
@@ -237,62 +185,11 @@ eap_method_ignore_ca_cert_init (EAPMethod *method, NMConnection *connection)
/* Figure out if the user wants to ignore missing CA cert */
method->ignore_ca_cert = _get_ignore_ca_cert (uuid, method->phase2);
- }
-}
-gboolean
-eap_method_nag_init (EAPMethod *method,
- const char *ca_cert_chooser,
- NMConnection *connection)
-{
- GtkWidget *dialog, *widget;
- NagDialogResponseInfo *info;
- GError *error = NULL;
- char *text;
-
- g_return_val_if_fail (method != NULL, FALSE);
- g_return_val_if_fail (ca_cert_chooser != NULL, FALSE);
-
- method->nag_builder = gtk_builder_new ();
- if (!gtk_builder_add_from_file (method->nag_builder, NAG_DIALOG_UI, &error)) {
- g_warning ("Couldn't load UI builder file " NAG_DIALOG_UI ": %s",
- error->message);
- g_error_free (error);
- return FALSE;
+ method->ca_cert_chooser = g_strdup (id_ca_cert_chooser);
+ method->ca_cert_is_not_required_checkbox = g_strdup (id_ca_cert_is_not_required_checkbox);
}
-
- method->ca_cert_chooser = g_strdup (ca_cert_chooser);
- eap_method_ignore_ca_cert_init (method, connection);
-
- info = g_malloc0 (sizeof (NagDialogResponseInfo));
- info->method = method;
- info->connection = connection;
-
- dialog = GTK_WIDGET (gtk_builder_get_object (method->nag_builder, "nag_user_dialog"));
- g_assert (dialog);
- g_signal_connect (dialog, "response", G_CALLBACK (nag_dialog_response_cb), info);
- g_signal_connect (dialog, "delete-event", G_CALLBACK (nag_dialog_delete_event_cb), info);
- g_object_weak_ref (G_OBJECT (dialog), nag_dialog_destroyed, info);
-
- widget = GTK_WIDGET (gtk_builder_get_object (method->nag_builder, "content_label"));
- g_assert (widget);
-
- text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
- _("No Certificate Authority certificate chosen"),
- _("Not using a Certificate Authority (CA) certificate can result in
connections to insecure, rogue Wi-Fi networks. Would you like to choose a Certificate Authority
certificate?"));
- gtk_label_set_markup (GTK_LABEL (widget), text);
- g_free (text);
-
- widget = GTK_WIDGET (gtk_builder_get_object (method->nag_builder, "ignore_button"));
- gtk_button_set_label (GTK_BUTTON (widget), _("Ignore"));
- g_assert (widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (method->nag_builder, "change_button"));
- gtk_button_set_label (GTK_BUTTON (widget), _("Choose CA Certificate"));
- g_assert (widget);
-
- method->nag_dialog = dialog;
- return TRUE;
+ method->connection = connection;
}
void
@@ -401,11 +298,8 @@ eap_method_unref (EAPMethod *method)
if (method->destroy)
method->destroy (method);
- if (method->nag_dialog)
- gtk_widget_destroy (method->nag_dialog);
- if (method->nag_builder)
- g_object_unref (method->nag_builder);
g_free (method->ca_cert_chooser);
+ g_free (method->ca_cert_is_not_required_checkbox);
if (method->builder)
g_object_unref (method->builder);
if (method->ui_widget)
diff --git a/src/wireless-security/eap-method.h b/src/wireless-security/eap-method.h
index d0f6d8c..5929530 100644
--- a/src/wireless-security/eap-method.h
+++ b/src/wireless-security/eap-method.h
@@ -44,10 +44,10 @@ struct _EAPMethod {
GtkBuilder *builder;
GtkWidget *ui_widget;
- GtkBuilder *nag_builder;
char *ca_cert_chooser;
+ char *ca_cert_is_not_required_checkbox;
+ NMConnection *connection;
const char *default_field;
- GtkWidget *nag_dialog;
gboolean phase2;
gboolean secrets_only;
@@ -115,10 +115,9 @@ gboolean eap_method_validate_filepicker (GtkBuilder *builder,
const char *password,
NMSetting8021xCKFormat *out_format);
-void eap_method_ignore_ca_cert_init (EAPMethod *method, NMConnection *connection);
-gboolean eap_method_nag_init (EAPMethod *method,
- const char *ca_cert_chooser,
- NMConnection *connection);
+void eap_method_ignore_ca_cert_init (EAPMethod *method, NMConnection *connection,
+ const char *id_ca_cert_is_not_required_checkbox,
+ const char *id_ca_cert_chooser);
void eap_method_phase2_update_secrets_helper (EAPMethod *method,
NMConnection *connection,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]