Bug 1654678 Part 2 - Make CUPSPrinter own its CUPS dest data r=nordzilla
[gecko.git] / netwerk / wifi / nsWifiScannerMac.cpp
blob4b8757fd105113276f175f9dcc811112f3c732f0
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include <mach-o/dyld.h>
6 #include <dlfcn.h>
7 #include <unistd.h>
9 #include "osx_wifi.h"
11 #include "nsCOMArray.h"
12 #include "nsWifiMonitor.h"
13 #include "nsWifiAccessPoint.h"
15 #include "nsServiceManagerUtils.h"
16 #include "nsComponentManagerUtils.h"
18 using namespace mozilla;
20 // defined in osx_corewlan.mm
21 // basically replaces accesspoints in the passed reference
22 // it lives in a separate file so that we can use objective c.
23 extern nsresult GetAccessPointsFromWLAN(
24 nsCOMArray<nsWifiAccessPoint>& accessPoints);
26 nsresult nsWifiMonitor::DoScan() {
27 // Regularly get the access point data.
29 nsCOMArray<nsWifiAccessPoint> lastAccessPoints;
30 nsCOMArray<nsWifiAccessPoint> accessPoints;
32 do {
33 nsresult rv = GetAccessPointsFromWLAN(accessPoints);
34 if (NS_FAILED(rv)) return rv;
36 bool accessPointsChanged =
37 !AccessPointsEqual(accessPoints, lastAccessPoints);
38 ReplaceArray(lastAccessPoints, accessPoints);
40 rv = CallWifiListeners(lastAccessPoints, accessPointsChanged);
41 NS_ENSURE_SUCCESS(rv, rv);
43 // wait for some reasonable amount of time. pref?
44 LOG(("waiting on monitor\n"));
46 ReentrantMonitorAutoEnter mon(mReentrantMonitor);
47 mon.Wait(PR_SecondsToInterval(kDefaultWifiScanInterval));
48 } while (mKeepGoing);
50 return NS_OK;