diff -r 75a6055b8ce3 -r 30e048a7b597 wlansecuritysettings/wpasecuritysettingsui/src/WPASecuritySettingsImpl.cpp --- a/wlansecuritysettings/wpasecuritysettingsui/src/WPASecuritySettingsImpl.cpp Mon Jun 21 15:44:11 2010 +0300 +++ b/wlansecuritysettings/wpasecuritysettingsui/src/WPASecuritySettingsImpl.cpp Thu Aug 19 09:58:27 2010 +0300 @@ -16,7 +16,7 @@ */ /* -* %version: tr1cfwln#27 % +* %version: tr1cfwln#29 % */ // INCLUDE FILES @@ -69,7 +69,8 @@ TSecurityMode aSecurityMode ) : iSecurityMode( aSecurityMode ), iWPAMode( EFalse ), - iWpa2Only( EFalse ) + iWpa2Only( EFalse ), + iWPAUnencryptedConn( EFalse ) { iWPAEAPPlugin.Zero(); iWPAPreSharedKey.Zero(); @@ -123,18 +124,26 @@ TInt errorCode = wLanServiceTable->GotoFirstRecord(); if ( errorCode == KErrNone ) { - // Get WPA Mode - TRAPD( err, wLanServiceTable->ReadUintL( TPtrC( WLAN_ENABLE_WPA_PSK ), - ( TUint32& ) iWPAMode ) ); - if ( err != KErrNone ) - { // do not leave if value is not present in table... - if ( err != KErrUnknown ) - User::Leave( err ); + if ( iSecurityMode == ESecurityMode8021x ) + { + // in 802.1x PSK mode is not supported + iWPAMode = EFalse; } - + else + { + // Get WPA Mode + TRAPD( err, wLanServiceTable->ReadUintL( TPtrC( WLAN_ENABLE_WPA_PSK ), + ( TUint32& ) iWPAMode ) ); + if ( err != KErrNone ) + { // do not leave if value is not present in table... + if ( err != KErrUnknown ) + User::Leave( err ); + } + } + TUint32 secMode = 0; // Get WPA2 Only Mode - TRAP( err, wLanServiceTable->ReadUintL( TPtrC( WLAN_SECURITY_MODE ), + TRAPD( err, wLanServiceTable->ReadUintL( TPtrC( WLAN_SECURITY_MODE ), secMode ) ); if ( err != KErrNone ) { // do not leave if value is not present in table... @@ -144,6 +153,19 @@ iWpa2Only = secMode == EWpa2; + // Get Unencrypted Connection mode for 802.1x + if ( iSecurityMode == ESecurityMode8021x ) + { + // WLAN_WPA_KEY_LENGTH is used also for Unencrypted Connection mode + TRAPD( err2, wLanServiceTable->ReadUintL( TPtrC( WLAN_WPA_KEY_LENGTH ), + ( TUint32& ) iWPAUnencryptedConn ) ); + if ( err2 != KErrNone ) + { // do not leave if value is not present in table... + if ( err2 != KErrUnknown ) + User::Leave( err2 ); + } + } + // Get EAP list iWPAEAPPlugin.Copy( *wLanServiceTable->ReadLongTextLC( TPtrC( WLAN_EAPS ) ) ); @@ -248,8 +270,11 @@ } // Get PreShared Key - wLanServiceTable->ReadTextL( TPtrC( WLAN_WPA_PRE_SHARED_KEY ), + if ( iSecurityMode != ESecurityMode8021x ) + { + wLanServiceTable->ReadTextL( TPtrC( WLAN_WPA_PRE_SHARED_KEY ), iWPAPreSharedKey ); + } if ( !IsValidPsk( iWPAPreSharedKey ) ) { @@ -293,8 +318,11 @@ } // Save WPA Mode - wLanServiceTable->WriteUintL( TPtrC( WLAN_ENABLE_WPA_PSK ), + if ( iSecurityMode != ESecurityMode8021x ) + { + wLanServiceTable->WriteUintL( TPtrC( WLAN_ENABLE_WPA_PSK ), ( TUint32& ) iWPAMode ); + } TUint32 secMode; @@ -331,13 +359,26 @@ iWPADisabledEAPPlugin? (const TDesC8&)*iWPADisabledEAPPlugin: (const TDesC8&)KNullDesC8 ); - // Save PreShared Key - wLanServiceTable->WriteTextL( TPtrC( WLAN_WPA_PRE_SHARED_KEY ), - iWPAPreSharedKey ); + + - // Save PreShared Key Length - wLanServiceTable->WriteUintL( TPtrC( WLAN_WPA_KEY_LENGTH ), - iWPAPreSharedKey.Length() ); + if ( iSecurityMode == ESecurityMode8021x ) + { + // In 802.1x WpaKeyLength is not used + // and the field is reused to save UnencryptedConn mode + wLanServiceTable->WriteUintL( TPtrC( WLAN_WPA_KEY_LENGTH ), + ( TUint32& ) iWPAUnencryptedConn ); + } + else + { + // Save PreShared Key + wLanServiceTable->WriteTextL( TPtrC( WLAN_WPA_PRE_SHARED_KEY ), + iWPAPreSharedKey ); + + // Save PreShared Key Length + wLanServiceTable->WriteUintL( TPtrC( WLAN_WPA_KEY_LENGTH ), + iWPAPreSharedKey.Length() ); + } wLanServiceTable->PutRecordChanges(); @@ -542,16 +583,32 @@ if( generic->FindL( aSession) ) { - // Get WPA mode - CMDBField* enableWpaPskField = static_cast*> + if ( iSecurityMode == ESecurityMode8021x ) + { + // in 802.1x PSK mode is not supported + iWPAMode = EFalse; + } + else + { + // Get WPA mode + CMDBField* enableWpaPskField = static_cast*> ( generic->GetFieldByIdL( KCDTIdWlanEnableWpaPsk ) ); - iWPAMode = *enableWpaPskField; + iWPAMode = *enableWpaPskField; + } // Get WPA2 Only Mode CMDBField* secModeField = static_cast*> ( generic->GetFieldByIdL( KCDTIdWlanSecMode ) ); TUint32 secMode = *secModeField; iWpa2Only = secMode == EWpa2; + + // Get 802.1x Unencrypted Connection saved in reused WpaKeyLengthField + if ( iSecurityMode == ESecurityMode8021x ) + { + CMDBField* WpaKeyLengthField = static_cast*> + ( generic->GetFieldByIdL( KCDTIdWlanWpaKeyLength ) ); + iWPAUnencryptedConn = *WpaKeyLengthField; + } // Get EAP plugins CMDBField* wlanEapsField = static_cast*> @@ -652,10 +709,13 @@ } // GetWPA preshared key - CMDBField* wpaPskField = static_cast*> + if ( iSecurityMode != ESecurityMode8021x ) + { + CMDBField* wpaPskField = static_cast*> ( generic->GetFieldByIdL( KCDTIdWlanWpaPreSharedKey ) ); - iWPAPreSharedKey = *wpaPskField; - + iWPAPreSharedKey = *wpaPskField; + } + if ( !IsValidPsk( iWPAPreSharedKey ) ) { // invalid key format @@ -698,11 +758,14 @@ // If loading failed, WLAN service record will be // created and StoreL()-d, otherwise, ModifyL() - - // Set WPA mode - CMDBField* enableWpaPskField = static_cast*> - ( generic->GetFieldByIdL( KCDTIdWlanEnableWpaPsk ) ); - enableWpaPskField->SetL( iWPAMode ); + + if ( iSecurityMode != ESecurityMode8021x ) + { + // Set WPA mode + CMDBField* enableWpaPskField = static_cast*> + ( generic->GetFieldByIdL( KCDTIdWlanEnableWpaPsk ) ); + enableWpaPskField->SetL( iWPAMode ); + } // Set security mode TUint32 secMode; @@ -745,15 +808,23 @@ (const TDesC8&)*iWPADisabledEAPPlugin: (const TDesC8&)KNullDesC8 ); - // Save PreShared Key - CMDBField* wpaPskField = static_cast*> - ( generic->GetFieldByIdL( KCDTIdWlanWpaPreSharedKey ) ); - wpaPskField->SetL( iWPAPreSharedKey ); - // Save PreShared Key length CMDBField* keyLengthField = static_cast*> ( generic->GetFieldByIdL( KCDTIdWlanWpaKeyLength ) ); - keyLengthField->SetL( iWPAPreSharedKey.Length() ); + if ( iSecurityMode == ESecurityMode8021x ) + { + // In 802.1x keyLengthField is reused to contain Unencrypted Connection info + keyLengthField->SetL( iWPAUnencryptedConn ); + } + else + { + keyLengthField->SetL( iWPAPreSharedKey.Length() ); + + // Save PreShared Key + CMDBField* wpaPskField = static_cast*> + ( generic->GetFieldByIdL( KCDTIdWlanWpaPreSharedKey ) ); + wpaPskField->SetL( iWPAPreSharedKey ); + } TInt error( KErrNone );