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