122 TPtrC( WLAN_SERVICE ), TPtrC( WLAN_SERVICE_ID ), aIapId ); |
121 TPtrC( WLAN_SERVICE ), TPtrC( WLAN_SERVICE_ID ), aIapId ); |
123 |
122 |
124 TInt errorCode = wLanServiceTable->GotoFirstRecord(); |
123 TInt errorCode = wLanServiceTable->GotoFirstRecord(); |
125 if ( errorCode == KErrNone ) |
124 if ( errorCode == KErrNone ) |
126 { |
125 { |
127 if ( iSecurityMode == ESecurityMode8021x ) |
126 // Get WPA Mode |
128 { |
127 TRAPD( err, wLanServiceTable->ReadUintL( TPtrC( WLAN_ENABLE_WPA_PSK ), |
129 // in 802.1x PSK mode is not supported |
128 ( TUint32& ) iWPAMode ) ); |
130 iWPAMode = EFalse; |
129 if ( err != KErrNone ) |
131 } |
130 { // do not leave if value is not present in table... |
132 else |
131 if ( err != KErrUnknown ) |
133 { |
132 User::Leave( err ); |
134 // Get WPA Mode |
133 } |
135 TRAPD( err, wLanServiceTable->ReadUintL( TPtrC( WLAN_ENABLE_WPA_PSK ), |
134 |
136 ( TUint32& ) iWPAMode ) ); |
|
137 if ( err != KErrNone ) |
|
138 { // do not leave if value is not present in table... |
|
139 if ( err != KErrUnknown ) |
|
140 User::Leave( err ); |
|
141 } |
|
142 } |
|
143 |
|
144 TUint32 secMode = 0; |
135 TUint32 secMode = 0; |
145 // Get WPA2 Only Mode |
136 // Get WPA2 Only Mode |
146 TRAPD( err, wLanServiceTable->ReadUintL( TPtrC( WLAN_SECURITY_MODE ), |
137 TRAP( err, wLanServiceTable->ReadUintL( TPtrC( WLAN_SECURITY_MODE ), |
147 secMode ) ); |
138 secMode ) ); |
148 if ( err != KErrNone ) |
139 if ( err != KErrNone ) |
149 { // do not leave if value is not present in table... |
140 { // do not leave if value is not present in table... |
150 if ( err != KErrUnknown ) |
141 if ( err != KErrUnknown ) |
151 User::Leave( err ); |
142 User::Leave( err ); |
152 } |
143 } |
153 |
144 |
154 iWpa2Only = secMode == EWpa2; |
145 iWpa2Only = secMode == EWpa2; |
155 |
|
156 // Get Unencrypted Connection mode for 802.1x |
|
157 if ( iSecurityMode == ESecurityMode8021x ) |
|
158 { |
|
159 // WLAN_WPA_KEY_LENGTH is used also for Unencrypted Connection mode |
|
160 TRAPD( err2, wLanServiceTable->ReadUintL( TPtrC( WLAN_WPA_KEY_LENGTH ), |
|
161 ( TUint32& ) iWPAUnencryptedConn ) ); |
|
162 if ( err2 != KErrNone ) |
|
163 { // do not leave if value is not present in table... |
|
164 if ( err2 != KErrUnknown ) |
|
165 User::Leave( err2 ); |
|
166 } |
|
167 } |
|
168 |
146 |
169 // Get EAP list |
147 // Get EAP list |
170 iWPAEAPPlugin.Copy( *wLanServiceTable->ReadLongTextLC( |
148 iWPAEAPPlugin.Copy( *wLanServiceTable->ReadLongTextLC( |
171 TPtrC( WLAN_EAPS ) ) ); |
149 TPtrC( WLAN_EAPS ) ) ); |
172 CleanupStack::PopAndDestroy(); |
150 CleanupStack::PopAndDestroy(); |
268 // finally, wipe old column data |
246 // finally, wipe old column data |
269 iWPAEAPPlugin.Zero(); |
247 iWPAEAPPlugin.Zero(); |
270 } |
248 } |
271 |
249 |
272 // Get PreShared Key |
250 // Get PreShared Key |
273 if ( iSecurityMode != ESecurityMode8021x ) |
251 wLanServiceTable->ReadTextL( TPtrC( WLAN_WPA_PRE_SHARED_KEY ), |
274 { |
|
275 wLanServiceTable->ReadTextL( TPtrC( WLAN_WPA_PRE_SHARED_KEY ), |
|
276 iWPAPreSharedKey ); |
252 iWPAPreSharedKey ); |
277 } |
|
278 |
253 |
279 if ( !IsValidPsk( iWPAPreSharedKey ) ) |
254 if ( !IsValidPsk( iWPAPreSharedKey ) ) |
280 { |
255 { |
281 // invalid key format |
256 // invalid key format |
282 iWPAPreSharedKey.Zero(); |
257 iWPAPreSharedKey.Zero(); |
316 // Save link to LAN service |
291 // Save link to LAN service |
317 wLanServiceTable->WriteUintL( TPtrC( WLAN_SERVICE_ID ), aIapId ); |
292 wLanServiceTable->WriteUintL( TPtrC( WLAN_SERVICE_ID ), aIapId ); |
318 } |
293 } |
319 |
294 |
320 // Save WPA Mode |
295 // Save WPA Mode |
321 if ( iSecurityMode != ESecurityMode8021x ) |
296 wLanServiceTable->WriteUintL( TPtrC( WLAN_ENABLE_WPA_PSK ), |
322 { |
|
323 wLanServiceTable->WriteUintL( TPtrC( WLAN_ENABLE_WPA_PSK ), |
|
324 ( TUint32& ) iWPAMode ); |
297 ( TUint32& ) iWPAMode ); |
325 } |
|
326 |
298 |
327 TUint32 secMode; |
299 TUint32 secMode; |
328 |
300 |
329 if ( iSecurityMode == ESecurityMode8021x ) |
301 if ( iSecurityMode == ESecurityMode8021x ) |
330 { |
302 { |
357 |
329 |
358 wLanServiceTable->WriteTextL( TPtrC( WLAN_DISABLED_EAPS ), |
330 wLanServiceTable->WriteTextL( TPtrC( WLAN_DISABLED_EAPS ), |
359 iWPADisabledEAPPlugin? |
331 iWPADisabledEAPPlugin? |
360 (const TDesC8&)*iWPADisabledEAPPlugin: |
332 (const TDesC8&)*iWPADisabledEAPPlugin: |
361 (const TDesC8&)KNullDesC8 ); |
333 (const TDesC8&)KNullDesC8 ); |
362 |
334 // Save PreShared Key |
363 |
335 wLanServiceTable->WriteTextL( TPtrC( WLAN_WPA_PRE_SHARED_KEY ), |
364 |
|
365 if ( iSecurityMode == ESecurityMode8021x ) |
|
366 { |
|
367 // In 802.1x WpaKeyLength is not used |
|
368 // and the field is reused to save UnencryptedConn mode |
|
369 wLanServiceTable->WriteUintL( TPtrC( WLAN_WPA_KEY_LENGTH ), |
|
370 ( TUint32& ) iWPAUnencryptedConn ); |
|
371 } |
|
372 else |
|
373 { |
|
374 // Save PreShared Key |
|
375 wLanServiceTable->WriteTextL( TPtrC( WLAN_WPA_PRE_SHARED_KEY ), |
|
376 iWPAPreSharedKey ); |
336 iWPAPreSharedKey ); |
377 |
337 |
378 // Save PreShared Key Length |
338 // Save PreShared Key Length |
379 wLanServiceTable->WriteUintL( TPtrC( WLAN_WPA_KEY_LENGTH ), |
339 wLanServiceTable->WriteUintL( TPtrC( WLAN_WPA_KEY_LENGTH ), |
380 iWPAPreSharedKey.Length() ); |
340 iWPAPreSharedKey.Length() ); |
381 } |
|
382 |
341 |
383 wLanServiceTable->PutRecordChanges(); |
342 wLanServiceTable->PutRecordChanges(); |
384 |
343 |
385 if ( iPlugin ) |
344 if ( iPlugin ) |
386 { |
345 { |
581 // prime with service id |
540 // prime with service id |
582 *sidField = aIapId; |
541 *sidField = aIapId; |
583 |
542 |
584 if( generic->FindL( aSession) ) |
543 if( generic->FindL( aSession) ) |
585 { |
544 { |
586 if ( iSecurityMode == ESecurityMode8021x ) |
545 // Get WPA mode |
587 { |
546 CMDBField<TUint>* enableWpaPskField = static_cast<CMDBField<TUint>*> |
588 // in 802.1x PSK mode is not supported |
|
589 iWPAMode = EFalse; |
|
590 } |
|
591 else |
|
592 { |
|
593 // Get WPA mode |
|
594 CMDBField<TUint>* enableWpaPskField = static_cast<CMDBField<TUint>*> |
|
595 ( generic->GetFieldByIdL( KCDTIdWlanEnableWpaPsk ) ); |
547 ( generic->GetFieldByIdL( KCDTIdWlanEnableWpaPsk ) ); |
596 iWPAMode = *enableWpaPskField; |
548 iWPAMode = *enableWpaPskField; |
597 } |
|
598 |
549 |
599 // Get WPA2 Only Mode |
550 // Get WPA2 Only Mode |
600 CMDBField<TUint>* secModeField = static_cast<CMDBField<TUint>*> |
551 CMDBField<TUint>* secModeField = static_cast<CMDBField<TUint>*> |
601 ( generic->GetFieldByIdL( KCDTIdWlanSecMode ) ); |
552 ( generic->GetFieldByIdL( KCDTIdWlanSecMode ) ); |
602 TUint32 secMode = *secModeField; |
553 TUint32 secMode = *secModeField; |
603 iWpa2Only = secMode == EWpa2; |
554 iWpa2Only = secMode == EWpa2; |
604 |
|
605 // Get 802.1x Unencrypted Connection saved in reused WpaKeyLengthField |
|
606 if ( iSecurityMode == ESecurityMode8021x ) |
|
607 { |
|
608 CMDBField<TUint>* WpaKeyLengthField = static_cast<CMDBField<TUint>*> |
|
609 ( generic->GetFieldByIdL( KCDTIdWlanWpaKeyLength ) ); |
|
610 iWPAUnencryptedConn = *WpaKeyLengthField; |
|
611 } |
|
612 |
555 |
613 // Get EAP plugins |
556 // Get EAP plugins |
614 CMDBField<TDesC>* wlanEapsField = static_cast<CMDBField<TDesC>*> |
557 CMDBField<TDesC>* wlanEapsField = static_cast<CMDBField<TDesC>*> |
615 ( generic->GetFieldByIdL( KCDTIdWlanEaps ) ); |
558 ( generic->GetFieldByIdL( KCDTIdWlanEaps ) ); |
616 iWPAEAPPlugin = *wlanEapsField; |
559 iWPAEAPPlugin = *wlanEapsField; |
707 // finally, wipe old column data |
650 // finally, wipe old column data |
708 iWPAEAPPlugin.Zero(); |
651 iWPAEAPPlugin.Zero(); |
709 } |
652 } |
710 |
653 |
711 // GetWPA preshared key |
654 // GetWPA preshared key |
712 if ( iSecurityMode != ESecurityMode8021x ) |
655 CMDBField<TDesC8>* wpaPskField = static_cast<CMDBField<TDesC8>*> |
713 { |
|
714 CMDBField<TDesC8>* wpaPskField = static_cast<CMDBField<TDesC8>*> |
|
715 ( generic->GetFieldByIdL( KCDTIdWlanWpaPreSharedKey ) ); |
656 ( generic->GetFieldByIdL( KCDTIdWlanWpaPreSharedKey ) ); |
716 iWPAPreSharedKey = *wpaPskField; |
657 iWPAPreSharedKey = *wpaPskField; |
717 } |
658 |
718 |
|
719 if ( !IsValidPsk( iWPAPreSharedKey ) ) |
659 if ( !IsValidPsk( iWPAPreSharedKey ) ) |
720 { |
660 { |
721 // invalid key format |
661 // invalid key format |
722 iWPAPreSharedKey.Zero(); |
662 iWPAPreSharedKey.Zero(); |
723 } |
663 } |
756 |
696 |
757 TBool found = generic->FindL( aSession); |
697 TBool found = generic->FindL( aSession); |
758 |
698 |
759 // If loading failed, WLAN service record will be |
699 // If loading failed, WLAN service record will be |
760 // created and StoreL()-d, otherwise, ModifyL() |
700 // created and StoreL()-d, otherwise, ModifyL() |
761 |
701 |
762 if ( iSecurityMode != ESecurityMode8021x ) |
702 // Set WPA mode |
763 { |
703 CMDBField<TUint>* enableWpaPskField = static_cast<CMDBField<TUint>*> |
764 // Set WPA mode |
704 ( generic->GetFieldByIdL( KCDTIdWlanEnableWpaPsk ) ); |
765 CMDBField<TUint>* enableWpaPskField = static_cast<CMDBField<TUint>*> |
705 enableWpaPskField->SetL( iWPAMode ); |
766 ( generic->GetFieldByIdL( KCDTIdWlanEnableWpaPsk ) ); |
|
767 enableWpaPskField->SetL( iWPAMode ); |
|
768 } |
|
769 |
706 |
770 // Set security mode |
707 // Set security mode |
771 TUint32 secMode; |
708 TUint32 secMode; |
772 if ( iSecurityMode == ESecurityMode8021x ) |
709 if ( iSecurityMode == ESecurityMode8021x ) |
773 { |
710 { |
806 ( generic->GetFieldByIdL( KCDTIdWlanDisabledEaps ) ); |
743 ( generic->GetFieldByIdL( KCDTIdWlanDisabledEaps ) ); |
807 wlanDisabledEapsField->SetL( iWPADisabledEAPPlugin? |
744 wlanDisabledEapsField->SetL( iWPADisabledEAPPlugin? |
808 (const TDesC8&)*iWPADisabledEAPPlugin: |
745 (const TDesC8&)*iWPADisabledEAPPlugin: |
809 (const TDesC8&)KNullDesC8 ); |
746 (const TDesC8&)KNullDesC8 ); |
810 |
747 |
|
748 // Save PreShared Key |
|
749 CMDBField<TDesC8>* wpaPskField = static_cast<CMDBField<TDesC8>*> |
|
750 ( generic->GetFieldByIdL( KCDTIdWlanWpaPreSharedKey ) ); |
|
751 wpaPskField->SetL( iWPAPreSharedKey ); |
|
752 |
811 // Save PreShared Key length |
753 // Save PreShared Key length |
812 CMDBField<TUint>* keyLengthField = static_cast<CMDBField<TUint>*> |
754 CMDBField<TUint>* keyLengthField = static_cast<CMDBField<TUint>*> |
813 ( generic->GetFieldByIdL( KCDTIdWlanWpaKeyLength ) ); |
755 ( generic->GetFieldByIdL( KCDTIdWlanWpaKeyLength ) ); |
814 if ( iSecurityMode == ESecurityMode8021x ) |
756 keyLengthField->SetL( iWPAPreSharedKey.Length() ); |
815 { |
|
816 // In 802.1x keyLengthField is reused to contain Unencrypted Connection info |
|
817 keyLengthField->SetL( iWPAUnencryptedConn ); |
|
818 } |
|
819 else |
|
820 { |
|
821 keyLengthField->SetL( iWPAPreSharedKey.Length() ); |
|
822 |
|
823 // Save PreShared Key |
|
824 CMDBField<TDesC8>* wpaPskField = static_cast<CMDBField<TDesC8>*> |
|
825 ( generic->GetFieldByIdL( KCDTIdWlanWpaPreSharedKey ) ); |
|
826 wpaPskField->SetL( iWPAPreSharedKey ); |
|
827 } |
|
828 |
757 |
829 TInt error( KErrNone ); |
758 TInt error( KErrNone ); |
830 |
759 |
831 // Saving changes |
760 // Saving changes |
832 for ( TInt i( 0 ); i < KRetryCount; i++ ) |
761 for ( TInt i( 0 ); i < KRetryCount; i++ ) |