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