47 #include "wsfsearchwlansdialog.h" |
48 #include "wsfsearchwlansdialog.h" |
48 #include "wsfaicontrollercmds.h" |
49 #include "wsfaicontrollercmds.h" |
49 #include "wsfactivewaiter.h" |
50 #include "wsfactivewaiter.h" |
50 #include "wsflogger.h" |
51 #include "wsflogger.h" |
51 #include "wsfdbobserver.h" |
52 #include "wsfdbobserver.h" |
|
53 #include "wsfactivewrappers.h" |
52 |
54 |
53 |
55 |
54 // MACROS |
56 // MACROS |
55 #ifdef _DEBUG |
57 #ifdef _DEBUG |
56 _LIT( KControllerPanic, "CWsfAiController" ); |
58 _LIT( KControllerPanic, "CWsfAiController" ); |
96 // --------------------------------------------------------- |
98 // --------------------------------------------------------- |
97 // |
99 // |
98 void TWsfAiController::DeInitializeL() |
100 void TWsfAiController::DeInitializeL() |
99 { |
101 { |
100 LOG_ENTERFN( "TWsfAiController::DeInitializeL" ); |
102 LOG_ENTERFN( "TWsfAiController::DeInitializeL" ); |
101 iModel->AbortConnectingL(); |
|
102 iModel->AbortScanningL(); |
|
103 } |
103 } |
104 |
104 |
105 |
105 |
106 // -------------------------------------------------------------------------- |
106 // -------------------------------------------------------------------------- |
107 // TWsfAiController::Initialize |
107 // TWsfAiController::Initialize |
108 // -------------------------------------------------------------------------- |
108 // -------------------------------------------------------------------------- |
109 // |
109 // |
110 void TWsfAiController::InitializeL( CWsfModel* aModel, CWsfAiModel* aAiModel, |
110 void TWsfAiController::InitializeL( CWsfModel* aModel, CWsfAiModel* aAiModel, |
111 CWsfDbObserver* aObserver ) |
111 CWsfDbObserver* aObserver, |
|
112 CWsfActiveWrappers* aActiveWrappers ) |
112 { |
113 { |
113 LOG_ENTERFN( "TWsfAiController::InitializeL" ); |
114 LOG_ENTERFN( "TWsfAiController::InitializeL" ); |
114 iModel = aModel; |
115 iModel = aModel; |
115 iAiModel = aAiModel; |
116 iAiModel = aAiModel; |
116 iDbObserver = aObserver; |
117 iDbObserver = aObserver; |
|
118 iActiveWrappers = aActiveWrappers; |
117 iDbObserver->SetController( this ); |
119 iDbObserver->SetController( this ); |
118 iDbObserver->ActivateItL(); |
120 iDbObserver->ActivateItL(); |
119 iModel->SetEngineObserver( this ); |
121 iModel->SetEngineObserver( this ); |
120 |
|
121 iAiModel->SetConnected( iModel->IsConnectedL() ); |
|
122 } |
122 } |
123 |
123 |
124 |
124 |
125 // --------------------------------------------------------------------------- |
125 // --------------------------------------------------------------------------- |
126 // TWsfMainController::BrowserLaunchCompleteL |
126 // TWsfMainController::BrowserLaunchCompleteL |
196 RefreshUiL(); |
196 RefreshUiL(); |
197 } |
197 } |
198 |
198 |
199 |
199 |
200 // -------------------------------------------------------------------------- |
200 // -------------------------------------------------------------------------- |
201 // TWsfAiController::StartupRefreshL |
201 // TWsfAiController::StartupRefresh |
202 // -------------------------------------------------------------------------- |
202 // -------------------------------------------------------------------------- |
203 // |
203 // |
204 void TWsfAiController::StartupRefreshL() |
204 void TWsfAiController::StartupRefresh() |
205 { |
205 { |
206 LOG_ENTERFN( "TWsfAiController::StartupRefreshL" ); |
206 LOG_ENTERFN( "TWsfAiController::StartupRefresh" ); |
207 iModel->GetConnectedWlanDetailsL( iConnectedWlan ); |
207 iActiveWrappers->RefreshWLANList( ETrue ); |
|
208 } |
|
209 |
|
210 |
|
211 // -------------------------------------------------------------------------- |
|
212 // TWsfAiController::StartupRefreshDataReadyL |
|
213 // -------------------------------------------------------------------------- |
|
214 // |
|
215 void TWsfAiController::StartupRefreshDataReadyL() |
|
216 { |
|
217 LOG_ENTERFN( "TWsfAiController::StartupRefreshDataReadyL" ); |
|
218 |
|
219 iInfoArray = iActiveWrappers->GetWLANList(); |
|
220 iConnectedWlan = iActiveWrappers->GetConnectedWLANNetwork(); |
|
221 iAiModel->SetConnected( iConnectedWlan.Connected() ); |
208 iAiModel->SetConnectedWlanInfo( iConnectedWlan ); |
222 iAiModel->SetConnectedWlanInfo( iConnectedWlan ); |
209 |
223 |
210 iInfoArray = iModel->GetWlanListL(); |
224 LOG_WRITEF( "Connected = %d", iConnectedWlan.Connected() ); |
|
225 |
211 MDesCArray* data = iAiModel->FormatSingleLineWlanListL( iInfoArray ); |
226 MDesCArray* data = iAiModel->FormatSingleLineWlanListL( iInfoArray ); |
212 |
227 |
213 // index value to suppress 1 second refreshing state |
228 // index value to suppress 1 second refreshing state |
214 const TInt KSuppressRefreshIndex = 1024; |
229 const TInt KSuppressRefreshIndex = 1024; |
215 |
230 |
302 if ( !iAiModel->ScanningOn() ) |
317 if ( !iAiModel->ScanningOn() ) |
303 { |
318 { |
304 return; |
319 return; |
305 } |
320 } |
306 |
321 |
|
322 iActiveWrappers->RefreshWLANList( EFalse ); |
|
323 } |
|
324 |
|
325 |
|
326 // -------------------------------------------------------------------------- |
|
327 // TWsfAiController::WlanListDataReadyL |
|
328 // -------------------------------------------------------------------------- |
|
329 // |
|
330 void TWsfAiController::WlanListDataReadyL() |
|
331 { |
|
332 LOG_ENTERFN("TWsfAiController::WlanListDataReadyL" ); |
|
333 |
|
334 _ASS_D( iAiModel ); |
|
335 |
|
336 iInfoArray = iActiveWrappers->GetWLANList(); |
|
337 iConnectedWlan = iActiveWrappers->GetConnectedWLANNetwork(); |
|
338 iAiModel->SetConnected( iConnectedWlan.Connected() ); |
|
339 iAiModel->SetConnectedWlanInfo( iConnectedWlan ); |
|
340 |
|
341 LOG_WRITEF( "Connected = %d", iConnectedWlan.Connected() ); |
|
342 |
|
343 if ( !iAiModel->ScanningOn() && !iAiModel->Connected() ) |
|
344 { |
|
345 return; |
|
346 } |
|
347 |
307 _ASS_D( iModel ); |
348 _ASS_D( iModel ); |
308 _ASS_D( iUi ); |
349 _ASS_D( iUi ); |
309 |
350 |
310 TBool match( EFalse ); |
351 TBool match( EFalse ); |
311 TWsfWlanInfo previousSelected; |
352 TWsfWlanInfo previousSelected; |
323 match = ETrue; |
364 match = ETrue; |
324 previousSelected = *temp; |
365 previousSelected = *temp; |
325 } |
366 } |
326 } |
367 } |
327 } |
368 } |
328 iInfoArray = iModel->GetWlanListL(); |
|
329 TBool connected = iModel->GetConnectedWlanDetailsL( iConnectedWlan ); |
|
330 iAiModel->SetConnected( connected ); |
|
331 iAiModel->SetConnectedWlanInfo( iConnectedWlan ); |
|
332 |
369 |
333 MDesCArray* data = iUi->MultilineControl() ? |
370 MDesCArray* data = iUi->MultilineControl() ? |
334 iAiModel->FormatWlanListL( iInfoArray, ETrue ): |
371 iAiModel->FormatWlanListL( iInfoArray, ETrue ): |
335 iAiModel->FormatSingleLineWlanListL( iInfoArray ); |
372 iAiModel->FormatSingleLineWlanListL( iInfoArray ); |
336 |
373 |
386 // -------------------------------------------------------------------------- |
423 // -------------------------------------------------------------------------- |
387 // |
424 // |
388 void TWsfAiController::ScanEnabledL() |
425 void TWsfAiController::ScanEnabledL() |
389 { |
426 { |
390 LOG_ENTERFN( "TWsfAiController::ScanEnabledL" ); |
427 LOG_ENTERFN( "TWsfAiController::ScanEnabledL" ); |
391 iModel->RefreshScanL(); |
428 iActiveWrappers->RefreshScan(); |
392 } |
429 } |
393 |
430 |
394 |
431 |
395 // -------------------------------------------------------------------------- |
432 // -------------------------------------------------------------------------- |
396 // TWsfAiController::WlanConnectionActivatedL |
433 // TWsfAiController::WlanConnectionActivatedL |
399 void TWsfAiController::WlanConnectionActivatedL( |
436 void TWsfAiController::WlanConnectionActivatedL( |
400 const TDesC& /*aAccessPointName*/ ) |
437 const TDesC& /*aAccessPointName*/ ) |
401 { |
438 { |
402 LOG_ENTERFN( "TWsfAiController::WlanConnectionActivatedL" ); |
439 LOG_ENTERFN( "TWsfAiController::WlanConnectionActivatedL" ); |
403 iModel->SetConnecting( EFalse ); |
440 iModel->SetConnecting( EFalse ); |
404 iModel->GetConnectedWlanDetailsL( iConnectedWlan ); |
|
405 iAiModel->SetConnectedWlanInfo( iConnectedWlan ); |
|
406 iAiModel->SetConnected( ETrue ); |
441 iAiModel->SetConnected( ETrue ); |
407 iAiModel->SetConnecting( EFalse ); |
442 iAiModel->SetConnecting( EFalse ); |
408 |
443 |
409 RefreshUiL(); |
444 iActiveWrappers->RefreshWLANList( EFalse ); |
410 } |
445 } |
411 |
446 |
412 |
447 |
413 // -------------------------------------------------------------------------- |
448 // -------------------------------------------------------------------------- |
414 // TWsfAiController::WlanConnectionClosedL |
449 // TWsfAiController::WlanConnectionClosedL |
420 iModel->SetConnecting( EFalse ); |
455 iModel->SetConnecting( EFalse ); |
421 iAiModel->SetConnected( EFalse ); |
456 iAiModel->SetConnected( EFalse ); |
422 iAiModel->SetConnecting( EFalse ); |
457 iAiModel->SetConnecting( EFalse ); |
423 if ( iAiModel->ScanningOn() ) |
458 if ( iAiModel->ScanningOn() ) |
424 { |
459 { |
425 // update the model and refresh ui |
460 iActiveWrappers->RefreshWLANList( EFalse ); |
426 if ( iInfoArray ) |
|
427 { |
|
428 // check if the array has any items |
|
429 if ( iInfoArray->Count() ) |
|
430 { |
|
431 iInfoArray->SortArrayL(); |
|
432 TWsfWlanInfo* firstItem = iInfoArray->At( KFirstItemArrayIndex ); |
|
433 if ( firstItem && firstItem->Connected() ) |
|
434 { |
|
435 firstItem->iConnectionState = ENotConnected; |
|
436 } |
|
437 } |
|
438 } |
|
439 // Abort current scan if exists so that we get |
|
440 // newest scan results propagated to ui |
|
441 iModel->AbortScanningL(); |
|
442 iModel->RefreshScanL(); |
|
443 RefreshUiL(); |
|
444 } |
461 } |
445 else |
462 else |
446 { |
463 { |
447 iUi->DisplayEngineOffL(); |
464 iUi->DisplayEngineOffL(); |
448 } |
465 } |
466 } |
483 } |
467 iAiModel->SetConnecting( EFalse ); |
484 iAiModel->SetConnecting( EFalse ); |
468 if ( aResult == KErrNone ) |
485 if ( aResult == KErrNone ) |
469 { |
486 { |
470 iAiModel->SetConnected( ETrue ); |
487 iAiModel->SetConnected( ETrue ); |
471 iModel->FinalizeConnectL(); |
|
472 if ( !iShouldConnectOnly ) |
488 if ( !iShouldConnectOnly ) |
473 { |
489 { |
474 StartWebBrowserL( iUsedInfo ); |
490 StartWebBrowserL( iUsedInfo ); |
475 } |
491 } |
476 if ( iTestAccessPoint ) |
492 if ( iTestAccessPoint ) |
622 } |
637 } |
623 |
638 |
624 // Connect |
639 // Connect |
625 if ( iUsedInfo.iIapId ) |
640 if ( iUsedInfo.iIapId ) |
626 { |
641 { |
627 TInt result = KErrNone; |
642 if ( iTestAccessPoint ) |
628 result = iModel->ConnectWithoutConnWaiterL( iUsedInfo.iIapId, |
643 { |
629 !iTestAccessPoint ); |
644 iActiveWrappers->Connect( iUsedInfo.iIapId, EIapExpireOnDisconnect ); |
630 |
645 |
631 if ( result != KErrNone ) |
646 } |
632 { |
647 else |
633 LOG_WRITEF( "Connect failed with error = %d", result ); |
648 { |
634 User::Leave( result ); |
649 iActiveWrappers->Connect( iUsedInfo.iIapId, EIapPersistent ); |
635 } |
650 } |
|
651 |
636 } |
652 } |
637 // pop cleanup item |
653 // pop cleanup item |
638 CleanupStack::Pop(); |
654 CleanupStack::Pop(); |
639 } |
655 } |
640 |
656 |
792 dialog->SetIconArrayL( icons ); // ownership of the icon array is passed |
808 dialog->SetIconArrayL( icons ); // ownership of the icon array is passed |
793 CleanupStack::Pop( icons ); |
809 CleanupStack::Pop( icons ); |
794 |
810 |
795 // the dialog is ready to receive data... |
811 // the dialog is ready to receive data... |
796 iUi = dialog; |
812 iUi = dialog; |
797 iUi->UpdateHotSpotsL( iAiModel->FormatWlanListL( iModel->GetWlanListL(), EFalse ), |
813 iUi->UpdateHotSpotsL( iAiModel->FormatWlanListL( |
798 KFirstItemArrayIndex ); |
814 iActiveWrappers->GetWLANList(), EFalse ), |
|
815 KFirstItemArrayIndex ); |
799 |
816 |
800 return dialog->RunLD(); |
817 return dialog->RunLD(); |
801 } |
818 } |
802 |
819 |
803 |
820 |
844 { |
861 { |
845 return; |
862 return; |
846 } |
863 } |
847 iModel->EnableScanL(); |
864 iModel->EnableScanL(); |
848 iAiModel->SetScanningOn(); |
865 iAiModel->SetScanningOn(); |
|
866 |
|
867 LOG_WRITE( "DbObserver enable scan" ); |
849 iDbObserver->EnableScanL(); |
868 iDbObserver->EnableScanL(); |
850 |
869 |
851 MDesCArray *data = iAiModel->FormatRefreshingL(); |
870 MDesCArray *data = iAiModel->FormatRefreshingL(); |
852 iUi->UpdateHotSpotsL( data, KFirstItemArrayIndex ); |
871 iUi->UpdateHotSpotsL( data, KFirstItemArrayIndex ); |
853 } |
872 } |
871 } |
890 } |
872 iModel->DisableScanL(); |
891 iModel->DisableScanL(); |
873 iAiModel->SetScanningOff(); |
892 iAiModel->SetScanningOff(); |
874 iDbObserver->DisableScanL(); |
893 iDbObserver->DisableScanL(); |
875 iUi->DisplayEngineOffL(); |
894 iUi->DisplayEngineOffL(); |
876 } |
|
877 |
|
878 |
|
879 // -------------------------------------------------------------------------- |
|
880 // TWsfAiController::DisconnectL |
|
881 // -------------------------------------------------------------------------- |
|
882 // |
|
883 void TWsfAiController::DisconnectL() |
|
884 { |
|
885 LOG_ENTERFN( "TWsfAiController::DisconnectL" ); |
|
886 |
|
887 _ASS_D( iModel ); |
|
888 |
|
889 iModel->DisconnectL(); |
|
890 } |
895 } |
891 |
896 |
892 |
897 |
893 // -------------------------------------------------------------------------- |
898 // -------------------------------------------------------------------------- |
894 // TWsfAiController::DoHandleEngineErrorL |
899 // TWsfAiController::DoHandleEngineErrorL |
1186 |
1191 |
1187 if ( listQuery->RunLD() ) |
1192 if ( listQuery->RunLD() ) |
1188 { |
1193 { |
1189 if ( selectedMode == EAiConnectingDisconnect ) |
1194 if ( selectedMode == EAiConnectingDisconnect ) |
1190 { |
1195 { |
1191 if ( iModel->IsConnectedL() ) |
1196 if ( !iModel->IsConnecting() ) |
1192 { |
1197 { |
1193 // disconnect wlan |
1198 // disconnect wlan |
1194 iModel->DisconnectL(); |
1199 iActiveWrappers->Disconnect(); |
1195 } |
1200 } |
1196 else |
1201 else |
1197 { |
1202 { |
1198 // disconnect wlan |
1203 // disconnect wlan |
1199 iModel->AbortConnectingL(); |
1204 iModel->AbortConnectingL(); |
1200 } |
1205 ConnectingFinishedL( KErrCancel ); |
1201 ConnectingFinishedL( KErrCancel ); |
1206 } |
1202 } |
1207 } |
1203 } |
1208 } |
1204 } |
1209 } |
1205 |
1210 |
1206 |
1211 |