From 14ae87c1a1ba9b4636f809a0e2226a5cee2fcd5a Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 28 Apr 2005 01:54:46 +0000 Subject: [PATCH] 2005-04-27 Dan Williams * Fix choosing of wireless networks and "Other wireless network..." from the applet * Warn and exit if icons cannot be found git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@590 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 5 +++++ gnome/applet/applet-dbus-devices.c | 9 ++++----- gnome/applet/applet-dbus-devices.h | 2 +- gnome/applet/applet.c | 22 +++++++++++++++++--- gnome/applet/applet.h | 1 - gnome/applet/other-network-dialog.c | 5 +---- src/nm-dbus-nm.c | 31 +++++++---------------------- 7 files changed, 37 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index d1da641683..d308254ff2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-04-27 Dan Williams + + * Fix choosing of wireless networks and "Other wireless network..." from the applet + * Warn and exit if icons cannot be found + 2005-04-27 Dan Williams Patch from Tom Parker: diff --git a/gnome/applet/applet-dbus-devices.c b/gnome/applet/applet-dbus-devices.c index 87867b538b..5dc8bf5e5a 100644 --- a/gnome/applet/applet-dbus-devices.c +++ b/gnome/applet/applet-dbus-devices.c @@ -1141,7 +1141,7 @@ void nmwa_dbus_device_remove_one_device (NMWirelessApplet *applet, const char *d * possibly a specific wireless network too. * */ -void nmwa_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, WirelessNetwork *net, +void nmwa_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, const char *essid, NMEncKeyType key_type, const char *passphrase) { DBusMessage *message; @@ -1155,17 +1155,16 @@ void nmwa_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, Wirel if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "setActiveDevice"))) { const char *dev_path = network_device_get_nm_path (dev); - const char *net_path = net ? wireless_network_get_nm_path (net) : NULL; - if ((network_device_get_type (dev) == DEVICE_TYPE_WIRELESS_ETHERNET) && net && net_path) + if ((network_device_get_type (dev) == DEVICE_TYPE_WIRELESS_ETHERNET) && essid) { - nm_info ("Forcing device '%s' and network '%s' %s passphrase\n", dev_path, wireless_network_get_essid (net), passphrase ? "with" : "without"); + nm_info ("Forcing device '%s' and network '%s' %s passphrase\n", dev_path, essid, passphrase ? "with" : "without"); if (passphrase == NULL) passphrase = ""; dbus_message_append_args (message, DBUS_TYPE_OBJECT_PATH, &dev_path, - DBUS_TYPE_OBJECT_PATH, &net_path, + DBUS_TYPE_STRING, &essid, DBUS_TYPE_STRING, &passphrase, DBUS_TYPE_INT32, &key_type, DBUS_TYPE_INVALID); diff --git a/gnome/applet/applet-dbus-devices.h b/gnome/applet/applet-dbus-devices.h index 09150b87ff..153b562372 100644 --- a/gnome/applet/applet-dbus-devices.h +++ b/gnome/applet/applet-dbus-devices.h @@ -44,7 +44,7 @@ void nmwa_dbus_device_remove_one_device (NMWirelessApplet *applet, const cha void nmwa_dbus_device_update_one_network (NMWirelessApplet *applet, const char *dev_path, const char *net_path, const char *active_net_path); void nmwa_dbus_device_remove_one_network (NMWirelessApplet *applet, const char *dev_path, const char *net_path); -void nmwa_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, WirelessNetwork *net, NMEncKeyType key_type, const char *passphrase); +void nmwa_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, const char *essid, NMEncKeyType key_type, const char *passphrase); void nmwa_dbus_create_network (DBusConnection *connection, NetworkDevice *dev, const char *essid, NMEncKeyType key_type, const char *passphrase); #endif diff --git a/gnome/applet/applet.c b/gnome/applet/applet.c index 2acad32ff1..da9bae9bf0 100644 --- a/gnome/applet/applet.c +++ b/gnome/applet/applet.c @@ -914,7 +914,7 @@ static void nmwa_menu_item_activate (GtkMenuItem *item, gpointer user_data) if (dev) { - nmwa_dbus_set_device (applet->connection, dev, net, -1, NULL); + nmwa_dbus_set_device (applet->connection, dev, wireless_network_get_essid (net), -1, NULL); network_device_unref (dev); } } @@ -1887,7 +1887,6 @@ static void nmwa_icons_free (NMWirelessApplet *applet) { gint i; - g_object_unref (applet->no_nm_icon); g_object_unref (applet->no_connection_icon); g_object_unref (applet->wired_icon); g_object_unref (applet->adhoc_icon); @@ -1914,11 +1913,11 @@ nmwa_icons_load_from_disk (NMWirelessApplet *applet, GtkIconTheme *icon_theme) { char * name; int i; + gboolean success = TRUE; /* Assume icons are square */ gint icon_size = 22; - applet->no_nm_icon = gtk_icon_theme_load_icon (icon_theme, "nm-device-broken", icon_size, 0, NULL); applet->no_connection_icon = gtk_icon_theme_load_icon (icon_theme, "nm-no-connection", icon_size, 0, NULL); applet->wired_icon = gtk_icon_theme_load_icon (icon_theme, "nm-device-wired", icon_size, 0, NULL); applet->adhoc_icon = gtk_icon_theme_load_icon (icon_theme, "nm-adhoc", icon_size, 0, NULL); @@ -1930,11 +1929,18 @@ nmwa_icons_load_from_disk (NMWirelessApplet *applet, GtkIconTheme *icon_theme) applet->wireless_75_icon = gtk_icon_theme_load_icon (icon_theme, "nm-signal-75", icon_size, 0, NULL); applet->wireless_100_icon = gtk_icon_theme_load_icon (icon_theme, "nm-signal-100", icon_size, 0, NULL); + if (!applet->no_connection_icon || !applet->wired_icon || !applet->adhoc_icon || !applet->vpn_lock_icon + || !applet->wireless_00_icon || !applet->wireless_25_icon || !applet->wireless_50_icon || !applet->wireless_75_icon + || !applet->wireless_100_icon) + success = FALSE; + for (i = 0; i < NUM_WIRED_CONNECTING_FRAMES; i++) { name = g_strdup_printf ("nm-connecting%02d", i+1); applet->wired_connecting_icons[i] = gtk_icon_theme_load_icon (icon_theme, name, icon_size, 0, NULL); g_free (name); + if (!applet->wired_connecting_icons[i]) + success = FALSE; } for (i = 0; i < NUM_WIRELESS_CONNECTING_FRAMES; i++) @@ -1942,6 +1948,8 @@ nmwa_icons_load_from_disk (NMWirelessApplet *applet, GtkIconTheme *icon_theme) name = g_strdup_printf ("nm-connecting%02d", i+1); applet->wireless_connecting_icons[i] = gtk_icon_theme_load_icon (icon_theme, name, icon_size, 0, NULL); g_free (name); + if (!applet->wireless_connecting_icons[i]) + success = FALSE; } for (i = 0; i < NUM_WIRELESS_SCANNING_FRAMES; i++) @@ -1949,6 +1957,14 @@ nmwa_icons_load_from_disk (NMWirelessApplet *applet, GtkIconTheme *icon_theme) name = g_strdup_printf ("nm-detect%02d", i+1); applet->wireless_scanning_icons[i] = gtk_icon_theme_load_icon (icon_theme, name, icon_size, 0, NULL); g_free (name); + if (!applet->wireless_scanning_icons[i]) + success = FALSE; + } + + if (!success) + { + show_warning_dialog (_("The NetworkManager applet could not find some required resources. It cannot continue.\n")); + exit (1); } } diff --git a/gnome/applet/applet.h b/gnome/applet/applet.h index c35da35ced..71cfc13367 100644 --- a/gnome/applet/applet.h +++ b/gnome/applet/applet.h @@ -102,7 +102,6 @@ typedef struct GSList * dbus_vpn_connections; VPNConnection * dbus_active_vpn; - GdkPixbuf * no_nm_icon; GdkPixbuf * no_connection_icon; GdkPixbuf * wired_icon; GdkPixbuf * adhoc_icon; diff --git a/gnome/applet/other-network-dialog.c b/gnome/applet/other-network-dialog.c index 85ae332ee5..80e6f2ce2a 100644 --- a/gnome/applet/other-network-dialog.c +++ b/gnome/applet/other-network-dialog.c @@ -348,7 +348,6 @@ void nmwa_other_network_dialog_run (NMWirelessApplet *applet, gboolean create_ne if (essid[0] != '\000') { NMEncKeyType nm_key_type; - WirelessNetwork * net = network_device_get_wireless_network_by_essid (def_dev, essid); /* FIXME: allow picking of the wireless device, we currently just * use the first one found in our device list. @@ -375,10 +374,8 @@ void nmwa_other_network_dialog_run (NMWirelessApplet *applet, gboolean create_ne if (create_network) nmwa_dbus_create_network (applet->connection, def_dev, essid, nm_key_type, passphrase); else - nmwa_dbus_set_device (applet->connection, def_dev, net, nm_key_type, passphrase); + nmwa_dbus_set_device (applet->connection, def_dev, essid, nm_key_type, passphrase); - if (net) - wireless_network_unref (net); network_device_unref (def_dev); } } diff --git a/src/nm-dbus-nm.c b/src/nm-dbus-nm.c index 5d8645ab01..9aa89ca039 100644 --- a/src/nm-dbus-nm.c +++ b/src/nm-dbus-nm.c @@ -151,11 +151,9 @@ static DBusMessage *nm_dbus_nm_set_active_device (DBusConnection *connection, DB NMDevice * dev = NULL; DBusMessage * reply = NULL; char * dev_path = NULL; - char * net_path = NULL; + const char * essid = NULL; const char * key = NULL; const int key_type = -1; - DBusError error; - NMAccessPoint * ap = NULL; g_return_val_if_fail (connection != NULL, NULL); g_return_val_if_fail (message != NULL, NULL); @@ -163,27 +161,19 @@ static DBusMessage *nm_dbus_nm_set_active_device (DBusConnection *connection, DB g_return_val_if_fail (data->data != NULL, NULL); /* Try to grab both device _and_ network first, and if that fails then just the device. */ - dbus_error_init (&error); - if (!dbus_message_get_args (message, &error, DBUS_TYPE_OBJECT_PATH, &dev_path, - DBUS_TYPE_OBJECT_PATH, &net_path, + if (!dbus_message_get_args (message, NULL, DBUS_TYPE_OBJECT_PATH, &dev_path, + DBUS_TYPE_STRING, &essid, DBUS_TYPE_STRING, &key, DBUS_TYPE_INT32, &key_type, DBUS_TYPE_INVALID)) { - if (dbus_error_is_set (&error)) - dbus_error_free (&error); - /* So if that failed, try getting just the device */ - dbus_error_init (&error); - if (!dbus_message_get_args (message, &error, DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_INVALID)) + if (!dbus_message_get_args (message, NULL, DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_INVALID)) { - if (dbus_error_is_set (&error)) - dbus_error_free (&error); - reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, "InvalidArguments", "NetworkManager::setActiveDevice called with invalid arguments."); goto out; } else nm_info ("FORCE: device '%s'", dev_path); - } else nm_info ("FORCE: device '%s', network '%s'", dev_path, net_path); + } else nm_info ("FORCE: device '%s', network '%s'", dev_path, essid); /* So by now we have a valid device and possibly a network as well */ dev_path = nm_dbus_unescape_object_path (dev_path); @@ -196,15 +186,8 @@ static DBusMessage *nm_dbus_nm_set_active_device (DBusConnection *connection, DB goto out; } - if (net_path) - { - net_path = nm_dbus_unescape_object_path (net_path); - ap = nm_device_ap_list_get_ap_by_obj_path (dev, net_path); - g_free (net_path); - } - /* Make sure network is valid and device is wireless */ - if (nm_device_is_wireless (dev) && !ap) + if (nm_device_is_wireless (dev) && !essid) { reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, "InvalidArguments", "NetworkManager::setActiveDevice called with invalid arguments."); @@ -217,7 +200,7 @@ static DBusMessage *nm_dbus_nm_set_active_device (DBusConnection *connection, DB nm_device_deactivate (dev, FALSE); nm_schedule_state_change_signal_broadcast (data->data); - nm_device_schedule_force_use (dev, nm_ap_get_essid (ap), key, key_type); + nm_device_schedule_force_use (dev, essid, key, key_type); out: