mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 05:11:03 +00:00
6bedaf2149
- Bug 1193050 - Update the copy of GentiumPlus used in font-inspector test. r=jdaggett (253fce5764)
- align tests (5b817116a0)
- Bug 1246106 - pass aStyleBorder as reference to ComputeBorderOverflow. r=mats (53ccaa1282)
- align tests (81b3943058)
- Bug 1269080 - Convert NS_ERROR to NS_WARNING when setting an invalid scheme in nsSimpleURI. r=mcmanus (cad86c963d)
- Bug 1248558 - "[Static Analysis][Unintentional integer overflow][CacheFile.cpp::PreloadChunk, CacheFile.cpp::GetChunkLocked]". r=michal (6a9e34dfbe)
- Bug 1121672 - Make CacheFile::IsDoomed() protect mHandle with lock, r=michal (9e925b903a)
- Bug 1253040 - Do not write metadata if CacheFile is killed, r=honzab (c0378088b2)
- grammar as 1268922 (c801618b1d)
- Bug 1247548 - Changed nsCookieService::EnsureReadComplete and nsCookieService::PurgeCookeis to allocate nsTArray instead of AutoTArray. r=jdm (0e2bb0465e)
- var-let (1702e664dc)
- Bug 1233813 - Fix mDNS bug in resolving services with no TXT records. r=schien (4ce7e5fca0)
- Bug 1266632 - Add a null check in nsHostResolver::SizeOfIncludingThis. r=sworkman. (035d4a7130)
- Bug 1267000 - null deref with spdy proxy r=hurley (099db40d0f)
- Bug 1240932 - figure out 'network id' on Linux. r=mcmanus (47ceb12a70)
- Bug 1240932: add Telemetry to record network id successes, r=mcmanus (6985d1a4ce)
- Bug 1205158 - Use channel->Open2() netwerk/test/ (r=sicking) (64de01cda3)
- Bug 1240932 - figure out 'network id' on OS X, r=mcmanus (7ee4875835)
- Bug 1240932 - figure out 'network id' on Windows, r=mcmanus (3227a81c14)
- Bug 1188644 - Use channel->ascynOpen2 in netwerk/test (r=mcmanus) (7097897cdc)
- Bug 1264887: |nsWifiScannerDBus|: Hold DBusMessage references in |RefPtr|, r=josh (7e68e8663f)
- Bug 1196638 - Infer the proper button for synthesized mouse clicks on all callsites. r=jmaher (838230baaa)
- Bug 1258532 - Port test_bug574596.html to mochitest-plain in order to enable it on e10s; r=mrbkap (ae5693ab54)
- Bug 1252855 - allow setting a specific list of prefs from the content process, r=mrbkap,margaret,haik (b13645826a)
- Bug 1215965 - Remove use of non-standard features from toolkit/components/social/SocialService.jsm. r=mixedpuppy (a1d79f295c)
- ship cmpiler for XP (ac60884173)
- Bug 1262814 - Warn on Wlanapi.dll load or init fail, don't fail assertion, r=mcmanus (aa1335320a)
- Bug 1137151: Marked destructors of ref-counted time-zone classes as protected, r=dhylands (5668226442)
- Bug 1225549 - Modify the data type of mThreshold of NetworkParams to long long from long. r=ettseng (7164a517ac)
- Bug 1139805 - B2G NetworkManager: move NetworkManager.js out of EXTRA_PP_COMPONENTS in moz.build. r=echen (e857f53cfc)
- Bug 1087608 - ensuring multitap gestures do not resolve to explore. r=eeejay (6c4b603738)
- bug 1259023 - make nsIAccessible.{Next,Prev}Sibling work with proxied accessibles r=yzen (84b47a82e0)
- bug 1259023 - make nsIAccessible.indexInParent work on proxied accessibles r=yzen (3531b45e35)
- bug 1250882 - implement xpcAccessible::GetState() for proxied accessibles r=davidb (5e58214441)
- bug 1250882 - implement xpcAccessible::Name() for proxied accessibles r=davidb (4b11af6ecc)
- bug 1250882 - implement xpcAccessible::GetDescription() for proxied accessibles r=davidb (d0d0e133fb)
- bug 1250882 - implement xpcAccessible::GetLanguage() for proxied accessibles r=davidb (88e98a5b24)
- bug 1250882 - implement xpcAccessible::GetValue() for proxied accessibles r=davidb (9ad4347d45)
- bug 1250882 - implement xpcAccessible::GetBounds() for proxied accessibles r=davidb (e67f7c551b)
- Bug 1249930 - menupoup shouldn't look for children in XBL anonymous content, r=davidb (14b3e39954)
- Bug 1243233 - Test ALLOW_COMPILER_WARNINGS instead of WARNINGS_AS_ERRORS, and move it to after it is set, r=glandium (216c407d20)
- Bug 1245992 - Update the Safe Browsing phishing interstitial page. r=flod,past (80afbfc6c9)
- Bug 1245260 - Ignore redundant calls to RestyleManager::IncrementAnimationGeneration; r=dbaron (e35571b613)
- Bug 1182778, r=margaret,f=bz (b379c97f8e)
- Bug 1258212 - Hook the parent up to the cild for registerContentHandler. r=gwright (039c75d4d5)
196 lines
6.4 KiB
C++
196 lines
6.4 KiB
C++
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "nsWifiAccessPoint.h"
|
|
#include "win_wifiScanner.h"
|
|
|
|
// Moz headers (alphabetical)
|
|
#include "win_wlanLibrary.h"
|
|
|
|
#define DOT11_BSS_TYPE_UNUSED static_cast<DOT11_BSS_TYPE>(0)
|
|
|
|
class InterfaceScanCallbackData {
|
|
public:
|
|
InterfaceScanCallbackData(uint32_t numInterfaces)
|
|
: mCurrentlyScanningInterfaces(numInterfaces)
|
|
{
|
|
mAllInterfacesDoneScanningEvent =
|
|
::CreateEvent(nullptr, // null security
|
|
TRUE, // manual reset event
|
|
FALSE, // initially nonsignaled
|
|
nullptr); // not named
|
|
MOZ_ASSERT(NULL != mAllInterfacesDoneScanningEvent);
|
|
}
|
|
|
|
~InterfaceScanCallbackData()
|
|
{
|
|
::CloseHandle(mAllInterfacesDoneScanningEvent);
|
|
}
|
|
|
|
void
|
|
OnInterfaceScanComplete()
|
|
{
|
|
uint32_t val = ::InterlockedDecrement(&mCurrentlyScanningInterfaces);
|
|
if (!val) {
|
|
::SetEvent(mAllInterfacesDoneScanningEvent);
|
|
}
|
|
}
|
|
|
|
void
|
|
WaitForAllInterfacesToFinishScanning(uint32_t msToWait)
|
|
{
|
|
::WaitForSingleObject(mAllInterfacesDoneScanningEvent,
|
|
msToWait);
|
|
}
|
|
|
|
private:
|
|
volatile uint32_t mCurrentlyScanningInterfaces;
|
|
HANDLE mAllInterfacesDoneScanningEvent;
|
|
};
|
|
|
|
static void
|
|
OnScanComplete(PWLAN_NOTIFICATION_DATA data, PVOID context)
|
|
{
|
|
if (WLAN_NOTIFICATION_SOURCE_ACM != data->NotificationSource) {
|
|
return;
|
|
}
|
|
|
|
if (wlan_notification_acm_scan_complete != data->NotificationCode &&
|
|
wlan_notification_acm_scan_fail != data->NotificationCode) {
|
|
return;
|
|
}
|
|
|
|
InterfaceScanCallbackData* cbData =
|
|
reinterpret_cast<InterfaceScanCallbackData*>(context);
|
|
cbData->OnInterfaceScanComplete();
|
|
}
|
|
|
|
WinWifiScanner::WinWifiScanner()
|
|
{
|
|
// NOTE: We assume that, if we were unable to load the WLAN library when
|
|
// we initially tried, we will not be able to load it in the future.
|
|
// Technically, on Windows XP SP2, a user could install the redistributable
|
|
// and make our assumption incorrect. We opt to avoid making a bunch of
|
|
// spurious LoadLibrary calls in the common case rather than load the
|
|
// WLAN API in the edge case.
|
|
mWlanLibrary = WinWLANLibrary::Load();
|
|
if (!mWlanLibrary) {
|
|
NS_WARNING("Could not initialize Windows Wi-Fi scanner");
|
|
}
|
|
}
|
|
|
|
WinWifiScanner::~WinWifiScanner()
|
|
{
|
|
}
|
|
|
|
nsresult
|
|
WinWifiScanner::GetAccessPointsFromWLAN(nsCOMArray<nsWifiAccessPoint> &accessPoints)
|
|
{
|
|
accessPoints.Clear();
|
|
|
|
// NOTE: We do not try to load the WLAN library if we previously failed
|
|
// to load it. See the note in WinWifiScanner constructor
|
|
if (!mWlanLibrary) {
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
}
|
|
|
|
// Get the list of interfaces. WlanEnumInterfaces allocates interface_list.
|
|
WLAN_INTERFACE_INFO_LIST *interface_list = nullptr;
|
|
if (ERROR_SUCCESS !=
|
|
(*mWlanLibrary->GetWlanEnumInterfacesPtr())(mWlanLibrary->GetWLANHandle(),
|
|
nullptr,
|
|
&interface_list)) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
|
|
// This ensures we call WlanFreeMemory on interface_list
|
|
ScopedWLANObject scopedInterfaceList(mWlanLibrary, interface_list);
|
|
|
|
if (!interface_list->dwNumberOfItems) {
|
|
return NS_OK;
|
|
}
|
|
|
|
InterfaceScanCallbackData cbData(interface_list->dwNumberOfItems);
|
|
|
|
DWORD wlanNotifySource;
|
|
if (ERROR_SUCCESS !=
|
|
(*mWlanLibrary->GetWlanRegisterNotificationPtr())(
|
|
mWlanLibrary->GetWLANHandle(),
|
|
WLAN_NOTIFICATION_SOURCE_ACM,
|
|
TRUE,
|
|
(WLAN_NOTIFICATION_CALLBACK)OnScanComplete,
|
|
&cbData,
|
|
NULL,
|
|
&wlanNotifySource)) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
|
|
// Go through the list of interfaces and call `WlanScan` on each
|
|
for (unsigned int i = 0; i < interface_list->dwNumberOfItems; ++i) {
|
|
if (ERROR_SUCCESS !=
|
|
(*mWlanLibrary->GetWlanScanPtr())(
|
|
mWlanLibrary->GetWLANHandle(),
|
|
&interface_list->InterfaceInfo[i].InterfaceGuid,
|
|
NULL,
|
|
NULL,
|
|
NULL)) {
|
|
cbData.OnInterfaceScanComplete();
|
|
}
|
|
}
|
|
|
|
// From the MSDN documentation:
|
|
// "Wireless network drivers that meet Windows logo requirements are
|
|
// required to complete a WlanScan function request in 4 seconds"
|
|
cbData.WaitForAllInterfacesToFinishScanning(5000);
|
|
|
|
// Unregister for the notifications. The documentation mentions that,
|
|
// if a callback is currently running, this will wait for the callback
|
|
// to complete.
|
|
(*mWlanLibrary->GetWlanRegisterNotificationPtr())(
|
|
mWlanLibrary->GetWLANHandle(),
|
|
WLAN_NOTIFICATION_SOURCE_NONE,
|
|
TRUE,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
&wlanNotifySource);
|
|
|
|
// Go through the list of interfaces and get the data for each.
|
|
for (uint32_t i = 0; i < interface_list->dwNumberOfItems; ++i) {
|
|
WLAN_BSS_LIST *bss_list;
|
|
if (ERROR_SUCCESS !=
|
|
(*mWlanLibrary->GetWlanGetNetworkBssListPtr())(
|
|
mWlanLibrary->GetWLANHandle(),
|
|
&interface_list->InterfaceInfo[i].InterfaceGuid,
|
|
nullptr, // Use all SSIDs.
|
|
DOT11_BSS_TYPE_UNUSED,
|
|
false, // bSecurityEnabled - unused
|
|
nullptr, // reserved
|
|
&bss_list)) {
|
|
continue;
|
|
}
|
|
|
|
// This ensures we call WlanFreeMemory on bss_list
|
|
ScopedWLANObject scopedBssList(mWlanLibrary, bss_list);
|
|
|
|
// Store each discovered access point in our outparam
|
|
for (int j = 0; j < static_cast<int>(bss_list->dwNumberOfItems); ++j) {
|
|
nsWifiAccessPoint* ap = new nsWifiAccessPoint();
|
|
if (!ap) {
|
|
continue;
|
|
}
|
|
|
|
const WLAN_BSS_ENTRY bss_entry = bss_list->wlanBssEntries[j];
|
|
ap->setMac(bss_entry.dot11Bssid);
|
|
ap->setSignal(bss_entry.lRssi);
|
|
ap->setSSID(reinterpret_cast<char const*>(bss_entry.dot11Ssid.ucSSID),
|
|
bss_entry.dot11Ssid.uSSIDLength);
|
|
|
|
accessPoints.AppendObject(ap);
|
|
}
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|