NetworkManager r4228 - in trunk: . libnm-util system-settings/plugins/keyfile



Author: dcbw
Date: Mon Oct 27 17:36:18 2008
New Revision: 4228
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=4228&view=rev

Log:
2008-10-27  Dan Williams  <dcbw redhat com>

	Patch from Tambet Ingo <tambet gmail com>

	* libnm-util/nm-setting.h
	  libnm-util/nm-setting.c
		- Make properties private and add accessor functions

	* libnm-util/nm-connection.c
	  libnm-util/nm-setting-8021x.c
	  libnm-util/nm-setting-cdma.c
	  libnm-util/nm-setting-connection.c
	  libnm-util/nm-setting-gsm.c
	  libnm-util/nm-setting-ip4-config.c
	  libnm-util/nm-setting-ip6-config.c
	  libnm-util/nm-setting-ppp.c
	  libnm-util/nm-setting-pppoe.c
	  libnm-util/nm-setting-serial.c
	  libnm-util/nm-setting-template.c
	  libnm-util/nm-setting-vpn.c
	  libnm-util/nm-setting-wired.c
	  libnm-util/nm-setting-wireless-security.c
	  libnm-util/nm-setting-wireless.c
	  system-settings/plugins/keyfile/reader.c
	  system-settings/plugins/keyfile/writer.c
		- Use setting accessors



Modified:
   trunk/ChangeLog
   trunk/libnm-util/nm-connection.c
   trunk/libnm-util/nm-setting-8021x.c
   trunk/libnm-util/nm-setting-cdma.c
   trunk/libnm-util/nm-setting-connection.c
   trunk/libnm-util/nm-setting-gsm.c
   trunk/libnm-util/nm-setting-ip4-config.c
   trunk/libnm-util/nm-setting-ip6-config.c
   trunk/libnm-util/nm-setting-ppp.c
   trunk/libnm-util/nm-setting-pppoe.c
   trunk/libnm-util/nm-setting-serial.c
   trunk/libnm-util/nm-setting-template.c
   trunk/libnm-util/nm-setting-vpn.c
   trunk/libnm-util/nm-setting-wired.c
   trunk/libnm-util/nm-setting-wireless-security.c
   trunk/libnm-util/nm-setting-wireless.c
   trunk/libnm-util/nm-setting.c
   trunk/libnm-util/nm-setting.h
   trunk/system-settings/plugins/keyfile/reader.c
   trunk/system-settings/plugins/keyfile/writer.c

Modified: trunk/libnm-util/nm-connection.c
==============================================================================
--- trunk/libnm-util/nm-connection.c	(original)
+++ trunk/libnm-util/nm-connection.c	Mon Oct 27 17:36:18 2008
@@ -605,8 +605,8 @@
 	setting_hash = nm_setting_to_hash (setting);
 	if (setting_hash)
 		g_hash_table_insert (connection_hash,
-						 g_strdup (setting->name),
-						 setting_hash);
+							 g_strdup (nm_setting_get_name (setting)),
+							 setting_hash);
 }
 
 GHashTable *

Modified: trunk/libnm-util/nm-setting-8021x.c
==============================================================================
--- trunk/libnm-util/nm-setting-8021x.c	(original)
+++ trunk/libnm-util/nm-setting-8021x.c	Mon Oct 27 17:36:18 2008
@@ -559,7 +559,7 @@
 static void
 nm_setting_802_1x_init (NMSetting8021x *setting)
 {
-	((NMSetting *) setting)->name = g_strdup (NM_SETTING_802_1X_SETTING_NAME);
+	g_object_set (setting, NM_SETTING_NAME, NM_SETTING_802_1X_SETTING_NAME, NULL);
 }
 
 static void

Modified: trunk/libnm-util/nm-setting-cdma.c
==============================================================================
--- trunk/libnm-util/nm-setting-cdma.c	(original)
+++ trunk/libnm-util/nm-setting-cdma.c	Mon Oct 27 17:36:18 2008
@@ -188,7 +188,7 @@
 static void
 nm_setting_cdma_init (NMSettingCdma *setting)
 {
-	((NMSetting *) setting)->name = g_strdup (NM_SETTING_CDMA_SETTING_NAME);
+	g_object_set (setting, NM_SETTING_NAME, NM_SETTING_CDMA_SETTING_NAME, NULL);
 }
 
 static void

Modified: trunk/libnm-util/nm-setting-connection.c
==============================================================================
--- trunk/libnm-util/nm-setting-connection.c	(original)
+++ trunk/libnm-util/nm-setting-connection.c	Mon Oct 27 17:36:18 2008
@@ -211,7 +211,7 @@
 static void
 nm_setting_connection_init (NMSettingConnection *setting)
 {
-	((NMSetting *) setting)->name = g_strdup (NM_SETTING_CONNECTION_SETTING_NAME);
+	g_object_set (setting, NM_SETTING_NAME, NM_SETTING_CONNECTION_SETTING_NAME, NULL);
 }
 
 static void

Modified: trunk/libnm-util/nm-setting-gsm.c
==============================================================================
--- trunk/libnm-util/nm-setting-gsm.c	(original)
+++ trunk/libnm-util/nm-setting-gsm.c	Mon Oct 27 17:36:18 2008
@@ -285,7 +285,7 @@
 static void
 nm_setting_gsm_init (NMSettingGsm *setting)
 {
-	((NMSetting *) setting)->name = g_strdup (NM_SETTING_GSM_SETTING_NAME);
+	g_object_set (setting, NM_SETTING_NAME, NM_SETTING_GSM_SETTING_NAME, NULL);
 }
 
 static void

Modified: trunk/libnm-util/nm-setting-ip4-config.c
==============================================================================
--- trunk/libnm-util/nm-setting-ip4-config.c	(original)
+++ trunk/libnm-util/nm-setting-ip4-config.c	Mon Oct 27 17:36:18 2008
@@ -213,7 +213,7 @@
 static void
 nm_setting_ip4_config_init (NMSettingIP4Config *setting)
 {
-	((NMSetting *) setting)->name = g_strdup (NM_SETTING_IP4_CONFIG_SETTING_NAME);
+	g_object_set (setting, NM_SETTING_NAME, NM_SETTING_IP4_CONFIG_SETTING_NAME, NULL);
 }
 
 static void

Modified: trunk/libnm-util/nm-setting-ip6-config.c
==============================================================================
--- trunk/libnm-util/nm-setting-ip6-config.c	(original)
+++ trunk/libnm-util/nm-setting-ip6-config.c	Mon Oct 27 17:36:18 2008
@@ -162,7 +162,7 @@
 static void
 nm_setting_ip6_config_init (NMSettingIP6Config *setting)
 {
-	((NMSetting *) setting)->name = g_strdup (NM_SETTING_IP6_CONFIG_SETTING_NAME);
+	g_object_set (setting, NM_SETTING_NAME, NM_SETTING_IP6_CONFIG_SETTING_NAME, NULL);
 }
 
 static void

Modified: trunk/libnm-util/nm-setting-ppp.c
==============================================================================
--- trunk/libnm-util/nm-setting-ppp.c	(original)
+++ trunk/libnm-util/nm-setting-ppp.c	Mon Oct 27 17:36:18 2008
@@ -115,7 +115,7 @@
 static void
 nm_setting_ppp_init (NMSettingPPP *setting)
 {
-	((NMSetting *) setting)->name = g_strdup (NM_SETTING_PPP_SETTING_NAME);
+	g_object_set (setting, NM_SETTING_NAME, NM_SETTING_PPP_SETTING_NAME, NULL);
 }
 
 static void

Modified: trunk/libnm-util/nm-setting-pppoe.c
==============================================================================
--- trunk/libnm-util/nm-setting-pppoe.c	(original)
+++ trunk/libnm-util/nm-setting-pppoe.c	Mon Oct 27 17:36:18 2008
@@ -177,7 +177,7 @@
 static void
 nm_setting_pppoe_init (NMSettingPPPOE *setting)
 {
-	((NMSetting *) setting)->name = g_strdup (NM_SETTING_PPPOE_SETTING_NAME);
+	g_object_set (setting, NM_SETTING_NAME, NM_SETTING_PPPOE_SETTING_NAME, NULL);
 }
 
 static void

Modified: trunk/libnm-util/nm-setting-serial.c
==============================================================================
--- trunk/libnm-util/nm-setting-serial.c	(original)
+++ trunk/libnm-util/nm-setting-serial.c	Mon Oct 27 17:36:18 2008
@@ -162,7 +162,7 @@
 static void
 nm_setting_serial_init (NMSettingSerial *setting)
 {
-	((NMSetting *) setting)->name = g_strdup (NM_SETTING_SERIAL_SETTING_NAME);
+	g_object_set (setting, NM_SETTING_NAME, NM_SETTING_SERIAL_SETTING_NAME, NULL);
 }
 
 static void

Modified: trunk/libnm-util/nm-setting-template.c
==============================================================================
--- trunk/libnm-util/nm-setting-template.c	(original)
+++ trunk/libnm-util/nm-setting-template.c	Mon Oct 27 17:36:18 2008
@@ -52,7 +52,7 @@
 static void
 nm_setting_template_init (NMSettingTemplate *setting)
 {
-	((NMSetting *) setting)->name = g_strdup (NM_SETTING_TEMPLATE_SETTING_NAME);
+	g_object_set (setting, NM_SETTING_NAME, NM_SETTING_TEMPLATE_SETTING_NAME, NULL);
 }
 
 static void

Modified: trunk/libnm-util/nm-setting-vpn.c
==============================================================================
--- trunk/libnm-util/nm-setting-vpn.c	(original)
+++ trunk/libnm-util/nm-setting-vpn.c	Mon Oct 27 17:36:18 2008
@@ -140,7 +140,7 @@
 static void
 nm_setting_vpn_init (NMSettingVPN *setting)
 {
-	NM_SETTING (setting)->name = g_strdup (NM_SETTING_VPN_SETTING_NAME);
+	g_object_set (setting, NM_SETTING_NAME, NM_SETTING_VPN_SETTING_NAME, NULL);
 
 	setting->data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
 	setting->secrets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, destroy_one_secret);

Modified: trunk/libnm-util/nm-setting-wired.c
==============================================================================
--- trunk/libnm-util/nm-setting-wired.c	(original)
+++ trunk/libnm-util/nm-setting-wired.c	Mon Oct 27 17:36:18 2008
@@ -179,7 +179,7 @@
 static void
 nm_setting_wired_init (NMSettingWired *setting)
 {
-	((NMSetting *) setting)->name = g_strdup (NM_SETTING_WIRED_SETTING_NAME);
+	g_object_set (setting, NM_SETTING_NAME, NM_SETTING_WIRED_SETTING_NAME, NULL);
 }
 
 static void

Modified: trunk/libnm-util/nm-setting-wireless-security.c
==============================================================================
--- trunk/libnm-util/nm-setting-wireless-security.c	(original)
+++ trunk/libnm-util/nm-setting-wireless-security.c	Mon Oct 27 17:36:18 2008
@@ -398,7 +398,7 @@
 static void
 nm_setting_wireless_security_init (NMSettingWirelessSecurity *setting)
 {
-	((NMSetting *) setting)->name = g_strdup (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
+	g_object_set (setting, NM_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NULL);
 }
 
 static void

Modified: trunk/libnm-util/nm-setting-wireless.c
==============================================================================
--- trunk/libnm-util/nm-setting-wireless.c	(original)
+++ trunk/libnm-util/nm-setting-wireless.c	Mon Oct 27 17:36:18 2008
@@ -402,7 +402,7 @@
 static void
 nm_setting_wireless_init (NMSettingWireless *setting)
 {
-	((NMSetting *) setting)->name = g_strdup (NM_SETTING_WIRELESS_SETTING_NAME);
+	g_object_set (setting, NM_SETTING_NAME, NM_SETTING_WIRELESS_SETTING_NAME, NULL);
 }
 
 static void

Modified: trunk/libnm-util/nm-setting.c
==============================================================================
--- trunk/libnm-util/nm-setting.c	(original)
+++ trunk/libnm-util/nm-setting.c	Mon Oct 27 17:36:18 2008
@@ -31,6 +31,12 @@
 
 G_DEFINE_ABSTRACT_TYPE (NMSetting, nm_setting, G_TYPE_OBJECT)
 
+#define NM_SETTING_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING, NMSettingPrivate))
+
+typedef struct {
+	char *name;
+} NMSettingPrivate;
+
 enum {
 	PROP_0,
 	PROP_NAME,
@@ -187,7 +193,7 @@
 {
 	g_return_val_if_fail (NM_IS_SETTING (setting), NULL);
 
-	return setting->name;
+	return NM_SETTING_GET_PRIVATE (setting)->name;
 }
 
 gboolean
@@ -240,7 +246,7 @@
 			continue;
 
 		if (   (flags & COMPARE_FLAGS_IGNORE_ID)
-		    && !strcmp (setting->name, NM_SETTING_CONNECTION_SETTING_NAME)
+			   && !strcmp (nm_setting_get_name (setting), NM_SETTING_CONNECTION_SETTING_NAME)
 		    && !strcmp (prop_spec->name, NM_SETTING_CONNECTION_ID))
 			continue;
 
@@ -389,7 +395,7 @@
 	if (!property_specs)
 		return NULL;
 
-	string = g_string_new (setting->name);
+	string = g_string_new (nm_setting_get_name (setting));
 	g_string_append_c (string, '\n');
 
 	for (i = 0; i < n_property_specs; i++) {
@@ -442,7 +448,7 @@
 		   GObjectConstructParam *construct_params)
 {
 	GObject *object;
-	NMSetting *setting;
+	NMSettingPrivate *priv;
 
 	object = G_OBJECT_CLASS (nm_setting_parent_class)->constructor (type,
 													    n_construct_params,
@@ -450,8 +456,8 @@
 	if (!object)
 		return NULL;
 
-	setting = NM_SETTING (object);
-	if (!setting->name) {
+	priv = NM_SETTING_GET_PRIVATE (object);
+	if (!priv->name) {
 		nm_warning ("Setting name is not set.");
 		g_object_unref (object);
 		object = NULL;
@@ -463,9 +469,9 @@
 static void
 finalize (GObject *object)
 {
-	NMSetting *self = NM_SETTING (object);
+	NMSettingPrivate *priv = NM_SETTING_GET_PRIVATE (object);
 
-	g_free (self->name);
+	g_free (priv->name);
 
 	G_OBJECT_CLASS (nm_setting_parent_class)->finalize (object);
 }
@@ -474,12 +480,12 @@
 set_property (GObject *object, guint prop_id,
 		    const GValue *value, GParamSpec *pspec)
 {
-	NMSetting *setting = NM_SETTING (object);
+	NMSettingPrivate *priv = NM_SETTING_GET_PRIVATE (object);
 
 	switch (prop_id) {
 	case PROP_NAME:
-		g_free (setting->name);
-		setting->name = g_value_dup_string (value);
+		g_free (priv->name);
+		priv->name = g_value_dup_string (value);
 		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -495,7 +501,7 @@
 
 	switch (prop_id) {
 	case PROP_NAME:
-		g_value_set_string (value, setting->name);
+		g_value_set_string (value, nm_setting_get_name (setting));
 		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -508,6 +514,8 @@
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
 
+	g_type_class_add_private (setting_class, sizeof (NMSettingPrivate));
+
 	/* virtual methods */
 	object_class->constructor  = constructor;
 	object_class->set_property = set_property;

Modified: trunk/libnm-util/nm-setting.h
==============================================================================
--- trunk/libnm-util/nm-setting.h	(original)
+++ trunk/libnm-util/nm-setting.h	Mon Oct 27 17:36:18 2008
@@ -47,8 +47,6 @@
 
 typedef struct {
 	GObject parent;
-
-	char *name;
 } NMSetting;
 
 typedef struct {

Modified: trunk/system-settings/plugins/keyfile/reader.c
==============================================================================
--- trunk/system-settings/plugins/keyfile/reader.c	(original)
+++ trunk/system-settings/plugins/keyfile/reader.c	Mon Oct 27 17:36:18 2008
@@ -29,7 +29,7 @@
 		char **list, **iter;
 		int ret;
 
-		list = g_key_file_get_string_list (file, setting->name, key, &length, NULL);
+		list = g_key_file_get_string_list (file, nm_setting_get_name (setting), key, &length, NULL);
 		if (!list || !g_strv_length (list))
 			return TRUE;
 
@@ -48,7 +48,7 @@
 	} else {
 		gint *tmp;
 
-		tmp = g_key_file_get_integer_list (file, setting->name, key, &length, NULL);
+		tmp = g_key_file_get_integer_list (file, nm_setting_get_name (setting), key, &length, NULL);
 
 		array = g_array_sized_new (FALSE, FALSE, sizeof (guint32), length);
 		for (i = 0; i < length; i++)
@@ -255,19 +255,22 @@
                              const char *key)
 {
 	gboolean success = FALSE;
+	const char *setting_name;
 
 	/* Only handle IPv4 addresses and routes for now */
 	if (!NM_IS_SETTING_IP4_CONFIG (setting))
 		return FALSE;
 
+	setting_name = nm_setting_get_name (setting);
+
 	if (!strcmp (key, NM_SETTING_IP4_CONFIG_ADDRESSES)) {
 		GPtrArray *addresses;
 
-		addresses = read_addresses (file, setting->name, key);
+		addresses = read_addresses (file, setting_name, key);
 
 		/* Work around for previous syntax */
 		if (!addresses && !strcmp (key, NM_SETTING_IP4_CONFIG_ADDRESSES))
-			addresses = read_addresses (file, setting->name, "address");
+			addresses = read_addresses (file, setting_name, "address");
 
 		if (addresses) {
 			g_object_set (setting, key, addresses, NULL);
@@ -278,7 +281,7 @@
 	} else if (!strcmp (key, NM_SETTING_IP4_CONFIG_ROUTES)) {
 		GPtrArray *routes;
 
-		routes = read_routes (file, setting->name, key);
+		routes = read_routes (file, setting_name, key);
 		if (routes) {
 			g_object_set (setting, key, routes, NULL);
 			g_ptr_array_foreach (routes, free_one_route, NULL);
@@ -295,13 +298,14 @@
 {
 	char **keys, **iter;
 	char *value;
+	const char *setting_name = nm_setting_get_name (setting);
 
-	keys = g_key_file_get_keys (file, setting->name, NULL, NULL);
+	keys = g_key_file_get_keys (file, setting_name, NULL, NULL);
 	if (!keys || !*keys)
 		return;
 
 	for (iter = keys; *iter; iter++) {
-		value = g_key_file_get_string (file, setting->name, *iter, NULL);
+		value = g_key_file_get_string (file, setting_name, *iter, NULL);
 		if (!value)
 			continue;
 
@@ -330,6 +334,7 @@
 {
 	ReadSettingInfo *info = (ReadSettingInfo *) user_data;
 	GKeyFile *file = info->keyfile;
+	const char *setting_name;
 	GType type;
 	GError *err = NULL;
 	gboolean check_for_key = TRUE;
@@ -347,15 +352,17 @@
 	    && !strcmp (key, NM_SETTING_CONNECTION_READ_ONLY))
 		return;
 
+	setting_name = nm_setting_get_name (setting);
+
 	/* IPv4 addresses and VPN properties don't have the exact key name */
 	if (NM_IS_SETTING_IP4_CONFIG (setting) && !strcmp (key, NM_SETTING_IP4_CONFIG_ADDRESSES))
 		check_for_key = FALSE;
 	else if (NM_IS_SETTING_VPN (setting))
 		check_for_key = FALSE;
 
-	if (check_for_key && !g_key_file_has_key (file, setting->name, key, &err)) {
+	if (check_for_key && !g_key_file_has_key (file, setting_name, key, &err)) {
 		if (err) {
-			g_warning ("Error loading setting '%s' value: %s", setting->name, err->message);
+			g_warning ("Error loading setting '%s' value: %s", setting_name, err->message);
 			g_error_free (err);
 		}
 
@@ -367,30 +374,30 @@
 	if (type == G_TYPE_STRING) {
 		char *str_val;
 
-		str_val = g_key_file_get_string (file, setting->name, key, NULL);
+		str_val = g_key_file_get_string (file, setting_name, key, NULL);
 		g_object_set (setting, key, str_val, NULL);
 		g_free (str_val);
 	} else if (type == G_TYPE_UINT) {
 		int int_val;
 
-		int_val = g_key_file_get_integer (file, setting->name, key, NULL);
+		int_val = g_key_file_get_integer (file, setting_name, key, NULL);
 		if (int_val < 0)
 			g_warning ("Casting negative value (%i) to uint", int_val);
 		g_object_set (setting, key, int_val, NULL);
 	} else if (type == G_TYPE_INT) {
 		int int_val;
 
-		int_val = g_key_file_get_integer (file, setting->name, key, NULL);
+		int_val = g_key_file_get_integer (file, setting_name, key, NULL);
 		g_object_set (setting, key, int_val, NULL);
 	} else if (type == G_TYPE_BOOLEAN) {
 		gboolean bool_val;
 
-		bool_val = g_key_file_get_boolean (file, setting->name, key, NULL);
+		bool_val = g_key_file_get_boolean (file, setting_name, key, NULL);
 		g_object_set (setting, key, bool_val, NULL);
 	} else if (type == G_TYPE_CHAR) {
 		int int_val;
 
-		int_val = g_key_file_get_integer (file, setting->name, key, NULL);
+		int_val = g_key_file_get_integer (file, setting_name, key, NULL);
 		if (int_val < G_MININT8 || int_val > G_MAXINT8)
 			g_warning ("Casting value (%i) to char", int_val);
 
@@ -399,7 +406,7 @@
 		char *tmp_str;
 		guint64 uint_val;
 
-		tmp_str = g_key_file_get_value (file, setting->name, key, NULL);
+		tmp_str = g_key_file_get_value (file, setting_name, key, NULL);
 		uint_val = g_ascii_strtoull (tmp_str, NULL, 10);
 		g_free (tmp_str);
 		g_object_set (setting, key, uint_val, NULL);
@@ -409,7 +416,7 @@
 		gsize length;
 		int i;
 
-		tmp = g_key_file_get_integer_list (file, setting->name, key, &length, NULL);
+		tmp = g_key_file_get_integer_list (file, setting_name, key, &length, NULL);
 
 		array = g_byte_array_sized_new (length);
 		for (i = 0; i < length; i++) {
@@ -431,7 +438,7 @@
 		int i;
 		GSList *list = NULL;
 
-		sa = g_key_file_get_string_list (file, setting->name, key, &length, NULL);
+		sa = g_key_file_get_string_list (file, setting_name, key, &length, NULL);
 		for (i = 0; i < length; i++)
 			list = g_slist_prepend (list, sa[i]);
 
@@ -445,16 +452,16 @@
 	} else if (type == DBUS_TYPE_G_UINT_ARRAY) {
 		if (!read_array_of_uint (file, setting, key)) {
 			g_warning ("Unhandled setting property type (read): '%s/%s' : '%s'",
-					 setting->name, key, G_VALUE_TYPE_NAME (value));
+					 setting_name, key, G_VALUE_TYPE_NAME (value));
 		}
 	} else if (type == DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT) {
 		if (!read_array_of_array_of_uint (file, setting, key)) {
 			g_warning ("Unhandled setting property type (read): '%s/%s' : '%s'",
-					 setting->name, key, G_VALUE_TYPE_NAME (value));
+					 setting_name, key, G_VALUE_TYPE_NAME (value));
 		}
 	} else {
 		g_warning ("Unhandled setting property type (read): '%s/%s' : '%s'",
-				 setting->name, key, G_VALUE_TYPE_NAME (value));
+				 setting_name, key, G_VALUE_TYPE_NAME (value));
 	}
 }
 

Modified: trunk/system-settings/plugins/keyfile/writer.c
==============================================================================
--- trunk/system-settings/plugins/keyfile/writer.c	(original)
+++ trunk/system-settings/plugins/keyfile/writer.c	Mon Oct 27 17:36:18 2008
@@ -48,7 +48,7 @@
 			}
 		}
 
-		g_key_file_set_string_list (file, setting->name, key, (const char **) list, array->len);
+		g_key_file_set_string_list (file, nm_setting_get_name (setting), key, (const char **) list, array->len);
 		g_strfreev (list);
 	} else {
 		int *tmp_array;
@@ -57,7 +57,7 @@
 		for (i = 0; i < array->len; i++)
 			tmp_array[i] = g_array_index (array, int, i);
 
-		g_key_file_set_integer_list (file, setting->name, key, tmp_array, array->len);
+		g_key_file_set_integer_list (file, nm_setting_get_name (setting), key, tmp_array, array->len);
 		g_free (tmp_array);
 	}
 
@@ -136,9 +136,9 @@
 		return TRUE;
 
 	if (!strcmp (key, NM_SETTING_IP4_CONFIG_ADDRESSES))
-		write_ip4_values (file, setting->name, key, array, 3, 0, 2);
+		write_ip4_values (file, nm_setting_get_name (setting), key, array, 3, 0, 2);
 	else if (!strcmp (key, NM_SETTING_IP4_CONFIG_ROUTES))
-		write_ip4_values (file, setting->name, key, array, 4, 0, 2);
+		write_ip4_values (file, nm_setting_get_name (setting), key, array, 4, 0, 2);
 
 	return TRUE;
 }
@@ -177,7 +177,7 @@
 	    && !strcmp (key, NM_SETTING_VPN_SECRETS)) {
 		info.setting_name = VPN_SECRETS_GROUP;
 	} else
-		info.setting_name = setting->name;
+		info.setting_name = nm_setting_get_name (setting);
 
 	g_hash_table_foreach (hash, write_hash_of_string_helper, &info);
 }
@@ -190,6 +190,7 @@
 				 gpointer user_data)
 {
 	GKeyFile *file = (GKeyFile *) user_data;
+	const char *setting_name;
 	GType type;
 
 	type = G_VALUE_TYPE (value);
@@ -203,26 +204,28 @@
 	    && !strcmp (key, NM_SETTING_CONNECTION_READ_ONLY))
 		return;
 
+	setting_name = nm_setting_get_name (setting);
+
 	if (type == G_TYPE_STRING) {
 		const char *str;
 
 		str = g_value_get_string (value);
 		if (str)
-			g_key_file_set_string (file, setting->name, key, str);
+			g_key_file_set_string (file, setting_name, key, str);
 	} else if (type == G_TYPE_UINT)
-		g_key_file_set_integer (file, setting->name, key, (int) g_value_get_uint (value));
+		g_key_file_set_integer (file, setting_name, key, (int) g_value_get_uint (value));
 	else if (type == G_TYPE_INT)
-		g_key_file_set_integer (file, setting->name, key, g_value_get_int (value));
+		g_key_file_set_integer (file, setting_name, key, g_value_get_int (value));
 	else if (type == G_TYPE_UINT64) {
 		char *numstr;
 
 		numstr = g_strdup_printf ("%" G_GUINT64_FORMAT, g_value_get_uint64 (value));
-		g_key_file_set_value (file, setting->name, key, numstr);
+		g_key_file_set_value (file, setting_name, key, numstr);
 		g_free (numstr);
 	} else if (type == G_TYPE_BOOLEAN) {
-		g_key_file_set_boolean (file, setting->name, key, g_value_get_boolean (value));
+		g_key_file_set_boolean (file, setting_name, key, g_value_get_boolean (value));
 	} else if (type == G_TYPE_CHAR) {
-		g_key_file_set_integer (file, setting->name, key, (int) g_value_get_char (value));
+		g_key_file_set_integer (file, setting_name, key, (int) g_value_get_char (value));
 	} else if (type == DBUS_TYPE_G_UCHAR_ARRAY) {
 		GByteArray *array;
 
@@ -235,7 +238,7 @@
 			for (i = 0; i < array->len; i++)
 				tmp_array[i] = (int) array->data[i];
 
-			g_key_file_set_integer_list (file, setting->name, key, tmp_array, array->len);
+			g_key_file_set_integer_list (file, setting_name, key, tmp_array, array->len);
 			g_free (tmp_array);
 		}
 	} else if (type == dbus_g_type_get_collection ("GSList", G_TYPE_STRING)) {
@@ -251,7 +254,7 @@
 			for (iter = list; iter; iter = iter->next)
 				array[i++] = iter->data;
 
-			g_key_file_set_string_list (file, setting->name, key, (const gchar **const) array, i);
+			g_key_file_set_string_list (file, setting_name, key, (const gchar **const) array, i);
 			g_free (array);
 		}
 	} else if (type == dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING)) {
@@ -259,16 +262,16 @@
 	} else if (type == DBUS_TYPE_G_UINT_ARRAY) {
 		if (!write_array_of_uint (file, setting, key, value)) {
 			g_warning ("Unhandled setting property type (write) '%s/%s' : '%s'", 
-					 setting->name, key, g_type_name (type));
+					 setting_name, key, g_type_name (type));
 		}
 	} else if (type == DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT) {
 		if (!write_array_of_array_of_uint (file, setting, key, value)) {
 			g_warning ("Unhandled setting property type (write) '%s/%s' : '%s'", 
-					 setting->name, key, g_type_name (type));
+					 setting_name, key, g_type_name (type));
 		}
 	} else {
 		g_warning ("Unhandled setting property type (write) '%s/%s' : '%s'", 
-				 setting->name, key, g_type_name (type));
+				 setting_name, key, g_type_name (type));
 	}
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]