1 /* |
|
2 * Copyright (c) 2007-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: Implementation of TWsfMainController. |
|
15 * |
|
16 */ |
|
17 |
|
18 // EXTERNAL INCLUDES |
|
19 #include <e32def.h> |
|
20 #include <wlansniffer.rsg> |
|
21 #include <utf.h> |
|
22 #include <apgcli.h> |
|
23 #include <AknQueryDialog.h> |
|
24 #include <StringLoader.h> |
|
25 |
|
26 #include <cmmanagerext.h> |
|
27 |
|
28 // CLASS HEADER |
|
29 #include "wsfmaincontroller.h" |
|
30 |
|
31 // INTERNAL INCLUDES |
|
32 #include "wsfmodel.h" |
|
33 #include "wsfwlaninfo.h" |
|
34 #include "wsfwlaninfoarray.h" |
|
35 #include "wsfappui.h" |
|
36 #include "wsfmainviewcontrollerif.h" |
|
37 #include "wsfdetailsviewcontrollerif.h" |
|
38 #include "wsfmainapplication.hrh" |
|
39 #include "wsfwlaninfoarrayvisitor.h" |
|
40 |
|
41 #include "wsflogger.h" |
|
42 |
|
43 // LOCAL DEFINITIONS |
|
44 #ifdef _DEBUG |
|
45 _LIT( KMainControllerPanic, "TWsfMainController" ); |
|
46 #define _ASSERTD( cond ) __ASSERT_DEBUG( (cond), \ |
|
47 User::Panic( KMainControllerPanic, __LINE__) ) |
|
48 #else |
|
49 #define _ASSERTD( cond ) {} |
|
50 #endif //_DEBUG |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // TWsfMainController::Initialize |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 void TWsfMainController::Initialize( |
|
57 CWsfAppUi& aAppUi, |
|
58 CWsfModel& aModel, |
|
59 CWsfWlanInfoArrayVisitor &aWlanInfoBranding ) |
|
60 { |
|
61 iAppUi = &aAppUi; |
|
62 iModel = &aModel; |
|
63 iWlanInfoBranding = &aWlanInfoBranding; |
|
64 iModel->SetConnecting( EFalse ); |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // TWsfMainController::UpdateViewL |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 void TWsfMainController::UpdateViewL() |
|
72 { |
|
73 LOG_ENTERFN( "TWsfMainController::UpdateViewL" ); |
|
74 CWsfWlanInfoArray* array = iModel->GetWlanListL(); |
|
75 array->SortArrayL( *iWlanInfoBranding ); |
|
76 |
|
77 LOG_WRITEF( "ActiveViewL: %x", iModel->ActiveViewL().iUid ); |
|
78 switch ( iModel->ActiveViewL().iUid ) |
|
79 { |
|
80 case EMainViewId: |
|
81 { |
|
82 _ASSERTD( iMainView ); |
|
83 iMainView->UpdateWlanListL( array ); |
|
84 break; |
|
85 } |
|
86 |
|
87 case EDetailsViewId: |
|
88 { |
|
89 _ASSERTD( iDetailsView ); |
|
90 iMainView->UpdateWlanListInBackgroundL( array ); |
|
91 iDetailsView->WlanListChangedL( array ); |
|
92 break; |
|
93 } |
|
94 case EConnectedDetailsViewId: |
|
95 { |
|
96 iMainView->UpdateWlanListL( array ); |
|
97 iAppUi->UpdateConnectedDetailsL( array ); |
|
98 break; |
|
99 } |
|
100 default: |
|
101 { |
|
102 // Invalid view ID, make panic. |
|
103 _ASSERTD( 0 ); |
|
104 break; |
|
105 } |
|
106 } |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // TWsfMainController::UpdateViewL |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 void TWsfMainController::UpdateViewL( CWsfWlanInfoArray* aInfoArray ) |
|
114 { |
|
115 LOG_ENTERFN( "TWsfMainController::UpdateViewL( aInfoArray ) " ); |
|
116 LOG_WRITEF( "ActiveViewL: %x", iModel->ActiveViewL().iUid ); |
|
117 switch ( iModel->ActiveViewL().iUid ) |
|
118 { |
|
119 case EMainViewId: |
|
120 { |
|
121 iMainView->UpdateWlanListL( aInfoArray ); |
|
122 break; |
|
123 } |
|
124 |
|
125 case EDetailsViewId: |
|
126 { |
|
127 iDetailsView->WlanListChangedL( aInfoArray ); |
|
128 break; |
|
129 } |
|
130 case EConnectedDetailsViewId: |
|
131 { |
|
132 iMainView->UpdateWlanListL( aInfoArray ); |
|
133 iAppUi->UpdateConnectedDetailsL( aInfoArray ); |
|
134 break; |
|
135 } |
|
136 default: |
|
137 { |
|
138 // Invalid view ID, make panic. |
|
139 _ASSERTD( 0 ); |
|
140 break; |
|
141 } |
|
142 } |
|
143 } |
|
144 |
|
145 // Events from AppUi |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // TWsfMainController::ShowWlanListL |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 void TWsfMainController::ShowWlanListL() |
|
152 { |
|
153 LOG_ENTERFN( "TWsfMainController::ShowWlanListL" ); |
|
154 _ASSERTD( iAppUi ); |
|
155 _ASSERTD( iModel ); |
|
156 |
|
157 iModel->SetActiveViewL( EMainViewId ); |
|
158 iAppUi->ActivateMainViewL(); |
|
159 } |
|
160 |
|
161 // --------------------------------------------------------------------------- |
|
162 // TWsfMainController::ShowDetailsL |
|
163 // --------------------------------------------------------------------------- |
|
164 // |
|
165 void TWsfMainController::ShowDetailsL() |
|
166 { |
|
167 LOG_ENTERFN( "TWsfMainController::ShowDetailsL" ); |
|
168 _ASSERTD( iAppUi ); |
|
169 _ASSERTD( iModel ); |
|
170 _ASSERTD( iModel->ActiveViewL().iUid != EDetailsViewId ); |
|
171 |
|
172 TWsfWlanInfo* selectedWlan = iMainView->SelectedItem(); |
|
173 |
|
174 if ( selectedWlan ) |
|
175 { |
|
176 TBool connected = selectedWlan->Connected(); |
|
177 |
|
178 if( connected ) // Connected Details View - Replaced with dialog |
|
179 { |
|
180 // Work around - Emulated view |
|
181 iModel->SetActiveViewL( EConnectedDetailsViewId ); |
|
182 // Holds selected wlan Ssid |
|
183 HBufC8* ssid = selectedWlan->GetSsidAsUtf8LC(); |
|
184 |
|
185 // Holds current wlan array |
|
186 if ( !iInfoArray ) |
|
187 { |
|
188 iInfoArray = iModel->GetWlanListL(); |
|
189 iInfoArray->SortArrayL( *iWlanInfoBranding ); |
|
190 } |
|
191 // Start and execute the Connected Details dialog |
|
192 // Set array and Ssid to detail view |
|
193 iAppUi->StartConnectedDetailsL( iInfoArray, *ssid ); |
|
194 CleanupStack::PopAndDestroy( ssid ); |
|
195 |
|
196 // After the dismissal of the Connected Details dialog, |
|
197 // change back to the main view |
|
198 ShowWlanListL(); |
|
199 } |
|
200 else |
|
201 { |
|
202 iDetailsView = &( iAppUi->DetailsView( EDetailsViewId ) ); |
|
203 iModel->SetActiveViewL( EDetailsViewId ); |
|
204 iDetailsView->SetPartner( *this ); |
|
205 |
|
206 // Holds selected wlan Ssid |
|
207 HBufC8* ssid = selectedWlan->GetSsidAsUtf8LC(); |
|
208 |
|
209 // Holds current wlan array |
|
210 if ( !iInfoArray ) |
|
211 { |
|
212 iInfoArray = iModel->GetWlanListL(); |
|
213 iInfoArray->SortArrayL( *iWlanInfoBranding ); |
|
214 } |
|
215 //Set array and Ssid to detail view |
|
216 iDetailsView->SetWlanListL( iInfoArray, *ssid ); |
|
217 |
|
218 CleanupStack::PopAndDestroy( ssid ); |
|
219 |
|
220 iAppUi->ActivateDetailsViewL( iModel->ActiveViewL() ); |
|
221 } |
|
222 } |
|
223 } |
|
224 |
|
225 // --------------------------------------------------------------------------- |
|
226 // TWsfMainController::MainViewCreatedL |
|
227 // --------------------------------------------------------------------------- |
|
228 // |
|
229 void TWsfMainController::MainViewCreatedL() |
|
230 { |
|
231 LOG_ENTERFN( "TWsfMainController::MainViewCreatedL" ); |
|
232 iMainView = &( iAppUi->MainView() ); |
|
233 iMainView->SetPartner( *this ); |
|
234 iModel->SetActiveViewL( EMainViewId ); |
|
235 |
|
236 if ( !iModel->Refreshing() ) |
|
237 { |
|
238 iModel->SetRefreshState( ETrue ); |
|
239 } |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // TWsfMainController::WlanListChangedL |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 void TWsfMainController::WlanListChangedL() |
|
247 { |
|
248 LOG_ENTERFN( "TWsfMainController::WlanListChangedL" ); |
|
249 |
|
250 if ( iModel->IsConnecting() ) |
|
251 { |
|
252 LOG_WRITE( "We are connecting just return from here" ); |
|
253 return; |
|
254 } |
|
255 |
|
256 if ( iModel->Refreshing() ) |
|
257 { |
|
258 // Make sure if leave occures that we don't block ourselves for retry |
|
259 CleanupStack::PushL( TCleanupItem( RestoreRefreshState, this ) ); |
|
260 iModel->SetRefreshState( EFalse ); |
|
261 if ( iAppUi ) |
|
262 { |
|
263 iAppUi->HideWaitNoteL(); |
|
264 iInfoArray = iModel->GetWlanListL(); |
|
265 if ( !iInfoArray->Count() ) |
|
266 { |
|
267 iAppUi->ShowNoWlansFoundInfoL(); |
|
268 } |
|
269 UpdateViewL(); |
|
270 } |
|
271 // pop cleanup item RestoreRefreshState |
|
272 CleanupStack::Pop(); |
|
273 } |
|
274 } |
|
275 |
|
276 // --------------------------------------------------------------------------- |
|
277 // TWsfMainController::NotifyEngineError |
|
278 // --------------------------------------------------------------------------- |
|
279 // |
|
280 void TWsfMainController::NotifyEngineError( TInt aError ) |
|
281 { |
|
282 LOG_ENTERFN( "TWsfMainController::NotifyEngineError" ); |
|
283 switch ( aError ) |
|
284 { |
|
285 case KErrServerTerminated: |
|
286 { |
|
287 break; |
|
288 } |
|
289 |
|
290 default: |
|
291 { |
|
292 TRAP_IGNORE( iAppUi->ShowGlobalErrorNoteL( aError ) ); |
|
293 } |
|
294 } |
|
295 } |
|
296 |
|
297 // --------------------------------------------------------------------------- |
|
298 // TWsfMainController::ScanDisabledL |
|
299 // --------------------------------------------------------------------------- |
|
300 // |
|
301 void TWsfMainController::ScanDisabledL() |
|
302 { |
|
303 // no implementation required |
|
304 } |
|
305 |
|
306 // --------------------------------------------------------------------------- |
|
307 // TWsfMainController::ScanEnabledL |
|
308 // --------------------------------------------------------------------------- |
|
309 // |
|
310 void TWsfMainController::ScanEnabledL() |
|
311 { |
|
312 // no implementation required |
|
313 } |
|
314 |
|
315 // --------------------------------------------------------------------------- |
|
316 // TWsfMainController::WlanConnectionActivatedL |
|
317 // --------------------------------------------------------------------------- |
|
318 // |
|
319 void TWsfMainController::WlanConnectionActivatedL() |
|
320 { |
|
321 LOG_ENTERFN( "TWsfMainController::WlanConnectionActivatedL" ); |
|
322 |
|
323 // update the model and refresh ui |
|
324 if ( iInfoArray ) |
|
325 { |
|
326 TBool found = EFalse; |
|
327 TWsfWlanInfo info; |
|
328 iModel->GetConnectedWlanDetailsL( info ); |
|
329 if ( info.iIapId ) |
|
330 { |
|
331 // find the entry for iapid |
|
332 // mark it connected - sort the array and refresh |
|
333 TWsfWlanInfo* temp = iInfoArray->Match( info.iIapId, |
|
334 iInfoArray->Count() ); |
|
335 if ( temp ) |
|
336 { |
|
337 found = ETrue; |
|
338 temp->iConnectionState = EConnected; |
|
339 iInfoArray->SortArrayL(); |
|
340 UpdateViewL( iInfoArray ); |
|
341 } |
|
342 } |
|
343 |
|
344 if ( !found ) |
|
345 { |
|
346 // find the entry |
|
347 // mark it connected - sort the array and refresh |
|
348 TWsfWlanInfo* temp = iInfoArray->Match( info.iSsid, |
|
349 iInfoArray->Count() ); |
|
350 if ( temp ) |
|
351 { |
|
352 temp->iConnectionState = EConnected; |
|
353 temp->iIapId = info.iIapId; |
|
354 iInfoArray->SortArrayL(); |
|
355 UpdateViewL( iInfoArray ); |
|
356 } |
|
357 } |
|
358 } |
|
359 |
|
360 //Update icon |
|
361 iModel->RefreshScanL(); |
|
362 } |
|
363 |
|
364 // --------------------------------------------------------------------------- |
|
365 // TWsfMainController::WlanConnectionClosedL |
|
366 // --------------------------------------------------------------------------- |
|
367 // |
|
368 void TWsfMainController::WlanConnectionClosedL() |
|
369 { |
|
370 LOG_ENTERFN( "TWsfMainController::WlanConnectionClosedL" ); |
|
371 // update the model and refresh ui |
|
372 if ( iInfoArray ) |
|
373 { |
|
374 // check if the array has any items |
|
375 if ( iInfoArray->Count() ) |
|
376 { |
|
377 TWsfWlanInfo* firstItem = iInfoArray->At( 0 ); |
|
378 if ( firstItem && ( firstItem->Connected() || |
|
379 firstItem->iConnectionState == EConnecting ) ) |
|
380 { |
|
381 LOG_WRITEF( "info state = %d", firstItem->iConnectionState ); |
|
382 firstItem->iConnectionState = ENotConnected; |
|
383 TRAPD( error, iModel->CheckIsIapIdValidL( firstItem->iIapId ) ); |
|
384 if ( error ) |
|
385 { |
|
386 LOG_WRITEF( "Iap Id is not valid - error=%d", error ); |
|
387 if ( firstItem->iRawSsid.Length() ) |
|
388 { |
|
389 firstItem->iSsid.Copy( firstItem->iRawSsid ); |
|
390 } |
|
391 firstItem->iIapId = 0; |
|
392 } |
|
393 iInfoArray->SortArrayL(); |
|
394 UpdateViewL( iInfoArray ); |
|
395 } |
|
396 } |
|
397 } |
|
398 |
|
399 // Abort current scan if exists so that we get |
|
400 // newest scan results propagated to ui |
|
401 iModel->AbortScanningL(); |
|
402 iModel->RefreshScanL(); |
|
403 } |
|
404 |
|
405 // --------------------------------------------------------------------------- |
|
406 // TWsfMainController::ConnectingFinishedL |
|
407 // --------------------------------------------------------------------------- |
|
408 // |
|
409 void TWsfMainController::ConnectionCreationProcessFinishedL( TInt /*aResult*/ ) |
|
410 { |
|
411 // no implementation required |
|
412 } |
|
413 |
|
414 // --------------------------------------------------------------------------- |
|
415 // TWsfMainController::ShowMenuBarL |
|
416 // --------------------------------------------------------------------------- |
|
417 // |
|
418 void TWsfMainController::ShowMenuBarL() |
|
419 { |
|
420 LOG_ENTERFN( "TWsfMainController::ShowMenuBarL" ); |
|
421 iAppUi->ShowMenuBarL(); |
|
422 } |
|
423 |
|
424 // --------------------------- Events from the details view ------------------ |
|
425 |
|
426 // --------------------------------------------------------------------------- |
|
427 // TWsfMainController::CloseDetailsViewL |
|
428 // --------------------------------------------------------------------------- |
|
429 // |
|
430 void TWsfMainController::CloseDetailsViewL() |
|
431 { |
|
432 LOG_ENTERFN( "TWsfMainController::CloseDetailsViewL" ); |
|
433 ShowWlanListL(); |
|
434 // After the Details View closed the mainview's |
|
435 // WlanList will be refreshed. |
|
436 iModel->RefreshScanL(); |
|
437 } |
|
438 |
|
439 // ------------------------------- Menu press handler ------------------------ |
|
440 |
|
441 |
|
442 // ---------------------------------------------------------------------------- |
|
443 // TWsfMainController::StartBrowsingL |
|
444 // ---------------------------------------------------------------------------- |
|
445 // |
|
446 void TWsfMainController::StartBrowsingL() |
|
447 { |
|
448 LOG_ENTERFN( "TWsfMainController::StartBrowsingL" ); |
|
449 if ( iAppUi->SuppressingKeyEvents() || iModel->IsConnectedL() && |
|
450 ( !iMainView->SelectedItem() || |
|
451 !iMainView->SelectedItem()->Connected() ) ) |
|
452 { |
|
453 iAppUi->ShowErrorNoteL( R_QTN_WLAN_INFO_CONNECTION_ALREADY_ACTIVE ); |
|
454 return; |
|
455 } |
|
456 |
|
457 // make sure we don't suppress our key events forever |
|
458 CleanupStack::PushL( TCleanupItem( ReleaseSuppressingKeyEvents, this ) ); |
|
459 iAppUi->SetSuppressingKeyEvents( ETrue ); |
|
460 |
|
461 TWsfWlanInfo* selectedItem = iMainView->SelectedItem(); |
|
462 TWsfWlanInfo info; |
|
463 |
|
464 if ( selectedItem ) |
|
465 { |
|
466 info = *selectedItem; |
|
467 } |
|
468 |
|
469 // Prevent connections to ad-hoc + WPA |
|
470 if ( info.iNetMode == CMManager::EAdhoc |
|
471 && info.iSecurityMode == CMManager::EWlanSecModeWpa ) |
|
472 { |
|
473 iAppUi->ShowGlobalErrorNoteL( KErrNotSupported ); |
|
474 CleanupStack::PopAndDestroy(); |
|
475 return; |
|
476 } |
|
477 |
|
478 TInt result( KErrNone ); |
|
479 |
|
480 TWsfIapPersistence persistence = EIapPersistent; |
|
481 |
|
482 if ( !info.Known() && !info.Connected() ) |
|
483 { |
|
484 // if not known yet, create an IAP |
|
485 if ( iModel->CreateAccessPointL( info, EFalse ) ) |
|
486 { |
|
487 persistence = EIapExpireOnDisconnect; |
|
488 // update iapID to list |
|
489 UpdateIapIdToInfoArrayL( info ); |
|
490 } |
|
491 else |
|
492 { |
|
493 result = KErrGeneral; |
|
494 } |
|
495 } |
|
496 |
|
497 if ( info.iIapId && !info.Connected() ) |
|
498 { |
|
499 // hopefully we have a valid IAP id inside |
|
500 result = iModel->ConnectL( info.iIapId, EFalse, persistence ); |
|
501 } |
|
502 else if ( !info.Connected() ) |
|
503 { |
|
504 result = KErrGeneral; |
|
505 } |
|
506 |
|
507 // pop cleanup item ReleaseSuppressingKeyEvents |
|
508 CleanupStack::Pop(); |
|
509 iAppUi->SetSuppressingKeyEvents( EFalse ); |
|
510 |
|
511 if ( !result ) |
|
512 { |
|
513 TUint32 passedIap( info.iIapId ); |
|
514 |
|
515 if ( info.Connected() && !passedIap ) |
|
516 { |
|
517 // in case we have an EasyWLAN here |
|
518 RCmManagerExt cmmanager; |
|
519 cmmanager.OpenLC(); |
|
520 |
|
521 passedIap = cmmanager.EasyWlanIdL(); |
|
522 |
|
523 CleanupStack::PopAndDestroy( &cmmanager ); |
|
524 } |
|
525 |
|
526 // launch the browser |
|
527 iModel->LaunchBrowserL( passedIap ); |
|
528 } |
|
529 else if ( result == KErrCancel ) |
|
530 { |
|
531 // connection creation was cancelled, refresh the view |
|
532 iModel->RefreshScanL(); |
|
533 } |
|
534 |
|
535 } |
|
536 |
|
537 |
|
538 // ---------------------------------------------------------------------------- |
|
539 // TWsfMainController::ConnectL |
|
540 // ---------------------------------------------------------------------------- |
|
541 // |
|
542 void TWsfMainController::ConnectL() |
|
543 { |
|
544 LOG_ENTERFN( "TWsfMainController::ConnectL" ); |
|
545 if ( iAppUi->SuppressingKeyEvents() || iModel->IsConnectedL() ) |
|
546 { |
|
547 iAppUi->ShowErrorNoteL( R_QTN_WLAN_INFO_CONNECTION_ALREADY_ACTIVE ); |
|
548 return; |
|
549 } |
|
550 |
|
551 // make sure we don't suppress our key events forever |
|
552 CleanupStack::PushL( TCleanupItem( ReleaseSuppressingKeyEvents, this ) ); |
|
553 iAppUi->SetSuppressingKeyEvents( ETrue ); |
|
554 |
|
555 TWsfWlanInfo* selectedItem = iMainView->SelectedItem(); |
|
556 TWsfWlanInfo info; |
|
557 |
|
558 if ( selectedItem ) |
|
559 { |
|
560 info = *selectedItem; |
|
561 } |
|
562 |
|
563 // Prevent connections to ad-hoc + WPA |
|
564 if ( info.iNetMode == CMManager::EAdhoc |
|
565 && info.iSecurityMode == CMManager::EWlanSecModeWpa ) |
|
566 { |
|
567 iAppUi->ShowGlobalErrorNoteL( KErrNotSupported ); |
|
568 CleanupStack::PopAndDestroy(); |
|
569 return; |
|
570 } |
|
571 |
|
572 TWsfIapPersistence persistence = EIapPersistent; |
|
573 |
|
574 if ( !info.Known() ) |
|
575 { |
|
576 // a new access point needs to be created |
|
577 if ( iModel->CreateAccessPointL( info, EFalse ) ) |
|
578 { |
|
579 persistence = EIapExpireOnDisconnect; |
|
580 // update iapID to list |
|
581 UpdateIapIdToInfoArrayL( info ); |
|
582 } |
|
583 } |
|
584 |
|
585 if ( info.iIapId ) |
|
586 { |
|
587 // hopefully we have a valid IAP id inside |
|
588 iModel->ConnectL( info.iIapId, ETrue, persistence ); |
|
589 } |
|
590 |
|
591 // pop cleanup item ReleaseSuppressingKeyEvents |
|
592 CleanupStack::Pop(); |
|
593 iAppUi->SetSuppressingKeyEvents( EFalse ); |
|
594 |
|
595 } |
|
596 |
|
597 // --------------------------------------------------------------------------- |
|
598 // TWsfMainController::UpdateIapIdToInfoArrayL |
|
599 // --------------------------------------------------------------------------- |
|
600 // |
|
601 void TWsfMainController::UpdateIapIdToInfoArrayL( TWsfWlanInfo& aInfo ) |
|
602 { |
|
603 LOG_ENTERFN( "TWsfMainController::UpdateIapIdToInfoArrayL" ); |
|
604 TWsfWlanInfo* temp = iInfoArray->Match( aInfo.iSsid, iInfoArray->Count() ); |
|
605 if ( temp && !aInfo.Hidden() ) |
|
606 { |
|
607 LOG_WRITE( "Info found" ); |
|
608 |
|
609 // Check that there aren't any IAPs with same id |
|
610 TWsfWlanInfo* wlanInfoWithSameIapId = iInfoArray->Match( aInfo.iIapId, |
|
611 iInfoArray->Count() ); |
|
612 if ( wlanInfoWithSameIapId ) |
|
613 { |
|
614 // info with same id found set its iap id to zero |
|
615 LOG_WRITE( "info with same id found" ); |
|
616 wlanInfoWithSameIapId->iIapId = 0; |
|
617 } |
|
618 |
|
619 temp->iIapId = aInfo.iIapId; |
|
620 |
|
621 if ( aInfo.iNetworkName.Length() ) |
|
622 { |
|
623 // Replace ssid as well since scanner does this same thing |
|
624 temp->iSsid.Copy( aInfo.iNetworkName ); |
|
625 } |
|
626 } |
|
627 else |
|
628 { |
|
629 LOG_WRITE( "Info not found" ); |
|
630 TWsfWlanInfo* createdInfo = new (ELeave) TWsfWlanInfo( aInfo ); |
|
631 createdInfo->iVisibility = ETrue; |
|
632 createdInfo->iStrengthLevel = EWlanSignalStrengthMax; |
|
633 iInfoArray->AppendL( createdInfo ); |
|
634 } |
|
635 } |
|
636 |
|
637 // --------------------------------------------------------------------------- |
|
638 // TWsfMainController::DisconnectL |
|
639 // --------------------------------------------------------------------------- |
|
640 // |
|
641 void TWsfMainController::DisconnectL() |
|
642 { |
|
643 LOG_ENTERFN( "TWsfMainController::DisconnectL" ); |
|
644 if ( iModel->IsConnecting() ) |
|
645 { |
|
646 LOG_WRITE( "Abort connecting" ); |
|
647 iModel->AbortConnectingL(); |
|
648 } |
|
649 else |
|
650 { |
|
651 LOG_WRITE( "Disconnect" ); |
|
652 iModel->DisconnectL(); |
|
653 } |
|
654 } |
|
655 |
|
656 // --------------------------------------------------------------------------- |
|
657 // TWsfMainController::RefreshL |
|
658 // --------------------------------------------------------------------------- |
|
659 // |
|
660 void TWsfMainController::RefreshL() |
|
661 { |
|
662 LOG_ENTERFN( "TWsfMainController::RefreshL" ); |
|
663 TBool refreshing = iModel->RefreshScanL(); |
|
664 if ( refreshing ) |
|
665 { |
|
666 iAppUi->StartWaitNoteL( ETrue ); |
|
667 } |
|
668 } |
|
669 |
|
670 // --------------------------------------------------------------------------- |
|
671 // TWsfMainController::ContinueBrowsingL |
|
672 // --------------------------------------------------------------------------- |
|
673 // |
|
674 void TWsfMainController::ContinueBrowsingL() |
|
675 { |
|
676 LOG_ENTERFN( "TWsfMainController::ContinueBrowsingL" ); |
|
677 // pass selected WLAN info to engine |
|
678 TWsfWlanInfo *selectedItem = iMainView->SelectedItem(); |
|
679 |
|
680 if ( selectedItem ) |
|
681 { |
|
682 // Prevent connections to ad-hoc + WPA |
|
683 if ( selectedItem->iNetMode == CMManager::EAdhoc |
|
684 && selectedItem->iSecurityMode == CMManager::EWlanSecModeWpa ) |
|
685 { |
|
686 iAppUi->ShowGlobalErrorNoteL( KErrNotSupported ); |
|
687 return; |
|
688 } |
|
689 |
|
690 TUint iapId = selectedItem->iIapId; |
|
691 iModel->ContinueBrowsingL( iapId ); |
|
692 } |
|
693 } |
|
694 |
|
695 // --------------------------------------------------------------------------- |
|
696 // TWsfMainController::EngineRefreshing |
|
697 // --------------------------------------------------------------------------- |
|
698 // |
|
699 TBool TWsfMainController::EngineRefreshing() |
|
700 { |
|
701 LOG_ENTERFN( "TWsfMainController::EngineRefreshing" ); |
|
702 _ASSERTD( iModel ); |
|
703 return iModel->Refreshing(); |
|
704 } |
|
705 |
|
706 // --------------------------------------------------------------------------- |
|
707 // TWsfMainController::AppLaunchCompleteL |
|
708 // --------------------------------------------------------------------------- |
|
709 // |
|
710 void TWsfMainController::AppLaunchCompleteL() |
|
711 { |
|
712 LOG_ENTERFN( "TWsfMainController::AppLaunchCompleteL" ); |
|
713 iAppUi->StartWaitNoteL( EFalse ); |
|
714 iModel->EnableScanL(); |
|
715 } |
|
716 |
|
717 // --------------------------------------------------------------------------- |
|
718 // TWsfMainController::AppSwitchedForegroundL |
|
719 // --------------------------------------------------------------------------- |
|
720 // |
|
721 void TWsfMainController::AppSwitchedForegroundL() |
|
722 { |
|
723 LOG_ENTERFN( "TWsfMainController::AppSwitchedForegroundL" ); |
|
724 |
|
725 //turn on scanning for our point of view |
|
726 iModel->EnableScanL(); |
|
727 |
|
728 if ( !iModel->IsConnecting() ) |
|
729 { |
|
730 LOG_WRITE( "Scan now" ); |
|
731 TBool scan = iModel->RefreshScanL(); |
|
732 if( !scan ) |
|
733 { |
|
734 LOG_WRITE( "Set refresh state to true" ); |
|
735 //if the refresh call was called when the server was |
|
736 //actually making a scan then the refresh state of the |
|
737 //model is turned to false, but in this case the scanning |
|
738 //wait note will stuck on the screen, That's why the |
|
739 //refresh state must be turned to true |
|
740 iModel->SetRefreshState( ETrue ); |
|
741 } |
|
742 } |
|
743 } |
|
744 |
|
745 // --------------------------------------------------------------------------- |
|
746 // TWsfMainController::AppSwitchedBackgroundL |
|
747 // --------------------------------------------------------------------------- |
|
748 // |
|
749 void TWsfMainController::AppSwitchedBackgroundL() |
|
750 { |
|
751 LOG_ENTERFN( "TWsfMainController::AppSwitchedBackgroundL" ); |
|
752 iModel->DisableScanL(); |
|
753 } |
|
754 |
|
755 |
|
756 // --------------------------------------------------------------------------- |
|
757 // TWsfMainController::BrowserLaunchCompleteL |
|
758 // --------------------------------------------------------------------------- |
|
759 // |
|
760 void TWsfMainController::BrowserLaunchCompleteL() |
|
761 { |
|
762 LOG_ENTERFN( "TWsfMainController::BrowserLaunchCompleteL" ); |
|
763 // no implementation required |
|
764 } |
|
765 |
|
766 |
|
767 // --------------------------------------------------------------------------- |
|
768 // TWsfMainController::BrowserExitL |
|
769 // --------------------------------------------------------------------------- |
|
770 // |
|
771 void TWsfMainController::BrowserExitL() |
|
772 { |
|
773 LOG_ENTERFN( "TWsfMainController::BrowserExitL" ); |
|
774 iModel->AbortScanningL(); |
|
775 iModel->RefreshScanL(); |
|
776 } |
|
777 |
|
778 |
|
779 // --------------------------------------------------------------------------- |
|
780 // TWsfMainController::BrowserLaunchFailed |
|
781 // --------------------------------------------------------------------------- |
|
782 // |
|
783 void TWsfMainController::BrowserLaunchFailed( TInt aError ) |
|
784 { |
|
785 LOG_ENTERFN( "TWsfMainController::BrowserLaunchFailed" ); |
|
786 LOG_WRITEF( "error = %d", aError ); |
|
787 switch ( aError ) |
|
788 { |
|
789 case KErrCancel: |
|
790 { |
|
791 // user pressed cancel to connection creation |
|
792 break; |
|
793 } |
|
794 |
|
795 default: |
|
796 { |
|
797 break; |
|
798 } |
|
799 } |
|
800 } |
|
801 |
|
802 // --------------------------------------------------------------------------- |
|
803 // TWsfMainController::ConnectingL |
|
804 // --------------------------------------------------------------------------- |
|
805 // |
|
806 void TWsfMainController::ConnectingL( TUint32 aIapId ) |
|
807 { |
|
808 LOG_ENTERFN( "TWsfMainController::ConnectingL" ); |
|
809 iModel->SetConnecting( ETrue ); |
|
810 |
|
811 // update the model and refresh ui |
|
812 if ( iInfoArray ) |
|
813 { |
|
814 LOG_WRITEF( "Match array with iapID = %d", aIapId ); |
|
815 // find the entry for aIapId |
|
816 // mark it connecting - sort the array and refresh |
|
817 TWsfWlanInfo* temp = iInfoArray->Match( aIapId, iInfoArray->Count() ); |
|
818 if ( temp ) |
|
819 { |
|
820 LOG_WRITEF( "Info found iapID = %d", aIapId ); |
|
821 temp->iConnectionState = EConnecting; |
|
822 iInfoArray->SortArrayL(); |
|
823 UpdateViewL( iInfoArray ); |
|
824 } |
|
825 } |
|
826 } |
|
827 |
|
828 |
|
829 // --------------------------------------------------------------------------- |
|
830 // TWsfMainController::ConnectingFinishedL |
|
831 // --------------------------------------------------------------------------- |
|
832 // |
|
833 void TWsfMainController::ConnectingFinishedL( TInt aResult ) |
|
834 { |
|
835 LOG_ENTERFN( "TWsfMainController::ConnectingFinishedL" ); |
|
836 if ( iModel->IsConnecting() ) |
|
837 { |
|
838 iModel->SetConnecting( EFalse ); |
|
839 iModel->SetRefreshState( ETrue ); |
|
840 iAppUi->HideWaitNoteL(); |
|
841 } |
|
842 |
|
843 if ( aResult != KErrNone && aResult != KErrCancel ) |
|
844 { |
|
845 LOG_WRITEF( "Connection failed with error=%d", aResult ); |
|
846 if ( iInfoArray && iInfoArray->Count() && |
|
847 iInfoArray->At(0)->iConnectionState == EConnecting ) |
|
848 { |
|
849 iInfoArray->At(0)->iConnectionState = ENotConnected; |
|
850 TRAPD( error, iModel->CheckIsIapIdValidL( |
|
851 iInfoArray->At(0)->iIapId ) ); |
|
852 if ( error ) |
|
853 { |
|
854 LOG_WRITEF( "Iap Id %d is not valid - error=%d", |
|
855 iInfoArray->At(0)->iIapId, error ); |
|
856 |
|
857 if ( iInfoArray->At(0)->iRawSsid.Length() ) |
|
858 { |
|
859 iInfoArray->At(0)->iSsid.Copy( |
|
860 iInfoArray->At(0)->iRawSsid ); |
|
861 } |
|
862 |
|
863 iInfoArray->At(0)->iIapId = 0; |
|
864 } |
|
865 iInfoArray->SortArrayL(); |
|
866 UpdateViewL( iInfoArray ); |
|
867 iModel->AbortScanningL(); |
|
868 iModel->RefreshScanL(); |
|
869 } |
|
870 } |
|
871 } |
|
872 |
|
873 |
|
874 // --------------------------------------------------------------------------- |
|
875 // TWsfMainController::EditBlackListItemsL |
|
876 // --------------------------------------------------------------------------- |
|
877 // |
|
878 void TWsfMainController::EditBlackListItemsL() |
|
879 { |
|
880 LOG_ENTERFN( "TWsfMainController::EditBlackListItemsL" ); |
|
881 _ASSERTD( iWlanInfoBranding ); |
|
882 iWlanInfoBranding->EditBlackListL( *iInfoArray ); |
|
883 iModel->RefreshScanL(); |
|
884 } |
|
885 |
|
886 // --------------------------------------------------------------------------- |
|
887 // TWsfMainController::DetailsScanL |
|
888 // --------------------------------------------------------------------------- |
|
889 // |
|
890 void TWsfMainController::DetailsScanL() |
|
891 { |
|
892 LOG_ENTERFN( "TWsfMainController::DetailsScanL" ); |
|
893 iModel->RefreshScanL(); |
|
894 } |
|
895 |
|
896 // --------------------------------------------------------------------------- |
|
897 // TWsfMainController::ReleaseSuppressingKeyEvents |
|
898 // --------------------------------------------------------------------------- |
|
899 // |
|
900 void TWsfMainController::ReleaseSuppressingKeyEvents( TAny* aPtr ) |
|
901 { |
|
902 TWsfMainController* self = |
|
903 static_cast<TWsfMainController*>( aPtr ); |
|
904 self->iAppUi->SetSuppressingKeyEvents( EFalse ); |
|
905 self->iModel->SetConnecting( EFalse ); |
|
906 TRAP_IGNORE( self->iModel->RefreshScanL() ); |
|
907 } |
|
908 |
|
909 // --------------------------------------------------------------------------- |
|
910 // TWsfMainController::RestoreRefreshState |
|
911 // --------------------------------------------------------------------------- |
|
912 // |
|
913 void TWsfMainController::RestoreRefreshState( TAny* aPtr ) |
|
914 { |
|
915 TWsfMainController* self = |
|
916 static_cast<TWsfMainController*>( aPtr ); |
|
917 LOG_WRITE( "Restore refresh state") |
|
918 self->iModel->SetRefreshState( ETrue ); |
|
919 } |
|
920 |
|
921 // End of file |
|