NetworkManager r4215 - in trunk: . libnm-util src system-settings/plugins/ifcfg-fedora system-settings/plugins/ifcfg-suse system-settings/src
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r4215 - in trunk: . libnm-util src system-settings/plugins/ifcfg-fedora system-settings/plugins/ifcfg-suse system-settings/src
- Date: Sun, 26 Oct 2008 17:02:05 +0000 (UTC)
Author: dcbw
Date: Sun Oct 26 17:02:05 2008
New Revision: 4215
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=4215&view=rev
Log:
2008-10-26 Dan Williams <dcbw redhat com>
Patch from Tambet Ingo <tambet gmail com>
* libnm-util/libnm-util.ver
libnm-util/nm-setting-wired.c
libnm-util/nm-setting-wired.h
- Make properties private and add accessor functions
* src/nm-device-ethernet.c
system-settings/plugins/ifcfg-fedora/nm-ifcfg-connection.c
system-settings/plugins/ifcfg-suse/parser.c
system-settings/src/main.c
- Use those accessors
Modified:
trunk/ChangeLog
trunk/libnm-util/libnm-util.ver
trunk/libnm-util/nm-setting-wired.c
trunk/libnm-util/nm-setting-wired.h
trunk/src/nm-device-ethernet.c
trunk/system-settings/plugins/ifcfg-fedora/nm-ifcfg-connection.c
trunk/system-settings/plugins/ifcfg-suse/parser.c
trunk/system-settings/src/main.c
Modified: trunk/libnm-util/libnm-util.ver
==============================================================================
--- trunk/libnm-util/libnm-util.ver (original)
+++ trunk/libnm-util/libnm-util.ver Sun Oct 26 17:02:05 2008
@@ -95,6 +95,12 @@
nm_setting_wired_error_quark;
nm_setting_wired_get_type;
nm_setting_wired_new;
+ nm_setting_wired_get_port;
+ nm_setting_wired_get_speed;
+ nm_setting_wired_get_duplex;
+ nm_setting_wired_get_auto_negotiate;
+ nm_setting_wired_get_mac_address;
+ nm_setting_wired_get_mtu;
nm_setting_wireless_ap_security_compatible;
nm_setting_wireless_error_get_type;
nm_setting_wireless_error_quark;
Modified: trunk/libnm-util/nm-setting-wired.c
==============================================================================
--- trunk/libnm-util/nm-setting-wired.c (original)
+++ trunk/libnm-util/nm-setting-wired.c Sun Oct 26 17:02:05 2008
@@ -65,6 +65,17 @@
G_DEFINE_TYPE (NMSettingWired, nm_setting_wired, NM_TYPE_SETTING)
+#define NM_SETTING_WIRED_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIRED, NMSettingWiredPrivate))
+
+typedef struct {
+ char *port;
+ guint32 speed;
+ char *duplex;
+ gboolean auto_negotiate;
+ GByteArray *mac_address;
+ guint32 mtu;
+} NMSettingWiredPrivate;
+
enum {
PROP_0,
PROP_PORT,
@@ -83,14 +94,62 @@
return (NMSetting *) g_object_new (NM_TYPE_SETTING_WIRED, NULL);
}
+const char *
+nm_setting_wired_get_port (NMSettingWired *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
+
+ return NM_SETTING_WIRED_GET_PRIVATE (setting)->port;
+}
+
+guint32
+nm_setting_wired_get_speed (NMSettingWired *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), 0);
+
+ return NM_SETTING_WIRED_GET_PRIVATE (setting)->speed;
+}
+
+const char *
+nm_setting_wired_get_duplex (NMSettingWired *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
+
+ return NM_SETTING_WIRED_GET_PRIVATE (setting)->duplex;
+}
+
+gboolean
+nm_setting_wired_get_auto_negotiate (NMSettingWired *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE);
+
+ return NM_SETTING_WIRED_GET_PRIVATE (setting)->auto_negotiate;
+}
+
+const GByteArray *
+nm_setting_wired_get_mac_address (NMSettingWired *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
+
+ return NM_SETTING_WIRED_GET_PRIVATE (setting)->mac_address;
+}
+
+guint32
+nm_setting_wired_get_mtu (NMSettingWired *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), 0);
+
+ return NM_SETTING_WIRED_GET_PRIVATE (setting)->mtu;
+}
+
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
- NMSettingWired *self = NM_SETTING_WIRED (setting);
+ NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
const char *valid_ports[] = { "tp", "aui", "bnc", "mii", NULL };
const char *valid_duplex[] = { "half", "full", NULL };
- if (self->port && !nm_utils_string_in_list (self->port, valid_ports)) {
+ if (priv->port && !nm_utils_string_in_list (priv->port, valid_ports)) {
g_set_error (error,
NM_SETTING_WIRED_ERROR,
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
@@ -98,7 +157,7 @@
return FALSE;
}
- if (self->duplex && !nm_utils_string_in_list (self->duplex, valid_duplex)) {
+ if (priv->duplex && !nm_utils_string_in_list (priv->duplex, valid_duplex)) {
g_set_error (error,
NM_SETTING_WIRED_ERROR,
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
@@ -106,7 +165,7 @@
return FALSE;
}
- if (self->mac_address && self->mac_address->len != ETH_ALEN) {
+ if (priv->mac_address && priv->mac_address->len != ETH_ALEN) {
g_set_error (error,
NM_SETTING_WIRED_ERROR,
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
@@ -126,13 +185,13 @@
static void
finalize (GObject *object)
{
- NMSettingWired *self = NM_SETTING_WIRED (object);
+ NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (object);
- g_free (self->port);
- g_free (self->duplex);
+ g_free (priv->port);
+ g_free (priv->duplex);
- if (self->mac_address)
- g_byte_array_free (self->mac_address, TRUE);
+ if (priv->mac_address)
+ g_byte_array_free (priv->mac_address, TRUE);
G_OBJECT_CLASS (nm_setting_wired_parent_class)->finalize (object);
}
@@ -141,30 +200,30 @@
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
- NMSettingWired *setting = NM_SETTING_WIRED (object);
+ NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (object);
switch (prop_id) {
case PROP_PORT:
- g_free (setting->port);
- setting->port = g_value_dup_string (value);
+ g_free (priv->port);
+ priv->port = g_value_dup_string (value);
break;
case PROP_SPEED:
- setting->speed = g_value_get_uint (value);
+ priv->speed = g_value_get_uint (value);
break;
case PROP_DUPLEX:
- g_free (setting->duplex);
- setting->duplex = g_value_dup_string (value);
+ g_free (priv->duplex);
+ priv->duplex = g_value_dup_string (value);
break;
case PROP_AUTO_NEGOTIATE:
- setting->auto_negotiate = g_value_get_boolean (value);
+ priv->auto_negotiate = g_value_get_boolean (value);
break;
case PROP_MAC_ADDRESS:
- if (setting->mac_address)
- g_byte_array_free (setting->mac_address, TRUE);
- setting->mac_address = g_value_dup_boxed (value);
+ if (priv->mac_address)
+ g_byte_array_free (priv->mac_address, TRUE);
+ priv->mac_address = g_value_dup_boxed (value);
break;
case PROP_MTU:
- setting->mtu = g_value_get_uint (value);
+ priv->mtu = g_value_get_uint (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -180,22 +239,22 @@
switch (prop_id) {
case PROP_PORT:
- g_value_set_string (value, setting->port);
+ g_value_set_string (value, nm_setting_wired_get_port (setting));
break;
case PROP_SPEED:
- g_value_set_uint (value, setting->speed);
+ g_value_set_uint (value, nm_setting_wired_get_speed (setting));
break;
case PROP_DUPLEX:
- g_value_set_string (value, setting->duplex);
+ g_value_set_string (value, nm_setting_wired_get_duplex (setting));
break;
case PROP_AUTO_NEGOTIATE:
- g_value_set_boolean (value, setting->auto_negotiate);
+ g_value_set_boolean (value, nm_setting_wired_get_auto_negotiate (setting));
break;
case PROP_MAC_ADDRESS:
- g_value_set_boxed (value, setting->mac_address);
+ g_value_set_boxed (value, nm_setting_wired_get_mac_address (setting));
break;
case PROP_MTU:
- g_value_set_uint (value, setting->mtu);
+ g_value_set_uint (value, nm_setting_wired_get_mtu (setting));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -209,6 +268,8 @@
GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
+ g_type_class_add_private (setting_class, sizeof (NMSettingWiredPrivate));
+
/* virtual methods */
object_class->set_property = set_property;
object_class->get_property = get_property;
Modified: trunk/libnm-util/nm-setting-wired.h
==============================================================================
--- trunk/libnm-util/nm-setting-wired.h (original)
+++ trunk/libnm-util/nm-setting-wired.h Sun Oct 26 17:02:05 2008
@@ -61,13 +61,6 @@
typedef struct {
NMSetting parent;
-
- char *port;
- guint32 speed;
- char *duplex;
- gboolean auto_negotiate;
- GByteArray *mac_address;
- guint32 mtu;
} NMSettingWired;
typedef struct {
@@ -76,7 +69,13 @@
GType nm_setting_wired_get_type (void);
-NMSetting *nm_setting_wired_new (void);
+NMSetting *nm_setting_wired_new (void);
+const char *nm_setting_wired_get_port (NMSettingWired *setting);
+guint32 nm_setting_wired_get_speed (NMSettingWired *setting);
+const char *nm_setting_wired_get_duplex (NMSettingWired *setting);
+gboolean nm_setting_wired_get_auto_negotiate (NMSettingWired *setting);
+const GByteArray *nm_setting_wired_get_mac_address (NMSettingWired *setting);
+guint32 nm_setting_wired_get_mtu (NMSettingWired *setting);
G_END_DECLS
Modified: trunk/src/nm-device-ethernet.c
==============================================================================
--- trunk/src/nm-device-ethernet.c (original)
+++ trunk/src/nm-device-ethernet.c Sun Oct 26 17:02:05 2008
@@ -570,8 +570,10 @@
continue;
if (s_wired) {
- if ( s_wired->mac_address
- && memcmp (s_wired->mac_address->data, priv->hw_addr.ether_addr_octet, ETH_ALEN))
+ const GByteArray *mac;
+
+ mac = nm_setting_wired_get_mac_address (s_wired);
+ if (mac && memcmp (mac->data, priv->hw_addr.ether_addr_octet, ETH_ALEN))
continue;
}
@@ -1326,6 +1328,7 @@
if (ret == NM_ACT_STAGE_RETURN_SUCCESS) {
NMConnection *connection;
NMSettingWired *s_wired;
+ guint32 mtu;
connection = nm_act_request_get_connection (nm_device_get_act_request (device));
g_assert (connection);
@@ -1333,8 +1336,9 @@
g_assert (s_wired);
/* MTU override */
- if (s_wired->mtu)
- nm_ip4_config_set_mtu (*config, s_wired->mtu);
+ mtu = nm_setting_wired_get_mtu (s_wired);
+ if (mtu)
+ nm_ip4_config_set_mtu (*config, mtu);
}
} else {
/* PPPoE */
@@ -1401,8 +1405,10 @@
}
if (s_wired) {
- if ( s_wired->mac_address
- && memcmp (s_wired->mac_address->data, &(priv->hw_addr.ether_addr_octet), ETH_ALEN)) {
+ const GByteArray *mac;
+
+ mac = nm_setting_wired_get_mac_address (s_wired);
+ if (mac && memcmp (mac->data, &(priv->hw_addr.ether_addr_octet), ETH_ALEN)) {
g_set_error (error,
NM_ETHERNET_ERROR, NM_ETHERNET_ERROR_CONNECTION_INCOMPATIBLE,
"The connection's MAC address did not match this device.");
Modified: trunk/system-settings/plugins/ifcfg-fedora/nm-ifcfg-connection.c
==============================================================================
--- trunk/system-settings/plugins/ifcfg-fedora/nm-ifcfg-connection.c (original)
+++ trunk/system-settings/plugins/ifcfg-fedora/nm-ifcfg-connection.c Sun Oct 26 17:02:05 2008
@@ -79,7 +79,7 @@
static guint signals[LAST_SIGNAL] = { 0 };
static char *
-get_ether_device_udi (DBusGConnection *g_connection, GByteArray *mac, GSList *devices)
+get_ether_device_udi (DBusGConnection *g_connection, const GByteArray *mac, GSList *devices)
{
GError *error = NULL;
GSList *iter;
@@ -168,7 +168,7 @@
s_wired = (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED);
if (s_wired) {
devices = nm_system_config_hal_manager_get_devices_of_type (hal_mgr, NM_DEVICE_TYPE_ETHERNET);
- udi = get_ether_device_udi (g_connection, s_wired->mac_address, devices);
+ udi = get_ether_device_udi (g_connection, nm_setting_wired_get_mac_address (s_wired), devices);
}
break;
Modified: trunk/system-settings/plugins/ifcfg-suse/parser.c
==============================================================================
--- trunk/system-settings/plugins/ifcfg-suse/parser.c (original)
+++ trunk/system-settings/plugins/ifcfg-suse/parser.c Sun Oct 26 17:02:05 2008
@@ -199,7 +199,7 @@
;
else if (get_int (str, &mtu)) {
if (mtu >= 0 && mtu < G_MAXINT)
- s_wired->mtu = mtu;
+ g_object_set (s_wired, NM_SETTING_WIRED_MTU, mtu, NULL);
} else
g_warning ("Ignoring invalid MTU: '%s'", str);
g_free (str);
Modified: trunk/system-settings/src/main.c
==============================================================================
--- trunk/system-settings/src/main.c (original)
+++ trunk/system-settings/src/main.c Sun Oct 26 17:02:05 2008
@@ -281,6 +281,7 @@
GSList *list, *iter;
NMSettingConnection *s_con;
NMSettingWired *s_wired;
+ const GByteArray *setting_mac;
gboolean ret = FALSE;
g_return_val_if_fail (app != NULL, FALSE);
@@ -311,9 +312,10 @@
break;
}
- if (s_wired->mac_address) {
+ setting_mac = nm_setting_wired_get_mac_address (s_wired);
+ if (setting_mac) {
/* A connection mac-locked to this device */
- if (!memcmp (s_wired->mac_address->data, mac->data, ETH_ALEN)) {
+ if (!memcmp (setting_mac->data, mac->data, ETH_ALEN)) {
ret = TRUE;
break;
}
@@ -337,6 +339,7 @@
NMSettingConnection *s_con;
NMSettingWired *s_wired;
NMConnection *wrapped;
+ GByteArray *setting_mac;
if (info->add_id)
info->add_id = 0;
@@ -373,8 +376,12 @@
/* Lock the connection to this device */
s_wired = NM_SETTING_WIRED (nm_setting_wired_new ());
- s_wired->mac_address = g_byte_array_sized_new (ETH_ALEN);
- g_byte_array_append (s_wired->mac_address, info->mac->data, ETH_ALEN);
+
+ setting_mac = g_byte_array_sized_new (ETH_ALEN);
+ g_byte_array_append (setting_mac, info->mac->data, ETH_ALEN);
+ g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, setting_mac, NULL);
+ g_byte_array_free (setting_mac, TRUE);
+
nm_connection_add_setting (wrapped, NM_SETTING (s_wired));
nm_sysconfig_settings_add_connection (info->app->settings, info->connection);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]