phonebookengines/VirtualPhonebook/VPbkSimStore/src/CSupportedFieldTypes.cpp
branchRCL_3
changeset 85 38bb213f60ba
parent 63 f4a778e096c2
equal deleted inserted replaced
74:6b5524b4f673 85:38bb213f60ba
    42 // Symbian 2nd phase constructor can leave.
    42 // Symbian 2nd phase constructor can leave.
    43 // -----------------------------------------------------------------------------
    43 // -----------------------------------------------------------------------------
    44 //
    44 //
    45 void CSupportedFieldTypes::ConstructL( 
    45 void CSupportedFieldTypes::ConstructL( 
    46     const CFieldTypeMappings& aFieldTypeMappings,
    46     const CFieldTypeMappings& aFieldTypeMappings,
    47     TVPbkGsmStoreProperty& aSimStoreProperty,
    47     TVPbkGsmStoreProperty& aSimStoreProperty )
    48     TVPbkUSimStoreProperty* aUSimStoreProperty )
       
    49     {
    48     {
    50     // SIM supports always the name field
    49     // SIM supports always the name field
    51     const MVPbkFieldType* vpbkType = aFieldTypeMappings.Match( EVPbkSimName );
    50     const MVPbkFieldType* vpbkType = aFieldTypeMappings.Match( EVPbkSimName );
    52     iSupportedTypes.AppendL( vpbkType );
    51     iSupportedTypes.AppendL( vpbkType );
    53     // SIM supports always one number field
    52     // SIM supports always one number field
    54     vpbkType = aFieldTypeMappings.Match( EVPbkSimGsmNumber );
    53     vpbkType = aFieldTypeMappings.Match( EVPbkSimGsmNumber );
    55     const MVPbkFieldType* vpbkGsmType = vpbkType;
       
    56     iSupportedTypes.AppendL( vpbkType );
    54     iSupportedTypes.AppendL( vpbkType );
    57     // USIM can support additional numbers
    55     // USIM can support additional numbers
    58     if ( aSimStoreProperty.iCaps & VPbkSimStoreImpl::KAdditionalNumUsed )
    56     if ( aSimStoreProperty.iCaps & VPbkSimStoreImpl::KAdditionalNumUsed )
    59         {
    57         {
    60         if( aUSimStoreProperty )
    58         vpbkType = aFieldTypeMappings.Match( EVPbkSimAdditionalNumber );
    61             {
    59         // Check if the VPbk type is different than the type for
    62             for( TInt i = 1; i <= aUSimStoreProperty->iMaxNumOfAnrs; i ++ )
    60         // already added EVPbkSimGsmNumber
    63                 {
    61         if ( iSupportedTypes.Find( vpbkType ) == KErrNotFound )
    64                 TVPbkSimCntFieldType type;
    62             {
    65                 switch( i )
    63             iSupportedTypes.AppendL( vpbkType );
    66                     {
       
    67                     case 1:  // first additional number field type 
       
    68                         type = EVPbkSimAdditionalNumber1;
       
    69                         break;
       
    70                     case 2: // second additional number field type
       
    71                         type = EVPbkSimAdditionalNumber2;
       
    72                         break;
       
    73                     case 3: // third additional number field type
       
    74                         type = EVPbkSimAdditionalNumber3;
       
    75                         break;
       
    76                     default: // four and so on 
       
    77                         type = EVPbkSimAdditionalNumberLast;
       
    78                         break;
       
    79                     }
       
    80                 vpbkType = aFieldTypeMappings.Match( type );
       
    81                 if( !( vpbkGsmType->IsSame( *vpbkType ) ) )   // if not the same as GSM type.
       
    82                     {
       
    83                     iSupportedTypes.AppendL( vpbkType );
       
    84                     }
       
    85                 }
       
    86             }
       
    87         else
       
    88             {
       
    89             vpbkType = aFieldTypeMappings.Match( EVPbkSimAdditionalNumber );
       
    90             // Check if the VPbk type is different than the type for
       
    91             // already added EVPbkSimGsmNumber
       
    92             if ( iSupportedTypes.Find( vpbkType ) == KErrNotFound )
       
    93                 {
       
    94                 iSupportedTypes.AppendL( vpbkType );
       
    95                 }
       
    96             }
    64             }
    97         }
    65         }
    98     if ( aSimStoreProperty.iCaps & VPbkSimStoreImpl::KSecondNameUsed )
    66     if ( aSimStoreProperty.iCaps & VPbkSimStoreImpl::KSecondNameUsed )
    99         {
    67         {
   100 		// Second name field of the USIM is used for nick name in 
    68 		// Second name field of the USIM is used for nick name in 
   123     self->ConstructL( aFieldTypeMappings, aSimStoreProperty );
    91     self->ConstructL( aFieldTypeMappings, aSimStoreProperty );
   124     CleanupStack::Pop( self );
    92     CleanupStack::Pop( self );
   125     return self;
    93     return self;
   126     }
    94     }
   127 
    95 
   128 // -----------------------------------------------------------------------------
       
   129 // CSupportedFieldTypes::NewL
       
   130 // Two-phased constructor.
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 CSupportedFieldTypes* CSupportedFieldTypes::NewL(
       
   134     const CFieldTypeMappings& aFieldTypeMappings,
       
   135     TVPbkGsmStoreProperty& aSimStoreProperty,
       
   136     TVPbkUSimStoreProperty& aUSimStoreProperty )  
       
   137     {
       
   138     CSupportedFieldTypes* self = new( ELeave ) CSupportedFieldTypes;
       
   139     CleanupStack::PushL( self );
       
   140     self->ConstructL( aFieldTypeMappings, aSimStoreProperty, &aUSimStoreProperty );  
       
   141     CleanupStack::Pop( self );
       
   142     return self;
       
   143     }
       
   144 
       
   145 // Destructor
    96 // Destructor
   146 CSupportedFieldTypes::~CSupportedFieldTypes()
    97 CSupportedFieldTypes::~CSupportedFieldTypes()
   147     {    
    98     {    
   148     iSupportedTypes.Close();
    99     iSupportedTypes.Close();
   149     }
   100     }