libnm: add property_type argument to _nm_setting_property_define_direct_strv

The purpose of this is to allow overriding to_dbus_fcn and from_dbus_fcn when
necessary (such as for special behavior regarding a deprecated/aliased properties).
This commit is contained in:
Jan Vaclav
2024-02-19 14:39:25 +01:00
committed by Fernando Fernandez Mancera
parent 8f9ed29e2c
commit ec91aa3c70
4 changed files with 38 additions and 30 deletions

View File

@@ -2751,6 +2751,7 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass)
NM_SETTING_CONNECTION_SECONDARIES, NM_SETTING_CONNECTION_SECONDARIES,
PROP_SECONDARIES, PROP_SECONDARIES,
NM_SETTING_PARAM_FUZZY_IGNORE, NM_SETTING_PARAM_FUZZY_IGNORE,
NULL,
NMSettingConnectionPrivate, NMSettingConnectionPrivate,
secondaries); secondaries);

View File

@@ -739,6 +739,7 @@ nm_setting_match_class_init(NMSettingMatchClass *klass)
NM_SETTING_MATCH_INTERFACE_NAME, NM_SETTING_MATCH_INTERFACE_NAME,
PROP_INTERFACE_NAME, PROP_INTERFACE_NAME,
NM_SETTING_PARAM_FUZZY_IGNORE, NM_SETTING_PARAM_FUZZY_IGNORE,
NULL,
NMSettingMatch, NMSettingMatch,
interface_name); interface_name);
@@ -764,6 +765,7 @@ nm_setting_match_class_init(NMSettingMatchClass *klass)
NM_SETTING_MATCH_KERNEL_COMMAND_LINE, NM_SETTING_MATCH_KERNEL_COMMAND_LINE,
PROP_KERNEL_COMMAND_LINE, PROP_KERNEL_COMMAND_LINE,
NM_SETTING_PARAM_FUZZY_IGNORE, NM_SETTING_PARAM_FUZZY_IGNORE,
NULL,
NMSettingMatch, NMSettingMatch,
kernel_command_line); kernel_command_line);
@@ -783,6 +785,7 @@ nm_setting_match_class_init(NMSettingMatchClass *klass)
NM_SETTING_MATCH_DRIVER, NM_SETTING_MATCH_DRIVER,
PROP_DRIVER, PROP_DRIVER,
NM_SETTING_PARAM_FUZZY_IGNORE, NM_SETTING_PARAM_FUZZY_IGNORE,
NULL,
NMSettingMatch, NMSettingMatch,
driver); driver);
@@ -824,6 +827,7 @@ nm_setting_match_class_init(NMSettingMatchClass *klass)
NM_SETTING_MATCH_PATH, NM_SETTING_MATCH_PATH,
PROP_PATH, PROP_PATH,
NM_SETTING_PARAM_FUZZY_IGNORE, NM_SETTING_PARAM_FUZZY_IGNORE,
NULL,
NMSettingMatch, NMSettingMatch,
path); path);

View File

@@ -869,36 +869,38 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p
/*****************************************************************************/ /*****************************************************************************/
#define _nm_setting_property_define_direct_strv(properties_override, \ #define _nm_setting_property_define_direct_strv(properties_override, \
obj_properties, \ obj_properties, \
prop_name, \ prop_name, \
prop_id, \ prop_id, \
param_flags, \ param_flags, \
private_struct_type, \ property_type, \
private_struct_field, \ private_struct_type, \
... /* extra NMSettInfoProperty fields */) \ private_struct_field, \
({ \ ... /* extra NMSettInfoProperty fields */) \
GParamSpec *_param_spec; \ ({ \
\ GParamSpec *_param_spec; \
G_STATIC_ASSERT(!NM_FLAGS_ANY((param_flags), ~(NM_SETTING_PARAM_FUZZY_IGNORE))); \ const NMSettInfoPropertType *_property_type; \
\ G_STATIC_ASSERT(!NM_FLAGS_ANY((param_flags), ~(NM_SETTING_PARAM_FUZZY_IGNORE))); \
_param_spec = g_param_spec_boxed("" prop_name "", \ \
"", \ _param_spec = g_param_spec_boxed("" prop_name "", \
"", \ "", \
G_TYPE_STRV, \ "", \
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY \ G_TYPE_STRV, \
| G_PARAM_STATIC_STRINGS | (param_flags)); \ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY \
\ | G_PARAM_STATIC_STRINGS | (param_flags)); \
(obj_properties)[(prop_id)] = _param_spec; \ \
\ (obj_properties)[(prop_id)] = _param_spec; \
_nm_properties_override_gobj((properties_override), \ _property_type = (property_type) ?: &nm_sett_info_propert_type_direct_strv; \
_param_spec, \ \
&nm_sett_info_propert_type_direct_strv, \ _nm_properties_override_gobj((properties_override), \
.direct_offset = \ _param_spec, \
NM_STRUCT_OFFSET_ENSURE_TYPE(NMValueStrv, \ _property_type, \
private_struct_type, \ .direct_offset = \
private_struct_field), \ NM_STRUCT_OFFSET_ENSURE_TYPE(NMValueStrv, \
__VA_ARGS__); \ private_struct_type, \
private_struct_field), \
__VA_ARGS__); \
}) })
/*****************************************************************************/ /*****************************************************************************/

View File

@@ -1717,6 +1717,7 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass)
NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST, NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST,
PROP_MAC_ADDRESS_BLACKLIST, PROP_MAC_ADDRESS_BLACKLIST,
NM_SETTING_PARAM_FUZZY_IGNORE, NM_SETTING_PARAM_FUZZY_IGNORE,
NULL,
NMSettingWirelessPrivate, NMSettingWirelessPrivate,
mac_address_blacklist, mac_address_blacklist,
.direct_set_strv_normalize_hwaddr = TRUE, .direct_set_strv_normalize_hwaddr = TRUE,