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



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4227 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2008-10-27 17:07:42 +00:00
parent efdf6bab77
commit 519f8cd6c9
9 changed files with 66 additions and 1 deletions

View File

@ -1,3 +1,20 @@
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
2008-10-27 Tambet Ingo <tambet@gmail.com>
* src/nm-device-ethernet.c (nm_device_ethernet_get_speed): Implement

View File

@ -54,6 +54,7 @@ global:
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;

View File

@ -72,6 +72,7 @@ typedef struct {
char *type;
gboolean autoconnect;
guint64 timestamp;
gboolean read_only;
} NMSettingConnectionPrivate;
enum {
@ -81,6 +82,7 @@ enum {
PROP_TYPE,
PROP_AUTOCONNECT,
PROP_TIMESTAMP,
PROP_READ_ONLY,
LAST_PROP
};
@ -130,6 +132,14 @@ nm_setting_connection_get_timestamp (NMSettingConnection *setting)
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 @@ set_property (GObject *object, guint prop_id,
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 @@ get_property (GObject *object, guint prop_id,
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 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
"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));
}

View File

@ -58,6 +58,7 @@ GQuark nm_setting_connection_error_quark (void);
#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 @@ typedef struct {
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

View File

@ -899,6 +899,7 @@ connection_from_file (const char *filename,
GError **error)
{
NMConnection *connection = NULL;
NMSettingConnection *s_con;
shvarFile *parsed;
char *type;
char *nmc = NULL;
@ -987,6 +988,13 @@ connection_from_file (const char *filename,
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;

View File

@ -86,6 +86,7 @@ make_connection_setting (shvarFile *file,
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);

View File

@ -557,6 +557,7 @@ ifupdown_update_connection_from_if_block(NMConnection *connection,
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);

View File

@ -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 @@ read_one_setting_value (NMSetting *setting,
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;

View File

@ -198,6 +198,11 @@ write_setting_value (NMSetting *setting,
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;