NetworkManager r4227 - in trunk: . libnm-util system-settings/plugins/ifcfg-fedora system-settings/plugins/ifcfg-suse system-settings/plugins/ifupdown system-settings/plugins/keyfile



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

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

	* libnm-util/libnm-util.ver
	  libnm-util/nm-setting-connection.c
	  libnm-util/nm-setting-connection.h
		- Add a 'read-only' property that indicates the connection cannot be
			modified

	* system-settings/plugins/ifcfg-fedora/reader.c
	  system-settings/plugins/ifcfg-suse/parser.c
	  system-settings/plugins/ifupdown/parser.c
		- These plugins are read-only at the moment

	* system-settings/plugins/keyfile/reader.c
	  system-settings/plugins/keyfile/writer.c
		- Read-only shouldn't get saved out to files or read in from them



Modified:
   trunk/ChangeLog
   trunk/libnm-util/libnm-util.ver
   trunk/libnm-util/nm-setting-connection.c
   trunk/libnm-util/nm-setting-connection.h
   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/reader.c
   trunk/system-settings/plugins/keyfile/writer.c

Modified: trunk/libnm-util/libnm-util.ver
==============================================================================
--- trunk/libnm-util/libnm-util.ver	(original)
+++ trunk/libnm-util/libnm-util.ver	Mon Oct 27 17:07:42 2008
@@ -54,6 +54,7 @@
 	nm_setting_connection_get_connection_type;
 	nm_setting_connection_get_autoconnect;
 	nm_setting_connection_get_timestamp;
+	nm_setting_connection_get_read_only;
 	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	Mon Oct 27 17:07:42 2008
@@ -72,6 +72,7 @@
 	char *type;
 	gboolean autoconnect;
 	guint64 timestamp;
+	gboolean read_only;
 } NMSettingConnectionPrivate;
 
 enum {
@@ -81,6 +82,7 @@
 	PROP_TYPE,
 	PROP_AUTOCONNECT,
 	PROP_TIMESTAMP,
+	PROP_READ_ONLY,
 
 	LAST_PROP
 };
@@ -130,6 +132,14 @@
 	return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->timestamp;
 }
 
+gboolean
+nm_setting_connection_get_read_only (NMSettingConnection *setting)
+{
+	g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), TRUE);
+
+	return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->read_only;
+}
+
 static gint
 find_setting_by_name (gconstpointer a, gconstpointer b)
 {
@@ -241,6 +251,9 @@
 	case PROP_TIMESTAMP:
 		priv->timestamp = g_value_get_uint64 (value);
 		break;
+	case PROP_READ_ONLY:
+		priv->read_only = g_value_get_boolean (value);
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -269,6 +282,9 @@
 	case PROP_TIMESTAMP:
 		g_value_set_uint64 (value, nm_setting_connection_get_timestamp (setting));
 		break;
+	case PROP_READ_ONLY:
+		g_value_set_boolean (value, nm_setting_connection_get_read_only (setting));
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -329,4 +345,12 @@
 						  "Connection timestamp",
 						  0, G_MAXUINT64, 0,
 						  G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
+
+	g_object_class_install_property
+	    (object_class, PROP_READ_ONLY,
+	     g_param_spec_boolean (NM_SETTING_CONNECTION_READ_ONLY,
+	                      "Read-Only",
+	                      "Read-Only",
+	                      FALSE,
+	                      G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
 }

Modified: trunk/libnm-util/nm-setting-connection.h
==============================================================================
--- trunk/libnm-util/nm-setting-connection.h	(original)
+++ trunk/libnm-util/nm-setting-connection.h	Mon Oct 27 17:07:42 2008
@@ -58,6 +58,7 @@
 #define NM_SETTING_CONNECTION_TYPE        "type"
 #define NM_SETTING_CONNECTION_AUTOCONNECT "autoconnect"
 #define NM_SETTING_CONNECTION_TIMESTAMP   "timestamp"
+#define NM_SETTING_CONNECTION_READ_ONLY   "read-only"
 
 typedef struct {
 	NMSetting parent;
@@ -69,12 +70,13 @@
 
 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);
+gboolean    nm_setting_connection_get_read_only       (NMSettingConnection *setting);
 
 G_END_DECLS
 

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	Mon Oct 27 17:07:42 2008
@@ -899,6 +899,7 @@
                       GError **error)
 {
 	NMConnection *connection = NULL;
+	NMSettingConnection *s_con;
 	shvarFile *parsed;
 	char *type;
 	char *nmc = NULL;
@@ -987,6 +988,13 @@
 
 	g_free (type);
 
+	/* We don't write connections yet */
+	if (connection) {
+		s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+		if (s_con)
+			g_object_set (s_con, NM_SETTING_CONNECTION_READ_ONLY, TRUE, NULL);
+	}
+
 	/* Don't bother reading the connection fully if it's unmanaged */
 	if (!connection || *ignored)
 		goto done;

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	Mon Oct 27 17:07:42 2008
@@ -86,6 +86,7 @@
 	g_object_set (s_con,
 			    NM_SETTING_CONNECTION_ID, str,
 			    NM_SETTING_CONNECTION_TYPE, type,
+			    NM_SETTING_CONNECTION_READ_ONLY, TRUE,
 			    NULL);
 
 	g_free (str);

Modified: trunk/system-settings/plugins/ifupdown/parser.c
==============================================================================
--- trunk/system-settings/plugins/ifupdown/parser.c	(original)
+++ trunk/system-settings/plugins/ifupdown/parser.c	Mon Oct 27 17:07:42 2008
@@ -557,6 +557,7 @@
 	              NM_SETTING_CONNECTION_TYPE, type,
 	              NM_SETTING_CONNECTION_ID, idstr,
 	              NM_SETTING_CONNECTION_UUID, uuid,
+	              NM_SETTING_CONNECTION_READ_ONLY, TRUE,
 	              NULL);
 	g_free (uuid);
 

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:07:42 2008
@@ -9,6 +9,7 @@
 #include <nm-setting.h>
 #include <nm-setting-ip4-config.h>
 #include <nm-setting-vpn.h>
+#include <nm-setting-connection.h>
 #include <arpa/inet.h>
 #include <string.h>
 
@@ -341,6 +342,11 @@
 	if (secret && !info->secrets)
 		return;
 
+	/* Don't read the NMSettingConnection object's 'read-only' property */
+	if (   NM_IS_SETTING_CONNECTION (setting)
+	    && !strcmp (key, NM_SETTING_CONNECTION_READ_ONLY))
+		return;
+
 	/* 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;

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:07:42 2008
@@ -198,6 +198,11 @@
 	if (!strcmp (key, NM_SETTING_NAME))
 		return;
 
+	/* Don't write the NMSettingConnection object's 'read-only' property */
+	if (   NM_IS_SETTING_CONNECTION (setting)
+	    && !strcmp (key, NM_SETTING_CONNECTION_READ_ONLY))
+		return;
+
 	if (type == G_TYPE_STRING) {
 		const char *str;
 



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