cli: show progress in --pretty mode for 'nmcli dev disconnect'
This commit is contained in:
@@ -1161,6 +1161,16 @@ timeout_cb (gpointer user_data)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
progress_cb (gpointer user_data)
|
||||||
|
{
|
||||||
|
NMDevice *device = (NMDevice *) user_data;
|
||||||
|
|
||||||
|
nmc_terminal_show_progress (device ? device_state_to_string (nm_device_get_state (device)) : "");
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
disconnect_device_cb (NMDevice *device, GError *error, gpointer user_data)
|
disconnect_device_cb (NMDevice *device, GError *error, gpointer user_data)
|
||||||
{
|
{
|
||||||
@@ -1176,10 +1186,13 @@ disconnect_device_cb (NMDevice *device, GError *error, gpointer user_data)
|
|||||||
quit ();
|
quit ();
|
||||||
} else {
|
} else {
|
||||||
state = nm_device_get_state (device);
|
state = nm_device_get_state (device);
|
||||||
printf (_("Device state: %d (%s)\n"), state, device_state_to_string (state));
|
|
||||||
|
|
||||||
if (nmc->nowait_flag || state == NM_DEVICE_STATE_DISCONNECTED) {
|
if (nmc->nowait_flag || state == NM_DEVICE_STATE_DISCONNECTED) {
|
||||||
/* Don't want to wait or device already disconnected */
|
/* Don't want to wait or device already disconnected */
|
||||||
|
if (state == NM_DEVICE_STATE_DISCONNECTED && nmc->print_output == NMC_PRINT_PRETTY) {
|
||||||
|
nmc_terminal_erase_line ();
|
||||||
|
printf (_("Device '%s' has been disconnected.\n"), nm_device_get_iface (device));
|
||||||
|
}
|
||||||
quit ();
|
quit ();
|
||||||
} else {
|
} else {
|
||||||
g_signal_connect (device, "notify::state", G_CALLBACK (device_state_cb), nmc);
|
g_signal_connect (device, "notify::state", G_CALLBACK (device_state_cb), nmc);
|
||||||
@@ -1283,6 +1296,10 @@ do_device_disconnect (NmCli *nmc, int argc, char **argv)
|
|||||||
nmc->should_wait = TRUE;
|
nmc->should_wait = TRUE;
|
||||||
nm_device_disconnect (device, disconnect_device_cb, nmc);
|
nm_device_disconnect (device, disconnect_device_cb, nmc);
|
||||||
|
|
||||||
|
/* Start progress indication */
|
||||||
|
if (nmc->print_output == NMC_PRINT_PRETTY)
|
||||||
|
progress_id = g_timeout_add (120, progress_cb, device);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
return nmc->return_value;
|
return nmc->return_value;
|
||||||
}
|
}
|
||||||
@@ -1500,16 +1517,6 @@ error:
|
|||||||
return nmc->return_value;
|
return nmc->return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
progress_cb (gpointer user_data)
|
|
||||||
{
|
|
||||||
NMDevice *device = (NMDevice *) user_data;
|
|
||||||
|
|
||||||
nmc_terminal_show_progress (device ? device_state_to_string (nm_device_get_state (device)) : "");
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
monitor_device_state_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data)
|
monitor_device_state_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user