wlanutilities/wlansniffer/model/src/wsfmodel.cpp
branchRCL_3
changeset 25 f28ada11abbf
equal deleted inserted replaced
24:63be7eb3fc78 25:f28ada11abbf
       
     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 CWsfModel
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  EXTERNAL INCLUDES
       
    20 #include <eikenv.h>
       
    21 #include <apgcli.h>
       
    22 #include <apgtask.h>
       
    23 #include <ictsclientinterface.h>
       
    24 #include <cmmanagerext.h>
       
    25 #include <cmdestinationext.h>
       
    26 #include <cmpluginwlandef.h>
       
    27 #include <centralrepository.h>
       
    28 #include <internetconnectivitycrkeys.h>
       
    29 #include <featmgr.h>
       
    30 #include <sysutil.h>
       
    31 #include <wlanerrorcodes.h>
       
    32 
       
    33 //  CLASS HEADER
       
    34 #include "wsfmodel.h"
       
    35 
       
    36 //  INTERNAL INCLUDES
       
    37 #include "wsfwlaninfoarray.h"
       
    38 #include "wsfwlaniapwizard.h"
       
    39 #include "wsfapplauncher.h"
       
    40 #include "wsfmodelobserver.h"
       
    41 #include "wsfstatechangeobserver.h"
       
    42 #include "wsfscreensaverwatcher.h"
       
    43 #include "wsflogger.h"
       
    44 
       
    45 using namespace CMManager;
       
    46 
       
    47 
       
    48 /**
       
    49 * UID of helper application 
       
    50 * used when model is instantiated in the active idle
       
    51 */
       
    52 static const TUid KHelperApUid = { 0x10281CEB };
       
    53 
       
    54 /**
       
    55 * Estimated overhead for access point creation 
       
    56 */
       
    57 const TInt KEstimatedOverhead = 8192;
       
    58 
       
    59 
       
    60 // ----------------------------------------------------------------------------
       
    61 // CWsfModel::NewL
       
    62 // ----------------------------------------------------------------------------
       
    63 //
       
    64 EXPORT_C CWsfModel* CWsfModel::NewL( MWsfStateChangeObserver& aObserver,
       
    65                                      const TBool aScreenSaverAware )
       
    66     {
       
    67     CWsfModel* self = CWsfModel::NewLC( aObserver, aScreenSaverAware );
       
    68     CleanupStack::Pop( self );
       
    69     return self;
       
    70     }
       
    71 
       
    72 
       
    73 // ----------------------------------------------------------------------------
       
    74 // CWsfModel::NewLC
       
    75 // ----------------------------------------------------------------------------
       
    76 //
       
    77 EXPORT_C CWsfModel* CWsfModel::NewLC( MWsfStateChangeObserver& aObserver,
       
    78                                       const TBool aScreenSaverAware )
       
    79     {
       
    80     CWsfModel* self = new( ELeave ) CWsfModel;
       
    81     CleanupStack::PushL( self );
       
    82     self->ConstructL( aObserver, aScreenSaverAware );
       
    83     return self;
       
    84     }
       
    85 
       
    86 
       
    87 // ----------------------------------------------------------------------------
       
    88 // CWsfModel::~CWsfModel
       
    89 // ----------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C CWsfModel::~CWsfModel()
       
    92     {
       
    93     LOG_ENTERFN( "CWsfModel::~CWsfModel" );
       
    94     iSession.CancelNotifyEvent();
       
    95     iSession.Close();
       
    96     delete iScreenSaverWatcher;
       
    97     delete iArray;   
       
    98     delete iObservedWlan;
       
    99     delete iBrowserLauncher;
       
   100     }
       
   101 
       
   102 
       
   103 // ----------------------------------------------------------------------------
       
   104 // CWsfModel::CWsfModel
       
   105 // ----------------------------------------------------------------------------
       
   106 //
       
   107 CWsfModel::CWsfModel(): 
       
   108     iEikEnv( CEikonEnv::Static() ),
       
   109     iRefreshing( EFalse )
       
   110     {
       
   111     }
       
   112 
       
   113 
       
   114 // ----------------------------------------------------------------------------
       
   115 // CWsfModel::ConstructL
       
   116 // ----------------------------------------------------------------------------
       
   117 //
       
   118 void CWsfModel::ConstructL( MWsfStateChangeObserver& aObserver, 
       
   119                             const TBool aScreenSaverAware )
       
   120     {
       
   121     iArray = CWsfWlanInfoArray::NewL(); 
       
   122     iBrowserLauncher = CWsfAppLauncher::NewL();
       
   123     User::LeaveIfError( iSession.Connect() ); 
       
   124     iSession.NotifyEventL( aObserver );
       
   125     if ( aScreenSaverAware )
       
   126         {
       
   127         iScreenSaverWatcher = CWsfScreenSaverWatcher::NewL( *this );
       
   128         }
       
   129     }
       
   130 
       
   131 
       
   132 // ----------------------------------------------------------------------------
       
   133 // CWsfModel::SetEngineObserver
       
   134 // ----------------------------------------------------------------------------
       
   135 //
       
   136 EXPORT_C void CWsfModel::SetEngineObserver( MWsfModelObserver* aObserver )
       
   137     {
       
   138     LOG_ENTERFN( "CWsfModel::SetEngineObserver" );
       
   139     iObserver = aObserver;
       
   140     }
       
   141 
       
   142 
       
   143 // ----------------------------------------------------------------------------
       
   144 // CWsfModel::GetWlanListL
       
   145 // ----------------------------------------------------------------------------
       
   146 //
       
   147 EXPORT_C CWsfWlanInfoArray* CWsfModel::GetWlanListL()
       
   148     {
       
   149     LOG_ENTERFN( "CWsfModel::GetWlanListL" );
       
   150     iArray->Reset();
       
   151     iSession.UpdateWlanListL( iArray );
       
   152     return iArray;
       
   153     }
       
   154 
       
   155 
       
   156 // ----------------------------------------------------------------------------
       
   157 // CWsfModel::GetWlanListSize
       
   158 // ----------------------------------------------------------------------------
       
   159 //
       
   160 EXPORT_C void CWsfModel::GetWlanListSize( TPckgBuf<TUint>& aPckg, 
       
   161                                            TRequestStatus& aStatus )
       
   162     {
       
   163     LOG_ENTERFN( "CWsfModel::GetWlanListSize" );
       
   164     iSession.GetWlanListSize( aPckg, aStatus );
       
   165     }
       
   166 
       
   167 
       
   168 // ----------------------------------------------------------------------------
       
   169 // CWsfModel::GetWlanList
       
   170 // ----------------------------------------------------------------------------
       
   171 //
       
   172 EXPORT_C void CWsfModel::GetWlanList( TPckgBuf<TUint>& aPckg, TPtr8& aPtr, 
       
   173                                        TRequestStatus& aStatus )
       
   174     {
       
   175     LOG_ENTERFN( "CWsfModel::GetWlanList" );
       
   176     iSession.GetWlanList( aPckg, aPtr, aStatus );
       
   177     }
       
   178 
       
   179 
       
   180 // ----------------------------------------------------------------------------
       
   181 // CWsfModel::SetActiveViewL
       
   182 // ----------------------------------------------------------------------------
       
   183 //
       
   184 EXPORT_C void CWsfModel::SetActiveViewL( TInt aViewId )
       
   185     {
       
   186     TUid id;
       
   187     id.iUid = aViewId;
       
   188     iActiveView = id;
       
   189     }
       
   190         
       
   191 
       
   192 // ----------------------------------------------------------------------------
       
   193 // CWsfModel::ActiveViewL
       
   194 // ----------------------------------------------------------------------------
       
   195 //
       
   196 EXPORT_C TUid CWsfModel::ActiveViewL()
       
   197     {
       
   198     return iActiveView;
       
   199     }
       
   200 
       
   201     
       
   202 // ----------------------------------------------------------------------------
       
   203 // CWsfModel::SetObservedWlanL
       
   204 // ----------------------------------------------------------------------------
       
   205 //
       
   206 EXPORT_C void CWsfModel::SetObservedWlanL( const TDesC8& aSsid )
       
   207     {
       
   208     HBufC8* ssid = aSsid.AllocL();
       
   209     delete iObservedWlan;
       
   210     iObservedWlan = ssid;
       
   211     }
       
   212     
       
   213 
       
   214 // ----------------------------------------------------------------------------
       
   215 // CWsfModel::ObservedWlan
       
   216 // ----------------------------------------------------------------------------
       
   217 //
       
   218 EXPORT_C const TDesC8& CWsfModel::ObservedWlan()
       
   219     {
       
   220     return *iObservedWlan;
       
   221     }
       
   222 
       
   223 
       
   224 // ----------------------------------------------------------------------------
       
   225 // CWsfModel::ConnectL
       
   226 // ----------------------------------------------------------------------------
       
   227 //
       
   228 EXPORT_C int CWsfModel::ConnectL( TUint32 aIapId, TBool aConnectOnly,
       
   229                                   TWsfIapPersistence aPersistence )
       
   230     {
       
   231     LOG_ENTERFN( "CWsfModel::ConnectL" );
       
   232     
       
   233     if ( iObserver )
       
   234         {
       
   235         iObserver->ConnectingL( aIapId );
       
   236         }
       
   237     
       
   238     TInt err = iSession.ConnectWlanBearerL( aIapId, aConnectOnly, aPersistence );
       
   239     if ( err == KErrNone )
       
   240         {
       
   241         iConnectedIapId = aIapId;
       
   242         }
       
   243     else
       
   244         {
       
   245         if ( iObserver )
       
   246             {
       
   247             iObserver->BrowserLaunchFailed( err );            
       
   248             }
       
   249         }
       
   250 
       
   251     if ( iObserver )
       
   252         {
       
   253         iObserver->ConnectingFinishedL( err );
       
   254         }
       
   255     
       
   256     iRefreshing = iSession.RequestScanL();
       
   257     
       
   258     return err;
       
   259     }
       
   260 
       
   261 
       
   262 // ----------------------------------------------------------------------------
       
   263 // CWsfModel::ConnectL
       
   264 // ----------------------------------------------------------------------------
       
   265 //
       
   266 EXPORT_C void CWsfModel::ConnectL( TPckgBuf<TBool>& aPckg, TUint32 aIapId,
       
   267                                    TBool aConnectOnly,
       
   268                                    TWsfIapPersistence aPersistence,
       
   269                                    TRequestStatus& aStatus )
       
   270     {
       
   271     LOG_ENTERFN( "CWsfModel::ConnectL" );
       
   272     
       
   273     if ( iObserver )
       
   274         {
       
   275         iObserver->ConnectingL( aIapId );
       
   276         }
       
   277     
       
   278     iSession.ConnectWlanBearer( aPckg, aIapId, aConnectOnly, aPersistence, aStatus );
       
   279     }
       
   280 
       
   281 // ----------------------------------------------------------------------------
       
   282 // CWsfModel::SetConnectResultL
       
   283 // ----------------------------------------------------------------------------
       
   284 //
       
   285 EXPORT_C void CWsfModel::SetConnectResultL( TInt aResult, TUint /*aIapId*/ )
       
   286     {
       
   287     LOG_ENTERFN( "CWsfModel::SetConnectResultL" );
       
   288     
       
   289     iSession.SetConnectWlanBearerResult( aResult );
       
   290     
       
   291     if ( iObserver && aResult != KErrNone )
       
   292         {
       
   293         iObserver->ConnectingFinishedL( aResult );
       
   294         }
       
   295     }
       
   296 
       
   297 
       
   298 // ----------------------------------------------------------------------------
       
   299 // CWsfModel::DisconnectL
       
   300 // ----------------------------------------------------------------------------
       
   301 //
       
   302 EXPORT_C void CWsfModel::DisconnectL()
       
   303     {
       
   304     LOG_ENTERFN( "CWsfModel::DisconnectL" );
       
   305     TBool disconnected = iSession.DisconnectWlanBearerL();
       
   306     LOG_WRITEF( "disconnected = %d", disconnected );
       
   307     iConnectedIapId = 0;
       
   308     if ( !disconnected )
       
   309         {
       
   310         iRefreshing = iSession.RequestScanL(); 
       
   311         }
       
   312     }
       
   313 
       
   314 
       
   315 // ----------------------------------------------------------------------------
       
   316 // CWsfModel::Disconnect
       
   317 // ----------------------------------------------------------------------------
       
   318 //
       
   319 EXPORT_C void CWsfModel::Disconnect( TPckgBuf<TBool>& aPckg, TRequestStatus& aStatus )
       
   320     {
       
   321     LOG_ENTERFN( "CWsfModel::Disconnect" );
       
   322     iSession.DisconnectWlanBearer( aPckg, aStatus );
       
   323     iConnectedIapId = 0;
       
   324     }
       
   325 
       
   326 
       
   327 // ----------------------------------------------------------------------------
       
   328 // CWsfModel::Refreshing
       
   329 // ----------------------------------------------------------------------------
       
   330 //
       
   331 EXPORT_C TBool CWsfModel::Refreshing()
       
   332     {
       
   333     return iRefreshing;
       
   334     }
       
   335 
       
   336 
       
   337 // ----------------------------------------------------------------------------
       
   338 // CWsfModel::SetRefreshState
       
   339 // ----------------------------------------------------------------------------
       
   340 //
       
   341 EXPORT_C void CWsfModel::SetRefreshState( TBool aRefreshing )
       
   342     {
       
   343     iRefreshing = aRefreshing;
       
   344     }
       
   345 
       
   346 
       
   347 // ----------------------------------------------------------------------------
       
   348 // CWsfModel::EnableScanL
       
   349 // ----------------------------------------------------------------------------
       
   350 //
       
   351 EXPORT_C TBool CWsfModel::EnableScanL()
       
   352     {
       
   353     LOG_ENTERFN( "CWsfModel::EnableScanL" );
       
   354     TBool enableScan( iSession.EnableScanL() );
       
   355     if ( iScreenSaverWatcher )
       
   356         {
       
   357         iScreenSaverWatcher->Cancel();
       
   358         iScreenSaverWatcher->StartStatusScanning();
       
   359         }
       
   360     return enableScan;
       
   361     }
       
   362 
       
   363 
       
   364 // ----------------------------------------------------------------------------
       
   365 // CWsfModel::DisableScanL
       
   366 // ----------------------------------------------------------------------------
       
   367 //
       
   368 EXPORT_C TBool CWsfModel::DisableScanL()
       
   369     {
       
   370     LOG_ENTERFN( "CWsfModel::DisableScanL" );
       
   371     TBool disableScan( iSession.DisableScanL() );   
       
   372     if ( iScreenSaverWatcher )
       
   373         {
       
   374         iScreenSaverWatcher->Cancel();
       
   375         }
       
   376     return disableScan; 
       
   377     }
       
   378 
       
   379 
       
   380 // ----------------------------------------------------------------------------
       
   381 // CWsfModel::IsScanEnabledL
       
   382 // ----------------------------------------------------------------------------
       
   383 //
       
   384 EXPORT_C TBool CWsfModel::IsScanEnabledL()
       
   385     {
       
   386     return iSession.IsScanEnabledL(); 
       
   387     }
       
   388 
       
   389 
       
   390 // ----------------------------------------------------------------------------
       
   391 // CWsfModel::LaunchBrowserL
       
   392 // ----------------------------------------------------------------------------
       
   393 //
       
   394 EXPORT_C void CWsfModel::LaunchBrowserL( TUint32 aIapId )
       
   395     {
       
   396     LOG_ENTERFN( "CWsfModel::LaunchBrowserL" );
       
   397     
       
   398     if ( !iBrowserLauncher->Launching() ||
       
   399          iBrowserLauncher->BrowserIap() != aIapId ) 
       
   400         {
       
   401         LOG_WRITE( "launching browser..." );
       
   402         iConnectedIapId = aIapId;        
       
   403         iBrowserLauncher->LaunchBrowserL( *this, aIapId );
       
   404         }
       
   405     else if ( iBrowserLauncher->BrowserIap() == aIapId ) 
       
   406         {
       
   407         LOG_WRITE( "bringing browser to foreground..." );
       
   408         ContinueBrowsingL();
       
   409         }
       
   410         
       
   411     }
       
   412     
       
   413 
       
   414 // ----------------------------------------------------------------------------
       
   415 // CWsfModel::ContinueBrowsingL
       
   416 // ----------------------------------------------------------------------------
       
   417 //
       
   418 EXPORT_C void CWsfModel::ContinueBrowsingL()
       
   419     {
       
   420     LOG_ENTERFN( "CWsfModel::ContinueBrowsingL(void)" );
       
   421     iBrowserLauncher->ContinueBrowsingL();
       
   422     }
       
   423     
       
   424 
       
   425 // ----------------------------------------------------------------------------
       
   426 // CWsfModel::ContinueBrowsingL
       
   427 // ----------------------------------------------------------------------------
       
   428 //
       
   429 EXPORT_C void CWsfModel::ContinueBrowsingL( TUint32 aIapId )
       
   430     {
       
   431     LOG_ENTERFN( "CWsfModel::ContinueBrowsingL(TUint32)" );
       
   432     iBrowserLauncher->ContinueBrowsingL( *this, aIapId );
       
   433     }    
       
   434 
       
   435 
       
   436 // ----------------------------------------------------------------------------
       
   437 // CWsfModel::CreateAccessPointL
       
   438 // ----------------------------------------------------------------------------
       
   439 //
       
   440 EXPORT_C TBool CWsfModel::CreateAccessPointL( TWsfWlanInfo& aWlan, 
       
   441                                               TBool aExplicitDefine )
       
   442     {
       
   443     LOG_ENTERFN( "CWsfModel::CreateAccessPointL" );
       
   444     if ( aExplicitDefine )
       
   445         {
       
   446         LOG_WRITE( "called from 'Define access point'" );
       
   447         }
       
   448     
       
   449     CheckSpaceBelowCriticalLevelL();
       
   450     CheckUnknownWapiL( aWlan );
       
   451       
       
   452     CWsfWlanIapWizard* iapWizard = CWsfWlanIapWizard::NewLC();
       
   453     
       
   454     // the wlaninfo must be persistent to avoid nullpointer crashes due to
       
   455     // background refreshing 
       
   456     TBool ret( ETrue );
       
   457     
       
   458     // query necessary data
       
   459     if ( !iapWizard->LaunchWizardL( aWlan, aExplicitDefine ) )
       
   460         {
       
   461         LOG_WRITE( "iapWizard.LaunchWizardL failed" );
       
   462         ret = EFalse;
       
   463         }
       
   464 
       
   465     // then create accesspoint
       
   466     if ( ret )
       
   467         {
       
   468         if ( iapWizard->CreateAccessPointL() )
       
   469             {
       
   470             // copy back the IAP id
       
   471             LOG_WRITEF( "IAP id = %d", aWlan.iIapId );
       
   472             }
       
   473         else
       
   474             {
       
   475             LOG_WRITE( "iapWizard.CreateAccessPointL failed" );
       
   476             ret = EFalse;
       
   477             }
       
   478         }
       
   479 
       
   480     CleanupStack::PopAndDestroy( iapWizard );
       
   481     
       
   482     return ret;
       
   483     }
       
   484 
       
   485 
       
   486 // ----------------------------------------------------------------------------
       
   487 // CWsfModel::RefreshScanL
       
   488 // ----------------------------------------------------------------------------
       
   489 //
       
   490 EXPORT_C TBool CWsfModel::RefreshScanL()
       
   491     {
       
   492     LOG_ENTERFN( "CWsfModel::RefreshScanL" );
       
   493     iRefreshing = iSession.RequestScanL();
       
   494     LOG_WRITEF( "iRefreshing = %d", iRefreshing );
       
   495     return iRefreshing;
       
   496     }
       
   497 
       
   498 
       
   499 // ----------------------------------------------------------------------------
       
   500 // CWsfModel::RefreshScan
       
   501 // ----------------------------------------------------------------------------
       
   502 //
       
   503 EXPORT_C void CWsfModel::RefreshScan( TPckgBuf<TBool>& aPckg, 
       
   504                                        TRequestStatus& aStatus )
       
   505     {
       
   506     LOG_ENTERFN( "CWsfModel::RefreshScan" );
       
   507     iSession.RequestScan( aPckg, aStatus );
       
   508     }
       
   509 
       
   510 
       
   511 // ----------------------------------------------------------------------------
       
   512 // CWsfModel::CloseHelperApplication
       
   513 // ----------------------------------------------------------------------------
       
   514 //
       
   515 EXPORT_C TBool CWsfModel::CloseHelperApplication()
       
   516     {
       
   517     LOG_ENTERFN( "CWsfModel::CloseHelperApplication" );
       
   518     TBool endTaskCalled = EFalse;
       
   519     // check if the app is already running ... and kill it.
       
   520     TUid id( TUid::Uid( KHelperApUid.iUid ) );
       
   521     TApaTaskList taskList( iEikEnv->WsSession() );
       
   522     TApaTask task = taskList.FindApp( id );
       
   523 
       
   524     if ( task.Exists() )
       
   525         {
       
   526         LOG_WRITE( "ending task" );
       
   527         task.EndTask();
       
   528         endTaskCalled = ETrue;
       
   529         }
       
   530     return endTaskCalled;
       
   531     }
       
   532 
       
   533     
       
   534 
       
   535 // ----------------------------------------------------------------------------
       
   536 // CWsfModel::LaunchHelperApplicationL
       
   537 // ----------------------------------------------------------------------------
       
   538 //
       
   539 EXPORT_C void CWsfModel::LaunchHelperApplicationL( TWsfWlanInfo &aWlanInfo )
       
   540     {
       
   541     LOG_ENTERFN( "CWsfModel::LaunchHelperApplicationL" );
       
   542     TPckgC<TWsfWlanInfo> param( aWlanInfo );
       
   543     
       
   544     TBuf8<sizeof( TWsfWlanInfo )> temp;
       
   545     temp.Copy( param );
       
   546     
       
   547     TFileName fileName;
       
   548     fileName.Copy( temp );
       
   549     
       
   550     RApaLsSession appArcSession;
       
   551     
       
   552     User::LeaveIfError( appArcSession.Connect() ); // connect to AppArc server
       
   553     CleanupClosePushL( appArcSession );
       
   554 
       
   555     // check if the app is already running ... and kill it.
       
   556     TUid id( TUid::Uid( KHelperApUid.iUid ) );
       
   557     TApaTaskList taskList( iEikEnv->WsSession() );
       
   558     TApaTask task = taskList.FindApp( id );
       
   559 
       
   560     if ( task.Exists() )
       
   561         {
       
   562         task.EndTask();
       
   563         }    
       
   564 
       
   565     TThreadId threadId;
       
   566     User::LeaveIfError( appArcSession.StartDocument( fileName, TUid::Uid( 
       
   567                                              KHelperApUid.iUid ), threadId ) );
       
   568 
       
   569     CleanupStack::PopAndDestroy( &appArcSession );
       
   570     }
       
   571 
       
   572 
       
   573 // ----------------------------------------------------------------------------
       
   574 // CWsfModel::CancelNotifyEvents
       
   575 // ----------------------------------------------------------------------------
       
   576 //
       
   577 EXPORT_C void CWsfModel::CancelNotifyEvents()
       
   578     {
       
   579     LOG_ENTERFN( "CWsfModel::CancelNotifyEvents" );
       
   580     iSession.CancelNotifyEvent();
       
   581     }
       
   582 
       
   583 
       
   584 // ----------------------------------------------------------------------------
       
   585 // CWsfModel::RequestNotifyEventsL
       
   586 // ----------------------------------------------------------------------------
       
   587 //
       
   588 EXPORT_C void CWsfModel::RequestNotifyEventsL( 
       
   589                                            MWsfStateChangeObserver& aObserver )
       
   590     {
       
   591     LOG_ENTERFN( "CWsfModel::RequestNotifyEventsL" );
       
   592     iSession.NotifyEventL( aObserver );
       
   593     }
       
   594 
       
   595 
       
   596 // ------------------------- From MWsfBrowserLaunchObserver -------------------
       
   597     
       
   598 // ----------------------------------------------------------------------------
       
   599 // CWsfModel::BrowserLaunchFailed
       
   600 // ----------------------------------------------------------------------------
       
   601 //
       
   602 void CWsfModel::BrowserLaunchFailed( TInt aError )
       
   603     {
       
   604     LOG_ENTERFN( "CWsfModel::BrowserLaunchFailed" );
       
   605     LOG_WRITEF( "error = %d", aError );
       
   606     
       
   607     if ( iObserver )
       
   608         {
       
   609         iObserver->BrowserLaunchFailed( aError );    
       
   610         }
       
   611     }
       
   612 
       
   613 
       
   614 // ----------------------------------------------------------------------------
       
   615 // CWsfModel::BrowserLaunchCompleteL
       
   616 // ----------------------------------------------------------------------------
       
   617 //
       
   618 void CWsfModel::BrowserLaunchCompleteL()
       
   619     {
       
   620     LOG_ENTERFN( "CWsfModel::BrowserLaunchCompleteL" );
       
   621 
       
   622     iSession.MonitorAccessPointL( iConnectedIapId  );
       
   623     
       
   624     if ( iObserver )
       
   625         {
       
   626         iObserver->BrowserLaunchCompleteL();    
       
   627         }
       
   628     }
       
   629 
       
   630 
       
   631 // ----------------------------------------------------------------------------
       
   632 // CWsfModel::BrowserExitL
       
   633 // ----------------------------------------------------------------------------
       
   634 //
       
   635 void CWsfModel::BrowserExitL()
       
   636     {
       
   637     LOG_ENTERFN( "CWsfModel::BrowserExitL" );
       
   638     
       
   639     // browser has been terminated, do the cleanup if necessary
       
   640     iSession.SetIapPersistenceL( EIapForcedExpiry );
       
   641     
       
   642     if ( iObserver )
       
   643         {
       
   644         iObserver->BrowserExitL();    
       
   645         }
       
   646     }
       
   647     
       
   648 // ------------------------- From MWsfScreenSaverStateObserver ----------------
       
   649  
       
   650 // ----------------------------------------------------------------------------
       
   651 // CWsfModel::ScreenSaverStatusChangedL
       
   652 // ----------------------------------------------------------------------------
       
   653 //
       
   654 void CWsfModel::ScreenSaverStatusChangedL( const TBool aScreenSaverActive )
       
   655     {
       
   656     LOG_ENTERFN( "CWsfModel::ScreenSaverStatusChangedL" );
       
   657     LOG_WRITEF( "status = %d", aScreenSaverActive );
       
   658     if ( aScreenSaverActive )
       
   659         {
       
   660         iSession.DisableScanL();
       
   661         }
       
   662     else 
       
   663         {
       
   664         iSession.EnableScanL();
       
   665         }
       
   666     }
       
   667     
       
   668 
       
   669 // ----------------------------------------------------------------------------
       
   670 // CWsfModel::IsConnectedL
       
   671 // ----------------------------------------------------------------------------
       
   672 //
       
   673 EXPORT_C TBool CWsfModel::IsConnectedL()
       
   674     {
       
   675     return iSession.IsConnectedL();
       
   676     }
       
   677     
       
   678 
       
   679 // ----------------------------------------------------------------------------
       
   680 // CWsfModel::GetConnectedWlanDetailsL
       
   681 // ----------------------------------------------------------------------------
       
   682 //
       
   683 EXPORT_C TBool CWsfModel::GetConnectedWlanDetailsL( TWsfWlanInfo& aWlanInfo )
       
   684     {
       
   685     return iSession.GetConnectedWlanDetailsL( aWlanInfo );
       
   686     }
       
   687 
       
   688 // ----------------------------------------------------------------------------
       
   689 // CWsfModel::GetConnectedWlanDetails
       
   690 // ----------------------------------------------------------------------------
       
   691 //
       
   692 EXPORT_C void CWsfModel::GetConnectedWlanDetails( TPckgBuf<TBool>& aPckg,
       
   693                                                    TWsfWlanInfo& aWlanInfo,
       
   694                                                    TRequestStatus& aStatus )
       
   695     {
       
   696     iSession.GetConnectedWlanDetails( aPckg, aWlanInfo, aStatus );
       
   697     }
       
   698 
       
   699 
       
   700 // ----------------------------------------------------------------------------
       
   701 // CWsfModel::AbortConnectingL
       
   702 // ----------------------------------------------------------------------------
       
   703 //
       
   704 EXPORT_C void CWsfModel::AbortConnectingL()
       
   705     {
       
   706     LOG_ENTERFN( "CWsfModel::AbortConnectingL" );
       
   707     if ( iConnecting )
       
   708         {
       
   709         iSession.AbortConnectingL();
       
   710         }
       
   711     }
       
   712 
       
   713 
       
   714 // ----------------------------------------------------------------------------
       
   715 // CWsfModel::AbortScanningL
       
   716 // ----------------------------------------------------------------------------
       
   717 //
       
   718 EXPORT_C void CWsfModel::AbortScanningL()
       
   719     {
       
   720     LOG_ENTERFN( "CWsfModel::AbortScanningL" );
       
   721     if ( iRefreshing )
       
   722         {
       
   723         iSession.AbortScanningL();
       
   724         }
       
   725     }
       
   726 
       
   727 
       
   728 // ----------------------------------------------------------------------------
       
   729 // CWsfModel::CheckSpaceBelowCriticalLevelL
       
   730 // ----------------------------------------------------------------------------
       
   731 //
       
   732 void CWsfModel::CheckSpaceBelowCriticalLevelL() const
       
   733     {
       
   734     // OOD handling. If disk space is low user is notified.
       
   735     RFs fs;
       
   736     User::LeaveIfError( fs.Connect() );
       
   737     CleanupClosePushL<RFs>( fs );
       
   738     
       
   739     // Checks the FFS space "after" addition
       
   740     TBool belowCL = SysUtil::FFSSpaceBelowCriticalLevelL
       
   741             ( &fs, KEstimatedOverhead );
       
   742     
       
   743     CleanupStack::PopAndDestroy(); // fs
       
   744     
       
   745     if( belowCL )
       
   746         {
       
   747         User::Leave( KErrDiskFull );
       
   748         }
       
   749     }
       
   750 
       
   751 // ----------------------------------------------------------------------------
       
   752 // CWsfModel::CheckUnknownWapiL
       
   753 // ----------------------------------------------------------------------------
       
   754 //
       
   755 void CWsfModel::CheckUnknownWapiL( TWsfWlanInfo& aWlan ) const
       
   756     {    
       
   757     if( !aWlan.Known() && aWlan.SecurityMode() == EWlanSecModeWAPI )
       
   758         {
       
   759         User::Leave( KErrWlanProtectedSetupSetupLocked );
       
   760         }
       
   761     }
       
   762 
       
   763 // ----------------------------------------------------------------------------
       
   764 // CWsfModel::CheckIsIapIdValidL
       
   765 // ----------------------------------------------------------------------------
       
   766 //
       
   767 EXPORT_C void CWsfModel::CheckIsIapIdValidL( TUint aIapId ) const
       
   768     {    
       
   769     LOG_ENTERFN( "CWsfModel::CheckIsIapIdValidL" );
       
   770     LOG_WRITEF( "Checking iapId= %d", aIapId );
       
   771     if( aIapId )
       
   772         {
       
   773         RCmManagerExt cmManager;
       
   774         cmManager.OpenL();
       
   775         CleanupClosePushL( cmManager );        
       
   776 
       
   777         RCmConnectionMethodExt cm = cmManager.ConnectionMethodL( aIapId );
       
   778         cm.Close();
       
   779         CleanupStack::PopAndDestroy( &cmManager );
       
   780         }
       
   781     else
       
   782         {
       
   783         User::Leave( KErrArgument );
       
   784         }
       
   785     }
       
   786     
       
   787 // End of file