phonebookui/Phonebook/View/src/CPbkFieldAnalyzer.cpp
changeset 0 e686773b3f54
child 3 04ab22b956c2
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 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 *       Provides methods for analyzing if the contact field has 
       
    16 *       speed dial and voice tag.
       
    17 *
       
    18 */
       
    19 
       
    20 #include "cpbkfieldanalyzer.h"
       
    21 #include <cpbkcontactengine.h>
       
    22 #include <cpbkcontactitem.h>
       
    23 #include <featmgr.h>
       
    24 
       
    25 
       
    26 // ================= MEMBER FUNCTIONS =======================
       
    27 CPbkFieldAnalyzer::CPbkFieldAnalyzer(  const CPbkFieldArray& aArray  ) :
       
    28     iFieldArray( aArray )
       
    29     {
       
    30 
       
    31     }
       
    32 
       
    33 CPbkFieldAnalyzer::~CPbkFieldAnalyzer()
       
    34     {
       
    35     // Do nothing.
       
    36     }
       
    37 
       
    38 
       
    39 CPbkFieldAnalyzer* CPbkFieldAnalyzer::NewL(
       
    40     const CPbkFieldArray& aArray  )
       
    41     {
       
    42     CPbkFieldAnalyzer* self = 
       
    43         new(ELeave) CPbkFieldAnalyzer( aArray );
       
    44     
       
    45     return self;
       
    46     }
       
    47 
       
    48 TBool CPbkFieldAnalyzer::HasSpeedDialL( const TPbkContactItemField& aField ) const
       
    49     {
       
    50     TBool result = EFalse;
       
    51     
       
    52     if ( IsFieldOwned(aField) )
       
    53         {
       
    54         const CContentType& contentType =  aField.ItemField().ContentType();
       
    55         const TInt fieldtypeCount = contentType.FieldTypeCount();
       
    56         for (TInt i = 0; i < fieldtypeCount; ++i)
       
    57             {
       
    58             TFieldType fieldType = contentType.FieldType(i);
       
    59             switch (fieldType.iUid)
       
    60                 {
       
    61                 case KUidSpeedDialOneValue:			// FALLTHROUGH
       
    62                 case KUidSpeedDialTwoValue:			// FALLTHROUGH
       
    63                 case KUidSpeedDialThreeValue:		// FALLTHROUGH
       
    64                 case KUidSpeedDialFourValue:		// FALLTHROUGH
       
    65                 case KUidSpeedDialFiveValue:		// FALLTHROUGH
       
    66                 case KUidSpeedDialSixValue:			// FALLTHROUGH
       
    67                 case KUidSpeedDialSevenValue:		// FALLTHROUGH
       
    68                 case KUidSpeedDialEightValue:		// FALLTHROUGH
       
    69                 case KUidSpeedDialNineValue:
       
    70                     {
       
    71                     result = ETrue;
       
    72                     break;
       
    73                     }
       
    74                 }
       
    75             }
       
    76         }
       
    77     
       
    78     return result;
       
    79     }
       
    80 
       
    81 TBool CPbkFieldAnalyzer::HasVoiceTagL( const TPbkContactItemField& aField ) const
       
    82     {
       
    83     TPbkContactItemField* voiceTagField = NULL;
       
    84     
       
    85     // Deprecated function
       
    86     if ( !FeatureManager::FeatureSupported( KFeatureIdSind ) )
       
    87         {
       
    88         // scan the fields for a match in voice tag field for field id.
       
    89         const TInt fieldCount = iFieldArray.Count();
       
    90         for (TInt i = 0; i < fieldCount; ++i)
       
    91             {
       
    92             const TPbkContactItemField& field = iFieldArray[i];
       
    93             if (field.ItemField().ContentType().ContainsFieldType(
       
    94                     KUidContactsVoiceDialField))
       
    95                 {
       
    96                 voiceTagField = const_cast<TPbkContactItemField*>(&field);
       
    97                 break;
       
    98                 }
       
    99             }
       
   100         }
       
   101     
       
   102     if ( voiceTagField )
       
   103         {
       
   104         return ( !voiceTagField->IsEmptyOrAllSpaces() && voiceTagField->IsSame( aField ) );
       
   105         }
       
   106     else
       
   107         {
       
   108         return EFalse;
       
   109         }
       
   110     }
       
   111 
       
   112 TBool CPbkFieldAnalyzer::IsFieldOwned(  const TPbkContactItemField& aField  ) const
       
   113     {
       
   114     for ( TInt index = 0; index < iFieldArray.Count(); ++index )
       
   115         {
       
   116         if( iFieldArray[index].IsSame(aField) )
       
   117             {
       
   118             return ETrue;
       
   119             }
       
   120         }
       
   121     return EFalse;
       
   122     }
       
   123 
       
   124 // end of file.
       
   125