netwerk/wifi/nsWifiScannerMac.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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