зеркало из https://github.com/mozilla/gecko-dev.git
Bug 545371 Remove trailing white space at end of line for netwerk/wifi r=dougt
This commit is contained in:
Родитель
73da8e6c3f
Коммит
171afe0464
|
@ -39,7 +39,7 @@
|
|||
[scriptable, uuid(E28E614F-8F86-44FF-BCF5-5F18225834A0)]
|
||||
interface nsIWifiAccessPoint : nsISupports
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
* The mac address of the WiFi node. The format of this string is:
|
||||
* XX-XX-XX-XX-XX-XX
|
||||
|
|
|
@ -57,6 +57,6 @@ interface nsIWifiListener : nsISupports
|
|||
* @param error the error which caused this event. The
|
||||
* error values will be nsresult codes.
|
||||
*/
|
||||
|
||||
|
||||
void onError(in long error);
|
||||
};
|
||||
|
|
|
@ -112,7 +112,7 @@ NS_IMETHODIMP nsWifiMonitor::StartWatching(nsIWifiListener *aListener)
|
|||
}
|
||||
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
|
||||
|
||||
mKeepGoing = PR_TRUE;
|
||||
|
||||
mListeners.AppendElement(nsWifiListener(aListener));
|
||||
|
@ -130,7 +130,7 @@ NS_IMETHODIMP nsWifiMonitor::StopWatching(nsIWifiListener *aListener)
|
|||
LOG(("removing listener\n"));
|
||||
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
|
||||
|
||||
for (PRUint32 i = 0; i < mListeners.Length(); i++) {
|
||||
|
||||
if (mListeners[i].mListener == aListener) {
|
||||
|
|
|
@ -68,7 +68,7 @@ class nsWifiListener
|
|||
mHasSentData = PR_FALSE;
|
||||
}
|
||||
~nsWifiListener() {}
|
||||
|
||||
|
||||
nsCOMPtr<nsIWifiListener> mListener;
|
||||
PRBool mHasSentData;
|
||||
};
|
||||
|
|
|
@ -62,11 +62,11 @@ nsresult
|
|||
nsWifiMonitor::DoScanWithCoreWLAN()
|
||||
{
|
||||
// Regularly get the access point data.
|
||||
|
||||
|
||||
nsCOMArray<nsWifiAccessPoint> lastAccessPoints;
|
||||
nsCOMArray<nsWifiAccessPoint> accessPoints;
|
||||
|
||||
do {
|
||||
do {
|
||||
nsresult rv = GetAccessPointsFromWLAN(accessPoints);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
@ -76,7 +76,7 @@ nsWifiMonitor::DoScanWithCoreWLAN()
|
|||
|
||||
{
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
|
||||
|
||||
for (PRUint32 i = 0; i < mListeners.Length(); i++) {
|
||||
if (!mListeners[i].mHasSentData || accessPointsChanged) {
|
||||
mListeners[i].mHasSentData = PR_TRUE;
|
||||
|
@ -84,7 +84,7 @@ nsWifiMonitor::DoScanWithCoreWLAN()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ReplaceArray(lastAccessPoints, accessPoints);
|
||||
|
||||
if (currentListeners.Count() > 0)
|
||||
|
@ -99,9 +99,9 @@ nsWifiMonitor::DoScanWithCoreWLAN()
|
|||
result[i] = lastAccessPoints[i];
|
||||
|
||||
for (PRInt32 i = 0; i < currentListeners.Count(); i++) {
|
||||
|
||||
|
||||
LOG(("About to send data to the wifi listeners\n"));
|
||||
|
||||
|
||||
nsCOMPtr<nsIWifiListener> proxy;
|
||||
nsCOMPtr<nsIProxyObjectManager> proxyObjMgr = do_GetService("@mozilla.org/xpcomproxy;1");
|
||||
proxyObjMgr->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
|
@ -124,12 +124,12 @@ nsWifiMonitor::DoScanWithCoreWLAN()
|
|||
|
||||
// wait for some reasonable amount of time. pref?
|
||||
LOG(("waiting on monitor\n"));
|
||||
|
||||
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
mon.Wait(PR_SecondsToInterval(60));
|
||||
}
|
||||
while (mKeepGoing);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ nsWifiMonitor::DoScanOld()
|
|||
WirelessAttachFunction WirelessAttach_function_ = reinterpret_cast<WirelessAttachFunction>(dlsym(apple_80211_library, "WirelessAttach"));
|
||||
WirelessScanSplitFunction WirelessScanSplit_function_ = reinterpret_cast<WirelessScanSplitFunction>(dlsym(apple_80211_library, "WirelessScanSplit"));
|
||||
WirelessDetachFunction WirelessDetach_function_ = reinterpret_cast<WirelessDetachFunction>(dlsym(apple_80211_library, "WirelessDetach"));
|
||||
|
||||
|
||||
if (!WirelessAttach_function_ || !WirelessScanSplit_function_ || !WirelessDetach_function_) {
|
||||
dlclose(apple_80211_library);
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
@ -163,7 +163,7 @@ nsWifiMonitor::DoScanOld()
|
|||
}
|
||||
|
||||
// Regularly get the access point data.
|
||||
|
||||
|
||||
nsCOMArray<nsWifiAccessPoint> lastAccessPoints;
|
||||
nsCOMArray<nsWifiAccessPoint> accessPoints;
|
||||
|
||||
|
@ -172,14 +172,14 @@ nsWifiMonitor::DoScanOld()
|
|||
|
||||
CFArrayRef managed_access_points = NULL;
|
||||
CFArrayRef adhoc_access_points = NULL;
|
||||
|
||||
|
||||
if ((*WirelessScanSplit_function_)(wifi_context_,
|
||||
&managed_access_points,
|
||||
&adhoc_access_points,
|
||||
0) != noErr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (managed_access_points == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ nsWifiMonitor::DoScanOld()
|
|||
|
||||
{
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
|
||||
|
||||
for (PRUint32 i = 0; i < mListeners.Length(); i++) {
|
||||
if (!mListeners[i].mHasSentData || accessPointsChanged) {
|
||||
mListeners[i].mHasSentData = PR_TRUE;
|
||||
|
@ -219,7 +219,7 @@ nsWifiMonitor::DoScanOld()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ReplaceArray(lastAccessPoints, accessPoints);
|
||||
|
||||
if (currentListeners.Count() > 0)
|
||||
|
@ -235,9 +235,9 @@ nsWifiMonitor::DoScanOld()
|
|||
result[i] = lastAccessPoints[i];
|
||||
|
||||
for (PRInt32 i = 0; i < currentListeners.Count(); i++) {
|
||||
|
||||
|
||||
LOG(("About to send data to the wifi listeners\n"));
|
||||
|
||||
|
||||
nsCOMPtr<nsIWifiListener> proxy;
|
||||
nsCOMPtr<nsIProxyObjectManager> proxyObjMgr = do_GetService("@mozilla.org/xpcomproxy;1");
|
||||
proxyObjMgr->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
|
@ -260,16 +260,16 @@ nsWifiMonitor::DoScanOld()
|
|||
|
||||
// wait for some reasonable amount of time. pref?
|
||||
LOG(("waiting on monitor\n"));
|
||||
|
||||
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
mon.Wait(PR_SecondsToInterval(60));
|
||||
}
|
||||
while (mKeepGoing);
|
||||
|
||||
|
||||
(*WirelessDetach_function_)(wifi_context_);
|
||||
|
||||
|
||||
dlclose(apple_80211_library);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,12 +54,12 @@
|
|||
|
||||
|
||||
typedef int (*iw_open_t)(void);
|
||||
|
||||
|
||||
typedef void (*iw_enum_t)(int skfd,
|
||||
iw_enum_handler fn,
|
||||
char *args[],
|
||||
int count);
|
||||
|
||||
|
||||
typedef int (*iw_stats_t)(int skfd,
|
||||
const char *ifname,
|
||||
iwstats *stats,
|
||||
|
@ -94,7 +94,7 @@ static int scan_wifi(int skfd, char* ifname, char* args[], int count)
|
|||
delete ap;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ap->setSSID(buffer, wrq.u.essid.length);
|
||||
|
||||
result = iw_get_ext(skfd, ifname, SIOCGIWAP, &wrq);
|
||||
|
@ -160,19 +160,19 @@ nsWifiMonitor::DoScan()
|
|||
nsCOMArray<nsWifiAccessPoint> accessPoints;
|
||||
|
||||
char* args[] = {(char*) &accessPoints, (char*) iw_stats, nsnull };
|
||||
|
||||
|
||||
while (mKeepGoing) {
|
||||
|
||||
accessPoints.Clear();
|
||||
|
||||
(*iw_enum)(skfd, &scan_wifi, args, 1);
|
||||
|
||||
|
||||
PRBool accessPointsChanged = !AccessPointsEqual(accessPoints, lastAccessPoints);
|
||||
nsCOMArray<nsIWifiListener> currentListeners;
|
||||
|
||||
{
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
|
||||
|
||||
for (PRUint32 i = 0; i < mListeners.Length(); i++) {
|
||||
if (!mListeners[i].mHasSentData || accessPointsChanged) {
|
||||
mListeners[i].mHasSentData = PR_TRUE;
|
||||
|
@ -196,9 +196,9 @@ nsWifiMonitor::DoScan()
|
|||
result[i] = lastAccessPoints[i];
|
||||
|
||||
for (PRInt32 i = 0; i < currentListeners.Count(); i++) {
|
||||
|
||||
|
||||
LOG(("About to send data to the wifi listeners\n"));
|
||||
|
||||
|
||||
nsCOMPtr<nsIWifiListener> proxy;
|
||||
nsCOMPtr<nsIProxyObjectManager> proxyObjMgr = do_GetService("@mozilla.org/xpcomproxy;1");
|
||||
proxyObjMgr->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
|
@ -220,8 +220,7 @@ nsWifiMonitor::DoScan()
|
|||
}
|
||||
|
||||
LOG(("waiting on monitor\n"));
|
||||
|
||||
|
||||
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
mon.Wait(PR_SecondsToInterval(60));
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ int PerformQuery(HANDLE &ndis_handle,
|
|||
NDISUIO_QUERY_OID *query = (NDISUIO_QUERY_OID*)(buffer);
|
||||
query->ptcDeviceName = const_cast<PTCHAR>(device_name);
|
||||
query->Oid = OID_802_11_BSSID_LIST;
|
||||
|
||||
|
||||
if (!DeviceIoControl(ndis_handle,
|
||||
IOCTL_NDISUIO_QUERY_OID_VALUE,
|
||||
query,
|
||||
|
@ -135,27 +135,27 @@ void GetNetworkInterfaces(GETADAPTERSINFO pGetAdaptersInfo, nsStringArray& inter
|
|||
ULONG buffer_size = 0;
|
||||
// since buffer_size is zero before this, we should get ERROR_BUFFER_OVERFLOW
|
||||
// after this error the value of buffer_size will reflect the size needed
|
||||
if (pGetAdaptersInfo(NULL, &buffer_size) != ERROR_BUFFER_OVERFLOW)
|
||||
if (pGetAdaptersInfo(NULL, &buffer_size) != ERROR_BUFFER_OVERFLOW)
|
||||
return;
|
||||
|
||||
|
||||
// Allocate adapter_info with correct size.
|
||||
IP_ADAPTER_INFO *adapter_info = (IP_ADAPTER_INFO*)malloc(buffer_size);
|
||||
if (adapter_info == NULL){
|
||||
free (adapter_info);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (pGetAdaptersInfo(adapter_info, &buffer_size) != ERROR_SUCCESS){
|
||||
free (adapter_info);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Walk through the list of adapters.
|
||||
while (adapter_info) {
|
||||
while (adapter_info) {
|
||||
// AdapterName e.g. TNETW12511
|
||||
nsString adapterName;
|
||||
// AdapterName is in ASCII
|
||||
adapterName.AppendWithConversion(adapter_info->AdapterName);
|
||||
adapterName.AppendWithConversion(adapter_info->AdapterName);
|
||||
interfaces.AppendString(adapterName);
|
||||
adapter_info = adapter_info->Next;
|
||||
}
|
||||
|
@ -173,13 +173,13 @@ nsresult SetupWince(HANDLE& ndis_handle, GETADAPTERSINFO& pGetAdaptersInfo){
|
|||
FILE_ATTRIBUTE_READONLY, NULL);
|
||||
if (INVALID_HANDLE_VALUE == ndis_handle)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
HINSTANCE hIpDLL = LoadLibraryW(L"Iphlpapi.dll");
|
||||
if (!hIpDLL)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
|
||||
pGetAdaptersInfo = (GETADAPTERSINFO) GetProcAddress(hIpDLL, "GetAdaptersInfo");
|
||||
|
||||
|
||||
if (!pGetAdaptersInfo)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -193,7 +193,7 @@ int PerformQuery(HANDLE adapter_handle,
|
|||
DWORD *bytes_out) {
|
||||
|
||||
DWORD oid = OID_802_11_BSSID_LIST;
|
||||
|
||||
|
||||
if (!DeviceIoControl(adapter_handle,
|
||||
IOCTL_NDIS_QUERY_GLOBAL_STATS,
|
||||
&oid,
|
||||
|
@ -209,7 +209,7 @@ int PerformQuery(HANDLE adapter_handle,
|
|||
|
||||
HANDLE GetFileHandle(const PRUnichar* device_name) {
|
||||
// We access a device with DOS path \Device\<device_name> at
|
||||
// \\.\<device_name>.
|
||||
// \\.\<device_name>.
|
||||
|
||||
nsString formatted_device_name;
|
||||
formatted_device_name.Assign(L"\\\\.\\");
|
||||
|
@ -245,10 +245,10 @@ bool DefineDosDeviceIfNotExists(const PRUnichar* device_name, bool* dosDeviceDef
|
|||
|
||||
WCHAR target[kStringLength];
|
||||
|
||||
if (QueryDosDeviceW(device_name, target, kStringLength) > 0 && target_path.Equals(target)) {
|
||||
if (QueryDosDeviceW(device_name, target, kStringLength) > 0 && target_path.Equals(target)) {
|
||||
// Device already exists.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
DWORD error = GetLastError();
|
||||
if (error != ERROR_FILE_NOT_FOUND) {
|
||||
|
@ -261,10 +261,10 @@ bool DefineDosDeviceIfNotExists(const PRUnichar* device_name, bool* dosDeviceDef
|
|||
return false;
|
||||
}
|
||||
*dosDeviceDefined = true;
|
||||
// Check that the device is really there.
|
||||
// Check that the device is really there.
|
||||
return QueryDosDeviceW(device_name, target, kStringLength) > 0 &&
|
||||
target_path.Equals(target);
|
||||
}
|
||||
}
|
||||
|
||||
void GetNetworkInterfaces(nsStringArray& interfaces)
|
||||
{
|
||||
|
@ -276,13 +276,13 @@ void GetNetworkInterfaces(nsStringArray& interfaces)
|
|||
&network_cards_key) != ERROR_SUCCESS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; ; ++i) {
|
||||
WCHAR name[kStringLength];
|
||||
DWORD name_size = kStringLength;
|
||||
FILETIME time;
|
||||
|
||||
|
||||
if (RegEnumKeyExW(network_cards_key,
|
||||
i,
|
||||
name,
|
||||
|
@ -290,11 +290,11 @@ void GetNetworkInterfaces(nsStringArray& interfaces)
|
|||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&time) != ERROR_SUCCESS)
|
||||
&time) != ERROR_SUCCESS)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HKEY hardware_key = NULL;
|
||||
if (RegOpenKeyExW(network_cards_key,
|
||||
name,
|
||||
|
@ -304,20 +304,20 @@ void GetNetworkInterfaces(nsStringArray& interfaces)
|
|||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
PRUnichar service_name[kStringLength];
|
||||
DWORD service_name_size = kStringLength;
|
||||
DWORD type = 0;
|
||||
|
||||
|
||||
if (RegQueryValueExW(hardware_key,
|
||||
L"ServiceName",
|
||||
NULL,
|
||||
&type,
|
||||
(LPBYTE)service_name,
|
||||
&service_name_size) == ERROR_SUCCESS) {
|
||||
|
||||
|
||||
interfaces.AppendString(nsString(service_name)); // is this allowed?
|
||||
}
|
||||
}
|
||||
RegCloseKey(hardware_key);
|
||||
}
|
||||
RegCloseKey(network_cards_key);
|
||||
|
@ -355,7 +355,7 @@ nsWifiMonitor::DoScan()
|
|||
|
||||
nsCOMArray<nsWifiAccessPoint> lastAccessPoints;
|
||||
nsCOMArray<nsWifiAccessPoint> accessPoints;
|
||||
|
||||
|
||||
do {
|
||||
accessPoints.Clear();
|
||||
|
||||
|
@ -365,19 +365,19 @@ nsWifiMonitor::DoScan()
|
|||
#else
|
||||
GetNetworkInterfaces(interfaces);
|
||||
#endif
|
||||
|
||||
|
||||
for (int i = 0; i < interfaces.Count(); i++) {
|
||||
nsString *s = interfaces.StringAt(i);
|
||||
const PRUnichar *service_name = s->get();
|
||||
|
||||
#ifndef WINCE
|
||||
|
||||
#ifndef WINCE
|
||||
bool dosDeviceDefined = false;
|
||||
if (!DefineDosDeviceIfNotExists(service_name, &dosDeviceDefined))
|
||||
continue;
|
||||
|
||||
// Get the handle to the device. This will fail if the named device is not
|
||||
// valid.
|
||||
|
||||
|
||||
HANDLE adapter_handle = GetFileHandle(service_name);
|
||||
if (adapter_handle == INVALID_HANDLE_VALUE)
|
||||
continue;
|
||||
|
@ -386,7 +386,7 @@ nsWifiMonitor::DoScan()
|
|||
#endif
|
||||
|
||||
// Get the data.
|
||||
|
||||
|
||||
BYTE *buffer = (BYTE*)malloc(oid_buffer_size_);
|
||||
if (buffer == NULL) {
|
||||
#ifdef WINCE
|
||||
|
@ -397,36 +397,36 @@ nsWifiMonitor::DoScan()
|
|||
|
||||
DWORD bytes_out;
|
||||
int result;
|
||||
|
||||
while (true) {
|
||||
|
||||
while (true) {
|
||||
|
||||
NS_ASSERTION(buffer && oid_buffer_size_ > 0, "buffer must not be null, and the size must be larger than 0");
|
||||
|
||||
bytes_out = 0;
|
||||
bytes_out = 0;
|
||||
#ifdef WINCE
|
||||
result = PerformQuery(ndis_handle, service_name, buffer, oid_buffer_size_, data, &bytes_out);
|
||||
#else
|
||||
result = PerformQuery(adapter_handle, buffer, oid_buffer_size_, &bytes_out);
|
||||
#endif
|
||||
|
||||
|
||||
if (result == ERROR_GEN_FAILURE || // Returned by some Intel cards.
|
||||
result == ERROR_INVALID_USER_BUFFER || // Returned on the Samsung Omnia II.
|
||||
result == ERROR_INSUFFICIENT_BUFFER ||
|
||||
result == ERROR_MORE_DATA ||
|
||||
result == NDIS_STATUS_INVALID_LENGTH ||
|
||||
result == NDIS_STATUS_BUFFER_TOO_SHORT) {
|
||||
|
||||
// The buffer we supplied is too small, so increase it. bytes_out should
|
||||
// provide the required buffer size, but this is not always the case.
|
||||
|
||||
if (bytes_out > static_cast<DWORD>(oid_buffer_size_)) {
|
||||
|
||||
// The buffer we supplied is too small, so increase it. bytes_out should
|
||||
// provide the required buffer size, but this is not always the case.
|
||||
|
||||
if (bytes_out > static_cast<DWORD>(oid_buffer_size_)) {
|
||||
oid_buffer_size_ = bytes_out;
|
||||
} else {
|
||||
oid_buffer_size_ *= 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!ResizeBuffer(oid_buffer_size_, &buffer)) {
|
||||
oid_buffer_size_ = kInitialBufferSize; // Reset for next time.
|
||||
oid_buffer_size_ = kInitialBufferSize; // Reset for next time.
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
|
@ -434,63 +434,61 @@ nsWifiMonitor::DoScan()
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (result == ERROR_SUCCESS) {
|
||||
#ifdef WINCE
|
||||
NDIS_802_11_BSSID_LIST* bssid_list = (NDIS_802_11_BSSID_LIST*)data;
|
||||
#else
|
||||
NDIS_802_11_BSSID_LIST* bssid_list = (NDIS_802_11_BSSID_LIST*)buffer;
|
||||
#endif
|
||||
|
||||
|
||||
// Walk through the BSS IDs.
|
||||
const uint8 *iterator = (const uint8*)&bssid_list->Bssid[0];
|
||||
const uint8 *end_of_buffer = (const uint8*)buffer + oid_buffer_size_;
|
||||
for (int i = 0; i < static_cast<int>(bssid_list->NumberOfItems); ++i) {
|
||||
|
||||
|
||||
const NDIS_WLAN_BSSID *bss_id = (const NDIS_WLAN_BSSID*)iterator;
|
||||
|
||||
|
||||
// Check that the length of this BSS ID is reasonable.
|
||||
if (bss_id->Length < sizeof(NDIS_WLAN_BSSID) ||
|
||||
iterator + bss_id->Length > end_of_buffer) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
nsWifiAccessPoint* ap = new nsWifiAccessPoint();
|
||||
if (!ap)
|
||||
continue;
|
||||
|
||||
|
||||
ap->setMac(bss_id->MacAddress);
|
||||
ap->setSignal(bss_id->Rssi);
|
||||
ap->setSSID((char*) bss_id->Ssid.Ssid, bss_id->Ssid.SsidLength);
|
||||
|
||||
|
||||
accessPoints.AppendObject(ap);
|
||||
|
||||
|
||||
// Move to the next BSS ID.
|
||||
iterator += bss_id->Length;
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
free(buffer);
|
||||
|
||||
// Clean up.
|
||||
#ifndef WINCE
|
||||
CloseHandle(adapter_handle);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef WINCE
|
||||
if (dosDeviceDefined)
|
||||
UndefineDosDevice(service_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
PRBool accessPointsChanged = !AccessPointsEqual(accessPoints, lastAccessPoints);
|
||||
nsCOMArray<nsIWifiListener> currentListeners;
|
||||
|
||||
|
||||
{
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
|
||||
|
||||
for (PRUint32 i = 0; i < mListeners.Length(); i++) {
|
||||
if (!mListeners[i].mHasSentData || accessPointsChanged) {
|
||||
mListeners[i].mHasSentData = PR_TRUE;
|
||||
|
@ -498,9 +496,9 @@ nsWifiMonitor::DoScan()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ReplaceArray(lastAccessPoints, accessPoints);
|
||||
|
||||
|
||||
if (currentListeners.Count() > 0) {
|
||||
|
||||
PRUint32 resultCount = lastAccessPoints.Count();
|
||||
|
@ -514,11 +512,11 @@ nsWifiMonitor::DoScan()
|
|||
|
||||
for (PRUint32 i = 0; i < resultCount; i++)
|
||||
result[i] = lastAccessPoints[i];
|
||||
|
||||
|
||||
for (PRInt32 i = 0; i < currentListeners.Count(); i++) {
|
||||
|
||||
|
||||
LOG(("About to send data to the wifi listeners\n"));
|
||||
|
||||
|
||||
nsCOMPtr<nsIWifiListener> proxy;
|
||||
nsCOMPtr<nsIProxyObjectManager> proxyObjMgr = do_GetService("@mozilla.org/xpcomproxy;1");
|
||||
proxyObjMgr->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
|
@ -538,10 +536,10 @@ nsWifiMonitor::DoScan()
|
|||
|
||||
nsMemory::Free(result);
|
||||
}
|
||||
|
||||
|
||||
// wait for some reasonable amount of time. pref?
|
||||
LOG(("waiting on monitor\n"));
|
||||
|
||||
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
mon.Wait(PR_SecondsToInterval(60));
|
||||
}
|
||||
|
@ -559,28 +557,28 @@ nsWifiMonitor::DoScan()
|
|||
HINSTANCE wlan_library = LoadLibrary("Wlanapi.dll");
|
||||
if (!wlan_library)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
|
||||
WlanOpenHandleFunction WlanOpenHandle = (WlanOpenHandleFunction) GetProcAddress(wlan_library, "WlanOpenHandle");
|
||||
WlanEnumInterfacesFunction WlanEnumInterfaces = (WlanEnumInterfacesFunction) GetProcAddress(wlan_library, "WlanEnumInterfaces");
|
||||
WlanGetNetworkBssListFunction WlanGetNetworkBssList = (WlanGetNetworkBssListFunction) GetProcAddress(wlan_library, "WlanGetNetworkBssList");
|
||||
WlanFreeMemoryFunction WlanFreeMemory = (WlanFreeMemoryFunction) GetProcAddress(wlan_library, "WlanFreeMemory");
|
||||
WlanCloseHandleFunction WlanCloseHandle = (WlanCloseHandleFunction) GetProcAddress(wlan_library, "WlanCloseHandle");
|
||||
|
||||
|
||||
if (!WlanOpenHandle ||
|
||||
!WlanEnumInterfaces ||
|
||||
!WlanGetNetworkBssList ||
|
||||
!WlanFreeMemory ||
|
||||
!WlanCloseHandle)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
// Regularly get the access point data.
|
||||
|
||||
|
||||
nsCOMArray<nsWifiAccessPoint> lastAccessPoints;
|
||||
nsCOMArray<nsWifiAccessPoint> accessPoints;
|
||||
|
||||
|
||||
do {
|
||||
accessPoints.Clear();
|
||||
|
||||
|
||||
// Get the handle to the WLAN API.
|
||||
DWORD negotiated_version;
|
||||
HANDLE wlan_handle = NULL;
|
||||
|
@ -594,11 +592,11 @@ nsWifiMonitor::DoScan()
|
|||
&wlan_handle) != ERROR_SUCCESS) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
|
||||
// try again later.
|
||||
if (!wlan_handle)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
// Get the list of interfaces. WlanEnumInterfaces allocates interface_list.
|
||||
WLAN_INTERFACE_INFO_LIST *interface_list = NULL;
|
||||
if ((*WlanEnumInterfaces)(wlan_handle, NULL, &interface_list) != ERROR_SUCCESS) {
|
||||
|
@ -606,10 +604,10 @@ nsWifiMonitor::DoScan()
|
|||
(*WlanCloseHandle)(wlan_handle, NULL);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
// Go through the list of interfaces and get the data for each.
|
||||
for (int i = 0; i < static_cast<int>(interface_list->dwNumberOfItems); ++i) {
|
||||
|
||||
|
||||
WLAN_BSS_LIST *bss_list;
|
||||
HRESULT rv = (*WlanGetNetworkBssList)(wlan_handle,
|
||||
&interface_list->InterfaceInfo[i].InterfaceGuid,
|
||||
|
@ -621,38 +619,38 @@ nsWifiMonitor::DoScan()
|
|||
if (rv != ERROR_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
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((char*) bss_entry.dot11Ssid.ucSSID,
|
||||
bss_entry.dot11Ssid.uSSIDLength);
|
||||
|
||||
|
||||
accessPoints.AppendObject(ap);
|
||||
}
|
||||
(*WlanFreeMemory)(bss_list);
|
||||
}
|
||||
|
||||
|
||||
// Free interface_list.
|
||||
(*WlanFreeMemory)(interface_list);
|
||||
|
||||
|
||||
// Close the handle.
|
||||
(*WlanCloseHandle)(wlan_handle, NULL);
|
||||
|
||||
|
||||
|
||||
|
||||
PRBool accessPointsChanged = !AccessPointsEqual(accessPoints, lastAccessPoints);
|
||||
nsCOMArray<nsIWifiListener> currentListeners;
|
||||
|
||||
|
||||
{
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
|
||||
|
||||
for (PRUint32 i = 0; i < mListeners.Length(); i++) {
|
||||
if (!mListeners[i].mHasSentData || accessPointsChanged) {
|
||||
mListeners[i].mHasSentData = PR_TRUE;
|
||||
|
@ -660,22 +658,22 @@ nsWifiMonitor::DoScan()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ReplaceArray(lastAccessPoints, accessPoints);
|
||||
|
||||
|
||||
if (currentListeners.Count() > 0) {
|
||||
PRUint32 resultCount = lastAccessPoints.Count();
|
||||
nsIWifiAccessPoint** result = static_cast<nsIWifiAccessPoint**> (nsMemory::Alloc(sizeof(nsIWifiAccessPoint*) * resultCount));
|
||||
if (!result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
||||
for (PRUint32 i = 0; i < resultCount; i++)
|
||||
result[i] = lastAccessPoints[i];
|
||||
|
||||
|
||||
for (PRInt32 i = 0; i < currentListeners.Count(); i++) {
|
||||
|
||||
|
||||
LOG(("About to send data to the wifi listeners\n"));
|
||||
|
||||
|
||||
nsCOMPtr<nsIWifiListener> proxy;
|
||||
nsCOMPtr<nsIProxyObjectManager> proxyObjMgr = do_GetService("@mozilla.org/xpcomproxy;1");
|
||||
proxyObjMgr->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
|
@ -692,13 +690,13 @@ nsWifiMonitor::DoScan()
|
|||
LOG( ("... sent %d\n", rv));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsMemory::Free(result);
|
||||
}
|
||||
|
||||
|
||||
// wait for some reasonable amount of time. pref?
|
||||
LOG(("waiting on monitor\n"));
|
||||
|
||||
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
mon.Wait(PR_SecondsToInterval(60));
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
//
|
||||
// Copyright (c) 02006, Alf Watt (alf@istumbler.net). All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
|
@ -108,7 +108,7 @@ struct WirelessNetworkInfo
|
|||
// Note: An adhoc network created on the computer the scan is running on will
|
||||
// not be found. WirelessGetInfo can be used to find info about a local adhoc
|
||||
// network.
|
||||
//
|
||||
//
|
||||
// If stripDups != 0 only one bases tation for each SSID will be returned.
|
||||
typedef WIErr (*WirelessScanSplitFunction)(WirelessContextPtr inContext,
|
||||
CFArrayRef *apList,
|
||||
|
|
|
@ -21,8 +21,7 @@ test.prototype =
|
|||
var a = accessPoints[i];
|
||||
d.innerHTML = d.innerHTML + "<p>" + a.mac + " " + a.ssid + " " + a.signal + "</p>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
var c = document.getElementById("c");
|
||||
c.innerHTML = "<p>" + count++ + "</p>";
|
||||
|
||||
|
@ -46,7 +45,7 @@ test.prototype =
|
|||
|
||||
var listener = new test();
|
||||
var wifi_service = Components.classes["@mozilla.org/wifi/monitor;1"].getService(Components.interfaces.nsIWifiMonitor);
|
||||
|
||||
|
||||
wifi_service.startWatching(listener);
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче