mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-03 14:50:30 +01:00
cli: show differnt text for state of externally connected devices
This commit is contained in:
parent
a3528b1fe8
commit
ec332e3a25
5 changed files with 44 additions and 16 deletions
|
|
@ -2613,7 +2613,7 @@ progress_active_connection_cb (gpointer user_data)
|
|||
}
|
||||
|
||||
str = device
|
||||
? gettext (nmc_device_state_to_string (nm_device_get_state (device)))
|
||||
? gettext (nmc_device_state_to_string_with_external (device))
|
||||
: active_connection_state_to_string (ac_state);
|
||||
|
||||
nmc_terminal_show_progress (str);
|
||||
|
|
@ -6820,7 +6820,7 @@ progress_activation_editor_cb (gpointer user_data)
|
|||
ac_state = nm_active_connection_get_state (ac);
|
||||
dev_state = nm_device_get_state (device);
|
||||
|
||||
nmc_terminal_show_progress (gettext (nmc_device_state_to_string (dev_state)));
|
||||
nmc_terminal_show_progress (gettext (nmc_device_state_to_string_with_external (device)));
|
||||
|
||||
if ( ac_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED
|
||||
|| dev_state == NM_DEVICE_STATE_ACTIVATED) {
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ _metagen_device_status_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
|
|||
case NMC_GENERIC_INFO_TYPE_DEVICE_STATUS_TYPE:
|
||||
return nm_device_get_type_description (d);
|
||||
case NMC_GENERIC_INFO_TYPE_DEVICE_STATUS_STATE:
|
||||
return nmc_meta_generic_get_str_i18n (nmc_device_state_to_string (nm_device_get_state (d)),
|
||||
return nmc_meta_generic_get_str_i18n (nmc_device_state_to_string_with_external (d),
|
||||
get_type);
|
||||
case NMC_GENERIC_INFO_TYPE_DEVICE_STATUS_IP4_CONNECTIVITY:
|
||||
return nmc_meta_generic_get_str_i18n (nm_connectivity_to_string (nm_device_get_connectivity (d, AF_INET)),
|
||||
|
|
@ -147,7 +147,6 @@ _metagen_device_detail_general_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
|
|||
{
|
||||
NMDevice *d = target;
|
||||
NMActiveConnection *ac;
|
||||
NMDeviceState state;
|
||||
NMDeviceStateReason state_reason;
|
||||
NMConnectivityState connectivity;
|
||||
const char *s;
|
||||
|
|
@ -180,10 +179,9 @@ _metagen_device_detail_general_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
|
|||
case NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_MTU:
|
||||
return (*out_to_free = g_strdup_printf ("%u", (guint) nm_device_get_mtu (d)));
|
||||
case NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_STATE:
|
||||
state = nm_device_get_state (d);
|
||||
return (*out_to_free = nmc_meta_generic_get_enum_with_detail (NMC_META_GENERIC_GET_ENUM_TYPE_PARENTHESES,
|
||||
state,
|
||||
nmc_device_state_to_string (state),
|
||||
nm_device_get_state (d),
|
||||
nmc_device_state_to_string_with_external (d),
|
||||
get_type));
|
||||
case NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_REASON:
|
||||
state_reason = nm_device_get_state_reason (d);
|
||||
|
|
@ -1849,7 +1847,7 @@ progress_cb (gpointer user_data)
|
|||
{
|
||||
NMDevice *device = (NMDevice *) user_data;
|
||||
|
||||
nmc_terminal_show_progress (device ? gettext (nmc_device_state_to_string (nm_device_get_state (device))) : "");
|
||||
nmc_terminal_show_progress (device ? gettext (nmc_device_state_to_string_with_external (device)) : "");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -2620,17 +2618,15 @@ do_device_set (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*ar
|
|||
static void
|
||||
device_state (NMDevice *device, GParamSpec *pspec, NmCli *nmc)
|
||||
{
|
||||
NMDeviceState state = nm_device_get_state (device);
|
||||
gs_free char *str = NULL;
|
||||
NMMetaColor color;
|
||||
char *str;
|
||||
|
||||
color = nmc_device_state_to_color (device);
|
||||
str = nmc_colorize (&nmc->nmc_config, color, "%s: %s\n",
|
||||
nm_device_get_iface (device),
|
||||
gettext (nmc_device_state_to_string (state)));
|
||||
gettext (nmc_device_state_to_string_with_external (device)));
|
||||
|
||||
g_print ("%s", str);
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -1426,25 +1426,23 @@ nmc_command_func_overview (const NMCCommand *cmd, NmCli *nmc, int argc, const ch
|
|||
devices = nmc_get_devices_sorted (nmc->client);
|
||||
for (i = 0; devices[i]; i++) {
|
||||
NMDevice *device = devices[i];
|
||||
NMDeviceState state;
|
||||
|
||||
ac = nm_device_get_active_connection (device);
|
||||
|
||||
state = nm_device_get_state (device);
|
||||
color = nmc_device_state_to_color (device);
|
||||
if (ac) {
|
||||
/* TRANSLATORS: prints header line for activated device in plain `nmcli` overview output as
|
||||
* "<interface-name>: <device-state> to <connection-id>" */
|
||||
tmp = nmc_colorize (&nmc->nmc_config, color, C_("nmcli-overview", "%s: %s to %s"),
|
||||
nm_device_get_iface (device),
|
||||
gettext (nmc_device_state_to_string (state)),
|
||||
gettext (nmc_device_state_to_string_with_external (device)),
|
||||
nm_active_connection_get_id (ac));
|
||||
} else {
|
||||
/* TRANSLATORS: prints header line for not active device in plain `nmcli` overview output as
|
||||
* "<interface-name>: <device-state>" */
|
||||
tmp = nmc_colorize (&nmc->nmc_config, color, C_("nmcli-overview", "%s: %s"),
|
||||
nm_device_get_iface (device),
|
||||
gettext (nmc_device_state_to_string (state)));
|
||||
gettext (nmc_device_state_to_string_with_external (device)));
|
||||
}
|
||||
g_print ("%s\n", tmp);
|
||||
g_free (tmp);
|
||||
|
|
|
|||
|
|
@ -265,6 +265,38 @@ NM_UTILS_LOOKUP_STR_DEFINE (nmc_device_state_to_string, NMDeviceState,
|
|||
NM_UTILS_LOOKUP_ITEM (NM_DEVICE_STATE_UNKNOWN, N_("unknown")),
|
||||
)
|
||||
|
||||
static
|
||||
NM_UTILS_LOOKUP_STR_DEFINE (_device_state_to_string, NMDeviceState,
|
||||
NM_UTILS_LOOKUP_DEFAULT (NULL),
|
||||
NM_UTILS_LOOKUP_ITEM (NM_DEVICE_STATE_PREPARE, N_("connecting (externally)")),
|
||||
NM_UTILS_LOOKUP_ITEM (NM_DEVICE_STATE_CONFIG, N_("connecting (externally)")),
|
||||
NM_UTILS_LOOKUP_ITEM (NM_DEVICE_STATE_NEED_AUTH, N_("connecting (externally)")),
|
||||
NM_UTILS_LOOKUP_ITEM (NM_DEVICE_STATE_IP_CONFIG, N_("connecting (externally)")),
|
||||
NM_UTILS_LOOKUP_ITEM (NM_DEVICE_STATE_IP_CHECK, N_("connecting (externally)")),
|
||||
NM_UTILS_LOOKUP_ITEM (NM_DEVICE_STATE_SECONDARIES, N_("connecting (externally)")),
|
||||
NM_UTILS_LOOKUP_ITEM (NM_DEVICE_STATE_ACTIVATED, N_("connected (externally)")),
|
||||
NM_UTILS_LOOKUP_ITEM (NM_DEVICE_STATE_DEACTIVATING, N_("deactivating (externally)")),
|
||||
NM_UTILS_LOOKUP_ITEM (NM_DEVICE_STATE_FAILED, N_("deactivating (externally)")),
|
||||
NM_UTILS_LOOKUP_ITEM_IGNORE_OTHER (),
|
||||
)
|
||||
|
||||
const char *
|
||||
nmc_device_state_to_string_with_external (NMDevice *device)
|
||||
{
|
||||
NMActiveConnection *ac;
|
||||
NMDeviceState state;
|
||||
const char *s;
|
||||
|
||||
state = nm_device_get_state (device);
|
||||
|
||||
if ( (ac = nm_device_get_active_connection (device))
|
||||
&& NM_FLAGS_HAS (nm_active_connection_get_state_flags (ac), NM_ACTIVATION_STATE_FLAG_EXTERNAL)
|
||||
&& (s = _device_state_to_string (state)))
|
||||
return s;
|
||||
|
||||
return nmc_device_state_to_string (state);
|
||||
}
|
||||
|
||||
NM_UTILS_LOOKUP_STR_DEFINE (nmc_device_metered_to_string, NMMetered,
|
||||
NM_UTILS_LOOKUP_DEFAULT (N_("unknown")),
|
||||
NM_UTILS_LOOKUP_ITEM (NM_METERED_YES, N_("yes")),
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ gboolean matches (const char *cmd, const char *pattern);
|
|||
/* FIXME: don't expose this function on its own, at least not from this file. */
|
||||
const char *nmc_bond_validate_mode (const char *mode, GError **error);
|
||||
|
||||
const char *nmc_device_state_to_string_with_external (NMDevice *device);
|
||||
|
||||
const char *nm_active_connection_state_reason_to_string (NMActiveConnectionStateReason reason);
|
||||
const char *nmc_device_state_to_string (NMDeviceState state);
|
||||
const char *nmc_device_reason_to_string (NMDeviceStateReason reason);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue