network-manager-applet r667 - in trunk: . src/connection-editor src/gconf-helpers src/wireless-security
- From: tambeti svn gnome org
- To: svn-commits-list gnome org
- Subject: network-manager-applet r667 - in trunk: . src/connection-editor src/gconf-helpers src/wireless-security
- Date: Tue, 15 Apr 2008 17:04:13 +0100 (BST)
Author: tambeti
Date: Tue Apr 15 17:04:13 2008
New Revision: 667
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=667&view=rev
Log:
2008-04-15 Tambet Ingo <tambet gmail com>
* src/connection-editor/page-wireless.c (ce_page_wireless_new):
* src/connection-editor/page-wired.c (ce_page_wired_new):
* src/connection-editor/page-mobile.c (ce_page_mobile_new):
* src/connection-editor/page-ip4.c (ce_page_ip4_new):
* src/connection-editor/page-dsl.c (ce_page_dsl_new): Use
nm_setting_duplicate() instead of hashing the setting first and then
creating a new setting out of the hash. In addition to being annoying
to do, it also missed non-serializable properties in the duplicate.
2008-04-15 Tambet Ingo <tambet gmail com>
* src/connection-editor/page-wired-security.[ch]: Implement.
* src/connection-editor/nm-connection-editor.c
(nm_connection_editor_set_connection): Add wired security page.
* src/connection-editor/Makefile.am: Build new files.
* src/wireless-security/wireless-security.c
(ws_802_1x_auth_combo_init): Don't require a wireless security setting,
makes it preselect the correct EAP method for wired security as well.
* src/gconf-helpers/gconf-helpers.c (remove_leftovers): Implement.
(nm_gconf_write_connection): Remove the left over settings from GConf
which are not part of NMConnection anymore.
Added:
trunk/src/connection-editor/page-wired-security.c
trunk/src/connection-editor/page-wired-security.h
Modified:
trunk/ChangeLog
trunk/src/connection-editor/Makefile.am
trunk/src/connection-editor/nm-connection-editor.c
trunk/src/connection-editor/page-dsl.c
trunk/src/connection-editor/page-ip4.c
trunk/src/connection-editor/page-mobile.c
trunk/src/connection-editor/page-wired.c
trunk/src/connection-editor/page-wireless.c
trunk/src/gconf-helpers/gconf-helpers.c
trunk/src/wireless-security/wireless-security.c
Modified: trunk/src/connection-editor/Makefile.am
==============================================================================
--- trunk/src/connection-editor/Makefile.am (original)
+++ trunk/src/connection-editor/Makefile.am Tue Apr 15 17:04:13 2008
@@ -28,6 +28,8 @@
ce-page.c \
page-wired.h \
page-wired.c \
+ page-wired-security.h \
+ page-wired-security.c \
page-wireless.h \
page-wireless.c \
page-wireless-security.h \
Modified: trunk/src/connection-editor/nm-connection-editor.c
==============================================================================
--- trunk/src/connection-editor/nm-connection-editor.c (original)
+++ trunk/src/connection-editor/nm-connection-editor.c Tue Apr 15 17:04:13 2008
@@ -36,6 +36,7 @@
#include <nm-setting-connection.h>
#include <nm-setting-ip4-config.h>
#include <nm-setting-wired.h>
+#include <nm-setting-8021x.h>
#include <nm-setting-wireless.h>
#include <nm-setting-wireless-security.h>
#include <nm-setting-vpn.h>
@@ -50,6 +51,7 @@
#include "ce-page.h"
#include "page-wired.h"
+#include "page-wired-security.h"
#include "page-wireless.h"
#include "page-wireless-security.h"
#include "page-ip4.h"
@@ -376,6 +378,7 @@
if (!strcmp (s_con->type, NM_SETTING_WIRED_SETTING_NAME)) {
add_page (editor, CE_PAGE (ce_page_wired_new (editor->connection)));
+ add_page (editor, CE_PAGE (ce_page_wired_security_new (editor->connection)));
add_page (editor, CE_PAGE (ce_page_ip4_address_new (editor->connection)));
add_page (editor, CE_PAGE (ce_page_ip4_new (editor->connection)));
} else if (!strcmp (s_con->type, NM_SETTING_WIRELESS_SETTING_NAME)) {
Modified: trunk/src/connection-editor/page-dsl.c
==============================================================================
--- trunk/src/connection-editor/page-dsl.c (original)
+++ trunk/src/connection-editor/page-dsl.c Tue Apr 15 17:04:13 2008
@@ -120,15 +120,9 @@
priv = CE_PAGE_DSL_GET_PRIVATE (self);
s_pppoe = (NMSettingPPPOE *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPPOE);
- if (s_pppoe) {
- /* Duplicate it */
- /* FIXME: Implement nm_setting_dup () in nm-setting.[ch] maybe? */
- GHashTable *hash;
-
- hash = nm_setting_to_hash (NM_SETTING (s_pppoe));
- priv->setting = NM_SETTING_PPPOE (nm_setting_from_hash (NM_TYPE_SETTING_PPPOE, hash));
- g_hash_table_destroy (hash);
- } else
+ if (s_pppoe)
+ priv->setting = NM_SETTING_PPPOE (nm_setting_duplicate (NM_SETTING (s_pppoe)));
+ else
priv->setting = NM_SETTING_PPPOE (nm_setting_pppoe_new ());
populate_ui (self);
Modified: trunk/src/connection-editor/page-ip4.c
==============================================================================
--- trunk/src/connection-editor/page-ip4.c (original)
+++ trunk/src/connection-editor/page-ip4.c Tue Apr 15 17:04:13 2008
@@ -282,15 +282,9 @@
priv = CE_PAGE_IP4_GET_PRIVATE (self);
s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
- if (s_ip4) {
- /* Duplicate it */
- /* FIXME: Implement nm_setting_dup () in nm-setting.[ch] maybe? */
- GHashTable *hash;
-
- hash = nm_setting_to_hash (NM_SETTING (s_ip4));
- priv->setting = NM_SETTING_IP4_CONFIG (nm_setting_from_hash (NM_TYPE_SETTING_IP4_CONFIG, hash));
- g_hash_table_destroy (hash);
- } else
+ if (s_ip4)
+ priv->setting = NM_SETTING_IP4_CONFIG (nm_setting_duplicate (NM_SETTING (s_ip4)));
+ else
priv->setting = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
populate_ui (self);
Modified: trunk/src/connection-editor/page-mobile.c
==============================================================================
--- trunk/src/connection-editor/page-mobile.c (original)
+++ trunk/src/connection-editor/page-mobile.c Tue Apr 15 17:04:13 2008
@@ -192,7 +192,6 @@
CEPageMobilePrivate *priv;
CEPage *parent;
NMSetting *setting;
- GHashTable *hash;
self = CE_PAGE_MOBILE (g_object_new (CE_TYPE_PAGE_MOBILE, NULL));
parent = CE_PAGE (self);
@@ -228,10 +227,7 @@
return NULL;
}
- hash = nm_setting_to_hash (setting);
- priv->setting = nm_setting_from_hash (G_OBJECT_TYPE (setting), hash);
- g_hash_table_destroy (hash);
-
+ priv->setting = nm_setting_duplicate (setting);
populate_ui (self);
g_signal_connect (priv->number, "changed", G_CALLBACK (stuff_changed), self);
Added: trunk/src/connection-editor/page-wired-security.c
==============================================================================
--- (empty file)
+++ trunk/src/connection-editor/page-wired-security.c Tue Apr 15 17:04:13 2008
@@ -0,0 +1,174 @@
+/* -*- 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * (C) Copyright 2008 Red Hat, Inc.
+ */
+
+#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 "page-wired.h"
+#include "page-wired-security.h"
+#include "nm-connection-editor.h"
+#include "gconf-helpers.h"
+
+G_DEFINE_TYPE (CEPageWiredSecurity, ce_page_wired_security, CE_TYPE_PAGE)
+
+#define CE_PAGE_WIRED_SECURITY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CE_TYPE_PAGE_WIRED_SECURITY, CEPageWiredSecurityPrivate))
+
+typedef struct {
+ GtkToggleButton *enabled;
+ GtkWidget *security_widget;
+ WirelessSecurity *security;
+
+ gboolean disposed;
+} CEPageWiredSecurityPrivate;
+
+static void
+stuff_changed (WirelessSecurity *sec, gpointer user_data)
+{
+ ce_page_changed (CE_PAGE (user_data));
+}
+
+static void
+enable_toggled (GtkToggleButton *button, gpointer user_data)
+{
+ CEPageWiredSecurityPrivate *priv = CE_PAGE_WIRED_SECURITY_GET_PRIVATE (user_data);
+
+ gtk_widget_set_sensitive (priv->security_widget, gtk_toggle_button_get_active (priv->enabled));
+ ce_page_changed (CE_PAGE (user_data));
+}
+
+CEPageWiredSecurity *
+ce_page_wired_security_new (NMConnection *connection)
+{
+ CEPageWiredSecurity *self;
+ CEPage *parent;
+ CEPageWiredSecurityPrivate *priv;
+ const char *glade_file = GLADEDIR "/applet.glade";
+ const char *connection_id;
+ NMSetting *setting;
+
+ self = CE_PAGE_WIRED_SECURITY (g_object_new (CE_TYPE_PAGE_WIRED_SECURITY, NULL));
+ parent = CE_PAGE (self);
+ priv = CE_PAGE_WIRED_SECURITY_GET_PRIVATE (self);
+
+ parent->title = g_strdup (_("802.1x Security"));
+ parent->page = gtk_vbox_new (FALSE, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (parent->page), 6);
+
+ setting = nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
+
+ connection_id = g_object_get_data (G_OBJECT (connection), NMA_CONNECTION_ID_TAG);
+ priv->security = (WirelessSecurity *) ws_wpa_eap_new (glade_file, connection, connection_id);
+ wireless_security_set_changed_notify (priv->security, stuff_changed, self);
+ priv->security_widget = wireless_security_get_widget (priv->security);
+
+ priv->enabled = GTK_TOGGLE_BUTTON (gtk_check_button_new_with_label (_("Enabled")));
+ g_signal_connect (priv->enabled, "toggled",
+ G_CALLBACK (enable_toggled), self);
+
+ gtk_toggle_button_set_active (priv->enabled, setting != NULL);
+ gtk_widget_set_sensitive (priv->security_widget, setting != NULL);
+
+ gtk_box_pack_start_defaults (GTK_BOX (parent->page), GTK_WIDGET (priv->enabled));
+ gtk_box_pack_start_defaults (GTK_BOX (parent->page), priv->security_widget);
+ g_object_ref_sink (parent->page);
+ gtk_widget_show_all (parent->page);
+
+ return self;
+}
+
+static gboolean
+validate (CEPage *page)
+{
+ CEPageWiredSecurityPrivate *priv = CE_PAGE_WIRED_SECURITY_GET_PRIVATE (page);
+ gboolean valid = TRUE;
+
+ if (gtk_toggle_button_get_active (priv->enabled))
+ valid = wireless_security_validate (priv->security, NULL);
+
+ return valid;
+}
+
+static void
+update_connection (CEPage *page, NMConnection *connection)
+{
+ CEPageWiredSecurityPrivate *priv = CE_PAGE_WIRED_SECURITY_GET_PRIVATE (page);
+
+ if (gtk_toggle_button_get_active (priv->enabled)) {
+ NMConnection *tmp_connection;
+ NMSetting *s_8021x;
+
+ /* 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 ());
+ ws_802_1x_fill_connection (priv->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
+ nm_connection_remove_setting (connection, NM_TYPE_SETTING_802_1X);
+}
+
+static void
+ce_page_wired_security_init (CEPageWiredSecurity *self)
+{
+}
+
+static void
+dispose (GObject *object)
+{
+ CEPageWiredSecurityPrivate *priv = CE_PAGE_WIRED_SECURITY_GET_PRIVATE (object);
+
+ if (priv->disposed)
+ return;
+
+ priv->disposed = TRUE;
+ wireless_security_unref (priv->security);
+
+ G_OBJECT_CLASS (ce_page_wired_security_parent_class)->dispose (object);
+}
+
+static void
+ce_page_wired_security_class_init (CEPageWiredSecurityClass *wired_security_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (wired_security_class);
+ CEPageClass *parent_class = CE_PAGE_CLASS (wired_security_class);
+
+ g_type_class_add_private (object_class, sizeof (CEPageWiredSecurityPrivate));
+
+ /* virtual methods */
+ object_class->dispose = dispose;
+
+ parent_class->validate = validate;
+ parent_class->update_connection = update_connection;
+}
Added: trunk/src/connection-editor/page-wired-security.h
==============================================================================
--- (empty file)
+++ trunk/src/connection-editor/page-wired-security.h Tue Apr 15 17:04:13 2008
@@ -0,0 +1,54 @@
+/* -*- 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * (C) Copyright 2008 Red Hat, Inc.
+ */
+
+#ifndef __PAGE_WIRED_SECURITY_H__
+#define __PAGE_WIRED_SECURITY_H__
+
+#include "nm-connection-editor.h"
+
+#include <nm-connection.h>
+
+#include <glib/gtypes.h>
+#include <glib-object.h>
+
+#include "ce-page.h"
+
+#define CE_TYPE_PAGE_WIRED_SECURITY (ce_page_wired_security_get_type ())
+#define CE_PAGE_WIRED_SECURITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CE_TYPE_PAGE_WIRED_SECURITY, CEPageWiredSecurity))
+#define CE_PAGE_WIRED_SECURITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CE_TYPE_PAGE_WIRED_SECURITY, CEPageWiredSecurityClass))
+#define CE_IS_PAGE_WIRED_SECURITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CE_TYPE_PAGE_WIRED_SECURITY))
+#define CE_IS_PAGE_WIRED_SECURITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), CE_TYPE_PAGE_WIRED_SECURITY))
+#define CE_PAGE_WIRED_SECURITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CE_TYPE_PAGE_WIRED_SECURITY, CEPageWiredSecurityClass))
+
+typedef struct {
+ CEPage parent;
+} CEPageWiredSecurity;
+
+typedef struct {
+ CEPageClass parent;
+} CEPageWiredSecurityClass;
+
+GType ce_page_wired_security_get_type (void);
+
+CEPageWiredSecurity *ce_page_wired_security_new (NMConnection *connection);
+
+#endif /* __PAGE_WIRED_SECURITY_H__ */
Modified: trunk/src/connection-editor/page-wired.c
==============================================================================
--- trunk/src/connection-editor/page-wired.c (original)
+++ trunk/src/connection-editor/page-wired.c Tue Apr 15 17:04:13 2008
@@ -174,15 +174,9 @@
priv = CE_PAGE_WIRED_GET_PRIVATE (self);
s_wired = (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED);
- if (s_wired) {
- /* Duplicate it */
- /* FIXME: Implement nm_setting_dup () in nm-setting.[ch] maybe? */
- GHashTable *hash;
-
- hash = nm_setting_to_hash (NM_SETTING (s_wired));
- priv->setting = NM_SETTING_WIRED (nm_setting_from_hash (NM_TYPE_SETTING_WIRED, hash));
- g_hash_table_destroy (hash);
- } else
+ if (s_wired)
+ priv->setting = NM_SETTING_WIRED (nm_setting_duplicate (NM_SETTING (s_wired)));
+ else
priv->setting = NM_SETTING_WIRED (nm_setting_wired_new ());
populate_ui (self);
Modified: trunk/src/connection-editor/page-wireless.c
==============================================================================
--- trunk/src/connection-editor/page-wireless.c (original)
+++ trunk/src/connection-editor/page-wireless.c Tue Apr 15 17:04:13 2008
@@ -299,15 +299,9 @@
priv = CE_PAGE_WIRELESS_GET_PRIVATE (self);
s_wireless = (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
- if (s_wireless) {
- /* Duplicate it */
- /* FIXME: Implement nm_setting_dup () in nm-setting.[ch] maybe? */
- GHashTable *hash;
-
- hash = nm_setting_to_hash (NM_SETTING (s_wireless));
- priv->setting = NM_SETTING_WIRELESS (nm_setting_from_hash (NM_TYPE_SETTING_WIRELESS, hash));
- g_hash_table_destroy (hash);
- } else
+ if (s_wireless)
+ priv->setting = NM_SETTING_WIRELESS (nm_setting_duplicate (NM_SETTING (s_wireless)));
+ else
priv->setting = NM_SETTING_WIRELESS (nm_setting_wireless_new ());
populate_ui (self);
Modified: trunk/src/gconf-helpers/gconf-helpers.c
==============================================================================
--- trunk/src/gconf-helpers/gconf-helpers.c (original)
+++ trunk/src/gconf-helpers/gconf-helpers.c Tue Apr 15 17:04:13 2008
@@ -1098,6 +1098,30 @@
}
}
+static void
+remove_leftovers (CopyOneSettingValueInfo *info)
+{
+ GSList *dirs;
+ GSList *iter;
+ size_t prefix_len;
+
+ prefix_len = strlen (info->dir) + 1;
+
+ dirs = gconf_client_all_dirs (info->client, info->dir, NULL);
+ for (iter = dirs; iter; iter = iter->next) {
+ char *key = (char *) iter->data;
+ NMSetting *setting;
+
+ setting = nm_connection_get_setting_by_name (info->connection, key + prefix_len);
+ if (!setting)
+ gconf_client_recursive_unset (info->client, key, 0, NULL);
+
+ g_free (key);
+ }
+
+ g_slist_free (dirs);
+}
+
void
nm_gconf_write_connection (NMConnection *connection,
GConfClient *client,
@@ -1124,6 +1148,9 @@
nm_connection_for_each_setting_value (connection,
copy_one_setting_value_to_gconf,
&info);
+
+ remove_leftovers (&info);
+
write_applet_private_values_to_gconf (&info);
}
Modified: trunk/src/wireless-security/wireless-security.c
==============================================================================
--- trunk/src/wireless-security/wireless-security.c (original)
+++ trunk/src/wireless-security/wireless-security.c Tue Apr 15 17:04:13 2008
@@ -294,16 +294,11 @@
/* Grab the default EAP method out of the security object */
if (connection) {
- NMSettingWireless *s_wireless;
+ NMSetting8021x *s_8021x;
- s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
- if (s_wireless && s_wireless->security && !strcmp (s_wireless->security, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME)) {
- NMSetting8021x *s_8021x;
-
- s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
- if (s_8021x && s_8021x->eap)
- default_method = g_slist_nth_data (s_8021x->eap, 0);
- }
+ s_8021x = (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
+ if (s_8021x && s_8021x->eap)
+ default_method = g_slist_nth_data (s_8021x->eap, 0);
}
auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_g_type ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]