1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/wifi/nsWifiScannerMac.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include <mach-o/dyld.h> 1.9 +#include <dlfcn.h> 1.10 +#include <unistd.h> 1.11 + 1.12 +#include "osx_wifi.h" 1.13 + 1.14 +#include "nsAutoPtr.h" 1.15 +#include "nsCOMArray.h" 1.16 +#include "nsWifiMonitor.h" 1.17 +#include "nsWifiAccessPoint.h" 1.18 + 1.19 +#include "nsServiceManagerUtils.h" 1.20 +#include "nsComponentManagerUtils.h" 1.21 +#include "nsIMutableArray.h" 1.22 + 1.23 +using namespace mozilla; 1.24 + 1.25 +// defined in osx_corewlan.mm 1.26 +// basically replaces accesspoints in the passed reference 1.27 +// it lives in a separate file so that we can use objective c. 1.28 +extern nsresult GetAccessPointsFromWLAN(nsCOMArray<nsWifiAccessPoint> &accessPoints); 1.29 + 1.30 +nsresult 1.31 +nsWifiMonitor::DoScan() 1.32 +{ 1.33 + // Regularly get the access point data. 1.34 + 1.35 + nsCOMArray<nsWifiAccessPoint> lastAccessPoints; 1.36 + nsCOMArray<nsWifiAccessPoint> accessPoints; 1.37 + 1.38 + do { 1.39 + nsresult rv = GetAccessPointsFromWLAN(accessPoints); 1.40 + if (NS_FAILED(rv)) 1.41 + return rv; 1.42 + 1.43 + bool accessPointsChanged = !AccessPointsEqual(accessPoints, lastAccessPoints); 1.44 + ReplaceArray(lastAccessPoints, accessPoints); 1.45 + 1.46 + rv = CallWifiListeners(lastAccessPoints, accessPointsChanged); 1.47 + NS_ENSURE_SUCCESS(rv, rv); 1.48 + 1.49 + // wait for some reasonable amount of time. pref? 1.50 + LOG(("waiting on monitor\n")); 1.51 + 1.52 + ReentrantMonitorAutoEnter mon(mReentrantMonitor); 1.53 + mon.Wait(PR_SecondsToInterval(60)); 1.54 + } 1.55 + while (mKeepGoing); 1.56 + 1.57 + return NS_OK; 1.58 +}