wlanutilities/wlansniffer/aiplugin/src/wsfaicontroller.cpp
branchRCL_3
changeset 12 981afc7d3841
parent 11 8b0eae1b1d71
child 13 858c6c491d0e
equal deleted inserted replaced
11:8b0eae1b1d71 12:981afc7d3841
    64 
    64 
    65 
    65 
    66 //  LOCAL DEFINITIONS
    66 //  LOCAL DEFINITIONS
    67 LOCAL_D const TInt KFirstItemArrayIndex = 0;
    67 LOCAL_D const TInt KFirstItemArrayIndex = 0;
    68 
    68 
    69 // Category UID of AiHelper property
    69 // index value to suppress 1 second refreshing state
    70 static const TUid KWsfAiHelperCategoryUid = { 0x10281CEB };
       
    71 
       
    72 // key numbers within the property 
       
    73 static const TUint KWsfAiHelperExitCodeKey = 0;
       
    74 static const TUint KWsfAiHelperIapIdKey = 1;
       
    75 static const TInt KSuppressRefreshIndex = 1024;
    70 static const TInt KSuppressRefreshIndex = 1024;
    76 
    71 
    77 
    72 
    78 
    73 
    79 // --------------------------------------------------------------------------
    74 // --------------------------------------------------------------------------
   225     
   220     
   226     LOG_WRITEF( "Connected = %d", iConnectedWlan.Connected() );
   221     LOG_WRITEF( "Connected = %d", iConnectedWlan.Connected() );
   227     
   222     
   228     MDesCArray* data = iAiModel->FormatSingleLineWlanListL( iInfoArray );
   223     MDesCArray* data = iAiModel->FormatSingleLineWlanListL( iInfoArray );
   229     
   224     
   230     // index value to suppress 1 second refreshing state
       
   231     const TInt KSuppressRefreshIndex = 1024;
       
   232     
       
   233     iUi->UpdateHotSpotsL( data, KSuppressRefreshIndex );    
   225     iUi->UpdateHotSpotsL( data, KSuppressRefreshIndex );    
   234     }
   226     }
   235 
   227 
   236 
   228 
   237 // --------------------------------------------------------------------------
   229 // --------------------------------------------------------------------------
   286                 // browser is not running or not using the WLAN
   278                 // browser is not running or not using the WLAN
   287                 HandleMskIfConnectedL();
   279                 HandleMskIfConnectedL();
   288                 }
   280                 }
   289             }
   281             }
   290         }
   282         }
   291     }
       
   292 
       
   293 
       
   294 // --------------------------------------------------------------------------
       
   295 // TWsfAiController::DismissDialogsL
       
   296 // --------------------------------------------------------------------------
       
   297 //
       
   298 void TWsfAiController::DismissDialogsL()
       
   299     {
       
   300     LOG_ENTERFN("TWsfAiController::DismissDialogsL" );
       
   301     TKeyEvent key;
       
   302     key.iCode = EKeyEscape;
       
   303     key.iModifiers = 0;
       
   304     iEnv->SimulateKeyEventL( key, EEventKey );
       
   305     }
   283     }
   306 
   284 
   307 
   285 
   308 // --------------------------------------------------------------------------
   286 // --------------------------------------------------------------------------
   309 // TWsfAiController::WlanListChangedL
   287 // TWsfAiController::WlanListChangedL
   526     // make sure we don't show connecting stuff forever
   504     // make sure we don't show connecting stuff forever
   527     CleanupStack::PushL( TCleanupItem( CleanUpConnectingL, this ) );
   505     CleanupStack::PushL( TCleanupItem( CleanUpConnectingL, this ) );
   528     
   506     
   529     if ( !iUsedInfo.Connected() )
   507     if ( !iUsedInfo.Connected() )
   530         {
   508         {
   531         ConnectL( iUsedInfo, EFalse );
   509         ConnectL( iUsedInfo, EFalse, EFalse );
   532         }
   510         }
   533     else
   511     else
   534         {
   512         {
   535         LOG_WRITE("Start browser to connected network...");
   513         LOG_WRITE("Start browser to connected network...");
   536         iShouldConnectOnly = EFalse;
   514         iShouldConnectOnly = EFalse;
   572 
   550 
   573 // --------------------------------------------------------------------------
   551 // --------------------------------------------------------------------------
   574 // TWsfAiController::ConnectL
   552 // TWsfAiController::ConnectL
   575 // --------------------------------------------------------------------------
   553 // --------------------------------------------------------------------------
   576 //
   554 //
   577 void TWsfAiController::ConnectL( TWsfWlanInfo& aInfo, TBool aShoulConnectOnly )
   555 void TWsfAiController::ConnectL( TWsfWlanInfo& aInfo, TBool aConnectOnly, 
       
   556                                  TBool aTestAccessPoint )
   578     {
   557     {
   579     LOG_ENTERFN( "TWsfAiController::ConnectL" );
   558     LOG_ENTERFN( "TWsfAiController::ConnectL" );
   580     
   559     
   581     _ASS_D( iModel );
   560     _ASS_D( iModel );
   582     iTestAccessPoint = EFalse;
   561     iTestAccessPoint = aTestAccessPoint;
   583     iShouldConnectOnly = aShoulConnectOnly;
   562     iShouldConnectOnly = aConnectOnly;
   584     iUsedInfo = aInfo;
   563     iUsedInfo = aInfo;
   585     
   564     
   586     // Prevent connections to ad-hoc + WPA 
   565     // Prevent connections to ad-hoc + WPA 
   587     if ( iUsedInfo.iNetMode == CMManager::EAdhoc 
   566     if ( iUsedInfo.iNetMode == CMManager::EAdhoc 
   588             && iUsedInfo.iSecurityMode == CMManager::EWlanSecModeWpa )
   567             && iUsedInfo.iSecurityMode == CMManager::EWlanSecModeWpa )
   627         }
   606         }
   628     else if ( !iUsedInfo.iIapId )
   607     else if ( !iUsedInfo.iIapId )
   629         {
   608         {
   630         // let the helper app do the query if necessary
   609         // let the helper app do the query if necessary
   631         LOG_WRITE("AiHelper needs to be launched");
   610         LOG_WRITE("AiHelper needs to be launched");
   632         LaunchAiHelperAppL( iUsedInfo );
       
   633         ConnectingL( iUsedInfo.iIapId );
       
   634         iTestAccessPoint = ETrue;
   611         iTestAccessPoint = ETrue;
       
   612         iActiveWrappers->LaunchHelperApplicationL( iUsedInfo, 
       
   613                                                    iShouldConnectOnly,
       
   614                                                    iTestAccessPoint );
   635         }
   615         }
   636     
   616     
   637     // Connect
   617     // Connect
   638     if ( iUsedInfo.iIapId )
   618     if ( iUsedInfo.iIapId )
   639         {
   619         {
   644             }
   624             }
   645         else
   625         else
   646             {
   626             {
   647             iActiveWrappers->Connect( iUsedInfo.iIapId, EIapPersistent );
   627             iActiveWrappers->Connect( iUsedInfo.iIapId, EIapPersistent );
   648             }
   628             }
   649 
       
   650         }
   629         }
   651     // pop cleanup item 
   630     // pop cleanup item 
   652     CleanupStack::Pop();
   631     CleanupStack::Pop();
   653     }
   632     }
   654 
   633 
   662     LOG_ENTERFN( "TWsfAiController::CleanUpConnectingL" );
   641     LOG_ENTERFN( "TWsfAiController::CleanUpConnectingL" );
   663     TWsfAiController* self = static_cast<TWsfAiController*>( aPtr );
   642     TWsfAiController* self = static_cast<TWsfAiController*>( aPtr );
   664     self->iModel->SetConnecting( EFalse );
   643     self->iModel->SetConnecting( EFalse );
   665     self->iAiModel->SetConnecting( EFalse );
   644     self->iAiModel->SetConnecting( EFalse );
   666     TRAP_IGNORE( self->RefreshUiL());
   645     TRAP_IGNORE( self->RefreshUiL());
   667     }
       
   668 
       
   669 
       
   670 // --------------------------------------------------------------------------
       
   671 // TWsfAiController::LaunchAiHelperAppL
       
   672 // --------------------------------------------------------------------------
       
   673 //
       
   674 void TWsfAiController::LaunchAiHelperAppL( TWsfWlanInfo& aInfo )
       
   675     {
       
   676     LOG_ENTERFN( "TWsfAiController::LaunchAiHelperAppL" );
       
   677 
       
   678     CWsfActiveWaiter* waiter = CWsfActiveWaiter::NewL();
       
   679     CleanupStack::PushL( waiter );
       
   680     
       
   681     RProperty aiHelperApp;
       
   682     User::LeaveIfError( aiHelperApp.Attach( 
       
   683                                        KWsfAiHelperCategoryUid, 
       
   684                                        KWsfAiHelperExitCodeKey ) );
       
   685     CleanupClosePushL( aiHelperApp );
       
   686     
       
   687     aiHelperApp.Subscribe( waiter->iStatus );
       
   688 
       
   689     LOG_WRITE("launching...");
       
   690     iModel->LaunchHelperApplicationL( aInfo, ETrue, EFalse );
       
   691     waiter->WaitForRequest();
       
   692     
       
   693     TInt exitCode( KErrNone );
       
   694     aiHelperApp.Get( exitCode );
       
   695     
       
   696     LOG_WRITEF("AiHelper returned %d", exitCode );   
       
   697     
       
   698     if ( exitCode == KErrNone )
       
   699         {
       
   700         User::LeaveIfError( aiHelperApp.Attach( 
       
   701                                        KWsfAiHelperCategoryUid, 
       
   702                                        KWsfAiHelperIapIdKey ) );
       
   703         TInt iapId( 0 );
       
   704         aiHelperApp.Get( iapId );
       
   705         aInfo.iIapId = TUint32( iapId );
       
   706         LOG_WRITEF("AiHelper iap id = %d", iapId );
       
   707         }
       
   708     else
       
   709         {
       
   710         User::Leave( exitCode );
       
   711         }
       
   712     
       
   713     CleanupStack::PopAndDestroy( &aiHelperApp );
       
   714     CleanupStack::PopAndDestroy( waiter );
       
   715     }
   646     }
   716 
   647 
   717 
   648 
   718 // --------------------------------------------------------------------------
   649 // --------------------------------------------------------------------------
   719 // TWsfAiController::ContinueBrowsingL
   650 // TWsfAiController::ContinueBrowsingL
  1090                 // no known networks, let the user choose one
  1021                 // no known networks, let the user choose one
  1091                 TWsfWlanInfo info;
  1022                 TWsfWlanInfo info;
  1092                 
  1023                 
  1093                 if ( LaunchSearchDialogL( info ) )
  1024                 if ( LaunchSearchDialogL( info ) )
  1094                     {
  1025                     {
  1095                     ConnectL( info, ETrue );
  1026                     ConnectL( info, ETrue, EFalse );
  1096                     }
  1027                     }
  1097                 }
  1028                 }
  1098             else
  1029             else
  1099                 {
  1030                 {
  1100                 // there are known networks
  1031                 // there are known networks
  1101                 ConnectL( *wlanArray->At( KFirstItemArrayIndex ), ETrue );
  1032                 ConnectL( *wlanArray->At( KFirstItemArrayIndex ), ETrue, 
       
  1033                           EFalse );
  1102                 }
  1034                 }
  1103             
  1035             
  1104             break;
  1036             break;
  1105             }
  1037             }
  1106             
  1038             
  1118             // launch the search dialog
  1050             // launch the search dialog
  1119             TWsfWlanInfo info;
  1051             TWsfWlanInfo info;
  1120             
  1052             
  1121             if ( LaunchSearchDialogL( info ) )
  1053             if ( LaunchSearchDialogL( info ) )
  1122                 {
  1054                 {
  1123                 ConnectL( info, ETrue );
  1055                 ConnectL( info, ETrue, EFalse );
  1124                 }
  1056                 }
  1125 
  1057 
  1126             break;
  1058             break;
  1127             }
  1059             }
  1128             
  1060             
  1241 // --------------------------------------------------------------------------
  1173 // --------------------------------------------------------------------------
  1242 //
  1174 //
  1243 void TWsfAiController::RefreshRefreshingL()
  1175 void TWsfAiController::RefreshRefreshingL()
  1244 	{
  1176 	{
  1245 	LOG_ENTERFN( "TWsfAiController::RefreshRefreshingL" );
  1177 	LOG_ENTERFN( "TWsfAiController::RefreshRefreshingL" );
  1246 	MDesCArray *data = iAiModel->FormatRefreshingL();
  1178 	if ( !iUi->MultilineControl() )
  1247     iUi->UpdateViewL( data );
  1179 	    {
       
  1180         MDesCArray *data = iAiModel->FormatRefreshingL();
       
  1181         iUi->UpdateViewL( data );
       
  1182 	    }
       
  1183 	else
       
  1184 	    {
       
  1185         LOG_WRITE( "Multiline control in use - no update done" );
       
  1186 	    }
  1248 	}
  1187 	}
  1249 
  1188 
  1250 // --------------------------------------------------------------------------
  1189 // --------------------------------------------------------------------------
  1251 // TWsfAiController::RefreshConnectingL
  1190 // TWsfAiController::RefreshConnectingL
  1252 // --------------------------------------------------------------------------
  1191 // --------------------------------------------------------------------------
  1253 //
  1192 //
  1254 void TWsfAiController::RefreshConnectingL()
  1193 void TWsfAiController::RefreshConnectingL()
  1255     {
  1194     {
  1256     LOG_ENTERFN( "TWsfAiController::RefreshConnectingL" );
  1195     LOG_ENTERFN( "TWsfAiController::RefreshConnectingL" );
  1257     MDesCArray *data = iAiModel->FormatConnectingL();
  1196     if ( !iUi->MultilineControl() )
  1258     iUi->UpdateViewL( data );
  1197         {
       
  1198         MDesCArray *data = iAiModel->FormatConnectingL();
       
  1199         iUi->UpdateViewL( data );
       
  1200         }
       
  1201     else       
       
  1202         {
       
  1203         LOG_WRITE( "Multiline control in use - no update done" );
       
  1204         }
  1259     }
  1205     }
  1260 
  1206 
  1261 // End of file
  1207 // End of file