mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-05 07:40:49 +00:00
cli: move setting creation to meta data
This commit is contained in:
parent
b629b98687
commit
6d12d2f3a0
|
@ -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"));
|
"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
|
static void
|
||||||
quit (void)
|
quit (void)
|
||||||
{
|
{
|
||||||
|
@ -3531,16 +3515,8 @@ set_property (NMConnection *connection,
|
||||||
|
|
||||||
setting = nm_connection_get_setting_by_name (connection, setting_name);
|
setting = nm_connection_get_setting_by_name (connection, setting_name);
|
||||||
if (!setting) {
|
if (!setting) {
|
||||||
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),
|
||||||
if (!setting) {
|
NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI);
|
||||||
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);
|
|
||||||
nm_connection_add_setting (connection, setting);
|
nm_connection_add_setting (connection, setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3675,12 +3651,10 @@ ensure_settings (NMConnection *connection, const NMMetaSettingValidPartItem *con
|
||||||
continue;
|
continue;
|
||||||
if (nm_connection_get_setting_by_name (connection, (*item)->setting_info->general->setting_name))
|
if (nm_connection_get_setting_by_name (connection, (*item)->setting_info->general->setting_name))
|
||||||
continue;
|
continue;
|
||||||
setting = nmc_setting_new_for_name ((*item)->setting_info->general->setting_name);
|
setting = nm_meta_setting_info_editor_new_setting ((*item)->setting_info,
|
||||||
if (setting) {
|
NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI);
|
||||||
nmc_setting_custom_init (setting);
|
|
||||||
nm_connection_add_setting (connection, setting);
|
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)
|
if ( !strcmp (value, NM_SETTING_BLUETOOTH_TYPE_DUN)
|
||||||
|| !strcmp (value, NM_SETTING_BLUETOOTH_TYPE_DUN"-gsm")) {
|
|| !strcmp (value, NM_SETTING_BLUETOOTH_TYPE_DUN"-gsm")) {
|
||||||
value = NM_SETTING_BLUETOOTH_TYPE_DUN;
|
value = NM_SETTING_BLUETOOTH_TYPE_DUN;
|
||||||
setting = nm_setting_gsm_new ();
|
setting = nm_meta_setting_info_editor_new_setting (&nm_meta_setting_infos_editor[NM_META_SETTING_TYPE_GSM],
|
||||||
nmc_setting_custom_init (setting);
|
NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI);
|
||||||
nm_connection_add_setting (con, setting);
|
nm_connection_add_setting (con, setting);
|
||||||
} else if (!strcmp (value, NM_SETTING_BLUETOOTH_TYPE_DUN"-cdma")) {
|
} else if (!strcmp (value, NM_SETTING_BLUETOOTH_TYPE_DUN"-cdma")) {
|
||||||
value = NM_SETTING_BLUETOOTH_TYPE_DUN;
|
value = NM_SETTING_BLUETOOTH_TYPE_DUN;
|
||||||
|
@ -5066,7 +5040,8 @@ gen_property_names (const char *text, int state)
|
||||||
valid_settings_main,
|
valid_settings_main,
|
||||||
valid_settings_slave,
|
valid_settings_slave,
|
||||||
NULL);
|
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 {
|
||||||
/* Else take the current setting, if any */
|
/* Else take the current setting, if any */
|
||||||
setting = nmc_tab_completion.setting ? g_object_ref (nmc_tab_completion.setting) : NULL;
|
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,
|
setting_name = check_valid_name (sett, valid_settings_main,
|
||||||
valid_settings_slave, NULL);
|
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
|
||||||
setting = nmc_tab_completion.setting ? g_object_ref (nmc_tab_completion.setting) : NULL;
|
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);
|
setting_name = check_valid_name (name, valid_settings_main, valid_settings_slave, NULL);
|
||||||
|
|
||||||
if (setting_name) {
|
if (setting_name) {
|
||||||
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),
|
||||||
if (!setting)
|
NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI);
|
||||||
return NULL; /* This should really not happen */
|
|
||||||
nmc_setting_custom_init (setting);
|
|
||||||
}
|
}
|
||||||
return setting;
|
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);
|
setting = nm_connection_get_setting_by_name (connection, setting_name);
|
||||||
if (!setting) {
|
if (!setting) {
|
||||||
setting = nmc_setting_new_for_name (setting_name);
|
const NMMetaSettingInfoEditor *setting_info;
|
||||||
if (!setting) {
|
|
||||||
|
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);
|
g_print (_("Error: unknown setting '%s'\n"), setting_name);
|
||||||
break;
|
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))
|
if (NM_IS_SETTING_WIRELESS (setting))
|
||||||
nmc_setting_wireless_connect_handlers (NM_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,
|
NM_SETTING_CONNECTION_SLAVE_TYPE, slave_type,
|
||||||
NULL);
|
NULL);
|
||||||
} else {
|
} else {
|
||||||
|
const NMMetaSettingInfoEditor *setting_info;
|
||||||
|
|
||||||
/* Add a "base" setting to the connection by default */
|
/* Add a "base" setting to the connection by default */
|
||||||
base_setting = nmc_setting_new_for_name (con_type);
|
setting_info = nm_meta_setting_info_editor_find_by_name (con_type, FALSE);
|
||||||
if (!base_setting)
|
if (!setting_info)
|
||||||
return;
|
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);
|
nm_connection_add_setting (connection, base_setting);
|
||||||
|
|
||||||
set_default_interface_name (nmc, s_con);
|
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_meta_setting_info_editor_new_setting (&nm_meta_setting_infos_editor[NM_META_SETTING_TYPE_IP4_CONFIG],
|
||||||
setting = nm_setting_ip4_config_new ();
|
NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI);
|
||||||
nmc_setting_custom_init (setting);
|
|
||||||
nm_connection_add_setting (connection, setting);
|
nm_connection_add_setting (connection, setting);
|
||||||
|
|
||||||
setting = nm_setting_ip6_config_new ();
|
setting = nm_meta_setting_info_editor_new_setting (&nm_meta_setting_infos_editor[NM_META_SETTING_TYPE_IP6_CONFIG],
|
||||||
nmc_setting_custom_init (setting);
|
NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI);
|
||||||
nm_connection_add_setting (connection, setting);
|
nm_connection_add_setting (connection, setting);
|
||||||
|
|
||||||
/* Also Proxy Setting */
|
setting = nm_meta_setting_info_editor_new_setting (&nm_meta_setting_infos_editor[NM_META_SETTING_TYPE_PROXY],
|
||||||
setting = nm_setting_proxy_new ();
|
NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI);
|
||||||
nmc_setting_custom_init (setting);
|
|
||||||
nm_connection_add_setting (connection, setting);
|
nm_connection_add_setting (connection, setting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,74 +304,6 @@ nmc_setting_connection_connect_handlers (NMSettingConnection *setting, NMConnect
|
||||||
G_CALLBACK (connection_master_changed_cb), connection);
|
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
|
static gboolean
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void nmc_setting_custom_init (NMSetting *setting);
|
|
||||||
void nmc_setting_ip4_connect_handlers (NMSettingIPConfig *setting);
|
void nmc_setting_ip4_connect_handlers (NMSettingIPConfig *setting);
|
||||||
void nmc_setting_ip6_connect_handlers (NMSettingIPConfig *setting);
|
void nmc_setting_ip6_connect_handlers (NMSettingIPConfig *setting);
|
||||||
void nmc_setting_proxy_connect_handlers (NMSettingProxy *setting);
|
void nmc_setting_proxy_connect_handlers (NMSettingProxy *setting);
|
||||||
|
|
|
@ -148,6 +148,26 @@ nm_meta_property_info_find_by_setting (NMSetting *setting, const char *property_
|
||||||
return property_info;
|
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
|
/* this basically returns NMMetaSettingType.properties, but with type
|
||||||
|
|
|
@ -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_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_gtype (GType gtype);
|
||||||
const NMMetaSettingInfoEditor *nm_meta_setting_info_editor_find_by_setting (NMSetting *setting);
|
const NMMetaSettingInfoEditor *nm_meta_setting_info_editor_find_by_setting (NMSetting *setting);
|
||||||
|
|
|
@ -529,6 +529,9 @@ _env_warn_fcn (const NMMetaEnvironment *environment,
|
||||||
#define ARGS_VALUES_FCN \
|
#define ARGS_VALUES_FCN \
|
||||||
const NMMetaPropertyInfo *property_info, char ***out_to_free
|
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() \
|
#define RETURN_UNSUPPORTED_GET_TYPE() \
|
||||||
G_STMT_START { \
|
G_STMT_START { \
|
||||||
if (!NM_IN_SET (get_type, \
|
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_802_1X "802-1x settings"
|
||||||
#define SETTING_PRETTY_NAME_ADSL "ADSL connection"
|
#define SETTING_PRETTY_NAME_ADSL "ADSL connection"
|
||||||
#define SETTING_PRETTY_NAME_BLUETOOTH "bluetooth 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 (CONNECTION, TRUE),
|
||||||
NM_META_SETTING_VALID_PART_ITEM (ADSL, TRUE),
|
NM_META_SETTING_VALID_PART_ITEM (ADSL, TRUE),
|
||||||
),
|
),
|
||||||
|
.setting_init_fcn = _setting_init_fcn_adsl,
|
||||||
),
|
),
|
||||||
SETTING_INFO (BLUETOOTH,
|
SETTING_INFO (BLUETOOTH,
|
||||||
.valid_parts = NM_META_SETTING_VALID_PARTS (
|
.valid_parts = NM_META_SETTING_VALID_PARTS (
|
||||||
NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE),
|
NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE),
|
||||||
NM_META_SETTING_VALID_PART_ITEM (BLUETOOTH, TRUE),
|
NM_META_SETTING_VALID_PART_ITEM (BLUETOOTH, TRUE),
|
||||||
),
|
),
|
||||||
|
.setting_init_fcn = _setting_init_fcn_bluetooth,
|
||||||
),
|
),
|
||||||
SETTING_INFO (BOND,
|
SETTING_INFO (BOND,
|
||||||
.valid_parts = NM_META_SETTING_VALID_PARTS (
|
.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 (SERIAL, FALSE),
|
||||||
NM_META_SETTING_VALID_PART_ITEM (PPP, FALSE),
|
NM_META_SETTING_VALID_PART_ITEM (PPP, FALSE),
|
||||||
),
|
),
|
||||||
|
.setting_init_fcn = _setting_init_fcn_cdma,
|
||||||
),
|
),
|
||||||
SETTING_INFO (CONNECTION),
|
SETTING_INFO (CONNECTION),
|
||||||
SETTING_INFO (DCB),
|
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 (SERIAL, FALSE),
|
||||||
NM_META_SETTING_VALID_PART_ITEM (PPP, FALSE),
|
NM_META_SETTING_VALID_PART_ITEM (PPP, FALSE),
|
||||||
),
|
),
|
||||||
|
.setting_init_fcn = _setting_init_fcn_gsm,
|
||||||
),
|
),
|
||||||
SETTING_INFO (INFINIBAND,
|
SETTING_INFO (INFINIBAND,
|
||||||
.valid_parts = NM_META_SETTING_VALID_PARTS (
|
.valid_parts = NM_META_SETTING_VALID_PARTS (
|
||||||
NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE),
|
NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE),
|
||||||
NM_META_SETTING_VALID_PART_ITEM (INFINIBAND, 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,
|
SETTING_INFO (IP_TUNNEL,
|
||||||
.valid_parts = NM_META_SETTING_VALID_PARTS (
|
.valid_parts = NM_META_SETTING_VALID_PARTS (
|
||||||
NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE),
|
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 (CONNECTION, TRUE),
|
||||||
NM_META_SETTING_VALID_PART_ITEM (OLPC_MESH, TRUE),
|
NM_META_SETTING_VALID_PART_ITEM (OLPC_MESH, TRUE),
|
||||||
),
|
),
|
||||||
|
.setting_init_fcn = _setting_init_fcn_olpc_mesh,
|
||||||
),
|
),
|
||||||
SETTING_INFO (PPPOE,
|
SETTING_INFO (PPPOE,
|
||||||
/* PPPoE is a base connection type from historical reasons.
|
/* 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 (PPP),
|
||||||
SETTING_INFO (PROXY),
|
SETTING_INFO (PROXY,
|
||||||
|
.setting_init_fcn = _setting_init_fcn_proxy,
|
||||||
|
),
|
||||||
SETTING_INFO (SERIAL),
|
SETTING_INFO (SERIAL),
|
||||||
SETTING_INFO (TEAM,
|
SETTING_INFO (TEAM,
|
||||||
.valid_parts = NM_META_SETTING_VALID_PARTS (
|
.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 (TUN, TRUE),
|
||||||
NM_META_SETTING_VALID_PART_ITEM (WIRED, FALSE),
|
NM_META_SETTING_VALID_PART_ITEM (WIRED, FALSE),
|
||||||
),
|
),
|
||||||
|
.setting_init_fcn = _setting_init_fcn_tun,
|
||||||
),
|
),
|
||||||
SETTING_INFO_EMPTY (USER),
|
SETTING_INFO_EMPTY (USER),
|
||||||
SETTING_INFO (VLAN,
|
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 (VLAN, TRUE),
|
||||||
NM_META_SETTING_VALID_PART_ITEM (WIRED, FALSE),
|
NM_META_SETTING_VALID_PART_ITEM (WIRED, FALSE),
|
||||||
),
|
),
|
||||||
|
.setting_init_fcn = _setting_init_fcn_vlan,
|
||||||
),
|
),
|
||||||
SETTING_INFO (VPN,
|
SETTING_INFO (VPN,
|
||||||
.valid_parts = NM_META_SETTING_VALID_PARTS (
|
.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 (WIRELESS_SECURITY, FALSE),
|
||||||
NM_META_SETTING_VALID_PART_ITEM (802_1X, FALSE),
|
NM_META_SETTING_VALID_PART_ITEM (802_1X, FALSE),
|
||||||
),
|
),
|
||||||
|
.setting_init_fcn = _setting_init_fcn_wireless,
|
||||||
),
|
),
|
||||||
SETTING_INFO (WIRELESS_SECURITY,
|
SETTING_INFO (WIRELESS_SECURITY,
|
||||||
.alias = "wifi-sec",
|
.alias = "wifi-sec",
|
||||||
|
|
|
@ -108,6 +108,11 @@ typedef enum {
|
||||||
NM_META_ACCESSOR_GET_TYPE_TERMFORMAT,
|
NM_META_ACCESSOR_GET_TYPE_TERMFORMAT,
|
||||||
} NMMetaAccessorGetType;
|
} NMMetaAccessorGetType;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
NM_META_ACCESSOR_SETTING_INIT_TYPE_DEFAULT,
|
||||||
|
NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI,
|
||||||
|
} NMMetaAccessorSettingInitType;
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
nm_meta_termformat_unpack (gconstpointer value, NMMetaTermColor *out_color, NMMetaTermFormat *out_format)
|
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
|
* don't have valid_settings but are usually referenced by other
|
||||||
* settings to be valid for them. */
|
* settings to be valid for them. */
|
||||||
const NMMetaSettingValidPartItem *const*valid_parts;
|
const NMMetaSettingValidPartItem *const*valid_parts;
|
||||||
|
|
||||||
|
void (*setting_init_fcn) (const NMMetaSettingInfoEditor *setting_info,
|
||||||
|
NMSetting *setting,
|
||||||
|
NMMetaAccessorSettingInitType init_type);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _NMMetaType {
|
struct _NMMetaType {
|
||||||
|
|
Loading…
Reference in a new issue