From 4fb9663e6206160efd6cc057ad6549147b7932f2 Mon Sep 17 00:00:00 2001 From: Jirka Klimes Date: Fri, 19 Feb 2010 15:26:43 +0100 Subject: [PATCH] 'nmcli con status': new columns added to active connections output Service, Drivers and UUID columns was added to the output of active connections. Mainly Drivers entry is useful to match drivers and connections. Note: There are other information that could be useful, however the output format has to be better thought up. --- src/connections.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/connections.c b/src/connections.c index 3fa428a..4780660 100644 --- a/src/connections.c +++ b/src/connections.c @@ -233,10 +233,26 @@ show_active_connection (gpointer data, gpointer user_data) const char *active_path; NMConnectionScope active_service_scope; NMSettingConnection *s_con; + const GPtrArray *devices; + GString *dev_str; + int i; + + dev_str = g_string_new (NULL); active_path = nm_active_connection_get_connection (active); active_service_scope = nm_active_connection_get_scope (active); + /* Get devices of the active connection */ + devices = nm_active_connection_get_devices (active); + for (i = 0; devices && (i < devices->len); i++) { + NMDevice *device = g_ptr_array_index (devices, i); + + g_string_append (dev_str, nm_device_get_iface (device)); + g_string_append_c (dev_str, ','); + } + if (dev_str->len > 0) + g_string_truncate (dev_str, dev_str->len - 1); /* Cut off last ',' */ + for (iter = con_list; iter; iter = g_slist_next (iter)) { NMConnection *connection = (NMConnection *) iter->data; const char *con_path = nm_connection_get_path (connection); @@ -246,11 +262,19 @@ show_active_connection (gpointer data, gpointer user_data) /* this connection is active */ s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION); g_assert (s_con != NULL); - print_table_line (0, nm_active_connection_get_default (active) ? _("yes") : _("no"), 8, nm_setting_connection_get_id (s_con), 0, NULL); + // FIXME: Fix the output + print_table_line (0, nm_active_connection_get_default (active) ? _("yes") : _("no"), 8, + nm_active_connection_get_service_name (active), 45, +// nm_active_connection_get_specific_object (active), 0, +// nm_active_connection_get_connection (active), 0, + dev_str->str, 10, + nm_setting_connection_get_uuid (s_con), 38, + nm_setting_connection_get_id (s_con), 0, NULL); } } + g_string_free (dev_str, TRUE); } static NMCResultCode @@ -266,10 +290,11 @@ do_connections_status (NmCli *nmc, int argc, char **argv) active_cons = nm_client_get_active_connections (nmc->client); + // FIXME: Fix the output if (nmc->print_output == NMC_PRINT_PRETTY) - print_table_header (_("Active connections"), _("Default"), 8, _("Name"), 20, NULL); + print_table_header (_("Active connections"), _("Default"), 8, _("Service"), 45, _("Drivers"), 10, _("UUID"), 38, _("Name"), 20, NULL); else if (nmc->print_output == NMC_PRINT_NORMAL) - print_table_line (0, _("Default"), 8, _("Name"), 0, NULL); + print_table_line (0, _("Default"), 8, _("Service"), 45, _("Drivers"), 10, _("UUID"), 38, _("Name"), 0, NULL); if (active_cons && active_cons->len) { g_ptr_array_foreach ((GPtrArray *) active_cons, show_active_connection, (gpointer) nmc->system_connections); -- 2.11.4.GIT