mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 00:00:08 +01:00
We already have
- data sources (nm_cli, connections or settings)
- meta data information how to access the data sources (NMMetaAbstractInfo,
NmcMetaGenericInfo, NMMetaPropertyInfo)
Add now a generic way to output cli data using nmc_print(). It gets a
list of data-sources (@targets) and a list of available fields (meta
data). It also gets cli configuration (NmcConfig) and field selector
strings (@field_str).
Based on that, it should output the desired data.
This is intended to replaces the previous approach, where functions like
show_nm_status() have full knowledge about how to access the data and
create an intermediate output format (NmcOutputData, NmcOutputField)
that was printed via print_data().
show_nm_status() contained both knowledge about the data itself (how to
print a value) and intimate knoweledge about the output intermediate
format. Also, the intermediate format is hard to understand. For
example, sometimes we put the field prefix in NmcOutputField at index 0
and via the NmcOfFlags we control how to output the data.
Clearly separate the responsibilities.
- The meta data (NmcMetaGenericInfo) is only concerned with converting
a data source to a string (or a color format).
- the field selection (@field_str) only cares about parsing the list
of NMMetaAbstractInfo.
- _print_fill() populates a table with output values and header
entries.
- _print_do() prints the previously prepared table.
The advantage is that if you want to change anything, you only need to
touch a particular part.
This is only a show-case for `nmcli general status`. Parts are still
un-implemented and will follow.
This changes behavior for --terse mode: the values are now no longer
translated:
$ LANG=de_DE.utf8 nmcli -t --mode multiline general
63 lines
3.1 KiB
C
63 lines
3.1 KiB
C
/* NetworkManager
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
*
|
|
* Copyright 2010 - 2017 Red Hat, Inc.
|
|
*/
|
|
|
|
#ifndef _NM_META_SETTING_ACCESS_H__
|
|
#define _NM_META_SETTING_ACCESS_H__
|
|
|
|
#include "nm-meta-setting.h"
|
|
#include "nm-meta-setting-desc.h"
|
|
|
|
/*****************************************************************************/
|
|
|
|
const NMMetaSettingInfoEditor *nm_meta_setting_info_editor_find_by_name (const char *setting_name);
|
|
const NMMetaSettingInfoEditor *nm_meta_setting_info_editor_find_by_gtype (GType gtype);
|
|
const NMMetaSettingInfoEditor *nm_meta_setting_info_editor_find_by_setting (NMSetting *setting);
|
|
|
|
const NMMetaPropertyInfo *nm_meta_setting_info_editor_get_property_info (const NMMetaSettingInfoEditor *setting_info,
|
|
const char *property_name);
|
|
const NMMetaPropertyInfo *nm_meta_property_info_find_by_name (const char *setting_name,
|
|
const char *property_name);
|
|
const NMMetaPropertyInfo *nm_meta_property_info_find_by_setting (NMSetting *setting,
|
|
const char *property_name);
|
|
|
|
/*****************************************************************************/
|
|
|
|
const NMMetaPropertyInfo *const*nm_property_infos_for_setting_type (NMMetaSettingType setting_type);
|
|
|
|
const NMMetaSettingInfoEditor *const*nm_meta_setting_infos_editor_p (void);
|
|
|
|
/*****************************************************************************/
|
|
|
|
const char *nm_meta_abstract_info_get_name (const NMMetaAbstractInfo *abstract_info);
|
|
|
|
const NMMetaAbstractInfo *const*nm_meta_abstract_info_get_nested (const NMMetaAbstractInfo *abstract_info,
|
|
guint *out_len,
|
|
gpointer *nested_to_free);
|
|
|
|
gconstpointer nm_meta_abstract_info_get (const NMMetaAbstractInfo *abstract_info,
|
|
const NMMetaEnvironment *environment,
|
|
gpointer environment_user_data,
|
|
gpointer target,
|
|
NMMetaAccessorGetType get_type,
|
|
NMMetaAccessorGetFlags get_flags,
|
|
gpointer *out_to_free);
|
|
|
|
/*****************************************************************************/
|
|
|
|
#endif /* _NM_META_SETTING_ACCESS_H__ */
|