Merge backout

This commit is contained in:
Matthew Gregan 2010-02-26 15:18:27 -08:00
commit adc03f189b
2 changed files with 24 additions and 12 deletions

View File

@ -89,8 +89,6 @@ MOZ_X11 = @MOZ_X11@
MOZ_PANGO = @MOZ_PANGO@ MOZ_PANGO = @MOZ_PANGO@
MOZ_CORETEXT = @MOZ_CORETEXT@
MOZ_JS_LIBS = @MOZ_JS_LIBS@ MOZ_JS_LIBS = @MOZ_JS_LIBS@
MOZ_DEBUG = @MOZ_DEBUG@ MOZ_DEBUG = @MOZ_DEBUG@

View File

@ -43,6 +43,7 @@
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-runtime.h> #include <objc/objc-runtime.h>
#include "nsObjCExceptions.h"
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
#include "nsCOMArray.h" #include "nsCOMArray.h"
#include "nsWifiMonitor.h" #include "nsWifiMonitor.h"
@ -59,36 +60,43 @@ BOOL UsingSnowLeopard() {
nsresult nsresult
GetAccessPointsFromWLAN(nsCOMArray<nsWifiAccessPoint> &accessPoints) GetAccessPointsFromWLAN(nsCOMArray<nsWifiAccessPoint> &accessPoints)
{ {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
if (!UsingSnowLeopard()) if (!UsingSnowLeopard())
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
accessPoints.Clear(); accessPoints.Clear();
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@try {
NSBundle * bundle = [[NSBundle alloc] initWithPath:@"/System/Library/Frameworks/CoreWLAN.framework"]; @try {
if (!bundle) NSBundle * bundle = [[[NSBundle alloc] initWithPath:@"/System/Library/Frameworks/CoreWLAN.framework"] autorelease];
if (!bundle) {
[pool release];
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
}
Class CWI_class = [bundle classNamed:@"CWInterface"]; Class CWI_class = [bundle classNamed:@"CWInterface"];
if (!CWI_class) if (!CWI_class) {
[pool release];
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
}
NSDictionary *params = nil; id scanResult = [[CWI_class interface] scanForNetworksWithParameters:nil error:nil];
NSError *err = nil; if (!scanResult) {
id scanResult = [[CWI_class interface] scanForNetworksWithParameters: params error: err]; [pool release];
if (!scanResult)
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
}
NSArray* scan = [NSMutableArray arrayWithArray:scanResult]; NSArray* scan = [NSMutableArray arrayWithArray:scanResult];
NSEnumerator *enumerator = [scan objectEnumerator]; NSEnumerator *enumerator = [scan objectEnumerator];
while (id anObject = [enumerator nextObject]) { while (id anObject = [enumerator nextObject]) {
nsWifiAccessPoint* ap = new nsWifiAccessPoint(); nsWifiAccessPoint* ap = new nsWifiAccessPoint();
if (!ap) if (!ap) {
[pool release];
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
}
NSData* data = [anObject bssidData]; NSData* data = [anObject bssidData];
ap->setMac((unsigned char*)[data bytes]); ap->setMac((unsigned char*)[data bytes]);
ap->setSignal([[anObject rssi] intValue]); ap->setSignal([[anObject rssi] intValue]);
@ -98,7 +106,13 @@ GetAccessPointsFromWLAN(nsCOMArray<nsWifiAccessPoint> &accessPoints)
} }
} }
@catch(NSException *_exn) { @catch(NSException *_exn) {
[pool release];
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
} }
[pool release];
return NS_OK; return NS_OK;
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NS_ERROR_NOT_AVAILABLE);
} }