NetworkManager r4220 - in trunk: . libnm-util src src/ppp-manager src/vpn-manager system-settings/plugins/ifcfg-fedora system-settings/plugins/ifcfg-suse system-settings/plugins/ifupdown system-settings/plugins/keyfile system-settings/src
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r4220 - in trunk: . libnm-util src src/ppp-manager src/vpn-manager system-settings/plugins/ifcfg-fedora system-settings/plugins/ifcfg-suse system-settings/plugins/ifupdown system-settings/plugins/keyfile system-settings/src
- Date: Sun, 26 Oct 2008 17:41:37 +0000 (UTC)
Author: dcbw
Date: Sun Oct 26 17:41:37 2008
New Revision: 4220
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=4220&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-connection.c
libnm-util/nm-setting-connection.h
- Make properties private and add accessor functions
* src/NetworkManagerPolicy.c
src/nm-cdma-device.c
src/nm-device-ethernet.c
src/nm-device-interface.c
src/nm-device-wifi.c
src/nm-gsm-device.c
src/nm-manager.c
src/ppp-manager/nm-ppp-manager.c
src/vpn-manager/nm-vpn-connection.c
system-settings/plugins/ifcfg-fedora/nm-ifcfg-connection.c
system-settings/plugins/ifcfg-fedora/plugin.c
system-settings/plugins/ifcfg-fedora/reader.c
system-settings/plugins/ifcfg-suse/parser.c
system-settings/plugins/ifupdown/parser.c
system-settings/plugins/keyfile/nm-keyfile-connection.c
system-settings/plugins/keyfile/plugin.c
system-settings/plugins/keyfile/writer.c
system-settings/src/main.c
- Use those accessors
Modified:
trunk/ChangeLog
trunk/libnm-util/libnm-util.ver
trunk/libnm-util/nm-setting-connection.c
trunk/libnm-util/nm-setting-connection.h
trunk/src/NetworkManagerPolicy.c
trunk/src/nm-cdma-device.c
trunk/src/nm-device-ethernet.c
trunk/src/nm-device-interface.c
trunk/src/nm-device-wifi.c
trunk/src/nm-gsm-device.c
trunk/src/nm-manager.c
trunk/src/ppp-manager/nm-ppp-manager.c
trunk/src/vpn-manager/nm-vpn-connection.c
trunk/system-settings/plugins/ifcfg-fedora/nm-ifcfg-connection.c
trunk/system-settings/plugins/ifcfg-fedora/plugin.c
trunk/system-settings/plugins/ifcfg-fedora/reader.c
trunk/system-settings/plugins/ifcfg-suse/parser.c
trunk/system-settings/plugins/ifupdown/parser.c
trunk/system-settings/plugins/keyfile/nm-keyfile-connection.c
trunk/system-settings/plugins/keyfile/plugin.c
trunk/system-settings/plugins/keyfile/writer.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:41:37 2008
@@ -49,6 +49,11 @@
nm_setting_connection_error_quark;
nm_setting_connection_get_type;
nm_setting_connection_new;
+ nm_setting_connection_get_id;
+ nm_setting_connection_get_uuid;
+ nm_setting_connection_get_connection_type;
+ nm_setting_connection_get_autoconnect;
+ nm_setting_connection_get_timestamp;
nm_setting_duplicate;
nm_setting_enumerate_values;
nm_setting_from_hash;
Modified: trunk/libnm-util/nm-setting-connection.c
==============================================================================
--- trunk/libnm-util/nm-setting-connection.c (original)
+++ trunk/libnm-util/nm-setting-connection.c Sun Oct 26 17:41:37 2008
@@ -64,6 +64,16 @@
G_DEFINE_TYPE (NMSettingConnection, nm_setting_connection, NM_TYPE_SETTING)
+#define NM_SETTING_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_CONNECTION, NMSettingConnectionPrivate))
+
+typedef struct {
+ char *id;
+ char *uuid;
+ char *type;
+ gboolean autoconnect;
+ guint64 timestamp;
+} NMSettingConnectionPrivate;
+
enum {
PROP_0,
PROP_ID,
@@ -80,6 +90,46 @@
return (NMSetting *) g_object_new (NM_TYPE_SETTING_CONNECTION, NULL);
}
+const char *
+nm_setting_connection_get_id (NMSettingConnection *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
+
+ return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->id;
+}
+
+const char *
+nm_setting_connection_get_uuid (NMSettingConnection *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
+
+ return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->uuid;
+}
+
+const char *
+nm_setting_connection_get_connection_type (NMSettingConnection *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
+
+ return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->type;
+}
+
+gboolean
+nm_setting_connection_get_autoconnect (NMSettingConnection *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
+
+ return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->autoconnect;
+}
+
+guint64
+nm_setting_connection_get_timestamp (NMSettingConnection *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), 0);
+
+ return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->timestamp;
+}
+
static gint
find_setting_by_name (gconstpointer a, gconstpointer b)
{
@@ -92,15 +142,15 @@
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
- NMSettingConnection *self = NM_SETTING_CONNECTION (setting);
+ NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
- if (!self->id) {
+ if (!priv->id) {
g_set_error (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY,
NM_SETTING_CONNECTION_ID);
return FALSE;
- } else if (!strlen (self->id)) {
+ } else if (!strlen (priv->id)) {
g_set_error (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
@@ -108,13 +158,13 @@
return FALSE;
}
- if (!self->uuid) {
+ if (!priv->uuid) {
g_set_error (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY,
NM_SETTING_CONNECTION_UUID);
return FALSE;
- } else if (!strlen (self->uuid)) {
+ } else if (!strlen (priv->uuid)) {
g_set_error (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
@@ -122,13 +172,13 @@
return FALSE;
}
- if (!self->type) {
+ if (!priv->type) {
g_set_error (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY,
NM_SETTING_CONNECTION_TYPE);
return FALSE;
- } else if (!strlen (self->type)) {
+ } else if (!strlen (priv->type)) {
g_set_error (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
@@ -137,7 +187,7 @@
}
/* Make sure the corresponding 'type' item is present */
- if (all_settings && !g_slist_find_custom (all_settings, self->type, find_setting_by_name)) {
+ if (all_settings && !g_slist_find_custom (all_settings, priv->type, find_setting_by_name)) {
g_set_error (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND,
@@ -157,11 +207,11 @@
static void
finalize (GObject *object)
{
- NMSettingConnection *self = NM_SETTING_CONNECTION (object);
+ NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE (object);
- g_free (self->id);
- g_free (self->uuid);
- g_free (self->type);
+ g_free (priv->id);
+ g_free (priv->uuid);
+ g_free (priv->type);
G_OBJECT_CLASS (nm_setting_connection_parent_class)->finalize (object);
}
@@ -170,26 +220,26 @@
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
- NMSettingConnection *setting = NM_SETTING_CONNECTION (object);
+ NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE (object);
switch (prop_id) {
case PROP_ID:
- g_free (setting->id);
- setting->id = g_value_dup_string (value);
+ g_free (priv->id);
+ priv->id = g_value_dup_string (value);
break;
case PROP_UUID:
- g_free (setting->uuid);
- setting->uuid = g_value_dup_string (value);
+ g_free (priv->uuid);
+ priv->uuid = g_value_dup_string (value);
break;
case PROP_TYPE:
- g_free (setting->type);
- setting->type = g_value_dup_string (value);
+ g_free (priv->type);
+ priv->type = g_value_dup_string (value);
break;
case PROP_AUTOCONNECT:
- setting->autoconnect = g_value_get_boolean (value);
+ priv->autoconnect = g_value_get_boolean (value);
break;
case PROP_TIMESTAMP:
- setting->timestamp = g_value_get_uint64 (value);
+ priv->timestamp = g_value_get_uint64 (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -205,19 +255,19 @@
switch (prop_id) {
case PROP_ID:
- g_value_set_string (value, setting->id);
+ g_value_set_string (value, nm_setting_connection_get_id (setting));
break;
case PROP_UUID:
- g_value_set_string (value, setting->uuid);
+ g_value_set_string (value, nm_setting_connection_get_uuid (setting));
break;
case PROP_TYPE:
- g_value_set_string (value, setting->type);
+ g_value_set_string (value, nm_setting_connection_get_connection_type (setting));
break;
case PROP_AUTOCONNECT:
- g_value_set_boolean (value, setting->autoconnect);
+ g_value_set_boolean (value, nm_setting_connection_get_autoconnect (setting));
break;
case PROP_TIMESTAMP:
- g_value_set_uint64 (value, setting->timestamp);
+ g_value_set_uint64 (value, nm_setting_connection_get_timestamp (setting));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -231,6 +281,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 (NMSettingConnectionPrivate));
+
/* virtual methods */
object_class->set_property = set_property;
object_class->get_property = get_property;
Modified: trunk/libnm-util/nm-setting-connection.h
==============================================================================
--- trunk/libnm-util/nm-setting-connection.h (original)
+++ trunk/libnm-util/nm-setting-connection.h Sun Oct 26 17:41:37 2008
@@ -61,12 +61,6 @@
typedef struct {
NMSetting parent;
-
- char *id;
- char *uuid;
- char *type;
- gboolean autoconnect;
- guint64 timestamp;
} NMSettingConnection;
typedef struct {
@@ -75,7 +69,12 @@
GType nm_setting_connection_get_type (void);
-NMSetting *nm_setting_connection_new (void);
+NMSetting *nm_setting_connection_new (void);
+const char *nm_setting_connection_get_id (NMSettingConnection *setting);
+const char *nm_setting_connection_get_uuid (NMSettingConnection *setting);
+const char *nm_setting_connection_get_connection_type (NMSettingConnection *setting);
+gboolean nm_setting_connection_get_autoconnect (NMSettingConnection *setting);
+guint64 nm_setting_connection_get_timestamp (NMSettingConnection *setting);
G_END_DECLS
Modified: trunk/src/NetworkManagerPolicy.c
==============================================================================
--- trunk/src/NetworkManagerPolicy.c (original)
+++ trunk/src/NetworkManagerPolicy.c Sun Oct 26 17:41:37 2008
@@ -177,7 +177,7 @@
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
g_return_val_if_fail (s_con != NULL, NULL);
- return s_con->id;
+ return nm_setting_connection_get_id (s_con);
}
static NMDevice *
@@ -485,6 +485,7 @@
NMVPNConnection *vpn = NULL;
NMConnection *connection = NULL;
NMSettingConnection *s_con = NULL;
+ const char *connection_id;
best = get_best_device (policy->manager, &best_req);
if (!best)
@@ -593,8 +594,9 @@
if (connection)
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
- if (s_con && s_con->id)
- nm_info ("Policy set '%s' (%s) as default for routing and DNS.", s_con->id, ip_iface);
+ connection_id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
+ if (connection_id)
+ nm_info ("Policy set '%s' (%s) as default for routing and DNS.", connection_id, ip_iface);
else
nm_info ("Policy set (%s) as default for routing and DNS.", ip_iface);
@@ -666,7 +668,7 @@
g_assert (s_con);
nm_warning ("Connection '%s' auto-activation failed: (%d) %s",
- s_con->id, error->code, error->message);
+ nm_setting_connection_get_id (s_con), error->code, error->message);
g_error_free (error);
}
}
@@ -945,7 +947,7 @@
if (!nm_manager_deactivate_connection (manager, path, NM_DEVICE_STATE_REASON_CONNECTION_REMOVED, &error)) {
nm_warning ("Connection '%s' disappeared, but error deactivating it: (%d) %s",
- s_con->id, error->code, error->message);
+ nm_setting_connection_get_id (s_con), error->code, error->message);
g_error_free (error);
}
g_free (path);
Modified: trunk/src/nm-cdma-device.c
==============================================================================
--- trunk/src/nm-cdma-device.c (original)
+++ trunk/src/nm-cdma-device.c Sun Oct 26 17:41:37 2008
@@ -237,10 +237,10 @@
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
g_assert (s_con);
- if (!s_con->autoconnect)
+ if (!nm_setting_connection_get_autoconnect (s_con))
continue;
- if (strcmp (s_con->type, NM_SETTING_CDMA_SETTING_NAME))
+ if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_CDMA_SETTING_NAME))
continue;
return connection;
Modified: trunk/src/nm-device-ethernet.c
==============================================================================
--- trunk/src/nm-device-ethernet.c (original)
+++ trunk/src/nm-device-ethernet.c Sun Oct 26 17:41:37 2008
@@ -551,17 +551,19 @@
NMConnection *connection = NM_CONNECTION (iter->data);
NMSettingConnection *s_con;
NMSettingWired *s_wired;
+ const char *connection_type;
gboolean is_pppoe = FALSE;
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
g_assert (s_con);
- if (!strcmp (s_con->type, NM_SETTING_PPPOE_SETTING_NAME))
+ connection_type = nm_setting_connection_get_connection_type (s_con);
+ if (!strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME))
is_pppoe = TRUE;
- if (!is_pppoe && strcmp (s_con->type, NM_SETTING_WIRED_SETTING_NAME))
+ if (!is_pppoe && strcmp (connection_type, NM_SETTING_WIRED_SETTING_NAME))
continue;
- if (!s_con->autoconnect)
+ if (!nm_setting_connection_get_autoconnect (s_con))
continue;
s_wired = (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED);
@@ -1181,14 +1183,14 @@
NMActRequest *req = nm_device_get_act_request (NM_DEVICE (self));
nm_info ("Activation (%s/wired): connection '%s' has security, but secrets are required.",
- iface, s_connection->id);
+ iface, nm_setting_connection_get_id (s_connection));
ret = handle_auth_or_fail (self, req, FALSE);
if (ret != NM_ACT_STAGE_RETURN_POSTPONE)
*reason = NM_DEVICE_STATE_REASON_NO_SECRETS;
} else {
nm_info ("Activation (%s/wired): connection '%s' requires no security. No secrets needed.",
- iface, s_connection->id);
+ iface, nm_setting_connection_get_id (s_connection));
if (supplicant_interface_init (self))
ret = NM_ACT_STAGE_RETURN_POSTPONE;
@@ -1284,6 +1286,7 @@
real_act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
{
NMSettingConnection *s_connection;
+ const char *connection_type;
NMActStageReturn ret;
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
@@ -1291,7 +1294,8 @@
s_connection = NM_SETTING_CONNECTION (device_get_setting (device, NM_TYPE_SETTING_CONNECTION));
g_assert (s_connection);
- if (!strcmp (s_connection->type, NM_SETTING_WIRED_SETTING_NAME)) {
+ connection_type = nm_setting_connection_get_connection_type (s_connection);
+ if (!strcmp (connection_type, NM_SETTING_WIRED_SETTING_NAME)) {
NMSetting8021x *security;
security = (NMSetting8021x *) device_get_setting (device, NM_TYPE_SETTING_802_1X);
@@ -1299,10 +1303,10 @@
ret = nm_8021x_stage2_config (NM_DEVICE_ETHERNET (device), reason);
else
ret = NM_ACT_STAGE_RETURN_SUCCESS;
- } else if (!strcmp (s_connection->type, NM_SETTING_PPPOE_SETTING_NAME))
+ } else if (!strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME))
ret = pppoe_stage2_config (NM_DEVICE_ETHERNET (device), reason);
else {
- nm_warning ("Invalid connection type '%s' for ethernet device", s_connection->type);
+ nm_warning ("Invalid connection type '%s' for ethernet device", connection_type);
*reason = NM_DEVICE_STATE_REASON_CONFIG_FAILED;
ret = NM_ACT_STAGE_RETURN_FAILURE;
}
@@ -1382,20 +1386,22 @@
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
NMSettingConnection *s_con;
NMSettingWired *s_wired;
+ const char *connection_type;
gboolean is_pppoe = FALSE;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- if ( strcmp (s_con->type, NM_SETTING_WIRED_SETTING_NAME)
- && strcmp (s_con->type, NM_SETTING_PPPOE_SETTING_NAME)) {
+ connection_type = nm_setting_connection_get_connection_type (s_con);
+ if ( strcmp (connection_type, NM_SETTING_WIRED_SETTING_NAME)
+ && strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME)) {
g_set_error (error,
NM_ETHERNET_ERROR, NM_ETHERNET_ERROR_CONNECTION_NOT_WIRED,
"The connection was not a wired or PPPoE connection.");
return FALSE;
}
- if (!strcmp (s_con->type, NM_SETTING_PPPOE_SETTING_NAME))
+ if (!strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME))
is_pppoe = TRUE;
s_wired = (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED);
Modified: trunk/src/nm-device-interface.c
==============================================================================
--- trunk/src/nm-device-interface.c (original)
+++ trunk/src/nm-device-interface.c Sun Oct 26 17:41:37 2008
@@ -223,7 +223,8 @@
g_assert (s_con);
iface = nm_device_interface_get_iface (device);
- nm_info ("Activation (%s) starting connection '%s'", iface, s_con->id);
+ nm_info ("Activation (%s) starting connection '%s'", iface,
+ nm_setting_connection_get_id (s_con));
g_free (iface);
success = NM_DEVICE_INTERFACE_GET_INTERFACE (device)->activate (device, req, error);
Modified: trunk/src/nm-device-wifi.c
==============================================================================
--- trunk/src/nm-device-wifi.c (original)
+++ trunk/src/nm-device-wifi.c Sun Oct 26 17:41:37 2008
@@ -990,7 +990,7 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- if (strcmp (s_con->type, NM_SETTING_WIRELESS_SETTING_NAME)) {
+ if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_WIRELESS_SETTING_NAME)) {
g_set_error (error,
NM_WIFI_ERROR, NM_WIFI_ERROR_CONNECTION_NOT_WIRELESS,
"The connection was not a WiFi connection.");
@@ -1060,9 +1060,9 @@
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
if (s_con == NULL)
continue;
- if (strcmp (s_con->type, NM_SETTING_WIRELESS_SETTING_NAME))
+ if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_WIRELESS_SETTING_NAME))
continue;
- if (!s_con->autoconnect)
+ if (!nm_setting_connection_get_autoconnect (s_con))
continue;
s_wireless = (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
@@ -2869,7 +2869,7 @@
if (setting_name) {
nm_info ("Activation (%s/wireless): access point '%s' has security,"
" but secrets are required.",
- iface, s_connection->id);
+ iface, nm_setting_connection_get_id (s_connection));
ret = handle_auth_or_fail (self, req, FALSE);
if (ret == NM_ACT_STAGE_RETURN_FAILURE)
@@ -2881,11 +2881,11 @@
if (s_wireless->security) {
nm_info ("Activation (%s/wireless): connection '%s' has security"
", and secrets exist. No new secrets needed.",
- iface, s_connection->id);
+ iface, nm_setting_connection_get_id (s_connection));
} else {
nm_info ("Activation (%s/wireless): connection '%s' requires no "
"security. No secrets needed.",
- iface, s_connection->id);
+ iface, nm_setting_connection_get_id (s_connection));
}
config = build_supplicant_config (self, connection, ap);
@@ -2997,7 +2997,7 @@
/* Activation failed, we must have bad encryption key */
nm_info ("Activation (%s/wireless): could not get IP configuration for "
"connection '%s'.",
- nm_device_get_iface (dev), s_con->id);
+ nm_device_get_iface (dev), nm_setting_connection_get_id (s_con));
ret = handle_auth_or_fail (self, req, TRUE);
if (ret == NM_ACT_STAGE_RETURN_POSTPONE) {
Modified: trunk/src/nm-gsm-device.c
==============================================================================
--- trunk/src/nm-gsm-device.c (original)
+++ trunk/src/nm-gsm-device.c Sun Oct 26 17:41:37 2008
@@ -684,10 +684,10 @@
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
g_assert (s_con);
- if (!s_con->autoconnect)
+ if (!nm_setting_connection_get_autoconnect (s_con))
continue;
- if (strcmp (s_con->type, NM_SETTING_GSM_SETTING_NAME))
+ if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_GSM_SETTING_NAME))
continue;
return connection;
Modified: trunk/src/nm-manager.c
==============================================================================
--- trunk/src/nm-manager.c (original)
+++ trunk/src/nm-manager.c Sun Oct 26 17:41:37 2008
@@ -1846,7 +1846,7 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- if (!strcmp (s_con->type, NM_SETTING_VPN_SETTING_NAME)) {
+ if (!strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_VPN_SETTING_NAME)) {
NMActRequest *req;
NMVPNManager *vpn_manager;
@@ -2163,15 +2163,15 @@
con_b = (NMSettingConnection *) nm_connection_get_setting (b, NM_TYPE_SETTING_CONNECTION);
g_assert (con_b);
- if (con_a->autoconnect != con_b->autoconnect) {
- if (con_a->autoconnect)
+ if (nm_setting_connection_get_autoconnect (con_a) != nm_setting_connection_get_autoconnect (con_b)) {
+ if (nm_setting_connection_get_autoconnect (con_a))
return -1;
return 1;
}
- if (con_a->timestamp > con_b->timestamp)
+ if (nm_setting_connection_get_timestamp (con_a) > nm_setting_connection_get_timestamp (con_b))
return -1;
- else if (con_a->timestamp == con_b->timestamp)
+ else if (nm_setting_connection_get_timestamp (con_a) == nm_setting_connection_get_timestamp (con_b))
return 0;
return 1;
}
Modified: trunk/src/ppp-manager/nm-ppp-manager.c
==============================================================================
--- trunk/src/ppp-manager/nm-ppp-manager.c (original)
+++ trunk/src/ppp-manager/nm-ppp-manager.c Sun Oct 26 17:41:37 2008
@@ -347,6 +347,7 @@
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
NMConnection *connection;
NMSettingConnection *s_con;
+ const char *connection_type;
const char *setting_name;
guint32 tries;
GPtrArray *hints = NULL;
@@ -356,14 +357,16 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- g_assert (s_con->type);
+
+ connection_type = nm_setting_connection_get_connection_type (s_con);
+ g_assert (connection_type);
nm_connection_clear_secrets (connection);
setting_name = nm_connection_need_secrets (connection, &hints);
if (!setting_name) {
NMSetting *setting;
- setting = nm_connection_get_setting_by_name (connection, s_con->type);
+ setting = nm_connection_get_setting_by_name (connection, connection_type);
if (setting) {
const char *username = NULL;
const char *password = NULL;
Modified: trunk/src/vpn-manager/nm-vpn-connection.c
==============================================================================
--- trunk/src/vpn-manager/nm-vpn-connection.c (original)
+++ trunk/src/vpn-manager/nm-vpn-connection.c Sun Oct 26 17:41:37 2008
@@ -631,7 +631,7 @@
priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
setting = (NMSettingConnection *) nm_connection_get_setting (priv->connection, NM_TYPE_SETTING_CONNECTION);
- return setting->id;
+ return nm_setting_connection_get_id (setting);
}
NMConnection *
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:41:37 2008
@@ -126,22 +126,25 @@
{
NMDeviceType devtype = NM_DEVICE_TYPE_UNKNOWN;
NMSettingConnection *s_con;
+ const char *ctype;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
if (!s_con)
return NM_DEVICE_TYPE_UNKNOWN;
- if ( !strcmp (s_con->type, NM_SETTING_WIRED_SETTING_NAME)
- || !strcmp (s_con->type, NM_SETTING_PPPOE_SETTING_NAME)) {
+ ctype = nm_setting_connection_get_connection_type (s_con);
+
+ if ( !strcmp (ctype, NM_SETTING_WIRED_SETTING_NAME)
+ || !strcmp (ctype, NM_SETTING_PPPOE_SETTING_NAME)) {
if (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED))
devtype = NM_DEVICE_TYPE_ETHERNET;
- } else if (!strcmp (s_con->type, NM_SETTING_WIRELESS_SETTING_NAME)) {
+ } else if (!strcmp (ctype, NM_SETTING_WIRELESS_SETTING_NAME)) {
if (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS))
devtype = NM_DEVICE_TYPE_WIFI;
- } else if (!strcmp (s_con->type, NM_SETTING_GSM_SETTING_NAME)) {
+ } else if (!strcmp (ctype, NM_SETTING_GSM_SETTING_NAME)) {
if (nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM))
devtype = NM_DEVICE_TYPE_GSM;
- } else if (!strcmp (s_con->type, NM_SETTING_CDMA_SETTING_NAME)) {
+ } else if (!strcmp (ctype, NM_SETTING_CDMA_SETTING_NAME)) {
if (nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA))
devtype = NM_DEVICE_TYPE_CDMA;
}
Modified: trunk/system-settings/plugins/ifcfg-fedora/plugin.c
==============================================================================
--- trunk/system-settings/plugins/ifcfg-fedora/plugin.c (original)
+++ trunk/system-settings/plugins/ifcfg-fedora/plugin.c Sun Oct 26 17:41:37 2008
@@ -166,21 +166,24 @@
if (connection) {
NMConnection *wrapped;
NMSettingConnection *s_con;
+ const char *cid;
wrapped = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (connection));
g_assert (wrapped);
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (wrapped, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- g_assert (s_con->id);
+
+ cid = nm_setting_connection_get_id (s_con);
+ g_assert (cid);
g_hash_table_insert (priv->connections,
(gpointer) nm_ifcfg_connection_get_filename (connection),
g_object_ref (connection));
- PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " read connection '%s'", s_con->id);
+ PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " read connection '%s'", cid);
if (nm_ifcfg_connection_get_unmanaged (connection)) {
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "Ignoring connection '%s' and its "
- "device because NM_CONTROLLED was false.", s_con->id);
+ "device because NM_CONTROLLED was false.", cid);
g_signal_emit_by_name (plugin, "unmanaged-devices-changed");
} else {
/* Wait for the connection to become unmanaged once it knows the
@@ -321,13 +324,16 @@
if (old_unmanaged) { /* no longer unmanaged */
NMSettingConnection *s_con;
+ const char *cid;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (new_wrapped, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- g_assert (s_con->id);
+
+ cid = nm_setting_connection_get_id (s_con);
+ g_assert (cid);
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "Managing connection '%s' and its "
- "device because NM_CONTROLLED was true.", s_con->id);
+ "device because NM_CONTROLLED was true.", cid);
g_signal_emit_by_name (plugin, "connection-added", connection);
}
Modified: trunk/system-settings/plugins/ifcfg-fedora/reader.c
==============================================================================
--- trunk/system-settings/plugins/ifcfg-fedora/reader.c (original)
+++ trunk/system-settings/plugins/ifcfg-fedora/reader.c Sun Oct 26 17:41:37 2008
@@ -91,6 +91,7 @@
{
NMSettingConnection *s_con;
char *ifcfg_name = NULL;
+ char *new_id = NULL, *uuid = NULL;
ifcfg_name = get_ifcfg_name (file);
if (!ifcfg_name)
@@ -102,23 +103,32 @@
/* For cosmetic reasons, if the suggested name is the same as
* the ifcfg files name, don't use it.
*/
- if (strcmp (ifcfg_name, suggested))
- s_con->id = g_strdup_printf ("System %s (%s)", suggested, ifcfg_name);
+ if (strcmp (ifcfg_name, suggested)) {
+ new_id = g_strdup_printf ("System %s (%s)", suggested, ifcfg_name);
+ g_object_set (s_con, NM_SETTING_CONNECTION_ID, new_id, NULL);
+ }
}
- if (!s_con->id)
- s_con->id = g_strdup_printf ("System %s", ifcfg_name);
+ if (!nm_setting_connection_get_id (s_con)) {
+ new_id = g_strdup_printf ("System %s", ifcfg_name);
+ g_object_set (s_con, NM_SETTING_CONNECTION_ID, new_id, NULL);
+ }
- s_con->type = g_strdup (type);
+ g_free (new_id);
- s_con->uuid = nm_utils_uuid_generate_from_string (ifcfg->fileName);
+ uuid = nm_utils_uuid_generate_from_string (ifcfg->fileName);
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_TYPE, type,
+ NM_SETTING_CONNECTION_UUID, uuid,
+ NULL);
+ g_free (uuid);
/* Be somewhat conservative about autoconnect */
if (svTrueValue (ifcfg, "ONBOOT", FALSE))
- s_con->autoconnect = TRUE;
+ g_object_set (s_con, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NULL);
g_free (ifcfg_name);
- return (NMSetting *) s_con;
+ return NM_SETTING (s_con);
}
static void
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:41:37 2008
@@ -69,7 +69,7 @@
const char *suggested)
{
NMSettingConnection *s_con;
- char *str;
+ char *str = NULL;
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
if (suggested) {
@@ -77,21 +77,28 @@
* the ifcfg files name, don't use it.
*/
if (strcmp (iface, suggested))
- s_con->id = g_strdup_printf ("System %s (%s)", suggested, iface);
+ str = g_strdup_printf ("System %s (%s)", suggested, iface);
}
- if (!s_con->id)
- s_con->id = g_strdup_printf ("System %s", iface);
+ if (!str)
+ str = g_strdup_printf ("System %s", iface);
+
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_ID, str,
+ NM_SETTING_CONNECTION_TYPE, type,
+ NULL);
- s_con->type = g_strdup (type);
+ g_free (str);
- s_con->uuid = nm_utils_uuid_generate_from_string (file->fileName);
+ str = nm_utils_uuid_generate_from_string (file->fileName);
+ g_object_set (s_con, NM_SETTING_CONNECTION_UUID, str, NULL);
+ g_free (str);
str = svGetValue (file, "STARTMODE");
if (str && !g_ascii_strcasecmp (str, "manual"))
- s_con->autoconnect = FALSE;
+ g_object_set (s_con, NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, NULL);
else
- s_con->autoconnect = TRUE;
+ g_object_set (s_con, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NULL);
g_free (str);
return (NMSetting *) s_con;
Modified: trunk/system-settings/plugins/ifupdown/parser.c
==============================================================================
--- trunk/system-settings/plugins/ifupdown/parser.c (original)
+++ trunk/system-settings/plugins/ifupdown/parser.c Sun Oct 26 17:41:37 2008
@@ -536,7 +536,8 @@
const char *type = NULL;
char *idstr = NULL;
char *uuid_base = NULL;
- GError *verify_error =NULL;
+ GError *verify_error = NULL;
+ char *uuid = NULL;
NMSettingConnection *connection_setting =
NM_SETTING_CONNECTION(nm_connection_get_setting
@@ -551,18 +552,19 @@
idstr = g_strconcat("Ifupdown (", block->name,")", NULL);
uuid_base = idstr;
+ uuid = nm_utils_uuid_generate_from_string(uuid_base);
g_object_set (connection_setting,
- "type", type,
- "id", idstr,
- NULL);
- connection_setting->uuid =
- nm_utils_uuid_generate_from_string(uuid_base);
+ NM_SETTING_CONNECTION_TYPE, type,
+ NM_SETTING_CONNECTION_ID, idstr,
+ NM_SETTING_CONNECTION_UUID, uuid,
+ NULL);
+ g_free (uuid);
PLUGIN_PRINT("SCPlugin-Ifupdown", "update_connection_setting_from_if_block: name:%s, type:%s, autoconnect:%d, id:%s, uuid: %s",
block->name, type,
((gboolean) strcmp("dhcp", type) == 0),
idstr,
- connection_setting->uuid);
+ nm_setting_connection_get_uuid (connection_setting));
if(!strcmp (NM_SETTING_WIRED_SETTING_NAME, type)) {
update_wired_setting_from_if_block (connection, block);
Modified: trunk/system-settings/plugins/keyfile/nm-keyfile-connection.c
==============================================================================
--- trunk/system-settings/plugins/keyfile/nm-keyfile-connection.c (original)
+++ trunk/system-settings/plugins/keyfile/nm-keyfile-connection.c Sun Oct 26 17:41:37 2008
@@ -257,13 +257,17 @@
/* if for some reason the connection didn't have a UUID, add one */
s_con = (NMSettingConnection *) nm_connection_get_setting (wrapped, NM_TYPE_SETTING_CONNECTION);
- if (s_con && !s_con->uuid) {
+ if (s_con && !nm_setting_connection_get_uuid (s_con)) {
GError *error = NULL;
+ char *uuid;
+
+ uuid = nm_utils_uuid_generate ();
+ g_object_set (s_con, NM_SETTING_CONNECTION_UUID, uuid, NULL);
+ g_free (uuid);
- s_con->uuid = nm_utils_uuid_generate ();
if (!write_connection (wrapped, NULL, &error)) {
g_warning ("Couldn't update connection %s with a UUID: (%d) %s",
- s_con->id, error ? error->code : 0,
+ nm_setting_connection_get_id (s_con), error ? error->code : 0,
error ? error->message : "unknown");
g_error_free (error);
}
Modified: trunk/system-settings/plugins/keyfile/plugin.c
==============================================================================
--- trunk/system-settings/plugins/keyfile/plugin.c (original)
+++ trunk/system-settings/plugins/keyfile/plugin.c Sun Oct 26 17:41:37 2008
@@ -95,16 +95,17 @@
FindByUUIDInfo *info = user_data;
NMConnection *connection;
NMSettingConnection *s_con;
+ const char *uuid;
if (info->found)
return;
connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (keyfile));
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
- if (s_con && s_con->uuid) {
- if (!strcmp (info->uuid, s_con->uuid))
- info->found = keyfile;
- }
+
+ uuid = s_con ? nm_setting_connection_get_uuid (s_con) : NULL;
+ if (uuid && !strcmp (info->uuid, uuid))
+ info->found = keyfile;
}
static void
@@ -165,6 +166,7 @@
if (connection) {
NMConnection *tmp;
NMSettingConnection *s_con;
+ const char *connection_uuid;
NMKeyfileConnection *found = NULL;
/* Connection renames will show up as different files but with
@@ -172,8 +174,10 @@
*/
tmp = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (connection));
s_con = (NMSettingConnection *) nm_connection_get_setting (tmp, NM_TYPE_SETTING_CONNECTION);
- if (s_con && s_con->uuid) {
- FindByUUIDInfo info = { .found = NULL, .uuid = s_con->uuid };
+ connection_uuid = s_con ? nm_setting_connection_get_uuid (s_con) : NULL;
+
+ if (connection_uuid) {
+ FindByUUIDInfo info = { .found = NULL, .uuid = connection_uuid };
g_hash_table_foreach (priv->hash, find_by_uuid, &info);
found = info.found;
Modified: trunk/system-settings/plugins/keyfile/writer.c
==============================================================================
--- trunk/system-settings/plugins/keyfile/writer.c (original)
+++ trunk/system-settings/plugins/keyfile/writer.c Sun Oct 26 17:41:37 2008
@@ -310,7 +310,7 @@
if (!data)
goto out;
- filename = writer_id_to_filename (s_con->id);
+ filename = writer_id_to_filename (nm_setting_connection_get_id (s_con));
path = g_build_filename (KEYFILE_DIR, filename, NULL);
g_free (filename);
Modified: trunk/system-settings/src/main.c
==============================================================================
--- trunk/system-settings/src/main.c (original)
+++ trunk/system-settings/src/main.c Sun Oct 26 17:41:37 2008
@@ -294,20 +294,23 @@
for (iter = list; iter; iter = g_slist_next (iter)) {
NMExportedConnection *exported = NM_EXPORTED_CONNECTION (iter->data);
NMConnection *connection;
+ const char *connection_type;
connection = nm_exported_connection_get_connection (exported);
if (!connection)
continue;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- if ( strcmp (s_con->type, NM_SETTING_WIRED_SETTING_NAME)
- && strcmp (s_con->type, NM_SETTING_PPPOE_SETTING_NAME))
+ connection_type = nm_setting_connection_get_connection_type (s_con);
+
+ if ( strcmp (connection_type, NM_SETTING_WIRED_SETTING_NAME)
+ && strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME))
continue;
s_wired = (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED);
/* No wired setting; therefore the PPPoE connection applies to any device */
- if (!s_wired && !strcmp (s_con->type, NM_SETTING_PPPOE_SETTING_NAME)) {
+ if (!s_wired && !strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME)) {
ret = TRUE;
break;
}
@@ -340,6 +343,8 @@
NMSettingWired *s_wired;
NMConnection *wrapped;
GByteArray *setting_mac;
+ char *id;
+ char *uuid;
if (info->add_id)
info->add_id = 0;
@@ -366,13 +371,23 @@
g_object_unref (wrapped);
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
- s_con->id = g_strdup_printf (_("Auto %s"), info->iface);
- s_con->type = g_strdup (NM_SETTING_WIRED_SETTING_NAME);
- s_con->autoconnect = TRUE;
- s_con->uuid = nm_utils_uuid_generate ();
+
+ id = g_strdup_printf (_("Auto %s"), info->iface);
+ uuid = nm_utils_uuid_generate ();
+
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_ID, id,
+ NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
+ NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
+ NM_SETTING_CONNECTION_UUID, uuid,
+ NULL);
+
nm_connection_add_setting (wrapped, NM_SETTING (s_con));
- g_message ("Adding default connection '%s' for %s", s_con->id, info->udi);
+ g_message ("Adding default connection '%s' for %s", id, info->udi);
+
+ g_free (id);
+ g_free (uuid);
/* Lock the connection to this device */
s_wired = NM_SETTING_WIRED (nm_setting_wired_new ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]