ifcfg-rh: revert some bits of a2b1afb1e4

Revert the DEVICE and suffix bits for the connection name; there's
a few problems with this.  It adds the DEVICE value for connections
regardless of what type they, even in cases where it's not hugely
useful (ie basic wired).  We used to do this, but stopped doing it
because it has zero relevance to a large number of users.  Instead,
the UI itself should do this where appropriate.  That probably means
that 'nmcli' and other tools should give more information about
the components of a connection (like a slave device's master) and
GUI tools would show that in detailed connection information but
not in the at-a-glance status or tooltips.  Second, if more
more advanced users wish this information to show up in the name
they can always set the name themselves, or name the ifcfg file
something like "ifcfg-bond1-slave-of-eth0" too.
This commit is contained in:
Dan Williams 2011-11-17 18:05:35 -06:00
parent 9f86b44a52
commit 9dd270966e
2 changed files with 10 additions and 38 deletions

View file

@ -79,10 +79,12 @@ get_int (const char *str, int *value)
}
static char *
make_connection_name (shvarFile *ifcfg, const char *ifcfg_name,
const char *suggested, const char *prefix)
make_connection_name (shvarFile *ifcfg,
const char *ifcfg_name,
const char *suggested,
const char *prefix)
{
char *full_name = NULL, *name, *device;
char *full_name = NULL, *name;
/* If the ifcfg file already has a NAME, always use that */
name = svGetValue (ifcfg, "NAME", FALSE);
@ -91,32 +93,18 @@ make_connection_name (shvarFile *ifcfg, const char *ifcfg_name,
/* Otherwise construct a new NAME */
g_free (name);
device = svGetValue (ifcfg, "DEVICE", FALSE);
/*
* No name was specified, construct a default connection name based
* on the information we have.
*/
if (!prefix)
prefix = reader_get_prefix();
prefix = _("System");
/* For cosmetic reasons, if the suggested name is the same as
* the ifcfg files name, don't use it. Mainly for wifi so that
* the SSID is shown in the connection ID instead of just "wlan0".
*/
if (suggested && strcmp (ifcfg_name, suggested)) {
if (device)
full_name = g_strdup_printf ("%s %s (%s)", prefix, suggested, device);
else
full_name = g_strdup_printf ("%s %s (%s)", prefix, suggested, ifcfg_name);
} else {
if (device && strcmp (ifcfg_name, device))
full_name = g_strdup_printf ("%s %s (%s)", prefix, ifcfg_name, device);
else
full_name = g_strdup_printf ("%s %s", prefix, ifcfg_name);
}
if (suggested && strcmp (ifcfg_name, suggested))
full_name = g_strdup_printf ("%s %s (%s)", prefix, suggested, ifcfg_name);
else
full_name = g_strdup_printf ("%s %s", prefix, ifcfg_name);
g_free (device);
return full_name;
}
@ -161,17 +149,9 @@ make_connection_setting (const char *file,
value = svGetValue (ifcfg, "MASTER", FALSE);
if (value) {
const char *id;
g_object_set (s_con, NM_SETTING_CONNECTION_MASTER, value, NULL);
g_object_set (s_con, NM_SETTING_CONNECTION_SLAVE_TYPE,
NM_SETTING_BOND_SETTING_NAME, NULL);
/* Add a suffix to all slaves: "<NAME> [slave-of <MASTER>]" */
id = nm_setting_connection_get_id (s_con);
new_id = g_strdup_printf ("%s [slave-of %s]", id, value);
g_object_set (s_con, NM_SETTING_CONNECTION_ID, new_id, NULL);
g_free (value);
}
@ -3779,9 +3759,3 @@ done:
return connection;
}
const char *
reader_get_prefix (void)
{
return _("System");
}

View file

@ -37,6 +37,4 @@ NMConnection *connection_from_file (const char *filename,
GError **error,
gboolean *ignore_error);
const char *reader_get_prefix (void);
#endif /* __READER_H__ */