Export "scan now" command over D-Bus



We're developing a custom UI for an embedded device, and would like to
provide a "Scan Now" button in the UI to force an immediate rescan of
the wireless network.  This feature may be generally useful: certainly
I often see stale networks on my laptop when I resume from suspend,
and it would be nice not to have to wait 20s for the next scheduled
scan.

The attached patch is very small, as the functionality is already
present in network-manager, just not exported.  Comments?
 --scott

-- 
        (http://cscott.net)
commit d4df20a021d1a9d45dd34e0127d4ae6106c17631
Author: C. Scott Ananian <cscott litl com>
Date:   Thu Mar 26 14:45:23 2009 -0400

    Add ScanNow command to org.freedesktop.NetworkManager.Device.Wireless

diff --git a/introspection/nm-device-wifi.xml b/introspection/nm-device-wifi.xml
index 6b31b3a..69aaf56 100644
--- a/introspection/nm-device-wifi.xml
+++ b/introspection/nm-device-wifi.xml
@@ -13,6 +13,12 @@
         Get the list of access points visible to this device.
       </tp:docstring>
     </method>
+    <method name="ScanNow">
+      <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_scan_now"/>
+      <tp:docstring>
+        Request an immediate scan of visible access points.
+      </tp:docstring>
+    </method>
 
     <property name="HwAddress" type="s" access="read">
       <tp:docstring>
diff --git a/src/nm-device-wifi.c b/src/nm-device-wifi.c
index f0ed948..9d677ba 100644
--- a/src/nm-device-wifi.c
+++ b/src/nm-device-wifi.c
@@ -56,6 +56,8 @@
 static gboolean impl_device_get_access_points (NMDeviceWifi *device,
                                                GPtrArray **aps,
                                                GError **err);
+static gboolean impl_device_scan_now (NMDeviceWifi *device,
+									  GError **err);
 
 #include "nm-device-wifi-glue.h"
 
@@ -1149,6 +1151,15 @@ impl_device_get_access_points (NMDeviceWifi *self,
 	return TRUE;
 }
 
+static gboolean
+impl_device_scan_now (NMDeviceWifi *self, GError **err)
+{
+	/* Request a scan to get latest results */
+	cancel_pending_scan(self);
+	request_wireless_scan(self);
+	return TRUE;
+}
+
 /*
  * nm_device_get_mode
  *


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