netwerk/wifi/nsWifiScannerMac.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 "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);
    27 nsresult
    28 nsWifiMonitor::DoScan()
    29 {
    30   // Regularly get the access point data.
    32   nsCOMArray<nsWifiAccessPoint> lastAccessPoints;
    33   nsCOMArray<nsWifiAccessPoint> accessPoints;
    35   do {
    36     nsresult rv = GetAccessPointsFromWLAN(accessPoints);
    37     if (NS_FAILED(rv))
    38       return rv;
    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(60));
    51   }
    52   while (mKeepGoing);
    54   return NS_OK;
    55 }

mercurial