[libnma/lr/wireless-security: 7/9] xxx
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libnma/lr/wireless-security: 7/9] xxx
- Date: Tue, 29 Oct 2019 17:12:01 +0000 (UTC)
commit 60f34f46be898ca3597690c1adf487200ec417ef
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Tue Oct 22 07:16:01 2019 +0200
xxx
Makefile.am | 18 +-
src/libnma.ver | 43 ++-
src/nma-ws/nma-eap-fast.c | 42 +--
src/nma-ws/nma-eap-fast.h | 4 +-
src/nma-ws/nma-eap-leap.c | 68 ++---
src/nma-ws/nma-eap-leap.h | 4 +-
src/nma-ws/nma-eap-peap.c | 49 ++--
src/nma-ws/nma-eap-peap.h | 4 +-
src/nma-ws/nma-eap-simple.c | 60 ++--
src/nma-ws/nma-eap-simple.h | 2 +-
src/nma-ws/nma-eap-tls.c | 36 +--
src/nma-ws/nma-eap-tls.h | 6 +-
src/nma-ws/nma-eap-ttls.c | 55 ++--
src/nma-ws/nma-eap-ttls.h | 4 +-
src/nma-ws/nma-eap.c | 1 -
src/nma-ws/nma-ws-802-1x-private.h | 37 +++
src/nma-ws/nma-ws-802-1x.c | 525 ++++++++++++++++++++++++++++++++++
src/nma-ws/nma-ws-802-1x.h | 23 ++
src/nma-ws/nma-ws-802-1x.ui | 72 +++++
src/nma-ws/nma-ws-dynamic-wep.c | 107 ++-----
src/nma-ws/nma-ws-dynamic-wep.h | 19 +-
src/nma-ws/nma-ws-dynamic-wep.ui | 87 ------
src/nma-ws/nma-ws-helpers.c | 31 ++
src/nma-ws/nma-ws-helpers.h | 18 ++
src/nma-ws/nma-ws-leap.c | 302 +++++++++++++-------
src/nma-ws/nma-ws-leap.h | 19 +-
src/nma-ws/nma-ws-leap.ui | 152 +++++-----
src/nma-ws/nma-ws-sae.c | 267 +++++++++++------
src/nma-ws/nma-ws-sae.h | 20 +-
src/nma-ws/nma-ws-sae.ui | 148 +++++-----
src/nma-ws/nma-ws-wep-key.c | 440 +++++++++++++++++-----------
src/nma-ws/nma-ws-wep-key.h | 19 +-
src/nma-ws/nma-ws-wep-key.ui | 227 +++++++--------
src/nma-ws/nma-ws-wpa-eap.c | 115 +++-----
src/nma-ws/nma-ws-wpa-eap.h | 19 +-
src/nma-ws/nma-ws-wpa-eap.ui | 87 ------
src/nma-ws/nma-ws-wpa-psk.c | 269 +++++++++++------
src/nma-ws/nma-ws-wpa-psk.h | 19 +-
src/nma-ws/nma-ws-wpa-psk.ui | 147 +++++-----
src/nma-ws/nma-ws.c | 570 ++++---------------------------------
src/nma-ws/nma-ws.h | 122 +-------
src/nma.gresource.xml | 3 +-
src/wireless-security/ws-leap.ui | 2 +-
43 files changed, 2264 insertions(+), 1998 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 60f961a6..80b3fd7e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -292,13 +292,6 @@ libnma_h_pub = \
src/nma-ws/nma-ws-wep-key.h \
src/nma-ws/nma-ws-wpa-eap.h \
src/nma-ws/nma-ws-wpa-psk.h \
- src/nma-ws/nma-eap-fast.h \
- src/nma-ws/nma-eap.h \
- src/nma-ws/nma-eap-leap.h \
- src/nma-ws/nma-eap-peap.h \
- src/nma-ws/nma-eap-simple.h \
- src/nma-ws/nma-eap-tls.h \
- src/nma-ws/nma-eap-ttls.h \
src/nma-ws/nma-ws.h
libnma_c_real = \
@@ -314,7 +307,11 @@ libnma_c_real = \
src/nma-bar-code.c \
\
src/nma-ws/nma-ws.h \
+ src/nma-ws/nma-ws-private.h \
src/nma-ws/nma-ws.c \
+ src/nma-ws/nma-ws-802-1x.h \
+ src/nma-ws/nma-ws-802-1x-private.h \
+ src/nma-ws/nma-ws-802-1x.c \
src/nma-ws/nma-ws-sae.h \
src/nma-ws/nma-ws-sae.c \
src/nma-ws/nma-ws-wep-key.h \
@@ -340,7 +337,9 @@ libnma_c_real = \
src/nma-ws/nma-eap-peap.h \
src/nma-ws/nma-eap-peap.c \
src/nma-ws/nma-eap-simple.h \
- src/nma-ws/nma-eap-simple.c
+ src/nma-ws/nma-eap-simple.c \
+ src/nma-ws/nma-ws-helpers.h \
+ src/nma-ws/nma-ws-helpers.c
EXTRA_DIST += \
src/qrcodegen.c \
@@ -836,11 +835,10 @@ EXTRA_DIST += \
src/nma-ws/nma-eap-simple.ui \
src/nma-ws/nma-eap-tls.ui \
src/nma-ws/nma-eap-ttls.ui \
- src/nma-ws/nma-ws-dynamic-wep.ui \
+ src/nma-ws/nma-ws-802-1x.ui \
src/nma-ws/nma-ws-leap.ui \
src/nma-ws/nma-ws-sae.ui \
src/nma-ws/nma-ws-wep-key.ui \
- src/nma-ws/nma-ws-wpa-eap.ui \
src/nma-ws/nma-ws-wpa-psk.ui \
src/nma-ws/meson.build
diff --git a/src/libnma.ver b/src/libnma.ver
index 7b25e9c8..fcdb0adc 100644
--- a/src/libnma.ver
+++ b/src/libnma.ver
@@ -114,22 +114,47 @@ libnma_1_8_22 {
} libnma_1_8_12;
libnma_1_8_28 {
- nma_eap_get_type;
- nma_eap_method_ca_cert_ignore_load;
- nma_eap_method_ca_cert_ignore_save;
- nma_ws_802_1x_fill_connection;
nma_ws_add_to_size_group;
- nma_ws_adhoc_compatible;
- nma_ws_dynamic_wep_new;
nma_ws_fill_connection;
nma_ws_get_type;
+ nma_ws_validate;
+
+ nma_eap_get_type;
+ nma_ws_802_1x_get_type;
+
+
+/*
+ nma_ws_802_1x_fill_connection;
+ nma_ws_adhoc_compatible;
+
+ nma_eap_method_ca_cert_ignore_load;
+ nma_eap_method_ca_cert_ignore_save;
+
+ // obsolete
nma_ws_get_widget;
- nma_ws_leap_new;
- nma_ws_sae_new;
nma_ws_set_changed_notify;
nma_ws_unref;
- nma_ws_validate;
+
+ // constructors
+ nma_ws_dynamic_wep_new;
+ nma_ws_leap_new;
+ nma_ws_sae_new;
nma_ws_wep_key_new;
nma_ws_wpa_eap_new;
nma_ws_wpa_psk_new;
+*/
+
+ nma_ws_sae_get_type;
+ nma_ws_leap_get_type;
+ nma_ws_wpa_psk_get_type;
+ nma_ws_wep_key_get_type;
+ nma_ws_dynamic_wep_get_type;
+ nma_ws_wpa_eap_get_type;
+
+
+ /* dialog only */
+/*
+ nma_ws_update_secrets;
+*/
+
} libnma_1_8_22;
diff --git a/src/nma-ws/nma-eap-fast.c b/src/nma-ws/nma-eap-fast.c
index 1ee93e49..f2a241f8 100644
--- a/src/nma-ws/nma-eap-fast.c
+++ b/src/nma-ws/nma-eap-fast.c
@@ -13,25 +13,25 @@
#include "nma-eap.h"
#include "nma-ws.h"
+#include "nma-ws-private.h"
#include "utils.h"
-#include "helpers.h"
#define I_NAME_COLUMN 0
#define I_METHOD_COLUMN 1
-struct _NMAEapFAST {
+struct _NMAEapFast {
NMAEap parent;
const char *password_flags_name;
GtkSizeGroup *size_group;
- NMAWs *sec_parent;
+ NMAWs8021x *ws_8021x;
gboolean is_editor;
};
static void
destroy (NMAEap *parent)
{
- NMAEapFAST *method = (NMAEapFAST *) parent;
+ NMAEapFast *method = (NMAEapFast *) parent;
if (method->size_group)
g_object_unref (method->size_group);
@@ -75,7 +75,7 @@ validate (NMAEap *parent, GError **error)
static void
add_to_size_group (NMAEap *parent, GtkSizeGroup *group)
{
- NMAEapFAST *method = (NMAEapFAST *) parent;
+ NMAEapFast *method = (NMAEapFast *) parent;
GtkWidget *widget;
GtkTreeModel *model;
GtkTreeIter iter;
@@ -180,7 +180,7 @@ static void
inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
{
NMAEap *parent = (NMAEap *) user_data;
- NMAEapFAST *method = (NMAEapFAST *) parent;
+ NMAEapFast *method = (NMAEapFast *) parent;
GtkWidget *vbox;
NMAEap *eap = NULL;
GList *elt, *children;
@@ -212,11 +212,11 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
nma_eap_unref (eap);
- nma_ws_changed_cb (combo, method->sec_parent);
+ nma_ws_changed_cb (combo, method->ws_8021x);
}
static GtkWidget *
-inner_auth_combo_init (NMAEapFAST *method,
+inner_auth_combo_init (NMAEapFast *method,
NMConnection *connection,
NMSetting8021x *s_8021x,
gboolean secrets_only)
@@ -246,7 +246,7 @@ inner_auth_combo_init (NMAEapFAST *method,
if (secrets_only)
simple_flags |= NMA_EAP_SIMPLE_FLAG_SECRETS_ONLY;
- em_gtc = nma_eap_simple_new (method->sec_parent,
+ em_gtc = nma_eap_simple_new (method->ws_8021x,
connection,
NMA_EAP_SIMPLE_TYPE_GTC,
simple_flags,
@@ -262,7 +262,7 @@ inner_auth_combo_init (NMAEapFAST *method,
if (phase2_auth && !strcasecmp (phase2_auth, "gtc"))
active = 0;
- em_mschap_v2 = nma_eap_simple_new (method->sec_parent,
+ em_mschap_v2 = nma_eap_simple_new (method->ws_8021x,
connection,
NMA_EAP_SIMPLE_TYPE_MSCHAP_V2,
simple_flags,
@@ -304,7 +304,7 @@ static void
pac_toggled_cb (GtkWidget *widget, gpointer user_data)
{
NMAEap *parent = (NMAEap *) user_data;
- NMAEapFAST *method = (NMAEapFAST *) parent;
+ NMAEapFast *method = (NMAEapFast *) parent;
gboolean enabled = FALSE;
GtkWidget *provision_combo;
@@ -315,24 +315,24 @@ pac_toggled_cb (GtkWidget *widget, gpointer user_data)
gtk_widget_set_sensitive (provision_combo, enabled);
- nma_ws_changed_cb (widget, method->sec_parent);
+ nma_ws_changed_cb (widget, method->ws_8021x);
}
-NMAEapFAST *
-nma_eap_fast_new (NMAWs *ws_parent,
+NMAEapFast *
+nma_eap_fast_new (NMAWs8021x *ws_8021x,
NMConnection *connection,
gboolean is_editor,
gboolean secrets_only)
{
NMAEap *parent;
- NMAEapFAST *method;
+ NMAEapFast *method;
GtkWidget *widget;
GtkFileFilter *filter;
NMSetting8021x *s_8021x = NULL;
const char *filename;
gboolean provisioning_enabled = TRUE;
- parent = nma_eap_init (sizeof (NMAEapFAST),
+ parent = nma_eap_init (sizeof (NMAEapFast),
validate,
add_to_size_group,
fill_connection,
@@ -345,9 +345,9 @@ nma_eap_fast_new (NMAWs *ws_parent,
if (!parent)
return NULL;
- method = (NMAEapFAST *) parent;
+ method = (NMAEapFast *) parent;
method->password_flags_name = NM_SETTING_802_1X_PASSWORD;
- method->sec_parent = ws_parent;
+ method->ws_8021x = ws_8021x;
method->is_editor = is_editor;
if (connection)
@@ -375,7 +375,7 @@ nma_eap_fast_new (NMAWs *ws_parent,
gtk_widget_set_sensitive (widget, provisioning_enabled);
g_signal_connect (G_OBJECT (widget), "changed",
(GCallback) nma_ws_changed_cb,
- ws_parent);
+ ws_8021x);
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_provision_checkbutton"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), provisioning_enabled);
@@ -386,7 +386,7 @@ nma_eap_fast_new (NMAWs *ws_parent,
gtk_editable_set_text (GTK_EDITABLE (widget), nm_setting_802_1x_get_anonymous_identity
(s_8021x));
g_signal_connect (G_OBJECT (widget), "changed",
(GCallback) nma_ws_changed_cb,
- ws_parent);
+ ws_8021x);
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_file_button"));
g_assert (widget);
@@ -395,7 +395,7 @@ nma_eap_fast_new (NMAWs *ws_parent,
_("Choose a PAC file"));
g_signal_connect (G_OBJECT (widget), "selection-changed",
(GCallback) nma_ws_changed_cb,
- ws_parent);
+ ws_8021x);
filter = gtk_file_filter_new ();
gtk_file_filter_add_pattern (filter, "*.pac");
diff --git a/src/nma-ws/nma-eap-fast.h b/src/nma-ws/nma-eap-fast.h
index a1ece4df..750cac1f 100644
--- a/src/nma-ws/nma-eap-fast.h
+++ b/src/nma-ws/nma-eap-fast.h
@@ -10,9 +10,9 @@
#include "nma-ws.h"
-typedef struct _NMAEapFAST NMAEapFAST;
+typedef struct _NMAEapFast NMAEapFast;
-NMAEapFAST *nma_eap_fast_new (NMAWs *ws_parent,
+NMAEapFast *nma_eap_fast_new (NMAWs8021x *ws_8021x,
NMConnection *connection,
gboolean is_editor,
gboolean secrets_only);
diff --git a/src/nma-ws/nma-eap-leap.c b/src/nma-ws/nma-eap-leap.c
index 6d316edb..102b30d6 100644
--- a/src/nma-ws/nma-eap-leap.c
+++ b/src/nma-ws/nma-eap-leap.c
@@ -13,14 +13,17 @@
#include "nma-eap.h"
#include "nma-ws.h"
-#include "helpers.h"
+#include "nma-ws-private.h"
+#include "nma-ws-helpers.h"
+#include "nma-ws-802-1x.h"
+#include "nma-ws-802-1x-private.h"
#include "nma-ui-utils.h"
#include "utils.h"
-struct _NMAEapLEAP {
+struct _NMAEapLeap {
NMAEap parent;
- NMAWs *ws_parent;
+ NMAWs8021x *ws_8021x;
gboolean editing_connection;
@@ -31,7 +34,7 @@ struct _NMAEapLEAP {
};
static void
-show_toggled_cb (GtkToggleButton *button, NMAEapLEAP *method)
+show_toggled_cb (GtkToggleButton *button, NMAEapLeap *method)
{
gboolean visible;
@@ -42,7 +45,7 @@ show_toggled_cb (GtkToggleButton *button, NMAEapLEAP *method)
static gboolean
validate (NMAEap *parent, GError **error)
{
- NMAEapLEAP *method = (NMAEapLEAP *)parent;
+ NMAEapLeap *method = (NMAEapLeap *)parent;
const char *text;
gboolean ret = TRUE;
@@ -84,7 +87,7 @@ add_to_size_group (NMAEap *parent, GtkSizeGroup *group)
static void
fill_connection (NMAEap *parent, NMConnection *connection)
{
- NMAEapLEAP *method = (NMAEapLEAP *) parent;
+ NMAEapLeap *method = (NMAEapLeap *) parent;
NMSetting8021x *s_8021x;
NMSettingSecretFlags secret_flags;
GtkWidget *passwd_entry;
@@ -116,45 +119,44 @@ fill_connection (NMAEap *parent, NMConnection *connection)
static void
update_secrets (NMAEap *parent, NMConnection *connection)
{
- helper_fill_secret_entry (connection,
- parent->builder,
- "eap_leap_password_entry",
- NM_TYPE_SETTING_802_1X,
- (HelperSecretFunc) nm_setting_802_1x_get_password);
+ nma_ws_helper_fill_secret_entry (connection,
+ GTK_EDITABLE (gtk_builder_get_object (parent->builder,
"eap_leap_password_entry")),
+ NM_TYPE_SETTING_802_1X,
+ (HelperSecretFunc) nm_setting_802_1x_get_password);
}
/* Set the UI fields for user, password and show_password to the
- * values as provided by method->ws_parent. */
+ * values as provided by method->ws_8021x. */
static void
-set_userpass_ui (NMAEapLEAP *method)
+set_userpass_ui (NMAEapLeap *method)
{
- if (method->ws_parent->username) {
+ if (method->ws_8021x->username) {
gtk_editable_set_text (GTK_EDITABLE (method->username_entry),
- method->ws_parent->username);
+ method->ws_8021x->username);
} else {
gtk_editable_set_text (GTK_EDITABLE (method->username_entry), "");
}
- if (method->ws_parent->password && !method->ws_parent->always_ask) {
+ if (method->ws_8021x->password && !method->ws_8021x->always_ask) {
gtk_editable_set_text (GTK_EDITABLE (method->password_entry),
- method->ws_parent->password);
+ method->ws_8021x->password);
} else {
gtk_editable_set_text (GTK_EDITABLE (method->password_entry), "");
}
- gtk_toggle_button_set_active (method->show_password, method->ws_parent->show_password);
+ gtk_toggle_button_set_active (method->show_password, method->ws_8021x->show_password);
}
static void
-widgets_realized (GtkWidget *widget, NMAEapLEAP *method)
+widgets_realized (GtkWidget *widget, NMAEapLeap *method)
{
set_userpass_ui (method);
}
static void
-widgets_unrealized (GtkWidget *widget, NMAEapLEAP *method)
+widgets_unrealized (GtkWidget *widget, NMAEapLeap *method)
{
- nma_ws_set_userpass (method->ws_parent,
+ nma_ws_802_1x_set_userpass (method->ws_8021x,
gtk_editable_get_text (GTK_EDITABLE (method->username_entry)),
gtk_editable_get_text (GTK_EDITABLE (method->password_entry)),
(gboolean) -1,
@@ -164,29 +166,29 @@ widgets_unrealized (GtkWidget *widget, NMAEapLEAP *method)
static void
destroy (NMAEap *parent)
{
- NMAEapLEAP *method = (NMAEapLEAP *) parent;
+ NMAEapLeap *method = (NMAEapLeap *) parent;
GtkWidget *widget;
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_leap_notebook"));
g_assert (widget);
g_signal_handlers_disconnect_by_data (widget, method);
- g_signal_handlers_disconnect_by_data (method->username_entry, method->ws_parent);
- g_signal_handlers_disconnect_by_data (method->password_entry, method->ws_parent);
+ g_signal_handlers_disconnect_by_data (method->username_entry, method->ws_8021x);
+ g_signal_handlers_disconnect_by_data (method->password_entry, method->ws_8021x);
g_signal_handlers_disconnect_by_data (method->show_password, method);
}
-NMAEapLEAP *
-nma_eap_leap_new (NMAWs *ws_parent,
+NMAEapLeap *
+nma_eap_leap_new (NMAWs8021x *ws_8021x,
NMConnection *connection,
gboolean secrets_only)
{
- NMAEapLEAP *method;
+ NMAEapLeap *method;
NMAEap *parent;
GtkWidget *widget;
NMSetting8021x *s_8021x = NULL;
- parent = nma_eap_init (sizeof (NMAEapLEAP),
+ parent = nma_eap_init (sizeof (NMAEapLeap),
validate,
add_to_size_group,
fill_connection,
@@ -199,10 +201,10 @@ nma_eap_leap_new (NMAWs *ws_parent,
if (!parent)
return NULL;
- method = (NMAEapLEAP *) parent;
+ method = (NMAEapLeap *) parent;
method->password_flags_name = NM_SETTING_802_1X_PASSWORD;
method->editing_connection = secrets_only ? FALSE : TRUE;
- method->ws_parent = ws_parent;
+ method->ws_8021x = ws_8021x;
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_leap_notebook"));
g_assert (widget);
@@ -218,7 +220,7 @@ nma_eap_leap_new (NMAWs *ws_parent,
method->username_entry = GTK_ENTRY (widget);
g_signal_connect (G_OBJECT (widget), "changed",
(GCallback) nma_ws_changed_cb,
- ws_parent);
+ ws_8021x);
if (secrets_only)
gtk_widget_set_sensitive (widget, FALSE);
@@ -228,7 +230,7 @@ nma_eap_leap_new (NMAWs *ws_parent,
method->password_entry = GTK_ENTRY (widget);
g_signal_connect (G_OBJECT (widget), "changed",
(GCallback) nma_ws_changed_cb,
- ws_parent);
+ ws_8021x);
/* Create password-storage popup menu for password entry under entry's secondary icon */
if (connection)
@@ -243,7 +245,7 @@ nma_eap_leap_new (NMAWs *ws_parent,
(GCallback) show_toggled_cb,
parent);
- /* Initialize the UI fields with the security settings from method->ws_parent.
+ /* Initialize the UI fields with the security settings from method->ws_8021x.
* This will be done again when the widget gets realized. It must be done here as well,
* because the outer dialog will ask to 'validate' the connection before the security tab
* is shown/realized (to enable the 'Apply' button).
diff --git a/src/nma-ws/nma-eap-leap.h b/src/nma-ws/nma-eap-leap.h
index 738cf20a..c75aa56a 100644
--- a/src/nma-ws/nma-eap-leap.h
+++ b/src/nma-ws/nma-eap-leap.h
@@ -10,9 +10,9 @@
#include "nma-ws.h"
-typedef struct _NMAEapLEAP NMAEapLEAP;
+typedef struct _NMAEapLeap NMAEapLeap;
-NMAEapLEAP *nma_eap_leap_new (NMAWs *ws_parent,
+NMAEapLeap *nma_eap_leap_new (NMAWs8021x *ws_8021x,
NMConnection *connection,
gboolean secrets_only);
diff --git a/src/nma-ws/nma-eap-peap.c b/src/nma-ws/nma-eap-peap.c
index e41a479a..e008c67e 100644
--- a/src/nma-ws/nma-eap-peap.c
+++ b/src/nma-ws/nma-eap-peap.c
@@ -13,18 +13,19 @@
#include "nma-eap.h"
#include "nma-ws.h"
+#include "nma-ws-private.h"
#include "nma-cert-chooser.h"
#include "utils.h"
#define I_NAME_COLUMN 0
#define I_METHOD_COLUMN 1
-struct _NMAEapPEAP {
+struct _NMAEapPeap {
NMAEap parent;
const char *password_flags_name;
GtkSizeGroup *size_group;
- NMAWs *sec_parent;
+ NMAWs8021x *ws_8021x;
gboolean is_editor;
GtkWidget *ca_cert_chooser;
};
@@ -32,7 +33,7 @@ struct _NMAEapPEAP {
static void
destroy (NMAEap *parent)
{
- NMAEapPEAP *method = (NMAEapPEAP *) parent;
+ NMAEapPeap *method = (NMAEapPeap *) parent;
if (method->size_group)
g_object_unref (method->size_group);
@@ -41,7 +42,7 @@ destroy (NMAEap *parent)
static gboolean
validate (NMAEap *parent, GError **error)
{
- NMAEapPEAP *method = (NMAEapPEAP *) parent;
+ NMAEapPeap *method = (NMAEapPeap *) parent;
GtkWidget *widget;
GtkTreeModel *model;
GtkTreeIter iter;
@@ -67,7 +68,7 @@ validate (NMAEap *parent, GError **error)
static void
ca_cert_not_required_toggled (GtkWidget *button, gpointer user_data)
{
- NMAEapPEAP *method = (NMAEapPEAP *) user_data;
+ NMAEapPeap *method = (NMAEapPeap *) user_data;
gtk_widget_set_sensitive (method->ca_cert_chooser,
!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)));
@@ -76,7 +77,7 @@ ca_cert_not_required_toggled (GtkWidget *button, gpointer user_data)
static void
add_to_size_group (NMAEap *parent, GtkSizeGroup *group)
{
- NMAEapPEAP *method = (NMAEapPEAP *) parent;
+ NMAEapPeap *method = (NMAEapPeap *) parent;
GtkWidget *widget;
GtkTreeModel *model;
GtkTreeIter iter;
@@ -118,7 +119,7 @@ add_to_size_group (NMAEap *parent, GtkSizeGroup *group)
static void
fill_connection (NMAEap *parent, NMConnection *connection)
{
- NMAEapPEAP *method = (NMAEapPEAP *) parent;
+ NMAEapPeap *method = (NMAEapPeap *) parent;
NMSetting8021x *s_8021x;
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
GtkWidget *widget;
@@ -203,7 +204,7 @@ static void
inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
{
NMAEap *parent = (NMAEap *) user_data;
- NMAEapPEAP *method = (NMAEapPEAP *) parent;
+ NMAEapPeap *method = (NMAEapPeap *) parent;
GtkWidget *vbox;
NMAEap *eap = NULL;
GList *elt, *children;
@@ -234,11 +235,11 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
nma_eap_unref (eap);
- nma_ws_changed_cb (combo, method->sec_parent);
+ nma_ws_changed_cb (combo, method->ws_8021x);
}
static GtkWidget *
-inner_auth_combo_init (NMAEapPEAP *method,
+inner_auth_combo_init (NMAEapPeap *method,
NMConnection *connection,
NMSetting8021x *s_8021x,
gboolean secrets_only)
@@ -269,7 +270,7 @@ inner_auth_combo_init (NMAEapPEAP *method,
if (secrets_only)
simple_flags |= NMA_EAP_SIMPLE_FLAG_SECRETS_ONLY;
- em_mschap_v2 = nma_eap_simple_new (method->sec_parent,
+ em_mschap_v2 = nma_eap_simple_new (method->ws_8021x,
connection,
NMA_EAP_SIMPLE_TYPE_MSCHAP_V2,
simple_flags,
@@ -285,7 +286,7 @@ inner_auth_combo_init (NMAEapPEAP *method,
if (phase2_auth && !strcasecmp (phase2_auth, "mschapv2"))
active = 0;
- em_md5 = nma_eap_simple_new (method->sec_parent,
+ em_md5 = nma_eap_simple_new (method->ws_8021x,
connection,
NMA_EAP_SIMPLE_TYPE_MD5,
simple_flags,
@@ -301,7 +302,7 @@ inner_auth_combo_init (NMAEapPEAP *method,
if (phase2_auth && !strcasecmp (phase2_auth, "md5"))
active = 1;
- em_gtc = nma_eap_simple_new (method->sec_parent,
+ em_gtc = nma_eap_simple_new (method->ws_8021x,
connection,
NMA_EAP_SIMPLE_TYPE_GTC,
simple_flags,
@@ -339,19 +340,19 @@ update_secrets (NMAEap *parent, NMConnection *connection)
I_METHOD_COLUMN);
}
-NMAEapPEAP *
-nma_eap_peap_new (NMAWs *ws_parent,
+NMAEapPeap *
+nma_eap_peap_new (NMAWs8021x *ws_8021x,
NMConnection *connection,
gboolean is_editor,
gboolean secrets_only)
{
NMAEap *parent;
- NMAEapPEAP *method;
+ NMAEapPeap *method;
GtkWidget *widget;
NMSetting8021x *s_8021x = NULL;
gboolean ca_not_required = FALSE;
- parent = nma_eap_init (sizeof (NMAEapPEAP),
+ parent = nma_eap_init (sizeof (NMAEapPeap),
validate,
add_to_size_group,
fill_connection,
@@ -364,9 +365,9 @@ nma_eap_peap_new (NMAWs *ws_parent,
if (!parent)
return NULL;
- method = (NMAEapPEAP *) parent;
+ method = (NMAEapPeap *) parent;
method->password_flags_name = NM_SETTING_802_1X_PASSWORD;
- method->sec_parent = ws_parent;
+ method->ws_8021x = ws_8021x;
method->is_editor = is_editor;
if (connection)
@@ -388,7 +389,7 @@ nma_eap_peap_new (NMAWs *ws_parent,
g_signal_connect (method->ca_cert_chooser,
"changed",
G_CALLBACK (nma_ws_changed_cb),
- ws_parent);
+ ws_8021x);
nma_eap_setup_cert_chooser (NMA_CERT_CHOOSER (method->ca_cert_chooser), s_8021x,
nm_setting_802_1x_get_ca_cert_scheme,
@@ -421,7 +422,7 @@ nma_eap_peap_new (NMAWs *ws_parent,
parent);
g_signal_connect (G_OBJECT (widget), "toggled",
(GCallback) nma_ws_changed_cb,
- ws_parent);
+ ws_8021x);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), ca_not_required);
widget = inner_auth_combo_init (method, connection, s_8021x, secrets_only);
@@ -444,21 +445,21 @@ nma_eap_peap_new (NMAWs *ws_parent,
}
g_signal_connect (G_OBJECT (widget), "changed",
(GCallback) nma_ws_changed_cb,
- ws_parent);
+ ws_8021x);
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_anon_identity_entry"));
if (s_8021x && nm_setting_802_1x_get_anonymous_identity (s_8021x))
gtk_editable_set_text (GTK_EDITABLE (widget), nm_setting_802_1x_get_anonymous_identity
(s_8021x));
g_signal_connect (G_OBJECT (widget), "changed",
(GCallback) nma_ws_changed_cb,
- ws_parent);
+ ws_8021x);
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_domain_entry"));
if (s_8021x && nm_setting_802_1x_get_domain_suffix_match (s_8021x))
gtk_editable_set_text (GTK_EDITABLE (widget), nm_setting_802_1x_get_domain_suffix_match
(s_8021x));
g_signal_connect (G_OBJECT (widget), "changed",
(GCallback) nma_ws_changed_cb,
- ws_parent);
+ ws_8021x);
if (secrets_only) {
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder,
"eap_peap_anon_identity_label"));
diff --git a/src/nma-ws/nma-eap-peap.h b/src/nma-ws/nma-eap-peap.h
index 8f4d88bd..9f6c4a1e 100644
--- a/src/nma-ws/nma-eap-peap.h
+++ b/src/nma-ws/nma-eap-peap.h
@@ -10,9 +10,9 @@
#include "nma-ws.h"
-typedef struct _NMAEapPEAP NMAEapPEAP;
+typedef struct _NMAEapPeap NMAEapPeap;
-NMAEapPEAP *nma_eap_peap_new (NMAWs *ws_parent,
+NMAEapPeap *nma_eap_peap_new (NMAWs8021x *ws_8021x,
NMConnection *connection,
gboolean is_editor,
gboolean secrets_only);
diff --git a/src/nma-ws/nma-eap-simple.c b/src/nma-ws/nma-eap-simple.c
index d5f90c52..50e68106 100644
--- a/src/nma-ws/nma-eap-simple.c
+++ b/src/nma-ws/nma-eap-simple.c
@@ -13,14 +13,17 @@
#include "nma-eap.h"
#include "nma-ws.h"
-#include "helpers.h"
+#include "nma-ws-private.h"
+#include "nma-ws-helpers.h"
+#include "nma-ws-802-1x.h"
+#include "nma-ws-802-1x-private.h"
#include "nma-ui-utils.h"
#include "utils.h"
struct _NMAEapSimple {
NMAEap parent;
- NMAWs *ws_parent;
+ NMAWs8021x *ws_8021x;
const char *password_flags_name;
NMAEapSimpleType type;
@@ -237,22 +240,20 @@ fill_connection (NMAEap *parent, NMConnection *connection)
static void
update_secrets (NMAEap *parent, NMConnection *connection)
{
- helper_fill_secret_entry (connection,
- parent->builder,
- "eap_simple_password_entry",
- NM_TYPE_SETTING_802_1X,
- (HelperSecretFunc) nm_setting_802_1x_get_password);
- helper_fill_secret_entry (connection,
- parent->builder,
- "eap_simple_pkey_passphrase_entry",
- NM_TYPE_SETTING_802_1X,
- (HelperSecretFunc) nm_setting_802_1x_get_private_key_password);
+ nma_ws_helper_fill_secret_entry (connection,
+ GTK_EDITABLE (gtk_builder_get_object (parent->builder,
"eap_simple_password_entry")),
+ NM_TYPE_SETTING_802_1X,
+ (HelperSecretFunc) nm_setting_802_1x_get_password);
+ nma_ws_helper_fill_secret_entry (connection,
+ GTK_EDITABLE (gtk_builder_get_object (parent->builder,
"eap_simple_pkey_passphrase_entry")),
+ NM_TYPE_SETTING_802_1X,
+ (HelperSecretFunc) nm_setting_802_1x_get_private_key_password);
}
static gboolean
stuff_changed (NMAEapSimple *method)
{
- nma_ws_changed_cb (NULL, method->ws_parent);
+ nma_ws_changed_cb (NULL, method->ws_8021x);
method->idle_func_id = 0;
return FALSE;
}
@@ -281,25 +282,26 @@ password_storage_changed (GObject *entry,
}
/* Set the UI fields for user, password, always_ask and show_password to the
- * values as provided by method->ws_parent. */
+ * values as provided by method->ws_8021x. */
static void
set_userpass_ui (NMAEapSimple *method)
{
- if (method->ws_parent->username) {
+ if (method->ws_8021x->username) {
gtk_editable_set_text (GTK_EDITABLE (method->username_entry),
- method->ws_parent->username);
+ method->ws_8021x->username);
} else {
gtk_editable_set_text (GTK_EDITABLE (method->username_entry), "");
}
- if (method->ws_parent->password && !method->ws_parent->always_ask) {
+ if (method->ws_8021x->password && !method->ws_8021x->always_ask) {
gtk_editable_set_text (GTK_EDITABLE (method->password_entry),
- method->ws_parent->password);
+ method->ws_8021x->password);
} else {
gtk_editable_set_text (GTK_EDITABLE (method->password_entry), "");
}
- gtk_toggle_button_set_active (method->show_password, method->ws_parent->show_password);
+ gtk_toggle_button_set_active (method->show_password, method->ws_8021x->show_password);
+
password_storage_changed (NULL, NULL, method);
}
@@ -312,7 +314,7 @@ widgets_realized (GtkWidget *widget, NMAEapSimple *method)
static void
widgets_unrealized (GtkWidget *widget, NMAEapSimple *method)
{
- nma_ws_set_userpass (method->ws_parent,
+ nma_ws_802_1x_set_userpass (method->ws_8021x,
gtk_editable_get_text (GTK_EDITABLE (method->username_entry)),
gtk_editable_get_text (GTK_EDITABLE (method->password_entry)),
always_ask_selected (method->password_entry),
@@ -329,11 +331,11 @@ destroy (NMAEap *parent)
g_assert (widget);
g_signal_handlers_disconnect_by_data (widget, method);
- g_signal_handlers_disconnect_by_data (method->username_entry, method->ws_parent);
- g_signal_handlers_disconnect_by_data (method->password_entry, method->ws_parent);
+ g_signal_handlers_disconnect_by_data (method->username_entry, method->ws_8021x);
+ g_signal_handlers_disconnect_by_data (method->password_entry, method->ws_8021x);
g_signal_handlers_disconnect_by_data (method->password_entry, method);
g_signal_handlers_disconnect_by_data (method->show_password, method);
- g_signal_handlers_disconnect_by_data (method->pkey_passphrase_entry, method->ws_parent);
+ g_signal_handlers_disconnect_by_data (method->pkey_passphrase_entry, method->ws_8021x);
g_signal_handlers_disconnect_by_data (method->show_pkey_passphrase, method);
nm_clear_g_source (&method->idle_func_id);
@@ -347,7 +349,7 @@ hide_row (GtkWidget **widgets, size_t num)
}
NMAEapSimple *
-nma_eap_simple_new (NMAWs *ws_parent,
+nma_eap_simple_new (NMAWs8021x *ws_8021x,
NMConnection *connection,
NMAEapSimpleType type,
NMAEapSimpleFlags flags,
@@ -374,7 +376,7 @@ nma_eap_simple_new (NMAWs *ws_parent,
method = (NMAEapSimple *) parent;
method->password_flags_name = NM_SETTING_802_1X_PASSWORD;
- method->ws_parent = ws_parent;
+ method->ws_8021x = ws_8021x;
method->flags = flags;
method->type = type;
g_assert (type < NMA_EAP_SIMPLE_TYPE_LAST);
@@ -410,7 +412,7 @@ nma_eap_simple_new (NMAWs *ws_parent,
method->username_entry = GTK_ENTRY (widget);
g_signal_connect (G_OBJECT (widget), "changed",
(GCallback) nma_ws_changed_cb,
- ws_parent);
+ ws_8021x);
if ( (method->flags & NMA_EAP_SIMPLE_FLAG_SECRETS_ONLY)
&& !method->username_requested)
@@ -421,7 +423,7 @@ nma_eap_simple_new (NMAWs *ws_parent,
method->password_entry = GTK_ENTRY (widget);
g_signal_connect (G_OBJECT (widget), "changed",
(GCallback) nma_ws_changed_cb,
- ws_parent);
+ ws_8021x);
/* Create password-storage popup menu for password entry under entry's secondary icon */
if (connection)
@@ -445,7 +447,7 @@ nma_eap_simple_new (NMAWs *ws_parent,
method->pkey_passphrase_entry = GTK_ENTRY (widget);
g_signal_connect (G_OBJECT (widget), "changed",
(GCallback) nma_ws_changed_cb,
- ws_parent);
+ ws_8021x);
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder,
"eap_simple_show_pkey_passphrase_checkbutton"));
g_assert (widget);
@@ -471,7 +473,7 @@ nma_eap_simple_new (NMAWs *ws_parent,
if (!method->pkey_passphrase_requested)
hide_row (widget_row, 3);
- /* Initialize the UI fields with the security settings from method->ws_parent.
+ /* Initialize the UI fields with the security settings from method->ws_8021x.
* This will be done again when the widget gets realized. It must be done here as well,
* because the outer dialog will ask to 'validate' the connection before the security tab
* is shown/realized (to enable the 'Apply' button).
diff --git a/src/nma-ws/nma-eap-simple.h b/src/nma-ws/nma-eap-simple.h
index 8676e395..82024dca 100644
--- a/src/nma-ws/nma-eap-simple.h
+++ b/src/nma-ws/nma-eap-simple.h
@@ -40,7 +40,7 @@ typedef enum {
typedef struct _NMAEapSimple NMAEapSimple;
-NMAEapSimple *nma_eap_simple_new (NMAWs *ws_parent,
+NMAEapSimple *nma_eap_simple_new (NMAWs8021x *ws_8021x,
NMConnection *connection,
NMAEapSimpleType type,
NMAEapSimpleFlags flags,
diff --git a/src/nma-ws/nma-eap-tls.c b/src/nma-ws/nma-eap-tls.c
index 102ed36b..595996d8 100644
--- a/src/nma-ws/nma-eap-tls.c
+++ b/src/nma-ws/nma-eap-tls.c
@@ -14,12 +14,12 @@
#include "nma-eap.h"
#include "nma-ws.h"
-#include "helpers.h"
+#include "nma-ws-private.h"
#include "nma-ui-utils.h"
#include "nma-cert-chooser.h"
#include "utils.h"
-struct _NMAEapTLS {
+struct _NMAEapTls {
NMAEap parent;
const char *ca_cert_password_flags_name;
@@ -35,7 +35,7 @@ struct _NMAEapTLS {
static gboolean
validate (NMAEap *parent, GError **error)
{
- NMAEapTLS *method = (NMAEapTLS *) parent;
+ NMAEapTls *method = (NMAEapTls *) parent;
GtkWidget *widget;
const char *identity;
@@ -63,7 +63,7 @@ validate (NMAEap *parent, GError **error)
static void
ca_cert_not_required_toggled (GtkWidget *button, gpointer user_data)
{
- NMAEapTLS *method = (NMAEapTLS *) user_data;
+ NMAEapTls *method = (NMAEapTls *) user_data;
gtk_widget_set_sensitive (method->ca_cert_chooser,
!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)));
@@ -72,7 +72,7 @@ ca_cert_not_required_toggled (GtkWidget *button, gpointer user_data)
static void
add_to_size_group (NMAEap *parent, GtkSizeGroup *group)
{
- NMAEapTLS *method = (NMAEapTLS *) parent;
+ NMAEapTls *method = (NMAEapTls *) parent;
GtkWidget *widget;
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_identity_label"));
@@ -90,7 +90,7 @@ add_to_size_group (NMAEap *parent, GtkSizeGroup *group)
static void
fill_connection (NMAEap *parent, NMConnection *connection)
{
- NMAEapTLS *method = (NMAEapTLS *) parent;
+ NMAEapTls *method = (NMAEapTls *) parent;
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
NMSetting8021x *s_8021x;
NMSettingSecretFlags secret_flags;
@@ -318,7 +318,7 @@ client_cert_fixup_pkcs12 (NMACertChooser *cert_chooser, gpointer user_data)
static void
update_secrets (NMAEap *parent, NMConnection *connection)
{
- NMAEapTLS *method = (NMAEapTLS *) parent;
+ NMAEapTls *method = (NMAEapTls *) parent;
nma_eap_setup_cert_chooser (NMA_CERT_CHOOSER (method->client_cert_chooser),
nm_connection_get_setting_802_1x (connection),
@@ -332,19 +332,19 @@ update_secrets (NMAEap *parent, NMConnection *connection)
parent->phase2 ? nm_setting_802_1x_get_phase2_private_key_password :
nm_setting_802_1x_get_private_key_password);
}
-NMAEapTLS *
-nma_eap_tls_new (NMAWs *ws_parent,
+NMAEapTls *
+nma_eap_tls_new (NMAWs8021x *ws_8021x,
NMConnection *connection,
gboolean phase2,
gboolean secrets_only)
{
- NMAEapTLS *method;
+ NMAEapTls *method;
NMAEap *parent;
GtkWidget *widget;
NMSetting8021x *s_8021x = NULL;
gboolean ca_not_required = FALSE;
- parent = nma_eap_init (sizeof (NMAEapTLS),
+ parent = nma_eap_init (sizeof (NMAEapTls),
validate,
add_to_size_group,
fill_connection,
@@ -357,7 +357,7 @@ nma_eap_tls_new (NMAWs *ws_parent,
if (!parent)
return NULL;
- method = (NMAEapTLS *) parent;
+ method = (NMAEapTls *) parent;
method->ca_cert_password_flags_name = phase2
? NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD
: NM_SETTING_802_1X_CA_CERT_PASSWORD;
@@ -379,13 +379,13 @@ nma_eap_tls_new (NMAWs *ws_parent,
parent);
g_signal_connect (G_OBJECT (widget), "toggled",
(GCallback) nma_ws_changed_cb,
- ws_parent);
+ ws_8021x);
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_identity_entry"));
g_assert (widget);
g_signal_connect (G_OBJECT (widget), "changed",
(GCallback) nma_ws_changed_cb,
- ws_parent);
+ ws_8021x);
if (s_8021x && nm_setting_802_1x_get_identity (s_8021x))
gtk_editable_set_text (GTK_EDITABLE (widget), nm_setting_802_1x_get_identity (s_8021x));
@@ -393,7 +393,7 @@ nma_eap_tls_new (NMAWs *ws_parent,
g_assert (widget);
g_signal_connect (G_OBJECT (widget), "changed",
(GCallback) nma_ws_changed_cb,
- ws_parent);
+ ws_8021x);
if (phase2) {
if (s_8021x && nm_setting_802_1x_get_phase2_domain_suffix_match (s_8021x))
gtk_editable_set_text (GTK_EDITABLE (widget),
nm_setting_802_1x_get_phase2_domain_suffix_match (s_8021x));
@@ -418,7 +418,7 @@ nma_eap_tls_new (NMAWs *ws_parent,
g_signal_connect (method->ca_cert_chooser,
"changed",
G_CALLBACK (nma_ws_changed_cb),
- ws_parent);
+ ws_8021x);
nma_eap_setup_cert_chooser (NMA_CERT_CHOOSER (method->ca_cert_chooser), s_8021x,
phase2 ? nm_setting_802_1x_get_phase2_ca_cert_scheme :
nm_setting_802_1x_get_ca_cert_scheme,
@@ -463,11 +463,11 @@ nma_eap_tls_new (NMAWs *ws_parent,
g_signal_connect (method->client_cert_chooser,
"changed",
G_CALLBACK (client_cert_fixup_pkcs12),
- ws_parent);
+ ws_8021x);
g_signal_connect (method->client_cert_chooser,
"changed",
G_CALLBACK (nma_ws_changed_cb),
- ws_parent);
+ ws_8021x);
nma_eap_setup_cert_chooser (NMA_CERT_CHOOSER (method->client_cert_chooser), s_8021x,
phase2 ? nm_setting_802_1x_get_phase2_client_cert_scheme :
nm_setting_802_1x_get_client_cert_scheme,
diff --git a/src/nma-ws/nma-eap-tls.h b/src/nma-ws/nma-eap-tls.h
index 105e0426..5de30814 100644
--- a/src/nma-ws/nma-eap-tls.h
+++ b/src/nma-ws/nma-eap-tls.h
@@ -8,11 +8,11 @@
#ifndef NMA_EAP_TLS_H
#define NMA_EAP_TLS_H
-#include "nma-ws.h"
+#include "nma-ws-802-1x.h"
-typedef struct _NMAEapTLS NMAEapTLS;
+typedef struct _NMAEapTls NMAEapTls;
-NMAEapTLS *nma_eap_tls_new (NMAWs *ws_parent,
+NMAEapTls *nma_eap_tls_new (NMAWs8021x *ws_8021x,
NMConnection *connection,
gboolean phase2,
gboolean secrets_only);
diff --git a/src/nma-ws/nma-eap-ttls.c b/src/nma-ws/nma-eap-ttls.c
index e2e82601..22f8d492 100644
--- a/src/nma-ws/nma-eap-ttls.c
+++ b/src/nma-ws/nma-eap-ttls.c
@@ -13,18 +13,19 @@
#include "nma-eap.h"
#include "nma-ws.h"
+#include "nma-ws-private.h"
#include "nma-cert-chooser.h"
#include "utils.h"
#define I_NAME_COLUMN 0
#define I_METHOD_COLUMN 1
-struct _NMAEapTTLS {
+struct _NMAEapTtls {
NMAEap parent;
const char *password_flags_name;
GtkSizeGroup *size_group;
- NMAWs *sec_parent;
+ NMAWs8021x *ws_8021x;
gboolean is_editor;
GtkWidget *ca_cert_chooser;
@@ -33,7 +34,7 @@ struct _NMAEapTTLS {
static void
destroy (NMAEap *parent)
{
- NMAEapTTLS *method = (NMAEapTTLS *) parent;
+ NMAEapTtls *method = (NMAEapTtls *) parent;
if (method->size_group)
g_object_unref (method->size_group);
@@ -42,7 +43,7 @@ destroy (NMAEap *parent)
static gboolean
validate (NMAEap *parent, GError **error)
{
- NMAEapTTLS *method = (NMAEapTTLS *) parent;
+ NMAEapTtls *method = (NMAEapTtls *) parent;
GtkWidget *widget;
GtkTreeModel *model;
GtkTreeIter iter;
@@ -68,7 +69,7 @@ validate (NMAEap *parent, GError **error)
static void
ca_cert_not_required_toggled (GtkWidget *button, gpointer user_data)
{
- NMAEapTTLS *method = (NMAEapTTLS *) user_data;
+ NMAEapTtls *method = (NMAEapTtls *) user_data;
gtk_widget_set_sensitive (method->ca_cert_chooser,
!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)));
@@ -77,7 +78,7 @@ ca_cert_not_required_toggled (GtkWidget *button, gpointer user_data)
static void
add_to_size_group (NMAEap *parent, GtkSizeGroup *group)
{
- NMAEapTTLS *method = (NMAEapTTLS *) parent;
+ NMAEapTtls *method = (NMAEapTtls *) parent;
GtkWidget *widget;
GtkTreeModel *model;
GtkTreeIter iter;
@@ -115,7 +116,7 @@ add_to_size_group (NMAEap *parent, GtkSizeGroup *group)
static void
fill_connection (NMAEap *parent, NMConnection *connection)
{
- NMAEapTTLS *method = (NMAEapTTLS *) parent;
+ NMAEapTtls *method = (NMAEapTtls *) parent;
NMSetting8021x *s_8021x;
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
NMSettingSecretFlags secret_flags;
@@ -186,7 +187,7 @@ static void
inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
{
NMAEap *parent = (NMAEap *) user_data;
- NMAEapTTLS *method = (NMAEapTTLS *) parent;
+ NMAEapTtls *method = (NMAEapTtls *) parent;
GtkWidget *vbox;
NMAEap *eap = NULL;
GList *elt, *children;
@@ -218,11 +219,11 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
nma_eap_unref (eap);
- nma_ws_changed_cb (combo, method->sec_parent);
+ nma_ws_changed_cb (combo, method->ws_8021x);
}
static GtkWidget *
-inner_auth_combo_init (NMAEapTTLS *method,
+inner_auth_combo_init (NMAEapTtls *method,
NMConnection *connection,
NMSetting8021x *s_8021x,
gboolean secrets_only)
@@ -257,7 +258,7 @@ inner_auth_combo_init (NMAEapTTLS *method,
if (secrets_only)
simple_flags |= NMA_EAP_SIMPLE_FLAG_SECRETS_ONLY;
- em_pap = nma_eap_simple_new (method->sec_parent,
+ em_pap = nma_eap_simple_new (method->ws_8021x,
connection,
NMA_EAP_SIMPLE_TYPE_PAP,
simple_flags,
@@ -273,7 +274,7 @@ inner_auth_combo_init (NMAEapTTLS *method,
if (phase2_auth && !strcasecmp (phase2_auth, "pap"))
active = 0;
- em_mschap = nma_eap_simple_new (method->sec_parent,
+ em_mschap = nma_eap_simple_new (method->ws_8021x,
connection,
NMA_EAP_SIMPLE_TYPE_MSCHAP,
simple_flags,
@@ -289,7 +290,7 @@ inner_auth_combo_init (NMAEapTTLS *method,
if (phase2_auth && !strcasecmp (phase2_auth, "mschap"))
active = 1;
- em_mschap_v2 = nma_eap_simple_new (method->sec_parent,
+ em_mschap_v2 = nma_eap_simple_new (method->ws_8021x,
connection,
NMA_EAP_SIMPLE_TYPE_MSCHAP_V2,
simple_flags,
@@ -306,7 +307,7 @@ inner_auth_combo_init (NMAEapTTLS *method,
nm_setting_802_1x_get_phase2_autheap (s_8021x) != NULL)
active = 2;
- em_plain_mschap_v2 = nma_eap_simple_new (method->sec_parent,
+ em_plain_mschap_v2 = nma_eap_simple_new (method->ws_8021x,
connection,
NMA_EAP_SIMPLE_TYPE_PLAIN_MSCHAP_V2,
simple_flags,
@@ -323,7 +324,7 @@ inner_auth_combo_init (NMAEapTTLS *method,
nm_setting_802_1x_get_phase2_auth (s_8021x) != NULL)
active = 3;
- em_chap = nma_eap_simple_new (method->sec_parent,
+ em_chap = nma_eap_simple_new (method->ws_8021x,
connection,
NMA_EAP_SIMPLE_TYPE_CHAP,
simple_flags,
@@ -339,7 +340,7 @@ inner_auth_combo_init (NMAEapTTLS *method,
if (phase2_auth && !strcasecmp (phase2_auth, "chap"))
active = 4;
- em_md5 = nma_eap_simple_new (method->sec_parent,
+ em_md5 = nma_eap_simple_new (method->ws_8021x,
connection,
NMA_EAP_SIMPLE_TYPE_MD5,
simple_flags,
@@ -355,7 +356,7 @@ inner_auth_combo_init (NMAEapTTLS *method,
if (phase2_auth && !strcasecmp (phase2_auth, "md5"))
active = 5;
- em_gtc = nma_eap_simple_new (method->sec_parent,
+ em_gtc = nma_eap_simple_new (method->ws_8021x,
connection,
NMA_EAP_SIMPLE_TYPE_GTC,
simple_flags,
@@ -393,19 +394,19 @@ update_secrets (NMAEap *parent, NMConnection *connection)
I_METHOD_COLUMN);
}
-NMAEapTTLS *
-nma_eap_ttls_new (NMAWs *ws_parent,
+NMAEapTtls *
+nma_eap_ttls_new (NMAWs8021x *ws_8021x,
NMConnection *connection,
gboolean is_editor,
gboolean secrets_only)
{
NMAEap *parent;
- NMAEapTTLS *method;
+ NMAEapTtls *method;
GtkWidget *widget;
NMSetting8021x *s_8021x = NULL;
gboolean ca_not_required = FALSE;
- parent = nma_eap_init (sizeof (NMAEapTTLS),
+ parent = nma_eap_init (sizeof (NMAEapTtls),
validate,
add_to_size_group,
fill_connection,
@@ -418,9 +419,9 @@ nma_eap_ttls_new (NMAWs *ws_parent,
if (!parent)
return NULL;
- method = (NMAEapTTLS *) parent;
+ method = (NMAEapTtls *) parent;
method->password_flags_name = NM_SETTING_802_1X_PASSWORD;
- method->sec_parent = ws_parent;
+ method->ws_8021x = ws_8021x;
method->is_editor = is_editor;
if (connection)
@@ -442,7 +443,7 @@ nma_eap_ttls_new (NMAWs *ws_parent,
g_signal_connect (method->ca_cert_chooser,
"changed",
G_CALLBACK (nma_ws_changed_cb),
- ws_parent);
+ ws_8021x);
nma_eap_setup_cert_chooser (NMA_CERT_CHOOSER (method->ca_cert_chooser), s_8021x,
nm_setting_802_1x_get_ca_cert_scheme,
@@ -475,7 +476,7 @@ nma_eap_ttls_new (NMAWs *ws_parent,
parent);
g_signal_connect (G_OBJECT (widget), "toggled",
(GCallback) nma_ws_changed_cb,
- ws_parent);
+ ws_8021x);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), ca_not_required);
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_anon_identity_entry"));
@@ -483,14 +484,14 @@ nma_eap_ttls_new (NMAWs *ws_parent,
gtk_editable_set_text (GTK_EDITABLE (widget), nm_setting_802_1x_get_anonymous_identity
(s_8021x));
g_signal_connect (G_OBJECT (widget), "changed",
(GCallback) nma_ws_changed_cb,
- ws_parent);
+ ws_8021x);
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_domain_entry"));
if (s_8021x && nm_setting_802_1x_get_domain_suffix_match (s_8021x))
gtk_editable_set_text (GTK_EDITABLE (widget), nm_setting_802_1x_get_domain_suffix_match
(s_8021x));
g_signal_connect (G_OBJECT (widget), "changed",
(GCallback) nma_ws_changed_cb,
- ws_parent);
+ ws_8021x);
widget = inner_auth_combo_init (method, connection, s_8021x, secrets_only);
inner_auth_combo_changed_cb (widget, (gpointer) method);
diff --git a/src/nma-ws/nma-eap-ttls.h b/src/nma-ws/nma-eap-ttls.h
index 034ad3e4..1e072336 100644
--- a/src/nma-ws/nma-eap-ttls.h
+++ b/src/nma-ws/nma-eap-ttls.h
@@ -10,9 +10,9 @@
#include "nma-ws.h"
-typedef struct _NMAEapTTLS NMAEapTTLS;
+typedef struct _NMAEapTtls NMAEapTtls;
-NMAEapTTLS *nma_eap_ttls_new (NMAWs *ws_parent,
+NMAEapTtls *nma_eap_ttls_new (NMAWs8021x *ws_8021x,
NMConnection *connection,
gboolean is_editor,
gboolean secrets_only);
diff --git a/src/nma-ws/nma-eap.c b/src/nma-ws/nma-eap.c
index 61340363..f666dab9 100644
--- a/src/nma-ws/nma-eap.c
+++ b/src/nma-ws/nma-eap.c
@@ -16,7 +16,6 @@
#include "nma-eap.h"
#include "nm-utils.h"
#include "utils.h"
-#include "helpers.h"
G_DEFINE_BOXED_TYPE (NMAEap, nma_eap, nma_eap_ref, nma_eap_unref)
diff --git a/src/nma-ws/nma-ws-802-1x-private.h b/src/nma-ws/nma-ws-802-1x-private.h
new file mode 100644
index 00000000..23743eee
--- /dev/null
+++ b/src/nma-ws/nma-ws-802-1x-private.h
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2007 - 2019 Red Hat, Inc.
+ */
+
+#ifndef NMA_WS_802_1X_PRIVATE_H
+#define NMA_WS_802_1X_PRIVATE_H
+
+struct _NMAWs8021xClass {
+ GtkGridClass parent;
+};
+
+struct _NMAWs8021x {
+ GtkGrid parent;
+
+ GtkWidget *eap_auth_combo;
+ GtkWidget *eap_auth_label;
+ GtkWidget *eap_vbox;
+
+ NMConnection *connection;
+ gboolean secrets_only;
+ gboolean is_editor;
+ char **secrets_hints;
+
+ char *username, *password;
+ gboolean always_ask, show_password;
+};
+
+void nma_ws_802_1x_fill_connection (NMAWs *ws, NMConnection *connection);
+
+void nma_ws_802_1x_set_userpass (NMAWs8021x *self,
+ const char *user,
+ const char *password,
+ gboolean always_ask,
+ gboolean show_password);
+
+#endif /* NMA_WS_802_1X_PRIVATE_H */
diff --git a/src/nma-ws/nma-ws-802-1x.c b/src/nma-ws/nma-ws-802-1x.c
new file mode 100644
index 00000000..ad0c13a5
--- /dev/null
+++ b/src/nma-ws/nma-ws-802-1x.c
@@ -0,0 +1,525 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2007 - 2019 Red Hat, Inc.
+ */
+
+#include "nm-default.h"
+#include "nma-private.h"
+
+#include <ctype.h>
+#include <string.h>
+
+#include "nma-ws.h"
+#include "nma-ws-private.h"
+#include "nma-ws-802-1x.h"
+#include "nma-ws-802-1x-private.h"
+#include "nma-ws-helpers.h"
+#include "nma-ui-utils.h"
+
+#include "nma-eap-tls.h"
+#include "nma-eap-leap.h"
+#include "nma-eap-fast.h"
+#include "nma-eap-ttls.h"
+#include "nma-eap-peap.h"
+#include "nma-eap-simple.h"
+#include "nma-eap.h"
+
+#include "utils.h"
+
+#define AUTH_NAME_COLUMN 0
+#define AUTH_METHOD_COLUMN 1
+
+static void nma_ws_interface_init (NMAWsInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (NMAWs8021x, nma_ws_802_1x, GTK_TYPE_GRID,
+ G_IMPLEMENT_INTERFACE (NMA_TYPE_WS, nma_ws_interface_init))
+
+enum {
+ PROP_0,
+ PROP_CONNECTION,
+ PROP_SECRETS_ONLY,
+ PROP_IS_EDITOR,
+ PROP_SECRETS_HINTS,
+ PROP_LAST
+};
+
+void
+nma_ws_802_1x_set_userpass (NMAWs8021x *self,
+ const char *user,
+ const char *password,
+ gboolean always_ask,
+ gboolean show_password)
+{
+ g_free (self->username);
+ self->username = g_strdup (user);
+
+ if (self->password) {
+ memset (self->password, 0, strlen (self->password));
+ g_free (self->password);
+ }
+ self->password = g_strdup (password);
+
+ if (always_ask != (gboolean) -1)
+ self->always_ask = always_ask;
+ self->show_password = show_password;
+}
+
+static void
+init_userpass (NMAWs8021x *self, NMConnection *connection)
+{
+ const char *user = NULL, *password = NULL;
+ gboolean always_ask = FALSE, show_password = FALSE;
+ NMSetting8021x *setting;
+ NMSettingSecretFlags flags;
+
+ if (!connection)
+ goto set;
+
+ setting = nm_connection_get_setting_802_1x (connection);
+ if (!setting)
+ goto set;
+
+ user = nm_setting_802_1x_get_identity (setting);
+ password = nm_setting_802_1x_get_password (setting);
+
+ if (nm_setting_get_secret_flags (NM_SETTING (setting), NM_SETTING_802_1X_PASSWORD, &flags, NULL))
+ always_ask = !!(flags & NM_SETTING_SECRET_FLAG_NOT_SAVED);
+
+set:
+ nma_ws_802_1x_set_userpass (self, user, password, always_ask, show_password);
+}
+
+static gboolean
+validate (NMAWs *ws, GError **error)
+{
+ NMAWs8021x *self = NMA_WS_802_1X (ws);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ NMAEap *eap = NULL;
+ gboolean valid = FALSE;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (self->eap_auth_combo));
+ gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self->eap_auth_combo), &iter);
+ gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1);
+ g_return_val_if_fail (eap, FALSE);
+ valid = nma_eap_validate (eap, error);
+ nma_eap_unref (eap);
+ return valid;
+}
+
+static void
+auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
+{
+ NMAWs8021x *self = NMA_WS_802_1X (user_data);
+
+ NMAEap *eap = NULL;
+ GList *elt, *children;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkWidget *eap_widget;
+ GtkWidget *eap_default_widget = NULL;
+
+ /* Remove any previous wireless security widgets */
+ children = gtk_container_get_children (GTK_CONTAINER (self->eap_vbox));
+ for (elt = children; elt; elt = g_list_next (elt))
+ gtk_container_remove (GTK_CONTAINER (self->eap_vbox), GTK_WIDGET (elt->data));
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
+ gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
+ gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1);
+ g_return_if_fail (eap);
+
+ eap_widget = nma_eap_get_widget (eap);
+ g_return_if_fail (eap_widget);
+ gtk_widget_unparent (eap_widget);
+
+ gtk_container_add (GTK_CONTAINER (self->eap_vbox), eap_widget);
+
+ /* Refocus the EAP method's default widget */
+ if (eap->default_field) {
+ eap_default_widget = GTK_WIDGET (gtk_builder_get_object (eap->builder, eap->default_field));
+ if (eap_default_widget)
+ gtk_widget_grab_focus (eap_default_widget);
+ }
+
+ nma_eap_unref (eap);
+
+ nma_ws_changed_cb (combo, NMA_WS (self));
+}
+
+static void
+add_to_size_group (NMAWs *ws, GtkSizeGroup *group)
+{
+ NMAWs8021x *self = NMA_WS_802_1X (ws);
+ NMAEap *eap = NULL;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (self->eap_auth_combo));
+
+ /* Let each EAP method try to update its secrets */
+ if (gtk_tree_model_get_iter_first (model, &iter)) {
+ do {
+ gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1);
+ if (eap) {
+ nma_eap_add_to_size_group (eap, group);
+ nma_eap_unref (eap);
+ }
+ } while (gtk_tree_model_iter_next (model, &iter));
+ }
+
+ gtk_size_group_add_widget (group, self->eap_auth_label);
+}
+
+void
+nma_ws_802_1x_fill_connection (NMAWs *ws, NMConnection *connection)
+{
+ NMAWs8021x *self = NMA_WS_802_1X (ws);
+ NMSettingWirelessSecurity *s_wireless_sec;
+ NMSetting8021x *s_8021x;
+ NMAEap *eap = NULL;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ /* Get the NMAEap object */
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (self->eap_auth_combo));
+ gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self->eap_auth_combo), &iter);
+ gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1);
+ g_return_if_fail (eap);
+
+ /* Blow away the old wireless security setting by adding a clear one */
+ s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
+ nm_connection_add_setting (connection, (NMSetting *) s_wireless_sec);
+
+ /* Blow away the old 802.1x setting by adding a clear one */
+ s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
+ nm_connection_add_setting (connection, (NMSetting *) s_8021x);
+
+ nma_eap_fill_connection (eap, connection);
+ nma_eap_unref (eap);
+}
+
+static void
+update_secrets (NMAWs *ws, NMConnection *connection)
+{
+ NMAWs8021x *self = NMA_WS_802_1X (ws);
+ NMAEap *eap = NULL;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ g_return_if_fail (connection != NULL);
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (self->eap_auth_combo));
+
+ /* Let each EAP method try to update its secrets */
+ if (gtk_tree_model_get_iter_first (model, &iter)) {
+ do {
+ gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1);
+ if (eap) {
+ nma_eap_update_secrets (eap, connection);
+ nma_eap_unref (eap);
+ }
+ } while (gtk_tree_model_iter_next (model, &iter));
+ }
+}
+
+static void
+get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ NMAWs8021x *self = NMA_WS_802_1X (object);
+
+ switch (prop_id) {
+ case PROP_CONNECTION:
+ g_value_set_object (value, self->connection);
+ break;
+ case PROP_SECRETS_ONLY:
+ g_value_set_boolean (value, self->secrets_only);
+ break;
+ case PROP_IS_EDITOR:
+ g_value_set_boolean (value, self->is_editor);
+ break;
+ case PROP_SECRETS_HINTS:
+ g_value_set_boxed (value, self->secrets_hints);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ NMAWs8021x *self = NMA_WS_802_1X (object);
+
+ switch (prop_id) {
+ case PROP_CONNECTION:
+ self->connection = g_value_dup_object (value);
+ break;
+ case PROP_SECRETS_ONLY:
+ self->secrets_only = g_value_get_boolean (value);
+ break;
+ case PROP_IS_EDITOR:
+ self->is_editor = g_value_get_boolean (value);
+ break;
+ case PROP_SECRETS_HINTS:
+ self->secrets_hints = g_value_dup_boxed (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+nma_ws_802_1x_init (NMAWs8021x *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+static void
+nma_ws_interface_init (NMAWsInterface *iface)
+{
+ iface->validate = validate;
+ iface->add_to_size_group = add_to_size_group;
+ iface->fill_connection = nma_ws_802_1x_fill_connection;
+ iface->update_secrets = update_secrets;
+ iface->adhoc_compatible = FALSE;
+ iface->hotspot_compatible = FALSE;
+}
+
+static void
+constructed (GObject *object)
+{
+ NMAWs8021x *self = NMA_WS_802_1X (object);
+ GtkListStore *auth_model;
+ GtkTreeIter iter;
+ NMAEapSimple *em_md5;
+ NMAEapTls *em_tls;
+ NMAEapLeap *em_leap;
+ NMAEapSimple *em_pwd;
+ NMAEapFast *em_fast;
+ NMAEapTtls *em_ttls;
+ NMAEapPeap *em_peap;
+ const char *default_method = NULL, *ctype = NULL;
+ int active = -1, item = 0;
+ gboolean wired = FALSE;
+ NMAEapSimpleFlags simple_flags = NMA_EAP_SIMPLE_FLAG_NONE;
+
+ /* Grab the default EAP method out of the security object */
+ if (self->connection) {
+ NMSettingConnection *s_con;
+ NMSetting8021x *s_8021x;
+
+ s_con = nm_connection_get_setting_connection (self->connection);
+ if (s_con)
+ ctype = nm_setting_connection_get_connection_type (s_con);
+ if ( (g_strcmp0 (ctype, NM_SETTING_WIRED_SETTING_NAME) == 0)
+ || nm_connection_get_setting_wired (self->connection))
+ wired = TRUE;
+
+ s_8021x = nm_connection_get_setting_802_1x (self->connection);
+ if (s_8021x && nm_setting_802_1x_get_num_eap_methods (s_8021x))
+ default_method = nm_setting_802_1x_get_eap_method (s_8021x, 0);
+ }
+
+ /* initialize NMAWs userpass from connection (clear if no connection) */
+ init_userpass (self, self->connection);
+
+ auth_model = gtk_list_store_new (2, G_TYPE_STRING, nma_eap_get_type ());
+
+ if (self->is_editor)
+ simple_flags |= NMA_EAP_SIMPLE_FLAG_IS_EDITOR;
+ if (self->secrets_only)
+ simple_flags |= NMA_EAP_SIMPLE_FLAG_SECRETS_ONLY;
+
+ if (wired) {
+ em_md5 = nma_eap_simple_new (self, self->connection, NMA_EAP_SIMPLE_TYPE_MD5, simple_flags,
NULL);
+ gtk_list_store_append (auth_model, &iter);
+ gtk_list_store_set (auth_model, &iter,
+ AUTH_NAME_COLUMN, _("MD5"),
+ AUTH_METHOD_COLUMN, em_md5,
+ -1);
+ nma_eap_unref (NMA_EAP (em_md5));
+ if (default_method && (active < 0) && !strcmp (default_method, "md5"))
+ active = item;
+ item++;
+ }
+
+ em_tls = nma_eap_tls_new (self, self->connection, FALSE, self->secrets_only);
+ gtk_list_store_append (auth_model, &iter);
+ gtk_list_store_set (auth_model, &iter,
+ AUTH_NAME_COLUMN, _("TLS"),
+ AUTH_METHOD_COLUMN, em_tls,
+ -1);
+ nma_eap_unref (NMA_EAP (em_tls));
+ if (default_method && (active < 0) && !strcmp (default_method, "tls"))
+ active = item;
+ item++;
+
+ if (!wired) {
+ em_leap = nma_eap_leap_new (self, self->connection, self->secrets_only);
+ gtk_list_store_append (auth_model, &iter);
+ gtk_list_store_set (auth_model, &iter,
+ AUTH_NAME_COLUMN, _("LEAP"),
+ AUTH_METHOD_COLUMN, em_leap,
+ -1);
+ nma_eap_unref (NMA_EAP (em_leap));
+ if (default_method && (active < 0) && !strcmp (default_method, "leap"))
+ active = item;
+ item++;
+ }
+
+ em_pwd = nma_eap_simple_new (self, self->connection, NMA_EAP_SIMPLE_TYPE_PWD, simple_flags, NULL);
+ gtk_list_store_append (auth_model, &iter);
+ gtk_list_store_set (auth_model, &iter,
+ AUTH_NAME_COLUMN, _("PWD"),
+ AUTH_METHOD_COLUMN, em_pwd,
+ -1);
+ nma_eap_unref (NMA_EAP (em_pwd));
+ if (default_method && (active < 0) && !strcmp (default_method, "pwd"))
+ active = item;
+ item++;
+
+ em_fast = nma_eap_fast_new (self, self->connection, self->is_editor, self->secrets_only);
+ gtk_list_store_append (auth_model, &iter);
+ gtk_list_store_set (auth_model, &iter,
+ AUTH_NAME_COLUMN, _("FAST"),
+ AUTH_METHOD_COLUMN, em_fast,
+ -1);
+ nma_eap_unref (NMA_EAP (em_fast));
+ if (default_method && (active < 0) && !strcmp (default_method, "fast"))
+ active = item;
+ item++;
+
+ em_ttls = nma_eap_ttls_new (self, self->connection, self->is_editor, self->secrets_only);
+ gtk_list_store_append (auth_model, &iter);
+ gtk_list_store_set (auth_model, &iter,
+ AUTH_NAME_COLUMN, _("Tunneled TLS"),
+ AUTH_METHOD_COLUMN, em_ttls,
+ -1);
+ nma_eap_unref (NMA_EAP (em_ttls));
+ if (default_method && (active < 0) && !strcmp (default_method, "ttls"))
+ active = item;
+ item++;
+
+ em_peap = nma_eap_peap_new (self, self->connection, self->is_editor, self->secrets_only);
+ gtk_list_store_append (auth_model, &iter);
+ gtk_list_store_set (auth_model, &iter,
+ AUTH_NAME_COLUMN, _("Protected EAP (PEAP)"),
+ AUTH_METHOD_COLUMN, em_peap,
+ -1);
+ nma_eap_unref (NMA_EAP (em_peap));
+ if (default_method && (active < 0) && !strcmp (default_method, "peap"))
+ active = item;
+ item++;
+
+ if (self->secrets_hints && self->secrets_hints[0]) {
+ NMAEapSimple *em_hints;
+
+ em_hints = nma_eap_simple_new (self, self->connection, NMA_EAP_SIMPLE_TYPE_UNKNOWN,
+ simple_flags, (const char **)self->secrets_hints);
+ gtk_list_store_append (auth_model, &iter);
+ gtk_list_store_set (auth_model, &iter,
+ AUTH_NAME_COLUMN, _("Unknown"),
+ AUTH_METHOD_COLUMN, em_hints,
+ -1);
+ nma_eap_unref (NMA_EAP (em_hints));
+ active = item;
+ item++;
+ } else if (default_method && !strcmp (default_method, "external")) {
+ NMAEapSimple *em_extern;
+ const char *empty_hints[] = { NULL };
+
+ em_extern = nma_eap_simple_new (self, self->connection, NMA_EAP_SIMPLE_TYPE_UNKNOWN,
+ simple_flags, empty_hints);
+ gtk_list_store_append (auth_model, &iter);
+ gtk_list_store_set (auth_model, &iter,
+ AUTH_NAME_COLUMN, _("Externally configured"),
+ AUTH_METHOD_COLUMN, em_extern,
+ -1);
+ nma_eap_unref (NMA_EAP (em_extern));
+ active = item;
+ item++;
+ }
+
+ gtk_combo_box_set_model (GTK_COMBO_BOX (self->eap_auth_combo), GTK_TREE_MODEL (auth_model));
+ g_object_unref (G_OBJECT (auth_model));
+ gtk_combo_box_set_active (GTK_COMBO_BOX (self->eap_auth_combo), active < 0 ? 0 : (guint32) active);
+
+ if (self->secrets_only) {
+ gtk_widget_hide (self->eap_auth_combo);
+ gtk_widget_hide (self->eap_auth_label);
+ }
+
+ G_OBJECT_CLASS (nma_ws_802_1x_parent_class)->constructed (object);
+}
+
+NMAWs8021x *
+nma_ws_802_1x_new (NMConnection *connection, gboolean secrets_only)
+{
+ return g_object_new (NMA_TYPE_WS_802_1X,
+ "connection", connection,
+ "secrets-only", secrets_only,
+ NULL);
+}
+
+static void
+dispose (GObject *object)
+{
+ NMAWs8021x *self = NMA_WS_802_1X (object);
+
+ g_clear_object (&self->connection);
+ g_clear_pointer (&self->secrets_hints, g_strfreev);
+ g_clear_pointer (&self->username, g_free);
+ g_clear_pointer (&self->password, g_free);
+}
+
+static void
+nma_ws_802_1x_class_init (NMAWs8021xClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->get_property = get_property;
+ object_class->set_property = set_property;
+ object_class->constructed = constructed;
+ object_class->dispose = dispose;
+
+ g_object_class_override_property (object_class,
+ PROP_CONNECTION, "connection");
+
+ g_object_class_override_property (object_class,
+ PROP_SECRETS_ONLY, "secrets-only");
+
+ g_object_class_install_property
+ (object_class, PROP_IS_EDITOR,
+ g_param_spec_boolean ("is-editor", "", "",
+ FALSE,
+ G_PARAM_READWRITE
+ | G_PARAM_CONSTRUCT
+ | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property
+ (object_class, PROP_SECRETS_HINTS,
+ g_param_spec_boxed ("secrets-hints", "", "",
+ G_TYPE_STRV,
+ G_PARAM_READWRITE
+ | G_PARAM_CONSTRUCT
+ | G_PARAM_STATIC_STRINGS));
+
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/libnma/nma-ws-802-1x.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, NMAWs8021x, eap_auth_combo);
+ gtk_widget_class_bind_template_child (widget_class, NMAWs8021x, eap_auth_label);
+ gtk_widget_class_bind_template_child (widget_class, NMAWs8021x, eap_vbox);
+
+ gtk_widget_class_bind_template_callback (widget_class, auth_combo_changed_cb);
+}
diff --git a/src/nma-ws/nma-ws-802-1x.h b/src/nma-ws/nma-ws-802-1x.h
new file mode 100644
index 00000000..e9964b4b
--- /dev/null
+++ b/src/nma-ws/nma-ws-802-1x.h
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2007 - 2019 Red Hat, Inc.
+ */
+
+#ifndef NMA_WS_802_1X_H
+#define NMA_WS_802_1X_H
+
+typedef struct _NMAWs8021xClass NMAWs8021xClass;
+typedef struct _NMAWs8021x NMAWs8021x;
+
+#define NMA_TYPE_WS_802_1X (nma_ws_802_1x_get_type ())
+#define NMA_WS_802_1X(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_WS_802_1X, NMAWs8021x))
+#define NMA_WS_802_1X_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_WS_802_1X,
NMAWs8021xClass))
+#define NMA_IS_WS_802_1X(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_WS_802_1X))
+#define NMA_IS_WS_802_1X_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_WS_802_1X))
+#define NMA_WS_802_1X_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_WS_802_1X,
NMAWs8021xClass))
+
+GType nma_ws_802_1x_get_type (void);
+
+NMAWs8021x *nma_ws_802_1x_new (NMConnection *connection, gboolean secrets_only);
+
+#endif /* NMA_WS_802_1X_H */
diff --git a/src/nma-ws/nma-ws-802-1x.ui b/src/nma-ws/nma-ws-802-1x.ui
new file mode 100644
index 00000000..74233203
--- /dev/null
+++ b/src/nma-ws/nma-ws-802-1x.ui
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface domain="nm-applet">
+ <requires lib="gtk+" version="3.10"/>
+ <object class="GtkListStore" id="model5">
+ <columns>
+ <!-- column-name gchararray -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0"> </col>
+ </row>
+ </data>
+ </object>
+ <template class="NMAWs8021x" parent="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="eap_auth_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Au_thentication</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">eap_auth_combo</property>
+ <property name="xalign">1</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="eap_auth_combo">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="model">model5</property>
+ <child>
+ <object class="GtkCellRendererText" id="renderer5"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ <signal name="changed" handler="auth_combo_changed_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="eap_vbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">2</property>
+ </packing>
+ </child>
+ </template>
+</interface>
diff --git a/src/nma-ws/nma-ws-dynamic-wep.c b/src/nma-ws/nma-ws-dynamic-wep.c
index 95f27b53..911d7db6 100644
--- a/src/nma-ws/nma-ws-dynamic-wep.c
+++ b/src/nma-ws/nma-ws-dynamic-wep.c
@@ -4,114 +4,65 @@
*
* Copyright 2007 - 2019 Red Hat, Inc.
*/
-
#include "nm-default.h"
-
-#include <ctype.h>
-#include <string.h>
+#include "nma-private.h"
#include "nma-ws.h"
-#include "nma-eap.h"
+#include "nma-ws-private.h"
+#include "nma-ws-802-1x.h"
+#include "nma-ws-802-1x-private.h"
+#include "nma-ws-dynamic-wep.h"
-struct _NMAWsDynamicWEP {
- NMAWs parent;
+typedef struct {
+ NMAWs8021xClass parent;
+} NMAWsDynamicWepClass;
- GtkSizeGroup *size_group;
+struct _NMAWsDynamicWep {
+ NMAWs8021x parent;
};
-static void
-destroy (NMAWs *parent)
-{
- NMAWsDynamicWEP *sec = (NMAWsDynamicWEP *) parent;
+static void nma_ws_interface_init (NMAWsInterface *iface);
- if (sec->size_group)
- g_object_unref (sec->size_group);
-}
-
-static gboolean
-validate (NMAWs *parent, GError **error)
-{
- return nma_ws_802_1x_validate (parent, "dynamic_wep_auth_combo", error);
-}
+G_DEFINE_TYPE_WITH_CODE (NMAWsDynamicWep, nma_ws_dynamic_wep, NMA_TYPE_WS_802_1X,
+ G_IMPLEMENT_INTERFACE (NMA_TYPE_WS, nma_ws_interface_init))
static void
-add_to_size_group (NMAWs *parent, GtkSizeGroup *group)
-{
- NMAWsDynamicWEP *sec = (NMAWsDynamicWEP *) parent;
-
- if (sec->size_group)
- g_object_unref (sec->size_group);
- sec->size_group = g_object_ref (group);
-
- nma_ws_802_1x_add_to_size_group (parent,
- sec->size_group,
- "dynamic_wep_auth_label",
- "dynamic_wep_auth_combo");
-}
-
-static void
-fill_connection (NMAWs *parent, NMConnection *connection)
+fill_connection (NMAWs *ws, NMConnection *connection)
{
NMSettingWirelessSecurity *s_wireless_sec;
- nma_ws_802_1x_fill_connection (parent, "dynamic_wep_auth_combo", connection);
+ nma_ws_802_1x_fill_connection (ws, connection);
s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
- g_assert (s_wireless_sec);
+ g_return_if_fail (s_wireless_sec);
g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", NULL);
}
static void
-auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
+nma_ws_dynamic_wep_init (NMAWsDynamicWep *self)
{
- NMAWs *parent = NMA_WS (user_data);
- NMAWsDynamicWEP *sec = (NMAWsDynamicWEP *) parent;
-
- nma_ws_802_1x_auth_combo_changed (combo,
- parent,
- "dynamic_wep_method_vbox",
- sec->size_group);
}
static void
-update_secrets (NMAWs *parent, NMConnection *connection)
+nma_ws_interface_init (NMAWsInterface *iface)
{
- nma_ws_802_1x_update_secrets (parent, "dynamic_wep_auth_combo", connection);
+ iface->fill_connection = fill_connection;
}
-NMAWsDynamicWEP *
+NMAWsDynamicWep *
nma_ws_dynamic_wep_new (NMConnection *connection,
gboolean is_editor,
gboolean secrets_only)
{
- NMAWs *parent;
- GtkWidget *widget;
-
- parent = nma_ws_init (sizeof (NMAWsDynamicWEP),
- validate,
- add_to_size_group,
- fill_connection,
- update_secrets,
- destroy,
- "/org/gnome/libnma/nma-ws-dynamic-wep.ui",
- "dynamic_wep_notebook",
- NULL);
- if (!parent)
- return NULL;
-
- parent->adhoc_compatible = FALSE;
- parent->hotspot_compatible = FALSE;
-
- widget = nma_ws_802_1x_auth_combo_init (parent,
- "dynamic_wep_auth_combo",
- "dynamic_wep_auth_label",
- (GCallback) auth_combo_changed_cb,
- connection,
- is_editor,
- secrets_only,
- NULL);
- auth_combo_changed_cb (widget, (gpointer) parent);
+ return g_object_new (NMA_TYPE_WS_DYNAMIC_WEP,
+ "connection", connection,
+ "secrets-only", secrets_only,
+ "is-editor", is_editor,
+ NULL);
+}
- return (NMAWsDynamicWEP *) parent;
+static void
+nma_ws_dynamic_wep_class_init (NMAWsDynamicWepClass *klass)
+{
}
diff --git a/src/nma-ws/nma-ws-dynamic-wep.h b/src/nma-ws/nma-ws-dynamic-wep.h
index 1dfc3f8c..8d1fcda9 100644
--- a/src/nma-ws/nma-ws-dynamic-wep.h
+++ b/src/nma-ws/nma-ws-dynamic-wep.h
@@ -5,13 +5,22 @@
* Copyright 2007 - 2019 Red Hat, Inc.
*/
-#ifndef WS_DYNAMIC_WEP_H
-#define WS_DYNAMIC_WEP_H
+#ifndef NMA_WS_DYNAMIC_WEP_H
+#define NMA_WS_DYNAMIC_WEP_H
-typedef struct _NMAWsDynamicWEP NMAWsDynamicWEP;
+typedef struct _NMAWsDynamicWep NMAWsDynamicWep;
-NMAWsDynamicWEP *nma_ws_dynamic_wep_new (NMConnection *connection,
+#define NMA_TYPE_WS_DYNAMIC_WEP (nma_ws_dynamic_wep_get_type ())
+#define NMA_WS_DYNAMIC_WEP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_WS_SAE,
NMAWsDynamicWep))
+#define NMA_WS_DYNAMIC_WEP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_WS_SAE,
NMAWsDynamicWepClass))
+#define NMA_IS_WS_DYNAMIC_WEP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_WS_SAE))
+#define NMA_IS_WS_DYNAMIC_WEP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_WS_SAE))
+#define NMA_WS_DYNAMIC_WEP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_WS_SAE,
NMAWsDynamicWepClass))
+
+GType nma_ws_dynamic_wep_get_type (void);
+
+NMAWsDynamicWep *nma_ws_dynamic_wep_new (NMConnection *connection,
gboolean is_editor,
gboolean secrets_only);
-#endif /* WS_DYNAMIC_WEP_H */
+#endif /* NMA_WS_DYNAMIC_WEP_H */
diff --git a/src/nma-ws/nma-ws-helpers.c b/src/nma-ws/nma-ws-helpers.c
new file mode 100644
index 00000000..d517ae38
--- /dev/null
+++ b/src/nma-ws/nma-ws-helpers.c
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Dan Williams <dcbw redhat com>
+ *
+ * Copyright 2009 - 2019 Red Hat, Inc.
+ */
+
+#include "nm-default.h"
+#include "nma-private.h"
+#include "nma-ws-helpers.h"
+
+void
+nma_ws_helper_fill_secret_entry (NMConnection *connection,
+ GtkEditable *entry,
+ GType setting_type,
+ HelperSecretFunc func)
+{
+ NMSetting *setting;
+ const char *tmp;
+
+ g_return_if_fail (connection != NULL);
+ g_return_if_fail (entry != NULL);
+ g_return_if_fail (func != NULL);
+
+ setting = nm_connection_get_setting (connection, setting_type);
+ if (setting) {
+ tmp = (*func) (setting);
+ if (tmp)
+ gtk_editable_set_text (entry, tmp);
+ }
+}
diff --git a/src/nma-ws/nma-ws-helpers.h b/src/nma-ws/nma-ws-helpers.h
new file mode 100644
index 00000000..3f842646
--- /dev/null
+++ b/src/nma-ws/nma-ws-helpers.h
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Dan Williams <dcbw redhat com>
+ *
+ * Copyright 2009 - 2019 Red Hat, Inc.
+ */
+
+#ifndef _NMA_WS_HELPERS_H_
+#define _NMA_WS_HELPERS_H_
+
+typedef const char * (*HelperSecretFunc)(NMSetting *);
+
+void nma_ws_helper_fill_secret_entry (NMConnection *connection,
+ GtkEditable *entry,
+ GType setting_type,
+ HelperSecretFunc func);
+
+#endif /* _NMA_WS_HELPERS_H_ */
diff --git a/src/nma-ws/nma-ws-leap.c b/src/nma-ws/nma-ws-leap.c
index 6c0814e2..ef2cf8bf 100644
--- a/src/nma-ws/nma-ws-leap.c
+++ b/src/nma-ws/nma-ws-leap.c
@@ -8,62 +8,81 @@
#include "nm-default.h"
#include "nma-private.h"
+#include <ctype.h>
#include <string.h>
#include "nma-ws.h"
-#include "helpers.h"
+#include "nma-ws-private.h"
+#include "nma-ws-leap.h"
+#include "nma-ws-helpers.h"
#include "nma-ui-utils.h"
#include "utils.h"
-struct _NMAWsLEAP {
- NMAWs parent;
- gboolean editing_connection;
- const char *password_flags_name;
+typedef struct {
+ GtkGridClass parent;
+} NMAWsLeapClass;
+
+struct _NMAWsLeap {
+ GtkGrid parent;
+
+ GtkWidget *leap_username_entry;
+ GtkWidget *leap_password_entry;
+ GtkWidget *leap_username_label;
+ GtkWidget *leap_password_label;
+ GtkWidget *show_checkbutton_leap;
+
+ NMConnection *connection;
+ gboolean secrets_only;
+};
+
+static void nma_ws_interface_init (NMAWsInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (NMAWsLeap, nma_ws_leap, GTK_TYPE_GRID,
+ G_IMPLEMENT_INTERFACE (NMA_TYPE_WS, nma_ws_interface_init))
+
+enum {
+ PROP_0,
+ PROP_CONNECTION,
+ PROP_SECRETS_ONLY,
+ PROP_LAST
};
static void
-show_toggled_cb (GtkCheckButton *button, NMAWs *sec)
+show_toggled_cb (GtkCheckButton *button, gpointer user_data)
{
- GtkWidget *widget;
+ NMAWsLeap *self = NMA_WS_LEAP (user_data);
gboolean visible;
- widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "leap_password_entry"));
- g_assert (widget);
-
visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
- gtk_entry_set_visibility (GTK_ENTRY (widget), visible);
+ gtk_entry_set_visibility (GTK_ENTRY (self->leap_password_entry), visible);
}
static gboolean
-validate (NMAWs *parent, GError **error)
+validate (NMAWs *ws, GError **error)
{
- GtkWidget *entry;
+ NMAWsLeap *self = NMA_WS_LEAP (ws);
NMSettingSecretFlags secret_flags;
const char *text;
gboolean ret = TRUE;
- entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "leap_username_entry"));
- g_assert (entry);
- text = gtk_editable_get_text (GTK_EDITABLE (entry));
+ text = gtk_editable_get_text (GTK_EDITABLE (self->leap_username_entry));
if (!text || !strlen (text)) {
- widget_set_error (entry);
+ widget_set_error (self->leap_username_entry);
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("missing leap-username"));
ret = FALSE;
- } else
- widget_unset_error (entry);
-
- entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "leap_password_entry"));
- g_assert (entry);
+ } else {
+ widget_unset_error (self->leap_username_entry);
+ }
- secret_flags = nma_utils_menu_to_secret_flags (entry);
- text = gtk_editable_get_text (GTK_EDITABLE (entry));
+ secret_flags = nma_utils_menu_to_secret_flags (self->leap_password_entry);
+ text = gtk_editable_get_text (GTK_EDITABLE (self->leap_password_entry));
if ( secret_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED
|| secret_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED
|| (text && strlen (text))) {
- widget_unset_error (entry);
+ widget_unset_error (self->leap_password_entry);
} else {
- widget_set_error (entry);
+ widget_set_error (self->leap_password_entry);
if (ret) {
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("missing leap-password"));
ret = FALSE;
@@ -74,36 +93,28 @@ validate (NMAWs *parent, GError **error)
}
static void
-add_to_size_group (NMAWs *parent, GtkSizeGroup *group)
+add_to_size_group (NMAWs *ws, GtkSizeGroup *group)
{
- GtkWidget *widget;
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "leap_username_label"));
- gtk_size_group_add_widget (group, widget);
+ NMAWsLeap *self = NMA_WS_LEAP (ws);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "leap_password_label"));
- gtk_size_group_add_widget (group, widget);
+ gtk_size_group_add_widget (group, self->leap_username_label);
+ gtk_size_group_add_widget (group, self->leap_password_label);
}
static void
-fill_connection (NMAWs *parent, NMConnection *connection)
+fill_connection (NMAWs *ws, NMConnection *connection)
{
- NMAWsLEAP *sec = (NMAWsLEAP *) parent;
+ NMAWsLeap *self = NMA_WS_LEAP (ws);
NMSettingWirelessSecurity *s_wireless_sec;
NMSettingSecretFlags secret_flags;
- GtkWidget *widget, *passwd_entry;
const char *leap_password = NULL, *leap_username = NULL;
/* Blow away the old security setting by adding a clear one */
s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
nm_connection_add_setting (connection, (NMSetting *) s_wireless_sec);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "leap_username_entry"));
- leap_username = gtk_editable_get_text (GTK_EDITABLE (widget));
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "leap_password_entry"));
- passwd_entry = widget;
- leap_password = gtk_editable_get_text (GTK_EDITABLE (widget));
+ leap_username = gtk_editable_get_text (GTK_EDITABLE (self->leap_username_entry));
+ leap_password = gtk_editable_get_text (GTK_EDITABLE (self->leap_password_entry));
g_object_set (s_wireless_sec,
NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x",
@@ -113,48 +124,96 @@ fill_connection (NMAWs *parent, NMConnection *connection)
NULL);
/* Save LEAP_PASSWORD_FLAGS to the connection */
- secret_flags = nma_utils_menu_to_secret_flags (passwd_entry);
- nm_setting_set_secret_flags (NM_SETTING (s_wireless_sec), sec->password_flags_name,
+ secret_flags = nma_utils_menu_to_secret_flags (self->leap_password_entry);
+ nm_setting_set_secret_flags (NM_SETTING (s_wireless_sec), NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD,
secret_flags, NULL);
/* Update secret flags and popup when editing the connection */
- if (sec->editing_connection)
- nma_utils_update_password_storage (passwd_entry, secret_flags,
- NM_SETTING (s_wireless_sec), sec->password_flags_name);
+ if (!self->secrets_only) {
+ nma_utils_update_password_storage (self->leap_password_entry, secret_flags,
+ NM_SETTING (s_wireless_sec),
+ NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD);
+ }
+}
+
+static void
+update_secrets (NMAWs *ws, NMConnection *connection)
+{
+ NMAWsLeap *self = NMA_WS_LEAP (ws);
+
+ nma_ws_helper_fill_secret_entry (connection,
+ GTK_EDITABLE (self->leap_password_entry),
+ NM_TYPE_SETTING_WIRELESS_SECURITY,
+ (HelperSecretFunc) nm_setting_wireless_security_get_leap_password);
}
static void
-update_secrets (NMAWs *parent, NMConnection *connection)
+get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- helper_fill_secret_entry (connection,
- parent->builder,
- "leap_password_entry",
- NM_TYPE_SETTING_WIRELESS_SECURITY,
- (HelperSecretFunc) nm_setting_wireless_security_get_leap_password);
+ NMAWsLeap *self = NMA_WS_LEAP (object);
+
+ switch (prop_id) {
+ case PROP_CONNECTION:
+ g_value_set_object (value, self->connection);
+ break;
+ case PROP_SECRETS_ONLY:
+ g_value_set_boolean (value, self->secrets_only);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
-NMAWsLEAP *
-nma_ws_leap_new (NMConnection *connection, gboolean secrets_only)
+static void
+set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- NMAWs *parent;
- NMAWsLEAP *sec;
- GtkWidget *widget;
+ NMAWsLeap *self = NMA_WS_LEAP (object);
+
+ switch (prop_id) {
+ case PROP_CONNECTION:
+ self->connection = g_value_dup_object (value);
+ break;
+ case PROP_SECRETS_ONLY:
+ self->secrets_only = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+nma_ws_leap_init (NMAWsLeap *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+static void
+nma_ws_interface_init (NMAWsInterface *iface)
+{
+ iface->validate = validate;
+ iface->add_to_size_group = add_to_size_group;
+ iface->fill_connection = fill_connection;
+ iface->update_secrets = update_secrets;
+ iface->adhoc_compatible = FALSE;
+ iface->hotspot_compatible = FALSE;
+}
+
+static void
+constructed (GObject *object)
+{
+ NMAWsLeap *self = NMA_WS_LEAP (object);
NMSettingWirelessSecurity *wsec = NULL;
- parent = nma_ws_init (sizeof (NMAWsLEAP),
- validate,
- add_to_size_group,
- fill_connection,
- update_secrets,
- NULL,
- "/org/gnome/libnma/nma-ws-leap.ui",
- "leap_notebook",
- "leap_username_entry");
- if (!parent)
- return NULL;
-
- if (connection) {
- wsec = nm_connection_get_setting_wireless_security (connection);
+ if (self->connection) {
+ wsec = nm_connection_get_setting_wireless_security (self->connection);
if (wsec) {
const char *auth_alg;
@@ -165,41 +224,70 @@ nma_ws_leap_new (NMConnection *connection, gboolean secrets_only)
}
}
- parent->adhoc_compatible = FALSE;
- parent->hotspot_compatible = FALSE;
- sec = (NMAWsLEAP *) parent;
- sec->editing_connection = secrets_only ? FALSE : TRUE;
- sec->password_flags_name = NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD;
+ /* Create password-storage popup menu for password entry under entry's secondary icon */
+ nma_utils_setup_password_storage (self->leap_password_entry, 0, (NMSetting *) wsec,
+ NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD,
+ FALSE, self->secrets_only);
+
+ if (wsec) {
+ update_secrets (NMA_WS (self), self->connection);
+ gtk_editable_set_text (GTK_EDITABLE (self->leap_username_entry),
+ nm_setting_wireless_security_get_leap_username (wsec));
+ }
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "leap_password_entry"));
- g_assert (widget);
- g_signal_connect (G_OBJECT (widget), "changed",
- (GCallback) nma_ws_changed_cb,
- sec);
+ if (self->secrets_only) {
+ gtk_widget_hide (self->leap_username_label);
+ gtk_widget_hide (self->leap_username_entry);
+ }
- /* Create password-storage popup menu for password entry under entry's secondary icon */
- nma_utils_setup_password_storage (widget, 0, (NMSetting *) wsec, sec->password_flags_name,
- FALSE, secrets_only);
-
- if (wsec)
- update_secrets (NMA_WS (sec), connection);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "leap_username_entry"));
- g_assert (widget);
- g_signal_connect (G_OBJECT (widget), "changed",
- (GCallback) nma_ws_changed_cb,
- sec);
- if (wsec)
- gtk_editable_set_text (GTK_EDITABLE (widget), nm_setting_wireless_security_get_leap_username
(wsec));
-
- if (secrets_only)
- gtk_widget_hide (widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_leap"));
- g_assert (widget);
- g_signal_connect (G_OBJECT (widget), "toggled",
- (GCallback) show_toggled_cb,
- sec);
-
- return sec;
+ gtk_widget_grab_focus (self->leap_password_entry);
+
+ G_OBJECT_CLASS (nma_ws_leap_parent_class)->constructed (object);
+}
+
+NMAWsLeap *
+nma_ws_leap_new (NMConnection *connection, gboolean secrets_only)
+{
+ return g_object_new (NMA_TYPE_WS_LEAP,
+ "connection", connection,
+ "secrets-only", secrets_only,
+ NULL);
+}
+
+static void
+dispose (GObject *object)
+{
+ NMAWsLeap *self = NMA_WS_LEAP (object);
+
+ g_clear_object (&self->connection);
+}
+
+static void
+nma_ws_leap_class_init (NMAWsLeapClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->get_property = get_property;
+ object_class->set_property = set_property;
+ object_class->constructed = constructed;
+ object_class->dispose = dispose;
+
+ g_object_class_override_property (object_class,
+ PROP_CONNECTION, "connection");
+
+ g_object_class_override_property (object_class,
+ PROP_SECRETS_ONLY, "secrets-only");
+
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/libnma/nma-ws-leap.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, NMAWsLeap, leap_username_entry);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsLeap, leap_password_entry);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsLeap, leap_username_label);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsLeap, leap_password_label);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsLeap, show_checkbutton_leap);
+
+ gtk_widget_class_bind_template_callback (widget_class, nma_ws_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, show_toggled_cb);
}
diff --git a/src/nma-ws/nma-ws-leap.h b/src/nma-ws/nma-ws-leap.h
index 29f12602..606ce50e 100644
--- a/src/nma-ws/nma-ws-leap.h
+++ b/src/nma-ws/nma-ws-leap.h
@@ -5,11 +5,20 @@
* Copyright 2007 - 2019 Red Hat, Inc.
*/
-#ifndef WS_LEAP_H
-#define WS_LEAP_H
+#ifndef NMA_WS_LEAP_H
+#define NMA_WS_LEAP_H
-typedef struct _NMAWsLEAP NMAWsLEAP;
+typedef struct _NMAWsLeap NMAWsLeap;
-NMAWsLEAP *nma_ws_leap_new (NMConnection *connection, gboolean secrets_only);
+#define NMA_TYPE_WS_LEAP (nma_ws_leap_get_type ())
+#define NMA_WS_LEAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_WS_LEAP, NMAWsLeap))
+#define NMA_WS_LEAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_WS_LEAP, NMAWsLeapClass))
+#define NMA_IS_WS_LEAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_WS_LEAP))
+#define NMA_IS_WS_LEAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_WS_LEAP))
+#define NMA_WS_LEAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_WS_LEAP, NMAWsLeapClass))
-#endif /* WS_LEAP_H */
+GType nma_ws_leap_get_type (void);
+
+NMAWsLeap *nma_ws_leap_new (NMConnection *connection, gboolean secrets_only);
+
+#endif /* NMA_WS_LEAP_H */
diff --git a/src/nma-ws/nma-ws-leap.ui b/src/nma-ws/nma-ws-leap.ui
index a93121d6..da44a23b 100644
--- a/src/nma-ws/nma-ws-leap.ui
+++ b/src/nma-ws/nma-ws-leap.ui
@@ -1,100 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="nm-applet">
<requires lib="gtk+" version="3.10"/>
- <object class="GtkNotebook" id="leap_notebook">
+ <template class="NMAWsLeap" parent="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="show_tabs">False</property>
- <property name="show_border">False</property>
+ <property name="valign">start</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
<child>
- <object class="GtkGrid" id="table5">
+ <object class="GtkLabel" id="leap_username_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="valign">start</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">6</property>
- <child>
- <object class="GtkLabel" id="leap_username_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Username</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">leap_username_entry</property>
- <property name="xalign">1</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="leap_password_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Password</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">leap_password_entry</property>
- <property name="xalign">1</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="leap_password_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="visibility">False</property>
- <property name="activates_default">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="show_checkbutton_leap">
- <property name="label" translatable="yes">Sho_w password</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="hexpand">True</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="leap_username_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="activates_default">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <placeholder/>
- </child>
+ <property name="label" translatable="yes">_Username</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">leap_username_entry</property>
+ <property name="xalign">1</property>
</object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
</child>
- <child type="tab">
- <object class="GtkLabel" id="GtkLabel1">
+ <child>
+ <object class="GtkLabel" id="leap_password_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Password</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">leap_password_entry</property>
+ <property name="xalign">1</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="leap_password_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="visibility">False</property>
+ <property name="activates_default">True</property>
+ <signal name="changed" handler="nma_ws_changed_cb" swapped="no"/>
</object>
<packing>
- <property name="tab_fill">False</property>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
</packing>
</child>
- </object>
+ <child>
+ <object class="GtkCheckButton" id="show_checkbutton_leap">
+ <property name="label" translatable="yes">Sho_w password</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="hexpand">True</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="show_toggled_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="leap_username_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="activates_default">True</property>
+ <signal name="changed" handler="nma_ws_changed_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </template>
</interface>
diff --git a/src/nma-ws/nma-ws-sae.c b/src/nma-ws/nma-ws-sae.c
index 3ac2b95b..a697b7c0 100644
--- a/src/nma-ws/nma-ws-sae.c
+++ b/src/nma-ws/nma-ws-sae.c
@@ -10,75 +10,87 @@
#include <string.h>
#include "nma-ws.h"
-#include "helpers.h"
+#include "nma-ws-private.h"
+#include "nma-ws-sae.h"
+#include "nma-ws-helpers.h"
#include "nma-ui-utils.h"
#include "utils.h"
-#define WPA_PMK_LEN 32
+typedef struct {
+ GtkGridClass parent;
+} NMAWsSaeClass;
-struct _NMAWsSAE {
- NMAWs parent;
+struct _NMAWsSae {
+ GtkGrid parent;
- gboolean editing_connection;
- const char *password_flags_name;
+ GtkWidget *psk_entry;
+ GtkWidget *sae_label;
+ GtkWidget *sae_type_combo;
+ GtkWidget *sae_type_label;
+ GtkWidget *show_checkbutton_sae;
+
+ NMConnection *connection;
+ gboolean secrets_only;
+};
+
+static void nma_ws_interface_init (NMAWsInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (NMAWsSae, nma_ws_sae, GTK_TYPE_GRID,
+ G_IMPLEMENT_INTERFACE (NMA_TYPE_WS, nma_ws_interface_init))
+
+enum {
+ PROP_0,
+ PROP_CONNECTION,
+ PROP_SECRETS_ONLY,
+ PROP_LAST
};
static void
-show_toggled_cb (GtkCheckButton *button, NMAWs *sec)
+show_toggled_cb (GtkCheckButton *button, gpointer user_data)
{
- GtkWidget *widget;
+ NMAWsSae *self = NMA_WS_SAE (user_data);
gboolean visible;
- widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "psk_entry"));
- g_assert (widget);
-
visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
- gtk_entry_set_visibility (GTK_ENTRY (widget), visible);
+ gtk_entry_set_visibility (GTK_ENTRY (self->psk_entry), visible);
}
static gboolean
-validate (NMAWs *parent, GError **error)
+validate (NMAWs *ws, GError **error)
{
- GtkWidget *entry;
+ NMAWsSae *self = NMA_WS_SAE (ws);
NMSettingSecretFlags secret_flags;
const char *key;
- entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "psk_entry"));
- g_assert (entry);
-
- secret_flags = nma_utils_menu_to_secret_flags (entry);
- key = gtk_editable_get_text (GTK_EDITABLE (entry));
+ secret_flags = nma_utils_menu_to_secret_flags (self->psk_entry);
+ key = gtk_editable_get_text (GTK_EDITABLE (self->psk_entry));
if ( secret_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED
|| secret_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED) {
/* All good. */
} else if (key == NULL || key[0] == '\0') {
- widget_set_error (entry);
+ widget_set_error (self->psk_entry);
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("missing password"));
return FALSE;
}
- widget_unset_error (entry);
+ widget_unset_error (self->psk_entry);
return TRUE;
}
static void
-add_to_size_group (NMAWs *parent, GtkSizeGroup *group)
+add_to_size_group (NMAWs *ws, GtkSizeGroup *group)
{
- GtkWidget *widget;
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "sae_type_label"));
- gtk_size_group_add_widget (group, widget);
+ NMAWsSae *self = NMA_WS_SAE (ws);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "sae_label"));
- gtk_size_group_add_widget (group, widget);
+ gtk_size_group_add_widget (group, self->sae_type_label);
+ gtk_size_group_add_widget (group, self->sae_label);
}
static void
-fill_connection (NMAWs *parent, NMConnection *connection)
+fill_connection (NMAWs *ws, NMConnection *connection)
{
- NMAWsSAE *sae = (NMAWsSAE *) parent;
- GtkWidget *widget, *passwd_entry;
+ NMAWsSae *self = NMA_WS_SAE (ws);
const char *key;
NMSettingWireless *s_wireless;
NMSettingWirelessSecurity *s_wireless_sec;
@@ -87,7 +99,7 @@ fill_connection (NMAWs *parent, NMConnection *connection)
gboolean is_adhoc = FALSE;
s_wireless = nm_connection_get_setting_wireless (connection);
- g_assert (s_wireless);
+ g_return_if_fail (s_wireless);
mode = nm_setting_wireless_get_mode (s_wireless);
if (mode && !strcmp (mode, "adhoc"))
@@ -97,20 +109,20 @@ fill_connection (NMAWs *parent, NMConnection *connection)
s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
nm_connection_add_setting (connection, (NMSetting *) s_wireless_sec);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "psk_entry"));
- passwd_entry = widget;
- key = gtk_editable_get_text (GTK_EDITABLE (widget));
+ key = gtk_editable_get_text (GTK_EDITABLE (self->psk_entry));
g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_PSK, key, NULL);
/* Save PSK_FLAGS to the connection */
- secret_flags = nma_utils_menu_to_secret_flags (passwd_entry);
+ secret_flags = nma_utils_menu_to_secret_flags (self->psk_entry);
nm_setting_set_secret_flags (NM_SETTING (s_wireless_sec), NM_SETTING_WIRELESS_SECURITY_PSK,
secret_flags, NULL);
/* Update secret flags and popup when editing the connection */
- if (sae->editing_connection)
- nma_utils_update_password_storage (passwd_entry, secret_flags,
- NM_SETTING (s_wireless_sec), sae->password_flags_name);
+ if (!self->secrets_only) {
+ nma_utils_update_password_storage (self->psk_entry, secret_flags,
+ NM_SETTING (s_wireless_sec),
+ NM_SETTING_WIRELESS_SECURITY_PSK);
+ }
nma_ws_clear_ciphers (connection);
if (is_adhoc) {
@@ -129,74 +141,145 @@ fill_connection (NMAWs *parent, NMConnection *connection)
}
static void
-update_secrets (NMAWs *parent, NMConnection *connection)
+update_secrets (NMAWs *ws, NMConnection *connection)
{
- helper_fill_secret_entry (connection,
- parent->builder,
- "psk_entry",
- NM_TYPE_SETTING_WIRELESS_SECURITY,
- (HelperSecretFunc) nm_setting_wireless_security_get_psk);
+ NMAWsSae *self = NMA_WS_SAE (ws);
+
+ nma_ws_helper_fill_secret_entry (connection,
+ GTK_EDITABLE (self->psk_entry),
+ NM_TYPE_SETTING_WIRELESS_SECURITY,
+ (HelperSecretFunc) nm_setting_wireless_security_get_psk);
}
-NMAWsSAE *
-nma_ws_sae_new (NMConnection *connection, gboolean secrets_only)
+static void
+get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- NMAWs *parent;
- NMAWsSAE *sec;
+ NMAWsSae *self = NMA_WS_SAE (object);
+
+ switch (prop_id) {
+ case PROP_CONNECTION:
+ g_value_set_object (value, self->connection);
+ break;
+ case PROP_SECRETS_ONLY:
+ g_value_set_boolean (value, self->secrets_only);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ NMAWsSae *self = NMA_WS_SAE (object);
+
+ switch (prop_id) {
+ case PROP_CONNECTION:
+ self->connection = g_value_dup_object (value);
+ break;
+ case PROP_SECRETS_ONLY:
+ self->secrets_only = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+nma_ws_sae_init (NMAWsSae *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+static void
+nma_ws_interface_init (NMAWsInterface *iface)
+{
+ iface->validate = validate;
+ iface->add_to_size_group = add_to_size_group;
+ iface->fill_connection = fill_connection;
+ iface->update_secrets = update_secrets;
+ iface->adhoc_compatible = TRUE;
+ iface->hotspot_compatible = TRUE;
+}
+
+static void
+constructed (GObject *object)
+{
+ NMAWsSae *self = NMA_WS_SAE (object);
NMSetting *setting = NULL;
- GtkWidget *widget;
-
- parent = nma_ws_init (sizeof (NMAWsSAE),
- validate,
- add_to_size_group,
- fill_connection,
- update_secrets,
- NULL,
- "/org/gnome/libnma/nma-ws-sae.ui",
- "sae_notebook",
- "psk_entry");
- if (!parent)
- return NULL;
-
- parent->adhoc_compatible = TRUE;
- sec = (NMAWsSAE *) parent;
- sec->editing_connection = secrets_only ? FALSE : TRUE;
- sec->password_flags_name = NM_SETTING_WIRELESS_SECURITY_PSK;
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "psk_entry"));
- g_assert (widget);
- g_signal_connect (G_OBJECT (widget), "changed",
- (GCallback) nma_ws_changed_cb,
- sec);
- gtk_editable_set_width_chars (GTK_EDITABLE (widget), 28);
/* Create password-storage popup menu for password entry under entry's secondary icon */
- if (connection)
- setting = (NMSetting *) nm_connection_get_setting_wireless_security (connection);
- nma_utils_setup_password_storage (widget, 0, setting, sec->password_flags_name,
- FALSE, secrets_only);
+ if (self->connection)
+ setting = (NMSetting *) nm_connection_get_setting_wireless_security (self->connection);
+ nma_utils_setup_password_storage (self->psk_entry, 0, setting, NM_SETTING_WIRELESS_SECURITY_PSK,
+ FALSE, self->secrets_only);
/* Fill secrets, if any */
- if (connection)
- update_secrets (NMA_WS (sec), connection);
+ if (self->connection)
+ update_secrets (NMA_WS (self), self->connection);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_sae"));
- g_assert (widget);
- g_signal_connect (G_OBJECT (widget), "toggled",
- (GCallback) show_toggled_cb,
- sec);
+ gtk_widget_grab_focus (self->psk_entry);
/* Hide WPA/RSN for now since this can be autodetected by NM and the
* supplicant when connecting to the AP.
*/
+ gtk_widget_hide (self->sae_type_combo);
+ gtk_widget_hide (self->sae_type_label);
+
+ G_OBJECT_CLASS (nma_ws_sae_parent_class)->constructed (object);
+}
+
+NMAWsSae *
+nma_ws_sae_new (NMConnection *connection, gboolean secrets_only)
+{
+ return g_object_new (NMA_TYPE_WS_SAE,
+ "connection", connection,
+ "secrets-only", secrets_only,
+ NULL);
+}
+
+static void
+dispose (GObject *object)
+{
+ NMAWsSae *self = NMA_WS_SAE (object);
+
+ g_clear_object (&self->connection);
+}
+
+static void
+nma_ws_sae_class_init (NMAWsSaeClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->get_property = get_property;
+ object_class->set_property = set_property;
+ object_class->constructed = constructed;
+ object_class->dispose = dispose;
+
+ g_object_class_override_property (object_class,
+ PROP_CONNECTION, "connection");
+
+ g_object_class_override_property (object_class,
+ PROP_SECRETS_ONLY, "secrets-only");
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "sae_type_combo"));
- g_assert (widget);
- gtk_widget_hide (widget);
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/libnma/nma-ws-sae.ui");
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "sae_type_label"));
- g_assert (widget);
- gtk_widget_hide (widget);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsSae, psk_entry);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsSae, sae_label);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsSae, sae_type_combo);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsSae, sae_type_label);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsSae, show_checkbutton_sae);
- return sec;
+ gtk_widget_class_bind_template_callback (widget_class, nma_ws_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, show_toggled_cb);
}
diff --git a/src/nma-ws/nma-ws-sae.h b/src/nma-ws/nma-ws-sae.h
index 05e0de88..3eab3918 100644
--- a/src/nma-ws/nma-ws-sae.h
+++ b/src/nma-ws/nma-ws-sae.h
@@ -3,14 +3,20 @@
* Copyright 2007 - 2019 Red Hat, Inc.
*/
-#ifndef WS_SAE_H
-#define WS_SAE_H
+#ifndef NMA_WS_SAE_H
+#define NMA_WS_SAE_H
-/* For compatibility with NetworkManager-1.20 and earlier. */
-#define NMU_SEC_SAE 9
+typedef struct _NMAWsSae NMAWsSae;
-typedef struct _NMAWsSAE NMAWsSAE;
+#define NMA_TYPE_WS_SAE (nma_ws_sae_get_type ())
+#define NMA_WS_SAE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_WS_SAE, NMAWsSae))
+#define NMA_WS_SAE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_WS_SAE, NMAWsSaeClass))
+#define NMA_IS_WS_SAE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_WS_SAE))
+#define NMA_IS_WS_SAE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_WS_SAE))
+#define NMA_WS_SAE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_WS_SAE, NMAWsSaeClass))
-NMAWsSAE *nma_ws_sae_new (NMConnection *connection, gboolean secrets_only);
+GType nma_ws_sae_get_type (void);
-#endif /* WS_SAE_H */
+NMAWsSae *nma_ws_sae_new (NMConnection *connection, gboolean secrets_only);
+
+#endif /* NMA_WS_SAE_H */
diff --git a/src/nma-ws/nma-ws-sae.ui b/src/nma-ws/nma-ws-sae.ui
index 8f0d0413..89094a18 100644
--- a/src/nma-ws/nma-ws-sae.ui
+++ b/src/nma-ws/nma-ws-sae.ui
@@ -1,98 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="nm-applet">
<requires lib="gtk+" version="3.10"/>
- <object class="GtkNotebook" id="sae_notebook">
+ <template class="NMAWsSae" parent="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="show_tabs">False</property>
- <property name="show_border">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
<child>
- <object class="GtkGrid" id="sae_table">
+ <object class="GtkLabel" id="sae_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">6</property>
- <child>
- <object class="GtkLabel" id="sae_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Password</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">psk_entry</property>
- <property name="xalign">1</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="psk_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="max_length">64</property>
- <property name="visibility">False</property>
- <property name="activates_default">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="sae_type_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Type</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">sae_type_combo</property>
- <property name="xalign">1</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="show_checkbutton_sae">
- <property name="label" translatable="yes">Sho_w password</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="hexpand">True</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="sae_type_combo">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- <child>
- <placeholder/>
- </child>
+ <property name="label" translatable="yes">_Password</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">psk_entry</property>
+ <property name="xalign">1</property>
</object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="psk_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="max_length">64</property>
+ <property name="visibility">False</property>
+ <property name="activates_default">True</property>
+ <property name="width_chars">28</property>
+ <signal name="changed" handler="nma_ws_changed_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="sae_type_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Type</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">sae_type_combo</property>
+ <property name="xalign">1</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="show_checkbutton_sae">
+ <property name="label" translatable="yes">Sho_w password</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="hexpand">True</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="show_toggled_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
</child>
- <child type="tab">
- <object class="GtkLabel" id="GtkLabel2">
+ <child>
+ <object class="GtkComboBox" id="sae_type_combo">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
- <property name="tab_fill">False</property>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
</packing>
</child>
- </object>
+ <child>
+ <placeholder/>
+ </child>
+ </template>
</interface>
diff --git a/src/nma-ws/nma-ws-wep-key.c b/src/nma-ws/nma-ws-wep-key.c
index 221bf8da..6150d282 100644
--- a/src/nma-ws/nma-ws-wep-key.c
+++ b/src/nma-ws/nma-ws-wep-key.c
@@ -1,108 +1,119 @@
// SPDX-License-Identifier: GPL-2.0+
/*
- * Dan Williams <dcbw redhat com>
- *
* Copyright 2007 - 2019 Red Hat, Inc.
*/
#include "nm-default.h"
#include "nma-private.h"
+#include <ctype.h>
#include <string.h>
#include "nma-ws.h"
-#include "utils.h"
-#include "helpers.h"
+#include "nma-ws-private.h"
+#include "nma-ws-wep-key.h"
+#include "nma-ws-helpers.h"
#include "nma-ui-utils.h"
+#include "utils.h"
+
+typedef struct {
+ GtkGridClass parent;
+} NMAWsWepKeyClass;
-struct _NMAWsWEPKey {
- NMAWs parent;
+struct _NMAWsWepKey {
+ GtkGrid parent;
- gboolean editing_connection;
- const char *password_flags_name;
+ GtkWidget *auth_method_combo;
+ GtkWidget *auth_method_label;
+ GtkWidget *key_index_combo;
+ GtkWidget *key_index_label;
+ GtkWidget *show_checkbutton_wep;
+ GtkWidget *wep_key_entry;
+ GtkWidget *wep_key_label;
+
+ NMConnection *connection;
+ gboolean secrets_only;
+ NMWepKeyType adhoc_create;
+ NMWepKeyType key_type;
- NMWepKeyType type;
char keys[4][65];
guint8 cur_index;
};
+static void nma_ws_interface_init (NMAWsInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (NMAWsWepKey, nma_ws_wep_key, GTK_TYPE_GRID,
+ G_IMPLEMENT_INTERFACE (NMA_TYPE_WS, nma_ws_interface_init))
+
+enum {
+ PROP_0,
+ PROP_CONNECTION,
+ PROP_SECRETS_ONLY,
+ PROP_KEY_TYPE,
+ PROP_ADHOC_CREATE,
+ PROP_LAST
+};
+
static void
-show_toggled_cb (GtkCheckButton *button, NMAWs *sec)
+show_toggled_cb (GtkCheckButton *button, gpointer user_data)
{
- GtkWidget *widget;
+ NMAWsWepKey *self = NMA_WS_WEP_KEY (user_data);
gboolean visible;
- widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "wep_key_entry"));
- g_assert (widget);
-
visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
- gtk_entry_set_visibility (GTK_ENTRY (widget), visible);
+ gtk_entry_set_visibility (GTK_ENTRY (self->wep_key_entry), visible);
}
static void
-key_index_combo_changed_cb (GtkWidget *combo, NMAWs *parent)
+key_index_combo_changed_cb (GtkWidget *combo, NMAWs *ws)
{
- NMAWsWEPKey *sec = (NMAWsWEPKey *) parent;
+ NMAWsWepKey *self = NMA_WS_WEP_KEY (ws);
GtkWidget *entry;
const char *key;
int key_index;
/* Save WEP key for old key index */
- entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wep_key_entry"));
+ entry = GTK_WIDGET (self->wep_key_entry);
key = gtk_editable_get_text (GTK_EDITABLE (entry));
if (key)
- g_strlcpy (sec->keys[sec->cur_index], key, sizeof (sec->keys[sec->cur_index]));
+ g_strlcpy (self->keys[self->cur_index], key, sizeof (self->keys[self->cur_index]));
else
- memset (sec->keys[sec->cur_index], 0, sizeof (sec->keys[sec->cur_index]));
+ memset (self->keys[self->cur_index], 0, sizeof (self->keys[self->cur_index]));
key_index = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
g_return_if_fail (key_index <= 3);
g_return_if_fail (key_index >= 0);
/* Populate entry with key from new index */
- gtk_editable_set_text (GTK_EDITABLE (entry), sec->keys[key_index]);
- sec->cur_index = key_index;
+ gtk_editable_set_text (GTK_EDITABLE (entry), self->keys[key_index]);
+ self->cur_index = key_index;
- nma_ws_changed_cb (combo, parent);
-}
-
-static void
-destroy (NMAWs *parent)
-{
- NMAWsWEPKey *sec = (NMAWsWEPKey *) parent;
- int i;
-
- for (i = 0; i < 4; i++)
- memset (sec->keys[i], 0, sizeof (sec->keys[i]));
+ nma_ws_changed_cb (combo, ws);
}
static gboolean
-validate (NMAWs *parent, GError **error)
+validate (NMAWs *ws, GError **error)
{
- NMAWsWEPKey *sec = (NMAWsWEPKey *) parent;
+ NMAWsWepKey *self = NMA_WS_WEP_KEY (ws);
NMSettingSecretFlags secret_flags;
- GtkWidget *entry;
const char *key;
int i;
- entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wep_key_entry"));
- g_assert (entry);
-
- secret_flags = nma_utils_menu_to_secret_flags (entry);
- key = gtk_editable_get_text (GTK_EDITABLE (entry));
+ secret_flags = nma_utils_menu_to_secret_flags (self->wep_key_entry);
+ key = gtk_editable_get_text (GTK_EDITABLE (self->wep_key_entry));
if ( secret_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED
|| secret_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED) {
/* All good. */
} else if (!key) {
- widget_set_error (entry);
+ widget_set_error (self->wep_key_entry);
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("missing wep-key"));
return FALSE;
- } else if (sec->type == NM_WEP_KEY_TYPE_KEY) {
+ } else if (self->key_type == NM_WEP_KEY_TYPE_KEY) {
if ((strlen (key) == 10) || (strlen (key) == 26)) {
for (i = 0; i < strlen (key); i++) {
if (!g_ascii_isxdigit (key[i])) {
- widget_set_error (entry);
+ widget_set_error (self->wep_key_entry);
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wep-key:
key with a length of %zu must contain only hex-digits"), strlen (key));
return FALSE;
}
@@ -110,19 +121,19 @@ validate (NMAWs *parent, GError **error)
} else if ((strlen (key) == 5) || (strlen (key) == 13)) {
for (i = 0; i < strlen (key); i++) {
if (!utils_char_is_ascii_print (key[i])) {
- widget_set_error (entry);
+ widget_set_error (self->wep_key_entry);
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wep-key:
key with a length of %zu must contain only ascii characters"), strlen (key));
return FALSE;
}
}
} else {
- widget_set_error (entry);
+ widget_set_error (self->wep_key_entry);
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wep-key: wrong key
length %zu. A key must be either of length 5/13 (ascii) or 10/26 (hex)"), strlen (key));
return FALSE;
}
- } else if (sec->type == NM_WEP_KEY_TYPE_PASSPHRASE) {
+ } else if (self->key_type == NM_WEP_KEY_TYPE_PASSPHRASE) {
if (!*key || (strlen (key) > 64)) {
- widget_set_error (entry);
+ widget_set_error (self->wep_key_entry);
if (!*key)
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wep-key:
passphrase must be non-empty"));
else
@@ -130,44 +141,34 @@ validate (NMAWs *parent, GError **error)
return FALSE;
}
}
- widget_unset_error (entry);
+ widget_unset_error (self->wep_key_entry);
return TRUE;
}
static void
-add_to_size_group (NMAWs *parent, GtkSizeGroup *group)
+add_to_size_group (NMAWs *ws, GtkSizeGroup *group)
{
- GtkWidget *widget;
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "auth_method_label"));
- gtk_size_group_add_widget (group, widget);
+ NMAWsWepKey *self = NMA_WS_WEP_KEY (ws);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wep_key_label"));
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_index_label"));
- gtk_size_group_add_widget (group, widget);
+ gtk_size_group_add_widget (group, self->auth_method_label);
+ gtk_size_group_add_widget (group, self->wep_key_label);
+ gtk_size_group_add_widget (group, self->key_index_label);
}
static void
-fill_connection (NMAWs *parent, NMConnection *connection)
+fill_connection (NMAWs *ws, NMConnection *connection)
{
- NMAWsWEPKey *sec = (NMAWsWEPKey *) parent;
+ NMAWsWepKey *self = NMA_WS_WEP_KEY (ws);
NMSettingWirelessSecurity *s_wsec;
NMSettingSecretFlags secret_flags;
- GtkWidget *widget, *passwd_entry;
- gint auth_alg;
+ int auth_alg;
const char *key;
int i;
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "auth_method_combo"));
- auth_alg = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wep_key_entry"));
- passwd_entry = widget;
- key = gtk_editable_get_text (GTK_EDITABLE (widget));
- g_strlcpy (sec->keys[sec->cur_index], key, sizeof (sec->keys[sec->cur_index]));
+ auth_alg = gtk_combo_box_get_active (GTK_COMBO_BOX (self->auth_method_combo));
+ key = gtk_editable_get_text (GTK_EDITABLE (self->wep_key_entry));
+ g_strlcpy (self->keys[self->cur_index], key, sizeof (self->keys[self->cur_index]));
/* Blow away the old security setting by adding a clear one */
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
@@ -175,36 +176,38 @@ fill_connection (NMAWs *parent, NMConnection *connection)
g_object_set (s_wsec,
NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none",
- NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, sec->cur_index,
+ NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, self->cur_index,
NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, (auth_alg == 1) ? "shared" : "open",
- NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, sec->type,
+ NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, self->key_type,
NULL);
for (i = 0; i < 4; i++) {
- if (strlen (sec->keys[i]))
- nm_setting_wireless_security_set_wep_key (s_wsec, i, sec->keys[i]);
+ if (strlen (self->keys[i]))
+ nm_setting_wireless_security_set_wep_key (s_wsec, i, self->keys[i]);
}
/* Save WEP_KEY_FLAGS to the connection */
- secret_flags = nma_utils_menu_to_secret_flags (passwd_entry);
+ secret_flags = nma_utils_menu_to_secret_flags (self->wep_key_entry);
g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS, secret_flags, NULL);
/* Update secret flags and popup when editing the connection */
- if (sec->editing_connection)
- nma_utils_update_password_storage (passwd_entry, secret_flags,
- NM_SETTING (s_wsec), sec->password_flags_name);
+ if (!self->secrets_only) {
+ nma_utils_update_password_storage (self->wep_key_entry, secret_flags,
+ NM_SETTING (s_wsec),
+ NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
+ }
}
static void
wep_entry_filter_cb (GtkEditable *editable,
- gchar *text,
- gint length,
- gint *position,
+ char *text,
+ int length,
+ int *position,
gpointer data)
{
- NMAWsWEPKey *sec = (NMAWsWEPKey *) data;
+ NMAWsWepKey *self = NMA_WS_WEP_KEY (data);
- if (sec->type == NM_WEP_KEY_TYPE_KEY) {
+ if (self->key_type == NM_WEP_KEY_TYPE_KEY) {
utils_filter_editable_on_insert_text (editable,
text, length, position, data,
utils_char_is_ascii_print,
@@ -212,12 +215,12 @@ wep_entry_filter_cb (GtkEditable *editable,
}
}
+
static void
-update_secrets (NMAWs *parent, NMConnection *connection)
+update_secrets (NMAWs *ws, NMConnection *connection)
{
- NMAWsWEPKey *sec = (NMAWsWEPKey *) parent;
+ NMAWsWepKey *self = NMA_WS_WEP_KEY (ws);
NMSettingWirelessSecurity *s_wsec;
- GtkEditable *entry;
const char *tmp;
int i;
@@ -225,66 +228,115 @@ update_secrets (NMAWs *parent, NMConnection *connection)
for (i = 0; s_wsec && i < 4; i++) {
tmp = nm_setting_wireless_security_get_wep_key (s_wsec, i);
if (tmp)
- g_strlcpy (sec->keys[i], tmp, sizeof (sec->keys[i]));
+ g_strlcpy (self->keys[i], tmp, sizeof (self->keys[i]));
}
- entry = GTK_EDITABLE (gtk_builder_get_object (parent->builder, "wep_key_entry"));
- if (strlen (sec->keys[sec->cur_index]))
- gtk_editable_set_text (entry, sec->keys[sec->cur_index]);
+ if (strlen (self->keys[self->cur_index])) {
+ gtk_editable_set_text (GTK_EDITABLE (self->wep_key_entry),
+ self->keys[self->cur_index]);
+ }
}
-NMAWsWEPKey *
-nma_ws_wep_key_new (NMConnection *connection,
- NMWepKeyType type,
- gboolean adhoc_create,
- gboolean secrets_only)
+
+static void
+get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ NMAWsWepKey *self = NMA_WS_WEP_KEY (object);
+
+ switch (prop_id) {
+ case PROP_CONNECTION:
+ g_value_set_object (value, self->connection);
+ break;
+ case PROP_SECRETS_ONLY:
+ g_value_set_boolean (value, self->secrets_only);
+ break;
+ case PROP_KEY_TYPE:
+ g_value_set_uint (value, self->key_type);
+ break;
+ case PROP_ADHOC_CREATE:
+ g_value_set_boolean (value, self->adhoc_create);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- NMAWs *parent;
- NMAWsWEPKey *sec;
- GtkWidget *widget;
+ NMAWsWepKey *self = NMA_WS_WEP_KEY (object);
+
+ switch (prop_id) {
+ case PROP_CONNECTION:
+ self->connection = g_value_dup_object (value);
+ break;
+ case PROP_SECRETS_ONLY:
+ self->secrets_only = g_value_get_boolean (value);
+ break;
+ case PROP_KEY_TYPE:
+ self->key_type = g_value_get_uint (value);
+ break;
+ case PROP_ADHOC_CREATE:
+ self->adhoc_create = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+nma_ws_wep_key_init (NMAWsWepKey *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+static void
+nma_ws_interface_init (NMAWsInterface *iface)
+{
+ iface->validate = validate;
+ iface->add_to_size_group = add_to_size_group;
+ iface->fill_connection = fill_connection;
+ iface->update_secrets = update_secrets;
+ iface->adhoc_compatible = TRUE;
+ iface->hotspot_compatible = TRUE;
+}
+
+static void
+constructed (GObject *object)
+{
+ NMAWsWepKey *self = NMA_WS_WEP_KEY (object);
NMSettingWirelessSecurity *s_wsec = NULL;
NMSetting *setting = NULL;
guint8 default_key_idx = 0;
- gboolean is_adhoc = adhoc_create;
+ gboolean is_adhoc = self->adhoc_create;
gboolean is_shared_key = FALSE;
- parent = nma_ws_init (sizeof (NMAWsWEPKey),
- validate,
- add_to_size_group,
- fill_connection,
- update_secrets,
- destroy,
- "/org/gnome/libnma/nma-ws-wep-key.ui",
- "wep_key_notebook",
- "wep_key_entry");
- if (!parent)
- return NULL;
-
- sec = (NMAWsWEPKey *) parent;
- sec->editing_connection = secrets_only ? FALSE : TRUE;
- sec->password_flags_name = NM_SETTING_WIRELESS_SECURITY_WEP_KEY0;
- sec->type = type;
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wep_key_entry"));
- g_assert (widget);
- gtk_editable_set_width_chars (GTK_EDITABLE (widget), 28);
/* Create password-storage popup menu for password entry under entry's secondary icon */
- if (connection)
- setting = (NMSetting *) nm_connection_get_setting_wireless_security (connection);
- nma_utils_setup_password_storage (widget, 0, setting, sec->password_flags_name,
- FALSE, secrets_only);
+ if (self->connection)
+ setting = (NMSetting *) nm_connection_get_setting_wireless_security (self->connection);
+ nma_utils_setup_password_storage (self->wep_key_entry, 0, setting,
+ NM_SETTING_WIRELESS_SECURITY_WEP_KEY0,
+ FALSE, self->secrets_only);
- if (connection) {
+ if (self->connection) {
NMSettingWireless *s_wireless;
const char *mode, *auth_alg;
- s_wireless = nm_connection_get_setting_wireless (connection);
+ s_wireless = nm_connection_get_setting_wireless (self->connection);
mode = s_wireless ? nm_setting_wireless_get_mode (s_wireless) : NULL;
if (mode && !strcmp (mode, "adhoc"))
is_adhoc = TRUE;
- s_wsec = nm_connection_get_setting_wireless_security (connection);
+ s_wsec = nm_connection_get_setting_wireless_security (self->connection);
if (s_wsec) {
auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec);
if (auth_alg && !strcmp (auth_alg, "shared"))
@@ -292,62 +344,114 @@ nma_ws_wep_key_new (NMConnection *connection,
}
}
- g_signal_connect (G_OBJECT (widget), "changed",
- (GCallback) nma_ws_changed_cb,
- sec);
- g_signal_connect (G_OBJECT (widget), "insert-text",
- (GCallback) wep_entry_filter_cb,
- sec);
- if (sec->type == NM_WEP_KEY_TYPE_KEY)
- gtk_entry_set_max_length (GTK_ENTRY (widget), 26);
- else if (sec->type == NM_WEP_KEY_TYPE_PASSPHRASE)
- gtk_entry_set_max_length (GTK_ENTRY (widget), 64);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_index_combo"));
- if (connection && s_wsec)
+ if (self->key_type == NM_WEP_KEY_TYPE_KEY)
+ gtk_entry_set_max_length (GTK_ENTRY (self->wep_key_entry), 26);
+ else if (self->key_type == NM_WEP_KEY_TYPE_PASSPHRASE)
+ gtk_entry_set_max_length (GTK_ENTRY (self->wep_key_entry), 64);
+
+ if (self->connection && s_wsec)
default_key_idx = nm_setting_wireless_security_get_wep_tx_keyidx (s_wsec);
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), default_key_idx);
- sec->cur_index = default_key_idx;
- g_signal_connect (G_OBJECT (widget), "changed",
- (GCallback) key_index_combo_changed_cb,
- sec);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (self->key_index_combo), default_key_idx);
+ self->cur_index = default_key_idx;
/* Key index is useless with adhoc networks */
- if (is_adhoc || secrets_only) {
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_index_label"));
- gtk_widget_hide (widget);
+ if (is_adhoc || self->secrets_only) {
+ gtk_widget_hide (self->key_index_combo);
+ gtk_widget_hide (self->key_index_label);
}
/* Fill the key entry with the key for that index */
- if (connection)
- update_secrets (NMA_WS (sec), connection);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_wep"));
- g_assert (widget);
- g_signal_connect (G_OBJECT (widget), "toggled",
- (GCallback) show_toggled_cb,
- sec);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "auth_method_combo"));
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), is_shared_key ? 1 : 0);
+ if (self->connection)
+ update_secrets (NMA_WS (self), self->connection);
- g_signal_connect (G_OBJECT (widget), "changed",
- (GCallback) nma_ws_changed_cb,
- sec);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (self->auth_method_combo),
+ is_shared_key ? 1 : 0);
/* Don't show auth method for adhoc (which always uses open-system) or
* when in "simple" mode.
*/
- if (is_adhoc || secrets_only) {
+ if (is_adhoc || self->secrets_only) {
/* Ad-Hoc connections can't use Shared Key auth */
if (is_adhoc)
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "auth_method_label"));
- gtk_widget_hide (widget);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (self->auth_method_combo), 0);
+ gtk_widget_hide (self->auth_method_combo);
+ gtk_widget_hide (self->auth_method_label);
}
- return sec;
+ gtk_widget_grab_focus (self->wep_key_entry);
+
+ G_OBJECT_CLASS (nma_ws_wep_key_parent_class)->constructed (object);
+}
+
+NMAWsWepKey *
+nma_ws_wep_key_new (NMConnection *connection,
+ NMWepKeyType key_type,
+ gboolean adhoc_create,
+ gboolean secrets_only)
+{
+ return g_object_new (NMA_TYPE_WS_WEP_KEY,
+ "connection", connection,
+ "key-type", key_type,
+ "adhoc-create", adhoc_create,
+ "secrets-only", secrets_only,
+ NULL);
+}
+
+static void
+dispose (GObject *object)
+{
+ NMAWsWepKey *self = NMA_WS_WEP_KEY (object);
+
+ g_clear_object (&self->connection);
+}
+
+static void
+nma_ws_wep_key_class_init (NMAWsWepKeyClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->get_property = get_property;
+ object_class->set_property = set_property;
+ object_class->constructed = constructed;
+ object_class->dispose = dispose;
+
+ g_object_class_override_property (object_class,
+ PROP_CONNECTION, "connection");
+
+ g_object_class_override_property (object_class,
+ PROP_SECRETS_ONLY, "secrets-only");
+
+ g_object_class_install_property
+ (object_class, PROP_KEY_TYPE,
+ g_param_spec_uint ("key-type", "", "",
+ 0, G_MAXUINT, 0,
+ G_PARAM_READWRITE
+ | G_PARAM_CONSTRUCT
+ | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property
+ (object_class, PROP_ADHOC_CREATE,
+ g_param_spec_boolean ("adhoc-create", "", "",
+ FALSE,
+ G_PARAM_READWRITE
+ | G_PARAM_CONSTRUCT
+ | G_PARAM_STATIC_STRINGS));
+
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/libnma/nma-ws-wep-key.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, NMAWsWepKey, auth_method_combo);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsWepKey, auth_method_label);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsWepKey, key_index_combo);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsWepKey, key_index_label);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsWepKey, show_checkbutton_wep);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsWepKey, wep_key_entry);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsWepKey, wep_key_label);
+
+ gtk_widget_class_bind_template_callback (widget_class, key_index_combo_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, nma_ws_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, show_toggled_cb);
+ gtk_widget_class_bind_template_callback (widget_class, wep_entry_filter_cb);
}
diff --git a/src/nma-ws/nma-ws-wep-key.h b/src/nma-ws/nma-ws-wep-key.h
index 98ecb111..1fd5e32b 100644
--- a/src/nma-ws/nma-ws-wep-key.h
+++ b/src/nma-ws/nma-ws-wep-key.h
@@ -5,14 +5,23 @@
* Copyright 2007 - 2019 Red Hat, Inc.
*/
-#ifndef WS_WEP_KEY_H
-#define WS_WEP_KEY_H
+#ifndef NMA_WS_WEP_KEY_H
+#define NMA_WS_WEP_KEY_H
-typedef struct _NMAWsWEPKey NMAWsWEPKey;
+typedef struct _NMAWsWepKey NMAWsWepKey;
-NMAWsWEPKey *nma_ws_wep_key_new (NMConnection *connection,
+#define NMA_TYPE_WS_WEP_KEY (nma_ws_wep_key_get_type ())
+#define NMA_WS_WEP_KEY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_WS_WEP_KEY, NMAWsWepKey))
+#define NMA_WS_WEP_KEY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_WS_WEP_KEY,
NMAWsWepKeyClass))
+#define NMA_IS_WS_WEP_KEY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_WS_WEP_KEY))
+#define NMA_IS_WS_WEP_KEY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_WS_WEP_KEY))
+#define NMA_WS_WEP_KEY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_WS_WEP_KEY,
NMAWsWepKeyClass))
+
+GType nma_ws_wep_key_get_type (void);
+
+NMAWsWepKey *nma_ws_wep_key_new (NMConnection *connection,
NMWepKeyType type,
gboolean adhoc_create,
gboolean secrets_only);
-#endif /* WS_WEP_KEY_H */
+#endif /* NMA_WS_WEP_KEY_H */
diff --git a/src/nma-ws/nma-ws-wep-key.ui b/src/nma-ws/nma-ws-wep-key.ui
index 44ccd180..f3e627d1 100644
--- a/src/nma-ws/nma-ws-wep-key.ui
+++ b/src/nma-ws/nma-ws-wep-key.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="nm-applet">
<requires lib="gtk+" version="3.10"/>
<object class="GtkListStore" id="model3">
@@ -36,137 +36,126 @@
</row>
</data>
</object>
- <object class="GtkNotebook" id="wep_key_notebook">
+ <template class="NMAWsWepKey" parent="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="show_tabs">False</property>
- <property name="show_border">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
<child>
- <object class="GtkGrid" id="table6">
+ <object class="GtkLabel" id="wep_key_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">6</property>
- <child>
- <object class="GtkLabel" id="wep_key_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Key</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">wep_key_entry</property>
- <property name="xalign">1</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="wep_key_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="max_length">64</property>
- <property name="visibility">False</property>
- <property name="activates_default">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="show_checkbutton_wep">
- <property name="label" translatable="yes">Sho_w key</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="hexpand">True</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="auth_method_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Au_thentication</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">auth_method_combo</property>
- <property name="xalign">1</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="auth_method_combo">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="model">model3</property>
- <child>
- <object class="GtkCellRendererText" id="renderer3"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="key_index_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">WEP inde_x</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">key_index_combo</property>
- <property name="xalign">1</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="key_index_combo">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="model">model4</property>
- <child>
- <object class="GtkCellRendererText" id="renderer4"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
+ <property name="label" translatable="yes">_Key</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">wep_key_entry</property>
+ <property name="xalign">1</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="wep_key_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="max_length">64</property>
+ <property name="visibility">False</property>
+ <property name="activates_default">True</property>
+ <property name="width_chars">28</property>
+ <signal name="changed" handler="nma_ws_changed_cb" swapped="no"/>
+ <signal name="insert-text" handler="wep_entry_filter_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="show_checkbutton_wep">
+ <property name="label" translatable="yes">Sho_w key</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="hexpand">True</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="show_toggled_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="auth_method_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Au_thentication</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">auth_method_combo</property>
+ <property name="xalign">1</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="auth_method_combo">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="model">model3</property>
<child>
- <placeholder/>
+ <object class="GtkCellRendererText" id="renderer3"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
</child>
+ <signal name="changed" handler="nma_ws_changed_cb" swapped="no"/>
</object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ </packing>
</child>
- <child type="tab">
- <object class="GtkLabel" id="label23">
+ <child>
+ <object class="GtkLabel" id="key_index_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="label" translatable="yes">WEP inde_x</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">key_index_combo</property>
+ <property name="xalign">1</property>
</object>
<packing>
- <property name="tab_fill">False</property>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
</packing>
</child>
- </object>
+ <child>
+ <object class="GtkComboBox" id="key_index_combo">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="model">model4</property>
+ <child>
+ <object class="GtkCellRendererText" id="renderer4"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ <signal name="changed" handler="key_index_combo_changed_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </template>
</interface>
diff --git a/src/nma-ws/nma-ws-wpa-eap.c b/src/nma-ws/nma-ws-wpa-eap.c
index 81193840..a9f09f99 100644
--- a/src/nma-ws/nma-ws-wpa-eap.c
+++ b/src/nma-ws/nma-ws-wpa-eap.c
@@ -4,116 +4,67 @@
*
* Copyright 2007 - 2019 Red Hat, Inc.
*/
-
#include "nm-default.h"
-
-#include <ctype.h>
-#include <string.h>
+#include "nma-private.h"
#include "nma-ws.h"
-#include "nma-eap.h"
+#include "nma-ws-private.h"
+#include "nma-ws-802-1x.h"
+#include "nma-ws-802-1x-private.h"
+#include "nma-ws-wpa-eap.h"
-struct _NMAWsWPAEAP {
- NMAWs parent;
+typedef struct {
+ NMAWs8021xClass parent;
+} NMAWsWpaEapClass;
- GtkSizeGroup *size_group;
+struct _NMAWsWpaEap {
+ NMAWs8021x parent;
};
+static void nma_ws_interface_init (NMAWsInterface *iface);
-static void
-destroy (NMAWs *parent)
-{
- NMAWsWPAEAP *sec = (NMAWsWPAEAP *) parent;
-
- if (sec->size_group)
- g_object_unref (sec->size_group);
-}
-
-static gboolean
-validate (NMAWs *parent, GError **error)
-{
- return nma_ws_802_1x_validate (parent, "wpa_eap_auth_combo", error);
-}
-
-static void
-add_to_size_group (NMAWs *parent, GtkSizeGroup *group)
-{
- NMAWsWPAEAP *sec = (NMAWsWPAEAP *) parent;
-
- if (sec->size_group)
- g_object_unref (sec->size_group);
- sec->size_group = g_object_ref (group);
-
- nma_ws_802_1x_add_to_size_group (parent,
- sec->size_group,
- "wpa_eap_auth_label",
- "wpa_eap_auth_combo");
-}
+G_DEFINE_TYPE_WITH_CODE (NMAWsWpaEap, nma_ws_wpa_eap, NMA_TYPE_WS_802_1X,
+ G_IMPLEMENT_INTERFACE (NMA_TYPE_WS, nma_ws_interface_init))
static void
-fill_connection (NMAWs *parent, NMConnection *connection)
+fill_connection (NMAWs *ws, NMConnection *connection)
{
NMSettingWirelessSecurity *s_wireless_sec;
- nma_ws_802_1x_fill_connection (parent, "wpa_eap_auth_combo", connection);
+ nma_ws_802_1x_fill_connection (ws, connection);
s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
- g_assert (s_wireless_sec);
+ g_return_if_fail (s_wireless_sec);
g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap", NULL);
}
static void
-auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
+nma_ws_wpa_eap_init (NMAWsWpaEap *self)
{
- NMAWs *parent = NMA_WS (user_data);
- NMAWsWPAEAP *sec = (NMAWsWPAEAP *) parent;
-
- nma_ws_802_1x_auth_combo_changed (combo,
- parent,
- "wpa_nma_eap_vbox",
- sec->size_group);
}
static void
-update_secrets (NMAWs *parent, NMConnection *connection)
+nma_ws_interface_init (NMAWsInterface *iface)
{
- nma_ws_802_1x_update_secrets (parent, "wpa_eap_auth_combo", connection);
+ iface->fill_connection = fill_connection;
}
-NMAWsWPAEAP *
+NMAWsWpaEap *
nma_ws_wpa_eap_new (NMConnection *connection,
- gboolean is_editor,
- gboolean secrets_only,
- const char *const*secrets_hints)
+ gboolean is_editor,
+ gboolean secrets_only,
+ const char *const*secrets_hints)
{
- NMAWs *parent;
- GtkWidget *widget;
-
- parent = nma_ws_init (sizeof (NMAWsWPAEAP),
- validate,
- add_to_size_group,
- fill_connection,
- update_secrets,
- destroy,
- "/org/gnome/libnma/nma-ws-wpa-eap.ui",
- "wpa_eap_notebook",
- NULL);
- if (!parent)
- return NULL;
-
- parent->adhoc_compatible = FALSE;
- parent->hotspot_compatible = FALSE;
-
- widget = nma_ws_802_1x_auth_combo_init (parent,
- "wpa_eap_auth_combo",
- "wpa_eap_auth_label",
- (GCallback) auth_combo_changed_cb,
- connection,
- is_editor,
- secrets_only,
- secrets_hints);
- auth_combo_changed_cb (widget, parent);
+ return g_object_new (NMA_TYPE_WS_WPA_EAP,
+ "connection", connection,
+ "secrets-only", secrets_only,
+ "is-editor", is_editor,
+ "secrets-hints", secrets_hints,
+ NULL);
+}
- return (NMAWsWPAEAP *) parent;
+static void
+nma_ws_wpa_eap_class_init (NMAWsWpaEapClass *klass)
+{
}
diff --git a/src/nma-ws/nma-ws-wpa-eap.h b/src/nma-ws/nma-ws-wpa-eap.h
index e3b39beb..27dd846f 100644
--- a/src/nma-ws/nma-ws-wpa-eap.h
+++ b/src/nma-ws/nma-ws-wpa-eap.h
@@ -5,14 +5,23 @@
* Copyright 2007 - 2019 Red Hat, Inc.
*/
-#ifndef WS_WPA_EAP_H
-#define WS_WPA_EAP_H
+#ifndef NMA_WS_WPA_EAP_H
+#define NMA_WS_WPA_EAP_H
-typedef struct _NMAWsWPAEAP NMAWsWPAEAP;
+typedef struct _NMAWsWpaEap NMAWsWpaEap;
-NMAWsWPAEAP *nma_ws_wpa_eap_new (NMConnection *connection,
+#define NMA_TYPE_WS_WPA_EAP (nma_ws_wpa_eap_get_type ())
+#define NMA_WS_WPA_EAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_WS_SAE, NMAWsWpaEap))
+#define NMA_WS_WPA_EAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_WS_SAE, NMAWsWpaEapClass))
+#define NMA_IS_WS_WPA_EAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_WS_SAE))
+#define NMA_IS_WS_WPA_EAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_WS_SAE))
+#define NMA_WS_WPA_EAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_WS_SAE, NMAWsWpaEapClass))
+
+GType nma_ws_wpa_eap_get_type (void);
+
+NMAWsWpaEap *nma_ws_wpa_eap_new (NMConnection *connection,
gboolean is_editor,
gboolean secrets_only,
const char *const*secrets_hints);
-#endif /* WS_WPA_EAP_H */
+#endif /* NMA_WS_WPA_EAP_H */
diff --git a/src/nma-ws/nma-ws-wpa-psk.c b/src/nma-ws/nma-ws-wpa-psk.c
index d3a8aab1..a161243f 100644
--- a/src/nma-ws/nma-ws-wpa-psk.c
+++ b/src/nma-ws/nma-ws-wpa-psk.c
@@ -12,66 +12,84 @@
#include <string.h>
#include "nma-ws.h"
-#include "helpers.h"
+#include "nma-ws-private.h"
+#include "nma-ws-wpa-psk.h"
+#include "nma-ws-helpers.h"
#include "nma-ui-utils.h"
#include "utils.h"
#define WPA_PMK_LEN 32
-struct _NMAWsWPAPSK {
- NMAWs parent;
+typedef struct {
+ GtkGridClass parent;
+} NMAWsWpaPskClass;
- gboolean editing_connection;
- const char *password_flags_name;
+struct _NMAWsWpaPsk {
+ GtkGrid parent;
+
+ GtkWidget *wpa_psk_entry;
+ GtkWidget *wpa_psk_label;
+ GtkWidget *wpa_psk_type_combo;
+ GtkWidget *wpa_psk_type_label;
+ GtkWidget *show_checkbutton_wpa;
+
+ NMConnection *connection;
+ gboolean secrets_only;
+};
+
+static void nma_ws_interface_init (NMAWsInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (NMAWsWpaPsk, nma_ws_wpa_psk, GTK_TYPE_GRID,
+ G_IMPLEMENT_INTERFACE (NMA_TYPE_WS, nma_ws_interface_init))
+
+enum {
+ PROP_0,
+ PROP_CONNECTION,
+ PROP_SECRETS_ONLY,
+ PROP_LAST
};
static void
-show_toggled_cb (GtkCheckButton *button, NMAWs *sec)
+show_toggled_cb (GtkCheckButton *button, gpointer user_data)
{
- GtkWidget *widget;
+ NMAWsWpaPsk *self = NMA_WS_WPA_PSK (user_data);
gboolean visible;
- widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "wpa_psk_entry"));
- g_assert (widget);
-
visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
- gtk_entry_set_visibility (GTK_ENTRY (widget), visible);
+ gtk_entry_set_visibility (GTK_ENTRY (self->wpa_psk_entry), visible);
}
static gboolean
-validate (NMAWs *parent, GError **error)
+validate (NMAWs *ws, GError **error)
{
- GtkWidget *entry;
+ NMAWsWpaPsk *self = NMA_WS_WPA_PSK (ws);
NMSettingSecretFlags secret_flags;
const char *key;
gsize len;
int i;
- entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wpa_psk_entry"));
- g_assert (entry);
-
- secret_flags = nma_utils_menu_to_secret_flags (entry);
- key = gtk_editable_get_text (GTK_EDITABLE (entry));
+ secret_flags = nma_utils_menu_to_secret_flags (self->wpa_psk_entry);
+ key = gtk_editable_get_text (GTK_EDITABLE (self->wpa_psk_entry));
len = key ? strlen (key) : 0;
if ( secret_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED
|| secret_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED) {
/* All good. */
} else if ((len < 8) || (len > 64)) {
- widget_set_error (entry);
+ widget_set_error (self->wpa_psk_entry);
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wpa-psk: invalid key-length %zu.
Must be [8,63] bytes or 64 hex digits"), len);
return FALSE;
} else if (len == 64) {
/* Hex PSK */
for (i = 0; i < len; i++) {
if (!isxdigit (key[i])) {
- widget_set_error (entry);
+ widget_set_error (self->wpa_psk_entry);
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wpa-psk:
cannot interpret key with 64 bytes as hex"));
return FALSE;
}
}
}
- widget_unset_error (entry);
+ widget_unset_error (self->wpa_psk_entry);
/* passphrase can be between 8 and 63 characters inclusive */
@@ -79,22 +97,18 @@ validate (NMAWs *parent, GError **error)
}
static void
-add_to_size_group (NMAWs *parent, GtkSizeGroup *group)
+add_to_size_group (NMAWs *ws, GtkSizeGroup *group)
{
- GtkWidget *widget;
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wpa_psk_type_label"));
- gtk_size_group_add_widget (group, widget);
+ NMAWsWpaPsk *self = NMA_WS_WPA_PSK (ws);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wpa_psk_label"));
- gtk_size_group_add_widget (group, widget);
+ gtk_size_group_add_widget (group, self->wpa_psk_type_label);
+ gtk_size_group_add_widget (group, self->wpa_psk_label);
}
static void
-fill_connection (NMAWs *parent, NMConnection *connection)
+fill_connection (NMAWs *ws, NMConnection *connection)
{
- NMAWsWPAPSK *wpa_psk = (NMAWsWPAPSK *) parent;
- GtkWidget *widget, *passwd_entry;
+ NMAWsWpaPsk *self = NMA_WS_WPA_PSK (ws);
const char *key;
NMSettingWireless *s_wireless;
NMSettingWirelessSecurity *s_wireless_sec;
@@ -103,7 +117,7 @@ fill_connection (NMAWs *parent, NMConnection *connection)
gboolean is_adhoc = FALSE;
s_wireless = nm_connection_get_setting_wireless (connection);
- g_assert (s_wireless);
+ g_return_if_fail (s_wireless);
mode = nm_setting_wireless_get_mode (s_wireless);
if (mode && !strcmp (mode, "adhoc"))
@@ -113,20 +127,20 @@ fill_connection (NMAWs *parent, NMConnection *connection)
s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
nm_connection_add_setting (connection, (NMSetting *) s_wireless_sec);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wpa_psk_entry"));
- passwd_entry = widget;
- key = gtk_editable_get_text (GTK_EDITABLE (widget));
+ key = gtk_editable_get_text (GTK_EDITABLE (self->wpa_psk_entry));
g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_PSK, key, NULL);
/* Save PSK_FLAGS to the connection */
- secret_flags = nma_utils_menu_to_secret_flags (passwd_entry);
+ secret_flags = nma_utils_menu_to_secret_flags (self->wpa_psk_entry);
nm_setting_set_secret_flags (NM_SETTING (s_wireless_sec), NM_SETTING_WIRELESS_SECURITY_PSK,
secret_flags, NULL);
/* Update secret flags and popup when editing the connection */
- if (wpa_psk->editing_connection)
- nma_utils_update_password_storage (passwd_entry, secret_flags,
- NM_SETTING (s_wireless_sec), wpa_psk->password_flags_name);
+ if (!self->secrets_only) {
+ nma_utils_update_password_storage (self->wpa_psk_entry, secret_flags,
+ NM_SETTING (s_wireless_sec),
+ NM_SETTING_WIRELESS_SECURITY_PSK);
+ }
nma_ws_clear_ciphers (connection);
if (is_adhoc) {
@@ -145,74 +159,145 @@ fill_connection (NMAWs *parent, NMConnection *connection)
}
static void
-update_secrets (NMAWs *parent, NMConnection *connection)
+update_secrets (NMAWs *ws, NMConnection *connection)
{
- helper_fill_secret_entry (connection,
- parent->builder,
- "wpa_psk_entry",
- NM_TYPE_SETTING_WIRELESS_SECURITY,
- (HelperSecretFunc) nm_setting_wireless_security_get_psk);
+ NMAWsWpaPsk *self = NMA_WS_WPA_PSK (ws);
+
+ nma_ws_helper_fill_secret_entry (connection,
+ GTK_EDITABLE (self->wpa_psk_entry),
+ NM_TYPE_SETTING_WIRELESS_SECURITY,
+ (HelperSecretFunc) nm_setting_wireless_security_get_psk);
}
-NMAWsWPAPSK *
-nma_ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only)
+static void
+get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ NMAWsWpaPsk *self = NMA_WS_WPA_PSK (object);
+
+ switch (prop_id) {
+ case PROP_CONNECTION:
+ g_value_set_object (value, self->connection);
+ break;
+ case PROP_SECRETS_ONLY:
+ g_value_set_boolean (value, self->secrets_only);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ NMAWsWpaPsk *self = NMA_WS_WPA_PSK (object);
+
+ switch (prop_id) {
+ case PROP_CONNECTION:
+ self->connection = g_value_dup_object (value);
+ break;
+ case PROP_SECRETS_ONLY:
+ self->secrets_only = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+nma_ws_wpa_psk_init (NMAWsWpaPsk *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+static void
+nma_ws_interface_init (NMAWsInterface *iface)
+{
+ iface->validate = validate;
+ iface->add_to_size_group = add_to_size_group;
+ iface->fill_connection = fill_connection;
+ iface->update_secrets = update_secrets;
+ iface->adhoc_compatible = TRUE;
+ iface->hotspot_compatible = TRUE;
+}
+
+static void
+constructed (GObject *object)
{
- NMAWs *parent;
- NMAWsWPAPSK *sec;
+ NMAWsWpaPsk *self = NMA_WS_WPA_PSK (object);
NMSetting *setting = NULL;
- GtkWidget *widget;
-
- parent = nma_ws_init (sizeof (NMAWsWPAPSK),
- validate,
- add_to_size_group,
- fill_connection,
- update_secrets,
- NULL,
- "/org/gnome/libnma/nma-ws-wpa-psk.ui",
- "wpa_psk_notebook",
- "wpa_psk_entry");
- if (!parent)
- return NULL;
-
- parent->adhoc_compatible = TRUE;
- sec = (NMAWsWPAPSK *) parent;
- sec->editing_connection = secrets_only ? FALSE : TRUE;
- sec->password_flags_name = NM_SETTING_WIRELESS_SECURITY_PSK;
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wpa_psk_entry"));
- g_assert (widget);
- g_signal_connect (G_OBJECT (widget), "changed",
- (GCallback) nma_ws_changed_cb,
- sec);
- gtk_editable_set_width_chars (GTK_EDITABLE (widget), 28);
/* Create password-storage popup menu for password entry under entry's secondary icon */
- if (connection)
- setting = (NMSetting *) nm_connection_get_setting_wireless_security (connection);
- nma_utils_setup_password_storage (widget, 0, setting, sec->password_flags_name,
- FALSE, secrets_only);
+ if (self->connection)
+ setting = (NMSetting *) nm_connection_get_setting_wireless_security (self->connection);
+ nma_utils_setup_password_storage (self->wpa_psk_entry, 0, setting, NM_SETTING_WIRELESS_SECURITY_PSK,
+ FALSE, self->secrets_only);
/* Fill secrets, if any */
- if (connection)
- update_secrets (NMA_WS (sec), connection);
+ if (self->connection)
+ update_secrets (NMA_WS (self), self->connection);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_wpa"));
- g_assert (widget);
- g_signal_connect (G_OBJECT (widget), "toggled",
- (GCallback) show_toggled_cb,
- sec);
+ gtk_widget_grab_focus (self->wpa_psk_entry);
/* Hide WPA/RSN for now since this can be autodetected by NM and the
* supplicant when connecting to the AP.
*/
+ gtk_widget_hide (self->wpa_psk_type_combo);
+ gtk_widget_hide (self->wpa_psk_type_label);
+
+ G_OBJECT_CLASS (nma_ws_wpa_psk_parent_class)->constructed (object);
+}
+
+NMAWsWpaPsk *
+nma_ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only)
+{
+ return g_object_new (NMA_TYPE_WS_WPA_PSK,
+ "connection", connection,
+ "secrets-only", secrets_only,
+ NULL);
+}
+
+static void
+dispose (GObject *object)
+{
+ NMAWsWpaPsk *self = NMA_WS_WPA_PSK (object);
+
+ g_clear_object (&self->connection);
+}
+
+static void
+nma_ws_wpa_psk_class_init (NMAWsWpaPskClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->get_property = get_property;
+ object_class->set_property = set_property;
+ object_class->constructed = constructed;
+ object_class->dispose = dispose;
+
+ g_object_class_override_property (object_class,
+ PROP_CONNECTION, "connection");
+
+ g_object_class_override_property (object_class,
+ PROP_SECRETS_ONLY, "secrets-only");
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wpa_psk_type_combo"));
- g_assert (widget);
- gtk_widget_hide (widget);
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/libnma/nma-ws-wpa-psk.ui");
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wpa_psk_type_label"));
- g_assert (widget);
- gtk_widget_hide (widget);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsWpaPsk, wpa_psk_entry);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsWpaPsk, wpa_psk_label);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsWpaPsk, wpa_psk_type_combo);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsWpaPsk, wpa_psk_type_label);
+ gtk_widget_class_bind_template_child (widget_class, NMAWsWpaPsk, show_checkbutton_wpa);
- return sec;
+ gtk_widget_class_bind_template_callback (widget_class, nma_ws_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, show_toggled_cb);
}
diff --git a/src/nma-ws/nma-ws-wpa-psk.h b/src/nma-ws/nma-ws-wpa-psk.h
index 216853dd..b72a57ea 100644
--- a/src/nma-ws/nma-ws-wpa-psk.h
+++ b/src/nma-ws/nma-ws-wpa-psk.h
@@ -5,11 +5,20 @@
* Copyright 2007 - 2019 Red Hat, Inc.
*/
-#ifndef WS_WPA_PSK_H
-#define WS_WPA_PSK_H
+#ifndef NMA_WS_WPA_PSK_H
+#define NMA_WS_WPA_PSK_H
-typedef struct _NMAWsWPAPSK NMAWsWPAPSK;
+typedef struct _NMAWsWpaPsk NMAWsWpaPsk;
-NMAWsWPAPSK *nma_ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only);
+#define NMA_TYPE_WS_WPA_PSK (nma_ws_wpa_psk_get_type ())
+#define NMA_WS_WPA_PSK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_WS_WPA_PSK, NMAWsWpaPsk))
+#define NMA_WS_WPA_PSK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_WS_WPA_PSK,
NMAWsWpaPskClass))
+#define NMA_IS_WS_WPA_PSK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_WS_WPA_PSK))
+#define NMA_IS_WS_WPA_PSK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_WS_WPA_PSK))
+#define NMA_WS_WPA_PSK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_WS_WPA_PSK,
NMAWsWpaPskClass))
-#endif /* WS_WEP_KEY_H */
+GType nma_ws_wpa_psk_get_type (void);
+
+NMAWsWpaPsk *nma_ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only);
+
+#endif /* NMA_WS_WPA_PSK_H */
diff --git a/src/nma-ws/nma-ws-wpa-psk.ui b/src/nma-ws/nma-ws-wpa-psk.ui
index ace15468..17732468 100644
--- a/src/nma-ws/nma-ws-wpa-psk.ui
+++ b/src/nma-ws/nma-ws-wpa-psk.ui
@@ -1,98 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="nm-applet">
<requires lib="gtk+" version="3.10"/>
- <object class="GtkNotebook" id="wpa_psk_notebook">
+ <template class="NMAWsWpaPsk" parent="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="show_tabs">False</property>
- <property name="show_border">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
<child>
- <object class="GtkGrid" id="wpa_psk_table">
+ <object class="GtkLabel" id="wpa_psk_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">6</property>
- <child>
- <object class="GtkLabel" id="wpa_psk_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Password</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">wpa_psk_entry</property>
- <property name="xalign">1</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="wpa_psk_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="max_length">64</property>
- <property name="visibility">False</property>
- <property name="activates_default">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="wpa_psk_type_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Type</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">wpa_psk_type_combo</property>
- <property name="xalign">1</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="show_checkbutton_wpa">
- <property name="label" translatable="yes">Sho_w password</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="hexpand">True</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="wpa_psk_type_combo">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- <child>
- <placeholder/>
- </child>
+ <property name="label" translatable="yes">_Password</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">wpa_psk_entry</property>
+ <property name="xalign">1</property>
</object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="wpa_psk_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="max_length">64</property>
+ <property name="visibility">False</property>
+ <property name="activates_default">True</property>
+ <signal name="changed" handler="nma_ws_changed_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="wpa_psk_type_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Type</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">wpa_psk_type_combo</property>
+ <property name="xalign">1</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="show_checkbutton_wpa">
+ <property name="label" translatable="yes">Sho_w password</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="hexpand">True</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="show_toggled_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
</child>
- <child type="tab">
- <object class="GtkLabel" id="GtkLabel2">
+ <child>
+ <object class="GtkComboBox" id="wpa_psk_type_combo">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
- <property name="tab_fill">False</property>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
</packing>
</child>
- </object>
+ <child>
+ <placeholder/>
+ </child>
+ </template>
</interface>
diff --git a/src/nma-ws/nma-ws.c b/src/nma-ws/nma-ws.c
index 9f0cb94d..1861f822 100644
--- a/src/nma-ws/nma-ws.c
+++ b/src/nma-ws/nma-ws.c
@@ -10,236 +10,119 @@
#include <string.h>
#include "nma-ws.h"
+#include "nma-ws-private.h"
#include "nma-eap.h"
#include "utils.h"
-G_DEFINE_BOXED_TYPE (NMAWs, nma_ws, nma_ws_ref, nma_ws_unref)
-
-GtkWidget *
-nma_ws_get_widget (NMAWs *sec)
-{
- g_return_val_if_fail (sec != NULL, NULL);
-
- return sec->ui_widget;
-}
-
-void
-nma_ws_set_changed_notify (NMAWs *sec,
- NMAWsChangedFunc func,
- gpointer user_data)
-{
- g_return_if_fail (sec != NULL);
-
- sec->changed_notify = func;
- sec->changed_notify_data = user_data;
-}
+G_DEFINE_INTERFACE (NMAWs, nma_ws, G_TYPE_OBJECT)
void
nma_ws_changed_cb (GtkWidget *ignored, gpointer user_data)
{
- NMAWs *sec = NMA_WS (user_data);
-
- if (sec->changed_notify)
- (*(sec->changed_notify)) (sec, sec->changed_notify_data);
+ g_signal_emit_by_name (user_data, "ws-changed");
}
gboolean
-nma_ws_validate (NMAWs *sec, GError **error)
+nma_ws_validate (NMAWs *self, GError **error)
{
+ NMAWsInterface *iface;
gboolean result;
- g_return_val_if_fail (sec != NULL, FALSE);
+ g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (!error || !*error, FALSE);
- g_assert (sec->validate);
- result = (*(sec->validate)) (sec, error);
+ iface = NMA_WS_GET_INTERFACE (self);
+ g_return_val_if_fail (iface->validate, FALSE);
+ result = (*(iface->validate)) (self, error);
if (!result && error && !*error)
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Unknown error validating 802.1X
security"));
return result;
}
void
-nma_ws_add_to_size_group (NMAWs *sec, GtkSizeGroup *group)
+nma_ws_add_to_size_group (NMAWs *self, GtkSizeGroup *group)
{
- g_return_if_fail (sec != NULL);
+ NMAWsInterface *iface;
+
+ g_return_if_fail (self != NULL);
g_return_if_fail (group != NULL);
- g_assert (sec->add_to_size_group);
- return (*(sec->add_to_size_group)) (sec, group);
+ iface = NMA_WS_GET_INTERFACE (self);
+ g_return_if_fail (iface->add_to_size_group);
+ return (*(iface->add_to_size_group)) (self, group);
}
void
-nma_ws_fill_connection (NMAWs *sec,
+nma_ws_fill_connection (NMAWs *self,
NMConnection *connection)
{
- g_return_if_fail (sec != NULL);
- g_return_if_fail (connection != NULL);
-
- g_assert (sec->fill_connection);
- return (*(sec->fill_connection)) (sec, connection);
-}
+ NMAWsInterface *iface;
-void
-nma_ws_update_secrets (NMAWs *sec, NMConnection *connection)
-{
- g_return_if_fail (sec != NULL);
+ g_return_if_fail (self != NULL);
g_return_if_fail (connection != NULL);
- if (sec->update_secrets)
- sec->update_secrets (sec, connection);
-}
-
-NMAWs *
-nma_ws_ref (NMAWs *sec)
-{
- g_return_val_if_fail (sec != NULL, NULL);
- g_return_val_if_fail (sec->refcount > 0, NULL);
-
- sec->refcount++;
- return sec;
+ iface = NMA_WS_GET_INTERFACE (self);
+ g_return_if_fail (iface->fill_connection);
+ return (*(iface->fill_connection)) (self, connection);
}
void
-nma_ws_unref (NMAWs *sec)
+nma_ws_update_secrets (NMAWs *self, NMConnection *connection)
{
- g_return_if_fail (sec != NULL);
- g_return_if_fail (sec->refcount > 0);
-
- sec->refcount--;
- if (sec->refcount == 0) {
- if (sec->destroy)
- sec->destroy (sec);
+ NMAWsInterface *iface;
- g_free (sec->username);
- if (sec->password) {
- memset (sec->password, 0, strlen (sec->password));
- g_free (sec->password);
- }
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (connection != NULL);
- if (sec->builder)
- g_object_unref (sec->builder);
- if (sec->ui_widget)
- g_object_unref (sec->ui_widget);
- g_slice_free1 (sec->obj_size, sec);
- }
+ iface = NMA_WS_GET_INTERFACE (self);
+ if (iface->update_secrets)
+ iface->update_secrets (self, connection);
}
-NMAWs *
-nma_ws_init (gsize obj_size,
- NMAWsValidateFunc validate,
- NMAWsAddToSizeGroupFunc add_to_size_group,
- NMAWsFillConnectionFunc fill_connection,
- NMAWsUpdateSecretsFunc update_secrets,
- NMAWsDestroyFunc destroy,
- const char *ui_resource,
- const char *ui_widget_name,
- const char *default_field)
+void
+nma_ws_default_init (NMAWsInterface *iface)
{
- NMAWs *sec;
- GError *error = NULL;
-
- g_return_val_if_fail (obj_size > 0, NULL);
- g_return_val_if_fail (ui_resource != NULL, NULL);
- g_return_val_if_fail (ui_widget_name != NULL, NULL);
-
- sec = g_slice_alloc0 (obj_size);
- g_assert (sec);
-
- sec->refcount = 1;
- sec->obj_size = obj_size;
-
- sec->validate = validate;
- sec->add_to_size_group = add_to_size_group;
- sec->fill_connection = fill_connection;
- sec->update_secrets = update_secrets;
- sec->default_field = default_field;
+ GType iface_type = G_TYPE_FROM_INTERFACE (iface);
- sec->builder = gtk_builder_new ();
- if (!gtk_builder_add_from_resource (sec->builder, ui_resource, &error)) {
- g_warning ("Couldn't load UI builder resource %s: %s",
- ui_resource, error->message);
- g_error_free (error);
- nma_ws_unref (sec);
- return NULL;
- }
+ g_signal_new ("ws-changed",
+ iface_type,
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
- sec->ui_widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, ui_widget_name));
- if (!sec->ui_widget) {
- g_warning ("Couldn't load UI widget '%s' from UI file %s",
- ui_widget_name, ui_resource);
- nma_ws_unref (sec);
- return NULL;
- }
- g_object_ref_sink (sec->ui_widget);
+ iface->adhoc_compatible = TRUE;
+ iface->hotspot_compatible = TRUE;
- sec->destroy = destroy;
- sec->adhoc_compatible = TRUE;
- sec->hotspot_compatible = TRUE;
+ g_object_interface_install_property (iface,
+ g_param_spec_object ("connection", "", "",
+ NM_TYPE_CONNECTION,
+ G_PARAM_READWRITE
+ | G_PARAM_CONSTRUCT
+ | G_PARAM_STATIC_STRINGS));
- return sec;
+ g_object_interface_install_property (iface,
+ g_param_spec_boolean ("secrets-only", "", "",
+ FALSE,
+ G_PARAM_READWRITE
+ | G_PARAM_CONSTRUCT
+ | G_PARAM_STATIC_STRINGS));
}
gboolean
-nma_ws_adhoc_compatible (NMAWs *sec)
+nma_ws_adhoc_compatible (NMAWs *self)
{
- g_return_val_if_fail (sec != NULL, FALSE);
+ g_return_val_if_fail (self != NULL, FALSE);
- return sec->adhoc_compatible;
+ return NMA_WS_GET_INTERFACE (self)->adhoc_compatible;
}
gboolean
-nma_ws_hotspot_compatible (NMAWs *sec)
+nma_ws_hotspot_compatible (NMAWs *self)
{
- g_return_val_if_fail (sec != NULL, FALSE);
+ g_return_val_if_fail (self != NULL, FALSE);
- return sec->hotspot_compatible;
-}
-
-void
-nma_ws_set_userpass (NMAWs *sec,
- const char *user,
- const char *password,
- gboolean always_ask,
- gboolean show_password)
-{
- g_free (sec->username);
- sec->username = g_strdup (user);
-
- if (sec->password) {
- memset (sec->password, 0, strlen (sec->password));
- g_free (sec->password);
- }
- sec->password = g_strdup (password);
-
- if (always_ask != (gboolean) -1)
- sec->always_ask = always_ask;
- sec->show_password = show_password;
-}
-
-void
-nma_ws_set_userpass_802_1x (NMAWs *sec,
- NMConnection *connection)
-{
- const char *user = NULL, *password = NULL;
- gboolean always_ask = FALSE, show_password = FALSE;
- NMSetting8021x *setting;
- NMSettingSecretFlags flags;
-
- if (!connection)
- goto set;
-
- setting = nm_connection_get_setting_802_1x (connection);
- if (!setting)
- goto set;
-
- user = nm_setting_802_1x_get_identity (setting);
- password = nm_setting_802_1x_get_password (setting);
-
- if (nm_setting_get_secret_flags (NM_SETTING (setting), NM_SETTING_802_1X_PASSWORD, &flags, NULL))
- always_ask = !!(flags & NM_SETTING_SECRET_FLAG_NOT_SAVED);
-
-set:
- nma_ws_set_userpass (sec, user, password, always_ask, show_password);
+ return NMA_WS_GET_INTERFACE (self)->hotspot_compatible;
}
void
@@ -250,344 +133,9 @@ nma_ws_clear_ciphers (NMConnection *connection)
g_return_if_fail (connection != NULL);
s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
- g_assert (s_wireless_sec);
+ g_return_if_fail (s_wireless_sec);
nm_setting_wireless_security_clear_protos (s_wireless_sec);
nm_setting_wireless_security_clear_pairwise (s_wireless_sec);
nm_setting_wireless_security_clear_groups (s_wireless_sec);
}
-
-void
-nma_ws_802_1x_add_to_size_group (NMAWs *sec,
- GtkSizeGroup *size_group,
- const char *label_name,
- const char *combo_name)
-{
- GtkWidget *widget;
- GtkTreeModel *model;
- GtkTreeIter iter;
- NMAEap *eap;
-
- widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, label_name));
- g_assert (widget);
- gtk_size_group_add_widget (size_group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, combo_name));
- g_assert (widget);
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter);
- gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1);
- g_assert (eap);
- nma_eap_add_to_size_group (eap, size_group);
- nma_eap_unref (eap);
-}
-
-gboolean
-nma_ws_802_1x_validate (NMAWs *sec, const char *combo_name, GError **error)
-{
- GtkWidget *widget;
- GtkTreeModel *model;
- GtkTreeIter iter;
- NMAEap *eap = NULL;
- gboolean valid = FALSE;
-
- widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, combo_name));
- g_assert (widget);
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter);
- gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1);
- g_assert (eap);
- valid = nma_eap_validate (eap, error);
- nma_eap_unref (eap);
- return valid;
-}
-
-void
-nma_ws_802_1x_auth_combo_changed (GtkWidget *combo,
- NMAWs *sec,
- const char *vbox_name,
- GtkSizeGroup *size_group)
-{
- GtkWidget *vbox;
- NMAEap *eap = NULL;
- GList *elt, *children;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkWidget *eap_widget;
- GtkWidget *eap_default_widget = NULL;
-
- vbox = GTK_WIDGET (gtk_builder_get_object (sec->builder, vbox_name));
- g_assert (vbox);
-
- /* Remove any previous wireless security widgets */
- children = gtk_container_get_children (GTK_CONTAINER (vbox));
- for (elt = children; elt; elt = g_list_next (elt))
- gtk_container_remove (GTK_CONTAINER (vbox), GTK_WIDGET (elt->data));
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
- gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1);
- g_assert (eap);
-
- eap_widget = nma_eap_get_widget (eap);
- g_assert (eap_widget);
- gtk_widget_unparent (eap_widget);
-
- if (size_group)
- nma_eap_add_to_size_group (eap, size_group);
- gtk_container_add (GTK_CONTAINER (vbox), eap_widget);
-
- /* Refocus the EAP method's default widget */
- if (eap->default_field) {
- eap_default_widget = GTK_WIDGET (gtk_builder_get_object (eap->builder, eap->default_field));
- if (eap_default_widget)
- gtk_widget_grab_focus (eap_default_widget);
- }
-
- nma_eap_unref (eap);
-
- nma_ws_changed_cb (combo, NMA_WS (sec));
-}
-
-GtkWidget *
-nma_ws_802_1x_auth_combo_init (NMAWs *sec,
- const char *combo_name,
- const char *combo_label,
- GCallback auth_combo_changed_cb,
- NMConnection *connection,
- gboolean is_editor,
- gboolean secrets_only,
- const char *const*secrets_hints)
-{
- GtkWidget *combo, *widget;
- GtkListStore *auth_model;
- GtkTreeIter iter;
- NMAEapSimple *em_md5;
- NMAEapTLS *em_tls;
- NMAEapLEAP *em_leap;
- NMAEapSimple *em_pwd;
- NMAEapFAST *em_fast;
- NMAEapTTLS *em_ttls;
- NMAEapPEAP *em_peap;
- const char *default_method = NULL, *ctype = NULL;
- int active = -1, item = 0;
- gboolean wired = FALSE;
- NMAEapSimpleFlags simple_flags = NMA_EAP_SIMPLE_FLAG_NONE;
-
- /* Grab the default EAP method out of the security object */
- if (connection) {
- NMSettingConnection *s_con;
- NMSetting8021x *s_8021x;
-
- s_con = nm_connection_get_setting_connection (connection);
- if (s_con)
- ctype = nm_setting_connection_get_connection_type (s_con);
- if ( (g_strcmp0 (ctype, NM_SETTING_WIRED_SETTING_NAME) == 0)
- || nm_connection_get_setting_wired (connection))
- wired = TRUE;
-
- s_8021x = nm_connection_get_setting_802_1x (connection);
- if (s_8021x && nm_setting_802_1x_get_num_eap_methods (s_8021x))
- default_method = nm_setting_802_1x_get_eap_method (s_8021x, 0);
- }
-
- /* initialize NMAWs userpass from connection (clear if no connection) */
- nma_ws_set_userpass_802_1x (sec, connection);
-
- auth_model = gtk_list_store_new (2, G_TYPE_STRING, nma_eap_get_type ());
-
- if (is_editor)
- simple_flags |= NMA_EAP_SIMPLE_FLAG_IS_EDITOR;
- if (secrets_only)
- simple_flags |= NMA_EAP_SIMPLE_FLAG_SECRETS_ONLY;
-
- if (wired) {
- em_md5 = nma_eap_simple_new (sec, connection, NMA_EAP_SIMPLE_TYPE_MD5, simple_flags, NULL);
- gtk_list_store_append (auth_model, &iter);
- gtk_list_store_set (auth_model, &iter,
- AUTH_NAME_COLUMN, _("MD5"),
- AUTH_METHOD_COLUMN, em_md5,
- -1);
- nma_eap_unref (NMA_EAP (em_md5));
- if (default_method && (active < 0) && !strcmp (default_method, "md5"))
- active = item;
- item++;
- }
-
- em_tls = nma_eap_tls_new (sec, connection, FALSE, secrets_only);
- gtk_list_store_append (auth_model, &iter);
- gtk_list_store_set (auth_model, &iter,
- AUTH_NAME_COLUMN, _("TLS"),
- AUTH_METHOD_COLUMN, em_tls,
- -1);
- nma_eap_unref (NMA_EAP (em_tls));
- if (default_method && (active < 0) && !strcmp (default_method, "tls"))
- active = item;
- item++;
-
- if (!wired) {
- em_leap = nma_eap_leap_new (sec, connection, secrets_only);
- gtk_list_store_append (auth_model, &iter);
- gtk_list_store_set (auth_model, &iter,
- AUTH_NAME_COLUMN, _("LEAP"),
- AUTH_METHOD_COLUMN, em_leap,
- -1);
- nma_eap_unref (NMA_EAP (em_leap));
- if (default_method && (active < 0) && !strcmp (default_method, "leap"))
- active = item;
- item++;
- }
-
- em_pwd = nma_eap_simple_new (sec, connection, NMA_EAP_SIMPLE_TYPE_PWD, simple_flags, NULL);
- gtk_list_store_append (auth_model, &iter);
- gtk_list_store_set (auth_model, &iter,
- AUTH_NAME_COLUMN, _("PWD"),
- AUTH_METHOD_COLUMN, em_pwd,
- -1);
- nma_eap_unref (NMA_EAP (em_pwd));
- if (default_method && (active < 0) && !strcmp (default_method, "pwd"))
- active = item;
- item++;
-
- em_fast = nma_eap_fast_new (sec, connection, is_editor, secrets_only);
- gtk_list_store_append (auth_model, &iter);
- gtk_list_store_set (auth_model, &iter,
- AUTH_NAME_COLUMN, _("FAST"),
- AUTH_METHOD_COLUMN, em_fast,
- -1);
- nma_eap_unref (NMA_EAP (em_fast));
- if (default_method && (active < 0) && !strcmp (default_method, "fast"))
- active = item;
- item++;
-
- em_ttls = nma_eap_ttls_new (sec, connection, is_editor, secrets_only);
- gtk_list_store_append (auth_model, &iter);
- gtk_list_store_set (auth_model, &iter,
- AUTH_NAME_COLUMN, _("Tunneled TLS"),
- AUTH_METHOD_COLUMN, em_ttls,
- -1);
- nma_eap_unref (NMA_EAP (em_ttls));
- if (default_method && (active < 0) && !strcmp (default_method, "ttls"))
- active = item;
- item++;
-
- em_peap = nma_eap_peap_new (sec, connection, is_editor, secrets_only);
- gtk_list_store_append (auth_model, &iter);
- gtk_list_store_set (auth_model, &iter,
- AUTH_NAME_COLUMN, _("Protected EAP (PEAP)"),
- AUTH_METHOD_COLUMN, em_peap,
- -1);
- nma_eap_unref (NMA_EAP (em_peap));
- if (default_method && (active < 0) && !strcmp (default_method, "peap"))
- active = item;
- item++;
-
- if (secrets_hints && secrets_hints[0]) {
- NMAEapSimple *em_hints;
-
- em_hints = nma_eap_simple_new (sec, connection, NMA_EAP_SIMPLE_TYPE_UNKNOWN,
- simple_flags, secrets_hints);
- gtk_list_store_append (auth_model, &iter);
- gtk_list_store_set (auth_model, &iter,
- AUTH_NAME_COLUMN, _("Unknown"),
- AUTH_METHOD_COLUMN, em_hints,
- -1);
- nma_eap_unref (NMA_EAP (em_hints));
- active = item;
- item++;
- } else if (default_method && !strcmp (default_method, "external")) {
- NMAEapSimple *em_extern;
- const char *empty_hints[] = { NULL };
-
- em_extern = nma_eap_simple_new (sec, connection, NMA_EAP_SIMPLE_TYPE_UNKNOWN,
- simple_flags, empty_hints);
- gtk_list_store_append (auth_model, &iter);
- gtk_list_store_set (auth_model, &iter,
- AUTH_NAME_COLUMN, _("Externally configured"),
- AUTH_METHOD_COLUMN, em_extern,
- -1);
- nma_eap_unref (NMA_EAP (em_extern));
- active = item;
- item++;
- }
-
- combo = GTK_WIDGET (gtk_builder_get_object (sec->builder, combo_name));
- g_assert (combo);
-
- gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model));
- g_object_unref (G_OBJECT (auth_model));
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active < 0 ? 0 : (guint32) active);
-
- g_signal_connect (G_OBJECT (combo), "changed", auth_combo_changed_cb, sec);
-
- if (secrets_only) {
- gtk_widget_hide (combo);
- widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, combo_label));
- gtk_widget_hide (widget);
- }
-
- return combo;
-}
-
-void
-nma_ws_802_1x_fill_connection (NMAWs *sec,
- const char *combo_name,
- NMConnection *connection)
-{
- GtkWidget *widget;
- NMSettingWirelessSecurity *s_wireless_sec;
- NMSetting8021x *s_8021x;
- NMAEap *eap = NULL;
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- /* Get the NMAEap object */
- widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, combo_name));
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter);
- gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1);
- g_assert (eap);
-
- /* Blow away the old wireless security setting by adding a clear one */
- s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
- nm_connection_add_setting (connection, (NMSetting *) s_wireless_sec);
-
- /* Blow away the old 802.1x setting by adding a clear one */
- s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
- nm_connection_add_setting (connection, (NMSetting *) s_8021x);
-
- nma_eap_fill_connection (eap, connection);
- nma_eap_unref (eap);
-}
-
-void
-nma_ws_802_1x_update_secrets (NMAWs *sec,
- const char *combo_name,
- NMConnection *connection)
-{
- GtkWidget *widget;
- NMAEap *eap = NULL;
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- g_return_if_fail (sec != NULL);
- g_return_if_fail (combo_name != NULL);
- g_return_if_fail (connection != NULL);
-
- widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, combo_name));
- g_return_if_fail (widget != NULL);
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
-
- /* Let each EAP method try to update its secrets */
- if (gtk_tree_model_get_iter_first (model, &iter)) {
- do {
- gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1);
- if (eap) {
- nma_eap_update_secrets (eap, connection);
- nma_eap_unref (eap);
- }
- } while (gtk_tree_model_iter_next (model, &iter));
- }
-}
diff --git a/src/nma-ws/nma-ws.h b/src/nma-ws/nma-ws.h
index 660bc3b4..e32df098 100644
--- a/src/nma-ws/nma-ws.h
+++ b/src/nma-ws/nma-ws.h
@@ -9,127 +9,27 @@
#define NMA_WS_H
typedef struct _NMAWs NMAWs;
-GType nma_ws_get_type (void);
-
-#define NMA_TYPE_WS (nma_ws_get_type ())
-#define NMA_WS(x) ((NMAWs *) x)
-
-typedef void (*NMAWsChangedFunc) (NMAWs *sec, gpointer user_data);
-
-typedef void (*NMAWsAddToSizeGroupFunc) (NMAWs *sec, GtkSizeGroup *group);
-typedef void (*NMAWsFillConnectionFunc) (NMAWs *sec, NMConnection *connection);
-typedef void (*NMAWsUpdateSecretsFunc) (NMAWs *sec, NMConnection *connection);
-typedef void (*NMAWsDestroyFunc) (NMAWs *sec);
-typedef gboolean (*NMAWsValidateFunc) (NMAWs *sec, GError **error);
-typedef GtkWidget * (*NMAWsNagUserFunc) (NMAWs *sec);
-
-struct _NMAWs {
- guint32 refcount;
- gsize obj_size;
- GtkBuilder *builder;
- GtkWidget *ui_widget;
- NMAWsChangedFunc changed_notify;
- gpointer changed_notify_data;
- const char *default_field;
- gboolean adhoc_compatible;
- gboolean hotspot_compatible;
-
- char *username, *password;
- gboolean always_ask, show_password;
- NMAWsAddToSizeGroupFunc add_to_size_group;
- NMAWsFillConnectionFunc fill_connection;
- NMAWsUpdateSecretsFunc update_secrets;
- NMAWsValidateFunc validate;
- NMAWsDestroyFunc destroy;
-};
+#define NMA_TYPE_WS (nma_ws_get_type ())
+#define NMA_WS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_WS, NMAWs))
+#define NMA_IS_WS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_WS))
+#define NMA_WS_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NMA_TYPE_WS, NMAWsInterface))
-GtkWidget *nma_ws_get_widget (NMAWs *sec);
-
-void nma_ws_set_changed_notify (NMAWs *sec,
- NMAWsChangedFunc func,
- gpointer user_data);
+GType nma_ws_get_type (void);
-gboolean nma_ws_validate (NMAWs *sec, GError **error);
+gboolean nma_ws_validate (NMAWs *self, GError **error);
-void nma_ws_add_to_size_group (NMAWs *sec,
+void nma_ws_add_to_size_group (NMAWs *self,
GtkSizeGroup *group);
-void nma_ws_fill_connection (NMAWs *sec,
+void nma_ws_fill_connection (NMAWs *self,
NMConnection *connection);
-void nma_ws_update_secrets (NMAWs *sec,
+void nma_ws_update_secrets (NMAWs *self,
NMConnection *connection);
-gboolean nma_ws_adhoc_compatible (NMAWs *sec);
-
-gboolean nma_ws_hotspot_compatible (NMAWs *sec);
-
-void nma_ws_set_userpass (NMAWs *sec,
- const char *user,
- const char *password,
- gboolean always_ask,
- gboolean show_password);
-void nma_ws_set_userpass_802_1x (NMAWs *sec,
- NMConnection *connection);
-
-NMAWs *nma_ws_ref (NMAWs *sec);
-
-void nma_ws_unref (NMAWs *sec);
-
-/* Below for internal use only */
-
-#include "nma-ws-sae.h"
-#include "nma-ws-wep-key.h"
-#include "nma-ws-wpa-psk.h"
-#include "nma-ws-leap.h"
-#include "nma-ws-wpa-eap.h"
-#include "nma-ws-dynamic-wep.h"
-
-NMAWs *nma_ws_init (gsize obj_size,
- NMAWsValidateFunc validate,
- NMAWsAddToSizeGroupFunc add_to_size_group,
- NMAWsFillConnectionFunc fill_connection,
- NMAWsUpdateSecretsFunc update_secrets,
- NMAWsDestroyFunc destroy,
- const char *ui_resource,
- const char *ui_widget_name,
- const char *default_field);
-
-void nma_ws_changed_cb (GtkWidget *entry, gpointer user_data);
-
-void nma_ws_clear_ciphers (NMConnection *connection);
-
-#define AUTH_NAME_COLUMN 0
-#define AUTH_METHOD_COLUMN 1
-
-GtkWidget *nma_ws_802_1x_auth_combo_init (NMAWs *sec,
- const char *combo_name,
- const char *combo_label,
- GCallback auth_combo_changed_cb,
- NMConnection *connection,
- gboolean is_editor,
- gboolean secrets_only,
- const char *const*secrets_hints);
-
-void nma_ws_802_1x_auth_combo_changed (GtkWidget *combo,
- NMAWs *sec,
- const char *vbox_name,
- GtkSizeGroup *size_group);
-
-gboolean nma_ws_802_1x_validate (NMAWs *sec, const char *combo_name, GError **error);
-
-void nma_ws_802_1x_add_to_size_group (NMAWs *sec,
- GtkSizeGroup *size_group,
- const char *label_name,
- const char *combo_name);
-
-void nma_ws_802_1x_fill_connection (NMAWs *sec,
- const char *combo_name,
- NMConnection *connection);
+gboolean nma_ws_adhoc_compatible (NMAWs *self);
-void nma_ws_802_1x_update_secrets (NMAWs *sec,
- const char *combo_name,
- NMConnection *connection);
+gboolean nma_ws_hotspot_compatible (NMAWs *self);
#endif /* NMA_WS_H */
diff --git a/src/nma.gresource.xml b/src/nma.gresource.xml
index 569aa275..5c75f112 100644
--- a/src/nma.gresource.xml
+++ b/src/nma.gresource.xml
@@ -7,11 +7,10 @@
<file preprocess="xml-stripblanks">nma-mobile-wizard.ui</file>
<file preprocess="xml-stripblanks">nma-vpn-password-dialog.ui</file>
<file preprocess="xml-stripblanks">nma-bar-code-widget.ui</file>
- <file preprocess="xml-stripblanks"
alias="nma-ws-dynamic-wep.ui">nma-ws/nma-ws-dynamic-wep.ui</file>
+ <file preprocess="xml-stripblanks" alias="nma-ws-802-1x.ui">nma-ws/nma-ws-802-1x.ui</file>
<file preprocess="xml-stripblanks" alias="nma-ws-leap.ui">nma-ws/nma-ws-leap.ui</file>
<file preprocess="xml-stripblanks" alias="nma-ws-sae.ui">nma-ws/nma-ws-sae.ui</file>
<file preprocess="xml-stripblanks" alias="nma-ws-wep-key.ui">nma-ws/nma-ws-wep-key.ui</file>
- <file preprocess="xml-stripblanks" alias="nma-ws-wpa-eap.ui">nma-ws/nma-ws-wpa-eap.ui</file>
<file preprocess="xml-stripblanks" alias="nma-ws-wpa-psk.ui">nma-ws/nma-ws-wpa-psk.ui</file>
<file preprocess="xml-stripblanks" alias="nma-eap-fast.ui">nma-ws/nma-eap-fast.ui</file>
<file preprocess="xml-stripblanks" alias="nma-eap-leap.ui">nma-ws/nma-eap-leap.ui</file>
diff --git a/src/wireless-security/ws-leap.ui b/src/wireless-security/ws-leap.ui
index a93121d6..e772c5a2 100644
--- a/src/wireless-security/ws-leap.ui
+++ b/src/wireless-security/ws-leap.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="nm-applet">
<requires lib="gtk+" version="3.10"/>
<object class="GtkNotebook" id="leap_notebook">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]