From 9dd270966edb294452eadac34ec48615f31a851a Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 17 Nov 2011 18:05:35 -0600 Subject: [PATCH] ifcfg-rh: revert some bits of a2b1afb1e41805f3e0bf7e7c956c65d8374f1210 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. --- src/settings/plugins/ifcfg-rh/reader.c | 46 ++++++-------------------- src/settings/plugins/ifcfg-rh/reader.h | 2 -- 2 files changed, 10 insertions(+), 38 deletions(-) diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index 6bb6168052..187427b705 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -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: " [slave-of ]" */ - 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"); -} - diff --git a/src/settings/plugins/ifcfg-rh/reader.h b/src/settings/plugins/ifcfg-rh/reader.h index 2a031977dc..97c727cc79 100644 --- a/src/settings/plugins/ifcfg-rh/reader.h +++ b/src/settings/plugins/ifcfg-rh/reader.h @@ -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__ */