From 611c2b7d3f4c2b6a05968c58c8da251bc054e74e Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Wed, 17 Mar 2010 15:30:31 +1000 Subject: use dynamicstore instead --- src/plugins/bearer/corewlan/qcorewlanengine.mm | 43 +++++++++----------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm index 392e24c..67186a9 100644 --- a/src/plugins/bearer/corewlan/qcorewlanengine.mm +++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm @@ -737,37 +737,22 @@ void QCoreWlanEngine::getUserConfigurations() CWInterface *wifiInterface = [CWInterface interfaceWithName: [wifiInterfaces objectAtIndex:row]]; // add user configured system networks - NSString *filePath = @"/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist"; - NSDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath]; - NSString *input = @"KnownNetworks"; - NSString *ssidStr = @"SSID_STR"; - - for (id key in plistDict) { - if ([input isEqualToString:key]) { - - NSDictionary *knownNetworksDict = [plistDict objectForKey:key]; - for (id networkKey in knownNetworksDict) { - - NSDictionary *itemDict = [knownNetworksDict objectForKey:networkKey]; - NSInteger dictSize = [itemDict count]; - id objects[dictSize]; - id keys[dictSize]; - - [itemDict getObjects:objects andKeys:keys]; - - for(int i = 0; i < dictSize; i++) { - if([ssidStr isEqualToString:keys[i]]) { - QString thisSsid = qt_mac_NSStringToQString(objects[i]); - if(!userProfiles.contains(thisSsid)) { - QMap map; - map.insert(thisSsid, qt_mac_NSStringToQString([wifiInterface name])); - userProfiles.insert(thisSsid, map); - } - } - } - } + SCDynamicStoreRef dynRef = SCDynamicStoreCreate(kCFAllocatorSystemDefault, (CFStringRef)@"Qt corewlan", nil, nil); + CFDictionaryRef airportPlist = (const __CFDictionary*)SCDynamicStoreCopyValue(dynRef, (CFStringRef)[NSString stringWithFormat:@"Setup:/Network/Interface/%@/AirPort", [wifiInterface name]]); + CFRelease(dynRef); + + NSDictionary *prefNetDict = [airportPlist objectForKey:@"PreferredNetworks"]; + + NSArray *thisSsidarray = [prefNetDict valueForKey:@"SSID_STR"]; + for(NSString *ssidkey in thisSsidarray) { + QString thisSsid = qt_mac_NSStringToQString(ssidkey); + if(!userProfiles.contains(thisSsid)) { + QMap map; + map.insert(thisSsid, qt_mac_NSStringToQString([wifiInterface name])); + userProfiles.insert(thisSsid, map); } } + CFRelease(airportPlist); // 802.1X user profiles QString userProfilePath = QDir::homePath() + "/Library/Preferences/com.apple.eap.profiles.plist"; -- cgit v0.12