[gnome-control-center] network: Remove certificate helper function



commit acc8aff5d0b6ccd65afca21db8565051ad3f393e
Author: Robert Ancell <robert ancell canonical com>
Date:   Tue Nov 12 12:00:25 2019 +1300

    network: Remove certificate helper function
    
    It didn't really save any code.

 panels/network/wireless-security/eap-method-peap.c | 13 +++++++++----
 panels/network/wireless-security/eap-method-tls.c  | 10 ++++++----
 panels/network/wireless-security/eap-method-ttls.c | 12 ++++++++----
 panels/network/wireless-security/eap-method.c      | 21 ---------------------
 panels/network/wireless-security/eap-method.h      |  2 --
 5 files changed, 23 insertions(+), 35 deletions(-)
---
diff --git a/panels/network/wireless-security/eap-method-peap.c 
b/panels/network/wireless-security/eap-method-peap.c
index 22ad04c3b..5487a5e51 100644
--- a/panels/network/wireless-security/eap-method-peap.c
+++ b/panels/network/wireless-security/eap-method-peap.c
@@ -90,10 +90,15 @@ validate (EAPMethod *method, GError **error)
                g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-PEAP CA certificate: %s"), 
local_error->message);
                return FALSE;
        }
-       if (eap_method_ca_cert_required (GTK_TOGGLE_BUTTON (self->ca_cert_not_required_check),
-                                        GTK_FILE_CHOOSER (self->ca_cert_button))) {
-               g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-PEAP CA certificate: 
no certificate specified"));
-               return FALSE;
+
+       if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->ca_cert_not_required_check))) {
+               g_autofree gchar *filename = NULL;
+
+               filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (self->ca_cert_button));
+               if (filename == NULL) {
+                       g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-PEAP CA 
certificate: no certificate specified"));
+                       return FALSE;
+               }
        }
 
        return eap_method_validate (get_inner_method (self), error);
diff --git a/panels/network/wireless-security/eap-method-tls.c 
b/panels/network/wireless-security/eap-method-tls.c
index 3e55b64cb..fadd6e066 100644
--- a/panels/network/wireless-security/eap-method-tls.c
+++ b/panels/network/wireless-security/eap-method-tls.c
@@ -91,10 +91,12 @@ validate (EAPMethod *method, GError **error)
                        g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TLS CA certificate: 
%s"), ca_cert_error->message);
                        ret = FALSE;
                }
-       } else if (eap_method_ca_cert_required (GTK_TOGGLE_BUTTON (self->ca_cert_not_required_check),
-                                               GTK_FILE_CHOOSER (self->ca_cert_button))) {
-               widget_set_error (GTK_WIDGET (self->ca_cert_button));
-               if (ret) {
+       } else if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->ca_cert_not_required_check))) {
+               g_autofree gchar *filename = NULL;
+
+               filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (self->ca_cert_button));
+               if (filename == NULL) {
+                       widget_set_error (GTK_WIDGET (self->ca_cert_button));
                        g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TLS CA 
certificate: no certificate specified"));
                        ret = FALSE;
                }
diff --git a/panels/network/wireless-security/eap-method-ttls.c 
b/panels/network/wireless-security/eap-method-ttls.c
index ae6aa0629..198b08a18 100644
--- a/panels/network/wireless-security/eap-method-ttls.c
+++ b/panels/network/wireless-security/eap-method-ttls.c
@@ -101,10 +101,14 @@ validate (EAPMethod *method, GError **error)
                g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TTLS CA certificate: %s"), 
local_error->message);
                return FALSE;
        }
-       if (eap_method_ca_cert_required (GTK_TOGGLE_BUTTON (self->ca_cert_not_required_check),
-                                        GTK_FILE_CHOOSER (self->ca_cert_button))) {
-               g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TTLS CA certificate: 
no certificate specified"));
-               return FALSE;
+       if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->ca_cert_not_required_check))) {
+               g_autofree gchar *filename = NULL;
+
+               filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (self->ca_cert_button));
+               if (filename == NULL) {
+                       g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TTLS CA 
certificate: no certificate specified"));
+                       return FALSE;
+               }
        }
 
        return eap_method_validate (get_inner_method (self), error);
diff --git a/panels/network/wireless-security/eap-method.c b/panels/network/wireless-security/eap-method.c
index f0bb8a138..c392da8f5 100644
--- a/panels/network/wireless-security/eap-method.c
+++ b/panels/network/wireless-security/eap-method.c
@@ -382,27 +382,6 @@ eap_method_is_encrypted_private_key (const char *path)
        return is_encrypted;
 }
 
-/* Some methods (PEAP, TLS, TTLS) require a CA certificate. The user can choose
- * not to provide such a certificate. This method whether the checkbox
- * id_ca_cert_not_required_checkbutton is checked or id_ca_cert_chooser has a certificate
- * selected.
- */
-gboolean
-eap_method_ca_cert_required (GtkToggleButton *id_ca_cert_not_required_checkbutton, GtkFileChooser 
*id_ca_cert_chooser)
-{
-       g_assert (id_ca_cert_not_required_checkbutton && id_ca_cert_chooser);
-
-       if (!gtk_toggle_button_get_active (id_ca_cert_not_required_checkbutton)) {
-               g_autofree gchar *filename = NULL;
-
-               filename = gtk_file_chooser_get_filename (id_ca_cert_chooser);
-               if (!filename)
-                       return TRUE;
-       }
-       return FALSE;
-}
-
-
 void
 eap_method_ca_cert_not_required_toggled (GtkToggleButton *id_ca_cert_not_required_checkbutton, 
GtkFileChooser *id_ca_cert_chooser)
 {
diff --git a/panels/network/wireless-security/eap-method.h b/panels/network/wireless-security/eap-method.h
index 42c392f02..f51f309c9 100644
--- a/panels/network/wireless-security/eap-method.h
+++ b/panels/network/wireless-security/eap-method.h
@@ -75,8 +75,6 @@ gboolean eap_method_validate_filepicker (GtkFileChooser *chooser,
                                          NMSetting8021xCKFormat *out_format,
                                          GError **error);
 
-gboolean eap_method_ca_cert_required (GtkToggleButton *id_ca_cert_is_not_required_checkbutton,
-                                      GtkFileChooser *id_ca_cert_chooser);
 void eap_method_ca_cert_not_required_toggled (GtkToggleButton *id_ca_cert_is_not_required_checkbox,
                                               GtkFileChooser *id_ca_cert_chooser);
 


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