NetworkManager/clients/common/nm-meta-setting-access.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

101 lines
5.3 KiB
C
Raw Permalink Normal View History

/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (C) 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"
/*****************************************************************************/
NMSetting *nm_meta_setting_info_editor_new_setting(const NMMetaSettingInfoEditor *setting_info,
NMMetaAccessorSettingInitType init_type);
const NMMetaSettingInfoEditor *nm_meta_setting_info_editor_find_by_name(const char *setting_name,
gboolean use_alias);
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);
gboolean nm_meta_setting_info_editor_has_secrets(const NMMetaSettingInfoEditor *setting_info);
/*****************************************************************************/
const NMMetaSettingInfoEditor *const *nm_meta_setting_infos_editor_p(void);
/*****************************************************************************/
const char *nm_meta_abstract_info_get_name(const NMMetaAbstractInfo *abstract_info,
gboolean for_header);
const NMMetaAbstractInfo *const *
nm_meta_abstract_info_get_nested(const NMMetaAbstractInfo *abstract_info,
guint * out_len,
gpointer * nested_to_free);
cli: implement new nmc_print() command to generically output cli data 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
2017-04-04 15:23:39 +02:00
gconstpointer nm_meta_abstract_info_get(const NMMetaAbstractInfo * abstract_info,
const NMMetaEnvironment * environment,
gpointer environment_user_data,
gpointer target,
gpointer target_data,
cli: implement new nmc_print() command to generically output cli data 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
2017-04-04 15:23:39 +02:00
NMMetaAccessorGetType get_type,
NMMetaAccessorGetFlags get_flags,
NMMetaAccessorGetOutFlags *out_flags,
gboolean * out_is_default,
cli: implement new nmc_print() command to generically output cli data 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
2017-04-04 15:23:39 +02:00
gpointer * out_to_free);
const char *const *nm_meta_abstract_info_complete(const NMMetaAbstractInfo *abstract_info,
const NMMetaEnvironment * environment,
gpointer environment_user_data,
const NMMetaOperationContext *operation_context,
const char * text,
gboolean *out_complete_filename,
char *** out_to_free);
/*****************************************************************************/
2017-04-12 15:19:26 +02:00
char *nm_meta_abstract_info_get_nested_names_str(const NMMetaAbstractInfo *abstract_info,
const char * name_prefix);
char *nm_meta_abstract_infos_get_names_str(const NMMetaAbstractInfo *const *fields_array,
const char * name_prefix);
/*****************************************************************************/
typedef struct {
const NMMetaAbstractInfo *info;
const char * self_selection;
const char * sub_selection;
guint idx;
} NMMetaSelectionItem;
typedef struct {
const guint num;
const NMMetaSelectionItem items[];
} NMMetaSelectionResultList;
NMMetaSelectionResultList *
nm_meta_selection_create_all(const NMMetaAbstractInfo *const *fields_array);
NMMetaSelectionResultList *
nm_meta_selection_create_parse_one(const NMMetaAbstractInfo *const *fields_array,
const char * fields_prefix,
const char * fields_str,
gboolean validate_nested,
GError ** error);
NMMetaSelectionResultList *
nm_meta_selection_create_parse_list(const NMMetaAbstractInfo *const *fields_array,
const char * fields_str,
gboolean validate_nested,
GError ** error);
#endif /* _NM_META_SETTING_ACCESS_H__ */