mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-04 11:00:18 +01:00
tui, cli: improve printing of Wi-Fi strength bars (rh #1131491)
This commit is contained in:
commit
d83881a641
10 changed files with 811 additions and 819 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -253,142 +253,134 @@ static guint progress_id = 0; /* ID of event source for displaying progress */
|
|||
static void
|
||||
usage (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli device { COMMAND | help }\n\n"
|
||||
g_printerr (_("Usage: nmcli device { COMMAND | help }\n\n"
|
||||
#if WITH_WIMAX
|
||||
"COMMAND := { status | show | connect | disconnect | delete | wifi | wimax }\n\n"
|
||||
"COMMAND := { status | show | connect | disconnect | delete | wifi | wimax }\n\n"
|
||||
#else
|
||||
"COMMAND := { status | show | connect | disconnect | delete | wifi }\n\n"
|
||||
"COMMAND := { status | show | connect | disconnect | delete | wifi }\n\n"
|
||||
#endif
|
||||
" status\n\n"
|
||||
" show [<ifname>]\n\n"
|
||||
" connect <ifname>\n\n"
|
||||
" disconnect <ifname>\n\n"
|
||||
" delete <ifname>\n\n"
|
||||
" wifi [list [ifname <ifname>] [bssid <BSSID>]]\n\n"
|
||||
" wifi connect <(B)SSID> [password <password>] [wep-key-type key|phrase] [ifname <ifname>]\n"
|
||||
" [bssid <BSSID>] [name <name>] [private yes|no]\n\n"
|
||||
" wifi rescan [[ifname] <ifname>]\n\n"
|
||||
" status\n\n"
|
||||
" show [<ifname>]\n\n"
|
||||
" connect <ifname>\n\n"
|
||||
" disconnect <ifname>\n\n"
|
||||
" delete <ifname>\n\n"
|
||||
" wifi [list [ifname <ifname>] [bssid <BSSID>]]\n\n"
|
||||
" wifi connect <(B)SSID> [password <password>] [wep-key-type key|phrase] [ifname <ifname>]\n"
|
||||
" [bssid <BSSID>] [name <name>] [private yes|no]\n\n"
|
||||
" wifi rescan [[ifname] <ifname>]\n\n"
|
||||
#if WITH_WIMAX
|
||||
" wimax [list [ifname <ifname>] [nsp <name>]]\n\n"
|
||||
" wimax [list [ifname <ifname>] [nsp <name>]]\n\n"
|
||||
#endif
|
||||
));
|
||||
));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_device_status (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli device status { help }\n"
|
||||
"\n"
|
||||
"Show status for all devices.\n"
|
||||
"By default, the following columns are shown:\n"
|
||||
" DEVICE - interface name\n"
|
||||
" TYPE - device type\n"
|
||||
" STATE - device state\n"
|
||||
" CONNECTION - connection activated on device (if any)\n"
|
||||
"Displayed columns can be changed using '--fields' global option. 'status' is\n"
|
||||
"the default command, which means 'nmcli device' calls 'nmcli device status'.\n\n"));
|
||||
g_printerr (_("Usage: nmcli device status { help }\n"
|
||||
"\n"
|
||||
"Show status for all devices.\n"
|
||||
"By default, the following columns are shown:\n"
|
||||
" DEVICE - interface name\n"
|
||||
" TYPE - device type\n"
|
||||
" STATE - device state\n"
|
||||
" CONNECTION - connection activated on device (if any)\n"
|
||||
"Displayed columns can be changed using '--fields' global option. 'status' is\n"
|
||||
"the default command, which means 'nmcli device' calls 'nmcli device status'.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_device_show (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli device show { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [<ifname>]\n"
|
||||
"\n"
|
||||
"Show details of device(s).\n"
|
||||
"The command lists details for all devices, or for a given device.\n\n"));
|
||||
g_printerr (_("Usage: nmcli device show { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [<ifname>]\n"
|
||||
"\n"
|
||||
"Show details of device(s).\n"
|
||||
"The command lists details for all devices, or for a given device.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_device_connect (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli device connect { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := <ifname>\n"
|
||||
"\n"
|
||||
"Connect the device.\n"
|
||||
"NetworkManager will try to find a suitable connection that will be activated.\n"
|
||||
"It will also consider connections that are not set to auto-connect.\n\n"));
|
||||
g_printerr (_("Usage: nmcli device connect { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := <ifname>\n"
|
||||
"\n"
|
||||
"Connect the device.\n"
|
||||
"NetworkManager will try to find a suitable connection that will be activated.\n"
|
||||
"It will also consider connections that are not set to auto-connect.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_device_disconnect (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli device disconnect { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := <ifname>\n"
|
||||
"\n"
|
||||
"Disconnect the device.\n"
|
||||
"The command disconnects the device and prevents it from auto-activating\n"
|
||||
"further connections without user/manual intervention.\n\n"));
|
||||
g_printerr (_("Usage: nmcli device disconnect { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := <ifname>\n"
|
||||
"\n"
|
||||
"Disconnect the device.\n"
|
||||
"The command disconnects the device and prevents it from auto-activating\n"
|
||||
"further connections without user/manual intervention.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_device_delete (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli device delete { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := <ifname>\n"
|
||||
"\n"
|
||||
"Deletes the software device.\n"
|
||||
"The command removes the interface. It only works for software devices\n"
|
||||
"(like bonds, bridges, etc.). Hardware devices cannot be deleted by the\n"
|
||||
"command.\n\n"));
|
||||
g_printerr (_("Usage: nmcli device delete { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := <ifname>\n"
|
||||
"\n"
|
||||
"Deletes the software device.\n"
|
||||
"The command removes the interface. It only works for software devices\n"
|
||||
"(like bonds, bridges, etc.). Hardware devices cannot be deleted by the\n"
|
||||
"command.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_device_wifi (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli device wifi { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"Perform operation on Wi-Fi devices.\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [list [ifname <ifname>] [bssid <BSSID>]]\n"
|
||||
"\n"
|
||||
"List available Wi-Fi access points. The 'ifname' and 'bssid' options can be\n"
|
||||
"used to list APs for a particular interface, or with a specific BSSID.\n"
|
||||
"\n"
|
||||
"ARGUMENTS := connect <(B)SSID> [password <password>] [wep-key-type key|phrase] [ifname <ifname>]\n"
|
||||
" [bssid <BSSID>] [name <name>] [private yes|no]\n"
|
||||
"\n"
|
||||
"Connect to a Wi-Fi network specified by SSID or BSSID. The command creates\n"
|
||||
"a new connection and then activates it on a device. This is a command-line\n"
|
||||
"counterpart of clicking an SSID in a GUI client. The command always creates\n"
|
||||
"a new connection and thus it is mainly useful for connecting to new Wi-Fi\n"
|
||||
"networks. If a connection for the network already exists, it is better to\n"
|
||||
"bring up the existing profile as follows: nmcli con up id <name>. Note that\n"
|
||||
"only open, WEP and WPA-PSK networks are supported at the moment. It is also\n"
|
||||
"assumed that IP configuration is obtained via DHCP.\n"
|
||||
"\n"
|
||||
"ARGUMENTS := rescan [[ifname] <ifname>]\n"
|
||||
"\n"
|
||||
"Request that NetworkManager immediately re-scan for available access points.\n"
|
||||
"NetworkManager scans Wi-Fi networks periodically, but in some cases it might\n"
|
||||
"be useful to start scanning manually. Note that this command does not show\n"
|
||||
"the APs, use 'nmcli device wifi list' for that.\n\n"));
|
||||
g_printerr (_("Usage: nmcli device wifi { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"Perform operation on Wi-Fi devices.\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [list [ifname <ifname>] [bssid <BSSID>]]\n"
|
||||
"\n"
|
||||
"List available Wi-Fi access points. The 'ifname' and 'bssid' options can be\n"
|
||||
"used to list APs for a particular interface, or with a specific BSSID.\n"
|
||||
"\n"
|
||||
"ARGUMENTS := connect <(B)SSID> [password <password>] [wep-key-type key|phrase] [ifname <ifname>]\n"
|
||||
" [bssid <BSSID>] [name <name>] [private yes|no]\n"
|
||||
"\n"
|
||||
"Connect to a Wi-Fi network specified by SSID or BSSID. The command creates\n"
|
||||
"a new connection and then activates it on a device. This is a command-line\n"
|
||||
"counterpart of clicking an SSID in a GUI client. The command always creates\n"
|
||||
"a new connection and thus it is mainly useful for connecting to new Wi-Fi\n"
|
||||
"networks. If a connection for the network already exists, it is better to\n"
|
||||
"bring up the existing profile as follows: nmcli con up id <name>. Note that\n"
|
||||
"only open, WEP and WPA-PSK networks are supported at the moment. It is also\n"
|
||||
"assumed that IP configuration is obtained via DHCP.\n"
|
||||
"\n"
|
||||
"ARGUMENTS := rescan [[ifname] <ifname>]\n"
|
||||
"\n"
|
||||
"Request that NetworkManager immediately re-scan for available access points.\n"
|
||||
"NetworkManager scans Wi-Fi networks periodically, but in some cases it might\n"
|
||||
"be useful to start scanning manually. Note that this command does not show\n"
|
||||
"the APs, use 'nmcli device wifi list' for that.\n\n"));
|
||||
}
|
||||
|
||||
#if WITH_WIMAX
|
||||
static void
|
||||
usage_device_wimax (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli device wimax { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"Perform operation on WiMAX devices.\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [list [ifname <ifname>] [nsp <name>]]\n"
|
||||
"\n"
|
||||
"List available WiMAX NSPs. The 'ifname' and 'nsp' options can be used to\n"
|
||||
"list networks for a particular interface, or with a specific NSP.\n\n"));
|
||||
g_printerr (_("Usage: nmcli device wimax { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"Perform operation on WiMAX devices.\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [list [ifname <ifname>] [nsp <name>]]\n"
|
||||
"\n"
|
||||
"List available WiMAX NSPs. The 'ifname' and 'nsp' options can be used to\n"
|
||||
"list networks for a particular interface, or with a specific NSP.\n\n"));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -509,11 +501,6 @@ fill_output_access_point (gpointer data, gpointer user_data)
|
|||
*bitrate_str, *strength_str, *wpa_flags_str, *rsn_flags_str;
|
||||
GString *security_str;
|
||||
char *ap_name;
|
||||
const char *sig_level_0 = "____";
|
||||
const char *sig_level_1 = "▂___";
|
||||
const char *sig_level_2 = "▂▄__";
|
||||
const char *sig_level_3 = "▂▄▆_";
|
||||
const char *sig_level_4 = "▂▄▆█";
|
||||
const char *sig_bars;
|
||||
|
||||
if (info->active_bssid) {
|
||||
|
|
@ -548,11 +535,7 @@ fill_output_access_point (gpointer data, gpointer user_data)
|
|||
strength_str = g_strdup_printf ("%u", strength);
|
||||
wpa_flags_str = ap_wpa_rsn_flags_to_string (wpa_flags);
|
||||
rsn_flags_str = ap_wpa_rsn_flags_to_string (rsn_flags);
|
||||
sig_bars = strength > 80 ? sig_level_4 :
|
||||
strength > 55 ? sig_level_3 :
|
||||
strength > 30 ? sig_level_2 :
|
||||
strength > 5 ? sig_level_1 :
|
||||
sig_level_0;
|
||||
sig_bars = nm_utils_wifi_strength_bars (strength);
|
||||
|
||||
security_str = g_string_new (NULL);
|
||||
|
||||
|
|
@ -831,7 +814,7 @@ show_device_info (NMDevice *device, NmCli *nmc)
|
|||
char *section_fld = (char *) g_ptr_array_index (fields_in_section, k);
|
||||
|
||||
if (nmc->print_output != NMC_PRINT_TERSE && !nmc->multiline_output && was_output)
|
||||
printf ("\n"); /* Print empty line between groups in tabular mode */
|
||||
g_print ("\n"); /* Print empty line between groups in tabular mode */
|
||||
|
||||
was_output = FALSE;
|
||||
|
||||
|
|
@ -1244,7 +1227,7 @@ do_devices_status (NmCli *nmc, int argc, char **argv)
|
|||
size_t tmpl_len;
|
||||
|
||||
while (argc > 0) {
|
||||
fprintf (stderr, _("Unknown parameter: %s\n"), *argv);
|
||||
g_printerr (_("Unknown parameter: %s\n"), *argv);
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
|
@ -1329,7 +1312,7 @@ do_devices_show (NmCli *nmc, int argc, char **argv)
|
|||
if (!ret)
|
||||
break;
|
||||
if (devices[i + 1])
|
||||
printf ("\n"); /* Empty line */
|
||||
g_print ("\n"); /* Empty line */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1371,9 +1354,9 @@ connected_state_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data)
|
|||
|
||||
if (state == NM_DEVICE_STATE_ACTIVATED) {
|
||||
nmc_terminal_erase_line ();
|
||||
printf (_("Device '%s' successfully activated with '%s'.\n"),
|
||||
nm_device_get_iface (device),
|
||||
nm_active_connection_get_uuid (active));
|
||||
g_print (_("Device '%s' successfully activated with '%s'.\n"),
|
||||
nm_device_get_iface (device),
|
||||
nm_active_connection_get_uuid (active));
|
||||
g_object_unref (active);
|
||||
quit ();
|
||||
}
|
||||
|
|
@ -1393,8 +1376,8 @@ monitor_device_state_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data
|
|||
|
||||
if (nmc->print_output == NMC_PRINT_PRETTY)
|
||||
nmc_terminal_erase_line ();
|
||||
printf (_("Connection with UUID '%s' created and activated on device '%s'\n"),
|
||||
nm_active_connection_get_uuid (active), nm_device_get_iface (device));
|
||||
g_print (_("Connection with UUID '%s' created and activated on device '%s'\n"),
|
||||
nm_active_connection_get_uuid (active), nm_device_get_iface (device));
|
||||
quit ();
|
||||
} else if (state == NM_DEVICE_STATE_FAILED) {
|
||||
reason = nm_device_get_state_reason (device);
|
||||
|
|
@ -1444,8 +1427,8 @@ add_and_activate_cb (GObject *client,
|
|||
if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
|
||||
if (nmc->print_output == NMC_PRINT_PRETTY)
|
||||
nmc_terminal_erase_line ();
|
||||
printf (_("Connection with UUID '%s' created and activated on device '%s'\n"),
|
||||
nm_active_connection_get_uuid (active), nm_device_get_iface (device));
|
||||
g_print (_("Connection with UUID '%s' created and activated on device '%s'\n"),
|
||||
nm_active_connection_get_uuid (active), nm_device_get_iface (device));
|
||||
}
|
||||
g_object_unref (active);
|
||||
quit ();
|
||||
|
|
@ -1534,7 +1517,7 @@ connect_device_cb (GObject *client, GAsyncResult *result, gpointer user_data)
|
|||
/* Don't want to wait or device already activated */
|
||||
if (state == NM_DEVICE_STATE_ACTIVATED && nmc->print_output == NMC_PRINT_PRETTY) {
|
||||
nmc_terminal_erase_line ();
|
||||
printf (_("Device '%s' has been connected.\n"), nm_device_get_iface (device));
|
||||
g_print (_("Device '%s' has been connected.\n"), nm_device_get_iface (device));
|
||||
}
|
||||
quit ();
|
||||
} else {
|
||||
|
|
@ -1668,7 +1651,7 @@ disconnect_device_cb (GObject *object, GAsyncResult *result, gpointer user_data)
|
|||
if (state == NM_DEVICE_STATE_DISCONNECTED) {
|
||||
if (nmc->print_output == NMC_PRINT_PRETTY)
|
||||
nmc_terminal_erase_line ();
|
||||
printf (_("Device '%s' has been disconnected.\n"), nm_device_get_iface (device));
|
||||
g_print (_("Device '%s' has been disconnected.\n"), nm_device_get_iface (device));
|
||||
}
|
||||
quit ();
|
||||
} else {
|
||||
|
|
@ -1911,7 +1894,7 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
|
|||
}
|
||||
bssid_user = *argv;
|
||||
} else {
|
||||
fprintf (stderr, _("Unknown parameter: %s\n"), *argv);
|
||||
g_printerr (_("Unknown parameter: %s\n"), *argv);
|
||||
}
|
||||
|
||||
argc--;
|
||||
|
|
@ -2041,7 +2024,7 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
|
|||
g_free (bssid_up);
|
||||
}
|
||||
if (empty_line)
|
||||
printf ("\n"); /* Empty line between devices' APs */
|
||||
g_print ("\n"); /* Empty line between devices' APs */
|
||||
print_data (nmc); /* Print all data */
|
||||
nmc_empty_output_fields (nmc);
|
||||
empty_line = TRUE;
|
||||
|
|
@ -2063,7 +2046,7 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
|
|||
|
||||
if (NM_IS_DEVICE_WIFI (dev)) {
|
||||
if (empty_line)
|
||||
printf ("\n"); /* Empty line between devices' APs */
|
||||
g_print ("\n"); /* Empty line between devices' APs */
|
||||
show_access_point_info (dev, nmc);
|
||||
empty_line = TRUE;
|
||||
}
|
||||
|
|
@ -2285,7 +2268,7 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv)
|
|||
goto error;
|
||||
}
|
||||
} else {
|
||||
fprintf (stderr, _("Unknown parameter: %s\n"), *argv);
|
||||
g_printerr (_("Unknown parameter: %s\n"), *argv);
|
||||
}
|
||||
|
||||
argc--;
|
||||
|
|
@ -2571,7 +2554,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
|
|||
}
|
||||
nsp_user = *argv;
|
||||
} else {
|
||||
fprintf (stderr, _("Unknown parameter: %s\n"), *argv);
|
||||
g_printerr (_("Unknown parameter: %s\n"), *argv);
|
||||
}
|
||||
|
||||
argc--;
|
||||
|
|
@ -2684,7 +2667,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
|
|||
g_free (nsp_up);
|
||||
}
|
||||
if (empty_line)
|
||||
printf ("\n"); /* Empty line between devices' NSPs */
|
||||
g_print ("\n"); /* Empty line between devices' NSPs */
|
||||
print_data (nmc); /* Print all data */
|
||||
nmc_empty_output_fields (nmc);
|
||||
empty_line = TRUE;
|
||||
|
|
@ -2705,7 +2688,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
|
|||
|
||||
if (NM_IS_DEVICE_WIMAX (dev)) {
|
||||
if (empty_line)
|
||||
printf ("\n"); /* Empty line between devices' NSPs */
|
||||
g_print ("\n"); /* Empty line between devices' NSPs */
|
||||
show_nsp_info (dev, nmc);
|
||||
empty_line = TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
@ -89,161 +88,147 @@ extern GMainLoop *loop;
|
|||
static void
|
||||
usage_general (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli general { COMMAND | help }\n\n"
|
||||
"COMMAND := { status | hostname | permissions | logging }\n\n"
|
||||
" status\n\n"
|
||||
" hostname [<hostname>]\n\n"
|
||||
" permissions\n\n"
|
||||
" logging [level <log level>] [domains <log domains>]\n\n"));
|
||||
g_printerr (_("Usage: nmcli general { COMMAND | help }\n\n"
|
||||
"COMMAND := { status | hostname | permissions | logging }\n\n"
|
||||
" status\n\n"
|
||||
" hostname [<hostname>]\n\n"
|
||||
" permissions\n\n"
|
||||
" logging [level <log level>] [domains <log domains>]\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_general_status (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli general status { help }\n"
|
||||
"\n"
|
||||
"Show overall status of NetworkManager.\n"
|
||||
"'status' is the default action, which means 'nmcli gen' calls 'nmcli gen status'\n\n"));
|
||||
g_printerr (_("Usage: nmcli general status { help }\n"
|
||||
"\n"
|
||||
"Show overall status of NetworkManager.\n"
|
||||
"'status' is the default action, which means 'nmcli gen' calls 'nmcli gen status'\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_general_hostname (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli general hostname { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [<hostname>]\n"
|
||||
"\n"
|
||||
"Get or change persistent system hostname.\n"
|
||||
"With no arguments, this prints currently configured hostname. When you pass\n"
|
||||
"a hostname, NetworkManager will set it as the new persistent system hostname.\n\n"));
|
||||
g_printerr (_("Usage: nmcli general hostname { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [<hostname>]\n"
|
||||
"\n"
|
||||
"Get or change persistent system hostname.\n"
|
||||
"With no arguments, this prints currently configured hostname. When you pass\n"
|
||||
"a hostname, NetworkManager will set it as the new persistent system hostname.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_general_permissions (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli general permissions { help }\n"
|
||||
"\n"
|
||||
"Show caller permissions for authenticated operations.\n\n"));
|
||||
g_printerr (_("Usage: nmcli general permissions { help }\n"
|
||||
"\n"
|
||||
"Show caller permissions for authenticated operations.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_general_logging (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli general logging { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [level <log level>] [domains <log domains>]\n"
|
||||
"\n"
|
||||
"Get or change NetworkManager logging level and domains.\n"
|
||||
"Without any argument current logging level and domains are shown. In order to\n"
|
||||
"change logging state, provide level and/or domain. Please refer to the man page\n"
|
||||
"for the list of possible logging domains.\n\n"));
|
||||
g_printerr (_("Usage: nmcli general logging { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [level <log level>] [domains <log domains>]\n"
|
||||
"\n"
|
||||
"Get or change NetworkManager logging level and domains.\n"
|
||||
"Without any argument current logging level and domains are shown. In order to\n"
|
||||
"change logging state, provide level and/or domain. Please refer to the man page\n"
|
||||
"for the list of possible logging domains.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_networking (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli networking { COMMAND | help }\n\n"
|
||||
"COMMAND := { [ on | off | connectivity ] }\n\n"
|
||||
" on\n\n"
|
||||
" off\n\n"
|
||||
" connectivity [check]\n\n"));
|
||||
g_printerr (_("Usage: nmcli networking { COMMAND | help }\n\n"
|
||||
"COMMAND := { [ on | off | connectivity ] }\n\n"
|
||||
" on\n\n"
|
||||
" off\n\n"
|
||||
" connectivity [check]\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_networking_on (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli networking on { help }\n"
|
||||
"\n"
|
||||
"Switch networking on.\n\n"));
|
||||
g_printerr (_("Usage: nmcli networking on { help }\n"
|
||||
"\n"
|
||||
"Switch networking on.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_networking_off (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli networking off { help }\n"
|
||||
"\n"
|
||||
"Switch networking off.\n\n"));
|
||||
g_printerr (_("Usage: nmcli networking off { help }\n"
|
||||
"\n"
|
||||
"Switch networking off.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_networking_connectivity (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli networking connectivity { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [check]\n"
|
||||
"\n"
|
||||
"Get network connectivity state.\n"
|
||||
"The optional 'check' argument makes NetworkManager re-check the connectivity.\n\n"));
|
||||
g_printerr (_("Usage: nmcli networking connectivity { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [check]\n"
|
||||
"\n"
|
||||
"Get network connectivity state.\n"
|
||||
"The optional 'check' argument makes NetworkManager re-check the connectivity.\n\n"));
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
usage_radio (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli radio { COMMAND | help }\n\n"
|
||||
g_printerr (_("Usage: nmcli radio { COMMAND | help }\n\n"
|
||||
#if WITH_WIMAX
|
||||
"COMMAND := { all | wifi | wwan | wimax }\n\n"
|
||||
" all | wifi | wwan | wimax [ on | off ]\n\n"
|
||||
"COMMAND := { all | wifi | wwan | wimax }\n\n"
|
||||
" all | wifi | wwan | wimax [ on | off ]\n\n"
|
||||
#else
|
||||
"COMMAND := { all | wifi | wwan }\n\n"
|
||||
" all | wifi | wwan [ on | off ]\n\n"
|
||||
"COMMAND := { all | wifi | wwan }\n\n"
|
||||
" all | wifi | wwan [ on | off ]\n\n"
|
||||
#endif
|
||||
));
|
||||
));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_radio_all (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli radio all { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [on | off]\n"
|
||||
"\n"
|
||||
"Get status of all radio switches, or turn them on/off.\n\n"));
|
||||
g_printerr (_("Usage: nmcli radio all { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [on | off]\n"
|
||||
"\n"
|
||||
"Get status of all radio switches, or turn them on/off.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_radio_wifi (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli radio wifi { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [on | off]\n"
|
||||
"\n"
|
||||
"Get status of Wi-Fi radio switch, or turn it on/off.\n\n"));
|
||||
g_printerr (_("Usage: nmcli radio wifi { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [on | off]\n"
|
||||
"\n"
|
||||
"Get status of Wi-Fi radio switch, or turn it on/off.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_radio_wwan (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli radio wwan { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [on | off]\n"
|
||||
"\n"
|
||||
"Get status of mobile broadband radio switch, or turn it on/off.\n\n"));
|
||||
g_printerr (_("Usage: nmcli radio wwan { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [on | off]\n"
|
||||
"\n"
|
||||
"Get status of mobile broadband radio switch, or turn it on/off.\n\n"));
|
||||
}
|
||||
|
||||
#if WITH_WIMAX
|
||||
static void
|
||||
usage_radio_wimax (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: nmcli radio wimax { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [on | off]\n"
|
||||
"\n"
|
||||
"Get status of WiMAX radio switch, or turn it on/off.\n\n"));
|
||||
g_printerr (_("Usage: nmcli radio wimax { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [on | off]\n"
|
||||
"\n"
|
||||
"Get status of WiMAX radio switch, or turn it on/off.\n\n"));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -620,14 +605,14 @@ do_general (NmCli *nmc, int argc, char **argv)
|
|||
|
||||
g_object_get (rem_settings, NM_REMOTE_SETTINGS_HOSTNAME, &hostname, NULL);
|
||||
if (hostname)
|
||||
printf ("%s\n", hostname);
|
||||
g_print ("%s\n", hostname);
|
||||
g_free (hostname);
|
||||
} else {
|
||||
/* hostname provided -> set it */
|
||||
const char *hostname = *argv;
|
||||
|
||||
if (next_arg (&argc, &argv) == 0)
|
||||
printf ("Warning: ignoring extra garbage after '%s' hostname\n", hostname);
|
||||
g_print ("Warning: ignoring extra garbage after '%s' hostname\n", hostname);
|
||||
|
||||
nmc->should_wait = TRUE;
|
||||
nm_remote_settings_save_hostname_async (rem_settings, hostname, NULL, save_hostname_cb, nmc);
|
||||
|
|
|
|||
|
|
@ -78,29 +78,28 @@ nmcli_error_quark (void)
|
|||
static void
|
||||
usage (const char *prog_name)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("Usage: %s [OPTIONS] OBJECT { COMMAND | help }\n"
|
||||
"\n"
|
||||
"OPTIONS\n"
|
||||
" -t[erse] terse output\n"
|
||||
" -p[retty] pretty output\n"
|
||||
" -m[ode] tabular|multiline output mode\n"
|
||||
" -f[ields] <field1,field2,...>|all|common specify fields to output\n"
|
||||
" -e[scape] yes|no escape columns separators in values\n"
|
||||
" -n[ocheck] don't check nmcli and NetworkManager versions\n"
|
||||
" -a[sk] ask for missing parameters\n"
|
||||
" -w[ait] <seconds> set timeout waiting for finishing operations\n"
|
||||
" -v[ersion] show program version\n"
|
||||
" -h[elp] print this help\n"
|
||||
"\n"
|
||||
"OBJECT\n"
|
||||
" g[eneral] NetworkManager's general status and operations\n"
|
||||
" n[etworking] overall networking control\n"
|
||||
" r[adio] NetworkManager radio switches\n"
|
||||
" c[onnection] NetworkManager's connections\n"
|
||||
" d[evice] devices managed by NetworkManager\n"
|
||||
"\n"),
|
||||
prog_name);
|
||||
g_printerr (_("Usage: %s [OPTIONS] OBJECT { COMMAND | help }\n"
|
||||
"\n"
|
||||
"OPTIONS\n"
|
||||
" -t[erse] terse output\n"
|
||||
" -p[retty] pretty output\n"
|
||||
" -m[ode] tabular|multiline output mode\n"
|
||||
" -f[ields] <field1,field2,...>|all|common specify fields to output\n"
|
||||
" -e[scape] yes|no escape columns separators in values\n"
|
||||
" -n[ocheck] don't check nmcli and NetworkManager versions\n"
|
||||
" -a[sk] ask for missing parameters\n"
|
||||
" -w[ait] <seconds> set timeout waiting for finishing operations\n"
|
||||
" -v[ersion] show program version\n"
|
||||
" -h[elp] print this help\n"
|
||||
"\n"
|
||||
"OBJECT\n"
|
||||
" g[eneral] NetworkManager's general status and operations\n"
|
||||
" n[etworking] overall networking control\n"
|
||||
" r[adio] NetworkManager radio switches\n"
|
||||
" c[onnection] NetworkManager's connections\n"
|
||||
" d[evice] devices managed by NetworkManager\n"
|
||||
"\n"),
|
||||
prog_name);
|
||||
}
|
||||
|
||||
static NMCResultCode
|
||||
|
|
@ -248,7 +247,7 @@ parse_command_line (NmCli *nmc, int argc, char **argv)
|
|||
}
|
||||
nmc->timeout = (int) timeout;
|
||||
} else if (matches (opt, "-version") == 0) {
|
||||
printf (_("nmcli tool, version %s\n"), NMCLI_VERSION);
|
||||
g_print (_("nmcli tool, version %s\n"), NMCLI_VERSION);
|
||||
return NMC_RESULT_SUCCESS;
|
||||
} else if (matches (opt, "-help") == 0) {
|
||||
usage (base);
|
||||
|
|
@ -334,8 +333,8 @@ signal_handling_thread (void *arg) {
|
|||
} else {
|
||||
/* We can quit nmcli */
|
||||
nmc_cleanup_readline ();
|
||||
printf (_("\nError: nmcli terminated by signal %s (%d)\n"),
|
||||
strsignal (signo), signo);
|
||||
g_print (_("\nError: nmcli terminated by signal %s (%d)\n"),
|
||||
strsignal (signo), signo);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
|
|
@ -343,8 +342,8 @@ signal_handling_thread (void *arg) {
|
|||
case SIGTERM:
|
||||
nmc_cleanup_readline ();
|
||||
if (!nmcli_sigquit_internal)
|
||||
printf (_("\nError: nmcli terminated by signal %s (%d)\n"),
|
||||
strsignal (signo), signo);
|
||||
g_print (_("\nError: nmcli terminated by signal %s (%d)\n"),
|
||||
strsignal (signo), signo);
|
||||
exit (1);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -374,14 +373,14 @@ setup_signals (void)
|
|||
/* Block all signals of interest. */
|
||||
status = pthread_sigmask (SIG_BLOCK, &signal_set, NULL);
|
||||
if (status != 0) {
|
||||
fprintf (stderr, _("Failed to set signal mask: %d\n"), status);
|
||||
g_printerr (_("Failed to set signal mask: %d\n"), status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Create the signal handling thread. */
|
||||
status = pthread_create (&signal_thread_id, NULL, signal_handling_thread, NULL);
|
||||
if (status != 0) {
|
||||
fprintf (stderr, _("Failed to create signal handling thread: %d\n"), status);
|
||||
g_printerr (_("Failed to create signal handling thread: %d\n"), status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -588,7 +587,7 @@ main (int argc, char *argv[])
|
|||
|
||||
/* Print result descripting text */
|
||||
if (nm_cli.return_value != NMC_RESULT_SUCCESS) {
|
||||
fprintf (stderr, "%s\n", nm_cli.return_text->str);
|
||||
g_printerr ("%s\n", nm_cli.return_text->str);
|
||||
}
|
||||
|
||||
g_main_loop_unref (loop);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
|
@ -1841,9 +1840,9 @@ wireless_band_channel_changed_cb (GObject *object, GParamSpec *pspec, gpointer u
|
|||
|
||||
mode = nm_setting_wireless_get_mode (NM_SETTING_WIRELESS (object));
|
||||
if (!mode || !*mode || strcmp (mode, NM_SETTING_WIRELESS_MODE_INFRA) == 0) {
|
||||
printf (_("Warning: %s.%s set to '%s', but it might be ignored in infrastructure mode\n"),
|
||||
nm_setting_get_name (NM_SETTING (s_wireless)), g_param_spec_get_name (pspec),
|
||||
value);
|
||||
g_print (_("Warning: %s.%s set to '%s', but it might be ignored in infrastructure mode\n"),
|
||||
nm_setting_get_name (NM_SETTING (s_wireless)), g_param_spec_get_name (pspec),
|
||||
value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2504,7 +2503,7 @@ nmc_property_connection_set_secondaries (NMSetting *setting, const char *prop, c
|
|||
con = nmc_find_connection (nm_cli.system_connections,
|
||||
"uuid", *iter, NULL);
|
||||
if (!con)
|
||||
printf (_("Warning: %s is not an UUID of any existing connection profile\n"), *iter);
|
||||
g_print (_("Warning: %s is not an UUID of any existing connection profile\n"), *iter);
|
||||
else {
|
||||
/* Currenly NM only supports VPN connections as secondaries */
|
||||
if (!nm_connection_is_type (con, NM_SETTING_VPN_SETTING_NAME)) {
|
||||
|
|
@ -3804,8 +3803,8 @@ nmc_property_vlan_remove_priority_map (NMSetting *setting,
|
|||
if (!prio_map)
|
||||
return FALSE;
|
||||
if (prio_map[1])
|
||||
printf (_("Warning: only one mapping at a time is supported; taking the first one (%s)\n"),
|
||||
prio_map[0]);
|
||||
g_print (_("Warning: only one mapping at a time is supported; taking the first one (%s)\n"),
|
||||
prio_map[0]);
|
||||
ret = nm_setting_vlan_remove_priority_str_by_value (NM_SETTING_VLAN (setting),
|
||||
map,
|
||||
prio_map[0]);
|
||||
|
|
@ -4276,9 +4275,9 @@ nmc_property_wifi_set_wep_key (NMSetting *setting, const char *prop, const char
|
|||
}
|
||||
prev_idx = nm_setting_wireless_security_get_wep_tx_keyidx (NM_SETTING_WIRELESS_SECURITY (setting));
|
||||
idx = prop[strlen (prop) - 1] - '0';
|
||||
printf (_("WEP key is guessed to be of '%s'\n"), wep_key_type_to_string (guessed_type));
|
||||
g_print (_("WEP key is guessed to be of '%s'\n"), wep_key_type_to_string (guessed_type));
|
||||
if (idx != prev_idx)
|
||||
printf (_("WEP key index set to '%d'\n"), idx);
|
||||
g_print (_("WEP key index set to '%d'\n"), idx);
|
||||
|
||||
g_object_set (setting, prop, val, NULL);
|
||||
g_object_set (setting, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, guessed_type, NULL);
|
||||
|
|
@ -4317,17 +4316,17 @@ nmc_property_wifi_set_wep_key_type (NMSetting *setting, const char *prop, const
|
|||
key2 = nm_setting_wireless_security_get_wep_key (NM_SETTING_WIRELESS_SECURITY (setting), 2);
|
||||
key3 = nm_setting_wireless_security_get_wep_key (NM_SETTING_WIRELESS_SECURITY (setting), 3);
|
||||
if (key0 && !nm_utils_wep_key_valid (key0, type))
|
||||
printf (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
|
||||
NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, wep_key_type_to_string (type));
|
||||
g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
|
||||
NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, wep_key_type_to_string (type));
|
||||
if (key1 && !nm_utils_wep_key_valid (key1, type))
|
||||
printf (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
|
||||
NM_SETTING_WIRELESS_SECURITY_WEP_KEY1, wep_key_type_to_string (type));
|
||||
g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
|
||||
NM_SETTING_WIRELESS_SECURITY_WEP_KEY1, wep_key_type_to_string (type));
|
||||
if (key2 && !nm_utils_wep_key_valid (key2, type))
|
||||
printf (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
|
||||
NM_SETTING_WIRELESS_SECURITY_WEP_KEY2, wep_key_type_to_string (type));
|
||||
g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
|
||||
NM_SETTING_WIRELESS_SECURITY_WEP_KEY2, wep_key_type_to_string (type));
|
||||
if (key3 && !nm_utils_wep_key_valid (key3, type))
|
||||
printf (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
|
||||
NM_SETTING_WIRELESS_SECURITY_WEP_KEY3, wep_key_type_to_string (type));
|
||||
g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
|
||||
NM_SETTING_WIRELESS_SECURITY_WEP_KEY3, wep_key_type_to_string (type));
|
||||
|
||||
g_object_set (setting, prop, type, NULL);
|
||||
return TRUE;
|
||||
|
|
@ -4487,7 +4486,7 @@ dcb_check_feature_enabled (NMSettingDcb *s_dcb, const char *flags_prop)
|
|||
|
||||
g_object_get (s_dcb, flags_prop, &flags, NULL);
|
||||
if (!(flags & NM_SETTING_DCB_FLAG_ENABLE))
|
||||
printf (_("Warning: changes will have no effect until '%s' includes 1 (enabled)\n\n"), flags_prop);
|
||||
g_print (_("Warning: changes will have no effect until '%s' includes 1 (enabled)\n\n"), flags_prop);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -248,6 +248,9 @@ nmc_ip6_address_as_string (const struct in6_addr *ip, GError **error)
|
|||
void
|
||||
nmc_terminal_erase_line (void)
|
||||
{
|
||||
/* We intentionally use printf(), not g_print() here, to ensure that
|
||||
* GLib doesn't mistakenly try to convert the string.
|
||||
*/
|
||||
printf ("\33[2K\r");
|
||||
fflush (stdout);
|
||||
}
|
||||
|
|
@ -264,7 +267,7 @@ nmc_terminal_show_progress (const char *str)
|
|||
const char slashes[4] = {'|', '/', '-', '\\'};
|
||||
|
||||
nmc_terminal_erase_line ();
|
||||
printf ("%c %s", slashes[idx++], str ? str : "");
|
||||
g_print ("%c %s", slashes[idx++], str ? str : "");
|
||||
fflush (stdout);
|
||||
if (idx == 4)
|
||||
idx = 0;
|
||||
|
|
@ -432,7 +435,7 @@ nmc_get_user_input (const char *ask_str)
|
|||
size_t line_ln = 0;
|
||||
ssize_t num;
|
||||
|
||||
fprintf (stdout, "%s", ask_str);
|
||||
g_print ("%s", ask_str);
|
||||
num = getline (&line, &line_ln, stdin);
|
||||
|
||||
/* Remove newline from the string */
|
||||
|
|
@ -895,9 +898,9 @@ print_required_fields (NmCli *nmc, const NmcOutputField field_values[])
|
|||
line = g_strnfill (ML_HEADER_WIDTH, '=');
|
||||
width1 = strlen (fields.header_name);
|
||||
width2 = nmc_string_screen_width (fields.header_name, NULL);
|
||||
printf ("%s\n", line);
|
||||
printf ("%*s\n", (table_width + width2)/2 + width1 - width2, fields.header_name);
|
||||
printf ("%s\n", line);
|
||||
g_print ("%s\n", line);
|
||||
g_print ("%*s\n", (table_width + width2)/2 + width1 - width2, fields.header_name);
|
||||
g_print ("%s\n", line);
|
||||
g_free (line);
|
||||
}
|
||||
|
||||
|
|
@ -927,8 +930,8 @@ print_required_fields (NmCli *nmc, const NmcOutputField field_values[])
|
|||
j);
|
||||
width1 = strlen (tmp);
|
||||
width2 = nmc_string_screen_width (tmp, NULL);
|
||||
printf ("%-*s%s\n", terse ? 0 : ML_VALUE_INDENT+width1-width2, tmp,
|
||||
*p ? *p : not_set_str);
|
||||
g_print ("%-*s%s\n", terse ? 0 : ML_VALUE_INDENT+width1-width2, tmp,
|
||||
*p ? *p : not_set_str);
|
||||
g_free (tmp);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -942,14 +945,14 @@ print_required_fields (NmCli *nmc, const NmcOutputField field_values[])
|
|||
_(field_values[idx].name_l10n));
|
||||
width1 = strlen (tmp);
|
||||
width2 = nmc_string_screen_width (tmp, NULL);
|
||||
printf ("%-*s%s\n", terse ? 0 : ML_VALUE_INDENT+width1-width2, tmp,
|
||||
val ? val : not_set_str);
|
||||
g_print ("%-*s%s\n", terse ? 0 : ML_VALUE_INDENT+width1-width2, tmp,
|
||||
val ? val : not_set_str);
|
||||
g_free (tmp);
|
||||
}
|
||||
}
|
||||
if (pretty) {
|
||||
line = g_strnfill (ML_HEADER_WIDTH, '-');
|
||||
printf ("%s\n", line);
|
||||
g_print ("%s\n", line);
|
||||
g_free (line);
|
||||
}
|
||||
}
|
||||
|
|
@ -997,9 +1000,9 @@ print_required_fields (NmCli *nmc, const NmcOutputField field_values[])
|
|||
line = g_strnfill (table_width, '=');
|
||||
width1 = strlen (fields.header_name);
|
||||
width2 = nmc_string_screen_width (fields.header_name, NULL);
|
||||
printf ("%s\n", line);
|
||||
printf ("%*s\n", (table_width + width2)/2 + width1 - width2, fields.header_name);
|
||||
printf ("%s\n", line);
|
||||
g_print ("%s\n", line);
|
||||
g_print ("%*s\n", (table_width + width2)/2 + width1 - width2, fields.header_name);
|
||||
g_print ("%s\n", line);
|
||||
g_free (line);
|
||||
}
|
||||
|
||||
|
|
@ -1011,14 +1014,14 @@ print_required_fields (NmCli *nmc, const NmcOutputField field_values[])
|
|||
g_string_prepend (str, indent_str);
|
||||
g_free (indent_str);
|
||||
}
|
||||
printf ("%s\n", str->str);
|
||||
g_print ("%s\n", str->str);
|
||||
}
|
||||
|
||||
/* Print horizontal separator */
|
||||
if (!main_header_only && field_names && pretty) {
|
||||
if (str->len > 0) {
|
||||
line = g_strnfill (table_width, '-');
|
||||
printf ("%s\n", line);
|
||||
g_print ("%s\n", line);
|
||||
g_free (line);
|
||||
}
|
||||
}
|
||||
|
|
@ -1107,9 +1110,8 @@ nmc_versions_match (NmCli *nmc)
|
|||
if (dot) {
|
||||
dot = strchr (dot + 1, '.');
|
||||
if (dot && !strncmp (nm_ver, VERSION, dot-nm_ver)) {
|
||||
fprintf(stderr,
|
||||
_("Warning: nmcli (%s) and NetworkManager (%s) versions don't match. Use --nocheck to suppress the warning.\n"),
|
||||
VERSION, nm_ver);
|
||||
g_printerr (_("Warning: nmcli (%s) and NetworkManager (%s) versions don't match. Use --nocheck to suppress the warning.\n"),
|
||||
VERSION, nm_ver);
|
||||
match = TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,8 +61,6 @@ typedef struct {
|
|||
GSList *nmt_devices;
|
||||
} NmtConnectConnectionListPrivate;
|
||||
|
||||
static const char *strength_full, *strength_high, *strength_med, *strength_low, *strength_none;
|
||||
|
||||
/**
|
||||
* nmt_connect_connection_list_new:
|
||||
*
|
||||
|
|
@ -527,16 +525,7 @@ nmt_connect_connection_list_rebuild (NmtConnectConnectionList *list)
|
|||
if (nmtconn->ap) {
|
||||
guint8 strength = nm_access_point_get_strength (nmtconn->ap);
|
||||
|
||||
if (strength > 80)
|
||||
strength_col = strength_full;
|
||||
else if (strength > 55)
|
||||
strength_col = strength_high;
|
||||
else if (strength > 30)
|
||||
strength_col = strength_med;
|
||||
else if (strength > 5)
|
||||
strength_col = strength_low;
|
||||
else
|
||||
strength_col = strength_none;
|
||||
strength_col = nm_utils_wifi_strength_bars (strength);
|
||||
} else
|
||||
strength_col = NULL;
|
||||
|
||||
|
|
@ -608,30 +597,12 @@ static void
|
|||
nmt_connect_connection_list_class_init (NmtConnectConnectionListClass *list_class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (list_class);
|
||||
char *tmp;
|
||||
|
||||
g_type_class_add_private (list_class, sizeof (NmtConnectConnectionListPrivate));
|
||||
|
||||
/* virtual methods */
|
||||
object_class->constructed = nmt_connect_connection_list_constructed;
|
||||
object_class->finalize = nmt_connect_connection_list_finalize;
|
||||
|
||||
/* globals */
|
||||
tmp = nmt_newt_locale_from_utf8 ("\342\226\202\342\226\204\342\226\206\342\226\210");
|
||||
if (*tmp) {
|
||||
strength_full = /* ▂▄▆█ */ "\342\226\202\342\226\204\342\226\206\342\226\210";
|
||||
strength_high = /* ▂▄▆_ */ "\342\226\202\342\226\204\342\226\206_";
|
||||
strength_med = /* ▂▄__ */ "\342\226\202\342\226\204__";
|
||||
strength_low = /* ▂___ */ "\342\226\202___";
|
||||
strength_none = /* ____ */ "____";
|
||||
} else {
|
||||
strength_full = "****";
|
||||
strength_high = "*** ";
|
||||
strength_med = "** ";
|
||||
strength_low = "* ";
|
||||
strength_none = " ";
|
||||
}
|
||||
g_free (tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2100,6 +2100,66 @@ nm_utils_wifi_is_channel_valid (guint32 channel, const char *band)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_wifi_strength_bars:
|
||||
* @strength: the access point strength, from 0 to 100
|
||||
*
|
||||
* Converts @strength into a 4-character-wide graphical representation of
|
||||
* strength suitable for printing to stdout. If the current locale and terminal
|
||||
* support it, this will use unicode graphics characters to represent
|
||||
* "bars". Otherwise it will use 0 to 4 asterisks.
|
||||
*
|
||||
* Returns: the graphical representation of the access point strength
|
||||
*/
|
||||
const char *
|
||||
nm_utils_wifi_strength_bars (guint8 strength)
|
||||
{
|
||||
static const char *strength_full, *strength_high, *strength_med, *strength_low, *strength_none;
|
||||
|
||||
if (G_UNLIKELY (strength_full == NULL)) {
|
||||
gboolean can_show_graphics = TRUE;
|
||||
char *locale_str;
|
||||
|
||||
if (!g_get_charset (NULL)) {
|
||||
/* Non-UTF-8 locale */
|
||||
locale_str = g_locale_from_utf8 ("\342\226\202\342\226\204\342\226\206\342\226\210", -1, NULL, NULL, NULL);
|
||||
if (locale_str)
|
||||
g_free (locale_str);
|
||||
else
|
||||
can_show_graphics = FALSE;
|
||||
}
|
||||
|
||||
/* The linux console font doesn't have these characters */
|
||||
if (g_strcmp0 (g_getenv ("TERM"), "linux") == 0)
|
||||
can_show_graphics = FALSE;
|
||||
|
||||
if (can_show_graphics) {
|
||||
strength_full = /* ▂▄▆█ */ "\342\226\202\342\226\204\342\226\206\342\226\210";
|
||||
strength_high = /* ▂▄▆_ */ "\342\226\202\342\226\204\342\226\206_";
|
||||
strength_med = /* ▂▄__ */ "\342\226\202\342\226\204__";
|
||||
strength_low = /* ▂___ */ "\342\226\202___";
|
||||
strength_none = /* ____ */ "____";
|
||||
} else {
|
||||
strength_full = "****";
|
||||
strength_high = "*** ";
|
||||
strength_med = "** ";
|
||||
strength_low = "* ";
|
||||
strength_none = " ";
|
||||
}
|
||||
}
|
||||
|
||||
if (strength > 80)
|
||||
return strength_full;
|
||||
else if (strength > 55)
|
||||
return strength_high;
|
||||
else if (strength > 30)
|
||||
return strength_med;
|
||||
else if (strength > 5)
|
||||
return strength_low;
|
||||
else
|
||||
return strength_none;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_hwaddr_len:
|
||||
* @type: the type of address; either %ARPHRD_ETHER or %ARPHRD_INFINIBAND
|
||||
|
|
|
|||
|
|
@ -131,6 +131,8 @@ guint32 nm_utils_wifi_channel_to_freq (guint32 channel, const char *band);
|
|||
guint32 nm_utils_wifi_find_next_channel (guint32 channel, int direction, char *band);
|
||||
gboolean nm_utils_wifi_is_channel_valid (guint32 channel, const char *band);
|
||||
|
||||
const char *nm_utils_wifi_strength_bars (guint8 strength);
|
||||
|
||||
/**
|
||||
* NM_UTILS_HWADDR_LEN_MAX:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -931,6 +931,7 @@ global:
|
|||
nm_utils_wifi_find_next_channel;
|
||||
nm_utils_wifi_freq_to_channel;
|
||||
nm_utils_wifi_is_channel_valid;
|
||||
nm_utils_wifi_strength_bars;
|
||||
nm_utils_wpa_psk_valid;
|
||||
nm_vlan_flags_get_type;
|
||||
nm_vlan_priority_map_get_type;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue