summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Drake <dsd@laptop.org>2009-07-15 17:59:18 (GMT)
committerDan Williams <dcbw@redhat.com>2009-07-15 17:59:18 (GMT)
commit38afee1e9fb7858a713b55017c6e9edc588cea13 (patch)
tree5068aac1aadedf87f016b2859c5af4ad075a333f
parent3fe8d0eed4c1e2b4c4c2d4454e5ec68d2272d2c3 (diff)
wifi: allow wifi scans to be inhibited by other devices
Like the OLPC mesh interface, which uses the same actual MAC & radio as the OLPC wifi device, and thus when mesh is active the wifi shouldn't be scanning.
-rw-r--r--marshallers/nm-marshal.list1
-rw-r--r--src/nm-device-wifi.c43
2 files changed, 43 insertions, 1 deletions
diff --git a/marshallers/nm-marshal.list b/marshallers/nm-marshal.list
index 970fe24..6b855f9 100644
--- a/marshallers/nm-marshal.list
+++ b/marshallers/nm-marshal.list
@@ -21,4 +21,5 @@ VOID:POINTER,STRING
POINTER:POINTER
VOID:STRING,BOXED
BOOLEAN:POINTER,STRING,BOOLEAN,UINT,STRING,STRING
+BOOLEAN:VOID
diff --git a/src/nm-device-wifi.c b/src/nm-device-wifi.c
index 3538825..0fbff74 100644
--- a/src/nm-device-wifi.c
+++ b/src/nm-device-wifi.c
@@ -37,6 +37,7 @@
#include "nm-device-interface.h"
#include "nm-device-private.h"
#include "nm-utils.h"
+#include "nm-marshal.h"
#include "NetworkManagerUtils.h"
#include "NetworkManagerPolicy.h"
#include "nm-activation-request.h"
@@ -92,6 +93,7 @@ enum {
ACCESS_POINT_REMOVED,
HIDDEN_AP_FOUND,
PROPERTIES_CHANGED,
+ SCANNING_ALLOWED,
LAST_SIGNAL
};
@@ -1670,13 +1672,43 @@ can_scan (NMDeviceWifi *self)
}
static gboolean
+scan_allowed_accumulator (GSignalInvocationHint *ihint,
+ GValue *return_accu,
+ const GValue *handler_return,
+ gpointer data)
+{
+ if (!g_value_get_boolean (handler_return))
+ g_value_set_boolean (return_accu, FALSE);
+ return TRUE;
+}
+
+static gboolean
+scan_allowed (NMDeviceWifi *self)
+{
+ GValue instance = { 0, };
+ GValue retval = { 0, };
+
+ g_value_init (&instance, G_TYPE_OBJECT);
+ g_value_take_object (&instance, self);
+
+ g_value_init (&retval, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&retval, TRUE);
+
+ /* Use g_signal_emitv() rather than g_signal_emit() to avoid the return
+ * value being changed if no handlers are connected */
+ g_signal_emitv (&instance, signals[SCANNING_ALLOWED], 0, &retval);
+
+ return g_value_get_boolean (&retval);
+}
+
+static gboolean
request_wireless_scan (gpointer user_data)
{
NMDeviceWifi *self = NM_DEVICE_WIFI (user_data);
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
gboolean backoff = FALSE;
- if (can_scan (self)) {
+ if (can_scan (self) && scan_allowed (self)) {
if (nm_supplicant_interface_request_scan (priv->supplicant.iface)) {
/* success */
backoff = TRUE;
@@ -3615,6 +3647,15 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
nm_properties_changed_signal_new (object_class,
G_STRUCT_OFFSET (NMDeviceWifiClass, properties_changed));
+ signals[SCANNING_ALLOWED] =
+ g_signal_new ("scanning-allowed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ scan_allowed_accumulator, NULL,
+ _nm_marshal_BOOLEAN__VOID,
+ G_TYPE_BOOLEAN, 0);
+
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), &dbus_glib_nm_device_wifi_object_info);
dbus_g_error_domain_register (NM_WIFI_ERROR, NULL, NM_TYPE_WIFI_ERROR);