[gnome-control-center] network: Convert EAPMethod to an interface and make the subclasses GObjects
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Convert EAPMethod to an interface and make the subclasses GObjects
- Date: Wed, 27 Nov 2019 22:10:54 +0000 (UTC)
commit 5006342308bf9c9523a9753f3d45ed38be8eddf4
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Nov 7 10:21:54 2019 +1300
network: Convert EAPMethod to an interface and make the subclasses GObjects
panels/network/wireless-security/eap-method-fast.c | 54 ++++++---
panels/network/wireless-security/eap-method-fast.h | 15 ++-
panels/network/wireless-security/eap-method-leap.c | 54 ++++++---
panels/network/wireless-security/eap-method-leap.h | 13 +--
panels/network/wireless-security/eap-method-peap.c | 86 ++++++++------
panels/network/wireless-security/eap-method-peap.h | 13 +--
.../network/wireless-security/eap-method-simple.c | 89 +++++++++------
.../network/wireless-security/eap-method-simple.h | 15 +--
panels/network/wireless-security/eap-method-tls.c | 125 ++++++++++++---------
panels/network/wireless-security/eap-method-tls.h | 13 +--
panels/network/wireless-security/eap-method-ttls.c | 86 ++++++++------
panels/network/wireless-security/eap-method-ttls.h | 13 +--
panels/network/wireless-security/eap-method.c | 100 +++--------------
panels/network/wireless-security/eap-method.h | 65 +++--------
14 files changed, 368 insertions(+), 373 deletions(-)
---
diff --git a/panels/network/wireless-security/eap-method-fast.c
b/panels/network/wireless-security/eap-method-fast.c
index 475ea1008..df8bf77df 100644
--- a/panels/network/wireless-security/eap-method-fast.c
+++ b/panels/network/wireless-security/eap-method-fast.c
@@ -36,7 +36,7 @@
#define I_METHOD_COLUMN 1
struct _EAPMethodFAST {
- EAPMethod parent;
+ GObject parent;
GtkBuilder *builder;
GtkEntry *anon_identity_entry;
@@ -55,13 +55,20 @@ struct _EAPMethodFAST {
gboolean is_editor;
};
+static void eap_method_iface_init (EAPMethodInterface *);
+
+G_DEFINE_TYPE_WITH_CODE (EAPMethodFAST, eap_method_fast, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (eap_method_get_type (), eap_method_iface_init))
+
static void
-destroy (EAPMethod *parent)
+eap_method_fast_dispose (GObject *object)
{
- EAPMethodFAST *self = (EAPMethodFAST *) parent;
+ EAPMethodFAST *self = EAP_METHOD_FAST (object);
g_clear_object (&self->builder);
g_clear_object (&self->size_group);
+
+ G_OBJECT_CLASS (eap_method_fast_parent_class)->dispose (object);
}
static gboolean
@@ -312,13 +319,37 @@ changed_cb (EAPMethodFAST *self)
wireless_security_notify_changed (self->sec_parent);
}
+static void
+eap_method_fast_init (EAPMethodFAST *self)
+{
+}
+
+static void
+eap_method_fast_class_init (EAPMethodFASTClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = eap_method_fast_dispose;
+}
+
+static void
+eap_method_iface_init (EAPMethodInterface *iface)
+{
+ iface->validate = validate;
+ iface->add_to_size_group = add_to_size_group;
+ iface->fill_connection = fill_connection;
+ iface->update_secrets = update_secrets;
+ iface->get_widget = get_widget;
+ iface->get_default_field = get_default_field;
+ iface->get_password_flags_name = get_password_flags_name;
+}
+
EAPMethodFAST *
eap_method_fast_new (WirelessSecurity *ws_parent,
NMConnection *connection,
gboolean is_editor,
gboolean secrets_only)
{
- EAPMethod *parent;
EAPMethodFAST *self;
GtkFileFilter *filter;
NMSetting8021x *s_8021x = NULL;
@@ -326,20 +357,7 @@ eap_method_fast_new (WirelessSecurity *ws_parent,
gboolean provisioning_enabled = TRUE;
g_autoptr(GError) error = NULL;
- parent = eap_method_init (sizeof (EAPMethodFAST),
- validate,
- add_to_size_group,
- fill_connection,
- update_secrets,
- get_widget,
- get_default_field,
- get_password_flags_name,
- NULL,
- destroy);
- if (!parent)
- return NULL;
-
- self = (EAPMethodFAST *) parent;
+ self = g_object_new (eap_method_fast_get_type (), NULL);
self->sec_parent = ws_parent;
self->is_editor = is_editor;
diff --git a/panels/network/wireless-security/eap-method-fast.h
b/panels/network/wireless-security/eap-method-fast.h
index c19722058..4401f5315 100644
--- a/panels/network/wireless-security/eap-method-fast.h
+++ b/panels/network/wireless-security/eap-method-fast.h
@@ -20,20 +20,19 @@
* (C) Copyright 2012 Red Hat, Inc.
*/
-#ifndef EAP_METHOD_FAST_H
-#define EAP_METHOD_FAST_H
+#pragma once
+
+#include <NetworkManager.h>
#include "wireless-security.h"
-typedef struct _EAPMethodFAST EAPMethodFAST;
+G_BEGIN_DECLS
+
+G_DECLARE_FINAL_TYPE (EAPMethodFAST, eap_method_fast, EAP, METHOD_FAST, GObject)
EAPMethodFAST *eap_method_fast_new (WirelessSecurity *ws_parent,
NMConnection *connection,
gboolean is_editor,
gboolean secrets_only);
-static void eap_method_fast_unref (EAPMethodFAST *method) { eap_method_unref (EAP_METHOD (method)); }
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (EAPMethodFAST, eap_method_fast_unref)
-
-#endif /* EAP_METHOD_FAST_H */
-
+G_END_DECLS
diff --git a/panels/network/wireless-security/eap-method-leap.c
b/panels/network/wireless-security/eap-method-leap.c
index ef427eafc..fe5997f0b 100644
--- a/panels/network/wireless-security/eap-method-leap.c
+++ b/panels/network/wireless-security/eap-method-leap.c
@@ -33,7 +33,7 @@
#include "utils.h"
struct _EAPMethodLEAP {
- EAPMethod parent;
+ GObject parent;
GtkBuilder *builder;
GtkGrid *grid;
@@ -48,6 +48,11 @@ struct _EAPMethodLEAP {
gboolean editing_connection;
};
+static void eap_method_iface_init (EAPMethodInterface *);
+
+G_DEFINE_TYPE_WITH_CODE (EAPMethodLEAP, eap_method_leap, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (eap_method_get_type (), eap_method_iface_init))
+
static void
show_toggled_cb (EAPMethodLEAP *self)
{
@@ -183,15 +188,17 @@ widgets_unrealized (EAPMethodLEAP *self)
}
static void
-destroy (EAPMethod *parent)
+eap_method_leap_dispose (GObject *object)
{
- EAPMethodLEAP *self = (EAPMethodLEAP *) parent;
+ EAPMethodLEAP *self = EAP_METHOD_LEAP (object);
g_clear_object (&self->builder);
g_signal_handlers_disconnect_by_data (self->grid, self);
g_signal_handlers_disconnect_by_data (self->username_entry, self->ws_parent);
g_signal_handlers_disconnect_by_data (self->password_entry, self->ws_parent);
g_signal_handlers_disconnect_by_data (self->show_password_check, self);
+
+ G_OBJECT_CLASS (eap_method_leap_parent_class)->dispose (object);
}
static void
@@ -200,30 +207,41 @@ changed_cb (EAPMethodLEAP *self)
wireless_security_notify_changed (self->ws_parent);
}
+static void
+eap_method_leap_init (EAPMethodLEAP *self)
+{
+}
+
+static void
+eap_method_leap_class_init (EAPMethodLEAPClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = eap_method_leap_dispose;
+}
+
+static void
+eap_method_iface_init (EAPMethodInterface *iface)
+{
+ iface->validate = validate;
+ iface->add_to_size_group = add_to_size_group;
+ iface->fill_connection = fill_connection;
+ iface->update_secrets = update_secrets;
+ iface->get_widget = get_widget;
+ iface->get_default_field = get_default_field;
+ iface->get_password_flags_name = get_password_flags_name;
+}
+
EAPMethodLEAP *
eap_method_leap_new (WirelessSecurity *ws_parent,
NMConnection *connection,
gboolean secrets_only)
{
EAPMethodLEAP *self;
- EAPMethod *parent;
NMSetting8021x *s_8021x = NULL;
g_autoptr(GError) error = NULL;
- parent = eap_method_init (sizeof (EAPMethodLEAP),
- validate,
- add_to_size_group,
- fill_connection,
- update_secrets,
- get_widget,
- get_default_field,
- get_password_flags_name,
- NULL,
- destroy);
- if (!parent)
- return NULL;
-
- self = (EAPMethodLEAP *) parent;
+ self = g_object_new (eap_method_leap_get_type (), NULL);
self->editing_connection = secrets_only ? FALSE : TRUE;
self->ws_parent = ws_parent;
diff --git a/panels/network/wireless-security/eap-method-leap.h
b/panels/network/wireless-security/eap-method-leap.h
index 2d205d719..b8522ebab 100644
--- a/panels/network/wireless-security/eap-method-leap.h
+++ b/panels/network/wireless-security/eap-method-leap.h
@@ -20,19 +20,16 @@
* (C) Copyright 2007 - 2010 Red Hat, Inc.
*/
-#ifndef EAP_METHOD_LEAP_H
-#define EAP_METHOD_LEAP_H
+#pragma once
#include "wireless-security.h"
-typedef struct _EAPMethodLEAP EAPMethodLEAP;
+G_BEGIN_DECLS
+
+G_DECLARE_FINAL_TYPE (EAPMethodLEAP, eap_method_leap, EAP, METHOD_LEAP, GObject)
EAPMethodLEAP *eap_method_leap_new (WirelessSecurity *ws_parent,
NMConnection *connection,
gboolean secrets_only);
-static void eap_method_leap_unref (EAPMethodLEAP *method) { eap_method_unref (EAP_METHOD (method)); }
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (EAPMethodLEAP, eap_method_leap_unref)
-
-#endif /* EAP_METHOD_LEAP_H */
-
+G_END_DECLS
diff --git a/panels/network/wireless-security/eap-method-peap.c
b/panels/network/wireless-security/eap-method-peap.c
index 25b700f18..70e1b3e8c 100644
--- a/panels/network/wireless-security/eap-method-peap.c
+++ b/panels/network/wireless-security/eap-method-peap.c
@@ -35,7 +35,7 @@
#define I_METHOD_COLUMN 1
struct _EAPMethodPEAP {
- EAPMethod parent;
+ GObject parent;
GtkBuilder *builder;
GtkEntry *anon_identity_entry;
@@ -55,19 +55,26 @@ struct _EAPMethodPEAP {
gboolean is_editor;
};
+static void eap_method_iface_init (EAPMethodInterface *);
+
+G_DEFINE_TYPE_WITH_CODE (EAPMethodPEAP, eap_method_peap, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (eap_method_get_type (), eap_method_iface_init))
+
static void
-destroy (EAPMethod *parent)
+eap_method_peap_dispose (GObject *object)
{
- EAPMethodPEAP *self = (EAPMethodPEAP *) parent;
+ EAPMethodPEAP *self = EAP_METHOD_PEAP (object);
g_clear_object (&self->builder);
g_clear_object (&self->size_group);
+
+ G_OBJECT_CLASS (eap_method_peap_parent_class)->dispose (object);
}
static gboolean
-validate (EAPMethod *parent, GError **error)
+validate (EAPMethod *method, GError **error)
{
- EAPMethodPEAP *self = (EAPMethodPEAP *) parent;
+ EAPMethodPEAP *self = EAP_METHOD_PEAP (method);
GtkTreeModel *model;
GtkTreeIter iter;
g_autoptr(EAPMethod) eap = NULL;
@@ -102,9 +109,9 @@ ca_cert_not_required_toggled (EAPMethodPEAP *self)
}
static void
-add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
+add_to_size_group (EAPMethod *method, GtkSizeGroup *group)
{
- EAPMethodPEAP *self = (EAPMethodPEAP *) parent;
+ EAPMethodPEAP *self = EAP_METHOD_PEAP (method);
GtkTreeModel *model;
GtkTreeIter iter;
g_autoptr(EAPMethod) eap = NULL;
@@ -126,9 +133,9 @@ add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
}
static void
-fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFlags flags)
+fill_connection (EAPMethod *method, NMConnection *connection, NMSettingSecretFlags flags)
{
- EAPMethodPEAP *self = (EAPMethodPEAP *) parent;
+ EAPMethodPEAP *self = EAP_METHOD_PEAP (method);
NMSetting8021x *s_8021x;
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
const char *text;
@@ -154,7 +161,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
g_warning ("Couldn't read CA certificate '%s': %s", filename, error ? error->message :
"(unknown)");
ca_cert_error = TRUE;
}
- eap_method_ca_cert_ignore_set (parent, connection, filename, ca_cert_error);
+ eap_method_ca_cert_ignore_set (method, connection, filename, ca_cert_error);
peapver_active = gtk_combo_box_get_active (self->version_combo);
switch (peapver_active) {
@@ -286,31 +293,31 @@ inner_auth_combo_init (EAPMethodPEAP *self,
}
static void
-update_secrets (EAPMethod *parent, NMConnection *connection)
+update_secrets (EAPMethod *method, NMConnection *connection)
{
- EAPMethodPEAP *self = (EAPMethodPEAP *) parent;
- eap_method_phase2_update_secrets_helper (parent,
+ EAPMethodPEAP *self = EAP_METHOD_PEAP (method);
+ eap_method_phase2_update_secrets_helper (method,
connection,
self->inner_auth_combo,
I_METHOD_COLUMN);
}
static GtkWidget *
-get_widget (EAPMethod *parent)
+get_widget (EAPMethod *method)
{
- EAPMethodPEAP *self = (EAPMethodPEAP *) parent;
+ EAPMethodPEAP *self = EAP_METHOD_PEAP (method);
return GTK_WIDGET (self->grid);
}
static GtkWidget *
-get_default_field (EAPMethod *parent)
+get_default_field (EAPMethod *method)
{
- EAPMethodPEAP *self = (EAPMethodPEAP *) parent;
+ EAPMethodPEAP *self = EAP_METHOD_PEAP (method);
return GTK_WIDGET (self->anon_identity_entry);
}
static const gchar *
-get_password_flags_name (EAPMethod *parent)
+get_password_flags_name (EAPMethod *method)
{
return NM_SETTING_802_1X_PASSWORD;
}
@@ -321,33 +328,44 @@ changed_cb (EAPMethodPEAP *self)
wireless_security_notify_changed (self->sec_parent);
}
+static void
+eap_method_peap_init (EAPMethodPEAP *self)
+{
+}
+
+static void
+eap_method_peap_class_init (EAPMethodPEAPClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = eap_method_peap_dispose;
+}
+
+static void
+eap_method_iface_init (EAPMethodInterface *iface)
+{
+ iface->validate = validate;
+ iface->add_to_size_group = add_to_size_group;
+ iface->fill_connection = fill_connection;
+ iface->update_secrets = update_secrets;
+ iface->get_widget = get_widget;
+ iface->get_default_field = get_default_field;
+ iface->get_password_flags_name = get_password_flags_name;
+}
+
EAPMethodPEAP *
eap_method_peap_new (WirelessSecurity *ws_parent,
NMConnection *connection,
gboolean is_editor,
gboolean secrets_only)
{
- EAPMethod *parent;
EAPMethodPEAP *self;
GtkFileFilter *filter;
NMSetting8021x *s_8021x = NULL;
const char *filename;
g_autoptr(GError) error = NULL;
- parent = eap_method_init (sizeof (EAPMethodPEAP),
- validate,
- add_to_size_group,
- fill_connection,
- update_secrets,
- get_widget,
- get_default_field,
- get_password_flags_name,
- NULL,
- destroy);
- if (!parent)
- return NULL;
-
- self = (EAPMethodPEAP *) parent;
+ self = g_object_new (eap_method_peap_get_type (), NULL);
self->sec_parent = ws_parent;
self->is_editor = is_editor;
@@ -388,7 +406,7 @@ eap_method_peap_new (WirelessSecurity *ws_parent,
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (self->ca_cert_button),
filename);
}
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->ca_cert_not_required_check),
- !filename && eap_method_ca_cert_ignore_get (parent,
connection));
+ !filename && eap_method_ca_cert_ignore_get (EAP_METHOD (self),
connection));
}
inner_auth_combo_init (self, connection, s_8021x, secrets_only);
diff --git a/panels/network/wireless-security/eap-method-peap.h
b/panels/network/wireless-security/eap-method-peap.h
index 45625fb93..64952c689 100644
--- a/panels/network/wireless-security/eap-method-peap.h
+++ b/panels/network/wireless-security/eap-method-peap.h
@@ -20,20 +20,17 @@
* (C) Copyright 2007 - 2010 Red Hat, Inc.
*/
-#ifndef EAP_METHOD_PEAP_H
-#define EAP_METHOD_PEAP_H
+#pragma once
#include "wireless-security.h"
-typedef struct _EAPMethodPEAP EAPMethodPEAP;
+G_BEGIN_DECLS
+
+G_DECLARE_FINAL_TYPE (EAPMethodPEAP, eap_method_peap, EAP, METHOD_PEAP, GObject)
EAPMethodPEAP *eap_method_peap_new (WirelessSecurity *ws_parent,
NMConnection *connection,
gboolean is_editor,
gboolean secrets_only);
-static void eap_method_peap_unref (EAPMethodPEAP *method) { eap_method_unref (EAP_METHOD (method)); }
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (EAPMethodPEAP, eap_method_peap_unref)
-
-#endif /* EAP_METHOD_PEAP_H */
-
+G_END_DECLS
diff --git a/panels/network/wireless-security/eap-method-simple.c
b/panels/network/wireless-security/eap-method-simple.c
index 599b440f6..2eabf64d7 100644
--- a/panels/network/wireless-security/eap-method-simple.c
+++ b/panels/network/wireless-security/eap-method-simple.c
@@ -33,7 +33,7 @@
#include "utils.h"
struct _EAPMethodSimple {
- EAPMethod parent;
+ GObject parent;
GtkBuilder *builder;
GtkGrid *grid;
@@ -51,6 +51,11 @@ struct _EAPMethodSimple {
guint idle_func_id;
};
+static void eap_method_iface_init (EAPMethodInterface *);
+
+G_DEFINE_TYPE_WITH_CODE (EAPMethodSimple, eap_method_simple, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (eap_method_get_type (), eap_method_iface_init))
+
static void
show_toggled_cb (EAPMethodSimple *self)
{
@@ -68,9 +73,9 @@ always_ask_selected (GtkEntry *passwd_entry)
}
static gboolean
-validate (EAPMethod *parent, GError **error)
+validate (EAPMethod *method, GError **error)
{
- EAPMethodSimple *self = (EAPMethodSimple *)parent;
+ EAPMethodSimple *self = EAP_METHOD_SIMPLE (method);
const char *text;
gboolean ret = TRUE;
@@ -101,9 +106,9 @@ validate (EAPMethod *parent, GError **error)
}
static void
-add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
+add_to_size_group (EAPMethod *method, GtkSizeGroup *group)
{
- EAPMethodSimple *self = (EAPMethodSimple *) parent;
+ EAPMethodSimple *self = EAP_METHOD_SIMPLE (method);
gtk_size_group_add_widget (group, GTK_WIDGET (self->username_label));
gtk_size_group_add_widget (group, GTK_WIDGET (self->password_label));
}
@@ -126,9 +131,9 @@ static const EapType eap_table[EAP_METHOD_SIMPLE_TYPE_LAST] = {
};
static void
-fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFlags prev_flags)
+fill_connection (EAPMethod *method, NMConnection *connection, NMSettingSecretFlags prev_flags)
{
- EAPMethodSimple *self = (EAPMethodSimple *) parent;
+ EAPMethodSimple *self = EAP_METHOD_SIMPLE (method);
NMSetting8021x *s_8021x;
gboolean not_saved = FALSE;
NMSettingSecretFlags flags;
@@ -140,11 +145,11 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
/* If this is the main EAP method, clear any existing methods because the
* user-selected on will replace it.
*/
- if (eap_method_get_phase2 (parent) == FALSE)
+ if (eap_method_get_phase2 (method) == FALSE)
nm_setting_802_1x_clear_eap_methods (s_8021x);
eap_type = &eap_table[self->type];
- if (eap_method_get_phase2 (parent)) {
+ if (eap_method_get_phase2 (method)) {
/* If the outer EAP method (TLS, TTLS, PEAP, etc) allows inner/phase2
* EAP methods (which only TTLS allows) *and* the inner/phase2 method
* supports being an inner EAP method, then set PHASE2_AUTHEAP.
@@ -183,9 +188,9 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
}
static void
-update_secrets (EAPMethod *parent, NMConnection *connection)
+update_secrets (EAPMethod *method, NMConnection *connection)
{
- EAPMethodSimple *self = (EAPMethodSimple *) parent;
+ EAPMethodSimple *self = EAP_METHOD_SIMPLE (method);
helper_fill_secret_entry (connection,
self->password_entry,
NM_TYPE_SETTING_802_1X,
@@ -193,29 +198,29 @@ update_secrets (EAPMethod *parent, NMConnection *connection)
}
static GtkWidget *
-get_widget (EAPMethod *parent)
+get_widget (EAPMethod *method)
{
- EAPMethodSimple *self = (EAPMethodSimple *) parent;
+ EAPMethodSimple *self = EAP_METHOD_SIMPLE (method);
return GTK_WIDGET (self->grid);
}
static GtkWidget *
-get_default_field (EAPMethod *parent)
+get_default_field (EAPMethod *method)
{
- EAPMethodSimple *self = (EAPMethodSimple *) parent;
+ EAPMethodSimple *self = EAP_METHOD_SIMPLE (method);
return GTK_WIDGET (self->username_entry);
}
static const gchar *
-get_password_flags_name (EAPMethod *parent)
+get_password_flags_name (EAPMethod *method)
{
return NM_SETTING_802_1X_PASSWORD;
}
static const gboolean
-get_phase2 (EAPMethod *parent)
+get_phase2 (EAPMethod *method)
{
- EAPMethodSimple *self = (EAPMethodSimple *) parent;
+ EAPMethodSimple *self = EAP_METHOD_SIMPLE (method);
return self->flags & EAP_METHOD_SIMPLE_FLAG_PHASE2;
}
@@ -283,9 +288,9 @@ widgets_unrealized (EAPMethodSimple *self)
}
static void
-destroy (EAPMethod *parent)
+eap_method_simple_dispose (GObject *object)
{
- EAPMethodSimple *self = (EAPMethodSimple *) parent;
+ EAPMethodSimple *self = EAP_METHOD_SIMPLE (object);
g_clear_object (&self->builder);
g_signal_handlers_disconnect_by_data (self->grid, self);
@@ -295,6 +300,8 @@ destroy (EAPMethod *parent)
g_signal_handlers_disconnect_by_data (self->show_password_check, self);
nm_clear_g_source (&self->idle_func_id);
+
+ G_OBJECT_CLASS (eap_method_simple_parent_class)->dispose (object);
}
static void
@@ -303,31 +310,43 @@ changed_cb (EAPMethodSimple *self)
wireless_security_notify_changed (self->ws_parent);
}
+static void
+eap_method_simple_init (EAPMethodSimple *self)
+{
+}
+
+static void
+eap_method_simple_class_init (EAPMethodSimpleClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = eap_method_simple_dispose;
+}
+
+static void
+eap_method_iface_init (EAPMethodInterface *iface)
+{
+ iface->validate = validate;
+ iface->add_to_size_group = add_to_size_group;
+ iface->fill_connection = fill_connection;
+ iface->update_secrets = update_secrets;
+ iface->get_widget = get_widget;
+ iface->get_default_field = get_default_field;
+ iface->get_password_flags_name = get_password_flags_name;
+ iface->get_phase2 = get_phase2;
+}
+
EAPMethodSimple *
eap_method_simple_new (WirelessSecurity *ws_parent,
NMConnection *connection,
EAPMethodSimpleType type,
EAPMethodSimpleFlags flags)
{
- EAPMethod *parent;
EAPMethodSimple *self;
NMSetting8021x *s_8021x = NULL;
g_autoptr(GError) error = NULL;
- parent = eap_method_init (sizeof (EAPMethodSimple),
- validate,
- add_to_size_group,
- fill_connection,
- update_secrets,
- get_widget,
- get_default_field,
- get_password_flags_name,
- get_phase2,
- destroy);
- if (!parent)
- return NULL;
-
- self = (EAPMethodSimple *) parent;
+ self = g_object_new (eap_method_simple_get_type (), NULL);
self->ws_parent = ws_parent;
self->flags = flags;
self->type = type;
diff --git a/panels/network/wireless-security/eap-method-simple.h
b/panels/network/wireless-security/eap-method-simple.h
index 8a2c3400e..be418dd09 100644
--- a/panels/network/wireless-security/eap-method-simple.h
+++ b/panels/network/wireless-security/eap-method-simple.h
@@ -20,11 +20,14 @@
* (C) Copyright 2007 - 2010 Red Hat, Inc.
*/
-#ifndef EAP_METHOD_SIMPLE_H
-#define EAP_METHOD_SIMPLE_H
+#pragma once
#include "wireless-security.h"
+G_BEGIN_DECLS
+
+G_DECLARE_FINAL_TYPE (EAPMethodSimple, eap_method_simple, EAP, METHOD_SIMPLE, GObject)
+
typedef enum {
/* NOTE: when updating this table, also update eap_methods[] */
EAP_METHOD_SIMPLE_TYPE_PAP = 0,
@@ -52,15 +55,9 @@ typedef enum {
EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY = 0x08
} EAPMethodSimpleFlags;
-typedef struct _EAPMethodSimple EAPMethodSimple;
-
EAPMethodSimple *eap_method_simple_new (WirelessSecurity *ws_parent,
NMConnection *connection,
EAPMethodSimpleType type,
EAPMethodSimpleFlags flags);
-static void eap_method_simple_unref (EAPMethodSimple *method) { eap_method_unref (EAP_METHOD (method)); }
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (EAPMethodSimple, eap_method_simple_unref)
-
-#endif /* EAP_METHOD_SIMPLE_H */
-
+G_END_DECLS
diff --git a/panels/network/wireless-security/eap-method-tls.c
b/panels/network/wireless-security/eap-method-tls.c
index 13e85689a..8263d56e6 100644
--- a/panels/network/wireless-security/eap-method-tls.c
+++ b/panels/network/wireless-security/eap-method-tls.c
@@ -33,7 +33,7 @@
#include "utils.h"
struct _EAPMethodTLS {
- EAPMethod parent;
+ GObject parent;
GtkBuilder *builder;
GtkFileChooserButton *ca_cert_button;
@@ -56,12 +56,19 @@ struct _EAPMethodTLS {
gboolean editing_connection;
};
+static void eap_method_iface_init (EAPMethodInterface *);
+
+G_DEFINE_TYPE_WITH_CODE (EAPMethodTLS, eap_method_tls, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (eap_method_get_type (), eap_method_iface_init))
+
static void
-destroy (EAPMethod *parent)
+eap_method_tls_dispose (GObject *object)
{
- EAPMethodTLS *self = (EAPMethodTLS *) parent;
+ EAPMethodTLS *self = EAP_METHOD_TLS (object);
g_clear_object (&self->builder);
+
+ G_OBJECT_CLASS (eap_method_tls_parent_class)->dispose (object);
}
static void
@@ -74,9 +81,9 @@ show_toggled_cb (EAPMethodTLS *self)
}
static gboolean
-validate (EAPMethod *parent, GError **error)
+validate (EAPMethod *method, GError **error)
{
- EAPMethodTLS *self = (EAPMethodTLS *) parent;
+ EAPMethodTLS *self = EAP_METHOD_TLS (method);
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
const char *password, *identity;
g_autoptr(GError) ca_cert_error = NULL;
@@ -146,9 +153,9 @@ ca_cert_not_required_toggled (EAPMethodTLS *self)
}
static void
-add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
+add_to_size_group (EAPMethod *method, GtkSizeGroup *group)
{
- EAPMethodTLS *self = (EAPMethodTLS *) parent;
+ EAPMethodTLS *self = EAP_METHOD_TLS (method);
gtk_size_group_add_widget (group, GTK_WIDGET (self->ca_cert_not_required_check));
gtk_size_group_add_widget (group, GTK_WIDGET (self->identity_label));
@@ -159,9 +166,9 @@ add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
}
static void
-fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFlags flags)
+fill_connection (EAPMethod *method, NMConnection *connection, NMSettingSecretFlags flags)
{
- EAPMethodTLS *self = (EAPMethodTLS *) parent;
+ EAPMethodTLS *self = EAP_METHOD_TLS (method);
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
NMSetting8021x *s_8021x;
NMSettingSecretFlags secret_flags;
@@ -246,13 +253,12 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
ca_cert_error = TRUE;
}
}
- eap_method_ca_cert_ignore_set (parent, connection, ca_filename, ca_cert_error);
+ eap_method_ca_cert_ignore_set (method, connection, ca_filename, ca_cert_error);
}
static void
-private_key_picker_helper (EAPMethod *parent, const char *filename, gboolean changed)
+private_key_picker_helper (EAPMethodTLS *self, const char *filename, gboolean changed)
{
- EAPMethodTLS *self = (EAPMethodTLS *) parent;
g_autoptr(NMSetting8021x) setting = NULL;
NMSetting8021xCKFormat cert_format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
const char *password;
@@ -296,12 +302,12 @@ private_key_picker_helper (EAPMethod *parent, const char *filename, gboolean cha
static void
private_key_picker_file_set_cb (GtkWidget *chooser, gpointer user_data)
{
- EAPMethod *parent = (EAPMethod *) user_data;
+ EAPMethodTLS *self = user_data;
g_autofree gchar *filename = NULL;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
if (filename)
- private_key_picker_helper (parent, filename, TRUE);
+ private_key_picker_helper (self, filename, TRUE);
}
static void reset_filter (GtkWidget *widget, GParamSpec *spec, gpointer user_data)
@@ -323,10 +329,10 @@ changed_cb (EAPMethodTLS *self)
}
static void
-setup_filepicker (GtkFileChooserButton *button,
+setup_filepicker (EAPMethodTLS *self,
+ GtkFileChooserButton *button,
const char *title,
WirelessSecurity *ws_parent,
- EAPMethod *parent,
NMSetting8021x *s_8021x,
SchemeFunc scheme_func,
PathFunc path_func,
@@ -353,12 +359,12 @@ setup_filepicker (GtkFileChooserButton *button,
if (privkey) {
g_signal_connect (button, "selection-changed",
(GCallback) private_key_picker_file_set_cb,
- parent);
+ self);
if (filename)
- private_key_picker_helper (parent, filename, FALSE);
+ private_key_picker_helper (self, filename, FALSE);
}
- g_signal_connect_swapped (button, "selection-changed", G_CALLBACK (changed_cb), parent);
+ g_signal_connect_swapped (button, "selection-changed", G_CALLBACK (changed_cb), self);
filter = eap_method_default_file_chooser_filter_new (privkey);
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (button), filter);
@@ -373,9 +379,9 @@ setup_filepicker (GtkFileChooserButton *button,
}
static void
-update_secrets (EAPMethod *parent, NMConnection *connection)
+update_secrets (EAPMethod *method, NMConnection *connection)
{
- EAPMethodTLS *self = (EAPMethodTLS *) parent;
+ EAPMethodTLS *self = EAP_METHOD_TLS (method);
NMSetting8021x *s_8021x;
HelperSecretFunc password_func;
SchemeFunc scheme_func;
@@ -407,33 +413,59 @@ update_secrets (EAPMethod *parent, NMConnection *connection)
}
static GtkWidget *
-get_widget (EAPMethod *parent)
+get_widget (EAPMethod *method)
{
- EAPMethodTLS *self = (EAPMethodTLS *) parent;
+ EAPMethodTLS *self = EAP_METHOD_TLS (method);
return GTK_WIDGET (self->grid);
}
static GtkWidget *
-get_default_field (EAPMethod *parent)
+get_default_field (EAPMethod *method)
{
- EAPMethodTLS *self = (EAPMethodTLS *) parent;
+ EAPMethodTLS *self = EAP_METHOD_TLS (method);
return GTK_WIDGET (self->identity_entry);
}
static const gchar *
-get_password_flags_name (EAPMethod *parent)
+get_password_flags_name (EAPMethod *method)
{
- EAPMethodTLS *self = (EAPMethodTLS *) parent;
+ EAPMethodTLS *self = EAP_METHOD_TLS (method);
return self->password_flags_name;
}
static gboolean
-get_phase2 (EAPMethod *parent)
+get_phase2 (EAPMethod *method)
{
- EAPMethodTLS *self = (EAPMethodTLS *) parent;
+ EAPMethodTLS *self = EAP_METHOD_TLS (method);
return self->phase2;
}
+static void
+eap_method_tls_init (EAPMethodTLS *self)
+{
+}
+
+static void
+eap_method_tls_class_init (EAPMethodTLSClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = eap_method_tls_dispose;
+}
+
+static void
+eap_method_iface_init (EAPMethodInterface *iface)
+{
+ iface->validate = validate;
+ iface->add_to_size_group = add_to_size_group;
+ iface->fill_connection = fill_connection;
+ iface->update_secrets = update_secrets;
+ iface->get_widget = get_widget;
+ iface->get_default_field = get_default_field;
+ iface->get_password_flags_name = get_password_flags_name;
+ iface->get_phase2 = get_phase2;
+}
+
EAPMethodTLS *
eap_method_tls_new (WirelessSecurity *ws_parent,
NMConnection *connection,
@@ -441,25 +473,11 @@ eap_method_tls_new (WirelessSecurity *ws_parent,
gboolean secrets_only)
{
EAPMethodTLS *self;
- EAPMethod *parent;
NMSetting8021x *s_8021x = NULL;
gboolean ca_not_required = FALSE;
g_autoptr(GError) error = NULL;
- parent = eap_method_init (sizeof (EAPMethodTLS),
- validate,
- add_to_size_group,
- fill_connection,
- update_secrets,
- get_widget,
- get_default_field,
- get_password_flags_name,
- get_phase2,
- destroy);
- if (!parent)
- return NULL;
-
- self = (EAPMethodTLS *) parent;
+ self = g_object_new (eap_method_tls_get_type (), NULL);
self->phase2 = phase2;
self->password_flags_name = phase2 ?
NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD :
@@ -496,32 +514,35 @@ eap_method_tls_new (WirelessSecurity *ws_parent,
if (s_8021x && nm_setting_802_1x_get_identity (s_8021x))
gtk_entry_set_text (self->identity_entry, nm_setting_802_1x_get_identity (s_8021x));
- setup_filepicker (self->user_cert_button,
+ setup_filepicker (self,
+ self->user_cert_button,
_("Choose your personal certificate"),
- ws_parent, parent, s_8021x,
+ ws_parent, s_8021x,
phase2 ? nm_setting_802_1x_get_phase2_client_cert_scheme :
nm_setting_802_1x_get_client_cert_scheme,
phase2 ? nm_setting_802_1x_get_phase2_client_cert_path :
nm_setting_802_1x_get_client_cert_path,
FALSE, TRUE);
- setup_filepicker (self->ca_cert_button,
+ setup_filepicker (self,
+ self->ca_cert_button,
_("Choose a Certificate Authority certificate"),
- ws_parent, parent, s_8021x,
+ ws_parent, s_8021x,
phase2 ? nm_setting_802_1x_get_phase2_ca_cert_scheme :
nm_setting_802_1x_get_ca_cert_scheme,
phase2 ? nm_setting_802_1x_get_phase2_ca_cert_path :
nm_setting_802_1x_get_ca_cert_path,
FALSE, FALSE);
- setup_filepicker (self->private_key_button,
+ setup_filepicker (self,
+ self->private_key_button,
_("Choose your private key"),
- ws_parent, parent, s_8021x,
+ ws_parent, s_8021x,
phase2 ? nm_setting_802_1x_get_phase2_private_key_scheme :
nm_setting_802_1x_get_private_key_scheme,
phase2 ? nm_setting_802_1x_get_phase2_private_key_path :
nm_setting_802_1x_get_private_key_path,
TRUE, FALSE);
- if (connection && eap_method_ca_cert_ignore_get (parent, connection))
+ if (connection && eap_method_ca_cert_ignore_get (EAP_METHOD (self), connection))
ca_not_required = !gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (self->ca_cert_button));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->ca_cert_not_required_check), ca_not_required);
/* Fill secrets, if any */
if (connection)
- update_secrets (parent, connection);
+ update_secrets (EAP_METHOD (self), connection);
g_signal_connect_swapped (self->private_key_password_entry, "changed", G_CALLBACK (changed_cb), self);
diff --git a/panels/network/wireless-security/eap-method-tls.h
b/panels/network/wireless-security/eap-method-tls.h
index 341580f09..3507b0ffc 100644
--- a/panels/network/wireless-security/eap-method-tls.h
+++ b/panels/network/wireless-security/eap-method-tls.h
@@ -20,20 +20,17 @@
* (C) Copyright 2007 - 2010 Red Hat, Inc.
*/
-#ifndef EAP_METHOD_TLS_H
-#define EAP_METHOD_TLS_H
+#pragma once
#include "wireless-security.h"
-typedef struct _EAPMethodTLS EAPMethodTLS;
+G_BEGIN_DECLS
+
+G_DECLARE_FINAL_TYPE (EAPMethodTLS, eap_method_tls, EAP, METHOD_TLS, GObject)
EAPMethodTLS *eap_method_tls_new (WirelessSecurity *ws_parent,
NMConnection *connection,
gboolean phase2,
gboolean secrets_only);
-static void eap_method_tls_unref (EAPMethodTLS *method) { eap_method_unref (EAP_METHOD (method)); }
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (EAPMethodTLS, eap_method_tls_unref)
-
-#endif /* EAP_METHOD_TLS_H */
-
+G_END_DECLS
diff --git a/panels/network/wireless-security/eap-method-ttls.c
b/panels/network/wireless-security/eap-method-ttls.c
index 9a9553dec..e21c2f83e 100644
--- a/panels/network/wireless-security/eap-method-ttls.c
+++ b/panels/network/wireless-security/eap-method-ttls.c
@@ -35,7 +35,7 @@
#define I_METHOD_COLUMN 1
struct _EAPMethodTTLS {
- EAPMethod parent;
+ GObject parent;
GtkBuilder *builder;
GtkEntry *anon_identity_entry;
@@ -55,19 +55,26 @@ struct _EAPMethodTTLS {
gboolean is_editor;
};
+static void eap_method_iface_init (EAPMethodInterface *);
+
+G_DEFINE_TYPE_WITH_CODE (EAPMethodTTLS, eap_method_ttls, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (eap_method_get_type (), eap_method_iface_init))
+
static void
-destroy (EAPMethod *parent)
+eap_method_ttls_dispose (GObject *object)
{
- EAPMethodTTLS *self = (EAPMethodTTLS *) parent;
+ EAPMethodTTLS *self = EAP_METHOD_TTLS (object);
g_clear_object (&self->builder);
g_clear_object (&self->size_group);
+
+ G_OBJECT_CLASS (eap_method_ttls_parent_class)->dispose (object);
}
static gboolean
-validate (EAPMethod *parent, GError **error)
+validate (EAPMethod *method, GError **error)
{
- EAPMethodTTLS *self = (EAPMethodTTLS *) parent;
+ EAPMethodTTLS *self = EAP_METHOD_TTLS (method);
GtkTreeModel *model;
GtkTreeIter iter;
g_autoptr(EAPMethod) eap = NULL;
@@ -102,9 +109,9 @@ ca_cert_not_required_toggled (EAPMethodTTLS *self)
}
static void
-add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
+add_to_size_group (EAPMethod *method, GtkSizeGroup *group)
{
- EAPMethodTTLS *self = (EAPMethodTTLS *) parent;
+ EAPMethodTTLS *self = EAP_METHOD_TTLS (method);
GtkTreeModel *model;
GtkTreeIter iter;
g_autoptr(EAPMethod) eap = NULL;
@@ -126,9 +133,9 @@ add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
}
static void
-fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFlags flags)
+fill_connection (EAPMethod *method, NMConnection *connection, NMSettingSecretFlags flags)
{
- EAPMethodTTLS *self = (EAPMethodTTLS *) parent;
+ EAPMethodTTLS *self = EAP_METHOD_TTLS (method);
NMSetting8021x *s_8021x;
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
const char *text;
@@ -157,7 +164,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
g_warning ("Couldn't read CA certificate '%s': %s", filename, error ? error->message :
"(unknown)");
ca_cert_error = TRUE;
}
- eap_method_ca_cert_ignore_set (parent, connection, filename, ca_cert_error);
+ eap_method_ca_cert_ignore_set (method, connection, filename, ca_cert_error);
model = gtk_combo_box_get_model (self->inner_auth_combo);
gtk_combo_box_get_active_iter (self->inner_auth_combo, &iter);
@@ -339,31 +346,31 @@ inner_auth_combo_init (EAPMethodTTLS *self,
}
static void
-update_secrets (EAPMethod *parent, NMConnection *connection)
+update_secrets (EAPMethod *method, NMConnection *connection)
{
- EAPMethodTTLS *self = (EAPMethodTTLS *) parent;
- eap_method_phase2_update_secrets_helper (parent,
+ EAPMethodTTLS *self = EAP_METHOD_TTLS (method);
+ eap_method_phase2_update_secrets_helper (method,
connection,
self->inner_auth_combo,
I_METHOD_COLUMN);
}
static GtkWidget *
-get_widget (EAPMethod *parent)
+get_widget (EAPMethod *method)
{
- EAPMethodTTLS *self = (EAPMethodTTLS *) parent;
+ EAPMethodTTLS *self = EAP_METHOD_TTLS (method);
return GTK_WIDGET (self->grid);
}
static GtkWidget *
-get_default_field (EAPMethod *parent)
+get_default_field (EAPMethod *method)
{
- EAPMethodTTLS *self = (EAPMethodTTLS *) parent;
+ EAPMethodTTLS *self = EAP_METHOD_TTLS (method);
return GTK_WIDGET (self->anon_identity_entry);
}
static const gchar *
-get_password_flags_name (EAPMethod *parent)
+get_password_flags_name (EAPMethod *method)
{
return NM_SETTING_802_1X_PASSWORD;
}
@@ -374,33 +381,44 @@ changed_cb (EAPMethodTTLS *self)
wireless_security_notify_changed (self->sec_parent);
}
+static void
+eap_method_ttls_init (EAPMethodTTLS *self)
+{
+}
+
+static void
+eap_method_ttls_class_init (EAPMethodTTLSClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = eap_method_ttls_dispose;
+}
+
+static void
+eap_method_iface_init (EAPMethodInterface *iface)
+{
+ iface->validate = validate;
+ iface->add_to_size_group = add_to_size_group;
+ iface->fill_connection = fill_connection;
+ iface->update_secrets = update_secrets;
+ iface->get_widget = get_widget;
+ iface->get_default_field = get_default_field;
+ iface->get_password_flags_name = get_password_flags_name;
+}
+
EAPMethodTTLS *
eap_method_ttls_new (WirelessSecurity *ws_parent,
NMConnection *connection,
gboolean is_editor,
gboolean secrets_only)
{
- EAPMethod *parent;
EAPMethodTTLS *self;
GtkFileFilter *filter;
NMSetting8021x *s_8021x = NULL;
const char *filename;
g_autoptr(GError) error = NULL;
- parent = eap_method_init (sizeof (EAPMethodTTLS),
- validate,
- add_to_size_group,
- fill_connection,
- update_secrets,
- get_widget,
- get_default_field,
- get_password_flags_name,
- NULL,
- destroy);
- if (!parent)
- return NULL;
-
- self = (EAPMethodTTLS *) parent;
+ self = g_object_new (eap_method_ttls_get_type (), NULL);
self->sec_parent = ws_parent;
self->is_editor = is_editor;
@@ -441,7 +459,7 @@ eap_method_ttls_new (WirelessSecurity *ws_parent,
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (self->ca_cert_button),
filename);
}
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->ca_cert_not_required_check),
- !filename && eap_method_ca_cert_ignore_get (parent,
connection));
+ !filename && eap_method_ca_cert_ignore_get (EAP_METHOD (self),
connection));
}
if (s_8021x && nm_setting_802_1x_get_anonymous_identity (s_8021x))
diff --git a/panels/network/wireless-security/eap-method-ttls.h
b/panels/network/wireless-security/eap-method-ttls.h
index 836a6d9e6..58af57805 100644
--- a/panels/network/wireless-security/eap-method-ttls.h
+++ b/panels/network/wireless-security/eap-method-ttls.h
@@ -20,20 +20,17 @@
* (C) Copyright 2007 - 2010 Red Hat, Inc.
*/
-#ifndef EAP_METHOD_TTLS_H
-#define EAP_METHOD_TTLS_H
+#pragma once
#include "wireless-security.h"
-typedef struct _EAPMethodTTLS EAPMethodTTLS;
+G_BEGIN_DECLS
+
+G_DECLARE_FINAL_TYPE (EAPMethodTTLS, eap_method_ttls, EAP, METHOD_TTLS, GObject)
EAPMethodTTLS *eap_method_ttls_new (WirelessSecurity *ws_parent,
NMConnection *connection,
gboolean is_editor,
gboolean secrets_only);
-static void eap_method_ttls_unref (EAPMethodTTLS *method) { eap_method_unref (EAP_METHOD (method)); }
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (EAPMethodTTLS, eap_method_ttls_unref)
-
-#endif /* EAP_METHOD_TTLS_H */
-
+G_END_DECLS
diff --git a/panels/network/wireless-security/eap-method.c b/panels/network/wireless-security/eap-method.c
index 3bad3d9b6..e1a147c03 100644
--- a/panels/network/wireless-security/eap-method.c
+++ b/panels/network/wireless-security/eap-method.c
@@ -33,18 +33,11 @@
#include "utils.h"
#include "helpers.h"
-GType
-eap_method_get_type (void)
-{
- static GType type_id = 0;
-
- if (!type_id) {
- type_id = g_boxed_type_register_static ("CcEAPMethod",
- (GBoxedCopyFunc) eap_method_ref,
- (GBoxedFreeFunc) eap_method_unref);
- }
+G_DEFINE_INTERFACE (EAPMethod, eap_method, G_TYPE_OBJECT)
- return type_id;
+static void
+eap_method_default_init (EAPMethodInterface *iface)
+{
}
GtkWidget *
@@ -52,7 +45,7 @@ eap_method_get_widget (EAPMethod *self)
{
g_return_val_if_fail (self != NULL, NULL);
- return self->get_widget (self);
+ return EAP_METHOD_GET_IFACE (self)->get_widget (self);
}
GtkWidget *
@@ -60,7 +53,7 @@ eap_method_get_default_field (EAPMethod *self)
{
g_return_val_if_fail (self != NULL, NULL);
- return self->get_default_field (self);
+ return EAP_METHOD_GET_IFACE (self)->get_default_field (self);
}
const gchar *
@@ -68,8 +61,8 @@ eap_method_get_password_flags_name (EAPMethod *self)
{
g_return_val_if_fail (self != NULL, NULL);
- if (self->get_password_flags_name)
- return self->get_password_flags_name (self);
+ if (EAP_METHOD_GET_IFACE (self)->get_password_flags_name)
+ return EAP_METHOD_GET_IFACE (self)->get_password_flags_name (self);
else
return NULL;
}
@@ -79,8 +72,8 @@ eap_method_get_phase2 (EAPMethod *self)
{
g_return_val_if_fail (self != NULL, FALSE);
- if (self->get_phase2)
- return self->get_phase2 (self);
+ if (EAP_METHOD_GET_IFACE (self)->get_phase2)
+ return EAP_METHOD_GET_IFACE (self)->get_phase2 (self);
else
return FALSE;
}
@@ -92,8 +85,7 @@ eap_method_validate (EAPMethod *self, GError **error)
g_return_val_if_fail (self != NULL, FALSE);
- g_assert (self->validate);
- result = (*(self->validate)) (self, error);
+ result = (*(EAP_METHOD_GET_IFACE (self)->validate)) (self, error);
if (!result && error && !*error)
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("undefined error in 802.1X
security (wpa-eap)"));
return result;
@@ -105,8 +97,7 @@ eap_method_add_to_size_group (EAPMethod *self, GtkSizeGroup *group)
g_return_if_fail (self != NULL);
g_return_if_fail (group != NULL);
- g_assert (self->add_to_size_group);
- return (*(self->add_to_size_group)) (self, group);
+ return (*(EAP_METHOD_GET_IFACE (self)->add_to_size_group)) (self, group);
}
void
@@ -117,8 +108,7 @@ eap_method_fill_connection (EAPMethod *self,
g_return_if_fail (self != NULL);
g_return_if_fail (connection != NULL);
- g_assert (self->fill_connection);
- return (*(self->fill_connection)) (self, connection, flags);
+ return (*(EAP_METHOD_GET_IFACE (self)->fill_connection)) (self, connection, flags);
}
void
@@ -141,72 +131,12 @@ eap_method_phase2_update_secrets_helper (EAPMethod *self,
g_autoptr(EAPMethod) eap = NULL;
gtk_tree_model_get (model, &iter, column, &eap, -1);
- if (eap && eap->update_secrets)
- eap->update_secrets (self, connection);
+ if (eap && EAP_METHOD_GET_IFACE (eap)->update_secrets)
+ EAP_METHOD_GET_IFACE (eap)->update_secrets (self, connection);
} while (gtk_tree_model_iter_next (model, &iter));
}
}
-EAPMethod *
-eap_method_init (gsize obj_size,
- EMValidateFunc validate,
- EMAddToSizeGroupFunc add_to_size_group,
- EMFillConnectionFunc fill_connection,
- EMUpdateSecretsFunc update_secrets,
- EMGetWidgetFunc get_widget,
- EMGetWidgetFunc get_default_field,
- EMGetStringFunc get_password_flags_name,
- EMGetBooleanFunc get_phase2,
- EMDestroyFunc destroy)
-{
- g_autoptr(EAPMethod) self = NULL;
-
- g_return_val_if_fail (obj_size > 0, NULL);
-
- self = g_slice_alloc0 (obj_size);
- g_assert (self);
-
- self->refcount = 1;
- self->obj_size = obj_size;
- self->validate = validate;
- self->add_to_size_group = add_to_size_group;
- self->fill_connection = fill_connection;
- self->update_secrets = update_secrets;
- self->get_widget = get_widget;
- self->get_default_field = get_default_field;
- self->get_password_flags_name = get_password_flags_name;
- self->get_phase2 = get_phase2;
- self->destroy = destroy;
-
- return g_steal_pointer (&self);
-}
-
-
-EAPMethod *
-eap_method_ref (EAPMethod *self)
-{
- g_return_val_if_fail (self != NULL, NULL);
- g_return_val_if_fail (self->refcount > 0, NULL);
-
- self->refcount++;
- return self;
-}
-
-void
-eap_method_unref (EAPMethod *self)
-{
- g_return_if_fail (self != NULL);
- g_return_if_fail (self->refcount > 0);
-
- self->refcount--;
- if (self->refcount == 0) {
- if (self->destroy)
- self->destroy (self);
-
- g_slice_free1 (self->obj_size, self);
- }
-}
-
gboolean
eap_method_validate_filepicker (GtkFileChooser *chooser,
guint32 item_type,
diff --git a/panels/network/wireless-security/eap-method.h b/panels/network/wireless-security/eap-method.h
index 199dbfc06..3910a9e9f 100644
--- a/panels/network/wireless-security/eap-method.h
+++ b/panels/network/wireless-security/eap-method.h
@@ -20,39 +20,27 @@
* Copyright 2007 - 2014 Red Hat, Inc.
*/
-#ifndef EAP_METHOD_H
-#define EAP_METHOD_H
+#pragma once
+#include <glib-object.h>
#include <NetworkManager.h>
-typedef struct _EAPMethod EAPMethod;
-
-typedef void (*EMAddToSizeGroupFunc) (EAPMethod *method, GtkSizeGroup *group);
-typedef void (*EMFillConnectionFunc) (EAPMethod *method, NMConnection *connection,
NMSettingSecretFlags flags);
-typedef void (*EMUpdateSecretsFunc) (EAPMethod *method, NMConnection *connection);
-typedef void (*EMDestroyFunc) (EAPMethod *method);
-typedef gboolean (*EMValidateFunc) (EAPMethod *method, GError **error);
-typedef GtkWidget* (*EMGetWidgetFunc) (EAPMethod *method);
-typedef const gchar* (*EMGetStringFunc) (EAPMethod *method);
-typedef gboolean (*EMGetBooleanFunc) (EAPMethod *method);
-
-struct _EAPMethod {
- guint32 refcount;
- gsize obj_size;
-
- EMAddToSizeGroupFunc add_to_size_group;
- EMFillConnectionFunc fill_connection;
- EMUpdateSecretsFunc update_secrets;
- EMValidateFunc validate;
- EMGetWidgetFunc get_widget;
- EMGetWidgetFunc get_default_field;
- EMGetStringFunc get_password_flags_name;
- EMGetBooleanFunc get_phase2;
- EMDestroyFunc destroy;
-};
+G_BEGIN_DECLS
+
+G_DECLARE_INTERFACE (EAPMethod, eap_method, EAP, METHOD, GObject)
-#define EAP_METHOD(x) ((EAPMethod *) x)
+struct _EAPMethodInterface {
+ GTypeInterface g_iface;
+ void (*add_to_size_group) (EAPMethod *method, GtkSizeGroup *group);
+ void (*fill_connection) (EAPMethod *method, NMConnection *connection,
NMSettingSecretFlags flags);
+ void (*update_secrets) (EAPMethod *method, NMConnection *connection);
+ gboolean (*validate) (EAPMethod *method, GError **error);
+ GtkWidget* (*get_widget) (EAPMethod *method);
+ GtkWidget* (*get_default_field) (EAPMethod *method);
+ const gchar* (*get_password_flags_name) (EAPMethod *method);
+ gboolean (*get_phase2) (EAPMethod *method);
+};
GtkWidget *eap_method_get_widget (EAPMethod *method);
@@ -70,25 +58,8 @@ void eap_method_fill_connection (EAPMethod *method,
NMConnection *connection,
NMSettingSecretFlags flags);
-EAPMethod *eap_method_ref (EAPMethod *method);
-
-void eap_method_unref (EAPMethod *method);
-
-GType eap_method_get_type (void);
-
/* Below for internal use only */
-EAPMethod *eap_method_init (gsize obj_size,
- EMValidateFunc validate,
- EMAddToSizeGroupFunc add_to_size_group,
- EMFillConnectionFunc fill_connection,
- EMUpdateSecretsFunc update_secrets,
- EMGetWidgetFunc get_widget,
- EMGetWidgetFunc get_default_field,
- EMGetStringFunc get_password_flags_name,
- EMGetBooleanFunc get_phase2,
- EMDestroyFunc destroy);
-
GtkFileFilter * eap_method_default_file_chooser_filter_new (gboolean privkey);
gboolean eap_method_is_encrypted_private_key (const char *path);
@@ -122,6 +93,4 @@ gboolean eap_method_ca_cert_ignore_get (EAPMethod *method, NMConnection *connect
void eap_method_ca_cert_ignore_save (NMConnection *connection);
void eap_method_ca_cert_ignore_load (NMConnection *connection);
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (EAPMethod, eap_method_unref)
-
-#endif /* EAP_METHOD_H */
+G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]