mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-01 06:48:00 +02:00
libnm: use direct properties for NMSettingWpan
This commit is contained in:
parent
b688fc3da4
commit
6cc3b00060
1 changed files with 47 additions and 78 deletions
|
|
@ -43,10 +43,10 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_MAC_ADDRESS,
|
|||
|
||||
typedef struct {
|
||||
char * mac_address;
|
||||
guint16 pan_id;
|
||||
guint16 short_address;
|
||||
guint32 pan_id;
|
||||
guint32 short_address;
|
||||
gint32 page;
|
||||
gint16 channel;
|
||||
gint32 channel;
|
||||
} NMSettingWpanPrivate;
|
||||
|
||||
/**
|
||||
|
|
@ -200,33 +200,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingWpan *setting = NM_SETTING_WPAN(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_MAC_ADDRESS:
|
||||
g_value_set_string(value, nm_setting_wpan_get_mac_address(setting));
|
||||
break;
|
||||
case PROP_PAN_ID:
|
||||
g_value_set_uint(value, nm_setting_wpan_get_pan_id(setting));
|
||||
break;
|
||||
case PROP_SHORT_ADDRESS:
|
||||
g_value_set_uint(value, nm_setting_wpan_get_short_address(setting));
|
||||
break;
|
||||
case PROP_PAGE:
|
||||
g_value_set_int(value, nm_setting_wpan_get_page(setting));
|
||||
break;
|
||||
case PROP_CHANNEL:
|
||||
g_value_set_int(value, nm_setting_wpan_get_channel(setting));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
|
|
@ -260,13 +233,7 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
|
||||
static void
|
||||
nm_setting_wpan_init(NMSettingWpan *setting)
|
||||
{
|
||||
NMSettingWpanPrivate *priv = NM_SETTING_WPAN_GET_PRIVATE(setting);
|
||||
|
||||
priv->pan_id = G_MAXUINT16;
|
||||
priv->short_address = G_MAXUINT16;
|
||||
priv->channel = NM_SETTING_WPAN_CHANNEL_DEFAULT;
|
||||
}
|
||||
{}
|
||||
|
||||
/**
|
||||
* nm_setting_wpan_new:
|
||||
|
|
@ -283,16 +250,6 @@ nm_setting_wpan_new(void)
|
|||
return g_object_new(NM_TYPE_SETTING_WPAN, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize(GObject *object)
|
||||
{
|
||||
NMSettingWpanPrivate *priv = NM_SETTING_WPAN_GET_PRIVATE(object);
|
||||
|
||||
g_free(priv->mac_address);
|
||||
|
||||
G_OBJECT_CLASS(nm_setting_wpan_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_wpan_class_init(NMSettingWpanClass *klass)
|
||||
{
|
||||
|
|
@ -302,11 +259,11 @@ nm_setting_wpan_class_init(NMSettingWpanClass *klass)
|
|||
|
||||
g_type_class_add_private(setting_class, sizeof(NMSettingWpanPrivate));
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->get_property = _nm_setting_property_get_property_direct;
|
||||
object_class->set_property = set_property;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
setting_class->verify = verify;
|
||||
setting_class->verify = verify;
|
||||
setting_class->finalize_direct = TRUE;
|
||||
|
||||
/**
|
||||
* NMSettingWpan:mac-address:
|
||||
|
|
@ -321,39 +278,48 @@ nm_setting_wpan_class_init(NMSettingWpanClass *klass)
|
|||
* (e.g. 76:d8:9b:87:66:60:84:ee).
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_MAC_ADDRESS] =
|
||||
g_param_spec_string(NM_SETTING_WPAN_MAC_ADDRESS,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(
|
||||
properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WPAN_MAC_ADDRESS,
|
||||
PROP_MAC_ADDRESS,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingWpanPrivate,
|
||||
mac_address,
|
||||
/* it's special, because it uses _nm_utils_hwaddr_canonical_or_invalid(). */
|
||||
.direct_has_special_setter = TRUE);
|
||||
|
||||
/**
|
||||
* NMSettingWpan:pan-id:
|
||||
*
|
||||
* IEEE 802.15.4 Personal Area Network (PAN) identifier.
|
||||
**/
|
||||
obj_properties[PROP_PAN_ID] = g_param_spec_uint(NM_SETTING_WPAN_PAN_ID,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT16,
|
||||
G_MAXUINT16,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WPAN_PAN_ID,
|
||||
PROP_PAN_ID,
|
||||
0,
|
||||
G_MAXUINT16,
|
||||
G_MAXUINT16,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingWpanPrivate,
|
||||
pan_id);
|
||||
|
||||
/**
|
||||
* NMSettingWpan:short-address:
|
||||
*
|
||||
* Short IEEE 802.15.4 address to be used within a restricted environment.
|
||||
**/
|
||||
obj_properties[PROP_SHORT_ADDRESS] =
|
||||
g_param_spec_uint(NM_SETTING_WPAN_SHORT_ADDRESS,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT16,
|
||||
G_MAXUINT16,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WPAN_SHORT_ADDRESS,
|
||||
PROP_SHORT_ADDRESS,
|
||||
0,
|
||||
G_MAXUINT16,
|
||||
G_MAXUINT16,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingWpanPrivate,
|
||||
short_address);
|
||||
|
||||
/**
|
||||
* NMSettingWpan:page:
|
||||
|
|
@ -382,13 +348,16 @@ nm_setting_wpan_class_init(NMSettingWpanClass *klass)
|
|||
*
|
||||
* Since: 1.16
|
||||
**/
|
||||
obj_properties[PROP_CHANNEL] = g_param_spec_int(NM_SETTING_WPAN_CHANNEL,
|
||||
"",
|
||||
"",
|
||||
G_MININT16,
|
||||
G_MAXINT16,
|
||||
NM_SETTING_WPAN_CHANNEL_DEFAULT,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_int32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WPAN_CHANNEL,
|
||||
PROP_CHANNEL,
|
||||
G_MININT16,
|
||||
G_MAXINT16,
|
||||
NM_SETTING_WPAN_CHANNEL_DEFAULT,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingWpanPrivate,
|
||||
channel);
|
||||
|
||||
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue