cli: connect IP addresses/method handlers for existing connections (rh #998137)
The handlers detecting changes of IP addresses/method in nmcli interactive editor were connected only for newly created connection. That's why the automagic feature of setting 'method' when 'addresses' are changed and vice versa worked just for new connections, but not while editing existing connections.
This commit is contained in:
@@ -5199,6 +5199,21 @@ editor_init_new_connection (NmCli *nmc, NMConnection *connection)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
editor_init_existing_connection (NMConnection *connection)
|
||||||
|
{
|
||||||
|
NMSettingIP4Config *s_ip4;
|
||||||
|
NMSettingIP6Config *s_ip6;
|
||||||
|
|
||||||
|
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
||||||
|
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
||||||
|
|
||||||
|
if (s_ip4)
|
||||||
|
nmc_setting_ip4_connect_handlers (s_ip4);
|
||||||
|
if (s_ip6)
|
||||||
|
nmc_setting_ip6_connect_handlers (s_ip6);
|
||||||
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_connection_edit (NmCli *nmc, int argc, char **argv)
|
do_connection_edit (NmCli *nmc, int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -5302,6 +5317,8 @@ do_connection_edit (NmCli *nmc, int argc, char **argv)
|
|||||||
|
|
||||||
/* Load previously saved history commands for the connection */
|
/* Load previously saved history commands for the connection */
|
||||||
load_history_cmds (nm_connection_get_uuid (connection));
|
load_history_cmds (nm_connection_get_uuid (connection));
|
||||||
|
|
||||||
|
editor_init_existing_connection (connection);
|
||||||
} else {
|
} else {
|
||||||
/* New connection */
|
/* New connection */
|
||||||
connection_type = check_valid_name (type, nmc_valid_connection_types, &err1);
|
connection_type = check_valid_name (type, nmc_valid_connection_types, &err1);
|
||||||
|
@@ -1557,6 +1557,28 @@ ipv6_method_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
|
|||||||
g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv6_addresses_changed_cb), NULL);
|
g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv6_addresses_changed_cb), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nmc_setting_ip4_connect_handlers (NMSettingIP4Config *setting)
|
||||||
|
{
|
||||||
|
g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting));
|
||||||
|
|
||||||
|
g_signal_connect (setting, "notify::" NM_SETTING_IP4_CONFIG_ADDRESSES,
|
||||||
|
G_CALLBACK (ipv4_addresses_changed_cb), NULL);
|
||||||
|
g_signal_connect (setting, "notify::" NM_SETTING_IP4_CONFIG_METHOD,
|
||||||
|
G_CALLBACK (ipv4_method_changed_cb), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nmc_setting_ip6_connect_handlers (NMSettingIP6Config *setting)
|
||||||
|
{
|
||||||
|
g_return_if_fail (NM_IS_SETTING_IP6_CONFIG (setting));
|
||||||
|
|
||||||
|
g_signal_connect (setting, "notify::" NM_SETTING_IP6_CONFIG_ADDRESSES,
|
||||||
|
G_CALLBACK (ipv6_addresses_changed_cb), NULL);
|
||||||
|
g_signal_connect (setting, "notify::" NM_SETTING_IP6_CONFIG_METHOD,
|
||||||
|
G_CALLBACK (ipv6_method_changed_cb), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Customize some properties of the setting so that the setting has sensible
|
* Customize some properties of the setting so that the setting has sensible
|
||||||
* values.
|
* values.
|
||||||
@@ -1570,20 +1592,12 @@ nmc_setting_custom_init (NMSetting *setting)
|
|||||||
g_object_set (NM_SETTING_IP4_CONFIG (setting),
|
g_object_set (NM_SETTING_IP4_CONFIG (setting),
|
||||||
NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
|
NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
|
||||||
NULL);
|
NULL);
|
||||||
|
nmc_setting_ip4_connect_handlers (NM_SETTING_IP4_CONFIG (setting));
|
||||||
g_signal_connect (setting, "notify::" NM_SETTING_IP4_CONFIG_ADDRESSES,
|
|
||||||
G_CALLBACK (ipv4_addresses_changed_cb), NULL);
|
|
||||||
g_signal_connect (setting, "notify::" NM_SETTING_IP4_CONFIG_METHOD,
|
|
||||||
G_CALLBACK (ipv4_method_changed_cb), NULL);
|
|
||||||
} else if (NM_IS_SETTING_IP6_CONFIG (setting)) {
|
} else if (NM_IS_SETTING_IP6_CONFIG (setting)) {
|
||||||
g_object_set (NM_SETTING_IP6_CONFIG (setting),
|
g_object_set (NM_SETTING_IP6_CONFIG (setting),
|
||||||
NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
|
NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
|
||||||
NULL);
|
NULL);
|
||||||
|
nmc_setting_ip6_connect_handlers (NM_SETTING_IP6_CONFIG (setting));
|
||||||
g_signal_connect (setting, "notify::" NM_SETTING_IP6_CONFIG_ADDRESSES,
|
|
||||||
G_CALLBACK (ipv6_addresses_changed_cb), NULL);
|
|
||||||
g_signal_connect (setting, "notify::" NM_SETTING_IP6_CONFIG_METHOD,
|
|
||||||
G_CALLBACK (ipv6_method_changed_cb), NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -53,6 +53,8 @@ void nmc_properties_cleanup (void);
|
|||||||
|
|
||||||
NMSetting *nmc_setting_new_for_name (const char *name);
|
NMSetting *nmc_setting_new_for_name (const char *name);
|
||||||
void nmc_setting_custom_init (NMSetting *setting);
|
void nmc_setting_custom_init (NMSetting *setting);
|
||||||
|
void nmc_setting_ip4_connect_handlers (NMSettingIP4Config *setting);
|
||||||
|
void nmc_setting_ip6_connect_handlers (NMSettingIP6Config *setting);
|
||||||
|
|
||||||
char **nmc_setting_get_valid_properties (NMSetting *setting);
|
char **nmc_setting_get_valid_properties (NMSetting *setting);
|
||||||
char *nmc_setting_get_property_desc (NMSetting *setting, const char *prop);
|
char *nmc_setting_get_property_desc (NMSetting *setting, const char *prop);
|
||||||
|
Reference in New Issue
Block a user