diff options
Diffstat (limited to 'libnm-core/nm-setting-private.h')
| -rw-r--r-- | libnm-core/nm-setting-private.h | 130 |
1 files changed, 51 insertions, 79 deletions
diff --git a/libnm-core/nm-setting-private.h b/libnm-core/nm-setting-private.h index 1e25226e..863ea9f3 100644 --- a/libnm-core/nm-setting-private.h +++ b/libnm-core/nm-setting-private.h @@ -31,13 +31,18 @@ #include "nm-core-internal.h" -/*****************************************************************************/ +void _nm_register_setting_impl (const char *name, + GType type, + NMSettingPriority priority); + +#define _nm_register_setting(name, priority) \ + G_STMT_START { \ + _nm_register_setting_impl ("" NM_SETTING_ ## name ## _SETTING_NAME "", g_define_type_id, priority); \ + } G_STMT_END NMSettingPriority _nm_setting_get_base_type_priority (NMSetting *setting); NMSettingPriority _nm_setting_type_get_base_type_priority (GType type); -int _nm_setting_compare_priority (gconstpointer a, gconstpointer b); - -/*****************************************************************************/ +gint _nm_setting_compare_priority (gconstpointer a, gconstpointer b); typedef enum NMSettingUpdateSecretResult { NM_SETTING_UPDATE_SECRET_ERROR = FALSE, @@ -80,7 +85,10 @@ gboolean _nm_setting_clear_secrets_with_flags (NMSetting *setting, */ #define NM_SETTING_PARAM_REAPPLY_IMMEDIATELY (1 << (6 + G_PARAM_USER_SHIFT)) -#define NM_SETTING_PARAM_GENDATA_BACKED (1 << (7 + G_PARAM_USER_SHIFT)) +/* Ensure the setting's GType is registered at library load time */ +#define NM_SETTING_REGISTER_TYPE(x) \ +static void __attribute__((constructor)) register_setting (void) \ +{ g_type_ensure (x); } GVariant *_nm_setting_get_deprecated_virtual_interface_name (NMSetting *setting, NMConnection *connection, @@ -107,78 +115,44 @@ NMSetting *_nm_setting_new_from_dbus (GType setting_type, NMSettingParseFlags parse_flags, GError **error); -/*****************************************************************************/ - -static inline GArray * -_nm_sett_info_property_override_create_array (void) -{ - return g_array_new (FALSE, FALSE, sizeof (NMSettInfoProperty)); -} - -GArray *_nm_sett_info_property_override_create_array_ip_config (void); - -void _nm_setting_class_commit_full (NMSettingClass *setting_class, - NMMetaSettingType meta_type, - const NMSettInfoSettDetail *detail, - GArray *properties_override); - -static inline void -_nm_setting_class_commit (NMSettingClass *setting_class, - NMMetaSettingType meta_type) -{ - _nm_setting_class_commit_full (setting_class, meta_type, NULL, NULL); -} - -#define NM_SETT_INFO_SETT_GENDATA(...) \ - ({ \ - static const NMSettInfoSettGendata _g = { \ - __VA_ARGS__ \ - }; \ - \ - &_g; \ - }) - -#define NM_SETT_INFO_SETT_DETAIL(...) \ - (&((const NMSettInfoSettDetail) { \ - __VA_ARGS__ \ - })) - -#define NM_SETT_INFO_PROPERTY(...) \ - (&((const NMSettInfoProperty) { \ - __VA_ARGS__ \ - })) - -void _properties_override_add_struct (GArray *properties_override, - const NMSettInfoProperty *prop_info); - -void _properties_override_add__helper (GArray *properties_override, - NMSettInfoProperty *prop_info); - -#define _properties_override_add(properties_override, \ - ...) \ - (_properties_override_add_struct (properties_override, \ - NM_SETT_INFO_PROPERTY (__VA_ARGS__))) - -void _properties_override_add_dbus_only (GArray *properties_override, - const char *property_name, - const GVariantType *dbus_type, - NMSettingPropertySynthFunc synth_func, - NMSettingPropertySetFunc set_func); - -void _properties_override_add_override (GArray *properties_override, - GParamSpec *param_spec, - const GVariantType *dbus_type, - NMSettingPropertyGetFunc get_func, - NMSettingPropertySetFunc set_func, - NMSettingPropertyNotSetFunc not_set_func); - -void _properties_override_add_transform (GArray *properties_override, - GParamSpec *param_spec, - const GVariantType *dbus_type, - NMSettingPropertyTransformToFunc to_dbus, - NMSettingPropertyTransformFromFunc from_dbus); - -/*****************************************************************************/ +typedef GVariant * (*NMSettingPropertyGetFunc) (NMSetting *setting, + const char *property); +typedef GVariant * (*NMSettingPropertySynthFunc) (NMSetting *setting, + NMConnection *connection, + const char *property); +typedef gboolean (*NMSettingPropertySetFunc) (NMSetting *setting, + GVariant *connection_dict, + const char *property, + GVariant *value, + NMSettingParseFlags parse_flags, + GError **error); +typedef gboolean (*NMSettingPropertyNotSetFunc) (NMSetting *setting, + GVariant *connection_dict, + const char *property, + NMSettingParseFlags parse_flags, + GError **error); + +void _nm_setting_class_add_dbus_only_property (NMSettingClass *setting_class, + const char *property_name, + const GVariantType *dbus_type, + NMSettingPropertySynthFunc synth_func, + NMSettingPropertySetFunc set_func); + +void _nm_setting_class_override_property (NMSettingClass *setting_class, + const char *property_name, + const GVariantType *dbus_type, + NMSettingPropertyGetFunc get_func, + NMSettingPropertySetFunc set_func, + NMSettingPropertyNotSetFunc not_set_func); + +typedef GVariant * (*NMSettingPropertyTransformToFunc) (const GValue *from); +typedef void (*NMSettingPropertyTransformFromFunc) (GVariant *from, GValue *to); + +void _nm_setting_class_transform_property (NMSettingClass *setting_class, + const char *property_name, + const GVariantType *dbus_type, + NMSettingPropertyTransformToFunc to_dbus, + NMSettingPropertyTransformFromFunc from_dbus); gboolean _nm_setting_use_legacy_property (NMSetting *setting, GVariant *connection_dict, @@ -187,6 +161,4 @@ gboolean _nm_setting_use_legacy_property (NMSetting *setting, GPtrArray *_nm_setting_need_secrets (NMSetting *setting); -/*****************************************************************************/ - #endif /* NM_SETTING_PRIVATE_H */ |