mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 04:50:07 +01:00
nmcli: add get_env_flags() accessor to NMMetaEnvironment for checking offline mode
We will want to know whether we are in offline mode. Add an accessor to get environment flags, which libnmc-setting can use.
This commit is contained in:
parent
686d9ebd4f
commit
71a111bb9c
2 changed files with 28 additions and 0 deletions
|
|
@ -486,6 +486,11 @@ typedef enum {
|
|||
NM_META_ENV_WARN_LEVEL_WARN,
|
||||
} NMMetaEnvWarnLevel;
|
||||
|
||||
typedef enum {
|
||||
NM_META_ENV_FLAGS_NONE = 0,
|
||||
NM_META_ENV_FLAGS_OFFLINE = 0x1,
|
||||
} NMMetaEnvFlags;
|
||||
|
||||
/* the settings-meta data is supposed to be independent of an actual client
|
||||
* implementation. Hence, there is a need for hooks to the meta-data.
|
||||
* The meta-data handlers may call back to the environment with certain
|
||||
|
|
@ -506,8 +511,20 @@ struct _NMMetaEnvironment {
|
|||
struct _NMRemoteConnection *const *(*get_nm_connections)(const NMMetaEnvironment *environment,
|
||||
gpointer environment_user_data,
|
||||
guint *out_len);
|
||||
|
||||
NMMetaEnvFlags (*get_env_flags)(const NMMetaEnvironment *environment,
|
||||
gpointer environment_user_data);
|
||||
};
|
||||
|
||||
static inline NMMetaEnvFlags
|
||||
nm_meta_environment_get_env_flags(const NMMetaEnvironment *environment,
|
||||
gpointer environment_user_data)
|
||||
{
|
||||
if (environment && environment->get_env_flags)
|
||||
return environment->get_env_flags(environment, environment_user_data);
|
||||
return NM_META_ENV_FLAGS_NONE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* NMSettingBond is special in that it has nested properties.
|
||||
|
|
|
|||
|
|
@ -488,12 +488,23 @@ _env_get_nm_connections(const NMMetaEnvironment *environment,
|
|||
return (NMRemoteConnection *const *) values->pdata;
|
||||
}
|
||||
|
||||
static NMMetaEnvFlags
|
||||
_env_get_env_flags(const NMMetaEnvironment *environment, gpointer environment_user_data)
|
||||
{
|
||||
NmCli *nmc = environment_user_data;
|
||||
|
||||
nm_assert(nmc);
|
||||
|
||||
return (nmc->offline ? NM_META_ENV_FLAGS_OFFLINE : NM_META_ENV_FLAGS_NONE);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
const NMMetaEnvironment *const nmc_meta_environment = &((NMMetaEnvironment){
|
||||
.warn_fcn = _env_warn_fcn_handle,
|
||||
.get_nm_devices = _env_get_nm_devices,
|
||||
.get_nm_connections = _env_get_nm_connections,
|
||||
.get_env_flags = _env_get_env_flags,
|
||||
});
|
||||
|
||||
static char *
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue