diff options
author | Thomas Haller <thaller@redhat.com> | 2018-05-03 12:23:16 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-03-16 13:46:33 +0100 |
commit | f786bf9f29977d703fa1ec8ee4148a72424eebc6 (patch) | |
tree | c7b1e6f9d1154ec1bcb52e265b7dade3a1c5c6c7 | |
parent | 4bbdfd89c72c638b3645216857a991dda23d4fc0 (diff) | |
download | NetworkManager-f786bf9f29977d703fa1ec8ee4148a72424eebc6.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.c | 8 |
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 e706089cfd..b452e5e5fd 100644 --- a/clients/common/nm-meta-setting-access.c +++ b/clients/common/nm-meta-setting-access.c @@ -786,8 +786,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) { |