summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-03-20 17:03:00 +0100
committerThomas Haller <thaller@redhat.com>2020-04-03 11:26:49 +0200
commitf1da7cb452e880c373e519201e8e2cd19d787c44 (patch)
tree6998fac0657c5c8c9a74aafd98c77a71a3c2ac32
parentd2ee666dd74a74b26021d32ccd280306a1680944 (diff)
downloadNetworkManager-f1da7cb452e880c373e519201e8e2cd19d787c44.tar.gz
wifi: add and use nm_device_wifi_get_scanning()
Don't read GObject properties. It's inefficient and harder to track who calls who.
-rw-r--r--src/devices/wifi/nm-device-olpc-mesh.c11
-rw-r--r--src/devices/wifi/nm-device-wifi.c10
-rw-r--r--src/devices/wifi/nm-device-wifi.h2
3 files changed, 16 insertions, 7 deletions
diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c
index 2850682b00..bcb75f84b2 100644
--- a/src/devices/wifi/nm-device-olpc-mesh.c
+++ b/src/devices/wifi/nm-device-olpc-mesh.c
@@ -130,7 +130,6 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{
NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device);
NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self);
- gboolean scanning;
/* disconnect companion device, if it is connected */
if (nm_device_get_act_request (NM_DEVICE (priv->companion))) {
@@ -145,8 +144,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
}
/* wait with continuing configuration until the companion device is done scanning */
- g_object_get (priv->companion, NM_DEVICE_WIFI_SCANNING, &scanning, NULL);
- if (scanning) {
+ if (nm_device_wifi_get_scanning (NM_DEVICE_WIFI (priv->companion))) {
priv->stage1_waiting = TRUE;
return NM_ACT_STAGE_RETURN_POSTPONE;
}
@@ -248,13 +246,14 @@ companion_notify_cb (NMDeviceWifi *companion, GParamSpec *pspec, gpointer user_d
{
NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (user_data);
NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self);
- gboolean scanning;
+
+ nm_assert (NM_IS_DEVICE_WIFI (companion));
+ nm_assert (priv->companion == (gpointer) companion);
if (!priv->stage1_waiting)
return;
- g_object_get (companion, NM_DEVICE_WIFI_SCANNING, &scanning, NULL);
- if (!scanning) {
+ if (!nm_device_wifi_get_scanning (NM_DEVICE_WIFI (companion))) {
priv->stage1_waiting = FALSE;
nm_device_activate_schedule_stage1_device_prepare (NM_DEVICE (self), FALSE);
}
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index 9959be858b..0885f2a5ae 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -209,6 +209,14 @@ _ap_dump (NMDeviceWifi *self,
nm_wifi_ap_to_string (ap, buf, sizeof (buf), now_msec));
}
+gboolean
+nm_device_wifi_get_scanning (NMDeviceWifi *self)
+{
+ g_return_val_if_fail (NM_IS_DEVICE_WIFI (self), FALSE);
+
+ return NM_DEVICE_WIFI_GET_PRIVATE (self)->is_scanning;
+}
+
static void
_notify_scanning (NMDeviceWifi *self)
{
@@ -3276,7 +3284,7 @@ get_property (GObject *object, guint prop_id,
nm_dbus_utils_g_value_set_object_path (value, priv->current_ap);
break;
case PROP_SCANNING:
- g_value_set_boolean (value, priv->is_scanning);
+ g_value_set_boolean (value, nm_device_wifi_get_scanning (self));
break;
case PROP_LAST_SCAN:
g_value_set_int64 (value,
diff --git a/src/devices/wifi/nm-device-wifi.h b/src/devices/wifi/nm-device-wifi.h
index d861d24712..280856efaf 100644
--- a/src/devices/wifi/nm-device-wifi.h
+++ b/src/devices/wifi/nm-device-wifi.h
@@ -42,4 +42,6 @@ void _nm_device_wifi_request_scan (NMDeviceWifi *self,
GPtrArray *nmtst_ssids_options_to_ptrarray (GVariant *value, GError **error);
+gboolean nm_device_wifi_get_scanning (NMDeviceWifi *self);
+
#endif /* __NETWORKMANAGER_DEVICE_WIFI_H__ */