From fe043ba806a714d302ca49fbe4a8b197bf9add9b Mon Sep 17 00:00:00 2001 From: Robert Love Date: Tue, 4 Oct 2005 15:23:06 +0000 Subject: [PATCH] 2005-10-04 Robert Love * gnome/applet/applet-dbus-devices.c, gnome/applet/applet.c, gnome/applet/nm-device.c, gnome/applet/nm-device.h, gnome/applet/wireless-applet.glade, src/nm-dbus-device.c: Display default route in the 'Connection Information' dialog, send primary and secondary name servers in in "getProperties" DBUS method, add network_device_{get,set}_{primary,secondary}_dns(), The primary and secondary domain name servers are crucial pieces of information that a user might need in debugging a network problem. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@991 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 11 +++ gnome/applet/applet-dbus-devices.c | 6 ++ gnome/applet/applet.c | 18 ++-- gnome/applet/nm-device.c | 40 +++++++++ gnome/applet/nm-device.h | 6 ++ gnome/applet/wireless-applet.glade | 128 +++++++++++++++++++++++++++-- src/nm-dbus-device.c | 16 ++++ src/nm-ip4-config.c | 1 - 8 files changed, 213 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4295d435f..7c32f55d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-10-04 Robert Love + + * gnome/applet/applet-dbus-devices.c, gnome/applet/applet.c, + gnome/applet/nm-device.c, gnome/applet/nm-device.h, + gnome/applet/wireless-applet.glade, src/nm-dbus-device.c: Display + default route in the 'Connection Information' dialog, send primary + and secondary name servers in in "getProperties" DBUS method, add + network_device_{get,set}_{primary,secondary}_dns(), The primary and + secondary domain name servers are crucial pieces of information + that a user might need in debugging a network problem. + 2005-10-04 Robert Love * gnome/applet/applet-dbus-devices.c, gnome/applet/applet.c, diff --git a/gnome/applet/applet-dbus-devices.c b/gnome/applet/applet-dbus-devices.c index b39b0f643..867194d4f 100644 --- a/gnome/applet/applet-dbus-devices.c +++ b/gnome/applet/applet-dbus-devices.c @@ -663,6 +663,8 @@ static void nmwa_dbus_device_properties_cb (DBusPendingCall *pcall, void *user_d const char * subnetmask = NULL; const char * hw_addr = NULL; const char * route = NULL; + const char * primary_dns = NULL; + const char * secondary_dns = NULL; dbus_uint32_t mode = 0; dbus_int32_t strength = -1; char * active_network_path = NULL; @@ -695,6 +697,8 @@ static void nmwa_dbus_device_properties_cb (DBusPendingCall *pcall, void *user_d DBUS_TYPE_STRING, &broadcast, DBUS_TYPE_STRING, &hw_addr, DBUS_TYPE_STRING, &route, + DBUS_TYPE_STRING, &primary_dns, + DBUS_TYPE_STRING, &secondary_dns, DBUS_TYPE_UINT32, &mode, DBUS_TYPE_INT32, &strength, DBUS_TYPE_BOOLEAN,&link_active, @@ -716,6 +720,8 @@ static void nmwa_dbus_device_properties_cb (DBusPendingCall *pcall, void *user_d network_device_set_broadcast (dev, broadcast); network_device_set_netmask (dev, subnetmask); network_device_set_route (dev, route); + network_device_set_primary_dns (dev, primary_dns); + network_device_set_secondary_dns (dev, secondary_dns); /* If the device already exists in our list for some reason, remove it so we * can add the new one with updated data. diff --git a/gnome/applet/applet.c b/gnome/applet/applet.c index cbc6894ea..5cc2e3a62 100644 --- a/gnome/applet/applet.c +++ b/gnome/applet/applet.c @@ -188,8 +188,8 @@ static void nmwa_show_socket_err (GtkWidget *info_dialog, const char *err) static gboolean nmwa_update_info (NMWirelessApplet *applet) { GtkWidget *info_dialog; - char *addr = NULL, *mask = NULL, *broadcast = NULL; - char *mac = NULL, *iface_and_type = NULL, *route = NULL; + char *addr = NULL, *broadcast = NULL, *primary_dns = NULL, *secondary_dns = NULL; + char *mac = NULL, *iface_and_type = NULL, *route = NULL, *mask = NULL; GtkWidget *label; const char *iface = NULL; NetworkDevice *dev; @@ -219,6 +219,8 @@ static gboolean nmwa_update_info (NMWirelessApplet *applet) addr = (char*) network_device_get_ip4_address (dev); mask = (char*) network_device_get_netmask (dev); route = (char*) network_device_get_route (dev); + primary_dns = (char*) network_device_get_primary_dns (dev); + secondary_dns = (char*) network_device_get_secondary_dns (dev); if (network_device_is_wired (dev)) iface_and_type = g_strdup_printf (_("Wired Ethernet (%s)"), iface); @@ -237,12 +239,18 @@ static gboolean nmwa_update_info (NMWirelessApplet *applet) label = get_label (info_dialog, applet->info_dialog_xml, "label-subnet-mask"); gtk_label_set_text (GTK_LABEL (label), mask); - label = get_label (info_dialog, applet->info_dialog_xml, "label-hardware-address"); - gtk_label_set_text (GTK_LABEL (label), mac); - label = get_label (info_dialog, applet->info_dialog_xml, "label-default-route"); gtk_label_set_text (GTK_LABEL (label), route); + label = get_label (info_dialog, applet->info_dialog_xml, "label-primary-dns"); + gtk_label_set_text (GTK_LABEL (label), primary_dns); + + label = get_label (info_dialog, applet->info_dialog_xml, "label-secondary-dns"); + gtk_label_set_text (GTK_LABEL (label), secondary_dns); + + label = get_label (info_dialog, applet->info_dialog_xml, "label-hardware-address"); + gtk_label_set_text (GTK_LABEL (label), mac); + g_free (iface_and_type); return TRUE; diff --git a/gnome/applet/nm-device.c b/gnome/applet/nm-device.c index 1baeaba18..2c21157fe 100644 --- a/gnome/applet/nm-device.c +++ b/gnome/applet/nm-device.c @@ -46,6 +46,8 @@ struct NetworkDevice char * netmask; char * udi; char * route; + char * primary_dns; + char * secondary_dns; gint strength; GSList * networks; NMActStage act_stage; @@ -492,6 +494,44 @@ void network_device_set_route (NetworkDevice *dev, const char *route) dev->route = route ? g_strdup (route) : NULL; } +/* + * Accessors for primary DNS + */ +const char *network_device_get_primary_dns (NetworkDevice *dev) +{ + g_return_val_if_fail (dev != NULL, NULL); + + return (dev->primary_dns); +} + +void network_device_set_primary_dns (NetworkDevice *dev, const char *dns) +{ + g_return_if_fail (dev != NULL); + + if (dev->primary_dns) + g_free (dev->primary_dns); + dev->primary_dns = dns ? g_strdup (dns) : NULL; +} + +/* + * Accessors for secondary DNS + */ +const char *network_device_get_secondary_dns (NetworkDevice *dev) +{ + g_return_val_if_fail (dev != NULL, NULL); + + return (dev->secondary_dns); +} + +void network_device_set_secondary_dns (NetworkDevice *dev, const char *dns) +{ + g_return_if_fail (dev != NULL); + + if (dev->secondary_dns) + g_free (dev->secondary_dns); + dev->secondary_dns = dns ? g_strdup (dns) : NULL; +} + /* * Accessors for driver support level */ diff --git a/gnome/applet/nm-device.h b/gnome/applet/nm-device.h index c9defb0de..98a21ca68 100644 --- a/gnome/applet/nm-device.h +++ b/gnome/applet/nm-device.h @@ -72,6 +72,12 @@ void network_device_set_ip4_address (NetworkDevice *dev, const char *addr) const char * network_device_get_route (NetworkDevice *dev); void network_device_set_route (NetworkDevice *dev, const char *route); +const char * network_device_get_primary_dns (NetworkDevice *dev); +void network_device_set_primary_dns (NetworkDevice *dev, const char *dns); + +const char * network_device_get_secondary_dns (NetworkDevice *dev); +void network_device_set_secondary_dns (NetworkDevice *dev, const char *dns); + NMDriverSupportLevel network_device_get_driver_support_level (NetworkDevice *dev); void network_device_set_driver_support_level (NetworkDevice *dev, NMDriverSupportLevel level); diff --git a/gnome/applet/wireless-applet.glade b/gnome/applet/wireless-applet.glade index 9a350ffd4..0e208aff4 100644 --- a/gnome/applet/wireless-applet.glade +++ b/gnome/applet/wireless-applet.glade @@ -1061,7 +1061,7 @@ Hex Key (WEP) 1 True - 10 + 12 2 False 3 @@ -1489,10 +1489,39 @@ Hex Key (WEP) + + + True + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 8 + 9 + fill + + + + True - Hardware Address: + Default Route: False False GTK_JUSTIFY_LEFT @@ -1517,6 +1546,34 @@ Hex Key (WEP) + + + True + Hardware Address: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 11 + 12 + fill + + + + True @@ -1539,17 +1596,17 @@ Hex Key (WEP) 1 2 - 8 - 9 + 11 + 12 fill - + True - Default Route: + Primary DNS: False False GTK_JUSTIFY_LEFT @@ -1575,7 +1632,35 @@ Hex Key (WEP) - + + True + Secondary DNS: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 10 + 11 + fill + + + + + + True True @@ -1602,6 +1687,35 @@ Hex Key (WEP) + + + + True + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 10 + 11 + fill + + + 0 diff --git a/src/nm-dbus-device.c b/src/nm-dbus-device.c index aa5d52dcd..7370c97a3 100644 --- a/src/nm-dbus-device.c +++ b/src/nm-dbus-device.c @@ -330,6 +330,8 @@ static DBusMessage *nm_dbus_device_get_properties (DBusConnection *connection, D gchar * broadcast; gchar * subnetmask; gchar * route; + gchar * primary_dns; + gchar * secondary_dns; struct ether_addr hw_addr; char hw_addr_buf[20]; char * hw_addr_buf_ptr = &hw_addr_buf[0]; @@ -346,6 +348,8 @@ static DBusMessage *nm_dbus_device_get_properties (DBusConnection *connection, D guint32 broadcast_addr = 0; guint32 subnetmask_addr = 0; guint32 route_addr = 0; + guint32 primary_dns_addr = 0; + guint32 secondary_dns_addr = 0; nm_device_get_hw_address (dev, &hw_addr); memset (hw_addr_buf, 0, 20); @@ -354,14 +358,24 @@ static DBusMessage *nm_dbus_device_get_properties (DBusConnection *connection, D ip4config = nm_device_get_ip4_config (dev); if (ip4config) { + guint32 nr_nameservers; + broadcast_addr = nm_ip4_config_get_broadcast (ip4config); subnetmask_addr = nm_ip4_config_get_netmask (ip4config); route_addr = nm_ip4_config_get_gateway (ip4config); + + nr_nameservers = nm_ip4_config_get_num_nameservers (ip4config); + if (nr_nameservers > 1) + secondary_dns_addr = nm_ip4_config_get_nameserver (ip4config, 1); + if (nr_nameservers > 0) + primary_dns_addr = nm_ip4_config_get_nameserver (ip4config, 0); } ip4_address = nm_utils_inet_ip4_address_as_string (nm_device_get_ip4_address (dev)); broadcast = nm_utils_inet_ip4_address_as_string (broadcast_addr); subnetmask = nm_utils_inet_ip4_address_as_string (subnetmask_addr); route = nm_utils_inet_ip4_address_as_string (route_addr); + primary_dns = nm_utils_inet_ip4_address_as_string (primary_dns_addr); + secondary_dns = nm_utils_inet_ip4_address_as_string (secondary_dns_addr); if (nm_device_is_wireless (dev)) { @@ -416,6 +430,8 @@ static DBusMessage *nm_dbus_device_get_properties (DBusConnection *connection, D DBUS_TYPE_STRING, &broadcast, DBUS_TYPE_STRING, &hw_addr_buf_ptr, DBUS_TYPE_STRING, &route, + DBUS_TYPE_STRING, &primary_dns, + DBUS_TYPE_STRING, &secondary_dns, DBUS_TYPE_UINT32, &mode, DBUS_TYPE_INT32, &strength, DBUS_TYPE_BOOLEAN,&link_active, diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index 6d1a8f327..e3a502ebd 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -199,7 +199,6 @@ guint32 nm_ip4_config_get_num_nameservers (NMIP4Config *config) return (g_slist_length (config->nameservers)); } - void nm_ip4_config_add_domain (NMIP4Config *config, const char *domain) { g_return_if_fail (config != NULL);