Bug 1795230 - Fix -Wobjc-method-access warnings in osx_corewlan.mm. r=haik,necko-reviewers,valentin

This replaces deprecated classes, except in the one case where we're
purposely using the deprecated class until it's actively removed.

Differential Revision: https://phabricator.services.mozilla.com/D159368
This commit is contained in:
Mike Hommey 2022-10-17 21:58:42 +00:00
parent 969d7bb6fd
commit d01fe13a7e
2 changed files with 5 additions and 14 deletions

View File

@ -24,10 +24,6 @@ if CONFIG["OS_ARCH"] == "Darwin":
SOURCES += [
"osx_corewlan.mm",
]
# osx_corewlan.mm has warnings about scanForNetworksWithParameters,
# bssidData and rssi. These are APIs that were removed in 10.7, so we need
# to accept the warnings when targeting the newer SDKs.
SOURCES["osx_corewlan.mm"].flags += ["-Wno-error=objc-method-access"]
elif CONFIG["OS_ARCH"] in ("DragonFly", "FreeBSD"):
UNIFIED_SOURCES += [
"nsWifiScannerFreeBSD.cpp",

View File

@ -37,7 +37,7 @@ nsresult GetAccessPointsFromWLAN(nsCOMArray<nsWifiAccessPoint>& accessPoints) {
return NS_ERROR_NOT_AVAILABLE;
}
id scanResult = [[CWI_class interface] scanForNetworksWithParameters:nil error:nil];
id scanResult = [[CWI_class interface] scanForNetworksWithSSID:nil error:nil];
if (!scanResult) {
[pool release];
return NS_ERROR_NOT_AVAILABLE;
@ -57,7 +57,10 @@ nsresult GetAccessPointsFromWLAN(nsCOMArray<nsWifiAccessPoint>& accessPoints) {
// is a pain, so we'll use it for as long as it's available.
unsigned char macData[6] = {0};
if ([anObject respondsToSelector:@selector(bssidData)]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-method-access"
NSData* data = [anObject bssidData];
#pragma clang diagnostic pop
if (data) {
memcpy(macData, [data bytes], 6);
}
@ -77,15 +80,7 @@ nsresult GetAccessPointsFromWLAN(nsCOMArray<nsWifiAccessPoint>& accessPoints) {
}
}
// [CWInterface rssiValue] is available on OS X 10.7 and up (and
// [CWInterface rssi] is deprecated).
int signal = 0;
if ([anObject respondsToSelector:@selector(rssiValue)]) {
signal = (int)((NSInteger)[anObject rssiValue]);
} else {
signal = [[anObject rssi] intValue];
}
int signal = (int)((NSInteger)[anObject rssiValue]);
ap->setMac(macData);
ap->setSignal(signal);
ap->setSSID([[anObject ssid] UTF8String], 32);