[gnome-control-center] network: Simplify helper function
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Simplify helper function
- Date: Wed, 27 Nov 2019 22:11:44 +0000 (UTC)
commit 20097e2cbe6b777d94c5380507cabddb1e841f05
Author: Robert Ancell <robert ancell canonical com>
Date: Mon Nov 11 12:00:49 2019 +1300
network: Simplify helper function
The function took internal details of the few classes that were using it.
panels/network/wireless-security/eap-method-fast.c | 17 ++++++++---
panels/network/wireless-security/eap-method-peap.c | 17 ++++++++---
panels/network/wireless-security/eap-method-ttls.c | 17 ++++++++---
panels/network/wireless-security/eap-method.c | 35 ++++++----------------
panels/network/wireless-security/eap-method.h | 7 ++---
5 files changed, 50 insertions(+), 43 deletions(-)
---
diff --git a/panels/network/wireless-security/eap-method-fast.c
b/panels/network/wireless-security/eap-method-fast.c
index acb4b6f5b..929c3725c 100644
--- a/panels/network/wireless-security/eap-method-fast.c
+++ b/panels/network/wireless-security/eap-method-fast.c
@@ -270,10 +270,19 @@ static void
update_secrets (EAPMethod *parent, NMConnection *connection)
{
EAPMethodFAST *self = (EAPMethodFAST *) parent;
- eap_method_phase2_update_secrets_helper (parent,
- connection,
- self->inner_auth_combo,
- I_METHOD_COLUMN);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ model = gtk_combo_box_get_model (self->inner_auth_combo);
+ if (!gtk_tree_model_get_iter_first (model, &iter))
+ return;
+
+ do {
+ g_autoptr(EAPMethod) eap = NULL;
+
+ gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
+ eap_method_update_secrets (eap, connection);
+ } while (gtk_tree_model_iter_next (model, &iter));
}
static GtkWidget *
diff --git a/panels/network/wireless-security/eap-method-peap.c
b/panels/network/wireless-security/eap-method-peap.c
index 28e298e28..d772b8aaa 100644
--- a/panels/network/wireless-security/eap-method-peap.c
+++ b/panels/network/wireless-security/eap-method-peap.c
@@ -290,10 +290,19 @@ static void
update_secrets (EAPMethod *method, NMConnection *connection)
{
EAPMethodPEAP *self = EAP_METHOD_PEAP (method);
- eap_method_phase2_update_secrets_helper (method,
- connection,
- self->inner_auth_combo,
- I_METHOD_COLUMN);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ model = gtk_combo_box_get_model (self->inner_auth_combo);
+ if (!gtk_tree_model_get_iter_first (model, &iter))
+ return;
+
+ do {
+ g_autoptr(EAPMethod) eap = NULL;
+
+ gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
+ eap_method_update_secrets (eap, connection);
+ } while (gtk_tree_model_iter_next (model, &iter));
}
static GtkWidget *
diff --git a/panels/network/wireless-security/eap-method-ttls.c
b/panels/network/wireless-security/eap-method-ttls.c
index 6fb07894e..531528c07 100644
--- a/panels/network/wireless-security/eap-method-ttls.c
+++ b/panels/network/wireless-security/eap-method-ttls.c
@@ -343,10 +343,19 @@ static void
update_secrets (EAPMethod *method, NMConnection *connection)
{
EAPMethodTTLS *self = EAP_METHOD_TTLS (method);
- eap_method_phase2_update_secrets_helper (method,
- connection,
- self->inner_auth_combo,
- I_METHOD_COLUMN);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ model = gtk_combo_box_get_model (self->inner_auth_combo);
+ if (!gtk_tree_model_get_iter_first (model, &iter))
+ return;
+
+ do {
+ g_autoptr(EAPMethod) eap = NULL;
+
+ gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
+ eap_method_update_secrets (eap, connection);
+ } while (gtk_tree_model_iter_next (model, &iter));
}
static GtkWidget *
diff --git a/panels/network/wireless-security/eap-method.c b/panels/network/wireless-security/eap-method.c
index c309609b7..ce76885b4 100644
--- a/panels/network/wireless-security/eap-method.c
+++ b/panels/network/wireless-security/eap-method.c
@@ -83,6 +83,15 @@ eap_method_validate (EAPMethod *self, GError **error)
return result;
}
+void
+eap_method_update_secrets (EAPMethod *self, NMConnection *connection)
+{
+ g_return_if_fail (self != NULL);
+
+ if (EAP_METHOD_GET_IFACE (self)->update_secrets)
+ EAP_METHOD_GET_IFACE (self)->update_secrets (self, connection);
+}
+
void
eap_method_add_to_size_group (EAPMethod *self, GtkSizeGroup *group)
{
@@ -103,32 +112,6 @@ eap_method_fill_connection (EAPMethod *self,
return (*(EAP_METHOD_GET_IFACE (self)->fill_connection)) (self, connection, flags);
}
-void
-eap_method_phase2_update_secrets_helper (EAPMethod *self,
- NMConnection *connection,
- GtkComboBox *combo,
- guint32 column)
-{
- GtkTreeIter iter;
- GtkTreeModel *model;
-
- g_return_if_fail (self != NULL);
- g_return_if_fail (connection != NULL);
- g_return_if_fail (combo != NULL);
-
- /* Let each EAP phase2 method try to update its secrets */
- model = gtk_combo_box_get_model (combo);
- if (gtk_tree_model_get_iter_first (model, &iter)) {
- do {
- g_autoptr(EAPMethod) eap = NULL;
-
- gtk_tree_model_get (model, &iter, column, &eap, -1);
- 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));
- }
-}
-
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 4c23b5858..28d19790c 100644
--- a/panels/network/wireless-security/eap-method.h
+++ b/panels/network/wireless-security/eap-method.h
@@ -47,6 +47,8 @@ const gchar *eap_method_get_password_flags_name (EAPMethod *method);
gboolean eap_method_get_phase2 (EAPMethod *method);
+void eap_method_update_secrets (EAPMethod *method, NMConnection *connection);
+
gboolean eap_method_validate (EAPMethod *method, GError **error);
void eap_method_add_to_size_group (EAPMethod *method, GtkSizeGroup *group);
@@ -71,11 +73,6 @@ gboolean eap_method_validate_filepicker (GtkFileChooser *chooser,
NMSetting8021xCKFormat *out_format,
GError **error);
-void eap_method_phase2_update_secrets_helper (EAPMethod *method,
- NMConnection *connection,
- GtkComboBox *combo,
- guint32 column);
-
gboolean eap_method_ca_cert_required (GtkToggleButton *id_ca_cert_is_not_required_checkbutton,
GtkFileChooser *id_ca_cert_chooser);
void eap_method_ca_cert_not_required_toggled (GtkToggleButton *id_ca_cert_is_not_required_checkbox,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]