mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-02 08:27:59 +02:00
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.
This commit is contained in:
parent
3fe8d0eed4
commit
38afee1e9f
2 changed files with 43 additions and 1 deletions
|
|
@ -21,4 +21,5 @@ VOID:POINTER,STRING
|
|||
POINTER:POINTER
|
||||
VOID:STRING,BOXED
|
||||
BOOLEAN:POINTER,STRING,BOOLEAN,UINT,STRING,STRING
|
||||
BOOLEAN:VOID
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
|
@ -1669,6 +1671,36 @@ can_scan (NMDeviceWifi *self)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
@ -1676,7 +1708,7 @@ request_wireless_scan (gpointer 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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue