Ticket #40852: patch-src_plugins_bearer_corewlan_qcorewlanengine.mm.diff

File patch-src_plugins_bearer_corewlan_qcorewlanengine.mm.diff, 5.5 KB (added by BSeppke (Benjamin Seppke), 11 years ago)

New "now working at 10.9" patchfile for the Objective Code in bearer

  • src/plugins/bearer/corewlan/qcorewlanengine.mm

    old new  
    5252#include <QtCore/qdebug.h>
    5353
    5454#include <QDir>
     55
     56#ifdef MAC_SDK_10_7
     57    #include <CoreWLAN/CoreWLANConstants.h>
     58    #include <CoreWLAN/CoreWLANTypes.h>
     59#endif
    5560#include <CoreWLAN/CoreWLAN.h>
    5661#include <CoreWLAN/CWInterface.h>
    5762#include <CoreWLAN/CWNetwork.h>
     
    101106    NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
    102107    notificationCenter = [NSNotificationCenter defaultCenter];
    103108    currentInterface = [CWInterface interfaceWithName:nil];
    104     [notificationCenter addObserver:self selector:@selector(notificationHandler:) name:kCWPowerDidChangeNotification object:nil];
     109    [notificationCenter addObserver:self selector:@selector(notificationHandler:) name:CWPowerDidChangeNotification object:nil];
    105110    [locker unlock];
    106111    [autoreleasepool release];
    107112    return self;
     
    175180
    176181    if([currentInterface power]) {
    177182        NSError *err = nil;
    178         NSDictionary *parametersDict =  [NSDictionary dictionaryWithObjectsAndKeys:
    179                                    [NSNumber numberWithBool:YES], kCWScanKeyMerge,
    180                                    [NSNumber numberWithInt:kCWScanTypeFast], kCWScanKeyScanType,
    181                                    [NSNumber numberWithInteger:100], kCWScanKeyRestTime, nil];
    182 
    183         NSArray* apArray = [currentInterface scanForNetworksWithParameters:parametersDict error:&err];
    184         CWNetwork *apNetwork;
    185 
     183       
     184        NSSet* apArray = [currentInterface scanForNetworksWithSSID:nil error:&err];
     185       
    186186        if (!err) {
    187187
    188             for(uint row=0; row < [apArray count]; row++ ) {
    189                 apNetwork = [apArray objectAtIndex:row];
     188            for(CWNetwork *apNetwork in apArray) {
    190189
    191190                const QString networkSsid = qt_NSStringToQString([apNetwork ssid]);
    192191                const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkSsid));
     
    194193
    195194                QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined;
    196195                bool known = isKnownSsid(networkSsid);
    197                 if( [currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) {
     196                if( [currentInterface serviceActive] ) {
    198197                    if( networkSsid == qt_NSStringToQString( [currentInterface ssid])) {
    199198                        state = QNetworkConfiguration::Active;
    200199                    }
     
    207206                    }
    208207                }
    209208                QNetworkConfiguration::Purpose purpose = QNetworkConfiguration::UnknownPurpose;
    210                 if([[apNetwork securityMode] intValue] == kCWSecurityModeOpen) {
     209                if([[apNetwork supportsSecurity] intValue] == kCWSecurityNone) {
    211210                    purpose = QNetworkConfiguration::PublicPurpose;
    212211                } else {
    213212                    purpose = QNetworkConfiguration::PrivatePurpose;
     
    237236                interfaceName = ij.value();
    238237            }
    239238
    240             if( [currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) {
     239            if( [currentInterface serviceActive] ) {
    241240                if( networkSsid == qt_NSStringToQString([currentInterface ssid])) {
    242241                    state = QNetworkConfiguration::Active;
    243242                }
     
    508507                    else
    509508                        wantedSsid = thisName;
    510509
    511                     [params setValue: [array objectAtIndex:i] forKey:kCWAssocKey8021XProfile];
     510                    //[params setValue: [array objectAtIndex:i] forKey:kCWAssocKey8021XProfile];
    512511                    using8021X = true;
    513512                    break;
    514513                }
     
    528527                }
    529528            }
    530529        }
    531         NSDictionary *scanParameters = [NSDictionary dictionaryWithObjectsAndKeys:
    532                                         [NSNumber numberWithBool:YES], kCWScanKeyMerge,
    533                                         [NSNumber numberWithInt:kCWScanTypeFast], kCWScanKeyScanType,
    534                                         [NSNumber numberWithInteger:100], kCWScanKeyRestTime,
    535                                         qt_QStringToNSString(wantedSsid), kCWScanKeySSID,
    536                                         nil];
    537 
    538         NSArray *scanArray = [wifiInterface scanForNetworksWithParameters:scanParameters error:&err];
     530       
     531        NSSet *scanArray = [wifiInterface scanForNetworksWithSSID:nil error:&err];
    539532
    540533        if(!err) {
    541             for(uint row=0; row < [scanArray count]; row++ ) {
    542                 CWNetwork *apNetwork = [scanArray objectAtIndex:row];
     534            for(CWNetwork *apNetwork in scanArray) {
    543535
    544536                if(wantedSsid == qt_NSStringToQString([apNetwork ssid])) {
    545537
     
    595587                        } else {
    596588                            qDebug() << "SecKeychainSearchCopyNext error";
    597589                        }
    598                         [params setValue: password forKey: kCWAssocKeyPassphrase];
     590                        //[params setValue: password forKey: kCWAssocKeyPassphrase];
    599591                    } // end using8021X
    600592
    601593
     
    634626        [CWInterface interfaceWithName: qt_QStringToNSString(interfaceString)];
    635627
    636628    [wifiInterface disassociate];
    637     if ([[wifiInterface interfaceState]intValue] != kCWInterfaceStateInactive) {
     629    if ( [wifiInterface serviceActive] ){
    638630        locker.unlock();
    639631        emit connectionError(id, DisconnectionError);
    640632        locker.relock();