From 4d9fb7de86a2d5a9bc3f39e1c1b65869c3380a0a Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Fri, 5 Jul 2013 03:24:47 +0300 Subject: [PATCH] [mac] Fixed compilation issue with new MacOSX SDK - they removed WiFi scanning code starting from MacOS X 10.7 --- platform/location_service.cpp | 2 +- platform/platform.pro | 1 - platform/wifi_info_mac.mm | 110 ----------------------------- platform/wifi_location_service.cpp | 2 +- 4 files changed, 2 insertions(+), 113 deletions(-) delete mode 100644 platform/wifi_info_mac.mm diff --git a/platform/location_service.cpp b/platform/location_service.cpp index a24c8c8acd..8c2ac1a560 100644 --- a/platform/location_service.cpp +++ b/platform/location_service.cpp @@ -80,7 +80,7 @@ namespace location m_services.push_back(CreateAppleLocationService(*this)); #endif -#if defined(OMIM_OS_MAC) || defined(OMIM_OS_WINDOWS) +#if defined(OMIM_OS_WINDOWS) m_services.push_back(CreateWiFiLocationService(*this)); #endif } diff --git a/platform/platform.pro b/platform/platform.pro index 75fe5000a7..13e048c10f 100644 --- a/platform/platform.pro +++ b/platform/platform.pro @@ -30,7 +30,6 @@ INCLUDEPATH += $$ROOT_DIR/3party/jansson/src wifi_info_windows.cpp } else:macx* { OBJECTIVE_SOURCES += platform_mac.mm \ - wifi_info_mac.mm \ apple_video_timer.mm \ apple_location_service.mm } else:linux* { diff --git a/platform/wifi_info_mac.mm b/platform/wifi_info_mac.mm deleted file mode 100644 index 781d201728..0000000000 --- a/platform/wifi_info_mac.mm +++ /dev/null @@ -1,110 +0,0 @@ -#include "../std/target_os.hpp" -#ifdef OMIM_OS_MAC - -#include "wifi_info.hpp" - -#include "../base/string_utils.hpp" - -#import -#import -#import - -static string AppendZeroIfNeeded(string const & macAddrPart) -{ - string res(macAddrPart); - if (res.size() == 1) - res.insert(0, "0"); - return res; -} - -@interface WiFiInfoMac : NSObject { -@private - WiFiInfo::WifiRequestCallbackT m_callback; - vector m_accessPoints; -} -@end -//- (id)InitWithCallback:(WiFiInfo::WifiRequestCallbackT)callback; -@implementation WiFiInfoMac - -- (id)InitWithCallback:(WiFiInfo::WifiRequestCallbackT)callback -{ - self = [super init]; - m_callback = callback; - [self performSelectorInBackground:@selector(WifiScanThread) withObject:nil]; - return self; -} - -- (void)dealloc -{ - [super dealloc]; -// NSLog(@"Mac OS WiFiInfo selfdestructed successfully"); -} - -/// Executed on main thread -- (void)NotifyGUI -{ - m_callback(m_accessPoints); - // selfdestruct - [self release]; -} - -/// new background thread -- (void)WifiScanThread -{ - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - - m_accessPoints.clear(); - - // avoid crash on systems without wlan interfaces - NSArray * ifaces = [CWInterface supportedInterfaces]; - if ([ifaces count]) - { - CWInterface * iFace = [CWInterface interface]; - NSArray * nets = [iFace scanForNetworksWithParameters:nil error:nil]; - for (NSUInteger i = 0; i < [nets count]; ++i) - { - CWNetwork * net = (CWNetwork *)[nets objectAtIndex:i]; - WiFiInfo::AccessPoint apn; - apn.m_ssid = [net.ssid UTF8String]; - apn.m_signalStrength = strings::to_string([net.rssi intValue]); - // fix formatting for wifi address - string const rawBssid = [net.bssid UTF8String]; - if (!rawBssid.empty()) - { - strings::SimpleTokenizer tokIt(rawBssid, ":"); - apn.m_bssid = AppendZeroIfNeeded(*tokIt); - do - { - ++tokIt; - apn.m_bssid += "-"; - apn.m_bssid += AppendZeroIfNeeded(*tokIt); - } while (!tokIt.IsLast()); - } - m_accessPoints.push_back(apn); - } - } - [pool drain]; - - [self performSelectorOnMainThread:@selector(NotifyGUI) withObject:nil waitUntilDone:NO]; -} -@end -///////////////////////////////////////////////////////////////////////////// -WiFiInfo::WiFiInfo() -{ -} - -WiFiInfo::~WiFiInfo() -{ -} - -void WiFiInfo::RequestWiFiBSSIDs(WifiRequestCallbackT callback) -{ - // it will be self-destroyed when finished - [[WiFiInfoMac alloc] InitWithCallback:callback]; -} - -void WiFiInfo::Stop() -{ -} - -#endif diff --git a/platform/wifi_location_service.cpp b/platform/wifi_location_service.cpp index 6954a8aee5..3fd394c5a8 100644 --- a/platform/wifi_location_service.cpp +++ b/platform/wifi_location_service.cpp @@ -64,7 +64,7 @@ namespace location } else LOG(LWARNING, ("Location server is not available")); - /// free memory + // free memory delete &response; }