cli: split nm-meta-setting-desc out of settings

This part contains static functions and variables to describe
settings. It is distinct from the mechanism to use them, or
access them.

Split it out.

It still uses clients/cli/common.h and clients/cli/utils.h
which shall be fixed next.
This commit is contained in:
Thomas Haller 2017-03-28 11:38:00 +02:00
parent 2a71b5322f
commit b5c8622ad3
11 changed files with 6244 additions and 6184 deletions

View file

@ -416,7 +416,7 @@ libnm_core_lib_h_pub_mkenums = \
libnm_core_lib_h_priv = \
shared/nm-utils/nm-shared-utils.h \
shared/nm-utils/nm-udev-utils.h \
shared/nm-setting-metadata.h \
shared/nm-meta-setting.h \
libnm-core/crypto.h \
libnm-core/nm-connection-private.h \
libnm-core/nm-core-internal.h \
@ -429,7 +429,7 @@ libnm_core_lib_h_priv = \
libnm_core_lib_c_real = \
shared/nm-utils/nm-shared-utils.c \
shared/nm-utils/nm-udev-utils.c \
shared/nm-setting-metadata.c \
shared/nm-meta-setting.c \
libnm-core/crypto.c \
libnm-core/nm-connection.c \
libnm-core/nm-dbus-utils.c \
@ -3118,8 +3118,11 @@ bin_PROGRAMS += clients/cli/nmcli
clients_cli_nmcli_SOURCES = \
\
shared/nm-setting-metadata.c \
shared/nm-setting-metadata.h \
shared/nm-meta-setting.c \
shared/nm-meta-setting.h \
\
clients/common/nm-meta-setting-desc.c \
clients/common/nm-meta-setting-desc.h \
\
clients/cli/agent.c \
clients/cli/agent.h \

File diff suppressed because it is too large Load diff

View file

@ -20,106 +20,14 @@
#ifndef NMC_SETTINGS_H
#define NMC_SETTINGS_H
#include "nm-setting-metadata.h"
#include "nm-meta-setting.h"
#include "nm-meta-setting-desc.h"
#include "nmcli.h"
#include "utils.h"
/*****************************************************************************/
typedef enum {
NM_META_ACCESSOR_GET_TYPE_PRETTY,
NM_META_ACCESSOR_GET_TYPE_PARSABLE,
} NMMetaAccessorGetType;
typedef enum {
NM_META_PROPERTY_TYPE_MAC_MODE_DEFAULT,
NM_META_PROPERTY_TYPE_MAC_MODE_CLONED,
NM_META_PROPERTY_TYPE_MAC_MODE_INFINIBAND,
} NMMetaPropertyTypeMacMode;
typedef struct _NMMetaSettingInfoEditor NMMetaSettingInfoEditor;
typedef struct _NMMetaPropertyInfo NMMetaPropertyInfo;
typedef struct _NMMetaPropertyType NMMetaPropertyType;
typedef struct _NMMetaPropertyTypData NMMetaPropertyTypData;
struct _NMMetaPropertyType {
const char *(*describe_fcn) (const NMMetaSettingInfoEditor *setting_info,
const NMMetaPropertyInfo *property_info,
char **out_to_free);
char *(*get_fcn) (const NMMetaSettingInfoEditor *setting_info,
const NMMetaPropertyInfo *property_info,
NMSetting *setting,
NMMetaAccessorGetType get_type,
gboolean show_secrets);
gboolean (*set_fcn) (const NMMetaSettingInfoEditor *setting_info,
const NMMetaPropertyInfo *property_info,
NMSetting *setting,
const char *value,
GError **error);
gboolean (*remove_fcn) (const NMMetaSettingInfoEditor *setting_info,
const NMMetaPropertyInfo *property_info,
NMSetting *setting,
const char *option,
guint32 idx,
GError **error);
const char *const*(*values_fcn) (const NMMetaSettingInfoEditor *setting_info,
const NMMetaPropertyInfo *property_info,
char ***out_to_free);
};
struct _NMMetaPropertyTypData {
union {
struct {
gboolean (*fcn) (NMSetting *setting);
} get_with_default;
struct {
GType (*get_gtype) (void);
int min;
int max;
} gobject_enum;
struct {
guint32 (*get_fcn) (NMSetting *setting);
} mtu;
struct {
NMMetaPropertyTypeMacMode mode;
} mac;
} subtype;
const char *const*values_static;
};
struct _NMMetaPropertyInfo {
const char *property_name;
/* the property list for now must contain as first field the
* "name", which isn't a regular property. This is required by
* NmcOutputField and this first field is ignored for the
* group_list/setting_info. */
bool is_name:1;
bool is_secret:1;
const char *describe_message;
const NMMetaPropertyType *property_type;
const NMMetaPropertyTypData *property_typ_data;
};
struct _NMMetaSettingInfoEditor {
const NMMetaSettingInfo *general;
/* the order of the properties matter. The first *must* be the
* "name", and then the order is as they are listed by default. */
const NMMetaPropertyInfo *properties;
guint properties_num;
};
extern const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[_NM_META_SETTING_TYPE_NUM];
/*****************************************************************************/
NMSetting *nmc_setting_new_for_name (const char *name);
void nmc_setting_custom_init (NMSetting *setting);
void nmc_setting_ip4_connect_handlers (NMSettingIPConfig *setting);

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,118 @@
/* nmcli - command-line tool to control 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_DESC_H__
#define __NM_META_SETTING_DESC_H__
#include "nm-meta-setting.h"
#define NM_META_TEXT_HIDDEN "<hidden>"
typedef enum {
NM_META_ACCESSOR_GET_TYPE_PRETTY,
NM_META_ACCESSOR_GET_TYPE_PARSABLE,
} NMMetaAccessorGetType;
typedef enum {
NM_META_PROPERTY_TYPE_MAC_MODE_DEFAULT,
NM_META_PROPERTY_TYPE_MAC_MODE_CLONED,
NM_META_PROPERTY_TYPE_MAC_MODE_INFINIBAND,
} NMMetaPropertyTypeMacMode;
typedef struct _NMMetaSettingInfoEditor NMMetaSettingInfoEditor;
typedef struct _NMMetaPropertyInfo NMMetaPropertyInfo;
typedef struct _NMMetaPropertyType NMMetaPropertyType;
typedef struct _NMMetaPropertyTypData NMMetaPropertyTypData;
struct _NMMetaPropertyType {
const char *(*describe_fcn) (const NMMetaSettingInfoEditor *setting_info,
const NMMetaPropertyInfo *property_info,
char **out_to_free);
char *(*get_fcn) (const NMMetaSettingInfoEditor *setting_info,
const NMMetaPropertyInfo *property_info,
NMSetting *setting,
NMMetaAccessorGetType get_type,
gboolean show_secrets);
gboolean (*set_fcn) (const NMMetaSettingInfoEditor *setting_info,
const NMMetaPropertyInfo *property_info,
NMSetting *setting,
const char *value,
GError **error);
gboolean (*remove_fcn) (const NMMetaSettingInfoEditor *setting_info,
const NMMetaPropertyInfo *property_info,
NMSetting *setting,
const char *option,
guint32 idx,
GError **error);
const char *const*(*values_fcn) (const NMMetaSettingInfoEditor *setting_info,
const NMMetaPropertyInfo *property_info,
char ***out_to_free);
};
struct _NMMetaPropertyTypData {
union {
struct {
gboolean (*fcn) (NMSetting *setting);
} get_with_default;
struct {
GType (*get_gtype) (void);
int min;
int max;
} gobject_enum;
struct {
guint32 (*get_fcn) (NMSetting *setting);
} mtu;
struct {
NMMetaPropertyTypeMacMode mode;
} mac;
} subtype;
const char *const*values_static;
};
struct _NMMetaPropertyInfo {
const char *property_name;
/* the property list for now must contain as first field the
* "name", which isn't a regular property. This is required by
* NmcOutputField and this first field is ignored for the
* group_list/setting_info. */
bool is_name:1;
bool is_secret:1;
const char *describe_message;
const NMMetaPropertyType *property_type;
const NMMetaPropertyTypData *property_typ_data;
};
struct _NMMetaSettingInfoEditor {
const NMMetaSettingInfo *general;
/* the order of the properties matter. The first *must* be the
* "name", and then the order is as they are listed by default. */
const NMMetaPropertyInfo *properties;
guint properties_num;
};
extern const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[_NM_META_SETTING_TYPE_NUM];
#endif /* __NM_META_SETTING_DESC_H__ */

View file

@ -28,7 +28,7 @@
#include "nm-setting-8021x.h"
#include "nm-core-internal.h"
#include "nm-setting-metadata.h"
#include "nm-meta-setting.h"
/*****************************************************************************/

View file

@ -10,6 +10,7 @@ clients/cli/nmcli.c
clients/cli/polkit-agent.c
clients/cli/settings.c
clients/cli/utils.c
clients/common/nm-meta-setting-desc.c
clients/common/nm-polkit-listener.c
clients/common/nm-secret-agent-simple.c
clients/common/nm-vpn-helpers.c

View file

@ -21,7 +21,7 @@
#include "nm-default.h"
#include "nm-setting-metadata.h"
#include "nm-meta-setting.h"
#include "nm-setting-8021x.h"
#include "nm-setting-adsl.h"

View file

@ -19,8 +19,8 @@
* Copyright 2017 Red Hat, Inc.
*/
#ifndef __NM_SETTING_METADATA_H__
#define __NM_SETTING_METADATA_H__
#ifndef __NM_META_SETTING_H__
#define __NM_META_SETTING_H__
#include "nm-setting-8021x.h"
@ -108,4 +108,4 @@ const NMMetaSettingInfo *nm_meta_setting_infos_by_gtype (GType gtype);
/*****************************************************************************/
#endif /* __NM_SETTING_METADATA_H__ */
#endif /* __NM_META_SETTING_H__ */

View file

@ -47,7 +47,7 @@
#include "nm-utils.h"
#include "nm-core-internal.h"
#include "NetworkManagerUtils.h"
#include "nm-setting-metadata.h"
#include "nm-meta-setting.h"
#include "nms-ifcfg-rh-common.h"
#include "nms-ifcfg-rh-reader.h"

View file

@ -31,7 +31,7 @@
#include "settings/nm-settings-plugin.h"
#include "nm-core-internal.h"
#include "NetworkManagerUtils.h"
#include "nm-setting-metadata.h"
#include "nm-meta-setting.h"
#include "nms-ifnet-net-utils.h"
#include "nms-ifnet-wpa-parser.h"