2008-10-26 Dan Williams <dcbw@redhat.com>
authorDan Williams <dcbw@redhat.com>
Sun, 26 Oct 2008 17:41:37 +0000 (17:41 +0000)
committerDan Williams <dcbw@redhat.com>
Sun, 26 Oct 2008 17:41:37 +0000 (17:41 +0000)
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

git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4220 4912f4e0-d625-0410-9fb7-b9a5a253dbdc

22 files changed:
ChangeLog
libnm-util/libnm-util.ver
libnm-util/nm-setting-connection.c
libnm-util/nm-setting-connection.h
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

index 45e750a..ff6879f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+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
+
 2008-10-26  Dan Williams  <dcbw@redhat.com>
 
        Patch from Tambet Ingo <tambet@gmail.com>
index 1252cc1..17ad171 100644 (file)
@@ -49,6 +49,11 @@ global:
        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;
index 6c409bd..bb27f63 100644 (file)
@@ -64,6 +64,16 @@ nm_setting_connection_error_get_type (void)
 
 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 @@ NMSetting *nm_setting_connection_new (void)
        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 @@ find_setting_by_name (gconstpointer a, gconstpointer b)
 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 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
                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 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
                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 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
        }
 
        /* 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 @@ nm_setting_connection_init (NMSettingConnection *setting)
 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 @@ static void
 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 @@ get_property (GObject *object, guint prop_id,
 
        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 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
        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;
index d5e032a..16ff4e4 100644 (file)
@@ -61,12 +61,6 @@ GQuark nm_setting_connection_error_quark (void);
 
 typedef struct {
        NMSetting parent;
-
-       char *id;
-       char *uuid;
-       char *type;
-       gboolean autoconnect;
-       guint64 timestamp;
 } NMSettingConnection;
 
 typedef struct {
@@ -75,7 +69,12 @@ 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);
 
 G_END_DECLS
 
index 107a841..21b24cd 100644 (file)
@@ -177,7 +177,7 @@ get_connection_id (NMConnection *connection)
        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 @@ update_routing_and_dns (NMPolicy *policy, gboolean force_update)
        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 @@ update_routing_and_dns (NMPolicy *policy, gboolean force_update)
        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 @@ auto_activate_device (gpointer user_data)
                        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 @@ connection_removed (NMManager *manager,
 
                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);
index 9b49d6e..628a9b7 100644 (file)
@@ -237,10 +237,10 @@ real_get_best_auto_connection (NMDevice *dev,
                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;
index df69ba7..6fd3987 100644 (file)
@@ -551,17 +551,19 @@ real_get_best_auto_connection (NMDevice *dev,
                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 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason)
                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 @@ static NMActStageReturn
 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 @@ real_act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
        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 @@ real_act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
                        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 @@ real_check_connection_compatible (NMDevice *device,
        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);
index 88bb14a..2cd41de 100644 (file)
@@ -223,7 +223,8 @@ nm_device_interface_activate (NMDeviceInterface *device,
        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);
index 7cabe0f..6ab6144 100644 (file)
@@ -990,7 +990,7 @@ real_check_connection_compatible (NMDevice *device,
        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 @@ real_get_best_auto_connection (NMDevice *dev,
                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 @@ real_act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
        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 @@ real_act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
        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 @@ real_act_stage4_ip_config_timeout (NMDevice *dev,
                /* 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) {
index 670e2e6..1a9cb0f 100644 (file)
@@ -684,10 +684,10 @@ real_get_best_auto_connection (NMDevice *dev,
                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;
index 74345b0..4ae935a 100644 (file)
@@ -1846,7 +1846,7 @@ nm_manager_activate_connection (NMManager *manager,
        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 @@ connection_sort (gconstpointer pa, gconstpointer pb)
        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;
 }
index 8644347..1277b6f 100644 (file)
@@ -347,6 +347,7 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager,
        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 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager,
 
        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;
index 77075a5..5803631 100644 (file)
@@ -631,7 +631,7 @@ nm_vpn_connection_get_name (NMVPNConnection *connection)
        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 *
index f83a4fb..334a043 100644 (file)
@@ -126,22 +126,25 @@ get_device_type_for_connection (NMConnection *connection)
 {
        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;
        }
index ab350bf..48241e4 100644 (file)
@@ -166,21 +166,24 @@ read_one_connection (SCPluginIfcfg *plugin, const char *filename)
        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 @@ connection_changed_handler (SCPluginIfcfg *plugin,
 
                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);
                }
 
index 2127bf2..75713e2 100644 (file)
@@ -91,6 +91,7 @@ make_connection_setting (const char *file,
 {
        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 @@ make_connection_setting (const char *file,
                /* 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
index 68e646b..72460a8 100644 (file)
@@ -69,7 +69,7 @@ make_connection_setting (shvarFile *file,
                          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 @@ make_connection_setting (shvarFile *file,
                 * 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;
index b917d8c..713dd6c 100644 (file)
@@ -536,7 +536,8 @@ ifupdown_update_connection_from_if_block(NMConnection *connection,
        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 @@ ifupdown_update_connection_from_if_block(NMConnection *connection,
        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); 
index 3eca2c8..efb333a 100644 (file)
@@ -257,13 +257,17 @@ constructor (GType type,
 
        /* 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);
                }
index 06b83ab..860840e 100644 (file)
@@ -95,16 +95,17 @@ find_by_uuid (gpointer key, gpointer data, gpointer user_data)
        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 @@ dir_changed (GFileMonitor *monitor,
                        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 @@ dir_changed (GFileMonitor *monitor,
                                 */
                                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;
index 34cc8af..48e21af 100644 (file)
@@ -310,7 +310,7 @@ write_connection (NMConnection *connection, char **out_path, GError **error)
        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);
 
index 99d4f8e..4d01ab9 100644 (file)
@@ -294,20 +294,23 @@ have_connection_for_device (Application *app, GByteArray *mac)
        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 @@ add_default_dhcp_connection (gpointer user_data)
        NMSettingWired *s_wired;
        NMConnection *wrapped;
        GByteArray *setting_mac;
+       char *id;
+       char *uuid;
 
        if (info->add_id)
                info->add_id = 0;
@@ -366,13 +371,23 @@ add_default_dhcp_connection (gpointer user_data)
        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 ());