summaryrefslogtreecommitdiff
path: root/libnm-util
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2008-10-27 17:36:18 +0000
committerDan Williams <dcbw@redhat.com>2008-10-27 17:36:18 +0000
commitc438326110372b080d34b8d9b468c901b9e8f365 (patch)
tree2371c4c87db8d2aa11e6f207971c234bb6ef45df /libnm-util
parent519f8cd6c9fbbea83a1a07617b21e5247608037c (diff)
downloadNetworkManager-c438326110372b080d34b8d9b468c901b9e8f365.tar.gz
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 git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4228 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Diffstat (limited to 'libnm-util')
-rw-r--r--libnm-util/nm-connection.c4
-rw-r--r--libnm-util/nm-setting-8021x.c2
-rw-r--r--libnm-util/nm-setting-cdma.c2
-rw-r--r--libnm-util/nm-setting-connection.c2
-rw-r--r--libnm-util/nm-setting-gsm.c2
-rw-r--r--libnm-util/nm-setting-ip4-config.c2
-rw-r--r--libnm-util/nm-setting-ip6-config.c2
-rw-r--r--libnm-util/nm-setting-ppp.c2
-rw-r--r--libnm-util/nm-setting-pppoe.c2
-rw-r--r--libnm-util/nm-setting-serial.c2
-rw-r--r--libnm-util/nm-setting-template.c2
-rw-r--r--libnm-util/nm-setting-vpn.c2
-rw-r--r--libnm-util/nm-setting-wired.c2
-rw-r--r--libnm-util/nm-setting-wireless-security.c2
-rw-r--r--libnm-util/nm-setting-wireless.c2
-rw-r--r--libnm-util/nm-setting.c32
-rw-r--r--libnm-util/nm-setting.h2
17 files changed, 36 insertions, 30 deletions
diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c
index 876e866104..7ec48e6697 100644
--- a/libnm-util/nm-connection.c
+++ b/libnm-util/nm-connection.c
@@ -605,8 +605,8 @@ add_one_setting_to_hash (gpointer key, gpointer data, gpointer user_data)
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 *
diff --git a/libnm-util/nm-setting-8021x.c b/libnm-util/nm-setting-8021x.c
index 45caaf9f4d..d5a4b5ef0b 100644
--- a/libnm-util/nm-setting-8021x.c
+++ b/libnm-util/nm-setting-8021x.c
@@ -559,7 +559,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
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
diff --git a/libnm-util/nm-setting-cdma.c b/libnm-util/nm-setting-cdma.c
index 7c0fb8fe1e..2fff67e096 100644
--- a/libnm-util/nm-setting-cdma.c
+++ b/libnm-util/nm-setting-cdma.c
@@ -188,7 +188,7 @@ need_secrets (NMSetting *setting)
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
diff --git a/libnm-util/nm-setting-connection.c b/libnm-util/nm-setting-connection.c
index 422d8e8c14..ada3bfa44a 100644
--- a/libnm-util/nm-setting-connection.c
+++ b/libnm-util/nm-setting-connection.c
@@ -211,7 +211,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
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
diff --git a/libnm-util/nm-setting-gsm.c b/libnm-util/nm-setting-gsm.c
index 9ad0a76b0e..a035bccf8d 100644
--- a/libnm-util/nm-setting-gsm.c
+++ b/libnm-util/nm-setting-gsm.c
@@ -285,7 +285,7 @@ need_secrets (NMSetting *setting)
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
diff --git a/libnm-util/nm-setting-ip4-config.c b/libnm-util/nm-setting-ip4-config.c
index 7e8966850f..e6acece1ce 100644
--- a/libnm-util/nm-setting-ip4-config.c
+++ b/libnm-util/nm-setting-ip4-config.c
@@ -213,7 +213,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
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
diff --git a/libnm-util/nm-setting-ip6-config.c b/libnm-util/nm-setting-ip6-config.c
index fc6c5c7ac2..79cba289e2 100644
--- a/libnm-util/nm-setting-ip6-config.c
+++ b/libnm-util/nm-setting-ip6-config.c
@@ -162,7 +162,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
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
diff --git a/libnm-util/nm-setting-ppp.c b/libnm-util/nm-setting-ppp.c
index eaae42b287..f06fa8e219 100644
--- a/libnm-util/nm-setting-ppp.c
+++ b/libnm-util/nm-setting-ppp.c
@@ -115,7 +115,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
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
diff --git a/libnm-util/nm-setting-pppoe.c b/libnm-util/nm-setting-pppoe.c
index 13bfbad5b4..4c0196b88c 100644
--- a/libnm-util/nm-setting-pppoe.c
+++ b/libnm-util/nm-setting-pppoe.c
@@ -177,7 +177,7 @@ need_secrets (NMSetting *setting)
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
diff --git a/libnm-util/nm-setting-serial.c b/libnm-util/nm-setting-serial.c
index cdccd1641c..257f034614 100644
--- a/libnm-util/nm-setting-serial.c
+++ b/libnm-util/nm-setting-serial.c
@@ -162,7 +162,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
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
diff --git a/libnm-util/nm-setting-template.c b/libnm-util/nm-setting-template.c
index 9a1badd0b7..989c1db957 100644
--- a/libnm-util/nm-setting-template.c
+++ b/libnm-util/nm-setting-template.c
@@ -52,7 +52,7 @@ verify (NMSetting *setting, GSList *all_settings)
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
diff --git a/libnm-util/nm-setting-vpn.c b/libnm-util/nm-setting-vpn.c
index 0c2118312b..d7fbf3b2e5 100644
--- a/libnm-util/nm-setting-vpn.c
+++ b/libnm-util/nm-setting-vpn.c
@@ -140,7 +140,7 @@ destroy_one_secret (gpointer data)
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);
diff --git a/libnm-util/nm-setting-wired.c b/libnm-util/nm-setting-wired.c
index 8aa7758d26..2e0e022cf1 100644
--- a/libnm-util/nm-setting-wired.c
+++ b/libnm-util/nm-setting-wired.c
@@ -179,7 +179,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
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
diff --git a/libnm-util/nm-setting-wireless-security.c b/libnm-util/nm-setting-wireless-security.c
index 9c185182bb..5164cd03f4 100644
--- a/libnm-util/nm-setting-wireless-security.c
+++ b/libnm-util/nm-setting-wireless-security.c
@@ -398,7 +398,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
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
diff --git a/libnm-util/nm-setting-wireless.c b/libnm-util/nm-setting-wireless.c
index 7eeafd3564..74f02e1b2d 100644
--- a/libnm-util/nm-setting-wireless.c
+++ b/libnm-util/nm-setting-wireless.c
@@ -402,7 +402,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
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
diff --git a/libnm-util/nm-setting.c b/libnm-util/nm-setting.c
index 9c5cfc3780..426e83229a 100644
--- a/libnm-util/nm-setting.c
+++ b/libnm-util/nm-setting.c
@@ -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 @@ nm_setting_get_name (NMSetting *setting)
{
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 @@ nm_setting_compare (NMSetting *setting,
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 @@ nm_setting_to_string (NMSetting *setting)
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 @@ constructor (GType type,
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 @@ constructor (GType type,
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 @@ constructor (GType type,
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 @@ static void
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 @@ get_property (GObject *object, guint prop_id,
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 @@ nm_setting_class_init (NMSettingClass *setting_class)
{
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;
diff --git a/libnm-util/nm-setting.h b/libnm-util/nm-setting.h
index 435385655e..1a6c2937f2 100644
--- a/libnm-util/nm-setting.h
+++ b/libnm-util/nm-setting.h
@@ -47,8 +47,6 @@ G_BEGIN_DECLS
typedef struct {
GObject parent;
-
- char *name;
} NMSetting;
typedef struct {