Commit 191da673 authored by Jiří Klimeš's avatar Jiří Klimeš

cli: show progress in --pretty mode for 'nmcli con up'

We need to use a workaround for VPN connection state. There is a bug somewhere
causing that vpn-state-changed signal is not issued on active VPN connection.
Debugging showed that D-Bus PropertiesChanged and VpnStateChanged signals are
not processed properly. That's why libnm-glib's VPN connection object is not
updated. The issue may lie in libnm-glib or even in dbus-glib.
I wasn't able to get VpnStateChanged signal via dbus-glib
(dbus_g_proxy_add_signal() and dbus_g_proxy_connect_signal()), however received
the signal successfully using GDBus.

Until the issue is analyzed and fixed, we need to ask for VPN state of active
VPN connection every second in order to show progress and exit correctly.
parent d58c32d2
......@@ -358,3 +358,197 @@ print_dhcp6_config (NMDHCP6Config *dhcp6, NmCli *nmc, const char *group_prefix)
return FALSE;
}
const char *
nmc_device_state_to_string (NMDeviceState state)
{
switch (state) {
case NM_DEVICE_STATE_UNMANAGED:
return _("unmanaged");
case NM_DEVICE_STATE_UNAVAILABLE:
return _("unavailable");
case NM_DEVICE_STATE_DISCONNECTED:
return _("disconnected");
case NM_DEVICE_STATE_PREPARE:
return _("connecting (prepare)");
case NM_DEVICE_STATE_CONFIG:
return _("connecting (configuring)");
case NM_DEVICE_STATE_NEED_AUTH:
return _("connecting (need authentication)");
case NM_DEVICE_STATE_IP_CONFIG:
return _("connecting (getting IP configuration)");
case NM_DEVICE_STATE_IP_CHECK:
return _("connecting (checking IP connectivity)");
case NM_DEVICE_STATE_SECONDARIES:
return _("connecting (starting secondary connections)");
case NM_DEVICE_STATE_ACTIVATED:
return _("connected");
case NM_DEVICE_STATE_DEACTIVATING:
return _("deactivating");
case NM_DEVICE_STATE_FAILED:
return _("connection failed");
default:
return _("unknown");
}
}
const char *
nmc_device_reason_to_string (NMDeviceStateReason reason)
{
switch (reason) {
case NM_DEVICE_STATE_REASON_NONE:
return _("No reason given");
case NM_DEVICE_STATE_REASON_UNKNOWN:
return _("Unknown error");
case NM_DEVICE_STATE_REASON_NOW_MANAGED:
return _("Device is now managed");
case NM_DEVICE_STATE_REASON_NOW_UNMANAGED:
return _("Device is now unmanaged");
case NM_DEVICE_STATE_REASON_CONFIG_FAILED:
return _("The device could not be readied for configuration");
case NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE:
return _("IP configuration could not be reserved (no available address, timeout, etc)");
case NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED:
return _("The IP configuration is no longer valid");
case NM_DEVICE_STATE_REASON_NO_SECRETS:
return _("Secrets were required, but not provided");
case NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT:
return _("802.1X supplicant disconnected");
case NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED:
return _("802.1X supplicant configuration failed");
case NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED:
return _("802.1X supplicant failed");
case NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT:
return _("802.1X supplicant took too long to authenticate");
case NM_DEVICE_STATE_REASON_PPP_START_FAILED:
return _("PPP service failed to start");
case NM_DEVICE_STATE_REASON_PPP_DISCONNECT:
return _("PPP service disconnected");
case NM_DEVICE_STATE_REASON_PPP_FAILED:
return _("PPP failed");
case NM_DEVICE_STATE_REASON_DHCP_START_FAILED:
return _("DHCP client failed to start");
case NM_DEVICE_STATE_REASON_DHCP_ERROR:
return _("DHCP client error");
case NM_DEVICE_STATE_REASON_DHCP_FAILED:
return _("DHCP client failed");
case NM_DEVICE_STATE_REASON_SHARED_START_FAILED:
return _("Shared connection service failed to start");
case NM_DEVICE_STATE_REASON_SHARED_FAILED:
return _("Shared connection service failed");
case NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED:
return _("AutoIP service failed to start");
case NM_DEVICE_STATE_REASON_AUTOIP_ERROR:
return _("AutoIP service error");
case NM_DEVICE_STATE_REASON_AUTOIP_FAILED:
return _("AutoIP service failed");
case NM_DEVICE_STATE_REASON_MODEM_BUSY:
return _("The line is busy");
case NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE:
return _("No dial tone");
case NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER:
return _("No carrier could be established");
case NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT:
return _("The dialing request timed out");
case NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED:
return _("The dialing attempt failed");
case NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED:
return _("Modem initialization failed");
case NM_DEVICE_STATE_REASON_GSM_APN_FAILED:
return _("Failed to select the specified APN");
case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING:
return _("Not searching for networks");
case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED:
return _("Network registration denied");
case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT:
return _("Network registration timed out");
case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED:
return _("Failed to register with the requested network");
case NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED:
return _("PIN check failed");
case NM_DEVICE_STATE_REASON_FIRMWARE_MISSING:
return _("Necessary firmware for the device may be missing");
case NM_DEVICE_STATE_REASON_REMOVED:
return _("The device was removed");
case NM_DEVICE_STATE_REASON_SLEEPING:
return _("NetworkManager went to sleep");
case NM_DEVICE_STATE_REASON_CONNECTION_REMOVED:
return _("The device's active connection disappeared");
case NM_DEVICE_STATE_REASON_USER_REQUESTED:
return _("Device disconnected by user or client");
case NM_DEVICE_STATE_REASON_CARRIER:
return _("Carrier/link changed");
case NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED:
return _("The device's existing connection was assumed");
case NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE:
return _("The supplicant is now available");
case NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND:
return _("The modem could not be found");
case NM_DEVICE_STATE_REASON_BT_FAILED:
return _("The Bluetooth connection failed or timed out");
case NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED:
return _("GSM Modem's SIM card not inserted");
case NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED:
return _("GSM Modem's SIM PIN required");
case NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED:
return _("GSM Modem's SIM PUK required");
case NM_DEVICE_STATE_REASON_GSM_SIM_WRONG:
return _("GSM Modem's SIM wrong");
case NM_DEVICE_STATE_REASON_INFINIBAND_MODE:
return _("InfiniBand device does not support connected mode");
case NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED:
return _("A dependency of the connection failed");
default:
return _("Unknown");
}
}
......@@ -28,6 +28,7 @@
#include <nm-ip6-config.h>
#include <nm-dhcp4-config.h>
#include <nm-dhcp6-config.h>
#include <nm-device.h>
#include "nmcli.h"
......@@ -36,4 +37,7 @@ gboolean print_ip6_config (NMIP6Config *cfg6, NmCli *nmc, const char *group_pref
gboolean print_dhcp4_config (NMDHCP4Config *dhcp4, NmCli *nmc, const char *group_prefix);
gboolean print_dhcp6_config (NMDHCP6Config *dhcp6, NmCli *nmc, const char *group_prefix);
const char * nmc_device_state_to_string (NMDeviceState state);
const char * nmc_device_reason_to_string (NMDeviceStateReason reason);
#endif /* NMC_COMMON_H */
......@@ -178,6 +178,7 @@ typedef struct {
extern GMainLoop *loop;
static ArgsInfo args_info;
static guint progress_id = 0; /* ID of event source for displaying progress */
static void
usage (void)
......@@ -210,6 +211,11 @@ static const char *real_con_commands[] = {
static void
quit (void)
{
if (progress_id) {
g_source_remove (progress_id);
nmc_terminal_erase_line ();
}
g_main_loop_quit (loop); /* quit main loop */
}
......@@ -1336,10 +1342,12 @@ active_connection_state_cb (NMActiveConnection *active, GParamSpec *pspec, gpoin
state = nm_active_connection_get_state (active);
printf (_("state: %s\n"), active_connection_state_to_string (state));
if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
printf (_("Connection activated\n"));
if (nmc->print_output == NMC_PRINT_PRETTY) {
nmc_terminal_erase_line ();
printf (_("Connection successfully activated (D-Bus active path: %s)\n"),
nm_object_get_path (NM_OBJECT (active)));
}
quit ();
} else if (state == NM_ACTIVE_CONNECTION_STATE_UNKNOWN) {
g_string_printf (nmc->return_text, _("Error: Connection activation failed."));
......@@ -1361,17 +1369,22 @@ vpn_connection_state_cb (NMVPNConnection *vpn,
case NM_VPN_CONNECTION_STATE_NEED_AUTH:
case NM_VPN_CONNECTION_STATE_CONNECT:
case NM_VPN_CONNECTION_STATE_IP_CONFIG_GET:
printf (_("state: %s (%d)\n"), vpn_connection_state_to_string (state), state);
/* no operation */
break;
case NM_VPN_CONNECTION_STATE_ACTIVATED:
printf (_("Connection activated\n"));
if (nmc->print_output == NMC_PRINT_PRETTY) {
nmc_terminal_erase_line ();
printf (_("VPN connection successfully activated (D-Bus active path: %s)\n"),
nm_object_get_path (NM_OBJECT (vpn)));
}
quit ();
break;
case NM_VPN_CONNECTION_STATE_FAILED:
case NM_VPN_CONNECTION_STATE_DISCONNECTED:
g_string_printf (nmc->return_text, _("Error: Connection activation failed: %s."), vpn_connection_state_reason_to_string (reason));
g_string_printf (nmc->return_text, _("Error: Connection activation failed: %s."),
vpn_connection_state_reason_to_string (reason));
nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION;
quit ();
break;
......@@ -1381,6 +1394,85 @@ vpn_connection_state_cb (NMVPNConnection *vpn,
}
}
/* --- VPN state workaround BEGIN --- */
static NMVPNConnectionState
dbus_get_vpn_state (const char *path)
{
DBusGConnection *connection;
DBusGProxy *proxy;
GError *error = NULL;
GValue value = {0,};
NMVPNConnectionState state = NM_VPN_CONNECTION_STATE_UNKNOWN;
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
proxy = dbus_g_proxy_new_for_name (connection,
NM_DBUS_SERVICE,
path,
"org.freedesktop.DBus.Properties");
if (!proxy) {
g_warning ("%s: couldn't create D-Bus object proxy.", __func__);
dbus_g_connection_unref (connection);
return NM_VPN_CONNECTION_STATE_UNKNOWN;
}
/* Get VpnState property for object 'path' through D-Bus Get() call. */
if (dbus_g_proxy_call (proxy,
"Get", &error,
G_TYPE_STRING, NM_DBUS_INTERFACE_VPN_CONNECTION,
G_TYPE_STRING, "VpnState",
G_TYPE_INVALID,
G_TYPE_VALUE, &value, G_TYPE_INVALID)) {
state = g_value_get_uint (&value);
} else {
g_warning ("Error in getting active connection 'Vpn' property: (%d) %s",
error->code, error->message);
g_error_free (error);
}
g_object_unref (proxy);
dbus_g_connection_unref (connection);
return state;
}
typedef struct {
NmCli *nmc;
NMVPNConnection *vpn;
} VpnGetStateInfo;
static gboolean
get_vpn_state_cb (gpointer user_data)
{
VpnGetStateInfo *info = (VpnGetStateInfo *) user_data;
NmCli *nmc = info->nmc;
NMVPNConnection *vpn = info->vpn;
NMVPNConnectionState state;
if (!NM_IS_OBJECT (vpn)) {
/* Active connection failed and dissapeared, quit. */
g_string_printf (nmc->return_text, _("Error: Connection activation failed."));
nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION;
quit ();
g_free (info);
return FALSE;
}
state = dbus_get_vpn_state (nm_object_get_path (NM_OBJECT (vpn)));
vpn_connection_state_cb (vpn, state, NM_VPN_CONNECTION_STATE_REASON_UNKNOWN, nmc);
if ( state == NM_VPN_CONNECTION_STATE_ACTIVATED
|| state == NM_VPN_CONNECTION_STATE_FAILED
|| state == NM_VPN_CONNECTION_STATE_DISCONNECTED) {
g_free (info);
return FALSE;
} else
return TRUE;
}
/* --- VPN state workaround END --- */
static gboolean
timeout_cb (gpointer user_data)
{
......@@ -1394,10 +1486,58 @@ timeout_cb (gpointer user_data)
return FALSE;
}
static gboolean
progress_cb (gpointer user_data)
{
const char *str = (const char *) user_data;
nmc_terminal_show_progress (str);
return TRUE;
}
static gboolean
progress_device_cb (gpointer user_data)
{
NMDevice *device = (NMDevice *) user_data;
nmc_terminal_show_progress (device ? nmc_device_state_to_string (nm_device_get_state (device)) : "");
return TRUE;
}
static gboolean
progress_vpn_cb (gpointer user_data)
{
NMVPNConnection *vpn = (NMVPNConnection *) user_data;
const char *str;
/* VPN state workaround */
#if 0
str = NM_IS_VPN_CONNECTION (vpn) ?
vpn_connection_state_to_string (nm_vpn_connection_get_vpn_state (vpn)) :
"";
#endif
str = NM_IS_OBJECT (vpn) ?
vpn_connection_state_to_string (dbus_get_vpn_state (nm_object_get_path (NM_OBJECT (vpn)))) :
"";
nmc_terminal_show_progress (str);
return TRUE;
}
typedef struct {
NmCli *nmc;
NMDevice *device;
} ActivateConnectionInfo;
static void
activate_connection_cb (NMClient *client, NMActiveConnection *active, GError *error, gpointer user_data)
{
NmCli *nmc = (NmCli *) user_data;
ActivateConnectionInfo *info = (ActivateConnectionInfo *) user_data;
NmCli *nmc = info->nmc;
NMDevice *device = info->device;
NMActiveConnectionState state;
if (error) {
......@@ -1407,27 +1547,61 @@ activate_connection_cb (NMClient *client, NMActiveConnection *active, GError *er
} else {
state = nm_active_connection_get_state (active);
printf (_("Active connection state: %s\n"), active_connection_state_to_string (state));
printf (_("Active connection path: %s\n"), nm_object_get_path (NM_OBJECT (active)));
if (nmc->nowait_flag || state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
/* don't want to wait or already activated */
/* User doesn't want to wait or already activated */
if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED && nmc->print_output == NMC_PRINT_PRETTY) {
printf (_("Connection successfully activated (D-Bus active path: %s)\n"),
nm_object_get_path (NM_OBJECT (active)));
}
quit ();
} else {
if (NM_IS_VPN_CONNECTION (active))
g_signal_connect (NM_VPN_CONNECTION (active), "vpn-state-changed", G_CALLBACK (vpn_connection_state_cb), nmc);
else
if (NM_IS_VPN_CONNECTION (active)) {
VpnGetStateInfo *vpn_info;
/* Monitor VPN state */
g_signal_connect (G_OBJECT (active), "vpn-state-changed", G_CALLBACK (vpn_connection_state_cb), nmc);
/* Start progress indication showing VPN states */
if (nmc->print_output == NMC_PRINT_PRETTY) {
if (progress_id)
g_source_remove (progress_id);
progress_id = g_timeout_add (120, progress_vpn_cb, NM_VPN_CONNECTION (active));
}
/* --- workaround BEGIN --- */
/* There is a bug in libnm-glib or dbus-glib - 'vpn-state-changed' signal
* is never issued. After inspection it appears that PropertiesChanged and
* VpnStateChanged D-Bus signals are not processed, even if they are seen
* on D-Bus (checked via dbus-monitor). Until the bug is identified and
* fixed, we check the VPN state every second.
*/
vpn_info = g_malloc0 (sizeof (VpnGetStateInfo));
vpn_info->nmc = nmc;
vpn_info->vpn = NM_VPN_CONNECTION (active);
g_timeout_add_seconds (1, get_vpn_state_cb, vpn_info);
/* --- workaround END --- */
} else {
g_signal_connect (active, "notify::state", G_CALLBACK (active_connection_state_cb), nmc);
/* Start progress indication showing device states */
if (nmc->print_output == NMC_PRINT_PRETTY) {
if (progress_id)
g_source_remove (progress_id);
progress_id = g_timeout_add (120, progress_device_cb, device);
}
}
/* Start timer not to loop forever when signals are not emitted */
g_timeout_add_seconds (nmc->timeout, timeout_cb, nmc);
}
}
g_free (info);
}
static NMCResultCode
do_connection_up (NmCli *nmc, int argc, char **argv)
{
ActivateConnectionInfo *info;
NMDevice *device = NULL;
const char *spec_object = NULL;
gboolean device_found;
......@@ -1566,12 +1740,21 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
*/
nmc->nowait_flag = !wait;
nmc->should_wait = TRUE;
info = g_malloc0 (sizeof (ActivateConnectionInfo));
info->nmc = nmc;
info->device = device;
nm_client_activate_connection (nmc->client,
connection,
device,
spec_object,
activate_connection_cb,
nmc);
info);
/* Start progress indication */
if (nmc->print_output == NMC_PRINT_PRETTY)
progress_id = g_timeout_add (120, progress_cb, "preparing");
return nmc->return_value;
error:
......
......@@ -245,200 +245,6 @@ quit (void)
g_main_loop_quit (loop); /* quit main loop */
}
static const char *
device_state_to_string (NMDeviceState state)
{
switch (state) {
case NM_DEVICE_STATE_UNMANAGED:
return _("unmanaged");
case NM_DEVICE_STATE_UNAVAILABLE:
return _("unavailable");
case NM_DEVICE_STATE_DISCONNECTED:
return _("disconnected");
case NM_DEVICE_STATE_PREPARE:
return _("connecting (prepare)");
case NM_DEVICE_STATE_CONFIG:
return _("connecting (configuring)");
case NM_DEVICE_STATE_NEED_AUTH:
return _("connecting (need authentication)");
case NM_DEVICE_STATE_IP_CONFIG:
return _("connecting (getting IP configuration)");
case NM_DEVICE_STATE_IP_CHECK:
return _("connecting (checking IP connectivity)");
case NM_DEVICE_STATE_SECONDARIES:
return _("connecting (starting secondary connections)");
case NM_DEVICE_STATE_ACTIVATED:
return _("connected");
case NM_DEVICE_STATE_DEACTIVATING:
return _("deactivating");
case NM_DEVICE_STATE_FAILED:
return _("connection failed");
default:
return _("unknown");
}
}
static const char *
device_reason_to_string (NMDeviceStateReason reason)
{
switch (reason) {
case NM_DEVICE_STATE_REASON_NONE:
return _("No reason given");
case NM_DEVICE_STATE_REASON_UNKNOWN:
return _("Unknown error");
case NM_DEVICE_STATE_REASON_NOW_MANAGED:
return _("Device is now managed");
case NM_DEVICE_STATE_REASON_NOW_UNMANAGED:
return _("Device is now unmanaged");
case NM_DEVICE_STATE_REASON_CONFIG_FAILED:
return _("The device could not be readied for configuration");
case NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE:
return _("IP configuration could not be reserved (no available address, timeout, etc)");
case NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED:
return _("The IP configuration is no longer valid");
case NM_DEVICE_STATE_REASON_NO_SECRETS:
return _("Secrets were required, but not provided");
case NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT:
return _("802.1X supplicant disconnected");
case NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED:
return _("802.1X supplicant configuration failed");
case NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED:
return _("802.1X supplicant failed");
case NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT:
return _("802.1X supplicant took too long to authenticate");
case NM_DEVICE_STATE_REASON_PPP_START_FAILED:
return _("PPP service failed to start");
case NM_DEVICE_STATE_REASON_PPP_DISCONNECT:
return _("PPP service disconnected");
case NM_DEVICE_STATE_REASON_PPP_FAILED:
return _("PPP failed");
case NM_DEVICE_STATE_REASON_DHCP_START_FAILED:
return _("DHCP client failed to start");
case NM_DEVICE_STATE_REASON_DHCP_ERROR:
return _("DHCP client error");
case NM_DEVICE_STATE_REASON_DHCP_FAILED:
return _("DHCP client failed");
case NM_DEVICE_STATE_REASON_SHARED_START_FAILED:
return _("Shared connection service failed to start");
case NM_DEVICE_STATE_REASON_SHARED_FAILED:
return _("Shared connection service failed");
case NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED:
return _("AutoIP service failed to start");
case NM_DEVICE_STATE_REASON_AUTOIP_ERROR:
return _("AutoIP service error");
case NM_DEVICE_STATE_REASON_AUTOIP_FAILED:
return _("AutoIP service failed");
case NM_DEVICE_STATE_REASON_MODEM_BUSY:
return _("The line is busy");
case NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE:
return _("No dial tone");
case NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER:
return _("No carrier could be established");
case NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT:
return _("The dialing request timed out");
case NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED:
return _("The dialing attempt failed");
case NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED:
return _("Modem initialization failed");
case NM_DEVICE_STATE_REASON_GSM_APN_FAILED:
return _("Failed to select the specified APN");
case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING:
return _("Not searching for networks");
case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED:
return _("Network registration denied");
case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT:
return _("Network registration timed out");
case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED:
return _("Failed to register with the requested network");
case NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED:
return _("PIN check failed");
case NM_DEVICE_STATE_REASON_FIRMWARE_MISSING:
return _("Necessary firmware for the device may be missing");
case NM_DEVICE_STATE_REASON_REMOVED:
return _("The device was removed");
case NM_DEVICE_STATE_REASON_SLEEPING:
return _("NetworkManager went to sleep");
case NM_DEVICE_STATE_REASON_CONNECTION_REMOVED:
return _("The device's active connection disappeared");
case NM_DEVICE_STATE_REASON_USER_REQUESTED:
return _("Device disconnected by user or client");
case NM_DEVICE_STATE_REASON_CARRIER:
return _("Carrier/link changed");
case NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED:
return _("The device's existing connection was assumed");
case NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE:
return _("The supplicant is now available");
case NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND:
return _("The modem could not be found");
case NM_DEVICE_STATE_REASON_BT_FAILED:
return _("The Bluetooth connection failed or timed out");
case NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED:
return _("GSM Modem's SIM card not inserted");
case NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED:
return _("GSM Modem's SIM PIN required");
case NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED:
return _("GSM Modem's SIM PUK required");
case NM_DEVICE_STATE_REASON_GSM_SIM_WRONG:
return _("GSM Modem's SIM wrong");
case NM_DEVICE_STATE_REASON_INFINIBAND_MODE:
return _("InfiniBand device does not support connected mode");
case NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED:
return _("A dependency of the connection failed");
default:
return _("Unknown");
}
}
/* Convert device type to string. Use setting names strings to match with
* connection type names.
*/
......@@ -755,8 +561,8 @@ show_device_info (gpointer data, gpointer user_data)
else if (NM_IS_DEVICE_VLAN (device))
hwaddr = nm_device_vlan_get_hw_address (NM_DEVICE_VLAN (device));
state_str = g_strdup_printf ("%d (%s)", state, device_state_to_string (state));
reason_str = g_strdup_printf ("%d (%s)", reason, device_reason_to_string (reason));
state_str = g_strdup_printf ("%d (%s)", state, nmc_device_state_to_string (state));
reason_str = g_strdup_printf ("%d (%s)", reason, nmc_device_reason_to_string (reason));
nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[0].name; /* "GENERAL"*/
nmc->allowed_fields[1].value = nm_device_get_iface (device);
......@@ -985,7 +791,7 @@ show_device_status (NMDevice *device, NmCli *nmc)
{
nmc->allowed_fields[0].value = nm_device_get_iface (device);
nmc->allowed_fields[1].value = device_type_to_string (device);
nmc->allowed_fields[2].value = device_state_to_string (nm_device_get_state (device));
nmc->allowed_fields[2].value = nmc_device_state_to_string (nm_device_get_state (device));
nmc->allowed_fields[3].value = nm_object_get_path (NM_OBJECT (device));
nmc->print_fields.flags &= ~NMC_PF_FLAG_MAIN_HEADER_ADD & ~NMC_PF_FLAG_MAIN_HEADER_ONLY & ~NMC_PF_FLAG_FIELD_NAMES; /* Clear header flags */
......@@ -1166,7 +972,7 @@ progress_cb (gpointer user_data)
{
NMDevice *device = (NMDevice *) user_data;
nmc_terminal_show_progress (device ? device_state_to_string (nm_device_get_state (device)) : "");
nmc_terminal_show_progress (device ? nmc_device_state_to_string (nm_device_get_state (device)) : "");
return TRUE;
}
......@@ -1537,7 +1343,7 @@ monitor_device_state_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data
quit ();
} else if (state == NM_DEVICE_STATE_FAILED) {
g_string_printf (nmc->return_text, _("Error: Connection activation failed: (%d) %s."),
reason, device_reason_to_string (reason));
reason, nmc_device_reason_to_string (reason));
nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION;
quit ();
}
......