summaryrefslogtreecommitdiff
path: root/clients/common
diff options
context:
space:
mode:
Diffstat (limited to 'clients/common')
-rw-r--r--clients/common/nm-client-utils.c32
-rw-r--r--clients/common/nm-client-utils.h2
2 files changed, 34 insertions, 0 deletions
diff --git a/clients/common/nm-client-utils.c b/clients/common/nm-client-utils.c
index 97885291d6..d3a02161ce 100644
--- a/clients/common/nm-client-utils.c
+++ b/clients/common/nm-client-utils.c
@@ -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")),
diff --git a/clients/common/nm-client-utils.h b/clients/common/nm-client-utils.h
index 8983e6c89b..28eac4573f 100644
--- a/clients/common/nm-client-utils.h
+++ b/clients/common/nm-client-utils.h
@@ -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);