Commit 8b593e6a authored by Matthias Clasen's avatar Matthias Clasen Committed by Dan Winship

network: Implement the new design for wired

This expands the connection editor to cover ethernet,
and adds support for multiple wired profiles.
parent e5cc7d80
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkNotebook" id="page">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="show_tabs">False</property>
<property name="show_border">False</property>
<child>
<object class="GtkGrid" id="grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">50</property>
<property name="margin_right">50</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="row_spacing">10</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkLabel" id="heading_sec">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">802.1x _Security</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">8021x_switch</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="8021x_switch">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="vbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">2</property>
<property name="height">1</property>
</packing>
</child>
</object>
</child>
<child type="tab">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">page 1</property>
</object>
<packing>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">50</property>
<property name="margin_right">50</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="row_spacing">10</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkEntry" id="entry1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char"></property>
<property name="width_chars">35</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char"></property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char"></property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry4">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char"></property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry5">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char"></property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry6">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char"></property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry7">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char"></property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">6</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry8">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char"></property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">7</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry9">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char"></property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">8</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry10">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char"></property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">9</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Anony_mous identity</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Inner _authentication</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">page 2</property>
</object>
<packing>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
</object>
</interface>
......@@ -21,7 +21,11 @@ libconnection_editor_la_SOURCES = \
ce-page-security.h \
ce-page-security.c \
ce-page-reset.h \
ce-page-reset.c
ce-page-reset.c \
ce-page-ethernet.h \
ce-page-ethernet.c \
ce-page-8021x-security.h \
ce-page-8021x-security.c
libconnection_editor_la_CPPFLAGS = \
-I$(srcdir)/../wireless-security \
......
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager Connection editor -- Connection editor for NetworkManager
*
* Dan Williams <dcbw@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2008 - 2012 Red Hat, Inc.
*/
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <NetworkManager.h>
#include <nm-setting-connection.h>
#include <nm-setting-wired.h>
#include <nm-setting-8021x.h>
#include <nm-setting-wireless.h>
#include <nm-utils.h>
#include "wireless-security.h"
#include "ce-page-ethernet.h"
#include "ce-page-8021x-security.h"
G_DEFINE_TYPE (CEPage8021xSecurity, ce_page_8021x_security, CE_TYPE_PAGE)
static void
enable_toggled (GObject *sw, GParamSpec *pspec, gpointer user_data)
{
CEPage8021xSecurity *page = CE_PAGE_8021X_SECURITY (user_data);
gtk_widget_set_sensitive (page->security_widget, gtk_switch_get_active (page->enabled));
ce_page_changed (CE_PAGE (page));
}
static void
stuff_changed (WirelessSecurity *sec, gpointer user_data)
{
ce_page_changed (CE_PAGE (user_data));
}
static void
finish_setup (CEPage8021xSecurity *page, gpointer unused, GError *error, gpointer user_data)
{
GtkWidget *parent;
GtkWidget *vbox;
GtkWidget *heading;
if (error)
return;
vbox = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "vbox"));
heading = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "heading_sec"));
page->group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
page->security = (WirelessSecurity *) ws_wpa_eap_new (CE_PAGE (page)->connection, TRUE, FALSE);
if (!page->security) {
g_warning ("Could not load 802.1x user interface.");
return;
}
wireless_security_set_changed_notify (page->security, stuff_changed, page);
page->security_widget = wireless_security_get_widget (page->security);
parent = gtk_widget_get_parent (page->security_widget);
if (parent)
gtk_container_remove (GTK_CONTAINER (parent), page->security_widget);
gtk_switch_set_active (page->enabled, page->initial_have_8021x);
g_signal_connect (page->enabled, "notify::active", G_CALLBACK (enable_toggled), page);
gtk_widget_set_sensitive (page->security_widget, page->initial_have_8021x);
gtk_size_group_add_widget (page->group, heading);
wireless_security_add_to_size_group (page->security, page->group);
gtk_container_add (GTK_CONTAINER (vbox), page->security_widget);
}
CEPage *
ce_page_8021x_security_new (NMConnection *connection,
NMClient *client,
NMRemoteSettings *settings)
{
CEPage8021xSecurity *page;
page = CE_PAGE_8021X_SECURITY (ce_page_new (CE_TYPE_PAGE_8021X_SECURITY,
connection,
client,
settings,
"/org/gnome/control-center/network/8021x-security-page.ui",
_("Security")));
if (nm_connection_get_setting_802_1x (connection))
page->initial_have_8021x = TRUE;
page->enabled = GTK_SWITCH (gtk_builder_get_object (CE_PAGE (page)->builder, "8021x_switch"));
g_signal_connect (page, "initialized", G_CALLBACK (finish_setup), NULL);
if (page->initial_have_8021x)
CE_PAGE (page)->security_setting = NM_SETTING_802_1X_SETTING_NAME;
return CE_PAGE (page);
}
static gboolean
validate (CEPage *cepage, NMConnection *connection, GError **error)
{
CEPage8021xSecurity *page = CE_PAGE_8021X_SECURITY (cepage);
gboolean valid = TRUE;
if (gtk_switch_get_active (page->enabled)) {
NMConnection *tmp_connection;
NMSetting *s_8021x;
/* FIXME: get failed property and error out of wireless security objects */
valid = wireless_security_validate (page->security, NULL);
if (valid) {
NMSetting *s_con;
/* Here's a nice hack to work around the fact that ws_802_1x_fill_connection needs wireless setting. */
tmp_connection = nm_connection_new ();
nm_connection_add_setting (tmp_connection, nm_setting_wireless_new ());
/* temp connection needs a 'connection' setting too, since most of
* the EAP methods need the UUID for CA cert ignore stuff.
*/
s_con = nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
nm_connection_add_setting (tmp_connection, nm_setting_duplicate (s_con));
ws_802_1x_fill_connection (page->security, "wpa_eap_auth_combo", tmp_connection);
s_8021x = nm_connection_get_setting (tmp_connection, NM_TYPE_SETTING_802_1X);
nm_connection_add_setting (connection, NM_SETTING (g_object_ref (s_8021x)));
g_object_unref (tmp_connection);
} else
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_UNKNOWN, "Invalid 802.1x security");
} else {
nm_connection_remove_setting (connection, NM_TYPE_SETTING_802_1X);
valid = TRUE;
}
return valid;
}
static void
ce_page_8021x_security_init (CEPage8021xSecurity *page)
{
}
static void
dispose (GObject *object)
{
CEPage8021xSecurity *page = CE_PAGE_8021X_SECURITY (object);
if (page->security) {
wireless_security_unref (page->security);
page->security = NULL;
}
g_clear_object (&page->group);
G_OBJECT_CLASS (ce_page_8021x_security_parent_class)->dispose (object);
}
static void
ce_page_8021x_security_class_init (CEPage8021xSecurityClass *security_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (security_class);
CEPageClass *parent_class = CE_PAGE_CLASS (security_class);
/* virtual methods */
object_class->dispose = dispose;
parent_class->validate = validate;
}
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager Connection editor -- Connection editor for NetworkManager
*
* Dan Williams <dcbw@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2008 - 2012 Red Hat, Inc.
*/
#ifndef __CE_PAGE_8021X_SECURITY_H
#define __CE_PAGE_8021X_SECURITY_H
#include <nm-connection.h>
#include "wireless-security.h"
#include <glib.h>
#include <glib-object.h>
#include "ce-page.h"
#define CE_TYPE_PAGE_8021X_SECURITY (ce_page_8021x_security_get_type ())
#define CE_PAGE_8021X_SECURITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CE_TYPE_PAGE_8021X_SECURITY, CEPage8021xSecurity))
#define CE_PAGE_8021X_SECURITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CE_TYPE_PAGE_8021X_SECURITY, CEPage8021xSecurityClass))
#define CE_IS_PAGE_8021X_SECURITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CE_TYPE_PAGE_8021X_SECURITY))
#define CE_IS_PAGE_8021X_SECURITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CE_TYPE_PAGE_8021X_SECURITY))
#define CE_PAGE_8021X_SECURITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CE_TYPE_PAGE_8021X_SECURITY, CEPage8021xSecurityClass))
typedef struct CEPage8021xSecurity CEPage8021xSecurity;
typedef struct CEPage8021xSecurityClass CEPage8021xSecurityClass;
struct CEPage8021xSecurity {
CEPage parent;
GtkSwitch *enabled;
GtkWidget *security_widget;
WirelessSecurity *security;
GtkSizeGroup *group;
gboolean initial_have_8021x;
};
struct CEPage8021xSecurityClass {
CEPageClass parent;
};
GType ce_page_8021x_security_get_type (void);
CEPage *ce_page_8021x_security_new (NMConnection *connection,
NMClient *client,
NMRemoteSettings *settings);
#endif /* __CE_PAGE_8021X_SECURITY_H */
......@@ -26,6 +26,7 @@
#include <nm-utils.h>
#include <nm-device-wifi.h>
#include <nm-device-ethernet.h>
#include "../panel-common.h"
#include "ce-page-details.h"
......@@ -120,12 +121,35 @@ connect_details_page (CEPageDetails *page)
NMDeviceState state;
NMAccessPoint *active_ap;
const gchar *str;
gboolean device_is_active;
if (NM_IS_DEVICE_WIFI (page->device))
active_ap = nm_device_wifi_get_active_access_point (NM_DEVICE_WIFI (page->device));
else
active_ap = NULL;
state = nm_device_get_state (page->device);
device_is_active = FALSE;
speed = 0;
if (page->ap == active_ap && state != NM_DEVICE_STATE_UNAVAILABLE) {
speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (page->device)) / 1000;
if (active_ap && page->ap == active_ap && state != NM_DEVICE_STATE_UNAVAILABLE) {
device_is_active = TRUE;
if (NM_IS_DEVICE_WIFI (page->device))
speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (page->device)) / 1000;
} else {
NMActiveConnection *ac;
const gchar *p1, *p2;
ac = nm_device_get_active_connection (page->device);
p1 = ac ? nm_active_connection_get_connection (ac) : NULL;
p2 = nm_connection_get_path (CE_PAGE (page)->connection);
if (g_strcmp0 (p1, p2) == 0) {
device_is_active = TRUE;
if (NM_IS_DEVICE_WIFI (page->device))
speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (page->device)) / 1000;
else if (NM_IS_DEVICE_ETHERNET (page->device))
speed = nm_device_ethernet_get_speed (NM_DEVICE_ETHERNET (page->device));
}
}
if (speed > 0)
str = g_strdup_printf (_("%d Mb/s"), speed);
......@@ -133,11 +157,15 @@ connect_details_page (CEPageDetails *page)
str = NULL;
panel_set_device_widget_details (CE_PAGE (page)->builder, "speed", str);
str = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (page->device));
if (NM_IS_DEVICE_WIFI (page->device))
str = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (page->device));
else if (NM_IS_DEVICE_ETHERNET (page->device))
str = nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (page->device));
panel_set_device_widget_details (CE_PAGE (page)->builder, "mac", str);
str = NULL;
if (page->ap == active_ap)
if (device_is_active && active_ap)
str = get_ap_security_string (active_ap);
panel_set_device_widget_details (CE_PAGE (page)->builder, "security", str);
......@@ -160,12 +188,12 @@ connect_details_page (CEPageDetails *page)
panel_set_device_widget_details (CE_PAGE (page)->builder, "strength", str);
/* set IP entries */
if (page->ap != active_ap)
panel_unset_device_widgets (CE_PAGE (page)->builder);
else
if (device_is_active)
panel_set_device_widgets (CE_PAGE (page)->builder, page->device);
else
panel_unset_device_widgets (CE_PAGE (page)->builder);
if (page->ap != active_ap && CE_PAGE (page)->connection)
if (!device_is_active && CE_PAGE (page)->connection)
update_last_used (page, CE_PAGE (page)->connection);
else
panel_set_device_widget_details (CE_PAGE (page)->builder, "last_used", NULL);
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2012 Red Hat, Inc
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include <glib-object.h>
#include <glib/gi18n.h>
#include <nm-utils.h>
#include <nm-device-ethernet.h>
#include <net/if_arp.h>
#include "ce-page-ethernet.h"
G_DEFINE_TYPE (CEPageEthernet, ce_page_ethernet, CE_TYPE_PAGE)
static void
all_user_changed (GtkToggleButton *b, CEPageEthernet *page)
{
gboolean all_users;
NMSettingConnection *sc;
sc = nm_connection_get_setting_connection (CE_PAGE (page)->connection);
all_users = gtk_toggle_button_get_active (b);
g_object_set (sc, "permissions", NULL, NULL);
if (!all_users)
nm_setting_connection_add_permission (sc, "user", g_get_user_name (), NULL);
}