Commit 0215ad40 authored by Jiří Klimeš's avatar Jiří Klimeš

cli: use setting_details() to simplify printing connection details

parent 0c7bf6ba
...@@ -269,6 +269,7 @@ nmc_connection_detail (NMConnection *connection, NmCli *nmc) ...@@ -269,6 +269,7 @@ nmc_connection_detail (NMConnection *connection, NmCli *nmc)
/* Loop through the required settings and print them. */ /* Loop through the required settings and print them. */
for (i = 0; i < print_settings_array->len; i++) { for (i = 0; i < print_settings_array->len; i++) {
NMSetting *setting;
int section_idx = g_array_index (print_settings_array, int, i); int section_idx = g_array_index (print_settings_array, int, i);
if (nmc->print_output != NMC_PRINT_TERSE && !nmc->multiline_output && was_output) if (nmc->print_output != NMC_PRINT_TERSE && !nmc->multiline_output && was_output)
...@@ -276,204 +277,11 @@ nmc_connection_detail (NMConnection *connection, NmCli *nmc) ...@@ -276,204 +277,11 @@ nmc_connection_detail (NMConnection *connection, NmCli *nmc)
was_output = FALSE; was_output = FALSE;
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[0].name)) { setting = nm_connection_get_setting_by_name (connection, nmc_fields_settings_names[section_idx].name);
NMSettingConnection *s_con = nm_connection_get_setting_connection (connection); if (setting) {
if (s_con) { setting_details (setting, nmc);
setting_connection_details (s_con, nmc); was_output = TRUE;
was_output = TRUE; continue;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[1].name)) {
NMSettingWired *s_wired = nm_connection_get_setting_wired (connection);
if (s_wired) {
setting_wired_details (s_wired, nmc);
was_output = TRUE;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[2].name)) {
NMSetting8021x *s_8021X = nm_connection_get_setting_802_1x (connection);
if (s_8021X) {
setting_802_1X_details (s_8021X, nmc);
was_output = TRUE;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[3].name)) {
NMSettingWireless *s_wireless = nm_connection_get_setting_wireless (connection);
if (s_wireless) {
setting_wireless_details (s_wireless, nmc);
was_output = TRUE;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[4].name)) {
NMSettingWirelessSecurity *s_wsec = nm_connection_get_setting_wireless_security (connection);
if (s_wsec) {
setting_wireless_security_details (s_wsec, nmc);
was_output = TRUE;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[5].name)) {
NMSettingIP4Config *s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (s_ip4) {
setting_ip4_config_details (s_ip4, nmc);
was_output = TRUE;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[6].name)) {
NMSettingIP6Config *s_ip6 = nm_connection_get_setting_ip6_config (connection);
if (s_ip6) {
setting_ip6_config_details (s_ip6, nmc);
was_output = TRUE;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[7].name)) {
NMSettingSerial *s_serial = nm_connection_get_setting_serial (connection);
if (s_serial) {
setting_serial_details (s_serial, nmc);
was_output = TRUE;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[8].name)) {
NMSettingPPP *s_ppp = nm_connection_get_setting_ppp (connection);
if (s_ppp) {
setting_ppp_details (s_ppp, nmc);
was_output = TRUE;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[9].name)) {
NMSettingPPPOE *s_pppoe = nm_connection_get_setting_pppoe (connection);
if (s_pppoe) {
setting_pppoe_details (s_pppoe, nmc);
was_output = TRUE;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[10].name)) {
NMSettingGsm *s_gsm = nm_connection_get_setting_gsm (connection);
if (s_gsm) {
setting_gsm_details (s_gsm, nmc);
was_output = TRUE;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[11].name)) {
NMSettingCdma *s_cdma = nm_connection_get_setting_cdma (connection);
if (s_cdma) {
setting_cdma_details (s_cdma, nmc);
was_output = TRUE;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[12].name)) {
NMSettingBluetooth *s_bluetooth = nm_connection_get_setting_bluetooth (connection);
if (s_bluetooth) {
setting_bluetooth_details (s_bluetooth, nmc);
was_output = TRUE;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[13].name)) {
NMSettingOlpcMesh *s_olpc_mesh = nm_connection_get_setting_olpc_mesh (connection);
if (s_olpc_mesh) {
setting_olpc_mesh_details (s_olpc_mesh, nmc);
was_output = TRUE;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[14].name)) {
NMSettingVPN *s_vpn = nm_connection_get_setting_vpn (connection);
if (s_vpn) {
setting_vpn_details (s_vpn, nmc);
was_output = TRUE;
continue;
}
}
#if WITH_WIMAX
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[15].name)) {
NMSettingWimax *s_wimax = nm_connection_get_setting_wimax (connection);
if (s_wimax) {
setting_wimax_details (s_wimax, nmc);
was_output = TRUE;
continue;
}
}
#endif
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[16].name)) {
NMSettingInfiniband *s_infiniband = nm_connection_get_setting_infiniband (connection);
if (s_infiniband) {
setting_infiniband_details (s_infiniband, nmc);
was_output = TRUE;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[17].name)) {
NMSettingBond *s_bond = nm_connection_get_setting_bond (connection);
if (s_bond) {
setting_bond_details (s_bond, nmc);
was_output = TRUE;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[18].name)) {
NMSettingVlan *s_vlan = nm_connection_get_setting_vlan (connection);
if (s_vlan) {
setting_vlan_details (s_vlan, nmc);
was_output = TRUE;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[19].name)) {
NMSettingAdsl *s_adsl = nm_connection_get_setting_adsl (connection);
if (s_adsl) {
setting_adsl_details (s_adsl, nmc);
was_output = TRUE;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[20].name)) {
NMSettingBridge *s_bridge = nm_connection_get_setting_bridge (connection);
if (s_bridge) {
setting_bridge_details (s_bridge, nmc);
was_output = TRUE;
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[21].name)) {
NMSettingBridgePort *s_bridge_port = nm_connection_get_setting_bridge_port (connection);
if (s_bridge_port) {
setting_bridge_port_details (s_bridge_port, nmc);
was_output = TRUE;
continue;
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment