From 6d12d2f3a08609539dae93e0767d288816b35c4e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 12 Apr 2017 10:13:41 +0200 Subject: [PATCH] cli: move setting creation to meta data --- clients/cli/connections.c | 85 +++++-------- clients/cli/settings.c | 68 ----------- clients/cli/settings.h | 1 - clients/common/nm-meta-setting-access.c | 20 +++ clients/common/nm-meta-setting-access.h | 3 + clients/common/nm-meta-setting-desc.c | 155 +++++++++++++++++++++++- clients/common/nm-meta-setting-desc.h | 9 ++ 7 files changed, 216 insertions(+), 125 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index dd7cfc5261..cdc20578aa 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -495,22 +495,6 @@ usage_connection_export (void) "The data are directed to standard output or to a file if a name is given.\n\n")); } -static NMSetting * -nmc_setting_new_for_name (const char *name) -{ - GType stype; - NMSetting *setting = NULL; - - if (name) { - stype = nm_setting_lookup_type (name); - if (stype != G_TYPE_INVALID) { - setting = g_object_new (stype, NULL); - g_warn_if_fail (NM_IS_SETTING (setting)); - } - } - return setting; -} - static void quit (void) { @@ -3531,16 +3515,8 @@ set_property (NMConnection *connection, setting = nm_connection_get_setting_by_name (connection, setting_name); if (!setting) { - setting = nmc_setting_new_for_name (setting_name); - if (!setting) { - g_assert (FALSE); - /* This should really not happen */ - g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_UNKNOWN, - _("Error: don't know how to create '%s' setting."), - setting_name); - return FALSE; - } - nmc_setting_custom_init (setting); + setting = nm_meta_setting_info_editor_new_setting (nm_meta_setting_info_editor_find_by_name (setting_name, FALSE), + NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI); nm_connection_add_setting (connection, setting); } @@ -3675,11 +3651,9 @@ ensure_settings (NMConnection *connection, const NMMetaSettingValidPartItem *con continue; if (nm_connection_get_setting_by_name (connection, (*item)->setting_info->general->setting_name)) continue; - setting = nmc_setting_new_for_name ((*item)->setting_info->general->setting_name); - if (setting) { - nmc_setting_custom_init (setting); - nm_connection_add_setting (connection, setting); - } + setting = nm_meta_setting_info_editor_new_setting ((*item)->setting_info, + NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI); + nm_connection_add_setting (connection, setting); } } @@ -3926,8 +3900,8 @@ set_bluetooth_type (NmCli *nmc, NMConnection *con, const OptionInfo *option, con if ( !strcmp (value, NM_SETTING_BLUETOOTH_TYPE_DUN) || !strcmp (value, NM_SETTING_BLUETOOTH_TYPE_DUN"-gsm")) { value = NM_SETTING_BLUETOOTH_TYPE_DUN; - setting = nm_setting_gsm_new (); - nmc_setting_custom_init (setting); + setting = nm_meta_setting_info_editor_new_setting (&nm_meta_setting_infos_editor[NM_META_SETTING_TYPE_GSM], + NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI); nm_connection_add_setting (con, setting); } else if (!strcmp (value, NM_SETTING_BLUETOOTH_TYPE_DUN"-cdma")) { value = NM_SETTING_BLUETOOTH_TYPE_DUN; @@ -5066,7 +5040,8 @@ gen_property_names (const char *text, int state) valid_settings_main, valid_settings_slave, NULL); - setting = nmc_setting_new_for_name (setting_name); + setting = nm_meta_setting_info_editor_new_setting (nm_meta_setting_info_editor_find_by_name (setting_name, FALSE), + NM_META_ACCESSOR_SETTING_INIT_TYPE_DEFAULT); } else { /* Else take the current setting, if any */ setting = nmc_tab_completion.setting ? g_object_ref (nmc_tab_completion.setting) : NULL; @@ -5366,7 +5341,8 @@ get_setting_and_property (const char *prompt, const char *line, setting_name = check_valid_name (sett, valid_settings_main, valid_settings_slave, NULL); - setting = nmc_setting_new_for_name (setting_name); + setting = nm_meta_setting_info_editor_new_setting (nm_meta_setting_info_editor_find_by_name (setting_name, FALSE), + NM_META_ACCESSOR_SETTING_INIT_TYPE_DEFAULT); } else setting = nmc_tab_completion.setting ? g_object_ref (nmc_tab_completion.setting) : NULL; @@ -6570,10 +6546,8 @@ create_setting_by_name (const char *name, const NMMetaSettingValidPartItem *cons setting_name = check_valid_name (name, valid_settings_main, valid_settings_slave, NULL); if (setting_name) { - setting = nmc_setting_new_for_name (setting_name); - if (!setting) - return NULL; /* This should really not happen */ - nmc_setting_custom_init (setting); + setting = nm_meta_setting_info_editor_new_setting (nm_meta_setting_info_editor_find_by_name (setting_name, FALSE), + NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI); } return setting; } @@ -6912,12 +6886,16 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t setting = nm_connection_get_setting_by_name (connection, setting_name); if (!setting) { - setting = nmc_setting_new_for_name (setting_name); - if (!setting) { + const NMMetaSettingInfoEditor *setting_info; + + setting_info = nm_meta_setting_info_editor_find_by_name (setting_name, FALSE); + if (!setting_info) { g_print (_("Error: unknown setting '%s'\n"), setting_name); break; } - nmc_setting_custom_init (setting); + + setting = nm_meta_setting_info_editor_new_setting (setting_info, + NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI); if (NM_IS_SETTING_WIRELESS (setting)) nmc_setting_wireless_connect_handlers (NM_SETTING_WIRELESS (setting)); @@ -7548,11 +7526,14 @@ editor_init_new_connection (NmCli *nmc, NMConnection *connection) NM_SETTING_CONNECTION_SLAVE_TYPE, slave_type, NULL); } else { + const NMMetaSettingInfoEditor *setting_info; + /* Add a "base" setting to the connection by default */ - base_setting = nmc_setting_new_for_name (con_type); - if (!base_setting) + setting_info = nm_meta_setting_info_editor_find_by_name (con_type, FALSE); + if (!setting_info) return; - nmc_setting_custom_init (base_setting); + base_setting = nm_meta_setting_info_editor_new_setting (setting_info, + NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI); nm_connection_add_setting (connection, base_setting); set_default_interface_name (nmc, s_con); @@ -7567,18 +7548,16 @@ editor_init_new_connection (NmCli *nmc, NMConnection *connection) } - /* Always add IPv4 and IPv6 settings for non-slave connections */ - setting = nm_setting_ip4_config_new (); - nmc_setting_custom_init (setting); + setting = nm_meta_setting_info_editor_new_setting (&nm_meta_setting_infos_editor[NM_META_SETTING_TYPE_IP4_CONFIG], + NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI); nm_connection_add_setting (connection, setting); - setting = nm_setting_ip6_config_new (); - nmc_setting_custom_init (setting); + setting = nm_meta_setting_info_editor_new_setting (&nm_meta_setting_infos_editor[NM_META_SETTING_TYPE_IP6_CONFIG], + NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI); nm_connection_add_setting (connection, setting); - /* Also Proxy Setting */ - setting = nm_setting_proxy_new (); - nmc_setting_custom_init (setting); + setting = nm_meta_setting_info_editor_new_setting (&nm_meta_setting_infos_editor[NM_META_SETTING_TYPE_PROXY], + NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI); nm_connection_add_setting (connection, setting); } } diff --git a/clients/cli/settings.c b/clients/cli/settings.c index f3372da943..0f18ec7f67 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -304,74 +304,6 @@ nmc_setting_connection_connect_handlers (NMSettingConnection *setting, NMConnect G_CALLBACK (connection_master_changed_cb), connection); } -/* - * Customize some properties of the setting so that the setting has sensible - * values. - */ -void -nmc_setting_custom_init (NMSetting *setting) -{ - g_return_if_fail (NM_IS_SETTING (setting)); - - if (NM_IS_SETTING_VLAN (setting)) { - /* Set sensible initial VLAN values */ - g_object_set (NM_SETTING_VLAN (setting), - NM_SETTING_VLAN_ID, 1, - NULL); - } else if (NM_IS_SETTING_INFINIBAND (setting)) { - /* Initialize 'transport-mode' so that 'infiniband' is valid */ - g_object_set (NM_SETTING_INFINIBAND (setting), - NM_SETTING_INFINIBAND_TRANSPORT_MODE, "datagram", - NULL); - } else if (NM_IS_SETTING_CDMA (setting)) { - /* Initialize 'number' so that 'cdma' is valid */ - g_object_set (NM_SETTING_CDMA (setting), - NM_SETTING_CDMA_NUMBER, "#777", - NULL); - } else if (NM_IS_SETTING_GSM (setting)) { - /* Initialize 'number' so that 'gsm' is valid */ - g_object_set (NM_SETTING_GSM (setting), - NM_SETTING_GSM_NUMBER, "*99#", - NULL); - } else if (NM_IS_SETTING_OLPC_MESH (setting)) { - g_object_set (NM_SETTING_OLPC_MESH (setting), - NM_SETTING_OLPC_MESH_CHANNEL, 1, - NULL); - } else if (NM_IS_SETTING_WIRELESS (setting)) { - /* For Wi-Fi set mode to "infrastructure". Even though mode == NULL - * is regarded as "infrastructure", explicit value makes no doubts. - */ - g_object_set (NM_SETTING_WIRELESS (setting), - NM_SETTING_WIRELESS_MODE, NM_SETTING_WIRELESS_MODE_INFRA, - NULL); - } else if (NM_IS_SETTING_ADSL (setting)) { - /* Initialize a protocol */ - g_object_set (NM_SETTING_ADSL (setting), - NM_SETTING_ADSL_PROTOCOL, NM_SETTING_ADSL_PROTOCOL_PPPOE, - NULL); - } else if (NM_IS_SETTING_IP4_CONFIG (setting)) { - g_object_set (NM_SETTING_IP_CONFIG (setting), - NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, - NULL); - } else if (NM_IS_SETTING_IP6_CONFIG (setting)) { - g_object_set (NM_SETTING_IP_CONFIG (setting), - NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, - NULL); - } else if (NM_IS_SETTING_PROXY (setting)) { - g_object_set (NM_SETTING_PROXY (setting), - NM_SETTING_PROXY_METHOD, (int) NM_SETTING_PROXY_METHOD_NONE, - NULL); - } else if (NM_IS_SETTING_TUN (setting)) { - g_object_set (NM_SETTING_TUN (setting), - NM_SETTING_TUN_MODE, NM_SETTING_TUN_MODE_TUN, - NULL); - } else if (NM_IS_SETTING_BLUETOOTH (setting)) { - g_object_set (NM_SETTING_BLUETOOTH (setting), - NM_SETTING_BLUETOOTH_TYPE, NM_SETTING_BLUETOOTH_TYPE_PANU, - NULL); - } -} - /*****************************************************************************/ static gboolean diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 0125a78269..7dad622bf8 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -27,7 +27,6 @@ /*****************************************************************************/ -void nmc_setting_custom_init (NMSetting *setting); void nmc_setting_ip4_connect_handlers (NMSettingIPConfig *setting); void nmc_setting_ip6_connect_handlers (NMSettingIPConfig *setting); void nmc_setting_proxy_connect_handlers (NMSettingProxy *setting); diff --git a/clients/common/nm-meta-setting-access.c b/clients/common/nm-meta-setting-access.c index e53513e9c4..4b5f82d3e4 100644 --- a/clients/common/nm-meta-setting-access.c +++ b/clients/common/nm-meta-setting-access.c @@ -148,6 +148,26 @@ nm_meta_property_info_find_by_setting (NMSetting *setting, const char *property_ return property_info; } +NMSetting * +nm_meta_setting_info_editor_new_setting (const NMMetaSettingInfoEditor *setting_info, + NMMetaAccessorSettingInitType init_type) +{ + NMSetting *setting; + + g_return_val_if_fail (setting_info, NULL); + + setting = g_object_new (setting_info->general->get_setting_gtype (), NULL); + + if ( setting_info->setting_init_fcn + && init_type != NM_META_ACCESSOR_SETTING_INIT_TYPE_DEFAULT) { + setting_info->setting_init_fcn (setting_info, + setting, + init_type); + } + + return setting; +} + /*****************************************************************************/ /* this basically returns NMMetaSettingType.properties, but with type diff --git a/clients/common/nm-meta-setting-access.h b/clients/common/nm-meta-setting-access.h index 0479d03c2b..9863a96f14 100644 --- a/clients/common/nm-meta-setting-access.h +++ b/clients/common/nm-meta-setting-access.h @@ -25,6 +25,9 @@ /*****************************************************************************/ +NMSetting *nm_meta_setting_info_editor_new_setting (const NMMetaSettingInfoEditor *setting_info, + NMMetaAccessorSettingInitType init_type); + const NMMetaSettingInfoEditor *nm_meta_setting_info_editor_find_by_name (const char *setting_name, gboolean use_alias); const NMMetaSettingInfoEditor *nm_meta_setting_info_editor_find_by_gtype (GType gtype); const NMMetaSettingInfoEditor *nm_meta_setting_info_editor_find_by_setting (NMSetting *setting); diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c index ddcce8c04e..981ecddf30 100644 --- a/clients/common/nm-meta-setting-desc.c +++ b/clients/common/nm-meta-setting-desc.c @@ -529,6 +529,9 @@ _env_warn_fcn (const NMMetaEnvironment *environment, #define ARGS_VALUES_FCN \ const NMMetaPropertyInfo *property_info, char ***out_to_free +#define ARGS_SETTING_INIT_FCN \ + const NMMetaSettingInfoEditor *setting_info, NMSetting *setting, NMMetaAccessorSettingInitType init_type + #define RETURN_UNSUPPORTED_GET_TYPE() \ G_STMT_START { \ if (!NM_IN_SET (get_type, \ @@ -7213,6 +7216,137 @@ static const NMMetaPropertyInfo property_infos_WIRELESS_SECURITY[] = { }, }; +/*****************************************************************************/ + +static void +_setting_init_fcn_adsl (ARGS_SETTING_INIT_FCN) +{ + if (init_type == NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI) { + /* Initialize a protocol */ + g_object_set (NM_SETTING_ADSL (setting), + NM_SETTING_ADSL_PROTOCOL, NM_SETTING_ADSL_PROTOCOL_PPPOE, + NULL); + } +} + +static void +_setting_init_fcn_bluetooth (ARGS_SETTING_INIT_FCN) +{ + if (init_type == NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI) { + g_object_set (NM_SETTING_BLUETOOTH (setting), + NM_SETTING_BLUETOOTH_TYPE, NM_SETTING_BLUETOOTH_TYPE_PANU, + NULL); + } +} + +static void +_setting_init_fcn_cdma (ARGS_SETTING_INIT_FCN) +{ + if (init_type == NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI) { + /* Initialize 'number' so that 'cdma' is valid */ + g_object_set (NM_SETTING_CDMA (setting), + NM_SETTING_CDMA_NUMBER, "#777", + NULL); + } +} + +static void +_setting_init_fcn_gsm (ARGS_SETTING_INIT_FCN) +{ + if (init_type == NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI) { + /* Initialize 'number' so that 'gsm' is valid */ + g_object_set (NM_SETTING_GSM (setting), + NM_SETTING_GSM_NUMBER, "*99#", + NULL); + } +} + +static void +_setting_init_fcn_infiniband (ARGS_SETTING_INIT_FCN) +{ + if (init_type == NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI) { + /* Initialize 'transport-mode' so that 'infiniband' is valid */ + g_object_set (NM_SETTING_INFINIBAND (setting), + NM_SETTING_INFINIBAND_TRANSPORT_MODE, "datagram", + NULL); + } +} + +static void +_setting_init_fcn_ip4_config (ARGS_SETTING_INIT_FCN) +{ + if (init_type == NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI) { + g_object_set (NM_SETTING_IP_CONFIG (setting), + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, + NULL); + } +} + +static void +_setting_init_fcn_ip6_config (ARGS_SETTING_INIT_FCN) +{ + if (init_type == NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI) { + g_object_set (NM_SETTING_IP_CONFIG (setting), + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, + NULL); + } +} + +static void +_setting_init_fcn_olpc_mesh (ARGS_SETTING_INIT_FCN) +{ + if (init_type == NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI) { + g_object_set (NM_SETTING_OLPC_MESH (setting), + NM_SETTING_OLPC_MESH_CHANNEL, 1, + NULL); + } +} + +static void +_setting_init_fcn_proxy (ARGS_SETTING_INIT_FCN) +{ + if (init_type == NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI) { + g_object_set (NM_SETTING_PROXY (setting), + NM_SETTING_PROXY_METHOD, (int) NM_SETTING_PROXY_METHOD_NONE, + NULL); + } +} + +static void +_setting_init_fcn_tun (ARGS_SETTING_INIT_FCN) +{ + if (init_type == NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI) { + g_object_set (NM_SETTING_TUN (setting), + NM_SETTING_TUN_MODE, NM_SETTING_TUN_MODE_TUN, + NULL); + } +} + +static void +_setting_init_fcn_vlan (ARGS_SETTING_INIT_FCN) +{ + if (init_type == NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI) { + g_object_set (setting, + NM_SETTING_VLAN_ID, 1, + NULL); + } +} + +static void +_setting_init_fcn_wireless (ARGS_SETTING_INIT_FCN) +{ + if (init_type == NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI) { + /* For Wi-Fi set mode to "infrastructure". Even though mode == NULL + * is regarded as "infrastructure", explicit value makes no doubts. + */ + g_object_set (NM_SETTING_WIRELESS (setting), + NM_SETTING_WIRELESS_MODE, NM_SETTING_WIRELESS_MODE_INFRA, + NULL); + } +} + +/*****************************************************************************/ + #define SETTING_PRETTY_NAME_802_1X "802-1x settings" #define SETTING_PRETTY_NAME_ADSL "ADSL connection" #define SETTING_PRETTY_NAME_BLUETOOTH "bluetooth connection" @@ -7280,12 +7414,14 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = { NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE), NM_META_SETTING_VALID_PART_ITEM (ADSL, TRUE), ), + .setting_init_fcn = _setting_init_fcn_adsl, ), SETTING_INFO (BLUETOOTH, .valid_parts = NM_META_SETTING_VALID_PARTS ( NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE), NM_META_SETTING_VALID_PART_ITEM (BLUETOOTH, TRUE), ), + .setting_init_fcn = _setting_init_fcn_bluetooth, ), SETTING_INFO (BOND, .valid_parts = NM_META_SETTING_VALID_PARTS ( @@ -7309,6 +7445,7 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = { NM_META_SETTING_VALID_PART_ITEM (SERIAL, FALSE), NM_META_SETTING_VALID_PART_ITEM (PPP, FALSE), ), + .setting_init_fcn = _setting_init_fcn_cdma, ), SETTING_INFO (CONNECTION), SETTING_INFO (DCB), @@ -7332,15 +7469,21 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = { NM_META_SETTING_VALID_PART_ITEM (SERIAL, FALSE), NM_META_SETTING_VALID_PART_ITEM (PPP, FALSE), ), + .setting_init_fcn = _setting_init_fcn_gsm, ), SETTING_INFO (INFINIBAND, .valid_parts = NM_META_SETTING_VALID_PARTS ( NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE), NM_META_SETTING_VALID_PART_ITEM (INFINIBAND, TRUE), ), + .setting_init_fcn = _setting_init_fcn_infiniband, + ), + SETTING_INFO (IP4_CONFIG, + .setting_init_fcn = _setting_init_fcn_ip4_config, + ), + SETTING_INFO (IP6_CONFIG, + .setting_init_fcn = _setting_init_fcn_ip6_config, ), - SETTING_INFO (IP4_CONFIG), - SETTING_INFO (IP6_CONFIG), SETTING_INFO (IP_TUNNEL, .valid_parts = NM_META_SETTING_VALID_PARTS ( NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE), @@ -7368,6 +7511,7 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = { NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE), NM_META_SETTING_VALID_PART_ITEM (OLPC_MESH, TRUE), ), + .setting_init_fcn = _setting_init_fcn_olpc_mesh, ), SETTING_INFO (PPPOE, /* PPPoE is a base connection type from historical reasons. @@ -7382,7 +7526,9 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = { ), ), SETTING_INFO (PPP), - SETTING_INFO (PROXY), + SETTING_INFO (PROXY, + .setting_init_fcn = _setting_init_fcn_proxy, + ), SETTING_INFO (SERIAL), SETTING_INFO (TEAM, .valid_parts = NM_META_SETTING_VALID_PARTS ( @@ -7398,6 +7544,7 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = { NM_META_SETTING_VALID_PART_ITEM (TUN, TRUE), NM_META_SETTING_VALID_PART_ITEM (WIRED, FALSE), ), + .setting_init_fcn = _setting_init_fcn_tun, ), SETTING_INFO_EMPTY (USER), SETTING_INFO (VLAN, @@ -7406,6 +7553,7 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = { NM_META_SETTING_VALID_PART_ITEM (VLAN, TRUE), NM_META_SETTING_VALID_PART_ITEM (WIRED, FALSE), ), + .setting_init_fcn = _setting_init_fcn_vlan, ), SETTING_INFO (VPN, .valid_parts = NM_META_SETTING_VALID_PARTS ( @@ -7443,6 +7591,7 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = { NM_META_SETTING_VALID_PART_ITEM (WIRELESS_SECURITY, FALSE), NM_META_SETTING_VALID_PART_ITEM (802_1X, FALSE), ), + .setting_init_fcn = _setting_init_fcn_wireless, ), SETTING_INFO (WIRELESS_SECURITY, .alias = "wifi-sec", diff --git a/clients/common/nm-meta-setting-desc.h b/clients/common/nm-meta-setting-desc.h index 859f453d2f..cfacd347bf 100644 --- a/clients/common/nm-meta-setting-desc.h +++ b/clients/common/nm-meta-setting-desc.h @@ -108,6 +108,11 @@ typedef enum { NM_META_ACCESSOR_GET_TYPE_TERMFORMAT, } NMMetaAccessorGetType; +typedef enum { + NM_META_ACCESSOR_SETTING_INIT_TYPE_DEFAULT, + NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI, +} NMMetaAccessorSettingInitType; + static inline void nm_meta_termformat_unpack (gconstpointer value, NMMetaTermColor *out_color, NMMetaTermFormat *out_format) { @@ -310,6 +315,10 @@ struct _NMMetaSettingInfoEditor { * don't have valid_settings but are usually referenced by other * settings to be valid for them. */ const NMMetaSettingValidPartItem *const*valid_parts; + + void (*setting_init_fcn) (const NMMetaSettingInfoEditor *setting_info, + NMSetting *setting, + NMMetaAccessorSettingInitType init_type); }; struct _NMMetaType {