475 { |
475 { |
476 // if not known yet, create an IAP |
476 // if not known yet, create an IAP |
477 if ( iModel->CreateAccessPointL( info, EFalse ) ) |
477 if ( iModel->CreateAccessPointL( info, EFalse ) ) |
478 { |
478 { |
479 // update iapID to list |
479 // update iapID to list |
480 TWsfWlanInfo* temp = iInfoArray->Match( info.iSsid, |
480 UpdateIapIdToInfoArray( info ); |
481 iInfoArray->Count() ); |
481 |
482 if ( temp && !info.Hidden() ) |
|
483 { |
|
484 LOG_WRITE( "Info found" ); |
|
485 temp->iIapId = info.iIapId; |
|
486 } |
|
487 else |
|
488 { |
|
489 LOG_WRITE( "Info not found" ); |
|
490 TWsfWlanInfo* createdInfo = new (ELeave) TWsfWlanInfo( info ); |
|
491 createdInfo->iVisibility = ETrue; |
|
492 createdInfo->iStrengthLevel = EWlanSignalStrengthMax; |
|
493 iInfoArray->AppendL( createdInfo ); |
|
494 } |
|
495 // on success, test it and save it as well |
482 // on success, test it and save it as well |
496 result = iModel->TestAccessPointL( info, ETrue, EFalse ); |
483 result = iModel->TestAccessPointL( info, ETrue, EFalse ); |
497 } |
484 } |
498 else |
485 else |
499 { |
486 { |
522 |
509 |
523 passedIap = cmmanager.EasyWlanIdL(); |
510 passedIap = cmmanager.EasyWlanIdL(); |
524 |
511 |
525 CleanupStack::PopAndDestroy( &cmmanager ); |
512 CleanupStack::PopAndDestroy( &cmmanager ); |
526 } |
513 } |
527 |
514 |
528 const TInt KBrowserUid = 0x10008D39; |
515 // launch the browser |
529 TUid id( TUid::Uid( KBrowserUid ) ); |
516 iModel->LaunchBrowserL( passedIap ); |
530 TApaTaskList taskList( CEikonEnv::Static()->WsSession() ); |
|
531 TApaTask task = taskList.FindApp( id ); |
|
532 |
|
533 // Check if the Browser application is already running. |
|
534 if ( task.Exists() ) |
|
535 { |
|
536 HBufC* queryText = StringLoader::LoadLC( |
|
537 R_QTN_SNIFFER_QUEST_RESTART_BROWSING_WITH_WLAN ); |
|
538 |
|
539 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
540 TInt ret = dlg->ExecuteLD( |
|
541 R_RESTART_BROWSING_CONFIRMATION_QUERY, |
|
542 *queryText ); |
|
543 |
|
544 CleanupStack::PopAndDestroy( queryText ); |
|
545 |
|
546 if ( ( ret == EAknSoftkeyOk ) || ( ret == EAknSoftkeyYes ) ) |
|
547 { |
|
548 // User Press OK or Yes and launch the browser |
|
549 iModel->LaunchBrowserL( passedIap ); |
|
550 } |
|
551 else |
|
552 { |
|
553 // clean up the temporary IAP if any |
|
554 iModel->CleanUpCancelledLaunchL(); |
|
555 |
|
556 // if we are here then we can disconnect |
|
557 // and iModel->DisconnectL() handles view refreshing |
|
558 iModel->DisconnectL(); |
|
559 } |
|
560 } |
|
561 else |
|
562 { |
|
563 // finally launch the browser |
|
564 iModel->LaunchBrowserL( passedIap ); |
|
565 } |
|
566 } |
517 } |
567 else if ( result == KErrCancel ) |
518 else if ( result == KErrCancel ) |
568 { |
519 { |
569 // connection creation was cancelled, refresh the view |
520 // connection creation was cancelled, refresh the view |
570 iModel->RefreshScanL(); |
521 iModel->RefreshScanL(); |
610 { |
561 { |
611 // a new access point needs to be created |
562 // a new access point needs to be created |
612 if ( iModel->CreateAccessPointL( info, EFalse ) ) |
563 if ( iModel->CreateAccessPointL( info, EFalse ) ) |
613 { |
564 { |
614 // update iapID to list |
565 // update iapID to list |
615 TWsfWlanInfo* temp = iInfoArray->Match( info.iSsid, |
566 UpdateIapIdToInfoArray( info ); |
616 iInfoArray->Count() ); |
567 |
617 if ( temp && !info.Hidden() ) |
|
618 { |
|
619 LOG_WRITE( "Info found" ); |
|
620 temp->iIapId = info.iIapId; |
|
621 |
|
622 if ( info.iNetworkName.Length() ) |
|
623 { |
|
624 // Replace ssid as well since scanner does this same thing |
|
625 temp->iSsid.Copy( info.iNetworkName ); |
|
626 } |
|
627 } |
|
628 else |
|
629 { |
|
630 LOG_WRITE( "Info not found" ); |
|
631 TWsfWlanInfo* createdInfo = new (ELeave) TWsfWlanInfo( info ); |
|
632 createdInfo->iVisibility = ETrue; |
|
633 createdInfo->iStrengthLevel = EWlanSignalStrengthMax; |
|
634 iInfoArray->AppendL( createdInfo ); |
|
635 } |
|
636 |
|
637 // on success, test it and save it as well |
568 // on success, test it and save it as well |
638 // (testing actually creates the connection) |
569 // (testing actually creates the connection) |
639 if ( iModel->TestAccessPointL( info, ETrue, ETrue ) == KErrCancel ) |
570 if ( iModel->TestAccessPointL( info, ETrue, ETrue ) == KErrCancel ) |
640 { |
571 { |
641 // connection creation was cancelled, refresh the view |
572 // connection creation was cancelled, refresh the view |
652 // pop cleanup item ReleaseSuppressingKeyEvents |
583 // pop cleanup item ReleaseSuppressingKeyEvents |
653 CleanupStack::Pop(); |
584 CleanupStack::Pop(); |
654 iAppUi->SetSuppressingKeyEvents( EFalse ); |
585 iAppUi->SetSuppressingKeyEvents( EFalse ); |
655 |
586 |
656 } |
587 } |
|
588 |
|
589 // --------------------------------------------------------------------------- |
|
590 // TWsfMainController::UpdateIapIdToInfoArray |
|
591 // --------------------------------------------------------------------------- |
|
592 // |
|
593 void TWsfMainController::UpdateIapIdToInfoArray( TWsfWlanInfo& aInfo ) |
|
594 { |
|
595 LOG_ENTERFN( "TWsfMainController::UpdateIapIdToInfoArray" ); |
|
596 TWsfWlanInfo* temp = iInfoArray->Match( aInfo.iSsid, iInfoArray->Count() ); |
|
597 if ( temp && !aInfo.Hidden() ) |
|
598 { |
|
599 LOG_WRITE( "Info found" ); |
|
600 |
|
601 // Check that there aren't any IAPs with same id |
|
602 TWsfWlanInfo* wlanInfoWithSameIapId = iInfoArray->Match( aInfo.iIapId, |
|
603 iInfoArray->Count() ); |
|
604 if ( wlanInfoWithSameIapId ) |
|
605 { |
|
606 // info with same id found set its iap id to zero |
|
607 LOG_WRITE( "info with same id found" ); |
|
608 wlanInfoWithSameIapId->iIapId = 0; |
|
609 } |
|
610 |
|
611 temp->iIapId = aInfo.iIapId; |
|
612 |
|
613 if ( aInfo.iNetworkName.Length() ) |
|
614 { |
|
615 // Replace ssid as well since scanner does this same thing |
|
616 temp->iSsid.Copy( aInfo.iNetworkName ); |
|
617 } |
|
618 } |
|
619 else |
|
620 { |
|
621 LOG_WRITE( "Info not found" ); |
|
622 TWsfWlanInfo* createdInfo = new (ELeave) TWsfWlanInfo( aInfo ); |
|
623 createdInfo->iVisibility = ETrue; |
|
624 createdInfo->iStrengthLevel = EWlanSignalStrengthMax; |
|
625 iInfoArray->AppendL( createdInfo ); |
|
626 } |
|
627 } |
657 |
628 |
658 // --------------------------------------------------------------------------- |
629 // --------------------------------------------------------------------------- |
659 // TWsfMainController::DisconnectL |
630 // TWsfMainController::DisconnectL |
660 // --------------------------------------------------------------------------- |
631 // --------------------------------------------------------------------------- |
661 // |
632 // |
855 { |
826 { |
856 LOG_ENTERFN( "TWsfMainController::ConnectingFinishedL" ); |
827 LOG_ENTERFN( "TWsfMainController::ConnectingFinishedL" ); |
857 if ( iModel->IsConnecting() ) |
828 if ( iModel->IsConnecting() ) |
858 { |
829 { |
859 iModel->SetConnecting( EFalse ); |
830 iModel->SetConnecting( EFalse ); |
|
831 iModel->SetRefreshState( ETrue ); |
860 iAppUi->HideWaitNoteL(); |
832 iAppUi->HideWaitNoteL(); |
861 } |
833 } |
862 |
834 |
863 if ( aResult != KErrNone && aResult != KErrCancel ) |
835 if ( aResult != KErrNone && aResult != KErrCancel ) |
864 { |
836 { |
865 LOG_WRITEF( "Connection failed with error=%d", aResult ); |
837 LOG_WRITEF( "Connection failed with error=%d", aResult ); |
866 if ( iInfoArray && iInfoArray->Count() && |
838 if ( iInfoArray && iInfoArray->Count() && |
867 iInfoArray->At(0)->iConnectionState == EConnecting ) |
839 iInfoArray->At(0)->iConnectionState == EConnecting ) |
868 { |
840 { |
869 iInfoArray->At(0)->iConnectionState = ENotConnected; |
841 iInfoArray->At(0)->iConnectionState = ENotConnected; |
|
842 TRAPD( error, iModel->CheckIsIapIdValidL( |
|
843 iInfoArray->At(0)->iIapId ) ); |
|
844 if ( error ) |
|
845 { |
|
846 LOG_WRITEF( "Iap Id %d is not valid - error=%d", |
|
847 iInfoArray->At(0)->iIapId, error ); |
|
848 |
|
849 if ( iInfoArray->At(0)->iRawSsid.Length() ) |
|
850 { |
|
851 iInfoArray->At(0)->iSsid.Copy( |
|
852 iInfoArray->At(0)->iRawSsid ); |
|
853 } |
|
854 |
|
855 iInfoArray->At(0)->iIapId = 0; |
|
856 } |
870 iInfoArray->SortArrayL(); |
857 iInfoArray->SortArrayL(); |
871 UpdateViewL( iInfoArray ); |
858 UpdateViewL( iInfoArray ); |
|
859 iModel->AbortScanningL(); |
872 iModel->RefreshScanL(); |
860 iModel->RefreshScanL(); |
873 } |
861 } |
874 } |
862 } |
875 } |
863 } |
876 |
864 |