summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-05-03 12:23:16 +0200
committerThomas Haller <thaller@redhat.com>2018-06-13 15:29:41 +0200
commit5da944cf7bf847d3736799eab6704cc900adecc1 (patch)
tree248333d24b0fe3bb82d9ad14a232d992b46cdc85
parent89184dd90d68b1c2413d189040591146fc1c19dd (diff)
downloadNetworkManager-5da944cf7bf847d3736799eab6704cc900adecc1.tar.gz
cli: let nm_meta_selection_create_parse_list() handle selecting "common" fields
Already previously, nm_meta_selection_create_parse_list() would accept a fields-str with value %NULL, to mean to select all fields. That meant, every caller would usually before passing fields-str do something like: »···if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0) »···»···fields_str = NMC_FIELDS_DEV_WIFI_LIST_COMMON; »···else if (!nmc->required_fields || strcasecmp (nmc->required_fields, "all") == 0) { »···} else »···»···fields_str = nmc->required_fields; Now that meta-data allows to mark the fields that are to be returned for the "common" selector, let nm_meta_selection_create_parse_list() handle the "all" and "common" requests as well. Note that no caller were yet changed. The old way, where callers would mangle fields_str before calling nm_meta_selection_create_parse_list() still works the same. But this would allow to drop that code (provided that the common fields are marked accordingly).
-rw-r--r--clients/common/nm-meta-setting-access.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/clients/common/nm-meta-setting-access.c b/clients/common/nm-meta-setting-access.c
index 7579a5843c..204c1b3543 100644
--- a/clients/common/nm-meta-setting-access.c
+++ b/clients/common/nm-meta-setting-access.c
@@ -775,8 +775,14 @@ nm_meta_selection_create_parse_list (const NMMetaAbstractInfo *const* fields_arr
g_return_val_if_fail (!error || !*error, NULL);
- if (!fields_str)
+ if (!fields_str || !g_ascii_strcasecmp (fields_str, "all"))
return nm_meta_selection_create_all (fields_array);
+ else if (!g_ascii_strcasecmp (fields_str, "common")) {
+ gs_free gpointer f = NULL;
+
+ fields_array = nm_meta_abstract_infos_select_included_in_common (fields_array, -1, NULL, &f);
+ return nm_meta_selection_create_all (fields_array);
+ }
fields_str_clone = g_strdup (fields_str);
for (fields_str_cur = fields_str_clone; fields_str_cur; fields_str_cur = fields_str_next) {