wlanutilities/wlansniffer/mainapplication/src/wsfdetailsviewmodel.cpp
changeset 19 10810c91db26
parent 3 ff3b37722600
child 22 498f36116140
equal deleted inserted replaced
3:ff3b37722600 19:10810c91db26
     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 CWsfDetailsViewModel.
       
    15 *
       
    16 */
       
    17 
       
    18 //  EXTERNAL INCLUDES
       
    19 #include <badesca.h>
       
    20 #include <StringLoader.h> 
       
    21 #include <wlansniffer.rsg>
       
    22 #include <coemain.h>
       
    23 #include <avkon.rsg>
       
    24 #include <cmpluginwlandef.h>
       
    25 #include <cmmanager.h>
       
    26 #include <cmconnectionmethod.h>
       
    27 #include <rconnmon.h>
       
    28 
       
    29 //  INTERNAL INCLUDES
       
    30 #include "wsfwlaninfo.h"
       
    31 #include "wsfdetailsviewmodel.h"
       
    32 #include "wsfwlaninfoarray.h"
       
    33 #include "wsflogger.h"
       
    34 
       
    35 //  LOCAL DEFINITIONS
       
    36 using namespace CMManager;
       
    37 
       
    38 #ifdef _DEBUG
       
    39     _LIT( KDetailsViewModelPanic, "CWsfDetailsViewModel" );
       
    40     #define _ASSERTD( cond ) __ASSERT_DEBUG( (cond), \
       
    41             User::Panic( KDetailsViewModelPanic, __LINE__) )
       
    42 #else
       
    43     #define _ASSERTD( cond ) {}
       
    44 #endif //_DEBUG
       
    45 
       
    46 // the size of the Details Listbox's array
       
    47 const TInt KWlanInfoGranularity = 8;
       
    48 // the size of the numbers in the NaviPane
       
    49 const TInt KNumberLegth = 5;
       
    50 // Listbox elements format string
       
    51 _LIT( KListItemFormat, "%S\t%S" );
       
    52 // NaviPane elements format string
       
    53 _LIT( KPaneFormater, "%i/%i" ); 
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // CWsfDetailsViewModel::CWsfDetailsViewModel()
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CWsfDetailsViewModel::CWsfDetailsViewModel():iCoeEnv( CCoeEnv::Static() )
       
    60     {
       
    61     }
       
    62     
       
    63 // ---------------------------------------------------------------------------
       
    64 // CWsfDetailsViewModel::ConstructL()
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 void CWsfDetailsViewModel::ConstructL()
       
    68     {
       
    69     LOG_ENTERFN( "CWsfDetailsViewModel::ConstructL" );    
       
    70     iFormattedWlanInfo = new (ELeave) CDesCArrayFlat( KWlanInfoGranularity );
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CWsfDetailsViewModel::NewL()
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 EXPORT_C CWsfDetailsViewModel* CWsfDetailsViewModel::NewL()
       
    78     {
       
    79     LOG_ENTERFN( "CWsfDetailsViewModel::NewL" );    
       
    80     CWsfDetailsViewModel* self = CWsfDetailsViewModel::NewLC();
       
    81     CleanupStack::Pop( self );
       
    82     return self;
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // CWsfDetailsViewModel::NewLC()
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 EXPORT_C CWsfDetailsViewModel* CWsfDetailsViewModel::NewLC()
       
    90     {
       
    91     LOG_ENTERFN( "CWsfDetailsViewModel::NewLC" );
       
    92     CWsfDetailsViewModel* self = new( ELeave ) CWsfDetailsViewModel;
       
    93     CleanupStack::PushL( self );
       
    94     self->ConstructL();
       
    95     return self;
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // CWsfDetailsViewModel::~CWsfDetailsViewModel()
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 CWsfDetailsViewModel::~CWsfDetailsViewModel()
       
   103     {
       
   104     LOG_ENTERFN( "CWsfDetailsViewModel::~CWsfDetailsViewModel" );
       
   105     delete iFormattedWlanInfo;
       
   106     }
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 // CWsfDetailsViewModel::FormatWlanInfoL()
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 CDesCArrayFlat* CWsfDetailsViewModel::FormatWlanInfoL( 
       
   113                                             TWsfWlanInfo* aWlanInfo, 
       
   114                                             CWsfWlanInfoArray* aWlanArray )
       
   115     {
       
   116     LOG_ENTERFN( "CWsfDetailsViewModel::FormatWlanInfoL" );    
       
   117     _ASSERTD( aWlanArray );
       
   118 
       
   119     for( TInt i = 0; i < iFormattedWlanInfo->MdcaCount(); i++)
       
   120         {
       
   121         TPtrC temp = iFormattedWlanInfo->MdcaPoint( i );
       
   122         TBuf<100> tempElement = temp;
       
   123         LOG_WRITEF( "(1)iFormattedWlanInfo: %S", &tempElement );
       
   124         }
       
   125         
       
   126     iWlanArray = aWlanArray;
       
   127     iFormattedWlanInfo->Reset();
       
   128     
       
   129     // If Wlan if suppilied && arrays has items
       
   130     if ( aWlanInfo && VisibleWlans( *iWlanArray ) )
       
   131         {
       
   132         iWlanInfo = *aWlanInfo;
       
   133         TWsfWlanInfo* temp = iWlanArray->Match( aWlanInfo->iSsid, 
       
   134                                                 VisibleWlans( *iWlanArray ) );
       
   135         if ( temp )
       
   136             {
       
   137             iIndex = iWlanArray->GetArrayIndex( temp );
       
   138             }
       
   139         else 
       
   140             {
       
   141             iIndex = iWlanArray->GetArrayIndex( &iWlanInfo );
       
   142             }
       
   143 
       
   144         // create array of not-connected WLAN data 
       
   145         FormatAndAppenWlanIapNameL();           
       
   146         FormatAndAppenWlanSsidL();
       
   147         FormatAndAppenSingnalL();
       
   148         FormatAndAppenModeL();
       
   149         FormatAndAppenSecurityL();
       
   150         FormatAndAppenCoverageL();
       
   151         FormatAndAppenSpeedL();
       
   152         }
       
   153     else if ( !aWlanInfo )// Current Wlan info has no signal
       
   154         {
       
   155         iWlanInfo.iStrengthLevel = EWlanSignalUnavailable;
       
   156         FormatAndAppenWlanIapNameL();
       
   157         FormatAndAppenWlanSsidL();
       
   158         FormatAndAppenSingnalL();
       
   159         }
       
   160 
       
   161     for( TInt i = 0; i < iFormattedWlanInfo->MdcaCount(); i++)
       
   162         {
       
   163         TPtrC temp = iFormattedWlanInfo->MdcaPoint( i );
       
   164         TBuf<100> tempElement = temp;
       
   165         LOG_WRITEF( "(2)iFormattedWlanInfo: %S", &tempElement );
       
   166         }
       
   167                 
       
   168     return iFormattedWlanInfo;
       
   169     }
       
   170    
       
   171 // ---------------------------------------------------------------------------
       
   172 // CWsfDetailsViewModel::FormatNextWlanInfoL()
       
   173 // ---------------------------------------------------------------------------
       
   174 //
       
   175 
       
   176 CDesCArrayFlat* CWsfDetailsViewModel::FormatNextWlanInfoL()
       
   177     {
       
   178     LOG_ENTERFN( "CWsfDetailsViewModel::FormatNextWlanInfoL" );
       
   179     _ASSERTD( iWlanArray );
       
   180         
       
   181     if( iIndex < VisibleWlans( *iWlanArray ) - 1 )
       
   182         {
       
   183         iFormattedWlanInfo->Reset();
       
   184         iIndex++;
       
   185         
       
   186         if( iIndex >= VisibleWlans( *iWlanArray ) -1 )
       
   187             {
       
   188             iIndex = VisibleWlans( *iWlanArray ) -1;
       
   189             }
       
   190         else if ( iWlanInfo.SignalStrength() == ENoSignal )
       
   191             {
       
   192             iIndex = 0;
       
   193             }
       
   194             
       
   195         iWlanInfo = *(iWlanArray->At( iIndex ) );
       
   196         FormatAndAppenWlanIapNameL();
       
   197         FormatAndAppenWlanSsidL();
       
   198         FormatAndAppenSingnalL();
       
   199         FormatAndAppenModeL();
       
   200         FormatAndAppenSecurityL();
       
   201         FormatAndAppenCoverageL();
       
   202         FormatAndAppenSpeedL();
       
   203         }
       
   204         
       
   205     return iFormattedWlanInfo;      
       
   206     }
       
   207 
       
   208    
       
   209     
       
   210 // ---------------------------------------------------------------------------
       
   211 // CWsfDetailsViewModel::FormatPreviousWlanInfoL()
       
   212 // ---------------------------------------------------------------------------
       
   213 //
       
   214 
       
   215 CDesCArrayFlat* CWsfDetailsViewModel::FormatPreviousWlanInfoL()
       
   216     {
       
   217     LOG_ENTERFN( "CWsfDetailsViewModel::FormatPreviousWlanInfoL" );
       
   218     _ASSERTD( iWlanArray );
       
   219     
       
   220   
       
   221     if( VisibleWlans( *iWlanArray )  )
       
   222         {
       
   223         iFormattedWlanInfo->Reset();
       
   224         iIndex--;
       
   225         
       
   226         if ( iIndex < 0 || iWlanInfo.SignalStrength() == ENoSignal )
       
   227             {
       
   228             iIndex = 0;
       
   229             }
       
   230                        
       
   231         iWlanInfo = *(iWlanArray->At( iIndex ) );
       
   232         FormatAndAppenWlanIapNameL();
       
   233         FormatAndAppenWlanSsidL();
       
   234         FormatAndAppenSingnalL();
       
   235         FormatAndAppenModeL();
       
   236         FormatAndAppenSecurityL();
       
   237         FormatAndAppenCoverageL();
       
   238         FormatAndAppenSpeedL();
       
   239         }
       
   240     return iFormattedWlanInfo;
       
   241     }
       
   242 
       
   243 // ---------------------------------------------------------------------------
       
   244 // CWsfDetailsViewModel::FormatPaneTextLC()
       
   245 // ---------------------------------------------------------------------------
       
   246 //
       
   247 HBufC* CWsfDetailsViewModel::FormatPaneTextLC()
       
   248     {
       
   249     LOG_ENTERFN( "CWsfDetailsViewModel::FormatPaneTextLC" );
       
   250     HBufC* paneText = NULL;
       
   251     
       
   252     if ( iWlanInfo.SignalStrength() == ENoSignal )
       
   253         {
       
   254         paneText = KNullDesC().AllocLC();
       
   255         }
       
   256     else
       
   257         {
       
   258         if( VisibleWlans( *iWlanArray ) )
       
   259             {
       
   260             paneText = HBufC::NewLC( KPaneFormater().Length() + 
       
   261                                      KNumberLegth + 
       
   262                                      KNumberLegth );
       
   263                                         
       
   264             TPtr paneTextPrt = paneText->Des();
       
   265 
       
   266             // Format string ( KListItemFormat = %i/%i )
       
   267             paneTextPrt.Format( KPaneFormater, 
       
   268                                 iIndex + 1, 
       
   269                                 ( iWlanArray ) ? 
       
   270                                     VisibleWlans( *iWlanArray ) : 0 );
       
   271             }
       
   272         else
       
   273             {
       
   274             paneText = KNullDesC().AllocLC();
       
   275             }        
       
   276         }
       
   277         
       
   278     return paneText;
       
   279     }
       
   280 
       
   281 // ---------------------------------------------------------------------------
       
   282 // CWsfDetailsViewModel::FormatLeftScrollButton()
       
   283 // ---------------------------------------------------------------------------
       
   284 //
       
   285 TBool CWsfDetailsViewModel::FormatLeftScrollButton()
       
   286     {
       
   287     LOG_ENTERFN( "CWsfDetailsViewModel::FormatLeftScrollButton" );
       
   288     TBool leftButton( EFalse );
       
   289     
       
   290     if ( iIndex == 0 )
       
   291         {
       
   292         leftButton = ETrue;
       
   293         }
       
   294     
       
   295     return leftButton;
       
   296     }
       
   297 
       
   298 // ---------------------------------------------------------------------------
       
   299 // CWsfDetailsViewModel::FormatRightScrollButton()
       
   300 // ---------------------------------------------------------------------------
       
   301 //
       
   302 TBool CWsfDetailsViewModel::FormatRightScrollButton()
       
   303     {
       
   304     LOG_ENTERFN( "CWsfDetailsViewModel::FormatRightScrollButton" );
       
   305     TBool rightButton( EFalse );
       
   306     TUint count = iWlanArray->Count();
       
   307     
       
   308     if ( iIndex + 1 >= count )
       
   309         {
       
   310         rightButton = ETrue;
       
   311         }
       
   312     
       
   313     return rightButton;
       
   314     }
       
   315     
       
   316 // ---------------------------------------------------------------------------
       
   317 // CWsfDetailsViewModel::GetWlanDetails()
       
   318 // ---------------------------------------------------------------------------
       
   319 //
       
   320 CDesCArrayFlat* CWsfDetailsViewModel::GetWlanDetails()
       
   321     {
       
   322     return iFormattedWlanInfo;
       
   323     }
       
   324 
       
   325 // ---------------------------------------------------------------------------
       
   326 // CWsfDetailsViewModel::WlanSsid()
       
   327 // ---------------------------------------------------------------------------
       
   328 //
       
   329 const TDesC8& CWsfDetailsViewModel::WlanSsid() const
       
   330     {
       
   331     return iWlanInfo.iSsid;
       
   332     }
       
   333 
       
   334 // ---------------------------------------------------------------------------
       
   335 // CWsfDetailsViewModel::FormatListBoxItemLC
       
   336 // ---------------------------------------------------------------------------
       
   337 //
       
   338 HBufC* CWsfDetailsViewModel::FormatListBoxItemLC( 
       
   339                                            const TUint aResourceId, 
       
   340                                            const TDesC& aValueText ) const
       
   341     {
       
   342     LOG_ENTERFN( "CWsfDetailsViewModel::FormatListBoxItemLC" );
       
   343   // hold the column name on list item
       
   344     HBufC* columnName = NULL;
       
   345  
       
   346     if ( aResourceId )
       
   347         {
       
   348         columnName = StringLoader::LoadLC( aResourceId );
       
   349         }
       
   350     else
       
   351         {
       
   352         columnName = KNullDesC().AllocLC();
       
   353         }
       
   354 
       
   355 
       
   356     // Holds the list box item
       
   357     HBufC* listBoxItem = HBufC::NewL( KListItemFormat().Length()+
       
   358                                       columnName->Length() + 
       
   359                                       aValueText.Length() );
       
   360 
       
   361     // For formating needs
       
   362     TPtr listBoxItemPrt = listBoxItem->Des();
       
   363 
       
   364     // Format string ( KListItemFormat = %S\t%S )
       
   365     listBoxItemPrt.Format( KListItemFormat, columnName, &aValueText );
       
   366     CleanupStack::PopAndDestroy( columnName );
       
   367     CleanupStack::PushL( listBoxItem );
       
   368     return listBoxItem;
       
   369     }
       
   370 
       
   371 // ---------------------------------------------------------------------------
       
   372 // CWsfDetailsViewModel::FormatAndAppenWlanIapNameL()
       
   373 // ---------------------------------------------------------------------------
       
   374 //
       
   375 void CWsfDetailsViewModel::FormatAndAppenWlanIapNameL()
       
   376     {
       
   377     LOG_ENTERFN( "CWsfDetailsViewModel::FormatAndAppenWlanIapNameL" );
       
   378     if ( iWlanInfo.iNetworkName.Length() )
       
   379         {
       
   380         HBufC* wlanIapName = iWlanInfo.GetIapNameAsUnicodeLC();
       
   381         HBufC* listBoxItem = FormatListBoxItemLC( 
       
   382                                 R_QTN_CMON_HEADING_CONN_NAME, 
       
   383                                 *wlanIapName );
       
   384                                               
       
   385         iFormattedWlanInfo->AppendL( *listBoxItem );
       
   386         CleanupStack::PopAndDestroy( listBoxItem );
       
   387         CleanupStack::PopAndDestroy( wlanIapName );
       
   388         }
       
   389     }
       
   390     
       
   391 // ---------------------------------------------------------------------------
       
   392 // CWsfDetailsViewModel::FormatAndAppenWlanSsidL()
       
   393 // ---------------------------------------------------------------------------
       
   394 //
       
   395 void CWsfDetailsViewModel::FormatAndAppenWlanSsidL()
       
   396     {
       
   397     LOG_ENTERFN( "CWsfDetailsViewModel::FormatAndAppenWlanSsidL" );
       
   398     HBufC* wlanSsid = iWlanInfo.GetSsidAsUnicodeLC();
       
   399     HBufC* listBoxItem = FormatListBoxItemLC( 
       
   400                                 R_QTN_SNIFFER_HEADING_WLAN_NETWORK_NAME, 
       
   401                                 *wlanSsid );
       
   402                                               
       
   403     iFormattedWlanInfo->AppendL( *listBoxItem );
       
   404     CleanupStack::PopAndDestroy( listBoxItem );
       
   405     CleanupStack::PopAndDestroy( wlanSsid );
       
   406     }
       
   407 
       
   408 // ---------------------------------------------------------------------------
       
   409 // CWsfDetailsViewModel::FormatAndAppenSingnalL()
       
   410 // ---------------------------------------------------------------------------
       
   411 //
       
   412 void CWsfDetailsViewModel::FormatAndAppenSingnalL() 
       
   413     {
       
   414     LOG_ENTERFN( "CWsfDetailsViewModel::FormatAndAppenSingnalL" );    
       
   415     HBufC* singnalStrength = FormatSingnalStrenghtLC();
       
   416     HBufC* listBoxItem = FormatListBoxItemLC( 
       
   417                                 R_QTN_SNIFFER_HEADING_WLAN_SIGNAL_STRENGTH, 
       
   418                                 *singnalStrength );
       
   419                                               
       
   420     iFormattedWlanInfo->AppendL( *listBoxItem );
       
   421     CleanupStack::PopAndDestroy( listBoxItem );
       
   422     CleanupStack::PopAndDestroy( singnalStrength );
       
   423     }
       
   424 
       
   425 // ---------------------------------------------------------------------------
       
   426 // CWsfDetailsViewModel::FormatAndAppenModeL()
       
   427 // ---------------------------------------------------------------------------
       
   428 //
       
   429 void CWsfDetailsViewModel::FormatAndAppenModeL()
       
   430     {
       
   431     LOG_ENTERFN( "CWsfDetailsViewModel::FormatAndAppenModeL" ); 
       
   432     HBufC* mode = FormatModeLC();
       
   433     HBufC* listBoxItem = FormatListBoxItemLC( 
       
   434                                 R_QTN_SNIFFER_HEADING_WLAN_NETWORK_MODE, 
       
   435                                 *mode );
       
   436                                               
       
   437     iFormattedWlanInfo->AppendL( *listBoxItem );
       
   438     CleanupStack::PopAndDestroy( listBoxItem );
       
   439     CleanupStack::PopAndDestroy( mode );
       
   440     }
       
   441 
       
   442 // ---------------------------------------------------------------------------
       
   443 // CWsfDetailsViewModel::FormatAndAppenSecurityL()
       
   444 // ---------------------------------------------------------------------------
       
   445 //
       
   446 void CWsfDetailsViewModel::FormatAndAppenSecurityL()
       
   447     {
       
   448     LOG_ENTERFN( "CWsfDetailsViewModel::FormatAndAppenSecurityL" );
       
   449     HBufC* security = FormatSecurityLC();
       
   450     HBufC* listBoxItem = FormatListBoxItemLC( 
       
   451                                 R_QTN_SNIFFER_HEADING_WLAN_SECURITY_MODE, 
       
   452                                 *security );
       
   453                                               
       
   454     iFormattedWlanInfo->AppendL( *listBoxItem );
       
   455     CleanupStack::PopAndDestroy( listBoxItem );
       
   456     CleanupStack::PopAndDestroy( security );
       
   457     }
       
   458 
       
   459 // ---------------------------------------------------------------------------
       
   460 // CWsfDetailsViewModel::FormatAndAppenCoverageL()
       
   461 // ---------------------------------------------------------------------------
       
   462 //
       
   463 void CWsfDetailsViewModel::FormatAndAppenCoverageL()
       
   464     {
       
   465     LOG_ENTERFN( "CWsfDetailsViewModel::FormatAndAppenCoverageL" );
       
   466     HBufC* coverage = FormatCoverageLC();
       
   467     HBufC* listBoxItem = FormatListBoxItemLC( 
       
   468                                 R_QTN_SNIFFER_HEADING_WLAN_NW_AP_AMOUNT, 
       
   469                                 *coverage );
       
   470                                               
       
   471     iFormattedWlanInfo->AppendL( *listBoxItem );
       
   472     CleanupStack::PopAndDestroy( listBoxItem );
       
   473     CleanupStack::PopAndDestroy( coverage );
       
   474     }
       
   475 
       
   476 // ---------------------------------------------------------------------------
       
   477 // CWsfDetailsViewModel::FormatAndAppenSpeedL()
       
   478 // ---------------------------------------------------------------------------
       
   479 //
       
   480 void CWsfDetailsViewModel::FormatAndAppenSpeedL()
       
   481     {
       
   482     LOG_ENTERFN( "CWsfDetailsViewModel::FormatAndAppenSpeedL" );
       
   483     HBufC* speed = FormatSpeedLC();
       
   484     HBufC* listBoxItem = FormatListBoxItemLC( 
       
   485                                 R_QTN_SNIFFER_HEADING_WLAN_NW_MAX_RATE, 
       
   486                                 *speed );
       
   487                                               
       
   488     iFormattedWlanInfo->AppendL( *listBoxItem );
       
   489     CleanupStack::PopAndDestroy( listBoxItem );
       
   490     CleanupStack::PopAndDestroy( speed );
       
   491     }
       
   492 
       
   493 // ---------------------------------------------------------------------------
       
   494 // CWsfDetailsViewModel::FormatSingnalStrenghtLC()
       
   495 // ---------------------------------------------------------------------------
       
   496 //
       
   497 HBufC* CWsfDetailsViewModel::FormatSingnalStrenghtLC()
       
   498     {
       
   499     LOG_ENTERFN( "CWsfDetailsViewModel::FormatSingnalStrenghtLC" );
       
   500     // Holds the showed signal strenth string
       
   501     HBufC* singnalStrengthString = NULL;
       
   502        
       
   503     // Get string
       
   504     switch( iWlanInfo.SignalStrength() )
       
   505         {
       
   506         case ENoSignal:
       
   507             {
       
   508             singnalStrengthString = StringLoader::LoadLC( 
       
   509                 R_QTN_SNIFFER_WLAN_SIGNAL_STRENGTH_NO_SIGNAL, iCoeEnv );   
       
   510             break; 
       
   511             }
       
   512         case EPoor:
       
   513             {
       
   514             singnalStrengthString = StringLoader::LoadLC ( 
       
   515                                     R_QTN_SNIFFER_WLAN_SIGNAL_STRENGTH_LOW, 
       
   516                                     iWlanInfo.SignalStrengthPercentage(), 
       
   517                                     iCoeEnv );                   
       
   518             break;
       
   519             }
       
   520         case EAverage:
       
   521             {
       
   522             singnalStrengthString = StringLoader::LoadLC ( 
       
   523                                 R_QTN_SNIFFER_WLAN_SIGNAL_STRENGTH_MEDIUM, 
       
   524                                 iWlanInfo.SignalStrengthPercentage(), 
       
   525                                 iCoeEnv );                                 
       
   526             break;
       
   527             }
       
   528         case EExcelent:
       
   529             {
       
   530             singnalStrengthString = StringLoader::LoadLC ( 
       
   531                                 R_QTN_SNIFFER_WLAN_SIGNAL_STRENGTH_STRONG, 
       
   532                                 iWlanInfo.SignalStrengthPercentage(), 
       
   533                                 iCoeEnv );                 
       
   534             break;
       
   535             }
       
   536         default:
       
   537             {
       
   538             return KNullDesC().AllocLC();  
       
   539             }
       
   540 
       
   541         }    
       
   542     return singnalStrengthString;  
       
   543     }
       
   544 
       
   545 // ---------------------------------------------------------
       
   546 // CWsfDetailsViewModel::FormatModeLC
       
   547 // ---------------------------------------------------------
       
   548 //
       
   549 HBufC* CWsfDetailsViewModel::FormatModeLC()
       
   550     {
       
   551     LOG_ENTERFN( "CWsfDetailsViewModel::FormatModeLC" );
       
   552     TInt resourceId(0);
       
   553     
       
   554     switch( iWlanInfo.iNetMode )
       
   555         {
       
   556         case EAdhoc:
       
   557             {
       
   558             resourceId = R_QTN_SNIFFER_WLAN_SETT_NEWTWORK_MODE_ADHOC;
       
   559             break;
       
   560             }
       
   561 
       
   562         case EInfra:
       
   563             {
       
   564             resourceId = R_QTN_SNIFFER_WLAN_SETT_NEWTWORK_MODE_INFRA;
       
   565             break;
       
   566             }
       
   567         default:
       
   568             {
       
   569             return KNullDesC().AllocLC();  
       
   570             }
       
   571 
       
   572         }
       
   573         
       
   574     return StringLoader::LoadLC( resourceId ); 
       
   575     }
       
   576 
       
   577 // ---------------------------------------------------------
       
   578 // CWsfDetailsViewModel::FormatSecurityLC
       
   579 // ---------------------------------------------------------
       
   580 //
       
   581 HBufC* CWsfDetailsViewModel::FormatSecurityLC()
       
   582     {
       
   583     LOG_ENTERFN( "CWsfDetailsViewModel::FormatSecurityLC" );
       
   584     TInt resourceId(0);
       
   585     
       
   586     switch( iWlanInfo.iSecurityMode )
       
   587         {
       
   588         
       
   589         case EWlanSecModeOpen:
       
   590             {
       
   591             resourceId = R_QTN_SNIFFER_WLAN_SETT_SECURITY_MODE_OPEN;
       
   592             break;
       
   593             }
       
   594         case EWlanSecModeWep:
       
   595             {
       
   596             resourceId = R_QTN_SNIFFER_WLAN_SETT_SECURITY_MODE_WEP;
       
   597             break;
       
   598             }
       
   599         case EWlanSecMode802_1x:
       
   600             {
       
   601             resourceId = R_QTN_SNIFFER_WLAN_SETT_SECURITY_MODE_802_1X;
       
   602             break;
       
   603             }
       
   604         case EWlanSecModeWpa:
       
   605         case EWlanSecModeWpa2:
       
   606             {
       
   607             resourceId = R_QTN_SNIFFER_WLAN_SETT_SECURITY_MODE_WPA;
       
   608             break;
       
   609             }
       
   610         case EWlanSecModeWAPI:
       
   611             {
       
   612             resourceId = R_QTN_SNIFFER_WLAN_SETT_SECURITY_MODE_WAPI;
       
   613             break;
       
   614             }
       
   615         default:
       
   616             {
       
   617             return KNullDesC().AllocLC();  
       
   618             }
       
   619         }
       
   620 
       
   621     return StringLoader::LoadLC( resourceId );        
       
   622     }
       
   623 
       
   624 // ---------------------------------------------------------------------------
       
   625 // CWsfDetailsViewModel::FormatCoverageLC
       
   626 // ---------------------------------------------------------------------------
       
   627 //
       
   628 HBufC* CWsfDetailsViewModel::FormatCoverageLC()
       
   629     {
       
   630     LOG_ENTERFN( "CWsfDetailsViewModel::FormatCoverageLC" );
       
   631     if ( iWlanInfo.iCoverage == 1)
       
   632         {
       
   633         return StringLoader::LoadLC( 
       
   634                             R_QTN_SNIFFER_WLAN_AP_AMOUNT_IN_RANGE, iCoeEnv ); 
       
   635         }
       
   636     else 
       
   637         {
       
   638         return StringLoader::LoadLC( 
       
   639                             R_QTN_SNIFFER_WLAN_AP_AMOUNT_IN_RANGE_MANY, 
       
   640                             iWlanInfo.iCoverage, iCoeEnv );    
       
   641         }
       
   642     }
       
   643 
       
   644 // ---------------------------------------------------------------------------
       
   645 // CWsfDetailsViewModel::FormatSpeedLC
       
   646 // ---------------------------------------------------------------------------
       
   647 //
       
   648 HBufC* CWsfDetailsViewModel::FormatSpeedLC()
       
   649     {
       
   650     LOG_ENTERFN( "CWsfDetailsViewModel::FormatSpeedLC" );
       
   651     //if data rate is allowed to be a fraction, 
       
   652     //rewrite this format string
       
   653     _LIT( KRateFmt, "%d" );
       
   654 
       
   655     const TInt KMaxRateStringWidth = 8;
       
   656     TBuf<KMaxRateStringWidth> rate;
       
   657     rate.Format( KRateFmt, iWlanInfo.iTransferRate );
       
   658     
       
   659     return StringLoader::LoadLC( R_QTN_SNIFFER_WLAN_MAX_DATA_RATE, 
       
   660                                  rate, iCoeEnv );
       
   661     }
       
   662 
       
   663 // ---------------------------------------------------------------------------
       
   664 // CWsfDetailsViewModel::VisibleWlans
       
   665 // ---------------------------------------------------------------------------
       
   666 //
       
   667 TInt CWsfDetailsViewModel::VisibleWlans( CWsfWlanInfoArray& aArray )
       
   668     {
       
   669     LOG_ENTERFN( "CWsfDetailsViewModel::VisibleWlans" );
       
   670     TInt i = 0;
       
   671     TBool hiddenFound = EFalse;
       
   672     TWsfWlanInfo* wlanInfo;
       
   673     LOG_WRITEF( "Number of Wlans: %d", aArray.Count() );
       
   674     while ( i < aArray.Count() && !hiddenFound )
       
   675         {
       
   676         wlanInfo = aArray[i];
       
   677         if ( wlanInfo->Hidden() && !wlanInfo->Known() )
       
   678             {
       
   679             hiddenFound = ETrue;
       
   680             }
       
   681         else
       
   682             {
       
   683             ++i;                
       
   684             }
       
   685         }
       
   686     
       
   687     LOG_WRITEF( "VisibleWlans: %d", aArray.Count() );
       
   688     return i;
       
   689     }      
       
   690 
       
   691 // END OF FILE
       
   692