[gnome-control-center/network-widget-references: 3/13] network: Make public struct private
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/network-widget-references: 3/13] network: Make public struct private
- Date: Tue, 15 Oct 2019 03:40:23 +0000 (UTC)
commit 9512f7e680355877df4b3bca8dc7e5e28fca403b
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Oct 3 21:07:25 2019 +1300
network: Make public struct private
panels/network/wireless-security/eap-method-leap.c | 10 +-
.../network/wireless-security/eap-method-simple.c | 10 +-
.../network/wireless-security/wireless-security.c | 200 ++++++++++++++++-----
.../network/wireless-security/wireless-security.h | 32 ++--
panels/network/wireless-security/ws-dynamic-wep.c | 4 +-
panels/network/wireless-security/ws-leap.c | 4 +-
panels/network/wireless-security/ws-wpa-eap.c | 4 +-
panels/network/wireless-security/ws-wpa-psk.c | 2 +-
8 files changed, 184 insertions(+), 82 deletions(-)
---
diff --git a/panels/network/wireless-security/eap-method-leap.c
b/panels/network/wireless-security/eap-method-leap.c
index 57d8759b9..f6eadce91 100644
--- a/panels/network/wireless-security/eap-method-leap.c
+++ b/panels/network/wireless-security/eap-method-leap.c
@@ -139,17 +139,17 @@ update_secrets (EAPMethod *parent, NMConnection *connection)
static void
set_userpass_ui (EAPMethodLEAP *method)
{
- if (method->ws_parent->username)
- gtk_entry_set_text (method->username_entry, method->ws_parent->username);
+ if (wireless_security_get_username (method->ws_parent))
+ gtk_entry_set_text (method->username_entry, wireless_security_get_username
(method->ws_parent));
else
gtk_entry_set_text (method->username_entry, "");
- if (method->ws_parent->password && !method->ws_parent->always_ask)
- gtk_entry_set_text (method->password_entry, method->ws_parent->password);
+ if (wireless_security_get_password (method->ws_parent) && !wireless_security_get_always_ask
(method->ws_parent))
+ gtk_entry_set_text (method->password_entry, wireless_security_get_password
(method->ws_parent));
else
gtk_entry_set_text (method->password_entry, "");
- gtk_toggle_button_set_active (method->show_password, method->ws_parent->show_password);
+ gtk_toggle_button_set_active (method->show_password, wireless_security_get_show_password
(method->ws_parent));
}
static void
diff --git a/panels/network/wireless-security/eap-method-simple.c
b/panels/network/wireless-security/eap-method-simple.c
index 271ce007c..40db31651 100644
--- a/panels/network/wireless-security/eap-method-simple.c
+++ b/panels/network/wireless-security/eap-method-simple.c
@@ -231,17 +231,17 @@ password_storage_changed (GObject *entry,
static void
set_userpass_ui (EAPMethodSimple *method)
{
- if (method->ws_parent->username)
- gtk_entry_set_text (method->username_entry, method->ws_parent->username);
+ if (wireless_security_get_username (method->ws_parent))
+ gtk_entry_set_text (method->username_entry, wireless_security_get_username
(method->ws_parent));
else
gtk_entry_set_text (method->username_entry, "");
- if (method->ws_parent->password && !method->ws_parent->always_ask)
- gtk_entry_set_text (method->password_entry, method->ws_parent->password);
+ if (wireless_security_get_password (method->ws_parent) && !wireless_security_get_always_ask
(method->ws_parent))
+ gtk_entry_set_text (method->password_entry, wireless_security_get_password
(method->ws_parent));
else
gtk_entry_set_text (method->password_entry, "");
- gtk_toggle_button_set_active (method->show_password, method->ws_parent->show_password);
+ gtk_toggle_button_set_active (method->show_password, wireless_security_get_show_password
(method->ws_parent));
}
static void
diff --git a/panels/network/wireless-security/wireless-security.c
b/panels/network/wireless-security/wireless-security.c
index 5c5b90f0a..c460ea8b7 100644
--- a/panels/network/wireless-security/wireless-security.c
+++ b/panels/network/wireless-security/wireless-security.c
@@ -29,6 +29,25 @@
#include "eap-method.h"
#include "utils.h"
+struct _WirelessSecurityPrivate {
+ guint32 refcount;
+ gsize obj_size;
+ GtkWidget *ui_widget;
+ WSChangedFunc changed_notify;
+ gpointer changed_notify_data;
+ gboolean adhoc_compatible;
+ gboolean hotspot_compatible;
+
+ char *username, *password;
+ gboolean always_ask, show_password;
+
+ WSAddToSizeGroupFunc add_to_size_group;
+ WSFillConnectionFunc fill_connection;
+ WSUpdateSecretsFunc update_secrets;
+ WSValidateFunc validate;
+ WSDestroyFunc destroy;
+};
+
GType
wireless_security_get_type (void)
{
@@ -48,9 +67,10 @@ wireless_security_get_type (void)
GtkWidget *
wireless_security_get_widget (WirelessSecurity *sec)
{
+ WirelessSecurityPrivate *priv = sec->priv;
g_return_val_if_fail (sec != NULL, NULL);
- return sec->ui_widget;
+ return priv->ui_widget;
}
void
@@ -58,31 +78,34 @@ wireless_security_set_changed_notify (WirelessSecurity *sec,
WSChangedFunc func,
gpointer user_data)
{
+ WirelessSecurityPrivate *priv = sec->priv;
g_return_if_fail (sec != NULL);
- sec->changed_notify = func;
- sec->changed_notify_data = user_data;
+ priv->changed_notify = func;
+ priv->changed_notify_data = user_data;
}
void
wireless_security_changed_cb (GtkWidget *ignored, gpointer user_data)
{
WirelessSecurity *sec = WIRELESS_SECURITY (user_data);
+ WirelessSecurityPrivate *priv = sec->priv;
- if (sec->changed_notify)
- (*(sec->changed_notify)) (sec, sec->changed_notify_data);
+ if (priv->changed_notify)
+ (*(priv->changed_notify)) (sec, priv->changed_notify_data);
}
gboolean
wireless_security_validate (WirelessSecurity *sec, GError **error)
{
+ WirelessSecurityPrivate *priv = sec->priv;
gboolean result;
g_return_val_if_fail (sec != NULL, FALSE);
g_return_val_if_fail (!error || !*error, FALSE);
- g_assert (sec->validate);
- result = (*(sec->validate)) (sec, error);
+ g_assert (priv->validate);
+ result = (*(priv->validate)) (sec, error);
if (!result && error && !*error)
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Unknown error validating 802.1X
security"));
return result;
@@ -91,66 +114,77 @@ wireless_security_validate (WirelessSecurity *sec, GError **error)
void
wireless_security_add_to_size_group (WirelessSecurity *sec, GtkSizeGroup *group)
{
+ WirelessSecurityPrivate *priv = sec->priv;
+
g_return_if_fail (sec != NULL);
g_return_if_fail (group != NULL);
- g_assert (sec->add_to_size_group);
- return (*(sec->add_to_size_group)) (sec, group);
+ g_assert (priv->add_to_size_group);
+ return (*(priv->add_to_size_group)) (sec, group);
}
void
wireless_security_fill_connection (WirelessSecurity *sec,
NMConnection *connection)
{
+ WirelessSecurityPrivate *priv = sec->priv;
+
g_return_if_fail (sec != NULL);
g_return_if_fail (connection != NULL);
- g_assert (sec->fill_connection);
- return (*(sec->fill_connection)) (sec, connection);
+ g_assert (priv->fill_connection);
+ return (*(priv->fill_connection)) (sec, connection);
}
void
wireless_security_update_secrets (WirelessSecurity *sec, NMConnection *connection)
{
+ WirelessSecurityPrivate *priv = sec->priv;
+
g_return_if_fail (sec != NULL);
g_return_if_fail (connection != NULL);
- if (sec->update_secrets)
- sec->update_secrets (sec, connection);
+ if (priv->update_secrets)
+ priv->update_secrets (sec, connection);
}
WirelessSecurity *
wireless_security_ref (WirelessSecurity *sec)
{
+ WirelessSecurityPrivate *priv = sec->priv;
+
g_return_val_if_fail (sec != NULL, NULL);
- g_return_val_if_fail (sec->refcount > 0, NULL);
+ g_return_val_if_fail (priv->refcount > 0, NULL);
- sec->refcount++;
+ priv->refcount++;
return sec;
}
void
wireless_security_unref (WirelessSecurity *sec)
{
+ WirelessSecurityPrivate *priv = sec->priv;
+
g_return_if_fail (sec != NULL);
- g_return_if_fail (sec->refcount > 0);
+ g_return_if_fail (priv->refcount > 0);
- sec->refcount--;
- if (sec->refcount == 0) {
- if (sec->destroy)
- sec->destroy (sec);
+ priv->refcount--;
+ if (priv->refcount == 0) {
+ if (priv->destroy)
+ priv->destroy (sec);
- g_free (sec->username);
- if (sec->password) {
- memset (sec->password, 0, strlen (sec->password));
- g_free (sec->password);
+ g_free (priv->username);
+ if (priv->password) {
+ memset (priv->password, 0, strlen (priv->password));
+ g_free (priv->password);
}
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);
+ if (priv->ui_widget)
+ g_object_unref (priv->ui_widget);
+ g_slice_free1 (priv->obj_size, sec);
+ g_free (priv);
}
}
@@ -165,6 +199,7 @@ wireless_security_init (gsize obj_size,
const char *ui_widget_name)
{
g_autoptr(WirelessSecurity) sec = NULL;
+ WirelessSecurityPrivate *priv;
g_autoptr(GError) error = NULL;
g_return_val_if_fail (obj_size > 0, NULL);
@@ -175,14 +210,15 @@ wireless_security_init (gsize obj_size,
sec = g_slice_alloc0 (obj_size);
g_assert (sec);
+ sec->priv = priv = g_new0 (WirelessSecurityPrivate, 1);
- sec->refcount = 1;
- sec->obj_size = obj_size;
+ priv->refcount = 1;
+ priv->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;
+ priv->validate = validate;
+ priv->add_to_size_group = add_to_size_group;
+ priv->fill_connection = fill_connection;
+ priv->update_secrets = update_secrets;
sec->builder = gtk_builder_new ();
if (!gtk_builder_add_from_resource (sec->builder, ui_resource, &error)) {
@@ -191,35 +227,99 @@ wireless_security_init (gsize obj_size,
return NULL;
}
- sec->ui_widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, ui_widget_name));
- if (!sec->ui_widget) {
+ priv->ui_widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, ui_widget_name));
+ if (!priv->ui_widget) {
g_warning ("Couldn't load UI widget '%s' from UI file %s",
ui_widget_name, ui_resource);
return NULL;
}
- g_object_ref_sink (sec->ui_widget);
+ g_object_ref_sink (priv->ui_widget);
- sec->destroy = destroy;
- sec->adhoc_compatible = TRUE;
- sec->hotspot_compatible = TRUE;
+ priv->destroy = destroy;
+ priv->adhoc_compatible = TRUE;
+ priv->hotspot_compatible = TRUE;
return g_steal_pointer (&sec);
}
+void
+wireless_security_set_adhoc_compatible (WirelessSecurity *sec, gboolean adhoc_compatible)
+{
+ WirelessSecurityPrivate *priv = sec->priv;
+
+ g_return_if_fail (sec != NULL);
+
+ priv->adhoc_compatible = adhoc_compatible;
+}
+
gboolean
wireless_security_adhoc_compatible (WirelessSecurity *sec)
{
+ WirelessSecurityPrivate *priv = sec->priv;
+
g_return_val_if_fail (sec != NULL, FALSE);
- return sec->adhoc_compatible;
+ return priv->adhoc_compatible;
+}
+
+void
+wireless_security_set_hotspot_compatible (WirelessSecurity *sec, gboolean hotspot_compatible)
+{
+ WirelessSecurityPrivate *priv = sec->priv;
+
+ g_return_if_fail (sec != NULL);
+
+ priv->hotspot_compatible = hotspot_compatible;
}
gboolean
wireless_security_hotspot_compatible (WirelessSecurity *sec)
{
+ WirelessSecurityPrivate *priv = sec->priv;
+
g_return_val_if_fail (sec != NULL, FALSE);
- return sec->hotspot_compatible;
+ return priv->hotspot_compatible;
+}
+
+const gchar *
+wireless_security_get_username (WirelessSecurity *sec)
+{
+ WirelessSecurityPrivate *priv = sec->priv;
+
+ g_return_val_if_fail (sec != NULL, NULL);
+
+ return priv->username;
+}
+
+const gchar *
+wireless_security_get_password (WirelessSecurity *sec)
+{
+ WirelessSecurityPrivate *priv = sec->priv;
+
+ g_return_val_if_fail (sec != NULL, NULL);
+
+ return priv->password;
+}
+
+gboolean
+wireless_security_get_always_ask (WirelessSecurity *sec)
+{
+ WirelessSecurityPrivate *priv = sec->priv;
+
+ g_return_val_if_fail (sec != NULL, FALSE);
+
+ return priv->always_ask;
+}
+
+gboolean
+wireless_security_get_show_password (WirelessSecurity *sec)
+{
+ WirelessSecurityPrivate *priv = sec->priv;
+
+ g_return_val_if_fail (sec != NULL, FALSE);
+
+ return priv->show_password;
}
void
@@ -229,18 +329,20 @@ wireless_security_set_userpass (WirelessSecurity *sec,
gboolean always_ask,
gboolean show_password)
{
- g_free (sec->username);
- sec->username = g_strdup (user);
+ WirelessSecurityPrivate *priv = sec->priv;
+
+ g_free (priv->username);
+ priv->username = g_strdup (user);
- if (sec->password) {
- memset (sec->password, 0, strlen (sec->password));
- g_free (sec->password);
+ if (priv->password) {
+ memset (priv->password, 0, strlen (priv->password));
+ g_free (priv->password);
}
- sec->password = g_strdup (password);
+ priv->password = g_strdup (password);
if (always_ask != (gboolean) -1)
- sec->always_ask = always_ask;
- sec->show_password = show_password;
+ priv->always_ask = always_ask;
+ priv->show_password = show_password;
}
void
diff --git a/panels/network/wireless-security/wireless-security.h
b/panels/network/wireless-security/wireless-security.h
index d1baa3de5..19e05b553 100644
--- a/panels/network/wireless-security/wireless-security.h
+++ b/panels/network/wireless-security/wireless-security.h
@@ -28,6 +28,7 @@
#define WIRELESS_TYPE_SECURITY (wireless_security_get_type ())
typedef struct _WirelessSecurity WirelessSecurity;
+typedef struct _WirelessSecurityPrivate WirelessSecurityPrivate;
typedef void (*WSChangedFunc) (WirelessSecurity *sec, gpointer user_data);
@@ -38,23 +39,8 @@ typedef void (*WSDestroyFunc) (WirelessSecurity *sec);
typedef gboolean (*WSValidateFunc) (WirelessSecurity *sec, GError **error);
struct _WirelessSecurity {
- guint32 refcount;
- gsize obj_size;
+ WirelessSecurityPrivate *priv;
GtkBuilder *builder;
- GtkWidget *ui_widget;
- WSChangedFunc changed_notify;
- gpointer changed_notify_data;
- gboolean adhoc_compatible;
- gboolean hotspot_compatible;
-
- char *username, *password;
- gboolean always_ask, show_password;
-
- WSAddToSizeGroupFunc add_to_size_group;
- WSFillConnectionFunc fill_connection;
- WSUpdateSecretsFunc update_secrets;
- WSValidateFunc validate;
- WSDestroyFunc destroy;
};
#define WIRELESS_SECURITY(x) ((WirelessSecurity *) x)
@@ -77,10 +63,24 @@ void wireless_security_fill_connection (WirelessSecurity *sec,
void wireless_security_update_secrets (WirelessSecurity *sec,
NMConnection *connection);
+void wireless_security_set_adhoc_compatible (WirelessSecurity *sec,
+ gboolean adhoc_compatible);
+
gboolean wireless_security_adhoc_compatible (WirelessSecurity *sec);
+void wireless_security_set_hotspot_compatible (WirelessSecurity *sec,
+ gboolean hotspot_compatible);
+
gboolean wireless_security_hotspot_compatible (WirelessSecurity *sec);
+const gchar *wireless_security_get_username (WirelessSecurity *sec);
+
+const gchar *wireless_security_get_password (WirelessSecurity *sec);
+
+gboolean wireless_security_get_always_ask (WirelessSecurity *sec);
+
+gboolean wireless_security_get_show_password (WirelessSecurity *sec);
+
void wireless_security_set_userpass (WirelessSecurity *sec,
const char *user,
const char *password,
diff --git a/panels/network/wireless-security/ws-dynamic-wep.c
b/panels/network/wireless-security/ws-dynamic-wep.c
index 402019a94..b3398a814 100644
--- a/panels/network/wireless-security/ws-dynamic-wep.c
+++ b/panels/network/wireless-security/ws-dynamic-wep.c
@@ -114,8 +114,8 @@ ws_dynamic_wep_new (NMConnection *connection,
if (!parent)
return NULL;
- parent->adhoc_compatible = FALSE;
- parent->hotspot_compatible = FALSE;
+ wireless_security_set_adhoc_compatible (parent, FALSE);
+ wireless_security_set_hotspot_compatible (parent, FALSE);
widget = ws_802_1x_auth_combo_init (parent,
"dynamic_wep_auth_combo",
diff --git a/panels/network/wireless-security/ws-leap.c b/panels/network/wireless-security/ws-leap.c
index c7534232a..6334e6ed6 100644
--- a/panels/network/wireless-security/ws-leap.c
+++ b/panels/network/wireless-security/ws-leap.c
@@ -171,8 +171,8 @@ ws_leap_new (NMConnection *connection, gboolean secrets_only)
}
}
- parent->adhoc_compatible = FALSE;
- parent->hotspot_compatible = FALSE;
+ wireless_security_set_adhoc_compatible (parent, FALSE);
+ wireless_security_set_hotspot_compatible (parent, FALSE);
sec = (WirelessSecurityLEAP *) parent;
sec->editing_connection = secrets_only ? FALSE : TRUE;
sec->password_flags_name = NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD;
diff --git a/panels/network/wireless-security/ws-wpa-eap.c b/panels/network/wireless-security/ws-wpa-eap.c
index 479e01dc6..9d072c773 100644
--- a/panels/network/wireless-security/ws-wpa-eap.c
+++ b/panels/network/wireless-security/ws-wpa-eap.c
@@ -115,8 +115,8 @@ ws_wpa_eap_new (NMConnection *connection,
if (!parent)
return NULL;
- parent->adhoc_compatible = FALSE;
- parent->hotspot_compatible = FALSE;
+ wireless_security_set_adhoc_compatible (parent, FALSE);
+ wireless_security_set_hotspot_compatible (parent, FALSE);
widget = ws_802_1x_auth_combo_init (parent,
"wpa_eap_auth_combo",
diff --git a/panels/network/wireless-security/ws-wpa-psk.c b/panels/network/wireless-security/ws-wpa-psk.c
index caee64dfc..166e81f31 100644
--- a/panels/network/wireless-security/ws-wpa-psk.c
+++ b/panels/network/wireless-security/ws-wpa-psk.c
@@ -187,7 +187,7 @@ ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only)
if (!parent)
return NULL;
- parent->adhoc_compatible = FALSE;
+ wireless_security_set_adhoc_compatible (parent, FALSE);
sec = (WirelessSecurityWPAPSK *) parent;
sec->editing_connection = secrets_only ? FALSE : TRUE;
sec->password_flags_name = NM_SETTING_WIRELESS_SECURITY_PSK;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]