1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
/* NetworkManager Connection editor -- Connection editor for NetworkManager
4
* Dan Williams <dcbw@redhat.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License along
17
* with this program; if not, write to the Free Software Foundation, Inc.,
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
* (C) Copyright 2008 - 2012 Red Hat, Inc.
28
#include <glib/gi18n.h>
30
#include <NetworkManager.h>
32
#include "wireless-security.h"
33
#include "ce-page-ethernet.h"
34
#include "ce-page-8021x-security.h"
36
G_DEFINE_TYPE (CEPage8021xSecurity, ce_page_8021x_security, CE_TYPE_PAGE)
39
enable_toggled (GObject *sw, GParamSpec *pspec, gpointer user_data)
41
CEPage8021xSecurity *page = CE_PAGE_8021X_SECURITY (user_data);
43
gtk_widget_set_sensitive (page->security_widget, gtk_switch_get_active (page->enabled));
44
ce_page_changed (CE_PAGE (page));
48
stuff_changed (WirelessSecurity *sec, gpointer user_data)
50
ce_page_changed (CE_PAGE (user_data));
54
finish_setup (CEPage8021xSecurity *page, gpointer unused, GError *error, gpointer user_data)
63
vbox = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "vbox"));
64
heading = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "heading_sec"));
66
page->group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
68
page->security = (WirelessSecurity *) ws_wpa_eap_new (CE_PAGE (page)->connection, TRUE, FALSE);
69
if (!page->security) {
70
g_warning ("Could not load 802.1x user interface.");
74
wireless_security_set_changed_notify (page->security, stuff_changed, page);
75
page->security_widget = wireless_security_get_widget (page->security);
76
parent = gtk_widget_get_parent (page->security_widget);
78
gtk_container_remove (GTK_CONTAINER (parent), page->security_widget);
80
gtk_switch_set_active (page->enabled, page->initial_have_8021x);
81
g_signal_connect (page->enabled, "notify::active", G_CALLBACK (enable_toggled), page);
82
gtk_widget_set_sensitive (page->security_widget, page->initial_have_8021x);
84
gtk_size_group_add_widget (page->group, heading);
85
wireless_security_add_to_size_group (page->security, page->group);
87
gtk_container_add (GTK_CONTAINER (vbox), page->security_widget);
92
ce_page_8021x_security_new (NMConnection *connection,
95
CEPage8021xSecurity *page;
97
page = CE_PAGE_8021X_SECURITY (ce_page_new (CE_TYPE_PAGE_8021X_SECURITY,
100
"/org/gnome/control-center/network/8021x-security-page.ui",
103
if (nm_connection_get_setting_802_1x (connection))
104
page->initial_have_8021x = TRUE;
106
page->enabled = GTK_SWITCH (gtk_builder_get_object (CE_PAGE (page)->builder, "8021x_switch"));
108
g_signal_connect (page, "initialized", G_CALLBACK (finish_setup), NULL);
110
if (page->initial_have_8021x)
111
CE_PAGE (page)->security_setting = NM_SETTING_802_1X_SETTING_NAME;
113
return CE_PAGE (page);
117
validate (CEPage *cepage, NMConnection *connection, GError **error)
119
CEPage8021xSecurity *page = CE_PAGE_8021X_SECURITY (cepage);
120
gboolean valid = TRUE;
122
if (gtk_switch_get_active (page->enabled)) {
123
NMConnection *tmp_connection;
126
/* FIXME: get failed property and error out of wireless security objects */
127
valid = wireless_security_validate (page->security, error);
131
/* Here's a nice hack to work around the fact that ws_802_1x_fill_connection needs wireless setting. */
132
tmp_connection = nm_simple_connection_new ();
133
nm_connection_add_setting (tmp_connection, nm_setting_wireless_new ());
135
/* temp connection needs a 'connection' setting too, since most of
136
* the EAP methods need the UUID for CA cert ignore stuff.
138
s_con = nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
139
nm_connection_add_setting (tmp_connection, nm_setting_duplicate (s_con));
141
ws_802_1x_fill_connection (page->security, "wpa_eap_auth_combo", tmp_connection);
143
s_8021x = nm_connection_get_setting (tmp_connection, NM_TYPE_SETTING_802_1X);
144
nm_connection_add_setting (connection, NM_SETTING (g_object_ref (s_8021x)));
146
g_object_unref (tmp_connection);
149
nm_connection_remove_setting (connection, NM_TYPE_SETTING_802_1X);
157
ce_page_8021x_security_init (CEPage8021xSecurity *page)
162
dispose (GObject *object)
164
CEPage8021xSecurity *page = CE_PAGE_8021X_SECURITY (object);
166
if (page->security) {
167
wireless_security_unref (page->security);
168
page->security = NULL;
171
g_clear_object (&page->group);
173
G_OBJECT_CLASS (ce_page_8021x_security_parent_class)->dispose (object);
177
ce_page_8021x_security_class_init (CEPage8021xSecurityClass *security_class)
179
GObjectClass *object_class = G_OBJECT_CLASS (security_class);
180
CEPageClass *parent_class = CE_PAGE_CLASS (security_class);
182
/* virtual methods */
183
object_class->dispose = dispose;
185
parent_class->validate = validate;