wlansecuritysettings/wlaneapsettingsui/EapPluginConfig/src/EAPPlugInConfigurationModel.cpp
branchRCL_3
changeset 46 c74b3d9f6b9e
equal deleted inserted replaced
45:bad0cc58d154 46:c74b3d9f6b9e
       
     1 /*
       
     2 * Copyright (c) 2001-2009 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 the License "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 class CEAPPlugInConfigurationModel
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 14 %
       
    20 */
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include "EAPPluginConfigurationModel.h"
       
    24 #include "EAPPluginList.h"
       
    25 #include <ecom/ecom.h>
       
    26 
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 // Format text for MdcaPoint when Enabled
       
    31 _LIT( KFormatEnabled, "%d\t%S\t%d\t" );
       
    32 
       
    33 // Format text for MdcaPoint when Disabled
       
    34 _LIT( KFormatDisabled, "\t%S\t\t" );
       
    35 
       
    36 
       
    37 /**
       
    38 * Maximum length of the formatted text excluding the name.
       
    39 * (I.e. if the name is trimmed to this length, there will not be overflow.)
       
    40 * Includes the formatting tabs (3), the icon index length (1) plus maximum
       
    41 * length of an integer (11).
       
    42 */
       
    43 LOCAL_D const TInt KMaxLenForEmptyName = 15;
       
    44 
       
    45 
       
    46 // ============================ MEMBER FUNCTIONS ===============================
       
    47 
       
    48 // ---------------------------------------------------------
       
    49 // CEAPPluginConfigurationModel::MdcaCount
       
    50 // ---------------------------------------------------------
       
    51 //
       
    52 TInt CEAPPluginConfigurationModel::MdcaCount() const
       
    53     {
       
    54     return iPlugins.Count();
       
    55     }
       
    56 
       
    57 
       
    58 // ---------------------------------------------------------
       
    59 // CEAPPluginConfigurationModel::MdcaPoint
       
    60 // ---------------------------------------------------------
       
    61 //
       
    62 TPtrC16 CEAPPluginConfigurationModel::MdcaPoint( TInt aIndex ) const
       
    63     {
       
    64     // Oddly enough, MdcaPoint is const. We need to use MUTABLE_CAST.
       
    65     TInt maxName = EBufSize - KMaxLenForEmptyName;
       
    66     TPtrC name( iPlugins[aIndex].iInfo->DisplayName() );
       
    67     if ( name.Length() > maxName )
       
    68         {
       
    69         name.Set( name.Left( maxName ) );
       
    70         }
       
    71 
       
    72     if ( iPlugins[aIndex].iEnabled )
       
    73         {
       
    74         MUTABLE_CAST( TBuf<EBufSize>&, iBuf ).Format( KFormatEnabled, 
       
    75                                                       aIndex+1, &name, 0 );
       
    76         }
       
    77     else
       
    78         {
       
    79         MUTABLE_CAST( TBuf<EBufSize>&, iBuf ).Format( KFormatDisabled, &name );
       
    80         }
       
    81 
       
    82     return iBuf;
       
    83     }
       
    84 
       
    85 
       
    86 // ---------------------------------------------------------
       
    87 // CEAPPluginConfigurationModel::MdcaEnabledCount
       
    88 // ---------------------------------------------------------
       
    89 //
       
    90 TInt CEAPPluginConfigurationModel::MdcaEnabledCount() const
       
    91     {
       
    92     TInt index;
       
    93     TInt nPlugins = MdcaCount();
       
    94     TInt numEnabled = 0;
       
    95 
       
    96     for ( index = 0; index < nPlugins; index++ )
       
    97         {
       
    98         if ( iPlugins[index].iEnabled )
       
    99             {
       
   100             numEnabled++;
       
   101             }
       
   102         }
       
   103 
       
   104     return numEnabled;
       
   105     }
       
   106 
       
   107 
       
   108 //  End of File