network: Convert WirelessSecurity into a GObject

This commit is contained in:
Robert Ancell 2019-11-07 12:37:34 +13:00 committed by Georges Basile Stavracas Neto
parent 4b182dd7c0
commit 3d06da2d30
14 changed files with 297 additions and 309 deletions

View file

@ -164,7 +164,7 @@ ce_page_8021x_security_dispose (GObject *object)
CEPage8021xSecurity *self = CE_PAGE_8021X_SECURITY (object); CEPage8021xSecurity *self = CE_PAGE_8021X_SECURITY (object);
g_clear_object (&self->connection); g_clear_object (&self->connection);
g_clear_pointer ((WirelessSecurity**) &self->security, wireless_security_unref); g_clear_object (&self->security);
g_clear_object (&self->group); g_clear_object (&self->group);
G_OBJECT_CLASS (ce_page_8021x_security_parent_class)->dispose (object); G_OBJECT_CLASS (ce_page_8021x_security_parent_class)->dispose (object);

View file

@ -194,7 +194,7 @@ add_security_item (CEPageSecurity *self,
S_SEC_COLUMN, sec, S_SEC_COLUMN, sec,
S_ADHOC_VALID_COLUMN, adhoc_valid, S_ADHOC_VALID_COLUMN, adhoc_valid,
-1); -1);
wireless_security_unref (sec); g_object_unref (sec);
} }
static void static void
@ -250,7 +250,7 @@ finish_setup (CEPageSecurity *self)
if (sws) if (sws)
default_type = get_default_type_for_security (sws); default_type = get_default_type_for_security (sws);
sec_model = gtk_list_store_new (3, G_TYPE_STRING, WIRELESS_TYPE_SECURITY, G_TYPE_BOOLEAN); sec_model = gtk_list_store_new (3, G_TYPE_STRING, wireless_security_get_type (), G_TYPE_BOOLEAN);
if (nm_utils_security_valid (NMU_SEC_NONE, dev_caps, FALSE, is_adhoc, 0, 0, 0)) { if (nm_utils_security_valid (NMU_SEC_NONE, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
gtk_list_store_insert_with_values (sec_model, &iter, -1, gtk_list_store_insert_with_values (sec_model, &iter, -1,

View file

@ -35,47 +35,56 @@
#include "eap-method-ttls.h" #include "eap-method-ttls.h"
#include "utils.h" #include "utils.h"
struct _WirelessSecurityPrivate { typedef struct {
guint32 refcount;
gsize obj_size;
WSChangedFunc changed_notify; WSChangedFunc changed_notify;
gpointer changed_notify_data; gpointer changed_notify_data;
gboolean adhoc_compatible; gboolean adhoc_compatible;
char *username, *password; char *username, *password;
gboolean always_ask, show_password; gboolean always_ask, show_password;
} WirelessSecurityPrivate;
WSAddToSizeGroupFunc add_to_size_group; G_DEFINE_TYPE_WITH_PRIVATE (WirelessSecurity, wireless_security, G_TYPE_OBJECT)
WSFillConnectionFunc fill_connection;
WSGetWidgetFunc get_widget;
WSValidateFunc validate;
WSDestroyFunc destroy;
};
GType static void
wireless_security_get_type (void) wireless_security_dispose (GObject *object)
{ {
static GType type_id = 0; WirelessSecurity *self = WIRELESS_SECURITY (object);
WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
if (!type_id) { if (priv->password)
g_resources_register (wireless_security_get_resource ()); memset (priv->password, 0, strlen (priv->password));
type_id = g_boxed_type_register_static ("CcWirelessSecurity", g_clear_pointer (&priv->username, g_free);
(GBoxedCopyFunc) wireless_security_ref, g_clear_pointer (&priv->password, g_free);
(GBoxedFreeFunc) wireless_security_unref);
}
return type_id; G_OBJECT_CLASS (wireless_security_parent_class)->dispose (object);
}
void
wireless_security_init (WirelessSecurity *self)
{
WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
g_resources_register (wireless_security_get_resource ());
priv->adhoc_compatible = TRUE;
}
void
wireless_security_class_init (WirelessSecurityClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = wireless_security_dispose;
} }
GtkWidget * GtkWidget *
wireless_security_get_widget (WirelessSecurity *self) wireless_security_get_widget (WirelessSecurity *self)
{ {
WirelessSecurityPrivate *priv = self->priv; g_return_val_if_fail (WIRELESS_IS_SECURITY (self), NULL);
g_return_val_if_fail (self != NULL, NULL);
g_assert (priv->get_widget); return WIRELESS_SECURITY_GET_CLASS (self)->get_widget (self);
return (*(priv->get_widget)) (self);
} }
void void
@ -83,8 +92,9 @@ wireless_security_set_changed_notify (WirelessSecurity *self,
WSChangedFunc func, WSChangedFunc func,
gpointer user_data) gpointer user_data)
{ {
WirelessSecurityPrivate *priv = self->priv; WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
g_return_if_fail (self != NULL);
g_return_if_fail (WIRELESS_IS_SECURITY (self));
priv->changed_notify = func; priv->changed_notify = func;
priv->changed_notify_data = user_data; priv->changed_notify_data = user_data;
@ -93,7 +103,7 @@ wireless_security_set_changed_notify (WirelessSecurity *self,
void void
wireless_security_notify_changed (WirelessSecurity *self) wireless_security_notify_changed (WirelessSecurity *self)
{ {
WirelessSecurityPrivate *priv = self->priv; WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
if (priv->changed_notify) if (priv->changed_notify)
(*(priv->changed_notify)) (self, priv->changed_notify_data); (*(priv->changed_notify)) (self, priv->changed_notify_data);
@ -102,14 +112,12 @@ wireless_security_notify_changed (WirelessSecurity *self)
gboolean gboolean
wireless_security_validate (WirelessSecurity *self, GError **error) wireless_security_validate (WirelessSecurity *self, GError **error)
{ {
WirelessSecurityPrivate *priv = self->priv;
gboolean result; gboolean result;
g_return_val_if_fail (self != NULL, FALSE); g_return_val_if_fail (WIRELESS_IS_SECURITY (self), FALSE);
g_return_val_if_fail (!error || !*error, FALSE); g_return_val_if_fail (!error || !*error, FALSE);
g_assert (priv->validate); result = WIRELESS_SECURITY_GET_CLASS (self)->validate (self, error);
result = (*(priv->validate)) (self, error);
if (!result && error && !*error) if (!result && error && !*error)
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Unknown error validating 802.1X security")); g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Unknown error validating 802.1X security"));
return result; return result;
@ -118,102 +126,28 @@ wireless_security_validate (WirelessSecurity *self, GError **error)
void void
wireless_security_add_to_size_group (WirelessSecurity *self, GtkSizeGroup *group) wireless_security_add_to_size_group (WirelessSecurity *self, GtkSizeGroup *group)
{ {
WirelessSecurityPrivate *priv = self->priv; g_return_if_fail (WIRELESS_IS_SECURITY (self));
g_return_if_fail (GTK_IS_SIZE_GROUP (group));
g_return_if_fail (self != NULL); return WIRELESS_SECURITY_GET_CLASS (self)->add_to_size_group (self, group);
g_return_if_fail (group != NULL);
g_assert (priv->add_to_size_group);
return (*(priv->add_to_size_group)) (self, group);
} }
void void
wireless_security_fill_connection (WirelessSecurity *self, wireless_security_fill_connection (WirelessSecurity *self,
NMConnection *connection) NMConnection *connection)
{ {
WirelessSecurityPrivate *priv = self->priv; g_return_if_fail (WIRELESS_IS_SECURITY (self));
g_return_if_fail (self != NULL);
g_return_if_fail (connection != NULL); g_return_if_fail (connection != NULL);
g_assert (priv->fill_connection); return WIRELESS_SECURITY_GET_CLASS (self)->fill_connection (self, connection);
return (*(priv->fill_connection)) (self, connection);
}
WirelessSecurity *
wireless_security_ref (WirelessSecurity *self)
{
WirelessSecurityPrivate *priv = self->priv;
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (priv->refcount > 0, NULL);
priv->refcount++;
return self;
}
void
wireless_security_unref (WirelessSecurity *self)
{
WirelessSecurityPrivate *priv = self->priv;
g_return_if_fail (self != NULL);
g_return_if_fail (priv->refcount > 0);
priv->refcount--;
if (priv->refcount == 0) {
if (priv->destroy)
priv->destroy (self);
if (priv->password)
memset (priv->password, 0, strlen (priv->password));
g_clear_pointer (&priv->username, g_free);
g_clear_pointer (&priv->password, g_free);
g_slice_free1 (priv->obj_size, self);
g_free (priv);
}
}
WirelessSecurity *
wireless_security_init (gsize obj_size,
WSGetWidgetFunc get_widget,
WSValidateFunc validate,
WSAddToSizeGroupFunc add_to_size_group,
WSFillConnectionFunc fill_connection,
WSDestroyFunc destroy)
{
g_autoptr(WirelessSecurity) self = NULL;
WirelessSecurityPrivate *priv;
g_return_val_if_fail (obj_size > 0, NULL);
g_type_ensure (WIRELESS_TYPE_SECURITY);
self = g_slice_alloc0 (obj_size);
g_assert (self);
self->priv = priv = g_new0 (WirelessSecurityPrivate, 1);
priv->refcount = 1;
priv->obj_size = obj_size;
priv->get_widget = get_widget;
priv->validate = validate;
priv->add_to_size_group = add_to_size_group;
priv->fill_connection = fill_connection;
priv->destroy = destroy;
priv->adhoc_compatible = TRUE;
return g_steal_pointer (&self);
} }
void void
wireless_security_set_adhoc_compatible (WirelessSecurity *self, gboolean adhoc_compatible) wireless_security_set_adhoc_compatible (WirelessSecurity *self, gboolean adhoc_compatible)
{ {
WirelessSecurityPrivate *priv = self->priv; WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
g_return_if_fail (self != NULL); g_return_if_fail (WIRELESS_IS_SECURITY (self));
priv->adhoc_compatible = adhoc_compatible; priv->adhoc_compatible = adhoc_compatible;
} }
@ -221,9 +155,9 @@ wireless_security_set_adhoc_compatible (WirelessSecurity *self, gboolean adhoc_c
gboolean gboolean
wireless_security_adhoc_compatible (WirelessSecurity *self) wireless_security_adhoc_compatible (WirelessSecurity *self)
{ {
WirelessSecurityPrivate *priv = self->priv; WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
g_return_val_if_fail (self != NULL, FALSE); g_return_val_if_fail (WIRELESS_IS_SECURITY (self), FALSE);
return priv->adhoc_compatible; return priv->adhoc_compatible;
} }
@ -231,9 +165,9 @@ wireless_security_adhoc_compatible (WirelessSecurity *self)
const gchar * const gchar *
wireless_security_get_username (WirelessSecurity *self) wireless_security_get_username (WirelessSecurity *self)
{ {
WirelessSecurityPrivate *priv = self->priv; WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
g_return_val_if_fail (self != NULL, NULL); g_return_val_if_fail (WIRELESS_IS_SECURITY (self), NULL);
return priv->username; return priv->username;
} }
@ -241,9 +175,9 @@ wireless_security_get_username (WirelessSecurity *self)
const gchar * const gchar *
wireless_security_get_password (WirelessSecurity *self) wireless_security_get_password (WirelessSecurity *self)
{ {
WirelessSecurityPrivate *priv = self->priv; WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
g_return_val_if_fail (self != NULL, NULL); g_return_val_if_fail (WIRELESS_IS_SECURITY (self), NULL);
return priv->password; return priv->password;
} }
@ -251,9 +185,9 @@ wireless_security_get_password (WirelessSecurity *self)
gboolean gboolean
wireless_security_get_always_ask (WirelessSecurity *self) wireless_security_get_always_ask (WirelessSecurity *self)
{ {
WirelessSecurityPrivate *priv = self->priv; WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
g_return_val_if_fail (self != NULL, FALSE); g_return_val_if_fail (WIRELESS_IS_SECURITY (self), FALSE);
return priv->always_ask; return priv->always_ask;
} }
@ -261,9 +195,9 @@ wireless_security_get_always_ask (WirelessSecurity *self)
gboolean gboolean
wireless_security_get_show_password (WirelessSecurity *self) wireless_security_get_show_password (WirelessSecurity *self)
{ {
WirelessSecurityPrivate *priv = self->priv; WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
g_return_val_if_fail (self != NULL, FALSE); g_return_val_if_fail (WIRELESS_IS_SECURITY (self), FALSE);
return priv->show_password; return priv->show_password;
} }
@ -275,7 +209,7 @@ wireless_security_set_userpass (WirelessSecurity *self,
gboolean always_ask, gboolean always_ask,
gboolean show_password) gboolean show_password)
{ {
WirelessSecurityPrivate *priv = self->priv; WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
g_clear_pointer (&priv->username, g_free); g_clear_pointer (&priv->username, g_free);
priv->username = g_strdup (user); priv->username = g_strdup (user);

View file

@ -20,31 +20,25 @@
* Copyright 2007 - 2014 Red Hat, Inc. * Copyright 2007 - 2014 Red Hat, Inc.
*/ */
#ifndef WIRELESS_SECURITY_H #pragma once
#define WIRELESS_SECURITY_H
#include <gtk/gtk.h> #include <gtk/gtk.h>
#define WIRELESS_TYPE_SECURITY (wireless_security_get_type ()) G_BEGIN_DECLS
typedef struct _WirelessSecurity WirelessSecurity; G_DECLARE_DERIVABLE_TYPE (WirelessSecurity, wireless_security, WIRELESS, SECURITY, GObject)
typedef struct _WirelessSecurityPrivate WirelessSecurityPrivate;
typedef void (*WSChangedFunc) (WirelessSecurity *sec, gpointer user_data); typedef void (*WSChangedFunc) (WirelessSecurity *sec, gpointer user_data);
typedef void (*WSAddToSizeGroupFunc) (WirelessSecurity *sec, GtkSizeGroup *group); struct _WirelessSecurityClass {
typedef void (*WSFillConnectionFunc) (WirelessSecurity *sec, NMConnection *connection); GObjectClass parent_class;
typedef void (*WSDestroyFunc) (WirelessSecurity *sec);
typedef gboolean (*WSValidateFunc) (WirelessSecurity *sec, GError **error);
typedef GtkWidget* (*WSGetWidgetFunc) (WirelessSecurity *sec);
struct _WirelessSecurity { void (*add_to_size_group) (WirelessSecurity *sec, GtkSizeGroup *group);
WirelessSecurityPrivate *priv; void (*fill_connection) (WirelessSecurity *sec, NMConnection *connection);
gboolean (*validate) (WirelessSecurity *sec, GError **error);
GtkWidget* (*get_widget) (WirelessSecurity *sec);
}; };
#define WIRELESS_SECURITY(x) ((WirelessSecurity *) x)
GtkWidget *wireless_security_get_widget (WirelessSecurity *sec); GtkWidget *wireless_security_get_widget (WirelessSecurity *sec);
void wireless_security_set_changed_notify (WirelessSecurity *sec, void wireless_security_set_changed_notify (WirelessSecurity *sec,
@ -78,21 +72,8 @@ void wireless_security_set_userpass (WirelessSecurity *sec,
gboolean always_ask, gboolean always_ask,
gboolean show_password); gboolean show_password);
WirelessSecurity *wireless_security_ref (WirelessSecurity *sec);
void wireless_security_unref (WirelessSecurity *sec);
GType wireless_security_get_type (void);
/* Below for internal use only */ /* Below for internal use only */
WirelessSecurity *wireless_security_init (gsize obj_size,
WSGetWidgetFunc get_widget,
WSValidateFunc validate,
WSAddToSizeGroupFunc add_to_size_group,
WSFillConnectionFunc fill_connection,
WSDestroyFunc destroy);
void wireless_security_notify_changed (WirelessSecurity *sec); void wireless_security_notify_changed (WirelessSecurity *sec);
void wireless_security_clear_ciphers (NMConnection *connection); void wireless_security_clear_ciphers (NMConnection *connection);
@ -117,6 +98,4 @@ EAPMethod *ws_802_1x_auth_combo_get_eap (GtkComboBox *combo);
void ws_802_1x_fill_connection (GtkComboBox *combo, void ws_802_1x_fill_connection (GtkComboBox *combo,
NMConnection *connection); NMConnection *connection);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WirelessSecurity, wireless_security_unref) G_END_DECLS
#endif /* WIRELESS_SECURITY_H */

View file

@ -41,33 +41,37 @@ struct _WirelessSecurityDynamicWEP {
GtkSizeGroup *size_group; GtkSizeGroup *size_group;
}; };
G_DEFINE_TYPE (WirelessSecurityDynamicWEP, ws_dynamic_wep, wireless_security_get_type ())
static void static void
destroy (WirelessSecurity *parent) ws_dynamic_wep_dispose (GObject *object)
{ {
WirelessSecurityDynamicWEP *self = (WirelessSecurityDynamicWEP *) parent; WirelessSecurityDynamicWEP *self = WS_DYNAMIC_WEP (object);
g_clear_object (&self->builder); g_clear_object (&self->builder);
g_clear_object (&self->size_group); g_clear_object (&self->size_group);
G_OBJECT_CLASS (ws_dynamic_wep_parent_class)->dispose (object);
} }
static GtkWidget * static GtkWidget *
get_widget (WirelessSecurity *parent) get_widget (WirelessSecurity *security)
{ {
WirelessSecurityDynamicWEP *self = (WirelessSecurityDynamicWEP *) parent; WirelessSecurityDynamicWEP *self = WS_DYNAMIC_WEP (security);
return GTK_WIDGET (self->grid); return GTK_WIDGET (self->grid);
} }
static gboolean static gboolean
validate (WirelessSecurity *parent, GError **error) validate (WirelessSecurity *security, GError **error)
{ {
WirelessSecurityDynamicWEP *self = (WirelessSecurityDynamicWEP *) parent; WirelessSecurityDynamicWEP *self = WS_DYNAMIC_WEP (security);
return eap_method_validate (ws_802_1x_auth_combo_get_eap (self->auth_combo), error); return eap_method_validate (ws_802_1x_auth_combo_get_eap (self->auth_combo), error);
} }
static void static void
add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group) add_to_size_group (WirelessSecurity *security, GtkSizeGroup *group)
{ {
WirelessSecurityDynamicWEP *self = (WirelessSecurityDynamicWEP *) parent; WirelessSecurityDynamicWEP *self = WS_DYNAMIC_WEP (security);
g_clear_object (&self->size_group); g_clear_object (&self->size_group);
self->size_group = g_object_ref (group); self->size_group = g_object_ref (group);
@ -77,9 +81,9 @@ add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group)
} }
static void static void
fill_connection (WirelessSecurity *parent, NMConnection *connection) fill_connection (WirelessSecurity *security, NMConnection *connection)
{ {
WirelessSecurityDynamicWEP *self = (WirelessSecurityDynamicWEP *) parent; WirelessSecurityDynamicWEP *self = WS_DYNAMIC_WEP (security);
NMSettingWirelessSecurity *s_wireless_sec; NMSettingWirelessSecurity *s_wireless_sec;
ws_802_1x_fill_connection (self->auth_combo, connection); ws_802_1x_fill_connection (self->auth_combo, connection);
@ -100,24 +104,33 @@ auth_combo_changed_cb (WirelessSecurityDynamicWEP *self)
wireless_security_notify_changed (WIRELESS_SECURITY (self)); wireless_security_notify_changed (WIRELESS_SECURITY (self));
} }
void
ws_dynamic_wep_init (WirelessSecurityDynamicWEP *self)
{
}
void
ws_dynamic_wep_class_init (WirelessSecurityDynamicWEPClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
WirelessSecurityClass *ws_class = WIRELESS_SECURITY_CLASS (klass);
object_class->dispose = ws_dynamic_wep_dispose;
ws_class->get_widget = get_widget;
ws_class->validate = validate;
ws_class->add_to_size_group = add_to_size_group;
ws_class->fill_connection = fill_connection;
}
WirelessSecurityDynamicWEP * WirelessSecurityDynamicWEP *
ws_dynamic_wep_new (NMConnection *connection, ws_dynamic_wep_new (NMConnection *connection,
gboolean is_editor, gboolean is_editor,
gboolean secrets_only) gboolean secrets_only)
{ {
WirelessSecurity *parent;
WirelessSecurityDynamicWEP *self; WirelessSecurityDynamicWEP *self;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
parent = wireless_security_init (sizeof (WirelessSecurityDynamicWEP), self = g_object_new (ws_dynamic_wep_get_type (), NULL);
get_widget,
validate,
add_to_size_group,
fill_connection,
destroy);
if (!parent)
return NULL;
self = (WirelessSecurityDynamicWEP *) parent;
self->builder = gtk_builder_new (); self->builder = gtk_builder_new ();
if (!gtk_builder_add_from_resource (self->builder, "/org/gnome/ControlCenter/network/ws-dynamic-wep.ui", &error)) { if (!gtk_builder_add_from_resource (self->builder, "/org/gnome/ControlCenter/network/ws-dynamic-wep.ui", &error)) {
@ -130,9 +143,9 @@ 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 (parent, FALSE); wireless_security_set_adhoc_compatible (WIRELESS_SECURITY (self), FALSE);
ws_802_1x_auth_combo_init (parent, ws_802_1x_auth_combo_init (WIRELESS_SECURITY (self),
self->auth_combo, self->auth_combo,
connection, connection,
is_editor, is_editor,

View file

@ -20,13 +20,18 @@
* Copyright 2007 - 2014 Red Hat, Inc. * Copyright 2007 - 2014 Red Hat, Inc.
*/ */
#ifndef WS_DYNAMIC_WEP_H #pragma once
#define WS_DYNAMIC_WEP_H
typedef struct _WirelessSecurityDynamicWEP WirelessSecurityDynamicWEP; #include <NetworkManager.h>
#include "wireless-security.h"
G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (WirelessSecurityDynamicWEP, ws_dynamic_wep, WS, DYNAMIC_WEP, WirelessSecurity)
WirelessSecurityDynamicWEP *ws_dynamic_wep_new (NMConnection *connection, WirelessSecurityDynamicWEP *ws_dynamic_wep_new (NMConnection *connection,
gboolean is_editor, gboolean is_editor,
gboolean secrets_only); gboolean secrets_only);
#endif /* WS_DYNAMIC_WEP_H */ G_END_DECLS

View file

@ -45,12 +45,16 @@ struct _WirelessSecurityLEAP {
const char *password_flags_name; const char *password_flags_name;
}; };
G_DEFINE_TYPE (WirelessSecurityLEAP, ws_leap, wireless_security_get_type ())
static void static void
destroy (WirelessSecurity *parent) ws_leap_dispose (GObject *object)
{ {
WirelessSecurityLEAP *self = (WirelessSecurityLEAP *) parent; WirelessSecurityLEAP *self = WS_LEAP (object);
g_clear_object (&self->builder); g_clear_object (&self->builder);
G_OBJECT_CLASS (ws_leap_parent_class)->dispose (object);
} }
static void static void
@ -63,16 +67,16 @@ show_toggled_cb (WirelessSecurityLEAP *self)
} }
static GtkWidget * static GtkWidget *
get_widget (WirelessSecurity *parent) get_widget (WirelessSecurity *security)
{ {
WirelessSecurityLEAP *self = (WirelessSecurityLEAP *) parent; WirelessSecurityLEAP *self = WS_LEAP (security);
return GTK_WIDGET (self->grid); return GTK_WIDGET (self->grid);
} }
static gboolean static gboolean
validate (WirelessSecurity *parent, GError **error) validate (WirelessSecurity *security, GError **error)
{ {
WirelessSecurityLEAP *self = (WirelessSecurityLEAP *) parent; WirelessSecurityLEAP *self = WS_LEAP (security);
const char *text; const char *text;
gboolean ret = TRUE; gboolean ret = TRUE;
@ -98,17 +102,17 @@ validate (WirelessSecurity *parent, GError **error)
} }
static void static void
add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group) add_to_size_group (WirelessSecurity *security, GtkSizeGroup *group)
{ {
WirelessSecurityLEAP *self = (WirelessSecurityLEAP *) parent; WirelessSecurityLEAP *self = WS_LEAP (security);
gtk_size_group_add_widget (group, GTK_WIDGET (self->username_label)); gtk_size_group_add_widget (group, GTK_WIDGET (self->username_label));
gtk_size_group_add_widget (group, GTK_WIDGET (self->password_label)); gtk_size_group_add_widget (group, GTK_WIDGET (self->password_label));
} }
static void static void
fill_connection (WirelessSecurity *parent, NMConnection *connection) fill_connection (WirelessSecurity *security, NMConnection *connection)
{ {
WirelessSecurityLEAP *self = (WirelessSecurityLEAP *) parent; WirelessSecurityLEAP *self = WS_LEAP (security);
NMSettingWirelessSecurity *s_wireless_sec; NMSettingWirelessSecurity *s_wireless_sec;
NMSettingSecretFlags secret_flags; NMSettingSecretFlags secret_flags;
const char *leap_password = NULL, *leap_username = NULL; const char *leap_password = NULL, *leap_username = NULL;
@ -138,38 +142,38 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
NM_SETTING (s_wireless_sec), self->password_flags_name); NM_SETTING (s_wireless_sec), self->password_flags_name);
} }
static void
update_secrets (WirelessSecurity *parent, NMConnection *connection)
{
WirelessSecurityLEAP *self = (WirelessSecurityLEAP *) parent;
helper_fill_secret_entry (connection,
self->password_entry,
NM_TYPE_SETTING_WIRELESS_SECURITY,
(HelperSecretFunc) nm_setting_wireless_security_get_leap_password);
}
static void static void
changed_cb (WirelessSecurityLEAP *self) changed_cb (WirelessSecurityLEAP *self)
{ {
wireless_security_notify_changed ((WirelessSecurity *) self); wireless_security_notify_changed ((WirelessSecurity *) self);
} }
void
ws_leap_init (WirelessSecurityLEAP *self)
{
}
void
ws_leap_class_init (WirelessSecurityLEAPClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
WirelessSecurityClass *ws_class = WIRELESS_SECURITY_CLASS (klass);
object_class->dispose = ws_leap_dispose;
ws_class->get_widget = get_widget;
ws_class->validate = validate;
ws_class->add_to_size_group = add_to_size_group;
ws_class->fill_connection = fill_connection;
}
WirelessSecurityLEAP * WirelessSecurityLEAP *
ws_leap_new (NMConnection *connection, gboolean secrets_only) ws_leap_new (NMConnection *connection, gboolean secrets_only)
{ {
WirelessSecurity *parent;
WirelessSecurityLEAP *self; WirelessSecurityLEAP *self;
NMSettingWirelessSecurity *wsec = NULL; NMSettingWirelessSecurity *wsec = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
parent = wireless_security_init (sizeof (WirelessSecurityLEAP), self = g_object_new (ws_leap_get_type (), NULL);
get_widget,
validate,
add_to_size_group,
fill_connection,
destroy);
if (!parent)
return NULL;
if (connection) { if (connection) {
wsec = nm_connection_get_setting_wireless_security (connection); wsec = nm_connection_get_setting_wireless_security (connection);
@ -183,8 +187,8 @@ ws_leap_new (NMConnection *connection, gboolean secrets_only)
} }
} }
wireless_security_set_adhoc_compatible (parent, FALSE); wireless_security_set_adhoc_compatible (WIRELESS_SECURITY (self), FALSE);
self = (WirelessSecurityLEAP *) parent;
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;
@ -208,7 +212,10 @@ ws_leap_new (NMConnection *connection, gboolean secrets_only)
FALSE, secrets_only); FALSE, secrets_only);
if (wsec) if (wsec)
update_secrets (WIRELESS_SECURITY (self), connection); helper_fill_secret_entry (connection,
self->password_entry,
NM_TYPE_SETTING_WIRELESS_SECURITY,
(HelperSecretFunc) nm_setting_wireless_security_get_leap_password);
g_signal_connect_swapped (self->username_entry, "changed", G_CALLBACK (changed_cb), self); g_signal_connect_swapped (self->username_entry, "changed", G_CALLBACK (changed_cb), self);
if (wsec) if (wsec)

View file

@ -20,11 +20,16 @@
* Copyright 2007 - 2014 Red Hat, Inc. * Copyright 2007 - 2014 Red Hat, Inc.
*/ */
#ifndef WS_LEAP_H #pragma once
#define WS_LEAP_H
typedef struct _WirelessSecurityLEAP WirelessSecurityLEAP; #include <NetworkManager.h>
#include "wireless-security.h"
G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (WirelessSecurityLEAP, ws_leap, WS, LEAP, WirelessSecurity)
WirelessSecurityLEAP * ws_leap_new (NMConnection *connection, gboolean secrets_only); WirelessSecurityLEAP * ws_leap_new (NMConnection *connection, gboolean secrets_only);
#endif /* WS_LEAP_H */ G_END_DECLS

View file

@ -51,6 +51,8 @@ struct _WirelessSecurityWEPKey {
guint8 cur_index; guint8 cur_index;
}; };
G_DEFINE_TYPE (WirelessSecurityWEPKey, ws_wep_key, wireless_security_get_type ())
static void static void
show_toggled_cb (WirelessSecurityWEPKey *self) show_toggled_cb (WirelessSecurityWEPKey *self)
{ {
@ -85,27 +87,29 @@ key_index_combo_changed_cb (WirelessSecurityWEPKey *self)
} }
static void static void
destroy (WirelessSecurity *parent) ws_wep_key_dispose (GObject *object)
{ {
WirelessSecurityWEPKey *self = (WirelessSecurityWEPKey *) parent; WirelessSecurityWEPKey *self = WS_WEP_KEY (object);
int i; int i;
g_clear_object (&self->builder); g_clear_object (&self->builder);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
memset (self->keys[i], 0, sizeof (self->keys[i])); memset (self->keys[i], 0, sizeof (self->keys[i]));
G_OBJECT_CLASS (ws_wep_key_parent_class)->dispose (object);
} }
static GtkWidget * static GtkWidget *
get_widget (WirelessSecurity *parent) get_widget (WirelessSecurity *security)
{ {
WirelessSecurityWEPKey *self = (WirelessSecurityWEPKey *) parent; WirelessSecurityWEPKey *self = WS_WEP_KEY (security);
return GTK_WIDGET (self->grid); return GTK_WIDGET (self->grid);
} }
static gboolean static gboolean
validate (WirelessSecurity *parent, GError **error) validate (WirelessSecurity *security, GError **error)
{ {
WirelessSecurityWEPKey *self = (WirelessSecurityWEPKey *) parent; WirelessSecurityWEPKey *self = WS_WEP_KEY (security);
const char *key; const char *key;
int i; int i;
@ -154,18 +158,18 @@ validate (WirelessSecurity *parent, GError **error)
} }
static void static void
add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group) add_to_size_group (WirelessSecurity *security, GtkSizeGroup *group)
{ {
WirelessSecurityWEPKey *self = (WirelessSecurityWEPKey *) parent; WirelessSecurityWEPKey *self = WS_WEP_KEY (security);
gtk_size_group_add_widget (group, GTK_WIDGET (self->auth_method_label)); gtk_size_group_add_widget (group, GTK_WIDGET (self->auth_method_label));
gtk_size_group_add_widget (group, GTK_WIDGET (self->key_label)); gtk_size_group_add_widget (group, GTK_WIDGET (self->key_label));
gtk_size_group_add_widget (group, GTK_WIDGET (self->key_index_label)); gtk_size_group_add_widget (group, GTK_WIDGET (self->key_index_label));
} }
static void static void
fill_connection (WirelessSecurity *parent, NMConnection *connection) fill_connection (WirelessSecurity *security, NMConnection *connection)
{ {
WirelessSecurityWEPKey *self = (WirelessSecurityWEPKey *) parent; WirelessSecurityWEPKey *self = WS_WEP_KEY (security);
NMSettingWirelessSecurity *s_wsec; NMSettingWirelessSecurity *s_wsec;
NMSettingSecretFlags secret_flags; NMSettingSecretFlags secret_flags;
gint auth_alg; gint auth_alg;
@ -229,9 +233,8 @@ wep_entry_filter_cb (WirelessSecurityWEPKey *self,
} }
static void static void
update_secrets (WirelessSecurity *parent, NMConnection *connection) update_secrets (WirelessSecurityWEPKey *self, NMConnection *connection)
{ {
WirelessSecurityWEPKey *self = (WirelessSecurityWEPKey *) parent;
NMSettingWirelessSecurity *s_wsec; NMSettingWirelessSecurity *s_wsec;
const char *tmp; const char *tmp;
int i; int i;
@ -253,13 +256,30 @@ changed_cb (WirelessSecurityWEPKey *self)
wireless_security_notify_changed ((WirelessSecurity *) self); wireless_security_notify_changed ((WirelessSecurity *) self);
} }
void
ws_wep_key_init (WirelessSecurityWEPKey *self)
{
}
void
ws_wep_key_class_init (WirelessSecurityWEPKeyClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
WirelessSecurityClass *ws_class = WIRELESS_SECURITY_CLASS (klass);
object_class->dispose = ws_wep_key_dispose;
ws_class->get_widget = get_widget;
ws_class->validate = validate;
ws_class->add_to_size_group = add_to_size_group;
ws_class->fill_connection = fill_connection;
}
WirelessSecurityWEPKey * WirelessSecurityWEPKey *
ws_wep_key_new (NMConnection *connection, ws_wep_key_new (NMConnection *connection,
NMWepKeyType type, NMWepKeyType type,
gboolean adhoc_create, gboolean adhoc_create,
gboolean secrets_only) gboolean secrets_only)
{ {
WirelessSecurity *parent;
WirelessSecurityWEPKey *self; WirelessSecurityWEPKey *self;
NMSettingWirelessSecurity *s_wsec = NULL; NMSettingWirelessSecurity *s_wsec = NULL;
NMSetting *setting = NULL; NMSetting *setting = NULL;
@ -268,15 +288,7 @@ ws_wep_key_new (NMConnection *connection,
gboolean is_shared_key = FALSE; gboolean is_shared_key = FALSE;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
parent = wireless_security_init (sizeof (WirelessSecurityWEPKey), self = g_object_new (ws_wep_key_get_type (), NULL);
get_widget,
validate,
add_to_size_group,
fill_connection,
destroy);
if (!parent)
return NULL;
self = (WirelessSecurityWEPKey *) parent;
self->builder = gtk_builder_new (); self->builder = gtk_builder_new ();
if (!gtk_builder_add_from_resource (self->builder, "/org/gnome/ControlCenter/network/ws-wep-key.ui", &error)) { if (!gtk_builder_add_from_resource (self->builder, "/org/gnome/ControlCenter/network/ws-wep-key.ui", &error)) {
@ -344,7 +356,7 @@ ws_wep_key_new (NMConnection *connection,
/* Fill the key entry with the key for that index */ /* Fill the key entry with the key for that index */
if (connection) if (connection)
update_secrets (WIRELESS_SECURITY (self), connection); update_secrets (self, connection);
g_signal_connect_swapped (self->show_key_check, "toggled", G_CALLBACK (show_toggled_cb), self); g_signal_connect_swapped (self->show_key_check, "toggled", G_CALLBACK (show_toggled_cb), self);

View file

@ -20,14 +20,19 @@
* Copyright 2007 - 2014 Red Hat, Inc. * Copyright 2007 - 2014 Red Hat, Inc.
*/ */
#ifndef WS_WEP_KEY_H #pragma once
#define WS_WEP_KEY_H
typedef struct _WirelessSecurityWEPKey WirelessSecurityWEPKey; #include <NetworkManager.h>
#include "wireless-security.h"
G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (WirelessSecurityWEPKey, ws_wep_key, WS, WEP_KEY, WirelessSecurity)
WirelessSecurityWEPKey *ws_wep_key_new (NMConnection *connection, WirelessSecurityWEPKey *ws_wep_key_new (NMConnection *connection,
NMWepKeyType type, NMWepKeyType type,
gboolean adhoc_create, gboolean adhoc_create,
gboolean secrets_only); gboolean secrets_only);
#endif /* WS_WEP_KEY_H */ G_END_DECLS

View file

@ -41,33 +41,37 @@ struct _WirelessSecurityWPAEAP {
GtkSizeGroup *size_group; GtkSizeGroup *size_group;
}; };
G_DEFINE_TYPE (WirelessSecurityWPAEAP, ws_wpa_eap, wireless_security_get_type ())
static void static void
destroy (WirelessSecurity *parent) ws_wpa_eap_dispose (GObject *object)
{ {
WirelessSecurityWPAEAP *self = (WirelessSecurityWPAEAP *) parent; WirelessSecurityWPAEAP *self = WS_WPA_EAP (object);
g_clear_object (&self->builder); g_clear_object (&self->builder);
g_clear_object (&self->size_group); g_clear_object (&self->size_group);
G_OBJECT_CLASS (ws_wpa_eap_parent_class)->dispose (object);
} }
static GtkWidget * static GtkWidget *
get_widget (WirelessSecurity *parent) get_widget (WirelessSecurity *security)
{ {
WirelessSecurityWPAEAP *self = (WirelessSecurityWPAEAP *) parent; WirelessSecurityWPAEAP *self = WS_WPA_EAP (security);
return GTK_WIDGET (self->grid); return GTK_WIDGET (self->grid);
} }
static gboolean static gboolean
validate (WirelessSecurity *parent, GError **error) validate (WirelessSecurity *security, GError **error)
{ {
WirelessSecurityWPAEAP *self = (WirelessSecurityWPAEAP *) parent; WirelessSecurityWPAEAP *self = WS_WPA_EAP (security);
return eap_method_validate (ws_802_1x_auth_combo_get_eap (self->auth_combo), error); return eap_method_validate (ws_802_1x_auth_combo_get_eap (self->auth_combo), error);
} }
static void static void
add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group) add_to_size_group (WirelessSecurity *security, GtkSizeGroup *group)
{ {
WirelessSecurityWPAEAP *self = (WirelessSecurityWPAEAP *) parent; WirelessSecurityWPAEAP *self = WS_WPA_EAP (security);
g_clear_object (&self->size_group); g_clear_object (&self->size_group);
self->size_group = g_object_ref (group); self->size_group = g_object_ref (group);
@ -77,9 +81,9 @@ add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group)
} }
static void static void
fill_connection (WirelessSecurity *parent, NMConnection *connection) fill_connection (WirelessSecurity *security, NMConnection *connection)
{ {
WirelessSecurityWPAEAP *self = (WirelessSecurityWPAEAP *) parent; WirelessSecurityWPAEAP *self = WS_WPA_EAP (security);
NMSettingWirelessSecurity *s_wireless_sec; NMSettingWirelessSecurity *s_wireless_sec;
ws_802_1x_fill_connection (self->auth_combo, connection); ws_802_1x_fill_connection (self->auth_combo, connection);
@ -100,24 +104,33 @@ auth_combo_changed_cb (WirelessSecurityWPAEAP *self)
wireless_security_notify_changed (WIRELESS_SECURITY (self)); wireless_security_notify_changed (WIRELESS_SECURITY (self));
} }
void
ws_wpa_eap_init (WirelessSecurityWPAEAP *self)
{
}
void
ws_wpa_eap_class_init (WirelessSecurityWPAEAPClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
WirelessSecurityClass *ws_class = WIRELESS_SECURITY_CLASS (klass);
object_class->dispose = ws_wpa_eap_dispose;
ws_class->get_widget = get_widget;
ws_class->validate = validate;
ws_class->add_to_size_group = add_to_size_group;
ws_class->fill_connection = fill_connection;
}
WirelessSecurityWPAEAP * WirelessSecurityWPAEAP *
ws_wpa_eap_new (NMConnection *connection, ws_wpa_eap_new (NMConnection *connection,
gboolean is_editor, gboolean is_editor,
gboolean secrets_only) gboolean secrets_only)
{ {
WirelessSecurity *parent;
WirelessSecurityWPAEAP *self; WirelessSecurityWPAEAP *self;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
parent = wireless_security_init (sizeof (WirelessSecurityWPAEAP), self = g_object_new (ws_wpa_eap_get_type (), NULL);
get_widget,
validate,
add_to_size_group,
fill_connection,
destroy);
if (!parent)
return NULL;
self = (WirelessSecurityWPAEAP *) parent;
self->builder = gtk_builder_new (); self->builder = gtk_builder_new ();
if (!gtk_builder_add_from_resource (self->builder, "/org/gnome/ControlCenter/network/ws-wpa-eap.ui", &error)) { if (!gtk_builder_add_from_resource (self->builder, "/org/gnome/ControlCenter/network/ws-wpa-eap.ui", &error)) {
@ -130,9 +143,9 @@ 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 (parent, FALSE); wireless_security_set_adhoc_compatible (WIRELESS_SECURITY (self), FALSE);
ws_802_1x_auth_combo_init (parent, ws_802_1x_auth_combo_init (WIRELESS_SECURITY (self),
self->auth_combo, self->auth_combo,
connection, connection,
is_editor, is_editor,

View file

@ -20,12 +20,15 @@
* Copyright 2007 - 2014 Red Hat, Inc. * Copyright 2007 - 2014 Red Hat, Inc.
*/ */
#ifndef WS_WPA_EAP_H #pragma once
#define WS_WPA_EAP_H
#include <gtk/gtk.h> #include <NetworkManager.h>
typedef struct _WirelessSecurityWPAEAP WirelessSecurityWPAEAP; #include "wireless-security.h"
G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (WirelessSecurityWPAEAP, ws_wpa_eap, WS, WPA_EAP, WirelessSecurity)
WirelessSecurityWPAEAP *ws_wpa_eap_new (NMConnection *connection, WirelessSecurityWPAEAP *ws_wpa_eap_new (NMConnection *connection,
gboolean is_editor, gboolean is_editor,
@ -33,4 +36,4 @@ WirelessSecurityWPAEAP *ws_wpa_eap_new (NMConnection *connection,
GtkComboBox *ws_wpa_eap_get_auth_combo (WirelessSecurityWPAEAP *sec); GtkComboBox *ws_wpa_eap_get_auth_combo (WirelessSecurityWPAEAP *sec);
#endif /* WS_WPA_EAP_H */ G_END_DECLS

View file

@ -48,18 +48,22 @@ struct _WirelessSecurityWPAPSK {
const char *password_flags_name; const char *password_flags_name;
}; };
G_DEFINE_TYPE (WirelessSecurityWPAPSK, ws_wpa_psk, wireless_security_get_type ())
static void static void
destroy (WirelessSecurity *parent) ws_wpa_psk_dispose (GObject *object)
{ {
WirelessSecurityWPAPSK *self = (WirelessSecurityWPAPSK *) parent; WirelessSecurityWPAPSK *self = WS_WPA_PSK (object);
g_clear_object (&self->builder); g_clear_object (&self->builder);
G_OBJECT_CLASS (ws_wpa_psk_parent_class)->dispose (object);
} }
static GtkWidget * static GtkWidget *
get_widget (WirelessSecurity *parent) get_widget (WirelessSecurity *security)
{ {
WirelessSecurityWPAPSK *self = (WirelessSecurityWPAPSK *) parent; WirelessSecurityWPAPSK *self = WS_WPA_PSK (security);
return GTK_WIDGET (self->grid); return GTK_WIDGET (self->grid);
} }
@ -73,9 +77,9 @@ show_toggled_cb (WirelessSecurityWPAPSK *self)
} }
static gboolean static gboolean
validate (WirelessSecurity *parent, GError **error) validate (WirelessSecurity *security, GError **error)
{ {
WirelessSecurityWPAPSK *self = (WirelessSecurityWPAPSK *) parent; WirelessSecurityWPAPSK *self = WS_WPA_PSK (security);
const char *key; const char *key;
gsize len; gsize len;
int i; int i;
@ -106,17 +110,17 @@ validate (WirelessSecurity *parent, GError **error)
} }
static void static void
add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group) add_to_size_group (WirelessSecurity *security, GtkSizeGroup *group)
{ {
WirelessSecurityWPAPSK *self = (WirelessSecurityWPAPSK *) parent; WirelessSecurityWPAPSK *self = WS_WPA_PSK (security);
gtk_size_group_add_widget (group, GTK_WIDGET (self->type_label)); gtk_size_group_add_widget (group, GTK_WIDGET (self->type_label));
gtk_size_group_add_widget (group, GTK_WIDGET (self->password_label)); gtk_size_group_add_widget (group, GTK_WIDGET (self->password_label));
} }
static void static void
fill_connection (WirelessSecurity *parent, NMConnection *connection) fill_connection (WirelessSecurity *security, NMConnection *connection)
{ {
WirelessSecurityWPAPSK *self = (WirelessSecurityWPAPSK *) parent; WirelessSecurityWPAPSK *self = WS_WPA_PSK (security);
const char *key; const char *key;
NMSettingWireless *s_wireless; NMSettingWireless *s_wireless;
NMSettingWirelessSecurity *s_wireless_sec; NMSettingWirelessSecurity *s_wireless_sec;
@ -168,39 +172,38 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
} }
} }
static void
update_secrets (WirelessSecurity *parent, NMConnection *connection)
{
WirelessSecurityWPAPSK *self = (WirelessSecurityWPAPSK *) parent;
helper_fill_secret_entry (connection,
self->password_entry,
NM_TYPE_SETTING_WIRELESS_SECURITY,
(HelperSecretFunc) nm_setting_wireless_security_get_psk);
}
static void static void
changed_cb (WirelessSecurityWPAPSK *self) changed_cb (WirelessSecurityWPAPSK *self)
{ {
wireless_security_notify_changed ((WirelessSecurity *) self); wireless_security_notify_changed ((WirelessSecurity *) self);
} }
void
ws_wpa_psk_init (WirelessSecurityWPAPSK *self)
{
}
void
ws_wpa_psk_class_init (WirelessSecurityWPAPSKClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
WirelessSecurityClass *ws_class = WIRELESS_SECURITY_CLASS (klass);
object_class->dispose = ws_wpa_psk_dispose;
ws_class->get_widget = get_widget;
ws_class->validate = validate;
ws_class->add_to_size_group = add_to_size_group;
ws_class->fill_connection = fill_connection;
}
WirelessSecurityWPAPSK * WirelessSecurityWPAPSK *
ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only) ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only)
{ {
WirelessSecurity *parent;
WirelessSecurityWPAPSK *self; WirelessSecurityWPAPSK *self;
NMSetting *setting = NULL; NMSetting *setting = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
parent = wireless_security_init (sizeof (WirelessSecurityWPAPSK), self = g_object_new (ws_wpa_psk_get_type (), NULL);
get_widget,
validate,
add_to_size_group,
fill_connection,
destroy);
if (!parent)
return NULL;
self = (WirelessSecurityWPAPSK *) parent;
self->builder = gtk_builder_new (); self->builder = gtk_builder_new ();
if (!gtk_builder_add_from_resource (self->builder, "/org/gnome/ControlCenter/network/ws-wpa-psk.ui", &error)) { if (!gtk_builder_add_from_resource (self->builder, "/org/gnome/ControlCenter/network/ws-wpa-psk.ui", &error)) {
@ -215,7 +218,7 @@ 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 (parent, FALSE); 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;
@ -230,8 +233,12 @@ ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only)
FALSE, secrets_only); FALSE, secrets_only);
/* Fill secrets, if any */ /* Fill secrets, if any */
if (connection) if (connection) {
update_secrets (WIRELESS_SECURITY (self), connection); helper_fill_secret_entry (connection,
self->password_entry,
NM_TYPE_SETTING_WIRELESS_SECURITY,
(HelperSecretFunc) nm_setting_wireless_security_get_psk);
}
g_signal_connect_swapped (self->show_password_check, "toggled", G_CALLBACK (show_toggled_cb), self); g_signal_connect_swapped (self->show_password_check, "toggled", G_CALLBACK (show_toggled_cb), self);

View file

@ -20,11 +20,16 @@
* Copyright 2007 - 2014 Red Hat, Inc. * Copyright 2007 - 2014 Red Hat, Inc.
*/ */
#ifndef WS_WPA_PSK_H #pragma once
#define WS_WPA_PSK_H
typedef struct _WirelessSecurityWPAPSK WirelessSecurityWPAPSK; #include <NetworkManager.h>
#include "wireless-security.h"
G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (WirelessSecurityWPAPSK, ws_wpa_psk, WS, WPA_PSK, WirelessSecurity)
WirelessSecurityWPAPSK * ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only); WirelessSecurityWPAPSK * ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only);
#endif /* WS_WEP_KEY_H */ G_END_DECLS