diff --git a/ChangeLog b/ChangeLog index 214010c285..7f28d064f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2006-01-30 Dan Williams + + * gnome/applet/applet-dbus-devices.c + - (nmwa_dbus_device_get_driver_cb, nmwa_dbus_device_get_driver): new + functions, grab device driver name from NetworkManager + - (nmwa_dbus_device_properties_cb): call functions to get driver + + * gnome/applet/applet.c + - (nmwa_update_info): show driver name in Connection Information + dialog + + * gnome/applet/nm-device.[ch] + - (network_device_get_driver, network_device_set_driver): add + accessors for driver name + + * gnome/applet/wireless-applet.glade + - Add line for driver name to Connection Information dialog + + * src/nm-dbus-device.c + - (nm_dbus_device_get_driver): new function to return driver name + - (nm_dbus_device_methods): hook up driver name function to dbus + + * test/nm-tool.c + - (get_driver_name): new function + - (detail_device): grab and show driver name + 2006-01-30 Robert Love * gnome/applet/applet.c: Apparently gtk_message_dialog_new_with_markup diff --git a/gnome/applet/applet-dbus-devices.c b/gnome/applet/applet-dbus-devices.c index d98e37f84d..fef86719e3 100644 --- a/gnome/applet/applet-dbus-devices.c +++ b/gnome/applet/applet-dbus-devices.c @@ -99,6 +99,96 @@ void nmwa_dbus_update_nm_state (NMWirelessApplet *applet) } +typedef struct DriverCBData +{ + NMWirelessApplet * applet; + NetworkDevice * dev; +} DriverCBData; + + +/* + * nmwa_dbus_device_get_driver_cb + * + * Callback from nmwa_dbus_update_wireless_enabled + * + */ +static void nmwa_dbus_device_get_driver_cb (DBusPendingCall *pcall, void *user_data) +{ + DBusMessage * reply; + NMWirelessApplet * applet = (NMWirelessApplet *) user_data; + DriverCBData * data = (DriverCBData *) user_data; + const char * driver; + + g_return_if_fail (pcall != NULL); + g_return_if_fail (applet != NULL); + + if (!(reply = dbus_pending_call_steal_reply (pcall))) + goto out; + + if (message_is_error (reply)) + { + DBusError err; + + dbus_error_init (&err); + dbus_set_error_from_message (&err, reply); + nm_warning ("%s(): dbus returned an error.\n (%s) %s\n", __func__, err.name, err.message); + dbus_error_free (&err); + dbus_message_unref (reply); + goto out; + } + + if (dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &driver, DBUS_TYPE_INVALID)) + { + if (data && data->dev) + network_device_set_driver (data->dev, driver); + } + + dbus_message_unref (reply); + +out: + if (data) + { + if (data->dev) + network_device_unref (data->dev); + g_free (data); + } + dbus_pending_call_unref (pcall); +} + + +/* + * nmwa_dbus_device_get_driver + * + * Get the a device's driver name + * + */ +static void nmwa_dbus_device_get_driver (NetworkDevice *dev, NMWirelessApplet *applet) +{ + DBusMessage * message; + DBusPendingCall * pcall = NULL; + const char * op; + + g_return_if_fail (applet != NULL); + g_return_if_fail (dev != NULL); + + op = network_device_get_nm_path (dev); + if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, op, NM_DBUS_INTERFACE_DEVICES, "getDriver"))) + { + dbus_connection_send_with_reply (applet->connection, message, &pcall, -1); + if (pcall) + { + DriverCBData * data = g_malloc0 (sizeof (DriverCBData)); + + network_device_ref (dev); + data->dev = dev; + data->applet = applet; + dbus_pending_call_set_notify (pcall, nmwa_dbus_device_get_driver_cb, data, NULL); + } + dbus_message_unref (message); + } +} + + /* * nmwa_dbus_update_wireless_enabled_cb * @@ -723,6 +813,7 @@ static void nmwa_dbus_device_properties_cb (DBusPendingCall *pcall, void *user_d } nmwa_dbus_update_device_info_from_hal (dev, applet); + nmwa_dbus_device_get_driver (dev, applet); if (type == DEVICE_TYPE_802_11_WIRELESS) { diff --git a/gnome/applet/applet.c b/gnome/applet/applet.c index d52085235d..b7ac739c45 100644 --- a/gnome/applet/applet.c +++ b/gnome/applet/applet.c @@ -187,7 +187,7 @@ static gboolean nmwa_update_info (NMWirelessApplet *applet) 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; + const char *iface = NULL, *driver = NULL; NetworkDevice *dev; info_dialog = glade_xml_get_widget (applet->info_dialog_xml, "info_dialog"); @@ -210,6 +210,8 @@ static gboolean nmwa_update_info (NMWirelessApplet *applet) return FALSE; } + if (!(driver = network_device_get_driver (dev))) + driver = "(unknown)"; mac = (char*) network_device_get_address (dev); broadcast = (char*) network_device_get_broadcast (dev); addr = (char*) network_device_get_ip4_address (dev); @@ -226,6 +228,9 @@ static gboolean nmwa_update_info (NMWirelessApplet *applet) label = get_label (info_dialog, applet->info_dialog_xml, "label-interface"); gtk_label_set_text (GTK_LABEL (label), iface_and_type); + label = get_label (info_dialog, applet->info_dialog_xml, "label-driver"); + gtk_label_set_text (GTK_LABEL (label), driver); + label = get_label (info_dialog, applet->info_dialog_xml, "label-ip-address"); gtk_label_set_text (GTK_LABEL (label), addr); diff --git a/gnome/applet/nm-device.c b/gnome/applet/nm-device.c index 8fd1b85d8a..5b06aadca5 100644 --- a/gnome/applet/nm-device.c +++ b/gnome/applet/nm-device.c @@ -34,6 +34,7 @@ struct NetworkDevice { int refcount; char * iface; + char * driver; char * desc; char * nm_path; NMDeviceType type; @@ -93,6 +94,7 @@ NetworkDevice *network_device_copy (NetworkDevice *src) network_device_ref (dev); dev->nm_path = g_strdup (src->nm_path); + dev->driver = g_strdup (src->driver); dev->type = src->type; dev->link = src->link; dev->addr = g_strdup (src->addr); @@ -153,6 +155,7 @@ void network_device_unref (NetworkDevice *dev) network_device_clear_wireless_networks (dev); g_free (dev->nm_path); g_free (dev->iface); + g_free (dev->driver); g_free (dev->route); g_free (dev->udi); g_free (dev->desc); @@ -400,6 +403,25 @@ guint network_device_get_num_wireless_networks (NetworkDevice *dev) } +/* + * Accessors for driver name + */ +const char *network_device_get_driver (NetworkDevice *dev) +{ + g_return_val_if_fail (dev != NULL, NULL); + + return dev->driver; +} + +void network_device_set_driver (NetworkDevice *dev, const char *driver) +{ + g_return_if_fail (dev != NULL); + + if (dev->driver) + g_free (dev->driver); + dev->driver = driver ? g_strdup (driver) : NULL; +} + /* * Accessors for hardware address */ diff --git a/gnome/applet/nm-device.h b/gnome/applet/nm-device.h index b286d48f5f..9925ccdf08 100644 --- a/gnome/applet/nm-device.h +++ b/gnome/applet/nm-device.h @@ -106,4 +106,7 @@ void network_device_set_desc (NetworkDevice *dev, const char *desc); NMActStage network_device_get_act_stage (NetworkDevice *dev); void network_device_set_act_stage (NetworkDevice *dev, NMActStage act_stage); +const char * network_device_get_driver (NetworkDevice *dev); +void network_device_set_driver (NetworkDevice *dev, const char *driver); + #endif diff --git a/gnome/applet/wireless-applet.glade b/gnome/applet/wireless-applet.glade index 4c811baac8..a2b859edf8 100644 --- a/gnome/applet/wireless-applet.glade +++ b/gnome/applet/wireless-applet.glade @@ -924,7 +924,7 @@ WEP 40/128-bit ASCII 1 True - 12 + 13 2 False 3 @@ -1070,345 +1070,6 @@ WEP 40/128-bit ASCII - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 3 - 4 - fill - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 3 - 4 - fill - - - - - - - Destination Address: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 4 - 5 - fill - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - True - 0 - 0 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 4 - 5 - fill - - - - - - - True - IP Address: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 5 - 6 - fill - - - - - - - True - True - - False - False - GTK_JUSTIFY_LEFT - False - True - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 5 - 6 - fill - - - - - - - True - Broadcast Address: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 6 - 7 - fill - - - - - - - True - True - - False - False - GTK_JUSTIFY_LEFT - False - True - 0 - 0 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 6 - 7 - fill - - - - - - - True - Subnet Mask: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 7 - 8 - fill - - - - - - - True - True - - False - False - GTK_JUSTIFY_LEFT - False - True - 0 - 0 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 7 - 8 - fill - - - - - - - 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 - Default Route: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 8 - 9 - fill - - - - True @@ -1427,6 +1088,63 @@ WEP 40/128-bit ASCII False 0 + + 0 + 1 + 12 + 13 + fill + + + + + + + True + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 12 + 13 + fill + + + + + + + True + Secondary DNS: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + 0 1 @@ -1438,7 +1156,7 @@ WEP 40/128-bit ASCII - + True True @@ -1484,34 +1202,6 @@ WEP 40/128-bit ASCII False 0 - - 0 - 1 - 9 - 10 - fill - - - - - - - True - Secondary DNS: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - 0 1 @@ -1544,6 +1234,34 @@ WEP 40/128-bit ASCII 1 2 + 10 + 11 + fill + + + + + + + True + Default Route: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 9 10 fill @@ -1552,7 +1270,7 @@ WEP 40/128-bit ASCII - + True True @@ -1573,8 +1291,346 @@ WEP 40/128-bit ASCII 1 2 - 10 - 11 + 9 + 10 + fill + + + + + + + True + Subnet Mask: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 8 + 9 + fill + + + + + + + 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 + Broadcast Address: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 7 + 8 + fill + + + + + + + True + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 7 + 8 + fill + + + + + + + True + IP Address: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 6 + 7 + fill + + + + + + + True + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 6 + 7 + fill + + + + + + + Destination Address: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 5 + 6 + fill + + + + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 5 + 6 + fill + + + + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 4 + 5 + fill + + + + + + + True + Driver: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 3 + 4 fill diff --git a/src/nm-dbus-device.c b/src/nm-dbus-device.c index e0a3b6c1b5..4cb0a844e3 100644 --- a/src/nm-dbus-device.c +++ b/src/nm-dbus-device.c @@ -295,6 +295,23 @@ static DBusMessage *nm_dbus_device_get_capabilities (DBusConnection *connection, return reply; } +static DBusMessage *nm_dbus_device_get_driver (DBusConnection *connection, DBusMessage *message, NMDbusCBData *data) +{ + DBusMessage *reply = NULL; + NMDevice *dev; + + g_return_val_if_fail (data && data->data && data->dev && connection && message, NULL); + + dev = data->dev; + if ((reply = dbus_message_new_method_return (message))) + { + const char * driver = nm_device_get_driver (dev); + dbus_message_append_args (reply, DBUS_TYPE_STRING, &driver, DBUS_TYPE_INVALID); + } + + return reply; +} + static DBusMessage *nm_dbus_device_set_link_active (DBusConnection *connection, DBusMessage *message, NMDbusCBData *data) { DBusMessage *reply = NULL; @@ -492,6 +509,7 @@ NMDbusMethodList *nm_dbus_device_methods_setup (void) nm_dbus_method_list_add_method (list, "getLinkActive", nm_dbus_device_get_link_active); nm_dbus_method_list_add_method (list, "setLinkActive", nm_dbus_device_set_link_active); nm_dbus_method_list_add_method (list, "getCapabilities", nm_dbus_device_get_capabilities); + nm_dbus_method_list_add_method (list, "getDriver", nm_dbus_device_get_driver); return (list); } diff --git a/test/nm-tool.c b/test/nm-tool.c index 429abde976..87874d44c9 100644 --- a/test/nm-tool.c +++ b/test/nm-tool.c @@ -191,6 +191,38 @@ static void detail_network (DBusConnection *connection, const char *path, const } +static char * +get_driver_name (DBusConnection *connection, const char *path) +{ + DBusMessage * message; + DBusMessage * reply; + char * driver = NULL; + DBusError error; + + g_return_val_if_fail (path != NULL, NULL); + + if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, path, NM_DBUS_INTERFACE_DEVICES, "getDriver"))) + { + nm_warning ("%s(): Couldn't allocate the dbus message", __func__); + return NULL; + } + + dbus_error_init (&error); + reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error); + dbus_message_unref (message); + if (dbus_error_is_set (&error)) + dbus_error_free (&error); + else if (reply) + { + if (dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &driver, DBUS_TYPE_INVALID)) + driver = g_strdup (driver); + dbus_message_unref (reply); + } + + return driver; +} + + static void detail_device (DBusConnection *connection, const char *path) { DBusMessage * message = NULL; @@ -256,6 +288,8 @@ static void detail_device (DBusConnection *connection, const char *path) DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &networks, &num_networks, DBUS_TYPE_INVALID)) { + char * driver; + printf ("- Device: %s ----------------------------------------------------------------\n", iface); /* General information */ @@ -264,6 +298,12 @@ static void detail_device (DBusConnection *connection, const char *path) print_string ("Type", "802.11 Wireless"); else if (type == DEVICE_TYPE_802_3_ETHERNET) print_string ("Type", "Wired"); + + if ((driver = get_driver_name (connection, path))) + print_string ("Driver", driver); + else + print_string ("Driver", "(unknown)"); + if (active) print_string ("Active", "yes"); else