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
This commit is contained in:
@@ -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 *
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -47,8 +47,6 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef struct {
|
||||
GObject parent;
|
||||
|
||||
char *name;
|
||||
} NMSetting;
|
||||
|
||||
typedef struct {
|
||||
|
Reference in New Issue
Block a user