Commit bb36e068 authored by Dan Williams's avatar Dan Williams
Browse files

2005-06-09 Dan Williams <dcbw@redhat.com>

	* NetworkManager.h
		- Add NMWirelessScanMethod enum for scan methods

	* gnome/applet/applet-dbus-devices.c
		- (nmwa_dbus_update_scanning_enabled_cb): remove
		- (nmwa_dbus_update_scanning_enabled): remove
		- (nmwa_dbus_update_devices): don't call nmwa_dbus_update_scanning_enabled() anymore
			since it got removed
		- (nmwa_dbus_enable_scanning): remove

	* gnome/applet/applet-dbus-info.c
		- (nmi_dbus_signal_update_scan_method): new function, signal NetworkManager to
			update the wireless scanning method from NMI
		- (nmi_dbus_get_wireless_scan_method): new function, return wireless scanning
			method value to NetworkManager
		- (nmi_dbus_info_message_handler): respond to the "getWirelessScanMethod" method call

	* gnome/applet/applet-dbus-info.h
		- Add prototype for nmi_dbus_signal_update_scan_method

	* gnome/applet/applet.c
		- (scanning_menu_update): new function, update one GtkCheckMenuItem from the
			Wireless Scanning menu based on current wireless scan method
		- (nmwa_menu_scanning_item_activate): new function, callback for GTK "activate"
			signal for Wireless Scanning menu items, tell NetworkManager the new method
			and update our menu items to make sure the right one is checked
		- (nmwa_set_scanning_enabled_cb): remove
		- (nmwa_context_menu_update): remove references to pause_scanning_item
		- (nmwa_context_menu_create): remove pause_scanning_item, and add new Wireless
			Scanning menu item
		- (nmwa_gconf_get_wireless_scan_method): new method, pull wireless scanning method
			from GConf
		- nmwa_gconf_networks_notify_callback -> nmwa_gconf_info_notify_callback: generalize
			so we get notified of preference values too
		- (nmwa_get_instance): monitor GCONF_PATH_WIRELESS rather than GCONF_PATH_WIRELESS_NETWORKS

	* gnome/applet/applet.h
		- GCONF_PATH_WIRELESS added, one level below GCONF_PATH_WIRELESS_NETWORKS
		- Add wireless scan method member to applet data
		- Remove pause_scanning_item, add Wireless Scanning submenu

	* src/NetworkManager.c
		- (nm_data_new): default to NM_SCAN_METHOD_ON
		- (main): grab scanning method from NMI if we can

	* src/NetworkManagerDbus.c
		- (nm_dbus_update_wireless_scan_method_cb): new function, callback from
			nm_dbus_update_wireless_scan_method()
		- (nm_dbus_update_wireless_scan_method): new function to grab scanning method
			from NMI
		- (nm_dbus_nmi_is_running): redundant function, removed
		- (nm_dbus_signal_filter): trap "WirelessScanMethodUpdate" signal, grab scanning method
			when NMI comes back

	* src/NetworkManagerDevice.c
		- (nm_device_is_activated): return TRUE if the device is activated
		- (nm_device_wireless_scan): don't scan if the scan method is OFF, or if its AUTO
			and we are activated

	* src/nm-dbus-nm.c
		- (nm_dbus_nm_set_scanning_enabled): removed
		- nm_dbus_nm_get_scanning_enabled -> nm_dbus_nm_get_wireless_scan_method
		- (nm_dbus_nm_methods_setup): remove [get | set] ScanningEnabled and add "getWirelessScanMethod"


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@658 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 5ba7a465
2005-06-09 Dan Williams <dcbw@redhat.com>
* NetworkManager.h
- Add NMWirelessScanMethod enum for scan methods
* gnome/applet/applet-dbus-devices.c
- (nmwa_dbus_update_scanning_enabled_cb): remove
- (nmwa_dbus_update_scanning_enabled): remove
- (nmwa_dbus_update_devices): don't call nmwa_dbus_update_scanning_enabled() anymore
since it got removed
- (nmwa_dbus_enable_scanning): remove
* gnome/applet/applet-dbus-info.c
- (nmi_dbus_signal_update_scan_method): new function, signal NetworkManager to
update the wireless scanning method from NMI
- (nmi_dbus_get_wireless_scan_method): new function, return wireless scanning
method value to NetworkManager
- (nmi_dbus_info_message_handler): respond to the "getWirelessScanMethod" method call
* gnome/applet/applet-dbus-info.h
- Add prototype for nmi_dbus_signal_update_scan_method
* gnome/applet/applet.c
- (scanning_menu_update): new function, update one GtkCheckMenuItem from the
Wireless Scanning menu based on current wireless scan method
- (nmwa_menu_scanning_item_activate): new function, callback for GTK "activate"
signal for Wireless Scanning menu items, tell NetworkManager the new method
and update our menu items to make sure the right one is checked
- (nmwa_set_scanning_enabled_cb): remove
- (nmwa_context_menu_update): remove references to pause_scanning_item
- (nmwa_context_menu_create): remove pause_scanning_item, and add new Wireless
Scanning menu item
- (nmwa_gconf_get_wireless_scan_method): new method, pull wireless scanning method
from GConf
- nmwa_gconf_networks_notify_callback -> nmwa_gconf_info_notify_callback: generalize
so we get notified of preference values too
- (nmwa_get_instance): monitor GCONF_PATH_WIRELESS rather than GCONF_PATH_WIRELESS_NETWORKS
* gnome/applet/applet.h
- GCONF_PATH_WIRELESS added, one level below GCONF_PATH_WIRELESS_NETWORKS
- Add wireless scan method member to applet data
- Remove pause_scanning_item, add Wireless Scanning submenu
* src/NetworkManager.c
- (nm_data_new): default to NM_SCAN_METHOD_ON
- (main): grab scanning method from NMI if we can
* src/NetworkManagerDbus.c
- (nm_dbus_update_wireless_scan_method_cb): new function, callback from
nm_dbus_update_wireless_scan_method()
- (nm_dbus_update_wireless_scan_method): new function to grab scanning method
from NMI
- (nm_dbus_nmi_is_running): redundant function, removed
- (nm_dbus_signal_filter): trap "WirelessScanMethodUpdate" signal, grab scanning method
when NMI comes back
* src/NetworkManagerDevice.c
- (nm_device_is_activated): return TRUE if the device is activated
- (nm_device_wireless_scan): don't scan if the scan method is OFF, or if its AUTO
and we are activated
* src/nm-dbus-nm.c
- (nm_dbus_nm_set_scanning_enabled): removed
- nm_dbus_nm_get_scanning_enabled -> nm_dbus_nm_get_wireless_scan_method
- (nm_dbus_nm_methods_setup): remove [get | set] ScanningEnabled and add "getWirelessScanMethod"
2005-06-09 Dan Williams <dcbw@redhat.com>
* NetworkManager.h
......
......@@ -209,4 +209,16 @@ typedef enum NMActStage
} NMActStage;
/*
* Wireless scanning methods
*
*/
typedef enum NMWirelessScanMethod
{
NM_SCAN_METHOD_UNKNOWN = 0,
NM_SCAN_METHOD_ON,
NM_SCAN_METHOD_OFF,
NM_SCAN_METHOD_AUTO
} NMWirelessScanMethod;
#endif
......@@ -108,67 +108,6 @@ void nmwa_dbus_update_nm_state (NMWirelessApplet *applet)
}
/*
* nmwa_dbus_update_scanning_enabled_cb
*
* Callback from nmwa_dbus_update_scanning_enabled
*
*/
void nmwa_dbus_update_scanning_enabled_cb (DBusPendingCall *pcall, void *user_data)
{
DBusMessage * reply;
NMWirelessApplet * applet = (NMWirelessApplet *) user_data;
gboolean scanning_enabled;
g_return_if_fail (pcall != NULL);
g_return_if_fail (applet != NULL);
dbus_pending_call_ref (pcall);
if (!dbus_pending_call_get_completed (pcall))
goto out;
if (!(reply = dbus_pending_call_steal_reply (pcall)))
goto out;
if (message_is_error (reply))
{
dbus_message_unref (reply);
goto out;
}
if (dbus_message_get_args (reply, NULL, DBUS_TYPE_BOOLEAN, &scanning_enabled, DBUS_TYPE_INVALID))
applet->scanning_enabled = scanning_enabled;
dbus_message_unref (reply);
out:
dbus_pending_call_unref (pcall);
}
/*
* nmwa_dbus_update_scanning_enabled
*
* Get the scanning_enabled value from NetworkManager
*
*/
void nmwa_dbus_update_scanning_enabled (NMWirelessApplet *applet)
{
DBusMessage * message;
DBusPendingCall * pcall = NULL;
g_return_if_fail (applet != NULL);
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "getScanningEnabled")))
{
dbus_connection_send_with_reply (applet->connection, message, &pcall, -1);
dbus_message_unref (message);
if (pcall)
dbus_pending_call_set_notify (pcall, nmwa_dbus_update_scanning_enabled_cb, applet, NULL);
}
}
/*
* nmwa_dbus_update_wireless_enabled_cb
*
......@@ -1016,7 +955,6 @@ void nmwa_dbus_update_devices (NMWirelessApplet *applet)
dbus_pending_call_set_notify (pcall, nmwa_dbus_update_devices_cb, applet, NULL);
}
nmwa_dbus_update_scanning_enabled (applet);
nmwa_dbus_update_wireless_enabled (applet);
}
......@@ -1124,28 +1062,6 @@ void nmwa_dbus_create_network (DBusConnection *connection, NetworkDevice *dev, c
}
/*
* nmwa_dbus_enable_scanning
*
* Tell NetworkManager to start/stop scanning.
*
*/
void nmwa_dbus_enable_scanning (NMWirelessApplet *applet, gboolean enabled)
{
DBusMessage *message;
g_return_if_fail (applet != NULL);
g_return_if_fail (applet->connection != NULL);
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "setScanningEnabled")))
{
dbus_message_append_args (message, DBUS_TYPE_BOOLEAN, &enabled, DBUS_TYPE_INVALID);
dbus_connection_send (applet->connection, message, NULL);
nmwa_dbus_update_scanning_enabled (applet);
}
}
/*
* nmwa_dbus_enable_wireless
*
......
......@@ -114,6 +114,55 @@ void nmi_dbus_return_user_key (DBusConnection *connection, DBusMessage *message,
}
/*
* nmi_dbus_signal_update_scan_method
*
* Signal NetworkManager that it needs to update its wireless scanning method
*
*/
void nmi_dbus_signal_update_scan_method (DBusConnection *connection)
{
DBusMessage *message;
g_return_if_fail (connection != NULL);
message = dbus_message_new_signal (NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "WirelessScanMethodUpdate");
if (!message)
{
nm_warning ("nmi_dbus_signal_update_scan_method(): Not enough memory for new dbus message!");
return;
}
if (!dbus_connection_send (connection, message, NULL))
nm_warning ("nmi_dbus_signal_update_scan_method(): Could not raise the 'WirelessScanMethodUpdate' signal!");
dbus_message_unref (message);
}
/*
* nmi_dbus_get_wireless_scan_method
*
* Tell NetworkManager what wireless scanning method it should use
*
*/
static DBusMessage *nmi_dbus_get_wireless_scan_method (NMWirelessApplet *applet, DBusMessage *message)
{
DBusMessage * reply = NULL;
NMWirelessScanMethod method = NM_SCAN_METHOD_ON;
GConfEntry * entry;
g_return_val_if_fail (applet != NULL, NULL);
g_return_val_if_fail (message != NULL, NULL);
method = nmwa_gconf_get_wireless_scan_method (applet);
reply = dbus_message_new_method_return (message);
dbus_message_append_args (reply, DBUS_TYPE_UINT32, &method, DBUS_TYPE_INVALID);
return (reply);
}
/*
* nmi_dbus_signal_update_network
*
......@@ -913,6 +962,7 @@ DBusHandlerResult nmi_dbus_info_message_handler (DBusConnection *connection, DBu
reply = nmi_dbus_get_key_for_network (applet, message);
else if (strcmp ("cancelGetKeyForNetwork", method) == 0)
nmi_passphrase_dialog_schedule_cancel (applet);
#if 0 /* Not used at this time */
else if (strcmp ("networkNotFound", method) == 0)
{
const char * network;
......@@ -933,6 +983,9 @@ DBusHandlerResult nmi_dbus_info_message_handler (DBusConnection *connection, DBu
gtk_widget_destroy (GTK_WIDGET (dialog));
}
}
#endif
else if (strcmp ("getWirelessScanMethod", method) == 0)
reply = nmi_dbus_get_wireless_scan_method (applet, message);
else if (strcmp ("getNetworks", method) == 0)
reply = nmi_dbus_get_networks (applet, message);
else if (strcmp ("getNetworkProperties", method) == 0)
......
......@@ -31,6 +31,8 @@ DBusHandlerResult nmi_dbus_info_message_handler (DBusConnection *connection,
void nmi_dbus_return_user_key (DBusConnection *connection, DBusMessage *message, const char *passphrase, const int key_type);
void nmi_dbus_signal_update_scan_method (DBusConnection *connection);
void nmi_dbus_signal_update_network (DBusConnection *connection, const char *network, NMNetworkType type);
void nmi_dbus_signal_update_vpn_connection (DBusConnection *connection, const char *name);
......
......@@ -1137,6 +1137,50 @@ static void nmwa_menu_disconnect_vpn_item_activate (GtkMenuItem *item, gpointer
}
static void scanning_menu_update (GtkWidget *menu_item, GtkCheckMenuItem *active_item)
{
g_return_if_fail (active_item != NULL);
g_object_set_data (G_OBJECT (menu_item), "block-activate", GINT_TO_POINTER(1));
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), (GTK_CHECK_MENU_ITEM (menu_item) == active_item) ? TRUE : FALSE);
g_object_set_data (G_OBJECT (menu_item), "block-activate", GINT_TO_POINTER(0));
}
/*
* nmwa_menu_scanning_item_activate
*
* Handle a request to change scanning behavior
*
*/
static void nmwa_menu_scanning_item_activate (GtkMenuItem *item, gpointer user_data)
{
NMWirelessApplet * applet = (NMWirelessApplet *)user_data;
char * tag;
g_return_if_fail (item != NULL);
g_return_if_fail (applet != NULL);
if ((tag = g_object_get_data (G_OBJECT (item), "block-activate")))
if (GPOINTER_TO_INT(tag) == 1)
return;
if ((tag = g_object_get_data (G_OBJECT (item), "scan_method")))
{
NMWirelessScanMethod method = GPOINTER_TO_UINT (tag);
if ((method == NM_SCAN_METHOD_ON) || (method == NM_SCAN_METHOD_OFF) || (method == NM_SCAN_METHOD_AUTO))
gconf_client_set_int (applet->gconf_client, GCONF_PATH_WIRELESS "/scan_method", method, NULL);
}
/* Check only this menu item */
if (!applet->scanning_menu)
return;
gtk_container_foreach (GTK_CONTAINER (applet->scanning_menu), (GtkCallback) scanning_menu_update, (gpointer) item);
}
/*
* nmwa_menu_add_separator_item
*
......@@ -1492,13 +1536,6 @@ static void nmwa_menu_add_devices (GtkWidget *menu, NMWirelessApplet *applet)
}
static void nmwa_set_scanning_enabled_cb (GtkWidget *widget, NMWirelessApplet *applet)
{
g_return_if_fail (applet != NULL);
nmwa_dbus_enable_scanning (applet, !applet->scanning_enabled);
}
static void nmwa_set_wireless_enabled_cb (GtkWidget *widget, NMWirelessApplet *applet)
{
g_return_if_fail (applet != NULL);
......@@ -1645,29 +1682,12 @@ static void nmwa_context_menu_update (NMWirelessApplet *applet)
GtkWidget *image;
g_return_if_fail (applet != NULL);
g_return_if_fail (applet->pause_scanning_item != NULL);
g_return_if_fail (applet->stop_wireless_item != NULL);
g_mutex_lock (applet->data_mutex);
gtk_widget_destroy (applet->pause_scanning_item);
gtk_widget_destroy (applet->stop_wireless_item);
if (applet->scanning_enabled)
{
applet->pause_scanning_item = gtk_image_menu_item_new_with_label (_("Pause Wireless Scanning"));
image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_PAUSE, GTK_ICON_SIZE_MENU);
}
else
{
applet->pause_scanning_item = gtk_image_menu_item_new_with_label (_("Resume Wireless Scanning"));
image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_MENU);
}
g_signal_connect (G_OBJECT (applet->pause_scanning_item), "activate", G_CALLBACK (nmwa_set_scanning_enabled_cb), applet);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (applet->pause_scanning_item), image);
gtk_menu_shell_insert (GTK_MENU_SHELL (applet->context_menu), applet->pause_scanning_item, 0);
gtk_widget_show_all (applet->pause_scanning_item);
if (applet->wireless_enabled)
{
applet->stop_wireless_item = gtk_image_menu_item_new_with_label (_("Stop All Wireless Devices"));
......@@ -1698,25 +1718,49 @@ static GtkWidget *nmwa_context_menu_create (NMWirelessApplet *applet)
GtkWidget *menu;
GtkWidget *menu_item;
GtkWidget *image;
GtkWidget *scanning_subitem;
g_return_val_if_fail (applet != NULL, NULL);
menu = gtk_menu_new ();
applet->pause_scanning_item = gtk_image_menu_item_new_with_label (_("Pause Wireless Scanning"));
g_signal_connect (G_OBJECT (applet->pause_scanning_item), "activate", G_CALLBACK (nmwa_set_scanning_enabled_cb), applet);
image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_PAUSE, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (applet->pause_scanning_item), image);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), applet->pause_scanning_item);
/* Construct the wireless scanning submenu */
applet->scan_method = nmwa_gconf_get_wireless_scan_method (applet);
applet->scanning_item = gtk_menu_item_new_with_label (_("Wireless Scanning"));
applet->scanning_menu = gtk_menu_new ();
scanning_subitem = GTK_WIDGET (gtk_check_menu_item_new_with_label (_("On")));
g_object_set_data (G_OBJECT (scanning_subitem), "scan_method", GUINT_TO_POINTER (NM_SCAN_METHOD_ON));
if (applet->scan_method == NM_SCAN_METHOD_ON)
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (scanning_subitem), TRUE);
g_signal_connect (G_OBJECT (scanning_subitem), "activate", G_CALLBACK (nmwa_menu_scanning_item_activate), applet);
gtk_menu_shell_append (GTK_MENU_SHELL (applet->scanning_menu), GTK_WIDGET (scanning_subitem));
scanning_subitem = GTK_WIDGET (gtk_check_menu_item_new_with_label (_("Off")));
g_object_set_data (G_OBJECT (scanning_subitem), "scan_method", GINT_TO_POINTER (NM_SCAN_METHOD_OFF));
if (applet->scan_method == NM_SCAN_METHOD_OFF)
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (scanning_subitem), TRUE);
g_signal_connect (G_OBJECT (scanning_subitem), "activate", G_CALLBACK (nmwa_menu_scanning_item_activate), applet);
gtk_menu_shell_append (GTK_MENU_SHELL (applet->scanning_menu), GTK_WIDGET (scanning_subitem));
scanning_subitem = GTK_WIDGET (gtk_check_menu_item_new_with_label (_("Automatic")));
g_object_set_data (G_OBJECT (scanning_subitem), "scan_method", GINT_TO_POINTER (NM_SCAN_METHOD_AUTO));
if (applet->scan_method == NM_SCAN_METHOD_AUTO)
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (scanning_subitem), TRUE);
g_signal_connect (G_OBJECT (scanning_subitem), "activate", G_CALLBACK (nmwa_menu_scanning_item_activate), applet);
gtk_menu_shell_append (GTK_MENU_SHELL (applet->scanning_menu), GTK_WIDGET (scanning_subitem));
gtk_menu_item_set_submenu (GTK_MENU_ITEM (applet->scanning_item), applet->scanning_menu);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), applet->scanning_item);
/* Stop All Wireless Devices item */
applet->stop_wireless_item = gtk_image_menu_item_new_with_label (_("Stop All Wireless Devices"));
g_signal_connect (G_OBJECT (applet->stop_wireless_item), "activate", G_CALLBACK (nmwa_set_wireless_enabled_cb), applet);
image = gtk_image_new_from_stock (GTK_STOCK_STOP, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (applet->stop_wireless_item), image);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), applet->stop_wireless_item);
menu_item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
nmwa_menu_add_separator_item (menu);
menu_item = gtk_image_menu_item_new_with_label (_("Help"));
/* g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (nmwa_help_cb), applet); */
......@@ -1827,13 +1871,45 @@ static void nmwa_setup_widgets (NMWirelessApplet *applet)
applet->encryption_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
}
/*
* nmwa_gconf_get_wireless_scan_method
*
* Grab the wireless scan method from GConf
*
*/
NMWirelessScanMethod nmwa_gconf_get_wireless_scan_method (NMWirelessApplet *applet)
{
NMWirelessScanMethod method = NM_SCAN_METHOD_ON;
GConfEntry * entry;
g_return_val_if_fail (applet, NM_SCAN_METHOD_ON);
g_return_val_if_fail (applet->gconf_client, NM_SCAN_METHOD_ON);
if ((entry = gconf_client_get_entry (applet->gconf_client, GCONF_PATH_WIRELESS "/scan_method", NULL, TRUE, NULL)))
{
GConfValue * value = gconf_entry_get_value (entry);
if (value && (value->type == GCONF_VALUE_INT))
{
NMWirelessScanMethod temp_method = gconf_value_get_int (value);
if ((method == NM_SCAN_METHOD_ON) || (method == NM_SCAN_METHOD_OFF) || (method == NM_SCAN_METHOD_AUTO))
method = temp_method;
}
}
return method;
}
/*
* nmwa_gconf_networks_notify_callback
* nmwa_gconf_info_notify_callback
*
* Callback from gconf when wireless networking key/values have changed.
* Callback from gconf when wireless key/values have changed.
*
*/
static void nmwa_gconf_networks_notify_callback (GConfClient *client, guint connection_id, GConfEntry *entry, gpointer user_data)
static void nmwa_gconf_info_notify_callback (GConfClient *client, guint connection_id, GConfEntry *entry, gpointer user_data)
{
NMWirelessApplet * applet = (NMWirelessApplet *)user_data;
const char * key = NULL;
......@@ -1844,11 +1920,23 @@ static void nmwa_gconf_networks_notify_callback (GConfClient *client, guint conn
if ((key = gconf_entry_get_key (entry)))
{
int path_len = strlen (GCONF_PATH_WIRELESS_NETWORKS) + 1;
int net_path_len = strlen (GCONF_PATH_WIRELESS_NETWORKS) + 1;
if (strcmp (GCONF_PATH_WIRELESS "/scan_method", key) == 0)
{
GConfValue * value = gconf_entry_get_value (entry);
if (strncmp (GCONF_PATH_WIRELESS_NETWORKS"/", key, path_len) == 0)
if (value && (value->type == GCONF_VALUE_INT))
{
NMWirelessScanMethod method = gconf_value_get_int (value);
if ((method == NM_SCAN_METHOD_ON) || (method == NM_SCAN_METHOD_OFF) || (method == NM_SCAN_METHOD_AUTO))
nmi_dbus_signal_update_scan_method (applet->connection);
}
}
if (strncmp (GCONF_PATH_WIRELESS_NETWORKS"/", key, net_path_len) == 0)
{
char *network = g_strdup ((key + path_len));
char *network = g_strdup ((key + net_path_len));
char *slash_pos;
char *unescaped_network;
......@@ -1941,7 +2029,7 @@ static void nmwa_destroy (NMWirelessApplet *applet, gpointer user_data)
g_free (applet->glade_file);
gconf_client_notify_remove (applet->gconf_client, applet->gconf_net_notify_id);
gconf_client_notify_remove (applet->gconf_client, applet->gconf_prefs_notify_id);
gconf_client_notify_remove (applet->gconf_client, applet->gconf_vpn_notify_id);
g_object_unref (G_OBJECT (applet->gconf_client));
}
......@@ -1974,6 +2062,8 @@ static GtkWidget * nmwa_get_instance (NMWirelessApplet *applet)
applet->thread_context = NULL;
applet->thread_loop = NULL;
applet->thread_done = FALSE;
applet->scanning_menu = NULL;
applet->scanning_item = NULL;
applet->glade_file = g_build_filename (GLADEDIR, "wireless-applet.glade", NULL);
if (!applet->glade_file || !g_file_test (applet->glade_file, G_FILE_TEST_IS_REGULAR))
......@@ -1990,9 +2080,9 @@ static GtkWidget * nmwa_get_instance (NMWirelessApplet *applet)
if (!applet->gconf_client)
return NULL;
gconf_client_add_dir (applet->gconf_client, GCONF_PATH_WIRELESS_NETWORKS, GCONF_CLIENT_PRELOAD_NONE, NULL);
applet->gconf_net_notify_id = gconf_client_notify_add (applet->gconf_client, GCONF_PATH_WIRELESS_NETWORKS,
nmwa_gconf_networks_notify_callback, applet, NULL, NULL);
gconf_client_add_dir (applet->gconf_client, GCONF_PATH_WIRELESS, GCONF_CLIENT_PRELOAD_NONE, NULL);
applet->gconf_prefs_notify_id = gconf_client_notify_add (applet->gconf_client, GCONF_PATH_WIRELESS,
nmwa_gconf_info_notify_callback, applet, NULL, NULL);
gconf_client_add_dir (applet->gconf_client, GCONF_PATH_VPN_CONNECTIONS, GCONF_CLIENT_PRELOAD_NONE, NULL);
applet->gconf_vpn_notify_id = gconf_client_notify_add (applet->gconf_client, GCONF_PATH_VPN_CONNECTIONS,
......
......@@ -37,6 +37,7 @@
* Preference locations
*/
#define GCONF_PATH_WIRELESS_NETWORKS "/system/networking/wireless/networks"
#define GCONF_PATH_WIRELESS "/system/networking/wireless"
#define GCONF_PATH_VPN_CONNECTIONS "/system/networking/vpn_connections"
#define GCONF_PATH_PREFS "/apps/NetworkManagerApplet"
......@@ -66,7 +67,7 @@ typedef struct
DBusConnection * connection;
GConfClient * gconf_client;
guint gconf_net_notify_id;
guint gconf_prefs_notify_id;
guint gconf_vpn_notify_id;
char * glade_file;
guint redraw_timeout_id;
......@@ -80,7 +81,7 @@ typedef struct
/* Data model elements */
GMutex * data_mutex;
gboolean is_adhoc;
gboolean scanning_enabled;
NMWirelessScanMethod scan_method;
gboolean wireless_enabled;
gboolean nm_running;
......@@ -130,7 +131,8 @@ typedef struct
GtkTooltips * tooltips;
GtkWidget * context_menu;
GtkWidget * pause_scanning_item;
GtkWidget * scanning_item;
GtkWidget * scanning_menu;
GtkWidget * stop_wireless_item;
GtkWidget * passphrase_dialog;
......@@ -152,6 +154,8 @@ void nmwa_schedule_vpn_login_banner_dialog (NMWirelessApplet *applet, const c
NetworkDevice * nmwa_get_first_active_device (GSList *dev_list);
NMWirelessScanMethod nmwa_gconf_get_wireless_scan_method (NMWirelessApplet *applet);
int nm_null_safe_strcmp (const char *s1, const char *s2);
#endif
......@@ -437,7 +437,7 @@ static NMData *nm_data_new (gboolean enable_test_devices)
data->enable_test_devices = enable_test_devices;
data->scanning_enabled = TRUE;
data->scanning_method = NM_SCAN_METHOD_ON;
data->wireless_enabled = TRUE;
nm_policy_schedule_device_change_check (data);
......@@ -862,6 +862,7 @@ int main( int argc, char *argv[] )
{
nm_policy_schedule_allowed_ap_list_update (nm_data);
nm_dbus_vpn_schedule_vpn_connections_update (nm_data);
nm_dbus_update_wireless_scan_method (nm_data->dbus_connection, nm_data);
}
/* Right before we init hal, we have to make sure our mainloop
......
......@@ -557,6 +557,73 @@ void nm_dbus_cancel_get_user_key_for_network (DBusConnection *connection, NMActR
}
/*
* nm_dbus_update_wireless_scan_method_cb
*
* Callback from nm_dbus_update_wireless_scan_method
*
*/
static void nm_dbus_update_wireless_scan_method_cb (DBusPendingCall *pcall, NMData *data)
{
DBusMessage * reply;
NMWirelessScanMethod method = NM_SCAN_METHOD_UNKNOWN;