[network-manager-applet: 3/6] applet: Use NMAWs classes instead of WirelessSecurity




commit 66e9adfb8bd96df53b933c9c11b47d38d6ff9db1
Author: Andrew Zaborowski <andrew zaborowski intel com>
Date:   Sat Nov 7 03:08:00 2020 +0100

    applet: Use NMAWs classes instead of WirelessSecurity
    
    Convert the ethernet dialog to use the NMAWs8021x class and remove the
    dependency on wireless-security to work around issue #92.  Take
    advantage of libnma having a pure 8021x ui (without the WPA-EAP
    assumptions) meaning that the hack that adds the wireless setting is no
    longer needed.  Unfotunately this change is not tested.

 src/ethernet-dialog.c | 59 +++++++++++++++++----------------------------------
 1 file changed, 19 insertions(+), 40 deletions(-)
---
diff --git a/src/ethernet-dialog.c b/src/ethernet-dialog.c
index 11c07274b..21e295652 100644
--- a/src/ethernet-dialog.c
+++ b/src/ethernet-dialog.c
@@ -10,17 +10,17 @@
 #include "nm-default.h"
 
 
+#include "nma-ws.h"
 #include "ethernet-dialog.h"
-#include "wireless-security.h"
 #include "applet-dialogs.h"
 #include "eap-method.h"
 
 static void
-stuff_changed_cb (WirelessSecurity *sec, gpointer user_data)
+stuff_changed_cb (NMAWs *ws, gpointer user_data)
 {
        GtkWidget *button = GTK_WIDGET (user_data);
 
-       gtk_widget_set_sensitive (button, wireless_security_validate (sec, NULL));
+       gtk_widget_set_sensitive (button, nma_ws_validate (ws, NULL));
 }
 
 static void
@@ -34,16 +34,18 @@ dialog_set_network_name (NMConnection *connection, GtkEntry *entry)
        gtk_entry_set_text (entry, nm_setting_connection_get_id (setting));
 }
 
-static WirelessSecurity *
+static NMAWs *
 dialog_set_security (NMConnection *connection,
                      GtkBuilder *builder,
                      GtkBox *box)
 {
        GList *children;
        GList *iter;
-       WirelessSecurity *security;
+       NMAWs8021x *ws;
 
-       security = (WirelessSecurity *) ws_wpa_eap_new (connection, FALSE, TRUE, NULL);
+       ws = nma_ws_802_1x_new (connection, FALSE, TRUE);
+       if (G_IS_INITIALLY_UNOWNED (ws))
+               g_object_ref_sink (ws);
 
        /* Remove any previous wireless security widgets */
        children = gtk_container_get_children (GTK_CONTAINER (box));
@@ -51,9 +53,9 @@ dialog_set_security (NMConnection *connection,
                gtk_container_remove (GTK_CONTAINER (box), GTK_WIDGET (iter->data));
        g_list_free (children);
 
-       gtk_box_pack_start (box, wireless_security_get_widget (security), TRUE, TRUE, 0);
+       gtk_box_pack_start (box, GTK_WIDGET (ws), TRUE, TRUE, 0);
 
-       return security;
+       return NMA_WS (ws);
 }
 
 GtkWidget *
@@ -62,7 +64,7 @@ nma_ethernet_dialog_new (NMConnection *connection)
        GtkBuilder *builder;
        GtkWidget *dialog;
        GError *error = NULL;
-       WirelessSecurity *security;
+       NMAWs *security;
 
        builder = gtk_builder_new ();
 
@@ -90,10 +92,10 @@ nma_ethernet_dialog_new (NMConnection *connection)
        eap_method_ca_cert_ignore_load (connection);
 
        security = dialog_set_security (connection, builder, GTK_BOX (gtk_builder_get_object (builder, 
"security_vbox")));
-       wireless_security_set_changed_notify (security, stuff_changed_cb, GTK_WIDGET (gtk_builder_get_object 
(builder, "ok_button")));
+       g_signal_connect (security, "ws-changed", G_CALLBACK (stuff_changed_cb), GTK_WIDGET 
(gtk_builder_get_object (builder, "ok_button")));
        g_object_set_data_full (G_OBJECT (dialog),
                                "security", security,
-                               (GDestroyNotify) wireless_security_unref);
+                               (GDestroyNotify) g_object_unref);
 
        g_object_set_data_full (G_OBJECT (dialog),
                                "connection", g_object_ref (connection),
@@ -106,47 +108,24 @@ nma_ethernet_dialog_new (NMConnection *connection)
 
        return dialog;
 }
-                                         
+
 NMConnection *
 nma_ethernet_dialog_get_connection (GtkWidget *dialog)
 {
-       NMConnection *connection, *tmp_connection;
-       WirelessSecurity *security;
-       NMSetting *s_8021x, *s_con;
+       NMConnection *connection;
+       NMAWs *security;
 
        g_return_val_if_fail (dialog != NULL, NULL);
 
        connection = g_object_get_data (G_OBJECT (dialog), "connection");
        security = g_object_get_data (G_OBJECT (dialog), "security");
 
-       /* Here's a nice hack to work around the fact that ws_802_1x_fill_connection()
-        * needs a wireless setting and a connection setting for various things.
-        */
-       tmp_connection = nm_simple_connection_new ();
-
-       /* Add the fake connection setting (mainly for the UUID for cert ignore checking) */
-       s_con = nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
-       g_assert (s_con);
-       nm_connection_add_setting (tmp_connection, NM_SETTING (g_object_ref (s_con)));
-
-       /* And the fake wireless setting */
-       nm_connection_add_setting (tmp_connection, nm_setting_wireless_new ());
-
        /* Fill up the 802.1x setting */
-       ws_802_1x_fill_connection (security, "wpa_eap_auth_combo", tmp_connection);
-
-       /* Grab it and add it to our original connection */
-       s_8021x = nm_connection_get_setting (tmp_connection, NM_TYPE_SETTING_802_1X);
-       nm_connection_add_setting (connection, NM_SETTING (g_object_ref (s_8021x)));
+       nma_ws_fill_connection (security, connection);
+       nm_connection_remove_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
 
        /* Save new CA cert ignore values to GSettings */
-       eap_method_ca_cert_ignore_save (tmp_connection);
-
-       /* Remove the 8021x setting to prevent the clearing of secrets when the
-        * simple-connection is destroyed.
-        */
-       nm_connection_remove_setting (tmp_connection, NM_TYPE_SETTING_802_1X);
-       g_object_unref (tmp_connection);
+       eap_method_ca_cert_ignore_save (connection);
 
        return connection;
 }


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