mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-06 05:50:28 +01:00
libnm: extend nm_setting_enumerate_values() to support non-GObject base properties
While nm_setting_enumerate_values() should not be used anymore, still extend it to make it workable also for properties that are not based on GObject properties.
This commit is contained in:
parent
879820ccd5
commit
52368678d6
3 changed files with 53 additions and 29 deletions
|
|
@ -614,7 +614,8 @@ gboolean _nm_setting_sriov_sort_vfs (NMSettingSriov *setting);
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _NMSettInfoSetting NMSettInfoSetting;
|
||||
typedef struct _NMSettInfoSetting NMSettInfoSetting;
|
||||
typedef struct _NMSettInfoProperty NMSettInfoProperty;
|
||||
|
||||
typedef GVariant *(*NMSettingPropertyGetFunc) (NMSetting *setting,
|
||||
const char *property);
|
||||
|
|
@ -638,7 +639,7 @@ typedef GVariant *(*NMSettingPropertyTransformToFunc) (const GValue *from);
|
|||
typedef void (*NMSettingPropertyTransformFromFunc) (GVariant *from,
|
||||
GValue *to);
|
||||
|
||||
typedef struct {
|
||||
struct _NMSettInfoProperty {
|
||||
const char *name;
|
||||
GParamSpec *param_spec;
|
||||
const GVariantType *dbus_type;
|
||||
|
|
@ -650,7 +651,7 @@ typedef struct {
|
|||
|
||||
NMSettingPropertyTransformToFunc to_dbus;
|
||||
NMSettingPropertyTransformFromFunc from_dbus;
|
||||
} NMSettInfoProperty;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
const GVariantType *(*get_variant_type) (const struct _NMSettInfoSetting *sett_info,
|
||||
|
|
|
|||
|
|
@ -1729,6 +1729,27 @@ nm_setting_diff (NMSetting *a,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
enumerate_values (const NMSettInfoProperty *property_info,
|
||||
NMSetting *setting,
|
||||
NMSettingValueIterFn func,
|
||||
gpointer user_data)
|
||||
{
|
||||
GValue value = G_VALUE_INIT;
|
||||
|
||||
if (!property_info->param_spec)
|
||||
return;
|
||||
|
||||
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (property_info->param_spec));
|
||||
g_object_get_property (G_OBJECT (setting), property_info->param_spec->name, &value);
|
||||
func (setting,
|
||||
property_info->param_spec->name,
|
||||
&value,
|
||||
property_info->param_spec->flags,
|
||||
user_data);
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_enumerate_values:
|
||||
* @setting: the #NMSetting
|
||||
|
|
@ -1784,16 +1805,10 @@ nm_setting_enumerate_values (NMSetting *setting,
|
|||
}
|
||||
|
||||
for (i = 0; i < sett_info->property_infos_len; i++) {
|
||||
GParamSpec *prop_spec = _nm_sett_info_property_info_get_sorted (sett_info, i)->param_spec;
|
||||
GValue value = G_VALUE_INIT;
|
||||
|
||||
if (!prop_spec)
|
||||
continue;
|
||||
|
||||
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (prop_spec));
|
||||
g_object_get_property (G_OBJECT (setting), prop_spec->name, &value);
|
||||
func (setting, prop_spec->name, &value, prop_spec->flags, user_data);
|
||||
g_value_unset (&value);
|
||||
NM_SETTING_GET_CLASS (setting)->enumerate_values (_nm_sett_info_property_info_get_sorted (sett_info, i),
|
||||
setting,
|
||||
func,
|
||||
user_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2606,6 +2621,7 @@ nm_setting_class_init (NMSettingClass *setting_class)
|
|||
setting_class->compare_property = compare_property;
|
||||
setting_class->clear_secrets = clear_secrets;
|
||||
setting_class->duplicate_copy_properties = duplicate_copy_properties;
|
||||
setting_class->enumerate_values = enumerate_values;
|
||||
|
||||
/**
|
||||
* NMSetting:name:
|
||||
|
|
|
|||
|
|
@ -170,6 +170,22 @@ typedef gboolean (*NMSettingClearSecretsWithFlagsFn) (NMSetting *setting,
|
|||
|
||||
struct _NMMetaSettingInfo;
|
||||
struct _NMSettInfoSetting;
|
||||
struct _NMSettInfoProperty;
|
||||
|
||||
/**
|
||||
* NMSettingValueIterFn:
|
||||
* @setting: The setting for which properties are being iterated, given to
|
||||
* nm_setting_enumerate_values()
|
||||
* @key: The value/property name
|
||||
* @value: The property's value
|
||||
* @flags: The property's flags, like %NM_SETTING_PARAM_SECRET
|
||||
* @user_data: User data passed to nm_setting_enumerate_values()
|
||||
*/
|
||||
typedef void (*NMSettingValueIterFn) (NMSetting *setting,
|
||||
const char *key,
|
||||
const GValue *value,
|
||||
GParamFlags flags,
|
||||
gpointer user_data);
|
||||
|
||||
typedef struct {
|
||||
GObjectClass parent;
|
||||
|
|
@ -225,28 +241,19 @@ typedef struct {
|
|||
NMSetting *src,
|
||||
NMSetting *dst);
|
||||
|
||||
/*< private >*/
|
||||
void (*enumerate_values) (const struct _NMSettInfoProperty *property_info,
|
||||
NMSetting *setting,
|
||||
NMSettingValueIterFn func,
|
||||
gpointer user_data);
|
||||
|
||||
/*< private >*/
|
||||
const struct _NMMetaSettingInfo *setting_info;
|
||||
|
||||
/*< private >*/
|
||||
gpointer padding[5];
|
||||
gpointer padding[4];
|
||||
} NMSettingClass;
|
||||
|
||||
/**
|
||||
* NMSettingValueIterFn:
|
||||
* @setting: The setting for which properties are being iterated, given to
|
||||
* nm_setting_enumerate_values()
|
||||
* @key: The value/property name
|
||||
* @value: The property's value
|
||||
* @flags: The property's flags, like %NM_SETTING_PARAM_SECRET
|
||||
* @user_data: User data passed to nm_setting_enumerate_values()
|
||||
*/
|
||||
typedef void (*NMSettingValueIterFn) (NMSetting *setting,
|
||||
const char *key,
|
||||
const GValue *value,
|
||||
GParamFlags flags,
|
||||
gpointer user_data);
|
||||
|
||||
GType nm_setting_get_type (void);
|
||||
|
||||
GType nm_setting_lookup_type (const char *name);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue