network: Convert WirelessSecurity property to a virtual method

This commit is contained in:
Robert Ancell 2019-11-07 13:58:30 +13:00 committed by Georges Basile Stavracas Neto
parent 125d971ebe
commit e5ae62a6a3
6 changed files with 33 additions and 31 deletions

View file

@ -36,7 +36,6 @@
#include "utils.h" #include "utils.h"
typedef struct { typedef struct {
gboolean adhoc_compatible;
char *username, *password; char *username, *password;
gboolean always_ask, show_password; gboolean always_ask, show_password;
} WirelessSecurityPrivate; } WirelessSecurityPrivate;
@ -68,11 +67,7 @@ wireless_security_dispose (GObject *object)
void void
wireless_security_init (WirelessSecurity *self) wireless_security_init (WirelessSecurity *self)
{ {
WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
g_resources_register (wireless_security_get_resource ()); g_resources_register (wireless_security_get_resource ());
priv->adhoc_compatible = TRUE;
} }
void void
@ -141,24 +136,13 @@ wireless_security_fill_connection (WirelessSecurity *self,
return WIRELESS_SECURITY_GET_CLASS (self)->fill_connection (self, connection); return WIRELESS_SECURITY_GET_CLASS (self)->fill_connection (self, connection);
} }
void
wireless_security_set_adhoc_compatible (WirelessSecurity *self, gboolean adhoc_compatible)
{
WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
g_return_if_fail (WIRELESS_IS_SECURITY (self));
priv->adhoc_compatible = adhoc_compatible;
}
gboolean gboolean
wireless_security_adhoc_compatible (WirelessSecurity *self) wireless_security_adhoc_compatible (WirelessSecurity *self)
{ {
WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self); if (WIRELESS_SECURITY_GET_CLASS (self)->adhoc_compatible)
return WIRELESS_SECURITY_GET_CLASS (self)->adhoc_compatible (self);
g_return_val_if_fail (WIRELESS_IS_SECURITY (self), FALSE); else
return TRUE;
return priv->adhoc_compatible;
} }
const gchar * const gchar *

View file

@ -34,6 +34,7 @@ struct _WirelessSecurityClass {
void (*add_to_size_group) (WirelessSecurity *sec, GtkSizeGroup *group); void (*add_to_size_group) (WirelessSecurity *sec, GtkSizeGroup *group);
void (*fill_connection) (WirelessSecurity *sec, NMConnection *connection); void (*fill_connection) (WirelessSecurity *sec, NMConnection *connection);
gboolean (*validate) (WirelessSecurity *sec, GError **error); gboolean (*validate) (WirelessSecurity *sec, GError **error);
gboolean (*adhoc_compatible) (WirelessSecurity *sec);
GtkWidget* (*get_widget) (WirelessSecurity *sec); GtkWidget* (*get_widget) (WirelessSecurity *sec);
}; };
@ -47,9 +48,6 @@ void wireless_security_add_to_size_group (WirelessSecurity *sec,
void wireless_security_fill_connection (WirelessSecurity *sec, void wireless_security_fill_connection (WirelessSecurity *sec,
NMConnection *connection); NMConnection *connection);
void wireless_security_set_adhoc_compatible (WirelessSecurity *sec,
gboolean adhoc_compatible);
gboolean wireless_security_adhoc_compatible (WirelessSecurity *sec); gboolean wireless_security_adhoc_compatible (WirelessSecurity *sec);
const gchar *wireless_security_get_username (WirelessSecurity *sec); const gchar *wireless_security_get_username (WirelessSecurity *sec);

View file

@ -94,6 +94,12 @@ fill_connection (WirelessSecurity *security, NMConnection *connection)
g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", NULL); g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", NULL);
} }
static gboolean
adhoc_compatible (WirelessSecurity *security)
{
return FALSE;
}
static void static void
auth_combo_changed_cb (WirelessSecurityDynamicWEP *self) auth_combo_changed_cb (WirelessSecurityDynamicWEP *self)
{ {
@ -120,6 +126,7 @@ ws_dynamic_wep_class_init (WirelessSecurityDynamicWEPClass *klass)
ws_class->validate = validate; ws_class->validate = validate;
ws_class->add_to_size_group = add_to_size_group; ws_class->add_to_size_group = add_to_size_group;
ws_class->fill_connection = fill_connection; ws_class->fill_connection = fill_connection;
ws_class->adhoc_compatible = adhoc_compatible;
} }
WirelessSecurityDynamicWEP * WirelessSecurityDynamicWEP *
@ -143,8 +150,6 @@ ws_dynamic_wep_new (NMConnection *connection,
self->grid = GTK_GRID (gtk_builder_get_object (self->builder, "grid")); self->grid = GTK_GRID (gtk_builder_get_object (self->builder, "grid"));
self->method_box = GTK_BOX (gtk_builder_get_object (self->builder, "method_box")); self->method_box = GTK_BOX (gtk_builder_get_object (self->builder, "method_box"));
wireless_security_set_adhoc_compatible (WIRELESS_SECURITY (self), FALSE);
ws_802_1x_auth_combo_init (WIRELESS_SECURITY (self), ws_802_1x_auth_combo_init (WIRELESS_SECURITY (self),
self->auth_combo, self->auth_combo,
connection, connection,

View file

@ -142,6 +142,12 @@ fill_connection (WirelessSecurity *security, NMConnection *connection)
NM_SETTING (s_wireless_sec), self->password_flags_name); NM_SETTING (s_wireless_sec), self->password_flags_name);
} }
static gboolean
adhoc_compatible (WirelessSecurity *security)
{
return FALSE;
}
static void static void
changed_cb (WirelessSecurityLEAP *self) changed_cb (WirelessSecurityLEAP *self)
{ {
@ -164,6 +170,7 @@ ws_leap_class_init (WirelessSecurityLEAPClass *klass)
ws_class->validate = validate; ws_class->validate = validate;
ws_class->add_to_size_group = add_to_size_group; ws_class->add_to_size_group = add_to_size_group;
ws_class->fill_connection = fill_connection; ws_class->fill_connection = fill_connection;
ws_class->adhoc_compatible = adhoc_compatible;
} }
WirelessSecurityLEAP * WirelessSecurityLEAP *
@ -187,8 +194,6 @@ ws_leap_new (NMConnection *connection, gboolean secrets_only)
} }
} }
wireless_security_set_adhoc_compatible (WIRELESS_SECURITY (self), FALSE);
self->editing_connection = secrets_only ? FALSE : TRUE; self->editing_connection = secrets_only ? FALSE : TRUE;
self->password_flags_name = NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD; self->password_flags_name = NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD;

View file

@ -94,6 +94,12 @@ fill_connection (WirelessSecurity *security, NMConnection *connection)
g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap", NULL); g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap", NULL);
} }
static gboolean
adhoc_compatible (WirelessSecurity *security)
{
return FALSE;
}
static void static void
auth_combo_changed_cb (WirelessSecurityWPAEAP *self) auth_combo_changed_cb (WirelessSecurityWPAEAP *self)
{ {
@ -120,6 +126,7 @@ ws_wpa_eap_class_init (WirelessSecurityWPAEAPClass *klass)
ws_class->validate = validate; ws_class->validate = validate;
ws_class->add_to_size_group = add_to_size_group; ws_class->add_to_size_group = add_to_size_group;
ws_class->fill_connection = fill_connection; ws_class->fill_connection = fill_connection;
ws_class->adhoc_compatible = adhoc_compatible;
} }
WirelessSecurityWPAEAP * WirelessSecurityWPAEAP *
@ -143,8 +150,6 @@ ws_wpa_eap_new (NMConnection *connection,
self->grid = GTK_GRID (gtk_builder_get_object (self->builder, "grid")); self->grid = GTK_GRID (gtk_builder_get_object (self->builder, "grid"));
self->method_box = GTK_BOX (gtk_builder_get_object (self->builder, "method_box")); self->method_box = GTK_BOX (gtk_builder_get_object (self->builder, "method_box"));
wireless_security_set_adhoc_compatible (WIRELESS_SECURITY (self), FALSE);
ws_802_1x_auth_combo_init (WIRELESS_SECURITY (self), ws_802_1x_auth_combo_init (WIRELESS_SECURITY (self),
self->auth_combo, self->auth_combo,
connection, connection,

View file

@ -172,6 +172,12 @@ fill_connection (WirelessSecurity *security, NMConnection *connection)
} }
} }
static gboolean
adhoc_compatible (WirelessSecurity *security)
{
return FALSE;
}
static void static void
changed_cb (WirelessSecurityWPAPSK *self) changed_cb (WirelessSecurityWPAPSK *self)
{ {
@ -194,6 +200,7 @@ ws_wpa_psk_class_init (WirelessSecurityWPAPSKClass *klass)
ws_class->validate = validate; ws_class->validate = validate;
ws_class->add_to_size_group = add_to_size_group; ws_class->add_to_size_group = add_to_size_group;
ws_class->fill_connection = fill_connection; ws_class->fill_connection = fill_connection;
ws_class->adhoc_compatible = adhoc_compatible;
} }
WirelessSecurityWPAPSK * WirelessSecurityWPAPSK *
@ -218,8 +225,6 @@ ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only)
self->type_combo = GTK_COMBO_BOX (gtk_builder_get_object (self->builder, "type_combo")); self->type_combo = GTK_COMBO_BOX (gtk_builder_get_object (self->builder, "type_combo"));
self->type_label = GTK_LABEL (gtk_builder_get_object (self->builder, "type_label")); self->type_label = GTK_LABEL (gtk_builder_get_object (self->builder, "type_label"));
wireless_security_set_adhoc_compatible (WIRELESS_SECURITY (self), FALSE);
self->editing_connection = secrets_only ? FALSE : TRUE; self->editing_connection = secrets_only ? FALSE : TRUE;
self->password_flags_name = NM_SETTING_WIRELESS_SECURITY_PSK; self->password_flags_name = NM_SETTING_WIRELESS_SECURITY_PSK;