2008-10-27 Dan Williams <dcbw@redhat.com>
authorDan Williams <dcbw@redhat.com>
Mon, 27 Oct 2008 17:07:42 +0000 (17:07 +0000)
committerDan Williams <dcbw@redhat.com>
Mon, 27 Oct 2008 17:07:42 +0000 (17:07 +0000)
* 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

ChangeLog
libnm-util/libnm-util.ver
libnm-util/nm-setting-connection.c
libnm-util/nm-setting-connection.h
system-settings/plugins/ifcfg-fedora/reader.c
system-settings/plugins/ifcfg-suse/parser.c
system-settings/plugins/ifupdown/parser.c
system-settings/plugins/keyfile/reader.c
system-settings/plugins/keyfile/writer.c

index 46f775c..7808442 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index 17ad171..32b5e2d 100644 (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;
index bb27f63..422d8e8 100644 (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));
 }
index 16ff4e4..04157da 100644 (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
 
index 75713e2..26c1bb7 100644 (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;
index 72460a8..0bd7e4f 100644 (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);
index 713dd6c..224f397 100644 (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);
 
index 2702bff..86cd8d3 100644 (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;
index 48e21af..c80feed 100644 (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;