25 #include "mpmwlanquerydialog.h" |
25 #include "mpmwlanquerydialog.h" |
26 #include "mpmiapselection.h" |
26 #include "mpmiapselection.h" |
27 #include "mpmconnmonevents.h" |
27 #include "mpmconnmonevents.h" |
28 #include "mpmlogger.h" |
28 #include "mpmlogger.h" |
29 |
29 |
30 // valid Wep key lengths, to check wep key format |
|
31 // (wep key format depends on key length) |
|
32 const TInt KConnUiUtilsWepLengthASCII5 = 5; |
|
33 const TInt KConnUiUtilsWepLengthASCII13 = 13; |
|
34 const TInt KConnUiUtilsWepLengthASCII29 = 29; |
|
35 const TInt KConnUiUtilsWepLengthHEX10 = 10; |
|
36 const TInt KConnUiUtilsWepLengthHEX26 = 26; |
|
37 const TInt KConnUiUtilsWepLengthHEX58 = 58; |
|
38 |
|
39 // Retry count and delay for storing Easy WLAN data |
|
40 const TInt KStoreRetryCount = 10; |
|
41 const TInt KStoreRetryDelay = 100000; |
|
42 |
|
43 // ======== MEMBER FUNCTIONS ======== |
30 // ======== MEMBER FUNCTIONS ======== |
44 |
31 |
45 // --------------------------------------------------------------------------- |
32 // --------------------------------------------------------------------------- |
46 // CMPMWlanQueryDialog::CMPMWlanQueryDialog |
33 // CMPMWlanQueryDialog::CMPMWlanQueryDialog |
47 // --------------------------------------------------------------------------- |
34 // --------------------------------------------------------------------------- |
48 // |
35 // |
49 CMPMWlanQueryDialog::CMPMWlanQueryDialog( CMPMIapSelection& aSession, |
36 CMPMWlanQueryDialog::CMPMWlanQueryDialog( CMPMIapSelection& aIapSelection, |
50 TUint32 aWlanIapId ) |
37 TUint32 aWlanIapId ) |
51 : CActive( CActive::EPriorityStandard ), |
38 : CActive( CActive::EPriorityStandard ), |
52 iIapSelection( aSession ), |
39 iIapSelection( aIapSelection ), |
53 iNetworkPrefs(), |
40 iWlanQueryState( EOffline ), |
54 iNotifWep(), |
|
55 iWlanQueryState( EWlanNetwork ), |
|
56 iWlanIapId( aWlanIapId ), |
41 iWlanIapId( aWlanIapId ), |
57 iEasyWlanSelected( EFalse ), |
42 iOverrideStatus( KErrNone ) |
58 iOverrideStatus( KErrNone ), |
43 { |
59 iConnUiUtils( NULL ), |
44 CActiveScheduler::Add( this ); |
60 iWps( NULL ), |
|
61 iWpsReturn( WiFiProt::EWiFiOK ), |
|
62 iWpsCompleted( EFalse ), |
|
63 iRetryCount( 0 ) |
|
64 { |
|
65 |
|
66 } |
45 } |
67 |
46 |
68 // --------------------------------------------------------------------------- |
47 // --------------------------------------------------------------------------- |
69 // CMPMWlanQueryDialog::ConstructL |
48 // CMPMWlanQueryDialog::ConstructL |
70 // --------------------------------------------------------------------------- |
49 // --------------------------------------------------------------------------- |
71 // |
50 // |
72 void CMPMWlanQueryDialog::ConstructL() |
51 void CMPMWlanQueryDialog::ConstructL() |
73 { |
52 { |
74 User::LeaveIfError(iNotifier.Connect()); |
53 User::LeaveIfError(iNotifier.Connect()); |
75 CActiveScheduler::Add( this ); |
|
76 iConnUiUtils = CConnectionUiUtilities::NewL(); |
|
77 User::LeaveIfError( iTimer.CreateLocal() ); |
|
78 } |
54 } |
79 |
55 |
80 // --------------------------------------------------------------------------- |
56 // --------------------------------------------------------------------------- |
81 // CMPMWlanQueryDialog::NewL |
57 // CMPMWlanQueryDialog::NewL |
82 // --------------------------------------------------------------------------- |
58 // --------------------------------------------------------------------------- |
189 void CMPMWlanQueryDialog::RunL() |
139 void CMPMWlanQueryDialog::RunL() |
190 { |
140 { |
191 MPMLOGSTRING3( "CMPMWlanQueryDialog::RunL status %d state %d", |
141 MPMLOGSTRING3( "CMPMWlanQueryDialog::RunL status %d state %d", |
192 iStatus.Int(), |
142 iStatus.Int(), |
193 iWlanQueryState ) |
143 iWlanQueryState ) |
|
144 |
194 if( iWlanQueryState == EOffline ) |
145 if( iWlanQueryState == EOffline ) |
195 { |
146 { |
196 if( iStatus.Int() == KErrNone ) |
147 if( iStatus.Int() == KErrNone ) |
197 { |
148 { |
198 iIapSelection.SetOfflineNoteResponse( EOfflineResponseYes ); |
149 iIapSelection.Session()->MyServer().SetOfflineWlanQueryResponse( |
199 if( iIapSelection.Session()->MyServer().CommsDatAccess()->CheckEasyWLanL( iWlanIapId ) ) |
150 EOfflineResponseYes ); |
200 { |
|
201 MPMLOGSTRING( "CMPMWlanQueryDialog::RunL starting wlan network query" ) |
|
202 GetNetworkPrefs(); |
|
203 return; |
|
204 } |
|
205 } |
151 } |
206 else if ( iStatus.Int() == KErrCancel ) |
152 else if ( iStatus.Int() == KErrCancel ) |
207 { |
153 { |
208 iIapSelection.SetOfflineNoteResponse( EOfflineResponseNo ); |
154 iIapSelection.Session()->MyServer().SetOfflineWlanQueryResponse( |
|
155 EOfflineResponseNo ); |
209 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL offline query returned %d", |
156 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL offline query returned %d", |
210 iStatus.Int() ) |
157 iStatus.Int() ) |
211 } |
158 } |
212 else |
159 else |
213 { |
160 { |
214 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL offline query returned %d", |
161 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL offline query returned %d", |
215 iStatus.Int() ) |
162 iStatus.Int() ) |
216 } |
163 } |
217 } |
164 } |
218 else if( iWlanQueryState == EWlanNetwork ) |
165 // if an error was given through OfferInformation() -call we abort the execution. |
219 { |
166 // |
220 if( iStatus.Int() == KErrNone ) |
167 else if ( iOverrideStatus != KErrNone ) |
221 { |
168 { |
222 |
169 MPMLOGSTRING2( "CMPMWlanQueryDialog::StartWlanQuery inherited error %d", iOverrideStatus ) |
223 TUint secMode( 0 ); |
170 iIapSelection.UserWlanSelectionDoneL( iOverrideStatus, iWlanIapId ); |
224 TWlanNetMode connMode( EInfra ); |
|
225 TInt err = ConnSecModeToCommsDatSecMode( iNetworkPrefs().iSecMode, |
|
226 secMode ); |
|
227 if( err != KErrNone ) |
|
228 { |
|
229 MPMLOGSTRING( "CMPMWlanQueryDialog::RunL, Unknown security mode" ) |
|
230 iWlanIapId = 0; |
|
231 iWlanQueryState = EWlanNetwork; |
|
232 iIapSelection.UserWlanSelectionDoneL( KErrCouldNotConnect, iWlanIapId ); |
|
233 return; |
|
234 } |
|
235 |
|
236 TUint32 configuredIap = iIapSelection.Session()->MyServer(). |
|
237 CommsDatAccess()->CheckWLANIapWithSsidL( iNetworkPrefs().iSsId, |
|
238 secMode, |
|
239 connMode ); |
|
240 // If previously unknown IAP, query wep/wpa parameters |
|
241 // |
|
242 if( !configuredIap ) |
|
243 { |
|
244 iEasyWlanSelected = ETrue; |
|
245 if ( iNetworkPrefs().iProtectedSetupSupported && |
|
246 iNetworkPrefs().iNetworkMode != EWlanConnectionModeAdhoc ) |
|
247 { |
|
248 StartWpsDlgL(); |
|
249 return; |
|
250 } |
|
251 // WEP |
|
252 // |
|
253 if( iNetworkPrefs().iSecMode == EWlanConnectionSecurityWep ) |
|
254 { |
|
255 MPMLOGSTRING( "CMPMWlanQueryDialog::RunL unknown wep network" ) |
|
256 iWlanQueryState = EWepSettings; |
|
257 iNotifier.StartNotifierAndGetResponse( iStatus, |
|
258 KUidEasyWepDlg, |
|
259 iNotifWep, |
|
260 iNotifWep ); |
|
261 SetActive(); |
|
262 return; |
|
263 } |
|
264 // WPA |
|
265 // |
|
266 else if ( iNetworkPrefs().iSecMode == EWlanConnectionSecurityWpaPsk ) |
|
267 { |
|
268 MPMLOGSTRING( "CMPMWlanQueryDialog::RunL unknown wpa network" ) |
|
269 iWlanQueryState = EWpaSettings; |
|
270 iNotifier.StartNotifierAndGetResponse( iStatus, |
|
271 KUidEasyWpaDlg, |
|
272 iNotifWpaKey, |
|
273 iNotifWpaKey ); |
|
274 SetActive(); |
|
275 return; |
|
276 |
|
277 } |
|
278 else |
|
279 { |
|
280 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL security mode %d", |
|
281 iNetworkPrefs().iSecMode ) |
|
282 } |
|
283 } |
|
284 |
|
285 else |
|
286 { |
|
287 iWlanIapId = configuredIap; |
|
288 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL found configured iap matching ssid, id %d", |
|
289 iWlanIapId ) |
|
290 |
|
291 } |
|
292 } |
|
293 else if( iStatus.Int() == KErrCancel ) |
|
294 { |
|
295 iEasyWlanSelected = EFalse; |
|
296 MPMLOGSTRING( "CMPMWlanQueryDialog::RunL easy wlan dialog cancelled, \ |
|
297 setting easy wlan as not selected" ) |
|
298 } |
|
299 else |
|
300 { |
|
301 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL EWlanNetwork error %d", |
|
302 iStatus.Int() ) |
|
303 } |
|
304 |
|
305 } |
|
306 else if( iWlanQueryState == EWepSettings || iWlanQueryState == EWpaSettings ) |
|
307 { |
|
308 if( iStatus.Int() == KErrCancel ) |
|
309 { |
|
310 MPMLOGSTRING( "CMPMWlanQueryDialog::Key dialog cancelled,back to easy wlan" ) |
|
311 iNetworkPrefs().iSsId.FillZ(); |
|
312 iNetworkPrefs().iNetworkMode = EWlanConnectionModeNotConnected; |
|
313 iNetworkPrefs().iSecMode = EWlanConnectionSecurityOpen; |
|
314 GetNetworkPrefs(); |
|
315 return; |
|
316 } |
|
317 } |
|
318 else if( iWlanQueryState == EWPS ) |
|
319 { |
|
320 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL WPS, status %d", iStatus.Int() ) |
|
321 if( iStatus.Int() == KErrNone ) |
|
322 { |
|
323 if( iWpsReturn == WiFiProt::EWiFiOK) |
|
324 { |
|
325 MPMLOGSTRING( "CMPMWlanQueryDialog::RunL WPS ok" ) |
|
326 iWpsCompleted = ETrue; |
|
327 } |
|
328 else if ( iWpsReturn == WiFiProt::EWiFiCancel ) |
|
329 { |
|
330 MPMLOGSTRING( "CMPMWlanQueryDialog::RunL WPS cancelled" ) |
|
331 iStatus = KErrCancel; |
|
332 } |
|
333 else // WiFiProt::EWiFiNoAuto |
|
334 { |
|
335 if( iNetworkPrefs().iSecMode == EWlanConnectionSecurityWep ) |
|
336 { |
|
337 MPMLOGSTRING( "CMPMWlanQueryDialog::RunL: No WPS, starting WEP key query" ); |
|
338 iWlanQueryState = EWepSettings; |
|
339 iNotifier.StartNotifierAndGetResponse( iStatus, |
|
340 KUidEasyWepDlg, |
|
341 iNotifWep, |
|
342 iNotifWep ); |
|
343 SetActive(); |
|
344 return; |
|
345 } |
|
346 else if ( iNetworkPrefs().iSecMode == EWlanConnectionSecurityWpaPsk ) |
|
347 { |
|
348 MPMLOGSTRING( "CMPMWlanQueryDialog::RunL: No WPS, starting WPA key query" ); |
|
349 iWlanQueryState = EWpaSettings; |
|
350 iNotifier.StartNotifierAndGetResponse( iStatus, |
|
351 KUidEasyWpaDlg, |
|
352 iNotifWpaKey, |
|
353 iNotifWpaKey ); |
|
354 SetActive(); |
|
355 return; |
|
356 } |
|
357 else if ( iNetworkPrefs().iSecMode == EWlanConnectionSecurityOpen ) |
|
358 { |
|
359 MPMLOGSTRING( "CMPMWlanQueryDialog::RunL: No WPS, sec mode open" ); |
|
360 iStatus = KErrNone; |
|
361 } |
|
362 else |
|
363 { |
|
364 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL: No WPS, unsupported sec mode %d", |
|
365 iNetworkPrefs().iSecMode ); |
|
366 iStatus = KErrNotSupported; |
|
367 } |
|
368 } |
|
369 } |
|
370 } |
|
371 else if ( iWlanQueryState == ERetrySettingsStorage ) |
|
372 { |
|
373 // Retry settings storage |
|
374 MPMLOGSTRING( "CMPMWlanQueryDialog::RunL Retry settings storage" ) |
|
375 } |
171 } |
376 else |
172 else |
377 { |
173 { |
378 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL, unknown state: %d", iWlanQueryState ) |
174 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL, unknown state: %d", iWlanQueryState ) |
379 User::Leave( KErrCancel ); |
175 User::Leave( KErrCancel ); |
380 } |
176 } |
381 |
177 |
382 TRAPD( leaveCode, iIapSelection.UserWlanSelectionDoneL( iStatus.Int(), iWlanIapId ) ); |
178 iIapSelection.UserWlanSelectionDoneL( iStatus.Int(), iWlanIapId ); |
383 if( leaveCode != KErrNone ) |
|
384 { |
|
385 // Something caused method to leave, if CommsDat was locked we should retry |
|
386 if ( iStatus.Int() == KErrNone && |
|
387 leaveCode == KErrLocked && |
|
388 iRetryCount > 0 ) |
|
389 { |
|
390 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL Start retry timer, retry count %d", iRetryCount ) |
|
391 iWlanQueryState = ERetrySettingsStorage; |
|
392 iRetryCount--; |
|
393 iTimer.After( iStatus, KStoreRetryDelay ); |
|
394 SetActive(); |
|
395 return; |
|
396 } |
|
397 else |
|
398 { |
|
399 User::Leave( leaveCode ); |
|
400 } |
|
401 } |
|
402 |
179 |
403 iWlanIapId = 0; |
180 iWlanIapId = 0; |
404 iWlanQueryState = EWlanNetwork; |
|
405 } |
181 } |
406 |
182 |
407 // --------------------------------------------------------------------------- |
183 // --------------------------------------------------------------------------- |
408 // CMPMWlanQueryDialog::RunError |
184 // CMPMWlanQueryDialog::RunError |
409 // --------------------------------------------------------------------------- |
185 // --------------------------------------------------------------------------- |
410 // |
186 // |
411 TInt CMPMWlanQueryDialog::RunError( TInt aError ) |
187 TInt CMPMWlanQueryDialog::RunError( TInt aError ) |
412 { |
188 { |
413 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunError failed with %d", aError ) |
189 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunError failed with %d", aError ) |
414 iEasyWlanSelected = EFalse; |
|
415 iIapSelection.ChooseIapComplete( aError, NULL ); |
190 iIapSelection.ChooseIapComplete( aError, NULL ); |
416 return KErrNone; |
191 return KErrNone; |
417 } |
192 } |
418 |
193 |
419 // ----------------------------------------------------------------------------- |
194 // ----------------------------------------------------------------------------- |
488 KNullDesC8(), |
236 KNullDesC8(), |
489 iOfflineReply ); |
237 iOfflineReply ); |
490 SetActive(); |
238 SetActive(); |
491 } |
239 } |
492 } |
240 } |
493 // if easy wlan iap and some wlan iap started, use existing connection |
|
494 // |
|
495 else if( iIapSelection.Session()->MyServer().CommsDatAccess()->CheckEasyWLanL( iWlanIapId ) && |
|
496 activeWlanIap ) |
|
497 { |
|
498 MPMLOGSTRING2( "CMPMWlanQueryDialog::StartWlanQuery using active WLAN IAP %d", |
|
499 activeWlanIap ) |
|
500 iIapSelection.UserWlanSelectionDoneL( KErrNone, activeWlanIap ); |
|
501 } |
|
502 // if easy wlan iap and easy wlan is not already started |
|
503 // |
|
504 else if( iIapSelection.Session()->MyServer().CommsDatAccess()->CheckEasyWLanL( iWlanIapId ) && |
|
505 !iIapSelection.Session()->MyServer().CheckIfStarted( iWlanIapId ) && |
|
506 iNetworkPrefs().iSsId.Length() == 0 && |
|
507 iOverrideStatus == KErrNone ) |
|
508 { |
|
509 MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery starting network query" ) |
|
510 GetNetworkPrefs(); |
|
511 } |
|
512 // if an error was given through OfferInformation() -call we abort the execution. |
|
513 // |
|
514 else if ( iOverrideStatus != KErrNone ) |
|
515 { |
|
516 MPMLOGSTRING2( "CMPMWlanQueryDialog::StartWlanQuery inherited error %d", iOverrideStatus ) |
|
517 iIapSelection.UserWlanSelectionDoneL( iOverrideStatus, iWlanIapId ); |
|
518 } |
|
519 else |
241 else |
520 { |
242 { |
521 MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery no wlan dialog to show" ) |
243 MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery no wlan dialog to show" ) |
522 iIapSelection.UserWlanSelectionDoneL( KErrNone, iWlanIapId ); |
244 iIapSelection.UserWlanSelectionDoneL( KErrNone, iWlanIapId ); |
523 } |
245 } |
524 } |
246 } |
525 |
247 |
526 |
|
527 // ----------------------------------------------------------------------------- |
248 // ----------------------------------------------------------------------------- |
528 // CMPMWlanQueryDialog::OfferInformation |
249 // CMPMWlanQueryDialog::OfferInformation |
529 // ----------------------------------------------------------------------------- |
250 // ----------------------------------------------------------------------------- |
530 // |
251 // |
531 void CMPMWlanQueryDialog::OfferInformation( |
252 void CMPMWlanQueryDialog::OfferInformation( TInt aDialogStatus ) |
532 TUint32 aWlanIapId, |
253 { |
533 TOfflineNoteResponse aOfflineStatus, |
254 TOfflineWlanQueryResponse offlineResponse = |
534 TInt aDialogStatus ) |
255 iIapSelection.Session()->MyServer().OfflineWlanQueryResponse(); |
535 { |
256 if ( offlineResponse != EOfflineResponseUndefined ) |
536 TBool isEasyWlan( EFalse ); |
|
537 // Take information from earlier note into use |
|
538 // if the selected IAP is EasyWLAN or Offline note response was No. |
|
539 // |
|
540 TRAP_IGNORE( isEasyWlan = |
|
541 iIapSelection.Session()->MyServer().CommsDatAccess()->CheckEasyWLanL( iWlanIapId ); ) |
|
542 if ( isEasyWlan ) |
|
543 { |
|
544 // iEasyWlanSelected is not passed as only the first connection |
|
545 // should write the easy wlan settings to commsdat if easy wlan is used. |
|
546 // |
|
547 MPMLOGSTRING3( "CMPMWlanQueryDialog<0x%x>::OfferInformation: EasyWLAN, iap %d", |
|
548 iIapSelection.Session()->ConnectionId(), |
|
549 aWlanIapId ) |
|
550 |
|
551 iWlanIapId = aWlanIapId; |
|
552 iOverrideStatus = aDialogStatus; |
|
553 } |
|
554 if ( aOfflineStatus != EOfflineResponseUndefined ) |
|
555 { |
257 { |
556 MPMLOGSTRING3( "CMPMWlanQueryDialog<0x%x>::OfferInformation: offline response %d", |
258 MPMLOGSTRING3( "CMPMWlanQueryDialog<0x%x>::OfferInformation: offline response %d", |
557 iIapSelection.Session()->ConnectionId(), |
259 iIapSelection.Session()->ConnectionId(), |
558 aOfflineStatus ) |
260 offlineResponse ) |
559 iIapSelection.SetOfflineNoteResponse( aOfflineStatus ); |
|
560 iOverrideStatus = aDialogStatus; |
261 iOverrideStatus = aDialogStatus; |
561 } |
262 } |
562 |
263 |
563 #ifdef _LOG |
264 #ifdef _LOG |
564 else |
265 else |
566 MPMLOGSTRING( "CMPMWlanQueryDialog::OfferInformation, information not taken." ) |
267 MPMLOGSTRING( "CMPMWlanQueryDialog::OfferInformation, information not taken." ) |
567 } |
268 } |
568 #endif |
269 #endif |
569 } |
270 } |
570 |
271 |
571 |
|
572 // ----------------------------------------------------------------------------- |
|
573 // CMPMWlanQueryDialog::StoreEasyWlanSelectionL |
|
574 // ----------------------------------------------------------------------------- |
|
575 // |
|
576 void CMPMWlanQueryDialog::StoreEasyWlanSelectionL() |
|
577 { |
|
578 if( iEasyWlanSelected ) |
|
579 { |
|
580 TWlanSsid ssid; |
|
581 TWepKeyData wepData; |
|
582 TUint wpaPskEnabled( 0 ); |
|
583 TUint wpaPskLen( 0 ); |
|
584 TBuf8<KWLMMaxWpaPskLength> wpa; |
|
585 TUint secMode( 0 ); |
|
586 TWlanNetMode connMode( EInfra ); |
|
587 |
|
588 if( iWpsCompleted ) |
|
589 { |
|
590 GetEasyWlanDataForWpsL( ssid, |
|
591 secMode, |
|
592 connMode, |
|
593 wepData, |
|
594 wpaPskEnabled, |
|
595 wpa, |
|
596 wpaPskLen ); |
|
597 MPMLOGSTRING3( "CMPMWlanQueryDialog::StoreEasyWlanSelection: \ |
|
598 wps used, connection iap %d, ssid %S", iWlanIapId, &iWpsAttribute.iSsid ) |
|
599 iIapSelection.Session()->MyServer().Events()-> |
|
600 SetConnInfoIapSsid( iWlanIapId, |
|
601 iWpsAttribute.iSsid ); |
|
602 iIapSelection.Session()->MyServer().CommsDatAccess()->SetEasyWlanDataL( ssid, |
|
603 secMode, |
|
604 connMode, |
|
605 wepData, |
|
606 wpaPskEnabled, |
|
607 wpa, |
|
608 wpaPskLen ); |
|
609 return; |
|
610 } |
|
611 |
|
612 MPMLOGSTRING( "CMPMWlanQueryDialog::StoreEasyWlanSelection: setting easy wlan data" ) |
|
613 GetEasyWlanDataL( ssid, |
|
614 secMode, |
|
615 connMode, |
|
616 wepData, |
|
617 wpaPskEnabled, |
|
618 wpa, |
|
619 wpaPskLen ); |
|
620 |
|
621 MPMLOGSTRING3( "CMPMWlanQueryDialog::StoreEasyWlanSelection: \ |
|
622 setting easy wlan iap %d ssid %S in connmon events", iWlanIapId, &iNetworkPrefs().iSsId ) |
|
623 iIapSelection.Session()->MyServer().Events()->SetConnInfoIapSsid( iWlanIapId, |
|
624 iNetworkPrefs().iSsId ); |
|
625 iIapSelection.Session()->MyServer().CommsDatAccess()->SetEasyWlanDataL( ssid, |
|
626 secMode, |
|
627 connMode, |
|
628 wepData, |
|
629 wpaPskEnabled, |
|
630 wpa, |
|
631 wpaPskLen ); |
|
632 |
|
633 } |
|
634 else |
|
635 { |
|
636 MPMLOGSTRING( "CMPMWlanQueryDialog::StoreEasyWlanSelection: no easy wlan selected by user" ) |
|
637 } |
|
638 } |
|
639 |
|
640 |
|
641 // ----------------------------------------------------------------------------- |
|
642 // CMPMWlanQueryDialog::GetEasyWlanDataL |
|
643 // ----------------------------------------------------------------------------- |
|
644 // |
|
645 void CMPMWlanQueryDialog::GetEasyWlanDataL( TWlanSsid& aSsid, |
|
646 TUint& aSecMode, |
|
647 TWlanNetMode& aConnMode, |
|
648 TWepKeyData& aWepData, |
|
649 TUint& aEnableWpaPsk, |
|
650 TDes8& aWpaPsk, |
|
651 TUint& aWpaKeyLen ) |
|
652 { |
|
653 aSsid.Copy( iNetworkPrefs().iSsId ); |
|
654 if ( iNetworkPrefs().iNetworkMode == EWlanConnectionModeAdhoc ) |
|
655 { |
|
656 aConnMode = EAdhoc; |
|
657 } |
|
658 |
|
659 // Set security mode |
|
660 TInt err = ConnSecModeToCommsDatSecMode( iNetworkPrefs().iSecMode, |
|
661 aSecMode ); |
|
662 |
|
663 if( err != KErrNone ) |
|
664 { |
|
665 MPMLOGSTRING2( "CMPMWlanQueryDialog::StoreEasyWlanSelection: \ |
|
666 unsupported sec mode %d. leaving", iNetworkPrefs().iSecMode ) |
|
667 User::Leave( KErrNotSupported ); |
|
668 } |
|
669 |
|
670 if( iNetworkPrefs().iSecMode == EWlanConnectionSecurityWep ) |
|
671 { |
|
672 CnvUtfConverter::ConvertFromUnicodeToUtf8( aWepData.iWep1, iNotifWep().iKey ); |
|
673 //MPMLOG8STRING2( "CMPMWlanQueryDialog::StoreEasyWlanSelection:wep-key8:%S ", &aWepData.iWep1 ) |
|
674 if( iNotifWep().iHex ) |
|
675 { |
|
676 aWepData.iWepFormat1 = 1; |
|
677 MPMLOGSTRING( "CMPMWlanQueryDialog::StoreEasyWlanSelection: wep format is 1 (hex)") |
|
678 } |
|
679 aWepData.iDefaultWep = EWlanDefaultWepKey1; |
|
680 } |
|
681 else if( iNetworkPrefs().iSecMode == EWlanConnectionSecurityWpaPsk ) |
|
682 { |
|
683 CnvUtfConverter::ConvertFromUnicodeToUtf8( aWpaPsk, iNotifWpaKey() ); |
|
684 aEnableWpaPsk = 1; |
|
685 aWpaKeyLen = aWpaPsk.Length(); |
|
686 MPMLOGSTRING3( "CMPMWlanQueryDialog::StoreEasyWlanSelection:wpapsk-key:%s, len:%d", |
|
687 &iNotifWpaKey(), |
|
688 aWpaKeyLen ) |
|
689 } |
|
690 else |
|
691 { |
|
692 MPMLOGSTRING2( "CMPMWlanQueryDialog::StoreEasyWlanSelection: \ |
|
693 no key handling needed for sec mode %d", iNetworkPrefs().iSecMode ) |
|
694 } |
|
695 } |
|
696 |
|
697 // --------------------------------------------------------------------------- |
|
698 // CMPMWlanQueryDialog::ConnSecModeToCommsDatSecMode |
|
699 // --------------------------------------------------------------------------- |
|
700 // |
|
701 TInt CMPMWlanQueryDialog::ConnSecModeToCommsDatSecMode( TWlanConnectionSecurityMode aConnSecmode, |
|
702 TUint& aCommsdatSecMode ) const |
|
703 { |
|
704 |
|
705 if ( aConnSecmode == EWlanConnectionSecurityOpen ) |
|
706 { |
|
707 aCommsdatSecMode = EWlanSecModeOpen; |
|
708 } |
|
709 else if ( aConnSecmode == EWlanConnectionSecurityWep ) |
|
710 { |
|
711 aCommsdatSecMode = EWlanSecModeWep; |
|
712 } |
|
713 else if ( aConnSecmode == EWlanConnectionSecurityWpaPsk ) |
|
714 { |
|
715 aCommsdatSecMode = EWlanSecModeWpa2; |
|
716 } |
|
717 else if ( aConnSecmode == EWlanConnectionSecurityWpa ) |
|
718 { |
|
719 aCommsdatSecMode = EWlanSecModeWpa; |
|
720 } |
|
721 else |
|
722 { |
|
723 MPMLOGSTRING( "CMPMWlanQueryDialog::RunL, Unknown security mode" ) |
|
724 return KErrCouldNotConnect; |
|
725 } |
|
726 return KErrNone; |
|
727 } |
|
728 |
|
729 |
|
730 // --------------------------------------------------------------------------- |
|
731 // CMPMWlanQueryDialog::IapSecModeToCommsDatSecMode |
|
732 // --------------------------------------------------------------------------- |
|
733 // |
|
734 TInt CMPMWlanQueryDialog::IapSecModeToCommsDatSecMode( TWlanIapSecurityMode aIapSecmode, |
|
735 TUint& aCommsdatSecMode ) const |
|
736 { |
|
737 switch( aIapSecmode ) |
|
738 { |
|
739 case EWlanIapSecurityModeAllowUnsecure: |
|
740 aCommsdatSecMode |= EWlanSecModeOpen; |
|
741 break; |
|
742 case EWlanIapSecurityModeWep: |
|
743 aCommsdatSecMode |= EWlanSecModeWep; |
|
744 break; |
|
745 case EWlanIapSecurityModeWpa: |
|
746 aCommsdatSecMode |= EWlanSecModeWpa; |
|
747 break; |
|
748 case EWlanIapSecurityModeWpa2Only: |
|
749 aCommsdatSecMode |= EWlanSecModeWpa2; |
|
750 break; |
|
751 default: |
|
752 MPMLOGSTRING2( "CMPMWlanQueryDialog::IapSecModeToCommsDatSecMode: \ |
|
753 unsupported sec mode %d ", aIapSecmode ) |
|
754 return KErrNotSupported; |
|
755 } |
|
756 return KErrNone; |
|
757 } |
|
758 |
|
759 // ----------------------------------------------------------------------------- |
|
760 // CMPMWlanQueryDialog::GetEasyWlanDataForWpsL |
|
761 // ----------------------------------------------------------------------------- |
|
762 // |
|
763 void CMPMWlanQueryDialog::GetEasyWlanDataForWpsL( TWlanSsid& aSsid, |
|
764 TUint& aSecMode, |
|
765 TWlanNetMode& aConnMode, |
|
766 TWepKeyData& aWepKeyData, |
|
767 TUint& aEnableWpaPsk, |
|
768 TDes8& aWpaPsk, |
|
769 TUint& aWpaKeyLen ) |
|
770 { |
|
771 aSsid.Copy( iWpsAttribute.iSsid ); |
|
772 if ( iWpsAttribute.iOperatingMode == EWlanOperatingModeAdhoc ) |
|
773 { |
|
774 aConnMode = EAdhoc; |
|
775 } |
|
776 TInt err = IapSecModeToCommsDatSecMode( iWpsAttribute.iSecurityMode, |
|
777 aSecMode ); |
|
778 if( err != KErrNone ) |
|
779 { |
|
780 MPMLOGSTRING( "CMPMWlanQueryDialog::GetEasyWlanDataForWpsL: \ |
|
781 unsupported wps sec mode leaving" ) |
|
782 User::Leave( KErrNotSupported ); |
|
783 } |
|
784 |
|
785 if( iWpsAttribute.iSecurityMode == EWlanIapSecurityModeWep ) |
|
786 { |
|
787 if( iWpsAttribute.iWepKey1.Length() && |
|
788 IsWepFormatHexL( iWpsAttribute.iWepKey1.Length() ) ) |
|
789 { |
|
790 aWepKeyData.iWepFormat1 = 1; |
|
791 } |
|
792 if( iWpsAttribute.iWepKey2.Length() && |
|
793 IsWepFormatHexL( iWpsAttribute.iWepKey2.Length() ) ) |
|
794 { |
|
795 aWepKeyData.iWepFormat2 = 1; |
|
796 } |
|
797 if( iWpsAttribute.iWepKey3.Length() && |
|
798 IsWepFormatHexL( iWpsAttribute.iWepKey3.Length() ) ) |
|
799 { |
|
800 aWepKeyData.iWepFormat3 = 1; |
|
801 } |
|
802 if( iWpsAttribute.iWepKey4.Length() && |
|
803 IsWepFormatHexL( iWpsAttribute.iWepKey4.Length() ) ) |
|
804 { |
|
805 aWepKeyData.iWepFormat4 = 1; |
|
806 } |
|
807 aWepKeyData.iWep1.Copy( iWpsAttribute.iWepKey1 ); |
|
808 aWepKeyData.iWep2.Copy( iWpsAttribute.iWepKey2 ); |
|
809 aWepKeyData.iWep3.Copy( iWpsAttribute.iWepKey3 ); |
|
810 aWepKeyData.iWep4.Copy( iWpsAttribute.iWepKey4 ); |
|
811 aWepKeyData.iDefaultWep = iWpsAttribute.iWepDefaultKey; |
|
812 } |
|
813 if( iWpsAttribute.iWpaPreSharedKey.Length() ) |
|
814 { |
|
815 aEnableWpaPsk = 1; |
|
816 aWpaPsk.Copy( iWpsAttribute.iWpaPreSharedKey ); |
|
817 aWpaKeyLen = aWpaPsk.Length(); |
|
818 } |
|
819 |
|
820 } |
|
821 |
|
822 // --------------------------------------------------------------------------- |
|
823 // CMPMWlanQueryDialog::StartWpsDlgL |
|
824 // --------------------------------------------------------------------------- |
|
825 // |
|
826 void CMPMWlanQueryDialog::StartWpsDlgL() |
|
827 { |
|
828 MPMLOGSTRING( "CMPMWlanQueryDialog::StartWpsDlgL, Starting WPS" ) |
|
829 iWlanQueryState = EWPS; |
|
830 iWps = CWiFiProtUiClient::NewL(); |
|
831 iWps->StartWiFiProtConnL( iNetworkPrefs().iSsId, // TWlanSsid&, |
|
832 iWpsAttribute, |
|
833 iWpsReturn, |
|
834 iStatus ); |
|
835 SetActive(); |
|
836 } |
|
837 |
|
838 // --------------------------------------------------------------------------- |
|
839 // CMPMWlanQueryDialog::IsWepFormatHexL |
|
840 // --------------------------------------------------------------------------- |
|
841 // |
|
842 TBool CMPMWlanQueryDialog::IsWepFormatHexL( TInt aLength ) const |
|
843 { |
|
844 MPMLOGSTRING2( "CMPMWlanQueryDialog::IsWepFormatHexL length %d", aLength ) |
|
845 |
|
846 if ( ( aLength == KConnUiUtilsWepLengthASCII5 ) || |
|
847 ( aLength == KConnUiUtilsWepLengthASCII13 ) || |
|
848 ( aLength == KConnUiUtilsWepLengthASCII29 ) ) |
|
849 { |
|
850 return EFalse; |
|
851 } |
|
852 else if ( ( aLength == KConnUiUtilsWepLengthHEX10 ) || |
|
853 ( aLength == KConnUiUtilsWepLengthHEX26 ) || |
|
854 ( aLength == KConnUiUtilsWepLengthHEX58 ) ) |
|
855 { |
|
856 return ETrue; |
|
857 } |
|
858 else |
|
859 { |
|
860 User::Leave( KErrNotSupported ); |
|
861 } |
|
862 return EFalse; |
|
863 } |
|
864 |
|
865 // --------------------------------------------------------------------------- |
|
866 // CMPMWlanQueryDialog::GetNetworkPrefs |
|
867 // --------------------------------------------------------------------------- |
|
868 // |
|
869 void CMPMWlanQueryDialog::GetNetworkPrefs() |
|
870 { |
|
871 iWlanQueryState = EWlanNetwork; |
|
872 iConnUiUtils->SearchWLANNetworkAsync( iStatus, |
|
873 iNetworkPrefs().iSsId, |
|
874 iNetworkPrefs().iNetworkMode, |
|
875 iNetworkPrefs().iSecMode, |
|
876 iNetworkPrefs().iProtectedSetupSupported |
|
877 ); |
|
878 SetActive(); |
|
879 } |
|
880 |
|