|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Handles displaying wlan dialogs |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <wlanmgmtcommon.h> |
|
20 #include <e32std.h> |
|
21 #include <utf.h> |
|
22 #include <cmpluginwlandef.h> |
|
23 #include <ctsydomainpskeys.h> |
|
24 |
|
25 #include "mpmwlanquerydialog.h" |
|
26 #include "mpmiapselection.h" |
|
27 #include "mpmconnmonevents.h" |
|
28 #include "mpmlogger.h" |
|
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 ======== |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // CMPMWlanQueryDialog::CMPMWlanQueryDialog |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CMPMWlanQueryDialog::CMPMWlanQueryDialog( CMPMIapSelection& aSession, |
|
50 TUint32 aWlanIapId ) |
|
51 : CActive( CActive::EPriorityStandard ), |
|
52 iIapSelection( aSession ), |
|
53 iNetworkPrefs(), |
|
54 iNotifWep(), |
|
55 iWlanQueryState( EWlanNetwork ), |
|
56 iWlanIapId( aWlanIapId ), |
|
57 iEasyWlanSelected( EFalse ), |
|
58 iOverrideStatus( KErrNone ), |
|
59 iConnUiUtils( NULL ), |
|
60 iWps( NULL ), |
|
61 iWpsReturn( WiFiProt::EWiFiOK ), |
|
62 iWpsCompleted( EFalse ), |
|
63 iRetryCount( 0 ) |
|
64 { |
|
65 |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // CMPMWlanQueryDialog::ConstructL |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 void CMPMWlanQueryDialog::ConstructL() |
|
73 { |
|
74 User::LeaveIfError(iNotifier.Connect()); |
|
75 CActiveScheduler::Add( this ); |
|
76 iConnUiUtils = CConnectionUiUtilities::NewL(); |
|
77 User::LeaveIfError( iTimer.CreateLocal() ); |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CMPMWlanQueryDialog::NewL |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 CMPMWlanQueryDialog* CMPMWlanQueryDialog::NewL( CMPMIapSelection& aSession, |
|
85 TUint32 aWlanIapElementId ) |
|
86 { |
|
87 CMPMWlanQueryDialog* self = new( ELeave ) CMPMWlanQueryDialog( aSession, |
|
88 aWlanIapElementId ); |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL(); |
|
91 CleanupStack::Pop( self ); |
|
92 return self; |
|
93 } |
|
94 |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // CMPMWlanQueryDialog::~CMPMWlanQueryDialog |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 CMPMWlanQueryDialog::~CMPMWlanQueryDialog() |
|
101 { |
|
102 MPMLOGSTRING( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog enters" ) |
|
103 // Check if this dialog instance was not started but only added to the queue |
|
104 if ( iIapSelection.Session()->MyServer().FirstInWlanQueryQueue() != this ) |
|
105 { |
|
106 MPMLOGSTRING( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog, not a active delete" ) |
|
107 |
|
108 // Close notifier and timer |
|
109 iNotifier.Close(); |
|
110 iTimer.Close(); |
|
111 |
|
112 // We're not first in the queue, thus we can just delete. |
|
113 // But remember the pointer in the array. |
|
114 iIapSelection.Session()->MyServer().RemoveFromWlanQueryQueue( this ); |
|
115 MPMLOGSTRING( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog exits (break)" ) |
|
116 return; |
|
117 } |
|
118 |
|
119 // Cancel previous dialogs if any. |
|
120 Cancel(); |
|
121 |
|
122 // Close notifier and timer |
|
123 iNotifier.Close(); |
|
124 iTimer.Close(); |
|
125 |
|
126 delete iConnUiUtils; |
|
127 |
|
128 delete iWps; |
|
129 // Remove self from the queue |
|
130 iIapSelection.Session()->MyServer().RemoveFromWlanQueryQueue( this ); |
|
131 |
|
132 // Start the next query |
|
133 CMPMWlanQueryDialog* dlg = iIapSelection.Session()->MyServer().FirstInWlanQueryQueue(); |
|
134 if ( dlg ) |
|
135 { |
|
136 MPMLOGSTRING( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog starts new dialog" ) |
|
137 dlg->OfferInformation( iWlanIapId, |
|
138 iIapSelection.OfflineNoteResponse(), |
|
139 iStatus.Int() ); |
|
140 // In destructor we cannot let the query leave |
|
141 TRAPD( err, dlg->StartWlanQueryL(); ) |
|
142 if ( err != KErrNone ) |
|
143 { |
|
144 MPMLOGSTRING2( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog caught Leave %d, executing RunError()", err ) |
|
145 dlg->RunError( err ); |
|
146 } |
|
147 } |
|
148 |
|
149 MPMLOGSTRING( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog exits" ) |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------------------------- |
|
153 // CMPMWlanQueryDialog::DoCancel |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 void CMPMWlanQueryDialog::DoCancel() |
|
157 { |
|
158 MPMLOGSTRING2( "CMPMWlanQueryDialog::DoCancel state %d", iWlanQueryState ) |
|
159 if ( iWlanQueryState == EOffline ) |
|
160 { |
|
161 iNotifier.CancelNotifier( KUidCOfflineWlanNoteDlg ); |
|
162 } |
|
163 else if ( iWlanQueryState == EWlanNetwork ) |
|
164 { |
|
165 iConnUiUtils->CancelSearchWLANNetwork(); |
|
166 } |
|
167 else if ( iWlanQueryState == EWepSettings ) |
|
168 { |
|
169 iNotifier.CancelNotifier( KUidEasyWepDlg ); |
|
170 } |
|
171 else if( iWlanQueryState == EWPS ) |
|
172 { |
|
173 iWps->CancelWiFiProt(); |
|
174 } |
|
175 else if ( iWlanQueryState == EWpaSettings ) |
|
176 { |
|
177 iNotifier.CancelNotifier( KUidEasyWpaDlg ); |
|
178 } |
|
179 else // ERetrySettingsStorage |
|
180 { |
|
181 iTimer.Cancel(); |
|
182 } |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // CMPMWlanQueryDialog::RunL |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 void CMPMWlanQueryDialog::RunL() |
|
190 { |
|
191 MPMLOGSTRING3( "CMPMWlanQueryDialog::RunL status %d state %d", |
|
192 iStatus.Int(), |
|
193 iWlanQueryState ) |
|
194 if( iWlanQueryState == EOffline ) |
|
195 { |
|
196 if( iStatus.Int() == KErrNone ) |
|
197 { |
|
198 iIapSelection.SetOfflineNoteResponse( EOfflineResponseYes ); |
|
199 if( iIapSelection.Session()->MyServer().CommsDatAccess()->CheckEasyWLanL( iWlanIapId ) ) |
|
200 { |
|
201 MPMLOGSTRING( "CMPMWlanQueryDialog::RunL starting wlan network query" ) |
|
202 GetNetworkPrefs(); |
|
203 return; |
|
204 } |
|
205 } |
|
206 else if ( iStatus.Int() == KErrCancel ) |
|
207 { |
|
208 iIapSelection.SetOfflineNoteResponse( EOfflineResponseNo ); |
|
209 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL offline query returned %d", |
|
210 iStatus.Int() ) |
|
211 } |
|
212 else |
|
213 { |
|
214 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL offline query returned %d", |
|
215 iStatus.Int() ) |
|
216 } |
|
217 } |
|
218 else if( iWlanQueryState == EWlanNetwork ) |
|
219 { |
|
220 if( iStatus.Int() == KErrNone ) |
|
221 { |
|
222 |
|
223 TUint secMode( 0 ); |
|
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 MPMLOGSTRING( "CMPMWlanQueryDialog::RunL No Auto, starting WPA key query" ) |
|
336 iWlanQueryState = EWpaSettings; |
|
337 iNotifier.StartNotifierAndGetResponse( iStatus, |
|
338 KUidEasyWpaDlg, |
|
339 iNotifWpaKey, |
|
340 iNotifWpaKey ); |
|
341 SetActive(); |
|
342 return; |
|
343 } |
|
344 } |
|
345 } |
|
346 else if ( iWlanQueryState == ERetrySettingsStorage ) |
|
347 { |
|
348 // Retry settings storage |
|
349 MPMLOGSTRING( "CMPMWlanQueryDialog::RunL Retry settings storage" ) |
|
350 } |
|
351 else |
|
352 { |
|
353 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL, unknown state: %d", iWlanQueryState ) |
|
354 User::Leave( KErrCancel ); |
|
355 } |
|
356 |
|
357 TRAPD( leaveCode, iIapSelection.UserWlanSelectionDoneL( iStatus.Int(), iWlanIapId ) ); |
|
358 if( leaveCode != KErrNone ) |
|
359 { |
|
360 // Something caused method to leave, if CommsDat was locked we should retry |
|
361 if ( iStatus.Int() == KErrNone && |
|
362 leaveCode == KErrLocked && |
|
363 iRetryCount > 0 ) |
|
364 { |
|
365 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL Start retry timer, retry count %d", iRetryCount ) |
|
366 iWlanQueryState = ERetrySettingsStorage; |
|
367 iRetryCount--; |
|
368 iTimer.After( iStatus, KStoreRetryDelay ); |
|
369 SetActive(); |
|
370 return; |
|
371 } |
|
372 else |
|
373 { |
|
374 User::Leave( leaveCode ); |
|
375 } |
|
376 } |
|
377 |
|
378 iWlanIapId = 0; |
|
379 iWlanQueryState = EWlanNetwork; |
|
380 } |
|
381 |
|
382 // --------------------------------------------------------------------------- |
|
383 // CMPMWlanQueryDialog::RunError |
|
384 // --------------------------------------------------------------------------- |
|
385 // |
|
386 TInt CMPMWlanQueryDialog::RunError( TInt aError ) |
|
387 { |
|
388 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunError failed with %d", aError ) |
|
389 iEasyWlanSelected = EFalse; |
|
390 iIapSelection.ChooseIapComplete( aError, NULL ); |
|
391 return KErrNone; |
|
392 } |
|
393 |
|
394 // ----------------------------------------------------------------------------- |
|
395 // CMPMWlanQueryDialog::StartWlanQueryL |
|
396 // ----------------------------------------------------------------------------- |
|
397 // |
|
398 void CMPMWlanQueryDialog::StartWlanQueryL() |
|
399 { |
|
400 MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery" ) |
|
401 |
|
402 iRetryCount = KStoreRetryCount; |
|
403 |
|
404 // if first dialog user, add it to the array and continue. |
|
405 // |
|
406 if ( iIapSelection.Session()->MyServer().WlanQueryQueue()->Count() == 0 ) |
|
407 { |
|
408 MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery First one, start immediately" ) |
|
409 iIapSelection.Session()->MyServer().AppendWlanQueryQueueL( this ); |
|
410 } |
|
411 // if another dialog should be processed before this, just add and return. |
|
412 // |
|
413 else if ( iIapSelection.Session()->MyServer().FirstInWlanQueryQueue() != this ) |
|
414 { |
|
415 MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery Latter, process later" ) |
|
416 iIapSelection.Session()->MyServer().AppendWlanQueryQueueL( this ); |
|
417 return; |
|
418 } |
|
419 // else Continue to process the first dialog.(this one) |
|
420 // FirstInWlanQueryQueue() == this && Count() > 0 |
|
421 |
|
422 TUint32 activeWlanIap = iIapSelection.Session()->MyServer().IsWlanConnectionStartedL( |
|
423 iIapSelection.Session()->MyServer().CommsDatAccess() ); |
|
424 |
|
425 // Get EmergencyCallInfo via Publish & Subscribe |
|
426 // |
|
427 TInt emergencyCallEstablished( 0 ); |
|
428 RProperty::Get( KPSUidCtsyEmergencyCallInfo, |
|
429 KCTSYEmergencyCallInfo, |
|
430 emergencyCallEstablished ); |
|
431 MPMLOGSTRING2( "CMPMWlanQueryDialog::StartWlanQuery KCTSYEmergencyCallInfo = %d", |
|
432 emergencyCallEstablished ) |
|
433 |
|
434 if( !emergencyCallEstablished && |
|
435 iIapSelection.Session()->IsPhoneOfflineL() && |
|
436 !activeWlanIap && |
|
437 iIapSelection.OfflineNoteResponse() != EOfflineResponseYes && |
|
438 iOverrideStatus == KErrNone ) |
|
439 { |
|
440 // if user has already refused offline note complete immediately |
|
441 // |
|
442 if ( iIapSelection.OfflineNoteResponse() == EOfflineResponseNo ) |
|
443 { |
|
444 MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery user has already refused offline" ) |
|
445 iIapSelection.UserWlanSelectionDoneL( KErrCancel, iWlanIapId ); |
|
446 } |
|
447 else |
|
448 { |
|
449 MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery, starting offline note" ) |
|
450 iWlanQueryState = EOffline; |
|
451 iNotifier.StartNotifierAndGetResponse( iStatus, |
|
452 KUidCOfflineWlanNoteDlg, |
|
453 KNullDesC8(), |
|
454 iOfflineReply ); |
|
455 SetActive(); |
|
456 } |
|
457 } |
|
458 // if easy wlan iap and some wlan iap started, use existing connection |
|
459 // |
|
460 else if( iIapSelection.Session()->MyServer().CommsDatAccess()->CheckEasyWLanL( iWlanIapId ) && |
|
461 activeWlanIap ) |
|
462 { |
|
463 MPMLOGSTRING2( "CMPMWlanQueryDialog::StartWlanQuery using active WLAN IAP %d", |
|
464 activeWlanIap ) |
|
465 iIapSelection.UserWlanSelectionDoneL( KErrNone, activeWlanIap ); |
|
466 } |
|
467 // if easy wlan iap and easy wlan is not already started |
|
468 // |
|
469 else if( iIapSelection.Session()->MyServer().CommsDatAccess()->CheckEasyWLanL( iWlanIapId ) && |
|
470 !iIapSelection.Session()->MyServer().CheckIfStarted( iWlanIapId ) && |
|
471 iNetworkPrefs().iSsId.Length() == 0 && |
|
472 iOverrideStatus == KErrNone ) |
|
473 { |
|
474 MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery starting network query" ) |
|
475 GetNetworkPrefs(); |
|
476 } |
|
477 // if an error was given through OfferInformation() -call we abort the execution. |
|
478 // |
|
479 else if ( iOverrideStatus != KErrNone ) |
|
480 { |
|
481 MPMLOGSTRING2( "CMPMWlanQueryDialog::StartWlanQuery inherited error %d", iOverrideStatus ) |
|
482 iIapSelection.UserWlanSelectionDoneL( iOverrideStatus, iWlanIapId ); |
|
483 } |
|
484 else |
|
485 { |
|
486 MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery no wlan dialog to show" ) |
|
487 iIapSelection.UserWlanSelectionDoneL( KErrNone, iWlanIapId ); |
|
488 } |
|
489 } |
|
490 |
|
491 |
|
492 // ----------------------------------------------------------------------------- |
|
493 // CMPMWlanQueryDialog::OfferInformation |
|
494 // ----------------------------------------------------------------------------- |
|
495 // |
|
496 void CMPMWlanQueryDialog::OfferInformation( |
|
497 TUint32 aWlanIapId, |
|
498 TOfflineNoteResponse aOfflineStatus, |
|
499 TInt aDialogStatus ) |
|
500 { |
|
501 TBool isEasyWlan( EFalse ); |
|
502 // Take information from earlier note into use |
|
503 // if the selected IAP is EasyWLAN or Offline note response was No. |
|
504 // |
|
505 TRAP_IGNORE( isEasyWlan = |
|
506 iIapSelection.Session()->MyServer().CommsDatAccess()->CheckEasyWLanL( iWlanIapId ); ) |
|
507 if ( isEasyWlan ) |
|
508 { |
|
509 // iEasyWlanSelected is not passed as only the first connection |
|
510 // should write the easy wlan settings to commsdat if easy wlan is used. |
|
511 // |
|
512 MPMLOGSTRING3( "CMPMWlanQueryDialog<0x%x>::OfferInformation: EasyWLAN, iap %d", |
|
513 iIapSelection.Session()->ConnectionId(), |
|
514 aWlanIapId ) |
|
515 |
|
516 iWlanIapId = aWlanIapId; |
|
517 iOverrideStatus = aDialogStatus; |
|
518 } |
|
519 if ( aOfflineStatus != EOfflineResponseUndefined ) |
|
520 { |
|
521 MPMLOGSTRING3( "CMPMWlanQueryDialog<0x%x>::OfferInformation: offline response %d", |
|
522 iIapSelection.Session()->ConnectionId(), |
|
523 aOfflineStatus ) |
|
524 iIapSelection.SetOfflineNoteResponse( aOfflineStatus ); |
|
525 iOverrideStatus = aDialogStatus; |
|
526 } |
|
527 |
|
528 #ifdef _LOG |
|
529 else |
|
530 { |
|
531 MPMLOGSTRING( "CMPMWlanQueryDialog::OfferInformation, information not taken." ) |
|
532 } |
|
533 #endif |
|
534 } |
|
535 |
|
536 |
|
537 // ----------------------------------------------------------------------------- |
|
538 // CMPMWlanQueryDialog::StoreEasyWlanSelectionL |
|
539 // ----------------------------------------------------------------------------- |
|
540 // |
|
541 void CMPMWlanQueryDialog::StoreEasyWlanSelectionL() |
|
542 { |
|
543 if( iEasyWlanSelected ) |
|
544 { |
|
545 TWlanSsid ssid; |
|
546 TWepKeyData wepData; |
|
547 TUint wpaPskEnabled( 0 ); |
|
548 TUint wpaPskLen( 0 ); |
|
549 TBuf8<KWLMMaxWpaPskLength> wpa; |
|
550 TUint secMode( 0 ); |
|
551 TWlanNetMode connMode( EInfra ); |
|
552 |
|
553 if( iWpsCompleted ) |
|
554 { |
|
555 GetEasyWlanDataForWpsL( ssid, |
|
556 secMode, |
|
557 connMode, |
|
558 wepData, |
|
559 wpaPskEnabled, |
|
560 wpa, |
|
561 wpaPskLen ); |
|
562 MPMLOGSTRING3( "CMPMWlanQueryDialog::StoreEasyWlanSelection: \ |
|
563 wps used, connection iap %d, ssid %S", iWlanIapId, &iWpsAttribute.iSsid ) |
|
564 iIapSelection.Session()->MyServer().Events()-> |
|
565 SetConnInfoIapSsid( iWlanIapId, |
|
566 iWpsAttribute.iSsid ); |
|
567 iIapSelection.Session()->MyServer().CommsDatAccess()->SetEasyWlanDataL( ssid, |
|
568 secMode, |
|
569 connMode, |
|
570 wepData, |
|
571 wpaPskEnabled, |
|
572 wpa, |
|
573 wpaPskLen ); |
|
574 return; |
|
575 } |
|
576 |
|
577 MPMLOGSTRING( "CMPMWlanQueryDialog::StoreEasyWlanSelection: setting easy wlan data" ) |
|
578 GetEasyWlanDataL( ssid, |
|
579 secMode, |
|
580 connMode, |
|
581 wepData, |
|
582 wpaPskEnabled, |
|
583 wpa, |
|
584 wpaPskLen ); |
|
585 |
|
586 MPMLOGSTRING3( "CMPMWlanQueryDialog::StoreEasyWlanSelection: \ |
|
587 setting easy wlan iap %d ssid %S in connmon events", iWlanIapId, &iNetworkPrefs().iSsId ) |
|
588 iIapSelection.Session()->MyServer().Events()->SetConnInfoIapSsid( iWlanIapId, |
|
589 iNetworkPrefs().iSsId ); |
|
590 iIapSelection.Session()->MyServer().CommsDatAccess()->SetEasyWlanDataL( ssid, |
|
591 secMode, |
|
592 connMode, |
|
593 wepData, |
|
594 wpaPskEnabled, |
|
595 wpa, |
|
596 wpaPskLen ); |
|
597 |
|
598 } |
|
599 else |
|
600 { |
|
601 MPMLOGSTRING( "CMPMWlanQueryDialog::StoreEasyWlanSelection: no easy wlan selected by user" ) |
|
602 } |
|
603 } |
|
604 |
|
605 |
|
606 // ----------------------------------------------------------------------------- |
|
607 // CMPMWlanQueryDialog::GetEasyWlanDataL |
|
608 // ----------------------------------------------------------------------------- |
|
609 // |
|
610 void CMPMWlanQueryDialog::GetEasyWlanDataL( TWlanSsid& aSsid, |
|
611 TUint& aSecMode, |
|
612 TWlanNetMode& aConnMode, |
|
613 TWepKeyData& aWepData, |
|
614 TUint& aEnableWpaPsk, |
|
615 TDes8& aWpaPsk, |
|
616 TUint& aWpaKeyLen ) |
|
617 { |
|
618 aSsid.Copy( iNetworkPrefs().iSsId ); |
|
619 if ( iNetworkPrefs().iNetworkMode == EWlanConnectionModeAdhoc ) |
|
620 { |
|
621 aConnMode = EAdhoc; |
|
622 } |
|
623 |
|
624 // Set security mode |
|
625 TInt err = ConnSecModeToCommsDatSecMode( iNetworkPrefs().iSecMode, |
|
626 aSecMode ); |
|
627 |
|
628 if( err != KErrNone ) |
|
629 { |
|
630 MPMLOGSTRING2( "CMPMWlanQueryDialog::StoreEasyWlanSelection: \ |
|
631 unsupported sec mode %d. leaving", iNetworkPrefs().iSecMode ) |
|
632 User::Leave( KErrNotSupported ); |
|
633 } |
|
634 |
|
635 if( iNetworkPrefs().iSecMode == EWlanConnectionSecurityWep ) |
|
636 { |
|
637 CnvUtfConverter::ConvertFromUnicodeToUtf8( aWepData.iWep1, iNotifWep().iKey ); |
|
638 //MPMLOG8STRING2( "CMPMWlanQueryDialog::StoreEasyWlanSelection:wep-key8:%S ", &aWepData.iWep1 ) |
|
639 if( iNotifWep().iHex ) |
|
640 { |
|
641 aWepData.iWepFormat1 = 1; |
|
642 MPMLOGSTRING( "CMPMWlanQueryDialog::StoreEasyWlanSelection: wep format is 1 (hex)") |
|
643 } |
|
644 aWepData.iDefaultWep = EWlanDefaultWepKey1; |
|
645 } |
|
646 else if( iNetworkPrefs().iSecMode == EWlanConnectionSecurityWpaPsk ) |
|
647 { |
|
648 CnvUtfConverter::ConvertFromUnicodeToUtf8( aWpaPsk, iNotifWpaKey() ); |
|
649 aEnableWpaPsk = 1; |
|
650 aWpaKeyLen = aWpaPsk.Length(); |
|
651 MPMLOGSTRING3( "CMPMWlanQueryDialog::StoreEasyWlanSelection:wpapsk-key:%s, len:%d", |
|
652 &iNotifWpaKey(), |
|
653 aWpaKeyLen ) |
|
654 } |
|
655 else |
|
656 { |
|
657 MPMLOGSTRING2( "CMPMWlanQueryDialog::StoreEasyWlanSelection: \ |
|
658 no key handling needed for sec mode %d", iNetworkPrefs().iSecMode ) |
|
659 } |
|
660 } |
|
661 |
|
662 // --------------------------------------------------------------------------- |
|
663 // CMPMWlanQueryDialog::ConnSecModeToCommsDatSecMode |
|
664 // --------------------------------------------------------------------------- |
|
665 // |
|
666 TInt CMPMWlanQueryDialog::ConnSecModeToCommsDatSecMode( TWlanConnectionSecurityMode aConnSecmode, |
|
667 TUint& aCommsdatSecMode ) const |
|
668 { |
|
669 |
|
670 if ( aConnSecmode == EWlanConnectionSecurityOpen ) |
|
671 { |
|
672 aCommsdatSecMode = EWlanSecModeOpen; |
|
673 } |
|
674 else if ( aConnSecmode == EWlanConnectionSecurityWep ) |
|
675 { |
|
676 aCommsdatSecMode = EWlanSecModeWep; |
|
677 } |
|
678 else if ( aConnSecmode == EWlanConnectionSecurityWpaPsk ) |
|
679 { |
|
680 aCommsdatSecMode = EWlanSecModeWpa2; |
|
681 } |
|
682 else if ( aConnSecmode == EWlanConnectionSecurityWpa ) |
|
683 { |
|
684 aCommsdatSecMode = EWlanSecModeWpa; |
|
685 } |
|
686 else |
|
687 { |
|
688 MPMLOGSTRING( "CMPMWlanQueryDialog::RunL, Unknown security mode" ) |
|
689 return KErrCouldNotConnect; |
|
690 } |
|
691 return KErrNone; |
|
692 } |
|
693 |
|
694 |
|
695 // --------------------------------------------------------------------------- |
|
696 // CMPMWlanQueryDialog::IapSecModeToCommsDatSecMode |
|
697 // --------------------------------------------------------------------------- |
|
698 // |
|
699 TInt CMPMWlanQueryDialog::IapSecModeToCommsDatSecMode( TWlanIapSecurityMode aIapSecmode, |
|
700 TUint& aCommsdatSecMode ) const |
|
701 { |
|
702 switch( aIapSecmode ) |
|
703 { |
|
704 case EWlanIapSecurityModeAllowUnsecure: |
|
705 aCommsdatSecMode |= EWlanSecModeOpen; |
|
706 break; |
|
707 case EWlanIapSecurityModeWep: |
|
708 aCommsdatSecMode |= EWlanSecModeWep; |
|
709 break; |
|
710 case EWlanIapSecurityModeWpa: |
|
711 aCommsdatSecMode |= EWlanSecModeWpa; |
|
712 break; |
|
713 case EWlanIapSecurityModeWpa2Only: |
|
714 aCommsdatSecMode |= EWlanSecModeWpa2; |
|
715 break; |
|
716 default: |
|
717 MPMLOGSTRING2( "CMPMWlanQueryDialog::IapSecModeToCommsDatSecMode: \ |
|
718 unsupported sec mode %d ", aIapSecmode ) |
|
719 return KErrNotSupported; |
|
720 } |
|
721 return KErrNone; |
|
722 } |
|
723 |
|
724 // ----------------------------------------------------------------------------- |
|
725 // CMPMWlanQueryDialog::GetEasyWlanDataForWpsL |
|
726 // ----------------------------------------------------------------------------- |
|
727 // |
|
728 void CMPMWlanQueryDialog::GetEasyWlanDataForWpsL( TWlanSsid& aSsid, |
|
729 TUint& aSecMode, |
|
730 TWlanNetMode& aConnMode, |
|
731 TWepKeyData& aWepKeyData, |
|
732 TUint& aEnableWpaPsk, |
|
733 TDes8& aWpaPsk, |
|
734 TUint& aWpaKeyLen ) |
|
735 { |
|
736 aSsid.Copy( iWpsAttribute.iSsid ); |
|
737 if ( iWpsAttribute.iOperatingMode == EWlanOperatingModeAdhoc ) |
|
738 { |
|
739 aConnMode = EAdhoc; |
|
740 } |
|
741 TInt err = IapSecModeToCommsDatSecMode( iWpsAttribute.iSecurityMode, |
|
742 aSecMode ); |
|
743 if( err != KErrNone ) |
|
744 { |
|
745 MPMLOGSTRING( "CMPMWlanQueryDialog::GetEasyWlanDataForWpsL: \ |
|
746 unsupported wps sec mode leaving" ) |
|
747 User::Leave( KErrNotSupported ); |
|
748 } |
|
749 |
|
750 if( iWpsAttribute.iSecurityMode == EWlanIapSecurityModeWep ) |
|
751 { |
|
752 if( iWpsAttribute.iWepKey1.Length() && |
|
753 IsWepFormatHexL( iWpsAttribute.iWepKey1.Length() ) ) |
|
754 { |
|
755 aWepKeyData.iWepFormat1 = 1; |
|
756 } |
|
757 if( iWpsAttribute.iWepKey2.Length() && |
|
758 IsWepFormatHexL( iWpsAttribute.iWepKey2.Length() ) ) |
|
759 { |
|
760 aWepKeyData.iWepFormat2 = 1; |
|
761 } |
|
762 if( iWpsAttribute.iWepKey3.Length() && |
|
763 IsWepFormatHexL( iWpsAttribute.iWepKey3.Length() ) ) |
|
764 { |
|
765 aWepKeyData.iWepFormat3 = 1; |
|
766 } |
|
767 if( iWpsAttribute.iWepKey4.Length() && |
|
768 IsWepFormatHexL( iWpsAttribute.iWepKey4.Length() ) ) |
|
769 { |
|
770 aWepKeyData.iWepFormat4 = 1; |
|
771 } |
|
772 aWepKeyData.iWep1.Copy( iWpsAttribute.iWepKey1 ); |
|
773 aWepKeyData.iWep2.Copy( iWpsAttribute.iWepKey2 ); |
|
774 aWepKeyData.iWep3.Copy( iWpsAttribute.iWepKey3 ); |
|
775 aWepKeyData.iWep4.Copy( iWpsAttribute.iWepKey4 ); |
|
776 aWepKeyData.iDefaultWep = iWpsAttribute.iWepDefaultKey; |
|
777 } |
|
778 if( iWpsAttribute.iWpaPreSharedKey.Length() ) |
|
779 { |
|
780 aEnableWpaPsk = 1; |
|
781 aWpaPsk.Copy( iWpsAttribute.iWpaPreSharedKey ); |
|
782 aWpaKeyLen = aWpaPsk.Length(); |
|
783 } |
|
784 |
|
785 } |
|
786 |
|
787 // --------------------------------------------------------------------------- |
|
788 // CMPMWlanQueryDialog::StartWpsDlgL |
|
789 // --------------------------------------------------------------------------- |
|
790 // |
|
791 void CMPMWlanQueryDialog::StartWpsDlgL() |
|
792 { |
|
793 MPMLOGSTRING( "CMPMWlanQueryDialog::StartWpsDlgL, Starting WPS" ) |
|
794 iWlanQueryState = EWPS; |
|
795 iWps = CWiFiProtUiClient::NewL(); |
|
796 iWps->StartWiFiProtConnL( iNetworkPrefs().iSsId, // TWlanSsid&, |
|
797 iWpsAttribute, |
|
798 iWpsReturn, |
|
799 iStatus ); |
|
800 SetActive(); |
|
801 } |
|
802 |
|
803 // --------------------------------------------------------------------------- |
|
804 // CMPMWlanQueryDialog::IsWepFormatHexL |
|
805 // --------------------------------------------------------------------------- |
|
806 // |
|
807 TBool CMPMWlanQueryDialog::IsWepFormatHexL( TInt aLength ) const |
|
808 { |
|
809 MPMLOGSTRING2( "CMPMWlanQueryDialog::IsWepFormatHexL length %d", aLength ) |
|
810 |
|
811 if ( ( aLength == KConnUiUtilsWepLengthASCII5 ) || |
|
812 ( aLength == KConnUiUtilsWepLengthASCII13 ) || |
|
813 ( aLength == KConnUiUtilsWepLengthASCII29 ) ) |
|
814 { |
|
815 return EFalse; |
|
816 } |
|
817 else if ( ( aLength == KConnUiUtilsWepLengthHEX10 ) || |
|
818 ( aLength == KConnUiUtilsWepLengthHEX26 ) || |
|
819 ( aLength == KConnUiUtilsWepLengthHEX58 ) ) |
|
820 { |
|
821 return ETrue; |
|
822 } |
|
823 else |
|
824 { |
|
825 User::Leave( KErrNotSupported ); |
|
826 } |
|
827 return EFalse; |
|
828 } |
|
829 |
|
830 // --------------------------------------------------------------------------- |
|
831 // CMPMWlanQueryDialog::GetNetworkPrefs |
|
832 // --------------------------------------------------------------------------- |
|
833 // |
|
834 void CMPMWlanQueryDialog::GetNetworkPrefs() |
|
835 { |
|
836 iWlanQueryState = EWlanNetwork; |
|
837 iConnUiUtils->SearchWLANNetworkAsync( iStatus, |
|
838 iNetworkPrefs().iSsId, |
|
839 iNetworkPrefs().iNetworkMode, |
|
840 iNetworkPrefs().iSecMode, |
|
841 iNetworkPrefs().iProtectedSetupSupported |
|
842 ); |
|
843 SetActive(); |
|
844 } |
|
845 |