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>
11 #include "nsAutoPtr.h"
12 #include "nsCOMArray.h"
13 #include "nsWifiMonitor.h"
14 #include "nsWifiAccessPoint.h"
16 #include "nsServiceManagerUtils.h"
17 #include "nsComponentManagerUtils.h"
18 #include "nsIMutableArray.h"
20 using namespace mozilla
;
22 // defined in osx_corewlan.mm
23 // basically replaces accesspoints in the passed reference
24 // it lives in a separate file so that we can use objective c.
25 extern nsresult
GetAccessPointsFromWLAN(nsCOMArray
<nsWifiAccessPoint
> &accessPoints
);
28 nsWifiMonitor::DoScan()
30 // Regularly get the access point data.
32 nsCOMArray
<nsWifiAccessPoint
> lastAccessPoints
;
33 nsCOMArray
<nsWifiAccessPoint
> accessPoints
;
36 nsresult rv
= GetAccessPointsFromWLAN(accessPoints
);
40 bool accessPointsChanged
= !AccessPointsEqual(accessPoints
, lastAccessPoints
);
41 ReplaceArray(lastAccessPoints
, accessPoints
);
43 rv
= CallWifiListeners(lastAccessPoints
, accessPointsChanged
);
44 NS_ENSURE_SUCCESS(rv
, rv
);
46 // wait for some reasonable amount of time. pref?
47 LOG(("waiting on monitor\n"));
49 ReentrantMonitorAutoEnter
mon(mReentrantMonitor
);
50 mon
.Wait(PR_SecondsToInterval(kDefaultWifiScanInterval
));