wlanutilities/wlanplugin/src/wlanpluginwlanstate.cpp
changeset 0 56b72877c1cb
child 10 dff6ebfd236f
equal deleted inserted replaced
-1:000000000000 0:56b72877c1cb
       
     1 /*
       
     2 * Copyright (c) 2007 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: 
       
    15 *      Implementation of utilities functions.   
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 //User includes
       
    24 #include "wlanpluginwlanstate.h"
       
    25 #include "wlanplugindbobserver.h"
       
    26 #include "wlanpluginlogger.h"
       
    27 #include "wlanplugintimeshifter.h"
       
    28 
       
    29 //System includes
       
    30 #include <wsfmodel.h>
       
    31 #include <wsfwlaninfoarray.h>
       
    32 #include <wlanpluginrsc.rsg>
       
    33 #include <StringLoader.h> 
       
    34 #include <gsparentplugin.h>
       
    35 #include <wlanplugin.mbg>
       
    36 #include <wsfwlaninfoarrayvisitor.h>
       
    37 
       
    38 
       
    39 // ================= MEMBER FUNCTIONS =======================
       
    40 
       
    41 // ---------------------------------------------------------
       
    42 // CWlanPluginWlanState::CWlanPluginWlanState
       
    43 // Constructor
       
    44 // ---------------------------------------------------------
       
    45 CWlanPluginWlanState::CWlanPluginWlanState( CGSParentPlugin *aParent ) 
       
    46 : iScanning( EFalse ),
       
    47   iConnected( EFalse ),
       
    48   iExplicitScanning( 0 ),
       
    49   iCoeEnv( CCoeEnv::Static() ),
       
    50   iParent( aParent ),
       
    51   iSignalStrength(ENoSignal),
       
    52   iSupressParentUpdate( EFalse ),
       
    53   iSupressUpdateWlan( EFalse ),
       
    54   iValidSecondLine( ETrue ),   
       
    55   iSupressTimeShifter( EFalse )
       
    56     {
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------
       
    60 // CWlanPluginWlanState::~CWlanPluginWlanState
       
    61 // Descructor
       
    62 // ---------------------------------------------------------
       
    63 CWlanPluginWlanState::~CWlanPluginWlanState()
       
    64     {
       
    65 
       
    66     CLOG_ENTERFN( "CWlanPluginWlanState::~CWlanPluginWlanState()" );  
       
    67     
       
    68     if ( iEngine )
       
    69         {
       
    70         iEngine->CancelNotifyEvents();
       
    71         }
       
    72     
       
    73     if( iExplicitScanning )
       
    74         {
       
    75         TRAP_IGNORE( SetScanningL( EFalse ) );
       
    76         }
       
    77     if( iTimeShifter )
       
    78         {
       
    79         delete iTimeShifter;
       
    80         }
       
    81        
       
    82     delete iDbObserver;
       
    83     
       
    84     delete iWlanInfoBranding;
       
    85     
       
    86     //remove self from further notifications from the
       
    87     //sniffer server
       
    88     delete iEngine;
       
    89     delete iPresentString;
       
    90         
       
    91     CLOG_LEAVEFN( "CWlanPluginWlanState::~CWlanPluginWlanState()" );        
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------
       
    95 // CWlanPluginWlanState::NewLC
       
    96 // ---------------------------------------------------------
       
    97 CWlanPluginWlanState* CWlanPluginWlanState::NewLC( CGSParentPlugin *aParent )
       
    98     {
       
    99     CWlanPluginWlanState* self= new ( ELeave ) 
       
   100                                    CWlanPluginWlanState( aParent );
       
   101     CleanupStack::PushL( self );
       
   102     self->ConstructL();
       
   103     return self;
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------
       
   107 // CWlanPluginWlanState::NewL
       
   108 // ---------------------------------------------------------
       
   109 CWlanPluginWlanState* CWlanPluginWlanState::NewL( CGSParentPlugin *aParent )
       
   110     {
       
   111     CWlanPluginWlanState* self = CWlanPluginWlanState::NewLC( aParent );
       
   112     CleanupStack::Pop( self );    
       
   113     return self;
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------
       
   117 // CWlanPluginWlanState::ConstructL
       
   118 // ---------------------------------------------------------
       
   119 void CWlanPluginWlanState::ConstructL()
       
   120     {
       
   121     CLOG_ENTERFN( "CWlanPluginWlanState::ConstructL()" );  
       
   122               
       
   123     iSupressParentUpdate = ETrue;
       
   124         
       
   125     iEngine = CWsfModel::NewL( *this, EFalse );
       
   126     
       
   127     iWlanInfoBranding = CWsfWlanInfoArrayVisitor::NewL( ETrue );
       
   128     iWlanInfoBranding->LoadFilterDefinitionsL();
       
   129     
       
   130     if( iEngine->IsScanEnabledL() )
       
   131         {
       
   132         iScanning = ETrue;
       
   133         UpdateWlanListL();
       
   134         }
       
   135     
       
   136     if( iEngine->IsConnectedL() )
       
   137         {
       
   138         iConnected = ETrue;
       
   139         iEngine->GetConnectedWlanDetailsL( iConnectedWlanInfo );
       
   140         }
       
   141             
       
   142     iDbObserver = CWlanPluginDbObserver::NewL( this );
       
   143     iDbObserver->ActivateItL();
       
   144     
       
   145     if( !iConnected && !iScanning && iExplicitScanning )
       
   146         {
       
   147         iValidSecondLine = EFalse;
       
   148         }
       
   149         
       
   150     iSupressParentUpdate = EFalse;
       
   151     
       
   152     CLOG_LEAVEFN( "CWlanPluginWlanState::ConstructL()" );            
       
   153     }
       
   154 
       
   155 // ---------------------------------------------------------
       
   156 // CWlanPluginWlanState::WlanListChangedL
       
   157 // ---------------------------------------------------------
       
   158 void CWlanPluginWlanState::WlanListChangedL()
       
   159     {
       
   160     CLOG_ENTERFN( "CWlanPluginWlanState::WlanListChangedL()" );  
       
   161 	
       
   162 	iValidSecondLine = ETrue;
       
   163     //if there is modification
       
   164     UpdateWlanListL();
       
   165     
       
   166     UpdateParentViewL();
       
   167     
       
   168     CLOG_LEAVEFN( "CWlanPluginWlanState::WlanListChangedL()" );    
       
   169     }
       
   170 
       
   171 // ---------------------------------------------------------
       
   172 // CWlanPluginWlanState::NotifyEngineError
       
   173 // ---------------------------------------------------------
       
   174 void CWlanPluginWlanState::NotifyEngineError( TInt /*aError*/ )
       
   175     {
       
   176     CLOG_ENTERFN( "CWlanPluginWlanState::NotifyEngineError()" ); 
       
   177     
       
   178     iScanning = EFalse;
       
   179     
       
   180     CLOG_LEAVEFN( "CWlanPluginWlanState::NotifyEngineError()" );
       
   181     }
       
   182 
       
   183 // ---------------------------------------------------------
       
   184 // CWlanPluginWlanState::ScanDisabledL
       
   185 // ---------------------------------------------------------
       
   186 void CWlanPluginWlanState::ScanDisabledL()
       
   187     {
       
   188     CLOG_ENTERFN( "CWlanPluginWlanState::ScanDisabledL()" ); 
       
   189     
       
   190     iScanning = EFalse;
       
   191     //UpdateWlanListL();
       
   192     UpdateParentViewL();
       
   193     
       
   194     CLOG_LEAVEFN( "CWlanPluginWlanState::ScanDisabledL()" );    
       
   195     }
       
   196 
       
   197 // ---------------------------------------------------------
       
   198 // CWlanPluginWlanState::ScanEnabledL
       
   199 // ---------------------------------------------------------
       
   200 void CWlanPluginWlanState::ScanEnabledL()
       
   201     {
       
   202     CLOG_ENTERFN( "CWlanPluginWlanState::ScanEnabledL()" ); 
       
   203     
       
   204     // plugin has enabled scanning - background scan is on
       
   205     if ( iExplicitScanning )
       
   206         {
       
   207         CLOG_WRITE( "Refresh scan results" );
       
   208         iEngine->RefreshScanL();
       
   209         }
       
   210     
       
   211     iScanning = ETrue;
       
   212     UpdateWlanListL();
       
   213     UpdateParentViewL();
       
   214         
       
   215     CLOG_LEAVEFN( "CWlanPluginWlanState::ScanEnabledL()" );
       
   216     }
       
   217 
       
   218 // ---------------------------------------------------------
       
   219 // CWlanPluginWlanState::WlanConnectionActivatedL
       
   220 // ---------------------------------------------------------    
       
   221 void CWlanPluginWlanState::WlanConnectionActivatedL( 
       
   222                                 const TDesC& /*aAccessPointName*/ )
       
   223     {
       
   224     CLOG_ENTERFN( "CWlanPluginWlanState::WlanConnectionActivatedL()" );   
       
   225     
       
   226     iConnected = ETrue;
       
   227     iEngine->GetConnectedWlanDetailsL( iConnectedWlanInfo );
       
   228     UpdateParentViewL();
       
   229                 
       
   230     CLOG_LEAVEFN( "CWlanPluginWlanState::WlanConnectionActivatedL()" );
       
   231     }
       
   232 
       
   233 // ---------------------------------------------------------
       
   234 // CWlanPluginWlanState::WlanConnectionClosedL
       
   235 // ---------------------------------------------------------    
       
   236 void CWlanPluginWlanState::WlanConnectionClosedL()
       
   237     {
       
   238     CLOG_ENTERFN( "CWlanPluginWlanState::WlanConnectionClosedL()" );    
       
   239     
       
   240     iConnected = EFalse;
       
   241     if( iScanning )
       
   242         {
       
   243         UpdateWlanListL();
       
   244         }
       
   245         
       
   246     UpdateParentViewL();
       
   247     
       
   248     CLOG_LEAVEFN( "CWlanPluginWlanState::WlanConnectionClosedL()" );
       
   249     }
       
   250 
       
   251 // ---------------------------------------------------------------------------
       
   252 // CWlanPluginWlanState::ConnectionCreationProcessFinishedL
       
   253 // ---------------------------------------------------------------------------
       
   254 //
       
   255 void CWlanPluginWlanState::ConnectionCreationProcessFinishedL( TInt /*aResult*/ )
       
   256     {
       
   257     // no implementation required
       
   258     }
       
   259 
       
   260 // ---------------------------------------------------------
       
   261 // CWlanPluginWlanState::GetStateStringL
       
   262 // ---------------------------------------------------------
       
   263 void CWlanPluginWlanState::GetStateStringL( TDes& aDes )
       
   264     {
       
   265     CLOG_ENTERFN( "CWlanPluginWlanState::GetStateStringL()" ); 
       
   266     
       
   267     if( !iValidSecondLine )
       
   268     	{
       
   269         return;
       
   270     	}
       
   271     
       
   272     //make the string according to it
       
   273     HBufC* statestring = NULL;
       
   274     MakeStateStringL( iInfoArray, statestring );
       
   275     aDes.Copy( statestring->Des() );
       
   276     
       
   277     //keep it to decide later if it changed
       
   278     delete iPresentString; 
       
   279     iPresentString = statestring;
       
   280     
       
   281     CLOG_LEAVEFN( "CWlanPluginWlanState::GetStateStringL()" );
       
   282     }
       
   283 
       
   284 // ---------------------------------------------------------
       
   285 // CWlanPluginWlanState::MakeStateStringL
       
   286 // ---------------------------------------------------------    
       
   287 void CWlanPluginWlanState::MakeStateStringL(
       
   288                             CWsfWlanInfoArray* aArray, HBufC*& aBuf )
       
   289     {
       
   290     CLOG_ENTERFN( "CWlanPluginWlanState::MakeStateStringL()" ); 
       
   291     
       
   292     if( iConnected )
       
   293         {
       
   294         CLOG_ENTERFN( "Connected format needed" );
       
   295         FormatConnectedL( aBuf );	
       
   296         }
       
   297     else if ( !iScanning )
       
   298         {
       
   299         CLOG_ENTERFN( "Offline format needed" );
       
   300         FormatStatusOffL( aBuf );        
       
   301         }
       
   302     // if there's wlans avail
       
   303     else if ( aArray && aArray->Count() )
       
   304         {
       
   305         CLOG_ENTERFN( "wlans/wlan format needed" );
       
   306         CheckWlansL( aArray, aBuf );            
       
   307         }
       
   308     else 
       
   309         {
       
   310         // no wlans available
       
   311         CLOG_ENTERFN( "No wlan format needed" );
       
   312         FormatNoWlansAvailableL( aBuf );
       
   313         }
       
   314     
       
   315     CLOG_LEAVEFN( "CWlanPluginWlanState::MakeStateStringL()" );
       
   316     }
       
   317     
       
   318 // ---------------------------------------------------------
       
   319 // CWlanPluginWlanState::FormatConnectedL
       
   320 // ---------------------------------------------------------    
       
   321 void CWlanPluginWlanState::FormatConnectedL( HBufC*& aBuf )
       
   322     {
       
   323     CLOG_ENTERFN( "CWlanPluginWlanState::FormatConnectedL()" ); 
       
   324     
       
   325     //Ssid as primary text
       
   326     HBufC* ssid( NULL );
       
   327     
       
   328     if ( iConnectedWlanInfo.iNetworkName.Length() ) // If there is IAP
       
   329         {
       
   330         ssid = iConnectedWlanInfo.GetIapNameAsUnicodeLC();
       
   331         }
       
   332     else // If there no IAP
       
   333         {
       
   334         ssid = iConnectedWlanInfo.GetSsidAsUnicodeLC();
       
   335         }
       
   336     
       
   337     aBuf = StringLoader::LoadL( R_QTN_CP_DETAIL_WLAN_CONNECTED, 
       
   338                        *ssid );
       
   339                        
       
   340     CleanupStack::PopAndDestroy( ssid );
       
   341     
       
   342     CLOG_LEAVEFN( "CWlanPluginWlanState::FormatConnectedL()" );
       
   343     }
       
   344 
       
   345 
       
   346 // ---------------------------------------------------------
       
   347 // CWlanPluginWlanState::FormatStatusOffL
       
   348 // ---------------------------------------------------------    
       
   349 void CWlanPluginWlanState::FormatStatusOffL( HBufC*& aBuf )
       
   350     {
       
   351     CLOG_ENTERFN( "CWlanPluginWlanState::FormatStatusOffL()" ); 
       
   352     
       
   353     aBuf = StringLoader::LoadL( R_QTN_CP_DETAIL_WLAN_SCAN_OFF );
       
   354     
       
   355     CLOG_LEAVEFN( "CWlanPluginWlanState::FormatStatusOffL()" );
       
   356     }
       
   357 
       
   358 // ---------------------------------------------------------
       
   359 // CWlanPluginWlanState::FormatNoWlansAvailableL
       
   360 // ---------------------------------------------------------    
       
   361 void CWlanPluginWlanState::FormatNoWlansAvailableL( HBufC*& aBuf )
       
   362     { 
       
   363     CLOG_ENTERFN( "CWlanPluginWlanState::FormatNoWlansAvailableL()" ); 
       
   364       
       
   365     aBuf = StringLoader::LoadL( R_QTN_CP_DETAIL_WLAN_NO_NW_AVAILABLE );
       
   366     
       
   367     CLOG_LEAVEFN( "CWlanPluginWlanState::FormatNoWlansAvailableL()" );
       
   368     }
       
   369 
       
   370 // ---------------------------------------------------------
       
   371 // CWlanPluginWlanState::CheckWlansL
       
   372 // ---------------------------------------------------------    
       
   373 void CWlanPluginWlanState::CheckWlansL( CWsfWlanInfoArray* aArray, 
       
   374                                     HBufC*& aBuf )
       
   375     {
       
   376     CLOG_ENTERFN( "CWlanPluginWlanState::CheckWlansL()" ); 
       
   377 
       
   378     if ( aArray->At( 0 )->Known() )
       
   379         {
       
   380         FormatWlanSingleLineL( *aArray->At( 0 ), aBuf );
       
   381         return;
       
   382         }
       
   383     TBool multipleUnknownWlans = ( aArray->Count() > 1 );
       
   384     FormatUnknownWlansSingleLineL( multipleUnknownWlans, aBuf );    
       
   385     
       
   386     CLOG_LEAVEFN( "CWlanPluginWlanState::CheckWlansL()" );
       
   387     }
       
   388 
       
   389 // ---------------------------------------------------------
       
   390 // CWlanPluginWlanState::FormatWlanSingleLineL
       
   391 // ---------------------------------------------------------     
       
   392 void CWlanPluginWlanState::FormatWlanSingleLineL( 
       
   393                                      TWsfWlanInfo& aWlan, HBufC*& aBuf )
       
   394     {
       
   395     CLOG_ENTERFN( "CWlanPluginWlanState::FormatWlanSingleLineL()" ); 
       
   396     
       
   397         //Ssid as primary text
       
   398     HBufC* ssid( NULL );
       
   399     
       
   400     if ( aWlan.iNetworkName.Length() ) // If there is IAP
       
   401         {
       
   402         ssid = aWlan.GetIapNameAsUnicodeLC();
       
   403         }
       
   404     else // If there no IAP
       
   405         {
       
   406         ssid = aWlan.GetSsidAsUnicodeLC();
       
   407         }
       
   408         
       
   409     TInt formatResource = R_QTN_CP_DETAIL_WLAN_KNOWN_NW_AVAILABLE; 
       
   410     
       
   411     aBuf = StringLoader::LoadL ( formatResource, *ssid );
       
   412    
       
   413     CleanupStack::PopAndDestroy( ssid );            
       
   414     
       
   415     CLOG_LEAVEFN( "CWlanPluginWlanState::FormatWlanSingleLineL()" );
       
   416     }
       
   417 
       
   418 // ---------------------------------------------------------
       
   419 // CWlanPluginWlanState::FormatUnknownWlansSingleLineL
       
   420 // ---------------------------------------------------------
       
   421 void CWlanPluginWlanState::FormatUnknownWlansSingleLineL( 
       
   422                         const TBool aMultipleUnknownWlans, HBufC*& aBuf )
       
   423     {
       
   424     CLOG_ENTERFN( "CWlanPluginWlanState::FormatUnknownWlansSingleLineL()" ); 
       
   425     
       
   426     TInt unknownItemResource = aMultipleUnknownWlans ? 
       
   427                         R_QTN_CP_DETAIL_WLAN_NETWORKS_AVAILABLE :
       
   428                         R_QTN_CP_DETAIL_WLAN_NETWORK_AVAILABLE;
       
   429 
       
   430     aBuf = StringLoader::LoadL( unknownItemResource );
       
   431                 
       
   432     CLOG_LEAVEFN( "CWlanPluginWlanState::FormatUnknownWlansSingleLineL()" );   
       
   433     } 
       
   434 
       
   435 // ---------------------------------------------------------
       
   436 // CWlanPluginWlanState::GetMainIconL
       
   437 // ---------------------------------------------------------    
       
   438 TBool CWlanPluginWlanState::GetMainIconL( TInt& aPic, 
       
   439 		                                  TInt& aPicMask,
       
   440 		                                  TAknsItemID& aItemId )
       
   441     {
       
   442     CLOG_ENTERFN( "CWlanPluginWlanState::GetMainIconL()" ); 
       
   443     
       
   444     if( !iValidSecondLine )
       
   445         {
       
   446         aPic = EMbmWlanpluginQgn_prop_set_conn_wlan;
       
   447         aPicMask = EMbmWlanpluginQgn_prop_set_conn_wlan_mask;  
       
   448         aItemId = KAknsIIDQgnPropSetConnWlanConn;
       
   449         CLOG_LEAVEFN( "CWlanPluginWlanState::GetMainIconL()" );
       
   450         return ETrue;
       
   451         }
       
   452     
       
   453     if( !iSupressTimeShifter)
       
   454         {
       
   455         iSupressTimeShifter = EFalse;
       
   456         CLOG_WRITE(" Time shifter start not supressed ");
       
   457         if( !iTimeShifter )
       
   458             {
       
   459         	CLOG_WRITE(" Time shifter started ");
       
   460             iSupressTimeShifter = ETrue;
       
   461             iTimeShifter = CWlanPluginTimeShifter::NewL( this );
       
   462             iTimeShifter->ActivateIt();
       
   463             }
       
   464         }
       
   465     else
       
   466         {
       
   467         CLOG_WRITE(" Time shifter start supressed ");
       
   468         iSupressTimeShifter = EFalse;
       
   469         }
       
   470     if( iConnected )
       
   471         {
       
   472         //CONNECTED
       
   473         aPic = EMbmWlanpluginQgn_prop_set_conn_wlan_conn;
       
   474         aPicMask = EMbmWlanpluginQgn_prop_set_conn_wlan_conn_mask;
       
   475         aItemId = KAknsIIDQgnPropSetConnWlanConn;
       
   476         }
       
   477     else if( iScanning )
       
   478         {
       
   479         //SCANNING BUT NOT CONNECTED
       
   480         aPic = EMbmWlanpluginQgn_prop_set_conn_wlan;
       
   481         aPicMask = EMbmWlanpluginQgn_prop_set_conn_wlan_mask;  
       
   482         aItemId = KAknsIIDQgnPropSetConnWlanConn;
       
   483         }
       
   484     else
       
   485         {
       
   486         //SCANNING DISABLED
       
   487         aPic = EMbmWlanpluginQgn_prop_set_conn_wlan_off;
       
   488         aPicMask = EMbmWlanpluginQgn_prop_set_conn_wlan_off_mask;
       
   489         aItemId = KAknsIIDQgnPropSetConnWlanOff;
       
   490         }
       
   491               
       
   492     CLOG_LEAVEFN( "CWlanPluginWlanState::GetMainIconL()" );
       
   493     return ETrue;
       
   494     }
       
   495 
       
   496 // ---------------------------------------------------------
       
   497 // CWlanPluginWlanState::GetStrengthIconL
       
   498 // ---------------------------------------------------------        
       
   499 TBool CWlanPluginWlanState::GetStrengthIconL( TInt& aPic, 
       
   500 		                                      TInt& aPicMask, 
       
   501 		                                      TAknsItemID& aItemId)
       
   502     {
       
   503     CLOG_ENTERFN( "CWlanPluginWlanState::GetStrengthIconL()" ); 
       
   504     
       
   505     if( !iValidSecondLine )
       
   506     	{
       
   507         return EFalse;
       
   508     	}
       
   509     if ( iConnected )
       
   510         {
       
   511         switch( iConnectedWlanInfo.SignalStrength() )
       
   512             {
       
   513             case EPoor:
       
   514                 aPic = EMbmWlanpluginQgn_indi_wlan_signal_low_add;
       
   515                 aPicMask = EMbmWlanpluginQgn_indi_wlan_signal_low_add_mask;
       
   516                 aItemId = KAknsIIDQgnIndiWlanSignalLowAdd;
       
   517                 break;    
       
   518             case EAverage:
       
   519                 aPic = EMbmWlanpluginQgn_indi_wlan_signal_med_add;
       
   520                 aPicMask = EMbmWlanpluginQgn_indi_wlan_signal_med_add_mask;
       
   521                 aItemId = KAknsIIDQgnIndiWlanSignalMedAdd;
       
   522                 break;
       
   523             case EExcelent:
       
   524                 aPic = EMbmWlanpluginQgn_indi_wlan_signal_good_add;
       
   525                 aPicMask = EMbmWlanpluginQgn_indi_wlan_signal_good_add_mask;
       
   526                 aItemId = KAknsIIDQgnIndiWlanSignalGoodAdd;
       
   527                 break;
       
   528             default:
       
   529                 aPic = EMbmWlanpluginQgn_indi_wlan_signal_low_add;
       
   530                 aPicMask = EMbmWlanpluginQgn_indi_wlan_signal_low_add_mask;
       
   531                 aItemId = KAknsIIDQgnIndiWlanSignalLowAdd;
       
   532             }
       
   533         iSignalStrength = iConnectedWlanInfo.SignalStrength();
       
   534         CLOG_LEAVEFN( "CWlanPluginWlanState::GetStrengthIconL()" );
       
   535         return ETrue;
       
   536         }
       
   537     iSignalStrength = ENoSignal;            
       
   538     
       
   539     CLOG_LEAVEFN( "CWlanPluginWlanState::GetStrengthIconL()" );
       
   540     
       
   541     return EFalse;    
       
   542     }
       
   543 
       
   544 // ---------------------------------------------------------
       
   545 // CWlanPluginWlanState::IsStateChangedL
       
   546 // ---------------------------------------------------------    
       
   547 TBool CWlanPluginWlanState::IsStateChangedL()
       
   548     {
       
   549     CLOG_ENTERFN( "CWlanPluginWlanState::IsStateChangedL()" ); 
       
   550 
       
   551     if ( !iPresentString ) 
       
   552         {
       
   553         CLOG_LEAVEFN( "CWlanPluginWlanState::IsStateChangedL()" );
       
   554         return ETrue;
       
   555         }
       
   556     //alloc a buf
       
   557     CLOG_WRITE( "CWlanPluginWlanState::IsStateChangedL - there is presentstring" );
       
   558     HBufC* buf = NULL;
       
   559        
       
   560     CLOG_WRITE( "CWlanPluginWlanState::IsStateChangedL - wlan list get" );
       
   561     //make the string that would be written out
       
   562     MakeStateStringL( iInfoArray, buf );
       
   563     
       
   564     CleanupStack::PushL( buf ); 
       
   565     
       
   566     CLOG_WRITE( "CWlanPluginWlanState::IsStateChangedL - state string made" );
       
   567     
       
   568     //decide if the string is the same as it was written before
       
   569     //and the connection state is the same
       
   570     TBool ret = 
       
   571             ( buf->Des().Compare( iPresentString->Des() ) ||
       
   572             iSignalStrength != GetSignalStrength() )
       
   573             ? ETrue : EFalse;  
       
   574     
       
   575     CLOG_WRITE( "CWlanPluginWlanState::IsStateChangedL - ret get" );
       
   576     
       
   577     CleanupStack::PopAndDestroy( buf );
       
   578         
       
   579     if( ret )
       
   580         {
       
   581         CLOG_WRITE( "State Changed" );   
       
   582         }
       
   583     else
       
   584         {
       
   585         CLOG_WRITE( "State NOT Changed" );
       
   586         }        
       
   587     
       
   588     CLOG_LEAVEFN( "CWlanPluginWlanState::IsStateChangedL()" );
       
   589     
       
   590     //just to have ETrue in all true cases
       
   591     return ret;
       
   592     }
       
   593    
       
   594 // ---------------------------------------------------------
       
   595 // CWlanPluginWlanState::GetSignalStrength
       
   596 // ---------------------------------------------------------    
       
   597 TWsfWlanSignalStrengthLevel CWlanPluginWlanState::GetSignalStrength()
       
   598     {
       
   599     CLOG_ENTERFN( "CWlanPluginWlanState::GetSignalStrength()" ); 
       
   600 
       
   601     if ( iConnected )
       
   602         {
       
   603         CLOG_LEAVEFN( "CWlanPluginWlanState::GetSignalStrength()" );
       
   604         return iConnectedWlanInfo.SignalStrength();
       
   605         }
       
   606     else 
       
   607         {
       
   608         CLOG_LEAVEFN( "CWlanPluginWlanState::GetSignalStrength()" );
       
   609         return ENoSignal;
       
   610         }
       
   611     }
       
   612 
       
   613 // ---------------------------------------------------------
       
   614 // CWlanPluginWlanState::IsScanning
       
   615 // ---------------------------------------------------------    
       
   616 TBool CWlanPluginWlanState::IsScanning()
       
   617     {
       
   618     CLOG_ENTERFN( "CWlanPluginWlanState::IsScanning()" ); 
       
   619     CLOG_LEAVEFN( "CWlanPluginWlanState::IsScanning()" );
       
   620     return iScanning;
       
   621     }
       
   622 
       
   623 // ---------------------------------------------------------
       
   624 // CWlanPluginWlanState::SetScanning
       
   625 // ---------------------------------------------------------    
       
   626 void CWlanPluginWlanState::SetScanningL( TBool aScanning )
       
   627     {
       
   628     CLOG_ENTERFN( "CWlanPluginWlanState::SetScanningL()" ); 
       
   629         
       
   630     if( aScanning )
       
   631         {
       
   632         iExplicitScanning++;
       
   633         if( iExplicitScanning == 1 && iEngine )
       
   634             {
       
   635             iEngine->EnableScanL(); 
       
   636             }
       
   637         }
       
   638     else 
       
   639         {
       
   640         iExplicitScanning--;
       
   641         if( iExplicitScanning == 0 && iEngine )
       
   642             {
       
   643             iEngine->DisableScanL(); 
       
   644             }
       
   645         }    
       
   646                    
       
   647     CLOG_LEAVEFN( "CWlanPluginWlanState::SetScanningL()" );
       
   648     }
       
   649 
       
   650 // ---------------------------------------------------------
       
   651 // CWlanPluginWlanState::UpdateParentViewL
       
   652 // ---------------------------------------------------------  
       
   653 void CWlanPluginWlanState::UpdateParentViewL()
       
   654     {
       
   655     CLOG_ENTERFN( "CWlanPluginWlanState::UpdateParentViewL()" );
       
   656     
       
   657     
       
   658     if( iSupressParentUpdate )
       
   659         {
       
   660         CLOG_WRITE( "Parent update suppressed" );  
       
   661         CLOG_LEAVEFN( "CWlanPluginWlanState::UpdateParentViewL()" );
       
   662         return;
       
   663         }
       
   664         
       
   665     iSupressParentUpdate = ETrue;
       
   666     
       
   667     if ( IsStateChangedL() )
       
   668         {
       
   669         iSupressTimeShifter = ETrue;
       
   670         iParent->UpdateView();
       
   671         }
       
   672     else
       
   673     	{
       
   674     	iSupressTimeShifter = EFalse;
       
   675     	}
       
   676         
       
   677     iSupressParentUpdate = EFalse;
       
   678     
       
   679     CLOG_LEAVEFN( "CWlanPluginWlanState::UpdateParentViewL()" );
       
   680     } 
       
   681     
       
   682 // ---------------------------------------------------------
       
   683 // CWlanPluginWlanState::UpdateWlanListL
       
   684 // ---------------------------------------------------------  
       
   685 void CWlanPluginWlanState::UpdateWlanListL()
       
   686     {
       
   687     CLOG_ENTERFN( "CWlanPluginWlanState::UpdateWlanListL()" );
       
   688     if( iSupressUpdateWlan )
       
   689         {
       
   690         CLOG_WRITE( "Update WLAN List supressed" );
       
   691         CLOG_LEAVEFN( "CWlanPluginWlanState::UpdateWlanListL()" );
       
   692         return;
       
   693         }
       
   694     
       
   695     iSupressUpdateWlan = ETrue; 
       
   696     
       
   697     TRAPD( error,
       
   698     iInfoArray = iEngine->GetWlanListL();
       
   699     
       
   700     if( iConnected )
       
   701         {
       
   702         iEngine->GetConnectedWlanDetailsL( iConnectedWlanInfo );
       
   703         }
       
   704     
       
   705     iWlanInfoBranding->LoadFilterDefinitionsL();
       
   706     
       
   707     iInfoArray->SortArrayL( *iWlanInfoBranding );
       
   708     );
       
   709     
       
   710     if ( error != KErrNone )
       
   711         {
       
   712         CLOG_WRITE( "Fetching wlan data leaved" );
       
   713         // Reset the temporary flag so that wlan list 
       
   714         // updates are not completely suppressed 
       
   715         iSupressUpdateWlan = EFalse;
       
   716         User::Leave( error );
       
   717         }
       
   718     
       
   719 #ifdef _DEBUG    
       
   720     if( iInfoArray )
       
   721         {
       
   722         if( iInfoArray->Count() <=0 )
       
   723             {
       
   724             CLOG_WRITE( "EMPTY ARRAY" );
       
   725             }
       
   726         for(TInt i = 0; i< iInfoArray->Count(); i++)
       
   727             {
       
   728             
       
   729             CLOG_WRITE( "----AP----" );
       
   730             HBufC* buf = iInfoArray->At( i )->GetSsidAsUnicodeLC();
       
   731             CLOG_WRITEF(_L("AP: %S"), ( buf ) );
       
   732             CleanupStack::PopAndDestroy( buf );
       
   733             if( iInfoArray->At( i )->Connected() )
       
   734                 {
       
   735                 CLOG_WRITE( "--Connected--" );
       
   736                 }
       
   737             else
       
   738                 {
       
   739                 CLOG_WRITE( "--NOT Connected--" );
       
   740                 }
       
   741             if( iInfoArray->At( i )->Known() )
       
   742                 {
       
   743                 CLOG_WRITE( "--Known--" );
       
   744                 }
       
   745             else
       
   746                 {
       
   747                 CLOG_WRITE( "--NOT Known--" );
       
   748                 }    
       
   749             }
       
   750         }
       
   751     else
       
   752         {
       
   753         CLOG_ENTERFN( "NO ARRAY" );
       
   754         }
       
   755 #endif
       
   756     
       
   757     iSupressUpdateWlan = EFalse;
       
   758     CLOG_LEAVEFN( "CWlanPluginWlanState::UpdateWlanListL()" );
       
   759     }
       
   760     
       
   761 // ---------------------------------------------------------
       
   762 // CWlanPluginWlanState::DirectlyScan
       
   763 // ---------------------------------------------------------      
       
   764 void CWlanPluginWlanState::DirectlyScanL()
       
   765     {
       
   766     CLOG_ENTERFN( "CWlanPluginWlanState::DirectlyScan()" );
       
   767     if ( iExplicitScanning && iParent->IsForeground())
       
   768         {
       
   769         iEngine->RefreshScanL();
       
   770         }
       
   771     CLOG_LEAVEFN( "CWlanPluginWlanState::DirectlyScan()" );
       
   772     }
       
   773 
       
   774 // ---------------------------------------------------------
       
   775 // CWlanPluginWlanState::DeleteTimeShifter
       
   776 // ---------------------------------------------------------          
       
   777 void CWlanPluginWlanState::DeleteTimeShifter()
       
   778     {
       
   779     CLOG_ENTERFN( "CWlanPluginWlanState::DeleteTimeShifter()" );
       
   780     delete iTimeShifter;
       
   781     iTimeShifter = NULL;
       
   782     CLOG_LEAVEFN( "CWlanPluginWlanState::DeleteTimeShifter()" );
       
   783     }