wlanutilities/wlansniffer/aiplugin/src/wsfaicontroller.cpp
changeset 0 56b72877c1cb
child 1 d07e190ed096
equal deleted inserted replaced
-1:000000000000 0:56b72877c1cb
       
     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 TWsfAiController.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  EXTERNAL INCLUDES
       
    20 #include <apgcli.h>
       
    21 #include <centralrepository.h>
       
    22 #include <BrowserUiSDKCRKeys.h>
       
    23 #include <AknIconArray.h>
       
    24 #include <AknQueryDialog.h>
       
    25 #include <cmpluginwlandef.h>
       
    26 #include <ErrorUI.h>
       
    27 #include <StringLoader.h>
       
    28 #include <aknnotewrappers.h>
       
    29 #include <wsfaipluginrsc.rsg>
       
    30 #include <rconnmon.h>
       
    31 #include <utf.h>
       
    32 #include <cmmanager.h>
       
    33 #include <internetconnectivitycrkeys.h>
       
    34 #include <wlanerrorcodes.h>
       
    35 
       
    36 //  CLASS HEADER
       
    37 #include "wsfaicontroller.h"
       
    38 
       
    39 //  INTERNAL INCLUDES
       
    40 #include "wsfwlaninfo.h"
       
    41 #include "wsfwlaninfoarray.h"
       
    42 #include "wsfaiuiobserver.h"
       
    43 #include "wsfaimodel.h"
       
    44 #include "wsficonarraycreator.h"
       
    45 #include "wsfmodel.h"
       
    46 #include "wsfsearchwlansdialog.h"
       
    47 #include "wsfaicontrollercmds.h"
       
    48 #include "wsfactivewaiter.h"
       
    49 #include "wsflogger.h"
       
    50 #include "wsfdbobserver.h"
       
    51 
       
    52 
       
    53 //  MACROS
       
    54 #ifdef _DEBUG
       
    55     _LIT( KControllerPanic, "CWsfAiController" );
       
    56     #define _ASS_D( cond ) __ASSERT_DEBUG( (cond), \
       
    57             User::Panic( KControllerPanic, __LINE__) )
       
    58 #else
       
    59     #define _ASS_D( cond )
       
    60 #endif //_DEBUG
       
    61 
       
    62 
       
    63 //  LOCAL DEFINITIONS
       
    64 LOCAL_D const TInt KFirstItemArrayIndex = 0;
       
    65 
       
    66 // Category UID of AiHelper property
       
    67 static const TUid KWsfAiHelperCategoryUid = { 0x10281CEB };
       
    68 
       
    69 // key numbers within the property 
       
    70 static const TUint KWsfAiHelperExitCodeKey = 0;
       
    71 static const TUint KWsfAiHelperIapIdKey = 1;
       
    72 static const TInt KSuppressRefreshIndex = 1024;
       
    73 
       
    74 
       
    75 
       
    76 // --------------------------------------------------------------------------
       
    77 // TWsfAiController::TWsfAiController
       
    78 // --------------------------------------------------------------------------
       
    79 //
       
    80 TWsfAiController::TWsfAiController():
       
    81     iModel( NULL ),
       
    82     iAiModel( NULL ),
       
    83     iUi( NULL ),
       
    84     iDbObserver( NULL ),
       
    85     iShouldConnectOnly( EFalse ),
       
    86     iTestAccessPoint( EFalse )
       
    87     {
       
    88     // null the pointers
       
    89     iConnectedWlan.iConnectionState = ENotConnected;
       
    90     }
       
    91 
       
    92 
       
    93 // ---------------------------------------------------------
       
    94 // CWsfActiveWaiter::DeInitializeL
       
    95 // ---------------------------------------------------------
       
    96 //    
       
    97 void TWsfAiController::DeInitializeL()
       
    98     {
       
    99     LOG_ENTERFN( "TWsfAiController::DeInitializeL" );
       
   100     iModel->AbortConnectingL();
       
   101     iModel->AbortScanningL();
       
   102     }
       
   103 
       
   104 
       
   105 // --------------------------------------------------------------------------
       
   106 // TWsfAiController::Initialize
       
   107 // --------------------------------------------------------------------------
       
   108 //
       
   109 void TWsfAiController::InitializeL( CWsfModel* aModel, CWsfAiModel* aAiModel,
       
   110 		                             CWsfDbObserver* aObserver )
       
   111     {
       
   112     LOG_ENTERFN( "TWsfAiController::InitializeL" );
       
   113     iModel = aModel;
       
   114     iAiModel = aAiModel;
       
   115     iDbObserver = aObserver;
       
   116     iDbObserver->SetController( this );
       
   117     iDbObserver->ActivateItL();
       
   118     iModel->SetEngineObserver( this );
       
   119     
       
   120     iAiModel->SetConnected( iModel->IsConnectedL() );
       
   121     }
       
   122 
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // TWsfMainController::BrowserLaunchCompleteL
       
   126 // ---------------------------------------------------------------------------
       
   127 // 
       
   128 void TWsfAiController::BrowserLaunchCompleteL()
       
   129     {
       
   130     LOG_ENTERFN( "TWsfAiController::BrowserLaunchCompleteL" );
       
   131     // no implementation required
       
   132     }
       
   133 
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // TWsfMainController::BrowserExitL
       
   137 // ---------------------------------------------------------------------------
       
   138 // 
       
   139 void TWsfAiController::BrowserExitL()
       
   140     {
       
   141     LOG_ENTERFN( "TWsfAiController::BrowserExitL" ); 
       
   142     // no implementation required
       
   143     }
       
   144 
       
   145 
       
   146 // ---------------------------------------------------------------------------
       
   147 // TWsfMainController::BrowserLaunchFailed
       
   148 // ---------------------------------------------------------------------------
       
   149 //
       
   150 #ifdef _DEBUG
       
   151 void TWsfAiController::BrowserLaunchFailed( TInt aError )
       
   152     {
       
   153     LOG_ENTERFN( "TWsfAiController::BrowserLaunchFailed" ); 
       
   154     LOG_WRITEF( "error = %d", aError );
       
   155 #else
       
   156 void TWsfAiController::BrowserLaunchFailed( TInt /*aError*/ )
       
   157     {   
       
   158     // no implementation required
       
   159 #endif
       
   160     }
       
   161 
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 // TWsfMainController::ConnectingL
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 void TWsfAiController::ConnectingL( TUint32 /*aIapId*/ )
       
   168     {
       
   169     LOG_ENTERFN( "TWsfAiController::ConnectingL" ); 
       
   170     iModel->SetConnecting( ETrue );
       
   171     iAiModel->SetConnecting( ETrue );
       
   172     iUi->StartConnectingAnimationL();
       
   173     RefreshUiL();
       
   174     }
       
   175 
       
   176 
       
   177 // ---------------------------------------------------------------------------
       
   178 // TWsfMainController::ConnectingFinishedL
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 #ifdef _DEBUG
       
   182 void TWsfAiController::ConnectingFinishedL( TInt aResult )
       
   183     {
       
   184     LOG_ENTERFN( "TWsfAiController::ConnectingFinishedL" );
       
   185     LOG_WRITEF( "aResult = %d", aResult );
       
   186 #else
       
   187 void TWsfAiController::ConnectingFinishedL( TInt /*aResult*/ )
       
   188     {
       
   189 #endif
       
   190     if ( iModel->IsConnecting() )
       
   191         {
       
   192         iModel->SetConnecting( EFalse );
       
   193         }
       
   194     iAiModel->SetConnecting( EFalse );
       
   195     RefreshUiL();
       
   196     }
       
   197 
       
   198 
       
   199 // --------------------------------------------------------------------------
       
   200 // TWsfAiController::StartupRefreshL
       
   201 // --------------------------------------------------------------------------
       
   202 //
       
   203 void TWsfAiController::StartupRefreshL()
       
   204     {
       
   205     LOG_ENTERFN( "TWsfAiController::StartupRefreshL" );
       
   206     iModel->GetConnectedWlanDetailsL( iConnectedWlan );
       
   207     iAiModel->SetConnectedWlanInfo( iConnectedWlan );
       
   208     
       
   209     iInfoArray = iModel->GetWlanListL();
       
   210     MDesCArray* data = iAiModel->FormatSingleLineWlanListL( iInfoArray );
       
   211     
       
   212     // index value to suppress 1 second refreshing state
       
   213     const TInt KSuppressRefreshIndex = 1024;
       
   214     
       
   215     iUi->UpdateHotSpotsL( data, KSuppressRefreshIndex );    
       
   216     }
       
   217 
       
   218 
       
   219 // --------------------------------------------------------------------------
       
   220 // TWsfAiController::SetUi
       
   221 // --------------------------------------------------------------------------
       
   222 //
       
   223 void TWsfAiController::SetUi( MWsfAiUiObserver& aUi )
       
   224     {
       
   225     LOG_ENTERFN( "TWsfAiController::SetUi" );
       
   226     iUi = &aUi;    
       
   227     }
       
   228 
       
   229 
       
   230 // --------------------------------------------------------------------------
       
   231 // TWsfAiController::HandleSelectionKeyL
       
   232 // --------------------------------------------------------------------------
       
   233 //
       
   234 void TWsfAiController::HandleSelectionKeyL()
       
   235     {
       
   236     LOG_ENTERFN( "TWsfAiController::HandleSelectionKeyL" );
       
   237     _ASS_D( iAiModel );
       
   238     
       
   239     if ( !iAiModel->ScanningOn() && !iAiModel->Connected() )
       
   240         {
       
   241         // scanning was off and there wasn't a connected network
       
   242         EnableScanL();
       
   243         }
       
   244     else
       
   245         {
       
   246         // scanning was on
       
   247         // menu contents depend on the connection and browser status
       
   248         if ( iModel->IsConnecting() )
       
   249             {
       
   250             // connecting
       
   251             HandleMskIfConnectingL();
       
   252             }
       
   253         else if ( !iAiModel->Connected() )
       
   254             {
       
   255             // not connected
       
   256             HandleMskIfOfflineL();
       
   257             }
       
   258         else
       
   259             {
       
   260             // connected
       
   261             if ( IsWlanUsedByBrowserL() )
       
   262                 {
       
   263                 // browser is using active WLAN connection
       
   264                 HandleMskIfBrowsingL();
       
   265                 }
       
   266             else
       
   267                 {
       
   268                 // browser is not running or not using the WLAN
       
   269                 HandleMskIfConnectedL();
       
   270                 }
       
   271             }
       
   272         }
       
   273 
       
   274     }
       
   275 
       
   276 
       
   277 // --------------------------------------------------------------------------
       
   278 // TWsfAiController::DismissDialogsL
       
   279 // --------------------------------------------------------------------------
       
   280 //
       
   281 void TWsfAiController::DismissDialogsL()
       
   282     {
       
   283     LOG_ENTERFN("TWsfAiController::DismissDialogsL" );
       
   284     TKeyEvent key;
       
   285     key.iCode = EKeyEscape;
       
   286     key.iModifiers = 0;
       
   287     CEikonEnv::Static()->SimulateKeyEventL( key, EEventKey );
       
   288     }
       
   289 
       
   290 
       
   291 // --------------------------------------------------------------------------
       
   292 // TWsfAiController::WlanListChangedL
       
   293 // --------------------------------------------------------------------------
       
   294 //
       
   295 void TWsfAiController::WlanListChangedL()
       
   296     {
       
   297     LOG_ENTERFN("TWsfAiController::WlanListChangedL" );
       
   298  
       
   299     _ASS_D( iAiModel );
       
   300     
       
   301     if ( !iAiModel->ScanningOn() )
       
   302         {
       
   303         return;
       
   304         }
       
   305     
       
   306     _ASS_D( iModel );
       
   307     _ASS_D( iUi );
       
   308     
       
   309     TBool match( EFalse );    
       
   310     TWsfWlanInfo previousSelected;        
       
   311     CWsfWlanInfoArray* modelArr = iAiModel->GetInfoArray();   
       
   312     
       
   313     if ( modelArr )
       
   314         {
       
   315         TInt selectedItem = iUi->SelectedItem();
       
   316         if ( selectedItem >= KFirstItemArrayIndex && 
       
   317              selectedItem < modelArr->Count() )
       
   318             {
       
   319             TWsfWlanInfo* temp = modelArr->At( selectedItem );
       
   320             if ( temp )
       
   321                 {
       
   322                 match = ETrue;
       
   323                 previousSelected = *temp;
       
   324                 }                
       
   325             }
       
   326         }
       
   327     iInfoArray = iModel->GetWlanListL();
       
   328     TBool connected = iModel->GetConnectedWlanDetailsL( iConnectedWlan );
       
   329     iAiModel->SetConnected( connected );
       
   330     iAiModel->SetConnectedWlanInfo( iConnectedWlan );
       
   331         
       
   332     MDesCArray* data = iUi->MultilineControl() ? 
       
   333             iAiModel->FormatWlanListL( iInfoArray, ETrue ): 
       
   334             iAiModel->FormatSingleLineWlanListL( iInfoArray );
       
   335     
       
   336     
       
   337     TInt index( KErrNotFound );
       
   338     if ( match )
       
   339         {            
       
   340         TWsfWlanInfo* currentMatch = iInfoArray->Match( 
       
   341                                                     previousSelected.iSsid, 
       
   342                                                     iInfoArray->Count() );
       
   343         if ( currentMatch )
       
   344             {
       
   345             index = iInfoArray->GetArrayIndex( currentMatch );
       
   346             }
       
   347         }
       
   348     
       
   349     if ( !iUi->MultilineControl() && iModel->IsConnecting() )
       
   350         {
       
   351         index = KSuppressRefreshIndex;
       
   352         }
       
   353     
       
   354     iUi->UpdateHotSpotsL( data, index );
       
   355 
       
   356     }
       
   357 
       
   358 
       
   359 // --------------------------------------------------------------------------
       
   360 // TWsfAiController::NotifyEngineError
       
   361 // --------------------------------------------------------------------------
       
   362 //
       
   363 void TWsfAiController::NotifyEngineError( TInt aError )
       
   364     {
       
   365     LOG_ENTERFN( "TWsfAiController::NotifyEngineError" );
       
   366     //Let the user know about the error.
       
   367     LOG_WRITEF( "error = %d", aError );
       
   368     TRAP_IGNORE( DoHandleEngineErrorL( aError ) ); 
       
   369     }
       
   370 
       
   371 
       
   372 // --------------------------------------------------------------------------
       
   373 // TWsfAiController::ScanDisabledL
       
   374 // --------------------------------------------------------------------------
       
   375 //
       
   376 void TWsfAiController::ScanDisabledL()
       
   377     {
       
   378     LOG_ENTERFN( "TWsfAiController::ScanDisabledL" );
       
   379     // no implementation required
       
   380     }
       
   381 
       
   382 
       
   383 // --------------------------------------------------------------------------
       
   384 // TWsfAiController::ScanEnabledL
       
   385 // --------------------------------------------------------------------------
       
   386 //
       
   387 void TWsfAiController::ScanEnabledL()
       
   388     {
       
   389     LOG_ENTERFN( "TWsfAiController::ScanEnabledL" );
       
   390     iModel->RefreshScanL();
       
   391     }
       
   392 
       
   393 
       
   394 // --------------------------------------------------------------------------
       
   395 // TWsfAiController::WlanConnectionActivatedL
       
   396 // --------------------------------------------------------------------------
       
   397 //
       
   398 void TWsfAiController::WlanConnectionActivatedL( 
       
   399                                             const TDesC& /*aAccessPointName*/ )
       
   400     {
       
   401     LOG_ENTERFN( "TWsfAiController::WlanConnectionActivatedL" );
       
   402     iModel->SetConnecting( EFalse );
       
   403     iModel->GetConnectedWlanDetailsL( iConnectedWlan );
       
   404     iAiModel->SetConnectedWlanInfo( iConnectedWlan );
       
   405     iAiModel->SetConnected( ETrue );
       
   406     iAiModel->SetConnecting( EFalse );
       
   407 
       
   408     RefreshUiL();
       
   409     } 
       
   410 
       
   411 
       
   412 // --------------------------------------------------------------------------
       
   413 // TWsfAiController::WlanConnectionClosedL
       
   414 // --------------------------------------------------------------------------
       
   415 //
       
   416 void TWsfAiController::WlanConnectionClosedL()
       
   417     {
       
   418     LOG_ENTERFN( "TWsfAiController::WlanConnectionClosedL" );
       
   419     iModel->SetConnecting( EFalse );
       
   420     iAiModel->SetConnected( EFalse );
       
   421     iAiModel->SetConnecting( EFalse );
       
   422     if ( iAiModel->ScanningOn() )
       
   423         {
       
   424         // update the model and refresh ui
       
   425         if ( iInfoArray )
       
   426             {
       
   427             // check if the array has any items
       
   428             if ( iInfoArray->Count() )
       
   429                 {
       
   430                 iInfoArray->SortArrayL();
       
   431                 TWsfWlanInfo* firstItem = iInfoArray->At( KFirstItemArrayIndex );
       
   432                 if ( firstItem && firstItem->Connected() )
       
   433                     {
       
   434                     firstItem->iConnectionState = ENotConnected;                 
       
   435                     }
       
   436                 }
       
   437             }
       
   438         // Abort current scan if exists so that we get 
       
   439         // newest scan results propagated to ui
       
   440         iModel->AbortScanningL();
       
   441         iModel->RefreshScanL();
       
   442         RefreshUiL();  
       
   443         }
       
   444     else
       
   445         {
       
   446         iUi->DisplayEngineOffL();
       
   447         }
       
   448         
       
   449     }
       
   450 
       
   451 
       
   452 // ---------------------------------------------------------------------------
       
   453 // TWsfMainController::ConnectionCreationProcessFinished
       
   454 // ---------------------------------------------------------------------------
       
   455 //
       
   456 void TWsfAiController::ConnectionCreationProcessFinishedL( TInt aResult )
       
   457     {
       
   458     LOG_ENTERFN( "TWsfAiController::ConnectionCreationProcessFinished" );
       
   459     LOG_WRITEF( "aResult = %d", aResult );
       
   460     // release flags if we leave occures
       
   461     CleanupStack::PushL( TCleanupItem( CleanUpConnectingL, this ) );
       
   462     if ( iModel->IsConnecting() )
       
   463         {
       
   464         iModel->SetConnecting( EFalse );
       
   465         }
       
   466     iAiModel->SetConnecting( EFalse );
       
   467     if ( aResult == KErrNone )
       
   468         {
       
   469         iAiModel->SetConnected( ETrue );
       
   470         iModel->FinalizeConnectL();
       
   471         if ( !iShouldConnectOnly )
       
   472             {
       
   473             StartWebBrowserL( iUsedInfo );
       
   474             }
       
   475         if ( iTestAccessPoint )
       
   476             {
       
   477             iModel->TestConnectedAccessPointL( iUsedInfo, iShouldConnectOnly );
       
   478             }
       
   479         }
       
   480     else
       
   481         {
       
   482         iAiModel->SetConnected( EFalse );
       
   483         }
       
   484     RefreshUiL();
       
   485     // pop cleanup item 
       
   486     CleanupStack::Pop();
       
   487     }
       
   488 
       
   489 
       
   490 // --------------------------------------------------------------------------
       
   491 // TWsfAiController::StartBrowsingL
       
   492 // --------------------------------------------------------------------------
       
   493 //
       
   494 void TWsfAiController::StartBrowsingL( TWsfWlanInfo& aInfo )
       
   495     {
       
   496     LOG_ENTERFN( "TWsfAiController::StartBrowsingL" );
       
   497     
       
   498     _ASS_D( iModel );
       
   499     
       
   500     iUsedInfo = aInfo;
       
   501     
       
   502     // Prevent connections to ad-hoc + WPA 
       
   503     if ( iUsedInfo.iNetMode == CMManager::EAdhoc 
       
   504             && iUsedInfo.iSecurityMode == CMManager::EWlanSecModeWpa )
       
   505         {
       
   506         CErrorUI* errorUi = CErrorUI::NewLC();
       
   507         errorUi->ShowGlobalErrorNoteL( KErrNotSupported );
       
   508         CleanupStack::PopAndDestroy( errorUi ); // errorUi
       
   509         return;
       
   510         }
       
   511     
       
   512     // make sure we don't show connecting stuff forever
       
   513     CleanupStack::PushL( TCleanupItem( CleanUpConnectingL, this ) );
       
   514     
       
   515     if ( !iUsedInfo.Connected() )
       
   516         {
       
   517         ConnectL( iUsedInfo, EFalse );
       
   518         }
       
   519     else
       
   520         {
       
   521         LOG_WRITE("Start browser to connected network...");
       
   522         iShouldConnectOnly = EFalse;
       
   523         StartWebBrowserL( iUsedInfo );
       
   524         }
       
   525     
       
   526     // pop cleanup item 
       
   527     CleanupStack::Pop();
       
   528     }
       
   529 
       
   530 
       
   531 // --------------------------------------------------------------------------
       
   532 // TWsfAiController::StartWebBrowserL
       
   533 // --------------------------------------------------------------------------
       
   534 //
       
   535 void TWsfAiController::StartWebBrowserL( TWsfWlanInfo& aInfo )
       
   536     {
       
   537     LOG_ENTERFN( "TWsfAiController::StartWebBrowserL" );
       
   538     
       
   539     _ASS_D( iModel );
       
   540     
       
   541     TUint32 passedIap( aInfo.iIapId );
       
   542 
       
   543     if ( aInfo.Connected() && !passedIap )
       
   544         {
       
   545         // in case we have an EasyWLAN here
       
   546         RCmManager cmmanager;
       
   547         cmmanager.OpenLC();
       
   548 
       
   549         passedIap = cmmanager.EasyWlanIdL();
       
   550 
       
   551         CleanupStack::PopAndDestroy( &cmmanager );
       
   552         }
       
   553 
       
   554     const TUid KBrowserUid = { 0x10008D39 };
       
   555     TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
       
   556     TApaTask task = taskList.FindApp( KBrowserUid );
       
   557 
       
   558     // Check if the Browser application is already running.        
       
   559     if ( task.Exists() )
       
   560         {
       
   561         HBufC* queryText = StringLoader::LoadLC( 
       
   562                 R_QTN_SNIFFER_QUEST_RESTART_BROWSING_WITH_WLAN );
       
   563 
       
   564         CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
   565         TInt ret = dlg->ExecuteLD( 
       
   566                 R_RESTART_BROWSING_CONFIRMATION_QUERY,
       
   567                 *queryText );
       
   568 
       
   569         CleanupStack::PopAndDestroy( queryText );
       
   570 
       
   571         if ( ( ret == EAknSoftkeyOk ) || ( ret == EAknSoftkeyYes ) )
       
   572             {
       
   573             // User Press OK or Yes and launch the browser
       
   574             iModel->LaunchBrowserL( passedIap );
       
   575             }
       
   576         else
       
   577             {
       
   578             // clean up the temporary IAP if any
       
   579             iModel->CleanUpCancelledLaunchL();
       
   580 
       
   581             // we are at this point then we can disconnect 
       
   582             // and iModel->DisconnectL() handles view refreshing 
       
   583             iModel->DisconnectL();
       
   584             }
       
   585         }
       
   586     else
       
   587         {
       
   588         // finally launch the browser
       
   589         iModel->LaunchBrowserL( passedIap );
       
   590         }
       
   591     }
       
   592 
       
   593 
       
   594 // --------------------------------------------------------------------------
       
   595 // TWsfAiController::ConnectL
       
   596 // --------------------------------------------------------------------------
       
   597 //
       
   598 void TWsfAiController::ConnectL( TWsfWlanInfo& aInfo, TBool aShoulConnectOnly )
       
   599     {
       
   600     LOG_ENTERFN( "TWsfAiController::ConnectL" );
       
   601     
       
   602     _ASS_D( iModel );
       
   603     iTestAccessPoint = EFalse;
       
   604     iShouldConnectOnly = aShoulConnectOnly;
       
   605     iUsedInfo = aInfo;
       
   606     
       
   607     // Prevent connections to ad-hoc + WPA 
       
   608     if ( iUsedInfo.iNetMode == CMManager::EAdhoc 
       
   609             && iUsedInfo.iSecurityMode == CMManager::EWlanSecModeWpa )
       
   610         {
       
   611         CErrorUI* errorUi = CErrorUI::NewLC();
       
   612         errorUi->ShowGlobalErrorNoteL(KErrNotSupported);
       
   613         CleanupStack::PopAndDestroy(errorUi); // errorUi
       
   614         return;
       
   615         }
       
   616     
       
   617     // make sure we don't show connecting stuff forever
       
   618     CleanupStack::PushL( TCleanupItem( CleanUpConnectingL, this ) );
       
   619     
       
   620     if ( !iUsedInfo.iIapId && !iUsedInfo.Hidden() &&
       
   621             iUsedInfo.iSecurityMode == CMManager::EWlanSecModeOpen )
       
   622         {
       
   623         TBool success( EFalse );
       
   624         // just create the IAP
       
   625         TRAPD( accessPointCreatedError, 
       
   626                 success = iModel->CreateAccessPointL( 
       
   627                 iUsedInfo, EFalse ); 
       
   628         );
       
   629         
       
   630         // notify user that Disk is full or creation of a WAPI IAP 
       
   631         // is not supported on-the-fly and leave
       
   632         if ( accessPointCreatedError == KErrDiskFull ||
       
   633              accessPointCreatedError == KErrWlanProtectedSetupSetupLocked )
       
   634             {
       
   635             LOG_WRITE( "showing error note" );
       
   636             CErrorUI* errorUi = CErrorUI::NewLC();
       
   637             errorUi->ShowGlobalErrorNoteL( accessPointCreatedError );
       
   638             CleanupStack::PopAndDestroy( errorUi );
       
   639             User::Leave( accessPointCreatedError );
       
   640             }
       
   641         // just leave because we failed to create accesspoint
       
   642         else if ( accessPointCreatedError != KErrNone || !success )
       
   643             {
       
   644             User::Leave( accessPointCreatedError );
       
   645             }
       
   646         ConnectingL( iUsedInfo.iIapId );
       
   647         iTestAccessPoint = ETrue;
       
   648         }
       
   649     else if ( !iUsedInfo.iIapId )
       
   650         {
       
   651         // let the helper app do the query if necessary
       
   652         LOG_WRITE("AiHelper needs to be launched");
       
   653         LaunchAiHelperAppL( iUsedInfo );
       
   654         ConnectingL( iUsedInfo.iIapId );
       
   655         iTestAccessPoint = ETrue;
       
   656         }
       
   657     
       
   658     // Connect
       
   659     if ( iUsedInfo.iIapId )
       
   660         {
       
   661         TInt result = KErrNone;
       
   662         result = iModel->ConnectWithoutConnWaiterL( iUsedInfo.iIapId, 
       
   663                                                     !iTestAccessPoint );
       
   664 
       
   665         if ( result != KErrNone )
       
   666             {
       
   667             LOG_WRITEF( "Connect failed with error = %d", result );
       
   668             User::Leave( result );
       
   669             }
       
   670         }
       
   671     // pop cleanup item 
       
   672     CleanupStack::Pop();
       
   673     }
       
   674 
       
   675 
       
   676 // ---------------------------------------------------------------------------
       
   677 // TWsfAiController::CleanUpConnectingL
       
   678 // ---------------------------------------------------------------------------
       
   679 //
       
   680 void TWsfAiController::CleanUpConnectingL( TAny* aPtr )
       
   681     {
       
   682     LOG_ENTERFN( "TWsfAiController::CleanUpConnectingL" );
       
   683     TWsfAiController* self = static_cast<TWsfAiController*>( aPtr );
       
   684     self->iModel->SetConnecting( EFalse );
       
   685     self->iAiModel->SetConnecting( EFalse );
       
   686     TRAP_IGNORE( self->RefreshUiL());
       
   687     }
       
   688 
       
   689 
       
   690 // --------------------------------------------------------------------------
       
   691 // TWsfAiController::LaunchAiHelperAppL
       
   692 // --------------------------------------------------------------------------
       
   693 //
       
   694 void TWsfAiController::LaunchAiHelperAppL( TWsfWlanInfo& aInfo )
       
   695     {
       
   696     LOG_ENTERFN( "TWsfAiController::LaunchAiHelperAppL" );
       
   697 
       
   698     CWsfActiveWaiter* waiter = CWsfActiveWaiter::NewL();
       
   699     CleanupStack::PushL( waiter );
       
   700     
       
   701     RProperty aiHelperApp;
       
   702     User::LeaveIfError( aiHelperApp.Attach( 
       
   703                                        KWsfAiHelperCategoryUid, 
       
   704                                        KWsfAiHelperExitCodeKey ) );
       
   705     CleanupClosePushL( aiHelperApp );
       
   706     
       
   707     aiHelperApp.Subscribe( waiter->iStatus );
       
   708 
       
   709     LOG_WRITE("launching...");
       
   710     iModel->LaunchHelperApplicationL( aInfo, ETrue, EFalse );
       
   711     waiter->WaitForRequest();
       
   712     
       
   713     TInt exitCode( KErrNone );
       
   714     aiHelperApp.Get( exitCode );
       
   715     
       
   716     LOG_WRITEF("AiHelper returned %d", exitCode );   
       
   717     
       
   718     if ( exitCode == KErrNone )
       
   719         {
       
   720         User::LeaveIfError( aiHelperApp.Attach( 
       
   721                                        KWsfAiHelperCategoryUid, 
       
   722                                        KWsfAiHelperIapIdKey ) );
       
   723         TInt iapId( 0 );
       
   724         aiHelperApp.Get( iapId );
       
   725         aInfo.iIapId = TUint32( iapId );
       
   726         LOG_WRITEF("AiHelper iap id = %d", iapId );
       
   727         }
       
   728     else
       
   729         {
       
   730         User::Leave( exitCode );
       
   731         }
       
   732     
       
   733     CleanupStack::PopAndDestroy( &aiHelperApp );
       
   734     CleanupStack::PopAndDestroy( waiter );
       
   735     }
       
   736 
       
   737 
       
   738 // --------------------------------------------------------------------------
       
   739 // TWsfAiController::ContinueBrowsingL
       
   740 // --------------------------------------------------------------------------
       
   741 //
       
   742 void TWsfAiController::ContinueBrowsingL()
       
   743     {
       
   744     LOG_ENTERFN( "TWsfAiController::ContinueBrowsingL" );
       
   745 
       
   746     _ASS_D( iModel );
       
   747 
       
   748     iModel->ContinueBrowsingL();
       
   749     }
       
   750 
       
   751 
       
   752 // --------------------------------------------------------------------------
       
   753 // TWsfAiController::LaunchSearchDialogL
       
   754 // --------------------------------------------------------------------------
       
   755 //
       
   756 TBool TWsfAiController::LaunchSearchDialogL( TWsfWlanInfo& aInfo )
       
   757     {
       
   758     LOG_ENTERFN( "TWsfAiController::LaunchSearchDialogL" );
       
   759     
       
   760     _ASS_D( iAiModel );
       
   761     _ASS_D( iUi );
       
   762     
       
   763     MWsfAiUiObserver* temp = iUi;
       
   764     TInt selectedWlan( KFirstItemArrayIndex );
       
   765     TBool success( EFalse );
       
   766 
       
   767     TRAPD( err, success = DoLaunchSearchDialogL( selectedWlan ) );
       
   768     
       
   769     iUi = temp;
       
   770     User::LeaveIfError( err );
       
   771     
       
   772     if ( success )
       
   773         {
       
   774         if ( iAiModel->Connected() )
       
   775             {
       
   776             // show the error note of double connections
       
   777             HBufC* txt = StringLoader::LoadLC( 
       
   778                                  R_QTN_WLAN_INFO_CONNECTION_ALREADY_ACTIVE );
       
   779             
       
   780             CAknErrorNote* errorNote = new (ELeave) CAknErrorNote;
       
   781             errorNote->ExecuteLD( *txt );
       
   782             
       
   783             CleanupStack::PopAndDestroy( txt );
       
   784             success = EFalse;
       
   785             }
       
   786         else
       
   787             {
       
   788             // check that the model still has the entry
       
   789             if ( selectedWlan < iAiModel->GetInfoArray()->Count() )
       
   790                 {
       
   791                 // get wlan info
       
   792                 aInfo = *iAiModel->GetInfoArray()->At( selectedWlan );
       
   793                 }
       
   794             else
       
   795                 {
       
   796                 // other unlisted item was selected
       
   797                 }
       
   798             }
       
   799         }
       
   800         
       
   801     RefreshUiL();
       
   802     
       
   803     return success;
       
   804     }
       
   805 
       
   806 
       
   807 // --------------------------------------------------------------------------
       
   808 // TWsfAiController::DoLaunchSearchDialogL
       
   809 // --------------------------------------------------------------------------
       
   810 //
       
   811 TBool TWsfAiController::DoLaunchSearchDialogL( TInt& aSelectedItem )
       
   812     {
       
   813     LOG_ENTERFN( "TWsfAiController::DoLaunchSearchDialogL" );
       
   814     
       
   815     _ASS_D( iAiModel );
       
   816     _ASS_D( iModel );
       
   817     
       
   818     CWsfSearchWlansDialog* dialog = CWsfSearchWlansDialog::NewL( 
       
   819                                                              aSelectedItem );
       
   820     dialog->PrepareLC( R_QTN_PLUGIN_SEARCH_WLAN_NETWORKS );
       
   821 
       
   822     // ownership of the icon array is passed
       
   823     CAknIconArray* icons = CWsfIconArrayCreator::CreateArrayL();
       
   824     CleanupStack::PushL( icons );
       
   825     iAiModel->AppendBrandIconsL( *icons );
       
   826     dialog->SetIconArrayL( icons ); // ownership of the icon array is passed
       
   827     CleanupStack::Pop( icons );
       
   828 
       
   829     // the dialog is ready to receive data...
       
   830     iUi = dialog;           
       
   831     iUi->UpdateHotSpotsL( iAiModel->FormatWlanListL( iModel->GetWlanListL(), EFalse ),
       
   832                           KFirstItemArrayIndex );
       
   833     
       
   834     return dialog->RunLD();
       
   835     }
       
   836     
       
   837 
       
   838 // --------------------------------------------------------------------------
       
   839 // TWsfAiController::RefreshUiL
       
   840 // --------------------------------------------------------------------------
       
   841 //
       
   842 void TWsfAiController::RefreshUiL()
       
   843     {
       
   844     LOG_ENTERFN( "TWsfAiController::RefreshUiL" );
       
   845 
       
   846     _ASS_D( iAiModel );
       
   847     _ASS_D( iUi );
       
   848 
       
   849     if ( !iInfoArray )
       
   850         {
       
   851         return;
       
   852         }
       
   853     
       
   854     MDesCArray* data = iUi->MultilineControl() ? 
       
   855             iAiModel->FormatWlanListL( iInfoArray, ETrue ): 
       
   856             iAiModel->FormatSingleLineWlanListL( iInfoArray );
       
   857             
       
   858     TInt currentItem = ( iModel->IsConnecting() )? 
       
   859                           KSuppressRefreshIndex: KFirstItemArrayIndex;  
       
   860 
       
   861     iUi->UpdateHotSpotsL( data, currentItem );    
       
   862     }
       
   863 
       
   864 
       
   865 // --------------------------------------------------------------------------
       
   866 // TWsfAiController::EnableScanL
       
   867 // --------------------------------------------------------------------------
       
   868 //
       
   869 void TWsfAiController::EnableScanL()
       
   870     {
       
   871     LOG_ENTERFN( "TWsfAiController::EnableScanL" );
       
   872     
       
   873     _ASS_D( iAiModel );
       
   874     _ASS_D( iModel );
       
   875     _ASS_D( iUi );
       
   876     
       
   877     if ( iAiModel->ScanningOn() )
       
   878         {
       
   879         return;
       
   880         }
       
   881     iModel->EnableScanL();
       
   882     iAiModel->SetScanningOn();
       
   883     iDbObserver->EnableScanL();
       
   884 
       
   885     MDesCArray *data = iAiModel->FormatRefreshingL();
       
   886     iUi->UpdateHotSpotsL( data, KFirstItemArrayIndex );
       
   887     }
       
   888 
       
   889 
       
   890 // --------------------------------------------------------------------------
       
   891 // TWsfAiController::DisableScanL
       
   892 // --------------------------------------------------------------------------
       
   893 //
       
   894 void TWsfAiController::DisableScanL()
       
   895     {
       
   896     LOG_ENTERFN( "TWsfAiController::DisableScanL" );
       
   897     
       
   898     _ASS_D( iAiModel );
       
   899     _ASS_D( iModel );
       
   900     _ASS_D( iUi );
       
   901 
       
   902     if ( !iAiModel->ScanningOn() )
       
   903         {
       
   904         return;
       
   905         } 
       
   906     iModel->DisableScanL();
       
   907     iAiModel->SetScanningOff();
       
   908     iDbObserver->DisableScanL();
       
   909     iUi->DisplayEngineOffL();
       
   910     }
       
   911 
       
   912 
       
   913 // --------------------------------------------------------------------------
       
   914 // TWsfAiController::DisconnectL
       
   915 // --------------------------------------------------------------------------
       
   916 //
       
   917 void TWsfAiController::DisconnectL()
       
   918     {
       
   919     LOG_ENTERFN( "TWsfAiController::DisconnectL" );
       
   920     
       
   921     _ASS_D( iModel );
       
   922 
       
   923     iModel->DisconnectL();  
       
   924     }
       
   925 
       
   926 
       
   927 // --------------------------------------------------------------------------
       
   928 // TWsfAiController::DoHandleEngineErrorL
       
   929 // --------------------------------------------------------------------------
       
   930 //
       
   931 void TWsfAiController::DoHandleEngineErrorL( TInt aError )
       
   932     {
       
   933     LOG_ENTERFN( "TWsfAiController::DoHandleEngineErrorL" );
       
   934     // start by freeing some resources... 
       
   935     // we could start by freeing wlan search results
       
   936     _ASS_D( iAiModel );
       
   937 
       
   938     // show error to user...
       
   939     CEikonEnv::Static()->ResolveError( aError );
       
   940     }
       
   941 
       
   942 
       
   943 // ---------------------------------------------------------------------------
       
   944 // TWsfAiController::IsWlanUsedByBrowserL
       
   945 // ---------------------------------------------------------------------------
       
   946 //
       
   947 TBool TWsfAiController::IsWlanUsedByBrowserL()
       
   948     {
       
   949     LOG_ENTERFN( "CWsfMainView::IsWlanUsedByBrowserL" );
       
   950     
       
   951     _ASS_D( iAiModel );
       
   952     
       
   953     const TInt KBrowserUid = 0x10008D39;
       
   954     TUid id( TUid::Uid( KBrowserUid ) );
       
   955     
       
   956     // Check if the Browser application is already running.
       
   957     TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
       
   958     TApaTask task = taskList.FindApp( id );
       
   959     TBool isWlanUsed( EFalse );
       
   960     
       
   961 #ifndef __WINS__
       
   962 
       
   963     if ( task.Exists() )
       
   964         {
       
   965         LOG_WRITE( "The Browser is running." );
       
   966         // The Browser is already running.
       
   967         // Check if the selected WLAN is connected.
       
   968         TBool connected( iAiModel->Connected() );
       
   969         LOG_WRITEF("Connected? %d", connected);
       
   970 
       
   971         if ( connected )
       
   972             {
       
   973             RConnectionMonitor connectionMonitor;
       
   974             connectionMonitor.ConnectL();
       
   975             // We have to check if the Browser using the selected 
       
   976             // connection.
       
   977             // We have get the connectiond ID first.
       
   978             CWsfActiveWaiter* waiter = CWsfActiveWaiter::NewL();
       
   979             CleanupStack::PushL( waiter );
       
   980             
       
   981             // first call, need to get the connection parameters
       
   982             TUint connectionCount( 0 );
       
   983             
       
   984             connectionMonitor.GetConnectionCount( connectionCount, 
       
   985                                                   waiter->iStatus );
       
   986             waiter->WaitForRequest();
       
   987             
       
   988             // find the connection with WLAN bearer 
       
   989             // that will be the selected WLAN
       
   990             TUint connectionId( 0 );
       
   991             for ( TUint i = 1; i <= connectionCount; ++i )
       
   992                 {
       
   993                 TUint tmpConnectionId( 0 );
       
   994                 TUint subConnectionCount( 0 );
       
   995                 TConnMonBearerType bearerType( EBearerUnknown );
       
   996                 
       
   997                 connectionMonitor.GetConnectionInfo( i, 
       
   998                                                      tmpConnectionId, 
       
   999                                                      subConnectionCount );
       
  1000                 connectionMonitor.GetIntAttribute( tmpConnectionId, 
       
  1001                                                    0, 
       
  1002                                                    KBearer, 
       
  1003                                                    ( TInt& )bearerType, 
       
  1004                                                    waiter->iStatus );
       
  1005                 waiter->WaitForRequest();
       
  1006                 if ( bearerType == EBearerWLAN )
       
  1007                     {
       
  1008                     connectionId = tmpConnectionId;
       
  1009                     break;
       
  1010                     }
       
  1011                 }
       
  1012             // Now we have the connectiond ID.
       
  1013             LOG_WRITEF( "connectionId: %d", connectionId );
       
  1014             
       
  1015             TInt count( 0 );
       
  1016             TConnMonClientEnumBuf clientBuf;
       
  1017                 
       
  1018             connectionMonitor.GetPckgAttribute( connectionId,
       
  1019                                                 0,
       
  1020                                                 KClientInfo,
       
  1021                                                 clientBuf,
       
  1022                                                 waiter->iStatus );
       
  1023             waiter->WaitForRequest();
       
  1024             if ( !waiter->iStatus.Int() )
       
  1025                 {
       
  1026                 count = clientBuf().iCount;
       
  1027                 }
       
  1028             
       
  1029             RApaLsSession appSess;
       
  1030             TApaAppInfo appInfo;
       
  1031             
       
  1032             // The connection could be shared by several applications
       
  1033             User::LeaveIfError( appSess.Connect() );
       
  1034             
       
  1035             for ( TUint i = 0; i < count; i++ )
       
  1036                 {
       
  1037                 appInfo.iCaption.Zero();
       
  1038                 TInt result = appSess.GetAppInfo( appInfo, 
       
  1039                                                   clientBuf().iUid[i] );
       
  1040                 
       
  1041                 LOG_WRITEF( "result: %d", result ); 
       
  1042                 LOG_WRITEF( "iClientInfo.iUid[i].iUid: %x", 
       
  1043                              clientBuf().iUid[i].iUid );
       
  1044                 
       
  1045                 if ( clientBuf().iUid[i].iUid == KBrowserUid )
       
  1046                     {
       
  1047                     isWlanUsed = ETrue;
       
  1048                     }
       
  1049                 }
       
  1050             CleanupStack::PopAndDestroy( waiter );
       
  1051             appSess.Close();
       
  1052             connectionMonitor.Close();
       
  1053             }                
       
  1054         }
       
  1055     else 
       
  1056         {
       
  1057         LOG_WRITE( "No Browser running." );
       
  1058         }
       
  1059         
       
  1060 #endif // __WINS__
       
  1061     
       
  1062     LOG_WRITEF( "isWlanUsedByBrowser: %d", isWlanUsed ); 
       
  1063     return isWlanUsed;
       
  1064     }
       
  1065 
       
  1066 
       
  1067 // --------------------------------------------------------------------------
       
  1068 // TWsfAiController::HandleMskIfOfflineL
       
  1069 // --------------------------------------------------------------------------
       
  1070 //
       
  1071 void TWsfAiController::HandleMskIfOfflineL()
       
  1072     {
       
  1073     LOG_ENTERFN( "TWsfAiController::HandleMskIfOfflineL" );
       
  1074     
       
  1075     // create the dialog with options
       
  1076     TInt selectedMode( 0 );
       
  1077     CAknListQueryDialog* listQuery = new (ELeave) CAknListQueryDialog( 
       
  1078                                                            &selectedMode );
       
  1079     listQuery->PrepareLC( R_QTN_AIPLUGIN_OPTIONS_OFFLINE );
       
  1080 
       
  1081     if ( !listQuery->RunLD() )
       
  1082         {
       
  1083         // cancelled
       
  1084         return;
       
  1085         }
       
  1086     
       
  1087     CWsfWlanInfoArray* wlanArray = iAiModel->GetInfoArray(); 
       
  1088     
       
  1089     
       
  1090     switch ( selectedMode )
       
  1091         {
       
  1092         case EAiOfflineStartBrowsing:
       
  1093             {
       
  1094             // Start web browsing was selected
       
  1095             if ( !wlanArray->Count() ||
       
  1096                  !wlanArray->At( KFirstItemArrayIndex )->Known() )
       
  1097                 {
       
  1098                 // no known networks, let the user choose one
       
  1099                 TWsfWlanInfo info;
       
  1100                 
       
  1101                 if ( LaunchSearchDialogL( info ) )
       
  1102                     {
       
  1103                     StartBrowsingL( info );
       
  1104                     }
       
  1105                 }
       
  1106             else
       
  1107                 {
       
  1108                 // there are known networks
       
  1109                 StartBrowsingL( *wlanArray->At( KFirstItemArrayIndex ) );
       
  1110                 }
       
  1111             
       
  1112             break;
       
  1113             }
       
  1114             
       
  1115         case EAiOfflineConnect:
       
  1116             {
       
  1117             // Connect was selected
       
  1118             if ( !wlanArray->Count() ||
       
  1119                  !wlanArray->At( KFirstItemArrayIndex )->Known() )
       
  1120                 {
       
  1121                 // no known networks, let the user choose one
       
  1122                 TWsfWlanInfo info;
       
  1123                 
       
  1124                 if ( LaunchSearchDialogL( info ) )
       
  1125                     {
       
  1126                     ConnectL( info, ETrue );
       
  1127                     }
       
  1128                 }
       
  1129             else
       
  1130                 {
       
  1131                 // there are known networks
       
  1132                 ConnectL( *wlanArray->At( KFirstItemArrayIndex ), ETrue );
       
  1133                 }
       
  1134             
       
  1135             break;
       
  1136             }
       
  1137             
       
  1138         case EAiOfflineSearchWlans:
       
  1139             {
       
  1140             // Search for wlans was selected
       
  1141             if ( !wlanArray || !wlanArray->Count() )
       
  1142                 {
       
  1143                 // there are no available networks
       
  1144                 HBufC* infoText = StringLoader::LoadLC( 
       
  1145                                           R_QTN_WLAN_INFO_NO_NETWORKS_FOUND ); 
       
  1146                 CAknInformationNote* infoNote = new (ELeave) 
       
  1147                                                  CAknInformationNote( ETrue );
       
  1148                 infoNote->ExecuteLD( *infoText ); 
       
  1149                 CleanupStack::PopAndDestroy( infoText );
       
  1150                 }
       
  1151 
       
  1152             // launch the search dialog
       
  1153             TWsfWlanInfo info;
       
  1154             
       
  1155             if ( LaunchSearchDialogL( info ) )
       
  1156                 {
       
  1157                 ConnectL( info, ETrue );
       
  1158                 }
       
  1159 
       
  1160             break;
       
  1161             }
       
  1162             
       
  1163         case EAiOfflineDisableScan:
       
  1164             {
       
  1165             // disable the scan
       
  1166             DisableScanL();
       
  1167             break;
       
  1168             }
       
  1169             
       
  1170         default:
       
  1171             {
       
  1172             }
       
  1173 
       
  1174         }
       
  1175     }
       
  1176 
       
  1177 
       
  1178 
       
  1179 // --------------------------------------------------------------------------
       
  1180 // TWsfAiController::HandleMskIfConnectedL
       
  1181 // --------------------------------------------------------------------------
       
  1182 //
       
  1183 void TWsfAiController::HandleMskIfConnectedL()
       
  1184     {
       
  1185     LOG_ENTERFN( "TWsfAiController::HandleMskIfConnectedL" );
       
  1186     
       
  1187     _ASS_D( iModel );
       
  1188     
       
  1189     TInt selectedMode( 0 );
       
  1190     CAknListQueryDialog* listQuery = new (ELeave) CAknListQueryDialog( 
       
  1191                                                            &selectedMode );
       
  1192     listQuery->PrepareLC( R_QTN_AIPLUGIN_OPTIONS_CONNECTED );
       
  1193     
       
  1194     if ( listQuery->RunLD() )
       
  1195         {
       
  1196         if ( selectedMode == EAiConnectedStartBrowsing )
       
  1197             {
       
  1198             StartBrowsingL( iConnectedWlan );
       
  1199             }
       
  1200         else if ( selectedMode == EAiConnectedDisconnect )
       
  1201             {
       
  1202             // disconnect wlan
       
  1203             iModel->DisconnectL();        
       
  1204             }
       
  1205         }
       
  1206     }
       
  1207 
       
  1208 
       
  1209 // --------------------------------------------------------------------------
       
  1210 // TWsfAiController::HandleMskIfConnectingL
       
  1211 // --------------------------------------------------------------------------
       
  1212 //
       
  1213 void TWsfAiController::HandleMskIfConnectingL()
       
  1214     {
       
  1215     LOG_ENTERFN( "TWsfAiController::HandleMskIfConnectingL" );
       
  1216     
       
  1217     _ASS_D( iModel );
       
  1218     
       
  1219     TInt selectedMode( 0 );
       
  1220     CAknListQueryDialog* listQuery = new (ELeave) CAknListQueryDialog( 
       
  1221                                                            &selectedMode );
       
  1222     listQuery->PrepareLC( R_QTN_AIPLUGIN_OPTIONS_CONNECTING );
       
  1223     
       
  1224     if ( listQuery->RunLD() )
       
  1225         {
       
  1226         if ( selectedMode == EAiConnectingDisconnect )
       
  1227             {
       
  1228             if ( iModel->IsConnectedL() )
       
  1229                 {
       
  1230                 // disconnect wlan
       
  1231                 iModel->DisconnectL();
       
  1232                 }
       
  1233             else
       
  1234                 {
       
  1235                 // disconnect wlan
       
  1236                 iModel->AbortConnectingL();  
       
  1237                 }
       
  1238             ConnectingFinishedL( KErrCancel );
       
  1239             }
       
  1240         }
       
  1241     }
       
  1242 
       
  1243 
       
  1244 // --------------------------------------------------------------------------
       
  1245 // TWsfAiController::HandleMskIfBrowsingL
       
  1246 // --------------------------------------------------------------------------
       
  1247 //
       
  1248 void TWsfAiController::HandleMskIfBrowsingL()
       
  1249     {
       
  1250     LOG_ENTERFN( "TWsfAiController::HandleMskIfBrowsingL" );
       
  1251     
       
  1252     _ASS_D( iModel );
       
  1253     
       
  1254     TInt selectedMode( KFirstItemArrayIndex );
       
  1255     CAknListQueryDialog* listQuery = new (ELeave) CAknListQueryDialog( 
       
  1256                                                            &selectedMode );
       
  1257     listQuery->PrepareLC( R_QTN_AIPLUGIN_OPTIONS_BROWSING );
       
  1258 
       
  1259     if ( listQuery->RunLD() )
       
  1260         {
       
  1261         if ( selectedMode == EAiBrowsingContinueBrowsing )
       
  1262             {
       
  1263             // launch the browser...
       
  1264             ContinueBrowsingL();
       
  1265             }
       
  1266         else if ( selectedMode == EAiBrowsingDisconnect )
       
  1267             {
       
  1268             // disconnect wlan
       
  1269             iModel->DisconnectL();
       
  1270             }
       
  1271         }
       
  1272     }
       
  1273 
       
  1274 // --------------------------------------------------------------------------
       
  1275 // TWsfAiController::RefreshRefreshingL
       
  1276 // --------------------------------------------------------------------------
       
  1277 //
       
  1278 void TWsfAiController::RefreshRefreshingL()
       
  1279 	{
       
  1280 	LOG_ENTERFN( "TWsfAiController::RefreshRefreshingL" );
       
  1281 	MDesCArray *data = iAiModel->FormatRefreshingL();
       
  1282     iUi->UpdateViewL( data );
       
  1283 	}
       
  1284 
       
  1285 // --------------------------------------------------------------------------
       
  1286 // TWsfAiController::RefreshConnectingL
       
  1287 // --------------------------------------------------------------------------
       
  1288 //
       
  1289 void TWsfAiController::RefreshConnectingL()
       
  1290     {
       
  1291     LOG_ENTERFN( "TWsfAiController::RefreshConnectingL" );
       
  1292     MDesCArray *data = iAiModel->FormatConnectingL();
       
  1293     iUi->UpdateViewL( data );
       
  1294     }
       
  1295 
       
  1296 // End of file