wlanutilities/wlansniffer/model/src/wsfmodel.cpp
branchRCL_3
changeset 10 dff6ebfd236f
parent 2 6e4b6261703d
child 11 8b0eae1b1d71
equal deleted inserted replaced
8:c2bc3f8c7777 10:dff6ebfd236f
    94 // CWsfModel::~CWsfModel
    94 // CWsfModel::~CWsfModel
    95 // ----------------------------------------------------------------------------
    95 // ----------------------------------------------------------------------------
    96 //
    96 //
    97 EXPORT_C CWsfModel::~CWsfModel()
    97 EXPORT_C CWsfModel::~CWsfModel()
    98     {
    98     {
       
    99     LOG_ENTERFN( "CWsfModel::~CWsfModel" );
       
   100     if ( iIct )
       
   101         {
       
   102         LOG_WRITE( "ict cancel" );
       
   103         TRAP_IGNORE( iIct->CancelStartL() );
       
   104         delete iIct;
       
   105         iIct = NULL;
       
   106         }
       
   107     if ( iIctWait.IsStarted() )
       
   108         {
       
   109         LOG_WRITE( "ict wait cancel" );
       
   110         iIctWait.AsyncStop();
       
   111         }
    99     iSession.CancelNotifyEvent();
   112     iSession.CancelNotifyEvent();
   100     iSession.Close();
   113     iSession.Close();
   101     delete iScreenSaverWatcher;
   114     delete iScreenSaverWatcher;
   102     delete iArray;   
   115     delete iArray;   
   103     delete iObservedWlan;
   116     delete iObservedWlan;
   141 // CWsfModel::SetEngineObserver
   154 // CWsfModel::SetEngineObserver
   142 // ----------------------------------------------------------------------------
   155 // ----------------------------------------------------------------------------
   143 //
   156 //
   144 EXPORT_C void CWsfModel::SetEngineObserver( MWsfModelObserver* aObserver )
   157 EXPORT_C void CWsfModel::SetEngineObserver( MWsfModelObserver* aObserver )
   145     {
   158     {
       
   159     LOG_ENTERFN( "CWsfModel::SetEngineObserver" );
   146     iObserver = aObserver;
   160     iObserver = aObserver;
   147     }
   161     }
   148 
   162 
   149 
   163 
   150 // ----------------------------------------------------------------------------
   164 // ----------------------------------------------------------------------------
   159     return iArray;
   173     return iArray;
   160     }
   174     }
   161 
   175 
   162 
   176 
   163 // ----------------------------------------------------------------------------
   177 // ----------------------------------------------------------------------------
       
   178 // CWsfModel::GetWlanListSize
       
   179 // ----------------------------------------------------------------------------
       
   180 //
       
   181 EXPORT_C void CWsfModel::GetWlanListSize( TPckgBuf<TUint>& aPckg, 
       
   182                                            TRequestStatus& aStatus )
       
   183     {
       
   184     LOG_ENTERFN( "CWsfModel::GetWlanListSize" );
       
   185     iSession.GetWlanListSize( aPckg, aStatus );
       
   186     }
       
   187 
       
   188 
       
   189 // ----------------------------------------------------------------------------
       
   190 // CWsfModel::GetWlanList
       
   191 // ----------------------------------------------------------------------------
       
   192 //
       
   193 EXPORT_C void CWsfModel::GetWlanList( TPckgBuf<TUint>& aPckg, TPtr8& aPtr, 
       
   194                                        TRequestStatus& aStatus )
       
   195     {
       
   196     LOG_ENTERFN( "CWsfModel::GetWlanList" );
       
   197     iSession.GetWlanList( aPckg, aPtr, aStatus );
       
   198     }
       
   199 
       
   200 
       
   201 // ----------------------------------------------------------------------------
   164 // CWsfModel::SetActiveViewL
   202 // CWsfModel::SetActiveViewL
   165 // ----------------------------------------------------------------------------
   203 // ----------------------------------------------------------------------------
   166 //
   204 //
   167 EXPORT_C void CWsfModel::SetActiveViewL( TInt aViewId )
   205 EXPORT_C void CWsfModel::SetActiveViewL( TInt aViewId )
   168     {
   206     {
   232 
   270 
   233     if ( iObserver )
   271     if ( iObserver )
   234         {
   272         {
   235         iObserver->ConnectingFinishedL( err );
   273         iObserver->ConnectingFinishedL( err );
   236         }
   274         }
   237 
       
   238     TBool timerStarted( EFalse );
       
   239     timerStarted = iSession.ControlDisconnectTimerL( 
       
   240                                          EAdcStartTimer | EAdcTimerReset );
       
   241     
       
   242     if ( !timerStarted )
       
   243         {
       
   244         LOG_WRITE( "auto-disconnect timer couldn't be started!" );
       
   245         }
       
   246     
       
   247     
   275     
   248     iRefreshing = iSession.RequestScanL();   
   276     iRefreshing = iSession.RequestScanL();   
   249     
   277     
   250     return err;
   278     return err;
   251     }
   279     }
   252 
   280 
   253 
   281 
   254 // ----------------------------------------------------------------------------
   282 // ----------------------------------------------------------------------------
   255 // CWsfModel::ConnectWithoutConnWaiterL
   283 // CWsfModel::ConnectL
   256 // ----------------------------------------------------------------------------
   284 // ----------------------------------------------------------------------------
   257 //
   285 //
   258 EXPORT_C int CWsfModel::ConnectWithoutConnWaiterL( TUint32 aIapId, 
   286 EXPORT_C void CWsfModel::ConnectL( TPckgBuf<TBool>& aPckg, TUint32 aIapId, 
   259                                                    TBool aTestedAccessPoint )
   287                                   TWsfIapPersistence aPersistence,
   260     {
   288                                   TRequestStatus& aStatus )
   261     LOG_ENTERFN( "CWsfModel::ConnectWithoutConnWaiterL" );
   289     {
       
   290     LOG_ENTERFN( "CWsfModel::ConnectL" );
   262     
   291     
   263     if ( iObserver )
   292     if ( iObserver )
   264         {
   293         {
   265         iObserver->ConnectingL( aIapId );
   294         iObserver->ConnectingL( aIapId );
   266         }
   295         }
   267     if ( aTestedAccessPoint )
   296     
   268         {
   297     iSession.ConnectWlanBearer( aPckg, aIapId, aPersistence, aStatus );
   269         return iSession.ConnectWlanBearerWithoutConnWaiterL( aIapId, 
   298     }
   270                                                        EIapPersistent );
   299 
   271         }
   300 // ----------------------------------------------------------------------------
   272     else
   301 // CWsfModel::SetConnectResultL
   273         {
   302 // ----------------------------------------------------------------------------
   274         return iSession.ConnectWlanBearerWithoutConnWaiterL( aIapId, 
   303 //
   275                                                        EIapExpireOnDisconnect );
   304 EXPORT_C void CWsfModel::SetConnectResultL( TInt aResult, TUint /*aIapId*/ )
   276         }
   305     {
   277     }
   306     LOG_ENTERFN( "CWsfModel::SetConnectResultL" );
   278 
   307     
   279 
   308     iSession.SetConnectWlanBearerResult( aResult );
   280 // ----------------------------------------------------------------------------
   309     
   281 // CWsfModel::FinalizeConnectL
   310     if ( iObserver && aResult != KErrNone )
   282 // ----------------------------------------------------------------------------
   311         {
   283 //
   312         iObserver->ConnectingFinishedL( aResult );
   284 EXPORT_C void CWsfModel::FinalizeConnectL()
       
   285     {
       
   286     LOG_ENTERFN( "CWsfModel::FinalizeConnectL" );
       
   287     
       
   288     TBool timerStarted( EFalse );
       
   289     timerStarted = iSession.ControlDisconnectTimerL( 
       
   290                                               EAdcStartTimer | EAdcTimerReset );
       
   291     
       
   292     if ( !timerStarted )
       
   293         {
       
   294         LOG_WRITE( "auto-disconnect timer couldn't be started!" );
       
   295         }
   313         }
   296     }
   314     }
   297 
   315 
   298 
   316 
   299 // ----------------------------------------------------------------------------
   317 // ----------------------------------------------------------------------------
   305     LOG_ENTERFN( "CWsfModel::DisconnectL" );
   323     LOG_ENTERFN( "CWsfModel::DisconnectL" );
   306     iSession.DisconnectWlanBearerL();
   324     iSession.DisconnectWlanBearerL();
   307     iConnectedIapId = 0;
   325     iConnectedIapId = 0;
   308     iConnectedNetId = 0;
   326     iConnectedNetId = 0;
   309     iConnectOnly = EFalse;
   327     iConnectOnly = EFalse;
   310     iRefreshing = iSession.RequestScanL();    
   328 	iRefreshing = iSession.RequestScanL(); 
       
   329     }
       
   330 
       
   331 
       
   332 // ----------------------------------------------------------------------------
       
   333 // CWsfModel::Disconnect
       
   334 // ----------------------------------------------------------------------------
       
   335 //
       
   336 EXPORT_C void CWsfModel::Disconnect( TPckgBuf<TBool>& aPckg, TRequestStatus& aStatus )
       
   337     {
       
   338     LOG_ENTERFN( "CWsfModel::Disconnect" );
       
   339     iSession.DisconnectWlanBearer( aPckg, aStatus );
       
   340     iConnectedIapId = 0;
       
   341     iConnectedNetId = 0;
       
   342     iConnectOnly = EFalse;
   311     }
   343     }
   312 
   344 
   313 
   345 
   314 // ----------------------------------------------------------------------------
   346 // ----------------------------------------------------------------------------
   315 // CWsfModel::Refreshing
   347 // CWsfModel::Refreshing
   385     if ( !iBrowserLauncher->Launching() ||
   417     if ( !iBrowserLauncher->Launching() ||
   386          iBrowserLauncher->BrowserIap() != aIapId ) 
   418          iBrowserLauncher->BrowserIap() != aIapId ) 
   387         {
   419         {
   388         LOG_WRITE( "launching browser..." );
   420         LOG_WRITE( "launching browser..." );
   389         iConnectedIapId = aIapId;        
   421         iConnectedIapId = aIapId;        
   390         iSession.MonitorAccessPointL( aIapId );
       
   391         iSession.ControlDisconnectTimerL( EAdcStopTimer );
       
   392         iBrowserLauncher->LaunchBrowserL( *this, aIapId );
   422         iBrowserLauncher->LaunchBrowserL( *this, aIapId );
   393         }
   423         }
   394     else if ( iBrowserLauncher->BrowserIap() == aIapId ) 
   424     else if ( iBrowserLauncher->BrowserIap() == aIapId ) 
   395         {
   425         {
   396         LOG_WRITE( "bringing browser to foreground..." );
   426         LOG_WRITE( "bringing browser to foreground..." );
   397         ContinueBrowsingL();
   427         ContinueBrowsingL();
   398         }
   428         }
   399         
   429         
   400     }
       
   401 
       
   402 
       
   403 // ----------------------------------------------------------------------------
       
   404 // CWsfModel::CleanUpCancelledLaunchL
       
   405 // ----------------------------------------------------------------------------
       
   406 //
       
   407 EXPORT_C void CWsfModel::CleanUpCancelledLaunchL()
       
   408     {
       
   409     LOG_ENTERFN( "CWsfModel::CleanUpCancelledLaunchL" );
       
   410     iSession.SetIapPersistenceL( EIapForcedExpiry );
       
   411     }
   430     }
   412     
   431     
   413 
   432 
   414 // ----------------------------------------------------------------------------
   433 // ----------------------------------------------------------------------------
   415 // CWsfModel::ContinueBrowsingL
   434 // CWsfModel::ContinueBrowsingL
   496         if ( err )
   515         if ( err )
   497             {
   516             {
   498             LOG_WRITEF( "MakeIctIapPersistentL leaved with error = %d", err );
   517             LOG_WRITEF( "MakeIctIapPersistentL leaved with error = %d", err );
   499             }
   518             }
   500         }
   519         }
   501 
       
   502     if ( iKeepConnection )
       
   503         {
       
   504         // trigger the auto-disconnect timer as well
       
   505         TBool timerStarted( EFalse );
       
   506         TRAP_IGNORE( timerStarted = iSession.ControlDisconnectTimerL( 
       
   507                                           EAdcStartTimer | EAdcTimerReset ) );
       
   508         
       
   509         if ( !timerStarted )
       
   510             {
       
   511             LOG_WRITE( "auto-disconnect timer couldn't be started!" );
       
   512             }
       
   513         }
       
   514         
   520         
   515     LOG_WRITE( "before AsyncStop" );
   521     LOG_WRITE( "before AsyncStop" );
   516     // finally stop blocking the caller
   522     // finally stop blocking the caller
   517     iIctEnded = ETrue; 
   523     iIctEnded = ETrue; 
   518     if ( iIctWait.IsStarted() )
   524     if ( iIctWait.IsStarted() )
   519         {
   525         {
   520         LOG_WRITE( "ICT: AsyncStop" );
   526         LOG_WRITE( "ICT: AsyncStop" );
   521         iIctWait.AsyncStop();
   527         iIctWait.AsyncStop();
   522         } 
   528         }
   523      
   529     
   524 
       
   525     }
   530     }
   526 
   531 
   527 // -----------------------------------------------------------------------------
   532 // -----------------------------------------------------------------------------
   528 // CWsfModel::LaunchWlanLoginL()
   533 // CWsfModel::LaunchWlanLoginL()
   529 // -----------------------------------------------------------------------------
   534 // -----------------------------------------------------------------------------
   795     
   800     
   796         
   801         
   797     if ( err == KErrNone && ictTestPermission == EIctsNeverRun )
   802     if ( err == KErrNone && ictTestPermission == EIctsNeverRun )
   798         {
   803         {
   799         LOG_WRITE( "ICT is set to never run, IAP remains temporary" );
   804         LOG_WRITE( "ICT is set to never run, IAP remains temporary" );
   800         
       
   801         if ( !iKeepConnection )
       
   802             {
       
   803             //get the engine monitor the IAP
       
   804             iSession.MonitorAccessPointL( iIctWlanInfo.iIapId );
       
   805             iSession.SetIapPersistenceL( EIapExpireOnShutdown );
       
   806             iSession.MonitorAccessPointL( iIctWlanInfo.iIapId );
       
   807             }
       
   808 
   805 
   809         ConnectivityObserver( EConnectionNotOk, KNullDesC );
   806         ConnectivityObserver( EConnectionNotOk, KNullDesC );
   810         }
   807         }
   811 
   808 
   812     return err;
   809     return err;
   854 
   851 
   855         CleanupStack::PopAndDestroy( &cm );
   852         CleanupStack::PopAndDestroy( &cm );
   856         CleanupStack::PopAndDestroy( &cmManager );
   853         CleanupStack::PopAndDestroy( &cmManager );
   857 
   854 
   858         LOG_WRITE( "starting ICT test..." );
   855         LOG_WRITE( "starting ICT test..." );
   859         CIctsClientInterface* ict = CIctsClientInterface::NewL( 
   856         
   860                                                     iConnectedIapId, 
   857         if ( iIct )
   861                                                     iConnectedNetId,
   858             {
   862                                                     *this );
   859             iIct->CancelStartL();
       
   860             delete iIct;
       
   861             iIct = NULL;
       
   862             }
       
   863         
       
   864         iIct = CIctsClientInterface::NewL( iConnectedIapId, 
       
   865                                            iConnectedNetId,
       
   866                                            *this );
   863         LOG_WRITE( "ICT created" );
   867         LOG_WRITE( "ICT created" );
   864         CleanupStack::PushL( ict );
   868         iIct->StartL();
   865         ict->StartL();
       
   866         LOG_WRITE( "ICT: started" );
   869         LOG_WRITE( "ICT: started" );
   867         
   870         
   868         // enter a waitloop since ICT is a kind of asynchronous service
   871         // enter a waitloop since ICT is a kind of asynchronous service
   869         if ( !iIctEnded )
   872         if ( !iIctEnded )
   870             {
   873             {
   871             LOG_WRITE( "ICT: iIctWait started" );
   874             LOG_WRITE( "ICT: iIctWait started" );
   872             iIctWait.Start();
   875             iIctWait.Start();
   873             }
   876             }
   874             
   877         
   875         iIctEnded = EFalse;
   878         iIctEnded = EFalse;
   876         CleanupStack::PopAndDestroy( ict );
       
   877         LOG_WRITE( "ICT test done." );
   879         LOG_WRITE( "ICT test done." );
   878         }
   880         }
   879 
   881 
   880     if ( ictTestPermission == EIctsNeverRun )
   882     if ( ictTestPermission == EIctsNeverRun )
   881         {
   883         {
   896     LOG_ENTERFN( "CWsfModel::RefreshScanL" );
   898     LOG_ENTERFN( "CWsfModel::RefreshScanL" );
   897     iRefreshing = iSession.RequestScanL();
   899     iRefreshing = iSession.RequestScanL();
   898     LOG_WRITEF( "iRefreshing = %d", iRefreshing );
   900     LOG_WRITEF( "iRefreshing = %d", iRefreshing );
   899     return iRefreshing;
   901     return iRefreshing;
   900     }
   902     }
       
   903 
       
   904 
       
   905 // ----------------------------------------------------------------------------
       
   906 // CWsfModel::RefreshScan
       
   907 // ----------------------------------------------------------------------------
       
   908 //
       
   909 EXPORT_C void CWsfModel::RefreshScan( TPckgBuf<TBool>& aPckg, 
       
   910                                        TRequestStatus& aStatus )
       
   911     {
       
   912     LOG_ENTERFN( "CWsfModel::RefreshScan" );
       
   913     iSession.RequestScan( aPckg, aStatus );
       
   914     }
   901     
   915     
   902 
   916 
   903 // ----------------------------------------------------------------------------
   917 // ----------------------------------------------------------------------------
   904 // CWsfModel::LaunchHelperApplicationL
   918 // CWsfModel::LaunchHelperApplicationL
   905 // ----------------------------------------------------------------------------
   919 // ----------------------------------------------------------------------------
   976 void CWsfModel::BrowserLaunchFailed( TInt aError )
   990 void CWsfModel::BrowserLaunchFailed( TInt aError )
   977     {
   991     {
   978     LOG_ENTERFN( "CWsfModel::BrowserLaunchFailed" );
   992     LOG_ENTERFN( "CWsfModel::BrowserLaunchFailed" );
   979     LOG_WRITEF( "error = %d", aError );
   993     LOG_WRITEF( "error = %d", aError );
   980     
   994     
   981     // do the cleanup if necessary
       
   982     TRAP_IGNORE( 
       
   983         iSession.SetIapPersistenceL( EIapForcedExpiry );
       
   984         iSession.ControlDisconnectTimerL( EAdcStartTimer | EAdcTimerReset );
       
   985     );
       
   986     
       
   987     if ( iObserver )
   995     if ( iObserver )
   988         {
   996         {
   989         iObserver->BrowserLaunchFailed( aError );    
   997         iObserver->BrowserLaunchFailed( aError );    
   990         }
   998         }
   991     }
   999     }
   997 //
  1005 //
   998 void CWsfModel::BrowserLaunchCompleteL()
  1006 void CWsfModel::BrowserLaunchCompleteL()
   999     {
  1007     {
  1000     LOG_ENTERFN( "CWsfModel::BrowserLaunchCompleteL" );
  1008     LOG_ENTERFN( "CWsfModel::BrowserLaunchCompleteL" );
  1001 
  1009 
       
  1010     iSession.MonitorAccessPointL( iConnectedIapId  );
       
  1011     
  1002     if ( iObserver )
  1012     if ( iObserver )
  1003         {
  1013         {
  1004         iObserver->BrowserLaunchCompleteL();    
  1014         iObserver->BrowserLaunchCompleteL();    
  1005         }
  1015         }
  1006     }
  1016     }
  1014     {
  1024     {
  1015     LOG_ENTERFN( "CWsfModel::BrowserExitL" );
  1025     LOG_ENTERFN( "CWsfModel::BrowserExitL" );
  1016     
  1026     
  1017     // browser has been terminated, do the cleanup if necessary
  1027     // browser has been terminated, do the cleanup if necessary
  1018     iSession.SetIapPersistenceL( EIapForcedExpiry );
  1028     iSession.SetIapPersistenceL( EIapForcedExpiry );
  1019     iSession.ControlDisconnectTimerL( EAdcStartTimer | EAdcTimerReset );
       
  1020     
  1029     
  1021     if ( iObserver )
  1030     if ( iObserver )
  1022         {
  1031         {
  1023         iObserver->BrowserExitL();    
  1032         iObserver->BrowserExitL();    
  1024         }
  1033         }
  1060 // ----------------------------------------------------------------------------
  1069 // ----------------------------------------------------------------------------
  1061 //
  1070 //
  1062 EXPORT_C TBool CWsfModel::GetConnectedWlanDetailsL( TWsfWlanInfo& aWlanInfo )
  1071 EXPORT_C TBool CWsfModel::GetConnectedWlanDetailsL( TWsfWlanInfo& aWlanInfo )
  1063     {
  1072     {
  1064     return iSession.GetConnectedWlanDetailsL( aWlanInfo );
  1073     return iSession.GetConnectedWlanDetailsL( aWlanInfo );
       
  1074     }
       
  1075 
       
  1076 // ----------------------------------------------------------------------------
       
  1077 // CWsfModel::GetConnectedWlanDetails
       
  1078 // ----------------------------------------------------------------------------
       
  1079 //
       
  1080 EXPORT_C void CWsfModel::GetConnectedWlanDetails( TPckgBuf<TBool>& aPckg,
       
  1081                                                    TWsfWlanInfo& aWlanInfo,
       
  1082                                                    TRequestStatus& aStatus )
       
  1083     {
       
  1084     iSession.GetConnectedWlanDetails( aPckg, aWlanInfo, aStatus );
  1065     }
  1085     }
  1066 
  1086 
  1067 
  1087 
  1068 // ----------------------------------------------------------------------------
  1088 // ----------------------------------------------------------------------------
  1069 // CWsfModel::AbortConnectingL
  1089 // CWsfModel::AbortConnectingL