Re: [PATCH 2/4] wifi: expose a ScanDone signal on DBus when the supplicant is done scanning.



On Thu, 2014-09-04 at 22:04 -0400, Mathieu Trudel-Lapierre wrote:
Signed-off-by: Mathieu Trudel-Lapierre <mathieu trudel-lapierre canonical com>
---
 introspection/nm-device-wifi.xml  |  6 ++++++
 src/devices/wifi/nm-device-wifi.c | 12 ++++++++++++
 src/devices/wifi/nm-device-wifi.h |  1 +
 3 files changed, 19 insertions(+)

diff --git a/introspection/nm-device-wifi.xml b/introspection/nm-device-wifi.xml
index 65c7b71..c0ed607 100644
--- a/introspection/nm-device-wifi.xml
+++ b/introspection/nm-device-wifi.xml
@@ -118,6 +118,12 @@
         </tp:docstring>
     </signal>
 
+    <signal name="ScanDone">
+        <tp:docstring>
+            Emitted when the device has finished scanning for new APs.
+        </tp:docstring>
+    </signal>
+
     <tp:flags name="NM_802_11_DEVICE_CAP" type="u">
       <tp:docstring>
         Flags describing the capabilities of a wireless device.
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index 41a75da..e1d9343 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -107,6 +107,7 @@ enum {
      ACCESS_POINT_ADDED,
      ACCESS_POINT_REMOVED,
      SCANNING_ALLOWED,
+     SCAN_DONE,
 
      LAST_SIGNAL
 };
@@ -1636,6 +1637,9 @@ supplicant_iface_scan_done_cb (NMSupplicantInterface *iface,
 
      _LOGD (LOGD_WIFI_SCAN, "scan %s", success ? "successful" : "failed");
 
+     if (priv->pending_scan_id)
+             g_signal_emit (self, signals[SCAN_DONE], 0, NULL);
+
      schedule_scan (self, success);

I think we'll have the same problem here as we've talked about on IRC,
where nm-supplicant-interface.c::scan_request_cb() emits SCAN_DONE a bit
too early, after the D-Bus call has returned.  So not fixing that issue
would cause the NMDeviceWifi D-Bus signal to be emitted too early too,
most of the time.

Other than that, the patch works for me.

Dan

 
      /* Ensure that old APs get removed, which otherwise only
@@ -3449,6 +3453,14 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
                            scanning_allowed_accumulator, NULL, NULL,
                            G_TYPE_BOOLEAN, 0);
 
+     signals[SCAN_DONE] =
+             g_signal_new ("scan-done",
+                           G_OBJECT_CLASS_TYPE (object_class),
+                           G_SIGNAL_RUN_FIRST,
+                           G_STRUCT_OFFSET (NMDeviceWifiClass, scan_done),
+                           NULL, NULL, NULL,
+                           G_TYPE_NONE, 0);
+
      nm_dbus_manager_register_exported_type (nm_dbus_manager_get (),
                                              G_TYPE_FROM_CLASS (klass),
                                              &dbus_glib_nm_device_wifi_object_info);
diff --git a/src/devices/wifi/nm-device-wifi.h b/src/devices/wifi/nm-device-wifi.h
index 538aef0..d64a582 100644
--- a/src/devices/wifi/nm-device-wifi.h
+++ b/src/devices/wifi/nm-device-wifi.h
@@ -80,6 +80,7 @@ struct _NMDeviceWifiClass
      void (*access_point_added)   (NMDeviceWifi *device, NMAccessPoint *ap);
      void (*access_point_removed) (NMDeviceWifi *device, NMAccessPoint *ap);
      gboolean (*scanning_allowed) (NMDeviceWifi *device);
+     void (*scan_done) (NMDeviceWifi *device);
 };
 





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]